@yielded/auth-persistence-drizzle 0.1.0-beta.22 → 0.1.0-beta.24

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 (200) hide show
  1. package/README.md +3 -0
  2. package/dist/D1.d.mts +11 -11
  3. package/dist/D1.mjs +2 -1
  4. package/dist/D1.mjs.map +1 -1
  5. package/dist/Libsql.d.mts +40 -56
  6. package/dist/Libsql.mjs +2 -1
  7. package/dist/Libsql.mjs.map +1 -1
  8. package/dist/Mysql2.d.mts +16 -17
  9. package/dist/Pglite.d.mts +18 -18
  10. package/dist/Pglite.mjs +2 -1
  11. package/dist/Pglite.mjs.map +1 -1
  12. package/dist/Postgres.d.mts +24 -24
  13. package/dist/Postgres.mjs +2 -1
  14. package/dist/Postgres.mjs.map +1 -1
  15. package/dist/SqliteBun.d.mts +39 -55
  16. package/dist/SqliteBun.mjs +2 -1
  17. package/dist/SqliteBun.mjs.map +1 -1
  18. package/dist/SqliteDo.d.mts +48 -64
  19. package/dist/SqliteDo.mjs +2 -1
  20. package/dist/SqliteDo.mjs.map +1 -1
  21. package/dist/SqliteNode.d.mts +45 -61
  22. package/dist/SqliteNode.mjs +2 -1
  23. package/dist/SqliteNode.mjs.map +1 -1
  24. package/dist/SqliteWasm.d.mts +48 -64
  25. package/dist/SqliteWasm.mjs +2 -1
  26. package/dist/SqliteWasm.mjs.map +1 -1
  27. package/dist/drizzle/crypto.mjs +1 -1
  28. package/dist/drizzle/d1-emails.d.mts +1 -1
  29. package/dist/drizzle/d1-oauth.d.mts +14 -14
  30. package/dist/drizzle/d1-passkey.d.mts +1 -1
  31. package/dist/drizzle/d1-password-prepared.d.mts +4 -4
  32. package/dist/drizzle/d1-password-prepared.mjs.map +1 -1
  33. package/dist/drizzle/d1-passwords.d.mts +18 -35
  34. package/dist/drizzle/d1-passwords.mjs +78 -290
  35. package/dist/drizzle/d1-passwords.mjs.map +1 -1
  36. package/dist/drizzle/d1-phone.d.mts +1 -1
  37. package/dist/drizzle/d1-proofs.d.mts +2 -2
  38. package/dist/drizzle/d1-sessions.d.mts +3 -3
  39. package/dist/drizzle/d1-sessions.mjs +11 -6
  40. package/dist/drizzle/d1-sessions.mjs.map +1 -1
  41. package/dist/drizzle/d1-totp.d.mts +1 -1
  42. package/dist/drizzle/mysql-password-prepared.d.mts +5 -5
  43. package/dist/drizzle/mysql-password-prepared.mjs.map +1 -1
  44. package/dist/drizzle/mysql-passwords.d.mts +16 -32
  45. package/dist/drizzle/mysql-passwords.mjs.map +1 -1
  46. package/dist/drizzle/mysql-sessions.d.mts +1 -1
  47. package/dist/drizzle/native-sql-table.mjs +135 -0
  48. package/dist/drizzle/native-sql-table.mjs.map +1 -0
  49. package/dist/drizzle/oauth-connected-model.d.mts +20 -281
  50. package/dist/drizzle/oauth-connected-model.mjs +3 -17
  51. package/dist/drizzle/oauth-connected-model.mjs.map +1 -1
  52. package/dist/drizzle/oauth-connected-reference.d.mts +1 -3
  53. package/dist/drizzle/oauth-connected-reference.mjs +4 -53
  54. package/dist/drizzle/oauth-connected-reference.mjs.map +1 -1
  55. package/dist/drizzle/oauth-connected-target.d.mts +3 -990
  56. package/dist/drizzle/oauth-connected-target.mjs +8 -92
  57. package/dist/drizzle/oauth-connected-target.mjs.map +1 -1
  58. package/dist/drizzle/oauth-kernel.mjs +11 -0
  59. package/dist/drizzle/oauth-kernel.mjs.map +1 -0
  60. package/dist/drizzle/oauth-model.d.mts +35 -438
  61. package/dist/drizzle/oauth-model.mjs +6 -44
  62. package/dist/drizzle/oauth-model.mjs.map +1 -1
  63. package/dist/drizzle/oauth-mysql.mjs +2 -2
  64. package/dist/drizzle/oauth-mysql.mjs.map +1 -1
  65. package/dist/drizzle/oauth-proxy.d.mts +10 -0
  66. package/dist/drizzle/oauth-proxy.mjs +54 -0
  67. package/dist/drizzle/oauth-proxy.mjs.map +1 -0
  68. package/dist/drizzle/oauth-target.d.mts +6 -107
  69. package/dist/drizzle/oauth-target.mjs +15 -245
  70. package/dist/drizzle/oauth-target.mjs.map +1 -1
  71. package/dist/drizzle/password-model.d.mts +5 -8
  72. package/dist/drizzle/password-prepared-model.d.mts +5 -5
  73. package/dist/drizzle/password-prepared-model.mjs.map +1 -1
  74. package/dist/drizzle/password-prepared-state.mjs +1 -1
  75. package/dist/drizzle/password-sql.mjs +2 -1
  76. package/dist/drizzle/password-sql.mjs.map +1 -1
  77. package/dist/drizzle/password-target.mjs +13 -2
  78. package/dist/drizzle/password-target.mjs.map +1 -1
  79. package/dist/drizzle/pg-password-prepared.d.mts +5 -5
  80. package/dist/drizzle/pg-password-prepared.mjs.map +1 -1
  81. package/dist/drizzle/pg-passwords.d.mts +16 -32
  82. package/dist/drizzle/pg-passwords.mjs.map +1 -1
  83. package/dist/drizzle/pg-sessions.d.mts +1 -1
  84. package/dist/drizzle/phone-target.d.mts +2 -2
  85. package/dist/drizzle/phone-target.mjs +1 -1
  86. package/dist/drizzle/query-operations.mjs +3 -1
  87. package/dist/drizzle/query-operations.mjs.map +1 -1
  88. package/dist/drizzle/session-sql.mjs +2 -1
  89. package/dist/drizzle/session-sql.mjs.map +1 -1
  90. package/dist/drizzle/sqlite-password-prepared.mjs.map +1 -1
  91. package/dist/drizzle/sqlite-passwords.mjs.map +1 -1
  92. package/dist/drizzle/storage-validation.mjs +10 -198
  93. package/dist/drizzle/storage-validation.mjs.map +1 -1
  94. package/dist/drizzle/totp-target.d.mts +3 -3
  95. package/dist/drizzle/totp-target.mjs +2 -2
  96. package/dist/drizzle/transaction-execution.d.mts +2 -2
  97. package/dist/drizzle/transaction-owner.d.mts +1 -2
  98. package/dist/index.d.mts +3 -2
  99. package/dist/internal/drizzle-postgres-oauth-proxy.d.mts +138 -0
  100. package/dist/internal/drizzle-postgres-oauth-proxy.mjs +29 -0
  101. package/dist/internal/drizzle-postgres-oauth-proxy.mjs.map +1 -0
  102. package/dist/internal/drizzle-postgres.mjs +2 -0
  103. package/dist/internal/drizzle-postgres.mjs.map +1 -1
  104. package/dist/internal/drizzle-sqlite-oauth-proxy.d.mts +146 -0
  105. package/dist/internal/drizzle-sqlite-oauth-proxy.mjs +29 -0
  106. package/dist/internal/drizzle-sqlite-oauth-proxy.mjs.map +1 -0
  107. package/dist/internal/drizzle-sqlite.mjs +2 -0
  108. package/dist/internal/drizzle-sqlite.mjs.map +1 -1
  109. package/package.json +1 -1
  110. package/src/D1.ts +2 -0
  111. package/src/Libsql.ts +2 -0
  112. package/src/Pglite.ts +2 -0
  113. package/src/Postgres.ts +2 -0
  114. package/src/SqliteBun.ts +2 -0
  115. package/src/SqliteDo.ts +2 -0
  116. package/src/SqliteNode.ts +2 -0
  117. package/src/SqliteWasm.ts +2 -0
  118. package/src/drizzle/d1-password-prepared.ts +2 -23
  119. package/src/drizzle/d1-passwords.ts +158 -780
  120. package/src/drizzle/d1-sessions.ts +21 -6
  121. package/src/drizzle/mysql-password-prepared.ts +4 -16
  122. package/src/drizzle/mysql-passwords.ts +5 -20
  123. package/src/drizzle/native-sql-table.ts +259 -0
  124. package/src/drizzle/oauth-connected-model.ts +97 -315
  125. package/src/drizzle/oauth-connected-reference.ts +13 -93
  126. package/src/drizzle/oauth-connected-target.ts +14 -271
  127. package/src/drizzle/oauth-kernel.ts +10 -0
  128. package/src/drizzle/oauth-model.ts +188 -541
  129. package/src/drizzle/oauth-mysql.ts +2 -2
  130. package/src/drizzle/oauth-proxy.ts +101 -0
  131. package/src/drizzle/oauth-target.ts +33 -737
  132. package/src/drizzle/password-model.ts +0 -33
  133. package/src/drizzle/password-prepared-model.ts +0 -18
  134. package/src/drizzle/password-sql.ts +3 -0
  135. package/src/drizzle/password-target.ts +41 -4
  136. package/src/drizzle/pg-password-prepared.ts +4 -16
  137. package/src/drizzle/pg-passwords.ts +5 -20
  138. package/src/drizzle/query-operations.ts +4 -0
  139. package/src/drizzle/session-sql.ts +2 -1
  140. package/src/drizzle/sqlite-password-prepared.ts +4 -52
  141. package/src/drizzle/sqlite-passwords.ts +7 -28
  142. package/src/drizzle/storage-validation.ts +13 -222
  143. package/src/index.ts +2 -8
  144. package/src/internal/drizzle-postgres-oauth-proxy.ts +37 -0
  145. package/src/internal/drizzle-postgres.ts +2 -0
  146. package/src/internal/drizzle-sqlite-oauth-proxy.ts +44 -0
  147. package/src/internal/drizzle-sqlite.ts +2 -0
  148. package/dist/_virtual/_rolldown/runtime.mjs +0 -13
  149. package/dist/drizzle/oauth-accounts.mjs +0 -359
  150. package/dist/drizzle/oauth-accounts.mjs.map +0 -1
  151. package/dist/drizzle/oauth-connected-access.mjs +0 -212
  152. package/dist/drizzle/oauth-connected-access.mjs.map +0 -1
  153. package/dist/drizzle/oauth-connected-collection.mjs +0 -202
  154. package/dist/drizzle/oauth-connected-collection.mjs.map +0 -1
  155. package/dist/drizzle/oauth-connected-custody.mjs +0 -147
  156. package/dist/drizzle/oauth-connected-custody.mjs.map +0 -1
  157. package/dist/drizzle/oauth-connected-flow.mjs +0 -297
  158. package/dist/drizzle/oauth-connected-flow.mjs.map +0 -1
  159. package/dist/drizzle/oauth-connected-input.mjs +0 -122
  160. package/dist/drizzle/oauth-connected-input.mjs.map +0 -1
  161. package/dist/drizzle/oauth-connected-maintenance.mjs +0 -214
  162. package/dist/drizzle/oauth-connected-maintenance.mjs.map +0 -1
  163. package/dist/drizzle/oauth-connected-management.mjs +0 -229
  164. package/dist/drizzle/oauth-connected-management.mjs.map +0 -1
  165. package/dist/drizzle/oauth-connected-settlement.mjs +0 -128
  166. package/dist/drizzle/oauth-connected-settlement.mjs.map +0 -1
  167. package/dist/drizzle/oauth-connected-sign-in.mjs +0 -265
  168. package/dist/drizzle/oauth-connected-sign-in.mjs.map +0 -1
  169. package/dist/drizzle/oauth-connected-state.d.mts +0 -2062
  170. package/dist/drizzle/oauth-connected-state.mjs +0 -430
  171. package/dist/drizzle/oauth-connected-state.mjs.map +0 -1
  172. package/dist/drizzle/oauth-flow.d.mts +0 -22
  173. package/dist/drizzle/oauth-flow.mjs +0 -253
  174. package/dist/drizzle/oauth-flow.mjs.map +0 -1
  175. package/dist/drizzle/oauth-input.mjs +0 -127
  176. package/dist/drizzle/oauth-input.mjs.map +0 -1
  177. package/dist/drizzle/oauth-owner.d.mts +0 -10
  178. package/dist/drizzle/oauth-owner.mjs +0 -10
  179. package/dist/drizzle/oauth-owner.mjs.map +0 -1
  180. package/dist/drizzle/oauth-registration.d.mts +0 -5
  181. package/dist/drizzle/oauth-registration.mjs +0 -374
  182. package/dist/drizzle/oauth-registration.mjs.map +0 -1
  183. package/dist/drizzle/oauth-state.mjs +0 -107
  184. package/dist/drizzle/oauth-state.mjs.map +0 -1
  185. package/src/drizzle/oauth-accounts.ts +0 -805
  186. package/src/drizzle/oauth-connected-access.ts +0 -361
  187. package/src/drizzle/oauth-connected-collection.ts +0 -324
  188. package/src/drizzle/oauth-connected-custody.ts +0 -279
  189. package/src/drizzle/oauth-connected-flow.ts +0 -529
  190. package/src/drizzle/oauth-connected-input.ts +0 -147
  191. package/src/drizzle/oauth-connected-maintenance.ts +0 -346
  192. package/src/drizzle/oauth-connected-management.ts +0 -365
  193. package/src/drizzle/oauth-connected-settlement.ts +0 -251
  194. package/src/drizzle/oauth-connected-sign-in.ts +0 -443
  195. package/src/drizzle/oauth-connected-state.ts +0 -872
  196. package/src/drizzle/oauth-flow.ts +0 -462
  197. package/src/drizzle/oauth-input.ts +0 -201
  198. package/src/drizzle/oauth-owner.ts +0 -29
  199. package/src/drizzle/oauth-registration.ts +0 -640
  200. package/src/drizzle/oauth-state.ts +0 -218
@@ -1,291 +1,30 @@
1
- import { SubjectIdCodec } from "./model.mjs";
2
- import { OAuthAuthorityReadTable, OAuthClock, OAuthCredentialReadTable, OAuthFlowTable, OAuthOwnershipMutation, OAuthSubjectReadTable, requiredOAuthTupleConstraints } from "./oauth-model.mjs";
3
- import { InferInsertModel, InferSelectModel, SQL, Table } from "drizzle-orm";
4
- import { AuthenticationRequirement } from "@yielded/auth/Sessions";
5
- import * as M from "@yielded/auth/OAuth";
6
- import { OAuthAccountRevision } from "@yielded/auth/OAuth";
1
+ import { DrizzleTableModel } from "./table-model.mjs";
2
+ import * as Shared from "@yielded/auth-persistence/Adapter";
3
+ import { OAuthConnectedAction, OAuthConnectedOrderCodec, OAuthConnectedPolicyInput, requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints } from "@yielded/auth-persistence/Adapter";
4
+ import { SQL, Table } from "drizzle-orm";
7
5
  //#region src/drizzle/oauth-connected-model.d.ts
8
- type Column<T extends Table> = Extract<keyof T["_"]["columns"], string>;
9
- export type OAuthConnectedAction = M.OAuthConnectedActionChallenge["action"];
10
- export interface OAuthConnectedSubjectTable<S extends Table> extends OAuthSubjectReadTable<S> {
11
- readonly decodeActionRequirement: (row: InferSelectModel<S>, action: OAuthConnectedAction) => AuthenticationRequirement;
12
- }
13
- /** All mapped order columns use exact SQL integer comparison through 2^53-1.
14
- * These codecs bridge driver representations, not alternative ordering rules. */
15
- export interface OAuthConnectedOrderCodec {
16
- readonly encode: (order: number) => unknown;
17
- readonly decode: (value: unknown) => number;
18
- }
19
- export interface OAuthConnectedFlowTable<F extends Table, N> {
20
- readonly table: F;
21
- readonly moduleId: Column<F>;
22
- readonly flowId: Column<F>;
23
- readonly commandId: Column<F>;
24
- readonly subjectId: Column<F>;
25
- readonly clientKey: Column<F>;
26
- readonly cohortKey: Column<F>;
27
- readonly state: Column<F>;
28
- readonly version: Column<F>;
29
- readonly stateDigest: Column<F>;
30
- readonly snapshot: Column<F>;
31
- readonly claimId: Column<F>;
32
- readonly claimDigest: Column<F>;
33
- readonly claimOrder: Column<F>;
34
- readonly claimedAt: Column<F>;
35
- readonly claimExpiresAt: Column<F>;
36
- readonly expiresAt: Column<F>;
37
- readonly retentionUntil: Column<F>;
38
- /** None before claim, Unresolved after claim, Resolved only after definite
39
- * cancellation or atomic transfer to a grant/job. Never reset by cleanup. */
40
- readonly work: Column<F>;
41
- /** Exact sealed quarantine when no correctly sealed revocation job is available. */
42
- readonly custody: Column<F>;
43
- /** Required when retaining grants during sign-in. subjectId is NULL until
44
- * identity resolution; custom required columns are supplied by this encoder. */
45
- readonly encodeSignIn?: (reservation: M.OAuthSignInAccessClaim) => InferInsertModel<F>;
46
- readonly encodeInsert: (input: {
47
- readonly flow: M.OAuthConnectedPendingFlow;
48
- readonly subjectId: N;
49
- }) => InferInsertModel<F>;
50
- }
51
- export interface OAuthConnectedGrantTable<G extends Table, N> {
52
- readonly table: G;
53
- readonly moduleId: Column<G>;
54
- readonly grantId: Column<G>;
55
- readonly subjectId: Column<G>;
56
- readonly identityKey: Column<G>;
57
- /** Nullable unique active slot; historical/disconnected records use null. */
58
- readonly activeIdentityKey: Column<G>;
59
- readonly clientKey: Column<G>;
60
- readonly cohortKey: Column<G>;
61
- readonly profileKey: Column<G>;
62
- readonly grantVersion: Column<G>;
63
- readonly tokenVersion: Column<G>;
64
- readonly cohortGeneration: Column<G>;
65
- readonly state: Column<G>;
66
- readonly version: Column<G>;
67
- readonly context: Column<G>;
68
- readonly sealed: Column<G>;
69
- /** Canonical OAuthConnectedSummary only: list never loads token envelopes. */
70
- readonly summary: Column<G>;
71
- readonly revocationJobId: Column<G>;
72
- readonly refreshWork: Column<G>;
73
- readonly refreshClaim: Column<G>;
74
- readonly refreshClaimExpiresAt: Column<G>;
75
- readonly retentionUntil: Column<G>;
76
- readonly encodeInsert: (input: {
77
- readonly grant: M.OAuthConnectedStoredGrant;
78
- readonly subjectId: N;
79
- }) => InferInsertModel<G>;
80
- }
6
+ export type OAuthConnectedSubjectTable<S extends Table> = Shared.OAuthConnectedSubjectTable<DrizzleTableModel<S>, SQL>;
7
+ export type OAuthConnectedFlowTable<F extends Table, N> = Shared.OAuthConnectedFlowTable<DrizzleTableModel<F>, N>;
8
+ export type OAuthConnectedGrantTable<G extends Table, N> = Shared.OAuthConnectedGrantTable<DrizzleTableModel<G>, N>;
81
9
  /** Also stores a permanent provider/issuer scope anchor. clientKey must fit 52
82
10
  * ASCII characters. Empty clientRegistrationId is reserved for that anchor;
83
11
  * actual profile registrations are nonempty. Scope counter stays zero. */
84
- export interface OAuthConnectedClientRegistrationTable<C extends Table> {
85
- readonly table: C;
86
- readonly clientKey: Column<C>;
87
- readonly provider: Column<C>;
88
- readonly issuer: Column<C>;
89
- readonly clientRegistrationId: Column<C>;
90
- readonly counter: Column<C>;
91
- readonly version: Column<C>;
92
- readonly encodeInsert: (configuration: M.OAuthConnectedConfiguration) => InferInsertModel<C>;
93
- }
12
+ export type OAuthConnectedClientRegistrationTable<C extends Table> = Shared.OAuthConnectedClientRegistrationTable<DrizzleTableModel<C>>;
94
13
  /** Remote authority: no local-subject column or subject-scoped key. Retain this
95
14
  * anchor/cutoff when a legitimately released tuple gains a different local owner. */
96
- export interface OAuthConnectedCohortTable<C extends Table> {
97
- readonly table: C;
98
- readonly cohortKey: Column<C>;
99
- readonly clientKey: Column<C>;
100
- readonly identityKey: Column<C>;
101
- readonly generation: Column<C>;
102
- readonly cutoff: Column<C>;
103
- readonly state: Column<C>;
104
- readonly version: Column<C>;
105
- readonly encodeInsert: (input: {
106
- readonly clientKey: string;
107
- readonly identityKey: string;
108
- }) => InferInsertModel<C>;
109
- }
110
- export interface OAuthConnectedAdmissionTable<A extends Table, N> {
111
- readonly table: A;
112
- readonly admissionId: Column<A>;
113
- readonly moduleId: Column<A>;
114
- readonly grantId: Column<A>;
115
- readonly subjectId: Column<A>;
116
- readonly identityKey: Column<A>;
117
- readonly clientKey: Column<A>;
118
- readonly cohortKey: Column<A>;
119
- readonly snapshot: Column<A>;
120
- readonly admittedAt: Column<A>;
121
- readonly expiresAt: Column<A>;
122
- readonly version: Column<A>;
123
- readonly encodeInsert: (input: {
124
- readonly admissionId: string;
125
- readonly grant: M.OAuthConnectedStoredGrant;
126
- readonly authorization: M.OAuthConnectedUseAuthorization;
127
- readonly subjectId: N;
128
- }) => InferInsertModel<A>;
129
- }
130
- export interface OAuthConnectedCommandTable<C extends Table, N> {
131
- readonly table: C;
132
- readonly moduleId: Column<C>;
133
- readonly commandId: Column<C>;
134
- readonly subjectId: Column<C>;
135
- readonly grantId: Column<C>;
136
- readonly intent: Column<C>;
137
- readonly decision: Column<C>;
138
- readonly retentionUntil: Column<C>;
139
- readonly version: Column<C>;
140
- readonly encodeInsert: (input: {
141
- readonly commandId: string;
142
- readonly grant: M.OAuthConnectedDisconnectGrant;
143
- readonly subjectId: N;
144
- }) => InferInsertModel<C>;
145
- }
146
- export interface OAuthConnectedRevocationJobTable<J extends Table, N> {
147
- readonly table: J;
148
- readonly jobId: Column<J>;
149
- readonly moduleId: Column<J>;
150
- readonly subjectId: Column<J>;
151
- readonly identityKey: Column<J>;
152
- readonly clientKey: Column<J>;
153
- readonly cohortKey: Column<J>;
154
- readonly grantId: Column<J>;
155
- readonly snapshot: Column<J>;
156
- readonly state: Column<J>;
157
- readonly claimId: Column<J>;
158
- readonly claimedAt: Column<J>;
159
- readonly claimExpiresAt: Column<J>;
160
- readonly retentionUntil: Column<J>;
161
- readonly version: Column<J>;
162
- readonly encodeInsert: (input: {
163
- readonly job: M.OAuthConnectedRevocationJob;
164
- readonly subjectId: N;
165
- }) => InferInsertModel<J>;
166
- }
167
- export type OAuthConnectedPolicyInput<N> = {
168
- readonly subjectId: N;
169
- readonly revision: OAuthAccountRevision;
170
- } & ({
171
- readonly kind: "action";
172
- readonly operation: "issue" | "claim" | "settle" | "disconnect";
173
- readonly authorization: M.OAuthConnectedActionAuthorization;
174
- readonly configuration: M.OAuthConnectedConfiguration;
175
- readonly grant?: M.OAuthConnectedTokenContext;
176
- } | {
177
- readonly kind: "sign-in";
178
- readonly credential: M.OAuthCredentialSnapshot;
179
- readonly configuration: M.OAuthConnectedConfiguration;
180
- readonly grant?: M.OAuthConnectedTokenContext;
181
- } | {
182
- readonly kind: "metadata" | "use";
183
- readonly authorization: M.OAuthConnectedUseAuthorization;
184
- readonly grant?: M.OAuthConnectedTokenContext;
185
- });
186
- export interface OAuthConnectedPolicyGuardTable<T extends Table, N> {
187
- readonly table: T;
188
- readonly orderBy: Column<T>;
189
- readonly condition: (input: OAuthConnectedPolicyInput<N>) => SQL;
190
- }
191
- export interface OAuthConnectedPolicyGuard<N> {
192
- readonly table: Table;
193
- readonly orderBy: string;
194
- readonly condition: (input: OAuthConnectedPolicyInput<N>) => SQL;
195
- }
15
+ export type OAuthConnectedCohortTable<C extends Table> = Shared.OAuthConnectedCohortTable<DrizzleTableModel<C>>;
16
+ export type OAuthConnectedAdmissionTable<A extends Table, N> = Shared.OAuthConnectedAdmissionTable<DrizzleTableModel<A>, N>;
17
+ export type OAuthConnectedCommandTable<C extends Table, N> = Shared.OAuthConnectedCommandTable<DrizzleTableModel<C>, N>;
18
+ export type OAuthConnectedRevocationJobTable<J extends Table, N> = Shared.OAuthConnectedRevocationJobTable<DrizzleTableModel<J>, N>;
19
+ export type OAuthConnectedPolicyGuardTable<T extends Table, N> = Shared.OAuthConnectedPolicyGuardTable<DrizzleTableModel<T>, N, SQL>;
20
+ export type OAuthConnectedPolicyGuard<N> = Shared.OAuthConnectedPolicyGuard<N, SQL, Table>;
196
21
  export declare const oauthConnectedPolicyGuard: <T extends Table, N>(input: OAuthConnectedPolicyGuardTable<T, N>) => OAuthConnectedPolicyGuard<N>;
197
- export interface OAuthConnectedSqlPolicy<N> {
198
- /** Up to 32 scopes, each selecting 1..64 stable rows in global lock order.
199
- * Omit only when subject/shared authority locks already serialize every mutable
200
- * policy dependency or policy is immutable. All writers follow that order. */
201
- readonly guards?: ReadonlyArray<OAuthConnectedPolicyGuard<N>>;
202
- /** Recheck exact policy revision, purpose, optional grant/profile restrictions
203
- * and current profile/permissions; joins and absence assumptions are authority.
204
- * The engine checks this before and after every owner/application write. */
205
- readonly condition: (input: OAuthConnectedPolicyInput<N>) => SQL;
206
- }
207
- export declare const requiredOAuthConnectedConstraints: {
208
- readonly flow: "unique(connectedFlow.moduleId,connectedFlow.flowId)";
209
- readonly flowCommand: "unique(connectedFlow.moduleId,connectedFlow.commandId)";
210
- readonly stateDigest: "unique(connectedFlow.stateDigest)";
211
- readonly client: "unique(connectedClient.clientKey)";
212
- readonly cohort: "unique(connectedCohort.cohortKey)";
213
- readonly grant: "unique(connectedGrant.moduleId,connectedGrant.grantId)";
214
- readonly grantIdentity: "unique(connectedGrant.moduleId,connectedGrant.subjectId,connectedGrant.profileKey,connectedGrant.activeIdentityKey)";
215
- readonly admission: "unique(connectedAdmission.admissionId)";
216
- readonly command: "unique(connectedCommand.moduleId,connectedCommand.commandId)";
217
- };
218
- export declare const requiredOAuthConnectedRevocationConstraints: {
219
- readonly job: "unique(connectedRevocation.jobId)";
220
- };
22
+ export type OAuthConnectedSqlPolicy<N> = Shared.OAuthConnectedSqlPolicy<N, SQL, Table>;
221
23
  /** Existing ownership only; workers never allocate or acquire a tuple. */
222
- export type OAuthConnectedOwnershipRead<T extends Table, O extends Table, N> = {
223
- readonly mode: "integrated";
224
- readonly tuple: Omit<OAuthOwnershipMutation<T, O, N>["tuple"], "encodeInsert">;
225
- } | {
226
- readonly mode: "separate";
227
- readonly tuple: Omit<OAuthOwnershipMutation<T, O, N>["tuple"], "encodeInsert">;
228
- readonly external: Omit<Extract<OAuthOwnershipMutation<T, O, N>, {
229
- readonly mode: "separate";
230
- }>["external"], "encodeInsert">;
231
- };
232
- export interface OAuthConnectedAuthorityMapping<T extends Table, O extends Table, F extends Table, G extends Table, C extends Table, H extends Table, N> {
233
- readonly ownership: OAuthConnectedOwnershipRead<T, O, N>;
234
- readonly subjectId: SubjectIdCodec<N>;
235
- readonly flow: Omit<OAuthConnectedFlowTable<F, N>, "encodeInsert">;
236
- readonly grant: Omit<OAuthConnectedGrantTable<G, N>, "encodeInsert">;
237
- readonly client: Omit<OAuthConnectedClientRegistrationTable<C>, "encodeInsert">;
238
- readonly cohort: Omit<OAuthConnectedCohortTable<H>, "encodeInsert">;
239
- readonly clock: OAuthClock;
240
- readonly order: OAuthConnectedOrderCodec;
241
- readonly tupleConstraints: typeof requiredOAuthTupleConstraints;
242
- /** Safe metadata retention, never an expiry/quiescence proof for unresolved work. */
243
- readonly retentionMillis: number;
244
- }
245
- export interface OAuthConnectedMapping<S extends Table, AC extends Table, T extends Table, O extends Table, F extends Table, G extends Table, C extends Table, H extends Table, A extends Table, D extends Table, N, J extends Table = never> extends OAuthConnectedAuthorityMapping<T, O, F, G, C, H, N> {
246
- readonly ownership: OAuthOwnershipMutation<T, O, N>;
247
- readonly flow: OAuthConnectedFlowTable<F, N>;
248
- readonly grant: OAuthConnectedGrantTable<G, N>;
249
- readonly client: OAuthConnectedClientRegistrationTable<C>;
250
- readonly cohort: OAuthConnectedCohortTable<H>;
251
- readonly subject: OAuthConnectedSubjectTable<S>;
252
- readonly authority: OAuthAuthorityReadTable<AC>;
253
- readonly admission: OAuthConnectedAdmissionTable<A, N>;
254
- /** Same shared sign-in tables used by OAuthSignInPersistence. Enable only
255
- * alongside a nullable connected-flow subjectId and flow.encodeSignIn. */
256
- readonly signIn?: {
257
- readonly credential: OAuthCredentialReadTable<Table>;
258
- readonly flow: OAuthFlowTable<Table>;
259
- };
260
- readonly command: OAuthConnectedCommandTable<D, N>;
261
- readonly policy: OAuthConnectedSqlPolicy<N>;
262
- readonly constraints: typeof requiredOAuthConnectedConstraints;
263
- readonly revocation: {
264
- readonly mode: "unsupported";
265
- } | {
266
- readonly mode: "cohort";
267
- readonly job: OAuthConnectedRevocationJobTable<J, N>;
268
- readonly constraints: typeof requiredOAuthConnectedRevocationConstraints;
269
- };
270
- /** Without an authoritative same-owner predicate, conservatively retain Owned.
271
- * Include login/other installed references; never filter away former-subject
272
- * work. This pure SQL constructor supports both bound values and correlated
273
- * column expressions with identical semantics; it performs no I/O.
274
- * Compare through the reference table's typed columns (for example, eq) so
275
- * native values use their encoders. Back the same-owner lookup with an index:
276
- * discovery applies this predicate before its candidate limit.
277
- * Connected references are checked separately. */
278
- readonly externalReference?: (input: {
279
- readonly identityKey: string;
280
- readonly subjectId: N;
281
- } | {
282
- readonly identityKey: SQL;
283
- readonly subjectId: SQL;
284
- }) => SQL;
285
- }
286
- export interface OAuthConnectedRevocationMapping<T extends Table, O extends Table, F extends Table, G extends Table, C extends Table, H extends Table, J extends Table, N> extends OAuthConnectedAuthorityMapping<T, O, F, G, C, H, N> {
287
- readonly job: Omit<OAuthConnectedRevocationJobTable<J, N>, "encodeInsert">;
288
- readonly constraints: typeof requiredOAuthConnectedRevocationConstraints;
289
- }
24
+ export type OAuthConnectedOwnershipRead<T extends Table, O extends Table, N> = Shared.OAuthConnectedOwnershipRead<DrizzleTableModel<T>, DrizzleTableModel<O>, N, SQL>;
25
+ export type OAuthConnectedAuthorityMapping<T extends Table, O extends Table, F extends Table, G extends Table, C extends Table, H extends Table, N> = Shared.OAuthConnectedAuthorityMapping<DrizzleTableModel<T>, DrizzleTableModel<O>, DrizzleTableModel<F>, DrizzleTableModel<G>, DrizzleTableModel<C>, DrizzleTableModel<H>, N, SQL>;
26
+ export type OAuthConnectedMapping<S extends Table, AC extends Table, T extends Table, O extends Table, F extends Table, G extends Table, C extends Table, H extends Table, A extends Table, D extends Table, N, J extends Table = never> = Shared.OAuthConnectedMapping<DrizzleTableModel<S>, DrizzleTableModel<AC>, DrizzleTableModel<T>, DrizzleTableModel<O>, DrizzleTableModel<F>, DrizzleTableModel<G>, DrizzleTableModel<C>, DrizzleTableModel<H>, DrizzleTableModel<A>, DrizzleTableModel<D>, N, DrizzleTableModel<J>, SQL, Table, DrizzleTableModel<Table>>;
27
+ export type OAuthConnectedRevocationMapping<T extends Table, O extends Table, F extends Table, G extends Table, C extends Table, H extends Table, J extends Table, N> = Shared.OAuthConnectedRevocationMapping<DrizzleTableModel<T>, DrizzleTableModel<O>, DrizzleTableModel<F>, DrizzleTableModel<G>, DrizzleTableModel<C>, DrizzleTableModel<H>, DrizzleTableModel<J>, N, SQL>;
290
28
  //#endregion
29
+ export { type OAuthConnectedAction, type OAuthConnectedOrderCodec, type OAuthConnectedPolicyInput, requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints };
291
30
  //# sourceMappingURL=oauth-connected-model.d.mts.map
@@ -1,21 +1,7 @@
1
+ import * as Shared from "@yielded/auth-persistence/Adapter";
2
+ import { requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints } from "@yielded/auth-persistence/Adapter";
1
3
  //#region src/drizzle/oauth-connected-model.ts
2
- const oauthConnectedPolicyGuard = (input) => Object.freeze({
3
- table: input.table,
4
- orderBy: input.orderBy,
5
- condition: input.condition
6
- });
7
- const requiredOAuthConnectedConstraints = {
8
- flow: "unique(connectedFlow.moduleId,connectedFlow.flowId)",
9
- flowCommand: "unique(connectedFlow.moduleId,connectedFlow.commandId)",
10
- stateDigest: "unique(connectedFlow.stateDigest)",
11
- client: "unique(connectedClient.clientKey)",
12
- cohort: "unique(connectedCohort.cohortKey)",
13
- grant: "unique(connectedGrant.moduleId,connectedGrant.grantId)",
14
- grantIdentity: "unique(connectedGrant.moduleId,connectedGrant.subjectId,connectedGrant.profileKey,connectedGrant.activeIdentityKey)",
15
- admission: "unique(connectedAdmission.admissionId)",
16
- command: "unique(connectedCommand.moduleId,connectedCommand.commandId)"
17
- };
18
- const requiredOAuthConnectedRevocationConstraints = { job: "unique(connectedRevocation.jobId)" };
4
+ const oauthConnectedPolicyGuard = (input) => Shared.oauthConnectedPolicyGuard(input);
19
5
  //#endregion
20
6
  export { oauthConnectedPolicyGuard, requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints };
21
7
 
@@ -1 +1 @@
1
- {"version":3,"file":"oauth-connected-model.mjs","names":[],"sources":["../../src/drizzle/oauth-connected-model.ts"],"sourcesContent":["import type { OAuthAccountRevision } from \"@yielded/auth/OAuth\";\nimport type * as M from \"@yielded/auth/OAuth\";\nimport type { AuthenticationRequirement } from \"@yielded/auth/Sessions\";\nimport type { InferInsertModel, InferSelectModel, SQL, Table } from \"drizzle-orm\";\n\nimport type { SubjectIdCodec } from \"./model\";\nimport type {\n OAuthAuthorityReadTable,\n OAuthClock,\n OAuthCredentialReadTable,\n OAuthFlowTable,\n OAuthOwnershipMutation,\n OAuthSubjectReadTable,\n requiredOAuthTupleConstraints,\n} from \"./oauth-model\";\n\ntype Column<T extends Table> = Extract<keyof T[\"_\"][\"columns\"], string>;\nexport type OAuthConnectedAction = M.OAuthConnectedActionChallenge[\"action\"];\n\nexport interface OAuthConnectedSubjectTable<S extends Table> extends OAuthSubjectReadTable<S> {\n readonly decodeActionRequirement: (\n row: InferSelectModel<S>,\n action: OAuthConnectedAction,\n ) => AuthenticationRequirement;\n}\n\n/** All mapped order columns use exact SQL integer comparison through 2^53-1.\n * These codecs bridge driver representations, not alternative ordering rules. */\nexport interface OAuthConnectedOrderCodec {\n readonly encode: (order: number) => unknown;\n readonly decode: (value: unknown) => number;\n}\n\nexport interface OAuthConnectedFlowTable<F extends Table, N> {\n readonly table: F;\n readonly moduleId: Column<F>;\n readonly flowId: Column<F>;\n readonly commandId: Column<F>;\n readonly subjectId: Column<F>;\n readonly clientKey: Column<F>;\n readonly cohortKey: Column<F>;\n readonly state: Column<F>;\n readonly version: Column<F>;\n readonly stateDigest: Column<F>;\n readonly snapshot: Column<F>;\n readonly claimId: Column<F>;\n readonly claimDigest: Column<F>;\n readonly claimOrder: Column<F>;\n readonly claimedAt: Column<F>;\n readonly claimExpiresAt: Column<F>;\n readonly expiresAt: Column<F>;\n readonly retentionUntil: Column<F>;\n /** None before claim, Unresolved after claim, Resolved only after definite\n * cancellation or atomic transfer to a grant/job. Never reset by cleanup. */\n readonly work: Column<F>;\n /** Exact sealed quarantine when no correctly sealed revocation job is available. */\n readonly custody: Column<F>;\n /** Required when retaining grants during sign-in. subjectId is NULL until\n * identity resolution; custom required columns are supplied by this encoder. */\n readonly encodeSignIn?: (reservation: M.OAuthSignInAccessClaim) => InferInsertModel<F>;\n readonly encodeInsert: (input: {\n readonly flow: M.OAuthConnectedPendingFlow;\n readonly subjectId: N;\n }) => InferInsertModel<F>;\n}\n\nexport interface OAuthConnectedGrantTable<G extends Table, N> {\n readonly table: G;\n readonly moduleId: Column<G>;\n readonly grantId: Column<G>;\n readonly subjectId: Column<G>;\n readonly identityKey: Column<G>;\n /** Nullable unique active slot; historical/disconnected records use null. */\n readonly activeIdentityKey: Column<G>;\n readonly clientKey: Column<G>;\n readonly cohortKey: Column<G>;\n readonly profileKey: Column<G>;\n readonly grantVersion: Column<G>;\n readonly tokenVersion: Column<G>;\n readonly cohortGeneration: Column<G>;\n readonly state: Column<G>;\n readonly version: Column<G>;\n readonly context: Column<G>;\n readonly sealed: Column<G>;\n /** Canonical OAuthConnectedSummary only: list never loads token envelopes. */\n readonly summary: Column<G>;\n readonly revocationJobId: Column<G>;\n readonly refreshWork: Column<G>;\n readonly refreshClaim: Column<G>;\n readonly refreshClaimExpiresAt: Column<G>;\n readonly retentionUntil: Column<G>;\n readonly encodeInsert: (input: {\n readonly grant: M.OAuthConnectedStoredGrant;\n readonly subjectId: N;\n }) => InferInsertModel<G>;\n}\n\n/** Also stores a permanent provider/issuer scope anchor. clientKey must fit 52\n * ASCII characters. Empty clientRegistrationId is reserved for that anchor;\n * actual profile registrations are nonempty. Scope counter stays zero. */\nexport interface OAuthConnectedClientRegistrationTable<C extends Table> {\n readonly table: C;\n readonly clientKey: Column<C>;\n readonly provider: Column<C>;\n readonly issuer: Column<C>;\n readonly clientRegistrationId: Column<C>;\n readonly counter: Column<C>;\n readonly version: Column<C>;\n readonly encodeInsert: (configuration: M.OAuthConnectedConfiguration) => InferInsertModel<C>;\n}\n\n/** Remote authority: no local-subject column or subject-scoped key. Retain this\n * anchor/cutoff when a legitimately released tuple gains a different local owner. */\nexport interface OAuthConnectedCohortTable<C extends Table> {\n readonly table: C;\n readonly cohortKey: Column<C>;\n readonly clientKey: Column<C>;\n readonly identityKey: Column<C>;\n readonly generation: Column<C>;\n readonly cutoff: Column<C>;\n readonly state: Column<C>;\n readonly version: Column<C>;\n readonly encodeInsert: (input: {\n readonly clientKey: string;\n readonly identityKey: string;\n }) => InferInsertModel<C>;\n}\n\nexport interface OAuthConnectedAdmissionTable<A extends Table, N> {\n readonly table: A;\n readonly admissionId: Column<A>;\n readonly moduleId: Column<A>;\n readonly grantId: Column<A>;\n readonly subjectId: Column<A>;\n readonly identityKey: Column<A>;\n readonly clientKey: Column<A>;\n readonly cohortKey: Column<A>;\n readonly snapshot: Column<A>;\n readonly admittedAt: Column<A>;\n readonly expiresAt: Column<A>;\n readonly version: Column<A>;\n readonly encodeInsert: (input: {\n readonly admissionId: string;\n readonly grant: M.OAuthConnectedStoredGrant;\n readonly authorization: M.OAuthConnectedUseAuthorization;\n readonly subjectId: N;\n }) => InferInsertModel<A>;\n}\n\nexport interface OAuthConnectedCommandTable<C extends Table, N> {\n readonly table: C;\n readonly moduleId: Column<C>;\n readonly commandId: Column<C>;\n readonly subjectId: Column<C>;\n readonly grantId: Column<C>;\n readonly intent: Column<C>;\n readonly decision: Column<C>;\n readonly retentionUntil: Column<C>;\n readonly version: Column<C>;\n readonly encodeInsert: (input: {\n readonly commandId: string;\n readonly grant: M.OAuthConnectedDisconnectGrant;\n readonly subjectId: N;\n }) => InferInsertModel<C>;\n}\n\nexport interface OAuthConnectedRevocationJobTable<J extends Table, N> {\n readonly table: J;\n readonly jobId: Column<J>;\n readonly moduleId: Column<J>;\n readonly subjectId: Column<J>;\n readonly identityKey: Column<J>;\n readonly clientKey: Column<J>;\n readonly cohortKey: Column<J>;\n readonly grantId: Column<J>;\n readonly snapshot: Column<J>;\n readonly state: Column<J>;\n readonly claimId: Column<J>;\n readonly claimedAt: Column<J>;\n readonly claimExpiresAt: Column<J>;\n readonly retentionUntil: Column<J>;\n readonly version: Column<J>;\n readonly encodeInsert: (input: {\n readonly job: M.OAuthConnectedRevocationJob;\n readonly subjectId: N;\n }) => InferInsertModel<J>;\n}\n\nexport type OAuthConnectedPolicyInput<N> = {\n readonly subjectId: N;\n readonly revision: OAuthAccountRevision;\n} & (\n | {\n readonly kind: \"action\";\n readonly operation: \"issue\" | \"claim\" | \"settle\" | \"disconnect\";\n readonly authorization: M.OAuthConnectedActionAuthorization;\n readonly configuration: M.OAuthConnectedConfiguration;\n readonly grant?: M.OAuthConnectedTokenContext;\n }\n | {\n readonly kind: \"sign-in\";\n readonly credential: M.OAuthCredentialSnapshot;\n readonly configuration: M.OAuthConnectedConfiguration;\n readonly grant?: M.OAuthConnectedTokenContext;\n }\n | {\n readonly kind: \"metadata\" | \"use\";\n readonly authorization: M.OAuthConnectedUseAuthorization;\n readonly grant?: M.OAuthConnectedTokenContext;\n }\n);\n\nexport interface OAuthConnectedPolicyGuardTable<T extends Table, N> {\n readonly table: T;\n readonly orderBy: Column<T>;\n readonly condition: (input: OAuthConnectedPolicyInput<N>) => SQL;\n}\n\nexport interface OAuthConnectedPolicyGuard<N> {\n readonly table: Table;\n readonly orderBy: string;\n readonly condition: (input: OAuthConnectedPolicyInput<N>) => SQL;\n}\n\nexport const oauthConnectedPolicyGuard = <T extends Table, N>(\n input: OAuthConnectedPolicyGuardTable<T, N>,\n): OAuthConnectedPolicyGuard<N> =>\n Object.freeze({\n table: input.table,\n orderBy: input.orderBy,\n condition: input.condition,\n });\n\nexport interface OAuthConnectedSqlPolicy<N> {\n /** Up to 32 scopes, each selecting 1..64 stable rows in global lock order.\n * Omit only when subject/shared authority locks already serialize every mutable\n * policy dependency or policy is immutable. All writers follow that order. */\n readonly guards?: ReadonlyArray<OAuthConnectedPolicyGuard<N>>;\n /** Recheck exact policy revision, purpose, optional grant/profile restrictions\n * and current profile/permissions; joins and absence assumptions are authority.\n * The engine checks this before and after every owner/application write. */\n readonly condition: (input: OAuthConnectedPolicyInput<N>) => SQL;\n}\n\nexport const requiredOAuthConnectedConstraints = {\n flow: \"unique(connectedFlow.moduleId,connectedFlow.flowId)\",\n flowCommand: \"unique(connectedFlow.moduleId,connectedFlow.commandId)\",\n stateDigest: \"unique(connectedFlow.stateDigest)\",\n client: \"unique(connectedClient.clientKey)\",\n cohort: \"unique(connectedCohort.cohortKey)\",\n grant: \"unique(connectedGrant.moduleId,connectedGrant.grantId)\",\n grantIdentity:\n \"unique(connectedGrant.moduleId,connectedGrant.subjectId,connectedGrant.profileKey,connectedGrant.activeIdentityKey)\",\n admission: \"unique(connectedAdmission.admissionId)\",\n command: \"unique(connectedCommand.moduleId,connectedCommand.commandId)\",\n} as const;\n\nexport const requiredOAuthConnectedRevocationConstraints = {\n job: \"unique(connectedRevocation.jobId)\",\n} as const;\n\n/** Existing ownership only; workers never allocate or acquire a tuple. */\nexport type OAuthConnectedOwnershipRead<T extends Table, O extends Table, N> =\n | {\n readonly mode: \"integrated\";\n readonly tuple: Omit<OAuthOwnershipMutation<T, O, N>[\"tuple\"], \"encodeInsert\">;\n }\n | {\n readonly mode: \"separate\";\n readonly tuple: Omit<OAuthOwnershipMutation<T, O, N>[\"tuple\"], \"encodeInsert\">;\n readonly external: Omit<\n Extract<OAuthOwnershipMutation<T, O, N>, { readonly mode: \"separate\" }>[\"external\"],\n \"encodeInsert\"\n >;\n };\n\nexport interface OAuthConnectedAuthorityMapping<\n T extends Table,\n O extends Table,\n F extends Table,\n G extends Table,\n C extends Table,\n H extends Table,\n N,\n> {\n readonly ownership: OAuthConnectedOwnershipRead<T, O, N>;\n readonly subjectId: SubjectIdCodec<N>;\n readonly flow: Omit<OAuthConnectedFlowTable<F, N>, \"encodeInsert\">;\n readonly grant: Omit<OAuthConnectedGrantTable<G, N>, \"encodeInsert\">;\n readonly client: Omit<OAuthConnectedClientRegistrationTable<C>, \"encodeInsert\">;\n readonly cohort: Omit<OAuthConnectedCohortTable<H>, \"encodeInsert\">;\n readonly clock: OAuthClock;\n readonly order: OAuthConnectedOrderCodec;\n readonly tupleConstraints: typeof requiredOAuthTupleConstraints;\n /** Safe metadata retention, never an expiry/quiescence proof for unresolved work. */\n readonly retentionMillis: number;\n}\n\nexport interface OAuthConnectedMapping<\n S extends Table,\n AC extends Table,\n T extends Table,\n O extends Table,\n F extends Table,\n G extends Table,\n C extends Table,\n H extends Table,\n A extends Table,\n D extends Table,\n N,\n J extends Table = never,\n> extends OAuthConnectedAuthorityMapping<T, O, F, G, C, H, N> {\n readonly ownership: OAuthOwnershipMutation<T, O, N>;\n readonly flow: OAuthConnectedFlowTable<F, N>;\n readonly grant: OAuthConnectedGrantTable<G, N>;\n readonly client: OAuthConnectedClientRegistrationTable<C>;\n readonly cohort: OAuthConnectedCohortTable<H>;\n readonly subject: OAuthConnectedSubjectTable<S>;\n readonly authority: OAuthAuthorityReadTable<AC>;\n readonly admission: OAuthConnectedAdmissionTable<A, N>;\n /** Same shared sign-in tables used by OAuthSignInPersistence. Enable only\n * alongside a nullable connected-flow subjectId and flow.encodeSignIn. */\n readonly signIn?: {\n readonly credential: OAuthCredentialReadTable<Table>;\n readonly flow: OAuthFlowTable<Table>;\n };\n readonly command: OAuthConnectedCommandTable<D, N>;\n readonly policy: OAuthConnectedSqlPolicy<N>;\n readonly constraints: typeof requiredOAuthConnectedConstraints;\n readonly revocation:\n | { readonly mode: \"unsupported\" }\n | {\n readonly mode: \"cohort\";\n readonly job: OAuthConnectedRevocationJobTable<J, N>;\n readonly constraints: typeof requiredOAuthConnectedRevocationConstraints;\n };\n /** Without an authoritative same-owner predicate, conservatively retain Owned.\n * Include login/other installed references; never filter away former-subject\n * work. This pure SQL constructor supports both bound values and correlated\n * column expressions with identical semantics; it performs no I/O.\n * Compare through the reference table's typed columns (for example, eq) so\n * native values use their encoders. Back the same-owner lookup with an index:\n * discovery applies this predicate before its candidate limit.\n * Connected references are checked separately. */\n readonly externalReference?: (\n input:\n | { readonly identityKey: string; readonly subjectId: N }\n | { readonly identityKey: SQL; readonly subjectId: SQL },\n ) => SQL;\n}\n\nexport interface OAuthConnectedRevocationMapping<\n T extends Table,\n O extends Table,\n F extends Table,\n G extends Table,\n C extends Table,\n H extends Table,\n J extends Table,\n N,\n> extends OAuthConnectedAuthorityMapping<T, O, F, G, C, H, N> {\n readonly job: Omit<OAuthConnectedRevocationJobTable<J, N>, \"encodeInsert\">;\n readonly constraints: typeof requiredOAuthConnectedRevocationConstraints;\n}\n"],"mappings":";AAgOA,MAAa,6BACX,UAEA,OAAO,OAAO;CACZ,OAAO,MAAM;CACb,SAAS,MAAM;CACf,WAAW,MAAM;AACnB,CAAC;AAaH,MAAa,oCAAoC;CAC/C,MAAM;CACN,aAAa;CACb,aAAa;CACb,QAAQ;CACR,QAAQ;CACR,OAAO;CACP,eACE;CACF,WAAW;CACX,SAAS;AACX;AAEA,MAAa,8CAA8C,EACzD,KAAK,oCACP"}
1
+ {"version":3,"file":"oauth-connected-model.mjs","names":[],"sources":["../../src/drizzle/oauth-connected-model.ts"],"sourcesContent":["import * as Shared from \"@yielded/auth-persistence/Adapter\";\nimport type { SQL, Table } from \"drizzle-orm\";\n\nimport type { DrizzleTableModel } from \"./table-model\";\n\nexport {\n type OAuthConnectedAction,\n type OAuthConnectedOrderCodec,\n type OAuthConnectedPolicyInput,\n requiredOAuthConnectedConstraints,\n requiredOAuthConnectedRevocationConstraints,\n} from \"@yielded/auth-persistence/Adapter\";\n\nexport type OAuthConnectedSubjectTable<S extends Table> = Shared.OAuthConnectedSubjectTable<\n DrizzleTableModel<S>,\n SQL\n>;\n\nexport type OAuthConnectedFlowTable<F extends Table, N> = Shared.OAuthConnectedFlowTable<\n DrizzleTableModel<F>,\n N\n>;\n\nexport type OAuthConnectedGrantTable<G extends Table, N> = Shared.OAuthConnectedGrantTable<\n DrizzleTableModel<G>,\n N\n>;\n\n/** Also stores a permanent provider/issuer scope anchor. clientKey must fit 52\n * ASCII characters. Empty clientRegistrationId is reserved for that anchor;\n * actual profile registrations are nonempty. Scope counter stays zero. */\nexport type OAuthConnectedClientRegistrationTable<C extends Table> =\n Shared.OAuthConnectedClientRegistrationTable<DrizzleTableModel<C>>;\n\n/** Remote authority: no local-subject column or subject-scoped key. Retain this\n * anchor/cutoff when a legitimately released tuple gains a different local owner. */\nexport type OAuthConnectedCohortTable<C extends Table> = Shared.OAuthConnectedCohortTable<\n DrizzleTableModel<C>\n>;\n\nexport type OAuthConnectedAdmissionTable<A extends Table, N> = Shared.OAuthConnectedAdmissionTable<\n DrizzleTableModel<A>,\n N\n>;\n\nexport type OAuthConnectedCommandTable<C extends Table, N> = Shared.OAuthConnectedCommandTable<\n DrizzleTableModel<C>,\n N\n>;\n\nexport type OAuthConnectedRevocationJobTable<\n J extends Table,\n N,\n> = Shared.OAuthConnectedRevocationJobTable<DrizzleTableModel<J>, N>;\n\nexport type OAuthConnectedPolicyGuardTable<\n T extends Table,\n N,\n> = Shared.OAuthConnectedPolicyGuardTable<DrizzleTableModel<T>, N, SQL>;\n\nexport type OAuthConnectedPolicyGuard<N> = Shared.OAuthConnectedPolicyGuard<N, SQL, Table>;\n\nexport const oauthConnectedPolicyGuard = <T extends Table, N>(\n input: OAuthConnectedPolicyGuardTable<T, N>,\n): OAuthConnectedPolicyGuard<N> =>\n Shared.oauthConnectedPolicyGuard<DrizzleTableModel<T>, N, SQL>(input);\n\nexport type OAuthConnectedSqlPolicy<N> = Shared.OAuthConnectedSqlPolicy<N, SQL, Table>;\n\n/** Existing ownership only; workers never allocate or acquire a tuple. */\nexport type OAuthConnectedOwnershipRead<\n T extends Table,\n O extends Table,\n N,\n> = Shared.OAuthConnectedOwnershipRead<DrizzleTableModel<T>, DrizzleTableModel<O>, N, SQL>;\n\nexport type OAuthConnectedAuthorityMapping<\n T extends Table,\n O extends Table,\n F extends Table,\n G extends Table,\n C extends Table,\n H extends Table,\n N,\n> = Shared.OAuthConnectedAuthorityMapping<\n DrizzleTableModel<T>,\n DrizzleTableModel<O>,\n DrizzleTableModel<F>,\n DrizzleTableModel<G>,\n DrizzleTableModel<C>,\n DrizzleTableModel<H>,\n N,\n SQL\n>;\n\nexport type OAuthConnectedMapping<\n S extends Table,\n AC extends Table,\n T extends Table,\n O extends Table,\n F extends Table,\n G extends Table,\n C extends Table,\n H extends Table,\n A extends Table,\n D extends Table,\n N,\n J extends Table = never,\n> = Shared.OAuthConnectedMapping<\n DrizzleTableModel<S>,\n DrizzleTableModel<AC>,\n DrizzleTableModel<T>,\n DrizzleTableModel<O>,\n DrizzleTableModel<F>,\n DrizzleTableModel<G>,\n DrizzleTableModel<C>,\n DrizzleTableModel<H>,\n DrizzleTableModel<A>,\n DrizzleTableModel<D>,\n N,\n DrizzleTableModel<J>,\n SQL,\n Table,\n DrizzleTableModel<Table>\n>;\n\nexport type OAuthConnectedRevocationMapping<\n T extends Table,\n O extends Table,\n F extends Table,\n G extends Table,\n C extends Table,\n H extends Table,\n J extends Table,\n N,\n> = Shared.OAuthConnectedRevocationMapping<\n DrizzleTableModel<T>,\n DrizzleTableModel<O>,\n DrizzleTableModel<F>,\n DrizzleTableModel<G>,\n DrizzleTableModel<C>,\n DrizzleTableModel<H>,\n DrizzleTableModel<J>,\n N,\n SQL\n>;\n"],"mappings":";;;AA8DA,MAAa,6BACX,UAEA,OAAO,0BAAwD,KAAK"}
@@ -1,10 +1,8 @@
1
1
  import { OAuthReferenceGuardDescriptor } from "./oauth-model.mjs";
2
2
  import { OAuthConnectedMapping } from "./oauth-connected-model.mjs";
3
- import "./oauth-connected-state.mjs";
4
3
  import { SQL, Table } from "drizzle-orm";
5
4
  //#region src/drizzle/oauth-connected-reference.d.ts
6
- /** Compose Accounts.Unlink with this connected authority. The stable scope lock
7
- * serializes unknown claims across every client registration for an issuer. */
5
+ /** Compose login unlink with retained-grant ownership under this compiler. */
8
6
  export declare const oauthConnectedOwnershipReferences: <S extends Table, AC extends Table, T extends Table, O extends Table, F extends Table, G extends Table, C extends Table, H extends Table, A extends Table, D extends Table, N, J extends Table>(original: OAuthConnectedMapping<S, AC, T, O, F, G, C, H, A, D, N, J>) => {
9
7
  readonly connectedReferenceGuards: ReadonlyArray<OAuthReferenceGuardDescriptor<N>>;
10
8
  readonly connectedReference: (input: {
@@ -1,57 +1,8 @@
1
- import { oauthReferenceGuardTable } from "./oauth-model.mjs";
2
- import { captureOAuthMapping } from "./oauth-state.mjs";
3
- import { both } from "./transaction-owner.mjs";
4
- import { col, equal } from "./oauth-owner.mjs";
5
- import { scopeKey } from "./oauth-connected-state.mjs";
6
- import { eq, is, sql } from "drizzle-orm";
7
- import { Effect } from "effect";
8
- import { MySqlTable } from "drizzle-orm/mysql-core/table";
9
- import { PgTable } from "drizzle-orm/pg-core/table";
1
+ import { oauthKernel } from "./oauth-kernel.mjs";
10
2
  //#region src/drizzle/oauth-connected-reference.ts
11
- const exactText = (table, key, value) => {
12
- const column = col(table, key), bound = sql.param(value, column);
13
- return is(table, MySqlTable) ? sql`binary ${column} = binary ${bound}` : is(table, PgTable) ? sql`convert_to(cast(${column} as text),'UTF8') = convert_to(cast(${bound} as text),'UTF8')` : sql`cast(${column} as blob) = cast(${bound} as blob)`;
14
- };
15
- /** Compose Accounts.Unlink with this connected authority. The stable scope lock
16
- * serializes unknown claims across every client registration for an issuer. */
17
- const oauthConnectedOwnershipReferences = (original) => {
18
- const mapping = captureOAuthMapping(original), c = mapping.client;
19
- return Object.freeze({
20
- connectedReferenceGuards: [oauthReferenceGuardTable({
21
- table: c.table,
22
- orderBy: c.clientKey,
23
- condition: (input) => Effect.gen(function* () {
24
- const key = yield* scopeKey(input.identity.provider, input.identity.issuer);
25
- return both(equal(c.table, {
26
- [c.clientKey]: key,
27
- [c.counter]: mapping.order.encode(0)
28
- }), exactText(c.table, c.provider, input.identity.provider), exactText(c.table, c.issuer, input.identity.issuer), exactText(c.table, c.clientRegistrationId, ""));
29
- })
30
- })],
31
- connectedReference: (input) => connectedReferenceCondition(mapping, input.identityKey)
32
- });
33
- };
34
- const connectedReferenceCondition = (mapping, identityKey, knownIdentity) => {
35
- const c = mapping.client, t = mapping.ownership.tuple, f = mapping.flow, g = mapping.grant, h = mapping.cohort, a = mapping.admission, j = mapping.revocation.mode === "cohort" ? mapping.revocation.job : void 0;
36
- const tuple = equal(t.table, { [t.identityKey]: identityKey });
37
- const knownFlow = sql`exists(select 1 from ${h.table} where ${col(h.table, h.cohortKey)} = ${col(f.table, f.cohortKey)} and ${col(h.table, h.identityKey)} = ${identityKey})`;
38
- const unknownFlow = knownIdentity === void 0 ? sql`${col(f.table, f.cohortKey)} is null and exists(select 1 from ${c.table} where ${col(c.table, c.clientKey)} = ${col(f.table, f.clientKey)} and exists(select 1 from ${t.table} where ${tuple} and ${col(c.table, c.provider)} = ${col(t.table, t.provider)} and ${col(c.table, c.issuer)} = ${col(t.table, t.issuer)}))` : sql`${col(f.table, f.cohortKey)} is null and exists(select 1 from ${c.table} where ${col(c.table, c.clientKey)} = ${col(f.table, f.clientKey)} and ${col(c.table, c.provider)} = ${knownIdentity.provider} and ${col(c.table, c.issuer)} = ${knownIdentity.issuer})`;
39
- const related = [
40
- f,
41
- g,
42
- h,
43
- ...j === void 0 ? [] : [j]
44
- ];
45
- return sql`(${sql.join([
46
- sql`exists(select 1 from ${g.table} where ${eq(col(g.table, g.identityKey), identityKey)})`,
47
- sql`exists(select 1 from ${a.table} where ${eq(col(a.table, a.identityKey), identityKey)})`,
48
- sql`exists(select 1 from ${h.table} where ${both(eq(col(h.table, h.identityKey), identityKey), eq(col(h.table, h.state), "Blocked"))})`,
49
- sql`exists(select 1 from ${f.table} where ${col(f.table, f.work)} = 'Unresolved' and (${knownFlow} or (${unknownFlow})))`,
50
- ...j === void 0 ? [] : [sql`exists(select 1 from ${j.table} where ${eq(col(j.table, j.identityKey), identityKey)})`],
51
- ...related.map((v) => sql`exists(select 1 from ${v.table} where not exists(select 1 from ${c.table} where ${col(c.table, c.clientKey)} = ${col(v.table, v.clientKey)}))`)
52
- ], sql` or `)})`;
53
- };
3
+ /** Compose login unlink with retained-grant ownership under this compiler. */
4
+ const oauthConnectedOwnershipReferences = (original) => oauthKernel.connectedReference.oauthConnectedOwnershipReferences(original);
54
5
  //#endregion
55
- export { connectedReferenceCondition, oauthConnectedOwnershipReferences };
6
+ export { oauthConnectedOwnershipReferences };
56
7
 
57
8
  //# sourceMappingURL=oauth-connected-reference.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"oauth-connected-reference.mjs","names":[],"sources":["../../src/drizzle/oauth-connected-reference.ts"],"sourcesContent":["import { eq, is, sql, type SQL, type Table } from \"drizzle-orm\";\nimport { MySqlTable } from \"drizzle-orm/mysql-core/table\";\nimport { PgTable } from \"drizzle-orm/pg-core/table\";\nimport { Effect } from \"effect\";\n\nimport type { OAuthConnectedMapping } from \"./oauth-connected-model\";\nimport { scopeKey, type Mapping } from \"./oauth-connected-state\";\nimport { oauthReferenceGuardTable, type OAuthReferenceGuardDescriptor } from \"./oauth-model\";\nimport { both, col, equal } from \"./oauth-owner\";\nimport { captureOAuthMapping } from \"./oauth-state\";\n\nconst exactText = (table: Table, key: string, value: string) => {\n const column = col(table, key),\n bound = sql.param(value, column);\n\n return is(table, MySqlTable)\n ? sql`binary ${column} = binary ${bound}`\n : is(table, PgTable)\n ? sql`convert_to(cast(${column} as text),'UTF8') = convert_to(cast(${bound} as text),'UTF8')`\n : sql`cast(${column} as blob) = cast(${bound} as blob)`;\n};\n\n/** Compose Accounts.Unlink with this connected authority. The stable scope lock\n * serializes unknown claims across every client registration for an issuer. */\nexport const oauthConnectedOwnershipReferences = <\n S extends Table,\n AC extends Table,\n T extends Table,\n O extends Table,\n F extends Table,\n G extends Table,\n C extends Table,\n H extends Table,\n A extends Table,\n D extends Table,\n N,\n J extends Table,\n>(\n original: OAuthConnectedMapping<S, AC, T, O, F, G, C, H, A, D, N, J>,\n): {\n readonly connectedReferenceGuards: ReadonlyArray<OAuthReferenceGuardDescriptor<N>>;\n readonly connectedReference: (input: {\n readonly identityKey: string;\n readonly subjectId: N;\n }) => SQL;\n} => {\n const mapping = captureOAuthMapping(original),\n c = mapping.client;\n\n return Object.freeze({\n connectedReferenceGuards: [\n oauthReferenceGuardTable<C, N>({\n table: c.table,\n orderBy: c.clientKey,\n condition: (input) =>\n Effect.gen(function* () {\n const key = yield* scopeKey(input.identity.provider, input.identity.issuer);\n\n return both(\n equal(c.table, {\n [c.clientKey]: key,\n [c.counter]: mapping.order.encode(0),\n }),\n exactText(c.table, c.provider, input.identity.provider),\n exactText(c.table, c.issuer, input.identity.issuer),\n exactText(c.table, c.clientRegistrationId, \"\"),\n );\n }),\n }),\n ],\n connectedReference: (input) => connectedReferenceCondition(mapping, input.identityKey),\n });\n};\n\nexport const connectedReferenceCondition = (\n mapping: Mapping,\n identityKey: string | SQL,\n knownIdentity?: { readonly provider: string | SQL; readonly issuer: string | SQL },\n) => {\n const c = mapping.client,\n t = mapping.ownership.tuple,\n f = mapping.flow,\n g = mapping.grant,\n h = mapping.cohort,\n a = mapping.admission,\n j = mapping.revocation.mode === \"cohort\" ? mapping.revocation.job : undefined;\n\n const tuple = equal(t.table, { [t.identityKey]: identityKey });\n const knownFlow = sql`exists(select 1 from ${h.table} where ${col(h.table, h.cohortKey)} = ${col(f.table, f.cohortKey)} and ${col(h.table, h.identityKey)} = ${identityKey})`;\n\n const unknownFlow =\n knownIdentity === undefined\n ? sql`${col(f.table, f.cohortKey)} is null and exists(select 1 from ${c.table} where ${col(c.table, c.clientKey)} = ${col(f.table, f.clientKey)} and exists(select 1 from ${t.table} where ${tuple} and ${col(c.table, c.provider)} = ${col(t.table, t.provider)} and ${col(c.table, c.issuer)} = ${col(t.table, t.issuer)}))`\n : sql`${col(f.table, f.cohortKey)} is null and exists(select 1 from ${c.table} where ${col(c.table, c.clientKey)} = ${col(f.table, f.clientKey)} and ${col(c.table, c.provider)} = ${knownIdentity.provider} and ${col(c.table, c.issuer)} = ${knownIdentity.issuer})`;\n\n const related = [f, g, h, ...(j === undefined ? [] : [j])];\n\n return sql`(${sql.join(\n [\n sql`exists(select 1 from ${g.table} where ${eq(col(g.table, g.identityKey), identityKey)})`,\n sql`exists(select 1 from ${a.table} where ${eq(col(a.table, a.identityKey), identityKey)})`,\n sql`exists(select 1 from ${h.table} where ${both(eq(col(h.table, h.identityKey), identityKey), eq(col(h.table, h.state), \"Blocked\"))})`,\n sql`exists(select 1 from ${f.table} where ${col(f.table, f.work)} = 'Unresolved' and (${knownFlow} or (${unknownFlow})))`,\n ...(j === undefined\n ? []\n : [\n sql`exists(select 1 from ${j.table} where ${eq(col(j.table, j.identityKey), identityKey)})`,\n ]),\n // A missing real client cannot turn erased unknown work into absence.\n ...related.map(\n (v) =>\n sql`exists(select 1 from ${v.table} where not exists(select 1 from ${c.table} where ${col(c.table, c.clientKey)} = ${col(v.table, v.clientKey)}))`,\n ),\n ],\n sql` or `,\n )})`;\n};\n"],"mappings":";;;;;;;;;;AAWA,MAAM,aAAa,OAAc,KAAa,UAAkB;CAC9D,MAAM,SAAS,IAAI,OAAO,GAAG,GAC3B,QAAQ,IAAI,MAAM,OAAO,MAAM;CAEjC,OAAO,GAAG,OAAO,UAAU,IACvB,GAAG,UAAU,OAAO,YAAY,UAChC,GAAG,OAAO,OAAO,IACf,GAAG,mBAAmB,OAAO,sCAAsC,MAAM,qBACzE,GAAG,QAAQ,OAAO,mBAAmB,MAAM;AACnD;;;AAIA,MAAa,qCAcX,aAOG;CACH,MAAM,UAAU,oBAAoB,QAAQ,GAC1C,IAAI,QAAQ;CAEd,OAAO,OAAO,OAAO;EACnB,0BAA0B,CACxB,yBAA+B;GAC7B,OAAO,EAAE;GACT,SAAS,EAAE;GACX,YAAY,UACV,OAAO,IAAI,aAAa;IACtB,MAAM,MAAM,OAAO,SAAS,MAAM,SAAS,UAAU,MAAM,SAAS,MAAM;IAE1E,OAAO,KACL,MAAM,EAAE,OAAO;MACZ,EAAE,YAAY;MACd,EAAE,UAAU,QAAQ,MAAM,OAAO,CAAC;IACrC,CAAC,GACD,UAAU,EAAE,OAAO,EAAE,UAAU,MAAM,SAAS,QAAQ,GACtD,UAAU,EAAE,OAAO,EAAE,QAAQ,MAAM,SAAS,MAAM,GAClD,UAAU,EAAE,OAAO,EAAE,sBAAsB,EAAE,CAC/C;GACF,CAAC;EACL,CAAC,CACH;EACA,qBAAqB,UAAU,4BAA4B,SAAS,MAAM,WAAW;CACvF,CAAC;AACH;AAEA,MAAa,+BACX,SACA,aACA,kBACG;CACH,MAAM,IAAI,QAAQ,QAChB,IAAI,QAAQ,UAAU,OACtB,IAAI,QAAQ,MACZ,IAAI,QAAQ,OACZ,IAAI,QAAQ,QACZ,IAAI,QAAQ,WACZ,IAAI,QAAQ,WAAW,SAAS,WAAW,QAAQ,WAAW,MAAM,KAAA;CAEtE,MAAM,QAAQ,MAAM,EAAE,OAAO,GAAG,EAAE,cAAc,YAAY,CAAC;CAC7D,MAAM,YAAY,GAAG,wBAAwB,EAAE,MAAM,SAAS,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY;CAE3K,MAAM,cACJ,kBAAkB,KAAA,IACd,GAAG,GAAG,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,oCAAoC,EAAE,MAAM,SAAS,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,4BAA4B,EAAE,MAAM,SAAS,MAAM,OAAO,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,MACzT,GAAG,GAAG,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,oCAAoC,EAAE,MAAM,SAAS,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,cAAc,SAAS,OAAO,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,cAAc,OAAO;CAExQ,MAAM,UAAU;EAAC;EAAG;EAAG;EAAG,GAAI,MAAM,KAAA,IAAY,CAAC,IAAI,CAAC,CAAC;CAAE;CAEzD,OAAO,GAAG,IAAI,IAAI,KAChB;EACE,GAAG,wBAAwB,EAAE,MAAM,SAAS,GAAG,IAAI,EAAE,OAAO,EAAE,WAAW,GAAG,WAAW,EAAE;EACzF,GAAG,wBAAwB,EAAE,MAAM,SAAS,GAAG,IAAI,EAAE,OAAO,EAAE,WAAW,GAAG,WAAW,EAAE;EACzF,GAAG,wBAAwB,EAAE,MAAM,SAAS,KAAK,GAAG,IAAI,EAAE,OAAO,EAAE,WAAW,GAAG,WAAW,GAAG,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,GAAG,SAAS,CAAC,EAAE;EACrI,GAAG,wBAAwB,EAAE,MAAM,SAAS,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,uBAAuB,UAAU,OAAO,YAAY;EACrH,GAAI,MAAM,KAAA,IACN,CAAC,IACD,CACE,GAAG,wBAAwB,EAAE,MAAM,SAAS,GAAG,IAAI,EAAE,OAAO,EAAE,WAAW,GAAG,WAAW,EAAE,EAC3F;EAEJ,GAAG,QAAQ,KACR,MACC,GAAG,wBAAwB,EAAE,MAAM,kCAAkC,EAAE,MAAM,SAAS,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GACnJ;CACF,GACA,GAAG,MACL,EAAE;AACJ"}
1
+ {"version":3,"file":"oauth-connected-reference.mjs","names":[],"sources":["../../src/drizzle/oauth-connected-reference.ts"],"sourcesContent":["import type { SQL, Table } from \"drizzle-orm\";\n\nimport type { OAuthConnectedMapping } from \"./oauth-connected-model\";\nimport { oauthKernel } from \"./oauth-kernel\";\nimport type { OAuthReferenceGuardDescriptor } from \"./oauth-model\";\n\n/** Compose login unlink with retained-grant ownership under this compiler. */\nexport const oauthConnectedOwnershipReferences = <\n S extends Table,\n AC extends Table,\n T extends Table,\n O extends Table,\n F extends Table,\n G extends Table,\n C extends Table,\n H extends Table,\n A extends Table,\n D extends Table,\n N,\n J extends Table,\n>(\n original: OAuthConnectedMapping<S, AC, T, O, F, G, C, H, A, D, N, J>,\n): {\n readonly connectedReferenceGuards: ReadonlyArray<OAuthReferenceGuardDescriptor<N>>;\n readonly connectedReference: (input: {\n readonly identityKey: string;\n readonly subjectId: N;\n }) => SQL;\n} =>\n // The shared kernel returns this adapter's expressions; only compiler handles are erased.\n oauthKernel.connectedReference.oauthConnectedOwnershipReferences(original) as {\n readonly connectedReferenceGuards: ReadonlyArray<OAuthReferenceGuardDescriptor<N>>;\n readonly connectedReference: (input: {\n readonly identityKey: string;\n readonly subjectId: N;\n }) => SQL;\n };\n"],"mappings":";;;AAOA,MAAa,qCAcX,aASA,YAAY,mBAAmB,kCAAkC,QAAQ"}