@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-by-id.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/find-by-id.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"find-by-id.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/find-by-id.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAQ,MAAM,YAAY,CAAC;AAKxD,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,IAAI,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;eAY1C;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
import type { DatabaseContext
|
|
2
|
-
export declare function findByMagicLinkTokenFactory({ pg }: DatabaseContext): (magic_link_token: string) => Promise<
|
|
1
|
+
import type { DatabaseContext } from "#src/types";
|
|
2
|
+
export declare function findByMagicLinkTokenFactory({ pg }: DatabaseContext): (magic_link_token: string) => Promise<{
|
|
3
|
+
created_at: Date;
|
|
4
|
+
current_challenge: string | null;
|
|
5
|
+
email: string;
|
|
6
|
+
email_verified: boolean;
|
|
7
|
+
email_verified_at: Date | null;
|
|
8
|
+
encrypted_password: string | null;
|
|
9
|
+
encrypted_totp_key: string | null;
|
|
10
|
+
family_name: string | null;
|
|
11
|
+
force_2fa: boolean;
|
|
12
|
+
given_name: string | null;
|
|
13
|
+
id: number;
|
|
14
|
+
job: string | null;
|
|
15
|
+
last_sign_in_at: Date | null;
|
|
16
|
+
magic_link_sent_at: Date | null;
|
|
17
|
+
magic_link_token: string | null;
|
|
18
|
+
needs_inclusionconnect_onboarding_help: boolean;
|
|
19
|
+
needs_inclusionconnect_welcome_page: boolean;
|
|
20
|
+
phone_number: string | null;
|
|
21
|
+
reset_password_sent_at: Date | null;
|
|
22
|
+
reset_password_token: string | null;
|
|
23
|
+
sign_in_count: number;
|
|
24
|
+
totp_key_verified_at: Date | null;
|
|
25
|
+
updated_at: Date;
|
|
26
|
+
verify_email_sent_at: Date | null;
|
|
27
|
+
verify_email_token: string | null;
|
|
28
|
+
} | undefined>;
|
|
3
29
|
//# sourceMappingURL=find-by-magic-link-token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-by-magic-link-token.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/find-by-magic-link-token.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"find-by-magic-link-token.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/find-by-magic-link-token.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAQ,MAAM,YAAY,CAAC;AAKxD,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,kBAAkB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;eAWpE"}
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
import type { DatabaseContext
|
|
2
|
-
export declare function findByResetPasswordTokenFactory({ pg }: DatabaseContext): (reset_password_token: string) => Promise<
|
|
1
|
+
import type { DatabaseContext } from "#src/types";
|
|
2
|
+
export declare function findByResetPasswordTokenFactory({ pg }: DatabaseContext): (reset_password_token: string) => Promise<{
|
|
3
|
+
created_at: Date;
|
|
4
|
+
current_challenge: string | null;
|
|
5
|
+
email: string;
|
|
6
|
+
email_verified: boolean;
|
|
7
|
+
email_verified_at: Date | null;
|
|
8
|
+
encrypted_password: string | null;
|
|
9
|
+
encrypted_totp_key: string | null;
|
|
10
|
+
family_name: string | null;
|
|
11
|
+
force_2fa: boolean;
|
|
12
|
+
given_name: string | null;
|
|
13
|
+
id: number;
|
|
14
|
+
job: string | null;
|
|
15
|
+
last_sign_in_at: Date | null;
|
|
16
|
+
magic_link_sent_at: Date | null;
|
|
17
|
+
magic_link_token: string | null;
|
|
18
|
+
needs_inclusionconnect_onboarding_help: boolean;
|
|
19
|
+
needs_inclusionconnect_welcome_page: boolean;
|
|
20
|
+
phone_number: string | null;
|
|
21
|
+
reset_password_sent_at: Date | null;
|
|
22
|
+
reset_password_token: string | null;
|
|
23
|
+
sign_in_count: number;
|
|
24
|
+
totp_key_verified_at: Date | null;
|
|
25
|
+
updated_at: Date;
|
|
26
|
+
verify_email_sent_at: Date | null;
|
|
27
|
+
verify_email_token: string | null;
|
|
28
|
+
} | undefined>;
|
|
3
29
|
//# sourceMappingURL=find-by-reset-password-token.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-by-reset-password-token.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/find-by-reset-password-token.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"find-by-reset-password-token.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/find-by-reset-password-token.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAQ,MAAM,YAAY,CAAC;AAKxD,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,sBAAsB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;eAW5E"}
|
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
import type { DatabaseContext } from "#src/types";
|
|
2
|
-
export declare function getByIdFactory({ pg }: DatabaseContext): (id: number) => Promise<
|
|
2
|
+
export declare function getByIdFactory({ pg }: DatabaseContext): (id: number) => Promise<{
|
|
3
|
+
created_at: Date;
|
|
4
|
+
current_challenge: string | null;
|
|
5
|
+
email: string;
|
|
6
|
+
email_verified: boolean;
|
|
7
|
+
email_verified_at: Date | null;
|
|
8
|
+
encrypted_password: string | null;
|
|
9
|
+
encrypted_totp_key: string | null;
|
|
10
|
+
family_name: string | null;
|
|
11
|
+
force_2fa: boolean;
|
|
12
|
+
given_name: string | null;
|
|
13
|
+
id: number;
|
|
14
|
+
job: string | null;
|
|
15
|
+
last_sign_in_at: Date | null;
|
|
16
|
+
magic_link_sent_at: Date | null;
|
|
17
|
+
magic_link_token: string | null;
|
|
18
|
+
needs_inclusionconnect_onboarding_help: boolean;
|
|
19
|
+
needs_inclusionconnect_welcome_page: boolean;
|
|
20
|
+
phone_number: string | null;
|
|
21
|
+
reset_password_sent_at: Date | null;
|
|
22
|
+
reset_password_token: string | null;
|
|
23
|
+
sign_in_count: number;
|
|
24
|
+
totp_key_verified_at: Date | null;
|
|
25
|
+
updated_at: Date;
|
|
26
|
+
verify_email_sent_at: Date | null;
|
|
27
|
+
verify_email_token: string | null;
|
|
28
|
+
}>;
|
|
3
29
|
export type GetByIdHandler = ReturnType<typeof getByIdFactory>;
|
|
4
30
|
//# sourceMappingURL=get-by-id.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-by-id.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/get-by-id.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMlD,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAEtB,IAAI,MAAM
|
|
1
|
+
{"version":3,"file":"get-by-id.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/get-by-id.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAMlD,wBAAgB,cAAc,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAEtB,IAAI,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;GAOzC;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
|
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
import type { DatabaseContext, User } from "#src/types";
|
|
2
|
-
export declare function updateUserFactory({ pg }: DatabaseContext): (id: number, fieldsToUpdate: Partial<User>) => Promise<
|
|
2
|
+
export declare function updateUserFactory({ pg }: DatabaseContext): (id: number, fieldsToUpdate: Partial<User>) => Promise<{
|
|
3
|
+
created_at: Date;
|
|
4
|
+
current_challenge: string | null;
|
|
5
|
+
email: string;
|
|
6
|
+
email_verified: boolean;
|
|
7
|
+
email_verified_at: Date | null;
|
|
8
|
+
encrypted_password: string | null;
|
|
9
|
+
encrypted_totp_key: string | null;
|
|
10
|
+
family_name: string | null;
|
|
11
|
+
force_2fa: boolean;
|
|
12
|
+
given_name: string | null;
|
|
13
|
+
id: number;
|
|
14
|
+
job: string | null;
|
|
15
|
+
last_sign_in_at: Date | null;
|
|
16
|
+
magic_link_sent_at: Date | null;
|
|
17
|
+
magic_link_token: string | null;
|
|
18
|
+
needs_inclusionconnect_onboarding_help: boolean;
|
|
19
|
+
needs_inclusionconnect_welcome_page: boolean;
|
|
20
|
+
phone_number: string | null;
|
|
21
|
+
reset_password_sent_at: Date | null;
|
|
22
|
+
reset_password_token: string | null;
|
|
23
|
+
sign_in_count: number;
|
|
24
|
+
totp_key_verified_at: Date | null;
|
|
25
|
+
updated_at: Date;
|
|
26
|
+
verify_email_sent_at: Date | null;
|
|
27
|
+
verify_email_token: string | null;
|
|
28
|
+
}>;
|
|
3
29
|
export type UpdateUserHandler = ReturnType<typeof updateUserFactory>;
|
|
4
30
|
//# sourceMappingURL=update.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/update.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAKxD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,IAAI,MAAM,EAAE,gBAAgB,OAAO,CAAC,IAAI,CAAC
|
|
1
|
+
{"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/update.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAKxD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,IAAI,MAAM,EAAE,gBAAgB,OAAO,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;GAsB3E;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const AuthorizationRequestOutcomeEnum: z.ZodEnum<{
|
|
3
|
+
succeeded: "succeeded";
|
|
4
|
+
}>;
|
|
5
|
+
export type AuthorizationRequestOutcome = z.output<typeof AuthorizationRequestOutcomeEnum>;
|
|
6
|
+
export interface BaseAuthorizationRequest {
|
|
7
|
+
user_id: number;
|
|
8
|
+
oidc_client_id: number;
|
|
9
|
+
organization_id: number | null;
|
|
10
|
+
sp_name: string | null;
|
|
11
|
+
user_ip_address: string | null;
|
|
12
|
+
interaction_cid: string | null;
|
|
13
|
+
outcome: AuthorizationRequestOutcome | null;
|
|
14
|
+
}
|
|
15
|
+
export interface AuthorizationRequest extends BaseAuthorizationRequest {
|
|
16
|
+
id: number;
|
|
17
|
+
created_at: Date;
|
|
18
|
+
updated_at: Date;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=authorization-request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorization-request.d.ts","sourceRoot":"","sources":["../../src/types/authorization-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,+BAA+B;;EAAwB,CAAC;AAErE,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAChD,OAAO,+BAA+B,CACvC,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,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;IAC/B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAAC;CAC7C;AAED,MAAM,WAAW,oBAAqB,SAAQ,wBAAwB;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;CAClB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./authenticator.js";
|
|
2
|
+
export * from "./authorization-request.js";
|
|
2
3
|
export * from "./claims.js";
|
|
3
|
-
export * from "./connection.js";
|
|
4
4
|
export * from "./contexts.js";
|
|
5
5
|
export * from "./email-domain.js";
|
|
6
6
|
export * from "./franceconnect.js";
|
|
@@ -10,6 +10,7 @@ export * from "./official-contact-email-verification.js";
|
|
|
10
10
|
export * from "./oidc-client.js";
|
|
11
11
|
export * from "./organization-info.js";
|
|
12
12
|
export * from "./organization.js";
|
|
13
|
+
export * from "./recovery-words.js";
|
|
13
14
|
export * from "./user-organization-link.js";
|
|
14
15
|
export * from "./user.js";
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AACnC,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0CAA0C,CAAC;AACzD,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,WAAW,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//
|
|
2
2
|
export * from "./authenticator.js";
|
|
3
|
+
export * from "./authorization-request.js";
|
|
3
4
|
export * from "./claims.js";
|
|
4
|
-
export * from "./connection.js";
|
|
5
5
|
export * from "./contexts.js";
|
|
6
6
|
export * from "./email-domain.js";
|
|
7
7
|
export * from "./franceconnect.js";
|
|
@@ -11,5 +11,6 @@ export * from "./official-contact-email-verification.js";
|
|
|
11
11
|
export * from "./oidc-client.js";
|
|
12
12
|
export * from "./organization-info.js";
|
|
13
13
|
export * from "./organization.js";
|
|
14
|
+
export * from "./recovery-words.js";
|
|
14
15
|
export * from "./user-organization-link.js";
|
|
15
16
|
export * from "./user.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recovery-words.d.ts","sourceRoot":"","sources":["../../src/types/recovery-words.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,IAAI,CAAC;CAClB"}
|
package/dist/types/user.d.ts
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const UserSchema: z.ZodObject<{
|
|
3
|
+
created_at: z.ZodDate;
|
|
4
|
+
current_challenge: z.ZodNullable<z.ZodString>;
|
|
5
|
+
email: z.ZodString;
|
|
6
|
+
email_verified: z.ZodBoolean;
|
|
7
|
+
email_verified_at: z.ZodNullable<z.ZodDate>;
|
|
8
|
+
encrypted_password: z.ZodNullable<z.ZodString>;
|
|
9
|
+
encrypted_totp_key: z.ZodNullable<z.ZodString>;
|
|
10
|
+
family_name: z.ZodNullable<z.ZodString>;
|
|
11
|
+
force_2fa: z.ZodBoolean;
|
|
12
|
+
given_name: z.ZodNullable<z.ZodString>;
|
|
13
|
+
id: z.ZodNumber;
|
|
14
|
+
job: z.ZodNullable<z.ZodString>;
|
|
15
|
+
last_sign_in_at: z.ZodNullable<z.ZodDate>;
|
|
16
|
+
magic_link_sent_at: z.ZodNullable<z.ZodDate>;
|
|
17
|
+
magic_link_token: z.ZodNullable<z.ZodString>;
|
|
18
|
+
needs_inclusionconnect_onboarding_help: z.ZodBoolean;
|
|
19
|
+
needs_inclusionconnect_welcome_page: z.ZodBoolean;
|
|
20
|
+
phone_number: z.ZodNullable<z.ZodString>;
|
|
21
|
+
reset_password_sent_at: z.ZodNullable<z.ZodDate>;
|
|
22
|
+
reset_password_token: z.ZodNullable<z.ZodString>;
|
|
23
|
+
sign_in_count: z.ZodNumber;
|
|
24
|
+
totp_key_verified_at: z.ZodNullable<z.ZodDate>;
|
|
25
|
+
updated_at: z.ZodDate;
|
|
26
|
+
verify_email_sent_at: z.ZodNullable<z.ZodDate>;
|
|
27
|
+
verify_email_token: z.ZodNullable<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type User = z.output<typeof UserSchema>;
|
|
28
30
|
//# sourceMappingURL=user.d.ts.map
|
package/dist/types/user.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/types/user.ts"],"names":[],"mappings":"AAEA,
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/types/user.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BrB,CAAC;AAEH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
package/dist/types/user.js
CHANGED
|
@@ -1,2 +1,30 @@
|
|
|
1
1
|
//
|
|
2
|
-
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//
|
|
4
|
+
export const UserSchema = z.object({
|
|
5
|
+
created_at: z.date(),
|
|
6
|
+
current_challenge: z.string().nullable(),
|
|
7
|
+
email: z.string(),
|
|
8
|
+
email_verified: z.boolean(),
|
|
9
|
+
email_verified_at: z.date().nullable(),
|
|
10
|
+
encrypted_password: z.string().nullable(),
|
|
11
|
+
encrypted_totp_key: z.string().nullable(),
|
|
12
|
+
family_name: z.string().nullable(),
|
|
13
|
+
force_2fa: z.boolean(),
|
|
14
|
+
given_name: z.string().nullable(),
|
|
15
|
+
id: z.number(),
|
|
16
|
+
job: z.string().nullable(),
|
|
17
|
+
last_sign_in_at: z.date().nullable(),
|
|
18
|
+
magic_link_sent_at: z.date().nullable(),
|
|
19
|
+
magic_link_token: z.string().nullable(),
|
|
20
|
+
needs_inclusionconnect_onboarding_help: z.boolean(),
|
|
21
|
+
needs_inclusionconnect_welcome_page: z.boolean(),
|
|
22
|
+
phone_number: z.string().nullable(),
|
|
23
|
+
reset_password_sent_at: z.date().nullable(),
|
|
24
|
+
reset_password_token: z.string().nullable(),
|
|
25
|
+
sign_in_count: z.number(),
|
|
26
|
+
totp_key_verified_at: z.date().nullable(),
|
|
27
|
+
updated_at: z.date(),
|
|
28
|
+
verify_email_sent_at: z.date().nullable(),
|
|
29
|
+
verify_email_token: z.string().nullable(),
|
|
30
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proconnect-gouv/proconnect.identite",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"homepage": "https://github.com/proconnect-gouv/proconnect-identite/tree/main/packages/identite#readme",
|
|
5
5
|
"bugs": "https://github.com/proconnect-gouv/proconnect-identite/issues",
|
|
6
6
|
"repository": {
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"leven": "^4.0.0",
|
|
47
|
-
"openid-client": "^6.
|
|
47
|
+
"openid-client": "^6.8.8",
|
|
48
48
|
"sql-template-tag": "^5.2.1",
|
|
49
49
|
"ts-pattern": "^5.7.0",
|
|
50
|
-
"zod": "^4.
|
|
50
|
+
"zod": "^4.6.7"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@electric-sql/pglite": "^0.3.12",
|
package/src/connectors/index.ts
CHANGED
|
@@ -33,8 +33,8 @@ import {
|
|
|
33
33
|
upsertOfficialContactEmailVerificationFactory,
|
|
34
34
|
} from "#src/repositories/official-contact-email-verification";
|
|
35
35
|
import {
|
|
36
|
-
addConnectionFactory,
|
|
37
36
|
findByClientIdFactory,
|
|
37
|
+
upsertAuthorizationRequestFactory,
|
|
38
38
|
} from "#src/repositories/oidc-client";
|
|
39
39
|
import {
|
|
40
40
|
findBySiretFactory,
|
|
@@ -46,6 +46,11 @@ import {
|
|
|
46
46
|
getOrganizationByIdFactory,
|
|
47
47
|
upsertFactory,
|
|
48
48
|
} from "#src/repositories/organization";
|
|
49
|
+
import {
|
|
50
|
+
createRecoveryWordsFactory,
|
|
51
|
+
deleteRecoveryWordsByUserIdFactory,
|
|
52
|
+
findRecoveryWordsByUserIdFactory,
|
|
53
|
+
} from "#src/repositories/recovery-words";
|
|
49
54
|
import {
|
|
50
55
|
createUserFactory,
|
|
51
56
|
deleteUserFactory,
|
|
@@ -121,8 +126,8 @@ export function createContext({
|
|
|
121
126
|
upsert: upsertOfficialContactEmailVerificationFactory({ pg }),
|
|
122
127
|
},
|
|
123
128
|
oidc_clients: {
|
|
124
|
-
addConnection: addConnectionFactory({ pg }),
|
|
125
129
|
findByClientId: findByClientIdFactory({ pg }),
|
|
130
|
+
upsertAuthorizationRequest: upsertAuthorizationRequestFactory({ pg }),
|
|
126
131
|
},
|
|
127
132
|
organizations: {
|
|
128
133
|
findById: findOrganizationByIdFactory({ pg }),
|
|
@@ -134,6 +139,11 @@ export function createContext({
|
|
|
134
139
|
getById: getOrganizationByIdFactory({ pg }),
|
|
135
140
|
upsert: upsertFactory({ pg }),
|
|
136
141
|
},
|
|
142
|
+
recovery_words: {
|
|
143
|
+
create: createRecoveryWordsFactory({ pg }),
|
|
144
|
+
deleteByUserId: deleteRecoveryWordsByUserIdFactory({ pg }),
|
|
145
|
+
findByUserId: findRecoveryWordsByUserIdFactory({ pg }),
|
|
146
|
+
},
|
|
137
147
|
users_organizations: {
|
|
138
148
|
create: createUserOrganizationFactory({ pg }),
|
|
139
149
|
delete: deleteUserOrganizationFactory({ pg }),
|
|
@@ -0,0 +1,95 @@
|
|
|
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 { upsertAuthorizationRequestFactory } from "./upsert-authorization-request.js";
|
|
7
|
+
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
const upsertAuthorizationRequest = upsertAuthorizationRequestFactory({
|
|
11
|
+
pg: pg as any,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
suite("upsertAuthorizationRequestFactory", () => {
|
|
15
|
+
before(migrate);
|
|
16
|
+
beforeEach(emptyDatabase);
|
|
17
|
+
beforeEach(async () => {
|
|
18
|
+
await pg.sql`
|
|
19
|
+
INSERT INTO users
|
|
20
|
+
(id, email, created_at, updated_at, given_name, family_name, phone_number, job)
|
|
21
|
+
VALUES
|
|
22
|
+
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque')
|
|
23
|
+
;
|
|
24
|
+
`;
|
|
25
|
+
await pg.sql`
|
|
26
|
+
INSERT INTO oidc_clients
|
|
27
|
+
(id, client_id, client_name, client_secret, created_at, updated_at)
|
|
28
|
+
VALUES
|
|
29
|
+
(1, '⚔️', 'Dark Angels', 'secret', '4444-04-04', '4444-04-04')
|
|
30
|
+
;
|
|
31
|
+
`;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("should insert and return the authorization request", async () => {
|
|
35
|
+
const authorizationRequest = await upsertAuthorizationRequest({
|
|
36
|
+
user_id: 1,
|
|
37
|
+
oidc_client_id: 1,
|
|
38
|
+
organization_id: null,
|
|
39
|
+
sp_name: "proconnect",
|
|
40
|
+
user_ip_address: "127.0.0.1",
|
|
41
|
+
interaction_cid: "Rex5_Tq4tBqqwz0xPTJyd",
|
|
42
|
+
outcome: "succeeded",
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
assert.equal(authorizationRequest.user_id, 1);
|
|
46
|
+
assert.equal(authorizationRequest.oidc_client_id, 1);
|
|
47
|
+
assert.equal(authorizationRequest.interaction_cid, "Rex5_Tq4tBqqwz0xPTJyd");
|
|
48
|
+
assert.equal(authorizationRequest.outcome, "succeeded");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("should update the authorization request of the same interaction", async () => {
|
|
52
|
+
const request = {
|
|
53
|
+
user_id: 1,
|
|
54
|
+
oidc_client_id: 1,
|
|
55
|
+
organization_id: null,
|
|
56
|
+
sp_name: null,
|
|
57
|
+
user_ip_address: null,
|
|
58
|
+
};
|
|
59
|
+
await upsertAuthorizationRequest({
|
|
60
|
+
...request,
|
|
61
|
+
interaction_cid: "caliban",
|
|
62
|
+
outcome: null,
|
|
63
|
+
});
|
|
64
|
+
await upsertAuthorizationRequest({
|
|
65
|
+
...request,
|
|
66
|
+
interaction_cid: "fallen",
|
|
67
|
+
outcome: null,
|
|
68
|
+
});
|
|
69
|
+
await upsertAuthorizationRequest({
|
|
70
|
+
...request,
|
|
71
|
+
interaction_cid: "caliban",
|
|
72
|
+
outcome: "succeeded",
|
|
73
|
+
});
|
|
74
|
+
await upsertAuthorizationRequest({
|
|
75
|
+
...request,
|
|
76
|
+
interaction_cid: null,
|
|
77
|
+
outcome: "succeeded",
|
|
78
|
+
});
|
|
79
|
+
await upsertAuthorizationRequest({
|
|
80
|
+
...request,
|
|
81
|
+
interaction_cid: null,
|
|
82
|
+
outcome: "succeeded",
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const { rows } = await pg.query(
|
|
86
|
+
"SELECT interaction_cid, outcome FROM users_oidc_clients ORDER BY id",
|
|
87
|
+
);
|
|
88
|
+
assert.deepEqual(rows, [
|
|
89
|
+
{ interaction_cid: "caliban", outcome: "succeeded" },
|
|
90
|
+
{ interaction_cid: "fallen", outcome: null },
|
|
91
|
+
{ interaction_cid: null, outcome: "succeeded" },
|
|
92
|
+
{ interaction_cid: null, outcome: "succeeded" },
|
|
93
|
+
]);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
AuthorizationRequest,
|
|
5
|
+
BaseAuthorizationRequest,
|
|
6
|
+
DatabaseContext,
|
|
7
|
+
} from "#src/types";
|
|
8
|
+
import { type QueryResult } from "pg";
|
|
9
|
+
|
|
10
|
+
//
|
|
11
|
+
|
|
12
|
+
export function upsertAuthorizationRequestFactory({ pg }: DatabaseContext) {
|
|
13
|
+
return async function upsertAuthorizationRequest({
|
|
14
|
+
user_id,
|
|
15
|
+
oidc_client_id,
|
|
16
|
+
organization_id,
|
|
17
|
+
sp_name,
|
|
18
|
+
user_ip_address,
|
|
19
|
+
interaction_cid,
|
|
20
|
+
outcome,
|
|
21
|
+
}: BaseAuthorizationRequest) {
|
|
22
|
+
const { rows }: QueryResult<AuthorizationRequest> = await pg.query(
|
|
23
|
+
`
|
|
24
|
+
INSERT INTO users_oidc_clients
|
|
25
|
+
(user_id, oidc_client_id, organization_id, sp_name, user_ip_address, created_at, updated_at, interaction_cid, outcome)
|
|
26
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
|
27
|
+
ON CONFLICT (interaction_cid) WHERE interaction_cid IS NOT NULL
|
|
28
|
+
DO UPDATE SET
|
|
29
|
+
organization_id = EXCLUDED.organization_id,
|
|
30
|
+
outcome = EXCLUDED.outcome,
|
|
31
|
+
updated_at = EXCLUDED.updated_at,
|
|
32
|
+
user_id = EXCLUDED.user_id
|
|
33
|
+
RETURNING user_id, oidc_client_id, organization_id, sp_name, user_ip_address, created_at, updated_at, id, interaction_cid, outcome;
|
|
34
|
+
`,
|
|
35
|
+
[
|
|
36
|
+
user_id,
|
|
37
|
+
oidc_client_id,
|
|
38
|
+
organization_id,
|
|
39
|
+
sp_name,
|
|
40
|
+
user_ip_address,
|
|
41
|
+
new Date(),
|
|
42
|
+
new Date(),
|
|
43
|
+
interaction_cid,
|
|
44
|
+
outcome,
|
|
45
|
+
],
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
return rows.shift()!;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type { DatabaseContext, RecoveryWords } from "#src/types";
|
|
4
|
+
import { type QueryResult } from "pg";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
export function createRecoveryWordsFactory({ pg }: DatabaseContext) {
|
|
9
|
+
return async function createRecoveryWords({
|
|
10
|
+
user_id,
|
|
11
|
+
hashed_words,
|
|
12
|
+
}: {
|
|
13
|
+
user_id: number;
|
|
14
|
+
hashed_words: string;
|
|
15
|
+
}) {
|
|
16
|
+
const { rows }: QueryResult<RecoveryWords> = await pg.query(
|
|
17
|
+
`
|
|
18
|
+
INSERT INTO recovery_words
|
|
19
|
+
(user_id, hashed_words)
|
|
20
|
+
VALUES
|
|
21
|
+
($1, $2)
|
|
22
|
+
RETURNING *;`,
|
|
23
|
+
[user_id, hashed_words],
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return rows.shift()!;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type { DatabaseContext } from "#src/types";
|
|
4
|
+
import type { QueryResult } from "pg";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
export function deleteRecoveryWordsByUserIdFactory({ pg }: DatabaseContext) {
|
|
9
|
+
return async function deleteRecoveryWordsByUserId(user_id: number) {
|
|
10
|
+
const { rowCount, affectedRows } = (await pg.query(
|
|
11
|
+
`
|
|
12
|
+
DELETE FROM recovery_words
|
|
13
|
+
WHERE user_id = $1
|
|
14
|
+
RETURNING *`,
|
|
15
|
+
|
|
16
|
+
[user_id],
|
|
17
|
+
)) as QueryResult & { affectedRows?: number };
|
|
18
|
+
return (affectedRows ?? rowCount ?? 0) > 0;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type { DatabaseContext, RecoveryWords } from "#src/types";
|
|
4
|
+
import { type QueryResult } from "pg";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
export function findRecoveryWordsByUserIdFactory({ pg }: DatabaseContext) {
|
|
9
|
+
return async function findRecoveryWordsByUserId(user_id: number) {
|
|
10
|
+
const { rows }: QueryResult<RecoveryWords> = await pg.query(
|
|
11
|
+
`
|
|
12
|
+
SELECT *
|
|
13
|
+
FROM recovery_words
|
|
14
|
+
WHERE user_id = $1;`,
|
|
15
|
+
[user_id],
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
return rows.shift();
|
|
19
|
+
};
|
|
20
|
+
}
|