@proconnect-gouv/proconnect.identite 10.3.0 → 10.5.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/connectors/index.d.ts +224 -8
  3. package/dist/connectors/index.d.ts.map +1 -1
  4. package/dist/connectors/index.js +6 -0
  5. package/dist/managers/certification/match-identity-to-dirigeant.d.ts +44 -0
  6. package/dist/managers/certification/match-identity-to-dirigeant.d.ts.map +1 -0
  7. package/dist/managers/certification/match-identity-to-dirigeant.js +32 -0
  8. package/dist/managers/certification/process-certification-dirigeant.d.ts.map +1 -1
  9. package/dist/managers/certification/process-certification-dirigeant.js +1 -29
  10. package/dist/managers/organization/mark-domain-as-verified.d.ts.map +1 -1
  11. package/dist/managers/organization/mark-domain-as-verified.js +2 -0
  12. package/dist/repositories/moderation/get-moderation-by-id.d.ts.map +1 -1
  13. package/dist/repositories/moderation/get-moderation-by-id.js +1 -1
  14. package/dist/repositories/organization/find-users-by-organization.d.ts +28 -2
  15. package/dist/repositories/organization/find-users-by-organization.d.ts.map +1 -1
  16. package/dist/repositories/organization/find-users-by-organization.js +3 -6
  17. package/dist/repositories/recovery-words/create.d.ts +6 -0
  18. package/dist/repositories/recovery-words/create.d.ts.map +1 -0
  19. package/dist/repositories/recovery-words/create.js +14 -0
  20. package/dist/repositories/recovery-words/delete-all-by-user-id.d.ts +3 -0
  21. package/dist/repositories/recovery-words/delete-all-by-user-id.d.ts.map +1 -0
  22. package/dist/repositories/recovery-words/delete-all-by-user-id.js +11 -0
  23. package/dist/repositories/recovery-words/find-by-user-id.d.ts +3 -0
  24. package/dist/repositories/recovery-words/find-by-user-id.d.ts.map +1 -0
  25. package/dist/repositories/recovery-words/find-by-user-id.js +12 -0
  26. package/dist/repositories/recovery-words/index.d.ts +4 -0
  27. package/dist/repositories/recovery-words/index.d.ts.map +1 -0
  28. package/dist/repositories/recovery-words/index.js +4 -0
  29. package/dist/repositories/user/create.d.ts +28 -2
  30. package/dist/repositories/user/create.d.ts.map +1 -1
  31. package/dist/repositories/user/find-by-email.d.ts +28 -2
  32. package/dist/repositories/user/find-by-email.d.ts.map +1 -1
  33. package/dist/repositories/user/find-by-id.d.ts +28 -2
  34. package/dist/repositories/user/find-by-id.d.ts.map +1 -1
  35. package/dist/repositories/user/find-by-magic-link-token.d.ts +28 -2
  36. package/dist/repositories/user/find-by-magic-link-token.d.ts.map +1 -1
  37. package/dist/repositories/user/find-by-reset-password-token.d.ts +28 -2
  38. package/dist/repositories/user/find-by-reset-password-token.d.ts.map +1 -1
  39. package/dist/repositories/user/get-by-id.d.ts +27 -1
  40. package/dist/repositories/user/get-by-id.d.ts.map +1 -1
  41. package/dist/repositories/user/update.d.ts +27 -1
  42. package/dist/repositories/user/update.d.ts.map +1 -1
  43. package/dist/types/index.d.ts +1 -0
  44. package/dist/types/index.d.ts.map +1 -1
  45. package/dist/types/index.js +1 -0
  46. package/dist/types/recovery-words.d.ts +9 -0
  47. package/dist/types/recovery-words.d.ts.map +1 -0
  48. package/dist/types/recovery-words.js +1 -0
  49. package/dist/types/user.d.ts +29 -27
  50. package/dist/types/user.d.ts.map +1 -1
  51. package/dist/types/user.js +29 -1
  52. package/package.json +5 -5
  53. package/src/connectors/index.ts +10 -0
  54. package/src/managers/certification/match-identity-to-dirigeant.test.ts +62 -0
  55. package/src/managers/certification/match-identity-to-dirigeant.ts +40 -0
  56. package/src/managers/certification/process-certification-dirigeant.ts +1 -35
  57. package/src/managers/organization/mark-domain-as-verified.test.ts +174 -0
  58. package/src/managers/organization/mark-domain-as-verified.ts +2 -0
  59. package/src/repositories/moderation/get-moderation-by-id.test.ts +1 -1
  60. package/src/repositories/moderation/get-moderation-by-id.ts +1 -1
  61. package/src/repositories/organization/find-users-by-organization.ts +4 -12
  62. package/src/repositories/recovery-words/create.ts +28 -0
  63. package/src/repositories/recovery-words/delete-all-by-user-id.ts +20 -0
  64. package/src/repositories/recovery-words/find-by-user-id.ts +20 -0
  65. package/src/repositories/recovery-words/index.ts +5 -0
  66. package/src/types/index.ts +1 -0
  67. package/src/types/recovery-words.ts +9 -0
  68. package/src/types/user.ts +33 -27
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @proconnect-gouv/proconnect.identite
2
2
 
3
+ ## 10.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#2242](https://github.com/proconnect-gouv/proconnect-identite/pull/2242) [`31652e6`](https://github.com/proconnect-gouv/proconnect-identite/commit/31652e608dd645911f7cd5710fc5395c81bb8a5f) Thanks [@douglasduteil](https://github.com/douglasduteil)! - ajout du schéma zod UserSchema, le type User en est dérivé
8
+
9
+ ## 10.4.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#2154](https://github.com/proconnect-gouv/proconnect-identite/pull/2154) [`6894647`](https://github.com/proconnect-gouv/proconnect-identite/commit/6894647574f1482cf9a7064dc5188d09cf9ded2a) Thanks [@douglasduteil](https://github.com/douglasduteil)! - suppression des paramètres inutilisés additionalWhereClause et additionalParams de findUsersByOrganization
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [[`d7a9f69`](https://github.com/proconnect-gouv/proconnect-identite/commit/d7a9f69111ae9fe6b9c99a38e64258acc0663686)]:
18
+ - @proconnect-gouv/proconnect.core@1.1.0
19
+
3
20
  ## 10.3.0
4
21
 
5
22
  ### Minor Changes
@@ -536,7 +536,33 @@ export declare function createContext({ api_entreprise_client, api_insee_client,
536
536
  findPendingByUserId: (user_id: number) => Promise<(import("../types/organization.js").Organization & {
537
537
  moderation_id: number;
538
538
  })[]>;
539
- findUsers: (organization_id: number, additionalWhereClause?: string, additionalParams?: any[]) => Promise<(import("../types/user.js").User & {
539
+ findUsers: (organization_id: number) => Promise<({
540
+ created_at: Date;
541
+ current_challenge: string | null;
542
+ email: string;
543
+ email_verified: boolean;
544
+ email_verified_at: Date | null;
545
+ encrypted_password: string | null;
546
+ encrypted_totp_key: string | null;
547
+ family_name: string | null;
548
+ force_2fa: boolean;
549
+ given_name: string | null;
550
+ id: number;
551
+ job: string | null;
552
+ last_sign_in_at: Date | null;
553
+ magic_link_sent_at: Date | null;
554
+ magic_link_token: string | null;
555
+ needs_inclusionconnect_onboarding_help: boolean;
556
+ needs_inclusionconnect_welcome_page: boolean;
557
+ phone_number: string | null;
558
+ reset_password_sent_at: Date | null;
559
+ reset_password_token: string | null;
560
+ sign_in_count: number;
561
+ totp_key_verified_at: Date | null;
562
+ updated_at: Date;
563
+ verify_email_sent_at: Date | null;
564
+ verify_email_token: string | null;
565
+ } & {
540
566
  is_external: boolean;
541
567
  verification_type: "domain" | "organization_dirigeant" | "code_sent_to_official_contact_email" | "imported_from_coop_mediation_numerique" | "imported_from_inclusion_connect" | "in_liste_dirigeants_rna" | "in_liste_dirigeants_rne" | "official_contact_email" | "ordre_professionnel_domain" | "proof_received" | "verified_by_coop_mediation_numerique" | "bypassed" | "domain_not_verified_yet" | "no_validation_means_available" | "no_verification_means_for_entreprise_unipersonnelle" | "no_verification_means_for_small_association" | "no_verification_means_for_small_organization";
542
568
  verified_at: Date | null;
@@ -548,6 +574,14 @@ export declare function createContext({ api_entreprise_client, api_insee_client,
548
574
  organizationInfo: import("../types/organization-info.js").OrganizationInfo;
549
575
  }) => Promise<import("../types/organization.js").Organization>;
550
576
  };
577
+ recovery_words: {
578
+ create: ({ user_id, hashed_words, }: {
579
+ user_id: number;
580
+ hashed_words: string;
581
+ }) => Promise<import("../types/recovery-words.js").RecoveryWords>;
582
+ deleteByUserId: (user_id: number) => Promise<boolean>;
583
+ findByUserId: (user_id: number) => Promise<import("../types/recovery-words.js").RecoveryWords | undefined>;
584
+ };
551
585
  users_organizations: {
552
586
  create: ({ is_external, organization_id, user_id, verification_type, }: import("../types/user-organization-link.js").InsertUserOrganizationLink) => Promise<{
553
587
  is_external: boolean;
@@ -595,14 +629,196 @@ export declare function createContext({ api_entreprise_client, api_insee_client,
595
629
  create: ({ email, encrypted_password, }: {
596
630
  email: string;
597
631
  encrypted_password?: string | null;
598
- }) => Promise<import("../types/user.js").User>;
632
+ }) => Promise<{
633
+ created_at: Date;
634
+ current_challenge: string | null;
635
+ email: string;
636
+ email_verified: boolean;
637
+ email_verified_at: Date | null;
638
+ encrypted_password: string | null;
639
+ encrypted_totp_key: string | null;
640
+ family_name: string | null;
641
+ force_2fa: boolean;
642
+ given_name: string | null;
643
+ id: number;
644
+ job: string | null;
645
+ last_sign_in_at: Date | null;
646
+ magic_link_sent_at: Date | null;
647
+ magic_link_token: string | null;
648
+ needs_inclusionconnect_onboarding_help: boolean;
649
+ needs_inclusionconnect_welcome_page: boolean;
650
+ phone_number: string | null;
651
+ reset_password_sent_at: Date | null;
652
+ reset_password_token: string | null;
653
+ sign_in_count: number;
654
+ totp_key_verified_at: Date | null;
655
+ updated_at: Date;
656
+ verify_email_sent_at: Date | null;
657
+ verify_email_token: string | null;
658
+ }>;
599
659
  delete: (id: number) => Promise<boolean>;
600
- findByEmail: (email: string) => Promise<import("../types/user.js").User | undefined>;
601
- findById: (id: number) => Promise<import("../types/user.js").User | undefined>;
602
- findByMagicLinkToken: (magic_link_token: string) => Promise<import("../types/user.js").User | undefined>;
603
- findByResetPasswordToken: (reset_password_token: string) => Promise<import("../types/user.js").User | undefined>;
604
- getById: (id: number) => Promise<import("../types/user.js").User>;
605
- update: (id: number, fieldsToUpdate: Partial<import("../types/user.js").User>) => Promise<import("../types/user.js").User>;
660
+ findByEmail: (email: string) => Promise<{
661
+ created_at: Date;
662
+ current_challenge: string | null;
663
+ email: string;
664
+ email_verified: boolean;
665
+ email_verified_at: Date | null;
666
+ encrypted_password: string | null;
667
+ encrypted_totp_key: string | null;
668
+ family_name: string | null;
669
+ force_2fa: boolean;
670
+ given_name: string | null;
671
+ id: number;
672
+ job: string | null;
673
+ last_sign_in_at: Date | null;
674
+ magic_link_sent_at: Date | null;
675
+ magic_link_token: string | null;
676
+ needs_inclusionconnect_onboarding_help: boolean;
677
+ needs_inclusionconnect_welcome_page: boolean;
678
+ phone_number: string | null;
679
+ reset_password_sent_at: Date | null;
680
+ reset_password_token: string | null;
681
+ sign_in_count: number;
682
+ totp_key_verified_at: Date | null;
683
+ updated_at: Date;
684
+ verify_email_sent_at: Date | null;
685
+ verify_email_token: string | null;
686
+ } | undefined>;
687
+ findById: (id: number) => Promise<{
688
+ created_at: Date;
689
+ current_challenge: string | null;
690
+ email: string;
691
+ email_verified: boolean;
692
+ email_verified_at: Date | null;
693
+ encrypted_password: string | null;
694
+ encrypted_totp_key: string | null;
695
+ family_name: string | null;
696
+ force_2fa: boolean;
697
+ given_name: string | null;
698
+ id: number;
699
+ job: string | null;
700
+ last_sign_in_at: Date | null;
701
+ magic_link_sent_at: Date | null;
702
+ magic_link_token: string | null;
703
+ needs_inclusionconnect_onboarding_help: boolean;
704
+ needs_inclusionconnect_welcome_page: boolean;
705
+ phone_number: string | null;
706
+ reset_password_sent_at: Date | null;
707
+ reset_password_token: string | null;
708
+ sign_in_count: number;
709
+ totp_key_verified_at: Date | null;
710
+ updated_at: Date;
711
+ verify_email_sent_at: Date | null;
712
+ verify_email_token: string | null;
713
+ } | undefined>;
714
+ findByMagicLinkToken: (magic_link_token: string) => Promise<{
715
+ created_at: Date;
716
+ current_challenge: string | null;
717
+ email: string;
718
+ email_verified: boolean;
719
+ email_verified_at: Date | null;
720
+ encrypted_password: string | null;
721
+ encrypted_totp_key: string | null;
722
+ family_name: string | null;
723
+ force_2fa: boolean;
724
+ given_name: string | null;
725
+ id: number;
726
+ job: string | null;
727
+ last_sign_in_at: Date | null;
728
+ magic_link_sent_at: Date | null;
729
+ magic_link_token: string | null;
730
+ needs_inclusionconnect_onboarding_help: boolean;
731
+ needs_inclusionconnect_welcome_page: boolean;
732
+ phone_number: string | null;
733
+ reset_password_sent_at: Date | null;
734
+ reset_password_token: string | null;
735
+ sign_in_count: number;
736
+ totp_key_verified_at: Date | null;
737
+ updated_at: Date;
738
+ verify_email_sent_at: Date | null;
739
+ verify_email_token: string | null;
740
+ } | undefined>;
741
+ findByResetPasswordToken: (reset_password_token: string) => Promise<{
742
+ created_at: Date;
743
+ current_challenge: string | null;
744
+ email: string;
745
+ email_verified: boolean;
746
+ email_verified_at: Date | null;
747
+ encrypted_password: string | null;
748
+ encrypted_totp_key: string | null;
749
+ family_name: string | null;
750
+ force_2fa: boolean;
751
+ given_name: string | null;
752
+ id: number;
753
+ job: string | null;
754
+ last_sign_in_at: Date | null;
755
+ magic_link_sent_at: Date | null;
756
+ magic_link_token: string | null;
757
+ needs_inclusionconnect_onboarding_help: boolean;
758
+ needs_inclusionconnect_welcome_page: boolean;
759
+ phone_number: string | null;
760
+ reset_password_sent_at: Date | null;
761
+ reset_password_token: string | null;
762
+ sign_in_count: number;
763
+ totp_key_verified_at: Date | null;
764
+ updated_at: Date;
765
+ verify_email_sent_at: Date | null;
766
+ verify_email_token: string | null;
767
+ } | undefined>;
768
+ getById: (id: number) => Promise<{
769
+ created_at: Date;
770
+ current_challenge: string | null;
771
+ email: string;
772
+ email_verified: boolean;
773
+ email_verified_at: Date | null;
774
+ encrypted_password: string | null;
775
+ encrypted_totp_key: string | null;
776
+ family_name: string | null;
777
+ force_2fa: boolean;
778
+ given_name: string | null;
779
+ id: number;
780
+ job: string | null;
781
+ last_sign_in_at: Date | null;
782
+ magic_link_sent_at: Date | null;
783
+ magic_link_token: string | null;
784
+ needs_inclusionconnect_onboarding_help: boolean;
785
+ needs_inclusionconnect_welcome_page: boolean;
786
+ phone_number: string | null;
787
+ reset_password_sent_at: Date | null;
788
+ reset_password_token: string | null;
789
+ sign_in_count: number;
790
+ totp_key_verified_at: Date | null;
791
+ updated_at: Date;
792
+ verify_email_sent_at: Date | null;
793
+ verify_email_token: string | null;
794
+ }>;
795
+ update: (id: number, fieldsToUpdate: Partial<import("../types/user.js").User>) => Promise<{
796
+ created_at: Date;
797
+ current_challenge: string | null;
798
+ email: string;
799
+ email_verified: boolean;
800
+ email_verified_at: Date | null;
801
+ encrypted_password: string | null;
802
+ encrypted_totp_key: string | null;
803
+ family_name: string | null;
804
+ force_2fa: boolean;
805
+ given_name: string | null;
806
+ id: number;
807
+ job: string | null;
808
+ last_sign_in_at: Date | null;
809
+ magic_link_sent_at: Date | null;
810
+ magic_link_token: string | null;
811
+ needs_inclusionconnect_onboarding_help: boolean;
812
+ needs_inclusionconnect_welcome_page: boolean;
813
+ phone_number: string | null;
814
+ reset_password_sent_at: Date | null;
815
+ reset_password_token: string | null;
816
+ sign_in_count: number;
817
+ totp_key_verified_at: Date | null;
818
+ updated_at: Date;
819
+ verify_email_sent_at: Date | null;
820
+ verify_email_token: string | null;
821
+ }>;
606
822
  };
607
823
  franceconnect_userinfo: {
608
824
  delete: (user_id: number) => Promise<import("pg").QueryResult<any>>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/connectors/index.ts"],"names":[],"mappings":"AAiEA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;kDACA,CAAC;wDACgB,CAAC;iDACrC,CAAC;;;;;kCAQE,CAAC;;qBAEgB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBAnFF,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCADjB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8JP;AACD,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC"}
@@ -7,6 +7,7 @@ import { createModerationFactory, deleteModerationFactory, findModerationByIdFac
7
7
  import { deleteOfficialContactEmailVerificationFactory, findOfficialContactEmailVerificationFactory, upsertOfficialContactEmailVerificationFactory, } from "#src/repositories/official-contact-email-verification";
8
8
  import { addConnectionFactory, findByClientIdFactory, } from "#src/repositories/oidc-client";
9
9
  import { findBySiretFactory, findByUserIdFactory, findByVerifiedEmailDomainFactory, findOrganizationByIdFactory, findPendingByUserIdFactory, findUsersByOrganizationFactory, getOrganizationByIdFactory, upsertFactory, } from "#src/repositories/organization";
10
+ import { createRecoveryWordsFactory, deleteRecoveryWordsByUserIdFactory, findRecoveryWordsByUserIdFactory, } from "#src/repositories/recovery-words";
10
11
  import { createUserFactory, deleteUserFactory, findByEmailFactory, findByMagicLinkTokenFactory, findByResetPasswordTokenFactory, findByIdFactory as findUserByIdFactory, getByIdFactory, updateUserFactory, } from "#src/repositories/user";
11
12
  import { createUserOrganizationFactory, deleteUserOrganizationFactory, findUserOrganizationFactory, getUserOrganizationFactory, updateUserOrganizationFactory, } from "#src/repositories/user_organisation";
12
13
  import {} from "pg";
@@ -62,6 +63,11 @@ export function createContext({ api_entreprise_client, api_insee_client, api_reg
62
63
  getById: getOrganizationByIdFactory({ pg }),
63
64
  upsert: upsertFactory({ pg }),
64
65
  },
66
+ recovery_words: {
67
+ create: createRecoveryWordsFactory({ pg }),
68
+ deleteByUserId: deleteRecoveryWordsByUserIdFactory({ pg }),
69
+ findByUserId: findRecoveryWordsByUserIdFactory({ pg }),
70
+ },
65
71
  users_organizations: {
66
72
  create: createUserOrganizationFactory({ pg }),
67
73
  delete: deleteUserOrganizationFactory({ pg }),
@@ -0,0 +1,44 @@
1
+ import type { IdentityVector } from "#src/types";
2
+ export declare function match_identity_to_dirigeant(identity: IdentityVector, dirigeants: IdentityVector[]): {
3
+ kind: "exact_match";
4
+ closest: {
5
+ dirigeant: {
6
+ birthcountry: string | null;
7
+ birthdate: Date | null;
8
+ birthplace: string | null;
9
+ family_name: string | null;
10
+ gender: "male" | "female" | null;
11
+ given_name: string | null;
12
+ };
13
+ matches: Set<"family_name" | "gender" | "birth_country" | "birth_date" | "birth_place" | "first_name">;
14
+ };
15
+ } | {
16
+ kind: "close_match";
17
+ closest: {
18
+ dirigeant: {
19
+ birthcountry: string | null;
20
+ birthdate: Date | null;
21
+ birthplace: string | null;
22
+ family_name: string | null;
23
+ gender: "male" | "female" | null;
24
+ given_name: string | null;
25
+ };
26
+ matches: Set<"family_name" | "gender" | "birth_country" | "birth_date" | "birth_place" | "first_name">;
27
+ };
28
+ } | {
29
+ kind: "below_threshold";
30
+ closest: {
31
+ dirigeant: {
32
+ birthcountry: string | null;
33
+ birthdate: Date | null;
34
+ birthplace: string | null;
35
+ family_name: string | null;
36
+ gender: "male" | "female" | null;
37
+ given_name: string | null;
38
+ };
39
+ matches: Set<"family_name" | "gender" | "birth_country" | "birth_date" | "birth_place" | "first_name">;
40
+ };
41
+ } | {
42
+ kind: "no_candidates";
43
+ };
44
+ //# sourceMappingURL=match-identity-to-dirigeant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match-identity-to-dirigeant.d.ts","sourceRoot":"","sources":["../../../src/managers/certification/match-identity-to-dirigeant.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAMjD,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,cAAc,EACxB,UAAU,EAAE,cAAc,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6B7B"}
@@ -0,0 +1,32 @@
1
+ //
2
+ import { match } from "ts-pattern";
3
+ import { certificationScore } from "./certification-score.js";
4
+ //
5
+ export function match_identity_to_dirigeant(identity, dirigeants) {
6
+ if (dirigeants.length === 0)
7
+ return { kind: "no_candidates" };
8
+ const [closest] = dirigeants
9
+ .map((dirigeant) => ({
10
+ dirigeant,
11
+ matches: certificationScore(identity, dirigeant),
12
+ }))
13
+ .toSorted((a, b) => b.matches.size - a.matches.size); // Sort by score descending (higher is better)
14
+ // According to the specification, only score of 5 (perfect match) is certified
15
+ return match(closest.matches.size)
16
+ .with(5, () => ({
17
+ kind: "exact_match",
18
+ closest,
19
+ }))
20
+ .with(4, () => ({
21
+ kind: "close_match",
22
+ closest,
23
+ }))
24
+ .with(3, () => ({
25
+ kind: "close_match",
26
+ closest,
27
+ }))
28
+ .otherwise(() => ({
29
+ kind: "below_threshold",
30
+ closest,
31
+ }));
32
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"process-certification-dirigeant.d.ts","sourceRoot":"","sources":["../../../src/managers/certification/process-certification-dirigeant.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAEL,KAAK,qBAAqB,EAE1B,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,CAAC,MAAM,QAAQ,CAAC;AASvB,eAAO,MAAM,gCAAgC;;;;EAI3C,CAAC;AAEH,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CACpD,OAAO,gCAAgC,CACxC,CAAC;AAWF,wBAAgB,yCAAyC,CACvD,UAAU,EAAE,gCAAgC,UAG7C;AAoED,wBAAgB,oCAAoC,CAAC,OAAO,EAAE,OAAO,IAMjE,cAAc,YAAY,EAC1B,wBAAwB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEhD"}
1
+ {"version":3,"file":"process-certification-dirigeant.d.ts","sourceRoot":"","sources":["../../../src/managers/certification/process-certification-dirigeant.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAClB,MAAM,YAAY,CAAC;AAEpB,OAAO,CAAC,MAAM,QAAQ,CAAC;AASvB,eAAO,MAAM,gCAAgC;;;;EAI3C,CAAC;AAEH,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CACpD,OAAO,gCAAgC,CACxC,CAAC;AAWF,wBAAgB,yCAAyC,CACvD,UAAU,EAAE,gCAAgC,UAG7C;AAmCD,wBAAgB,oCAAoC,CAAC,OAAO,EAAE,OAAO,IAMjE,cAAc,YAAY,EAC1B,wBAAwB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEhD"}
@@ -7,7 +7,7 @@ import * as ApiEntreprise from "./adapters/api_entreprise.js";
7
7
  import * as FranceConnect from "./adapters/franceconnect.js";
8
8
  import * as INSEE from "./adapters/insee.js";
9
9
  import * as RNE from "./adapters/rne.js";
10
- import { certificationScore } from "./certification-score.js";
10
+ import { match_identity_to_dirigeant } from "./match-identity-to-dirigeant.js";
11
11
  //
12
12
  export const CertificationDirigeantDataSource = z.enum([
13
13
  "api.insee.fr/api-sirene/private",
@@ -42,34 +42,6 @@ async function getMandatairesSociaux({ client: { api_entreprise, rne } }, siren)
42
42
  };
43
43
  }
44
44
  }
45
- function match_identity_to_dirigeant(identity, dirigeants) {
46
- if (dirigeants.length === 0)
47
- return { kind: "no_candidates" };
48
- const [closest] = dirigeants
49
- .map((dirigeant) => ({
50
- dirigeant,
51
- matches: certificationScore(identity, dirigeant),
52
- }))
53
- .toSorted((a, b) => b.matches.size - a.matches.size); // Sort by score descending (higher is better)
54
- // According to the specification, only score of 5 (perfect match) is certified
55
- return match(closest.matches.size)
56
- .with(5, () => ({
57
- kind: "exact_match",
58
- closest,
59
- }))
60
- .with(4, () => ({
61
- kind: "close_match",
62
- closest,
63
- }))
64
- .with(3, () => ({
65
- kind: "close_match",
66
- closest,
67
- }))
68
- .otherwise(() => ({
69
- kind: "below_threshold",
70
- closest,
71
- }));
72
- }
73
45
  export function processCertificationDirigeantFactory(context) {
74
46
  const { client: { insee }, } = context;
75
47
  return async function processCertificationDirigeant(organization, franceconnect_userinfo) {
@@ -1 +1 @@
1
- {"version":3,"file":"mark-domain-as-verified.d.ts","sourceRoot":"","sources":["../../../src/managers/organization/mark-domain-as-verified.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAGL,KAAK,oCAAoC,EAK1C,MAAM,YAAY,CAAC;AAOpB,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,IAQf,wDAIxC;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,oCAAoC,CAAC;CAChE;;;;;;;;;GAgFF;AAED,MAAM,MAAM,2BAA2B,GAAG,UAAU,CAClD,OAAO,2BAA2B,CACnC,CAAC"}
1
+ {"version":3,"file":"mark-domain-as-verified.d.ts","sourceRoot":"","sources":["../../../src/managers/organization/mark-domain-as-verified.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAGL,KAAK,oCAAoC,EAK1C,MAAM,YAAY,CAAC;AAOpB,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,IAQf,wDAIxC;IACD,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB,EAAE,oCAAoC,CAAC;CAChE;;;;;;;;;GAkFF;AAED,MAAM,MAAM,2BAA2B,GAAG,UAAU,CAClD,OAAO,2BAA2B,CACnC,CAAC"}
@@ -36,6 +36,7 @@ export function markDomainAsVerifiedFactory(context) {
36
36
  domain_verification_types: [
37
37
  ...EmailDomainApprovedVerificationValues,
38
38
  ...EmailDomainPendingVerificationValues,
39
+ ...EmailDomainRejectedVerificationValues,
39
40
  ],
40
41
  });
41
42
  return email_domains.addDomain({
@@ -49,6 +50,7 @@ export function markDomainAsVerifiedFactory(context) {
49
50
  organization_id,
50
51
  domain,
51
52
  domain_verification_types: [
53
+ ...EmailDomainApprovedVerificationValues,
52
54
  ...EmailDomainPendingVerificationValues,
53
55
  ...EmailDomainRejectedVerificationValues,
54
56
  ],
@@ -1 +1 @@
1
- {"version":3,"file":"get-moderation-by-id.d.ts","sourceRoot":"","sources":["../../../src/repositories/moderation/get-moderation-by-id.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAMnE,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAGtB,IAAI,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC,CAOzE"}
1
+ {"version":3,"file":"get-moderation-by-id.d.ts","sourceRoot":"","sources":["../../../src/repositories/moderation/get-moderation-by-id.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAKnE,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAGtB,IAAI,MAAM,KAAG,OAAO,CAAC,UAAU,CAAC,CAOzE"}
@@ -1,6 +1,6 @@
1
1
  //
2
+ import { ModerationNotFoundError } from "#src/errors";
2
3
  import {} from "#src/types";
3
- import { ModerationNotFoundError } from "@proconnect-gouv/proconnect.identite/errors";
4
4
  import { findModerationByIdFactory } from "./find-moderation-by-id.js";
5
5
  //
6
6
  export function getModerationByIdFactory({ pg }) {
@@ -1,5 +1,31 @@
1
- import type { DatabaseContext, User } from "#src/types";
2
- export declare function findUsersByOrganizationFactory({ pg }: DatabaseContext): (organization_id: number, additionalWhereClause?: string, additionalParams?: any[]) => Promise<(User & {
1
+ import type { DatabaseContext } from "#src/types";
2
+ export declare function findUsersByOrganizationFactory({ pg }: DatabaseContext): (organization_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
  is_external: boolean;
4
30
  verification_type: "domain" | "organization_dirigeant" | "code_sent_to_official_contact_email" | "imported_from_coop_mediation_numerique" | "imported_from_inclusion_connect" | "in_liste_dirigeants_rna" | "in_liste_dirigeants_rne" | "official_contact_email" | "ordre_professionnel_domain" | "proof_received" | "verified_by_coop_mediation_numerique" | "bypassed" | "domain_not_verified_yet" | "no_validation_means_available" | "no_verification_means_for_entreprise_unipersonnelle" | "no_verification_means_for_small_association" | "no_verification_means_for_small_organization";
5
31
  verified_at: Date | null;
@@ -1 +1 @@
1
- {"version":3,"file":"find-users-by-organization.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/find-users-by-organization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,eAAe,EACf,IAAI,EACL,MAAM,YAAY,CAAC;AAKpB,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAElE,iBAAiB,MAAM,EACvB,wBAAuB,MAAW,EAClC,mBAAkB,GAAG,EAAO;;;;;MAsB/B"}
1
+ {"version":3,"file":"find-users-by-organization.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/find-users-by-organization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,iBAAiB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAiBtE"}
@@ -1,10 +1,8 @@
1
1
  //
2
2
  //
3
3
  export function findUsersByOrganizationFactory({ pg }) {
4
- return async function findUsersByOrganization(organization_id, additionalWhereClause = "", additionalParams = []) {
5
- const connection = pg;
6
- const baseParams = [organization_id];
7
- const { rows } = await connection.query(`
4
+ return async function findUsersByOrganization(organization_id) {
5
+ const { rows } = await pg.query(`
8
6
  SELECT u.*,
9
7
  uo.is_external,
10
8
  uo.verification_type,
@@ -12,8 +10,7 @@ export function findUsersByOrganizationFactory({ pg }) {
12
10
  uo.has_been_greeted
13
11
  FROM users u
14
12
  INNER JOIN users_organizations AS uo ON uo.user_id = u.id
15
- WHERE uo.organization_id = $1
16
- ${additionalWhereClause}`, [...baseParams, ...additionalParams]);
13
+ WHERE uo.organization_id = $1`, [organization_id]);
17
14
  return rows;
18
15
  };
19
16
  }
@@ -0,0 +1,6 @@
1
+ import type { DatabaseContext, RecoveryWords } from "#src/types";
2
+ export declare function createRecoveryWordsFactory({ pg }: DatabaseContext): ({ user_id, hashed_words, }: {
3
+ user_id: number;
4
+ hashed_words: string;
5
+ }) => Promise<RecoveryWords>;
6
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/repositories/recovery-words/create.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKjE,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,4BAGvC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB,4BAaF"}
@@ -0,0 +1,14 @@
1
+ //
2
+ import {} from "pg";
3
+ //
4
+ export function createRecoveryWordsFactory({ pg }) {
5
+ return async function createRecoveryWords({ user_id, hashed_words, }) {
6
+ const { rows } = await pg.query(`
7
+ INSERT INTO recovery_words
8
+ (user_id, hashed_words)
9
+ VALUES
10
+ ($1, $2)
11
+ RETURNING *;`, [user_id, hashed_words]);
12
+ return rows.shift();
13
+ };
14
+ }
@@ -0,0 +1,3 @@
1
+ import type { DatabaseContext } from "#src/types";
2
+ export declare function deleteRecoveryWordsByUserIdFactory({ pg }: DatabaseContext): (user_id: number) => Promise<boolean>;
3
+ //# sourceMappingURL=delete-all-by-user-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delete-all-by-user-id.d.ts","sourceRoot":"","sources":["../../../src/repositories/recovery-words/delete-all-by-user-id.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAKlD,wBAAgB,kCAAkC,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,SAAS,MAAM,sBAWlE"}
@@ -0,0 +1,11 @@
1
+ //
2
+ //
3
+ export function deleteRecoveryWordsByUserIdFactory({ pg }) {
4
+ return async function deleteRecoveryWordsByUserId(user_id) {
5
+ const { rowCount, affectedRows } = (await pg.query(`
6
+ DELETE FROM recovery_words
7
+ WHERE user_id = $1
8
+ RETURNING *`, [user_id]));
9
+ return (affectedRows ?? rowCount ?? 0) > 0;
10
+ };
11
+ }
@@ -0,0 +1,3 @@
1
+ import type { DatabaseContext, RecoveryWords } from "#src/types";
2
+ export declare function findRecoveryWordsByUserIdFactory({ pg }: DatabaseContext): (user_id: number) => Promise<RecoveryWords | undefined>;
3
+ //# sourceMappingURL=find-by-user-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"find-by-user-id.d.ts","sourceRoot":"","sources":["../../../src/repositories/recovery-words/find-by-user-id.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAKjE,wBAAgB,gCAAgC,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,SAAS,MAAM,wCAWhE"}
@@ -0,0 +1,12 @@
1
+ //
2
+ import {} from "pg";
3
+ //
4
+ export function findRecoveryWordsByUserIdFactory({ pg }) {
5
+ return async function findRecoveryWordsByUserId(user_id) {
6
+ const { rows } = await pg.query(`
7
+ SELECT *
8
+ FROM recovery_words
9
+ WHERE user_id = $1;`, [user_id]);
10
+ return rows.shift();
11
+ };
12
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./create.js";
2
+ export * from "./delete-all-by-user-id.js";
3
+ export * from "./find-by-user-id.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repositories/recovery-words/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAC;AAC5B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,4 @@
1
+ //
2
+ export * from "./create.js";
3
+ export * from "./delete-all-by-user-id.js";
4
+ export * from "./find-by-user-id.js";