@proconnect-gouv/proconnect.identite 16.0.0 → 17.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 +24 -0
- package/dist/connectors/index.d.ts +7 -71
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/index.js +5 -14
- 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/index.d.ts +1 -1
- package/dist/repositories/authenticator/index.js +1 -1
- package/dist/repositories/authenticator/rename-authenticator.d.ts +3 -0
- package/dist/repositories/authenticator/rename-authenticator.d.ts.map +1 -0
- package/dist/repositories/authenticator/rename-authenticator.js +14 -0
- 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/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/create.d.ts +1 -0
- package/dist/repositories/user/create.d.ts.map +1 -1
- package/dist/repositories/user/find-by-email.d.ts +1 -0
- package/dist/repositories/user/find-by-email.d.ts.map +1 -1
- package/dist/repositories/user/find-by-id.d.ts +1 -0
- package/dist/repositories/user/find-by-id.d.ts.map +1 -1
- package/dist/repositories/user/find-by-magic-link-token.d.ts +1 -0
- package/dist/repositories/user/find-by-magic-link-token.d.ts.map +1 -1
- package/dist/repositories/user/get-by-id.d.ts +1 -0
- package/dist/repositories/user/get-by-id.d.ts.map +1 -1
- 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/repositories/user/update.d.ts +1 -0
- package/dist/repositories/user/update.d.ts.map +1 -1
- package/dist/types/authenticator.d.ts.map +1 -1
- package/dist/types/user.d.ts +1 -0
- package/dist/types/user.d.ts.map +1 -1
- package/dist/types/user.js +1 -0
- package/package.json +2 -2
- package/src/connectors/index.ts +2 -17
- package/src/managers/certification/process-certification-dirigeant.ts +1 -2
- package/src/managers/organization/get-organization-info.ts +1 -2
- package/src/repositories/authenticator/index.ts +1 -1
- package/src/repositories/authenticator/rename-authenticator.test.ts +53 -0
- package/src/repositories/authenticator/rename-authenticator.ts +26 -0
- package/src/repositories/moderation/index.ts +0 -2
- package/src/repositories/organization/index.ts +0 -2
- package/src/repositories/user/create.test.ts +1 -0
- package/src/repositories/user/find-by-email.test.ts +1 -0
- package/src/repositories/user/find-by-id.test.ts +1 -0
- package/src/repositories/user/get-by-id.test.ts +1 -0
- package/src/repositories/user/index.ts +0 -1
- package/src/types/authenticator.ts +1 -7
- package/src/types/user.ts +1 -0
- 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/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
|
@@ -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 }
|
|
@@ -5,4 +5,4 @@ export * from "./delete-all-authenticators-by-user-id.js";
|
|
|
5
5
|
export * from "./delete-authenticator.js";
|
|
6
6
|
export * from "./find-authenticator.js";
|
|
7
7
|
export * from "./find-authenticators-by-user-id.js";
|
|
8
|
-
export * from "./
|
|
8
|
+
export * from "./rename-authenticator.js";
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { renameAuthenticatorFactory } from "./rename-authenticator.js";
|
|
7
|
+
|
|
8
|
+
//
|
|
9
|
+
|
|
10
|
+
const renameAuthenticator = renameAuthenticatorFactory({ pg: pg as any });
|
|
11
|
+
|
|
12
|
+
suite("renameAuthenticatorFactory", () => {
|
|
13
|
+
before(migrate);
|
|
14
|
+
beforeEach(emptyDatabase);
|
|
15
|
+
|
|
16
|
+
beforeEach(async () => {
|
|
17
|
+
await pg.sql`
|
|
18
|
+
INSERT INTO users
|
|
19
|
+
(id, email, created_at, updated_at, given_name, family_name, phone_number, job)
|
|
20
|
+
VALUES
|
|
21
|
+
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque'),
|
|
22
|
+
(2, 'perturabo@ironwarriors.world', '4444-04-04', '4444-04-04', 'perturabo', '', 'i', 'primarque')
|
|
23
|
+
;
|
|
24
|
+
`;
|
|
25
|
+
await pg.sql`
|
|
26
|
+
INSERT INTO authenticators
|
|
27
|
+
(credential_id, credential_public_key, counter, credential_backed_up, user_id, usage_count, user_verified, display_name)
|
|
28
|
+
VALUES
|
|
29
|
+
('CRED1', '\\x00', 42, false, 1, 7, true, 'iCloud Keychain')
|
|
30
|
+
;
|
|
31
|
+
`;
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("should rename the authenticator without touching its counters", async () => {
|
|
35
|
+
const authenticator = await renameAuthenticator(1, "CRED1", "iPhone perso");
|
|
36
|
+
|
|
37
|
+
assert.equal(authenticator?.display_name, "iPhone perso");
|
|
38
|
+
assert.equal(authenticator?.counter, 42);
|
|
39
|
+
assert.equal(authenticator?.usage_count, 7);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test("should reset the name to null", async () => {
|
|
43
|
+
const authenticator = await renameAuthenticator(1, "CRED1", null);
|
|
44
|
+
|
|
45
|
+
assert.equal(authenticator?.display_name, null);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("should not rename another user's authenticator", async () => {
|
|
49
|
+
const authenticator = await renameAuthenticator(2, "CRED1", "piraté");
|
|
50
|
+
|
|
51
|
+
assert.equal(authenticator, undefined);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
import type { Authenticator, DatabaseContext } from "#src/types";
|
|
4
|
+
import { type QueryResult } from "pg";
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
export function renameAuthenticatorFactory({ pg }: DatabaseContext) {
|
|
9
|
+
return async function renameAuthenticator(
|
|
10
|
+
user_id: number,
|
|
11
|
+
credential_id: string,
|
|
12
|
+
display_name: string | null,
|
|
13
|
+
) {
|
|
14
|
+
const { rows }: QueryResult<Authenticator> = await pg.query(
|
|
15
|
+
`
|
|
16
|
+
UPDATE authenticators
|
|
17
|
+
SET display_name = $3
|
|
18
|
+
WHERE user_id = $1
|
|
19
|
+
AND credential_id = $2
|
|
20
|
+
RETURNING *`,
|
|
21
|
+
[user_id, credential_id, display_name],
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
return rows.shift();
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -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";
|
|
@@ -2,13 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
export type Base64URLString = string;
|
|
4
4
|
export type AuthenticatorTransportFuture =
|
|
5
|
-
| "
|
|
6
|
-
| "cable"
|
|
7
|
-
| "hybrid"
|
|
8
|
-
| "internal"
|
|
9
|
-
| "nfc"
|
|
10
|
-
| "smart-card"
|
|
11
|
-
| "usb";
|
|
5
|
+
"ble" | "cable" | "hybrid" | "internal" | "nfc" | "smart-card" | "usb";
|
|
12
6
|
export type CredentialDeviceType = "singleDevice" | "multiDevice";
|
|
13
7
|
|
|
14
8
|
//
|
package/src/types/user.ts
CHANGED
|
@@ -26,6 +26,7 @@ export const UserSchema = z.object({
|
|
|
26
26
|
reset_password_sent_at: z.date().nullable(),
|
|
27
27
|
reset_password_token: z.string().nullable(),
|
|
28
28
|
sign_in_count: z.number(),
|
|
29
|
+
totp_display_name: z.string().nullable().default(null),
|
|
29
30
|
totp_key_verified_at: z.date().nullable(),
|
|
30
31
|
updated_at: z.date(),
|
|
31
32
|
verify_email_sent_at: z.date().nullable(),
|
package/testing/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
import type { FindPouvoirsBySirenHandler } from "@proconnect-gouv/proconnect.registre_national_entreprises/api";
|
|
10
10
|
import { noop } from "lodash-es";
|
|
11
11
|
import { runner } from "node-pg-migrate";
|
|
12
|
-
import { mock } from "node:test";
|
|
12
|
+
import { after, mock } from "node:test";
|
|
13
13
|
import { join } from "path";
|
|
14
14
|
import type { Pool } from "pg";
|
|
15
15
|
import type { FindUniteLegaleBySirenHandler } from "../../insee/src/api/find-by-siren.js";
|
|
@@ -19,6 +19,7 @@ import { createContext } from "../src/connectors/index.js";
|
|
|
19
19
|
//
|
|
20
20
|
|
|
21
21
|
export const pg = new PGlite();
|
|
22
|
+
after(() => pg.close());
|
|
22
23
|
|
|
23
24
|
export async function migrate() {
|
|
24
25
|
await runner({
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { Authenticator, Base64URLString, BaseAuthenticator, DatabaseContext } from "#src/types";
|
|
2
|
-
export declare function updateAuthenticatorFactory({ pg }: DatabaseContext): (credential_id: Base64URLString, { counter, last_used_at, usage_count }: Partial<BaseAuthenticator>) => Promise<Authenticator>;
|
|
3
|
-
//# sourceMappingURL=update-authenticator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-authenticator.d.ts","sourceRoot":"","sources":["../../../src/repositories/authenticator/update-authenticator.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,eAAe,EAChB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IAE9D,eAAe,eAAe,EAC9B,wCAAwC,OAAO,CAAC,iBAAiB,CAAC,4BAarE"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import {} from "pg";
|
|
3
|
-
//
|
|
4
|
-
export function updateAuthenticatorFactory({ pg }) {
|
|
5
|
-
return async function updateAuthenticator(credential_id, { counter, last_used_at, usage_count }) {
|
|
6
|
-
const { rows } = await pg.query(`
|
|
7
|
-
UPDATE authenticators
|
|
8
|
-
SET counter = $2, last_used_at = $3, usage_count = $4
|
|
9
|
-
WHERE credential_id = $1
|
|
10
|
-
RETURNING *`, [credential_id, counter, last_used_at, usage_count]);
|
|
11
|
-
return rows.shift();
|
|
12
|
-
};
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-email-in-deliverability-white-list.d.ts","sourceRoot":"","sources":["../../../src/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAMlD,wBAAgB,yCAAyC,CAAC,EACxD,EAAE,GACH,EAAE,eAAe,IACyC,OAAO,MAAM,6BAYvE"}
|
package/dist/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import {} from "#src/types";
|
|
3
|
-
import { getEmailDomain } from "@proconnect-gouv/proconnect.core/services/email";
|
|
4
|
-
import {} from "pg";
|
|
5
|
-
//
|
|
6
|
-
export function findEmailInDeliverabilityWhiteListFactory({ pg, }) {
|
|
7
|
-
return async function findEmailInDeliverabilityWhiteList(email) {
|
|
8
|
-
const domain = getEmailDomain(email);
|
|
9
|
-
const { rows } = await pg.query(`
|
|
10
|
-
SELECT *
|
|
11
|
-
FROM email_deliverability_whitelist WHERE email_domain = $1
|
|
12
|
-
`, [domain]);
|
|
13
|
-
return rows.shift();
|
|
14
|
-
};
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/repositories/email-deliverability-whitelist/index.ts"],"names":[],"mappings":"AAEA,cAAc,8CAA8C,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type DatabaseContext, type ModerationType } from "#src/types";
|
|
2
|
-
export declare function findPendingModerationFactory({ pg }: DatabaseContext): ({ user_id, organization_id, type, }: {
|
|
3
|
-
user_id: number;
|
|
4
|
-
organization_id: number;
|
|
5
|
-
type: ModerationType;
|
|
6
|
-
}) => Promise<{
|
|
7
|
-
id: number;
|
|
8
|
-
user_id: number;
|
|
9
|
-
organization_id: number;
|
|
10
|
-
ticket_id: string | null;
|
|
11
|
-
type: "non_verified_domain" | "organization_join_block";
|
|
12
|
-
created_at: Date;
|
|
13
|
-
moderated_at: Date | null;
|
|
14
|
-
comment: string | null;
|
|
15
|
-
moderated_by: string | null;
|
|
16
|
-
status: "accepted" | "pending" | "rejected" | "reopened" | "unknown";
|
|
17
|
-
end_user_reason: string;
|
|
18
|
-
allow_editing: boolean;
|
|
19
|
-
} | undefined>;
|
|
20
|
-
//# sourceMappingURL=find-pending-moderation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-pending-moderation.d.ts","sourceRoot":"","sources":["../../../src/repositories/moderation/find-pending-moderation.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,eAAe,EAEpB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,qCAIzC;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,cAAc,CAAC;CACtB;;;;;;;;;;;;;eAcF"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import {} from "#src/types";
|
|
3
|
-
import {} from "pg";
|
|
4
|
-
//
|
|
5
|
-
export function findPendingModerationFactory({ pg }) {
|
|
6
|
-
return async function findPendingModeration({ user_id, organization_id, type, }) {
|
|
7
|
-
const { rows } = await pg.query(`
|
|
8
|
-
SELECT *
|
|
9
|
-
FROM moderations
|
|
10
|
-
WHERE user_id = $1
|
|
11
|
-
AND organization_id = $2
|
|
12
|
-
AND type = $3
|
|
13
|
-
AND moderated_at IS NULL;`, [user_id, organization_id, type]);
|
|
14
|
-
return rows.shift();
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type DatabaseContext, type ModerationType } from "#src/types";
|
|
2
|
-
export declare function findRejectedModerationFactory({ pg }: DatabaseContext): ({ user_id, organization_id, type, }: {
|
|
3
|
-
user_id: number;
|
|
4
|
-
organization_id: number;
|
|
5
|
-
type: ModerationType;
|
|
6
|
-
}) => Promise<{
|
|
7
|
-
id: number;
|
|
8
|
-
user_id: number;
|
|
9
|
-
organization_id: number;
|
|
10
|
-
ticket_id: string | null;
|
|
11
|
-
type: "non_verified_domain" | "organization_join_block";
|
|
12
|
-
created_at: Date;
|
|
13
|
-
moderated_at: Date | null;
|
|
14
|
-
comment: string | null;
|
|
15
|
-
moderated_by: string | null;
|
|
16
|
-
status: "accepted" | "pending" | "rejected" | "reopened" | "unknown";
|
|
17
|
-
end_user_reason: string;
|
|
18
|
-
allow_editing: boolean;
|
|
19
|
-
} | undefined>;
|
|
20
|
-
//# sourceMappingURL=find-rejected-moderation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-rejected-moderation.d.ts","sourceRoot":"","sources":["../../../src/repositories/moderation/find-rejected-moderation.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,eAAe,EAEpB,KAAK,cAAc,EACpB,MAAM,YAAY,CAAC;AAKpB,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,qCAI1C;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,cAAc,CAAC;CACtB;;;;;;;;;;;;;eAeF"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { ModerationStatusSchema, } from "#src/types";
|
|
3
|
-
import {} from "pg";
|
|
4
|
-
//
|
|
5
|
-
export function findRejectedModerationFactory({ pg }) {
|
|
6
|
-
return async function findRejectedModeration({ user_id, organization_id, type, }) {
|
|
7
|
-
const { rows } = await pg.query(`
|
|
8
|
-
SELECT *
|
|
9
|
-
FROM moderations
|
|
10
|
-
WHERE user_id = $1
|
|
11
|
-
AND organization_id = $2
|
|
12
|
-
AND type = $3
|
|
13
|
-
AND moderated_at IS NOT NULL
|
|
14
|
-
AND status = $4;`, [user_id, organization_id, type, ModerationStatusSchema.enum.rejected]);
|
|
15
|
-
return rows.shift();
|
|
16
|
-
};
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-by-siret.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/find-by-siret.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAKhE,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,OAAO,MAAM,uCAYhD"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import {} from "pg";
|
|
3
|
-
//
|
|
4
|
-
export function findBySiretFactory({ pg }) {
|
|
5
|
-
return async function findBySiret(siret) {
|
|
6
|
-
const { rows } = await pg.query(`
|
|
7
|
-
SELECT *
|
|
8
|
-
FROM organizations
|
|
9
|
-
WHERE siret = $1
|
|
10
|
-
`, [siret]);
|
|
11
|
-
return rows.shift();
|
|
12
|
-
};
|
|
13
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext } from "#src/types";
|
|
2
|
-
import { type Organization } from "#src/types";
|
|
3
|
-
export declare function findPendingByUserIdFactory({ pg }: DatabaseContext): (user_id: number) => Promise<(Organization & {
|
|
4
|
-
moderation_id: number;
|
|
5
|
-
})[]>;
|
|
6
|
-
//# sourceMappingURL=find-pending-by-user-id.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-pending-by-user-id.d.ts","sourceRoot":"","sources":["../../../src/repositories/organization/find-pending-by-user-id.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAKrE,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,SAAS,MAAM;mBACK,MAAM;MAgBrE"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import { ModerationTypeSchema } from "#src/types";
|
|
3
|
-
import {} from "pg";
|
|
4
|
-
//
|
|
5
|
-
export function findPendingByUserIdFactory({ pg }) {
|
|
6
|
-
return async function findPendingByUserId(user_id) {
|
|
7
|
-
const { rows } = await pg.query(`
|
|
8
|
-
SELECT o.*, m.id as moderation_id
|
|
9
|
-
FROM moderations m
|
|
10
|
-
INNER JOIN organizations o on o.id = m.organization_id
|
|
11
|
-
WHERE m.user_id = $1
|
|
12
|
-
AND m.type = $2
|
|
13
|
-
AND m.moderated_at IS NULL
|
|
14
|
-
ORDER BY m.created_at
|
|
15
|
-
`, [user_id, ModerationTypeSchema.enum.organization_join_block]);
|
|
16
|
-
return rows;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { DatabaseContext } from "#src/types";
|
|
2
|
-
export declare function findByResetPasswordTokenFactory({ pg }: DatabaseContext): (reset_password_token: string) => Promise<{
|
|
3
|
-
created_at: Date;
|
|
4
|
-
current_challenge: string | null;
|
|
5
|
-
email: string;
|
|
6
|
-
email_verified: boolean;
|
|
7
|
-
email_verified_at: Date | null;
|
|
8
|
-
encrypted_password: string | null;
|
|
9
|
-
encrypted_totp_key: string | null;
|
|
10
|
-
family_name: string | null;
|
|
11
|
-
force_2fa: boolean;
|
|
12
|
-
given_name: string | null;
|
|
13
|
-
id: number;
|
|
14
|
-
job: string | null;
|
|
15
|
-
last_sign_in_at: Date | null;
|
|
16
|
-
magic_link_sent_at: Date | null;
|
|
17
|
-
magic_link_token: string | null;
|
|
18
|
-
needs_inclusionconnect_onboarding_help: boolean;
|
|
19
|
-
needs_inclusionconnect_welcome_page: boolean;
|
|
20
|
-
phone_number: string | null;
|
|
21
|
-
reset_password_sent_at: Date | null;
|
|
22
|
-
reset_password_token: string | null;
|
|
23
|
-
sign_in_count: number;
|
|
24
|
-
totp_key_verified_at: Date | null;
|
|
25
|
-
updated_at: Date;
|
|
26
|
-
verify_email_sent_at: Date | null;
|
|
27
|
-
verify_email_token: string | null;
|
|
28
|
-
} | undefined>;
|
|
29
|
-
//# sourceMappingURL=find-by-reset-password-token.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find-by-reset-password-token.d.ts","sourceRoot":"","sources":["../../../src/repositories/user/find-by-reset-password-token.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAQ,MAAM,YAAY,CAAC;AAKxD,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,IACtB,sBAAsB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;eAW5E"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
import {} from "pg";
|
|
3
|
-
//
|
|
4
|
-
export function findByResetPasswordTokenFactory({ pg }) {
|
|
5
|
-
return async function findByResetPasswordToken(reset_password_token) {
|
|
6
|
-
const { rows } = await pg.query(`
|
|
7
|
-
SELECT *
|
|
8
|
-
FROM users WHERE reset_password_token = $1
|
|
9
|
-
`, [reset_password_token]);
|
|
10
|
-
return rows.shift();
|
|
11
|
-
};
|
|
12
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
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 { updateAuthenticatorFactory } from "./update-authenticator.js";
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
const updateAuthenticator = updateAuthenticatorFactory({ pg: pg as any });
|
|
11
|
-
|
|
12
|
-
suite("updateAuthenticatorFactory", () => {
|
|
13
|
-
before(migrate);
|
|
14
|
-
beforeEach(emptyDatabase);
|
|
15
|
-
|
|
16
|
-
test("should update and return the authenticator", async () => {
|
|
17
|
-
await pg.sql`
|
|
18
|
-
INSERT INTO users
|
|
19
|
-
(id, email, created_at, updated_at, given_name, family_name, phone_number, job)
|
|
20
|
-
VALUES
|
|
21
|
-
(1, 'lion.eljonson@darkangels.world', '4444-04-04', '4444-04-04', 'lion', 'el''jonson', 'i', 'primarque')
|
|
22
|
-
;
|
|
23
|
-
`;
|
|
24
|
-
await pg.sql`
|
|
25
|
-
INSERT INTO authenticators
|
|
26
|
-
(credential_id, credential_public_key, counter, credential_backed_up, user_id, usage_count, user_verified, last_used_at)
|
|
27
|
-
VALUES
|
|
28
|
-
('CRED1', '\\x00', 0, false, 1, 0, true, '4444-04-04')
|
|
29
|
-
;
|
|
30
|
-
`;
|
|
31
|
-
|
|
32
|
-
const result = await updateAuthenticator("CRED1", {
|
|
33
|
-
counter: 7,
|
|
34
|
-
last_used_at: new Date("4444-04-05"),
|
|
35
|
-
usage_count: 3,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
assert.equal(result.counter, 7);
|
|
39
|
-
assert.equal(result.usage_count, 3);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
Authenticator,
|
|
5
|
-
Base64URLString,
|
|
6
|
-
BaseAuthenticator,
|
|
7
|
-
DatabaseContext,
|
|
8
|
-
} from "#src/types";
|
|
9
|
-
import { type QueryResult } from "pg";
|
|
10
|
-
|
|
11
|
-
//
|
|
12
|
-
|
|
13
|
-
export function updateAuthenticatorFactory({ pg }: DatabaseContext) {
|
|
14
|
-
return async function updateAuthenticator(
|
|
15
|
-
credential_id: Base64URLString,
|
|
16
|
-
{ counter, last_used_at, usage_count }: Partial<BaseAuthenticator>,
|
|
17
|
-
) {
|
|
18
|
-
const { rows }: QueryResult<Authenticator> = await pg.query(
|
|
19
|
-
`
|
|
20
|
-
UPDATE authenticators
|
|
21
|
-
SET counter = $2, last_used_at = $3, usage_count = $4
|
|
22
|
-
WHERE credential_id = $1
|
|
23
|
-
RETURNING *`,
|
|
24
|
-
[credential_id, counter, last_used_at, usage_count],
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
return rows.shift()!;
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
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 { findEmailInDeliverabilityWhiteListFactory } from "./find-email-in-deliverability-white-list.js";
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
const findEmailInDeliverabilityWhiteList =
|
|
11
|
-
findEmailInDeliverabilityWhiteListFactory({ pg: pg as any });
|
|
12
|
-
|
|
13
|
-
suite("findEmailInDeliverabilityWhiteListFactory", () => {
|
|
14
|
-
before(migrate);
|
|
15
|
-
beforeEach(emptyDatabase);
|
|
16
|
-
|
|
17
|
-
test("should return undefined when the domain is not whitelisted", async () => {
|
|
18
|
-
const result = await findEmailInDeliverabilityWhiteList(
|
|
19
|
-
"lion@darkangels.world",
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
assert.equal(result, undefined);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
test("should return the whitelist entry when the domain matches", async () => {
|
|
26
|
-
await pg.sql`
|
|
27
|
-
INSERT INTO email_deliverability_whitelist
|
|
28
|
-
(problematic_email, email_domain)
|
|
29
|
-
VALUES
|
|
30
|
-
('lion@darkangels.world', 'darkangels.world')
|
|
31
|
-
;
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
const result = await findEmailInDeliverabilityWhiteList(
|
|
35
|
-
"lion@darkangels.world",
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
assert.deepEqual(result, {
|
|
39
|
-
problematic_email: "lion@darkangels.world",
|
|
40
|
-
email_domain: "darkangels.world",
|
|
41
|
-
verified_at: result?.verified_at,
|
|
42
|
-
verified_by: null,
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
package/src/repositories/email-deliverability-whitelist/find-email-in-deliverability-white-list.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
import { type DatabaseContext } from "#src/types";
|
|
4
|
-
import { getEmailDomain } from "@proconnect-gouv/proconnect.core/services/email";
|
|
5
|
-
import { type QueryResult } from "pg";
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
|
|
9
|
-
export function findEmailInDeliverabilityWhiteListFactory({
|
|
10
|
-
pg,
|
|
11
|
-
}: DatabaseContext) {
|
|
12
|
-
return async function findEmailInDeliverabilityWhiteList(email: string) {
|
|
13
|
-
const domain = getEmailDomain(email);
|
|
14
|
-
const { rows }: QueryResult<{}> = await pg.query(
|
|
15
|
-
`
|
|
16
|
-
SELECT *
|
|
17
|
-
FROM email_deliverability_whitelist WHERE email_domain = $1
|
|
18
|
-
`,
|
|
19
|
-
[domain],
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
return rows.shift();
|
|
23
|
-
};
|
|
24
|
-
}
|