@proconnect-gouv/proconnect.identite 10.4.0 → 11.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/connectors/index.d.ts +225 -9
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/index.js +8 -2
- package/dist/repositories/oidc-client/index.d.ts +1 -1
- package/dist/repositories/oidc-client/index.d.ts.map +1 -1
- package/dist/repositories/oidc-client/index.js +1 -1
- package/dist/repositories/oidc-client/upsert-authorization-request.d.ts +3 -0
- package/dist/repositories/oidc-client/upsert-authorization-request.d.ts.map +1 -0
- package/dist/repositories/oidc-client/upsert-authorization-request.js +30 -0
- package/dist/repositories/organization/find-users-by-organization.d.ts +28 -2
- package/dist/repositories/organization/find-users-by-organization.d.ts.map +1 -1
- package/dist/repositories/recovery-words/create.d.ts +6 -0
- package/dist/repositories/recovery-words/create.d.ts.map +1 -0
- package/dist/repositories/recovery-words/create.js +14 -0
- package/dist/repositories/recovery-words/delete-all-by-user-id.d.ts +3 -0
- package/dist/repositories/recovery-words/delete-all-by-user-id.d.ts.map +1 -0
- package/dist/repositories/recovery-words/delete-all-by-user-id.js +11 -0
- package/dist/repositories/recovery-words/find-by-user-id.d.ts +3 -0
- package/dist/repositories/recovery-words/find-by-user-id.d.ts.map +1 -0
- package/dist/repositories/recovery-words/find-by-user-id.js +12 -0
- package/dist/repositories/recovery-words/index.d.ts +4 -0
- package/dist/repositories/recovery-words/index.d.ts.map +1 -0
- package/dist/repositories/recovery-words/index.js +4 -0
- package/dist/repositories/user/create.d.ts +28 -2
- package/dist/repositories/user/create.d.ts.map +1 -1
- package/dist/repositories/user/find-by-email.d.ts +28 -2
- package/dist/repositories/user/find-by-email.d.ts.map +1 -1
- package/dist/repositories/user/find-by-id.d.ts +28 -2
- package/dist/repositories/user/find-by-id.d.ts.map +1 -1
- package/dist/repositories/user/find-by-magic-link-token.d.ts +28 -2
- package/dist/repositories/user/find-by-magic-link-token.d.ts.map +1 -1
- package/dist/repositories/user/find-by-reset-password-token.d.ts +28 -2
- package/dist/repositories/user/find-by-reset-password-token.d.ts.map +1 -1
- package/dist/repositories/user/get-by-id.d.ts +27 -1
- package/dist/repositories/user/get-by-id.d.ts.map +1 -1
- package/dist/repositories/user/update.d.ts +27 -1
- package/dist/repositories/user/update.d.ts.map +1 -1
- package/dist/types/authorization-request.d.ts +20 -0
- package/dist/types/authorization-request.d.ts.map +1 -0
- package/dist/types/authorization-request.js +2 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -1
- package/dist/types/recovery-words.d.ts +9 -0
- package/dist/types/recovery-words.d.ts.map +1 -0
- package/dist/types/{connection.js → recovery-words.js} +0 -1
- package/dist/types/user.d.ts +29 -27
- package/dist/types/user.d.ts.map +1 -1
- package/dist/types/user.js +29 -1
- package/package.json +3 -3
- package/src/connectors/index.ts +12 -2
- package/src/repositories/oidc-client/index.ts +1 -1
- package/src/repositories/oidc-client/upsert-authorization-request.test.ts +95 -0
- package/src/repositories/oidc-client/upsert-authorization-request.ts +50 -0
- package/src/repositories/recovery-words/create.ts +28 -0
- package/src/repositories/recovery-words/delete-all-by-user-id.ts +20 -0
- package/src/repositories/recovery-words/find-by-user-id.ts +20 -0
- package/src/repositories/recovery-words/index.ts +5 -0
- package/src/types/authorization-request.ts +23 -0
- package/src/types/index.ts +2 -1
- package/src/types/recovery-words.ts +9 -0
- package/src/types/user.ts +33 -27
- package/testing/index.ts +2 -0
- package/dist/repositories/oidc-client/add-connection.d.ts +0 -3
- package/dist/repositories/oidc-client/add-connection.d.ts.map +0 -1
- package/dist/repositories/oidc-client/add-connection.js +0 -22
- package/dist/types/connection.d.ts +0 -13
- package/dist/types/connection.d.ts.map +0 -1
- package/src/repositories/oidc-client/add-connection.test.ts +0 -43
- package/src/repositories/oidc-client/add-connection.ts +0 -36
- package/src/types/connection.ts +0 -15
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const AuthorizationRequestOutcomeEnum = z.enum(["succeeded"]);
|
|
4
|
+
|
|
5
|
+
export type AuthorizationRequestOutcome = z.output<
|
|
6
|
+
typeof AuthorizationRequestOutcomeEnum
|
|
7
|
+
>;
|
|
8
|
+
|
|
9
|
+
export interface BaseAuthorizationRequest {
|
|
10
|
+
user_id: number;
|
|
11
|
+
oidc_client_id: number;
|
|
12
|
+
organization_id: number | null;
|
|
13
|
+
sp_name: string | null;
|
|
14
|
+
user_ip_address: string | null;
|
|
15
|
+
interaction_cid: string | null;
|
|
16
|
+
outcome: AuthorizationRequestOutcome | null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface AuthorizationRequest extends BaseAuthorizationRequest {
|
|
20
|
+
id: number;
|
|
21
|
+
created_at: Date;
|
|
22
|
+
updated_at: Date;
|
|
23
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
3
|
export * from "./authenticator.js";
|
|
4
|
+
export * from "./authorization-request.js";
|
|
4
5
|
export * from "./claims.js";
|
|
5
|
-
export * from "./connection.js";
|
|
6
6
|
export * from "./contexts.js";
|
|
7
7
|
export * from "./email-domain.js";
|
|
8
8
|
export * from "./franceconnect.js";
|
|
@@ -12,5 +12,6 @@ export * from "./official-contact-email-verification.js";
|
|
|
12
12
|
export * from "./oidc-client.js";
|
|
13
13
|
export * from "./organization-info.js";
|
|
14
14
|
export * from "./organization.js";
|
|
15
|
+
export * from "./recovery-words.js";
|
|
15
16
|
export * from "./user-organization-link.js";
|
|
16
17
|
export * from "./user.js";
|
package/src/types/user.ts
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
export const UserSchema = z.object({
|
|
8
|
+
created_at: z.date(),
|
|
9
|
+
current_challenge: z.string().nullable(),
|
|
10
|
+
email: z.string(),
|
|
11
|
+
email_verified: z.boolean(),
|
|
12
|
+
email_verified_at: z.date().nullable(),
|
|
13
|
+
encrypted_password: z.string().nullable(),
|
|
14
|
+
encrypted_totp_key: z.string().nullable(),
|
|
15
|
+
family_name: z.string().nullable(),
|
|
16
|
+
force_2fa: z.boolean(),
|
|
17
|
+
given_name: z.string().nullable(),
|
|
18
|
+
id: z.number(),
|
|
19
|
+
job: z.string().nullable(),
|
|
20
|
+
last_sign_in_at: z.date().nullable(),
|
|
21
|
+
magic_link_sent_at: z.date().nullable(),
|
|
22
|
+
magic_link_token: z.string().nullable(),
|
|
23
|
+
needs_inclusionconnect_onboarding_help: z.boolean(),
|
|
24
|
+
needs_inclusionconnect_welcome_page: z.boolean(),
|
|
25
|
+
phone_number: z.string().nullable(),
|
|
26
|
+
reset_password_sent_at: z.date().nullable(),
|
|
27
|
+
reset_password_token: z.string().nullable(),
|
|
28
|
+
sign_in_count: z.number(),
|
|
29
|
+
totp_key_verified_at: z.date().nullable(),
|
|
30
|
+
updated_at: z.date(),
|
|
31
|
+
verify_email_sent_at: z.date().nullable(),
|
|
32
|
+
verify_email_token: z.string().nullable(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export type User = z.output<typeof UserSchema>;
|
package/testing/index.ts
CHANGED
|
@@ -39,6 +39,8 @@ export async function emptyDatabase() {
|
|
|
39
39
|
await pg.sql`ALTER SEQUENCE users_id_seq RESTART WITH 1`;
|
|
40
40
|
await pg.sql`delete from email_domains;`;
|
|
41
41
|
await pg.sql`ALTER SEQUENCE email_domains_id_seq RESTART WITH 1`;
|
|
42
|
+
await pg.sql`delete from oidc_clients;`;
|
|
43
|
+
await pg.sql`ALTER SEQUENCE oidc_clients_id_seq RESTART WITH 1`;
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
//
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { BaseConnection, Connection, DatabaseContext } from "#src/types";
|
|
2
|
-
export declare function addConnectionFactory({ pg }: DatabaseContext): ({ user_id, oidc_client_id, organization_id, sp_name, user_ip_address, }: BaseConnection) => Promise<Connection>;
|
|
3
|
-
//# sourceMappingURL=add-connection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"add-connection.d.ts","sourceRoot":"","sources":["../../../src/repositories/oidc-client/add-connection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAK9E,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,yEAMjC,cAAc,yBAqBlB"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import {} from "pg";
|
|
3
|
-
//
|
|
4
|
-
export function addConnectionFactory({ pg }) {
|
|
5
|
-
return async function addConnection({ user_id, oidc_client_id, organization_id, sp_name, user_ip_address, }) {
|
|
6
|
-
const { rows } = await pg.query(`
|
|
7
|
-
INSERT INTO users_oidc_clients
|
|
8
|
-
(user_id, oidc_client_id, organization_id, sp_name, user_ip_address, created_at, updated_at)
|
|
9
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
10
|
-
RETURNING user_id, oidc_client_id, organization_id, sp_name, user_ip_address, created_at, updated_at, id;
|
|
11
|
-
`, [
|
|
12
|
-
user_id,
|
|
13
|
-
oidc_client_id,
|
|
14
|
-
organization_id,
|
|
15
|
-
sp_name,
|
|
16
|
-
user_ip_address,
|
|
17
|
-
new Date(),
|
|
18
|
-
new Date(),
|
|
19
|
-
]);
|
|
20
|
-
return rows.shift();
|
|
21
|
-
};
|
|
22
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface BaseConnection {
|
|
2
|
-
user_id: number;
|
|
3
|
-
oidc_client_id: number;
|
|
4
|
-
organization_id: number | null;
|
|
5
|
-
sp_name: string | null;
|
|
6
|
-
user_ip_address: string | null;
|
|
7
|
-
}
|
|
8
|
-
export interface Connection extends BaseConnection {
|
|
9
|
-
id: number;
|
|
10
|
-
created_at: Date;
|
|
11
|
-
updated_at: Date;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../src/types/connection.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;CAClB"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { emptyDatabase, migrate, pg } from "#testing";
|
|
4
|
-
import assert from "node:assert/strict";
|
|
5
|
-
import { before, beforeEach, suite, test } from "node:test";
|
|
6
|
-
import { addConnectionFactory } from "./add-connection.js";
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
const addConnection = addConnectionFactory({ pg: pg as any });
|
|
11
|
-
|
|
12
|
-
suite("addConnectionFactory", () => {
|
|
13
|
-
before(migrate);
|
|
14
|
-
beforeEach(emptyDatabase);
|
|
15
|
-
|
|
16
|
-
test("should insert and return the connection", async () => {
|
|
17
|
-
await pg.sql`
|
|
18
|
-
INSERT INTO users
|
|
19
|
-
(id, email, created_at, updated_at, given_name, family_name, phone_number, job)
|
|
20
|
-
VALUES
|
|
21
|
-
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque')
|
|
22
|
-
;
|
|
23
|
-
`;
|
|
24
|
-
await pg.sql`
|
|
25
|
-
INSERT INTO oidc_clients
|
|
26
|
-
(id, client_id, client_name, client_secret, created_at, updated_at)
|
|
27
|
-
VALUES
|
|
28
|
-
(1, '⚔️', 'Dark Angels', 'secret', '4444-04-04', '4444-04-04')
|
|
29
|
-
;
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
|
-
const connection = await addConnection({
|
|
33
|
-
user_id: 1,
|
|
34
|
-
oidc_client_id: 1,
|
|
35
|
-
organization_id: null,
|
|
36
|
-
sp_name: "proconnect",
|
|
37
|
-
user_ip_address: "127.0.0.1",
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
assert.equal(connection.user_id, 1);
|
|
41
|
-
assert.equal(connection.oidc_client_id, 1);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import type { BaseConnection, Connection, DatabaseContext } from "#src/types";
|
|
4
|
-
import { type QueryResult } from "pg";
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
export function addConnectionFactory({ pg }: DatabaseContext) {
|
|
9
|
-
return async function addConnection({
|
|
10
|
-
user_id,
|
|
11
|
-
oidc_client_id,
|
|
12
|
-
organization_id,
|
|
13
|
-
sp_name,
|
|
14
|
-
user_ip_address,
|
|
15
|
-
}: BaseConnection) {
|
|
16
|
-
const { rows }: QueryResult<Connection> = await pg.query(
|
|
17
|
-
`
|
|
18
|
-
INSERT INTO users_oidc_clients
|
|
19
|
-
(user_id, oidc_client_id, organization_id, sp_name, user_ip_address, created_at, updated_at)
|
|
20
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
21
|
-
RETURNING user_id, oidc_client_id, organization_id, sp_name, user_ip_address, created_at, updated_at, id;
|
|
22
|
-
`,
|
|
23
|
-
[
|
|
24
|
-
user_id,
|
|
25
|
-
oidc_client_id,
|
|
26
|
-
organization_id,
|
|
27
|
-
sp_name,
|
|
28
|
-
user_ip_address,
|
|
29
|
-
new Date(),
|
|
30
|
-
new Date(),
|
|
31
|
-
],
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
return rows.shift()!;
|
|
35
|
-
};
|
|
36
|
-
}
|
package/src/types/connection.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
export interface BaseConnection {
|
|
4
|
-
user_id: number;
|
|
5
|
-
oidc_client_id: number;
|
|
6
|
-
organization_id: number | null;
|
|
7
|
-
sp_name: string | null;
|
|
8
|
-
user_ip_address: string | null;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface Connection extends BaseConnection {
|
|
12
|
-
id: number;
|
|
13
|
-
created_at: Date;
|
|
14
|
-
updated_at: Date;
|
|
15
|
-
}
|