@proconnect-gouv/proconnect.identite 1.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.
- package/CHANGELOG.md +96 -0
- package/dist/data/organization/domains-whitelist.d.ts +2 -0
- package/dist/data/organization/domains-whitelist.d.ts.map +1 -0
- package/dist/data/organization/domains-whitelist.js +7 -0
- package/dist/data/organization/index.d.ts +2 -0
- package/dist/data/organization/index.d.ts.map +1 -0
- package/dist/data/organization/index.js +2 -0
- package/dist/errors/index.d.ts +22 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +43 -0
- package/dist/managers/certification/distance.d.ts +4 -0
- package/dist/managers/certification/distance.d.ts.map +1 -0
- package/dist/managers/certification/distance.js +16 -0
- package/dist/managers/certification/index.d.ts +3 -0
- package/dist/managers/certification/index.d.ts.map +1 -0
- package/dist/managers/certification/index.js +3 -0
- package/dist/managers/certification/is-organization-dirigeant.d.ts +15 -0
- package/dist/managers/certification/is-organization-dirigeant.d.ts.map +1 -0
- package/dist/managers/certification/is-organization-dirigeant.js +60 -0
- package/dist/managers/franceconnect/index.d.ts +2 -0
- package/dist/managers/franceconnect/index.d.ts.map +1 -0
- package/dist/managers/franceconnect/index.js +2 -0
- package/dist/managers/franceconnect/openid-client.d.ts +37 -0
- package/dist/managers/franceconnect/openid-client.d.ts.map +1 -0
- package/dist/managers/franceconnect/openid-client.js +54 -0
- package/dist/managers/organization/force-join-organization.d.ts +29 -0
- package/dist/managers/organization/force-join-organization.d.ts.map +1 -0
- package/dist/managers/organization/force-join-organization.js +33 -0
- package/dist/managers/organization/get-organization-info.d.ts +5 -0
- package/dist/managers/organization/get-organization-info.d.ts.map +1 -0
- package/dist/managers/organization/get-organization-info.js +33 -0
- package/dist/managers/organization/index.d.ts +4 -0
- package/dist/managers/organization/index.d.ts.map +1 -0
- package/dist/managers/organization/index.js +4 -0
- package/dist/managers/organization/mark-domain-as-verified.d.ts +20 -0
- package/dist/managers/organization/mark-domain-as-verified.d.ts.map +1 -0
- package/dist/managers/organization/mark-domain-as-verified.js +63 -0
- package/dist/managers/user/assign-user-verification-type-to-domain.d.ts +10 -0
- package/dist/managers/user/assign-user-verification-type-to-domain.d.ts.map +1 -0
- package/dist/managers/user/assign-user-verification-type-to-domain.js +21 -0
- package/dist/managers/user/index.d.ts +2 -0
- package/dist/managers/user/index.d.ts.map +1 -0
- package/dist/managers/user/index.js +1 -0
- package/dist/mappers/certification/index.d.ts +4 -0
- package/dist/mappers/certification/index.d.ts.map +1 -0
- package/dist/mappers/certification/index.js +11 -0
- package/dist/mappers/index.d.ts +2 -0
- package/dist/mappers/index.d.ts.map +1 -0
- package/dist/mappers/index.js +2 -0
- package/dist/mappers/organization/from-siret.d.ts +5 -0
- package/dist/mappers/organization/from-siret.d.ts.map +1 -0
- package/dist/mappers/organization/from-siret.js +51 -0
- package/dist/mappers/organization/index.d.ts +2 -0
- package/dist/mappers/organization/index.d.ts.map +1 -0
- package/dist/mappers/organization/index.js +2 -0
- package/dist/repositories/email-domain/add-domain.d.ts +8 -0
- package/dist/repositories/email-domain/add-domain.d.ts.map +1 -0
- package/dist/repositories/email-domain/add-domain.js +25 -0
- package/dist/repositories/email-domain/delete-email-domains-by-verification-types.d.ts +8 -0
- package/dist/repositories/email-domain/delete-email-domains-by-verification-types.d.ts.map +1 -0
- package/dist/repositories/email-domain/delete-email-domains-by-verification-types.js +21 -0
- package/dist/repositories/email-domain/find-email-domains-by-organization-id.d.ts +4 -0
- package/dist/repositories/email-domain/find-email-domains-by-organization-id.d.ts.map +1 -0
- package/dist/repositories/email-domain/find-email-domains-by-organization-id.js +11 -0
- package/dist/repositories/email-domain/index.d.ts +12 -0
- package/dist/repositories/email-domain/index.d.ts.map +1 -0
- package/dist/repositories/email-domain/index.js +3 -0
- package/dist/repositories/organization/find-by-id.d.ts +4 -0
- package/dist/repositories/organization/find-by-id.d.ts.map +1 -0
- package/dist/repositories/organization/find-by-id.js +11 -0
- package/dist/repositories/organization/find-by-user-id.d.ts +12 -0
- package/dist/repositories/organization/find-by-user-id.d.ts.map +1 -0
- package/dist/repositories/organization/find-by-user-id.js +22 -0
- package/dist/repositories/organization/get-by-id.d.ts +4 -0
- package/dist/repositories/organization/get-by-id.d.ts.map +1 -0
- package/dist/repositories/organization/get-by-id.js +15 -0
- package/dist/repositories/organization/get-users-by-organization.d.ts +12 -0
- package/dist/repositories/organization/get-users-by-organization.d.ts.map +1 -0
- package/dist/repositories/organization/get-users-by-organization.js +23 -0
- package/dist/repositories/organization/index.d.ts +7 -0
- package/dist/repositories/organization/index.d.ts.map +1 -0
- package/dist/repositories/organization/index.js +7 -0
- package/dist/repositories/organization/link-user-to-organization.d.ts +16 -0
- package/dist/repositories/organization/link-user-to-organization.d.ts.map +1 -0
- package/dist/repositories/organization/link-user-to-organization.js +22 -0
- package/dist/repositories/organization/upsert.d.ts +7 -0
- package/dist/repositories/organization/upsert.d.ts.map +1 -0
- package/dist/repositories/organization/upsert.js +103 -0
- package/dist/repositories/user/create.d.ts +7 -0
- package/dist/repositories/user/create.d.ts.map +1 -0
- package/dist/repositories/user/create.js +25 -0
- package/dist/repositories/user/find-by-email.d.ts +4 -0
- package/dist/repositories/user/find-by-email.d.ts.map +1 -0
- package/dist/repositories/user/find-by-email.js +12 -0
- package/dist/repositories/user/find-by-id.d.ts +4 -0
- package/dist/repositories/user/find-by-id.d.ts.map +1 -0
- package/dist/repositories/user/find-by-id.js +13 -0
- package/dist/repositories/user/get-by-id.d.ts +4 -0
- package/dist/repositories/user/get-by-id.d.ts.map +1 -0
- package/dist/repositories/user/get-by-id.js +15 -0
- package/dist/repositories/user/get-franceconnect-user-info.d.ts +15 -0
- package/dist/repositories/user/get-franceconnect-user-info.d.ts.map +1 -0
- package/dist/repositories/user/get-franceconnect-user-info.js +13 -0
- package/dist/repositories/user/index.d.ts +9 -0
- package/dist/repositories/user/index.d.ts.map +1 -0
- package/dist/repositories/user/index.js +9 -0
- package/dist/repositories/user/update-user-organization-link.d.ts +16 -0
- package/dist/repositories/user/update-user-organization-link.d.ts.map +1 -0
- package/dist/repositories/user/update-user-organization-link.js +20 -0
- package/dist/repositories/user/update.d.ts +4 -0
- package/dist/repositories/user/update.d.ts.map +1 -0
- package/dist/repositories/user/update.js +19 -0
- package/dist/repositories/user/upsert-franceconnect-userinfo.d.ts +15 -0
- package/dist/repositories/user/upsert-franceconnect-userinfo.d.ts.map +1 -0
- package/dist/repositories/user/upsert-franceconnect-userinfo.js +23 -0
- package/dist/services/organization/index.d.ts +3 -0
- package/dist/services/organization/index.d.ts.map +1 -0
- package/dist/services/organization/index.js +3 -0
- package/dist/services/organization/is-domain-allowed-for-organization.d.ts +2 -0
- package/dist/services/organization/is-domain-allowed-for-organization.d.ts.map +1 -0
- package/dist/services/organization/is-domain-allowed-for-organization.js +8 -0
- package/dist/services/organization/is-entreprise-unipersonnelle.d.ts +9 -0
- package/dist/services/organization/is-entreprise-unipersonnelle.d.ts.map +1 -0
- package/dist/services/organization/is-entreprise-unipersonnelle.js +18 -0
- package/dist/services/postgres/hash-to-postgres-params.d.ts +6 -0
- package/dist/services/postgres/hash-to-postgres-params.d.ts.map +1 -0
- package/dist/services/postgres/hash-to-postgres-params.js +21 -0
- package/dist/services/postgres/index.d.ts +2 -0
- package/dist/services/postgres/index.d.ts.map +1 -0
- package/dist/services/postgres/index.js +2 -0
- package/dist/types/claims.d.ts +16 -0
- package/dist/types/claims.d.ts.map +1 -0
- package/dist/types/claims.js +16 -0
- package/dist/types/contexts.d.ts +5 -0
- package/dist/types/contexts.d.ts.map +1 -0
- package/dist/types/contexts.js +2 -0
- package/dist/types/dirigeant.d.ts +9 -0
- package/dist/types/dirigeant.d.ts.map +1 -0
- package/dist/types/dirigeant.js +9 -0
- package/dist/types/email-domain.d.ts +25 -0
- package/dist/types/email-domain.d.ts.map +1 -0
- package/dist/types/email-domain.js +14 -0
- package/dist/types/franceconnect.d.ts +28 -0
- package/dist/types/franceconnect.d.ts.map +1 -0
- package/dist/types/franceconnect.js +22 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/organization-info.d.ts +27 -0
- package/dist/types/organization-info.d.ts.map +1 -0
- package/dist/types/organization-info.js +26 -0
- package/dist/types/organization.d.ts +26 -0
- package/dist/types/organization.d.ts.map +1 -0
- package/dist/types/organization.js +2 -0
- package/dist/types/user-organization-link.d.ts +92 -0
- package/dist/types/user-organization-link.d.ts.map +1 -0
- package/dist/types/user-organization-link.js +44 -0
- package/dist/types/user.d.ts +28 -0
- package/dist/types/user.d.ts.map +1 -0
- package/dist/types/user.js +2 -0
- package/package.json +68 -0
- package/src/data/organization/domains-whitelist.ts +8 -0
- package/src/data/organization/index.ts +3 -0
- package/src/errors/index.ts +50 -0
- package/src/managers/certification/distance.test.ts +109 -0
- package/src/managers/certification/distance.ts +41 -0
- package/src/managers/certification/index.ts +4 -0
- package/src/managers/certification/is-organization-dirigeant.test.ts +125 -0
- package/src/managers/certification/is-organization-dirigeant.ts +136 -0
- package/src/managers/franceconnect/index.ts +3 -0
- package/src/managers/franceconnect/openid-client.ts +131 -0
- package/src/managers/organization/force-join-organization.test.ts +94 -0
- package/src/managers/organization/force-join-organization.ts +90 -0
- package/src/managers/organization/get-organization-info.test.ts +47 -0
- package/src/managers/organization/get-organization-info.test.ts.snapshot +68 -0
- package/src/managers/organization/get-organization-info.ts +58 -0
- package/src/managers/organization/index.ts +5 -0
- package/src/managers/organization/mark-domain-as-verified.test.ts +90 -0
- package/src/managers/organization/mark-domain-as-verified.test.ts.snapshot +52 -0
- package/src/managers/organization/mark-domain-as-verified.ts +140 -0
- package/src/managers/user/assign-user-verification-type-to-domain.ts +50 -0
- package/src/managers/user/index.ts +1 -0
- package/src/mappers/certification/index.ts +18 -0
- package/src/mappers/index.ts +3 -0
- package/src/mappers/organization/from-siret.test.ts +26 -0
- package/src/mappers/organization/from-siret.test.ts.snapshot +68 -0
- package/src/mappers/organization/from-siret.ts +75 -0
- package/src/mappers/organization/index.ts +3 -0
- package/src/repositories/email-domain/add-domain.test.ts +43 -0
- package/src/repositories/email-domain/add-domain.ts +48 -0
- package/src/repositories/email-domain/delete-email-domains-by-verification-types.test.ts +49 -0
- package/src/repositories/email-domain/delete-email-domains-by-verification-types.ts +45 -0
- package/src/repositories/email-domain/find-email-domains-by-organization-id.test.ts +55 -0
- package/src/repositories/email-domain/find-email-domains-by-organization-id.ts +28 -0
- package/src/repositories/email-domain/index.ts +13 -0
- package/src/repositories/organization/find-by-id.test.ts +51 -0
- package/src/repositories/organization/find-by-id.ts +22 -0
- package/src/repositories/organization/find-by-user-id.test.ts +70 -0
- package/src/repositories/organization/find-by-user-id.test.ts.snapshot +102 -0
- package/src/repositories/organization/find-by-user-id.ts +38 -0
- package/src/repositories/organization/get-by-id.test.ts +60 -0
- package/src/repositories/organization/get-by-id.ts +21 -0
- package/src/repositories/organization/get-users-by-organization.test.ts +50 -0
- package/src/repositories/organization/get-users-by-organization.test.ts.snapshot +38 -0
- package/src/repositories/organization/get-users-by-organization.ts +46 -0
- package/src/repositories/organization/index.ts +8 -0
- package/src/repositories/organization/link-user-to-organization.test.ts +65 -0
- package/src/repositories/organization/link-user-to-organization.test.ts.snapshot +31 -0
- package/src/repositories/organization/link-user-to-organization.ts +45 -0
- package/src/repositories/organization/upsert.ts +142 -0
- package/src/repositories/organization/upset.test.ts +95 -0
- package/src/repositories/user/create.test.ts +49 -0
- package/src/repositories/user/create.ts +44 -0
- package/src/repositories/user/find-by-email.test.ts +62 -0
- package/src/repositories/user/find-by-email.ts +22 -0
- package/src/repositories/user/find-by-id.test.ts +64 -0
- package/src/repositories/user/find-by-id.ts +23 -0
- package/src/repositories/user/get-by-id.test.ts +63 -0
- package/src/repositories/user/get-by-id.ts +21 -0
- package/src/repositories/user/get-franceconnect-user-info.test.ts +58 -0
- package/src/repositories/user/get-franceconnect-user-info.ts +25 -0
- package/src/repositories/user/index.ts +10 -0
- package/src/repositories/user/update-user-organization-link.test.ts +46 -0
- package/src/repositories/user/update-user-organization-link.ts +42 -0
- package/src/repositories/user/update.test.ts +26 -0
- package/src/repositories/user/update.ts +34 -0
- package/src/repositories/user/upsert-franceconnect-userinfo.test.ts +100 -0
- package/src/repositories/user/upsert-franceconnect-userinfo.ts +41 -0
- package/src/services/organization/index.ts +4 -0
- package/src/services/organization/is-domain-allowed-for-organization.ts +10 -0
- package/src/services/organization/is-entreprise-unipersonnelle.test.ts +32 -0
- package/src/services/organization/is-entreprise-unipersonnelle.ts +31 -0
- package/src/services/postgres/hash-to-postgres-params.ts +34 -0
- package/src/services/postgres/index.ts +3 -0
- package/src/types/claims.ts +21 -0
- package/src/types/contexts.ts +9 -0
- package/src/types/dirigeant.ts +13 -0
- package/src/types/email-domain.ts +48 -0
- package/src/types/franceconnect.ts +37 -0
- package/src/types/index.ts +11 -0
- package/src/types/organization-info.ts +32 -0
- package/src/types/organization.ts +30 -0
- package/src/types/user-organization-link.ts +71 -0
- package/src/types/user.ts +29 -0
- package/testing/index.ts +31 -0
- package/testing/seed/franceconnect/index.ts +40 -0
- package/testing/seed/insee/index.ts +22 -0
- package/testing/seed/mandataires/index.ts +32 -0
- package/testing/seed/organizations/index.ts +41 -0
- package/tsconfig.json +17 -0
- package/tsconfig.lib.json +9 -0
- package/tsconfig.lib.tsbuildinfo +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
export const UserClaimsSchema = z.object({
|
|
8
|
+
email_verified: z.boolean(),
|
|
9
|
+
email: z.string(),
|
|
10
|
+
family_name: z.string().optional(),
|
|
11
|
+
given_name: z.string().optional(),
|
|
12
|
+
job: z.string().optional(),
|
|
13
|
+
phone_number_verified: z.boolean(),
|
|
14
|
+
phone_number: z.string().optional(),
|
|
15
|
+
sub: z.string(),
|
|
16
|
+
uid: z.string(),
|
|
17
|
+
updated_at: z.date(),
|
|
18
|
+
usual_name: z.string().optional(),
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type UserClaims = z.output<typeof UserClaimsSchema>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
export const IdentityVectorSchema = z.object({
|
|
8
|
+
birthdate: z.date().nullable(),
|
|
9
|
+
birthplace: z.string().nullable(),
|
|
10
|
+
family_name: z.string().nullable(),
|
|
11
|
+
given_name: z.string().nullable(),
|
|
12
|
+
});
|
|
13
|
+
export type IdentityVector = z.output<typeof IdentityVectorSchema>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
export const EMAIL_DOMAIN_APPROVED_VERIFICATION_TYPES = z.enum([
|
|
8
|
+
"official_contact",
|
|
9
|
+
"trackdechets_postal_mail",
|
|
10
|
+
"verified",
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
export type EmailDomainApprovedVerificationType = z.output<
|
|
14
|
+
typeof EMAIL_DOMAIN_APPROVED_VERIFICATION_TYPES
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
|
|
19
|
+
export const EMAIL_DOMAIN_REJECTED_VERIFICATION_TYPES = z.enum([
|
|
20
|
+
"blacklisted", // unused
|
|
21
|
+
"external", // domain used by external employees (eg. ext.numerique.gouv.fr)
|
|
22
|
+
"refused",
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
export type EmailDomainRejectedVerificationType = z.output<
|
|
26
|
+
typeof EMAIL_DOMAIN_REJECTED_VERIFICATION_TYPES
|
|
27
|
+
>;
|
|
28
|
+
|
|
29
|
+
//
|
|
30
|
+
|
|
31
|
+
export type EmailDomainVerificationType =
|
|
32
|
+
| EmailDomainApprovedVerificationType
|
|
33
|
+
| EmailDomainRejectedVerificationType
|
|
34
|
+
| null; // domain is not verified, but users are still permitted to use it
|
|
35
|
+
|
|
36
|
+
export interface EmailDomain {
|
|
37
|
+
id: number;
|
|
38
|
+
organization_id: number;
|
|
39
|
+
domain: string;
|
|
40
|
+
verification_type: EmailDomainVerificationType;
|
|
41
|
+
// Unused.
|
|
42
|
+
can_be_suggested: boolean;
|
|
43
|
+
// Can be updated when verification_type changes.
|
|
44
|
+
// In practice, entries are deleted and recreated rather than updated directly
|
|
45
|
+
verified_at: Date | null;
|
|
46
|
+
created_at: Date;
|
|
47
|
+
updated_at: Date;
|
|
48
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @see https://docs.partenaires.franceconnect.gouv.fr/fs/fs-technique/fs-technique-scope-fc/#liste-des-claims
|
|
9
|
+
*/
|
|
10
|
+
export const FranceConnectUserInfoResponseSchema = z.object({
|
|
11
|
+
birthdate: z.coerce.date(),
|
|
12
|
+
birthplace: z.string(),
|
|
13
|
+
family_name: z.string(),
|
|
14
|
+
gender: z.string(),
|
|
15
|
+
given_name: z.string(),
|
|
16
|
+
preferred_username: z.string().optional(),
|
|
17
|
+
sub: z.string(),
|
|
18
|
+
// NOTE(douglasduteil): the following ignore extra keys (aud, given_name_array)
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
export type FranceConnectUserInfoResponse = z.output<
|
|
22
|
+
typeof FranceConnectUserInfoResponseSchema
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
//
|
|
26
|
+
|
|
27
|
+
export const FranceConnectUserInfoSchema =
|
|
28
|
+
FranceConnectUserInfoResponseSchema.merge(
|
|
29
|
+
z.object({
|
|
30
|
+
created_at: z.coerce.date(),
|
|
31
|
+
updated_at: z.coerce.date(),
|
|
32
|
+
user_id: z.number(),
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
35
|
+
export type FranceConnectUserInfo = z.output<
|
|
36
|
+
typeof FranceConnectUserInfoSchema
|
|
37
|
+
>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
export * from "./claims.js";
|
|
4
|
+
export * from "./contexts.js";
|
|
5
|
+
export * from "./dirigeant.js";
|
|
6
|
+
export * from "./email-domain.js";
|
|
7
|
+
export * from "./franceconnect.js";
|
|
8
|
+
export * from "./organization-info.js";
|
|
9
|
+
export * from "./organization.js";
|
|
10
|
+
export * from "./user-organization-link.js";
|
|
11
|
+
export * from "./user.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
import type { TrancheEffectifs } from "@proconnect-gouv/proconnect.entreprise/types";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
export const OrganizationInfoSchema = z.object({
|
|
8
|
+
activitePrincipale: z.string(),
|
|
9
|
+
adresse: z.string(),
|
|
10
|
+
categorieJuridique: z.string(),
|
|
11
|
+
codeOfficielGeographique: z.string(),
|
|
12
|
+
codePostal: z.string().nullable(),
|
|
13
|
+
enseigne: z.string(),
|
|
14
|
+
estActive: z.boolean(),
|
|
15
|
+
estDiffusible: z.boolean(),
|
|
16
|
+
etatAdministratif: z.string(),
|
|
17
|
+
libelle: z.string(),
|
|
18
|
+
libelleActivitePrincipale: z.string(),
|
|
19
|
+
libelleCategorieJuridique: z.string(),
|
|
20
|
+
libelleTrancheEffectif: z.string(),
|
|
21
|
+
nomComplet: z.string(),
|
|
22
|
+
siret: z.string(),
|
|
23
|
+
statutDiffusion: z.enum([
|
|
24
|
+
"diffusible",
|
|
25
|
+
"partiellement_diffusible",
|
|
26
|
+
"non_diffusible",
|
|
27
|
+
]),
|
|
28
|
+
trancheEffectifs: z.custom<TrancheEffectifs | null>().nullable(),
|
|
29
|
+
trancheEffectifsUniteLegale: z.string().nullable(),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export type OrganizationInfo = z.output<typeof OrganizationInfoSchema>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type { TrancheEffectifs } from "@proconnect-gouv/proconnect.entreprise/types";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
export interface Organization {
|
|
8
|
+
id: number;
|
|
9
|
+
siret: string;
|
|
10
|
+
created_at: Date;
|
|
11
|
+
updated_at: Date;
|
|
12
|
+
cached_libelle: string | null;
|
|
13
|
+
cached_nom_complet: string | null;
|
|
14
|
+
cached_enseigne: string | null;
|
|
15
|
+
cached_tranche_effectifs: TrancheEffectifs;
|
|
16
|
+
cached_tranche_effectifs_unite_legale: string | null;
|
|
17
|
+
cached_libelle_tranche_effectif: string | null;
|
|
18
|
+
cached_etat_administratif: string | null;
|
|
19
|
+
cached_est_active: string | null;
|
|
20
|
+
cached_statut_diffusion: string | null;
|
|
21
|
+
cached_est_diffusible: string | null;
|
|
22
|
+
cached_adresse: string | null;
|
|
23
|
+
cached_code_postal: string | null;
|
|
24
|
+
cached_code_officiel_geographique: string | null;
|
|
25
|
+
cached_activite_principale: string | null;
|
|
26
|
+
cached_libelle_activite_principale: string | null;
|
|
27
|
+
cached_categorie_juridique: string | null;
|
|
28
|
+
cached_libelle_categorie_juridique: string | null;
|
|
29
|
+
organization_info_fetched_at: Date | null;
|
|
30
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const UserOrganizationLinkVerificationTypeSchema = z.enum([
|
|
4
|
+
"code_sent_to_official_contact_email",
|
|
5
|
+
"domain",
|
|
6
|
+
"imported_from_coop_mediation_numerique",
|
|
7
|
+
"imported_from_inclusion_connect",
|
|
8
|
+
"in_liste_dirigeants_rna",
|
|
9
|
+
"in_liste_dirigeants_rne",
|
|
10
|
+
"no_validation_means_available",
|
|
11
|
+
"no_verification_means_for_entreprise_unipersonnelle",
|
|
12
|
+
"no_verification_means_for_small_association",
|
|
13
|
+
"official_contact_email",
|
|
14
|
+
"organization_dirigeant",
|
|
15
|
+
"proof_received",
|
|
16
|
+
// Used in the sandbox environment to bypass the verification process
|
|
17
|
+
"bypassed",
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export type UserOrganizationLinkVerificationType = z.output<
|
|
21
|
+
typeof UserOrganizationLinkVerificationTypeSchema
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
//
|
|
25
|
+
|
|
26
|
+
export const BaseUserOrganizationLinkSchema = z.object({
|
|
27
|
+
is_external: z.boolean(),
|
|
28
|
+
verification_type: UserOrganizationLinkVerificationTypeSchema.nullable(),
|
|
29
|
+
// updated when verification_type is changed
|
|
30
|
+
verified_at: z.date().or(z.literal(null)),
|
|
31
|
+
has_been_greeted: z.boolean(),
|
|
32
|
+
needs_official_contact_email_verification: z.boolean(),
|
|
33
|
+
official_contact_email_verification_token: z.string().nullable(),
|
|
34
|
+
official_contact_email_verification_sent_at: z.date().nullable(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export type BaseUserOrganizationLink = z.output<
|
|
38
|
+
typeof BaseUserOrganizationLinkSchema
|
|
39
|
+
>;
|
|
40
|
+
|
|
41
|
+
//
|
|
42
|
+
|
|
43
|
+
export const UserOrganizationLinkSchema = BaseUserOrganizationLinkSchema.extend(
|
|
44
|
+
{
|
|
45
|
+
user_id: z.number(),
|
|
46
|
+
organization_id: z.number(),
|
|
47
|
+
created_at: z.date(),
|
|
48
|
+
updated_at: z.date(),
|
|
49
|
+
},
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
export type UserOrganizationLink = z.output<typeof UserOrganizationLinkSchema>;
|
|
53
|
+
|
|
54
|
+
//
|
|
55
|
+
|
|
56
|
+
export const InsertUserOrganizationLinkSchema = UserOrganizationLinkSchema.pick(
|
|
57
|
+
{
|
|
58
|
+
organization_id: true,
|
|
59
|
+
user_id: true,
|
|
60
|
+
verification_type: true,
|
|
61
|
+
},
|
|
62
|
+
).merge(
|
|
63
|
+
UserOrganizationLinkSchema.pick({
|
|
64
|
+
is_external: true,
|
|
65
|
+
needs_official_contact_email_verification: true,
|
|
66
|
+
}).partial(),
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
export type InsertUserOrganizationLink = z.output<
|
|
70
|
+
typeof InsertUserOrganizationLinkSchema
|
|
71
|
+
>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
export interface User {
|
|
4
|
+
created_at: Date;
|
|
5
|
+
current_challenge: string | null;
|
|
6
|
+
email_verified_at: Date | null;
|
|
7
|
+
email_verified: boolean;
|
|
8
|
+
email: string;
|
|
9
|
+
encrypted_password: string | null;
|
|
10
|
+
encrypted_totp_key: string | null;
|
|
11
|
+
family_name: string | null;
|
|
12
|
+
force_2fa: boolean;
|
|
13
|
+
given_name: string | null;
|
|
14
|
+
id: number;
|
|
15
|
+
job: string | null;
|
|
16
|
+
last_sign_in_at: Date | null;
|
|
17
|
+
magic_link_sent_at: Date | null;
|
|
18
|
+
magic_link_token: string | null;
|
|
19
|
+
needs_inclusionconnect_onboarding_help: boolean;
|
|
20
|
+
needs_inclusionconnect_welcome_page: boolean;
|
|
21
|
+
phone_number: string | null;
|
|
22
|
+
reset_password_sent_at: Date | null;
|
|
23
|
+
reset_password_token: string | null;
|
|
24
|
+
sign_in_count: number;
|
|
25
|
+
totp_key_verified_at: Date | null;
|
|
26
|
+
updated_at: Date;
|
|
27
|
+
verify_email_sent_at: Date | null;
|
|
28
|
+
verify_email_token: string | null;
|
|
29
|
+
}
|
package/testing/index.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import { PGlite } from "@electric-sql/pglite";
|
|
4
|
+
import { noop } from "lodash-es";
|
|
5
|
+
import { runner } from "node-pg-migrate";
|
|
6
|
+
import { join } from "path";
|
|
7
|
+
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
export const pg = new PGlite();
|
|
11
|
+
|
|
12
|
+
export function migrate() {
|
|
13
|
+
return runner({
|
|
14
|
+
dbClient: pg as any,
|
|
15
|
+
dir: join(import.meta.dirname, "../../../migrations"),
|
|
16
|
+
direction: "up",
|
|
17
|
+
migrationsTable: "pg-migrate",
|
|
18
|
+
log: noop,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export async function emptyDatabase() {
|
|
23
|
+
await pg.sql`delete from users_organizations;`;
|
|
24
|
+
//
|
|
25
|
+
await pg.sql`delete from organizations;`;
|
|
26
|
+
await pg.sql`ALTER SEQUENCE organizations_id_seq RESTART WITH 1`;
|
|
27
|
+
await pg.sql`delete from users;`;
|
|
28
|
+
await pg.sql`ALTER SEQUENCE users_id_seq RESTART WITH 1`;
|
|
29
|
+
await pg.sql`delete from email_domains;`;
|
|
30
|
+
await pg.sql`ALTER SEQUENCE email_domains_id_seq RESTART WITH 1`;
|
|
31
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { FranceConnectUserInfo } from "#src/types";
|
|
2
|
+
|
|
3
|
+
export const LiElJonsonFranceConnectUserInfo: FranceConnectUserInfo = {
|
|
4
|
+
birthdate: new Date(29000, 10, 7),
|
|
5
|
+
birthplace: "Caliban",
|
|
6
|
+
created_at: new Date("4444-04-04"),
|
|
7
|
+
family_name: "El’Jonson",
|
|
8
|
+
gender: "male",
|
|
9
|
+
given_name: "Li",
|
|
10
|
+
preferred_username: "Li",
|
|
11
|
+
sub: "abcdefghijklmnopqrstuvwxyz",
|
|
12
|
+
updated_at: new Date("4444-04-05"),
|
|
13
|
+
user_id: NaN,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const BelisariusCawlFranceConnectUserInfo: FranceConnectUserInfo = {
|
|
17
|
+
birthdate: new Date(28500, 1, 5),
|
|
18
|
+
birthplace: "MARS",
|
|
19
|
+
created_at: new Date("2023-04-10"),
|
|
20
|
+
family_name: "CAWL",
|
|
21
|
+
gender: "male",
|
|
22
|
+
given_name: "BELISARIUS",
|
|
23
|
+
preferred_username: "Archmagos",
|
|
24
|
+
sub: "belisariuscawlmechanicusdominus67890",
|
|
25
|
+
updated_at: new Date(),
|
|
26
|
+
user_id: NaN,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const RogalDornFranceConnectUserInfo: FranceConnectUserInfo = {
|
|
30
|
+
birthdate: new Date(29000, 0, 7),
|
|
31
|
+
birthplace: "INWIT",
|
|
32
|
+
created_at: new Date("2023-04-10"),
|
|
33
|
+
family_name: "DORN",
|
|
34
|
+
gender: "male",
|
|
35
|
+
given_name: "ROGAL",
|
|
36
|
+
preferred_username: "FortressionPrimarch",
|
|
37
|
+
sub: "IMP7777777",
|
|
38
|
+
updated_at: new Date(),
|
|
39
|
+
user_id: NaN,
|
|
40
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type { InseeSiretEstablishment } from "@proconnect-gouv/proconnect.insee/types";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
export const LiElJonsonEstablishment: InseeSiretEstablishment = {
|
|
7
|
+
uniteLegale: {
|
|
8
|
+
codeCommuneNaissanceUniteLegale: "INW",
|
|
9
|
+
dateNaissanceUniteLegale: "285000205",
|
|
10
|
+
nomUniteLegale: "EL'JONSON",
|
|
11
|
+
prenom1UniteLegale: "LION",
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const RogalDornEstablishment: InseeSiretEstablishment = {
|
|
16
|
+
uniteLegale: {
|
|
17
|
+
codeCommuneNaissanceUniteLegale: "INWIT",
|
|
18
|
+
dateNaissanceUniteLegale: "290000107",
|
|
19
|
+
nomUniteLegale: "DORN",
|
|
20
|
+
prenom1UniteLegale: "ROGAL",
|
|
21
|
+
},
|
|
22
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type { InfogreffeSirenMandatairesSociaux } from "@proconnect-gouv/proconnect.entreprise/types";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
export const UlysseToriMandataire: InfogreffeSirenMandatairesSociaux = {
|
|
8
|
+
code_nationalite: "FR",
|
|
9
|
+
code_pays_naissance: "FR",
|
|
10
|
+
date_naissance_timestamp: 715824000000,
|
|
11
|
+
date_naissance: "1992-09-07",
|
|
12
|
+
fonction: "DIRIGEANT",
|
|
13
|
+
lieu_naissance: "Internet",
|
|
14
|
+
nationalite: "Française",
|
|
15
|
+
nom: "TOSI",
|
|
16
|
+
pays_naissance: "FRANCE",
|
|
17
|
+
prenom: "Ulysse",
|
|
18
|
+
type: "personne_physique",
|
|
19
|
+
};
|
|
20
|
+
export const RogalDornMandataire: InfogreffeSirenMandatairesSociaux = {
|
|
21
|
+
code_nationalite: "IM",
|
|
22
|
+
code_pays_naissance: "IM",
|
|
23
|
+
date_naissance_timestamp: 852984946800000,
|
|
24
|
+
date_naissance: "29000-01-07",
|
|
25
|
+
fonction: "Primarch",
|
|
26
|
+
lieu_naissance: "INWIT",
|
|
27
|
+
nationalite: "IMPERIAL",
|
|
28
|
+
nom: "DORN",
|
|
29
|
+
pays_naissance: "IMPERIUM",
|
|
30
|
+
prenom: "ROGAL",
|
|
31
|
+
type: "personne_physique",
|
|
32
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type { Organization } from "#src/types";
|
|
4
|
+
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
export const association_org_info = {
|
|
8
|
+
siret: "83511518900010",
|
|
9
|
+
cached_tranche_effectifs: "00",
|
|
10
|
+
cached_tranche_effectifs_unite_legale: "00",
|
|
11
|
+
cached_libelle_tranche_effectif:
|
|
12
|
+
"0 salarié (n'ayant pas d'effectif au 31/12 mais ayant employé des salariés au cours de l'année de référence), en 2020",
|
|
13
|
+
cached_activite_principale: "81.21Z",
|
|
14
|
+
cached_libelle_activite_principale:
|
|
15
|
+
"81.21Z - Nettoyage courant des bâtiments",
|
|
16
|
+
cached_categorie_juridique: "9220",
|
|
17
|
+
cached_libelle_categorie_juridique: "Association déclarée",
|
|
18
|
+
} as Organization;
|
|
19
|
+
|
|
20
|
+
export const small_association_org_info = {
|
|
21
|
+
siret: "39399933900046",
|
|
22
|
+
cached_tranche_effectifs: "12",
|
|
23
|
+
cached_tranche_effectifs_unite_legale: "12",
|
|
24
|
+
cached_libelle_tranche_effectif: "20 à 49 salariés, en 2022",
|
|
25
|
+
cached_activite_principale: "84.13Z",
|
|
26
|
+
cached_libelle_activite_principale:
|
|
27
|
+
"84.13Z - Administration publique (tutelle) des activités économiques",
|
|
28
|
+
cached_categorie_juridique: "9220",
|
|
29
|
+
cached_libelle_categorie_juridique: "Association déclarée",
|
|
30
|
+
} as Organization;
|
|
31
|
+
|
|
32
|
+
export const entreprise_unipersonnelle_org_info = {
|
|
33
|
+
siret: "82869625200018",
|
|
34
|
+
cached_tranche_effectifs: null,
|
|
35
|
+
cached_tranche_effectifs_unite_legale: null,
|
|
36
|
+
cached_libelle_tranche_effectif: null,
|
|
37
|
+
cached_activite_principale: "62.01Z",
|
|
38
|
+
cached_libelle_activite_principale: "62.01Z - Programmation informatique",
|
|
39
|
+
cached_categorie_juridique: "1000",
|
|
40
|
+
cached_libelle_categorie_juridique: "Entrepreneur individuel",
|
|
41
|
+
} as Organization;
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": "./src",
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"declarationMap": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"resolveJsonModule": true,
|
|
8
|
+
"types": ["node"]
|
|
9
|
+
},
|
|
10
|
+
"extends": "@proconnect-gouv/proconnect.devtools.typescript/base/tsconfig.json",
|
|
11
|
+
"references": [
|
|
12
|
+
{ "path": "../core/tsconfig.lib.json" },
|
|
13
|
+
{ "path": "../entreprise/tsconfig.lib.json" },
|
|
14
|
+
{ "path": "../insee/tsconfig.lib.json" }
|
|
15
|
+
],
|
|
16
|
+
"include": ["./src/**/*", "./src/**/*.json", "testing"]
|
|
17
|
+
}
|