@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,14 @@
|
|
|
1
|
+
//
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//
|
|
4
|
+
export const EMAIL_DOMAIN_APPROVED_VERIFICATION_TYPES = z.enum([
|
|
5
|
+
"official_contact",
|
|
6
|
+
"trackdechets_postal_mail",
|
|
7
|
+
"verified",
|
|
8
|
+
]);
|
|
9
|
+
//
|
|
10
|
+
export const EMAIL_DOMAIN_REJECTED_VERIFICATION_TYPES = z.enum([
|
|
11
|
+
"blacklisted", // unused
|
|
12
|
+
"external", // domain used by external employees (eg. ext.numerique.gouv.fr)
|
|
13
|
+
"refused",
|
|
14
|
+
]);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* @see https://docs.partenaires.franceconnect.gouv.fr/fs/fs-technique/fs-technique-scope-fc/#liste-des-claims
|
|
4
|
+
*/
|
|
5
|
+
export declare const FranceConnectUserInfoResponseSchema: z.ZodObject<{
|
|
6
|
+
birthdate: z.ZodCoercedDate<unknown>;
|
|
7
|
+
birthplace: z.ZodString;
|
|
8
|
+
family_name: z.ZodString;
|
|
9
|
+
gender: z.ZodString;
|
|
10
|
+
given_name: z.ZodString;
|
|
11
|
+
preferred_username: z.ZodOptional<z.ZodString>;
|
|
12
|
+
sub: z.ZodString;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
export type FranceConnectUserInfoResponse = z.output<typeof FranceConnectUserInfoResponseSchema>;
|
|
15
|
+
export declare const FranceConnectUserInfoSchema: z.ZodObject<{
|
|
16
|
+
birthdate: z.ZodCoercedDate<unknown>;
|
|
17
|
+
birthplace: z.ZodString;
|
|
18
|
+
family_name: z.ZodString;
|
|
19
|
+
gender: z.ZodString;
|
|
20
|
+
given_name: z.ZodString;
|
|
21
|
+
preferred_username: z.ZodOptional<z.ZodString>;
|
|
22
|
+
sub: z.ZodString;
|
|
23
|
+
created_at: z.ZodCoercedDate<unknown>;
|
|
24
|
+
updated_at: z.ZodCoercedDate<unknown>;
|
|
25
|
+
user_id: z.ZodNumber;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export type FranceConnectUserInfo = z.output<typeof FranceConnectUserInfoSchema>;
|
|
28
|
+
//# sourceMappingURL=franceconnect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"franceconnect.d.ts","sourceRoot":"","sources":["../../src/types/franceconnect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;GAEG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;iBAS9C,CAAC;AAEH,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,MAAM,CAClD,OAAO,mCAAmC,CAC3C,CAAC;AAIF,eAAO,MAAM,2BAA2B;;;;;;;;;;;iBAOrC,CAAC;AACJ,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAC1C,OAAO,2BAA2B,CACnC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
//
|
|
4
|
+
/**
|
|
5
|
+
* @see https://docs.partenaires.franceconnect.gouv.fr/fs/fs-technique/fs-technique-scope-fc/#liste-des-claims
|
|
6
|
+
*/
|
|
7
|
+
export const FranceConnectUserInfoResponseSchema = z.object({
|
|
8
|
+
birthdate: z.coerce.date(),
|
|
9
|
+
birthplace: z.string(),
|
|
10
|
+
family_name: z.string(),
|
|
11
|
+
gender: z.string(),
|
|
12
|
+
given_name: z.string(),
|
|
13
|
+
preferred_username: z.string().optional(),
|
|
14
|
+
sub: z.string(),
|
|
15
|
+
// NOTE(douglasduteil): the following ignore extra keys (aud, given_name_array)
|
|
16
|
+
});
|
|
17
|
+
//
|
|
18
|
+
export const FranceConnectUserInfoSchema = FranceConnectUserInfoResponseSchema.merge(z.object({
|
|
19
|
+
created_at: z.coerce.date(),
|
|
20
|
+
updated_at: z.coerce.date(),
|
|
21
|
+
user_id: z.number(),
|
|
22
|
+
}));
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from "./claims.js";
|
|
2
|
+
export * from "./contexts.js";
|
|
3
|
+
export * from "./dirigeant.js";
|
|
4
|
+
export * from "./email-domain.js";
|
|
5
|
+
export * from "./franceconnect.js";
|
|
6
|
+
export * from "./organization-info.js";
|
|
7
|
+
export * from "./organization.js";
|
|
8
|
+
export * from "./user-organization-link.js";
|
|
9
|
+
export * from "./user.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//
|
|
2
|
+
export * from "./claims.js";
|
|
3
|
+
export * from "./contexts.js";
|
|
4
|
+
export * from "./dirigeant.js";
|
|
5
|
+
export * from "./email-domain.js";
|
|
6
|
+
export * from "./franceconnect.js";
|
|
7
|
+
export * from "./organization-info.js";
|
|
8
|
+
export * from "./organization.js";
|
|
9
|
+
export * from "./user-organization-link.js";
|
|
10
|
+
export * from "./user.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const OrganizationInfoSchema: z.ZodObject<{
|
|
3
|
+
activitePrincipale: z.ZodString;
|
|
4
|
+
adresse: z.ZodString;
|
|
5
|
+
categorieJuridique: z.ZodString;
|
|
6
|
+
codeOfficielGeographique: z.ZodString;
|
|
7
|
+
codePostal: z.ZodNullable<z.ZodString>;
|
|
8
|
+
enseigne: z.ZodString;
|
|
9
|
+
estActive: z.ZodBoolean;
|
|
10
|
+
estDiffusible: z.ZodBoolean;
|
|
11
|
+
etatAdministratif: z.ZodString;
|
|
12
|
+
libelle: z.ZodString;
|
|
13
|
+
libelleActivitePrincipale: z.ZodString;
|
|
14
|
+
libelleCategorieJuridique: z.ZodString;
|
|
15
|
+
libelleTrancheEffectif: z.ZodString;
|
|
16
|
+
nomComplet: z.ZodString;
|
|
17
|
+
siret: z.ZodString;
|
|
18
|
+
statutDiffusion: z.ZodEnum<{
|
|
19
|
+
diffusible: "diffusible";
|
|
20
|
+
partiellement_diffusible: "partiellement_diffusible";
|
|
21
|
+
non_diffusible: "non_diffusible";
|
|
22
|
+
}>;
|
|
23
|
+
trancheEffectifs: z.ZodNullable<z.ZodCustom<"NN" | "00" | "01" | "02" | "03" | "11" | "12" | "21" | "22" | "31" | "32" | "41" | "42" | "51" | "52" | "53" | null, "NN" | "00" | "01" | "02" | "03" | "11" | "12" | "21" | "22" | "31" | "32" | "41" | "42" | "51" | "52" | "53" | null>>;
|
|
24
|
+
trancheEffectifsUniteLegale: z.ZodNullable<z.ZodString>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
export type OrganizationInfo = z.output<typeof OrganizationInfoSchema>;
|
|
27
|
+
//# sourceMappingURL=organization-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-info.d.ts","sourceRoot":"","sources":["../../src/types/organization-info.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;iBAuBjC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,sBAAsB,CAAC,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
//
|
|
3
|
+
export const OrganizationInfoSchema = z.object({
|
|
4
|
+
activitePrincipale: z.string(),
|
|
5
|
+
adresse: z.string(),
|
|
6
|
+
categorieJuridique: z.string(),
|
|
7
|
+
codeOfficielGeographique: z.string(),
|
|
8
|
+
codePostal: z.string().nullable(),
|
|
9
|
+
enseigne: z.string(),
|
|
10
|
+
estActive: z.boolean(),
|
|
11
|
+
estDiffusible: z.boolean(),
|
|
12
|
+
etatAdministratif: z.string(),
|
|
13
|
+
libelle: z.string(),
|
|
14
|
+
libelleActivitePrincipale: z.string(),
|
|
15
|
+
libelleCategorieJuridique: z.string(),
|
|
16
|
+
libelleTrancheEffectif: z.string(),
|
|
17
|
+
nomComplet: z.string(),
|
|
18
|
+
siret: z.string(),
|
|
19
|
+
statutDiffusion: z.enum([
|
|
20
|
+
"diffusible",
|
|
21
|
+
"partiellement_diffusible",
|
|
22
|
+
"non_diffusible",
|
|
23
|
+
]),
|
|
24
|
+
trancheEffectifs: z.custom().nullable(),
|
|
25
|
+
trancheEffectifsUniteLegale: z.string().nullable(),
|
|
26
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TrancheEffectifs } from "@proconnect-gouv/proconnect.entreprise/types";
|
|
2
|
+
export interface Organization {
|
|
3
|
+
id: number;
|
|
4
|
+
siret: string;
|
|
5
|
+
created_at: Date;
|
|
6
|
+
updated_at: Date;
|
|
7
|
+
cached_libelle: string | null;
|
|
8
|
+
cached_nom_complet: string | null;
|
|
9
|
+
cached_enseigne: string | null;
|
|
10
|
+
cached_tranche_effectifs: TrancheEffectifs;
|
|
11
|
+
cached_tranche_effectifs_unite_legale: string | null;
|
|
12
|
+
cached_libelle_tranche_effectif: string | null;
|
|
13
|
+
cached_etat_administratif: string | null;
|
|
14
|
+
cached_est_active: string | null;
|
|
15
|
+
cached_statut_diffusion: string | null;
|
|
16
|
+
cached_est_diffusible: string | null;
|
|
17
|
+
cached_adresse: string | null;
|
|
18
|
+
cached_code_postal: string | null;
|
|
19
|
+
cached_code_officiel_geographique: string | null;
|
|
20
|
+
cached_activite_principale: string | null;
|
|
21
|
+
cached_libelle_activite_principale: string | null;
|
|
22
|
+
cached_categorie_juridique: string | null;
|
|
23
|
+
cached_libelle_categorie_juridique: string | null;
|
|
24
|
+
organization_info_fetched_at: Date | null;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=organization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.d.ts","sourceRoot":"","sources":["../../src/types/organization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8CAA8C,CAAC;AAIrF,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,wBAAwB,EAAE,gBAAgB,CAAC;IAC3C,qCAAqC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrD,+BAA+B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/C,yBAAyB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iCAAiC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjD,0BAA0B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,kCAAkC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClD,0BAA0B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,kCAAkC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClD,4BAA4B,EAAE,IAAI,GAAG,IAAI,CAAC;CAC3C"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const UserOrganizationLinkVerificationTypeSchema: z.ZodEnum<{
|
|
3
|
+
code_sent_to_official_contact_email: "code_sent_to_official_contact_email";
|
|
4
|
+
domain: "domain";
|
|
5
|
+
imported_from_coop_mediation_numerique: "imported_from_coop_mediation_numerique";
|
|
6
|
+
imported_from_inclusion_connect: "imported_from_inclusion_connect";
|
|
7
|
+
in_liste_dirigeants_rna: "in_liste_dirigeants_rna";
|
|
8
|
+
in_liste_dirigeants_rne: "in_liste_dirigeants_rne";
|
|
9
|
+
no_validation_means_available: "no_validation_means_available";
|
|
10
|
+
no_verification_means_for_entreprise_unipersonnelle: "no_verification_means_for_entreprise_unipersonnelle";
|
|
11
|
+
no_verification_means_for_small_association: "no_verification_means_for_small_association";
|
|
12
|
+
official_contact_email: "official_contact_email";
|
|
13
|
+
organization_dirigeant: "organization_dirigeant";
|
|
14
|
+
proof_received: "proof_received";
|
|
15
|
+
bypassed: "bypassed";
|
|
16
|
+
}>;
|
|
17
|
+
export type UserOrganizationLinkVerificationType = z.output<typeof UserOrganizationLinkVerificationTypeSchema>;
|
|
18
|
+
export declare const BaseUserOrganizationLinkSchema: z.ZodObject<{
|
|
19
|
+
is_external: z.ZodBoolean;
|
|
20
|
+
verification_type: z.ZodNullable<z.ZodEnum<{
|
|
21
|
+
code_sent_to_official_contact_email: "code_sent_to_official_contact_email";
|
|
22
|
+
domain: "domain";
|
|
23
|
+
imported_from_coop_mediation_numerique: "imported_from_coop_mediation_numerique";
|
|
24
|
+
imported_from_inclusion_connect: "imported_from_inclusion_connect";
|
|
25
|
+
in_liste_dirigeants_rna: "in_liste_dirigeants_rna";
|
|
26
|
+
in_liste_dirigeants_rne: "in_liste_dirigeants_rne";
|
|
27
|
+
no_validation_means_available: "no_validation_means_available";
|
|
28
|
+
no_verification_means_for_entreprise_unipersonnelle: "no_verification_means_for_entreprise_unipersonnelle";
|
|
29
|
+
no_verification_means_for_small_association: "no_verification_means_for_small_association";
|
|
30
|
+
official_contact_email: "official_contact_email";
|
|
31
|
+
organization_dirigeant: "organization_dirigeant";
|
|
32
|
+
proof_received: "proof_received";
|
|
33
|
+
bypassed: "bypassed";
|
|
34
|
+
}>>;
|
|
35
|
+
verified_at: z.ZodUnion<[z.ZodDate, z.ZodLiteral<null>]>;
|
|
36
|
+
has_been_greeted: z.ZodBoolean;
|
|
37
|
+
needs_official_contact_email_verification: z.ZodBoolean;
|
|
38
|
+
official_contact_email_verification_token: z.ZodNullable<z.ZodString>;
|
|
39
|
+
official_contact_email_verification_sent_at: z.ZodNullable<z.ZodDate>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
export type BaseUserOrganizationLink = z.output<typeof BaseUserOrganizationLinkSchema>;
|
|
42
|
+
export declare const UserOrganizationLinkSchema: z.ZodObject<{
|
|
43
|
+
is_external: z.ZodBoolean;
|
|
44
|
+
verification_type: z.ZodNullable<z.ZodEnum<{
|
|
45
|
+
code_sent_to_official_contact_email: "code_sent_to_official_contact_email";
|
|
46
|
+
domain: "domain";
|
|
47
|
+
imported_from_coop_mediation_numerique: "imported_from_coop_mediation_numerique";
|
|
48
|
+
imported_from_inclusion_connect: "imported_from_inclusion_connect";
|
|
49
|
+
in_liste_dirigeants_rna: "in_liste_dirigeants_rna";
|
|
50
|
+
in_liste_dirigeants_rne: "in_liste_dirigeants_rne";
|
|
51
|
+
no_validation_means_available: "no_validation_means_available";
|
|
52
|
+
no_verification_means_for_entreprise_unipersonnelle: "no_verification_means_for_entreprise_unipersonnelle";
|
|
53
|
+
no_verification_means_for_small_association: "no_verification_means_for_small_association";
|
|
54
|
+
official_contact_email: "official_contact_email";
|
|
55
|
+
organization_dirigeant: "organization_dirigeant";
|
|
56
|
+
proof_received: "proof_received";
|
|
57
|
+
bypassed: "bypassed";
|
|
58
|
+
}>>;
|
|
59
|
+
verified_at: z.ZodUnion<[z.ZodDate, z.ZodLiteral<null>]>;
|
|
60
|
+
has_been_greeted: z.ZodBoolean;
|
|
61
|
+
needs_official_contact_email_verification: z.ZodBoolean;
|
|
62
|
+
official_contact_email_verification_token: z.ZodNullable<z.ZodString>;
|
|
63
|
+
official_contact_email_verification_sent_at: z.ZodNullable<z.ZodDate>;
|
|
64
|
+
user_id: z.ZodNumber;
|
|
65
|
+
organization_id: z.ZodNumber;
|
|
66
|
+
created_at: z.ZodDate;
|
|
67
|
+
updated_at: z.ZodDate;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
export type UserOrganizationLink = z.output<typeof UserOrganizationLinkSchema>;
|
|
70
|
+
export declare const InsertUserOrganizationLinkSchema: z.ZodObject<{
|
|
71
|
+
user_id: z.ZodNumber;
|
|
72
|
+
verification_type: z.ZodNullable<z.ZodEnum<{
|
|
73
|
+
code_sent_to_official_contact_email: "code_sent_to_official_contact_email";
|
|
74
|
+
domain: "domain";
|
|
75
|
+
imported_from_coop_mediation_numerique: "imported_from_coop_mediation_numerique";
|
|
76
|
+
imported_from_inclusion_connect: "imported_from_inclusion_connect";
|
|
77
|
+
in_liste_dirigeants_rna: "in_liste_dirigeants_rna";
|
|
78
|
+
in_liste_dirigeants_rne: "in_liste_dirigeants_rne";
|
|
79
|
+
no_validation_means_available: "no_validation_means_available";
|
|
80
|
+
no_verification_means_for_entreprise_unipersonnelle: "no_verification_means_for_entreprise_unipersonnelle";
|
|
81
|
+
no_verification_means_for_small_association: "no_verification_means_for_small_association";
|
|
82
|
+
official_contact_email: "official_contact_email";
|
|
83
|
+
organization_dirigeant: "organization_dirigeant";
|
|
84
|
+
proof_received: "proof_received";
|
|
85
|
+
bypassed: "bypassed";
|
|
86
|
+
}>>;
|
|
87
|
+
organization_id: z.ZodNumber;
|
|
88
|
+
is_external: z.ZodOptional<z.ZodBoolean>;
|
|
89
|
+
needs_official_contact_email_verification: z.ZodOptional<z.ZodBoolean>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
export type InsertUserOrganizationLink = z.output<typeof InsertUserOrganizationLinkSchema>;
|
|
92
|
+
//# sourceMappingURL=user-organization-link.d.ts.map
|
|
@@ -0,0 +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,0CAA0C;;;;;;;;;;;;;;EAerD,CAAC;AAEH,MAAM,MAAM,oCAAoC,GAAG,CAAC,CAAC,MAAM,CACzD,OAAO,0CAA0C,CAClD,CAAC;AAIF,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"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const UserOrganizationLinkVerificationTypeSchema = z.enum([
|
|
3
|
+
"code_sent_to_official_contact_email",
|
|
4
|
+
"domain",
|
|
5
|
+
"imported_from_coop_mediation_numerique",
|
|
6
|
+
"imported_from_inclusion_connect",
|
|
7
|
+
"in_liste_dirigeants_rna",
|
|
8
|
+
"in_liste_dirigeants_rne",
|
|
9
|
+
"no_validation_means_available",
|
|
10
|
+
"no_verification_means_for_entreprise_unipersonnelle",
|
|
11
|
+
"no_verification_means_for_small_association",
|
|
12
|
+
"official_contact_email",
|
|
13
|
+
"organization_dirigeant",
|
|
14
|
+
"proof_received",
|
|
15
|
+
// Used in the sandbox environment to bypass the verification process
|
|
16
|
+
"bypassed",
|
|
17
|
+
]);
|
|
18
|
+
//
|
|
19
|
+
export const BaseUserOrganizationLinkSchema = z.object({
|
|
20
|
+
is_external: z.boolean(),
|
|
21
|
+
verification_type: UserOrganizationLinkVerificationTypeSchema.nullable(),
|
|
22
|
+
// updated when verification_type is changed
|
|
23
|
+
verified_at: z.date().or(z.literal(null)),
|
|
24
|
+
has_been_greeted: z.boolean(),
|
|
25
|
+
needs_official_contact_email_verification: z.boolean(),
|
|
26
|
+
official_contact_email_verification_token: z.string().nullable(),
|
|
27
|
+
official_contact_email_verification_sent_at: z.date().nullable(),
|
|
28
|
+
});
|
|
29
|
+
//
|
|
30
|
+
export const UserOrganizationLinkSchema = BaseUserOrganizationLinkSchema.extend({
|
|
31
|
+
user_id: z.number(),
|
|
32
|
+
organization_id: z.number(),
|
|
33
|
+
created_at: z.date(),
|
|
34
|
+
updated_at: z.date(),
|
|
35
|
+
});
|
|
36
|
+
//
|
|
37
|
+
export const InsertUserOrganizationLinkSchema = UserOrganizationLinkSchema.pick({
|
|
38
|
+
organization_id: true,
|
|
39
|
+
user_id: true,
|
|
40
|
+
verification_type: true,
|
|
41
|
+
}).merge(UserOrganizationLinkSchema.pick({
|
|
42
|
+
is_external: true,
|
|
43
|
+
needs_official_contact_email_verification: true,
|
|
44
|
+
}).partial());
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface User {
|
|
2
|
+
created_at: Date;
|
|
3
|
+
current_challenge: string | null;
|
|
4
|
+
email_verified_at: Date | null;
|
|
5
|
+
email_verified: boolean;
|
|
6
|
+
email: string;
|
|
7
|
+
encrypted_password: string | null;
|
|
8
|
+
encrypted_totp_key: string | null;
|
|
9
|
+
family_name: string | null;
|
|
10
|
+
force_2fa: boolean;
|
|
11
|
+
given_name: string | null;
|
|
12
|
+
id: number;
|
|
13
|
+
job: string | null;
|
|
14
|
+
last_sign_in_at: Date | null;
|
|
15
|
+
magic_link_sent_at: Date | null;
|
|
16
|
+
magic_link_token: string | null;
|
|
17
|
+
needs_inclusionconnect_onboarding_help: boolean;
|
|
18
|
+
needs_inclusionconnect_welcome_page: boolean;
|
|
19
|
+
phone_number: string | null;
|
|
20
|
+
reset_password_sent_at: Date | null;
|
|
21
|
+
reset_password_token: string | null;
|
|
22
|
+
sign_in_count: number;
|
|
23
|
+
totp_key_verified_at: Date | null;
|
|
24
|
+
updated_at: Date;
|
|
25
|
+
verify_email_sent_at: Date | null;
|
|
26
|
+
verify_email_token: string | null;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/types/user.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,IAAI;IACnB,UAAU,EAAE,IAAI,CAAC;IACjB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,iBAAiB,EAAE,IAAI,GAAG,IAAI,CAAC;IAC/B,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,eAAe,EAAE,IAAI,GAAG,IAAI,CAAC;IAC7B,kBAAkB,EAAE,IAAI,GAAG,IAAI,CAAC;IAChC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,sCAAsC,EAAE,OAAO,CAAC;IAChD,mCAAmC,EAAE,OAAO,CAAC;IAC7C,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,sBAAsB,EAAE,IAAI,GAAG,IAAI,CAAC;IACpC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,IAAI,GAAG,IAAI,CAAC;IAClC,UAAU,EAAE,IAAI,CAAC;IACjB,oBAAoB,EAAE,IAAI,GAAG,IAAI,CAAC;IAClC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proconnect-gouv/proconnect.identite",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"homepage": "https://github.com/proconnect-gouv/proconnect-identite/tree/main/packages/identite#readme",
|
|
5
|
+
"bugs": "https://github.com/proconnect-gouv/proconnect-identite/issues",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/proconnect-gouv/proconnect-identite.git",
|
|
9
|
+
"directory": "packages/identite"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"sideEffects": false,
|
|
13
|
+
"type": "module",
|
|
14
|
+
"imports": {
|
|
15
|
+
"#src/*": {
|
|
16
|
+
"types": "./dist/*/index.d.ts",
|
|
17
|
+
"default": "./dist/*/index.js"
|
|
18
|
+
},
|
|
19
|
+
"#testing": "./testing/index.ts",
|
|
20
|
+
"#testing/*": "./testing/*/index.ts"
|
|
21
|
+
},
|
|
22
|
+
"exports": {
|
|
23
|
+
"./*": {
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./dist/*/index.d.ts",
|
|
26
|
+
"default": "./dist/*/index.js"
|
|
27
|
+
},
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/*/index.d.ts",
|
|
30
|
+
"default": "./dist/*/index.js"
|
|
31
|
+
},
|
|
32
|
+
"types": "./dist/*/index.d.ts",
|
|
33
|
+
"default": "./dist/*/index.js"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "tsc --build tsconfig.lib.json",
|
|
38
|
+
"check": "npm run build -- --noEmit",
|
|
39
|
+
"clean": "rm -rf dist tsconfig*.tsbuildinfo",
|
|
40
|
+
"dev": "npm run build -- --watch --preserveWatchOutput",
|
|
41
|
+
"dev:test": "tsx --watch --test src/**/*.test.ts",
|
|
42
|
+
"test": "tsx --test --test-reporter=spec src/**/*.test.ts",
|
|
43
|
+
"test:update-snapshots": "tsx --test --test-reporter=spec --test-update-snapshots src/**/*.test.ts"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"leven": "^4.0.0",
|
|
47
|
+
"openid-client": "^6.6.4",
|
|
48
|
+
"sql-template-tag": "^5.2.1",
|
|
49
|
+
"zod": "^4.0.17"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@electric-sql/pglite": "^0.3.8",
|
|
53
|
+
"@proconnect-gouv/proconnect.core": "^1.0.0",
|
|
54
|
+
"@proconnect-gouv/proconnect.devtools.typescript": "1.0.0",
|
|
55
|
+
"@proconnect-gouv/proconnect.entreprise": "^1.0.0",
|
|
56
|
+
"@proconnect-gouv/proconnect.insee": "^1.0.0",
|
|
57
|
+
"@sinonjs/fake-timers": "^14.0.0",
|
|
58
|
+
"@types/node": "^22.18.6",
|
|
59
|
+
"await-to-js": "^3.0.0",
|
|
60
|
+
"node-pg-migrate": "^7.9.1",
|
|
61
|
+
"pg": "^8.16.3",
|
|
62
|
+
"tsx": "^4.20.3"
|
|
63
|
+
},
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public",
|
|
66
|
+
"provenance": true
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
export class InvalidCertificationError extends Error {
|
|
4
|
+
constructor(message?: string, options?: ErrorOptions) {
|
|
5
|
+
super(message, options);
|
|
6
|
+
this.name = "InvalidCertificationError";
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class InvalidSiretError extends Error {
|
|
11
|
+
constructor(message?: string, options?: ErrorOptions) {
|
|
12
|
+
super(message, options);
|
|
13
|
+
this.name = "InvalidSiretError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class NotFoundError extends Error {
|
|
18
|
+
constructor(message?: string, options?: ErrorOptions) {
|
|
19
|
+
super(message, options);
|
|
20
|
+
this.name = "NotFoundError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class OrganizationNotActiveError extends Error {
|
|
25
|
+
constructor(message?: string, options?: ErrorOptions) {
|
|
26
|
+
super(message, options);
|
|
27
|
+
this.name = "OrganizationNotActiveError";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class OrganizationNotFoundError extends Error {
|
|
32
|
+
constructor(message?: string, options?: ErrorOptions) {
|
|
33
|
+
super(message, options);
|
|
34
|
+
this.name = "OrganizationNotFoundError";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export class UserNotFoundError extends Error {
|
|
39
|
+
constructor(message?: string, options?: ErrorOptions) {
|
|
40
|
+
super(message, options);
|
|
41
|
+
this.name = "UserNotFoundError";
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class ModerationNotFoundError extends Error {
|
|
46
|
+
constructor(message?: string, options?: ErrorOptions) {
|
|
47
|
+
super(message, options);
|
|
48
|
+
this.name = "ModerationNotFoundError";
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import assert from "node:assert/strict";
|
|
4
|
+
import { describe, it } from "node:test";
|
|
5
|
+
import { distance } from "./distance.js";
|
|
6
|
+
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
describe("matching", () => {
|
|
10
|
+
it("same Bernard", () => {
|
|
11
|
+
assert.equal(
|
|
12
|
+
distance(
|
|
13
|
+
{
|
|
14
|
+
birthdate: new Date("1946-08-17"),
|
|
15
|
+
birthplace: "MARS",
|
|
16
|
+
family_name: "Bernard",
|
|
17
|
+
given_name: "Stéphane",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
birthdate: new Date("1946-08-17"),
|
|
21
|
+
birthplace: "MARS",
|
|
22
|
+
family_name: "Bernard",
|
|
23
|
+
given_name: "Stéphane",
|
|
24
|
+
},
|
|
25
|
+
),
|
|
26
|
+
0,
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("Stéphane but DuMoulin", () => {
|
|
31
|
+
assert.equal(
|
|
32
|
+
distance(
|
|
33
|
+
{
|
|
34
|
+
birthdate: new Date("1946-08-17"),
|
|
35
|
+
birthplace: "MARS",
|
|
36
|
+
family_name: "DuMoulin",
|
|
37
|
+
given_name: "Stéphane",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
birthdate: new Date("1946-08-17"),
|
|
41
|
+
birthplace: "MARS",
|
|
42
|
+
family_name: "Bernard",
|
|
43
|
+
given_name: "Stéphane",
|
|
44
|
+
},
|
|
45
|
+
),
|
|
46
|
+
8,
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("same Bernard but junior", () => {
|
|
51
|
+
assert.equal(
|
|
52
|
+
distance(
|
|
53
|
+
{
|
|
54
|
+
birthdate: new Date("1946-08-17"),
|
|
55
|
+
birthplace: "MARS",
|
|
56
|
+
family_name: "Bernard",
|
|
57
|
+
given_name: "Stéphane",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
birthdate: new Date("1986-08-17"),
|
|
61
|
+
birthplace: "MARS",
|
|
62
|
+
family_name: "Bernard",
|
|
63
|
+
given_name: "Stéphane",
|
|
64
|
+
},
|
|
65
|
+
),
|
|
66
|
+
14610,
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("same Bernard but from VENUS", () => {
|
|
71
|
+
assert.equal(
|
|
72
|
+
distance(
|
|
73
|
+
{
|
|
74
|
+
birthdate: new Date("1946-08-17"),
|
|
75
|
+
birthplace: "MARS",
|
|
76
|
+
family_name: "Bernard",
|
|
77
|
+
given_name: "Stéphane",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
birthdate: new Date("1946-08-17"),
|
|
81
|
+
birthplace: "VENUS",
|
|
82
|
+
family_name: "Bernard",
|
|
83
|
+
given_name: "Stéphane",
|
|
84
|
+
},
|
|
85
|
+
),
|
|
86
|
+
4,
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("inverse Bernard", () => {
|
|
91
|
+
assert.equal(
|
|
92
|
+
distance(
|
|
93
|
+
{
|
|
94
|
+
birthdate: new Date("1946-08-17"),
|
|
95
|
+
birthplace: "MARS",
|
|
96
|
+
family_name: "Stéphane",
|
|
97
|
+
given_name: "Bernard",
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
birthdate: new Date("1946-08-17"),
|
|
101
|
+
birthplace: "MARS",
|
|
102
|
+
family_name: "Bernard",
|
|
103
|
+
given_name: "Stéphane",
|
|
104
|
+
},
|
|
105
|
+
),
|
|
106
|
+
14,
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type { IdentityVector } from "#src/types";
|
|
4
|
+
import leven from "leven";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
// \from https://github.com/date-fns/date-fns/blob/v4.1.0/src/constants/index.ts#L84
|
|
9
|
+
export const millisecondsInDay = 86400000;
|
|
10
|
+
|
|
11
|
+
export function distance(
|
|
12
|
+
franceconnectUserInfo: IdentityVector,
|
|
13
|
+
sourceDirigeant: IdentityVector,
|
|
14
|
+
): number {
|
|
15
|
+
const sameGivenName = () =>
|
|
16
|
+
leven(
|
|
17
|
+
franceconnectUserInfo.given_name?.toUpperCase() ||
|
|
18
|
+
Math.random().toString(36),
|
|
19
|
+
sourceDirigeant.given_name?.toUpperCase() || Math.random().toString(36),
|
|
20
|
+
);
|
|
21
|
+
const sameFamilyName = () =>
|
|
22
|
+
leven(
|
|
23
|
+
franceconnectUserInfo.family_name?.toUpperCase() ||
|
|
24
|
+
Math.random().toString(36),
|
|
25
|
+
sourceDirigeant.family_name?.toUpperCase() || Math.random().toString(36),
|
|
26
|
+
);
|
|
27
|
+
const sameBirthDay = () =>
|
|
28
|
+
(Number(sourceDirigeant.birthdate) -
|
|
29
|
+
Number(franceconnectUserInfo.birthdate)) /
|
|
30
|
+
millisecondsInDay;
|
|
31
|
+
const sameBirthPlace = () =>
|
|
32
|
+
leven(
|
|
33
|
+
franceconnectUserInfo.birthplace || Math.random().toString(36),
|
|
34
|
+
sourceDirigeant.birthplace || Math.random().toString(36),
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
return [sameGivenName, sameFamilyName, sameBirthDay, sameBirthPlace].reduce(
|
|
38
|
+
(value, metric) => value + metric(),
|
|
39
|
+
0,
|
|
40
|
+
);
|
|
41
|
+
}
|