@proconnect-gouv/proconnect.identite 17.0.0 → 17.1.1

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/connectors/index.d.ts +7 -0
  3. package/dist/connectors/index.d.ts.map +1 -1
  4. package/dist/connectors/index.js +2 -1
  5. package/dist/repositories/authenticator/index.d.ts +1 -0
  6. package/dist/repositories/authenticator/index.d.ts.map +1 -1
  7. package/dist/repositories/authenticator/index.js +1 -0
  8. package/dist/repositories/authenticator/rename-authenticator.d.ts +3 -0
  9. package/dist/repositories/authenticator/rename-authenticator.d.ts.map +1 -0
  10. package/dist/repositories/authenticator/rename-authenticator.js +14 -0
  11. package/dist/repositories/user/create.d.ts +1 -0
  12. package/dist/repositories/user/create.d.ts.map +1 -1
  13. package/dist/repositories/user/find-by-email.d.ts +1 -0
  14. package/dist/repositories/user/find-by-email.d.ts.map +1 -1
  15. package/dist/repositories/user/find-by-id.d.ts +1 -0
  16. package/dist/repositories/user/find-by-id.d.ts.map +1 -1
  17. package/dist/repositories/user/find-by-magic-link-token.d.ts +1 -0
  18. package/dist/repositories/user/find-by-magic-link-token.d.ts.map +1 -1
  19. package/dist/repositories/user/get-by-id.d.ts +1 -0
  20. package/dist/repositories/user/get-by-id.d.ts.map +1 -1
  21. package/dist/repositories/user/update.d.ts +1 -0
  22. package/dist/repositories/user/update.d.ts.map +1 -1
  23. package/dist/types/user.d.ts +1 -0
  24. package/dist/types/user.d.ts.map +1 -1
  25. package/dist/types/user.js +1 -0
  26. package/package.json +11 -11
  27. package/src/connectors/index.ts +2 -0
  28. package/src/repositories/authenticator/index.ts +1 -0
  29. package/src/repositories/authenticator/rename-authenticator.test.ts +53 -0
  30. package/src/repositories/authenticator/rename-authenticator.ts +26 -0
  31. package/src/repositories/user/create.test.ts +1 -0
  32. package/src/repositories/user/find-by-email.test.ts +1 -0
  33. package/src/repositories/user/find-by-id.test.ts +1 -0
  34. package/src/repositories/user/get-by-id.test.ts +1 -0
  35. package/src/types/user.ts +1 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @proconnect-gouv/proconnect.identite
2
2
 
3
+ ## 17.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2585](https://github.com/proconnect-gouv/proconnect-identite/pull/2585) [`01ed18b`](https://github.com/proconnect-gouv/proconnect-identite/commit/01ed18bd538420e4736e29311e7f4bd63b1eecc6) Thanks [@douglasduteil](https://github.com/douglasduteil)! - 🔒 Publication via npm trusted publishing (OIDC) au lieu d'un jeton npm
8
+ - Updated dependencies [[`01ed18b`](https://github.com/proconnect-gouv/proconnect-identite/commit/01ed18bd538420e4736e29311e7f4bd63b1eecc6)]:
9
+ - @proconnect-gouv/proconnect.annuaire_entreprises@3.0.12
10
+ - @proconnect-gouv/proconnect.api_entreprise@2.3.1
11
+ - @proconnect-gouv/proconnect.core@1.1.2
12
+ - @proconnect-gouv/proconnect.insee@2.0.1
13
+ - @proconnect-gouv/proconnect.registre_national_entreprises@4.1.1
14
+
15
+ ## 17.1.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [#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`.
20
+
3
21
  ## 17.0.0
4
22
 
5
23
  ### 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":"AAoDA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,+DAA+D,CAAC;AAC1H,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,IAAI,CAAC;AAI/B,wBAAgB,aAAa,CAAC,EAC5B,qBAAqB,EACrB,gBAAgB,EAChB,wCAAwC,EACxC,EAAE,GACH,EAAE;IACD,qBAAqB,EAAE,mBAAmB,CAAC;IAC3C,gBAAgB,EAAE,cAAc,CAAC;IACjC,wCAAwC,EAAE,oCAAoC,CAAC;IAC/E,EAAE,EAAE,IAAI,CAAC;CACV;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAiEs/H,CAAC;oBAAkC,CAAC;;mBAAmG,CAAC;sBAA2C,CAAC;8BAAmD,CAAC;wCAA6D,CAAC;8BAAmD,CAAC;8BAAmD,CAAC;mCAAwD,CAAC;2BAAgD,CAAC;gCAAqD,CAAC;8BAAmD,CAAC;2BAAgD,CAAC;8BAAmD,CAAC;;;;;qBA1HjrJ,CAAC;qBACL,CAAA;0CAAwD,CAAC;sCAElD,CAAC;uCAEF,CAAC;wCAED,CAAC;+CAEa,CAAC;4CACS,CAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;kCA/EQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyHhC;AACD,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -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"}
@@ -4,3 +4,4 @@ export * from "./delete-all-authenticators-by-user-id.js";
4
4
  export * from "./delete-authenticator.js";
5
5
  export * from "./find-authenticator.js";
6
6
  export * from "./find-authenticators-by-user-id.js";
7
+ export * from "./rename-authenticator.js";
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BF;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;eAWhD;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;eAY1C;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;eAWpE"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;GAOzC;AAED,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC"}
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;;;;;;;;;;;;;;;;;;;;;;;;;;GAsB3E;AAED,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,OAAO,iBAAiB,CAAC,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"}
@@ -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>;
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BrB,CAAC;AAEH,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,UAAU,CAAC,CAAC"}
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"}
@@ -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.0.0",
3
+ "version": "17.1.1",
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": {
@@ -51,12 +51,12 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@electric-sql/pglite": "^0.5.16",
54
- "@proconnect-gouv/proconnect.annuaire_entreprises": "^3.0.5",
55
- "@proconnect-gouv/proconnect.api_entreprise": "^2.3.0",
56
- "@proconnect-gouv/proconnect.core": "^1.1.0",
54
+ "@proconnect-gouv/proconnect.annuaire_entreprises": "^3.0.12",
55
+ "@proconnect-gouv/proconnect.api_entreprise": "^2.3.1",
56
+ "@proconnect-gouv/proconnect.core": "^1.1.2",
57
57
  "@proconnect-gouv/proconnect.devtools.typescript": "1.0.0",
58
- "@proconnect-gouv/proconnect.insee": "^2.0.0",
59
- "@proconnect-gouv/proconnect.registre_national_entreprises": "^4.1.0",
58
+ "@proconnect-gouv/proconnect.insee": "^2.0.1",
59
+ "@proconnect-gouv/proconnect.registre_national_entreprises": "^4.1.1",
60
60
  "@types/node": "^22.18.6",
61
61
  "@types/pg": "^8.23.1",
62
62
  "await-to-js": "^3.0.0",
@@ -65,11 +65,11 @@
65
65
  "tsx": "^4.20.3"
66
66
  },
67
67
  "peerDependencies": {
68
- "@proconnect-gouv/proconnect.annuaire_entreprises": "^3.0.5",
69
- "@proconnect-gouv/proconnect.api_entreprise": "^2.3.0",
70
- "@proconnect-gouv/proconnect.core": "^1.1.0",
71
- "@proconnect-gouv/proconnect.insee": "^2.0.0",
72
- "@proconnect-gouv/proconnect.registre_national_entreprises": "^4.1.0"
68
+ "@proconnect-gouv/proconnect.annuaire_entreprises": "^3.0.12",
69
+ "@proconnect-gouv/proconnect.api_entreprise": "^2.3.1",
70
+ "@proconnect-gouv/proconnect.core": "^1.1.2",
71
+ "@proconnect-gouv/proconnect.insee": "^2.0.1",
72
+ "@proconnect-gouv/proconnect.registre_national_entreprises": "^4.1.1"
73
73
  },
74
74
  "peerDependenciesMeta": {
75
75
  "@proconnect-gouv/proconnect.annuaire_entreprises": {
@@ -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 }),
@@ -5,3 +5,4 @@ export * from "./delete-all-authenticators-by-user-id.js";
5
5
  export * from "./delete-authenticator.js";
6
6
  export * from "./find-authenticator.js";
7
7
  export * from "./find-authenticators-by-user-id.js";
8
+ export * from "./rename-authenticator.js";
@@ -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
+ }
@@ -40,6 +40,7 @@ suite("createUserFactory", () => {
40
40
  reset_password_sent_at: null,
41
41
  reset_password_token: null,
42
42
  sign_in_count: 0,
43
+ totp_display_name: null,
43
44
  totp_key_verified_at: null,
44
45
  updated_at: new Date("4444-04-04"),
45
46
  verify_email_sent_at: null,
@@ -47,6 +47,7 @@ suite("findByEmailFactory", () => {
47
47
  reset_password_sent_at: null,
48
48
  reset_password_token: null,
49
49
  sign_in_count: 0,
50
+ totp_display_name: null,
50
51
  totp_key_verified_at: null,
51
52
  updated_at: new Date("4444-04-04"),
52
53
  verify_email_sent_at: null,
@@ -49,6 +49,7 @@ suite("findByIdFactory", () => {
49
49
  reset_password_sent_at: null,
50
50
  reset_password_token: null,
51
51
  sign_in_count: 0,
52
+ totp_display_name: null,
52
53
  totp_key_verified_at: null,
53
54
  updated_at: new Date("4444-04-04"),
54
55
  verify_email_sent_at: null,
@@ -50,6 +50,7 @@ suite("getByIdFactory", () => {
50
50
  reset_password_sent_at: null,
51
51
  reset_password_token: null,
52
52
  sign_in_count: 0,
53
+ totp_display_name: null,
53
54
  totp_key_verified_at: null,
54
55
  updated_at: new Date("4444-04-04"),
55
56
  verify_email_sent_at: null,
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(),