@proconnect-gouv/proconnect.identite 15.0.0 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/dist/connectors/index.d.ts +2 -72
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/index.js +5 -14
- package/dist/managers/certification/certification-score.d.ts +16 -0
- package/dist/managers/certification/certification-score.d.ts.map +1 -1
- package/dist/managers/certification/certification-score.js +65 -41
- package/dist/managers/certification/process-certification-dirigeant.d.ts.map +1 -1
- package/dist/managers/organization/get-organization-info.d.ts.map +1 -1
- package/dist/repositories/authenticator/delete-all-authenticators-by-user-id.d.ts +3 -0
- package/dist/repositories/authenticator/delete-all-authenticators-by-user-id.d.ts.map +1 -0
- package/dist/repositories/authenticator/delete-all-authenticators-by-user-id.js +12 -0
- package/dist/repositories/authenticator/index.d.ts +1 -1
- package/dist/repositories/authenticator/index.d.ts.map +1 -1
- package/dist/repositories/authenticator/index.js +1 -1
- package/dist/repositories/moderation/index.d.ts +0 -2
- package/dist/repositories/moderation/index.d.ts.map +1 -1
- package/dist/repositories/moderation/index.js +0 -2
- package/dist/repositories/oidc-client/upsert-authorization-request.d.ts +1 -1
- package/dist/repositories/oidc-client/upsert-authorization-request.d.ts.map +1 -1
- package/dist/repositories/oidc-client/upsert-authorization-request.js +6 -4
- package/dist/repositories/organization/index.d.ts +0 -2
- package/dist/repositories/organization/index.d.ts.map +1 -1
- package/dist/repositories/organization/index.js +0 -2
- package/dist/repositories/user/index.d.ts +0 -1
- package/dist/repositories/user/index.d.ts.map +1 -1
- package/dist/repositories/user/index.js +0 -1
- package/dist/services/organization/get-membership-changes-by-domain-verification.d.ts +18 -0
- package/dist/services/organization/get-membership-changes-by-domain-verification.d.ts.map +1 -0
- package/dist/services/organization/get-membership-changes-by-domain-verification.js +21 -0
- package/dist/services/organization/index.d.ts +1 -1
- package/dist/services/organization/index.d.ts.map +1 -1
- package/dist/services/organization/index.js +1 -1
- package/dist/types/authenticator.d.ts.map +1 -1
- package/dist/types/authorization-request.d.ts +2 -0
- package/dist/types/authorization-request.d.ts.map +1 -1
- package/dist/types/authorization-request.js +4 -1
- package/package.json +2 -2
- package/src/connectors/index.ts +2 -17
- package/src/managers/certification/certification-score.test.ts +64 -1
- package/src/managers/certification/certification-score.ts +84 -50
- package/src/managers/certification/process-certification-dirigeant.ts +1 -2
- package/src/managers/organization/get-organization-info.ts +1 -2
- package/src/repositories/authenticator/delete-all-authenticators-by-user-id.test.ts +51 -0
- package/src/repositories/authenticator/delete-all-authenticators-by-user-id.ts +22 -0
- package/src/repositories/authenticator/index.ts +1 -1
- package/src/repositories/moderation/index.ts +0 -2
- package/src/repositories/oidc-client/upsert-authorization-request.test.ts +18 -5
- package/src/repositories/oidc-client/upsert-authorization-request.ts +6 -3
- package/src/repositories/organization/index.ts +0 -2
- package/src/repositories/user/index.ts +0 -1
- package/src/services/organization/get-membership-changes-by-domain-verification.test.ts +91 -0
- package/src/services/organization/get-membership-changes-by-domain-verification.ts +46 -0
- package/src/services/organization/index.ts +1 -1
- package/src/types/authenticator.ts +1 -7
- package/src/types/authorization-request.ts +5 -1
- package/testing/index.ts +2 -1
- package/dist/repositories/authenticator/update-authenticator.d.ts +0 -3
- package/dist/repositories/authenticator/update-authenticator.d.ts.map +0 -1
- package/dist/repositories/authenticator/update-authenticator.js +0 -13
- package/dist/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.d.ts +0 -3
- package/dist/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.d.ts.map +0 -1
- package/dist/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.js +0 -15
- package/dist/repositories/email-deliverability-whitelist/index.d.ts +0 -2
- package/dist/repositories/email-deliverability-whitelist/index.d.ts.map +0 -1
- package/dist/repositories/email-deliverability-whitelist/index.js +0 -2
- package/dist/repositories/moderation/find-pending-moderation.d.ts +0 -20
- package/dist/repositories/moderation/find-pending-moderation.d.ts.map +0 -1
- package/dist/repositories/moderation/find-pending-moderation.js +0 -16
- package/dist/repositories/moderation/find-rejected-moderation.d.ts +0 -20
- package/dist/repositories/moderation/find-rejected-moderation.d.ts.map +0 -1
- package/dist/repositories/moderation/find-rejected-moderation.js +0 -17
- package/dist/repositories/organization/find-by-siret.d.ts +0 -3
- package/dist/repositories/organization/find-by-siret.d.ts.map +0 -1
- package/dist/repositories/organization/find-by-siret.js +0 -13
- package/dist/repositories/organization/find-pending-by-user-id.d.ts +0 -6
- package/dist/repositories/organization/find-pending-by-user-id.d.ts.map +0 -1
- package/dist/repositories/organization/find-pending-by-user-id.js +0 -18
- package/dist/repositories/user/find-by-reset-password-token.d.ts +0 -29
- package/dist/repositories/user/find-by-reset-password-token.d.ts.map +0 -1
- package/dist/repositories/user/find-by-reset-password-token.js +0 -12
- package/dist/services/organization/get-member-ids-promoted-by-domain.d.ts +0 -9
- package/dist/services/organization/get-member-ids-promoted-by-domain.d.ts.map +0 -1
- package/dist/services/organization/get-member-ids-promoted-by-domain.js +0 -11
- package/src/repositories/authenticator/update-authenticator.test.ts +0 -41
- package/src/repositories/authenticator/update-authenticator.ts +0 -29
- package/src/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.test.ts +0 -45
- package/src/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.ts +0 -24
- package/src/repositories/email-deliverability-whitelist/index.ts +0 -3
- package/src/repositories/moderation/find-pending-moderation.test.ts +0 -57
- package/src/repositories/moderation/find-pending-moderation.ts +0 -35
- package/src/repositories/moderation/find-rejected-moderation.test.ts +0 -57
- package/src/repositories/moderation/find-rejected-moderation.ts +0 -37
- package/src/repositories/organization/find-by-siret.test.ts +0 -35
- package/src/repositories/organization/find-by-siret.ts +0 -21
- package/src/repositories/organization/find-pending-by-user-id.test.ts +0 -51
- package/src/repositories/organization/find-pending-by-user-id.ts +0 -27
- package/src/repositories/user/find-by-reset-password-token.test.ts +0 -37
- package/src/repositories/user/find-by-reset-password-token.ts +0 -20
- package/src/services/organization/get-member-ids-promoted-by-domain.test.ts +0 -100
- package/src/services/organization/get-member-ids-promoted-by-domain.ts +0 -27
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./compute-service-public-info.js";
|
|
2
|
-
export * from "./get-
|
|
2
|
+
export * from "./get-membership-changes-by-domain-verification.js";
|
|
3
3
|
export * from "./is-domain-allowed-for-organization.js";
|
|
4
4
|
export * from "./is-entreprise-unipersonnelle.js";
|
|
5
5
|
export * from "./is-organization-covered-by-certification-dirigeant.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/organization/index.ts"],"names":[],"mappings":"AAEA,cAAc,kCAAkC,CAAC;AACjD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/organization/index.ts"],"names":[],"mappings":"AAEA,cAAc,kCAAkC,CAAC;AACjD,cAAc,oDAAoD,CAAC;AACnE,cAAc,yCAAyC,CAAC;AACxD,cAAc,mCAAmC,CAAC;AAClD,cAAc,yDAAyD,CAAC;AACxE,cAAc,oCAAoC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
2
|
export * from "./compute-service-public-info.js";
|
|
3
|
-
export * from "./get-
|
|
3
|
+
export * from "./get-membership-changes-by-domain-verification.js";
|
|
4
4
|
export * from "./is-domain-allowed-for-organization.js";
|
|
5
5
|
export * from "./is-entreprise-unipersonnelle.js";
|
|
6
6
|
export * from "./is-organization-covered-by-certification-dirigeant.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticator.d.ts","sourceRoot":"","sources":["../../src/types/authenticator.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AACrC,MAAM,MAAM,4BAA4B,
|
|
1
|
+
{"version":3,"file":"authenticator.d.ts","sourceRoot":"","sources":["../../src/types/authenticator.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC;AACrC,MAAM,MAAM,4BAA4B,GACtC,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,UAAU,GAAG,KAAK,GAAG,YAAY,GAAG,KAAK,CAAC;AACzE,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG,aAAa,CAAC;AAIlE,MAAM,WAAW,iBAAiB;IAChC,aAAa,EAAE,eAAe,CAAC;IAC/B,qBAAqB,EAAE,UAAU,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB,EAAE,oBAAoB,CAAC;IAC7C,oBAAoB,EAAE,OAAO,CAAC;IAC9B,UAAU,CAAC,EAAE,4BAA4B,EAAE,CAAC;IAC5C,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,IAAI,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,IAAI,CAAC;CAClB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const AuthorizationRequestOutcomeEnum: z.ZodEnum<{
|
|
3
|
+
signed_out: "signed_out";
|
|
3
4
|
succeeded: "succeeded";
|
|
4
5
|
}>;
|
|
5
6
|
export type AuthorizationRequestOutcome = z.output<typeof AuthorizationRequestOutcomeEnum>;
|
|
@@ -11,6 +12,7 @@ export interface BaseAuthorizationRequest {
|
|
|
11
12
|
user_ip_address: string | null;
|
|
12
13
|
interaction_cid: string | null;
|
|
13
14
|
outcome: AuthorizationRequestOutcome | null;
|
|
15
|
+
sid: string | null;
|
|
14
16
|
}
|
|
15
17
|
export interface AuthorizationRequest extends BaseAuthorizationRequest {
|
|
16
18
|
id: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization-request.d.ts","sourceRoot":"","sources":["../../src/types/authorization-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,+BAA+B
|
|
1
|
+
{"version":3,"file":"authorization-request.d.ts","sourceRoot":"","sources":["../../src/types/authorization-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,+BAA+B;;;EAG1C,CAAC;AAEH,MAAM,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAChD,OAAO,+BAA+B,CACvC,CAAC;AAEF,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,EAAE,2BAA2B,GAAG,IAAI,CAAC;IAC5C,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,oBAAqB,SAAQ,wBAAwB;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,IAAI,CAAC;IACjB,UAAU,EAAE,IAAI,CAAC;CAClB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@proconnect-gouv/proconnect.identite",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "17.0.0",
|
|
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": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"zod": "^4.6.7"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@electric-sql/pglite": "^0.
|
|
53
|
+
"@electric-sql/pglite": "^0.5.16",
|
|
54
54
|
"@proconnect-gouv/proconnect.annuaire_entreprises": "^3.0.5",
|
|
55
55
|
"@proconnect-gouv/proconnect.api_entreprise": "^2.3.0",
|
|
56
56
|
"@proconnect-gouv/proconnect.core": "^1.1.0",
|
package/src/connectors/index.ts
CHANGED
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
createAuthenticatorFactory,
|
|
5
|
+
deleteAllAuthenticatorsByUserIdFactory,
|
|
5
6
|
deleteAuthenticatorFactory,
|
|
6
7
|
findAuthenticatorFactory,
|
|
7
8
|
findAuthenticatorsByUserIdFactory,
|
|
8
|
-
updateAuthenticatorFactory,
|
|
9
9
|
} from "#src/repositories/authenticator";
|
|
10
|
-
import { findEmailInDeliverabilityWhiteListFactory } from "#src/repositories/email-deliverability-whitelist";
|
|
11
10
|
import {
|
|
12
11
|
addDomainFactory,
|
|
13
12
|
findEmailDomainsByOrganizationIdFactory,
|
|
@@ -16,8 +15,6 @@ import { findFranceconnectUserinfoFactory } from "#src/repositories/franceconnec
|
|
|
16
15
|
import {
|
|
17
16
|
deleteModerationFactory,
|
|
18
17
|
findModerationByIdFactory,
|
|
19
|
-
findPendingModerationFactory,
|
|
20
|
-
findRejectedModerationFactory,
|
|
21
18
|
getModerationByIdFactory,
|
|
22
19
|
reopenModerationFactory,
|
|
23
20
|
} from "#src/repositories/moderation";
|
|
@@ -31,10 +28,8 @@ import {
|
|
|
31
28
|
upsertAuthorizationRequestFactory,
|
|
32
29
|
} from "#src/repositories/oidc-client";
|
|
33
30
|
import {
|
|
34
|
-
findBySiretFactory,
|
|
35
31
|
findByUserIdFactory,
|
|
36
32
|
findOrganizationByIdFactory,
|
|
37
|
-
findPendingByUserIdFactory,
|
|
38
33
|
getOrganizationByIdFactory,
|
|
39
34
|
upsertFactory,
|
|
40
35
|
} from "#src/repositories/organization";
|
|
@@ -47,7 +42,6 @@ import {
|
|
|
47
42
|
createUserFactory,
|
|
48
43
|
findByEmailFactory,
|
|
49
44
|
findByMagicLinkTokenFactory,
|
|
50
|
-
findByResetPasswordTokenFactory,
|
|
51
45
|
findByIdFactory as findUserByIdFactory,
|
|
52
46
|
getByIdFactory,
|
|
53
47
|
updateUserFactory,
|
|
@@ -84,13 +78,9 @@ export function createContext({
|
|
|
84
78
|
authenticators: {
|
|
85
79
|
create: createAuthenticatorFactory({ pg }),
|
|
86
80
|
delete: deleteAuthenticatorFactory({ pg }),
|
|
81
|
+
deleteAllByUserId: deleteAllAuthenticatorsByUserIdFactory({ pg }),
|
|
87
82
|
find: findAuthenticatorFactory({ pg }),
|
|
88
83
|
findByUserId: findAuthenticatorsByUserIdFactory({ pg }),
|
|
89
|
-
update: updateAuthenticatorFactory({ pg }),
|
|
90
|
-
},
|
|
91
|
-
email_deliverability_whitelist: {
|
|
92
|
-
findEmailInDeliverabilityWhiteList:
|
|
93
|
-
findEmailInDeliverabilityWhiteListFactory({ pg }),
|
|
94
84
|
},
|
|
95
85
|
email_domains: {
|
|
96
86
|
addDomain: addDomainFactory({ pg }),
|
|
@@ -100,8 +90,6 @@ export function createContext({
|
|
|
100
90
|
moderations: {
|
|
101
91
|
delete: deleteModerationFactory({ pg }),
|
|
102
92
|
findById: findModerationByIdFactory({ pg }),
|
|
103
|
-
findPending: findPendingModerationFactory({ pg }),
|
|
104
|
-
findRejected: findRejectedModerationFactory({ pg }),
|
|
105
93
|
getById: getModerationByIdFactory({ pg }),
|
|
106
94
|
reopen: reopenModerationFactory({ pg }),
|
|
107
95
|
},
|
|
@@ -116,9 +104,7 @@ export function createContext({
|
|
|
116
104
|
},
|
|
117
105
|
organizations: {
|
|
118
106
|
findById: findOrganizationByIdFactory({ pg }),
|
|
119
|
-
findBySiret: findBySiretFactory({ pg }),
|
|
120
107
|
findByUserId: findByUserIdFactory({ pg }),
|
|
121
|
-
findPendingByUserId: findPendingByUserIdFactory({ pg }),
|
|
122
108
|
getById: getOrganizationByIdFactory({ pg }),
|
|
123
109
|
upsert: upsertFactory({ pg }),
|
|
124
110
|
},
|
|
@@ -136,7 +122,6 @@ export function createContext({
|
|
|
136
122
|
findByEmail: findByEmailFactory({ pg }),
|
|
137
123
|
findById: findUserByIdFactory({ pg }),
|
|
138
124
|
findByMagicLinkToken: findByMagicLinkTokenFactory({ pg }),
|
|
139
|
-
findByResetPasswordToken: findByResetPasswordTokenFactory({ pg }),
|
|
140
125
|
getById: getByIdFactory({ pg }),
|
|
141
126
|
update: updateUserFactory({ pg }),
|
|
142
127
|
},
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import assert from "node:assert/strict";
|
|
4
4
|
import { describe, it } from "node:test";
|
|
5
|
-
import { certificationScore } from "./certification-score.js";
|
|
5
|
+
import { certificationScore, compareCriteria } from "./certification-score.js";
|
|
6
6
|
|
|
7
7
|
//
|
|
8
8
|
|
|
@@ -343,3 +343,66 @@ describe("certification scoring", () => {
|
|
|
343
343
|
);
|
|
344
344
|
});
|
|
345
345
|
});
|
|
346
|
+
|
|
347
|
+
describe("compareCriteria", () => {
|
|
348
|
+
it("keeps the received and the compared value of each side", () => {
|
|
349
|
+
assert.deepStrictEqual(
|
|
350
|
+
compareCriteria(
|
|
351
|
+
{
|
|
352
|
+
birthcountry: "99100",
|
|
353
|
+
birthdate: new Date("1946-08-17"),
|
|
354
|
+
birthplace: "47019",
|
|
355
|
+
family_name: "Bernard",
|
|
356
|
+
gender: "male",
|
|
357
|
+
given_name: "Jean-Pierre Paul",
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
birthcountry: null,
|
|
361
|
+
birthdate: new Date("1946-08-18"),
|
|
362
|
+
birthplace: "47209",
|
|
363
|
+
family_name: "BERNARD",
|
|
364
|
+
gender: null,
|
|
365
|
+
given_name: "Jean Pierre",
|
|
366
|
+
},
|
|
367
|
+
),
|
|
368
|
+
[
|
|
369
|
+
{
|
|
370
|
+
criterion: "family_name",
|
|
371
|
+
franceconnect: { compared: "BERNARD", raw: "Bernard" },
|
|
372
|
+
matched: true,
|
|
373
|
+
source: { compared: "BERNARD", raw: "BERNARD" },
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
criterion: "first_name",
|
|
377
|
+
franceconnect: { compared: "JEAN", raw: "Jean-Pierre Paul" },
|
|
378
|
+
matched: true,
|
|
379
|
+
source: { compared: "JEAN", raw: "Jean Pierre" },
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
criterion: "gender",
|
|
383
|
+
franceconnect: { compared: "male", raw: "male" },
|
|
384
|
+
matched: true,
|
|
385
|
+
source: { compared: null, raw: null },
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
criterion: "birth_date",
|
|
389
|
+
franceconnect: {
|
|
390
|
+
compared: "1946-08-17T00:00:00.000Z",
|
|
391
|
+
raw: "1946-08-17T00:00:00.000Z",
|
|
392
|
+
},
|
|
393
|
+
matched: false,
|
|
394
|
+
source: {
|
|
395
|
+
compared: "1946-08-18T00:00:00.000Z",
|
|
396
|
+
raw: "1946-08-18T00:00:00.000Z",
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
criterion: "birth_place",
|
|
401
|
+
franceconnect: { compared: "47209", raw: "47019" },
|
|
402
|
+
matched: true,
|
|
403
|
+
source: { compared: "47209", raw: "47209" },
|
|
404
|
+
},
|
|
405
|
+
],
|
|
406
|
+
);
|
|
407
|
+
});
|
|
408
|
+
});
|
|
@@ -40,69 +40,103 @@ export function certificationScore(
|
|
|
40
40
|
identitePivot: IdentityVector,
|
|
41
41
|
sourceDirigeant: IdentityVector,
|
|
42
42
|
) {
|
|
43
|
-
|
|
43
|
+
return new Set(
|
|
44
|
+
compareCriteria(identitePivot, sourceDirigeant)
|
|
45
|
+
.filter(({ matched }) => matched)
|
|
46
|
+
.map(({ criterion }) => criterion),
|
|
47
|
+
);
|
|
48
|
+
}
|
|
44
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Compares each evaluated criterion and keeps, for both sides, the value as
|
|
52
|
+
* received (`raw`) and the value actually compared (`compared`).
|
|
53
|
+
*/
|
|
54
|
+
export function compareCriteria(
|
|
55
|
+
identitePivot: IdentityVector,
|
|
56
|
+
sourceDirigeant: IdentityVector,
|
|
57
|
+
) {
|
|
45
58
|
// 1. Family name match (after normalization)
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
) {
|
|
54
|
-
matches.add(MatchCriteria.enum.family_name);
|
|
55
|
-
}
|
|
59
|
+
const family_name = compare({
|
|
60
|
+
criterion: MatchCriteria.enum.family_name,
|
|
61
|
+
franceconnect: identitePivot.family_name,
|
|
62
|
+
match: bothPresentAndEqual,
|
|
63
|
+
normalize: normalizeText,
|
|
64
|
+
source: sourceDirigeant.family_name,
|
|
65
|
+
});
|
|
56
66
|
|
|
57
67
|
// 2. First name match (first name only, after normalization)
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
const first_name = compare({
|
|
69
|
+
criterion: MatchCriteria.enum.first_name,
|
|
70
|
+
franceconnect: identitePivot.given_name,
|
|
71
|
+
match: bothPresentAndEqual,
|
|
72
|
+
normalize: extractFirstName,
|
|
73
|
+
source: sourceDirigeant.given_name,
|
|
74
|
+
});
|
|
64
75
|
|
|
65
76
|
// 3. Gender match (match or absent in source)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
identitePivot.gender
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
77
|
+
const gender = compare({
|
|
78
|
+
criterion: MatchCriteria.enum.gender,
|
|
79
|
+
franceconnect: identitePivot.gender,
|
|
80
|
+
match: (pivot, source) => !source || pivot === source,
|
|
81
|
+
source: sourceDirigeant.gender,
|
|
82
|
+
});
|
|
72
83
|
|
|
73
84
|
// 4. Birth date match (exact match)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
85
|
+
const birth_date = compare({
|
|
86
|
+
criterion: MatchCriteria.enum.birth_date,
|
|
87
|
+
franceconnect: identitePivot.birthdate?.toISOString() ?? null,
|
|
88
|
+
match: bothPresentAndEqual,
|
|
89
|
+
source: sourceDirigeant.birthdate?.toISOString() ?? null,
|
|
90
|
+
});
|
|
81
91
|
|
|
82
92
|
// 5. Birth place match (different logic for French vs foreigners)
|
|
83
93
|
const isFrench =
|
|
84
94
|
!identitePivot.birthcountry || identitePivot.birthcountry === "99100";
|
|
95
|
+
const birth = isFrench
|
|
96
|
+
? // For French: commune code (with conversion), match if source has none
|
|
97
|
+
compare({
|
|
98
|
+
criterion: MatchCriteria.enum.birth_place,
|
|
99
|
+
franceconnect: identitePivot.birthplace,
|
|
100
|
+
match: (pivot, source) => !source || (!!pivot && pivot === source),
|
|
101
|
+
normalize: convertCommuneCode,
|
|
102
|
+
source: sourceDirigeant.birthplace,
|
|
103
|
+
})
|
|
104
|
+
: // For foreigners: country code (COG 99XXX), match if either side has none
|
|
105
|
+
compare({
|
|
106
|
+
criterion: MatchCriteria.enum.birth_country,
|
|
107
|
+
franceconnect: identitePivot.birthcountry,
|
|
108
|
+
match: (pivot, source) =>
|
|
109
|
+
pivot === null || source === null || pivot === source,
|
|
110
|
+
source: sourceDirigeant.birthcountry,
|
|
111
|
+
});
|
|
85
112
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
113
|
+
return [family_name, first_name, gender, birth_date, birth];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function bothPresentAndEqual(pivot: string | null, source: string | null) {
|
|
117
|
+
return !!pivot && !!source && pivot === source;
|
|
118
|
+
}
|
|
90
119
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
120
|
+
function compare({
|
|
121
|
+
criterion,
|
|
122
|
+
franceconnect,
|
|
123
|
+
match,
|
|
124
|
+
normalize = (value) => value,
|
|
125
|
+
source,
|
|
126
|
+
}: {
|
|
127
|
+
criterion: MatchCriteria;
|
|
128
|
+
franceconnect: string | null;
|
|
129
|
+
match: (pivot: string | null, source: string | null) => boolean;
|
|
130
|
+
normalize?: (value: string | null) => string | null;
|
|
131
|
+
source: string | null;
|
|
132
|
+
}) {
|
|
133
|
+
const compared_franceconnect = normalize(franceconnect);
|
|
134
|
+
const compared_source = normalize(source);
|
|
106
135
|
|
|
107
|
-
return
|
|
136
|
+
return {
|
|
137
|
+
criterion,
|
|
138
|
+
franceconnect: { compared: compared_franceconnect, raw: franceconnect },
|
|
139
|
+
matched: match(compared_franceconnect, compared_source),
|
|
140
|
+
source: { compared: compared_source, raw: source },
|
|
141
|
+
};
|
|
108
142
|
}
|
|
@@ -45,8 +45,7 @@ export function getCertificationDirigeantDataSourceLabels(
|
|
|
45
45
|
//
|
|
46
46
|
|
|
47
47
|
export type SourceSelection =
|
|
48
|
-
|
|
49
|
-
| { kind: "preferred" };
|
|
48
|
+
{ kind: "fallback"; exception: unknown } | { kind: "preferred" };
|
|
50
49
|
|
|
51
50
|
async function getMandatairesSociaux(
|
|
52
51
|
{ client: { api_entreprise, rne } }: Context,
|
|
@@ -14,8 +14,7 @@ import * as ApiRne from "./adapters/rne.js";
|
|
|
14
14
|
//
|
|
15
15
|
|
|
16
16
|
export type RneEnrichment =
|
|
17
|
-
| { kind: "
|
|
18
|
-
| { kind: "failed"; exception: unknown };
|
|
17
|
+
{ kind: "enriched" } | { kind: "failed"; exception: unknown };
|
|
19
18
|
|
|
20
19
|
export type OrganizationInfoLookup =
|
|
21
20
|
| { kind: "api_entreprise_failed"; exception: unknown }
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import { emptyDatabase, migrate, pg } from "#testing";
|
|
4
|
+
import assert from "node:assert/strict";
|
|
5
|
+
import { before, beforeEach, suite, test } from "node:test";
|
|
6
|
+
import { deleteAllAuthenticatorsByUserIdFactory } from "./delete-all-authenticators-by-user-id.js";
|
|
7
|
+
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
const deleteAllAuthenticatorsByUserId = deleteAllAuthenticatorsByUserIdFactory({
|
|
11
|
+
pg: pg as any,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
suite("deleteAllAuthenticatorsByUserIdFactory", () => {
|
|
15
|
+
before(migrate);
|
|
16
|
+
beforeEach(emptyDatabase);
|
|
17
|
+
|
|
18
|
+
test("should delete all the authenticators of the user only", async () => {
|
|
19
|
+
await pg.sql`
|
|
20
|
+
INSERT INTO users
|
|
21
|
+
(id, email, created_at, updated_at, given_name, family_name, phone_number, job)
|
|
22
|
+
VALUES
|
|
23
|
+
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque'),
|
|
24
|
+
(2, 'rogal.dorn@imperialfists.world', '4444-04-04', '4444-04-04', 'rogal', 'dorn', 'i', 'primarque')
|
|
25
|
+
;
|
|
26
|
+
`;
|
|
27
|
+
await pg.sql`
|
|
28
|
+
INSERT INTO authenticators
|
|
29
|
+
(credential_id, credential_public_key, counter, credential_backed_up, user_id, usage_count, user_verified)
|
|
30
|
+
VALUES
|
|
31
|
+
('CRED1', '\\x00', 0, false, 1, 0, true),
|
|
32
|
+
('CRED2', '\\x00', 0, false, 1, 0, true),
|
|
33
|
+
('CRED3', '\\x00', 0, false, 2, 0, true)
|
|
34
|
+
;
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
const result = await deleteAllAuthenticatorsByUserId(1);
|
|
38
|
+
|
|
39
|
+
assert.equal(result, true);
|
|
40
|
+
const { rows } = await pg.query(
|
|
41
|
+
"SELECT credential_id FROM authenticators ORDER BY credential_id",
|
|
42
|
+
);
|
|
43
|
+
assert.deepEqual(rows, [{ credential_id: "CRED3" }]);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("should return false when the user has no authenticator", async () => {
|
|
47
|
+
const result = await deleteAllAuthenticatorsByUserId(1);
|
|
48
|
+
|
|
49
|
+
assert.equal(result, false);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type { DatabaseContext } from "#src/types";
|
|
4
|
+
import { type QueryResult } from "pg";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
export function deleteAllAuthenticatorsByUserIdFactory({
|
|
9
|
+
pg,
|
|
10
|
+
}: DatabaseContext) {
|
|
11
|
+
return async function deleteAllAuthenticatorsByUserId(user_id: number) {
|
|
12
|
+
const { rowCount, affectedRows } = (await pg.query(
|
|
13
|
+
`
|
|
14
|
+
DELETE FROM authenticators
|
|
15
|
+
WHERE user_id = $1
|
|
16
|
+
RETURNING *`,
|
|
17
|
+
[user_id],
|
|
18
|
+
)) as QueryResult & { affectedRows?: number };
|
|
19
|
+
|
|
20
|
+
return (affectedRows ?? rowCount ?? 0) > 0;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
3
|
export * from "./create-authenticator.js";
|
|
4
|
+
export * from "./delete-all-authenticators-by-user-id.js";
|
|
4
5
|
export * from "./delete-authenticator.js";
|
|
5
6
|
export * from "./find-authenticator.js";
|
|
6
7
|
export * from "./find-authenticators-by-user-id.js";
|
|
7
|
-
export * from "./update-authenticator.js";
|
|
@@ -2,7 +2,5 @@
|
|
|
2
2
|
|
|
3
3
|
export * from "./delete-moderation.js";
|
|
4
4
|
export * from "./find-moderation-by-id.js";
|
|
5
|
-
export * from "./find-pending-moderation.js";
|
|
6
|
-
export * from "./find-rejected-moderation.js";
|
|
7
5
|
export * from "./get-moderation-by-id.js";
|
|
8
6
|
export * from "./reopen-moderation.js";
|
|
@@ -40,12 +40,14 @@ suite("upsertAuthorizationRequestFactory", () => {
|
|
|
40
40
|
user_ip_address: "127.0.0.1",
|
|
41
41
|
interaction_cid: "Rex5_Tq4tBqqwz0xPTJyd",
|
|
42
42
|
outcome: "succeeded",
|
|
43
|
+
sid: "ulthwe",
|
|
43
44
|
});
|
|
44
45
|
|
|
45
46
|
assert.equal(authorizationRequest.user_id, 1);
|
|
46
47
|
assert.equal(authorizationRequest.oidc_client_id, 1);
|
|
47
48
|
assert.equal(authorizationRequest.interaction_cid, "Rex5_Tq4tBqqwz0xPTJyd");
|
|
48
49
|
assert.equal(authorizationRequest.outcome, "succeeded");
|
|
50
|
+
assert.equal(authorizationRequest.sid, "ulthwe");
|
|
49
51
|
});
|
|
50
52
|
|
|
51
53
|
test("should update the authorization request of the same interaction", async () => {
|
|
@@ -60,36 +62,47 @@ suite("upsertAuthorizationRequestFactory", () => {
|
|
|
60
62
|
...request,
|
|
61
63
|
interaction_cid: "caliban",
|
|
62
64
|
outcome: null,
|
|
65
|
+
sid: null,
|
|
63
66
|
});
|
|
64
67
|
await upsertAuthorizationRequest({
|
|
65
68
|
...request,
|
|
66
69
|
interaction_cid: "fallen",
|
|
67
70
|
outcome: null,
|
|
71
|
+
sid: "rock",
|
|
68
72
|
});
|
|
69
73
|
await upsertAuthorizationRequest({
|
|
70
74
|
...request,
|
|
71
75
|
interaction_cid: "caliban",
|
|
72
76
|
outcome: "succeeded",
|
|
77
|
+
sid: "rock",
|
|
78
|
+
});
|
|
79
|
+
await upsertAuthorizationRequest({
|
|
80
|
+
...request,
|
|
81
|
+
interaction_cid: "fallen",
|
|
82
|
+
outcome: null,
|
|
83
|
+
sid: null,
|
|
73
84
|
});
|
|
74
85
|
await upsertAuthorizationRequest({
|
|
75
86
|
...request,
|
|
76
87
|
interaction_cid: null,
|
|
77
88
|
outcome: "succeeded",
|
|
89
|
+
sid: "rock",
|
|
78
90
|
});
|
|
79
91
|
await upsertAuthorizationRequest({
|
|
80
92
|
...request,
|
|
81
93
|
interaction_cid: null,
|
|
82
94
|
outcome: "succeeded",
|
|
95
|
+
sid: "rock",
|
|
83
96
|
});
|
|
84
97
|
|
|
85
98
|
const { rows } = await pg.query(
|
|
86
|
-
"SELECT interaction_cid, outcome FROM users_oidc_clients ORDER BY id",
|
|
99
|
+
"SELECT interaction_cid, outcome, sid FROM users_oidc_clients ORDER BY id",
|
|
87
100
|
);
|
|
88
101
|
assert.deepEqual(rows, [
|
|
89
|
-
{ interaction_cid: "caliban", outcome: "succeeded" },
|
|
90
|
-
{ interaction_cid: "fallen", outcome: null },
|
|
91
|
-
{ interaction_cid: null, outcome: "succeeded" },
|
|
92
|
-
{ interaction_cid: null, outcome: "succeeded" },
|
|
102
|
+
{ interaction_cid: "caliban", outcome: "succeeded", sid: "rock" },
|
|
103
|
+
{ interaction_cid: "fallen", outcome: null, sid: "rock" },
|
|
104
|
+
{ interaction_cid: null, outcome: "succeeded", sid: "rock" },
|
|
105
|
+
{ interaction_cid: null, outcome: "succeeded", sid: "rock" },
|
|
93
106
|
]);
|
|
94
107
|
});
|
|
95
108
|
});
|
|
@@ -18,19 +18,21 @@ export function upsertAuthorizationRequestFactory({ pg }: DatabaseContext) {
|
|
|
18
18
|
user_ip_address,
|
|
19
19
|
interaction_cid,
|
|
20
20
|
outcome,
|
|
21
|
+
sid,
|
|
21
22
|
}: BaseAuthorizationRequest) {
|
|
22
23
|
const { rows }: QueryResult<AuthorizationRequest> = await pg.query(
|
|
23
24
|
`
|
|
24
25
|
INSERT INTO users_oidc_clients
|
|
25
|
-
(user_id, oidc_client_id, organization_id, sp_name, user_ip_address, created_at, updated_at, interaction_cid, outcome)
|
|
26
|
-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
|
26
|
+
(user_id, oidc_client_id, organization_id, sp_name, user_ip_address, created_at, updated_at, interaction_cid, outcome, sid)
|
|
27
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
|
27
28
|
ON CONFLICT (interaction_cid) WHERE interaction_cid IS NOT NULL
|
|
28
29
|
DO UPDATE SET
|
|
29
30
|
organization_id = EXCLUDED.organization_id,
|
|
30
31
|
outcome = EXCLUDED.outcome,
|
|
32
|
+
sid = COALESCE(EXCLUDED.sid, users_oidc_clients.sid),
|
|
31
33
|
updated_at = EXCLUDED.updated_at,
|
|
32
34
|
user_id = EXCLUDED.user_id
|
|
33
|
-
RETURNING user_id, oidc_client_id, organization_id, sp_name, user_ip_address, created_at, updated_at, id, interaction_cid, outcome;
|
|
35
|
+
RETURNING user_id, oidc_client_id, organization_id, sp_name, user_ip_address, created_at, updated_at, id, interaction_cid, outcome, sid;
|
|
34
36
|
`,
|
|
35
37
|
[
|
|
36
38
|
user_id,
|
|
@@ -42,6 +44,7 @@ RETURNING user_id, oidc_client_id, organization_id, sp_name, user_ip_address, cr
|
|
|
42
44
|
new Date(),
|
|
43
45
|
interaction_cid,
|
|
44
46
|
outcome,
|
|
47
|
+
sid,
|
|
45
48
|
],
|
|
46
49
|
);
|
|
47
50
|
|