@effect-auth/core 0.1.0-alpha.1 → 0.1.0-alpha.10
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/README.md +728 -72
- package/dist/ApiKey.d.ts +207 -0
- package/dist/ApiKey.d.ts.map +1 -0
- package/dist/ApiKey.js +275 -0
- package/dist/ApiKey.js.map +1 -0
- package/dist/AuditLog.d.ts +275 -1
- package/dist/AuditLog.d.ts.map +1 -1
- package/dist/AuditLog.js +213 -1
- package/dist/AuditLog.js.map +1 -1
- package/dist/AuthConfig.d.ts +42 -0
- package/dist/AuthConfig.d.ts.map +1 -0
- package/dist/AuthConfig.js +43 -0
- package/dist/AuthConfig.js.map +1 -0
- package/dist/AuthFlow.d.ts +462 -36
- package/dist/AuthFlow.d.ts.map +1 -1
- package/dist/AuthFlow.js +657 -5
- package/dist/AuthFlow.js.map +1 -1
- package/dist/AuthKernel.d.ts +3 -0
- package/dist/AuthKernel.d.ts.map +1 -0
- package/dist/AuthKernel.js +9 -0
- package/dist/AuthKernel.js.map +1 -0
- package/dist/Challenge.d.ts +24 -4
- package/dist/Challenge.d.ts.map +1 -1
- package/dist/Challenge.js +167 -1
- package/dist/Challenge.js.map +1 -1
- package/dist/Client.d.ts +378 -0
- package/dist/Client.d.ts.map +1 -0
- package/dist/Client.js +768 -0
- package/dist/Client.js.map +1 -0
- package/dist/Crypto.d.ts +6 -1
- package/dist/Crypto.d.ts.map +1 -1
- package/dist/Crypto.js +62 -1
- package/dist/Crypto.js.map +1 -1
- package/dist/EffectQbSqliteStorage.d.ts +600 -0
- package/dist/EffectQbSqliteStorage.d.ts.map +1 -0
- package/dist/EffectQbSqliteStorage.js +1637 -0
- package/dist/EffectQbSqliteStorage.js.map +1 -0
- package/dist/EmailOtp.d.ts +120 -0
- package/dist/EmailOtp.d.ts.map +1 -0
- package/dist/EmailOtp.js +286 -0
- package/dist/EmailOtp.js.map +1 -0
- package/dist/EmailVerification.d.ts +121 -0
- package/dist/EmailVerification.d.ts.map +1 -0
- package/dist/EmailVerification.js +200 -0
- package/dist/EmailVerification.js.map +1 -0
- package/dist/HttpApi/Api.d.ts +1956 -0
- package/dist/HttpApi/Api.d.ts.map +1 -0
- package/dist/HttpApi/Api.js +2325 -0
- package/dist/HttpApi/Api.js.map +1 -0
- package/dist/HttpApi/Endpoints.d.ts +945 -0
- package/dist/HttpApi/Endpoints.d.ts.map +1 -0
- package/dist/HttpApi/Endpoints.js +373 -0
- package/dist/HttpApi/Endpoints.js.map +1 -0
- package/dist/HttpApi/Errors.d.ts +82 -0
- package/dist/HttpApi/Errors.d.ts.map +1 -0
- package/dist/HttpApi/Errors.js +184 -0
- package/dist/HttpApi/Errors.js.map +1 -0
- package/dist/HttpApi/Schemas.d.ts +1113 -0
- package/dist/HttpApi/Schemas.d.ts.map +1 -0
- package/dist/HttpApi/Schemas.js +734 -0
- package/dist/HttpApi/Schemas.js.map +1 -0
- package/dist/HttpApi/Security.d.ts +159 -0
- package/dist/HttpApi/Security.d.ts.map +1 -0
- package/dist/HttpApi/Security.js +530 -0
- package/dist/HttpApi/Security.js.map +1 -0
- package/dist/HttpApi/Transport.d.ts +65 -0
- package/dist/HttpApi/Transport.d.ts.map +1 -0
- package/dist/HttpApi/Transport.js +311 -0
- package/dist/HttpApi/Transport.js.map +1 -0
- package/dist/HttpApi/index.d.ts +8 -0
- package/dist/HttpApi/index.d.ts.map +1 -0
- package/dist/HttpApi/index.js +7 -0
- package/dist/HttpApi/index.js.map +1 -0
- package/dist/HttpApi.d.ts +2 -0
- package/dist/HttpApi.d.ts.map +1 -0
- package/dist/HttpApi.js +2 -0
- package/dist/HttpApi.js.map +1 -0
- package/dist/Identifiers.d.ts.map +1 -1
- package/dist/Identifiers.js.map +1 -1
- package/dist/Internal.d.ts +7 -0
- package/dist/Internal.d.ts.map +1 -0
- package/dist/Internal.js +12 -0
- package/dist/Internal.js.map +1 -0
- package/dist/Jwt.d.ts +271 -0
- package/dist/Jwt.d.ts.map +1 -0
- package/dist/Jwt.js +512 -0
- package/dist/Jwt.js.map +1 -0
- package/dist/LoginApproval.d.ts +314 -0
- package/dist/LoginApproval.d.ts.map +1 -0
- package/dist/LoginApproval.js +551 -0
- package/dist/LoginApproval.js.map +1 -0
- package/dist/LoginNotification.d.ts +183 -0
- package/dist/LoginNotification.d.ts.map +1 -0
- package/dist/LoginNotification.js +329 -0
- package/dist/LoginNotification.js.map +1 -0
- package/dist/LoginRisk.d.ts +73 -0
- package/dist/LoginRisk.d.ts.map +1 -0
- package/dist/LoginRisk.js +57 -0
- package/dist/LoginRisk.js.map +1 -0
- package/dist/MagicLink.d.ts +85 -0
- package/dist/MagicLink.d.ts.map +1 -0
- package/dist/MagicLink.js +206 -0
- package/dist/MagicLink.js.map +1 -0
- package/dist/Mailer.d.ts +147 -0
- package/dist/Mailer.d.ts.map +1 -0
- package/dist/Mailer.js +208 -0
- package/dist/Mailer.js.map +1 -0
- package/dist/OAuth.d.ts +934 -0
- package/dist/OAuth.d.ts.map +1 -0
- package/dist/OAuth.js +1661 -0
- package/dist/OAuth.js.map +1 -0
- package/dist/Passkey.d.ts +334 -0
- package/dist/Passkey.d.ts.map +1 -0
- package/dist/Passkey.js +422 -0
- package/dist/Passkey.js.map +1 -0
- package/dist/PasskeySimpleWebAuthn.d.ts +11 -0
- package/dist/PasskeySimpleWebAuthn.d.ts.map +1 -0
- package/dist/PasskeySimpleWebAuthn.js +181 -0
- package/dist/PasskeySimpleWebAuthn.js.map +1 -0
- package/dist/Password.d.ts +237 -0
- package/dist/Password.d.ts.map +1 -0
- package/dist/Password.js +641 -0
- package/dist/Password.js.map +1 -0
- package/dist/Policy.d.ts +7 -4
- package/dist/Policy.d.ts.map +1 -1
- package/dist/Policy.js +28 -5
- package/dist/Policy.js.map +1 -1
- package/dist/Privacy.d.ts +15 -0
- package/dist/Privacy.d.ts.map +1 -1
- package/dist/Privacy.js +58 -1
- package/dist/Privacy.js.map +1 -1
- package/dist/RateLimiter.d.ts +104 -0
- package/dist/RateLimiter.d.ts.map +1 -0
- package/dist/RateLimiter.js +118 -0
- package/dist/RateLimiter.js.map +1 -0
- package/dist/RecoveryCode.d.ts +169 -0
- package/dist/RecoveryCode.d.ts.map +1 -0
- package/dist/RecoveryCode.js +299 -0
- package/dist/RecoveryCode.js.map +1 -0
- package/dist/RefreshToken.d.ts +222 -0
- package/dist/RefreshToken.d.ts.map +1 -0
- package/dist/RefreshToken.js +342 -0
- package/dist/RefreshToken.js.map +1 -0
- package/dist/SecurityTimeline.d.ts +72 -0
- package/dist/SecurityTimeline.d.ts.map +1 -0
- package/dist/SecurityTimeline.js +386 -0
- package/dist/SecurityTimeline.js.map +1 -0
- package/dist/Sessions.d.ts +123 -11
- package/dist/Sessions.d.ts.map +1 -1
- package/dist/Sessions.js +534 -1
- package/dist/Sessions.js.map +1 -1
- package/dist/StepUp.d.ts +44 -0
- package/dist/StepUp.d.ts.map +1 -0
- package/dist/StepUp.js +82 -0
- package/dist/StepUp.js.map +1 -0
- package/dist/Storage.d.ts +73 -5
- package/dist/Storage.d.ts.map +1 -1
- package/dist/Storage.js +11 -1
- package/dist/Storage.js.map +1 -1
- package/dist/StorageMigrations.d.ts +13 -1
- package/dist/StorageMigrations.d.ts.map +1 -1
- package/dist/StorageMigrations.js +256 -2
- package/dist/StorageMigrations.js.map +1 -1
- package/dist/Testing.d.ts +9 -1
- package/dist/Testing.d.ts.map +1 -1
- package/dist/Testing.js +30 -2
- package/dist/Testing.js.map +1 -1
- package/dist/Totp.d.ts +220 -0
- package/dist/Totp.d.ts.map +1 -0
- package/dist/Totp.js +477 -0
- package/dist/Totp.js.map +1 -0
- package/dist/TrustedDevice.d.ts +127 -0
- package/dist/TrustedDevice.d.ts.map +1 -0
- package/dist/TrustedDevice.js +252 -0
- package/dist/TrustedDevice.js.map +1 -0
- package/dist/WaitUntil.d.ts.map +1 -1
- package/dist/WaitUntil.js +1 -1
- package/dist/WaitUntil.js.map +1 -1
- package/dist/Webhook.d.ts +72 -0
- package/dist/Webhook.d.ts.map +1 -0
- package/dist/Webhook.js +82 -0
- package/dist/Webhook.js.map +1 -0
- package/dist/alchemy/cloudflare/Email.d.ts +25 -0
- package/dist/alchemy/cloudflare/Email.d.ts.map +1 -0
- package/dist/alchemy/cloudflare/Email.js +117 -0
- package/dist/alchemy/cloudflare/Email.js.map +1 -0
- package/dist/alchemy/cloudflare/RateLimitDurableObject.d.ts +34 -0
- package/dist/alchemy/cloudflare/RateLimitDurableObject.d.ts.map +1 -0
- package/dist/alchemy/cloudflare/RateLimitDurableObject.js +30 -0
- package/dist/alchemy/cloudflare/RateLimitDurableObject.js.map +1 -0
- package/dist/cloudflare/Email.d.ts +25 -0
- package/dist/cloudflare/Email.d.ts.map +1 -0
- package/dist/cloudflare/Email.js +153 -0
- package/dist/cloudflare/Email.js.map +1 -0
- package/dist/cloudflare/RateLimitDurableObject.d.ts +50 -0
- package/dist/cloudflare/RateLimitDurableObject.d.ts.map +1 -0
- package/dist/cloudflare/RateLimitDurableObject.js +51 -0
- package/dist/cloudflare/RateLimitDurableObject.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/RateLimitDurableObject.d.ts +32 -0
- package/dist/internal/RateLimitDurableObject.d.ts.map +1 -0
- package/dist/internal/RateLimitDurableObject.js +80 -0
- package/dist/internal/RateLimitDurableObject.js.map +1 -0
- package/migrations/0002_auth_password.sql +25 -0
- package/migrations/0003_auth_login_approval_review.sql +22 -0
- package/migrations/0004_auth_trusted_device.sql +12 -0
- package/migrations/0005_auth_passkey.sql +17 -0
- package/migrations/0006_auth_totp_factor.sql +17 -0
- package/migrations/0007_auth_recovery_code.sql +13 -0
- package/migrations/0008_auth_api_key.sql +17 -0
- package/migrations/0009_auth_refresh_token.sql +21 -0
- package/migrations/0010_auth_jwt_revocation.sql +8 -0
- package/migrations/0011_auth_oauth_account.sql +16 -0
- package/migrations/0012_auth_oauth_provider_token_vault.sql +20 -0
- package/migrations/0013_auth_security_timeline.sql +16 -0
- package/package.json +146 -26
- package/dist/D1Kysely.d.ts +0 -40
- package/dist/D1Kysely.d.ts.map +0 -1
- package/dist/D1Kysely.js +0 -75
- package/dist/D1Kysely.js.map +0 -1
- package/dist/KyselyStorage.d.ts +0 -41
- package/dist/KyselyStorage.d.ts.map +0 -1
- package/dist/KyselyStorage.js +0 -176
- package/dist/KyselyStorage.js.map +0 -1
package/dist/StepUp.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Data, Duration, Effect } from "effect";
|
|
2
|
+
import { currentUnixMillis } from "./Internal.js";
|
|
3
|
+
import { AuthzError } from "./Policy.js";
|
|
4
|
+
import { CurrentSession } from "./Sessions.js";
|
|
5
|
+
export class StepUpRequired extends Data.TaggedError("StepUpRequired") {
|
|
6
|
+
}
|
|
7
|
+
const aalRank = {
|
|
8
|
+
aal1: 1,
|
|
9
|
+
aal2: 2,
|
|
10
|
+
aal3: 3,
|
|
11
|
+
};
|
|
12
|
+
export const aalAtLeast = (actual, minimum) => aalRank[actual] >= aalRank[minimum];
|
|
13
|
+
const aalFailure = (session, requiredAal) => aalAtLeast(session.aal, requiredAal)
|
|
14
|
+
? undefined
|
|
15
|
+
: {
|
|
16
|
+
reason: "aal-too-low",
|
|
17
|
+
requiredAal,
|
|
18
|
+
currentAal: session.aal,
|
|
19
|
+
};
|
|
20
|
+
const freshnessFailure = (session, now, maxAge, verifiedAt = Number(session.authTime)) => {
|
|
21
|
+
const maxAgeMillis = Duration.toMillis(maxAge);
|
|
22
|
+
const authAgeMillis = Math.max(0, now - verifiedAt);
|
|
23
|
+
return authAgeMillis <= maxAgeMillis
|
|
24
|
+
? undefined
|
|
25
|
+
: {
|
|
26
|
+
reason: "auth-too-old",
|
|
27
|
+
maxAgeMillis,
|
|
28
|
+
authAgeMillis,
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
const freshnessReferenceTime = (session, requiredAal) => requiredAal !== undefined &&
|
|
32
|
+
aalRank[requiredAal] >= aalRank.aal2 &&
|
|
33
|
+
session.mfaVerifiedAt !== undefined
|
|
34
|
+
? Number(session.mfaVerifiedAt)
|
|
35
|
+
: Number(session.authTime);
|
|
36
|
+
const sessionRequirementFailures = (session, noSessionRequirements) => {
|
|
37
|
+
if (noSessionRequirements === undefined || noSessionRequirements.length === 0) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
const activeRequirements = session.claims?.requirements ?? [];
|
|
41
|
+
return noSessionRequirements.flatMap((requirement) => activeRequirements.includes(requirement)
|
|
42
|
+
? [
|
|
43
|
+
{
|
|
44
|
+
reason: "session-requirement-unsatisfied",
|
|
45
|
+
requirement,
|
|
46
|
+
},
|
|
47
|
+
]
|
|
48
|
+
: []);
|
|
49
|
+
};
|
|
50
|
+
export const checkStepUp = (requirement) => Effect.gen(function* () {
|
|
51
|
+
const session = yield* CurrentSession;
|
|
52
|
+
const now = requirement.maxAge === undefined ? undefined : yield* currentUnixMillis;
|
|
53
|
+
const failures = [
|
|
54
|
+
...(requirement.aal === undefined
|
|
55
|
+
? []
|
|
56
|
+
: [aalFailure(session, requirement.aal)].filter((failure) => failure !== undefined)),
|
|
57
|
+
...(requirement.maxAge === undefined || now === undefined
|
|
58
|
+
? []
|
|
59
|
+
: [
|
|
60
|
+
freshnessFailure(session, Number(now), requirement.maxAge, freshnessReferenceTime(session, requirement.aal)),
|
|
61
|
+
].filter((failure) => failure !== undefined)),
|
|
62
|
+
...sessionRequirementFailures(session, requirement.noSessionRequirements),
|
|
63
|
+
];
|
|
64
|
+
return failures.length === 0
|
|
65
|
+
? { _tag: "Satisfied", session }
|
|
66
|
+
: { _tag: "Required", session, failures };
|
|
67
|
+
});
|
|
68
|
+
export const requireStepUp = (requirement) => Effect.flatMap(checkStepUp(requirement), (decision) => decision._tag === "Satisfied"
|
|
69
|
+
? Effect.void
|
|
70
|
+
: Effect.fail(new StepUpRequired({
|
|
71
|
+
failures: decision.failures,
|
|
72
|
+
session: decision.session,
|
|
73
|
+
})));
|
|
74
|
+
export const requireAal = (aal) => requireStepUp({ aal });
|
|
75
|
+
export const requireFresh = (maxAge) => requireStepUp({ maxAge });
|
|
76
|
+
export const requireNoSessionRequirements = (...requirements) => requireStepUp({ noSessionRequirements: requirements });
|
|
77
|
+
export const toPolicy = (requirement, policyId) => requireStepUp(requirement).pipe(Effect.mapError((cause) => new AuthzError({
|
|
78
|
+
reason: "step-up-required",
|
|
79
|
+
policyId,
|
|
80
|
+
cause,
|
|
81
|
+
})));
|
|
82
|
+
//# sourceMappingURL=StepUp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StepUp.js","sourceRoot":"","sources":["../src/StepUp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAmC/C,MAAM,OAAO,cAAe,SAAQ,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAGnE;CAAG;AAEL,MAAM,OAAO,GAAuC;IAClD,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;CACR,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,MAA0B,EAC1B,OAA2B,EAClB,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;AAElD,MAAM,UAAU,GAAG,CACjB,OAA4B,EAC5B,WAA+B,EACE,EAAE,CACnC,UAAU,CAAC,OAAO,CAAC,GAAG,EAAE,WAAW,CAAC;IAClC,CAAC,CAAC,SAAS;IACX,CAAC,CAAC;QACE,MAAM,EAAE,aAAa;QACrB,WAAW;QAC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AM,aAAa,GAAG,CAC3B,WAA8B,EACuB,EAAE,CACvD,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CACpD,QAAQ,CAAC,IAAI,KAAK,WAAW;IAC3B,CAAC,CAAC,MAAM,CAAC,IAAI;IACb,CAAC,CAAC,MAAM,CAAC,IAAI,CACT,IAAI,cAAc,CAAC;QACjB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;KAC1B,CAAC,CACH,CACN,CAAC;AAEJ,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,GAAuB,EAC8B,EAAE,CACvD,aAAa,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;AAEzB,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,MAAyB,EAC4B,EAAE,CACvD,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;AAE5B,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAC1C,GAAG,YAA2C,EACO,EAAE,CACvD,aAAa,CAAC,EAAE,qBAAqB,EAAE,YAAY,EAAE,CAAC,CAAC;AAEzD,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,WAA8B,EAC9B,QAAmB,EAC8B,EAAE,CACnD,aAAa,CAAC,WAAW,CAAC,CAAC,IAAI,CAC7B,MAAM,CAAC,QAAQ,CACb,CAAC,KAAK,EAAE,EAAE,CACR,IAAI,UAAU,CAAC;IACb,MAAM,EAAE,kBAAkB;IAC1B,QAAQ;IACR,KAAK;CACN,CAAC,CACL,CACF,CAAC"}
|
package/dist/Storage.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Effect } from "effect";
|
|
2
|
+
import { Context } from "effect";
|
|
2
3
|
import type * as Option from "effect/Option";
|
|
3
4
|
import type { ChallengeType } from "./Challenge.js";
|
|
4
|
-
import type { ChallengeId, SessionId, UnixMillis, UserId } from "./Identifiers.js";
|
|
5
|
-
import type { AuthAssuranceLevel, AuthMethodReference } from "./Sessions.js";
|
|
6
|
-
export type StorageEntity = "session" | "verification" | (string & {});
|
|
5
|
+
import type { ChallengeId, CredentialId, Email, SessionId, UnixMillis, UserId } from "./Identifiers.js";
|
|
6
|
+
import type { AuthAssuranceLevel, AuthMethodReference, SessionClaims } from "./Sessions.js";
|
|
7
|
+
export type StorageEntity = "user" | "credential" | "session" | "verification" | (string & {});
|
|
7
8
|
export type StorageOperation = "find" | "insert" | "update" | "delete" | "consume" | (string & {});
|
|
8
9
|
declare const StorageError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
9
10
|
readonly _tag: "StorageError";
|
|
@@ -18,6 +19,60 @@ export declare class StorageError extends StorageError_base<{
|
|
|
18
19
|
export declare namespace StorageError {
|
|
19
20
|
const fromUnknown: (entity: StorageEntity, operation: StorageOperation, cause: unknown, message?: string) => StorageError;
|
|
20
21
|
}
|
|
22
|
+
export interface NewUserRow {
|
|
23
|
+
readonly id: UserId;
|
|
24
|
+
readonly email: Email;
|
|
25
|
+
readonly emailVerified: boolean;
|
|
26
|
+
readonly createdAt: UnixMillis;
|
|
27
|
+
readonly updatedAt: UnixMillis;
|
|
28
|
+
readonly disabledAt?: UnixMillis;
|
|
29
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
30
|
+
}
|
|
31
|
+
export interface UserRow extends NewUserRow {
|
|
32
|
+
}
|
|
33
|
+
export interface UserMarkEmailVerifiedInput {
|
|
34
|
+
readonly userId: UserId;
|
|
35
|
+
readonly updatedAt: UnixMillis;
|
|
36
|
+
}
|
|
37
|
+
export interface UserStoreService {
|
|
38
|
+
readonly findById: (id: UserId) => Effect.Effect<Option.Option<UserRow>, StorageError>;
|
|
39
|
+
readonly findByEmail: (email: Email) => Effect.Effect<Option.Option<UserRow>, StorageError>;
|
|
40
|
+
readonly insert: (row: NewUserRow) => Effect.Effect<void, StorageError>;
|
|
41
|
+
readonly markEmailVerified: (input: UserMarkEmailVerifiedInput) => Effect.Effect<Option.Option<UserRow>, StorageError>;
|
|
42
|
+
}
|
|
43
|
+
declare const UserStore_base: Context.ServiceClass<UserStore, "auth/UserStore", UserStoreService>;
|
|
44
|
+
export declare class UserStore extends UserStore_base {
|
|
45
|
+
}
|
|
46
|
+
export declare namespace UserStore {
|
|
47
|
+
const make: (service: UserStoreService) => UserStoreService;
|
|
48
|
+
}
|
|
49
|
+
export interface NewPasswordCredentialRow {
|
|
50
|
+
readonly id: CredentialId;
|
|
51
|
+
readonly userId: UserId;
|
|
52
|
+
readonly passwordHash: string;
|
|
53
|
+
readonly createdAt: UnixMillis;
|
|
54
|
+
readonly updatedAt: UnixMillis;
|
|
55
|
+
readonly revokedAt?: UnixMillis;
|
|
56
|
+
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
57
|
+
}
|
|
58
|
+
export interface PasswordCredentialRow extends NewPasswordCredentialRow {
|
|
59
|
+
}
|
|
60
|
+
export interface PasswordCredentialUpdatePasswordInput {
|
|
61
|
+
readonly userId: UserId;
|
|
62
|
+
readonly passwordHash: string;
|
|
63
|
+
readonly updatedAt: UnixMillis;
|
|
64
|
+
}
|
|
65
|
+
export interface CredentialStoreService {
|
|
66
|
+
readonly findPasswordByUserId: (userId: UserId) => Effect.Effect<Option.Option<PasswordCredentialRow>, StorageError>;
|
|
67
|
+
readonly insertPassword: (row: NewPasswordCredentialRow) => Effect.Effect<void, StorageError>;
|
|
68
|
+
readonly updatePassword: (input: PasswordCredentialUpdatePasswordInput) => Effect.Effect<Option.Option<PasswordCredentialRow>, StorageError>;
|
|
69
|
+
}
|
|
70
|
+
declare const CredentialStore_base: Context.ServiceClass<CredentialStore, "auth/CredentialStore", CredentialStoreService>;
|
|
71
|
+
export declare class CredentialStore extends CredentialStore_base {
|
|
72
|
+
}
|
|
73
|
+
export declare namespace CredentialStore {
|
|
74
|
+
const make: (service: CredentialStoreService) => CredentialStoreService;
|
|
75
|
+
}
|
|
21
76
|
export interface NewSessionRow {
|
|
22
77
|
readonly id: SessionId;
|
|
23
78
|
readonly userId: UserId;
|
|
@@ -26,7 +81,8 @@ export interface NewSessionRow {
|
|
|
26
81
|
readonly expiresAt: UnixMillis;
|
|
27
82
|
readonly authTime: UnixMillis;
|
|
28
83
|
readonly aal: AuthAssuranceLevel;
|
|
29
|
-
readonly amr:
|
|
84
|
+
readonly amr: readonly AuthMethodReference[];
|
|
85
|
+
readonly claims?: SessionClaims;
|
|
30
86
|
readonly mfaVerifiedAt?: UnixMillis;
|
|
31
87
|
readonly metadata?: Readonly<Record<string, unknown>>;
|
|
32
88
|
}
|
|
@@ -40,12 +96,22 @@ export interface SessionRefreshStoreInput {
|
|
|
40
96
|
readonly expiresAt: UnixMillis;
|
|
41
97
|
readonly lastSeenAt?: UnixMillis;
|
|
42
98
|
}
|
|
99
|
+
export interface SessionListByUserStoreInput {
|
|
100
|
+
readonly userId: UserId;
|
|
101
|
+
}
|
|
43
102
|
export interface SessionRotateStoreInput {
|
|
44
103
|
readonly sessionId: SessionId;
|
|
45
104
|
readonly secretHash: string;
|
|
46
105
|
readonly rotatedAt: UnixMillis;
|
|
47
106
|
readonly expiresAt?: UnixMillis;
|
|
48
107
|
}
|
|
108
|
+
export interface SessionUpdateClaimsStoreInput {
|
|
109
|
+
readonly sessionId: SessionId;
|
|
110
|
+
readonly claims?: SessionClaims;
|
|
111
|
+
readonly aal?: AuthAssuranceLevel;
|
|
112
|
+
readonly amr?: readonly AuthMethodReference[];
|
|
113
|
+
readonly mfaVerifiedAt?: UnixMillis;
|
|
114
|
+
}
|
|
49
115
|
export interface SessionRevokeStoreInput {
|
|
50
116
|
readonly sessionId: SessionId;
|
|
51
117
|
readonly revokedAt: UnixMillis;
|
|
@@ -58,9 +124,11 @@ export interface SessionRevokeAllForUserStoreInput {
|
|
|
58
124
|
}
|
|
59
125
|
export interface SessionStoreService {
|
|
60
126
|
readonly findById: (id: SessionId) => Effect.Effect<Option.Option<SessionRow>, StorageError>;
|
|
127
|
+
readonly listByUser: (input: SessionListByUserStoreInput) => Effect.Effect<readonly SessionRow[], StorageError>;
|
|
61
128
|
readonly insert: (row: NewSessionRow) => Effect.Effect<void, StorageError>;
|
|
62
129
|
readonly refresh: (input: SessionRefreshStoreInput) => Effect.Effect<Option.Option<SessionRow>, StorageError>;
|
|
63
130
|
readonly rotate: (input: SessionRotateStoreInput) => Effect.Effect<Option.Option<SessionRow>, StorageError>;
|
|
131
|
+
readonly updateClaims: (input: SessionUpdateClaimsStoreInput) => Effect.Effect<Option.Option<SessionRow>, StorageError>;
|
|
64
132
|
readonly revoke: (input: SessionRevokeStoreInput) => Effect.Effect<void, StorageError>;
|
|
65
133
|
readonly revokeAllForUser: (input: SessionRevokeAllForUserStoreInput) => Effect.Effect<void, StorageError>;
|
|
66
134
|
}
|
package/dist/Storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Storage.d.ts","sourceRoot":"","sources":["../src/Storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Storage.d.ts","sourceRoot":"","sources":["../src/Storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,OAAO,EAAQ,MAAM,QAAQ,CAAC;AACvC,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAE7C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,KAAK,EACL,SAAS,EACT,UAAU,EACV,MAAM,EACP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACd,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,aAAa,GAC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M,CAAC,eAAe,CAAC,EAAE,YAAY,CAAC,CAAC;IACjE,QAAQ,CAAC,aAAa,EAAE,CACtB,KAAK,EAAE,8BAA8B,KAClC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC1C;;AAED,qBAAa,iBAAkB,SAAQ,sBAGV;CAAG;AAEhC,yBAAiB,iBAAiB,CAAC;IAC1B,MAAM,IAAI,GACf,SAAS,wBAAwB,KAChC,wBAAyD,CAAC;CAC9D"}
|
package/dist/Storage.js
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import { Context, Data
|
|
1
|
+
import { Context, Data } from "effect";
|
|
2
2
|
export class StorageError extends Data.TaggedError("StorageError") {
|
|
3
3
|
}
|
|
4
4
|
(function (StorageError) {
|
|
5
5
|
StorageError.fromUnknown = (entity, operation, cause, message = `${entity} ${operation} failed`) => new StorageError({ entity, operation, message, cause });
|
|
6
6
|
})(StorageError || (StorageError = {}));
|
|
7
|
+
export class UserStore extends Context.Service()("auth/UserStore") {
|
|
8
|
+
}
|
|
9
|
+
(function (UserStore) {
|
|
10
|
+
UserStore.make = (service) => UserStore.of(service);
|
|
11
|
+
})(UserStore || (UserStore = {}));
|
|
12
|
+
export class CredentialStore extends Context.Service()("auth/CredentialStore") {
|
|
13
|
+
}
|
|
14
|
+
(function (CredentialStore) {
|
|
15
|
+
CredentialStore.make = (service) => CredentialStore.of(service);
|
|
16
|
+
})(CredentialStore || (CredentialStore = {}));
|
|
7
17
|
export class SessionStore extends Context.Service()("auth/SessionStore") {
|
|
8
18
|
}
|
|
9
19
|
(function (SessionStore) {
|
package/dist/Storage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Storage.js","sourceRoot":"","sources":["../src/Storage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Storage.js","sourceRoot":"","sources":["../src/Storage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,IAAI,E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G,CAClB,OAAiC,EACP,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;AAC/D,CAAC,EAJgB,iBAAiB,KAAjB,iBAAiB,QAIjC"}
|
|
@@ -3,5 +3,17 @@ export interface AuthStorageMigration {
|
|
|
3
3
|
readonly sql: string;
|
|
4
4
|
}
|
|
5
5
|
export declare const authStorageMigration001: AuthStorageMigration;
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const authStorageMigration002: AuthStorageMigration;
|
|
7
|
+
export declare const authStorageMigration003: AuthStorageMigration;
|
|
8
|
+
export declare const authStorageMigration004: AuthStorageMigration;
|
|
9
|
+
export declare const authStorageMigration005: AuthStorageMigration;
|
|
10
|
+
export declare const authStorageMigration006: AuthStorageMigration;
|
|
11
|
+
export declare const authStorageMigration007: AuthStorageMigration;
|
|
12
|
+
export declare const authStorageMigration008: AuthStorageMigration;
|
|
13
|
+
export declare const authStorageMigration009: AuthStorageMigration;
|
|
14
|
+
export declare const authStorageMigration010: AuthStorageMigration;
|
|
15
|
+
export declare const authStorageMigration011: AuthStorageMigration;
|
|
16
|
+
export declare const authStorageMigration012: AuthStorageMigration;
|
|
17
|
+
export declare const authStorageMigration013: AuthStorageMigration;
|
|
18
|
+
export declare const authStorageMigrations: readonly [AuthStorageMigration, AuthStorageMigration, AuthStorageMigration, AuthStorageMigration, AuthStorageMigration, AuthStorageMigration, AuthStorageMigration, AuthStorageMigration, AuthStorageMigration, AuthStorageMigration, AuthStorageMigration, AuthStorageMigration, AuthStorageMigration];
|
|
7
19
|
//# sourceMappingURL=StorageMigrations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageMigrations.d.ts","sourceRoot":"","sources":["../src/StorageMigrations.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"StorageMigrations.d.ts","sourceRoot":"","sources":["../src/StorageMigrations.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,uBAAuB,EAAE,oBAkCrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBA2BrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBAwBrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBAcrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBAmBrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBAmBrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBAerC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBAmBrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBAuBrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBAUrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBAkBrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBAsBrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,oBAkBrC,CAAC;AAEF,eAAO,MAAM,qBAAqB,ySAcxB,CAAC"}
|
|
@@ -31,7 +31,261 @@ create table if not exists auth_verification (
|
|
|
31
31
|
);
|
|
32
32
|
|
|
33
33
|
create index if not exists auth_verification_type_subject_idx on auth_verification (type, subject);
|
|
34
|
-
create index if not exists auth_verification_expires_at_idx on auth_verification (expires_at)
|
|
34
|
+
create index if not exists auth_verification_expires_at_idx on auth_verification (expires_at);`,
|
|
35
35
|
};
|
|
36
|
-
export const
|
|
36
|
+
export const authStorageMigration002 = {
|
|
37
|
+
id: "0002_auth_password",
|
|
38
|
+
sql: `create table if not exists auth_user (
|
|
39
|
+
id text primary key,
|
|
40
|
+
email text not null,
|
|
41
|
+
email_verified integer not null,
|
|
42
|
+
created_at integer not null,
|
|
43
|
+
updated_at integer not null,
|
|
44
|
+
disabled_at integer,
|
|
45
|
+
metadata text
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
create unique index if not exists auth_user_email_idx on auth_user (email);
|
|
49
|
+
|
|
50
|
+
create table if not exists auth_credential (
|
|
51
|
+
id text primary key,
|
|
52
|
+
user_id text not null,
|
|
53
|
+
type text not null,
|
|
54
|
+
password_hash text,
|
|
55
|
+
created_at integer not null,
|
|
56
|
+
updated_at integer not null,
|
|
57
|
+
revoked_at integer,
|
|
58
|
+
metadata text
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
create index if not exists auth_credential_user_id_idx on auth_credential (user_id);
|
|
62
|
+
create unique index if not exists auth_credential_user_type_idx on auth_credential (user_id, type);`,
|
|
63
|
+
};
|
|
64
|
+
export const authStorageMigration003 = {
|
|
65
|
+
id: "0003_auth_login_approval_review",
|
|
66
|
+
sql: `create table if not exists auth_login_approval_review (
|
|
67
|
+
approval_challenge_id text primary key,
|
|
68
|
+
flow_id text not null,
|
|
69
|
+
user_id text not null,
|
|
70
|
+
channel text not null,
|
|
71
|
+
reason text not null,
|
|
72
|
+
session_binding text not null,
|
|
73
|
+
same_device_required integer not null,
|
|
74
|
+
status text not null,
|
|
75
|
+
created_at integer not null,
|
|
76
|
+
expires_at integer not null,
|
|
77
|
+
reviewed_at integer,
|
|
78
|
+
reviewed_by text,
|
|
79
|
+
denied_reason text,
|
|
80
|
+
risk text,
|
|
81
|
+
metadata text,
|
|
82
|
+
review_metadata text
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
create index if not exists auth_login_approval_review_flow_id_idx on auth_login_approval_review (flow_id);
|
|
86
|
+
create index if not exists auth_login_approval_review_user_id_idx on auth_login_approval_review (user_id);
|
|
87
|
+
create index if not exists auth_login_approval_review_status_expires_at_idx on auth_login_approval_review (status, expires_at);`,
|
|
88
|
+
};
|
|
89
|
+
export const authStorageMigration004 = {
|
|
90
|
+
id: "0004_auth_trusted_device",
|
|
91
|
+
sql: `create table if not exists auth_trusted_device (
|
|
92
|
+
user_id text not null,
|
|
93
|
+
token_hash text not null,
|
|
94
|
+
created_at integer not null,
|
|
95
|
+
last_seen_at integer not null,
|
|
96
|
+
expires_at integer not null,
|
|
97
|
+
metadata text,
|
|
98
|
+
primary key (user_id, token_hash)
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
create index if not exists auth_trusted_device_user_id_idx on auth_trusted_device (user_id);
|
|
102
|
+
create index if not exists auth_trusted_device_expires_at_idx on auth_trusted_device (expires_at);`,
|
|
103
|
+
};
|
|
104
|
+
export const authStorageMigration005 = {
|
|
105
|
+
id: "0005_auth_passkey",
|
|
106
|
+
sql: `create table if not exists auth_passkey_credential (
|
|
107
|
+
id text primary key,
|
|
108
|
+
user_id text not null,
|
|
109
|
+
credential_id text not null,
|
|
110
|
+
public_key text not null,
|
|
111
|
+
sign_count integer not null,
|
|
112
|
+
transports text,
|
|
113
|
+
backed_up integer,
|
|
114
|
+
created_at integer not null,
|
|
115
|
+
last_used_at integer,
|
|
116
|
+
revoked_at integer,
|
|
117
|
+
metadata text
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
create unique index if not exists auth_passkey_credential_credential_id_idx on auth_passkey_credential (credential_id);
|
|
121
|
+
create index if not exists auth_passkey_credential_user_id_idx on auth_passkey_credential (user_id);
|
|
122
|
+
create index if not exists auth_passkey_credential_revoked_at_idx on auth_passkey_credential (revoked_at);`,
|
|
123
|
+
};
|
|
124
|
+
export const authStorageMigration006 = {
|
|
125
|
+
id: "0006_auth_totp_factor",
|
|
126
|
+
sql: `create table if not exists auth_totp_factor (
|
|
127
|
+
id text primary key,
|
|
128
|
+
user_id text not null,
|
|
129
|
+
secret text not null,
|
|
130
|
+
algorithm text not null,
|
|
131
|
+
digits integer not null,
|
|
132
|
+
period integer not null,
|
|
133
|
+
created_at integer not null,
|
|
134
|
+
confirmed_at integer,
|
|
135
|
+
last_used_at integer,
|
|
136
|
+
revoked_at integer,
|
|
137
|
+
metadata text
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
create index if not exists auth_totp_factor_user_id_idx on auth_totp_factor (user_id);
|
|
141
|
+
create index if not exists auth_totp_factor_confirmed_at_idx on auth_totp_factor (confirmed_at);
|
|
142
|
+
create index if not exists auth_totp_factor_revoked_at_idx on auth_totp_factor (revoked_at);`,
|
|
143
|
+
};
|
|
144
|
+
export const authStorageMigration007 = {
|
|
145
|
+
id: "0007_auth_recovery_code",
|
|
146
|
+
sql: `create table if not exists auth_recovery_code (
|
|
147
|
+
id text primary key,
|
|
148
|
+
user_id text not null,
|
|
149
|
+
code_hash text not null,
|
|
150
|
+
created_at integer not null,
|
|
151
|
+
used_at integer,
|
|
152
|
+
revoked_at integer,
|
|
153
|
+
metadata text
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
create index if not exists auth_recovery_code_user_id_idx on auth_recovery_code (user_id);
|
|
157
|
+
create index if not exists auth_recovery_code_used_at_idx on auth_recovery_code (used_at);
|
|
158
|
+
create index if not exists auth_recovery_code_revoked_at_idx on auth_recovery_code (revoked_at);`,
|
|
159
|
+
};
|
|
160
|
+
export const authStorageMigration008 = {
|
|
161
|
+
id: "0008_auth_api_key",
|
|
162
|
+
sql: `create table if not exists auth_api_key (
|
|
163
|
+
id text primary key,
|
|
164
|
+
user_id text not null,
|
|
165
|
+
prefix text not null,
|
|
166
|
+
secret_hash text not null,
|
|
167
|
+
scopes text not null,
|
|
168
|
+
created_at integer not null,
|
|
169
|
+
expires_at integer,
|
|
170
|
+
last_used_at integer,
|
|
171
|
+
revoked_at integer,
|
|
172
|
+
metadata text
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
create unique index if not exists auth_api_key_prefix_idx on auth_api_key (prefix);
|
|
176
|
+
create index if not exists auth_api_key_user_id_idx on auth_api_key (user_id);
|
|
177
|
+
create index if not exists auth_api_key_expires_at_idx on auth_api_key (expires_at);
|
|
178
|
+
create index if not exists auth_api_key_revoked_at_idx on auth_api_key (revoked_at);`,
|
|
179
|
+
};
|
|
180
|
+
export const authStorageMigration009 = {
|
|
181
|
+
id: "0009_auth_refresh_token",
|
|
182
|
+
sql: `create table if not exists auth_refresh_token (
|
|
183
|
+
id text primary key,
|
|
184
|
+
family_id text not null,
|
|
185
|
+
user_id text not null,
|
|
186
|
+
secret_hash text not null,
|
|
187
|
+
created_at integer not null,
|
|
188
|
+
expires_at integer not null,
|
|
189
|
+
last_used_at integer,
|
|
190
|
+
rotated_at integer,
|
|
191
|
+
replaced_by_id text,
|
|
192
|
+
revoked_at integer,
|
|
193
|
+
reuse_detected_at integer,
|
|
194
|
+
metadata text
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
create unique index if not exists auth_refresh_token_secret_hash_idx on auth_refresh_token (secret_hash);
|
|
198
|
+
create index if not exists auth_refresh_token_family_id_idx on auth_refresh_token (family_id);
|
|
199
|
+
create index if not exists auth_refresh_token_user_id_idx on auth_refresh_token (user_id);
|
|
200
|
+
create index if not exists auth_refresh_token_expires_at_idx on auth_refresh_token (expires_at);
|
|
201
|
+
create index if not exists auth_refresh_token_rotated_at_idx on auth_refresh_token (rotated_at);
|
|
202
|
+
create index if not exists auth_refresh_token_revoked_at_idx on auth_refresh_token (revoked_at);`,
|
|
203
|
+
};
|
|
204
|
+
export const authStorageMigration010 = {
|
|
205
|
+
id: "0010_auth_jwt_revocation",
|
|
206
|
+
sql: `create table if not exists auth_jwt_revocation (
|
|
207
|
+
jwt_id text primary key,
|
|
208
|
+
revoked_at integer not null,
|
|
209
|
+
expires_at integer,
|
|
210
|
+
reason text
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
create index if not exists auth_jwt_revocation_expires_at_idx on auth_jwt_revocation (expires_at);`,
|
|
214
|
+
};
|
|
215
|
+
export const authStorageMigration011 = {
|
|
216
|
+
id: "0011_auth_oauth_account",
|
|
217
|
+
sql: `create table if not exists auth_oauth_account (
|
|
218
|
+
id text primary key,
|
|
219
|
+
provider_id text not null,
|
|
220
|
+
provider_account_id text not null,
|
|
221
|
+
user_id text not null,
|
|
222
|
+
email text,
|
|
223
|
+
email_verified integer,
|
|
224
|
+
created_at integer not null,
|
|
225
|
+
updated_at integer not null,
|
|
226
|
+
unlinked_at integer,
|
|
227
|
+
metadata text
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
create unique index if not exists auth_oauth_account_provider_account_idx on auth_oauth_account (provider_id, provider_account_id);
|
|
231
|
+
create index if not exists auth_oauth_account_user_id_idx on auth_oauth_account (user_id);
|
|
232
|
+
create index if not exists auth_oauth_account_unlinked_at_idx on auth_oauth_account (unlinked_at);`,
|
|
233
|
+
};
|
|
234
|
+
export const authStorageMigration012 = {
|
|
235
|
+
id: "0012_auth_oauth_provider_token_vault",
|
|
236
|
+
sql: `create table if not exists auth_oauth_provider_token_vault (
|
|
237
|
+
account_id text primary key,
|
|
238
|
+
user_id text not null,
|
|
239
|
+
provider_id text not null,
|
|
240
|
+
provider_account_id text not null,
|
|
241
|
+
access_token_ciphertext text not null,
|
|
242
|
+
refresh_token_ciphertext text,
|
|
243
|
+
id_token_ciphertext text,
|
|
244
|
+
token_type text not null,
|
|
245
|
+
scopes text,
|
|
246
|
+
expires_at integer,
|
|
247
|
+
updated_at integer not null,
|
|
248
|
+
revoked_at integer,
|
|
249
|
+
revocation_reason text
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
create index if not exists auth_oauth_provider_token_vault_user_id_idx on auth_oauth_provider_token_vault (user_id);
|
|
253
|
+
create index if not exists auth_oauth_provider_token_vault_provider_account_idx on auth_oauth_provider_token_vault (provider_id, provider_account_id);
|
|
254
|
+
create index if not exists auth_oauth_provider_token_vault_expires_at_idx on auth_oauth_provider_token_vault (expires_at);
|
|
255
|
+
create index if not exists auth_oauth_provider_token_vault_revoked_at_idx on auth_oauth_provider_token_vault (revoked_at);`,
|
|
256
|
+
};
|
|
257
|
+
export const authStorageMigration013 = {
|
|
258
|
+
id: "0013_auth_security_timeline",
|
|
259
|
+
sql: `create table if not exists auth_security_timeline (
|
|
260
|
+
id text primary key,
|
|
261
|
+
user_id text not null,
|
|
262
|
+
type text not null,
|
|
263
|
+
category text not null,
|
|
264
|
+
severity text not null,
|
|
265
|
+
occurred_at integer not null,
|
|
266
|
+
summary text not null,
|
|
267
|
+
actor text,
|
|
268
|
+
request text,
|
|
269
|
+
metadata text
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
create index if not exists auth_security_timeline_user_occurred_at_idx on auth_security_timeline (user_id, occurred_at);
|
|
273
|
+
create index if not exists auth_security_timeline_type_idx on auth_security_timeline (type);
|
|
274
|
+
create index if not exists auth_security_timeline_category_idx on auth_security_timeline (category);`,
|
|
275
|
+
};
|
|
276
|
+
export const authStorageMigrations = [
|
|
277
|
+
authStorageMigration001,
|
|
278
|
+
authStorageMigration002,
|
|
279
|
+
authStorageMigration003,
|
|
280
|
+
authStorageMigration004,
|
|
281
|
+
authStorageMigration005,
|
|
282
|
+
authStorageMigration006,
|
|
283
|
+
authStorageMigration007,
|
|
284
|
+
authStorageMigration008,
|
|
285
|
+
authStorageMigration009,
|
|
286
|
+
authStorageMigration010,
|
|
287
|
+
authStorageMigration011,
|
|
288
|
+
authStorageMigration012,
|
|
289
|
+
authStorageMigration013,
|
|
290
|
+
];
|
|
37
291
|
//# sourceMappingURL=StorageMigrations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StorageMigrations.js","sourceRoot":"","sources":["../src/StorageMigrations.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,uBAAuB,GAAyB;IAC3D,EAAE,EAAE,mBAAmB;IACvB,GAAG,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+FA+BwF;CAC9F,
|
|
1
|
+
{"version":3,"file":"StorageMigrations.js","sourceRoot":"","sources":["../src/StorageMigrations.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,uBAAuB,GAAyB;IAC3D,EAAE,EAAE,mBAAmB;IACvB,GAA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AyB;IAC3D,EAAE,EAAE,yBAAyB;IAC7B,GAAG,EAAE;;;;;;;;;;;;;;;mGAe4F;CAClG,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAyB;IAC3D,EAAE,EAAE,sCAAsC;IAC1C,GAAG,EAAE;;;;;;;;;;;;;;;;;;;2HAmBoH;CAC1H,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAyB;IAC3D,EAAE,EAAE,6BAA6B;IACjC,GAAG,EAAE;;;;;;;;;;;;;;;qGAe8F;CACpG,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;IACvB,uBAAuB;CACf,CAAC"}
|
package/dist/Testing.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
-
|
|
2
|
+
import { Crypto } from "./Crypto.js";
|
|
3
|
+
import type { CryptoService } from "./Crypto.js";
|
|
4
|
+
import { PasswordHasher } from "./Password.js";
|
|
5
|
+
import type { PasswordHasherService } from "./Password.js";
|
|
6
|
+
export declare const makeTestCrypto: () => CryptoService;
|
|
7
|
+
export declare const CryptoTestLive: Layer.Layer<Crypto, never, never>;
|
|
8
|
+
export declare const makeTestPasswordHasher: () => PasswordHasherService;
|
|
9
|
+
export declare const PasswordHasherTestLive: Layer.Layer<PasswordHasher, never, never>;
|
|
10
|
+
export declare const CoreTestingLive: Layer.Layer<Crypto | import("./WaitUntil.js").WaitUntil | import("./Privacy.js").Privacy | import("./AuditLog.js").AuditLog | PasswordHasher, never, never>;
|
|
3
11
|
//# sourceMappingURL=Testing.d.ts.map
|
package/dist/Testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Testing.d.ts","sourceRoot":"","sources":["../src/Testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Testing.d.ts","sourceRoot":"","sources":["../src/Testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,EAAY,MAAM,QAAQ,CAAC;AAGjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAa,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAY3D,eAAO,MAAM,cAAc,QAAO,aA+BjC,CAAC;AAEF,eAAO,MAAM,cAAc,mCAA0C,CAAC;AAEtE,eAAO,MAAM,sBAAsB,QAAO,qBAQtC,CAAC;AAEL,eAAO,MAAM,sBAAsB,2CAElC,CAAC;AAEF,eAAO,MAAM,eAAe,6JAM3B,CAAC"}
|
package/dist/Testing.js
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
|
-
import { Layer } from "effect";
|
|
1
|
+
import { Effect, Layer, Redacted } from "effect";
|
|
2
2
|
import { AuditLogNoopLive } from "./AuditLog.js";
|
|
3
|
+
import { Crypto } from "./Crypto.js";
|
|
4
|
+
import { PasswordHasher } from "./Password.js";
|
|
3
5
|
import { PrivacyTestLive } from "./Privacy.js";
|
|
4
6
|
import { WaitUntilNoopLive } from "./WaitUntil.js";
|
|
5
|
-
|
|
7
|
+
const bytesToString = (bytes) => [...bytes].join(",");
|
|
8
|
+
const valueToString = (value) => typeof value === "string" ? value : bytesToString(value);
|
|
9
|
+
const keyToString = (key) => key instanceof Uint8Array ? bytesToString(key) : Redacted.value(key);
|
|
10
|
+
export const makeTestCrypto = () => {
|
|
11
|
+
let counter = 0;
|
|
12
|
+
return Crypto.make({
|
|
13
|
+
randomBytes: (byteLength) => Effect.sync(() => {
|
|
14
|
+
counter += 1;
|
|
15
|
+
return Uint8Array.from({ length: byteLength }, (_, index) => (counter + index) % 256);
|
|
16
|
+
}),
|
|
17
|
+
randomToken: (byteLength = 32) => Effect.sync(() => {
|
|
18
|
+
counter += 1;
|
|
19
|
+
return `test-token-${byteLength}-${counter}`;
|
|
20
|
+
}),
|
|
21
|
+
digestSha256: (input) => Effect.succeed(`test-digest:${valueToString(input.data)}`),
|
|
22
|
+
hmacSha256: (input) => Effect.succeed(`test-hmac:${keyToString(input.key)}:${valueToString(input.data)}`),
|
|
23
|
+
timingSafeEqual: (input) => Effect.succeed(input.left.length === input.right.length &&
|
|
24
|
+
input.left.every((value, index) => value === input.right[index])),
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export const CryptoTestLive = Layer.succeed(Crypto)(makeTestCrypto());
|
|
28
|
+
export const makeTestPasswordHasher = () => PasswordHasher.make({
|
|
29
|
+
hash: (input) => Effect.succeed(`test-hash:${Redacted.value(input.password)}`),
|
|
30
|
+
verify: (input) => Effect.succeed(input.hash === `test-hash:${Redacted.value(input.password)}`),
|
|
31
|
+
});
|
|
32
|
+
export const PasswordHasherTestLive = Layer.succeed(PasswordHasher)(makeTestPasswordHasher());
|
|
33
|
+
export const CoreTestingLive = Layer.mergeAll(AuditLogNoopLive, CryptoTestLive, PasswordHasherTestLive, PrivacyTestLive, WaitUntilNoopLive);
|
|
6
34
|
//# sourceMappingURL=Testing.js.map
|
package/dist/Testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Testing.js","sourceRoot":"","sources":["../src/Testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"Testing.js","sourceRoot":"","sources":["../src/Testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEjD,OAAO,EAAE,gBAAgB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