@yielded/auth-persistence-drizzle 0.1.0-beta.0 → 0.1.0-beta.12
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 +6 -1
- package/dist/D1.d.mts +155 -40
- package/dist/D1.mjs +10 -6
- package/dist/D1.mjs.map +1 -1
- package/dist/Libsql.d.mts +251 -129
- package/dist/Libsql.mjs +20 -21
- package/dist/Libsql.mjs.map +1 -1
- package/dist/Mysql2.d.mts +208 -56
- package/dist/Mysql2.mjs +13 -8
- package/dist/Mysql2.mjs.map +1 -1
- package/dist/Pglite.d.mts +209 -57
- package/dist/Pglite.mjs +13 -9
- package/dist/Pglite.mjs.map +1 -1
- package/dist/Postgres.d.mts +207 -55
- package/dist/Postgres.mjs +13 -9
- package/dist/Postgres.mjs.map +1 -1
- package/dist/SqliteBun.d.mts +249 -126
- package/dist/SqliteBun.mjs +20 -18
- package/dist/SqliteBun.mjs.map +1 -1
- package/dist/SqliteDo.d.mts +248 -158
- package/dist/SqliteDo.mjs +26 -44
- package/dist/SqliteDo.mjs.map +1 -1
- package/dist/SqliteNode.d.mts +247 -124
- package/dist/SqliteNode.mjs +20 -18
- package/dist/SqliteNode.mjs.map +1 -1
- package/dist/SqliteWasm.d.mts +251 -128
- package/dist/SqliteWasm.mjs +20 -18
- package/dist/SqliteWasm.mjs.map +1 -1
- package/dist/drizzle/D1BatchStatements.d.mts +1 -1
- package/dist/drizzle/D1BatchStatements.mjs.map +1 -1
- package/dist/drizzle/d1-database.d.mts +11 -0
- package/dist/drizzle/d1-database.mjs +8 -0
- package/dist/drizzle/d1-database.mjs.map +1 -0
- package/dist/drizzle/d1-emails.d.mts +8 -7
- package/dist/drizzle/d1-emails.mjs +7 -4
- package/dist/drizzle/d1-emails.mjs.map +1 -1
- package/dist/drizzle/d1-generated-statement.mjs.map +1 -1
- package/dist/drizzle/d1-identity.mjs +12 -9
- package/dist/drizzle/d1-identity.mjs.map +1 -1
- package/dist/drizzle/d1-oauth.d.mts +41 -10
- package/dist/drizzle/d1-oauth.mjs +8 -5
- package/dist/drizzle/d1-oauth.mjs.map +1 -1
- package/dist/drizzle/d1-passkey.d.mts +3 -14
- package/dist/drizzle/d1-passkey.mjs +2 -1
- package/dist/drizzle/d1-passkey.mjs.map +1 -1
- package/dist/drizzle/d1-password-prepared.d.mts +4 -3
- package/dist/drizzle/d1-password-prepared.mjs +3 -1
- package/dist/drizzle/d1-password-prepared.mjs.map +1 -1
- package/dist/drizzle/d1-passwords.d.mts +7 -6
- package/dist/drizzle/d1-passwords.mjs +5 -2
- package/dist/drizzle/d1-passwords.mjs.map +1 -1
- package/dist/drizzle/d1-phone.d.mts +3 -4
- package/dist/drizzle/d1-phone.mjs +2 -1
- package/dist/drizzle/d1-phone.mjs.map +1 -1
- package/dist/drizzle/d1-planning.d.mts +1 -1
- package/dist/drizzle/d1-proofs.d.mts +5 -4
- package/dist/drizzle/d1-proofs.mjs +3 -1
- package/dist/drizzle/d1-proofs.mjs.map +1 -1
- package/dist/drizzle/d1-sessions.d.mts +14 -13
- package/dist/drizzle/d1-sessions.mjs +15 -9
- package/dist/drizzle/d1-sessions.mjs.map +1 -1
- package/dist/drizzle/d1-totp.d.mts +3 -4
- package/dist/drizzle/d1-totp.mjs +2 -1
- package/dist/drizzle/d1-totp.mjs.map +1 -1
- package/dist/drizzle/email-registration.d.mts +1 -1
- package/dist/drizzle/email-registration.mjs +2 -1
- package/dist/drizzle/email-registration.mjs.map +1 -1
- package/dist/drizzle/email-target.d.mts +8 -7
- package/dist/drizzle/email-target.mjs +10 -10
- package/dist/drizzle/email-target.mjs.map +1 -1
- package/dist/drizzle/model.d.mts +2 -126
- package/dist/drizzle/model.mjs +2 -21
- package/dist/drizzle/model.mjs.map +1 -1
- package/dist/drizzle/mysql-database.d.mts +8 -0
- package/dist/drizzle/mysql-database.mjs +8 -0
- package/dist/drizzle/mysql-database.mjs.map +1 -0
- package/dist/drizzle/mysql-emails.d.mts +8 -7
- package/dist/drizzle/mysql-emails.mjs +12 -8
- package/dist/drizzle/mysql-emails.mjs.map +1 -1
- package/dist/drizzle/mysql-identity.mjs +12 -9
- package/dist/drizzle/mysql-identity.mjs.map +1 -1
- package/dist/drizzle/mysql-password-prepared.d.mts +4 -3
- package/dist/drizzle/mysql-password-prepared.mjs +6 -2
- package/dist/drizzle/mysql-password-prepared.mjs.map +1 -1
- package/dist/drizzle/mysql-passwords.d.mts +7 -5
- package/dist/drizzle/mysql-passwords.mjs +11 -7
- package/dist/drizzle/mysql-passwords.mjs.map +1 -1
- package/dist/drizzle/mysql-proofs.d.mts +4 -3
- package/dist/drizzle/mysql-proofs.mjs +8 -4
- package/dist/drizzle/mysql-proofs.mjs.map +1 -1
- package/dist/drizzle/mysql-sessions.d.mts +12 -11
- package/dist/drizzle/mysql-sessions.mjs +16 -12
- package/dist/drizzle/mysql-sessions.mjs.map +1 -1
- package/dist/drizzle/native-database.mjs +10 -0
- package/dist/drizzle/native-database.mjs.map +1 -0
- package/dist/drizzle/oauth-accounts.mjs +1 -1
- package/dist/drizzle/oauth-connected-access.mjs +14 -12
- package/dist/drizzle/oauth-connected-access.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-custody.mjs +2 -2
- package/dist/drizzle/oauth-connected-drivers.mjs +11 -6
- package/dist/drizzle/oauth-connected-drivers.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-flow.mjs +2 -2
- package/dist/drizzle/oauth-connected-input.mjs +14 -1
- package/dist/drizzle/oauth-connected-input.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-maintenance.mjs +1 -1
- package/dist/drizzle/oauth-connected-management.mjs +2 -2
- package/dist/drizzle/oauth-connected-model.d.mts +17 -3
- package/dist/drizzle/oauth-connected-model.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-settlement.mjs +51 -41
- package/dist/drizzle/oauth-connected-settlement.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-sign-in.mjs +263 -0
- package/dist/drizzle/oauth-connected-sign-in.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-state.d.mts +110 -2
- package/dist/drizzle/oauth-connected-state.mjs +9 -4
- package/dist/drizzle/oauth-connected-state.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-target.d.mts +142 -15
- package/dist/drizzle/oauth-connected-target.mjs +9 -6
- package/dist/drizzle/oauth-connected-target.mjs.map +1 -1
- package/dist/drizzle/oauth-drivers.mjs +9 -7
- package/dist/drizzle/oauth-drivers.mjs.map +1 -1
- package/dist/drizzle/oauth-flow.d.mts +1 -1
- package/dist/drizzle/oauth-flow.mjs +1 -1
- package/dist/drizzle/oauth-input.mjs +1 -1
- package/dist/drizzle/oauth-model.d.mts +1 -1
- package/dist/drizzle/oauth-owner.d.mts +1 -1
- package/dist/drizzle/oauth-registration.d.mts +2 -2
- package/dist/drizzle/oauth-registration.mjs +1 -1
- package/dist/drizzle/oauth-state.mjs +5 -4
- package/dist/drizzle/oauth-state.mjs.map +1 -1
- package/dist/drizzle/oauth-target.d.mts +14 -13
- package/dist/drizzle/oauth-target.mjs +14 -13
- package/dist/drizzle/oauth-target.mjs.map +1 -1
- package/dist/drizzle/passkey-drivers.mjs +8 -6
- package/dist/drizzle/passkey-drivers.mjs.map +1 -1
- package/dist/drizzle/passkey-write-drivers.mjs +5 -3
- package/dist/drizzle/passkey-write-drivers.mjs.map +1 -1
- package/dist/drizzle/passkey-write-target.d.mts +1 -1
- package/dist/drizzle/password-prepared-sql.mjs +2 -1
- package/dist/drizzle/password-prepared-sql.mjs.map +1 -1
- package/dist/drizzle/password-prepared-state.mjs +1 -1
- package/dist/drizzle/password-prepared-target.d.mts +4 -3
- package/dist/drizzle/password-prepared-target.mjs +4 -3
- package/dist/drizzle/password-prepared-target.mjs.map +1 -1
- package/dist/drizzle/password-registration.mjs +2 -1
- package/dist/drizzle/password-registration.mjs.map +1 -1
- package/dist/drizzle/password-target.d.mts +6 -5
- package/dist/drizzle/password-target.mjs +8 -8
- package/dist/drizzle/password-target.mjs.map +1 -1
- package/dist/drizzle/pg-database.d.mts +9 -0
- package/dist/drizzle/pg-database.mjs +8 -0
- package/dist/drizzle/pg-database.mjs.map +1 -0
- package/dist/drizzle/pg-emails.d.mts +8 -7
- package/dist/drizzle/pg-emails.mjs +12 -8
- package/dist/drizzle/pg-emails.mjs.map +1 -1
- package/dist/drizzle/pg-identity.mjs +92 -0
- package/dist/drizzle/pg-identity.mjs.map +1 -0
- package/dist/drizzle/pg-password-prepared.d.mts +4 -3
- package/dist/drizzle/pg-password-prepared.mjs +6 -2
- package/dist/drizzle/pg-password-prepared.mjs.map +1 -1
- package/dist/drizzle/pg-passwords.d.mts +7 -5
- package/dist/drizzle/pg-passwords.mjs +11 -7
- package/dist/drizzle/pg-passwords.mjs.map +1 -1
- package/dist/drizzle/pg-proofs.d.mts +4 -3
- package/dist/drizzle/pg-proofs.mjs +8 -4
- package/dist/drizzle/pg-proofs.mjs.map +1 -1
- package/dist/drizzle/pg-sessions.d.mts +12 -11
- package/dist/drizzle/pg-sessions.mjs +16 -12
- package/dist/drizzle/pg-sessions.mjs.map +1 -1
- package/dist/drizzle/phone-model.d.mts +1 -1
- package/dist/drizzle/phone-target.d.mts +5 -4
- package/dist/drizzle/phone-target.mjs +12 -11
- package/dist/drizzle/phone-target.mjs.map +1 -1
- package/dist/drizzle/proof-target.d.mts +4 -3
- package/dist/drizzle/proof-target.mjs +5 -5
- package/dist/drizzle/proof-target.mjs.map +1 -1
- package/dist/drizzle/session-sql.d.mts +1 -0
- package/dist/drizzle/session-target.d.mts +11 -9
- package/dist/drizzle/session-target.mjs +11 -11
- package/dist/drizzle/session-target.mjs.map +1 -1
- package/dist/drizzle/sqlite-emails.mjs +9 -5
- package/dist/drizzle/sqlite-emails.mjs.map +1 -1
- package/dist/drizzle/sqlite-identity.mjs +14 -11
- package/dist/drizzle/sqlite-identity.mjs.map +1 -1
- package/dist/drizzle/sqlite-password-prepared.mjs +7 -3
- package/dist/drizzle/sqlite-password-prepared.mjs.map +1 -1
- package/dist/drizzle/sqlite-passwords.mjs +10 -6
- package/dist/drizzle/sqlite-passwords.mjs.map +1 -1
- package/dist/drizzle/sqlite-proofs.mjs +7 -3
- package/dist/drizzle/sqlite-proofs.mjs.map +1 -1
- package/dist/drizzle/sqlite-sessions.mjs +16 -12
- package/dist/drizzle/sqlite-sessions.mjs.map +1 -1
- package/dist/drizzle/standalone-guard.d.mts +2 -0
- package/dist/drizzle/standalone-guard.mjs +8 -4
- package/dist/drizzle/standalone-guard.mjs.map +1 -1
- package/dist/drizzle/totp-model.d.mts +1 -1
- package/dist/drizzle/totp-target.d.mts +5 -4
- package/dist/drizzle/totp-target.mjs +31 -28
- package/dist/drizzle/totp-target.mjs.map +1 -1
- package/dist/drizzle/transaction-mysql.mjs +1 -1
- package/dist/drizzle/transaction-mysql.mjs.map +1 -1
- package/dist/index.d.mts +2 -4
- package/dist/index.mjs +2 -4
- package/dist/internal/drizzle-postgres.mjs.map +1 -1
- package/dist/internal/drizzle-sqlite.mjs.map +1 -1
- package/package.json +1 -1
- package/src/D1.ts +37 -26
- package/src/Libsql.ts +45 -61
- package/src/Mysql2.ts +39 -35
- package/src/Pglite.ts +48 -30
- package/src/Postgres.ts +48 -30
- package/src/SqliteBun.ts +59 -68
- package/src/SqliteDo.ts +61 -274
- package/src/SqliteNode.ts +56 -66
- package/src/SqliteWasm.ts +56 -66
- package/src/drizzle/D1BatchStatements.ts +1 -1
- package/src/drizzle/d1-database.ts +10 -0
- package/src/drizzle/d1-emails.ts +86 -88
- package/src/drizzle/d1-generated-statement.ts +1 -1
- package/src/drizzle/d1-identity.ts +17 -20
- package/src/drizzle/d1-oauth.ts +19 -8
- package/src/drizzle/d1-passkey.ts +5 -1
- package/src/drizzle/d1-password-prepared.ts +40 -42
- package/src/drizzle/d1-passwords.ts +76 -80
- package/src/drizzle/d1-phone.ts +5 -1
- package/src/drizzle/d1-proofs.ts +31 -34
- package/src/drizzle/d1-sessions.ts +53 -40
- package/src/drizzle/d1-totp.ts +5 -1
- package/src/drizzle/email-registration.ts +6 -2
- package/src/drizzle/email-target.ts +18 -20
- package/src/drizzle/model.ts +1 -208
- package/src/drizzle/mysql-database.ts +8 -0
- package/src/drizzle/mysql-emails.ts +29 -17
- package/src/drizzle/mysql-identity.ts +18 -21
- package/src/drizzle/mysql-password-prepared.ts +11 -9
- package/src/drizzle/mysql-passwords.ts +22 -10
- package/src/drizzle/mysql-proofs.ts +17 -6
- package/src/drizzle/mysql-sessions.ts +41 -18
- package/src/drizzle/native-database.ts +22 -0
- package/src/drizzle/oauth-connected-access.ts +8 -1
- package/src/drizzle/oauth-connected-drivers.ts +21 -6
- package/src/drizzle/oauth-connected-input.ts +13 -0
- package/src/drizzle/oauth-connected-model.ts +17 -0
- package/src/drizzle/oauth-connected-settlement.ts +65 -42
- package/src/drizzle/oauth-connected-sign-in.ts +438 -0
- package/src/drizzle/oauth-connected-state.ts +19 -7
- package/src/drizzle/oauth-connected-target.ts +26 -18
- package/src/drizzle/oauth-drivers.ts +26 -10
- package/src/drizzle/oauth-state.ts +5 -4
- package/src/drizzle/oauth-target.ts +31 -43
- package/src/drizzle/passkey-drivers.ts +21 -13
- package/src/drizzle/passkey-write-drivers.ts +11 -6
- package/src/drizzle/password-prepared-sql.ts +2 -4
- package/src/drizzle/password-prepared-target.ts +10 -7
- package/src/drizzle/password-registration.ts +7 -8
- package/src/drizzle/password-target.ts +20 -19
- package/src/drizzle/pg-database.ts +10 -0
- package/src/drizzle/pg-emails.ts +29 -17
- package/src/drizzle/pg-identity.ts +297 -0
- package/src/drizzle/pg-password-prepared.ts +11 -9
- package/src/drizzle/pg-passwords.ts +22 -10
- package/src/drizzle/pg-proofs.ts +17 -6
- package/src/drizzle/pg-sessions.ts +41 -18
- package/src/drizzle/phone-target.ts +23 -18
- package/src/drizzle/proof-target.ts +10 -13
- package/src/drizzle/session-target.ts +33 -51
- package/src/drizzle/sqlite-emails.ts +31 -14
- package/src/drizzle/sqlite-identity.ts +22 -42
- package/src/drizzle/sqlite-password-prepared.ts +24 -10
- package/src/drizzle/sqlite-passwords.ts +30 -16
- package/src/drizzle/sqlite-proofs.ts +29 -6
- package/src/drizzle/sqlite-sessions.ts +50 -24
- package/src/drizzle/standalone-guard.ts +19 -7
- package/src/drizzle/totp-target.ts +62 -61
- package/src/drizzle/transaction-mysql.ts +1 -1
- package/src/index.ts +0 -24
- package/src/internal/drizzle-postgres.ts +1 -1
- package/src/internal/drizzle-sqlite.ts +1 -1
- package/dist/drizzle/d1-identity.d.mts +0 -30
- package/dist/drizzle/mysql-identity.d.mts +0 -21
- package/dist/drizzle/mysql.d.mts +0 -69
- package/dist/drizzle/mysql.mjs +0 -218
- package/dist/drizzle/mysql.mjs.map +0 -1
- package/dist/drizzle/pg.d.mts +0 -80
- package/dist/drizzle/pg.mjs +0 -289
- package/dist/drizzle/pg.mjs.map +0 -1
- package/dist/drizzle/sqlite.d.mts +0 -77
- package/dist/drizzle/sqlite.mjs +0 -217
- package/dist/drizzle/sqlite.mjs.map +0 -1
- package/src/drizzle/mysql.ts +0 -687
- package/src/drizzle/pg.ts +0 -984
- package/src/drizzle/sqlite.ts +0 -705
|
@@ -1,13 +1,104 @@
|
|
|
1
1
|
import { OAuthTargetConfiguration } from "./oauth-target.mjs";
|
|
2
2
|
import { Mapping, Revocations, oauth_connected_state_d_exports } from "./oauth-connected-state.mjs";
|
|
3
|
+
import { Effect, Layer, Schema } from "effect";
|
|
3
4
|
import * as M from "@yielded/auth/OAuth";
|
|
4
5
|
import { OAuthConnectedPersistence, OAuthConnectedRevocationDecision, OAuthConnectedRevocations, OAuthExternalIdentity, PrepareOAuthCommit } from "@yielded/auth/OAuth";
|
|
5
|
-
import {
|
|
6
|
-
import { LifecycleHooks } from "@yielded/auth/Hooks";
|
|
7
|
-
import { Statement } from "effect/unstable/sql/Statement";
|
|
6
|
+
import { Statement } from "effect/sql/Statement";
|
|
8
7
|
//#region src/drizzle/oauth-connected-target.d.ts
|
|
9
|
-
export declare const makeTargetOAuthConnectedServices: (
|
|
8
|
+
export declare const makeTargetOAuthConnectedServices: (mapping: Mapping, configuration: OAuthTargetConfiguration) => Effect.Effect<{
|
|
10
9
|
oauthConnectedPersistence: {
|
|
10
|
+
readonly claimSignIn: <A>(input: {
|
|
11
|
+
readonly claim: M.OAuthClaim;
|
|
12
|
+
readonly configuration: M.OAuthConnectedConfiguration;
|
|
13
|
+
}, prepare: PrepareOAuthCommit<M.OAuthSignInAccessClaim, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, M.OAuthUnavailable, never>;
|
|
14
|
+
readonly inspectSignIn: (input: {
|
|
15
|
+
readonly reservation: M.OAuthSignInAccessClaim;
|
|
16
|
+
readonly credential: M.OAuthCredentialSnapshot;
|
|
17
|
+
readonly grantId: string & import("effect/Brand").Brand<"effect-auth/OAuthGrantId">;
|
|
18
|
+
}) => Effect.Effect<M.OAuthSignInAccessInspection, M.OAuthUnavailable>;
|
|
19
|
+
readonly settleSignIn: <A>(input: {
|
|
20
|
+
readonly reservation: M.OAuthSignInAccessClaim;
|
|
21
|
+
readonly outcome: M.OAuthSignInAccessOutcome;
|
|
22
|
+
}, prepare: PrepareOAuthCommit<{
|
|
23
|
+
readonly _tag: "Rejected";
|
|
24
|
+
} | {
|
|
25
|
+
readonly _tag: "Cancelled";
|
|
26
|
+
} | {
|
|
27
|
+
readonly _tag: "Ambiguous";
|
|
28
|
+
} | {
|
|
29
|
+
readonly _tag: "Connected";
|
|
30
|
+
readonly grant: {
|
|
31
|
+
readonly context: {
|
|
32
|
+
readonly namespace: "effect-auth/oauth-connected-token-context/v1";
|
|
33
|
+
readonly exchangeOrder: string;
|
|
34
|
+
readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
|
|
35
|
+
readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
|
|
36
|
+
readonly identity: {
|
|
37
|
+
readonly provider: string & import("effect/Brand").Brand<"effect-auth/OAuthProviderKey">;
|
|
38
|
+
readonly issuer: string & import("effect/Brand").Brand<"effect-auth/OAuthIssuer">;
|
|
39
|
+
readonly subject: string;
|
|
40
|
+
};
|
|
41
|
+
readonly configuration: {
|
|
42
|
+
readonly provider: string & import("effect/Brand").Brand<"effect-auth/OAuthProviderKey">;
|
|
43
|
+
readonly protocol: "oauth" | "oidc";
|
|
44
|
+
readonly configurationGeneration: number;
|
|
45
|
+
readonly issuer: string & import("effect/Brand").Brand<"effect-auth/OAuthIssuer">;
|
|
46
|
+
readonly responseIssuerMode: "required" | "unsupported";
|
|
47
|
+
readonly callbackId: string & import("effect/Brand").Brand<"effect-auth/OAuthCallbackId">;
|
|
48
|
+
readonly redirectUri: string & import("effect/Brand").Brand<"effect-auth/OAuthRedirectUri">;
|
|
49
|
+
readonly profile: {
|
|
50
|
+
readonly key: string & import("effect/Brand").Brand<"effect-auth/OAuthPermissionProfileKey">;
|
|
51
|
+
readonly generation: number;
|
|
52
|
+
readonly issuance: "active" | "retired";
|
|
53
|
+
readonly provider: string & import("effect/Brand").Brand<"effect-auth/OAuthProviderKey">;
|
|
54
|
+
readonly clientRegistrationId: string;
|
|
55
|
+
readonly scopes: readonly string[];
|
|
56
|
+
readonly resources: readonly string[];
|
|
57
|
+
readonly retention: "access-and-refresh" | "access-only";
|
|
58
|
+
readonly maximumAccessLifetimeMillis: number;
|
|
59
|
+
readonly maximumRefreshLifetimeMillis?: number | undefined;
|
|
60
|
+
readonly refreshAheadMillis: number;
|
|
61
|
+
readonly refresh: "confidential" | "rotating" | "unsupported";
|
|
62
|
+
readonly revocation: "cohort" | "unsupported";
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
readonly grantId: string & import("effect/Brand").Brand<"effect-auth/OAuthGrantId">;
|
|
66
|
+
readonly grantVersion: string & import("effect/Brand").Brand<"effect-auth/SecurityRevision">;
|
|
67
|
+
readonly tokenVersion: string & import("effect/Brand").Brand<"effect-auth/SecurityRevision">;
|
|
68
|
+
readonly cohortGeneration: string & import("effect/Brand").Brand<"effect-auth/SecurityRevision">;
|
|
69
|
+
readonly metadata: {
|
|
70
|
+
readonly scopes: readonly string[];
|
|
71
|
+
readonly resources: readonly string[];
|
|
72
|
+
readonly accessExpiresAtMillis?: number | undefined;
|
|
73
|
+
readonly refreshExpiresAtMillis?: number | undefined;
|
|
74
|
+
readonly useUntilMillis: number;
|
|
75
|
+
readonly refreshUseUntilMillis?: number | undefined;
|
|
76
|
+
readonly obtainedAtMillis: number;
|
|
77
|
+
readonly profile?: {
|
|
78
|
+
readonly displayName?: string | undefined;
|
|
79
|
+
readonly handle?: string | undefined;
|
|
80
|
+
readonly avatarUrl?: string | undefined;
|
|
81
|
+
readonly profileUrl?: string | undefined;
|
|
82
|
+
readonly email?: string | undefined;
|
|
83
|
+
readonly emailVerified?: boolean | undefined;
|
|
84
|
+
readonly providerData?: {
|
|
85
|
+
readonly [x: string]: Schema.Json;
|
|
86
|
+
} | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
readonly sealed: {
|
|
91
|
+
readonly format: "oauth-connected-xchacha20poly1305-v1";
|
|
92
|
+
readonly keyId: string;
|
|
93
|
+
readonly nonce: string;
|
|
94
|
+
readonly ciphertext: import("effect/Redacted").Redacted<string>;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
} | {
|
|
98
|
+
readonly _tag: "Conflict";
|
|
99
|
+
} | {
|
|
100
|
+
readonly _tag: "Busy";
|
|
101
|
+
}, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, M.OAuthUnavailable, never>;
|
|
11
102
|
readonly capture: (input: {
|
|
12
103
|
readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
|
|
13
104
|
readonly subjectId: import("@yielded/auth/Schema").SubjectId;
|
|
@@ -36,6 +127,21 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
|
|
|
36
127
|
readonly generation: number;
|
|
37
128
|
readonly flowId: string & import("effect/Brand").Brand<"effect-auth/RequestBindingFlowId">;
|
|
38
129
|
readonly commandId: string & import("effect/Brand").Brand<"effect-auth/OAuthCommandId">;
|
|
130
|
+
readonly access?: {
|
|
131
|
+
readonly key: string & import("effect/Brand").Brand<"effect-auth/OAuthPermissionProfileKey">;
|
|
132
|
+
readonly generation: number;
|
|
133
|
+
readonly issuance: "active" | "retired";
|
|
134
|
+
readonly provider: string & import("effect/Brand").Brand<"effect-auth/OAuthProviderKey">;
|
|
135
|
+
readonly clientRegistrationId: string;
|
|
136
|
+
readonly scopes: readonly string[];
|
|
137
|
+
readonly resources: readonly string[];
|
|
138
|
+
readonly retention: "access-and-refresh" | "access-only";
|
|
139
|
+
readonly maximumAccessLifetimeMillis: number;
|
|
140
|
+
readonly maximumRefreshLifetimeMillis?: number | undefined;
|
|
141
|
+
readonly refreshAheadMillis: number;
|
|
142
|
+
readonly refresh: "confidential" | "rotating" | "unsupported";
|
|
143
|
+
readonly revocation: "cohort" | "unsupported";
|
|
144
|
+
} | undefined;
|
|
39
145
|
readonly returnTarget: string & import("effect/Brand").Brand<"effect-auth/OAuthReturnTarget">;
|
|
40
146
|
readonly stateDigest: string & import("effect/Brand").Brand<"effect-auth/TokenDigest">;
|
|
41
147
|
readonly requestBindingVerifier: string & import("effect/Brand").Brand<"effect-auth/TokenDigest">;
|
|
@@ -138,6 +244,21 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
|
|
|
138
244
|
readonly generation: number;
|
|
139
245
|
readonly flowId: string & import("effect/Brand").Brand<"effect-auth/RequestBindingFlowId">;
|
|
140
246
|
readonly commandId: string & import("effect/Brand").Brand<"effect-auth/OAuthCommandId">;
|
|
247
|
+
readonly access?: {
|
|
248
|
+
readonly key: string & import("effect/Brand").Brand<"effect-auth/OAuthPermissionProfileKey">;
|
|
249
|
+
readonly generation: number;
|
|
250
|
+
readonly issuance: "active" | "retired";
|
|
251
|
+
readonly provider: string & import("effect/Brand").Brand<"effect-auth/OAuthProviderKey">;
|
|
252
|
+
readonly clientRegistrationId: string;
|
|
253
|
+
readonly scopes: readonly string[];
|
|
254
|
+
readonly resources: readonly string[];
|
|
255
|
+
readonly retention: "access-and-refresh" | "access-only";
|
|
256
|
+
readonly maximumAccessLifetimeMillis: number;
|
|
257
|
+
readonly maximumRefreshLifetimeMillis?: number | undefined;
|
|
258
|
+
readonly refreshAheadMillis: number;
|
|
259
|
+
readonly refresh: "confidential" | "rotating" | "unsupported";
|
|
260
|
+
readonly revocation: "cohort" | "unsupported";
|
|
261
|
+
} | undefined;
|
|
141
262
|
readonly returnTarget: string & import("effect/Brand").Brand<"effect-auth/OAuthReturnTarget">;
|
|
142
263
|
readonly stateDigest: string & import("effect/Brand").Brand<"effect-auth/TokenDigest">;
|
|
143
264
|
readonly requestBindingVerifier: string & import("effect/Brand").Brand<"effect-auth/TokenDigest">;
|
|
@@ -226,14 +347,14 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
|
|
|
226
347
|
readonly identity: typeof OAuthExternalIdentity.Type;
|
|
227
348
|
}) => Effect.Effect<{
|
|
228
349
|
readonly _tag: "Rejected";
|
|
350
|
+
} | {
|
|
351
|
+
readonly _tag: "Conflict";
|
|
229
352
|
} | {
|
|
230
353
|
readonly _tag: "Target";
|
|
231
354
|
readonly cohortGeneration: string & import("effect/Brand").Brand<"effect-auth/SecurityRevision">;
|
|
232
355
|
} | {
|
|
233
356
|
readonly _tag: "Quarantine";
|
|
234
357
|
readonly cohortGeneration: string & import("effect/Brand").Brand<"effect-auth/SecurityRevision">;
|
|
235
|
-
} | {
|
|
236
|
-
readonly _tag: "Conflict";
|
|
237
358
|
}, M.OAuthUnavailable>;
|
|
238
359
|
readonly settle: <A>(input: {
|
|
239
360
|
readonly claim: M.OAuthConnectedClaim;
|
|
@@ -242,17 +363,16 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
|
|
|
242
363
|
readonly nowMillis: number;
|
|
243
364
|
}, prepare: PrepareOAuthCommit<{
|
|
244
365
|
readonly _tag: "Rejected";
|
|
245
|
-
} | {
|
|
246
|
-
readonly _tag: "Ambiguous";
|
|
247
|
-
} | {
|
|
248
|
-
readonly _tag: "Conflict";
|
|
249
366
|
} | {
|
|
250
367
|
readonly _tag: "Cancelled";
|
|
368
|
+
} | {
|
|
369
|
+
readonly _tag: "Ambiguous";
|
|
251
370
|
} | {
|
|
252
371
|
readonly _tag: "Connected";
|
|
253
372
|
readonly grant: {
|
|
254
373
|
readonly context: {
|
|
255
374
|
readonly namespace: "effect-auth/oauth-connected-token-context/v1";
|
|
375
|
+
readonly exchangeOrder: string;
|
|
256
376
|
readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
|
|
257
377
|
readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
|
|
258
378
|
readonly identity: {
|
|
@@ -316,6 +436,8 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
|
|
|
316
436
|
readonly ciphertext: import("effect/Redacted").Redacted<string>;
|
|
317
437
|
};
|
|
318
438
|
};
|
|
439
|
+
} | {
|
|
440
|
+
readonly _tag: "Conflict";
|
|
319
441
|
} | {
|
|
320
442
|
readonly _tag: "Busy";
|
|
321
443
|
}, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, M.OAuthUnavailable, never>;
|
|
@@ -363,6 +485,7 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
|
|
|
363
485
|
readonly grant: {
|
|
364
486
|
readonly context: {
|
|
365
487
|
readonly namespace: "effect-auth/oauth-connected-token-context/v1";
|
|
488
|
+
readonly exchangeOrder: string;
|
|
366
489
|
readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
|
|
367
490
|
readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
|
|
368
491
|
readonly identity: {
|
|
@@ -475,6 +598,7 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
|
|
|
475
598
|
readonly grant: {
|
|
476
599
|
readonly context: {
|
|
477
600
|
readonly namespace: "effect-auth/oauth-connected-token-context/v1";
|
|
601
|
+
readonly exchangeOrder: string;
|
|
478
602
|
readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
|
|
479
603
|
readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
|
|
480
604
|
readonly identity: {
|
|
@@ -559,6 +683,7 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
|
|
|
559
683
|
readonly grant: {
|
|
560
684
|
readonly context: {
|
|
561
685
|
readonly namespace: "effect-auth/oauth-connected-token-context/v1";
|
|
686
|
+
readonly exchangeOrder: string;
|
|
562
687
|
readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
|
|
563
688
|
readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
|
|
564
689
|
readonly identity: {
|
|
@@ -622,6 +747,7 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
|
|
|
622
747
|
readonly ciphertext: import("effect/Redacted").Redacted<string>;
|
|
623
748
|
};
|
|
624
749
|
};
|
|
750
|
+
readonly order: string;
|
|
625
751
|
readonly claimId: string & import("effect/Brand").Brand<"effect-auth/OAuthClaimId">;
|
|
626
752
|
readonly claimedAtMillis: number;
|
|
627
753
|
readonly claimExpiresAtMillis: number;
|
|
@@ -641,6 +767,7 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
|
|
|
641
767
|
readonly grant: {
|
|
642
768
|
readonly context: {
|
|
643
769
|
readonly namespace: "effect-auth/oauth-connected-token-context/v1";
|
|
770
|
+
readonly exchangeOrder: string;
|
|
644
771
|
readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
|
|
645
772
|
readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
|
|
646
773
|
readonly identity: {
|
|
@@ -730,8 +857,8 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
|
|
|
730
857
|
readonly hasMore: boolean;
|
|
731
858
|
}, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, M.OAuthUnavailable, never>;
|
|
732
859
|
};
|
|
733
|
-
}, never, LifecycleHooks>;
|
|
734
|
-
export declare const makeTargetOAuthConnectedRevocationServices: (
|
|
860
|
+
}, never, import("@yielded/auth/Hooks").LifecycleHooks | import("@yielded/auth-persistence/Adapter").NativeDatabase>;
|
|
861
|
+
export declare const makeTargetOAuthConnectedRevocationServices: (mapping: Revocations, configuration: OAuthTargetConfiguration) => Effect.Effect<{
|
|
735
862
|
oauthConnectedRevocations: {
|
|
736
863
|
readonly claim: <A>(input: {
|
|
737
864
|
readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
|
|
@@ -745,8 +872,8 @@ export declare const makeTargetOAuthConnectedRevocationServices: (database: any,
|
|
|
745
872
|
readonly settled: boolean;
|
|
746
873
|
}, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, M.OAuthUnavailable>;
|
|
747
874
|
};
|
|
748
|
-
}, never, LifecycleHooks>;
|
|
749
|
-
export declare const oauthConnectedPersistenceLayer: (services: ReturnType<typeof makeTargetOAuthConnectedServices>) => Layer.Layer<OAuthConnectedPersistence,
|
|
750
|
-
export declare const oauthConnectedRevocationsLayer: (services: ReturnType<typeof makeTargetOAuthConnectedRevocationServices>) => Layer.Layer<OAuthConnectedRevocations,
|
|
875
|
+
}, never, import("@yielded/auth/Hooks").LifecycleHooks | import("@yielded/auth-persistence/Adapter").NativeDatabase>;
|
|
876
|
+
export declare const oauthConnectedPersistenceLayer: <E, R>(services: Effect.Effect<Effect.Success<ReturnType<typeof makeTargetOAuthConnectedServices>>, E, R>) => Layer.Layer<OAuthConnectedPersistence, E, Exclude<R, import("effect/Scope").Scope>>;
|
|
877
|
+
export declare const oauthConnectedRevocationsLayer: <E, R>(services: Effect.Effect<Effect.Success<ReturnType<typeof makeTargetOAuthConnectedRevocationServices>>, E, R>) => Layer.Layer<OAuthConnectedRevocations, E, Exclude<R, import("effect/Scope").Scope>>;
|
|
751
878
|
//#endregion
|
|
752
879
|
//# sourceMappingURL=oauth-connected-target.d.mts.map
|
|
@@ -9,10 +9,10 @@ import { admitUse, claimRefresh, inspectAccess, settleRefresh } from "./oauth-co
|
|
|
9
9
|
import { connectedInputs, connectedRevocationInputs } from "./oauth-connected-input.mjs";
|
|
10
10
|
import { claimRevocation, cleanup, settleRevocation } from "./oauth-connected-maintenance.mjs";
|
|
11
11
|
import { disconnect, inspectDisconnect, list } from "./oauth-connected-management.mjs";
|
|
12
|
+
import { claimSignIn, inspectSignIn, settleSignIn } from "./oauth-connected-sign-in.mjs";
|
|
13
|
+
import { Effect, Layer, Schema } from "effect";
|
|
12
14
|
import * as M from "@yielded/auth/OAuth";
|
|
13
15
|
import { OAuthConnectedPersistence, OAuthConnectedRevocationDecision, OAuthConnectedRevocations, OAuthExternalIdentity, snapshotOAuthSync } from "@yielded/auth/OAuth";
|
|
14
|
-
import { Effect, Layer, Schema } from "effect";
|
|
15
|
-
import { LifecycleHooks } from "@yielded/auth/Hooks";
|
|
16
16
|
//#region src/drizzle/oauth-connected-target.ts
|
|
17
17
|
const captured = (mapping) => {
|
|
18
18
|
const retained = captureOAuthMapping(mapping), codec = retained.subjectId;
|
|
@@ -53,6 +53,9 @@ const prepare = (schema, value, callback) => Effect.flatMap(CurrentOAuthTransact
|
|
|
53
53
|
const mutation = (mapping, execute, body, schema) => (input, callback) => execute.run(Effect.flatMap(body(mapping, input), (value) => prepare(schema, value, callback)));
|
|
54
54
|
const read = (mapping, execute, body) => (input) => execute.run(body(mapping, input), false);
|
|
55
55
|
const makeConnected = (mapping, execute) => capturedOAuthService({
|
|
56
|
+
claimSignIn: mutation(mapping, execute, claimSignIn, M.OAuthSignInAccessClaim),
|
|
57
|
+
inspectSignIn: read(mapping, execute, inspectSignIn),
|
|
58
|
+
settleSignIn: mutation(mapping, execute, settleSignIn, M.OAuthConnectedSettlementDecision),
|
|
56
59
|
capture: read(mapping, execute, capture),
|
|
57
60
|
issue: mutation(mapping, execute, issue, M.OAuthConnectedIssueDecision),
|
|
58
61
|
preflight: read(mapping, execute, preflight),
|
|
@@ -73,13 +76,13 @@ const makeRevocations = (mapping, execute) => capturedOAuthService({
|
|
|
73
76
|
claim: (input, callback) => execute.run(Effect.flatMap(claimRevocation(mapping, input), (value) => prepare(OAuthConnectedRevocationDecision, value, callback))),
|
|
74
77
|
settle: (input, callback) => execute.run(Effect.flatMap(settleRevocation(mapping, input), (value) => prepare(settled, value, callback)))
|
|
75
78
|
}, connectedRevocationInputs, execute.active, execute.poison);
|
|
76
|
-
const makeTargetOAuthConnectedServices = (
|
|
79
|
+
const makeTargetOAuthConnectedServices = (mapping, configuration) => {
|
|
77
80
|
const retained = captured(mapping);
|
|
78
|
-
return Effect.map(
|
|
81
|
+
return Effect.map(makeOAuthExecution(configuration), (execution) => ({ oauthConnectedPersistence: makeConnected(retained, execution) }));
|
|
79
82
|
};
|
|
80
|
-
const makeTargetOAuthConnectedRevocationServices = (
|
|
83
|
+
const makeTargetOAuthConnectedRevocationServices = (mapping, configuration) => {
|
|
81
84
|
const retained = captured(mapping);
|
|
82
|
-
return Effect.map(
|
|
85
|
+
return Effect.map(makeOAuthExecution(configuration), (execution) => ({ oauthConnectedRevocations: makeRevocations(retained, execution) }));
|
|
83
86
|
};
|
|
84
87
|
const coordinateTargetOAuthConnected = (database, mapping, configuration, owner) => coordinateOAuthOwner(database, captured(mapping), configuration, () => Effect.void, (value, execution) => ({ oauthConnectedPersistence: makeConnected(value, execution) }), owner);
|
|
85
88
|
const coordinateTargetOAuthConnectedRevocations = (database, mapping, configuration, owner) => coordinateOAuthOwner(database, captured(mapping), configuration, () => Effect.void, (value, execution) => ({ oauthConnectedRevocations: makeRevocations(value, execution) }), owner);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-connected-target.mjs","names":["S.nativeCopy","F.capture","F.issue","F.preflight","F.claim","F.inspectGrant","Management.list","Management.inspectDisconnect","Management.disconnect","A.inspectAccess","A.claimRefresh","A.settleRefresh","A.admitUse","Maintenance.cleanup","Maintenance.claimRevocation","Maintenance.settleRevocation"],"sources":["../../src/drizzle/oauth-connected-target.ts"],"sourcesContent":["import { LifecycleHooks } from \"@yielded/auth/Hooks\";\nimport * as M from \"@yielded/auth/OAuth\";\nimport {\n OAuthConnectedPersistence,\n OAuthConnectedRevocations,\n OAuthConnectedRevocationDecision,\n OAuthExternalIdentity,\n snapshotOAuthSync,\n type PrepareOAuthCommit,\n} from \"@yielded/auth/OAuth\";\n/* oxlint-disable no-explicit-any -- concrete adapters retain the native database, table and ID types. */\nimport { Effect, Layer, Schema } from \"effect\";\nimport type { Statement } from \"effect/unstable/sql/Statement\";\n\nimport type { PersistenceMappingError } from \"./model\";\nimport * as A from \"./oauth-connected-access\";\nimport * as F from \"./oauth-connected-flow\";\nimport { connectedInputs, connectedRevocationInputs } from \"./oauth-connected-input\";\nimport * as Maintenance from \"./oauth-connected-maintenance\";\nimport * as Management from \"./oauth-connected-management\";\nimport { settle } from \"./oauth-connected-settlement\";\nimport * as S from \"./oauth-connected-state\";\nimport { capturedOAuthService } from \"./oauth-input\";\nimport { CurrentOAuthTransaction } from \"./oauth-owner\";\nimport { captureOAuthMapping } from \"./oauth-state\";\nimport {\n coordinateOAuthOwner,\n makeOAuthExecution,\n type OAuthExecution,\n type OAuthTargetConfiguration,\n} from \"./oauth-target\";\n\nconst captured = <T extends S.Authority>(mapping: T): T => {\n const retained = captureOAuthMapping(mapping),\n codec = retained.subjectId;\n\n const subjectId = {\n ...codec,\n toNative: (subject: Parameters<typeof codec.toNative>[0]) =>\n Effect.map(codec.toNative(subject), S.nativeCopy),\n toSubject: (native: unknown) => codec.toSubject(S.nativeCopy(native)),\n equals: (a: unknown, b: unknown) => codec.equals(S.nativeCopy(a), S.nativeCopy(b)),\n };\n\n const ownership = retained.ownership;\n\n if (ownership.mode === \"separate\" && \"encodeInsert\" in ownership.external) {\n const encode = ownership.external.encodeInsert as (input: {\n readonly identity: typeof OAuthExternalIdentity.Type;\n readonly identityKey: string;\n readonly subjectId: unknown;\n }) => import(\"./oauth-owner\").Row;\n\n return captureOAuthMapping({\n ...retained,\n subjectId,\n ownership: {\n ...ownership,\n external: {\n ...ownership.external,\n encodeInsert: (input: Parameters<typeof encode>[0]) =>\n encode({\n ...input,\n identity: snapshotOAuthSync(OAuthExternalIdentity, input.identity),\n subjectId: S.nativeCopy(input.subjectId),\n }),\n },\n },\n });\n }\n\n return captureOAuthMapping({ ...retained, subjectId });\n};\n\nconst prepare = <Value, Encoded, A>(\n schema: Schema.Codec<Value, Encoded, never, never>,\n value: Value,\n callback: PrepareOAuthCommit<Value, A>,\n) =>\n Effect.flatMap(CurrentOAuthTransaction, (owner) =>\n Effect.sync(() => {\n owner.guards.push(owner.journal.prepare(undefined));\n\n return callback(snapshotOAuthSync(schema, value), owner.journal);\n }),\n );\n\nconst mutation =\n <Input, Value, Encoded>(\n mapping: S.Mapping,\n execute: OAuthExecution,\n body: (\n mapping: S.Mapping,\n input: Input,\n ) => Effect.Effect<\n Value,\n import(\"@yielded/auth/OAuth\").OAuthUnavailable | PersistenceMappingError,\n CurrentOAuthTransaction\n >,\n schema: Schema.Codec<Value, Encoded, never, never>,\n ) =>\n <A>(input: Input, callback: PrepareOAuthCommit<Value, A>) =>\n execute.run(Effect.flatMap(body(mapping, input), (value) => prepare(schema, value, callback)));\n\nconst read =\n <Input, Value>(\n mapping: S.Mapping,\n execute: OAuthExecution,\n body: (\n mapping: S.Mapping,\n input: Input,\n ) => Effect.Effect<\n Value,\n import(\"@yielded/auth/OAuth\").OAuthUnavailable | PersistenceMappingError,\n CurrentOAuthTransaction\n >,\n ) =>\n (input: Input) =>\n execute.run(body(mapping, input), false);\n\nexport const makeConnected = (\n mapping: S.Mapping,\n execute: OAuthExecution,\n): OAuthConnectedPersistence[\"Service\"] =>\n capturedOAuthService<OAuthConnectedPersistence[\"Service\"]>(\n {\n capture: read(mapping, execute, F.capture),\n issue: mutation(mapping, execute, F.issue, M.OAuthConnectedIssueDecision),\n preflight: read(mapping, execute, F.preflight),\n claim: mutation(mapping, execute, F.claim, M.OAuthConnectedClaimDecision),\n inspectGrant: read(mapping, execute, F.inspectGrant),\n settle: mutation(mapping, execute, settle, M.OAuthConnectedSettlementDecision),\n list: read(mapping, execute, Management.list),\n inspectDisconnect: read(mapping, execute, Management.inspectDisconnect),\n disconnect: mutation(\n mapping,\n execute,\n Management.disconnect,\n M.OAuthConnectedDisconnectDecision,\n ),\n inspectAccess: read(mapping, execute, A.inspectAccess),\n claimRefresh: mutation(mapping, execute, A.claimRefresh, M.OAuthConnectedRefreshDecision),\n settleRefresh: mutation(mapping, execute, A.settleRefresh, M.OAuthConnectedRefreshSettlement),\n admitUse: mutation(mapping, execute, A.admitUse, M.OAuthConnectedUseAdmission),\n cleanup: mutation(mapping, execute, Maintenance.cleanup, M.OAuthConnectedCleanupResult),\n },\n connectedInputs,\n execute.active,\n execute.poison,\n );\n\nconst settled = Schema.Struct({ settled: Schema.Boolean });\n\nexport const makeRevocations = (\n mapping: S.Revocations,\n execute: OAuthExecution,\n): OAuthConnectedRevocations[\"Service\"] =>\n capturedOAuthService<OAuthConnectedRevocations[\"Service\"]>(\n {\n claim: (input, callback) =>\n execute.run(\n Effect.flatMap(Maintenance.claimRevocation(mapping, input), (value) =>\n prepare(OAuthConnectedRevocationDecision, value, callback),\n ),\n ),\n settle: (input, callback) =>\n execute.run(\n Effect.flatMap(Maintenance.settleRevocation(mapping, input), (value) =>\n prepare(settled, value, callback),\n ),\n ),\n },\n connectedRevocationInputs,\n execute.active,\n execute.poison,\n );\n\nexport const makeTargetOAuthConnectedServices = (\n database: any,\n mapping: S.Mapping,\n configuration: OAuthTargetConfiguration,\n) => {\n const retained = captured(mapping);\n\n return Effect.map(LifecycleHooks, (hooks) => ({\n oauthConnectedPersistence: makeConnected(\n retained,\n makeOAuthExecution(database, hooks, configuration),\n ),\n }));\n};\n\nexport const makeTargetOAuthConnectedRevocationServices = (\n database: any,\n mapping: S.Revocations,\n configuration: OAuthTargetConfiguration,\n) => {\n const retained = captured(mapping);\n\n return Effect.map(LifecycleHooks, (hooks) => ({\n oauthConnectedRevocations: makeRevocations(\n retained,\n makeOAuthExecution(database, hooks, configuration),\n ),\n }));\n};\n\nexport const coordinateTargetOAuthConnected = <Transaction, A, E, R>(\n database: any,\n mapping: S.Mapping,\n configuration: OAuthTargetConfiguration,\n owner: (\n transaction: Transaction,\n services: { readonly oauthConnectedPersistence: OAuthConnectedPersistence[\"Service\"] },\n append: (statement: Statement<any>) => void,\n ) => Effect.Effect<A, E, R>,\n) =>\n coordinateOAuthOwner(\n database,\n captured(mapping),\n configuration,\n () => Effect.void,\n (value: S.Mapping, execution) => ({\n oauthConnectedPersistence: makeConnected(value, execution),\n }),\n owner,\n );\n\nexport const coordinateTargetOAuthConnectedRevocations = <Transaction, A, E, R>(\n database: any,\n mapping: S.Revocations,\n configuration: OAuthTargetConfiguration,\n owner: (\n transaction: Transaction,\n services: { readonly oauthConnectedRevocations: OAuthConnectedRevocations[\"Service\"] },\n append: (statement: Statement<any>) => void,\n ) => Effect.Effect<A, E, R>,\n) =>\n coordinateOAuthOwner(\n database,\n captured(mapping),\n configuration,\n () => Effect.void,\n (value: S.Revocations, execution) => ({\n oauthConnectedRevocations: makeRevocations(value, execution),\n }),\n owner,\n );\n\nexport const oauthConnectedPersistenceLayer = (\n services: ReturnType<typeof makeTargetOAuthConnectedServices>,\n) =>\n Layer.effect(\n OAuthConnectedPersistence,\n Effect.map(services, (value) => value.oauthConnectedPersistence),\n );\n\nexport const oauthConnectedRevocationsLayer = (\n services: ReturnType<typeof makeTargetOAuthConnectedRevocationServices>,\n) =>\n Layer.effect(\n OAuthConnectedRevocations,\n Effect.map(services, (value) => value.oauthConnectedRevocations),\n );\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAM,YAAmC,YAAkB;CACzD,MAAM,WAAW,oBAAoB,OAAO,GAC1C,QAA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B,UAAU,OAAO,aAAa,CACnD,EACF,EAAE;AACJ;AAEA,MAAa,kCACX,UACA,SACA,eACA,UAMA,qBACE,UACA,SAAS,OAAO,GAChB,qBACM,OAAO,OACZ,OAAkB,eAAe,EAChC,2BAA2B,cAAc,OAAO,SAAS,EAC3D,IACA,KACF;AAEF,MAAa,6CACX,UACA,SACA,eACA,UAMA,qBACE,UACA,SAAS,OAAO,GAChB,qBACM,OAAO,OACZ,OAAsB,eAAe,EACpC,2BAA2B,gBAAgB,OAAO,SAAS,EAC7D,IACA,KACF;AAEF,MAAa,kCACX,aAEA,MAAM,OACJ,2BACA,OAAO,IAAI,WAAW,UAAU,MAAM,yBAAyB,CACjE;AAEF,MAAa,kCACX,aAEA,MAAM,OACJ,2BACA,OAAO,IAAI,WAAW,UAAU,MAAM,yBAAyB,CACjE"}
|
|
1
|
+
{"version":3,"file":"oauth-connected-target.mjs","names":["S.nativeCopy","SignIn.claimSignIn","SignIn.inspectSignIn","SignIn.settleSignIn","F.capture","F.issue","F.preflight","F.claim","F.inspectGrant","Management.list","Management.inspectDisconnect","Management.disconnect","A.inspectAccess","A.claimRefresh","A.settleRefresh","A.admitUse","Maintenance.cleanup","Maintenance.claimRevocation","Maintenance.settleRevocation"],"sources":["../../src/drizzle/oauth-connected-target.ts"],"sourcesContent":["import * as M from \"@yielded/auth/OAuth\";\nimport {\n OAuthConnectedPersistence,\n OAuthConnectedRevocations,\n OAuthConnectedRevocationDecision,\n OAuthExternalIdentity,\n snapshotOAuthSync,\n type PrepareOAuthCommit,\n} from \"@yielded/auth/OAuth\";\n/* oxlint-disable no-explicit-any -- concrete adapters retain the native database, table and ID types. */\nimport { Effect, Layer, Schema } from \"effect\";\nimport type { Statement } from \"effect/sql/Statement\";\n\nimport type { PersistenceMappingError } from \"./model\";\nimport * as A from \"./oauth-connected-access\";\nimport * as F from \"./oauth-connected-flow\";\nimport { connectedInputs, connectedRevocationInputs } from \"./oauth-connected-input\";\nimport * as Maintenance from \"./oauth-connected-maintenance\";\nimport * as Management from \"./oauth-connected-management\";\nimport { settle } from \"./oauth-connected-settlement\";\nimport * as SignIn from \"./oauth-connected-sign-in\";\nimport * as S from \"./oauth-connected-state\";\nimport { capturedOAuthService } from \"./oauth-input\";\nimport { CurrentOAuthTransaction } from \"./oauth-owner\";\nimport { captureOAuthMapping } from \"./oauth-state\";\nimport {\n coordinateOAuthOwner,\n makeOAuthExecution,\n type OAuthExecution,\n type OAuthTargetConfiguration,\n} from \"./oauth-target\";\n\nconst captured = <T extends S.Authority>(mapping: T): T => {\n const retained = captureOAuthMapping(mapping),\n codec = retained.subjectId;\n\n const subjectId = {\n ...codec,\n toNative: (subject: Parameters<typeof codec.toNative>[0]) =>\n Effect.map(codec.toNative(subject), S.nativeCopy),\n toSubject: (native: unknown) => codec.toSubject(S.nativeCopy(native)),\n equals: (a: unknown, b: unknown) => codec.equals(S.nativeCopy(a), S.nativeCopy(b)),\n };\n\n const ownership = retained.ownership;\n\n if (ownership.mode === \"separate\" && \"encodeInsert\" in ownership.external) {\n const encode = ownership.external.encodeInsert as (input: {\n readonly identity: typeof OAuthExternalIdentity.Type;\n readonly identityKey: string;\n readonly subjectId: unknown;\n }) => import(\"./oauth-owner\").Row;\n\n return captureOAuthMapping({\n ...retained,\n subjectId,\n ownership: {\n ...ownership,\n external: {\n ...ownership.external,\n encodeInsert: (input: Parameters<typeof encode>[0]) =>\n encode({\n ...input,\n identity: snapshotOAuthSync(OAuthExternalIdentity, input.identity),\n subjectId: S.nativeCopy(input.subjectId),\n }),\n },\n },\n });\n }\n\n return captureOAuthMapping({ ...retained, subjectId });\n};\n\nconst prepare = <Value, Encoded, A>(\n schema: Schema.Codec<Value, Encoded, never, never>,\n value: Value,\n callback: PrepareOAuthCommit<Value, A>,\n) =>\n Effect.flatMap(CurrentOAuthTransaction, (owner) =>\n Effect.sync(() => {\n owner.guards.push(owner.journal.prepare(undefined));\n\n return callback(snapshotOAuthSync(schema, value), owner.journal);\n }),\n );\n\nconst mutation =\n <Input, Value, Encoded>(\n mapping: S.Mapping,\n execute: OAuthExecution,\n body: (\n mapping: S.Mapping,\n input: Input,\n ) => Effect.Effect<\n Value,\n import(\"@yielded/auth/OAuth\").OAuthUnavailable | PersistenceMappingError,\n CurrentOAuthTransaction\n >,\n schema: Schema.Codec<Value, Encoded, never, never>,\n ) =>\n <A>(input: Input, callback: PrepareOAuthCommit<Value, A>) =>\n execute.run(Effect.flatMap(body(mapping, input), (value) => prepare(schema, value, callback)));\n\nconst read =\n <Input, Value>(\n mapping: S.Mapping,\n execute: OAuthExecution,\n body: (\n mapping: S.Mapping,\n input: Input,\n ) => Effect.Effect<\n Value,\n import(\"@yielded/auth/OAuth\").OAuthUnavailable | PersistenceMappingError,\n CurrentOAuthTransaction\n >,\n ) =>\n (input: Input) =>\n execute.run(body(mapping, input), false);\n\nexport const makeConnected = (\n mapping: S.Mapping,\n execute: OAuthExecution,\n): OAuthConnectedPersistence[\"Service\"] =>\n capturedOAuthService<OAuthConnectedPersistence[\"Service\"]>(\n {\n claimSignIn: mutation(mapping, execute, SignIn.claimSignIn, M.OAuthSignInAccessClaim),\n inspectSignIn: read(mapping, execute, SignIn.inspectSignIn),\n settleSignIn: mutation(\n mapping,\n execute,\n SignIn.settleSignIn,\n M.OAuthConnectedSettlementDecision,\n ),\n capture: read(mapping, execute, F.capture),\n issue: mutation(mapping, execute, F.issue, M.OAuthConnectedIssueDecision),\n preflight: read(mapping, execute, F.preflight),\n claim: mutation(mapping, execute, F.claim, M.OAuthConnectedClaimDecision),\n inspectGrant: read(mapping, execute, F.inspectGrant),\n settle: mutation(mapping, execute, settle, M.OAuthConnectedSettlementDecision),\n list: read(mapping, execute, Management.list),\n inspectDisconnect: read(mapping, execute, Management.inspectDisconnect),\n disconnect: mutation(\n mapping,\n execute,\n Management.disconnect,\n M.OAuthConnectedDisconnectDecision,\n ),\n inspectAccess: read(mapping, execute, A.inspectAccess),\n claimRefresh: mutation(mapping, execute, A.claimRefresh, M.OAuthConnectedRefreshDecision),\n settleRefresh: mutation(mapping, execute, A.settleRefresh, M.OAuthConnectedRefreshSettlement),\n admitUse: mutation(mapping, execute, A.admitUse, M.OAuthConnectedUseAdmission),\n cleanup: mutation(mapping, execute, Maintenance.cleanup, M.OAuthConnectedCleanupResult),\n },\n connectedInputs,\n execute.active,\n execute.poison,\n );\n\nconst settled = Schema.Struct({ settled: Schema.Boolean });\n\nexport const makeRevocations = (\n mapping: S.Revocations,\n execute: OAuthExecution,\n): OAuthConnectedRevocations[\"Service\"] =>\n capturedOAuthService<OAuthConnectedRevocations[\"Service\"]>(\n {\n claim: (input, callback) =>\n execute.run(\n Effect.flatMap(Maintenance.claimRevocation(mapping, input), (value) =>\n prepare(OAuthConnectedRevocationDecision, value, callback),\n ),\n ),\n settle: (input, callback) =>\n execute.run(\n Effect.flatMap(Maintenance.settleRevocation(mapping, input), (value) =>\n prepare(settled, value, callback),\n ),\n ),\n },\n connectedRevocationInputs,\n execute.active,\n execute.poison,\n );\n\nexport const makeTargetOAuthConnectedServices = (\n mapping: S.Mapping,\n configuration: OAuthTargetConfiguration,\n) => {\n const retained = captured(mapping);\n\n return Effect.map(makeOAuthExecution(configuration), (execution) => ({\n oauthConnectedPersistence: makeConnected(retained, execution),\n }));\n};\n\nexport const makeTargetOAuthConnectedRevocationServices = (\n mapping: S.Revocations,\n configuration: OAuthTargetConfiguration,\n) => {\n const retained = captured(mapping);\n\n return Effect.map(makeOAuthExecution(configuration), (execution) => ({\n oauthConnectedRevocations: makeRevocations(retained, execution),\n }));\n};\n\nexport const coordinateTargetOAuthConnected = <Transaction, A, E, R>(\n database: any,\n mapping: S.Mapping,\n configuration: OAuthTargetConfiguration,\n owner: (\n transaction: Transaction,\n services: { readonly oauthConnectedPersistence: OAuthConnectedPersistence[\"Service\"] },\n append: (statement: Statement<any>) => void,\n ) => Effect.Effect<A, E, R>,\n) =>\n coordinateOAuthOwner(\n database,\n captured(mapping),\n configuration,\n () => Effect.void,\n (value: S.Mapping, execution) => ({\n oauthConnectedPersistence: makeConnected(value, execution),\n }),\n owner,\n );\n\nexport const coordinateTargetOAuthConnectedRevocations = <Transaction, A, E, R>(\n database: any,\n mapping: S.Revocations,\n configuration: OAuthTargetConfiguration,\n owner: (\n transaction: Transaction,\n services: { readonly oauthConnectedRevocations: OAuthConnectedRevocations[\"Service\"] },\n append: (statement: Statement<any>) => void,\n ) => Effect.Effect<A, E, R>,\n) =>\n coordinateOAuthOwner(\n database,\n captured(mapping),\n configuration,\n () => Effect.void,\n (value: S.Revocations, execution) => ({\n oauthConnectedRevocations: makeRevocations(value, execution),\n }),\n owner,\n );\n\nexport const oauthConnectedPersistenceLayer = <E, R>(\n services: Effect.Effect<\n Effect.Success<ReturnType<typeof makeTargetOAuthConnectedServices>>,\n E,\n R\n >,\n) =>\n Layer.effect(\n OAuthConnectedPersistence,\n Effect.map(services, (value) => value.oauthConnectedPersistence),\n );\n\nexport const oauthConnectedRevocationsLayer = <E, R>(\n services: Effect.Effect<\n Effect.Success<ReturnType<typeof makeTargetOAuthConnectedRevocationServices>>,\n E,\n R\n >,\n) =>\n Layer.effect(\n OAuthConnectedRevocations,\n Effect.map(services, (value) => value.oauthConnectedRevocations),\n );\n"],"mappings":";;;;;;;;;;;;;;;;AAgCA,MAAM,YAAmC,YAAkB;CACzD,MAAM,WAAW,oBAAoB,OAAO,GAC1C,QAAQ,SAAS;CAEnB,MAAM,YAAY;EAChB,GAAG;EACH,WAAW,YACT,OAAO,IAAI,MAAM,SAAS,OAAO,GAAGA,UAAY;EAClD,YAAY,WAAoB,MAAM,UAAUA,WAAa,MAAM,CAAC;EACpE,SAAS,GAAY,MAAe,MAAM,OAAOA,WAAa,CAAC,GAAGA,WAAa,CAAC,CAAC;CACnF;CAEA,MAAM,YAAY,SAAS;CAE3B,IAAI,UAAU,SAAS,cAAc,kBAAkB,UAAU,UAAU;EACzE,MAAM,SAAS,UAAU,SAAS;EAMlC,OAAO,oBAAoB;GACzB,GAAG;GACH;GACA,WAAW;IACT,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,EACpC,2BAA2B,gBAAgB,OAAO,SAAS,EAC7D,IACA,KACF;AAEF,MAAa,kCACX,aAMA,MAAM,OACJ,2BACA,OAAO,IAAI,WAAW,UAAU,MAAM,yBAAyB,CACjE;AAEF,MAAa,kCACX,aAMA,MAAM,OACJ,2BACA,OAAO,IAAI,WAAW,UAAU,MAAM,yBAAyB,CACjE"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { coordinateTargetOAuthAccounts, coordinateTargetOAuthRegistration, coordinateTargetOAuthRegistrationIntents, coordinateTargetOAuthSignIn, makeTargetOAuthAccountsServices, makeTargetOAuthRegistrationIntentServices, makeTargetOAuthRegistrationServices, makeTargetOAuthSignInServices } from "./oauth-target.mjs";
|
|
2
|
+
import { nativeDatabase } from "./native-database.mjs";
|
|
2
3
|
import { makeOAuthConnectedTarget } from "./oauth-connected-drivers.mjs";
|
|
3
|
-
import {
|
|
4
|
+
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
4
5
|
import { Context, Effect } from "effect";
|
|
6
|
+
import { OAuthAccountsPersistence, OAuthRegistrationIntents, OAuthSignInPersistence } from "@yielded/auth/OAuth";
|
|
5
7
|
//#region src/drizzle/oauth-drivers.ts
|
|
6
8
|
/** Driver-specific entry points instantiate both the database and table family. */
|
|
7
|
-
const makeOAuthTarget = (configuration) => {
|
|
9
|
+
const makeOAuthTarget = (databaseService, configuration) => {
|
|
8
10
|
function coordinateOAuthSignIn(acquire, options, body) {
|
|
9
11
|
return Effect.flatMap(acquire, (database) => coordinateTargetOAuthSignIn(database, options.mapping, configuration, (transaction, services) => {
|
|
10
12
|
const provided = Context.make(OAuthSignInPersistence, services.oauthSignInPersistence);
|
|
@@ -34,14 +36,14 @@ const makeOAuthTarget = (configuration) => {
|
|
|
34
36
|
}));
|
|
35
37
|
}
|
|
36
38
|
return {
|
|
37
|
-
...makeOAuthConnectedTarget(configuration),
|
|
39
|
+
...makeOAuthConnectedTarget(databaseService, configuration),
|
|
38
40
|
coordinateOAuthSignIn,
|
|
39
41
|
coordinateOAuthRegistrationIntents,
|
|
40
42
|
coordinateOAuthAccounts,
|
|
41
|
-
makeOAuthAccountsServices: (
|
|
42
|
-
makeOAuthSignInServices: (
|
|
43
|
-
makeOAuthRegistrationIntentServices: (
|
|
44
|
-
makeOAuthRegistrationServices: (
|
|
43
|
+
makeOAuthAccountsServices: (mapping) => makeTargetOAuthAccountsServices(mapping, configuration).pipe(Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService))),
|
|
44
|
+
makeOAuthSignInServices: (mapping) => makeTargetOAuthSignInServices(mapping, configuration).pipe(Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService))),
|
|
45
|
+
makeOAuthRegistrationIntentServices: (mapping) => makeTargetOAuthRegistrationIntentServices(mapping, configuration).pipe(Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService))),
|
|
46
|
+
makeOAuthRegistrationServices: (mapping) => makeTargetOAuthRegistrationServices(mapping, configuration).pipe(Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService))),
|
|
45
47
|
coordinateOAuthRegistration
|
|
46
48
|
};
|
|
47
49
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth-drivers.mjs","names":[],"sources":["../../src/drizzle/oauth-drivers.ts"],"sourcesContent":["import type { LifecycleHooks } from \"@yielded/auth/Hooks\";\nimport {\n OAuthAccountsPersistence,\n OAuthRegistrationIntents,\n OAuthSignInPersistence,\n} from \"@yielded/auth/OAuth\";\nimport type { Table } from \"drizzle-orm\";\nimport { Effect, Context } from \"effect\";\n\nimport { makeOAuthConnectedTarget } from \"./oauth-connected-drivers\";\nimport type {\n OAuthAccountsMapping,\n OAuthRegistrationAuthority,\n OAuthRegistrationIntentMapping,\n OAuthRegistrationMapping,\n OAuthSignInMapping,\n} from \"./oauth-model\";\nimport {\n type OAuthCoordinatorError,\n coordinateTargetOAuthAccounts,\n coordinateTargetOAuthSignIn,\n coordinateTargetOAuthRegistrationIntents,\n coordinateTargetOAuthRegistration,\n makeTargetOAuthRegistrationIntentServices,\n makeTargetOAuthRegistrationServices,\n makeTargetOAuthSignInServices,\n makeTargetOAuthAccountsServices,\n type OAuthTargetConfiguration,\n} from \"./oauth-target\";\nimport type { SuppliedService } from \"./SuppliedService\";\n\n// oxlint-disable-next-line no-explicit-any -- inspect the installed generic transaction signature without erasing its callback parameter.\ntype TransactionOf<D> = D extends { readonly transaction: (...args: any[]) => any }\n ? Parameters<Parameters<D[\"transaction\"]>[0]>[0]\n : never;\n\n/** Driver-specific entry points instantiate both the database and table family. */\nexport const makeOAuthTarget = <D, T extends Table, Synchronous extends boolean = false>(\n configuration: OAuthTargetConfiguration,\n) => {\n function coordinateOAuthSignIn<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthSignInMapping<S, O, C, AC, F, N>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<OAuthSignInPersistence> : R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, OAuthSignInPersistence>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthSignIn<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthSignInMapping<S, O, C, AC, F, N>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<\n A,\n E,\n Synchronous extends true ? NoInfer<OAuthSignInPersistence | TxId> : R\n >,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, OAuthSignInPersistence | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthSignIn<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthSignInMapping<S, O, C, AC, F, N>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n Exclude<R, OAuthSignInPersistence> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(acquire, (database) =>\n coordinateTargetOAuthSignIn<\n TransactionOf<Database>,\n A,\n E,\n Exclude<R, OAuthSignInPersistence>\n >(\n database,\n options.mapping,\n configuration,\n (\n transaction: TransactionOf<Database>,\n services: { readonly oauthSignInPersistence: OAuthSignInPersistence[\"Service\"] },\n ) => {\n const provided = Context.make(OAuthSignInPersistence, services.oauthSignInPersistence);\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ),\n );\n }\n function coordinateOAuthRegistrationIntents<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n I extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthRegistrationIntentMapping<S, O, C, AC, F, TA, I, N>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<OAuthRegistrationIntents> : R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, OAuthRegistrationIntents>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthRegistrationIntents<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n I extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthRegistrationIntentMapping<S, O, C, AC, F, TA, I, N>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<\n A,\n E,\n Synchronous extends true ? NoInfer<OAuthRegistrationIntents | TxId> : R\n >,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, OAuthRegistrationIntents | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthRegistrationIntents<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n I extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthRegistrationIntentMapping<S, O, C, AC, F, TA, I, N>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n Exclude<R, OAuthRegistrationIntents> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(acquire, (database) =>\n coordinateTargetOAuthRegistrationIntents<\n TransactionOf<Database>,\n A,\n E,\n Exclude<R, OAuthRegistrationIntents>\n >(\n database,\n options.mapping,\n configuration,\n (\n transaction: TransactionOf<Database>,\n services: { readonly oauthRegistrationIntents: OAuthRegistrationIntents[\"Service\"] },\n ) => {\n const provided = Context.make(\n OAuthRegistrationIntents,\n services.oauthRegistrationIntents,\n );\n\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ),\n );\n }\n function coordinateOAuthAccounts<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n U extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthAccountsMapping<S, O, C, AC, F, TA, U, N>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<OAuthAccountsPersistence> : R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, OAuthAccountsPersistence>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthAccounts<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n U extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthAccountsMapping<S, O, C, AC, F, TA, U, N>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<\n A,\n E,\n Synchronous extends true ? NoInfer<OAuthAccountsPersistence | TxId> : R\n >,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, OAuthAccountsPersistence | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthAccounts<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n U extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthAccountsMapping<S, O, C, AC, F, TA, U, N>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n Exclude<R, OAuthAccountsPersistence> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(acquire, (database) =>\n coordinateTargetOAuthAccounts<\n TransactionOf<Database>,\n A,\n E,\n Exclude<R, OAuthAccountsPersistence>\n >(\n database,\n options.mapping,\n configuration,\n (\n transaction: TransactionOf<Database>,\n services: { readonly oauthAccountsPersistence: OAuthAccountsPersistence[\"Service\"] },\n ) => {\n const provided = Context.make(\n OAuthAccountsPersistence,\n services.oauthAccountsPersistence,\n );\n\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ),\n );\n }\n function coordinateOAuthRegistration<\n Database extends D,\n TargetId,\n Registration,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n TA extends T,\n I extends T,\n Rq extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthRegistrationMapping<NoInfer<Registration>, S, O, C, AC, TA, I, Rq, N>;\n readonly target: SuppliedService<TargetId, OAuthRegistrationAuthority<Registration>>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<TargetId> : R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, TargetId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthRegistration<\n Database extends D,\n TargetId,\n Registration,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n TA extends T,\n I extends T,\n Rq extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthRegistrationMapping<NoInfer<Registration>, S, O, C, AC, TA, I, Rq, N>;\n readonly target: SuppliedService<TargetId, OAuthRegistrationAuthority<Registration>>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<TargetId | TxId> : R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, TargetId | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthRegistration<\n Database extends D,\n TargetId,\n Registration,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n TA extends T,\n I extends T,\n Rq extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthRegistrationMapping<NoInfer<Registration>, S, O, C, AC, TA, I, Rq, N>;\n readonly target: SuppliedService<TargetId, OAuthRegistrationAuthority<Registration>>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n Exclude<R, TargetId> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(acquire, (database) =>\n coordinateTargetOAuthRegistration<\n Registration,\n TransactionOf<Database>,\n A,\n E,\n Exclude<R, TargetId>\n >(\n database,\n options.mapping,\n configuration,\n (\n transaction: TransactionOf<Database>,\n services: { readonly registrationAuthority: OAuthRegistrationAuthority<Registration> },\n ) => {\n const provided = Context.make(options.target, services.registrationAuthority);\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ),\n );\n }\n\n return {\n ...makeOAuthConnectedTarget<D, T, {}, Synchronous>(configuration),\n coordinateOAuthSignIn,\n coordinateOAuthRegistrationIntents,\n coordinateOAuthAccounts,\n makeOAuthAccountsServices: <\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n U extends T,\n N,\n >(\n database: D,\n mapping: OAuthAccountsMapping<S, O, C, AC, F, TA, U, N>,\n ) => makeTargetOAuthAccountsServices(database, mapping, configuration),\n makeOAuthSignInServices: <S extends T, O extends T, C extends T, AC extends T, F extends T, N>(\n database: D,\n mapping: OAuthSignInMapping<S, O, C, AC, F, N>,\n ) => makeTargetOAuthSignInServices(database, mapping, configuration),\n makeOAuthRegistrationIntentServices: <\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n I extends T,\n N,\n >(\n database: D,\n mapping: OAuthRegistrationIntentMapping<S, O, C, AC, F, TA, I, N>,\n ) => makeTargetOAuthRegistrationIntentServices(database, mapping, configuration),\n makeOAuthRegistrationServices: <\n Registration,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n TA extends T,\n I extends T,\n R extends T,\n N,\n >(\n database: D,\n mapping: OAuthRegistrationMapping<Registration, S, O, C, AC, TA, I, R, N>,\n ) => makeTargetOAuthRegistrationServices<Registration>(database, mapping, configuration),\n coordinateOAuthRegistration,\n };\n};\n"],"mappings":";;;;;;AAqCA,MAAa,mBACX,kBACG;CA6DH,SAAS,sBAgBP,SACA,SAIA,MAKA;EACA,OAAO,OAAO,QAAQ,UAAU,aAC9B,4BAME,UACA,QAAQ,SACR,gBAEE,aACA,aACG;GACH,MAAM,WAAW,QAAQ,KAAK,wBAAwB,SAAS,sBAAsB;GACrF,MAAM,OAAO,OAAO,eAAe,MAAM,QAAQ;GAEjD,OAAO,QAAQ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AS,aAAa;EACrE,0BACE,UACA,YACG,8BAA8B,UAAU,SAAS,aAAa;EACnE,sCAUE,UACA,YACG,0CAA0C,UAAU,SAAS,aAAa;EAC/E,gCAWE,UACA,YACG,oCAAkD,UAAU,SAAS,aAAa;EACvF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"oauth-drivers.mjs","names":[],"sources":["../../src/drizzle/oauth-drivers.ts"],"sourcesContent":["import { NativeDatabase } from \"@yielded/auth-persistence/Adapter\";\nimport type { LifecycleHooks } from \"@yielded/auth/Hooks\";\nimport {\n OAuthAccountsPersistence,\n OAuthRegistrationIntents,\n OAuthSignInPersistence,\n} from \"@yielded/auth/OAuth\";\nimport type { Table } from \"drizzle-orm\";\nimport { Effect, Context } from \"effect\";\n\nimport { nativeDatabase } from \"./native-database\";\nimport { makeOAuthConnectedTarget } from \"./oauth-connected-drivers\";\nimport type {\n OAuthAccountsMapping,\n OAuthRegistrationAuthority,\n OAuthRegistrationIntentMapping,\n OAuthRegistrationMapping,\n OAuthSignInMapping,\n} from \"./oauth-model\";\nimport {\n type OAuthCoordinatorError,\n coordinateTargetOAuthAccounts,\n coordinateTargetOAuthSignIn,\n coordinateTargetOAuthRegistrationIntents,\n coordinateTargetOAuthRegistration,\n makeTargetOAuthRegistrationIntentServices,\n makeTargetOAuthRegistrationServices,\n makeTargetOAuthSignInServices,\n makeTargetOAuthAccountsServices,\n type OAuthTargetConfiguration,\n} from \"./oauth-target\";\nimport type { SuppliedService } from \"./SuppliedService\";\n\n// oxlint-disable-next-line no-explicit-any -- inspect the installed generic transaction signature without erasing its callback parameter.\ntype TransactionOf<D> = D extends { readonly transaction: (...args: any[]) => any }\n ? Parameters<Parameters<D[\"transaction\"]>[0]>[0]\n : never;\n\n/** Driver-specific entry points instantiate both the database and table family. */\nexport const makeOAuthTarget = <\n DatabaseId,\n D,\n T extends Table,\n Synchronous extends boolean = false,\n>(\n databaseService: Context.Service<DatabaseId, D>,\n configuration: OAuthTargetConfiguration,\n) => {\n function coordinateOAuthSignIn<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthSignInMapping<S, O, C, AC, F, N>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<OAuthSignInPersistence> : R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, OAuthSignInPersistence>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthSignIn<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthSignInMapping<S, O, C, AC, F, N>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<\n A,\n E,\n Synchronous extends true ? NoInfer<OAuthSignInPersistence | TxId> : R\n >,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, OAuthSignInPersistence | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthSignIn<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthSignInMapping<S, O, C, AC, F, N>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n Exclude<R, OAuthSignInPersistence> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(acquire, (database) =>\n coordinateTargetOAuthSignIn<\n TransactionOf<Database>,\n A,\n E,\n Exclude<R, OAuthSignInPersistence>\n >(\n database,\n options.mapping,\n configuration,\n (\n transaction: TransactionOf<Database>,\n services: { readonly oauthSignInPersistence: OAuthSignInPersistence[\"Service\"] },\n ) => {\n const provided = Context.make(OAuthSignInPersistence, services.oauthSignInPersistence);\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ),\n );\n }\n function coordinateOAuthRegistrationIntents<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n I extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthRegistrationIntentMapping<S, O, C, AC, F, TA, I, N>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<OAuthRegistrationIntents> : R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, OAuthRegistrationIntents>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthRegistrationIntents<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n I extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthRegistrationIntentMapping<S, O, C, AC, F, TA, I, N>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<\n A,\n E,\n Synchronous extends true ? NoInfer<OAuthRegistrationIntents | TxId> : R\n >,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, OAuthRegistrationIntents | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthRegistrationIntents<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n I extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthRegistrationIntentMapping<S, O, C, AC, F, TA, I, N>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n Exclude<R, OAuthRegistrationIntents> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(acquire, (database) =>\n coordinateTargetOAuthRegistrationIntents<\n TransactionOf<Database>,\n A,\n E,\n Exclude<R, OAuthRegistrationIntents>\n >(\n database,\n options.mapping,\n configuration,\n (\n transaction: TransactionOf<Database>,\n services: { readonly oauthRegistrationIntents: OAuthRegistrationIntents[\"Service\"] },\n ) => {\n const provided = Context.make(\n OAuthRegistrationIntents,\n services.oauthRegistrationIntents,\n );\n\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ),\n );\n }\n function coordinateOAuthAccounts<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n U extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthAccountsMapping<S, O, C, AC, F, TA, U, N>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<OAuthAccountsPersistence> : R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, OAuthAccountsPersistence>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthAccounts<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n U extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthAccountsMapping<S, O, C, AC, F, TA, U, N>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<\n A,\n E,\n Synchronous extends true ? NoInfer<OAuthAccountsPersistence | TxId> : R\n >,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, OAuthAccountsPersistence | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthAccounts<\n Database extends D,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n U extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthAccountsMapping<S, O, C, AC, F, TA, U, N>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n Exclude<R, OAuthAccountsPersistence> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(acquire, (database) =>\n coordinateTargetOAuthAccounts<\n TransactionOf<Database>,\n A,\n E,\n Exclude<R, OAuthAccountsPersistence>\n >(\n database,\n options.mapping,\n configuration,\n (\n transaction: TransactionOf<Database>,\n services: { readonly oauthAccountsPersistence: OAuthAccountsPersistence[\"Service\"] },\n ) => {\n const provided = Context.make(\n OAuthAccountsPersistence,\n services.oauthAccountsPersistence,\n );\n\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ),\n );\n }\n function coordinateOAuthRegistration<\n Database extends D,\n TargetId,\n Registration,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n TA extends T,\n I extends T,\n Rq extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthRegistrationMapping<NoInfer<Registration>, S, O, C, AC, TA, I, Rq, N>;\n readonly target: SuppliedService<TargetId, OAuthRegistrationAuthority<Registration>>;\n readonly transaction?: never;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<TargetId> : R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, TargetId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthRegistration<\n Database extends D,\n TargetId,\n Registration,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n TA extends T,\n I extends T,\n Rq extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthRegistrationMapping<NoInfer<Registration>, S, O, C, AC, TA, I, Rq, N>;\n readonly target: SuppliedService<TargetId, OAuthRegistrationAuthority<Registration>>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, Synchronous extends true ? NoInfer<TargetId | TxId> : R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, TargetId | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinateOAuthRegistration<\n Database extends D,\n TargetId,\n Registration,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n TA extends T,\n I extends T,\n Rq extends T,\n N,\n A,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: OAuthRegistrationMapping<NoInfer<Registration>, S, O, C, AC, TA, I, Rq, N>;\n readonly target: SuppliedService<TargetId, OAuthRegistrationAuthority<Registration>>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<A, E, R>,\n ): Effect.Effect<\n A,\n OAuthCoordinatorError<E> | DatabaseError,\n Exclude<R, TargetId> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(acquire, (database) =>\n coordinateTargetOAuthRegistration<\n Registration,\n TransactionOf<Database>,\n A,\n E,\n Exclude<R, TargetId>\n >(\n database,\n options.mapping,\n configuration,\n (\n transaction: TransactionOf<Database>,\n services: { readonly registrationAuthority: OAuthRegistrationAuthority<Registration> },\n ) => {\n const provided = Context.make(options.target, services.registrationAuthority);\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ),\n );\n }\n\n return {\n ...makeOAuthConnectedTarget<DatabaseId, D, T, {}, Synchronous>(databaseService, configuration),\n coordinateOAuthSignIn,\n coordinateOAuthRegistrationIntents,\n coordinateOAuthAccounts,\n makeOAuthAccountsServices: <\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n U extends T,\n N,\n >(\n mapping: OAuthAccountsMapping<S, O, C, AC, F, TA, U, N>,\n ) =>\n makeTargetOAuthAccountsServices(mapping, configuration).pipe(\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n makeOAuthSignInServices: <S extends T, O extends T, C extends T, AC extends T, F extends T, N>(\n mapping: OAuthSignInMapping<S, O, C, AC, F, N>,\n ) =>\n makeTargetOAuthSignInServices(mapping, configuration).pipe(\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n makeOAuthRegistrationIntentServices: <\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n F extends T,\n TA extends T,\n I extends T,\n N,\n >(\n mapping: OAuthRegistrationIntentMapping<S, O, C, AC, F, TA, I, N>,\n ) =>\n makeTargetOAuthRegistrationIntentServices(mapping, configuration).pipe(\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n makeOAuthRegistrationServices: <\n Registration,\n S extends T,\n O extends T,\n C extends T,\n AC extends T,\n TA extends T,\n I extends T,\n R extends T,\n N,\n >(\n mapping: OAuthRegistrationMapping<Registration, S, O, C, AC, TA, I, R, N>,\n ) =>\n makeTargetOAuthRegistrationServices<Registration>(mapping, configuration).pipe(\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n coordinateOAuthRegistration,\n };\n};\n"],"mappings":";;;;;;;;AAuCA,MAAa,mBAMX,iBACA,kBACG;CA6DH,SAAS,sBAgBP,SACA,SAIA,MAKA;EACA,OAAO,OAAO,QAAQ,UAAU,aAC9B,4BAME,UACA,QAAQ,SACR,gBAEE,aACA,aACG;GACH,MAAM,WAAW,QAAQ,KAAK,wBAAwB,SAAS,sBAAsB;GACrF,MAAM,OAAO,OAAO,eAAe,MAAM,QAAQ;GAEjD,OAAO,QAAQ,gBAAgB,KAAA,IAC3B,OACA,OAAO,eAAe,MAAM,QAAQ,aAAa,QAAQ,YAAY,GAAG,WAAW,CAAC;EAC1F,CACF,CACF;CACF;CAiEA,SAAS,mCAkBP,SACA,SAIA,MAKA;EACA,OAAO,OAAO,QAAQ,UAAU,aAC9B,yCAME,UACA,QAAQ,SACR,gBAEE,aACA,aACG;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,KAChE,OAAO,qBAAqB,gBAAgB,eAAe,eAAe,CAAC,CAC7E;EACF,gCAWE,YAEA,oCAAkD,SAAS,aAAa,CAAC,CAAC,KACxE,OAAO,qBAAqB,gBAAgB,eAAe,eAAe,CAAC,CAC7E;EACF;CACF;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Row } from "./transaction-owner.mjs";
|
|
2
2
|
import { CurrentOAuthTransaction } from "./oauth-owner.mjs";
|
|
3
|
-
import { OAuthClaim, OAuthCleanupInput, OAuthLinkClaim, OAuthLinkPendingFlow, OAuthPendingFlow, OAuthVerifiedExternalIdentity } from "@yielded/auth/OAuth";
|
|
4
3
|
import { Effect } from "effect";
|
|
4
|
+
import { OAuthClaim, OAuthCleanupInput, OAuthLinkClaim, OAuthLinkPendingFlow, OAuthPendingFlow, OAuthVerifiedExternalIdentity } from "@yielded/auth/OAuth";
|
|
5
5
|
//#region src/drizzle/oauth-flow.d.ts
|
|
6
6
|
/** Subject precedes credentials; the complete active credential vector is retained. */
|
|
7
7
|
export declare const currentSubject: (mapping: any, nativeId: unknown) => Effect.Effect<{
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { invariant, oauthIdentityKey, storage } from "./oauth-state.mjs";
|
|
2
2
|
import { both } from "./transaction-owner.mjs";
|
|
3
3
|
import { CurrentOAuthTransaction, col, copiedRow, equal } from "./oauth-owner.mjs";
|
|
4
|
-
import { OAuthAccountRevision, OAuthCleanupInput, OAuthCredentialSnapshot, OAuthLinkPendingFlow, OAuthModuleId, OAuthPendingFlow, snapshotOAuthSync } from "@yielded/auth/OAuth";
|
|
5
4
|
import { eq, sql } from "drizzle-orm";
|
|
6
5
|
import { Effect } from "effect";
|
|
6
|
+
import { OAuthAccountRevision, OAuthCleanupInput, OAuthCredentialSnapshot, OAuthLinkPendingFlow, OAuthModuleId, OAuthPendingFlow, snapshotOAuthSync } from "@yielded/auth/OAuth";
|
|
7
7
|
//#region src/drizzle/oauth-flow.ts
|
|
8
8
|
const pendingStorage = storage(OAuthPendingFlow);
|
|
9
9
|
const linkStorage = storage(OAuthLinkPendingFlow);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { invariant, unavailable } from "./oauth-state.mjs";
|
|
2
|
-
import { OAuthAccountRevision, OAuthActionAuthorization, OAuthClaim, OAuthClaimId, OAuthCleanupInput, OAuthCommandId, OAuthCredentialSnapshot, OAuthInstant, OAuthLinkAccess, OAuthLinkClaim, OAuthLinkOutcome, OAuthLinkPendingFlow, OAuthModuleId, OAuthPendingFlow, OAuthRegistrationAccess, OAuthRegistrationFingerprint, OAuthRegistrationIntent, OAuthSignInTransactionContext, OAuthVerifiedExternalIdentity, snapshotOAuthSync } from "@yielded/auth/OAuth";
|
|
3
2
|
import { Effect, Schema } from "effect";
|
|
4
3
|
import { SessionInvalidationWindow } from "@yielded/auth/Sessions";
|
|
4
|
+
import { OAuthAccountRevision, OAuthActionAuthorization, OAuthClaim, OAuthClaimId, OAuthCleanupInput, OAuthCommandId, OAuthCredentialSnapshot, OAuthInstant, OAuthLinkAccess, OAuthLinkClaim, OAuthLinkOutcome, OAuthLinkPendingFlow, OAuthModuleId, OAuthPendingFlow, OAuthRegistrationAccess, OAuthRegistrationFingerprint, OAuthRegistrationIntent, OAuthSignInTransactionContext, OAuthVerifiedExternalIdentity, snapshotOAuthSync } from "@yielded/auth/OAuth";
|
|
5
5
|
//#region src/drizzle/oauth-input.ts
|
|
6
6
|
const fields = OAuthSignInTransactionContext.fields;
|
|
7
7
|
const claimInput = Schema.Struct({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PersistenceMappingError, SubjectIdCodec } from "./model.mjs";
|
|
2
|
-
import { OAuthAccountRevision, OAuthActionAuthorization, OAuthCredentialSnapshot, OAuthExternalIdentity, OAuthRegistrationIntent } from "@yielded/auth/OAuth";
|
|
3
2
|
import { InferInsertModel, InferSelectModel, SQL, Table } from "drizzle-orm";
|
|
4
3
|
import { Effect } from "effect";
|
|
5
4
|
import { AuthenticationRequirement, SecurityRevision } from "@yielded/auth/Sessions";
|
|
5
|
+
import { OAuthAccountRevision, OAuthActionAuthorization, OAuthCredentialSnapshot, OAuthExternalIdentity, OAuthRegistrationIntent } from "@yielded/auth/OAuth";
|
|
6
6
|
import { AuthenticationFactor } from "@yielded/auth/Operations";
|
|
7
7
|
//#region src/drizzle/oauth-model.d.ts
|
|
8
8
|
type Column<T extends Table> = Extract<keyof T["_"]["columns"], string>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Row, TransactionOwner } from "./transaction-owner.mjs";
|
|
2
|
-
import { OAuthUnavailable } from "@yielded/auth/OAuth";
|
|
3
2
|
import { Context } from "effect";
|
|
4
3
|
import "@yielded/auth/Hooks";
|
|
4
|
+
import { OAuthUnavailable } from "@yielded/auth/OAuth";
|
|
5
5
|
//#region src/drizzle/oauth-owner.d.ts
|
|
6
6
|
export type OAuthOwner = TransactionOwner<OAuthUnavailable>;
|
|
7
7
|
declare const CurrentOAuthTransaction_base: Context.ServiceClass<CurrentOAuthTransaction, "effect-auth/drizzle/CurrentOAuthTransaction", OAuthOwner>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./model.mjs";
|
|
2
2
|
import "./oauth-model.mjs";
|
|
3
3
|
import "./oauth-owner.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Effect, Schema } from "effect";
|
|
5
|
+
import { OAuthExternalIdentity, OAuthRegistrationAccess, OAuthRegistrationIntent } from "@yielded/auth/OAuth";
|
|
@@ -2,9 +2,9 @@ import { invariant, oauthIdentityKey, sameIdentity, storage } from "./oauth-stat
|
|
|
2
2
|
import { both } from "./transaction-owner.mjs";
|
|
3
3
|
import { CurrentOAuthTransaction, col, equal, matchesNativeRow } from "./oauth-owner.mjs";
|
|
4
4
|
import { discoverOwned, exactClaim, resolveOwned, terminalFlow } from "./oauth-flow.mjs";
|
|
5
|
-
import { OAuthCredentialSnapshot, OAuthDisplayProfile, OAuthRegistrationAccess, OAuthRegistrationDecision, OAuthRegistrationFingerprint, OAuthRegistrationInspection, OAuthRegistrationIntent, OAuthSignInTransactionContext, snapshotOAuthSync } from "@yielded/auth/OAuth";
|
|
6
5
|
import { eq, sql } from "drizzle-orm";
|
|
7
6
|
import { Effect, Schema } from "effect";
|
|
7
|
+
import { OAuthCredentialSnapshot, OAuthDisplayProfile, OAuthRegistrationAccess, OAuthRegistrationDecision, OAuthRegistrationFingerprint, OAuthRegistrationInspection, OAuthRegistrationIntent, OAuthSignInTransactionContext, snapshotOAuthSync } from "@yielded/auth/OAuth";
|
|
8
8
|
//#region src/drizzle/oauth-registration.ts
|
|
9
9
|
const intentStorage = storage(OAuthRegistrationIntent);
|
|
10
10
|
const decisionStorage = storage(OAuthRegistrationDecision);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { DateTime, Effect, Schema } from "effect";
|
|
1
2
|
import { OAuthExternalIdentity, OAuthUnavailable, snapshotOAuthSync } from "@yielded/auth/OAuth";
|
|
2
|
-
import { DateTime, Effect, Encoding, Schema } from "effect";
|
|
3
3
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
4
4
|
import { randomBytes } from "@noble/hashes/utils.js";
|
|
5
|
+
import { Base64Url } from "effect/encoding";
|
|
5
6
|
//#region src/drizzle/oauth-state.ts
|
|
6
7
|
const encoder = new TextEncoder();
|
|
7
8
|
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
@@ -9,8 +10,8 @@ const unavailable = () => OAuthUnavailable.make({});
|
|
|
9
10
|
const invariant = (value) => {
|
|
10
11
|
if (!value) throw unavailable();
|
|
11
12
|
};
|
|
12
|
-
const nonce = () =>
|
|
13
|
-
const digest = (value) =>
|
|
13
|
+
const nonce = () => Base64Url.encode(randomBytes(32));
|
|
14
|
+
const digest = (value) => Base64Url.encode(sha256(encoder.encode(value)));
|
|
14
15
|
/** Capture configuration/callback references while preserving Drizzle table, SQL
|
|
15
16
|
* and Effect objects. Never freeze or mutate the consumer's original graph. */
|
|
16
17
|
const captureOAuthMapping = (input) => {
|
|
@@ -55,7 +56,7 @@ const oauthIdentityKey = (input) => {
|
|
|
55
56
|
packed.set(value, offset + 4);
|
|
56
57
|
offset += 4 + value.length;
|
|
57
58
|
}
|
|
58
|
-
return "v1:" +
|
|
59
|
+
return "v1:" + Base64Url.encode(sha256(packed));
|
|
59
60
|
};
|
|
60
61
|
const sameIdentity = (left, right) => left.provider === right.provider && left.issuer === right.issuer && left.subject === right.subject;
|
|
61
62
|
/** Private Type storage: opaque wrappers and DateTimes are freshly reconstructed. */
|