@proconnect-gouv/proconnect.identite 10.0.1 → 10.1.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 +15 -0
- package/dist/connectors/index.d.ts +49 -45
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/index.js +31 -53
- package/dist/managers/organization/adapters/api_entreprise.d.ts +1 -1
- package/dist/managers/user/assign-user-verification-type-to-domain.d.ts.map +1 -1
- package/dist/managers/user/assign-user-verification-type-to-domain.js +3 -3
- package/dist/repositories/authenticator/find-authenticators-by-user-id.d.ts +3 -0
- package/dist/repositories/authenticator/find-authenticators-by-user-id.d.ts.map +1 -0
- package/dist/repositories/authenticator/{get-authenticators-by-user-id.js → find-authenticators-by-user-id.js} +2 -2
- 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/authenticator/update-authenticator.d.ts +1 -2
- package/dist/repositories/authenticator/update-authenticator.d.ts.map +1 -1
- package/dist/repositories/franceconnect_userinfo/delete-franceconnect-userinfo.d.ts +4 -0
- package/dist/repositories/franceconnect_userinfo/delete-franceconnect-userinfo.d.ts.map +1 -0
- package/dist/repositories/{user → franceconnect_userinfo}/delete-franceconnect-userinfo.js +2 -2
- package/dist/repositories/{user/get-franceconnect-user-info.d.ts → franceconnect_userinfo/find-franceconnect-userinfo.d.ts} +2 -3
- package/dist/repositories/franceconnect_userinfo/find-franceconnect-userinfo.d.ts.map +1 -0
- package/dist/repositories/{user/get-franceconnect-user-info.js → franceconnect_userinfo/find-franceconnect-userinfo.js} +2 -2
- package/dist/repositories/franceconnect_userinfo/index.d.ts +4 -0
- package/dist/repositories/franceconnect_userinfo/index.d.ts.map +1 -0
- package/dist/repositories/franceconnect_userinfo/index.js +3 -0
- package/dist/repositories/franceconnect_userinfo/upsert-franceconnect-userinfo.d.ts.map +1 -0
- package/dist/repositories/official-contact-email-verification/delete-official-contact-email-verification.d.ts +3 -0
- package/dist/repositories/official-contact-email-verification/delete-official-contact-email-verification.d.ts.map +1 -0
- package/dist/repositories/official-contact-email-verification/delete-official-contact-email-verification.js +12 -0
- package/dist/repositories/official-contact-email-verification/find-official-contact-email-verification.d.ts +10 -0
- package/dist/repositories/official-contact-email-verification/find-official-contact-email-verification.d.ts.map +1 -0
- package/dist/repositories/official-contact-email-verification/find-official-contact-email-verification.js +13 -0
- package/dist/repositories/official-contact-email-verification/index.d.ts +4 -0
- package/dist/repositories/official-contact-email-verification/index.d.ts.map +1 -0
- package/dist/repositories/official-contact-email-verification/index.js +4 -0
- package/dist/repositories/official-contact-email-verification/upsert-official-contact-email-verification.d.ts +10 -0
- package/dist/repositories/official-contact-email-verification/upsert-official-contact-email-verification.d.ts.map +1 -0
- package/dist/repositories/official-contact-email-verification/upsert-official-contact-email-verification.js +19 -0
- package/dist/repositories/organization/find-by-user-id.d.ts +0 -3
- package/dist/repositories/organization/find-by-user-id.d.ts.map +1 -1
- package/dist/repositories/organization/find-by-user-id.js +10 -14
- package/dist/repositories/organization/find-organization-by-id.d.ts +4 -0
- package/dist/repositories/organization/find-organization-by-id.d.ts.map +1 -0
- package/dist/repositories/organization/{find-by-id.js → find-organization-by-id.js} +2 -2
- package/dist/repositories/organization/{get-users-by-organization.d.ts → find-users-by-organization.d.ts} +2 -6
- package/dist/repositories/organization/find-users-by-organization.d.ts.map +1 -0
- package/dist/repositories/organization/find-users-by-organization.js +19 -0
- package/dist/repositories/organization/get-organization-by-id.d.ts +3 -0
- package/dist/repositories/organization/get-organization-by-id.d.ts.map +1 -0
- package/dist/repositories/organization/get-organization-by-id.js +15 -0
- package/dist/repositories/organization/index.d.ts +3 -5
- package/dist/repositories/organization/index.d.ts.map +1 -1
- package/dist/repositories/organization/index.js +3 -5
- package/dist/repositories/user/index.d.ts +0 -3
- package/dist/repositories/user/index.d.ts.map +1 -1
- package/dist/repositories/user/index.js +0 -3
- package/dist/repositories/{organization/link-user-to-organization.d.ts → user_organisation/create-user-organization.d.ts} +2 -6
- package/dist/repositories/user_organisation/create-user-organization.d.ts.map +1 -0
- package/dist/repositories/{organization/link-user-to-organization.js → user_organisation/create-user-organization.js} +2 -3
- package/dist/repositories/user_organisation/delete-user-organization.d.ts +3 -0
- package/dist/repositories/user_organisation/delete-user-organization.d.ts.map +1 -0
- package/dist/repositories/{organization → user_organisation}/delete-user-organization.js +4 -2
- package/dist/repositories/{organization/get-user-organization-link.d.ts → user_organisation/find-user-organization.d.ts} +3 -6
- package/dist/repositories/user_organisation/find-user-organization.d.ts.map +1 -0
- package/dist/repositories/user_organisation/find-user-organization.js +20 -0
- package/dist/repositories/user_organisation/index.d.ts +5 -0
- package/dist/repositories/user_organisation/index.d.ts.map +1 -0
- package/dist/repositories/user_organisation/index.js +4 -0
- package/dist/repositories/{user/update-user-organization-link.d.ts → user_organisation/update-user-organization.d.ts} +3 -7
- package/dist/repositories/user_organisation/update-user-organization.d.ts.map +1 -0
- package/dist/repositories/{user/update-user-organization-link.js → user_organisation/update-user-organization.js} +2 -2
- package/dist/services/organization/compute-service-public-info.d.ts.map +1 -1
- package/dist/services/organization/compute-service-public-info.js +7 -6
- package/dist/types/authenticator.d.ts +3 -1
- package/dist/types/authenticator.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/official-contact-email-verification.d.ts +23 -0
- package/dist/types/official-contact-email-verification.d.ts.map +1 -0
- package/dist/types/official-contact-email-verification.js +15 -0
- package/dist/types/organization-info.d.ts +2 -1
- package/dist/types/organization-info.d.ts.map +1 -1
- package/dist/types/organization-info.js +1 -0
- package/dist/types/organization.d.ts +1 -1
- package/dist/types/organization.d.ts.map +1 -1
- package/dist/types/user-organization-link.d.ts +5 -7
- package/dist/types/user-organization-link.d.ts.map +1 -1
- package/dist/types/user-organization-link.js +4 -6
- package/package.json +3 -3
- package/src/connectors/index.ts +83 -53
- package/src/managers/organization/mark-domain-as-verified.test.ts +2 -3
- package/src/managers/user/assign-user-verification-type-to-domain.test.ts +7 -8
- package/src/managers/user/assign-user-verification-type-to-domain.ts +8 -5
- package/src/repositories/authenticator/{get-authenticators-by-user-id.test.ts → find-authenticators-by-user-id.test.ts} +5 -5
- package/src/repositories/authenticator/{get-authenticators-by-user-id.ts → find-authenticators-by-user-id.ts} +2 -2
- package/src/repositories/authenticator/index.ts +1 -1
- package/src/repositories/authenticator/update-authenticator.ts +1 -1
- package/src/repositories/{user → franceconnect_userinfo}/delete-franceconnect-userinfo.test.ts +7 -7
- package/src/repositories/franceconnect_userinfo/delete-franceconnect-userinfo.ts +21 -0
- package/src/repositories/{user/get-franceconnect-user-info.test.ts → franceconnect_userinfo/find-franceconnect-userinfo.test.ts} +5 -5
- package/src/repositories/{user/get-franceconnect-user-info.ts → franceconnect_userinfo/find-franceconnect-userinfo.ts} +2 -6
- package/src/repositories/franceconnect_userinfo/index.ts +3 -0
- package/src/repositories/official-contact-email-verification/delete-official-contact-email-verification.test.ts +106 -0
- package/src/repositories/official-contact-email-verification/delete-official-contact-email-verification.ts +29 -0
- package/src/repositories/official-contact-email-verification/find-official-contact-email-verification.test.ts +136 -0
- package/src/repositories/official-contact-email-verification/find-official-contact-email-verification.ts +31 -0
- package/src/repositories/official-contact-email-verification/index.ts +5 -0
- package/src/repositories/official-contact-email-verification/upsert-official-contact-email-verification.test.ts +170 -0
- package/src/repositories/official-contact-email-verification/upsert-official-contact-email-verification.ts +38 -0
- package/src/repositories/organization/find-by-user-id.test.ts +5 -6
- package/src/repositories/organization/find-by-user-id.test.ts.snapshot +3 -12
- package/src/repositories/organization/find-by-user-id.ts +10 -14
- package/src/repositories/organization/{find-by-id.test.ts → find-organization-by-id.test.ts} +4 -4
- package/src/repositories/organization/{find-by-id.ts → find-organization-by-id.ts} +3 -3
- package/src/repositories/organization/{get-users-by-organization.test.ts → find-users-by-organization.test.ts} +9 -8
- package/src/repositories/organization/{get-users-by-organization.test.ts.snapshot → find-users-by-organization.test.ts.snapshot} +2 -5
- package/src/repositories/organization/find-users-by-organization.ts +38 -0
- package/src/repositories/organization/get-organization-by-id.test.ts +37 -0
- package/src/repositories/organization/get-organization-by-id.ts +19 -0
- package/src/repositories/organization/index.ts +3 -5
- package/src/repositories/user/index.ts +0 -3
- package/src/repositories/{organization/link-user-to-organization.test.ts → user_organisation/create-user-organization.test.ts} +2 -2
- package/src/repositories/{organization/link-user-to-organization.test.ts.snapshot → user_organisation/create-user-organization.test.ts.snapshot} +0 -6
- package/src/repositories/{organization/link-user-to-organization.ts → user_organisation/create-user-organization.ts} +1 -7
- package/src/repositories/{organization → user_organisation}/delete-user-organization.ts +6 -7
- package/src/repositories/{organization/get-user-organization-link.test.ts → user_organisation/find-user-organization.test.ts} +5 -5
- package/src/repositories/user_organisation/find-user-organization.ts +35 -0
- package/src/repositories/user_organisation/index.ts +4 -0
- package/src/repositories/{user/update-user-organization-link.test.ts → user_organisation/update-user-organization.test.ts} +10 -8
- package/src/repositories/{user/update-user-organization-link.ts → user_organisation/update-user-organization.ts} +9 -9
- package/src/services/organization/compute-service-public-info.test.ts +10 -0
- package/src/services/organization/compute-service-public-info.ts +8 -7
- package/src/types/authenticator.ts +10 -5
- package/src/types/index.ts +1 -0
- package/src/types/official-contact-email-verification.ts +32 -0
- package/src/types/organization-info.ts +1 -1
- package/src/types/organization.ts +18 -1
- package/src/types/user-organization-link.ts +9 -8
- package/dist/repositories/authenticator/get-authenticators-by-user-id.d.ts +0 -3
- package/dist/repositories/authenticator/get-authenticators-by-user-id.d.ts.map +0 -1
- package/dist/repositories/organization/delete-user-organization.d.ts +0 -6
- package/dist/repositories/organization/delete-user-organization.d.ts.map +0 -1
- package/dist/repositories/organization/find-by-id.d.ts +0 -4
- package/dist/repositories/organization/find-by-id.d.ts.map +0 -1
- package/dist/repositories/organization/get-user-organization-link.d.ts.map +0 -1
- package/dist/repositories/organization/get-user-organization-link.js +0 -23
- package/dist/repositories/organization/get-users-by-organization.d.ts.map +0 -1
- package/dist/repositories/organization/get-users-by-organization.js +0 -23
- package/dist/repositories/organization/link-user-to-organization.d.ts.map +0 -1
- package/dist/repositories/user/delete-franceconnect-userinfo.d.ts +0 -4
- package/dist/repositories/user/delete-franceconnect-userinfo.d.ts.map +0 -1
- package/dist/repositories/user/get-franceconnect-user-info.d.ts.map +0 -1
- package/dist/repositories/user/update-user-organization-link.d.ts.map +0 -1
- package/dist/repositories/user/upsert-franceconnect-userinfo.d.ts.map +0 -1
- package/src/repositories/organization/get-user-organization-link.ts +0 -34
- package/src/repositories/organization/get-users-by-organization.ts +0 -46
- package/src/repositories/user/delete-franceconnect-userinfo.ts +0 -21
- package/tsconfig.lib.tsbuildinfo +0 -1
- /package/dist/repositories/{user → franceconnect_userinfo}/upsert-franceconnect-userinfo.d.ts +0 -0
- /package/dist/repositories/{user → franceconnect_userinfo}/upsert-franceconnect-userinfo.js +0 -0
- /package/src/repositories/{user → franceconnect_userinfo}/upsert-franceconnect-userinfo.test.ts +0 -0
- /package/src/repositories/{user → franceconnect_userinfo}/upsert-franceconnect-userinfo.ts +0 -0
- /package/src/repositories/{organization → user_organisation}/delete-user-organization.test.ts +0 -0
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
|
-
export * from "./delete-user-organization.js";
|
|
4
|
-
export * from "./find-by-id.js";
|
|
5
3
|
export * from "./find-by-siret.js";
|
|
6
4
|
export * from "./find-by-user-id.js";
|
|
7
5
|
export * from "./find-by-verified-email-domain.js";
|
|
6
|
+
export * from "./find-organization-by-id.js";
|
|
8
7
|
export * from "./find-pending-by-user-id.js";
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./get-
|
|
11
|
-
export * from "./link-user-to-organization.js";
|
|
8
|
+
export * from "./find-users-by-organization.js";
|
|
9
|
+
export * from "./get-organization-by-id.js";
|
|
12
10
|
export * from "./upsert.js";
|
|
@@ -7,7 +7,4 @@ export * from "./find-by-id.js";
|
|
|
7
7
|
export * from "./find-by-magic-link-token.js";
|
|
8
8
|
export * from "./find-by-reset-password-token.js";
|
|
9
9
|
export * from "./get-by-id.js";
|
|
10
|
-
export * from "./get-franceconnect-user-info.js";
|
|
11
|
-
export * from "./update-user-organization-link.js";
|
|
12
10
|
export * from "./update.js";
|
|
13
|
-
export * from "./upsert-franceconnect-userinfo.js";
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { LinkEnum } from "#src/types";
|
|
2
2
|
import { emptyDatabase, migrate, pg } from "#testing";
|
|
3
3
|
import { before, beforeEach, mock, suite, test } from "node:test";
|
|
4
|
-
import {
|
|
4
|
+
import { createUserOrganizationFactory } from "./create-user-organization.js";
|
|
5
5
|
|
|
6
6
|
//
|
|
7
7
|
|
|
8
|
-
const linkUserToOrganization =
|
|
8
|
+
const linkUserToOrganization = createUserOrganizationFactory({ pg: pg as any });
|
|
9
9
|
|
|
10
10
|
suite("linkUserToOrganizationFactory", () => {
|
|
11
11
|
before(migrate);
|
|
@@ -7,9 +7,6 @@ exports[`linkUserToOrganizationFactory > should link user to organization 1`] =
|
|
|
7
7
|
"updated_at": "4444-04-04T00:00:00.000Z",
|
|
8
8
|
"verification_type": "domain_not_verified_yet",
|
|
9
9
|
"has_been_greeted": false,
|
|
10
|
-
"needs_official_contact_email_verification": false,
|
|
11
|
-
"official_contact_email_verification_token": null,
|
|
12
|
-
"official_contact_email_verification_sent_at": null,
|
|
13
10
|
"verified_at": "4444-04-04T00:00:00.000Z"
|
|
14
11
|
}
|
|
15
12
|
`;
|
|
@@ -23,9 +20,6 @@ exports[`linkUserToOrganizationFactory > should mark a user as organization_diri
|
|
|
23
20
|
"updated_at": "4444-04-04T00:00:00.000Z",
|
|
24
21
|
"verification_type": "organization_dirigeant",
|
|
25
22
|
"has_been_greeted": false,
|
|
26
|
-
"needs_official_contact_email_verification": false,
|
|
27
|
-
"official_contact_email_verification_token": null,
|
|
28
|
-
"official_contact_email_verification_sent_at": null,
|
|
29
23
|
"verified_at": "4444-04-04T00:00:00.000Z"
|
|
30
24
|
}
|
|
31
25
|
`;
|
|
@@ -6,10 +6,9 @@ import type {
|
|
|
6
6
|
} from "#src/types";
|
|
7
7
|
import type { QueryResult } from "pg";
|
|
8
8
|
|
|
9
|
-
export function
|
|
9
|
+
export function createUserOrganizationFactory({ pg }: DatabaseContext) {
|
|
10
10
|
return async function linkUserToOrganization({
|
|
11
11
|
is_external = false,
|
|
12
|
-
needs_official_contact_email_verification = false,
|
|
13
12
|
organization_id,
|
|
14
13
|
user_id,
|
|
15
14
|
verification_type,
|
|
@@ -18,7 +17,6 @@ export function linkUserToOrganizationFactory({ pg }: DatabaseContext) {
|
|
|
18
17
|
hashToPostgresParams<UserOrganizationLink>({
|
|
19
18
|
created_at: new Date(),
|
|
20
19
|
is_external,
|
|
21
|
-
needs_official_contact_email_verification,
|
|
22
20
|
organization_id,
|
|
23
21
|
updated_at: new Date(),
|
|
24
22
|
user_id,
|
|
@@ -39,7 +37,3 @@ export function linkUserToOrganizationFactory({ pg }: DatabaseContext) {
|
|
|
39
37
|
return rows.shift()!;
|
|
40
38
|
};
|
|
41
39
|
}
|
|
42
|
-
|
|
43
|
-
export type LinkUserToOrganizationHandler = ReturnType<
|
|
44
|
-
typeof linkUserToOrganizationFactory
|
|
45
|
-
>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
|
-
import type { DatabaseContext } from "#src/types";
|
|
3
|
+
import type { DatabaseContext, FindUserOrganizationLink } from "#src/types";
|
|
4
4
|
import type { QueryResult } from "pg";
|
|
5
5
|
|
|
6
6
|
//
|
|
@@ -9,14 +9,13 @@ export function deleteUserOrganizationFactory({ pg }: DatabaseContext) {
|
|
|
9
9
|
return async function deleteUserOrganization({
|
|
10
10
|
user_id,
|
|
11
11
|
organization_id,
|
|
12
|
-
}: {
|
|
13
|
-
user_id: number;
|
|
14
|
-
organization_id: number;
|
|
15
|
-
}) {
|
|
12
|
+
}: FindUserOrganizationLink) {
|
|
16
13
|
const { rowCount, affectedRows } = (await pg.query(
|
|
17
14
|
`
|
|
18
|
-
DELETE
|
|
19
|
-
|
|
15
|
+
DELETE
|
|
16
|
+
FROM users_organizations
|
|
17
|
+
WHERE user_id = $1
|
|
18
|
+
AND organization_id = $2`,
|
|
20
19
|
[user_id, organization_id],
|
|
21
20
|
)) as QueryResult & { affectedRows?: number };
|
|
22
21
|
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
import { emptyDatabase, migrate, pg } from "#testing";
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
5
|
import { before, beforeEach, suite, test } from "node:test";
|
|
6
|
-
import {
|
|
6
|
+
import { findUserOrganizationFactory } from "./find-user-organization.js";
|
|
7
7
|
|
|
8
8
|
//
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const findUserOrganization = findUserOrganizationFactory({
|
|
11
11
|
pg: pg as any,
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
suite("
|
|
14
|
+
suite("findUserOrganizationFactory", () => {
|
|
15
15
|
before(migrate);
|
|
16
16
|
beforeEach(emptyDatabase);
|
|
17
17
|
|
|
18
18
|
test("should return undefined when the link does not exist", async () => {
|
|
19
|
-
const link = await
|
|
19
|
+
const link = await findUserOrganization({ organization_id: 1, user_id: 1 });
|
|
20
20
|
|
|
21
21
|
assert.equal(link, undefined);
|
|
22
22
|
});
|
|
@@ -44,7 +44,7 @@ suite("getUserOrganizationLinkFactory", () => {
|
|
|
44
44
|
;
|
|
45
45
|
`;
|
|
46
46
|
|
|
47
|
-
const link = await
|
|
47
|
+
const link = await findUserOrganization({ organization_id: 1, user_id: 1 });
|
|
48
48
|
|
|
49
49
|
assert.equal(link?.user_id, 1);
|
|
50
50
|
assert.equal(link?.organization_id, 1);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
DatabaseContext,
|
|
5
|
+
FindUserOrganizationLink,
|
|
6
|
+
UserOrganizationLink,
|
|
7
|
+
} from "#src/types";
|
|
8
|
+
import { type QueryResult } from "pg";
|
|
9
|
+
|
|
10
|
+
//
|
|
11
|
+
|
|
12
|
+
export function findUserOrganizationFactory({ pg }: DatabaseContext) {
|
|
13
|
+
return async function findUserOrganization({
|
|
14
|
+
organization_id,
|
|
15
|
+
user_id,
|
|
16
|
+
}: FindUserOrganizationLink) {
|
|
17
|
+
const { rows }: QueryResult<UserOrganizationLink> = await pg.query(
|
|
18
|
+
`
|
|
19
|
+
SELECT user_id,
|
|
20
|
+
organization_id,
|
|
21
|
+
is_external,
|
|
22
|
+
created_at,
|
|
23
|
+
updated_at,
|
|
24
|
+
verification_type,
|
|
25
|
+
verified_at,
|
|
26
|
+
has_been_greeted
|
|
27
|
+
FROM users_organizations
|
|
28
|
+
WHERE organization_id = $1
|
|
29
|
+
AND user_id = $2`,
|
|
30
|
+
[organization_id, user_id],
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
return rows.shift();
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
import { emptyDatabase, migrate, pg } from "#testing";
|
|
4
4
|
import assert from "node:assert/strict";
|
|
5
5
|
import { before, beforeEach, suite, test } from "node:test";
|
|
6
|
-
import {
|
|
6
|
+
import { updateUserOrganizationFactory } from "./update-user-organization.js";
|
|
7
7
|
|
|
8
8
|
//
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const updateUserOrganization = updateUserOrganizationFactory({
|
|
11
11
|
pg: pg as any,
|
|
12
12
|
});
|
|
13
13
|
|
|
@@ -32,15 +32,17 @@ suite("updateUserOrganizationLink", () => {
|
|
|
32
32
|
`;
|
|
33
33
|
await pg.sql`
|
|
34
34
|
INSERT INTO users_organizations
|
|
35
|
-
|
|
36
|
-
VALUES
|
|
37
|
-
(1, 1, '4444-04-04', '4444-04-04', false, 'no_verification_means_available', false, null, null)
|
|
35
|
+
(user_id, organization_id, created_at, updated_at, is_external, verification_type)
|
|
36
|
+
VALUES (1, 1, '4444-04-04', '4444-04-04', false, 'no_verification_means_available')
|
|
38
37
|
;
|
|
39
38
|
`;
|
|
40
39
|
|
|
41
|
-
const user = await
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
const user = await updateUserOrganization(
|
|
41
|
+
{ organization_id: 1, user_id: 1 },
|
|
42
|
+
{
|
|
43
|
+
is_external: true,
|
|
44
|
+
},
|
|
45
|
+
);
|
|
44
46
|
assert.ok(user.is_external);
|
|
45
47
|
});
|
|
46
48
|
});
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
3
|
import { hashToPostgresParams } from "#src/services/postgres";
|
|
4
|
-
import type {
|
|
4
|
+
import type {
|
|
5
|
+
DatabaseContext,
|
|
6
|
+
FindUserOrganizationLink,
|
|
7
|
+
User,
|
|
8
|
+
UserOrganizationLink,
|
|
9
|
+
} from "#src/types";
|
|
5
10
|
import type { QueryResult } from "pg";
|
|
6
11
|
|
|
7
12
|
//
|
|
8
13
|
|
|
9
|
-
export function
|
|
10
|
-
return async function
|
|
11
|
-
organization_id:
|
|
12
|
-
user_id: number,
|
|
14
|
+
export function updateUserOrganizationFactory({ pg }: DatabaseContext) {
|
|
15
|
+
return async function updateUserOrganization(
|
|
16
|
+
{ organization_id, user_id }: FindUserOrganizationLink,
|
|
13
17
|
fieldsToUpdate: Partial<UserOrganizationLink>,
|
|
14
18
|
) {
|
|
15
19
|
const connection = pg;
|
|
@@ -36,7 +40,3 @@ export function updateUserOrganizationLinkFactory({ pg }: DatabaseContext) {
|
|
|
36
40
|
return rows.shift()!;
|
|
37
41
|
};
|
|
38
42
|
}
|
|
39
|
-
|
|
40
|
-
export type UpdateUserOrganizationLinkHandler = ReturnType<
|
|
41
|
-
typeof updateUserOrganizationLinkFactory
|
|
42
|
-
>;
|
|
@@ -66,6 +66,16 @@ describe("computeServicePublicInfo", () => {
|
|
|
66
66
|
assert.equal(result.isServicePublic, false);
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
+
it("should return right roles for administration centrale", () => {
|
|
70
|
+
const result = computeServicePublicInfo({
|
|
71
|
+
siret: "26270289700014",
|
|
72
|
+
cached_categorie_juridique: "7364",
|
|
73
|
+
cached_etat_administratif: "A",
|
|
74
|
+
});
|
|
75
|
+
assert.equal(result.isServicePublic, true);
|
|
76
|
+
assert.equal(result.isAdministrationEtat, true);
|
|
77
|
+
});
|
|
78
|
+
|
|
69
79
|
it("should return false for closed entities", () => {
|
|
70
80
|
const closed_org = {
|
|
71
81
|
siret: "12345678900123",
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import type { Organization } from "#src/types";
|
|
4
4
|
import {
|
|
5
5
|
ADMINISTRATION_BLACKLIST,
|
|
6
|
-
ADMINISTRATION_ETAT_WHITELIST,
|
|
7
6
|
ADMINISTRATION_WHITELIST,
|
|
8
7
|
ADMINISTRATIONS,
|
|
9
8
|
} from "@proconnect-gouv/proconnect.annuaire_entreprises";
|
|
@@ -38,13 +37,15 @@ export const computeServicePublicInfo = ({
|
|
|
38
37
|
return { isServicePublic: false };
|
|
39
38
|
}
|
|
40
39
|
|
|
41
|
-
if (ADMINISTRATION_ETAT_WHITELIST.includes(siren)) {
|
|
42
|
-
return { isServicePublic: true, isAdministrationEtat: true };
|
|
43
|
-
}
|
|
44
|
-
|
|
45
40
|
// Check if entity is in whitelist (takes priority)
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
const administrationInWhitelist = ADMINISTRATION_WHITELIST.find(
|
|
42
|
+
(ADMINISTRATION) => ADMINISTRATION.siren === siren,
|
|
43
|
+
);
|
|
44
|
+
if (administrationInWhitelist) {
|
|
45
|
+
return {
|
|
46
|
+
isServicePublic: true,
|
|
47
|
+
isAdministrationEtat: administrationInWhitelist.isAdministrationEtat,
|
|
48
|
+
};
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
const ADMINISTRATION = ADMINISTRATIONS.find(
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
export type Base64URLString = string;
|
|
4
|
+
export type AuthenticatorTransportFuture =
|
|
5
|
+
| "ble"
|
|
6
|
+
| "cable"
|
|
7
|
+
| "hybrid"
|
|
8
|
+
| "internal"
|
|
9
|
+
| "nfc"
|
|
10
|
+
| "smart-card"
|
|
11
|
+
| "usb";
|
|
12
|
+
export type CredentialDeviceType = "singleDevice" | "multiDevice";
|
|
8
13
|
|
|
9
14
|
//
|
|
10
15
|
|
package/src/types/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./email-domain.js";
|
|
|
8
8
|
export * from "./franceconnect.js";
|
|
9
9
|
export * from "./identity-vector.js";
|
|
10
10
|
export * from "./moderation.js";
|
|
11
|
+
export * from "./official-contact-email-verification.js";
|
|
11
12
|
export * from "./oidc-client.js";
|
|
12
13
|
export * from "./organization-info.js";
|
|
13
14
|
export * from "./organization.js";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
export const BaseOfficialContactEmailVerificationSchema = z.object({
|
|
4
|
+
organization_id: z.number(),
|
|
5
|
+
sent_at: z.date().nullable(),
|
|
6
|
+
token: z.string().nullable(),
|
|
7
|
+
user_id: z.number(),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export type BaseOfficialContactEmailVerification = z.output<
|
|
11
|
+
typeof BaseOfficialContactEmailVerificationSchema
|
|
12
|
+
>;
|
|
13
|
+
|
|
14
|
+
export const OfficialContactEmailVerificationSchema =
|
|
15
|
+
BaseOfficialContactEmailVerificationSchema.extend({
|
|
16
|
+
created_at: z.date(),
|
|
17
|
+
updated_at: z.date(),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type OfficialContactEmailVerification = z.output<
|
|
21
|
+
typeof OfficialContactEmailVerificationSchema
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
export const FindOfficialContactEmailVerificationSchema =
|
|
25
|
+
OfficialContactEmailVerificationSchema.pick({
|
|
26
|
+
organization_id: true,
|
|
27
|
+
user_id: true,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export type FindOfficialContactEmailVerification = z.output<
|
|
31
|
+
typeof FindOfficialContactEmailVerificationSchema
|
|
32
|
+
>;
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
//
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export type TrancheEffectifs =
|
|
4
|
+
| "NN"
|
|
5
|
+
| "00"
|
|
6
|
+
| "01"
|
|
7
|
+
| "02"
|
|
8
|
+
| "03"
|
|
9
|
+
| "11"
|
|
10
|
+
| "12"
|
|
11
|
+
| "21"
|
|
12
|
+
| "22"
|
|
13
|
+
| "31"
|
|
14
|
+
| "32"
|
|
15
|
+
| "41"
|
|
16
|
+
| "42"
|
|
17
|
+
| "51"
|
|
18
|
+
| "52"
|
|
19
|
+
| "53"
|
|
20
|
+
| null;
|
|
4
21
|
|
|
5
22
|
//
|
|
6
23
|
|
|
@@ -55,17 +55,12 @@ export const BaseUserOrganizationLinkSchema = z.object({
|
|
|
55
55
|
// updated when verification_type is changed
|
|
56
56
|
verified_at: z.date().or(z.literal(null)),
|
|
57
57
|
has_been_greeted: z.boolean(),
|
|
58
|
-
needs_official_contact_email_verification: z.boolean(),
|
|
59
|
-
official_contact_email_verification_token: z.string().nullable(),
|
|
60
|
-
official_contact_email_verification_sent_at: z.date().nullable(),
|
|
61
58
|
});
|
|
62
59
|
|
|
63
60
|
export type BaseUserOrganizationLink = z.output<
|
|
64
61
|
typeof BaseUserOrganizationLinkSchema
|
|
65
62
|
>;
|
|
66
63
|
|
|
67
|
-
//
|
|
68
|
-
|
|
69
64
|
export const UserOrganizationLinkSchema = BaseUserOrganizationLinkSchema.extend(
|
|
70
65
|
{
|
|
71
66
|
user_id: z.number(),
|
|
@@ -77,8 +72,6 @@ export const UserOrganizationLinkSchema = BaseUserOrganizationLinkSchema.extend(
|
|
|
77
72
|
|
|
78
73
|
export type UserOrganizationLink = z.output<typeof UserOrganizationLinkSchema>;
|
|
79
74
|
|
|
80
|
-
//
|
|
81
|
-
|
|
82
75
|
export const InsertUserOrganizationLinkSchema = UserOrganizationLinkSchema.pick(
|
|
83
76
|
{
|
|
84
77
|
organization_id: true,
|
|
@@ -88,10 +81,18 @@ export const InsertUserOrganizationLinkSchema = UserOrganizationLinkSchema.pick(
|
|
|
88
81
|
).extend(
|
|
89
82
|
UserOrganizationLinkSchema.pick({
|
|
90
83
|
is_external: true,
|
|
91
|
-
needs_official_contact_email_verification: true,
|
|
92
84
|
}).partial().shape,
|
|
93
85
|
);
|
|
94
86
|
|
|
95
87
|
export type InsertUserOrganizationLink = z.output<
|
|
96
88
|
typeof InsertUserOrganizationLinkSchema
|
|
97
89
|
>;
|
|
90
|
+
|
|
91
|
+
export const FindUserOrganizationLinkSchema = UserOrganizationLinkSchema.pick({
|
|
92
|
+
organization_id: true,
|
|
93
|
+
user_id: true,
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export type FindUserOrganizationLink = z.output<
|
|
97
|
+
typeof FindUserOrganizationLinkSchema
|
|
98
|
+
>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-authenticators-by-user-id.d.ts","sourceRoot":"","sources":["../../../src/repositories/authenticator/get-authenticators-by-user-id.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAKjE,wBAAgB,gCAAgC,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,SAAS,MAAM,8BAYhE"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext } from "#src/types";
|
|
2
|
-
export declare function deleteUserOrganizationFactory({ pg }: DatabaseContext): ({ user_id, organization_id, }: {
|
|
3
|
-
user_id: number;
|
|
4
|
-
organization_id: number;
|
|
5
|
-
}) => Promise<boolean>;
|
|
6
|
-
//# sourceMappingURL=delete-user-organization.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete-user-organization.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/delete-user-organization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAKlD,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,+BAG1C;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;CACzB,sBAUF"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext, Organization } from "#src/types";
|
|
2
|
-
export declare function findByIdFactory({ pg }: DatabaseContext): (id: number) => Promise<Organization | undefined>;
|
|
3
|
-
export type FindByIdHandler = ReturnType<typeof findByIdFactory>;
|
|
4
|
-
//# sourceMappingURL=find-by-id.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-by-id.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/find-by-id.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAKhE,wBAAgB,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,IAAI,MAAM,uCAW1C;AAED,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-user-organization-link.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/get-user-organization-link.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAwB,MAAM,YAAY,CAAC;AAKxE,wBAAgB,8BAA8B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAElE,iBAAiB,MAAM,EACvB,SAAS,MAAM;;;;;;;;;;;;eAuBlB"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import {} from "pg";
|
|
3
|
-
//
|
|
4
|
-
export function getUserOrganizationLinkFactory({ pg }) {
|
|
5
|
-
return async function getUserOrganizationLink(organization_id, user_id) {
|
|
6
|
-
const { rows } = await pg.query(`
|
|
7
|
-
SELECT
|
|
8
|
-
user_id,
|
|
9
|
-
organization_id,
|
|
10
|
-
is_external,
|
|
11
|
-
created_at,
|
|
12
|
-
updated_at,
|
|
13
|
-
verification_type,
|
|
14
|
-
verified_at,
|
|
15
|
-
has_been_greeted,
|
|
16
|
-
needs_official_contact_email_verification,
|
|
17
|
-
official_contact_email_verification_token,
|
|
18
|
-
official_contact_email_verification_sent_at
|
|
19
|
-
FROM users_organizations
|
|
20
|
-
WHERE organization_id = $1 AND user_id = $2`, [organization_id, user_id]);
|
|
21
|
-
return rows.shift();
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-users-by-organization.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/get-users-by-organization.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,eAAe,EACf,IAAI,EACL,MAAM,YAAY,CAAC;AAKpB,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAEjE,iBAAiB,MAAM,EACvB,wBAAuB,MAAW,EAClC,mBAAkB,GAAG,EAAO;;;;;;;;MA0B/B;AAED,MAAM,MAAM,6BAA6B,GAAG,UAAU,CACpD,OAAO,6BAA6B,CACrC,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
export function getUsersByOrganizationFactory({ pg }) {
|
|
4
|
-
return async function getUsersByOrganization(organization_id, additionalWhereClause = "", additionalParams = []) {
|
|
5
|
-
const connection = pg;
|
|
6
|
-
const baseParams = [organization_id];
|
|
7
|
-
const { rows } = await connection.query(`
|
|
8
|
-
SELECT
|
|
9
|
-
u.*,
|
|
10
|
-
uo.is_external,
|
|
11
|
-
uo.verification_type,
|
|
12
|
-
uo.verified_at,
|
|
13
|
-
uo.has_been_greeted,
|
|
14
|
-
uo.needs_official_contact_email_verification,
|
|
15
|
-
uo.official_contact_email_verification_token,
|
|
16
|
-
uo.official_contact_email_verification_sent_at
|
|
17
|
-
FROM users u
|
|
18
|
-
INNER JOIN users_organizations AS uo ON uo.user_id = u.id
|
|
19
|
-
WHERE uo.organization_id = $1
|
|
20
|
-
${additionalWhereClause}`, [...baseParams, ...additionalParams]);
|
|
21
|
-
return rows;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"link-user-to-organization.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/link-user-to-organization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,0BAA0B,EAE3B,MAAM,YAAY,CAAC;AAGpB,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,0GAM1C,0BAA0B;;;;;;;;;;;;GAyB9B;AAED,MAAM,MAAM,6BAA6B,GAAG,UAAU,CACpD,OAAO,6BAA6B,CACrC,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext } from "#src/types";
|
|
2
|
-
export declare function deleteFranceConnectUserInfoFactory({ pg }: DatabaseContext): (user_id: number) => Promise<import("pg").QueryResult<any>>;
|
|
3
|
-
export type DeleteFranceConnectUserInfoHandler = ReturnType<typeof deleteFranceConnectUserInfoFactory>;
|
|
4
|
-
//# sourceMappingURL=delete-franceconnect-userinfo.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"delete-franceconnect-userinfo.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/delete-franceconnect-userinfo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAIlD,wBAAgB,kCAAkC,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,SAAS,MAAM,4CASlE;AAED,MAAM,MAAM,kCAAkC,GAAG,UAAU,CACzD,OAAO,kCAAkC,CAC1C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-franceconnect-user-info.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/get-franceconnect-user-info.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAyB,MAAM,YAAY,CAAC;AAKzE,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,SAAS,MAAM;;;;;;;;;;;;eAY/D;AAED,MAAM,MAAM,+BAA+B,GAAG,UAAU,CACtD,OAAO,+BAA+B,CACvC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-user-organization-link.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/update-user-organization-link.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAQ,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAK9E,wBAAgB,iCAAiC,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAErE,iBAAiB,MAAM,EACvB,SAAS,MAAM,EACf,gBAAgB,OAAO,CAAC,oBAAoB,CAAC;;;;;;;;;;;;GAyBhD;AAED,MAAM,MAAM,iCAAiC,GAAG,UAAU,CACxD,OAAO,iCAAiC,CACzC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upsert-franceconnect-userinfo.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/upsert-franceconnect-userinfo.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAIzE,wBAAgB,kCAAkC,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAEtE,OAAO,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,GAC3C,OAAO,CAAC,qBAAqB,CAAC;;;;;;;;;;;;GA0BnC;AAED,MAAM,MAAM,iCAAiC,GAAG,UAAU,CACxD,OAAO,kCAAkC,CAC1C,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import type { DatabaseContext, UserOrganizationLink } from "#src/types";
|
|
4
|
-
import { type QueryResult } from "pg";
|
|
5
|
-
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
export function getUserOrganizationLinkFactory({ pg }: DatabaseContext) {
|
|
9
|
-
return async function getUserOrganizationLink(
|
|
10
|
-
organization_id: number,
|
|
11
|
-
user_id: number,
|
|
12
|
-
) {
|
|
13
|
-
const { rows }: QueryResult<UserOrganizationLink> = await pg.query(
|
|
14
|
-
`
|
|
15
|
-
SELECT
|
|
16
|
-
user_id,
|
|
17
|
-
organization_id,
|
|
18
|
-
is_external,
|
|
19
|
-
created_at,
|
|
20
|
-
updated_at,
|
|
21
|
-
verification_type,
|
|
22
|
-
verified_at,
|
|
23
|
-
has_been_greeted,
|
|
24
|
-
needs_official_contact_email_verification,
|
|
25
|
-
official_contact_email_verification_token,
|
|
26
|
-
official_contact_email_verification_sent_at
|
|
27
|
-
FROM users_organizations
|
|
28
|
-
WHERE organization_id = $1 AND user_id = $2`,
|
|
29
|
-
[organization_id, user_id],
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
return rows.shift();
|
|
33
|
-
};
|
|
34
|
-
}
|