@proconnect-gouv/proconnect.identite 15.0.0 → 17.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/connectors/index.d.ts +2 -72
  3. package/dist/connectors/index.d.ts.map +1 -1
  4. package/dist/connectors/index.js +5 -14
  5. package/dist/managers/certification/certification-score.d.ts +16 -0
  6. package/dist/managers/certification/certification-score.d.ts.map +1 -1
  7. package/dist/managers/certification/certification-score.js +65 -41
  8. package/dist/managers/certification/process-certification-dirigeant.d.ts.map +1 -1
  9. package/dist/managers/organization/get-organization-info.d.ts.map +1 -1
  10. package/dist/repositories/authenticator/delete-all-authenticators-by-user-id.d.ts +3 -0
  11. package/dist/repositories/authenticator/delete-all-authenticators-by-user-id.d.ts.map +1 -0
  12. package/dist/repositories/authenticator/delete-all-authenticators-by-user-id.js +12 -0
  13. package/dist/repositories/authenticator/index.d.ts +1 -1
  14. package/dist/repositories/authenticator/index.d.ts.map +1 -1
  15. package/dist/repositories/authenticator/index.js +1 -1
  16. package/dist/repositories/moderation/index.d.ts +0 -2
  17. package/dist/repositories/moderation/index.d.ts.map +1 -1
  18. package/dist/repositories/moderation/index.js +0 -2
  19. package/dist/repositories/oidc-client/upsert-authorization-request.d.ts +1 -1
  20. package/dist/repositories/oidc-client/upsert-authorization-request.d.ts.map +1 -1
  21. package/dist/repositories/oidc-client/upsert-authorization-request.js +6 -4
  22. package/dist/repositories/organization/index.d.ts +0 -2
  23. package/dist/repositories/organization/index.d.ts.map +1 -1
  24. package/dist/repositories/organization/index.js +0 -2
  25. package/dist/repositories/user/index.d.ts +0 -1
  26. package/dist/repositories/user/index.d.ts.map +1 -1
  27. package/dist/repositories/user/index.js +0 -1
  28. package/dist/services/organization/get-membership-changes-by-domain-verification.d.ts +18 -0
  29. package/dist/services/organization/get-membership-changes-by-domain-verification.d.ts.map +1 -0
  30. package/dist/services/organization/get-membership-changes-by-domain-verification.js +21 -0
  31. package/dist/services/organization/index.d.ts +1 -1
  32. package/dist/services/organization/index.d.ts.map +1 -1
  33. package/dist/services/organization/index.js +1 -1
  34. package/dist/types/authenticator.d.ts.map +1 -1
  35. package/dist/types/authorization-request.d.ts +2 -0
  36. package/dist/types/authorization-request.d.ts.map +1 -1
  37. package/dist/types/authorization-request.js +4 -1
  38. package/package.json +2 -2
  39. package/src/connectors/index.ts +2 -17
  40. package/src/managers/certification/certification-score.test.ts +64 -1
  41. package/src/managers/certification/certification-score.ts +84 -50
  42. package/src/managers/certification/process-certification-dirigeant.ts +1 -2
  43. package/src/managers/organization/get-organization-info.ts +1 -2
  44. package/src/repositories/authenticator/delete-all-authenticators-by-user-id.test.ts +51 -0
  45. package/src/repositories/authenticator/delete-all-authenticators-by-user-id.ts +22 -0
  46. package/src/repositories/authenticator/index.ts +1 -1
  47. package/src/repositories/moderation/index.ts +0 -2
  48. package/src/repositories/oidc-client/upsert-authorization-request.test.ts +18 -5
  49. package/src/repositories/oidc-client/upsert-authorization-request.ts +6 -3
  50. package/src/repositories/organization/index.ts +0 -2
  51. package/src/repositories/user/index.ts +0 -1
  52. package/src/services/organization/get-membership-changes-by-domain-verification.test.ts +91 -0
  53. package/src/services/organization/get-membership-changes-by-domain-verification.ts +46 -0
  54. package/src/services/organization/index.ts +1 -1
  55. package/src/types/authenticator.ts +1 -7
  56. package/src/types/authorization-request.ts +5 -1
  57. package/testing/index.ts +2 -1
  58. package/dist/repositories/authenticator/update-authenticator.d.ts +0 -3
  59. package/dist/repositories/authenticator/update-authenticator.d.ts.map +0 -1
  60. package/dist/repositories/authenticator/update-authenticator.js +0 -13
  61. package/dist/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.d.ts +0 -3
  62. package/dist/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.d.ts.map +0 -1
  63. package/dist/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.js +0 -15
  64. package/dist/repositories/email-deliverability-whitelist/index.d.ts +0 -2
  65. package/dist/repositories/email-deliverability-whitelist/index.d.ts.map +0 -1
  66. package/dist/repositories/email-deliverability-whitelist/index.js +0 -2
  67. package/dist/repositories/moderation/find-pending-moderation.d.ts +0 -20
  68. package/dist/repositories/moderation/find-pending-moderation.d.ts.map +0 -1
  69. package/dist/repositories/moderation/find-pending-moderation.js +0 -16
  70. package/dist/repositories/moderation/find-rejected-moderation.d.ts +0 -20
  71. package/dist/repositories/moderation/find-rejected-moderation.d.ts.map +0 -1
  72. package/dist/repositories/moderation/find-rejected-moderation.js +0 -17
  73. package/dist/repositories/organization/find-by-siret.d.ts +0 -3
  74. package/dist/repositories/organization/find-by-siret.d.ts.map +0 -1
  75. package/dist/repositories/organization/find-by-siret.js +0 -13
  76. package/dist/repositories/organization/find-pending-by-user-id.d.ts +0 -6
  77. package/dist/repositories/organization/find-pending-by-user-id.d.ts.map +0 -1
  78. package/dist/repositories/organization/find-pending-by-user-id.js +0 -18
  79. package/dist/repositories/user/find-by-reset-password-token.d.ts +0 -29
  80. package/dist/repositories/user/find-by-reset-password-token.d.ts.map +0 -1
  81. package/dist/repositories/user/find-by-reset-password-token.js +0 -12
  82. package/dist/services/organization/get-member-ids-promoted-by-domain.d.ts +0 -9
  83. package/dist/services/organization/get-member-ids-promoted-by-domain.d.ts.map +0 -1
  84. package/dist/services/organization/get-member-ids-promoted-by-domain.js +0 -11
  85. package/src/repositories/authenticator/update-authenticator.test.ts +0 -41
  86. package/src/repositories/authenticator/update-authenticator.ts +0 -29
  87. package/src/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.test.ts +0 -45
  88. package/src/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.ts +0 -24
  89. package/src/repositories/email-deliverability-whitelist/index.ts +0 -3
  90. package/src/repositories/moderation/find-pending-moderation.test.ts +0 -57
  91. package/src/repositories/moderation/find-pending-moderation.ts +0 -35
  92. package/src/repositories/moderation/find-rejected-moderation.test.ts +0 -57
  93. package/src/repositories/moderation/find-rejected-moderation.ts +0 -37
  94. package/src/repositories/organization/find-by-siret.test.ts +0 -35
  95. package/src/repositories/organization/find-by-siret.ts +0 -21
  96. package/src/repositories/organization/find-pending-by-user-id.test.ts +0 -51
  97. package/src/repositories/organization/find-pending-by-user-id.ts +0 -27
  98. package/src/repositories/user/find-by-reset-password-token.test.ts +0 -37
  99. package/src/repositories/user/find-by-reset-password-token.ts +0 -20
  100. package/src/services/organization/get-member-ids-promoted-by-domain.test.ts +0 -100
  101. package/src/services/organization/get-member-ids-promoted-by-domain.ts +0 -27
@@ -0,0 +1,91 @@
1
+ //
2
+
3
+ import { getMembershipChangesByDomainVerification } from "#src/services/organization";
4
+ import assert from "node:assert/strict";
5
+ import { describe, it } from "node:test";
6
+
7
+ //
8
+
9
+ const unverified_darkangels = [
10
+ {
11
+ email: "lion.eljonson@darkangels.world",
12
+ verification_type: "no_validation_means_available",
13
+ },
14
+ {
15
+ email: "cat.eljonson@darkangels.world",
16
+ verification_type: "no_verification_means_for_entreprise_unipersonnelle",
17
+ },
18
+ {
19
+ email: "tiger.eljonson@darkangels.world",
20
+ verification_type: "no_verification_means_for_small_association",
21
+ },
22
+ {
23
+ email: "wolf.eljonson@darkangels.world",
24
+ verification_type: "no_verification_means_for_small_organization",
25
+ },
26
+ {
27
+ email: "mouse.eljonson@darkangels.world",
28
+ verification_type: "domain_not_verified_yet",
29
+ },
30
+ ];
31
+
32
+ const verified_darkangels = [
33
+ {
34
+ email: "luther@darkangels.world",
35
+ verification_type: "organization_dirigeant",
36
+ },
37
+ { email: "azrael@darkangels.world", verification_type: "domain" },
38
+ {
39
+ email: "belial@darkangels.world",
40
+ verification_type: "official_contact_email",
41
+ },
42
+ ];
43
+
44
+ const other_domains = [
45
+ {
46
+ email: "leman.russ@spacewolves.world",
47
+ verification_type: "no_validation_means_available",
48
+ },
49
+ {
50
+ email: "cypher@fallen.darkangels.world",
51
+ verification_type: "no_validation_means_available",
52
+ },
53
+ ];
54
+
55
+ const members = [
56
+ ...unverified_darkangels,
57
+ ...verified_darkangels,
58
+ ...other_domains,
59
+ ];
60
+
61
+ describe("getMembershipChangesByDomainVerification", () => {
62
+ it("should promote the unverified and super weak members of an approved domain", () => {
63
+ assert.deepEqual(
64
+ getMembershipChangesByDomainVerification({
65
+ domain: "darkangels.world",
66
+ members,
67
+ verification_type: "verified",
68
+ }),
69
+ {
70
+ kind: "domain_approved",
71
+ promoted_members: unverified_darkangels,
72
+ verification_type: "verified",
73
+ },
74
+ );
75
+ });
76
+
77
+ it("should remove every member of a refused domain, whatever their link", () => {
78
+ assert.deepEqual(
79
+ getMembershipChangesByDomainVerification({
80
+ domain: "darkangels.world",
81
+ members,
82
+ verification_type: "refused",
83
+ }),
84
+ {
85
+ kind: "domain_refused",
86
+ removed_members: [...unverified_darkangels, ...verified_darkangels],
87
+ verification_type: "refused",
88
+ },
89
+ );
90
+ });
91
+ });
@@ -0,0 +1,46 @@
1
+ //
2
+
3
+ import {
4
+ EmailDomainApprovedVerificationValues,
5
+ EmailDomainRejectedVerificationValues,
6
+ SuperWeakLinkEnum,
7
+ UnverifiedLinkEnum,
8
+ type EmailDomainNoPendingVerificationType,
9
+ } from "#src/types";
10
+ import { getEmailDomain } from "@proconnect-gouv/proconnect.core/services/email";
11
+ import { match } from "ts-pattern";
12
+
13
+ //
14
+
15
+ export function getMembershipChangesByDomainVerification<
16
+ Member extends { email: string; verification_type: string },
17
+ >({
18
+ domain,
19
+ members,
20
+ verification_type,
21
+ }: {
22
+ domain: string;
23
+ members: ReadonlyArray<Member>;
24
+ verification_type: EmailDomainNoPendingVerificationType;
25
+ }) {
26
+ const domain_members = members.filter(
27
+ ({ email }) => getEmailDomain(email) === domain,
28
+ );
29
+
30
+ return match(verification_type)
31
+ .with(...EmailDomainApprovedVerificationValues, (verification_type) => ({
32
+ kind: "domain_approved" as const,
33
+ promoted_members: domain_members.filter(
34
+ ({ verification_type }) =>
35
+ UnverifiedLinkEnum.safeParse(verification_type).success ||
36
+ SuperWeakLinkEnum.safeParse(verification_type).success,
37
+ ),
38
+ verification_type,
39
+ }))
40
+ .with(...EmailDomainRejectedVerificationValues, (verification_type) => ({
41
+ kind: "domain_refused" as const,
42
+ removed_members: domain_members,
43
+ verification_type,
44
+ }))
45
+ .exhaustive();
46
+ }
@@ -1,7 +1,7 @@
1
1
  //
2
2
 
3
3
  export * from "./compute-service-public-info.js";
4
- export * from "./get-member-ids-promoted-by-domain.js";
4
+ export * from "./get-membership-changes-by-domain-verification.js";
5
5
  export * from "./is-domain-allowed-for-organization.js";
6
6
  export * from "./is-entreprise-unipersonnelle.js";
7
7
  export * from "./is-organization-covered-by-certification-dirigeant.js";
@@ -2,13 +2,7 @@
2
2
 
3
3
  export type Base64URLString = string;
4
4
  export type AuthenticatorTransportFuture =
5
- | "ble"
6
- | "cable"
7
- | "hybrid"
8
- | "internal"
9
- | "nfc"
10
- | "smart-card"
11
- | "usb";
5
+ "ble" | "cable" | "hybrid" | "internal" | "nfc" | "smart-card" | "usb";
12
6
  export type CredentialDeviceType = "singleDevice" | "multiDevice";
13
7
 
14
8
  //
@@ -1,6 +1,9 @@
1
1
  import { z } from "zod";
2
2
 
3
- export const AuthorizationRequestOutcomeEnum = z.enum(["succeeded"]);
3
+ export const AuthorizationRequestOutcomeEnum = z.enum([
4
+ "signed_out",
5
+ "succeeded",
6
+ ]);
4
7
 
5
8
  export type AuthorizationRequestOutcome = z.output<
6
9
  typeof AuthorizationRequestOutcomeEnum
@@ -14,6 +17,7 @@ export interface BaseAuthorizationRequest {
14
17
  user_ip_address: string | null;
15
18
  interaction_cid: string | null;
16
19
  outcome: AuthorizationRequestOutcome | null;
20
+ sid: string | null;
17
21
  }
18
22
 
19
23
  export interface AuthorizationRequest extends BaseAuthorizationRequest {
package/testing/index.ts CHANGED
@@ -9,7 +9,7 @@ import type {
9
9
  import type { FindPouvoirsBySirenHandler } from "@proconnect-gouv/proconnect.registre_national_entreprises/api";
10
10
  import { noop } from "lodash-es";
11
11
  import { runner } from "node-pg-migrate";
12
- import { mock } from "node:test";
12
+ import { after, mock } from "node:test";
13
13
  import { join } from "path";
14
14
  import type { Pool } from "pg";
15
15
  import type { FindUniteLegaleBySirenHandler } from "../../insee/src/api/find-by-siren.js";
@@ -19,6 +19,7 @@ import { createContext } from "../src/connectors/index.js";
19
19
  //
20
20
 
21
21
  export const pg = new PGlite();
22
+ after(() => pg.close());
22
23
 
23
24
  export async function migrate() {
24
25
  await runner({
@@ -1,3 +0,0 @@
1
- import type { Authenticator, Base64URLString, BaseAuthenticator, DatabaseContext } from "#src/types";
2
- export declare function updateAuthenticatorFactory({ pg }: DatabaseContext): (credential_id: Base64URLString, { counter, last_used_at, usage_count }: Partial<BaseAuthenticator>) => Promise<Authenticator>;
3
- //# sourceMappingURL=update-authenticator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"update-authenticator.d.ts","sourceRoot":"","sources":["../../../src/repositories/authenticator/update-authenticator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,EAChB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAE9D,eAAe,eAAe,EAC9B,wCAAwC,OAAO,CAAC,iBAAiB,CAAC,4BAarE"}
@@ -1,13 +0,0 @@
1
- //
2
- import {} from "pg";
3
- //
4
- export function updateAuthenticatorFactory({ pg }) {
5
- return async function updateAuthenticator(credential_id, { counter, last_used_at, usage_count }) {
6
- const { rows } = await pg.query(`
7
- UPDATE authenticators
8
- SET counter = $2, last_used_at = $3, usage_count = $4
9
- WHERE credential_id = $1
10
- RETURNING *`, [credential_id, counter, last_used_at, usage_count]);
11
- return rows.shift();
12
- };
13
- }
@@ -1,3 +0,0 @@
1
- import { type DatabaseContext } from "#src/types";
2
- export declare function findEmailInDeliverabilityWhiteListFactory({ pg, }: DatabaseContext): (email: string) => Promise<{} | undefined>;
3
- //# sourceMappingURL=find-email-in-deliverability-white-list.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-email-in-deliverability-white-list.d.ts","sourceRoot":"","sources":["../../../src/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAMlD,wBAAgB,yCAAyC,CAAC,EACxD,EAAE,GACH,EAAE,eAAe,IACyC,OAAO,MAAM,6BAYvE"}
@@ -1,15 +0,0 @@
1
- //
2
- import {} from "#src/types";
3
- import { getEmailDomain } from "@proconnect-gouv/proconnect.core/services/email";
4
- import {} from "pg";
5
- //
6
- export function findEmailInDeliverabilityWhiteListFactory({ pg, }) {
7
- return async function findEmailInDeliverabilityWhiteList(email) {
8
- const domain = getEmailDomain(email);
9
- const { rows } = await pg.query(`
10
- SELECT *
11
- FROM email_deliverability_whitelist WHERE email_domain = $1
12
- `, [domain]);
13
- return rows.shift();
14
- };
15
- }
@@ -1,2 +0,0 @@
1
- export * from "./find-email-in-deliverability-white-list.js";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repositories/email-deliverability-whitelist/index.ts"],"names":[],"mappings":"AAEA,cAAc,8CAA8C,CAAC"}
@@ -1,2 +0,0 @@
1
- //
2
- export * from "./find-email-in-deliverability-white-list.js";
@@ -1,20 +0,0 @@
1
- import { type DatabaseContext, type ModerationType } from "#src/types";
2
- export declare function findPendingModerationFactory({ pg }: DatabaseContext): ({ user_id, organization_id, type, }: {
3
- user_id: number;
4
- organization_id: number;
5
- type: ModerationType;
6
- }) => Promise<{
7
- id: number;
8
- user_id: number;
9
- organization_id: number;
10
- ticket_id: string | null;
11
- type: "non_verified_domain" | "organization_join_block";
12
- created_at: Date;
13
- moderated_at: Date | null;
14
- comment: string | null;
15
- moderated_by: string | null;
16
- status: "accepted" | "pending" | "rejected" | "reopened" | "unknown";
17
- end_user_reason: string;
18
- allow_editing: boolean;
19
- } | undefined>;
20
- //# sourceMappingURL=find-pending-moderation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-pending-moderation.d.ts","sourceRoot":"","sources":["../../../src/repositories/moderation/find-pending-moderation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,qCAIzC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,cAAc,CAAC;CACtB;;;;;;;;;;;;;eAcF"}
@@ -1,16 +0,0 @@
1
- //
2
- import {} from "#src/types";
3
- import {} from "pg";
4
- //
5
- export function findPendingModerationFactory({ pg }) {
6
- return async function findPendingModeration({ user_id, organization_id, type, }) {
7
- const { rows } = await pg.query(`
8
- SELECT *
9
- FROM moderations
10
- WHERE user_id = $1
11
- AND organization_id = $2
12
- AND type = $3
13
- AND moderated_at IS NULL;`, [user_id, organization_id, type]);
14
- return rows.shift();
15
- };
16
- }
@@ -1,20 +0,0 @@
1
- import { type DatabaseContext, type ModerationType } from "#src/types";
2
- export declare function findRejectedModerationFactory({ pg }: DatabaseContext): ({ user_id, organization_id, type, }: {
3
- user_id: number;
4
- organization_id: number;
5
- type: ModerationType;
6
- }) => Promise<{
7
- id: number;
8
- user_id: number;
9
- organization_id: number;
10
- ticket_id: string | null;
11
- type: "non_verified_domain" | "organization_join_block";
12
- created_at: Date;
13
- moderated_at: Date | null;
14
- comment: string | null;
15
- moderated_by: string | null;
16
- status: "accepted" | "pending" | "rejected" | "reopened" | "unknown";
17
- end_user_reason: string;
18
- allow_editing: boolean;
19
- } | undefined>;
20
- //# sourceMappingURL=find-rejected-moderation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-rejected-moderation.d.ts","sourceRoot":"","sources":["../../../src/repositories/moderation/find-rejected-moderation.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EAEpB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,qCAI1C;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,cAAc,CAAC;CACtB;;;;;;;;;;;;;eAeF"}
@@ -1,17 +0,0 @@
1
- //
2
- import { ModerationStatusSchema, } from "#src/types";
3
- import {} from "pg";
4
- //
5
- export function findRejectedModerationFactory({ pg }) {
6
- return async function findRejectedModeration({ user_id, organization_id, type, }) {
7
- const { rows } = await pg.query(`
8
- SELECT *
9
- FROM moderations
10
- WHERE user_id = $1
11
- AND organization_id = $2
12
- AND type = $3
13
- AND moderated_at IS NOT NULL
14
- AND status = $4;`, [user_id, organization_id, type, ModerationStatusSchema.enum.rejected]);
15
- return rows.shift();
16
- };
17
- }
@@ -1,3 +0,0 @@
1
- import type { DatabaseContext, Organization } from "#src/types";
2
- export declare function findBySiretFactory({ pg }: DatabaseContext): (siret: string) => Promise<Organization | undefined>;
3
- //# sourceMappingURL=find-by-siret.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-by-siret.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/find-by-siret.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAKhE,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,OAAO,MAAM,uCAYhD"}
@@ -1,13 +0,0 @@
1
- //
2
- import {} from "pg";
3
- //
4
- export function findBySiretFactory({ pg }) {
5
- return async function findBySiret(siret) {
6
- const { rows } = await pg.query(`
7
- SELECT *
8
- FROM organizations
9
- WHERE siret = $1
10
- `, [siret]);
11
- return rows.shift();
12
- };
13
- }
@@ -1,6 +0,0 @@
1
- import type { DatabaseContext } from "#src/types";
2
- import { type Organization } from "#src/types";
3
- export declare function findPendingByUserIdFactory({ pg }: DatabaseContext): (user_id: number) => Promise<(Organization & {
4
- moderation_id: number;
5
- })[]>;
6
- //# sourceMappingURL=find-pending-by-user-id.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find-pending-by-user-id.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/find-pending-by-user-id.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAKrE,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,SAAS,MAAM;mBACK,MAAM;MAgBrE"}
@@ -1,18 +0,0 @@
1
- //
2
- import { ModerationTypeSchema } from "#src/types";
3
- import {} from "pg";
4
- //
5
- export function findPendingByUserIdFactory({ pg }) {
6
- return async function findPendingByUserId(user_id) {
7
- const { rows } = await pg.query(`
8
- SELECT o.*, m.id as moderation_id
9
- FROM moderations m
10
- INNER JOIN organizations o on o.id = m.organization_id
11
- WHERE m.user_id = $1
12
- AND m.type = $2
13
- AND m.moderated_at IS NULL
14
- ORDER BY m.created_at
15
- `, [user_id, ModerationTypeSchema.enum.organization_join_block]);
16
- return rows;
17
- };
18
- }
@@ -1,29 +0,0 @@
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>;
29
- //# sourceMappingURL=find-by-reset-password-token.d.ts.map
@@ -1 +0,0 @@
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,12 +0,0 @@
1
- //
2
- import {} from "pg";
3
- //
4
- export function findByResetPasswordTokenFactory({ pg }) {
5
- return async function findByResetPasswordToken(reset_password_token) {
6
- const { rows } = await pg.query(`
7
- SELECT *
8
- FROM users WHERE reset_password_token = $1
9
- `, [reset_password_token]);
10
- return rows.shift();
11
- };
12
- }
@@ -1,9 +0,0 @@
1
- export declare function getMemberIdsPromotedByDomain({ domain, members, }: {
2
- domain: string;
3
- members: ReadonlyArray<{
4
- email: string;
5
- id: number;
6
- verification_type: string;
7
- }>;
8
- }): number[];
9
- //# sourceMappingURL=get-member-ids-promoted-by-domain.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-member-ids-promoted-by-domain.d.ts","sourceRoot":"","sources":["../../../src/services/organization/get-member-ids-promoted-by-domain.ts"],"names":[],"mappings":"AAOA,wBAAgB,4BAA4B,CAAC,EAC3C,MAAM,EACN,OAAO,GACR,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,aAAa,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC,CAAC;CACJ,YASA"}
@@ -1,11 +0,0 @@
1
- //
2
- import { SuperWeakLinkEnum, UnverifiedLinkEnum } from "#src/types";
3
- import { getEmailDomain } from "@proconnect-gouv/proconnect.core/services/email";
4
- //
5
- export function getMemberIdsPromotedByDomain({ domain, members, }) {
6
- return members
7
- .filter(({ email, verification_type }) => getEmailDomain(email) === domain &&
8
- (UnverifiedLinkEnum.safeParse(verification_type).success ||
9
- SuperWeakLinkEnum.safeParse(verification_type).success))
10
- .map(({ id }) => id);
11
- }
@@ -1,41 +0,0 @@
1
- //
2
-
3
- import { emptyDatabase, migrate, pg } from "#testing";
4
- import assert from "node:assert/strict";
5
- import { before, beforeEach, suite, test } from "node:test";
6
- import { updateAuthenticatorFactory } from "./update-authenticator.js";
7
-
8
- //
9
-
10
- const updateAuthenticator = updateAuthenticatorFactory({ pg: pg as any });
11
-
12
- suite("updateAuthenticatorFactory", () => {
13
- before(migrate);
14
- beforeEach(emptyDatabase);
15
-
16
- test("should update and return the authenticator", async () => {
17
- await pg.sql`
18
- INSERT INTO users
19
- (id, email, created_at, updated_at, given_name, family_name, phone_number, job)
20
- VALUES
21
- (1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque')
22
- ;
23
- `;
24
- await pg.sql`
25
- INSERT INTO authenticators
26
- (credential_id, credential_public_key, counter, credential_backed_up, user_id, usage_count, user_verified, last_used_at)
27
- VALUES
28
- ('CRED1', '\\x00', 0, false, 1, 0, true, '4444-04-04')
29
- ;
30
- `;
31
-
32
- const result = await updateAuthenticator("CRED1", {
33
- counter: 7,
34
- last_used_at: new Date("4444-04-05"),
35
- usage_count: 3,
36
- });
37
-
38
- assert.equal(result.counter, 7);
39
- assert.equal(result.usage_count, 3);
40
- });
41
- });
@@ -1,29 +0,0 @@
1
- //
2
-
3
- import type {
4
- Authenticator,
5
- Base64URLString,
6
- BaseAuthenticator,
7
- DatabaseContext,
8
- } from "#src/types";
9
- import { type QueryResult } from "pg";
10
-
11
- //
12
-
13
- export function updateAuthenticatorFactory({ pg }: DatabaseContext) {
14
- return async function updateAuthenticator(
15
- credential_id: Base64URLString,
16
- { counter, last_used_at, usage_count }: Partial<BaseAuthenticator>,
17
- ) {
18
- const { rows }: QueryResult<Authenticator> = await pg.query(
19
- `
20
- UPDATE authenticators
21
- SET counter = $2, last_used_at = $3, usage_count = $4
22
- WHERE credential_id = $1
23
- RETURNING *`,
24
- [credential_id, counter, last_used_at, usage_count],
25
- );
26
-
27
- return rows.shift()!;
28
- };
29
- }
@@ -1,45 +0,0 @@
1
- //
2
-
3
- import { emptyDatabase, migrate, pg } from "#testing";
4
- import assert from "node:assert/strict";
5
- import { before, beforeEach, suite, test } from "node:test";
6
- import { findEmailInDeliverabilityWhiteListFactory } from "./find-email-in-deliverability-white-list.js";
7
-
8
- //
9
-
10
- const findEmailInDeliverabilityWhiteList =
11
- findEmailInDeliverabilityWhiteListFactory({ pg: pg as any });
12
-
13
- suite("findEmailInDeliverabilityWhiteListFactory", () => {
14
- before(migrate);
15
- beforeEach(emptyDatabase);
16
-
17
- test("should return undefined when the domain is not whitelisted", async () => {
18
- const result = await findEmailInDeliverabilityWhiteList(
19
- "lion@darkangels.world",
20
- );
21
-
22
- assert.equal(result, undefined);
23
- });
24
-
25
- test("should return the whitelist entry when the domain matches", async () => {
26
- await pg.sql`
27
- INSERT INTO email_deliverability_whitelist
28
- (problematic_email, email_domain)
29
- VALUES
30
- ('lion@darkangels.world', 'darkangels.world')
31
- ;
32
- `;
33
-
34
- const result = await findEmailInDeliverabilityWhiteList(
35
- "lion@darkangels.world",
36
- );
37
-
38
- assert.deepEqual(result, {
39
- problematic_email: "lion@darkangels.world",
40
- email_domain: "darkangels.world",
41
- verified_at: result?.verified_at,
42
- verified_by: null,
43
- });
44
- });
45
- });
@@ -1,24 +0,0 @@
1
- //
2
-
3
- import { type DatabaseContext } from "#src/types";
4
- import { getEmailDomain } from "@proconnect-gouv/proconnect.core/services/email";
5
- import { type QueryResult } from "pg";
6
-
7
- //
8
-
9
- export function findEmailInDeliverabilityWhiteListFactory({
10
- pg,
11
- }: DatabaseContext) {
12
- return async function findEmailInDeliverabilityWhiteList(email: string) {
13
- const domain = getEmailDomain(email);
14
- const { rows }: QueryResult<{}> = await pg.query(
15
- `
16
- SELECT *
17
- FROM email_deliverability_whitelist WHERE email_domain = $1
18
- `,
19
- [domain],
20
- );
21
-
22
- return rows.shift();
23
- };
24
- }
@@ -1,3 +0,0 @@
1
- //
2
-
3
- export * from "./find-email-in-deliverability-white-list.js";