@yielded/auth-persistence-drizzle 0.1.0-beta.0 → 0.1.0-beta.1

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.
Files changed (204) hide show
  1. package/README.md +6 -1
  2. package/dist/D1.d.mts +135 -25
  3. package/dist/D1.mjs +1 -3
  4. package/dist/D1.mjs.map +1 -1
  5. package/dist/Libsql.d.mts +192 -75
  6. package/dist/Libsql.mjs +1 -7
  7. package/dist/Libsql.mjs.map +1 -1
  8. package/dist/Mysql2.d.mts +177 -37
  9. package/dist/Mysql2.mjs +1 -3
  10. package/dist/Mysql2.mjs.map +1 -1
  11. package/dist/Pglite.d.mts +171 -30
  12. package/dist/Pglite.mjs +2 -3
  13. package/dist/Pglite.mjs.map +1 -1
  14. package/dist/Postgres.d.mts +177 -36
  15. package/dist/Postgres.mjs +2 -3
  16. package/dist/Postgres.mjs.map +1 -1
  17. package/dist/SqliteBun.d.mts +192 -74
  18. package/dist/SqliteBun.mjs +1 -5
  19. package/dist/SqliteBun.mjs.map +1 -1
  20. package/dist/SqliteDo.d.mts +194 -110
  21. package/dist/SqliteDo.mjs +2 -32
  22. package/dist/SqliteDo.mjs.map +1 -1
  23. package/dist/SqliteNode.d.mts +190 -72
  24. package/dist/SqliteNode.mjs +1 -5
  25. package/dist/SqliteNode.mjs.map +1 -1
  26. package/dist/SqliteWasm.d.mts +192 -74
  27. package/dist/SqliteWasm.mjs +1 -5
  28. package/dist/SqliteWasm.mjs.map +1 -1
  29. package/dist/drizzle/D1BatchStatements.d.mts +1 -1
  30. package/dist/drizzle/D1BatchStatements.mjs.map +1 -1
  31. package/dist/drizzle/d1-emails.mjs.map +1 -1
  32. package/dist/drizzle/d1-generated-statement.mjs.map +1 -1
  33. package/dist/drizzle/d1-identity.d.mts +1 -1
  34. package/dist/drizzle/d1-oauth.d.mts +35 -5
  35. package/dist/drizzle/d1-oauth.mjs +1 -1
  36. package/dist/drizzle/d1-password-prepared.mjs.map +1 -1
  37. package/dist/drizzle/d1-passwords.d.mts +1 -1
  38. package/dist/drizzle/d1-passwords.mjs.map +1 -1
  39. package/dist/drizzle/d1-proofs.d.mts +1 -1
  40. package/dist/drizzle/d1-proofs.mjs.map +1 -1
  41. package/dist/drizzle/d1-sessions.d.mts +3 -3
  42. package/dist/drizzle/d1-sessions.mjs.map +1 -1
  43. package/dist/drizzle/email-registration.d.mts +1 -1
  44. package/dist/drizzle/email-target.d.mts +1 -1
  45. package/dist/drizzle/email-target.mjs.map +1 -1
  46. package/dist/drizzle/model.d.mts +2 -126
  47. package/dist/drizzle/model.mjs +2 -21
  48. package/dist/drizzle/model.mjs.map +1 -1
  49. package/dist/drizzle/mysql-emails.d.mts +1 -1
  50. package/dist/drizzle/mysql-emails.mjs.map +1 -1
  51. package/dist/drizzle/mysql-identity.d.mts +1 -1
  52. package/dist/drizzle/mysql-password-prepared.d.mts +1 -1
  53. package/dist/drizzle/mysql-password-prepared.mjs.map +1 -1
  54. package/dist/drizzle/mysql-passwords.d.mts +1 -1
  55. package/dist/drizzle/mysql-passwords.mjs.map +1 -1
  56. package/dist/drizzle/mysql-proofs.d.mts +1 -1
  57. package/dist/drizzle/mysql-proofs.mjs.map +1 -1
  58. package/dist/drizzle/mysql-sessions.d.mts +1 -1
  59. package/dist/drizzle/mysql-sessions.mjs.map +1 -1
  60. package/dist/drizzle/oauth-accounts.mjs +1 -1
  61. package/dist/drizzle/oauth-connected-access.mjs +14 -12
  62. package/dist/drizzle/oauth-connected-access.mjs.map +1 -1
  63. package/dist/drizzle/oauth-connected-custody.mjs +2 -2
  64. package/dist/drizzle/oauth-connected-drivers.mjs +4 -1
  65. package/dist/drizzle/oauth-connected-drivers.mjs.map +1 -1
  66. package/dist/drizzle/oauth-connected-flow.mjs +2 -2
  67. package/dist/drizzle/oauth-connected-input.mjs +14 -1
  68. package/dist/drizzle/oauth-connected-input.mjs.map +1 -1
  69. package/dist/drizzle/oauth-connected-maintenance.mjs +1 -1
  70. package/dist/drizzle/oauth-connected-management.mjs +2 -2
  71. package/dist/drizzle/oauth-connected-model.d.mts +17 -3
  72. package/dist/drizzle/oauth-connected-model.mjs.map +1 -1
  73. package/dist/drizzle/oauth-connected-settlement.mjs +51 -41
  74. package/dist/drizzle/oauth-connected-settlement.mjs.map +1 -1
  75. package/dist/drizzle/oauth-connected-sign-in.mjs +263 -0
  76. package/dist/drizzle/oauth-connected-sign-in.mjs.map +1 -0
  77. package/dist/drizzle/oauth-connected-state.d.mts +110 -2
  78. package/dist/drizzle/oauth-connected-state.mjs +9 -4
  79. package/dist/drizzle/oauth-connected-state.mjs.map +1 -1
  80. package/dist/drizzle/oauth-connected-target.d.mts +137 -9
  81. package/dist/drizzle/oauth-connected-target.mjs +6 -2
  82. package/dist/drizzle/oauth-connected-target.mjs.map +1 -1
  83. package/dist/drizzle/oauth-drivers.mjs +1 -1
  84. package/dist/drizzle/oauth-flow.d.mts +1 -1
  85. package/dist/drizzle/oauth-flow.mjs +1 -1
  86. package/dist/drizzle/oauth-input.mjs +1 -1
  87. package/dist/drizzle/oauth-model.d.mts +1 -1
  88. package/dist/drizzle/oauth-owner.d.mts +1 -1
  89. package/dist/drizzle/oauth-registration.d.mts +2 -2
  90. package/dist/drizzle/oauth-registration.mjs +1 -1
  91. package/dist/drizzle/oauth-state.mjs +5 -4
  92. package/dist/drizzle/oauth-state.mjs.map +1 -1
  93. package/dist/drizzle/oauth-target.d.mts +2 -2
  94. package/dist/drizzle/oauth-target.mjs +1 -1
  95. package/dist/drizzle/oauth-target.mjs.map +1 -1
  96. package/dist/drizzle/passkey-write-target.d.mts +1 -1
  97. package/dist/drizzle/password-prepared-state.mjs +1 -1
  98. package/dist/drizzle/password-prepared-target.d.mts +1 -1
  99. package/dist/drizzle/password-prepared-target.mjs.map +1 -1
  100. package/dist/drizzle/password-target.d.mts +1 -1
  101. package/dist/drizzle/password-target.mjs.map +1 -1
  102. package/dist/drizzle/pg-emails.d.mts +1 -1
  103. package/dist/drizzle/pg-emails.mjs.map +1 -1
  104. package/dist/drizzle/pg-identity.d.mts +22 -0
  105. package/dist/drizzle/pg-identity.mjs +89 -0
  106. package/dist/drizzle/pg-identity.mjs.map +1 -0
  107. package/dist/drizzle/pg-password-prepared.d.mts +1 -1
  108. package/dist/drizzle/pg-password-prepared.mjs.map +1 -1
  109. package/dist/drizzle/pg-passwords.d.mts +1 -1
  110. package/dist/drizzle/pg-passwords.mjs.map +1 -1
  111. package/dist/drizzle/pg-proofs.d.mts +1 -1
  112. package/dist/drizzle/pg-proofs.mjs.map +1 -1
  113. package/dist/drizzle/pg-sessions.d.mts +1 -1
  114. package/dist/drizzle/pg-sessions.mjs.map +1 -1
  115. package/dist/drizzle/phone-model.d.mts +1 -1
  116. package/dist/drizzle/phone-target.d.mts +1 -1
  117. package/dist/drizzle/phone-target.mjs.map +1 -1
  118. package/dist/drizzle/proof-target.d.mts +1 -1
  119. package/dist/drizzle/proof-target.mjs.map +1 -1
  120. package/dist/drizzle/session-target.d.mts +1 -1
  121. package/dist/drizzle/session-target.mjs.map +1 -1
  122. package/dist/drizzle/sqlite-emails.mjs.map +1 -1
  123. package/dist/drizzle/sqlite-password-prepared.mjs.map +1 -1
  124. package/dist/drizzle/sqlite-passwords.mjs.map +1 -1
  125. package/dist/drizzle/sqlite-proofs.mjs.map +1 -1
  126. package/dist/drizzle/sqlite-sessions.mjs.map +1 -1
  127. package/dist/drizzle/standalone-guard.mjs.map +1 -1
  128. package/dist/drizzle/totp-model.d.mts +1 -1
  129. package/dist/drizzle/totp-target.d.mts +1 -1
  130. package/dist/drizzle/totp-target.mjs.map +1 -1
  131. package/dist/drizzle/transaction-mysql.mjs +1 -1
  132. package/dist/drizzle/transaction-mysql.mjs.map +1 -1
  133. package/dist/index.d.mts +2 -4
  134. package/dist/index.mjs +2 -4
  135. package/dist/internal/drizzle-postgres.mjs.map +1 -1
  136. package/dist/internal/drizzle-sqlite.mjs.map +1 -1
  137. package/package.json +1 -1
  138. package/src/D1.ts +1 -17
  139. package/src/Libsql.ts +0 -44
  140. package/src/Mysql2.ts +1 -23
  141. package/src/Pglite.ts +2 -18
  142. package/src/Postgres.ts +2 -18
  143. package/src/SqliteBun.ts +1 -38
  144. package/src/SqliteDo.ts +1 -256
  145. package/src/SqliteNode.ts +1 -38
  146. package/src/SqliteWasm.ts +1 -38
  147. package/src/drizzle/D1BatchStatements.ts +1 -1
  148. package/src/drizzle/d1-emails.ts +2 -4
  149. package/src/drizzle/d1-generated-statement.ts +1 -1
  150. package/src/drizzle/d1-password-prepared.ts +2 -5
  151. package/src/drizzle/d1-passwords.ts +2 -4
  152. package/src/drizzle/d1-proofs.ts +2 -4
  153. package/src/drizzle/d1-sessions.ts +2 -2
  154. package/src/drizzle/email-target.ts +1 -1
  155. package/src/drizzle/model.ts +1 -208
  156. package/src/drizzle/mysql-emails.ts +1 -1
  157. package/src/drizzle/mysql-password-prepared.ts +1 -1
  158. package/src/drizzle/mysql-passwords.ts +1 -1
  159. package/src/drizzle/mysql-proofs.ts +1 -1
  160. package/src/drizzle/mysql-sessions.ts +1 -1
  161. package/src/drizzle/oauth-connected-access.ts +8 -1
  162. package/src/drizzle/oauth-connected-drivers.ts +3 -0
  163. package/src/drizzle/oauth-connected-input.ts +13 -0
  164. package/src/drizzle/oauth-connected-model.ts +17 -0
  165. package/src/drizzle/oauth-connected-settlement.ts +65 -42
  166. package/src/drizzle/oauth-connected-sign-in.ts +438 -0
  167. package/src/drizzle/oauth-connected-state.ts +19 -7
  168. package/src/drizzle/oauth-connected-target.ts +10 -1
  169. package/src/drizzle/oauth-state.ts +5 -4
  170. package/src/drizzle/oauth-target.ts +1 -1
  171. package/src/drizzle/password-prepared-target.ts +1 -1
  172. package/src/drizzle/password-target.ts +1 -1
  173. package/src/drizzle/pg-emails.ts +1 -1
  174. package/src/drizzle/pg-identity.ts +301 -0
  175. package/src/drizzle/pg-password-prepared.ts +1 -1
  176. package/src/drizzle/pg-passwords.ts +1 -1
  177. package/src/drizzle/pg-proofs.ts +1 -1
  178. package/src/drizzle/pg-sessions.ts +1 -1
  179. package/src/drizzle/phone-target.ts +1 -1
  180. package/src/drizzle/proof-target.ts +1 -1
  181. package/src/drizzle/session-target.ts +1 -1
  182. package/src/drizzle/sqlite-emails.ts +1 -1
  183. package/src/drizzle/sqlite-password-prepared.ts +1 -1
  184. package/src/drizzle/sqlite-passwords.ts +1 -1
  185. package/src/drizzle/sqlite-proofs.ts +1 -1
  186. package/src/drizzle/sqlite-sessions.ts +1 -1
  187. package/src/drizzle/standalone-guard.ts +1 -1
  188. package/src/drizzle/totp-target.ts +1 -1
  189. package/src/drizzle/transaction-mysql.ts +1 -1
  190. package/src/index.ts +0 -24
  191. package/src/internal/drizzle-postgres.ts +1 -1
  192. package/src/internal/drizzle-sqlite.ts +1 -1
  193. package/dist/drizzle/mysql.d.mts +0 -69
  194. package/dist/drizzle/mysql.mjs +0 -218
  195. package/dist/drizzle/mysql.mjs.map +0 -1
  196. package/dist/drizzle/pg.d.mts +0 -80
  197. package/dist/drizzle/pg.mjs +0 -289
  198. package/dist/drizzle/pg.mjs.map +0 -1
  199. package/dist/drizzle/sqlite.d.mts +0 -77
  200. package/dist/drizzle/sqlite.mjs +0 -217
  201. package/dist/drizzle/sqlite.mjs.map +0 -1
  202. package/src/drizzle/mysql.ts +0 -687
  203. package/src/drizzle/pg.ts +0 -984
  204. package/src/drizzle/sqlite.ts +0 -705
@@ -1,13 +1,105 @@
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 * as M from "@yielded/auth/OAuth";
4
- import { OAuthConnectedPersistence, OAuthConnectedRevocationDecision, OAuthConnectedRevocations, OAuthExternalIdentity, PrepareOAuthCommit } from "@yielded/auth/OAuth";
5
3
  import { Effect, Layer, Schema } from "effect";
6
4
  import { LifecycleHooks } from "@yielded/auth/Hooks";
7
- import { Statement } from "effect/unstable/sql/Statement";
5
+ import * as M from "@yielded/auth/OAuth";
6
+ import { OAuthConnectedPersistence, OAuthConnectedRevocationDecision, OAuthConnectedRevocations, OAuthExternalIdentity, PrepareOAuthCommit } from "@yielded/auth/OAuth";
7
+ import { Statement } from "effect/sql/Statement";
8
8
  //#region src/drizzle/oauth-connected-target.d.ts
9
9
  export declare const makeTargetOAuthConnectedServices: (database: any, mapping: Mapping, configuration: OAuthTargetConfiguration) => Effect.Effect<{
10
10
  oauthConnectedPersistence: {
11
+ readonly claimSignIn: <A>(input: {
12
+ readonly claim: M.OAuthClaim;
13
+ readonly configuration: M.OAuthConnectedConfiguration;
14
+ }, prepare: PrepareOAuthCommit<M.OAuthSignInAccessClaim, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, M.OAuthUnavailable, never>;
15
+ readonly inspectSignIn: (input: {
16
+ readonly reservation: M.OAuthSignInAccessClaim;
17
+ readonly credential: M.OAuthCredentialSnapshot;
18
+ readonly grantId: string & import("effect/Brand").Brand<"effect-auth/OAuthGrantId">;
19
+ }) => Effect.Effect<M.OAuthSignInAccessInspection, M.OAuthUnavailable>;
20
+ readonly settleSignIn: <A>(input: {
21
+ readonly reservation: M.OAuthSignInAccessClaim;
22
+ readonly outcome: M.OAuthSignInAccessOutcome;
23
+ }, prepare: PrepareOAuthCommit<{
24
+ readonly _tag: "Rejected";
25
+ } | {
26
+ readonly _tag: "Cancelled";
27
+ } | {
28
+ readonly _tag: "Ambiguous";
29
+ } | {
30
+ readonly _tag: "Connected";
31
+ readonly grant: {
32
+ readonly context: {
33
+ readonly namespace: "effect-auth/oauth-connected-token-context/v1";
34
+ readonly exchangeOrder: string;
35
+ readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
36
+ readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
37
+ readonly identity: {
38
+ readonly provider: string & import("effect/Brand").Brand<"effect-auth/OAuthProviderKey">;
39
+ readonly issuer: string & import("effect/Brand").Brand<"effect-auth/OAuthIssuer">;
40
+ readonly subject: string;
41
+ };
42
+ readonly configuration: {
43
+ readonly provider: string & import("effect/Brand").Brand<"effect-auth/OAuthProviderKey">;
44
+ readonly protocol: "oauth" | "oidc";
45
+ readonly configurationGeneration: number;
46
+ readonly issuer: string & import("effect/Brand").Brand<"effect-auth/OAuthIssuer">;
47
+ readonly responseIssuerMode: "required" | "unsupported";
48
+ readonly callbackId: string & import("effect/Brand").Brand<"effect-auth/OAuthCallbackId">;
49
+ readonly redirectUri: string & import("effect/Brand").Brand<"effect-auth/OAuthRedirectUri">;
50
+ readonly profile: {
51
+ readonly key: string & import("effect/Brand").Brand<"effect-auth/OAuthPermissionProfileKey">;
52
+ readonly generation: number;
53
+ readonly issuance: "active" | "retired";
54
+ readonly provider: string & import("effect/Brand").Brand<"effect-auth/OAuthProviderKey">;
55
+ readonly clientRegistrationId: string;
56
+ readonly scopes: readonly string[];
57
+ readonly resources: readonly string[];
58
+ readonly retention: "access-and-refresh" | "access-only";
59
+ readonly maximumAccessLifetimeMillis: number;
60
+ readonly maximumRefreshLifetimeMillis?: number | undefined;
61
+ readonly refreshAheadMillis: number;
62
+ readonly refresh: "confidential" | "rotating" | "unsupported";
63
+ readonly revocation: "cohort" | "unsupported";
64
+ };
65
+ };
66
+ readonly grantId: string & import("effect/Brand").Brand<"effect-auth/OAuthGrantId">;
67
+ readonly grantVersion: string & import("effect/Brand").Brand<"effect-auth/SecurityRevision">;
68
+ readonly tokenVersion: string & import("effect/Brand").Brand<"effect-auth/SecurityRevision">;
69
+ readonly cohortGeneration: string & import("effect/Brand").Brand<"effect-auth/SecurityRevision">;
70
+ readonly metadata: {
71
+ readonly scopes: readonly string[];
72
+ readonly resources: readonly string[];
73
+ readonly accessExpiresAtMillis?: number | undefined;
74
+ readonly refreshExpiresAtMillis?: number | undefined;
75
+ readonly useUntilMillis: number;
76
+ readonly refreshUseUntilMillis?: number | undefined;
77
+ readonly obtainedAtMillis: number;
78
+ readonly profile?: {
79
+ readonly displayName?: string | undefined;
80
+ readonly handle?: string | undefined;
81
+ readonly avatarUrl?: string | undefined;
82
+ readonly profileUrl?: string | undefined;
83
+ readonly email?: string | undefined;
84
+ readonly emailVerified?: boolean | undefined;
85
+ readonly providerData?: {
86
+ readonly [x: string]: Schema.Json;
87
+ } | undefined;
88
+ } | undefined;
89
+ };
90
+ };
91
+ readonly sealed: {
92
+ readonly format: "oauth-connected-xchacha20poly1305-v1";
93
+ readonly keyId: string;
94
+ readonly nonce: string;
95
+ readonly ciphertext: import("effect/Redacted").Redacted<string>;
96
+ };
97
+ };
98
+ } | {
99
+ readonly _tag: "Conflict";
100
+ } | {
101
+ readonly _tag: "Busy";
102
+ }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, M.OAuthUnavailable, never>;
11
103
  readonly capture: (input: {
12
104
  readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
13
105
  readonly subjectId: import("@yielded/auth/Schema").SubjectId;
@@ -36,6 +128,21 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
36
128
  readonly generation: number;
37
129
  readonly flowId: string & import("effect/Brand").Brand<"effect-auth/RequestBindingFlowId">;
38
130
  readonly commandId: string & import("effect/Brand").Brand<"effect-auth/OAuthCommandId">;
131
+ readonly access?: {
132
+ readonly key: string & import("effect/Brand").Brand<"effect-auth/OAuthPermissionProfileKey">;
133
+ readonly generation: number;
134
+ readonly issuance: "active" | "retired";
135
+ readonly provider: string & import("effect/Brand").Brand<"effect-auth/OAuthProviderKey">;
136
+ readonly clientRegistrationId: string;
137
+ readonly scopes: readonly string[];
138
+ readonly resources: readonly string[];
139
+ readonly retention: "access-and-refresh" | "access-only";
140
+ readonly maximumAccessLifetimeMillis: number;
141
+ readonly maximumRefreshLifetimeMillis?: number | undefined;
142
+ readonly refreshAheadMillis: number;
143
+ readonly refresh: "confidential" | "rotating" | "unsupported";
144
+ readonly revocation: "cohort" | "unsupported";
145
+ } | undefined;
39
146
  readonly returnTarget: string & import("effect/Brand").Brand<"effect-auth/OAuthReturnTarget">;
40
147
  readonly stateDigest: string & import("effect/Brand").Brand<"effect-auth/TokenDigest">;
41
148
  readonly requestBindingVerifier: string & import("effect/Brand").Brand<"effect-auth/TokenDigest">;
@@ -138,6 +245,21 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
138
245
  readonly generation: number;
139
246
  readonly flowId: string & import("effect/Brand").Brand<"effect-auth/RequestBindingFlowId">;
140
247
  readonly commandId: string & import("effect/Brand").Brand<"effect-auth/OAuthCommandId">;
248
+ readonly access?: {
249
+ readonly key: string & import("effect/Brand").Brand<"effect-auth/OAuthPermissionProfileKey">;
250
+ readonly generation: number;
251
+ readonly issuance: "active" | "retired";
252
+ readonly provider: string & import("effect/Brand").Brand<"effect-auth/OAuthProviderKey">;
253
+ readonly clientRegistrationId: string;
254
+ readonly scopes: readonly string[];
255
+ readonly resources: readonly string[];
256
+ readonly retention: "access-and-refresh" | "access-only";
257
+ readonly maximumAccessLifetimeMillis: number;
258
+ readonly maximumRefreshLifetimeMillis?: number | undefined;
259
+ readonly refreshAheadMillis: number;
260
+ readonly refresh: "confidential" | "rotating" | "unsupported";
261
+ readonly revocation: "cohort" | "unsupported";
262
+ } | undefined;
141
263
  readonly returnTarget: string & import("effect/Brand").Brand<"effect-auth/OAuthReturnTarget">;
142
264
  readonly stateDigest: string & import("effect/Brand").Brand<"effect-auth/TokenDigest">;
143
265
  readonly requestBindingVerifier: string & import("effect/Brand").Brand<"effect-auth/TokenDigest">;
@@ -226,14 +348,14 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
226
348
  readonly identity: typeof OAuthExternalIdentity.Type;
227
349
  }) => Effect.Effect<{
228
350
  readonly _tag: "Rejected";
351
+ } | {
352
+ readonly _tag: "Conflict";
229
353
  } | {
230
354
  readonly _tag: "Target";
231
355
  readonly cohortGeneration: string & import("effect/Brand").Brand<"effect-auth/SecurityRevision">;
232
356
  } | {
233
357
  readonly _tag: "Quarantine";
234
358
  readonly cohortGeneration: string & import("effect/Brand").Brand<"effect-auth/SecurityRevision">;
235
- } | {
236
- readonly _tag: "Conflict";
237
359
  }, M.OAuthUnavailable>;
238
360
  readonly settle: <A>(input: {
239
361
  readonly claim: M.OAuthConnectedClaim;
@@ -242,17 +364,16 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
242
364
  readonly nowMillis: number;
243
365
  }, prepare: PrepareOAuthCommit<{
244
366
  readonly _tag: "Rejected";
245
- } | {
246
- readonly _tag: "Ambiguous";
247
- } | {
248
- readonly _tag: "Conflict";
249
367
  } | {
250
368
  readonly _tag: "Cancelled";
369
+ } | {
370
+ readonly _tag: "Ambiguous";
251
371
  } | {
252
372
  readonly _tag: "Connected";
253
373
  readonly grant: {
254
374
  readonly context: {
255
375
  readonly namespace: "effect-auth/oauth-connected-token-context/v1";
376
+ readonly exchangeOrder: string;
256
377
  readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
257
378
  readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
258
379
  readonly identity: {
@@ -316,6 +437,8 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
316
437
  readonly ciphertext: import("effect/Redacted").Redacted<string>;
317
438
  };
318
439
  };
440
+ } | {
441
+ readonly _tag: "Conflict";
319
442
  } | {
320
443
  readonly _tag: "Busy";
321
444
  }, A>) => Effect.Effect<import("@yielded/auth/Hooks").PreparedCommit<A>, M.OAuthUnavailable, never>;
@@ -363,6 +486,7 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
363
486
  readonly grant: {
364
487
  readonly context: {
365
488
  readonly namespace: "effect-auth/oauth-connected-token-context/v1";
489
+ readonly exchangeOrder: string;
366
490
  readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
367
491
  readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
368
492
  readonly identity: {
@@ -475,6 +599,7 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
475
599
  readonly grant: {
476
600
  readonly context: {
477
601
  readonly namespace: "effect-auth/oauth-connected-token-context/v1";
602
+ readonly exchangeOrder: string;
478
603
  readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
479
604
  readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
480
605
  readonly identity: {
@@ -559,6 +684,7 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
559
684
  readonly grant: {
560
685
  readonly context: {
561
686
  readonly namespace: "effect-auth/oauth-connected-token-context/v1";
687
+ readonly exchangeOrder: string;
562
688
  readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
563
689
  readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
564
690
  readonly identity: {
@@ -622,6 +748,7 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
622
748
  readonly ciphertext: import("effect/Redacted").Redacted<string>;
623
749
  };
624
750
  };
751
+ readonly order: string;
625
752
  readonly claimId: string & import("effect/Brand").Brand<"effect-auth/OAuthClaimId">;
626
753
  readonly claimedAtMillis: number;
627
754
  readonly claimExpiresAtMillis: number;
@@ -641,6 +768,7 @@ export declare const makeTargetOAuthConnectedServices: (database: any, mapping:
641
768
  readonly grant: {
642
769
  readonly context: {
643
770
  readonly namespace: "effect-auth/oauth-connected-token-context/v1";
771
+ readonly exchangeOrder: string;
644
772
  readonly moduleId: string & import("effect/Brand").Brand<"effect-auth/OAuthModuleId">;
645
773
  readonly subjectId: string & import("effect/Brand").Brand<"effect-auth/SubjectId">;
646
774
  readonly identity: {
@@ -9,10 +9,11 @@ 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 * as M from "@yielded/auth/OAuth";
13
- import { OAuthConnectedPersistence, OAuthConnectedRevocationDecision, OAuthConnectedRevocations, OAuthExternalIdentity, snapshotOAuthSync } from "@yielded/auth/OAuth";
12
+ import { claimSignIn, inspectSignIn, settleSignIn } from "./oauth-connected-sign-in.mjs";
14
13
  import { Effect, Layer, Schema } from "effect";
15
14
  import { LifecycleHooks } from "@yielded/auth/Hooks";
15
+ import * as M from "@yielded/auth/OAuth";
16
+ import { OAuthConnectedPersistence, OAuthConnectedRevocationDecision, OAuthConnectedRevocations, OAuthExternalIdentity, snapshotOAuthSync } from "@yielded/auth/OAuth";
16
17
  //#region src/drizzle/oauth-connected-target.ts
17
18
  const captured = (mapping) => {
18
19
  const retained = captureOAuthMapping(mapping), codec = retained.subjectId;
@@ -53,6 +54,9 @@ const prepare = (schema, value, callback) => Effect.flatMap(CurrentOAuthTransact
53
54
  const mutation = (mapping, execute, body, schema) => (input, callback) => execute.run(Effect.flatMap(body(mapping, input), (value) => prepare(schema, value, callback)));
54
55
  const read = (mapping, execute, body) => (input) => execute.run(body(mapping, input), false);
55
56
  const makeConnected = (mapping, execute) => capturedOAuthService({
57
+ claimSignIn: mutation(mapping, execute, claimSignIn, M.OAuthSignInAccessClaim),
58
+ inspectSignIn: read(mapping, execute, inspectSignIn),
59
+ settleSignIn: mutation(mapping, execute, settleSignIn, M.OAuthConnectedSettlementDecision),
56
60
  capture: read(mapping, execute, capture),
57
61
  issue: mutation(mapping, execute, issue, M.OAuthConnectedIssueDecision),
58
62
  preflight: read(mapping, execute, preflight),
@@ -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,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,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,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 { 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/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 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":";;;;;;;;;;;;;;;;;AAiCA,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,GAAG;IACH,UAAU;KACR,GAAG,UAAU;KACb,eAAe,UACb,OAAO;MACL,GAAG;MACH,UAAU,kBAAkB,uBAAuB,MAAM,QAAQ;MACjE,WAAWA,WAAa,MAAM,SAAS;KACzC,CAAC;IACL;GACF;EACF,C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,CACjE;AAEF,MAAa,kCACX,aAEA,MAAM,OACJ,2BACA,OAAO,IAAI,WAAW,UAAU,MAAM,yBAAyB,CACjE"}
@@ -1,7 +1,7 @@
1
1
  import { coordinateTargetOAuthAccounts, coordinateTargetOAuthRegistration, coordinateTargetOAuthRegistrationIntents, coordinateTargetOAuthSignIn, makeTargetOAuthAccountsServices, makeTargetOAuthRegistrationIntentServices, makeTargetOAuthRegistrationServices, makeTargetOAuthSignInServices } from "./oauth-target.mjs";
2
2
  import { makeOAuthConnectedTarget } from "./oauth-connected-drivers.mjs";
3
- import { OAuthAccountsPersistence, OAuthRegistrationIntents, OAuthSignInPersistence } from "@yielded/auth/OAuth";
4
3
  import { Context, Effect } from "effect";
4
+ import { OAuthAccountsPersistence, OAuthRegistrationIntents, OAuthSignInPersistence } from "@yielded/auth/OAuth";
5
5
  //#region src/drizzle/oauth-drivers.ts
6
6
  /** Driver-specific entry points instantiate both the database and table family. */
7
7
  const makeOAuthTarget = (configuration) => {
@@ -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 { OAuthExternalIdentity, OAuthRegistrationAccess, OAuthRegistrationIntent } from "@yielded/auth/OAuth";
5
- import { Effect, Schema } from "effect";
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 = () => Encoding.encodeBase64Url(randomBytes(32));
13
- const digest = (value) => Encoding.encodeBase64Url(sha256(encoder.encode(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:" + Encoding.encodeBase64Url(sha256(packed));
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. */
@@ -1 +1 @@
1
- {"version":3,"file":"oauth-state.mjs","names":[],"sources":["../../src/drizzle/oauth-state.ts"],"sourcesContent":["// oxlint-disable-next-line import/extensions -- Noble exposes only its explicit .js subpath.\nimport { sha256 } from \"@noble/hashes/sha2.js\";\n// oxlint-disable-next-line import/extensions -- Noble exposes only its explicit .js subpath.\nimport { randomBytes } from \"@noble/hashes/utils.js\";\nimport {\n type OAuthActionAuthorization,\n type OAuthAccountRevision,\n OAuthUnavailable,\n OAuthExternalIdentity,\n snapshotOAuthSync,\n} from \"@yielded/auth/OAuth\";\nimport type { AuthenticationRequirement } from \"@yielded/auth/Sessions\";\nimport { DateTime, Effect, Encoding, Schema } from \"effect\";\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder(\"utf-8\", { fatal: true });\n\nexport const unavailable = () => OAuthUnavailable.make({});\n\nexport const invariant: (value: unknown) => asserts value = (value) => {\n if (!value) throw unavailable();\n};\n\nexport const nonce = () => Encoding.encodeBase64Url(randomBytes(32));\nexport const digest = (value: string) => Encoding.encodeBase64Url(sha256(encoder.encode(value)));\n\n/** Capture configuration/callback references while preserving Drizzle table, SQL\n * and Effect objects. Never freeze or mutate the consumer's original graph. */\nexport const captureOAuthMapping = <A>(input: A): A => {\n const seen = new Map<object, unknown>();\n\n const copy = (value: unknown): unknown => {\n if (value === null || typeof value !== \"object\" || Effect.isEffect(value)) return value;\n if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype) return value;\n const prior = seen.get(value);\n\n if (prior !== undefined) return prior;\n if (Array.isArray(value)) {\n const result: unknown[] = [];\n\n seen.set(value, result);\n result.push(...value.map(copy));\n\n return Object.freeze(result);\n }\n const result: Record<string, unknown> = {};\n\n seen.set(value, result);\n for (const [key, child] of Object.entries(value)) result[key] = copy(child);\n\n return Object.freeze(result);\n };\n\n return copy(input) as A;\n};\n\n/** Versioned length-delimited UTF-8 tuple; the module is deliberately excluded.\n * Reject ill-formed UTF-16 rather than letting UTF-8 replacement alias identities. */\nexport const oauthIdentityKey = (input: typeof OAuthExternalIdentity.Type): string => {\n const identity = snapshotOAuthSync(OAuthExternalIdentity, input);\n\n const fields = [\n \"effect-auth/oauth-identity-key/v1\",\n identity.provider,\n identity.issuer,\n identity.subject,\n ];\n\n const bytes = fields.map((field) => {\n const value = encoder.encode(field);\n\n invariant(decoder.decode(value) === field);\n\n return value;\n });\n\n const packed = new Uint8Array(bytes.reduce((size, value) => size + 4 + value.length, 0));\n const view = new DataView(packed.buffer);\n let offset = 0;\n\n for (const value of bytes) {\n view.setUint32(offset, value.length, false);\n packed.set(value, offset + 4);\n offset += 4 + value.length;\n }\n\n return \"v1:\" + Encoding.encodeBase64Url(sha256(packed));\n};\n\nexport const sameIdentity = (\n left: typeof OAuthExternalIdentity.Type,\n right: typeof OAuthExternalIdentity.Type,\n) =>\n left.provider === right.provider &&\n left.issuer === right.issuer &&\n left.subject === right.subject;\n\n/** Private Type storage: opaque wrappers and DateTimes are freshly reconstructed. */\nexport const storage = <S extends Schema.Codec<unknown, unknown, never, never>>(schema: S) => {\n const codec = Schema.fromJsonString(Schema.toCodecJson(Schema.toType(schema)));\n const encode = Schema.encodeSync(codec);\n const decode = Schema.decodeSync(codec);\n\n return {\n encode: (value: S[\"Type\"]) => encode(snapshotOAuthSync(schema, value)),\n decode: (value: string) => snapshotOAuthSync(schema, decode(value)),\n };\n};\n\nexport const sameRevision = (left: OAuthAccountRevision, right: OAuthAccountRevision) => {\n if (\n left.subjectId !== right.subjectId ||\n left.securityRevision !== right.securityRevision ||\n left.credentials.length !== right.credentials.length\n )\n return false;\n const revisions = new Map(left.credentials.map((item) => [item.credentialId, item.revision]));\n\n return (\n revisions.size === left.credentials.length &&\n new Set(right.credentials.map((item) => item.credentialId)).size === right.credentials.length &&\n right.credentials.every((item) => revisions.get(item.credentialId) === item.revision)\n );\n};\n\nexport const satisfies = (\n proofs: ReadonlyArray<{\n readonly credentialId: string;\n readonly factors: ReadonlyArray<string>;\n readonly userVerified: boolean;\n readonly phishingResistant: boolean;\n }>,\n requirement: AuthenticationRequirement,\n) => {\n const factors = new Set(proofs.flatMap((proof) => [...proof.factors]));\n const count = new Set(proofs.map((proof) => proof.credentialId)).size;\n\n return requirement.alternatives.some(\n (alternative) =>\n alternative.factors.every((factor) => factors.has(factor)) &&\n count >= alternative.minimumCredentials &&\n proofs.some(\n (proof) =>\n (!alternative.userVerified || proof.userVerified) &&\n (!alternative.phishingResistant || proof.phishingResistant),\n ),\n );\n};\n\nexport const validAction = (\n authorization: OAuthActionAuthorization,\n expected: {\n readonly moduleId: string;\n readonly action: OAuthActionAuthorization[\"challenge\"][\"action\"];\n readonly flowId: string;\n readonly commandId: string;\n readonly revision: OAuthAccountRevision;\n readonly intent: string;\n },\n currentRequirement: AuthenticationRequirement,\n now: number,\n maximumAgeMillis: number,\n) => {\n const challenge = authorization.challenge;\n const evidence = authorization.evidence;\n const intentDigest = digest(expected.intent);\n\n const binding = digest(\n // oxlint-disable-next-line no-restricted-properties -- Fixed private action fingerprint format shared with the core verifier.\n JSON.stringify([\n \"effect-auth/oauth-action/v1\",\n expected.moduleId,\n expected.action,\n expected.flowId,\n expected.commandId,\n intentDigest,\n ]),\n );\n\n if (\n challenge.moduleId !== expected.moduleId ||\n challenge.action !== expected.action ||\n challenge.flowId !== expected.flowId ||\n challenge.commandId !== expected.commandId ||\n challenge.intentDigest !== intentDigest ||\n challenge.bindingDigest !== binding ||\n evidence.flowId !== expected.flowId ||\n evidence.bindingDigest !== binding ||\n !sameRevision(challenge.revision, expected.revision) ||\n !sameRevision(evidence.revision, expected.revision)\n )\n return false;\n\n const revisions = new Map(\n expected.revision.credentials.map((item) => [item.credentialId, item.revision]),\n );\n\n if (\n evidence.proofs.some(\n (proof) =>\n !revisions.has(proof.credentialId) || DateTime.toEpochMillis(proof.verifiedAt) > now,\n )\n )\n return false;\n\n return [authorization.requirement, currentRequirement].every((requirement) => {\n const fresh = evidence.proofs.filter((proof) => {\n const age = now - DateTime.toEpochMillis(proof.verifiedAt);\n\n return age >= 0 && age < Math.min(maximumAgeMillis, requirement.maximumAgeMillis);\n });\n\n return satisfies(fresh, requirement);\n });\n};\n"],"mappings":";;;;;AAcA,MAAM,UAAU,IAAI,YAAY;AAChC,MAAM,UAAU,IAAI,YAAY,SAAS,EAAE,OAAO,KAAK,CAAC;AAExD,MAAa,oBAAoB,iBAAiB,KAAK,CAAC,CAAC;AAEzD,MAAa,aAAgD,UAAU;CACrE,IAAI,CAAC,OAAO,MAAM,YAAY;AAChC;AAEA,MAAa,cAAc,SAAS,gBAAgB,YAAY,EAAE,CAAC;AACnE,MAAa,UAAU,UAAkB,SAAS,gBAAgB,OAAO,QAAQ,OAAO,KAAK,CAAC,CAAC;;;AAI/F,MAAa,uBAA0B,UAAgB;CACrD,MAAM,uBAAO,IAAI,IAAqB;CAEtC,MAAM,QAAQ,UAA4B;EACxC,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,GAAG,OAAO;EAClF,IAAI,CAAC,MAAM,QAAQ,KAAK,KAAK,OAAO,eAAe,KAAK,MAAM,OAAO,WAAW,OAAO;EACvF,MAAM,QAAQ,KAAK,IAAI,KAAK;EAE5B,IAAI,UAAU,KAAA,GAAW,OAAO;EAChC,IAAI,MAAM,QAAQ,KAAK,GAAG;GACxB,MAAM,SAAoB,CAAC;GAE3B,KAAK,IAAI,OAAO,MAAM;GACtB,OAAO,KAAK,GAAG,MAAM,IAAI,IAAI,CAAC;GAE9B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gBAC3B,UAAU,kBAAkB,WAC5B,SAAS,WAAW,SAAS,UAC7B,SAAS,kBAAkB,WAC3B,CAAC,aAAa,UAAU,UAAU,SAAS,QAAQ,KACnD,CAAC,aAAa,SAAS,UAAU,SAAS,QAAQ,GAElD,OAAO;CAET,MAAM,YAAY,IAAI,IACpB,SAAS,SAAS,YAAY,KAAK,SAAS,CAAC,KAAK,cAAc,KAAK,QAAQ,CAAC,CAChF;CAEA,IACE,SAAS,OAAO,MACb,UACC,CAAC,UAAU,IAAI,MAAM,YAAY,KAAK,SAAS,cAAc,MAAM,UAAU,IAAI,GACrF,GAEA,OAAO;CAET,OAAO,CAAC,cAAc,aAAa,kBAAkB,CAAC,CAAC,OAAO,gBAAgB;EAC5E,MAAM,QAAQ,SAAS,OAAO,QAAQ,UAAU;GAC9C,MAAM,MAAM,MAAM,SAAS,cAAc,MAAM,UAAU;GAEzD,OAAO,OAAO,KAAK,MAAM,KAAK,IAAI,kBAAkB,YAAY,gBAAgB;EAClF,CAAC;EAED,OAAO,UAAU,OAAO,WAAW;CACrC,CAAC;AACH"}
1
+ {"version":3,"file":"oauth-state.mjs","names":[],"sources":["../../src/drizzle/oauth-state.ts"],"sourcesContent":["// oxlint-disable-next-line import/extensions -- Noble exposes only its explicit .js subpath.\nimport { sha256 } from \"@noble/hashes/sha2.js\";\n// oxlint-disable-next-line import/extensions -- Noble exposes only its explicit .js subpath.\nimport { randomBytes } from \"@noble/hashes/utils.js\";\nimport {\n type OAuthActionAuthorization,\n type OAuthAccountRevision,\n OAuthUnavailable,\n OAuthExternalIdentity,\n snapshotOAuthSync,\n} from \"@yielded/auth/OAuth\";\nimport type { AuthenticationRequirement } from \"@yielded/auth/Sessions\";\nimport { DateTime, Effect, Schema } from \"effect\";\nimport { Base64Url } from \"effect/encoding\";\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder(\"utf-8\", { fatal: true });\n\nexport const unavailable = () => OAuthUnavailable.make({});\n\nexport const invariant: (value: unknown) => asserts value = (value) => {\n if (!value) throw unavailable();\n};\n\nexport const nonce = () => Base64Url.encode(randomBytes(32));\nexport const digest = (value: string) => Base64Url.encode(sha256(encoder.encode(value)));\n\n/** Capture configuration/callback references while preserving Drizzle table, SQL\n * and Effect objects. Never freeze or mutate the consumer's original graph. */\nexport const captureOAuthMapping = <A>(input: A): A => {\n const seen = new Map<object, unknown>();\n\n const copy = (value: unknown): unknown => {\n if (value === null || typeof value !== \"object\" || Effect.isEffect(value)) return value;\n if (!Array.isArray(value) && Object.getPrototypeOf(value) !== Object.prototype) return value;\n const prior = seen.get(value);\n\n if (prior !== undefined) return prior;\n if (Array.isArray(value)) {\n const result: unknown[] = [];\n\n seen.set(value, result);\n result.push(...value.map(copy));\n\n return Object.freeze(result);\n }\n const result: Record<string, unknown> = {};\n\n seen.set(value, result);\n for (const [key, child] of Object.entries(value)) result[key] = copy(child);\n\n return Object.freeze(result);\n };\n\n return copy(input) as A;\n};\n\n/** Versioned length-delimited UTF-8 tuple; the module is deliberately excluded.\n * Reject ill-formed UTF-16 rather than letting UTF-8 replacement alias identities. */\nexport const oauthIdentityKey = (input: typeof OAuthExternalIdentity.Type): string => {\n const identity = snapshotOAuthSync(OAuthExternalIdentity, input);\n\n const fields = [\n \"effect-auth/oauth-identity-key/v1\",\n identity.provider,\n identity.issuer,\n identity.subject,\n ];\n\n const bytes = fields.map((field) => {\n const value = encoder.encode(field);\n\n invariant(decoder.decode(value) === field);\n\n return value;\n });\n\n const packed = new Uint8Array(bytes.reduce((size, value) => size + 4 + value.length, 0));\n const view = new DataView(packed.buffer);\n let offset = 0;\n\n for (const value of bytes) {\n view.setUint32(offset, value.length, false);\n packed.set(value, offset + 4);\n offset += 4 + value.length;\n }\n\n return \"v1:\" + Base64Url.encode(sha256(packed));\n};\n\nexport const sameIdentity = (\n left: typeof OAuthExternalIdentity.Type,\n right: typeof OAuthExternalIdentity.Type,\n) =>\n left.provider === right.provider &&\n left.issuer === right.issuer &&\n left.subject === right.subject;\n\n/** Private Type storage: opaque wrappers and DateTimes are freshly reconstructed. */\nexport const storage = <S extends Schema.Codec<unknown, unknown, never, never>>(schema: S) => {\n const codec = Schema.fromJsonString(Schema.toCodecJson(Schema.toType(schema)));\n const encode = Schema.encodeSync(codec);\n const decode = Schema.decodeSync(codec);\n\n return {\n encode: (value: S[\"Type\"]) => encode(snapshotOAuthSync(schema, value)),\n decode: (value: string) => snapshotOAuthSync(schema, decode(value)),\n };\n};\n\nexport const sameRevision = (left: OAuthAccountRevision, right: OAuthAccountRevision) => {\n if (\n left.subjectId !== right.subjectId ||\n left.securityRevision !== right.securityRevision ||\n left.credentials.length !== right.credentials.length\n )\n return false;\n const revisions = new Map(left.credentials.map((item) => [item.credentialId, item.revision]));\n\n return (\n revisions.size === left.credentials.length &&\n new Set(right.credentials.map((item) => item.credentialId)).size === right.credentials.length &&\n right.credentials.every((item) => revisions.get(item.credentialId) === item.revision)\n );\n};\n\nexport const satisfies = (\n proofs: ReadonlyArray<{\n readonly credentialId: string;\n readonly factors: ReadonlyArray<string>;\n readonly userVerified: boolean;\n readonly phishingResistant: boolean;\n }>,\n requirement: AuthenticationRequirement,\n) => {\n const factors = new Set(proofs.flatMap((proof) => [...proof.factors]));\n const count = new Set(proofs.map((proof) => proof.credentialId)).size;\n\n return requirement.alternatives.some(\n (alternative) =>\n alternative.factors.every((factor) => factors.has(factor)) &&\n count >= alternative.minimumCredentials &&\n proofs.some(\n (proof) =>\n (!alternative.userVerified || proof.userVerified) &&\n (!alternative.phishingResistant || proof.phishingResistant),\n ),\n );\n};\n\nexport const validAction = (\n authorization: OAuthActionAuthorization,\n expected: {\n readonly moduleId: string;\n readonly action: OAuthActionAuthorization[\"challenge\"][\"action\"];\n readonly flowId: string;\n readonly commandId: string;\n readonly revision: OAuthAccountRevision;\n readonly intent: string;\n },\n currentRequirement: AuthenticationRequirement,\n now: number,\n maximumAgeMillis: number,\n) => {\n const challenge = authorization.challenge;\n const evidence = authorization.evidence;\n const intentDigest = digest(expected.intent);\n\n const binding = digest(\n // oxlint-disable-next-line no-restricted-properties -- Fixed private action fingerprint format shared with the core verifier.\n JSON.stringify([\n \"effect-auth/oauth-action/v1\",\n expected.moduleId,\n expected.action,\n expected.flowId,\n expected.commandId,\n intentDigest,\n ]),\n );\n\n if (\n challenge.moduleId !== expected.moduleId ||\n challenge.action !== expected.action ||\n challenge.flowId !== expected.flowId ||\n challenge.commandId !== expected.commandId ||\n challenge.intentDigest !== intentDigest ||\n challenge.bindingDigest !== binding ||\n evidence.flowId !== expected.flowId ||\n evidence.bindingDigest !== binding ||\n !sameRevision(challenge.revision, expected.revision) ||\n !sameRevision(evidence.revision, expected.revision)\n )\n return false;\n\n const revisions = new Map(\n expected.revision.credentials.map((item) => [item.credentialId, item.revision]),\n );\n\n if (\n evidence.proofs.some(\n (proof) =>\n !revisions.has(proof.credentialId) || DateTime.toEpochMillis(proof.verifiedAt) > now,\n )\n )\n return false;\n\n return [authorization.requirement, currentRequirement].every((requirement) => {\n const fresh = evidence.proofs.filter((proof) => {\n const age = now - DateTime.toEpochMillis(proof.verifiedAt);\n\n return age >= 0 && age < Math.min(maximumAgeMillis, requirement.maximumAgeMillis);\n });\n\n return satisfies(fresh, requirement);\n });\n};\n"],"mappings":";;;;;;AAeA,MAAM,UAAU,IAAI,YAAY;AAChC,MAAM,UAAU,IAAI,YAAY,SAAS,EAAE,OAAO,KAAK,CAAC;AAExD,MAAa,oBAAoB,iBAAiB,KAAK,CAAC,CAAC;AAEzD,MAAa,aAAgD,UAAU;CACrE,IAAI,CAAC,OAAO,MAAM,YAAY;AAChC;AAEA,MAAa,cAAc,UAAU,OAAO,YAAY,EAAE,CAAC;AAC3D,MAAa,UAAU,UAAkB,UAAU,OAAO,OAAO,QAAQ,OAAO,KAAK,CAAC,CAAC;;;AAIvF,MAAa,uBAA0B,UAAgB;CACrD,MAAM,uBAAO,IAAI,IAAqB;CAEtC,MAAM,QAAQ,UAA4B;EACxC,IAAI,UAAU,QAAQ,OAAO,UAAU,YA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A,UAQA,oBACA,KACA,qBACG;CACH,MAAM,YAAY,cAAc;CAChC,MAAM,WAAW,cAAc;CAC/B,MAAM,eAAe,OAAO,SAAS,MAAM;CAE3C,MAAM,UAAU,OAEd,KAAK,UAAU;EACb;EACA,SAAS;EACT,SAAS;EACT,SAAS;EACT,SAAS;EACT;CACF,CAAC,CACH;CAEA,IACE,UAAU,aAAa,SAAS,YAChC,UAAU,WAAW,SAAS,UAC9B,UAAU,WAAW,SAAS,UAC9B,UAAU,cAAc,SAAS,aACjC,UAAU,iBAAiB,gBAC3B,UAAU,kBAAkB,WAC5B,SAAS,WAAW,SAAS,UAC7B,SAAS,kBAAkB,WAC3B,CAAC,aAAa,UAAU,UAAU,SAAS,QAAQ,KACnD,CAAC,aAAa,SAAS,UAAU,SAAS,QAAQ,GAElD,OAAO;CAET,MAAM,YAAY,IAAI,IACpB,SAAS,SAAS,YAAY,KAAK,SAAS,CAAC,KAAK,cAAc,KAAK,QAAQ,CAAC,CAChF;CAEA,IACE,SAAS,OAAO,MACb,UACC,CAAC,UAAU,IAAI,MAAM,YAAY,KAAK,SAAS,cAAc,MAAM,UAAU,IAAI,GACrF,GAEA,OAAO;CAET,OAAO,CAAC,cAAc,aAAa,kBAAkB,CAAC,CAAC,OAAO,gBAAgB;EAC5E,MAAM,QAAQ,SAAS,OAAO,QAAQ,UAAU;GAC9C,MAAM,MAAM,MAAM,SAAS,cAAc,MAAM,UAAU;GAEzD,OAAO,OAAO,KAAK,MAAM,KAAK,IAAI,kBAAkB,YAAY,gBAAgB;EAClF,CAAC;EAED,OAAO,UAAU,OAAO,WAAW;CACrC,CAAC;AACH"}
@@ -3,10 +3,10 @@ import { OAuthRegistrationAuthority } from "./oauth-model.mjs";
3
3
  import "./oauth-owner.mjs";
4
4
  import "./oauth-registration.mjs";
5
5
  import { TransactionCoordinatorError, TransactionTargetConfiguration } from "./transaction-execution.mjs";
6
- import { OAuthAccountRevision, OAuthAccountsPersistence, OAuthClaim, OAuthClaimDecision, OAuthCleanupInput, OAuthCredentialSnapshot, OAuthIssueDecision, OAuthLinkClaimDecision, OAuthLinkDecision, OAuthLinkIssueDecision, OAuthLinkPendingFlow, OAuthPendingFlow, OAuthRegistrationIntent, OAuthRegistrationIntents, OAuthSettlementDecision, OAuthSignInPersistence, OAuthUnavailable, OAuthUnlinkDecision, OAuthUnlinkInspection, OAuthVerifiedExternalIdentity, PrepareOAuthCommit } from "@yielded/auth/OAuth";
7
6
  import { Context, Effect, Layer } from "effect";
8
7
  import { LifecycleHooks } from "@yielded/auth/Hooks";
9
- import { Statement } from "effect/unstable/sql/Statement";
8
+ import { OAuthAccountRevision, OAuthAccountsPersistence, OAuthClaim, OAuthClaimDecision, OAuthCleanupInput, OAuthCredentialSnapshot, OAuthIssueDecision, OAuthLinkClaimDecision, OAuthLinkDecision, OAuthLinkIssueDecision, OAuthLinkPendingFlow, OAuthPendingFlow, OAuthRegistrationIntent, OAuthRegistrationIntents, OAuthSettlementDecision, OAuthSignInPersistence, OAuthUnavailable, OAuthUnlinkDecision, OAuthUnlinkInspection, OAuthVerifiedExternalIdentity, PrepareOAuthCommit } from "@yielded/auth/OAuth";
9
+ import { Statement } from "effect/sql/Statement";
10
10
  //#region src/drizzle/oauth-target.d.ts
11
11
  export type OAuthTargetConfiguration = TransactionTargetConfiguration<OAuthUnavailable>;
12
12
  export type OAuthCoordinatorError<E> = TransactionCoordinatorError<E, OAuthUnavailable>;
@@ -6,10 +6,10 @@ import { inspectIntent, register, registrationData, registrationResources, settl
6
6
  import { accountCurrent, claimLink, inspectUnlink, issueLink, preflightLink, settleLink, unlink } from "./oauth-accounts.mjs";
7
7
  import { accountsInputs, capturedOAuthService, registrationInputs, registrationIntentInputs, signInInputs } from "./oauth-input.mjs";
8
8
  import { coordinateTransactionOwner, makeTransactionExecution, sqlClientTransactionStandaloneGuard } from "./transaction-execution.mjs";
9
- import { OAuthAccountRevision, OAuthAccountsPersistence, OAuthClaim, OAuthClaimDecision, OAuthCleanupInput, OAuthCredentialSnapshot, OAuthIssueDecision, OAuthLinkClaimDecision, OAuthLinkDecision, OAuthLinkIssueDecision, OAuthLinkPendingFlow, OAuthPendingFlow, OAuthRegistrationFingerprint, OAuthRegistrationIntent, OAuthRegistrationIntents, OAuthSettlementDecision, OAuthSignInPersistence, OAuthUnlinkDecision, OAuthUnlinkInspection, OAuthVerifiedExternalIdentity, snapshotOAuthSync } from "@yielded/auth/OAuth";
10
9
  import { eq, sql } from "drizzle-orm";
11
10
  import { Effect, Layer } from "effect";
12
11
  import { LifecycleHooks } from "@yielded/auth/Hooks";
12
+ import { OAuthAccountRevision, OAuthAccountsPersistence, OAuthClaim, OAuthClaimDecision, OAuthCleanupInput, OAuthCredentialSnapshot, OAuthIssueDecision, OAuthLinkClaimDecision, OAuthLinkDecision, OAuthLinkIssueDecision, OAuthLinkPendingFlow, OAuthPendingFlow, OAuthRegistrationFingerprint, OAuthRegistrationIntent, OAuthRegistrationIntents, OAuthSettlementDecision, OAuthSignInPersistence, OAuthUnlinkDecision, OAuthUnlinkInspection, OAuthVerifiedExternalIdentity, snapshotOAuthSync } from "@yielded/auth/OAuth";
13
13
  //#region src/drizzle/oauth-target.ts
14
14
  const sqlClientOAuthStandaloneGuard = (database) => sqlClientTransactionStandaloneGuard(unavailable, database);
15
15
  const makeOAuthExecution = (database, hooks, configuration) => {