@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
package/src/SqliteNode.ts CHANGED
@@ -3,30 +3,12 @@ import { type EffectSQLiteNodeDatabase, makeWithDefaults } from "drizzle-orm/eff
3
3
  import type { AnySQLiteTable } from "drizzle-orm/sqlite-core";
4
4
  import { Effect } from "effect";
5
5
 
6
+ import { sqlClientEmailStandaloneGuard } from "./drizzle/email-target";
6
7
  import type {
7
- AuthStoreTables,
8
- AuthTables,
9
8
  ExternalIdentityTables,
10
9
  IdentityTables,
11
- OAuthStateTables,
12
10
  SubjectProvisioningTables,
13
11
  } from "./drizzle/model";
14
- import {
15
- coordinateSqliteAuthStoreTransaction,
16
- coordinateSqliteAuthTransaction,
17
- coordinateSqliteOAuthStateTransaction,
18
- makeSqliteAuthServices,
19
- makeSqliteAuthStoreServices,
20
- makeSqliteOAuthStateServices,
21
- } from "./drizzle/sqlite";
22
-
23
- export {
24
- coordinateSqliteAuthStoreTransaction as coordinateAuthStoreTransaction,
25
- coordinateSqliteAuthTransaction as coordinateAuthTransaction,
26
- coordinateSqliteOAuthStateTransaction as coordinateOAuthStateTransaction,
27
- };
28
-
29
- import { sqlClientEmailStandaloneGuard } from "./drizzle/email-target";
30
12
  import { sqlClientPasswordStandaloneGuard } from "./drizzle/password-target";
31
13
  import { sqlClientProofStandaloneGuard } from "./drizzle/proof-target";
32
14
  import { sqlClientSessionStandaloneGuard } from "./drizzle/session-target";
@@ -97,25 +79,6 @@ export const {
97
79
 
98
80
  export const commitMode = "interactive" as const;
99
81
 
100
- export const makeAuthStoreServices = <C extends AnySQLiteTable, R extends AnySQLiteTable>(
101
- database: EffectSQLiteNodeDatabase<AnyRelations>,
102
- mapping: AuthStoreTables<C, R>,
103
- ) => makeSqliteAuthStoreServices(database, mapping);
104
-
105
- export const makeOAuthStateServices = <S extends AnySQLiteTable>(
106
- database: EffectSQLiteNodeDatabase<AnyRelations>,
107
- mapping: OAuthStateTables<S>,
108
- ) => makeSqliteOAuthStateServices(database, mapping);
109
-
110
- export const makeAuthServices = <
111
- C extends AnySQLiteTable,
112
- R extends AnySQLiteTable,
113
- S extends AnySQLiteTable,
114
- >(
115
- database: EffectSQLiteNodeDatabase<AnyRelations>,
116
- mapping: AuthTables<C, R, S>,
117
- ) => makeSqliteAuthServices(database, mapping);
118
-
119
82
  export const makeIdentityServices = <
120
83
  Subject extends AnySQLiteTable,
121
84
  Identifier extends AnySQLiteTable,
package/src/SqliteWasm.ts CHANGED
@@ -3,30 +3,12 @@ import { type EffectSQLiteWasmDatabase, makeWithDefaults } from "drizzle-orm/eff
3
3
  import type { AnySQLiteTable } from "drizzle-orm/sqlite-core";
4
4
  import { Effect } from "effect";
5
5
 
6
+ import { sqlClientEmailStandaloneGuard } from "./drizzle/email-target";
6
7
  import type {
7
- AuthStoreTables,
8
- AuthTables,
9
8
  ExternalIdentityTables,
10
9
  IdentityTables,
11
- OAuthStateTables,
12
10
  SubjectProvisioningTables,
13
11
  } from "./drizzle/model";
14
- import {
15
- coordinateSqliteAuthStoreTransaction,
16
- coordinateSqliteAuthTransaction,
17
- coordinateSqliteOAuthStateTransaction,
18
- makeSqliteAuthServices,
19
- makeSqliteAuthStoreServices,
20
- makeSqliteOAuthStateServices,
21
- } from "./drizzle/sqlite";
22
-
23
- export {
24
- coordinateSqliteAuthStoreTransaction as coordinateAuthStoreTransaction,
25
- coordinateSqliteAuthTransaction as coordinateAuthTransaction,
26
- coordinateSqliteOAuthStateTransaction as coordinateOAuthStateTransaction,
27
- };
28
-
29
- import { sqlClientEmailStandaloneGuard } from "./drizzle/email-target";
30
12
  import { sqlClientPasswordStandaloneGuard } from "./drizzle/password-target";
31
13
  import { sqlClientProofStandaloneGuard } from "./drizzle/proof-target";
32
14
  import { sqlClientSessionStandaloneGuard } from "./drizzle/session-target";
@@ -97,25 +79,6 @@ export const {
97
79
 
98
80
  export const commitMode = "interactive" as const;
99
81
 
100
- export const makeAuthStoreServices = <C extends AnySQLiteTable, R extends AnySQLiteTable>(
101
- database: EffectSQLiteWasmDatabase<AnyRelations>,
102
- mapping: AuthStoreTables<C, R>,
103
- ) => makeSqliteAuthStoreServices(database, mapping);
104
-
105
- export const makeOAuthStateServices = <S extends AnySQLiteTable>(
106
- database: EffectSQLiteWasmDatabase<AnyRelations>,
107
- mapping: OAuthStateTables<S>,
108
- ) => makeSqliteOAuthStateServices(database, mapping);
109
-
110
- export const makeAuthServices = <
111
- C extends AnySQLiteTable,
112
- R extends AnySQLiteTable,
113
- S extends AnySQLiteTable,
114
- >(
115
- database: EffectSQLiteWasmDatabase<AnyRelations>,
116
- mapping: AuthTables<C, R, S>,
117
- ) => makeSqliteAuthServices(database, mapping);
118
-
119
82
  export const makeIdentityServices = <
120
83
  Subject extends AnySQLiteTable,
121
84
  Identifier extends AnySQLiteTable,
@@ -1,5 +1,5 @@
1
1
  import { Context, type Effect } from "effect";
2
- import type { Statement } from "effect/unstable/sql/Statement";
2
+ import type { Statement } from "effect/sql/Statement";
3
3
 
4
4
  /** Appends application statements to the current coordinator's single atomic batch. */
5
5
  export class D1BatchStatements extends Context.Service<
@@ -35,7 +35,7 @@ import type { EffectDrizzleQueryError } from "drizzle-orm/effect-core";
35
35
  import type { EffectSQLiteD1Database } from "drizzle-orm/effect-d1";
36
36
  import type { AnySQLiteTable } from "drizzle-orm/sqlite-core";
37
37
  import { Schema, Cause, DateTime, Effect, Option, Context } from "effect";
38
- import type { Statement } from "effect/unstable/sql/Statement";
38
+ import type { Statement } from "effect/sql/Statement";
39
39
 
40
40
  import { CurrentD1PlanningDatabase, makeD1Owner } from "./d1-planning";
41
41
  import { compileD1ProofCompletionPlan } from "./d1-proofs";
@@ -1797,9 +1797,7 @@ const executeStandalone = <A, E, R>(
1797
1797
  retries = 2,
1798
1798
  ): Effect.Effect<
1799
1799
  A,
1800
- | E
1801
- | import("@yielded/auth/Hooks").HookConfigurationError
1802
- | import("effect/unstable/sql/SqlError").SqlError,
1800
+ E | import("@yielded/auth/Hooks").HookConfigurationError | import("effect/sql/SqlError").SqlError,
1803
1801
  Exclude<R, CurrentCommitJournal> | CurrentD1PlanningDatabase | LifecycleHooks
1804
1802
  > =>
1805
1803
  Effect.suspend(() => {
@@ -1,6 +1,6 @@
1
1
  import { sql, type SQL } from "drizzle-orm";
2
2
  import { Schema } from "effect";
3
- import type { Statement } from "effect/unstable/sql/Statement";
3
+ import type { Statement } from "effect/sql/Statement";
4
4
 
5
5
  // oxlint-disable-next-line no-restricted-properties -- Statement.compile exposes untyped native SQL parameters.
6
6
  const valuesJson = Schema.encodeUnknownSync(
@@ -30,7 +30,7 @@ import { eq, is, isNotNull, lte, or, SQL, sql, type AnyRelations, type Table } f
30
30
  import type { EffectSQLiteD1Database } from "drizzle-orm/effect-d1";
31
31
  import type { AnySQLiteTable } from "drizzle-orm/sqlite-core";
32
32
  import { Cause, DateTime, Effect, Predicate, Redacted, Schema, Context } from "effect";
33
- import type { Statement } from "effect/unstable/sql/Statement";
33
+ import type { Statement } from "effect/sql/Statement";
34
34
 
35
35
  import { balancedD1And as and, compactD1GeneratedStatement } from "./d1-generated-statement";
36
36
  import { passwordD1Kernel as kernel } from "./d1-passwords";
@@ -791,10 +791,7 @@ const makePreparedPlans = (mapping: Mapping, proofMapping?: any) => {
791
791
  Effect.catchCause(
792
792
  (
793
793
  cause,
794
- ): Effect.Effect<
795
- never,
796
- PasswordRejected | import("effect/unstable/sql/SqlError").SqlError
797
- > =>
794
+ ): Effect.Effect<never, PasswordRejected | import("effect/sql/SqlError").SqlError> =>
798
795
  everyFailureMatches(cause, (failure) =>
799
796
  kernel.isGuardFailure(
800
797
  failure,
@@ -54,7 +54,7 @@ import type { EffectDrizzleQueryError } from "drizzle-orm/effect-core";
54
54
  import type { EffectSQLiteD1Database } from "drizzle-orm/effect-d1";
55
55
  import type { AnySQLiteTable } from "drizzle-orm/sqlite-core";
56
56
  import { Cause, DateTime, Effect, Option, Predicate, Redacted, Schema, Context } from "effect";
57
- import type { Statement } from "effect/unstable/sql/Statement";
57
+ import type { Statement } from "effect/sql/Statement";
58
58
 
59
59
  import { balancedD1And } from "./d1-generated-statement";
60
60
  import { CurrentD1PlanningDatabase, makeD1Owner } from "./d1-planning";
@@ -2624,9 +2624,7 @@ const executeStandalone = <A, E, R>(
2624
2624
  retries = 2,
2625
2625
  ): Effect.Effect<
2626
2626
  A,
2627
- | E
2628
- | import("@yielded/auth/Hooks").HookConfigurationError
2629
- | import("effect/unstable/sql/SqlError").SqlError,
2627
+ E | import("@yielded/auth/Hooks").HookConfigurationError | import("effect/sql/SqlError").SqlError,
2630
2628
  Exclude<R, CurrentCommitJournal> | CurrentD1PlanningDatabase | LifecycleHooks
2631
2629
  > =>
2632
2630
  Effect.suspend(() => {
@@ -45,7 +45,7 @@ import type { EffectDrizzleQueryError } from "drizzle-orm/effect-core";
45
45
  import type { EffectSQLiteD1Database } from "drizzle-orm/effect-d1";
46
46
  import type { AnySQLiteTable } from "drizzle-orm/sqlite-core";
47
47
  import { Cause, Effect, Schema, Context } from "effect";
48
- import type { Statement } from "effect/unstable/sql/Statement";
48
+ import type { Statement } from "effect/sql/Statement";
49
49
 
50
50
  import { balancedD1And } from "./d1-generated-statement";
51
51
  import { CurrentD1PlanningDatabase, makeD1Owner } from "./d1-planning";
@@ -2273,9 +2273,7 @@ const executeStandalone = <A, E, R>(
2273
2273
  retries = 2,
2274
2274
  ): Effect.Effect<
2275
2275
  A,
2276
- | E
2277
- | import("@yielded/auth/Hooks").HookConfigurationError
2278
- | import("effect/unstable/sql/SqlError").SqlError,
2276
+ E | import("@yielded/auth/Hooks").HookConfigurationError | import("effect/sql/SqlError").SqlError,
2279
2277
  Exclude<R, CurrentCommitJournal> | CurrentD1PlanningDatabase | LifecycleHooks
2280
2278
  > =>
2281
2279
  Effect.suspend(() => {
@@ -49,8 +49,8 @@ import { and, eq, getTableColumns, gt, inArray, not, or, sql, type SQL } from "d
49
49
  import type { EffectDrizzleQueryError } from "drizzle-orm/effect-core";
50
50
  import type { AnySQLiteTable } from "drizzle-orm/sqlite-core";
51
51
  import { Cause, Context, Data, DateTime, Effect, Schema } from "effect";
52
- import type * as SqlError from "effect/unstable/sql/SqlError";
53
- import type { Statement } from "effect/unstable/sql/Statement";
52
+ import type * as SqlError from "effect/sql/SqlError";
53
+ import type { Statement } from "effect/sql/Statement";
54
54
 
55
55
  import { compactD1GeneratedStatement } from "./d1-generated-statement";
56
56
  import {
@@ -7,7 +7,7 @@ import {
7
7
  } from "@yielded/auth/Hooks";
8
8
  /* oxlint-disable no-explicit-any -- public driver wrappers restore concrete Drizzle generics. */
9
9
  import { type Context, Effect, Layer } from "effect";
10
- import type * as SqlError from "effect/unstable/sql/SqlError";
10
+ import type * as SqlError from "effect/sql/SqlError";
11
11
 
12
12
  import {
13
13
  makeSqlEmailRegistrationAuthority,
@@ -1,6 +1,3 @@
1
- import { requireStandalone } from "@yielded/auth-persistence/Adapter";
2
- import { AuthStore } from "@yielded/auth/AuthStore";
3
- import { AuthStoreError } from "@yielded/auth/Errors";
4
1
  import {
5
2
  ExternalIdentityMutation,
6
3
  SubjectProvisioner,
@@ -8,48 +5,11 @@ import {
8
5
  type ExternalIdentity,
9
6
  type LoginIdentifier,
10
7
  } from "@yielded/auth/Identity";
11
- import { OAuthStateStore, type OAuthState } from "@yielded/auth/OAuth";
12
- import {
13
- type ConsumeChallenge,
14
- type NewChallenge,
15
- type NewRegistration,
16
- type PendingRegistration,
17
- } from "@yielded/auth/Schema";
18
- import {
19
- getTableColumns,
20
- type AnyColumn,
21
- type InferInsertModel,
22
- type InferSelectModel,
23
- type Table,
24
- } from "drizzle-orm";
8
+ import { getTableColumns, type AnyColumn, type InferInsertModel, type Table } from "drizzle-orm";
25
9
  import { Context, DateTime, Effect, Layer } from "effect";
26
- import type * as SqlClient from "effect/unstable/sql/SqlClient";
27
10
 
28
11
  export type CommitMode = "interactive" | "synchronous" | "batch";
29
12
 
30
- /**
31
- * Ordinary error-channel consumes must own their commit. Coordinated callers
32
- * use the decision methods inside their outer transaction and translate only
33
- * after that owner commits.
34
- */
35
- export interface SqlClientTransactionDatabase {
36
- readonly $client: Pick<SqlClient.SqlClient, "transactionService">;
37
- }
38
-
39
- export const requireStandaloneConsume = (
40
- database: SqlClientTransactionDatabase,
41
- ): Effect.Effect<void, AuthStoreError> =>
42
- requireStandalone(
43
- () =>
44
- AuthStoreError.make({
45
- message: "Use the decision consume API inside an outer database transaction",
46
- }),
47
- database.$client,
48
- );
49
-
50
- export type { ChallengeConsumeDecision } from "@yielded/auth/Persistence";
51
- export type { ConsumeDecision } from "@yielded/auth/AuthStore";
52
-
53
13
  export {
54
14
  PersistenceMappingError,
55
15
  isMappedConstraintConflict,
@@ -62,156 +22,8 @@ export interface InstantCodec<NativeInstant> {
62
22
  readonly decode: (native: NativeInstant) => Effect.Effect<DateTime.Utc, PersistenceMappingError>;
63
23
  }
64
24
 
65
- export interface RequiredAuthStoreConstraints {
66
- readonly series: "unique(namespace,value,purpose)";
67
- readonly challengeDigest: "unique(tokenDigest)";
68
- readonly registrationDigest: "unique(tokenDigest)";
69
- }
70
-
71
- export interface RequiredOAuthStateConstraints {
72
- readonly oauthStateDigest: "unique(stateDigest)";
73
- }
74
-
75
- export interface RequiredAuthConstraints
76
- extends RequiredAuthStoreConstraints, RequiredOAuthStateConstraints {}
77
-
78
- export const requiredAuthConstraints: RequiredAuthConstraints = {
79
- series: "unique(namespace,value,purpose)",
80
- challengeDigest: "unique(tokenDigest)",
81
- registrationDigest: "unique(tokenDigest)",
82
- oauthStateDigest: "unique(stateDigest)",
83
- };
84
-
85
- export const requiredAuthStoreConstraints: RequiredAuthStoreConstraints = {
86
- series: "unique(namespace,value,purpose)",
87
- challengeDigest: "unique(tokenDigest)",
88
- registrationDigest: "unique(tokenDigest)",
89
- };
90
-
91
- export const requiredOAuthStateConstraints: RequiredOAuthStateConstraints = {
92
- oauthStateDigest: "unique(stateDigest)",
93
- };
94
-
95
25
  type ColumnKey<T extends Table> = Extract<keyof T["_"]["columns"], string>;
96
26
 
97
- export interface ChallengeRecord {
98
- readonly challenge: NewChallenge;
99
- readonly namespace: string;
100
- readonly failedAttempts: number;
101
- readonly consumed: boolean;
102
- }
103
-
104
- export interface ChallengeColumns<T extends Table> {
105
- readonly challengeId: ColumnKey<T>;
106
- readonly tokenDigest: ColumnKey<T>;
107
- readonly namespace: ColumnKey<T>;
108
- readonly value: ColumnKey<T>;
109
- readonly purpose: ColumnKey<T>;
110
- readonly otpKeyId: ColumnKey<T>;
111
- readonly otpDigest: ColumnKey<T>;
112
- readonly issuedAt: ColumnKey<T>;
113
- readonly expiresAt: ColumnKey<T>;
114
- readonly attemptLimit: ColumnKey<T>;
115
- readonly failedAttempts: ColumnKey<T>;
116
- readonly consumed: ColumnKey<T>;
117
- }
118
-
119
- /**
120
- * Inputs are immutable server-created issuances. Replacements must advance
121
- * issuedAt; equal or older issuances fail even after consumption or expiry.
122
- * Instant encoding must preserve this ordering. Retain the series row as an
123
- * issuance watermark until every previously accepted issuance has expired;
124
- * current-row expiry alone is insufficient if historical lifetimes were longer.
125
- */
126
- export interface ChallengeTableMapping<T extends Table> {
127
- readonly table: T;
128
- readonly columns: ChallengeColumns<T>;
129
- readonly identifierNamespace: string;
130
- readonly encodeInstant: (instant: DateTime.Utc) => unknown;
131
- readonly encodeInsert: (
132
- input: NewChallenge,
133
- state: {
134
- readonly namespace: string;
135
- readonly failedAttempts: number;
136
- readonly consumed: false;
137
- },
138
- ) => InferInsertModel<T>;
139
- readonly encodeUpdate: (
140
- input: NewChallenge,
141
- state: {
142
- readonly namespace: string;
143
- readonly failedAttempts: unknown;
144
- readonly consumed: false;
145
- },
146
- ) => Readonly<Record<string, unknown>>;
147
- readonly decode: (
148
- row: InferSelectModel<T>,
149
- ) => Effect.Effect<ChallengeRecord, PersistenceMappingError>;
150
- }
151
-
152
- export interface RegistrationRecord {
153
- readonly registration: PendingRegistration;
154
- readonly consumed: boolean;
155
- }
156
-
157
- export interface RegistrationColumns<T extends Table> {
158
- readonly registrationId: ColumnKey<T>;
159
- readonly tokenDigest: ColumnKey<T>;
160
- readonly expiresAt: ColumnKey<T>;
161
- readonly consumed: ColumnKey<T>;
162
- }
163
-
164
- export interface RegistrationTableMapping<T extends Table> {
165
- readonly table: T;
166
- readonly columns: RegistrationColumns<T>;
167
- readonly encodeInstant: (instant: DateTime.Utc) => unknown;
168
- readonly encodeInsert: (input: NewRegistration, consumed: false) => InferInsertModel<T>;
169
- readonly decode: (
170
- row: InferSelectModel<T>,
171
- ) => Effect.Effect<RegistrationRecord, PersistenceMappingError>;
172
- }
173
-
174
- export interface OAuthStateColumns<T extends Table> {
175
- readonly stateDigest: ColumnKey<T>;
176
- readonly expiresAt: ColumnKey<T>;
177
- readonly consumed: ColumnKey<T>;
178
- }
179
-
180
- export interface OAuthStateTableMapping<T extends Table> {
181
- readonly table: T;
182
- readonly columns: OAuthStateColumns<T>;
183
- readonly encodeInstant: (instant: DateTime.Utc) => unknown;
184
- readonly encodeInsert: (state: OAuthState, consumed: false) => InferInsertModel<T>;
185
- readonly decode: (
186
- row: InferSelectModel<T>,
187
- ) => Effect.Effect<
188
- { readonly state: OAuthState; readonly consumed: boolean },
189
- PersistenceMappingError
190
- >;
191
- }
192
-
193
- export interface AuthStoreTables<Challenge extends Table, Registration extends Table> {
194
- readonly constraints: RequiredAuthStoreConstraints;
195
- readonly challenge: ChallengeTableMapping<Challenge>;
196
- readonly registration: RegistrationTableMapping<Registration>;
197
- }
198
-
199
- export interface OAuthStateTables<State extends Table> {
200
- readonly constraints: RequiredOAuthStateConstraints;
201
- readonly oauthState: OAuthStateTableMapping<State>;
202
- }
203
-
204
- export interface AuthTables<
205
- Challenge extends Table,
206
- Registration extends Table,
207
- State extends Table,
208
- > {
209
- readonly constraints: RequiredAuthConstraints;
210
- readonly challenge: ChallengeTableMapping<Challenge>;
211
- readonly registration: RegistrationTableMapping<Registration>;
212
- readonly oauthState: OAuthStateTableMapping<State>;
213
- }
214
-
215
27
  export interface RequiredIdentityConstraints {
216
28
  readonly identifier: "unique(namespace,value)";
217
29
  readonly externalIdentity: "unique(provider,issuer,subject)";
@@ -420,25 +232,6 @@ export const updateValues = <T extends Table>(
420
232
  entries: ReadonlyArray<readonly [ColumnKey<T>, unknown]>,
421
233
  ): Partial<InferInsertModel<T>> => Object.fromEntries(entries) as Partial<InferInsertModel<T>>;
422
234
 
423
- export type ChallengeInput = ConsumeChallenge;
424
-
425
- /** Acquire an application database in Effect and expose the auth stores as one layer. */
426
- export const authServicesLayer = <E, R>(
427
- acquire: Effect.Effect<
428
- {
429
- readonly authStore: AuthStore["Service"];
430
- readonly oauthStateStore: OAuthStateStore["Service"];
431
- },
432
- E,
433
- R
434
- >,
435
- ) =>
436
- Layer.effectContext(
437
- Effect.map(acquire, ({ authStore, oauthStateStore }) =>
438
- Context.make(AuthStore, authStore).pipe(Context.add(OAuthStateStore, oauthStateStore)),
439
- ),
440
- );
441
-
442
235
  /** Acquire an application database in Effect and expose the identity services as one layer. */
443
236
  export const identityServicesLayer = <E, R>(
444
237
  acquire: Effect.Effect<
@@ -5,7 +5,7 @@ import type { AnyRelations } from "drizzle-orm";
5
5
  import type { EffectMysql2Database } from "drizzle-orm/effect-mysql2";
6
6
  import type { AnyMySqlTable } from "drizzle-orm/mysql-core";
7
7
  import { Effect, Context } from "effect";
8
- import type { SqlError } from "effect/unstable/sql/SqlError";
8
+ import type { SqlError } from "effect/sql/SqlError";
9
9
 
10
10
  import type {
11
11
  EmailAddressMapping,
@@ -4,7 +4,7 @@ import type { AnyRelations } from "drizzle-orm";
4
4
  import type { EffectMysql2Database } from "drizzle-orm/effect-mysql2";
5
5
  import type { AnyMySqlTable } from "drizzle-orm/mysql-core";
6
6
  import { Effect, Context } from "effect";
7
- import type { SqlError } from "effect/unstable/sql/SqlError";
7
+ import type { SqlError } from "effect/sql/SqlError";
8
8
 
9
9
  import { mysqlPasswordConfiguration as configuration } from "./mysql-passwords";
10
10
  import type {
@@ -5,7 +5,7 @@ import type { AnyRelations } from "drizzle-orm";
5
5
  import type { EffectMysql2Database } from "drizzle-orm/effect-mysql2";
6
6
  import type { AnyMySqlTable } from "drizzle-orm/mysql-core";
7
7
  import { Effect, Context } from "effect";
8
- import type { SqlError } from "effect/unstable/sql/SqlError";
8
+ import type { SqlError } from "effect/sql/SqlError";
9
9
 
10
10
  import type { PasswordPersistenceMapping, PasswordRegistrationMapping } from "./password-model";
11
11
  import type { PasswordRegistrationAuthority } from "./password-registration";
@@ -4,7 +4,7 @@ import type { AnyRelations } from "drizzle-orm";
4
4
  import type { EffectMysql2Database } from "drizzle-orm/effect-mysql2";
5
5
  import type { AnyMySqlTable } from "drizzle-orm/mysql-core";
6
6
  import { Effect, Context } from "effect";
7
- import type { SqlError } from "effect/unstable/sql/SqlError";
7
+ import type { SqlError } from "effect/sql/SqlError";
8
8
 
9
9
  import { updateValues } from "./model";
10
10
  import type { ProofPersistenceMapping } from "./proof-model";
@@ -12,7 +12,7 @@ import type { AnyRelations } from "drizzle-orm";
12
12
  import type { EffectMysql2Database } from "drizzle-orm/effect-mysql2";
13
13
  import type { AnyMySqlTable } from "drizzle-orm/mysql-core";
14
14
  import { Effect, Context } from "effect";
15
- import type { SqlError } from "effect/unstable/sql/SqlError";
15
+ import type { SqlError } from "effect/sql/SqlError";
16
16
 
17
17
  import type {
18
18
  AuthenticationAuthorityMapping,
@@ -132,6 +132,7 @@ export const claimRefresh = Effect.fn("oauthConnected.claimRefresh")(function* (
132
132
 
133
133
  const claim = snapshotOAuthSync(M.OAuthConnectedRefreshClaim, {
134
134
  grant: input.grant,
135
+ order: String(yield* S.nextOrder(mapping, read.client)),
135
136
  claimId: input.claimId,
136
137
  claimedAtMillis: read.now,
137
138
  claimExpiresAtMillis: expires,
@@ -204,10 +205,16 @@ export const settleRefresh = Effect.fn("oauthConnected.settleRefresh")(function*
204
205
  if (incoming !== undefined)
205
206
  invariant(
206
207
  C.sameContext(
207
- { ...incoming.context, tokenVersion: old.tokenVersion, metadata: old.metadata },
208
+ {
209
+ ...incoming.context,
210
+ tokenVersion: old.tokenVersion,
211
+ metadata: old.metadata,
212
+ exchangeOrder: old.exchangeOrder,
213
+ },
208
214
  old,
209
215
  ) &&
210
216
  incoming.context.tokenVersion === input.claim.nextTokenVersion &&
217
+ incoming.context.exchangeOrder === input.claim.order &&
211
218
  validMetadata(incoming.context, now) &&
212
219
  incoming.context.metadata.obtainedAtMillis >= input.claim.claimedAtMillis &&
213
220
  (incoming.context.metadata.refreshUseUntilMillis === undefined ||
@@ -374,6 +374,9 @@ export const makeD1OAuthConnectedTarget = <Database, Family extends Table, Extra
374
374
  );
375
375
 
376
376
  const service: OAuthConnectedPersistence["Service"] = {
377
+ claimSignIn: (input, prepare) => owner.run(original.claimSignIn(input, prepare)),
378
+ inspectSignIn: (input) => owner.run(original.inspectSignIn(input)),
379
+ settleSignIn: (input, prepare) => owner.run(original.settleSignIn(input, prepare)),
377
380
  capture: (input) => owner.run(original.capture(input)),
378
381
  issue: (input, prepare) => owner.run(original.issue(input, prepare)),
379
382
  preflight: (input) => owner.run(original.preflight(input)),
@@ -105,6 +105,19 @@ const snapshot =
105
105
  snapshotOAuthSync(schema, input);
106
106
 
107
107
  export const connectedInputs = {
108
+ claimSignIn: snapshot(
109
+ Schema.Struct({ claim: M.OAuthClaim, configuration: M.OAuthConnectedConfiguration }),
110
+ ),
111
+ inspectSignIn: snapshot(
112
+ Schema.Struct({
113
+ reservation: M.OAuthSignInAccessClaim,
114
+ credential: M.OAuthCredentialSnapshot,
115
+ grantId: M.OAuthGrantId,
116
+ }),
117
+ ),
118
+ settleSignIn: snapshot(
119
+ Schema.Struct({ reservation: M.OAuthSignInAccessClaim, outcome: M.OAuthSignInAccessOutcome }),
120
+ ),
108
121
  capture: snapshot(capture),
109
122
  issue: snapshot(issue),
110
123
  preflight: snapshot(M.OAuthConnectedAccess),
@@ -7,6 +7,8 @@ import type { SubjectIdCodec } from "./model";
7
7
  import type {
8
8
  OAuthAuthorityReadTable,
9
9
  OAuthClock,
10
+ OAuthCredentialReadTable,
11
+ OAuthFlowTable,
10
12
  OAuthOwnershipMutation,
11
13
  OAuthSubjectReadTable,
12
14
  requiredOAuthTupleConstraints,
@@ -53,6 +55,9 @@ export interface OAuthConnectedFlowTable<F extends Table, N> {
53
55
  readonly work: Column<F>;
54
56
  /** Exact sealed quarantine when no correctly sealed revocation job is available. */
55
57
  readonly custody: Column<F>;
58
+ /** Required when retaining grants during sign-in. subjectId is NULL until
59
+ * identity resolution; custom required columns are supplied by this encoder. */
60
+ readonly encodeSignIn?: (reservation: M.OAuthSignInAccessClaim) => InferInsertModel<F>;
56
61
  readonly encodeInsert: (input: {
57
62
  readonly flow: M.OAuthConnectedPendingFlow;
58
63
  readonly subjectId: N;
@@ -192,6 +197,12 @@ export type OAuthConnectedPolicyInput<N> = {
192
197
  readonly configuration: M.OAuthConnectedConfiguration;
193
198
  readonly grant?: M.OAuthConnectedTokenContext;
194
199
  }
200
+ | {
201
+ readonly kind: "sign-in";
202
+ readonly credential: M.OAuthCredentialSnapshot;
203
+ readonly configuration: M.OAuthConnectedConfiguration;
204
+ readonly grant?: M.OAuthConnectedTokenContext;
205
+ }
195
206
  | {
196
207
  readonly kind: "metadata" | "use";
197
208
  readonly authorization: M.OAuthConnectedUseAuthorization;
@@ -307,6 +318,12 @@ export interface OAuthConnectedMapping<
307
318
  readonly subject: OAuthConnectedSubjectTable<S>;
308
319
  readonly authority: OAuthAuthorityReadTable<AC>;
309
320
  readonly admission: OAuthConnectedAdmissionTable<A, N>;
321
+ /** Same shared sign-in tables used by OAuthSignInPersistence. Enable only
322
+ * alongside a nullable connected-flow subjectId and flow.encodeSignIn. */
323
+ readonly signIn?: {
324
+ readonly credential: OAuthCredentialReadTable<Table>;
325
+ readonly flow: OAuthFlowTable<Table>;
326
+ };
310
327
  readonly command: OAuthConnectedCommandTable<D, N>;
311
328
  readonly policy: OAuthConnectedSqlPolicy<N>;
312
329
  readonly constraints: typeof requiredOAuthConnectedConstraints;