@proconnect-gouv/proconnect.identite 9.0.0 → 9.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.
- package/CHANGELOG.md +25 -0
- package/dist/managers/organization/mark-domain-as-verified.js +7 -7
- package/dist/managers/user/assign-user-verification-type-to-domain.d.ts.map +1 -1
- package/dist/managers/user/assign-user-verification-type-to-domain.js +4 -6
- package/dist/types/email-domain.d.ts +23 -10
- package/dist/types/email-domain.d.ts.map +1 -1
- package/dist/types/email-domain.js +14 -11
- package/dist/types/moderation.d.ts +1 -1
- package/dist/types/moderation.js +1 -1
- package/dist/types/user-organization-link.d.ts +30 -6
- package/dist/types/user-organization-link.d.ts.map +1 -1
- package/dist/types/user-organization-link.js +17 -11
- package/package.json +1 -1
- package/src/managers/organization/mark-domain-as-verified.ts +9 -9
- package/src/managers/user/assign-user-verification-type-to-domain.ts +4 -6
- package/src/repositories/organization/link-user-to-organization.test.ts +3 -3
- package/src/types/email-domain.ts +28 -16
- package/src/types/moderation.ts +1 -1
- package/src/types/user-organization-link.ts +21 -12
- package/tsconfig.lib.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# @proconnect-gouv/proconnect.identite
|
|
2
2
|
|
|
3
|
+
## 9.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1931](https://github.com/proconnect-gouv/proconnect-identite/pull/1931) [`40be4f7`](https://github.com/proconnect-gouv/proconnect-identite/commit/40be4f7cdd4ce339637e28155a4163edfc14848c) Thanks [@rebeccadumazert](https://github.com/rebeccadumazert)! - 🗃️ Renseigne allow_editing à true pour les modérations avec un motif de refus connu
|
|
8
|
+
|
|
9
|
+
## 9.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#1934](https://github.com/proconnect-gouv/proconnect-identite/pull/1934) [`169a4a5`](https://github.com/proconnect-gouv/proconnect-identite/commit/169a4a5927ef29b90c9a155433c9b2a5cfff2ca6) Thanks [@douglasduteil](https://github.com/douglasduteil)! - ♻️ Les exports `*Types` sont renommés selon une convention uniforme : tableaux `as const` → `*Values`, schémas Zod → `*Enum`.
|
|
14
|
+
|
|
15
|
+
| Avant | Après |
|
|
16
|
+
| --------------------------------------- | ------------------------------------------------------------------------------- |
|
|
17
|
+
| `LinkTypes` | `LinkEnum` |
|
|
18
|
+
| `StrongLinkTypes` | `StrongLinkValues` |
|
|
19
|
+
| `WeakLinkTypes` | `WeakLinkValues` |
|
|
20
|
+
| `SuperWeakLinkTypes` | `SuperWeakLinkValues` + `SuperWeakLinkEnum` |
|
|
21
|
+
| `UnverifiedLinkTypes` | `UnverifiedLinkValues` + `UnverifiedLinkEnum` |
|
|
22
|
+
| `EmailDomainApprovedVerificationTypes` | `EmailDomainApprovedVerificationEnum` |
|
|
23
|
+
| `EmailDomainPendingVerificationTypes` | `EmailDomainPendingVerificationValues` + `EmailDomainPendingVerificationEnum` |
|
|
24
|
+
| `EmailDomainRejectedVerificationTypes` | `EmailDomainRejectedVerificationValues` + `EmailDomainRejectedVerificationEnum` |
|
|
25
|
+
| `EmailDomainNoPendingVerificationTypes` | `EmailDomainNoPendingVerificationEnum` |
|
|
26
|
+
| `EmailDomainVerificationTypes` | `EmailDomainVerificationEnum` |
|
|
27
|
+
|
|
3
28
|
## 9.0.0
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//
|
|
2
2
|
import { NotFoundError } from "#src/errors";
|
|
3
3
|
import { assignUserVerificationTypeToDomainFactory } from "#src/managers/user";
|
|
4
|
-
import {
|
|
4
|
+
import { EmailDomainApprovedVerificationValues, EmailDomainPendingVerificationValues, EmailDomainRejectedVerificationValues, } from "#src/types";
|
|
5
5
|
import { isEmpty } from "lodash-es";
|
|
6
6
|
import { match } from "ts-pattern";
|
|
7
7
|
//
|
|
@@ -14,7 +14,7 @@ export function markDomainAsVerifiedFactory(context) {
|
|
|
14
14
|
throw new NotFoundError();
|
|
15
15
|
}
|
|
16
16
|
return match(domain_verification_type)
|
|
17
|
-
.with(...
|
|
17
|
+
.with(...EmailDomainApprovedVerificationValues, async (approved_verification_type) => {
|
|
18
18
|
await assignUserVerificationTypeToDomain(organization_id, domain);
|
|
19
19
|
return markDomainAsApproved({
|
|
20
20
|
organization_id,
|
|
@@ -22,7 +22,7 @@ export function markDomainAsVerifiedFactory(context) {
|
|
|
22
22
|
domain_verification_type: approved_verification_type,
|
|
23
23
|
});
|
|
24
24
|
})
|
|
25
|
-
.with(...
|
|
25
|
+
.with(...EmailDomainRejectedVerificationValues, (rejected_verification_type) => markDomainAsRejected({
|
|
26
26
|
organization_id,
|
|
27
27
|
domain,
|
|
28
28
|
domain_verification_type: rejected_verification_type,
|
|
@@ -34,8 +34,8 @@ export function markDomainAsVerifiedFactory(context) {
|
|
|
34
34
|
organization_id,
|
|
35
35
|
domain,
|
|
36
36
|
domain_verification_types: [
|
|
37
|
-
...
|
|
38
|
-
...
|
|
37
|
+
...EmailDomainApprovedVerificationValues,
|
|
38
|
+
...EmailDomainPendingVerificationValues,
|
|
39
39
|
],
|
|
40
40
|
});
|
|
41
41
|
return email_domains.addDomain({
|
|
@@ -49,8 +49,8 @@ export function markDomainAsVerifiedFactory(context) {
|
|
|
49
49
|
organization_id,
|
|
50
50
|
domain,
|
|
51
51
|
domain_verification_types: [
|
|
52
|
-
...
|
|
53
|
-
...
|
|
52
|
+
...EmailDomainPendingVerificationValues,
|
|
53
|
+
...EmailDomainRejectedVerificationValues,
|
|
54
54
|
],
|
|
55
55
|
});
|
|
56
56
|
return email_domains.addDomain({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assign-user-verification-type-to-domain.d.ts","sourceRoot":"","sources":["../../../src/managers/user/assign-user-verification-type-to-domain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"assign-user-verification-type-to-domain.d.ts","sourceRoot":"","sources":["../../../src/managers/user/assign-user-verification-type-to-domain.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAM/C,wBAAgB,yCAAyC,CAAC,EACxD,UAAU,EAAE,EAAE,aAAa,EAAE,mBAAmB,EAAE,GACnD,EAAE,OAAO,IAEN,iBAAiB,MAAM,EACvB,QAAQ,MAAM,mBAuBjB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
//
|
|
2
|
-
import {
|
|
2
|
+
import { LinkEnum, SuperWeakLinkEnum, UnverifiedLinkEnum } from "#src/types";
|
|
3
3
|
import { getEmailDomain } from "@proconnect-gouv/proconnect.core/services/email";
|
|
4
|
-
import { match } from "ts-pattern";
|
|
5
4
|
//
|
|
6
5
|
export function assignUserVerificationTypeToDomainFactory({ repository: { organizations, users_organizations }, }) {
|
|
7
6
|
return async function assignUserVerificationTypeToDomain(organization_id, domain) {
|
|
@@ -9,11 +8,10 @@ export function assignUserVerificationTypeToDomainFactory({ repository: { organi
|
|
|
9
8
|
await Promise.all(usersInOrganization.map(({ id, email, verification_type: link_verification_type }) => {
|
|
10
9
|
const userDomain = getEmailDomain(email);
|
|
11
10
|
if (userDomain === domain &&
|
|
12
|
-
|
|
13
|
-
.
|
|
14
|
-
.otherwise(() => false)) {
|
|
11
|
+
(UnverifiedLinkEnum.safeParse(link_verification_type).success ||
|
|
12
|
+
SuperWeakLinkEnum.safeParse(link_verification_type).success)) {
|
|
15
13
|
return users_organizations.update(organization_id, id, {
|
|
16
|
-
verification_type:
|
|
14
|
+
verification_type: LinkEnum.enum.domain,
|
|
17
15
|
});
|
|
18
16
|
}
|
|
19
17
|
return null;
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
export declare const EmailDomainApprovedVerificationValues: readonly ["official_contact", "trackdechets_postal_mail", "verified", "external"];
|
|
3
|
+
export declare const EmailDomainApprovedVerificationEnum: z.ZodEnum<{
|
|
4
|
+
official_contact: "official_contact";
|
|
5
|
+
trackdechets_postal_mail: "trackdechets_postal_mail";
|
|
6
|
+
verified: "verified";
|
|
7
|
+
external: "external";
|
|
8
|
+
}>;
|
|
9
|
+
export type EmailDomainApprovedVerificationType = z.output<typeof EmailDomainApprovedVerificationEnum>;
|
|
10
|
+
export declare const EmailDomainPendingVerificationValues: readonly ["not_verified_yet"];
|
|
11
|
+
export declare const EmailDomainPendingVerificationEnum: z.ZodEnum<{
|
|
12
|
+
not_verified_yet: "not_verified_yet";
|
|
13
|
+
}>;
|
|
14
|
+
export type EmailDomainPendingVerificationType = z.output<typeof EmailDomainPendingVerificationEnum>;
|
|
15
|
+
export declare const EmailDomainRejectedVerificationValues: readonly ["blacklisted", "refused"];
|
|
16
|
+
export declare const EmailDomainRejectedVerificationEnum: z.ZodEnum<{
|
|
17
|
+
blacklisted: "blacklisted";
|
|
18
|
+
refused: "refused";
|
|
19
|
+
}>;
|
|
20
|
+
export type EmailDomainRejectedVerificationType = z.output<typeof EmailDomainRejectedVerificationEnum>;
|
|
21
|
+
export declare const EmailDomainNoPendingVerificationEnum: z.ZodEnum<{
|
|
9
22
|
official_contact: "official_contact";
|
|
10
23
|
trackdechets_postal_mail: "trackdechets_postal_mail";
|
|
11
24
|
verified: "verified";
|
|
@@ -13,8 +26,8 @@ export declare const EmailDomainNoPendingVerificationTypes: z.ZodEnum<{
|
|
|
13
26
|
blacklisted: "blacklisted";
|
|
14
27
|
refused: "refused";
|
|
15
28
|
}>;
|
|
16
|
-
export type EmailDomainNoPendingVerificationType = z.output<typeof
|
|
17
|
-
export declare const
|
|
29
|
+
export type EmailDomainNoPendingVerificationType = z.output<typeof EmailDomainNoPendingVerificationEnum>;
|
|
30
|
+
export declare const EmailDomainVerificationEnum: z.ZodEnum<{
|
|
18
31
|
official_contact: "official_contact";
|
|
19
32
|
trackdechets_postal_mail: "trackdechets_postal_mail";
|
|
20
33
|
verified: "verified";
|
|
@@ -23,7 +36,7 @@ export declare const EmailDomainVerificationTypes: z.ZodEnum<{
|
|
|
23
36
|
blacklisted: "blacklisted";
|
|
24
37
|
refused: "refused";
|
|
25
38
|
}>;
|
|
26
|
-
export type EmailDomainVerificationType = z.output<typeof
|
|
39
|
+
export type EmailDomainVerificationType = z.output<typeof EmailDomainVerificationEnum>;
|
|
27
40
|
export declare const EmailDomainSchema: z.ZodObject<{
|
|
28
41
|
id: z.ZodNumber;
|
|
29
42
|
organization_id: z.ZodNumber;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"email-domain.d.ts","sourceRoot":"","sources":["../../src/types/email-domain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"email-domain.d.ts","sourceRoot":"","sources":["../../src/types/email-domain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,qCAAqC,mFAKxC,CAAC;AAEX,eAAO,MAAM,mCAAmC;;;;;EAE/C,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,MAAM,CACxD,OAAO,mCAAmC,CAC3C,CAAC;AAGF,eAAO,MAAM,oCAAoC,+BAEvC,CAAC;AAEX,eAAO,MAAM,kCAAkC;;EAE9C,CAAC;AAEF,MAAM,MAAM,kCAAkC,GAAG,CAAC,CAAC,MAAM,CACvD,OAAO,kCAAkC,CAC1C,CAAC;AAEF,eAAO,MAAM,qCAAqC,qCAGxC,CAAC;AAEX,eAAO,MAAM,mCAAmC;;;EAE/C,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,CAAC,CAAC,MAAM,CACxD,OAAO,mCAAmC,CAC3C,CAAC;AAEF,eAAO,MAAM,oCAAoC;;;;;;;EAG/C,CAAC;AAEH,MAAM,MAAM,oCAAoC,GAAG,CAAC,CAAC,MAAM,CACzD,OAAO,oCAAoC,CAC5C,CAAC;AAEF,eAAO,MAAM,2BAA2B;;;;;;;;EAItC,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAChD,OAAO,2BAA2B,CACnC,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;iBAY5B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC"}
|
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export const
|
|
2
|
+
export const EmailDomainApprovedVerificationValues = [
|
|
3
3
|
"official_contact",
|
|
4
4
|
"trackdechets_postal_mail",
|
|
5
5
|
"verified",
|
|
6
6
|
"external", // domain used by external employees (eg. ext.numerique.gouv.fr)
|
|
7
7
|
];
|
|
8
|
+
export const EmailDomainApprovedVerificationEnum = z.enum(EmailDomainApprovedVerificationValues);
|
|
8
9
|
// domain is not verified, but users are still permitted to use it
|
|
9
|
-
export const
|
|
10
|
+
export const EmailDomainPendingVerificationValues = [
|
|
10
11
|
"not_verified_yet",
|
|
11
12
|
];
|
|
12
|
-
export const
|
|
13
|
+
export const EmailDomainPendingVerificationEnum = z.enum(EmailDomainPendingVerificationValues);
|
|
14
|
+
export const EmailDomainRejectedVerificationValues = [
|
|
13
15
|
"blacklisted", // unused
|
|
14
16
|
"refused",
|
|
15
17
|
];
|
|
16
|
-
export const
|
|
17
|
-
|
|
18
|
-
...
|
|
18
|
+
export const EmailDomainRejectedVerificationEnum = z.enum(EmailDomainRejectedVerificationValues);
|
|
19
|
+
export const EmailDomainNoPendingVerificationEnum = z.enum([
|
|
20
|
+
...EmailDomainApprovedVerificationValues,
|
|
21
|
+
...EmailDomainRejectedVerificationValues,
|
|
19
22
|
]);
|
|
20
|
-
export const
|
|
21
|
-
...
|
|
22
|
-
...
|
|
23
|
-
...
|
|
23
|
+
export const EmailDomainVerificationEnum = z.enum([
|
|
24
|
+
...EmailDomainApprovedVerificationValues,
|
|
25
|
+
...EmailDomainPendingVerificationValues,
|
|
26
|
+
...EmailDomainRejectedVerificationValues,
|
|
24
27
|
]);
|
|
25
28
|
export const EmailDomainSchema = z.object({
|
|
26
29
|
id: z.number(),
|
|
27
30
|
organization_id: z.number(),
|
|
28
31
|
domain: z.string(),
|
|
29
|
-
verification_type:
|
|
32
|
+
verification_type: EmailDomainVerificationEnum,
|
|
30
33
|
// Unused.
|
|
31
34
|
can_be_suggested: z.boolean(),
|
|
32
35
|
// Can be updated when verification_type changes.
|
|
@@ -33,7 +33,7 @@ export declare const ModerationSchema: z.ZodObject<{
|
|
|
33
33
|
unknown: "unknown";
|
|
34
34
|
}>;
|
|
35
35
|
end_user_reason: z.ZodString;
|
|
36
|
-
allow_editing: z.
|
|
36
|
+
allow_editing: z.ZodBoolean;
|
|
37
37
|
}, z.core.$strip>;
|
|
38
38
|
export type Moderation = z.output<typeof ModerationSchema>;
|
|
39
39
|
//# sourceMappingURL=moderation.d.ts.map
|
package/dist/types/moderation.js
CHANGED
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
6
|
-
|
|
2
|
+
export declare const StrongLinkValues: readonly ["organization_dirigeant"];
|
|
3
|
+
export declare const WeakLinkValues: readonly ["code_sent_to_official_contact_email", "domain", "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"];
|
|
4
|
+
export declare const SuperWeakLinkValues: readonly ["domain_not_verified_yet"];
|
|
5
|
+
export declare const SuperWeakLinkEnum: z.ZodEnum<{
|
|
6
|
+
domain_not_verified_yet: "domain_not_verified_yet";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const VerifiedLinkValues: readonly ["organization_dirigeant", "code_sent_to_official_contact_email", "domain", "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"];
|
|
9
|
+
export declare const VerifiedLinkEnum: z.ZodEnum<{
|
|
10
|
+
domain: "domain";
|
|
11
|
+
organization_dirigeant: "organization_dirigeant";
|
|
12
|
+
code_sent_to_official_contact_email: "code_sent_to_official_contact_email";
|
|
13
|
+
imported_from_coop_mediation_numerique: "imported_from_coop_mediation_numerique";
|
|
14
|
+
imported_from_inclusion_connect: "imported_from_inclusion_connect";
|
|
15
|
+
in_liste_dirigeants_rna: "in_liste_dirigeants_rna";
|
|
16
|
+
in_liste_dirigeants_rne: "in_liste_dirigeants_rne";
|
|
17
|
+
official_contact_email: "official_contact_email";
|
|
18
|
+
ordre_professionnel_domain: "ordre_professionnel_domain";
|
|
19
|
+
proof_received: "proof_received";
|
|
20
|
+
verified_by_coop_mediation_numerique: "verified_by_coop_mediation_numerique";
|
|
21
|
+
bypassed: "bypassed";
|
|
22
|
+
domain_not_verified_yet: "domain_not_verified_yet";
|
|
23
|
+
}>;
|
|
24
|
+
export declare const UnverifiedLinkValues: readonly ["no_validation_means_available", "no_verification_means_for_entreprise_unipersonnelle", "no_verification_means_for_small_association"];
|
|
25
|
+
export declare const UnverifiedLinkEnum: z.ZodEnum<{
|
|
26
|
+
no_validation_means_available: "no_validation_means_available";
|
|
27
|
+
no_verification_means_for_entreprise_unipersonnelle: "no_verification_means_for_entreprise_unipersonnelle";
|
|
28
|
+
no_verification_means_for_small_association: "no_verification_means_for_small_association";
|
|
29
|
+
}>;
|
|
30
|
+
export declare const LinkEnum: z.ZodEnum<{
|
|
7
31
|
domain: "domain";
|
|
8
32
|
organization_dirigeant: "organization_dirigeant";
|
|
9
33
|
code_sent_to_official_contact_email: "code_sent_to_official_contact_email";
|
|
@@ -21,7 +45,7 @@ export declare const LinkTypes: z.ZodEnum<{
|
|
|
21
45
|
no_verification_means_for_entreprise_unipersonnelle: "no_verification_means_for_entreprise_unipersonnelle";
|
|
22
46
|
no_verification_means_for_small_association: "no_verification_means_for_small_association";
|
|
23
47
|
}>;
|
|
24
|
-
export type LinkType = z.output<typeof
|
|
48
|
+
export type LinkType = z.output<typeof LinkEnum>;
|
|
25
49
|
export declare const BaseUserOrganizationLinkSchema: z.ZodObject<{
|
|
26
50
|
is_external: z.ZodBoolean;
|
|
27
51
|
verification_type: z.ZodEnum<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"user-organization-link.d.ts","sourceRoot":"","sources":["../../src/types/user-organization-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"user-organization-link.d.ts","sourceRoot":"","sources":["../../src/types/user-organization-link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,gBAAgB,qCAAsC,CAAC;AAEpE,eAAO,MAAM,cAAc,6TAajB,CAAC;AAMX,eAAO,MAAM,mBAAmB,sCAAuC,CAAC;AAExE,eAAO,MAAM,iBAAiB;;EAA8B,CAAC;AAE7D,eAAO,MAAM,kBAAkB,kXAIrB,CAAC;AAEX,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;EAA6B,CAAC;AAE3D,eAAO,MAAM,oBAAoB,kJAIvB,CAAC;AAEX,eAAO,MAAM,kBAAkB;;;;EAA+B,CAAC;AAE/D,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;EAGnB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEjD,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;iBASzC,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,MAAM,CAC7C,OAAO,8BAA8B,CACtC,CAAC;AAIF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAOtC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAI/E,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;iBAW5C,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,MAAM,CAC/C,OAAO,gCAAgC,CACxC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export const
|
|
3
|
-
export const
|
|
2
|
+
export const StrongLinkValues = ["organization_dirigeant"];
|
|
3
|
+
export const WeakLinkValues = [
|
|
4
4
|
"code_sent_to_official_contact_email",
|
|
5
5
|
"domain",
|
|
6
6
|
"imported_from_coop_mediation_numerique",
|
|
@@ -14,25 +14,31 @@ export const WeakLinkTypes = [
|
|
|
14
14
|
// Used in the sandbox environment to bypass the verification process
|
|
15
15
|
"bypassed",
|
|
16
16
|
];
|
|
17
|
-
// This link
|
|
17
|
+
// This link value should be considered as unverified.
|
|
18
18
|
// However, doing so would trigger a FranceConnect authentication requirement for the user.
|
|
19
19
|
// Users shouldn't face inconvenience while waiting for domain review completion.
|
|
20
20
|
// Instead, we should remove these unverified domains and then eliminate this special case from the codebase.
|
|
21
|
-
export const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
...
|
|
25
|
-
...
|
|
21
|
+
export const SuperWeakLinkValues = ["domain_not_verified_yet"];
|
|
22
|
+
export const SuperWeakLinkEnum = z.enum(SuperWeakLinkValues);
|
|
23
|
+
export const VerifiedLinkValues = [
|
|
24
|
+
...StrongLinkValues,
|
|
25
|
+
...WeakLinkValues,
|
|
26
|
+
...SuperWeakLinkValues,
|
|
26
27
|
];
|
|
27
|
-
export const
|
|
28
|
+
export const VerifiedLinkEnum = z.enum(VerifiedLinkValues);
|
|
29
|
+
export const UnverifiedLinkValues = [
|
|
28
30
|
"no_validation_means_available",
|
|
29
31
|
"no_verification_means_for_entreprise_unipersonnelle",
|
|
30
32
|
"no_verification_means_for_small_association",
|
|
31
33
|
];
|
|
32
|
-
export const
|
|
34
|
+
export const UnverifiedLinkEnum = z.enum(UnverifiedLinkValues);
|
|
35
|
+
export const LinkEnum = z.enum([
|
|
36
|
+
...VerifiedLinkValues,
|
|
37
|
+
...UnverifiedLinkValues,
|
|
38
|
+
]);
|
|
33
39
|
export const BaseUserOrganizationLinkSchema = z.object({
|
|
34
40
|
is_external: z.boolean(),
|
|
35
|
-
verification_type:
|
|
41
|
+
verification_type: LinkEnum,
|
|
36
42
|
// updated when verification_type is changed
|
|
37
43
|
verified_at: z.date().or(z.literal(null)),
|
|
38
44
|
has_been_greeted: z.boolean(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proconnect-gouv/proconnect.identite",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.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": {
|
|
@@ -5,11 +5,11 @@ import { NotFoundError } from "#src/errors";
|
|
|
5
5
|
import { assignUserVerificationTypeToDomainFactory } from "#src/managers/user";
|
|
6
6
|
import {
|
|
7
7
|
type EmailDomainApprovedVerificationType,
|
|
8
|
-
|
|
8
|
+
EmailDomainApprovedVerificationValues,
|
|
9
9
|
type EmailDomainNoPendingVerificationType,
|
|
10
|
-
|
|
10
|
+
EmailDomainPendingVerificationValues,
|
|
11
11
|
type EmailDomainRejectedVerificationType,
|
|
12
|
-
|
|
12
|
+
EmailDomainRejectedVerificationValues,
|
|
13
13
|
type EmailDomainVerificationType,
|
|
14
14
|
} from "#src/types";
|
|
15
15
|
|
|
@@ -43,7 +43,7 @@ export function markDomainAsVerifiedFactory(context: Context) {
|
|
|
43
43
|
|
|
44
44
|
return match(domain_verification_type)
|
|
45
45
|
.with(
|
|
46
|
-
...
|
|
46
|
+
...EmailDomainApprovedVerificationValues,
|
|
47
47
|
async (approved_verification_type) => {
|
|
48
48
|
await assignUserVerificationTypeToDomain(organization_id, domain);
|
|
49
49
|
return markDomainAsApproved({
|
|
@@ -54,7 +54,7 @@ export function markDomainAsVerifiedFactory(context: Context) {
|
|
|
54
54
|
},
|
|
55
55
|
)
|
|
56
56
|
.with(
|
|
57
|
-
...
|
|
57
|
+
...EmailDomainRejectedVerificationValues,
|
|
58
58
|
(rejected_verification_type) =>
|
|
59
59
|
markDomainAsRejected({
|
|
60
60
|
organization_id,
|
|
@@ -78,8 +78,8 @@ export function markDomainAsVerifiedFactory(context: Context) {
|
|
|
78
78
|
organization_id,
|
|
79
79
|
domain,
|
|
80
80
|
domain_verification_types: [
|
|
81
|
-
...
|
|
82
|
-
...
|
|
81
|
+
...EmailDomainApprovedVerificationValues,
|
|
82
|
+
...EmailDomainPendingVerificationValues,
|
|
83
83
|
],
|
|
84
84
|
});
|
|
85
85
|
return email_domains.addDomain({
|
|
@@ -103,8 +103,8 @@ export function markDomainAsVerifiedFactory(context: Context) {
|
|
|
103
103
|
organization_id,
|
|
104
104
|
domain,
|
|
105
105
|
domain_verification_types: [
|
|
106
|
-
...
|
|
107
|
-
...
|
|
106
|
+
...EmailDomainPendingVerificationValues,
|
|
107
|
+
...EmailDomainRejectedVerificationValues,
|
|
108
108
|
],
|
|
109
109
|
});
|
|
110
110
|
return email_domains.addDomain({
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
3
|
import type { Context } from "#src/connectors";
|
|
4
|
-
import {
|
|
4
|
+
import { LinkEnum, SuperWeakLinkEnum, UnverifiedLinkEnum } from "#src/types";
|
|
5
5
|
import { getEmailDomain } from "@proconnect-gouv/proconnect.core/services/email";
|
|
6
|
-
import { match } from "ts-pattern";
|
|
7
6
|
|
|
8
7
|
//
|
|
9
8
|
|
|
@@ -22,12 +21,11 @@ export function assignUserVerificationTypeToDomainFactory({
|
|
|
22
21
|
const userDomain = getEmailDomain(email);
|
|
23
22
|
if (
|
|
24
23
|
userDomain === domain &&
|
|
25
|
-
|
|
26
|
-
.
|
|
27
|
-
.otherwise(() => false)
|
|
24
|
+
(UnverifiedLinkEnum.safeParse(link_verification_type).success ||
|
|
25
|
+
SuperWeakLinkEnum.safeParse(link_verification_type).success)
|
|
28
26
|
) {
|
|
29
27
|
return users_organizations.update(organization_id, id, {
|
|
30
|
-
verification_type:
|
|
28
|
+
verification_type: LinkEnum.enum.domain,
|
|
31
29
|
});
|
|
32
30
|
}
|
|
33
31
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LinkEnum } from "#src/types";
|
|
2
2
|
import { emptyDatabase, migrate, pg } from "#testing";
|
|
3
3
|
import { before, beforeEach, mock, suite, test } from "node:test";
|
|
4
4
|
import { linkUserToOrganizationFactory } from "./link-user-to-organization.js";
|
|
@@ -33,7 +33,7 @@ suite("linkUserToOrganizationFactory", () => {
|
|
|
33
33
|
const userOrganizationLink = await linkUserToOrganization({
|
|
34
34
|
organization_id: 1,
|
|
35
35
|
user_id: 1,
|
|
36
|
-
verification_type:
|
|
36
|
+
verification_type: LinkEnum.enum.domain_not_verified_yet,
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
t.assert.snapshot(userOrganizationLink);
|
|
@@ -58,7 +58,7 @@ suite("linkUserToOrganizationFactory", () => {
|
|
|
58
58
|
const userOrganizationLink = await linkUserToOrganization({
|
|
59
59
|
organization_id: 1,
|
|
60
60
|
user_id: 1,
|
|
61
|
-
verification_type:
|
|
61
|
+
verification_type: LinkEnum.enum.organization_dirigeant,
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
t.assert.snapshot(userOrganizationLink);
|
|
@@ -1,58 +1,70 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const EmailDomainApprovedVerificationValues = [
|
|
4
4
|
"official_contact",
|
|
5
5
|
"trackdechets_postal_mail",
|
|
6
6
|
"verified",
|
|
7
7
|
"external", // domain used by external employees (eg. ext.numerique.gouv.fr)
|
|
8
8
|
] as const;
|
|
9
9
|
|
|
10
|
+
export const EmailDomainApprovedVerificationEnum = z.enum(
|
|
11
|
+
EmailDomainApprovedVerificationValues,
|
|
12
|
+
);
|
|
13
|
+
|
|
10
14
|
export type EmailDomainApprovedVerificationType = z.output<
|
|
11
|
-
typeof
|
|
15
|
+
typeof EmailDomainApprovedVerificationEnum
|
|
12
16
|
>;
|
|
13
17
|
|
|
14
18
|
// domain is not verified, but users are still permitted to use it
|
|
15
|
-
export const
|
|
19
|
+
export const EmailDomainPendingVerificationValues = [
|
|
16
20
|
"not_verified_yet",
|
|
17
21
|
] as const;
|
|
18
22
|
|
|
23
|
+
export const EmailDomainPendingVerificationEnum = z.enum(
|
|
24
|
+
EmailDomainPendingVerificationValues,
|
|
25
|
+
);
|
|
26
|
+
|
|
19
27
|
export type EmailDomainPendingVerificationType = z.output<
|
|
20
|
-
typeof
|
|
28
|
+
typeof EmailDomainPendingVerificationEnum
|
|
21
29
|
>;
|
|
22
30
|
|
|
23
|
-
export const
|
|
31
|
+
export const EmailDomainRejectedVerificationValues = [
|
|
24
32
|
"blacklisted", // unused
|
|
25
33
|
"refused",
|
|
26
34
|
] as const;
|
|
27
35
|
|
|
36
|
+
export const EmailDomainRejectedVerificationEnum = z.enum(
|
|
37
|
+
EmailDomainRejectedVerificationValues,
|
|
38
|
+
);
|
|
39
|
+
|
|
28
40
|
export type EmailDomainRejectedVerificationType = z.output<
|
|
29
|
-
typeof
|
|
41
|
+
typeof EmailDomainRejectedVerificationEnum
|
|
30
42
|
>;
|
|
31
43
|
|
|
32
|
-
export const
|
|
33
|
-
...
|
|
34
|
-
...
|
|
44
|
+
export const EmailDomainNoPendingVerificationEnum = z.enum([
|
|
45
|
+
...EmailDomainApprovedVerificationValues,
|
|
46
|
+
...EmailDomainRejectedVerificationValues,
|
|
35
47
|
]);
|
|
36
48
|
|
|
37
49
|
export type EmailDomainNoPendingVerificationType = z.output<
|
|
38
|
-
typeof
|
|
50
|
+
typeof EmailDomainNoPendingVerificationEnum
|
|
39
51
|
>;
|
|
40
52
|
|
|
41
|
-
export const
|
|
42
|
-
...
|
|
43
|
-
...
|
|
44
|
-
...
|
|
53
|
+
export const EmailDomainVerificationEnum = z.enum([
|
|
54
|
+
...EmailDomainApprovedVerificationValues,
|
|
55
|
+
...EmailDomainPendingVerificationValues,
|
|
56
|
+
...EmailDomainRejectedVerificationValues,
|
|
45
57
|
]);
|
|
46
58
|
|
|
47
59
|
export type EmailDomainVerificationType = z.output<
|
|
48
|
-
typeof
|
|
60
|
+
typeof EmailDomainVerificationEnum
|
|
49
61
|
>;
|
|
50
62
|
|
|
51
63
|
export const EmailDomainSchema = z.object({
|
|
52
64
|
id: z.number(),
|
|
53
65
|
organization_id: z.number(),
|
|
54
66
|
domain: z.string(),
|
|
55
|
-
verification_type:
|
|
67
|
+
verification_type: EmailDomainVerificationEnum,
|
|
56
68
|
// Unused.
|
|
57
69
|
can_be_suggested: z.boolean(),
|
|
58
70
|
// Can be updated when verification_type changes.
|
package/src/types/moderation.ts
CHANGED
|
@@ -31,7 +31,7 @@ export const ModerationSchema = z.object({
|
|
|
31
31
|
moderated_by: z.string().nullable(),
|
|
32
32
|
status: ModerationStatusSchema,
|
|
33
33
|
end_user_reason: z.string(),
|
|
34
|
-
allow_editing: z.boolean()
|
|
34
|
+
allow_editing: z.boolean(),
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
export type Moderation = z.output<typeof ModerationSchema>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const StrongLinkValues = ["organization_dirigeant"] as const;
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const WeakLinkValues = [
|
|
6
6
|
"code_sent_to_official_contact_email",
|
|
7
7
|
"domain",
|
|
8
8
|
"imported_from_coop_mediation_numerique",
|
|
@@ -17,31 +17,40 @@ export const WeakLinkTypes = [
|
|
|
17
17
|
"bypassed",
|
|
18
18
|
] as const;
|
|
19
19
|
|
|
20
|
-
// This link
|
|
20
|
+
// This link value should be considered as unverified.
|
|
21
21
|
// However, doing so would trigger a FranceConnect authentication requirement for the user.
|
|
22
22
|
// Users shouldn't face inconvenience while waiting for domain review completion.
|
|
23
23
|
// Instead, we should remove these unverified domains and then eliminate this special case from the codebase.
|
|
24
|
-
export const
|
|
24
|
+
export const SuperWeakLinkValues = ["domain_not_verified_yet"] as const;
|
|
25
25
|
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
...
|
|
26
|
+
export const SuperWeakLinkEnum = z.enum(SuperWeakLinkValues);
|
|
27
|
+
|
|
28
|
+
export const VerifiedLinkValues = [
|
|
29
|
+
...StrongLinkValues,
|
|
30
|
+
...WeakLinkValues,
|
|
31
|
+
...SuperWeakLinkValues,
|
|
30
32
|
] as const;
|
|
31
33
|
|
|
32
|
-
export const
|
|
34
|
+
export const VerifiedLinkEnum = z.enum(VerifiedLinkValues);
|
|
35
|
+
|
|
36
|
+
export const UnverifiedLinkValues = [
|
|
33
37
|
"no_validation_means_available",
|
|
34
38
|
"no_verification_means_for_entreprise_unipersonnelle",
|
|
35
39
|
"no_verification_means_for_small_association",
|
|
36
40
|
] as const;
|
|
37
41
|
|
|
38
|
-
export const
|
|
42
|
+
export const UnverifiedLinkEnum = z.enum(UnverifiedLinkValues);
|
|
43
|
+
|
|
44
|
+
export const LinkEnum = z.enum([
|
|
45
|
+
...VerifiedLinkValues,
|
|
46
|
+
...UnverifiedLinkValues,
|
|
47
|
+
]);
|
|
39
48
|
|
|
40
|
-
export type LinkType = z.output<typeof
|
|
49
|
+
export type LinkType = z.output<typeof LinkEnum>;
|
|
41
50
|
|
|
42
51
|
export const BaseUserOrganizationLinkSchema = z.object({
|
|
43
52
|
is_external: z.boolean(),
|
|
44
|
-
verification_type:
|
|
53
|
+
verification_type: LinkEnum,
|
|
45
54
|
// updated when verification_type is changed
|
|
46
55
|
verified_at: z.date().or(z.literal(null)),
|
|
47
56
|
has_been_greeted: z.boolean(),
|