@proconnect-gouv/proconnect.identite 17.0.0 → 17.1.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 +6 -0
- package/dist/connectors/index.d.ts +7 -0
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/index.js +2 -1
- package/dist/repositories/authenticator/index.d.ts +1 -0
- package/dist/repositories/authenticator/index.d.ts.map +1 -1
- package/dist/repositories/authenticator/index.js +1 -0
- package/dist/repositories/authenticator/rename-authenticator.d.ts +3 -0
- package/dist/repositories/authenticator/rename-authenticator.d.ts.map +1 -0
- package/dist/repositories/authenticator/rename-authenticator.js +14 -0
- package/dist/repositories/user/create.d.ts +1 -0
- package/dist/repositories/user/create.d.ts.map +1 -1
- package/dist/repositories/user/find-by-email.d.ts +1 -0
- package/dist/repositories/user/find-by-email.d.ts.map +1 -1
- package/dist/repositories/user/find-by-id.d.ts +1 -0
- package/dist/repositories/user/find-by-id.d.ts.map +1 -1
- package/dist/repositories/user/find-by-magic-link-token.d.ts +1 -0
- package/dist/repositories/user/find-by-magic-link-token.d.ts.map +1 -1
- package/dist/repositories/user/get-by-id.d.ts +1 -0
- package/dist/repositories/user/get-by-id.d.ts.map +1 -1
- package/dist/repositories/user/update.d.ts +1 -0
- package/dist/repositories/user/update.d.ts.map +1 -1
- package/dist/types/user.d.ts +1 -0
- package/dist/types/user.d.ts.map +1 -1
- package/dist/types/user.js +1 -0
- package/package.json +1 -1
- package/src/connectors/index.ts +2 -0
- package/src/repositories/authenticator/index.ts +1 -0
- package/src/repositories/authenticator/rename-authenticator.test.ts +53 -0
- package/src/repositories/authenticator/rename-authenticator.ts +26 -0
- package/src/repositories/user/create.test.ts +1 -0
- package/src/repositories/user/find-by-email.test.ts +1 -0
- package/src/repositories/user/find-by-id.test.ts +1 -0
- package/src/repositories/user/get-by-id.test.ts +1 -0
- package/src/types/user.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @proconnect-gouv/proconnect.identite
|
|
2
2
|
|
|
3
|
+
## 17.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2424](https://github.com/proconnect-gouv/proconnect-identite/pull/2424) [`97bfc2c`](https://github.com/proconnect-gouv/proconnect-identite/commit/97bfc2ca795440d853f8e295f26f2be7a5048b67) Thanks [@rebeccadumazert](https://github.com/rebeccadumazert)! - Ajoute la colonne `users.totp_display_name`, le champ `totp_display_name` à `UserSchema` (`null` par défaut) et `authenticators.rename`, qui renomme une clé d'accès sans toucher à ses compteurs. La réinitialisation de la double authentification remet aussi ce nom à `null`.
|
|
8
|
+
|
|
3
9
|
## 17.0.0
|
|
4
10
|
|
|
5
11
|
### Major Changes
|
|
@@ -371,6 +371,7 @@ export declare function createContext({ api_entreprise_client, api_insee_client,
|
|
|
371
371
|
deleteAllByUserId: (user_id: number) => Promise<boolean>;
|
|
372
372
|
find: (user_id: number, serialized_credential_id: string) => Promise<import("../types/authenticator.js").Authenticator | undefined>;
|
|
373
373
|
findByUserId: (user_id: number) => Promise<import("../types/authenticator.js").Authenticator[]>;
|
|
374
|
+
rename: (user_id: number, credential_id: string, display_name: string | null) => Promise<import("../types/authenticator.js").Authenticator | undefined>;
|
|
374
375
|
};
|
|
375
376
|
email_domains: {
|
|
376
377
|
addDomain: ({ organization_id, domain, verification_type, }: {
|
|
@@ -524,6 +525,7 @@ export declare function createContext({ api_entreprise_client, api_insee_client,
|
|
|
524
525
|
reset_password_sent_at: Date | null;
|
|
525
526
|
reset_password_token: string | null;
|
|
526
527
|
sign_in_count: number;
|
|
528
|
+
totp_display_name: string | null;
|
|
527
529
|
totp_key_verified_at: Date | null;
|
|
528
530
|
updated_at: Date;
|
|
529
531
|
verify_email_sent_at: Date | null;
|
|
@@ -551,6 +553,7 @@ export declare function createContext({ api_entreprise_client, api_insee_client,
|
|
|
551
553
|
reset_password_sent_at: Date | null;
|
|
552
554
|
reset_password_token: string | null;
|
|
553
555
|
sign_in_count: number;
|
|
556
|
+
totp_display_name: string | null;
|
|
554
557
|
totp_key_verified_at: Date | null;
|
|
555
558
|
updated_at: Date;
|
|
556
559
|
verify_email_sent_at: Date | null;
|
|
@@ -578,6 +581,7 @@ export declare function createContext({ api_entreprise_client, api_insee_client,
|
|
|
578
581
|
reset_password_sent_at: Date | null;
|
|
579
582
|
reset_password_token: string | null;
|
|
580
583
|
sign_in_count: number;
|
|
584
|
+
totp_display_name: string | null;
|
|
581
585
|
totp_key_verified_at: Date | null;
|
|
582
586
|
updated_at: Date;
|
|
583
587
|
verify_email_sent_at: Date | null;
|
|
@@ -605,6 +609,7 @@ export declare function createContext({ api_entreprise_client, api_insee_client,
|
|
|
605
609
|
reset_password_sent_at: Date | null;
|
|
606
610
|
reset_password_token: string | null;
|
|
607
611
|
sign_in_count: number;
|
|
612
|
+
totp_display_name: string | null;
|
|
608
613
|
totp_key_verified_at: Date | null;
|
|
609
614
|
updated_at: Date;
|
|
610
615
|
verify_email_sent_at: Date | null;
|
|
@@ -632,6 +637,7 @@ export declare function createContext({ api_entreprise_client, api_insee_client,
|
|
|
632
637
|
reset_password_sent_at: Date | null;
|
|
633
638
|
reset_password_token: string | null;
|
|
634
639
|
sign_in_count: number;
|
|
640
|
+
totp_display_name: string | null;
|
|
635
641
|
totp_key_verified_at: Date | null;
|
|
636
642
|
updated_at: Date;
|
|
637
643
|
verify_email_sent_at: Date | null;
|
|
@@ -659,6 +665,7 @@ export declare function createContext({ api_entreprise_client, api_insee_client,
|
|
|
659
665
|
reset_password_sent_at: Date | null;
|
|
660
666
|
reset_password_token: string | null;
|
|
661
667
|
sign_in_count: number;
|
|
668
|
+
totp_display_name: string | null;
|
|
662
669
|
totp_key_verified_at: Date | null;
|
|
663
670
|
updated_at: Date;
|
|
664
671
|
verify_email_sent_at: Date | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":"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"}
|
package/dist/connectors/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//
|
|
2
|
-
import { createAuthenticatorFactory, deleteAllAuthenticatorsByUserIdFactory, deleteAuthenticatorFactory, findAuthenticatorFactory, findAuthenticatorsByUserIdFactory, } from "#src/repositories/authenticator";
|
|
2
|
+
import { createAuthenticatorFactory, deleteAllAuthenticatorsByUserIdFactory, deleteAuthenticatorFactory, findAuthenticatorFactory, findAuthenticatorsByUserIdFactory, renameAuthenticatorFactory, } from "#src/repositories/authenticator";
|
|
3
3
|
import { addDomainFactory, findEmailDomainsByOrganizationIdFactory, } from "#src/repositories/email-domain";
|
|
4
4
|
import { findFranceconnectUserinfoFactory } from "#src/repositories/franceconnect_userinfo";
|
|
5
5
|
import { deleteModerationFactory, findModerationByIdFactory, getModerationByIdFactory, reopenModerationFactory, } from "#src/repositories/moderation";
|
|
@@ -25,6 +25,7 @@ export function createContext({ api_entreprise_client, api_insee_client, api_reg
|
|
|
25
25
|
deleteAllByUserId: deleteAllAuthenticatorsByUserIdFactory({ pg }),
|
|
26
26
|
find: findAuthenticatorFactory({ pg }),
|
|
27
27
|
findByUserId: findAuthenticatorsByUserIdFactory({ pg }),
|
|
28
|
+
rename: renameAuthenticatorFactory({ pg }),
|
|
28
29
|
},
|
|
29
30
|
email_domains: {
|
|
30
31
|
addDomain: addDomainFactory({ pg }),
|
|
@@ -3,4 +3,5 @@ export * from "./delete-all-authenticators-by-user-id.js";
|
|
|
3
3
|
export * from "./delete-authenticator.js";
|
|
4
4
|
export * from "./find-authenticator.js";
|
|
5
5
|
export * from "./find-authenticators-by-user-id.js";
|
|
6
|
+
export * from "./rename-authenticator.js";
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repositories/authenticator/index.ts"],"names":[],"mappings":"AAEA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,qCAAqC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repositories/authenticator/index.ts"],"names":[],"mappings":"AAEA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,qCAAqC,CAAC;AACpD,cAAc,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Authenticator, DatabaseContext } from "#src/types";
|
|
2
|
+
export declare function renameAuthenticatorFactory({ pg }: DatabaseContext): (user_id: number, credential_id: string, display_name: string | null) => Promise<Authenticator | undefined>;
|
|
3
|
+
//# sourceMappingURL=rename-authenticator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rename-authenticator.d.ts","sourceRoot":"","sources":["../../../src/repositories/authenticator/rename-authenticator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAKjE,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAE9D,SAAS,MAAM,EACf,eAAe,MAAM,EACrB,cAAc,MAAM,GAAG,IAAI,wCAc9B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
import {} from "pg";
|
|
3
|
+
//
|
|
4
|
+
export function renameAuthenticatorFactory({ pg }) {
|
|
5
|
+
return async function renameAuthenticator(user_id, credential_id, display_name) {
|
|
6
|
+
const { rows } = await pg.query(`
|
|
7
|
+
UPDATE authenticators
|
|
8
|
+
SET display_name = $3
|
|
9
|
+
WHERE user_id = $1
|
|
10
|
+
AND credential_id = $2
|
|
11
|
+
RETURNING *`, [user_id, credential_id, display_name]);
|
|
12
|
+
return rows.shift();
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -24,6 +24,7 @@ export declare function createUserFactory({ pg }: DatabaseContext): ({ email, en
|
|
|
24
24
|
reset_password_sent_at: Date | null;
|
|
25
25
|
reset_password_token: string | null;
|
|
26
26
|
sign_in_count: number;
|
|
27
|
+
totp_display_name: string | null;
|
|
27
28
|
totp_key_verified_at: Date | null;
|
|
28
29
|
updated_at: Date;
|
|
29
30
|
verify_email_sent_at: Date | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAQ,MAAM,YAAY,CAAC;AAKxD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,gCAG9B;IACD,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAQ,MAAM,YAAY,CAAC;AAKxD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,gCAG9B;IACD,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BF;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -21,6 +21,7 @@ export declare function findByEmailFactory({ pg }: DatabaseContext): (email: str
|
|
|
21
21
|
reset_password_sent_at: Date | null;
|
|
22
22
|
reset_password_token: string | null;
|
|
23
23
|
sign_in_count: number;
|
|
24
|
+
totp_display_name: string | null;
|
|
24
25
|
totp_key_verified_at: Date | null;
|
|
25
26
|
updated_at: Date;
|
|
26
27
|
verify_email_sent_at: Date | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-by-email.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/find-by-email.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAQ,MAAM,YAAY,CAAC;AAKxD,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,OAAO,MAAM
|
|
1
|
+
{"version":3,"file":"find-by-email.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/find-by-email.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAQ,MAAM,YAAY,CAAC;AAKxD,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;eAWhD;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
|
|
@@ -21,6 +21,7 @@ export declare function findByIdFactory({ pg }: DatabaseContext): (id: number) =
|
|
|
21
21
|
reset_password_sent_at: Date | null;
|
|
22
22
|
reset_password_token: string | null;
|
|
23
23
|
sign_in_count: number;
|
|
24
|
+
totp_display_name: string | null;
|
|
24
25
|
totp_key_verified_at: Date | null;
|
|
25
26
|
updated_at: Date;
|
|
26
27
|
verify_email_sent_at: Date | null;
|
|
@@ -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,EAAQ,MAAM,YAAY,CAAC;AAKxD,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,IAAI,MAAM
|
|
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"}
|
|
@@ -21,6 +21,7 @@ export declare function findByMagicLinkTokenFactory({ pg }: DatabaseContext): (m
|
|
|
21
21
|
reset_password_sent_at: Date | null;
|
|
22
22
|
reset_password_token: string | null;
|
|
23
23
|
sign_in_count: number;
|
|
24
|
+
totp_display_name: string | null;
|
|
24
25
|
totp_key_verified_at: Date | null;
|
|
25
26
|
updated_at: Date;
|
|
26
27
|
verify_email_sent_at: Date | null;
|
|
@@ -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,EAAQ,MAAM,YAAY,CAAC;AAKxD,wBAAgB,2BAA2B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,kBAAkB,MAAM
|
|
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"}
|
|
@@ -21,6 +21,7 @@ export declare function getByIdFactory({ pg }: DatabaseContext): (id: number) =>
|
|
|
21
21
|
reset_password_sent_at: Date | null;
|
|
22
22
|
reset_password_token: string | null;
|
|
23
23
|
sign_in_count: number;
|
|
24
|
+
totp_display_name: string | null;
|
|
24
25
|
totp_key_verified_at: Date | null;
|
|
25
26
|
updated_at: Date;
|
|
26
27
|
verify_email_sent_at: Date | null;
|
|
@@ -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"}
|
|
@@ -21,6 +21,7 @@ export declare function updateUserFactory({ pg }: DatabaseContext): (id: number,
|
|
|
21
21
|
reset_password_sent_at: Date | null;
|
|
22
22
|
reset_password_token: string | null;
|
|
23
23
|
sign_in_count: number;
|
|
24
|
+
totp_display_name: string | null;
|
|
24
25
|
totp_key_verified_at: Date | null;
|
|
25
26
|
updated_at: Date;
|
|
26
27
|
verify_email_sent_at: Date | null;
|
|
@@ -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"}
|
package/dist/types/user.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare const UserSchema: z.ZodObject<{
|
|
|
21
21
|
reset_password_sent_at: z.ZodNullable<z.ZodDate>;
|
|
22
22
|
reset_password_token: z.ZodNullable<z.ZodString>;
|
|
23
23
|
sign_in_count: z.ZodNumber;
|
|
24
|
+
totp_display_name: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
24
25
|
totp_key_verified_at: z.ZodNullable<z.ZodDate>;
|
|
25
26
|
updated_at: z.ZodDate;
|
|
26
27
|
verify_email_sent_at: z.ZodNullable<z.ZodDate>;
|
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,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,UAAU
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA2BrB,CAAC;AAEH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
package/dist/types/user.js
CHANGED
|
@@ -23,6 +23,7 @@ export const UserSchema = z.object({
|
|
|
23
23
|
reset_password_sent_at: z.date().nullable(),
|
|
24
24
|
reset_password_token: z.string().nullable(),
|
|
25
25
|
sign_in_count: z.number(),
|
|
26
|
+
totp_display_name: z.string().nullable().default(null),
|
|
26
27
|
totp_key_verified_at: z.date().nullable(),
|
|
27
28
|
updated_at: z.date(),
|
|
28
29
|
verify_email_sent_at: z.date().nullable(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proconnect-gouv/proconnect.identite",
|
|
3
|
-
"version": "17.
|
|
3
|
+
"version": "17.1.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": {
|
package/src/connectors/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
deleteAuthenticatorFactory,
|
|
7
7
|
findAuthenticatorFactory,
|
|
8
8
|
findAuthenticatorsByUserIdFactory,
|
|
9
|
+
renameAuthenticatorFactory,
|
|
9
10
|
} from "#src/repositories/authenticator";
|
|
10
11
|
import {
|
|
11
12
|
addDomainFactory,
|
|
@@ -81,6 +82,7 @@ export function createContext({
|
|
|
81
82
|
deleteAllByUserId: deleteAllAuthenticatorsByUserIdFactory({ pg }),
|
|
82
83
|
find: findAuthenticatorFactory({ pg }),
|
|
83
84
|
findByUserId: findAuthenticatorsByUserIdFactory({ pg }),
|
|
85
|
+
rename: renameAuthenticatorFactory({ pg }),
|
|
84
86
|
},
|
|
85
87
|
email_domains: {
|
|
86
88
|
addDomain: addDomainFactory({ pg }),
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { renameAuthenticatorFactory } from "./rename-authenticator.js";
|
|
7
|
+
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
const renameAuthenticator = renameAuthenticatorFactory({ pg: pg as any });
|
|
11
|
+
|
|
12
|
+
suite("renameAuthenticatorFactory", () => {
|
|
13
|
+
before(migrate);
|
|
14
|
+
beforeEach(emptyDatabase);
|
|
15
|
+
|
|
16
|
+
beforeEach(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
|
+
(2, 'perturabo@ironwarriors.world', '4444-04-04', '4444-04-04', 'perturabo', '', 'i', 'primarque')
|
|
23
|
+
;
|
|
24
|
+
`;
|
|
25
|
+
await pg.sql`
|
|
26
|
+
INSERT INTO authenticators
|
|
27
|
+
(credential_id, credential_public_key, counter, credential_backed_up, user_id, usage_count, user_verified, display_name)
|
|
28
|
+
VALUES
|
|
29
|
+
('CRED1', '\\x00', 42, false, 1, 7, true, 'iCloud Keychain')
|
|
30
|
+
;
|
|
31
|
+
`;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("should rename the authenticator without touching its counters", async () => {
|
|
35
|
+
const authenticator = await renameAuthenticator(1, "CRED1", "iPhone perso");
|
|
36
|
+
|
|
37
|
+
assert.equal(authenticator?.display_name, "iPhone perso");
|
|
38
|
+
assert.equal(authenticator?.counter, 42);
|
|
39
|
+
assert.equal(authenticator?.usage_count, 7);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("should reset the name to null", async () => {
|
|
43
|
+
const authenticator = await renameAuthenticator(1, "CRED1", null);
|
|
44
|
+
|
|
45
|
+
assert.equal(authenticator?.display_name, null);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("should not rename another user's authenticator", async () => {
|
|
49
|
+
const authenticator = await renameAuthenticator(2, "CRED1", "piraté");
|
|
50
|
+
|
|
51
|
+
assert.equal(authenticator, undefined);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type { Authenticator, DatabaseContext } from "#src/types";
|
|
4
|
+
import { type QueryResult } from "pg";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
export function renameAuthenticatorFactory({ pg }: DatabaseContext) {
|
|
9
|
+
return async function renameAuthenticator(
|
|
10
|
+
user_id: number,
|
|
11
|
+
credential_id: string,
|
|
12
|
+
display_name: string | null,
|
|
13
|
+
) {
|
|
14
|
+
const { rows }: QueryResult<Authenticator> = await pg.query(
|
|
15
|
+
`
|
|
16
|
+
UPDATE authenticators
|
|
17
|
+
SET display_name = $3
|
|
18
|
+
WHERE user_id = $1
|
|
19
|
+
AND credential_id = $2
|
|
20
|
+
RETURNING *`,
|
|
21
|
+
[user_id, credential_id, display_name],
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return rows.shift();
|
|
25
|
+
};
|
|
26
|
+
}
|
package/src/types/user.ts
CHANGED
|
@@ -26,6 +26,7 @@ export const UserSchema = z.object({
|
|
|
26
26
|
reset_password_sent_at: z.date().nullable(),
|
|
27
27
|
reset_password_token: z.string().nullable(),
|
|
28
28
|
sign_in_count: z.number(),
|
|
29
|
+
totp_display_name: z.string().nullable().default(null),
|
|
29
30
|
totp_key_verified_at: z.date().nullable(),
|
|
30
31
|
updated_at: z.date(),
|
|
31
32
|
verify_email_sent_at: z.date().nullable(),
|