@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.
- package/README.md +3 -0
- package/dist/D1.d.mts +11 -11
- package/dist/D1.mjs +2 -1
- package/dist/D1.mjs.map +1 -1
- package/dist/Libsql.d.mts +40 -56
- package/dist/Libsql.mjs +2 -1
- package/dist/Libsql.mjs.map +1 -1
- package/dist/Mysql2.d.mts +16 -17
- package/dist/Pglite.d.mts +18 -18
- package/dist/Pglite.mjs +2 -1
- package/dist/Pglite.mjs.map +1 -1
- package/dist/Postgres.d.mts +24 -24
- package/dist/Postgres.mjs +2 -1
- package/dist/Postgres.mjs.map +1 -1
- package/dist/SqliteBun.d.mts +39 -55
- package/dist/SqliteBun.mjs +2 -1
- package/dist/SqliteBun.mjs.map +1 -1
- package/dist/SqliteDo.d.mts +48 -64
- package/dist/SqliteDo.mjs +2 -1
- package/dist/SqliteDo.mjs.map +1 -1
- package/dist/SqliteNode.d.mts +45 -61
- package/dist/SqliteNode.mjs +2 -1
- package/dist/SqliteNode.mjs.map +1 -1
- package/dist/SqliteWasm.d.mts +48 -64
- package/dist/SqliteWasm.mjs +2 -1
- package/dist/SqliteWasm.mjs.map +1 -1
- package/dist/drizzle/crypto.mjs +1 -1
- package/dist/drizzle/d1-emails.d.mts +1 -1
- package/dist/drizzle/d1-oauth.d.mts +14 -14
- package/dist/drizzle/d1-passkey.d.mts +1 -1
- package/dist/drizzle/d1-password-prepared.d.mts +4 -4
- package/dist/drizzle/d1-password-prepared.mjs.map +1 -1
- package/dist/drizzle/d1-passwords.d.mts +18 -35
- package/dist/drizzle/d1-passwords.mjs +78 -290
- package/dist/drizzle/d1-passwords.mjs.map +1 -1
- package/dist/drizzle/d1-phone.d.mts +1 -1
- package/dist/drizzle/d1-proofs.d.mts +2 -2
- package/dist/drizzle/d1-sessions.d.mts +3 -3
- package/dist/drizzle/d1-sessions.mjs +11 -6
- package/dist/drizzle/d1-sessions.mjs.map +1 -1
- package/dist/drizzle/d1-totp.d.mts +1 -1
- package/dist/drizzle/mysql-password-prepared.d.mts +5 -5
- package/dist/drizzle/mysql-password-prepared.mjs.map +1 -1
- package/dist/drizzle/mysql-passwords.d.mts +16 -32
- package/dist/drizzle/mysql-passwords.mjs.map +1 -1
- package/dist/drizzle/mysql-sessions.d.mts +1 -1
- package/dist/drizzle/native-sql-table.mjs +135 -0
- package/dist/drizzle/native-sql-table.mjs.map +1 -0
- package/dist/drizzle/oauth-connected-model.d.mts +20 -281
- package/dist/drizzle/oauth-connected-model.mjs +3 -17
- package/dist/drizzle/oauth-connected-model.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-reference.d.mts +1 -3
- package/dist/drizzle/oauth-connected-reference.mjs +4 -53
- package/dist/drizzle/oauth-connected-reference.mjs.map +1 -1
- package/dist/drizzle/oauth-connected-target.d.mts +3 -990
- package/dist/drizzle/oauth-connected-target.mjs +8 -92
- package/dist/drizzle/oauth-connected-target.mjs.map +1 -1
- package/dist/drizzle/oauth-kernel.mjs +11 -0
- package/dist/drizzle/oauth-kernel.mjs.map +1 -0
- package/dist/drizzle/oauth-model.d.mts +35 -438
- package/dist/drizzle/oauth-model.mjs +6 -44
- package/dist/drizzle/oauth-model.mjs.map +1 -1
- package/dist/drizzle/oauth-mysql.mjs +2 -2
- package/dist/drizzle/oauth-mysql.mjs.map +1 -1
- package/dist/drizzle/oauth-proxy.d.mts +10 -0
- package/dist/drizzle/oauth-proxy.mjs +54 -0
- package/dist/drizzle/oauth-proxy.mjs.map +1 -0
- package/dist/drizzle/oauth-target.d.mts +6 -107
- package/dist/drizzle/oauth-target.mjs +15 -245
- package/dist/drizzle/oauth-target.mjs.map +1 -1
- package/dist/drizzle/password-model.d.mts +5 -8
- package/dist/drizzle/password-prepared-model.d.mts +5 -5
- package/dist/drizzle/password-prepared-model.mjs.map +1 -1
- package/dist/drizzle/password-prepared-state.mjs +1 -1
- package/dist/drizzle/password-sql.mjs +2 -1
- package/dist/drizzle/password-sql.mjs.map +1 -1
- package/dist/drizzle/password-target.mjs +13 -2
- package/dist/drizzle/password-target.mjs.map +1 -1
- package/dist/drizzle/pg-password-prepared.d.mts +5 -5
- package/dist/drizzle/pg-password-prepared.mjs.map +1 -1
- package/dist/drizzle/pg-passwords.d.mts +16 -32
- package/dist/drizzle/pg-passwords.mjs.map +1 -1
- package/dist/drizzle/pg-sessions.d.mts +1 -1
- package/dist/drizzle/phone-target.d.mts +2 -2
- package/dist/drizzle/phone-target.mjs +1 -1
- package/dist/drizzle/query-operations.mjs +3 -1
- package/dist/drizzle/query-operations.mjs.map +1 -1
- package/dist/drizzle/session-sql.mjs +2 -1
- package/dist/drizzle/session-sql.mjs.map +1 -1
- package/dist/drizzle/sqlite-password-prepared.mjs.map +1 -1
- package/dist/drizzle/sqlite-passwords.mjs.map +1 -1
- package/dist/drizzle/storage-validation.mjs +10 -198
- package/dist/drizzle/storage-validation.mjs.map +1 -1
- package/dist/drizzle/totp-target.d.mts +3 -3
- package/dist/drizzle/totp-target.mjs +2 -2
- package/dist/drizzle/transaction-execution.d.mts +2 -2
- package/dist/drizzle/transaction-owner.d.mts +1 -2
- package/dist/index.d.mts +3 -2
- package/dist/internal/drizzle-postgres-oauth-proxy.d.mts +138 -0
- package/dist/internal/drizzle-postgres-oauth-proxy.mjs +29 -0
- package/dist/internal/drizzle-postgres-oauth-proxy.mjs.map +1 -0
- package/dist/internal/drizzle-postgres.mjs +2 -0
- package/dist/internal/drizzle-postgres.mjs.map +1 -1
- package/dist/internal/drizzle-sqlite-oauth-proxy.d.mts +146 -0
- package/dist/internal/drizzle-sqlite-oauth-proxy.mjs +29 -0
- package/dist/internal/drizzle-sqlite-oauth-proxy.mjs.map +1 -0
- package/dist/internal/drizzle-sqlite.mjs +2 -0
- package/dist/internal/drizzle-sqlite.mjs.map +1 -1
- package/package.json +1 -1
- package/src/D1.ts +2 -0
- package/src/Libsql.ts +2 -0
- package/src/Pglite.ts +2 -0
- package/src/Postgres.ts +2 -0
- package/src/SqliteBun.ts +2 -0
- package/src/SqliteDo.ts +2 -0
- package/src/SqliteNode.ts +2 -0
- package/src/SqliteWasm.ts +2 -0
- package/src/drizzle/d1-password-prepared.ts +2 -23
- package/src/drizzle/d1-passwords.ts +158 -780
- package/src/drizzle/d1-sessions.ts +21 -6
- package/src/drizzle/mysql-password-prepared.ts +4 -16
- package/src/drizzle/mysql-passwords.ts +5 -20
- package/src/drizzle/native-sql-table.ts +259 -0
- package/src/drizzle/oauth-connected-model.ts +97 -315
- package/src/drizzle/oauth-connected-reference.ts +13 -93
- package/src/drizzle/oauth-connected-target.ts +14 -271
- package/src/drizzle/oauth-kernel.ts +10 -0
- package/src/drizzle/oauth-model.ts +188 -541
- package/src/drizzle/oauth-mysql.ts +2 -2
- package/src/drizzle/oauth-proxy.ts +101 -0
- package/src/drizzle/oauth-target.ts +33 -737
- package/src/drizzle/password-model.ts +0 -33
- package/src/drizzle/password-prepared-model.ts +0 -18
- package/src/drizzle/password-sql.ts +3 -0
- package/src/drizzle/password-target.ts +41 -4
- package/src/drizzle/pg-password-prepared.ts +4 -16
- package/src/drizzle/pg-passwords.ts +5 -20
- package/src/drizzle/query-operations.ts +4 -0
- package/src/drizzle/session-sql.ts +2 -1
- package/src/drizzle/sqlite-password-prepared.ts +4 -52
- package/src/drizzle/sqlite-passwords.ts +7 -28
- package/src/drizzle/storage-validation.ts +13 -222
- package/src/index.ts +2 -8
- package/src/internal/drizzle-postgres-oauth-proxy.ts +37 -0
- package/src/internal/drizzle-postgres.ts +2 -0
- package/src/internal/drizzle-sqlite-oauth-proxy.ts +44 -0
- package/src/internal/drizzle-sqlite.ts +2 -0
- package/dist/_virtual/_rolldown/runtime.mjs +0 -13
- package/dist/drizzle/oauth-accounts.mjs +0 -359
- package/dist/drizzle/oauth-accounts.mjs.map +0 -1
- package/dist/drizzle/oauth-connected-access.mjs +0 -212
- package/dist/drizzle/oauth-connected-access.mjs.map +0 -1
- package/dist/drizzle/oauth-connected-collection.mjs +0 -202
- package/dist/drizzle/oauth-connected-collection.mjs.map +0 -1
- package/dist/drizzle/oauth-connected-custody.mjs +0 -147
- package/dist/drizzle/oauth-connected-custody.mjs.map +0 -1
- package/dist/drizzle/oauth-connected-flow.mjs +0 -297
- package/dist/drizzle/oauth-connected-flow.mjs.map +0 -1
- package/dist/drizzle/oauth-connected-input.mjs +0 -122
- package/dist/drizzle/oauth-connected-input.mjs.map +0 -1
- package/dist/drizzle/oauth-connected-maintenance.mjs +0 -214
- package/dist/drizzle/oauth-connected-maintenance.mjs.map +0 -1
- package/dist/drizzle/oauth-connected-management.mjs +0 -229
- package/dist/drizzle/oauth-connected-management.mjs.map +0 -1
- package/dist/drizzle/oauth-connected-settlement.mjs +0 -128
- package/dist/drizzle/oauth-connected-settlement.mjs.map +0 -1
- package/dist/drizzle/oauth-connected-sign-in.mjs +0 -265
- package/dist/drizzle/oauth-connected-sign-in.mjs.map +0 -1
- package/dist/drizzle/oauth-connected-state.d.mts +0 -2062
- package/dist/drizzle/oauth-connected-state.mjs +0 -430
- package/dist/drizzle/oauth-connected-state.mjs.map +0 -1
- package/dist/drizzle/oauth-flow.d.mts +0 -22
- package/dist/drizzle/oauth-flow.mjs +0 -253
- package/dist/drizzle/oauth-flow.mjs.map +0 -1
- package/dist/drizzle/oauth-input.mjs +0 -127
- package/dist/drizzle/oauth-input.mjs.map +0 -1
- package/dist/drizzle/oauth-owner.d.mts +0 -10
- package/dist/drizzle/oauth-owner.mjs +0 -10
- package/dist/drizzle/oauth-owner.mjs.map +0 -1
- package/dist/drizzle/oauth-registration.d.mts +0 -5
- package/dist/drizzle/oauth-registration.mjs +0 -374
- package/dist/drizzle/oauth-registration.mjs.map +0 -1
- package/dist/drizzle/oauth-state.mjs +0 -107
- package/dist/drizzle/oauth-state.mjs.map +0 -1
- package/src/drizzle/oauth-accounts.ts +0 -805
- package/src/drizzle/oauth-connected-access.ts +0 -361
- package/src/drizzle/oauth-connected-collection.ts +0 -324
- package/src/drizzle/oauth-connected-custody.ts +0 -279
- package/src/drizzle/oauth-connected-flow.ts +0 -529
- package/src/drizzle/oauth-connected-input.ts +0 -147
- package/src/drizzle/oauth-connected-maintenance.ts +0 -346
- package/src/drizzle/oauth-connected-management.ts +0 -365
- package/src/drizzle/oauth-connected-settlement.ts +0 -251
- package/src/drizzle/oauth-connected-sign-in.ts +0 -443
- package/src/drizzle/oauth-connected-state.ts +0 -872
- package/src/drizzle/oauth-flow.ts +0 -462
- package/src/drizzle/oauth-input.ts +0 -201
- package/src/drizzle/oauth-owner.ts +0 -29
- package/src/drizzle/oauth-registration.ts +0 -640
- package/src/drizzle/oauth-state.ts +0 -218
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite-passwords.mjs","names":[],"sources":["../../src/drizzle/sqlite-passwords.ts"],"sourcesContent":["import { NativeDatabase } from \"@yielded/auth-persistence/Adapter\";\nimport type { LifecycleHooks, HookConfigurationError } from \"@yielded/auth/Hooks\";\nimport { type PasswordUnavailable, PasswordPersistence } from \"@yielded/auth/Password\";\n/* oxlint-disable no-explicit-any -- proof mapping tables are independently typed by the proof owner; this driver forwards them unchanged to the shared target. */\nimport type { AnyRelations } from \"drizzle-orm\";\nimport type { EffectLibsqlDatabase } from \"drizzle-orm/effect-libsql\";\nimport type { EffectSQLiteBunDatabase } from \"drizzle-orm/effect-sqlite-bun\";\nimport type { EffectSQLiteNodeDatabase as NodeDatabase } from \"drizzle-orm/effect-sqlite-node\";\nimport type { EffectSQLiteWasmDatabase as WasmDatabase } from \"drizzle-orm/effect-sqlite-wasm\";\nimport type { AnySQLiteTable } from \"drizzle-orm/sqlite-core\";\nimport { Effect, Context } from \"effect\";\nimport type { SqlError } from \"effect/sql/SqlError\";\n\nimport { nativeDatabase } from \"./native-database\";\nimport type { PasswordPersistenceMapping, PasswordRegistrationMapping } from \"./password-model\";\nimport type { PasswordRegistrationAuthority } from \"./password-registration\";\nimport { CurrentPasswordSql } from \"./password-sql\";\nimport type { PasswordSqlQuery } from \"./password-sql\";\nimport {\n coordinateTargetPasswordPersistence,\n coordinateTargetPasswordRegistration,\n makeTargetPasswordPersistenceServices,\n makeTargetPasswordRegistrationServices,\n type PasswordTargetConfiguration,\n} from \"./password-target\";\nimport type { ProofPersistenceMapping } from \"./proof-model\";\nimport type { ProofSqlQuery } from \"./proof-sql\";\nimport type { DatabaseValue as DODatabase } from \"./sqlite-do-database\";\nimport {\n type TransactionService,\n acquireTransactionService,\n transactionService,\n} from \"./standalone-guard\";\nimport type { SuppliedService } from \"./SuppliedService\";\n\nexport type SqlitePasswordDatabase =\n | NodeDatabase<AnyRelations>\n | EffectSQLiteBunDatabase<AnyRelations>\n | EffectLibsqlDatabase<AnyRelations>\n | WasmDatabase<AnyRelations>\n | DODatabase<AnyRelations>;\n\ntype TransactionOf<D extends SqlitePasswordDatabase> = Parameters<\n Parameters<D[\"transaction\"]>[0]\n>[0];\n\nexport const sqlitePasswordConfiguration = (\n mode: \"interactive\" | \"synchronous\",\n standaloneGuard: PasswordTargetConfiguration[\"standaloneGuard\"],\n proofStandaloneGuard: PasswordTargetConfiguration[\"proof\"][\"standaloneGuard\"],\n coordinatorGuard?: PasswordTargetConfiguration[\"coordinatorGuard\"],\n): PasswordTargetConfiguration => ({\n mode,\n locking: false,\n standaloneGuard,\n ...(coordinatorGuard === undefined ? {} : { coordinatorGuard }),\n insertIfAbsent: (query: PasswordSqlQuery) => query.onConflictDoNothing(),\n generatedSubjectRows: (query: PasswordSqlQuery) => query.returning(),\n proof: {\n mode,\n locking: false,\n standaloneGuard: proofStandaloneGuard,\n insertIfAbsent: (query: ProofSqlQuery) => query.onConflictDoNothing(),\n },\n});\n\ntype Mapping<\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n A extends AnySQLiteTable,\n RS extends AnySQLiteTable,\n CE extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n> = PasswordPersistenceMapping<S, I, C, AC, A, RS, CE, M, NativeId>;\n\nexport const makeSqlitePasswordPersistenceServices = <\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n A extends AnySQLiteTable,\n RS extends AnySQLiteTable,\n CE extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n>(\n mapping: Mapping<S, I, C, AC, A, RS, CE, M, NativeId>,\n configuration: PasswordTargetConfiguration,\n proofMapping?: ProofPersistenceMapping<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n >,\n) => makeTargetPasswordPersistenceServices(mapping, configuration, proofMapping);\n\nexport const coordinateSqlitePasswordPersistence = <\n D extends SqlitePasswordDatabase,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n A extends AnySQLiteTable,\n RS extends AnySQLiteTable,\n CE extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n PM extends\n | ProofPersistenceMapping<any, any, any, any, any, any, any, any, any, any, any, any>\n | undefined,\n Out,\n E,\n R,\n>(\n database: D,\n mapping: Mapping<S, I, C, AC, A, RS, CE, M, NativeId>,\n configuration: PasswordTargetConfiguration,\n proofMapping: PM,\n owner: (\n transaction: TransactionOf<D>,\n services: { readonly passwordPersistence: PasswordPersistence[\"Service\"] },\n ) => Effect.Effect<Out, E, R>,\n) =>\n coordinateTargetPasswordPersistence<TransactionOf<D>, Out, E, R>(\n database,\n mapping,\n configuration,\n proofMapping,\n owner,\n );\n\nexport const makeSqlitePasswordRegistrationServices = <\n Registration,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n Rq extends AnySQLiteTable,\n NativeId,\n>(\n mapping: PasswordRegistrationMapping<Registration, S, I, C, AC, Rq, NativeId>,\n configuration: PasswordTargetConfiguration,\n) => makeTargetPasswordRegistrationServices<Registration>(mapping, configuration);\n\nexport const coordinateSqlitePasswordRegistration = <\n Registration,\n D extends SqlitePasswordDatabase,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n Rq extends AnySQLiteTable,\n NativeId,\n Out,\n E,\n R,\n>(\n database: D,\n mapping: PasswordRegistrationMapping<Registration, S, I, C, AC, Rq, NativeId>,\n configuration: PasswordTargetConfiguration,\n owner: (\n transaction: TransactionOf<D>,\n services: { readonly registrationAuthority: PasswordRegistrationAuthority<Registration> },\n ) => Effect.Effect<Out, E, R>,\n) =>\n coordinateTargetPasswordRegistration<Registration, TransactionOf<D>, Out, E, R>(\n database,\n mapping,\n configuration,\n owner,\n );\n\nexport const makeSqlitePasswordTarget = <\n DatabaseId,\n D extends SqlitePasswordDatabase,\n Synchronous extends boolean = false,\n>(\n databaseService: Context.Service<DatabaseId, D>,\n configuration:\n | PasswordTargetConfiguration\n | ((service: TransactionService | undefined) => PasswordTargetConfiguration),\n) => {\n const configurationFor = (database: D) =>\n typeof configuration === \"function\"\n ? configuration(transactionService(database))\n : configuration;\n\n const standaloneConfiguration =\n typeof configuration === \"function\"\n ? Effect.map(acquireTransactionService(databaseService), configuration)\n : Effect.succeed(configuration);\n\n function coordinatePasswordPersistence<\n Database extends D,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n A extends AnySQLiteTable,\n RS extends AnySQLiteTable,\n CE extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n PM extends\n | ProofPersistenceMapping<any, any, any, any, any, any, any, any, any, any, any, any>\n | undefined,\n Out,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: Mapping<S, I, C, AC, A, RS, CE, M, NativeId>;\n readonly proofMapping?: PM;\n readonly transaction?: never;\n },\n body: Effect.Effect<Out, E, Synchronous extends true ? NoInfer<PasswordPersistence> : R>,\n ): Effect.Effect<\n Out,\n E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, PasswordPersistence>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinatePasswordPersistence<\n Database extends D,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n A extends AnySQLiteTable,\n RS extends AnySQLiteTable,\n CE extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n PM extends\n | ProofPersistenceMapping<any, any, any, any, any, any, any, any, any, any, any, any>\n | undefined,\n Out,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: Mapping<S, I, C, AC, A, RS, CE, M, NativeId>;\n readonly proofMapping?: PM;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<Out, E, Synchronous extends true ? NoInfer<PasswordPersistence | TxId> : R>,\n ): Effect.Effect<\n Out,\n E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, PasswordPersistence | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinatePasswordPersistence<\n Database extends D,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n A extends AnySQLiteTable,\n RS extends AnySQLiteTable,\n CE extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n PM extends\n | ProofPersistenceMapping<any, any, any, any, any, any, any, any, any, any, any, any>\n | undefined,\n Out,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: Mapping<S, I, C, AC, A, RS, CE, M, NativeId>;\n readonly proofMapping?: PM;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<Out, E, R>,\n ): Effect.Effect<\n Out,\n E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,\n Exclude<R, PasswordPersistence> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(nativeDatabase(acquire), (database) =>\n coordinateSqlitePasswordPersistence(\n database,\n options.mapping,\n configurationFor(database),\n options.proofMapping,\n (\n transaction: TransactionOf<Database>,\n services: { readonly passwordPersistence: PasswordPersistence[\"Service\"] },\n ) => {\n const provided = Context.make(PasswordPersistence, services.passwordPersistence);\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ).pipe(Effect.provideService(NativeDatabase, database)),\n );\n }\n function coordinatePasswordRegistration<\n Database extends D,\n TargetId,\n Registration,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n Rq extends AnySQLiteTable,\n NativeId,\n Out,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: PasswordRegistrationMapping<\n NoInfer<Registration>,\n S,\n I,\n C,\n AC,\n Rq,\n NativeId\n >;\n readonly target: SuppliedService<TargetId, PasswordRegistrationAuthority<Registration>>;\n readonly transaction?: never;\n },\n body: Effect.Effect<Out, E, Synchronous extends true ? NoInfer<TargetId> : R>,\n ): Effect.Effect<\n Out,\n E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, TargetId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinatePasswordRegistration<\n Database extends D,\n TargetId,\n Registration,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n Rq extends AnySQLiteTable,\n NativeId,\n Out,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: PasswordRegistrationMapping<\n NoInfer<Registration>,\n S,\n I,\n C,\n AC,\n Rq,\n NativeId\n >;\n readonly target: SuppliedService<TargetId, PasswordRegistrationAuthority<Registration>>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<Out, E, Synchronous extends true ? NoInfer<TargetId | TxId> : R>,\n ): Effect.Effect<\n Out,\n E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, TargetId | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinatePasswordRegistration<\n Database extends D,\n TargetId,\n Registration,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n Rq extends AnySQLiteTable,\n NativeId,\n Out,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: PasswordRegistrationMapping<\n NoInfer<Registration>,\n S,\n I,\n C,\n AC,\n Rq,\n NativeId\n >;\n readonly target: SuppliedService<TargetId, PasswordRegistrationAuthority<Registration>>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<Out, E, R>,\n ): Effect.Effect<\n Out,\n E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,\n Exclude<R, TargetId> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(nativeDatabase(acquire), (database) =>\n coordinateSqlitePasswordRegistration(\n database,\n options.mapping,\n configurationFor(database),\n (\n transaction: TransactionOf<Database>,\n services: { readonly registrationAuthority: PasswordRegistrationAuthority<Registration> },\n ) => {\n const provided = Context.make(options.target, services.registrationAuthority);\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ).pipe(Effect.provideService(NativeDatabase, database)),\n );\n }\n\n return {\n makePasswordPersistenceServices: <\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n A extends AnySQLiteTable,\n RS extends AnySQLiteTable,\n CE extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n >(\n mapping: Mapping<S, I, C, AC, A, RS, CE, M, NativeId>,\n proofMapping?: ProofPersistenceMapping<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n >,\n ) =>\n Effect.flatMap(standaloneConfiguration, (configuration) =>\n makeSqlitePasswordPersistenceServices(mapping, configuration, proofMapping),\n ).pipe(\n Effect.provideServiceEffect(CurrentPasswordSql, nativeDatabase(databaseService)),\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n coordinatePasswordPersistence,\n makePasswordRegistrationServices: <\n Registration,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n Rq extends AnySQLiteTable,\n NativeId,\n >(\n mapping: PasswordRegistrationMapping<Registration, S, I, C, AC, Rq, NativeId>,\n ) =>\n Effect.flatMap(standaloneConfiguration, (configuration) =>\n makeSqlitePasswordRegistrationServices(mapping, configuration),\n ).pipe(\n Effect.provideServiceEffect(CurrentPasswordSql, nativeDatabase(databaseService)),\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n coordinatePasswordRegistration,\n };\n};\n"],"mappings":";;;;;;;;AA8CA,MAAa,+BACX,MACA,iBACA,sBACA,sBACiC;CACjC;CACA,SAAS;CACT;CACA,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,E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M,WAAW,QAAQ,KAAK,QAAQ,QAAQ,SAAS,qBAAqB;GAC5E,MAAM,OAAO,OAAO,eAAe,MAAM,QAAQ;GAEjD,OAAO,QAAQ,gBAAgB,KAAA,IAC3B,OACA,OAAO,eAAe,MAAM,QAAQ,aAAa,QAAQ,YAAY,GAAG,WAAW,CAAC;EAC1F,CACF,CAAC,CAAC,KAAK,OAAO,eAAe,gBAAgB,QAAQ,CAAC,CACxD;CACF;CAEA,OAAO;EACL,kCAWE,SACA,iBAeA,OAAO,QAAQ,0BAA0B,kBACvC,sCAAsC,SAAS,eAAe,YAAY,CAC5E,CAAC,CAAC,KACA,OAAO,qBAAqB,oBAAoB,eAAe,eAAe,CAAC,GAC/E,OAAO,qBAAqB,gBAAgB,eAAe,eAAe,CAAC,CAC7E;EACF;EACA,mCASE,YAEA,OAAO,QAAQ,0BAA0B,kBACvC,uCAAuC,SAAS,aAAa,CAC/D,CAAC,CAAC,KACA,OAAO,qBAAqB,oBAAoB,eAAe,eAAe,CAAC,GAC/E,OAAO,qBAAqB,gBAAgB,eAAe,eAAe,CAAC,CAC7E;EACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"sqlite-passwords.mjs","names":[],"sources":["../../src/drizzle/sqlite-passwords.ts"],"sourcesContent":["import { NativeDatabase } from \"@yielded/auth-persistence/Adapter\";\nimport type { LifecycleHooks, HookConfigurationError } from \"@yielded/auth/Hooks\";\nimport { type PasswordUnavailable, PasswordPersistence } from \"@yielded/auth/Password\";\n/* oxlint-disable no-explicit-any -- proof mapping tables are independently typed by the proof owner; this driver forwards them unchanged to the shared target. */\nimport type { AnyRelations } from \"drizzle-orm\";\nimport type { EffectLibsqlDatabase } from \"drizzle-orm/effect-libsql\";\nimport type { EffectSQLiteBunDatabase } from \"drizzle-orm/effect-sqlite-bun\";\nimport type { EffectSQLiteNodeDatabase as NodeDatabase } from \"drizzle-orm/effect-sqlite-node\";\nimport type { EffectSQLiteWasmDatabase as WasmDatabase } from \"drizzle-orm/effect-sqlite-wasm\";\nimport type { AnySQLiteTable } from \"drizzle-orm/sqlite-core\";\nimport { Effect, Context } from \"effect\";\nimport type { SqlError } from \"effect/sql/SqlError\";\n\nimport { nativeDatabase } from \"./native-database\";\nimport type { PasswordPersistenceMapping, PasswordRegistrationMapping } from \"./password-model\";\nimport type { PasswordRegistrationAuthority } from \"./password-registration\";\nimport { CurrentPasswordSql } from \"./password-sql\";\nimport type { PasswordSqlQuery } from \"./password-sql\";\nimport {\n coordinateTargetPasswordPersistence,\n coordinateTargetPasswordRegistration,\n makeTargetPasswordPersistenceServices,\n makeTargetPasswordRegistrationServices,\n type PasswordTargetConfiguration,\n} from \"./password-target\";\nimport type { ProofPersistenceMapping } from \"./proof-model\";\nimport type { ProofSqlQuery } from \"./proof-sql\";\nimport type { DatabaseValue as DODatabase } from \"./sqlite-do-database\";\nimport {\n type TransactionService,\n acquireTransactionService,\n transactionService,\n} from \"./standalone-guard\";\nimport type { SuppliedService } from \"./SuppliedService\";\n\nexport type SqlitePasswordDatabase =\n | NodeDatabase<AnyRelations>\n | EffectSQLiteBunDatabase<AnyRelations>\n | EffectLibsqlDatabase<AnyRelations>\n | WasmDatabase<AnyRelations>\n | DODatabase<AnyRelations>;\n\ntype TransactionOf<D extends SqlitePasswordDatabase> = Parameters<\n Parameters<D[\"transaction\"]>[0]\n>[0];\n\nexport const sqlitePasswordConfiguration = (\n mode: \"interactive\" | \"synchronous\",\n standaloneGuard: PasswordTargetConfiguration[\"standaloneGuard\"],\n proofStandaloneGuard: PasswordTargetConfiguration[\"proof\"][\"standaloneGuard\"],\n coordinatorGuard?: PasswordTargetConfiguration[\"coordinatorGuard\"],\n): PasswordTargetConfiguration => ({\n mode,\n locking: false,\n standaloneGuard,\n ...(coordinatorGuard === undefined ? {} : { coordinatorGuard }),\n insertIfAbsent: (query: PasswordSqlQuery) => query.onConflictDoNothing(),\n generatedSubjectRows: (query: PasswordSqlQuery) => query.returning(),\n proof: {\n mode,\n locking: false,\n standaloneGuard: proofStandaloneGuard,\n insertIfAbsent: (query: ProofSqlQuery) => query.onConflictDoNothing(),\n },\n});\n\ntype Mapping<\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n> = PasswordPersistenceMapping<S, I, C, AC, M, NativeId>;\n\nexport const makeSqlitePasswordPersistenceServices = <\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n>(\n mapping: Mapping<S, I, C, AC, M, NativeId>,\n configuration: PasswordTargetConfiguration,\n proofMapping?: ProofPersistenceMapping<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n >,\n) => makeTargetPasswordPersistenceServices(mapping, configuration, proofMapping);\n\nexport const coordinateSqlitePasswordPersistence = <\n D extends SqlitePasswordDatabase,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n PM extends\n | ProofPersistenceMapping<any, any, any, any, any, any, any, any, any, any, any, any>\n | undefined,\n Out,\n E,\n R,\n>(\n database: D,\n mapping: Mapping<S, I, C, AC, M, NativeId>,\n configuration: PasswordTargetConfiguration,\n proofMapping: PM,\n owner: (\n transaction: TransactionOf<D>,\n services: { readonly passwordPersistence: PasswordPersistence[\"Service\"] },\n ) => Effect.Effect<Out, E, R>,\n) =>\n coordinateTargetPasswordPersistence<TransactionOf<D>, Out, E, R>(\n database,\n mapping,\n configuration,\n proofMapping,\n owner,\n );\n\nexport const makeSqlitePasswordRegistrationServices = <\n Registration,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n Rq extends AnySQLiteTable,\n NativeId,\n>(\n mapping: PasswordRegistrationMapping<Registration, S, I, C, AC, Rq, NativeId>,\n configuration: PasswordTargetConfiguration,\n) => makeTargetPasswordRegistrationServices<Registration>(mapping, configuration);\n\nexport const coordinateSqlitePasswordRegistration = <\n Registration,\n D extends SqlitePasswordDatabase,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n Rq extends AnySQLiteTable,\n NativeId,\n Out,\n E,\n R,\n>(\n database: D,\n mapping: PasswordRegistrationMapping<Registration, S, I, C, AC, Rq, NativeId>,\n configuration: PasswordTargetConfiguration,\n owner: (\n transaction: TransactionOf<D>,\n services: { readonly registrationAuthority: PasswordRegistrationAuthority<Registration> },\n ) => Effect.Effect<Out, E, R>,\n) =>\n coordinateTargetPasswordRegistration<Registration, TransactionOf<D>, Out, E, R>(\n database,\n mapping,\n configuration,\n owner,\n );\n\nexport const makeSqlitePasswordTarget = <\n DatabaseId,\n D extends SqlitePasswordDatabase,\n Synchronous extends boolean = false,\n>(\n databaseService: Context.Service<DatabaseId, D>,\n configuration:\n | PasswordTargetConfiguration\n | ((service: TransactionService | undefined) => PasswordTargetConfiguration),\n) => {\n const configurationFor = (database: D) =>\n typeof configuration === \"function\"\n ? configuration(transactionService(database))\n : configuration;\n\n const standaloneConfiguration =\n typeof configuration === \"function\"\n ? Effect.map(acquireTransactionService(databaseService), configuration)\n : Effect.succeed(configuration);\n\n function coordinatePasswordPersistence<\n Database extends D,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n PM extends\n | ProofPersistenceMapping<any, any, any, any, any, any, any, any, any, any, any, any>\n | undefined,\n Out,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: Mapping<S, I, C, AC, M, NativeId>;\n readonly proofMapping?: PM;\n readonly transaction?: never;\n },\n body: Effect.Effect<Out, E, Synchronous extends true ? NoInfer<PasswordPersistence> : R>,\n ): Effect.Effect<\n Out,\n E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, PasswordPersistence>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinatePasswordPersistence<\n Database extends D,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n PM extends\n | ProofPersistenceMapping<any, any, any, any, any, any, any, any, any, any, any, any>\n | undefined,\n Out,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: Mapping<S, I, C, AC, M, NativeId>;\n readonly proofMapping?: PM;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<Out, E, Synchronous extends true ? NoInfer<PasswordPersistence | TxId> : R>,\n ): Effect.Effect<\n Out,\n E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, PasswordPersistence | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinatePasswordPersistence<\n Database extends D,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n PM extends\n | ProofPersistenceMapping<any, any, any, any, any, any, any, any, any, any, any, any>\n | undefined,\n Out,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: Mapping<S, I, C, AC, M, NativeId>;\n readonly proofMapping?: PM;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<Out, E, R>,\n ): Effect.Effect<\n Out,\n E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,\n Exclude<R, PasswordPersistence> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(nativeDatabase(acquire), (database) =>\n coordinateSqlitePasswordPersistence(\n database,\n options.mapping,\n configurationFor(database),\n options.proofMapping,\n (\n transaction: TransactionOf<Database>,\n services: { readonly passwordPersistence: PasswordPersistence[\"Service\"] },\n ) => {\n const provided = Context.make(PasswordPersistence, services.passwordPersistence);\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ).pipe(Effect.provideService(NativeDatabase, database)),\n );\n }\n function coordinatePasswordRegistration<\n Database extends D,\n TargetId,\n Registration,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n Rq extends AnySQLiteTable,\n NativeId,\n Out,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: PasswordRegistrationMapping<\n NoInfer<Registration>,\n S,\n I,\n C,\n AC,\n Rq,\n NativeId\n >;\n readonly target: SuppliedService<TargetId, PasswordRegistrationAuthority<Registration>>;\n readonly transaction?: never;\n },\n body: Effect.Effect<Out, E, Synchronous extends true ? NoInfer<TargetId> : R>,\n ): Effect.Effect<\n Out,\n E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, TargetId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinatePasswordRegistration<\n Database extends D,\n TargetId,\n Registration,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n Rq extends AnySQLiteTable,\n NativeId,\n Out,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: PasswordRegistrationMapping<\n NoInfer<Registration>,\n S,\n I,\n C,\n AC,\n Rq,\n NativeId\n >;\n readonly target: SuppliedService<TargetId, PasswordRegistrationAuthority<Registration>>;\n readonly transaction: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<Out, E, Synchronous extends true ? NoInfer<TargetId | TxId> : R>,\n ): Effect.Effect<\n Out,\n E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,\n | (Synchronous extends true ? never : Exclude<R, TargetId | TxId>)\n | LifecycleHooks\n | DatabaseRequirements\n >;\n function coordinatePasswordRegistration<\n Database extends D,\n TargetId,\n Registration,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n Rq extends AnySQLiteTable,\n NativeId,\n Out,\n E,\n R,\n DatabaseError,\n DatabaseRequirements,\n TxId,\n TxShape,\n >(\n acquire: Effect.Effect<Database, DatabaseError, DatabaseRequirements>,\n options: {\n readonly mapping: PasswordRegistrationMapping<\n NoInfer<Registration>,\n S,\n I,\n C,\n AC,\n Rq,\n NativeId\n >;\n readonly target: SuppliedService<TargetId, PasswordRegistrationAuthority<Registration>>;\n readonly transaction?: SuppliedService<TxId, NoInfer<TransactionOf<Database>>, TxShape>;\n },\n body: Effect.Effect<Out, E, R>,\n ): Effect.Effect<\n Out,\n E | PasswordUnavailable | HookConfigurationError | SqlError | DatabaseError,\n Exclude<R, TargetId> | LifecycleHooks | DatabaseRequirements\n > {\n return Effect.flatMap(nativeDatabase(acquire), (database) =>\n coordinateSqlitePasswordRegistration(\n database,\n options.mapping,\n configurationFor(database),\n (\n transaction: TransactionOf<Database>,\n services: { readonly registrationAuthority: PasswordRegistrationAuthority<Registration> },\n ) => {\n const provided = Context.make(options.target, services.registrationAuthority);\n const work = Effect.provideContext(body, provided);\n\n return options.transaction === undefined\n ? work\n : Effect.provideService(work, options.transaction, options.transaction.of(transaction));\n },\n ).pipe(Effect.provideService(NativeDatabase, database)),\n );\n }\n\n return {\n makePasswordPersistenceServices: <\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n M extends AnySQLiteTable,\n NativeId,\n >(\n mapping: Mapping<S, I, C, AC, M, NativeId>,\n proofMapping?: ProofPersistenceMapping<\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any,\n any\n >,\n ) =>\n Effect.flatMap(standaloneConfiguration, (configuration) =>\n makeSqlitePasswordPersistenceServices(mapping, configuration, proofMapping),\n ).pipe(\n Effect.provideServiceEffect(CurrentPasswordSql, nativeDatabase(databaseService)),\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n coordinatePasswordPersistence,\n makePasswordRegistrationServices: <\n Registration,\n S extends AnySQLiteTable,\n I extends AnySQLiteTable,\n C extends AnySQLiteTable,\n AC extends AnySQLiteTable,\n Rq extends AnySQLiteTable,\n NativeId,\n >(\n mapping: PasswordRegistrationMapping<Registration, S, I, C, AC, Rq, NativeId>,\n ) =>\n Effect.flatMap(standaloneConfiguration, (configuration) =>\n makeSqlitePasswordRegistrationServices(mapping, configuration),\n ).pipe(\n Effect.provideServiceEffect(CurrentPasswordSql, nativeDatabase(databaseService)),\n Effect.provideServiceEffect(NativeDatabase, nativeDatabase(databaseService)),\n ),\n coordinatePasswordRegistration,\n };\n};\n"],"mappings":";;;;;;;;AA8CA,MAAa,+BACX,MACA,iBACA,sBACA,sBACiC;CACjC;CACA,SAAS;CACT;CACA,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,iBAAiB;CAC7D,iBAAiB,UAA4B,MAAM,oBAAoB;CACvE,uBAAuB,UAA4B,MAAM,UAAU;CACnE,OAAO;EACL;EACA,SAAS;EACT,iBAAiB;EACjB,iBAAiB,UAAyB,MAAM,oBAAoB;CACtE;AACF;AAWA,MAAa,yCAQX,SACA,eACA,iBAcG,sCAAsC,SAAS,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AAC,KAAK,OAAO,eAAe,gBAAgB,QAAQ,CAAC,CACxD;CACF;CAEA,OAAO;EACL,kCAQE,SACA,iBAeA,OAAO,QAAQ,0BAA0B,kBACvC,sCAAsC,SAAS,eAAe,YAAY,CAC5E,CAAC,CAAC,KACA,OAAO,qBAAqB,oBAAoB,eAAe,eAAe,CAAC,GAC/E,OAAO,qBAAqB,gBAAgB,eAAe,eAAe,CAAC,CAC7E;EACF;EACA,mCASE,YAEA,OAAO,QAAQ,0BAA0B,kBACvC,uCAAuC,SAAS,aAAa,CAC/D,CAAC,CAAC,KACA,OAAO,qBAAqB,oBAAoB,eAAe,eAAe,CAAC,GAC/E,OAAO,qBAAqB,gBAAgB,eAAe,eAAe,CAAC,CAC7E;EACF;CACF;AACF"}
|
|
@@ -1,209 +1,17 @@
|
|
|
1
|
-
import { NativeDatabase, PersistenceMappingError, validateStorageBatch } from "@yielded/auth-persistence/Adapter";
|
|
1
|
+
import { NativeDatabase, PersistenceMappingError, storageKeyPlans, validateStorageBatch } from "@yielded/auth-persistence/Adapter";
|
|
2
2
|
import { Table, getTableColumns, getTableName, is } from "drizzle-orm";
|
|
3
|
-
import { Effect
|
|
3
|
+
import { Effect } from "effect";
|
|
4
4
|
import { MySqlTable, getTableConfig } from "drizzle-orm/mysql-core";
|
|
5
5
|
import { PgTable, getTableConfig as getTableConfig$1 } from "drizzle-orm/pg-core";
|
|
6
6
|
import { SqlClient } from "effect/sql/SqlClient";
|
|
7
7
|
//#region src/drizzle/storage-validation.ts
|
|
8
|
-
const uniquePlans = {
|
|
9
|
-
"unique(abuseEvent.moduleId,abuseEvent.action,abuseEvent.scopeKind,abuseEvent.scopeKey,abuseEvent.commandId)": ["abuseEvent", [
|
|
10
|
-
"moduleId",
|
|
11
|
-
"action",
|
|
12
|
-
"scopeKind",
|
|
13
|
-
"scopeKey",
|
|
14
|
-
"commandId"
|
|
15
|
-
]],
|
|
16
|
-
"unique(admission.moduleId)": ["admission", ["moduleId"]],
|
|
17
|
-
"unique(attempt.moduleId,attempt.attemptId)": ["attempt", ["moduleId", "attemptId"]],
|
|
18
|
-
"unique(authority.subjectId,authority.credentialId)": ["authority", ["subjectId", "credentialId"]],
|
|
19
|
-
"unique(authorityCredential.subjectId,authorityCredential.credentialId)": ["authorityCredential", ["subjectId", "credentialId"]],
|
|
20
|
-
"unique(charge.moduleId,charge.action,charge.scopeKind,charge.scopeKey,charge.attemptId)": ["charge", [
|
|
21
|
-
"moduleId",
|
|
22
|
-
"action",
|
|
23
|
-
"scopeKind",
|
|
24
|
-
"scopeKey",
|
|
25
|
-
"attemptId"
|
|
26
|
-
]],
|
|
27
|
-
"unique(command.moduleId,command.commandId)": ["command", ["moduleId", "commandId"]],
|
|
28
|
-
"unique(connectedAdmission.admissionId)": ["admission", ["admissionId"]],
|
|
29
|
-
"unique(connectedClient.clientKey)": ["client", ["clientKey"]],
|
|
30
|
-
"unique(connectedCohort.cohortKey)": ["cohort", ["cohortKey"]],
|
|
31
|
-
"unique(connectedCommand.moduleId,connectedCommand.commandId)": ["command", ["moduleId", "commandId"]],
|
|
32
|
-
"unique(connectedFlow.moduleId,connectedFlow.commandId)": ["flow", ["moduleId", "commandId"]],
|
|
33
|
-
"unique(connectedFlow.moduleId,connectedFlow.flowId)": ["flow", ["moduleId", "flowId"]],
|
|
34
|
-
"unique(connectedFlow.stateDigest)": ["flow", ["stateDigest"]],
|
|
35
|
-
"unique(connectedGrant.moduleId,connectedGrant.grantId)": ["grant", ["moduleId", "grantId"]],
|
|
36
|
-
"unique(connectedGrant.moduleId,connectedGrant.subjectId,connectedGrant.profileKey,connectedGrant.activeIdentityKey)": ["grant", [
|
|
37
|
-
"moduleId",
|
|
38
|
-
"subjectId",
|
|
39
|
-
"profileKey",
|
|
40
|
-
"activeIdentityKey"
|
|
41
|
-
]],
|
|
42
|
-
"unique(connectedRevocation.jobId)": ["job", ["jobId"]],
|
|
43
|
-
"unique(continuation.moduleId,continuation.continuationId)": ["continuation", ["moduleId", "continuationId"]],
|
|
44
|
-
"unique(continuation.moduleId,continuation.digest)": ["continuation", ["moduleId", "digest"]],
|
|
45
|
-
"unique(credential.credentialId)": ["credential", ["credentialId"]],
|
|
46
|
-
"unique(credential.identityKey)": ["credential", ["identityKey"]],
|
|
47
|
-
"unique(credential.moduleId,credential.credentialId)": ["credential", ["moduleId", "credentialId"]],
|
|
48
|
-
"unique(credential.moduleId,credential.subjectId)": ["credential", ["moduleId", "subjectId"]],
|
|
49
|
-
"unique(emailCommand.moduleId,emailCommand.commandId)": ["command", ["moduleId", "commandId"]],
|
|
50
|
-
"unique(emailCredential.moduleId,emailCredential.credentialId)": ["credential", ["moduleId", "credentialId"]],
|
|
51
|
-
"unique(emailCredential.moduleId,emailCredential.identifierNamespace,emailCredential.identifierValue)": ["credential", [
|
|
52
|
-
"moduleId",
|
|
53
|
-
"identifierNamespace",
|
|
54
|
-
"identifierValue"
|
|
55
|
-
]],
|
|
56
|
-
"unique(emailRegistration.moduleId,emailRegistration.commandId)": ["registration", ["moduleId", "commandId"]],
|
|
57
|
-
"unique(emailRegistration.pendingReference)": ["registration", ["pendingReference"]],
|
|
58
|
-
"unique(failureEvent.moduleId,failureEvent.seriesKey,failureEvent.commandId)": ["failureEvent", [
|
|
59
|
-
"moduleId",
|
|
60
|
-
"seriesKey",
|
|
61
|
-
"commandId"
|
|
62
|
-
]],
|
|
63
|
-
"unique(flow.flowId)": ["flow", ["flowId"]],
|
|
64
|
-
"unique(flow.moduleId,flow.commandId)": ["flow", ["moduleId", "commandId"]],
|
|
65
|
-
"unique(flow.moduleId,flow.flowId)": ["flow", ["moduleId", "flowId"]],
|
|
66
|
-
"unique(flow.stateDigest)": ["flow", ["stateDigest"]],
|
|
67
|
-
"unique(generation.moduleId,generation.deliveryId)": ["generation", ["moduleId", "deliveryId"]],
|
|
68
|
-
"unique(generation.moduleId,generation.proofId)": ["generation", ["moduleId", "proofId"]],
|
|
69
|
-
"unique(identifier.namespace,identifier.value)": ["identifier", ["namespace", "value"]],
|
|
70
|
-
"unique(intent.digest)": ["intent", ["digest"]],
|
|
71
|
-
"unique(intent.flowId)": ["intent", ["flowId"]],
|
|
72
|
-
"unique(intent.moduleId,intent.commandId)": ["intent", ["moduleId", "commandId"]],
|
|
73
|
-
"unique(intent.moduleId,intent.flowId)": ["intent", ["moduleId", "flowId"]],
|
|
74
|
-
"unique(intent.moduleId,intent.intentId)": ["intent", ["moduleId", "intentId"]],
|
|
75
|
-
"unique(intent.moduleId,intent.reference)": ["intent", ["moduleId", "reference"]],
|
|
76
|
-
"unique(ownership.identityKey)": ["ownership", ["identityKey"]],
|
|
77
|
-
"unique(pending.digest)": ["pending", ["digest"]],
|
|
78
|
-
"unique(pending.flowId)": ["pending", ["flowId"]],
|
|
79
|
-
"unique(rateScope.moduleId,rateScope.action,rateScope.scopeKind,rateScope.scopeKey)": ["rateScope", [
|
|
80
|
-
"moduleId",
|
|
81
|
-
"action",
|
|
82
|
-
"scopeKind",
|
|
83
|
-
"scopeKey"
|
|
84
|
-
]],
|
|
85
|
-
"unique(rateScope.moduleId,rateScope.purpose,rateScope.action,rateScope.scopeKind,rateScope.scopeKey)": ["rateScope", [
|
|
86
|
-
"moduleId",
|
|
87
|
-
"purpose",
|
|
88
|
-
"action",
|
|
89
|
-
"scopeKind",
|
|
90
|
-
"scopeKey"
|
|
91
|
-
]],
|
|
92
|
-
"unique(registration.moduleId,registration.requestId)": ["registration", ["moduleId", "requestId"]],
|
|
93
|
-
"unique(registration.recoveryReference)": ["registration", ["recoveryReference"]],
|
|
94
|
-
"unique(registrationCommand.moduleId,registrationCommand.commandId)": ["command", ["moduleId", "commandId"]],
|
|
95
|
-
"unique(request.moduleId,request.requestId)": ["request", ["moduleId", "requestId"]],
|
|
96
|
-
"unique(series.moduleId,series.purpose,series.scopeKey)": ["series", [
|
|
97
|
-
"moduleId",
|
|
98
|
-
"purpose",
|
|
99
|
-
"scopeKey"
|
|
100
|
-
]],
|
|
101
|
-
"unique(session.digest)": ["session", ["digest"]],
|
|
102
|
-
"unique(tombstone.subjectId,tombstone.sessionId)": ["tombstone", ["subjectId", "sessionId"]],
|
|
103
|
-
"unique(tuple.identityKey)": ["ownership.tuple", ["identityKey"]],
|
|
104
|
-
"unique(unlinkCommand.moduleId,unlinkCommand.commandId)": ["command", ["moduleId", "commandId"]]
|
|
105
|
-
};
|
|
106
|
-
const arrayRoles = {
|
|
107
|
-
credentialId: "credential",
|
|
108
|
-
factor: "authority",
|
|
109
|
-
credentialOwnership: "credentialOwnership",
|
|
110
|
-
handleOwnership: "handleOwnership",
|
|
111
|
-
boundSubjectHandle: "handleOwnership",
|
|
112
|
-
flow: "flow",
|
|
113
|
-
command: "flow",
|
|
114
|
-
admission: "admission",
|
|
115
|
-
charge: "charge",
|
|
116
|
-
intentFlow: "intent",
|
|
117
|
-
intentCommand: "intent",
|
|
118
|
-
handle: "handle"
|
|
119
|
-
};
|
|
120
|
-
const nestedMappings = [
|
|
121
|
-
"read",
|
|
122
|
-
"signIn",
|
|
123
|
-
"password",
|
|
124
|
-
"proof",
|
|
125
|
-
"proofs",
|
|
126
|
-
"revocation",
|
|
127
|
-
"pending",
|
|
128
|
-
"session",
|
|
129
|
-
"source"
|
|
130
|
-
];
|
|
131
|
-
const constraintGroups = [
|
|
132
|
-
"constraints",
|
|
133
|
-
"tupleConstraints",
|
|
134
|
-
"registrationConstraints",
|
|
135
|
-
"managementConstraints"
|
|
136
|
-
];
|
|
137
|
-
const MappingRecord = Schema.Record(Schema.String, Schema.Unknown);
|
|
138
|
-
const record = Schema.decodeUnknownSync(MappingRecord);
|
|
139
|
-
const plans = (mapping) => {
|
|
140
|
-
const result = [];
|
|
141
|
-
for (const group of constraintGroups) {
|
|
142
|
-
if (mapping[group] === void 0) continue;
|
|
143
|
-
for (const [name, declaration] of Object.entries(record(mapping[group]))) {
|
|
144
|
-
if (declaration === "notNull(provisioningRequest.subjectId)") continue;
|
|
145
|
-
let role;
|
|
146
|
-
let keys;
|
|
147
|
-
if (typeof declaration === "string") {
|
|
148
|
-
const plan = uniquePlans[declaration];
|
|
149
|
-
if (plan !== void 0) [role, keys] = plan;
|
|
150
|
-
else if (declaration === "unique(id)") {
|
|
151
|
-
role = "subject";
|
|
152
|
-
keys = ["id"];
|
|
153
|
-
} else if (declaration === "unique(scope)") {
|
|
154
|
-
role = name;
|
|
155
|
-
keys = ["scope"];
|
|
156
|
-
} else if (declaration === "unique(credentialId)") {
|
|
157
|
-
role = "credential";
|
|
158
|
-
keys = ["id"];
|
|
159
|
-
} else if (declaration === "unique(namespace,value)") {
|
|
160
|
-
role = "identifier";
|
|
161
|
-
keys = ["namespace", "value"];
|
|
162
|
-
} else if (declaration === "unique(provider,issuer,subject)") {
|
|
163
|
-
role = "externalIdentity";
|
|
164
|
-
keys = [
|
|
165
|
-
"provider",
|
|
166
|
-
"issuer",
|
|
167
|
-
"subject"
|
|
168
|
-
];
|
|
169
|
-
} else if (declaration === "unique(requestId)") {
|
|
170
|
-
role = "provisioningRequest";
|
|
171
|
-
keys = ["requestId"];
|
|
172
|
-
} else throw new Error("Unknown storage constraint");
|
|
173
|
-
} else if (Array.isArray(declaration) && declaration.every(Predicate.isString)) {
|
|
174
|
-
const mappedRole = group === "managementConstraints" && name === "command" ? "command" : arrayRoles[name];
|
|
175
|
-
if (mappedRole === void 0) throw new Error("Unknown storage constraint");
|
|
176
|
-
role = mappedRole;
|
|
177
|
-
keys = declaration;
|
|
178
|
-
} else throw new Error("Invalid storage constraint");
|
|
179
|
-
let target = mapping;
|
|
180
|
-
for (const segment of role.split(".")) target = record(target)[segment];
|
|
181
|
-
if (target === void 0 && Schema.is(MappingRecord)(mapping.pending)) target = mapping.pending[role];
|
|
182
|
-
let mapped = record(target);
|
|
183
|
-
if (role === "pending" && mapped.table === void 0) mapped = record(mapped.pending);
|
|
184
|
-
if (role === "ownership" && mapped.table === void 0) mapped = record(mapped.external ?? mapped.tuple);
|
|
185
|
-
if (!is(mapped.table, Table)) throw new Error("Missing storage table");
|
|
186
|
-
const columns = getTableColumns(mapped.table);
|
|
187
|
-
result.push({
|
|
188
|
-
table: mapped.table,
|
|
189
|
-
keys: keys.map((key) => {
|
|
190
|
-
const value = mapped[key];
|
|
191
|
-
if (typeof value !== "string" || columns[value] === void 0) throw new Error("Missing mapped key");
|
|
192
|
-
return value;
|
|
193
|
-
})
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
for (const nested of nestedMappings) {
|
|
198
|
-
const value = mapping[nested];
|
|
199
|
-
if (Schema.is(MappingRecord)(value) && value.table === void 0) result.push(...plans(value));
|
|
200
|
-
}
|
|
201
|
-
return result;
|
|
202
|
-
};
|
|
203
8
|
/** Validate at acquisition using the root database supplied by the adapter. */
|
|
204
9
|
const validateDrizzleStorage = Effect.fnUntraced(function* (mapping) {
|
|
205
10
|
const physical = yield* Effect.try({
|
|
206
|
-
try: () =>
|
|
11
|
+
try: () => storageKeyPlans(mapping, (table) => {
|
|
12
|
+
if (!is(table, Table)) throw new Error("Missing storage table");
|
|
13
|
+
return getTableColumns(table);
|
|
14
|
+
}),
|
|
207
15
|
catch: () => PersistenceMappingError.make({
|
|
208
16
|
operation: "mapping",
|
|
209
17
|
cause: "Invalid storage key mapping"
|
|
@@ -212,6 +20,10 @@ const validateDrizzleStorage = Effect.fnUntraced(function* (mapping) {
|
|
|
212
20
|
const { $client: client } = yield* NativeDatabase;
|
|
213
21
|
const batches = /* @__PURE__ */ new Map();
|
|
214
22
|
for (const plan of physical) {
|
|
23
|
+
if (!is(plan.table, Table)) return yield* PersistenceMappingError.make({
|
|
24
|
+
operation: "mapping",
|
|
25
|
+
cause: "Missing storage table"
|
|
26
|
+
});
|
|
215
27
|
const pg = is(plan.table, PgTable);
|
|
216
28
|
const mysql = is(plan.table, MySqlTable);
|
|
217
29
|
const schema = pg ? getTableConfig$1(plan.table).schema : mysql ? getTableConfig(plan.table).schema : void 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-validation.mjs","names":["getPgTableConfig","getMysqlTableConfig"],"sources":["../../src/drizzle/storage-validation.ts"],"sourcesContent":["import {\n NativeDatabase,\n PersistenceMappingError,\n validateStorageBatch,\n type StorageValidation,\n} from \"@yielded/auth-persistence/Adapter\";\nimport { getTableColumns, getTableName, is, Table } from \"drizzle-orm\";\nimport { getTableConfig as getMysqlTableConfig, MySqlTable } from \"drizzle-orm/mysql-core\";\nimport { getTableConfig as getPgTableConfig, PgTable } from \"drizzle-orm/pg-core\";\nimport { Effect, Predicate, Schema } from \"effect\";\nimport { SqlClient } from \"effect/sql/SqlClient\";\n\n// These are mapping contracts, not a parser for arbitrary constraint declarations.\n// Role aliases are explicit because their documentation names differ from mapping fields.\nconst uniquePlans: Readonly<Record<string, readonly [string, ReadonlyArray<string>]>> = {\n \"unique(abuseEvent.moduleId,abuseEvent.action,abuseEvent.scopeKind,abuseEvent.scopeKey,abuseEvent.commandId)\":\n [\"abuseEvent\", [\"moduleId\", \"action\", \"scopeKind\", \"scopeKey\", \"commandId\"]],\n \"unique(admission.moduleId)\": [\"admission\", [\"moduleId\"]],\n \"unique(attempt.moduleId,attempt.attemptId)\": [\"attempt\", [\"moduleId\", \"attemptId\"]],\n \"unique(authority.subjectId,authority.credentialId)\": [\n \"authority\",\n [\"subjectId\", \"credentialId\"],\n ],\n \"unique(authorityCredential.subjectId,authorityCredential.credentialId)\": [\n \"authorityCredential\",\n [\"subjectId\", \"credentialId\"],\n ],\n \"unique(charge.moduleId,charge.action,charge.scopeKind,charge.scopeKey,charge.attemptId)\": [\n \"charge\",\n [\"moduleId\", \"action\", \"scopeKind\", \"scopeKey\", \"attemptId\"],\n ],\n \"unique(command.moduleId,command.commandId)\": [\"command\", [\"moduleId\", \"commandId\"]],\n \"unique(connectedAdmission.admissionId)\": [\"admission\", [\"admissionId\"]],\n \"unique(connectedClient.clientKey)\": [\"client\", [\"clientKey\"]],\n \"unique(connectedCohort.cohortKey)\": [\"cohort\", [\"cohortKey\"]],\n \"unique(connectedCommand.moduleId,connectedCommand.commandId)\": [\n \"command\",\n [\"moduleId\", \"commandId\"],\n ],\n \"unique(connectedFlow.moduleId,connectedFlow.commandId)\": [\"flow\", [\"moduleId\", \"commandId\"]],\n \"unique(connectedFlow.moduleId,connectedFlow.flowId)\": [\"flow\", [\"moduleId\", \"flowId\"]],\n \"unique(connectedFlow.stateDigest)\": [\"flow\", [\"stateDigest\"]],\n \"unique(connectedGrant.moduleId,connectedGrant.grantId)\": [\"grant\", [\"moduleId\", \"grantId\"]],\n \"unique(connectedGrant.moduleId,connectedGrant.subjectId,connectedGrant.profileKey,connectedGrant.activeIdentityKey)\":\n [\"grant\", [\"moduleId\", \"subjectId\", \"profileKey\", \"activeIdentityKey\"]],\n \"unique(connectedRevocation.jobId)\": [\"job\", [\"jobId\"]],\n \"unique(continuation.moduleId,continuation.continuationId)\": [\n \"continuation\",\n [\"moduleId\", \"continuationId\"],\n ],\n \"unique(continuation.moduleId,continuation.digest)\": [\"continuation\", [\"moduleId\", \"digest\"]],\n \"unique(credential.credentialId)\": [\"credential\", [\"credentialId\"]],\n \"unique(credential.identityKey)\": [\"credential\", [\"identityKey\"]],\n \"unique(credential.moduleId,credential.credentialId)\": [\n \"credential\",\n [\"moduleId\", \"credentialId\"],\n ],\n \"unique(credential.moduleId,credential.subjectId)\": [\"credential\", [\"moduleId\", \"subjectId\"]],\n \"unique(emailCommand.moduleId,emailCommand.commandId)\": [\"command\", [\"moduleId\", \"commandId\"]],\n \"unique(emailCredential.moduleId,emailCredential.credentialId)\": [\n \"credential\",\n [\"moduleId\", \"credentialId\"],\n ],\n \"unique(emailCredential.moduleId,emailCredential.identifierNamespace,emailCredential.identifierValue)\":\n [\"credential\", [\"moduleId\", \"identifierNamespace\", \"identifierValue\"]],\n \"unique(emailRegistration.moduleId,emailRegistration.commandId)\": [\n \"registration\",\n [\"moduleId\", \"commandId\"],\n ],\n \"unique(emailRegistration.pendingReference)\": [\"registration\", [\"pendingReference\"]],\n \"unique(failureEvent.moduleId,failureEvent.seriesKey,failureEvent.commandId)\": [\n \"failureEvent\",\n [\"moduleId\", \"seriesKey\", \"commandId\"],\n ],\n \"unique(flow.flowId)\": [\"flow\", [\"flowId\"]],\n \"unique(flow.moduleId,flow.commandId)\": [\"flow\", [\"moduleId\", \"commandId\"]],\n \"unique(flow.moduleId,flow.flowId)\": [\"flow\", [\"moduleId\", \"flowId\"]],\n \"unique(flow.stateDigest)\": [\"flow\", [\"stateDigest\"]],\n \"unique(generation.moduleId,generation.deliveryId)\": [\"generation\", [\"moduleId\", \"deliveryId\"]],\n \"unique(generation.moduleId,generation.proofId)\": [\"generation\", [\"moduleId\", \"proofId\"]],\n \"unique(identifier.namespace,identifier.value)\": [\"identifier\", [\"namespace\", \"value\"]],\n \"unique(intent.digest)\": [\"intent\", [\"digest\"]],\n \"unique(intent.flowId)\": [\"intent\", [\"flowId\"]],\n \"unique(intent.moduleId,intent.commandId)\": [\"intent\", [\"moduleId\", \"commandId\"]],\n \"unique(intent.moduleId,intent.flowId)\": [\"intent\", [\"moduleId\", \"flowId\"]],\n \"unique(intent.moduleId,intent.intentId)\": [\"intent\", [\"moduleId\", \"intentId\"]],\n \"unique(intent.moduleId,intent.reference)\": [\"intent\", [\"moduleId\", \"reference\"]],\n \"unique(ownership.identityKey)\": [\"ownership\", [\"identityKey\"]],\n \"unique(pending.digest)\": [\"pending\", [\"digest\"]],\n \"unique(pending.flowId)\": [\"pending\", [\"flowId\"]],\n \"unique(rateScope.moduleId,rateScope.action,rateScope.scopeKind,rateScope.scopeKey)\": [\n \"rateScope\",\n [\"moduleId\", \"action\", \"scopeKind\", \"scopeKey\"],\n ],\n \"unique(rateScope.moduleId,rateScope.purpose,rateScope.action,rateScope.scopeKind,rateScope.scopeKey)\":\n [\"rateScope\", [\"moduleId\", \"purpose\", \"action\", \"scopeKind\", \"scopeKey\"]],\n \"unique(registration.moduleId,registration.requestId)\": [\n \"registration\",\n [\"moduleId\", \"requestId\"],\n ],\n \"unique(registration.recoveryReference)\": [\"registration\", [\"recoveryReference\"]],\n \"unique(registrationCommand.moduleId,registrationCommand.commandId)\": [\n \"command\",\n [\"moduleId\", \"commandId\"],\n ],\n \"unique(request.moduleId,request.requestId)\": [\"request\", [\"moduleId\", \"requestId\"]],\n \"unique(series.moduleId,series.purpose,series.scopeKey)\": [\n \"series\",\n [\"moduleId\", \"purpose\", \"scopeKey\"],\n ],\n \"unique(session.digest)\": [\"session\", [\"digest\"]],\n \"unique(tombstone.subjectId,tombstone.sessionId)\": [\"tombstone\", [\"subjectId\", \"sessionId\"]],\n \"unique(tuple.identityKey)\": [\"ownership.tuple\", [\"identityKey\"]],\n \"unique(unlinkCommand.moduleId,unlinkCommand.commandId)\": [\"command\", [\"moduleId\", \"commandId\"]],\n};\n\nconst arrayRoles: Readonly<Record<string, string>> = {\n credentialId: \"credential\",\n factor: \"authority\",\n credentialOwnership: \"credentialOwnership\",\n handleOwnership: \"handleOwnership\",\n boundSubjectHandle: \"handleOwnership\",\n flow: \"flow\",\n command: \"flow\",\n admission: \"admission\",\n charge: \"charge\",\n intentFlow: \"intent\",\n intentCommand: \"intent\",\n handle: \"handle\",\n};\n\nconst nestedMappings = [\n \"read\",\n \"signIn\",\n \"password\",\n \"proof\",\n \"proofs\",\n \"revocation\",\n \"pending\",\n \"session\",\n \"source\",\n];\n\nconst constraintGroups = [\n \"constraints\",\n \"tupleConstraints\",\n \"registrationConstraints\",\n \"managementConstraints\",\n];\n\nconst MappingRecord = Schema.Record(Schema.String, Schema.Unknown);\nconst record = Schema.decodeUnknownSync(MappingRecord);\n\nconst plans = (mapping: Readonly<Record<string, unknown>>) => {\n const result: Array<{ readonly table: Table; readonly keys: ReadonlyArray<string> }> = [];\n\n for (const group of constraintGroups) {\n if (mapping[group] === undefined) continue;\n for (const [name, declaration] of Object.entries(record(mapping[group]))) {\n if (declaration === \"notNull(provisioningRequest.subjectId)\") continue;\n let role: string;\n let keys: ReadonlyArray<string>;\n\n if (typeof declaration === \"string\") {\n const plan = uniquePlans[declaration];\n\n if (plan !== undefined) [role, keys] = plan;\n else if (declaration === \"unique(id)\") {\n role = \"subject\";\n keys = [\"id\"];\n } else if (declaration === \"unique(scope)\") {\n role = name;\n keys = [\"scope\"];\n } else if (declaration === \"unique(credentialId)\") {\n role = \"credential\";\n keys = [\"id\"];\n } else if (declaration === \"unique(namespace,value)\") {\n role = \"identifier\";\n keys = [\"namespace\", \"value\"];\n } else if (declaration === \"unique(provider,issuer,subject)\") {\n role = \"externalIdentity\";\n keys = [\"provider\", \"issuer\", \"subject\"];\n } else if (declaration === \"unique(requestId)\") {\n role = \"provisioningRequest\";\n keys = [\"requestId\"];\n } else throw new Error(\"Unknown storage constraint\");\n } else if (Array.isArray(declaration) && declaration.every(Predicate.isString)) {\n const mappedRole =\n group === \"managementConstraints\" && name === \"command\" ? \"command\" : arrayRoles[name];\n\n if (mappedRole === undefined) throw new Error(\"Unknown storage constraint\");\n role = mappedRole;\n keys = declaration;\n } else throw new Error(\"Invalid storage constraint\");\n\n let target: unknown = mapping;\n\n for (const segment of role.split(\".\")) target = record(target)[segment];\n // Session authority places its pending tables in one nested mapping.\n if (target === undefined && Schema.is(MappingRecord)(mapping.pending))\n target = mapping.pending[role];\n let mapped = record(target);\n\n if (role === \"pending\" && mapped.table === undefined) mapped = record(mapped.pending);\n // OAuth ownership can be integrated into its tuple authority or separate.\n if (role === \"ownership\" && mapped.table === undefined)\n mapped = record(mapped.external ?? mapped.tuple);\n if (!is(mapped.table, Table)) throw new Error(\"Missing storage table\");\n const columns = getTableColumns(mapped.table);\n\n result.push({\n table: mapped.table,\n keys: keys.map((key) => {\n const value = mapped[key];\n\n if (typeof value !== \"string\" || columns[value] === undefined)\n throw new Error(\"Missing mapped key\");\n\n return value;\n }),\n });\n }\n }\n for (const nested of nestedMappings) {\n const value = mapping[nested];\n\n if (Schema.is(MappingRecord)(value) && value.table === undefined) result.push(...plans(value));\n }\n\n return result;\n};\n\n/** Validate at acquisition using the root database supplied by the adapter. */\nexport const validateDrizzleStorage = Effect.fnUntraced(\n function* (mapping: unknown) {\n const physical = yield* Effect.try({\n try: () => plans(record(mapping)),\n catch: () =>\n PersistenceMappingError.make({\n operation: \"mapping\",\n cause: \"Invalid storage key mapping\",\n }),\n });\n\n const { $client: client } = yield* NativeDatabase;\n\n const batches = new Map<\"pg\" | \"mysql\" | \"sqlite\", StorageValidation[]>();\n\n for (const plan of physical) {\n const pg = is(plan.table, PgTable);\n const mysql = is(plan.table, MySqlTable);\n\n const schema = pg\n ? getPgTableConfig(plan.table).schema\n : mysql\n ? getMysqlTableConfig(plan.table).schema\n : undefined;\n\n const columns = getTableColumns(plan.table);\n\n const dialect = pg ? \"pg\" : mysql ? \"mysql\" : \"sqlite\";\n const batch = batches.get(dialect) ?? [];\n\n batch.push({\n table: {\n name: getTableName(plan.table),\n ...(schema === undefined ? {} : { schema }),\n columns: Object.fromEntries(plan.keys.map((key) => [key, { name: columns[key]!.name }])),\n },\n required: [plan.keys],\n });\n batches.set(dialect, batch);\n }\n for (const [dialect, requirements] of batches) {\n yield* validateStorageBatch(dialect, requirements).pipe(\n Effect.provideService(SqlClient, client),\n Effect.mapError(() =>\n PersistenceMappingError.make({\n operation: \"mapping\",\n cause: \"Required SQL storage key is unavailable\",\n }),\n ),\n );\n }\n },\n Effect.catchDefect(() =>\n Effect.fail(\n PersistenceMappingError.make({\n operation: \"mapping\",\n cause: \"Cannot inspect SQL storage metadata\",\n }),\n ),\n ),\n);\n"],"mappings":";;;;;;;AAcA,MAAM,cAAkF;CACtF,+GACE,CAAC,cAAc;EAAC;EAAY;EAAU;EAAa;EAAY;CAAW,CAAC;CAC7E,8BAA8B,CAAC,aAAa,CAAC,UAAU,CAAC;CACxD,8CAA8C,CAAC,WAAW,CAAC,YAAY,WAAW,CAAC;CACnF,sDAAsD,CACpD,aACA,CAAC,aAAa,cAAc,CAC9B;CACA,0EAA0E,CACxE,uBACA,CAAC,aAAa,cAAc,CAC9B;CACA,2FAA2F,CACzF,UACA;EAAC;EAAY;EAAU;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AC,CACH,CACF,CACF"}
|
|
1
|
+
{"version":3,"file":"storage-validation.mjs","names":["getPgTableConfig","getMysqlTableConfig"],"sources":["../../src/drizzle/storage-validation.ts"],"sourcesContent":["import {\n NativeDatabase,\n PersistenceMappingError,\n validateStorageBatch,\n type StorageValidation,\n storageKeyPlans,\n} from \"@yielded/auth-persistence/Adapter\";\nimport { getTableColumns, getTableName, is, Table } from \"drizzle-orm\";\nimport { getTableConfig as getMysqlTableConfig, MySqlTable } from \"drizzle-orm/mysql-core\";\nimport { getTableConfig as getPgTableConfig, PgTable } from \"drizzle-orm/pg-core\";\nimport { Effect } from \"effect\";\nimport { SqlClient } from \"effect/sql/SqlClient\";\n\n/** Validate at acquisition using the root database supplied by the adapter. */\nexport const validateDrizzleStorage = Effect.fnUntraced(\n function* (mapping: unknown) {\n const physical = yield* Effect.try({\n try: () =>\n storageKeyPlans(mapping, (table) => {\n if (!is(table, Table)) throw new Error(\"Missing storage table\");\n\n return getTableColumns(table);\n }),\n catch: () =>\n PersistenceMappingError.make({\n operation: \"mapping\",\n cause: \"Invalid storage key mapping\",\n }),\n });\n\n const { $client: client } = yield* NativeDatabase;\n\n const batches = new Map<\"pg\" | \"mysql\" | \"sqlite\", StorageValidation[]>();\n\n for (const plan of physical) {\n if (!is(plan.table, Table))\n return yield* PersistenceMappingError.make({\n operation: \"mapping\",\n cause: \"Missing storage table\",\n });\n const pg = is(plan.table, PgTable);\n const mysql = is(plan.table, MySqlTable);\n\n const schema = pg\n ? getPgTableConfig(plan.table).schema\n : mysql\n ? getMysqlTableConfig(plan.table).schema\n : undefined;\n\n const columns = getTableColumns(plan.table);\n\n const dialect = pg ? \"pg\" : mysql ? \"mysql\" : \"sqlite\";\n const batch = batches.get(dialect) ?? [];\n\n batch.push({\n table: {\n name: getTableName(plan.table),\n ...(schema === undefined ? {} : { schema }),\n columns: Object.fromEntries(plan.keys.map((key) => [key, { name: columns[key]!.name }])),\n },\n required: [plan.keys],\n });\n batches.set(dialect, batch);\n }\n for (const [dialect, requirements] of batches) {\n yield* validateStorageBatch(dialect, requirements).pipe(\n Effect.provideService(SqlClient, client),\n Effect.mapError(() =>\n PersistenceMappingError.make({\n operation: \"mapping\",\n cause: \"Required SQL storage key is unavailable\",\n }),\n ),\n );\n }\n },\n Effect.catchDefect(() =>\n Effect.fail(\n PersistenceMappingError.make({\n operation: \"mapping\",\n cause: \"Cannot inspect SQL storage metadata\",\n }),\n ),\n ),\n);\n"],"mappings":";;;;;;;;AAcA,MAAa,yBAAyB,OAAO,WAC3C,WAAW,SAAkB;CAC3B,MAAM,WAAW,OAAO,OAAO,IAAI;EACjC,WACE,gBAAgB,UAAU,UAAU;GAClC,IAAI,CAAC,GAAG,OAAO,KAAK,GAAG,MAAM,IAAI,MAAM,uBAAuB;GAE9D,OAAO,gBAAgB,KAAK;EAC9B,CAAC;EACH,aACE,wBAAwB,KAAK;GAC3B,WAAW;GACX,OAAO;EACT,CAAC;CACL,CAAC;CAED,MAAM,EAAE,SAAS,WAAW,OAAO;CAEnC,MAAM,0BAAU,IAAI,IAAoD;CAExE,KAAK,MAAM,QAAQ,UAAU;EAC3B,IAAI,CAAC,GAAG,KAAK,OAAO,KAAK,GACvB,OAAO,OAAO,wBAAwB,KAAK;GACzC,WAAW;GACX,OAAO;EACT,CAAC;EACH,MAAM,KAAK,GAAG,KAAK,OAAO,OAAO;EACjC,MAAM,QAAQ,GAAG,KAAK,OAAO,UAAU;EAEvC,MAAM,SAAS,KACXA,iBAAiB,KAAK,KAAK,CAAC,CAAC,SAC7B,QACEC,eAAoB,KAAK,KAAK,CAAC,CAAC,SAChC,KAAA;EAEN,MAAM,UAAU,gBAAgB,KAAK,KAAK;EAE1C,MAAM,UAAU,KAAK,OAAO,QAAQ,UAAU;EAC9C,MAAM,QAAQ,QAAQ,IAAI,OAAO,KAAK,CAAC;EAEvC,MAAM,KAAK;GACT,OAAO;IACL,MAAM,aAAa,KAAK,KAAK;IAC7B,GAAI,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;IACzC,SAAS,OAAO,YAAY,KAAK,KAAK,KAAK,QAAQ,CAAC,KAAK,EAAE,MAAM,QAAQ,IAAI,CAAE,KAAK,CAAC,CAAC,CAAC;GACzF;GACA,UAAU,CAAC,KAAK,IAAI;EACtB,CAAC;EACD,QAAQ,IAAI,SAAS,KAAK;CAC5B;CACA,KAAK,MAAM,CAAC,SAAS,iBAAiB,SACpC,OAAO,qBAAqB,SAAS,YAAY,CAAC,CAAC,KACjD,OAAO,eAAe,WAAW,MAAM,GACvC,OAAO,eACL,wBAAwB,KAAK;EAC3B,WAAW;EACX,OAAO;CACT,CAAC,CACH,CACF;AAEJ,GACA,OAAO,kBACL,OAAO,KACL,wBAAwB,KAAK;CAC3B,WAAW;CACX,OAAO;AACT,CAAC,CACH,CACF,CACF"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { PersistenceMappingError as PersistenceMappingError$1 } from "./model.mjs";
|
|
2
|
-
import "./transaction-owner.mjs";
|
|
3
|
-
import { TransactionCoordinatorError } from "./transaction-execution.mjs";
|
|
4
2
|
import "./totp-model.mjs";
|
|
3
|
+
import "./transaction-owner.mjs";
|
|
5
4
|
import "./SuppliedService.mjs";
|
|
5
|
+
import { TransactionCoordinatorError } from "./transaction-execution.mjs";
|
|
6
6
|
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
7
7
|
import { Table } from "drizzle-orm";
|
|
8
8
|
import { Context, Crypto, Effect } from "effect";
|
|
9
9
|
import { LifecycleHooks } from "@yielded/auth/Hooks";
|
|
10
|
-
import { TotpConfigurationError, TotpPersistence, TotpUnavailable } from "@yielded/auth/Totp";
|
|
11
10
|
import { Statement } from "effect/sql/Statement";
|
|
11
|
+
import { TotpConfigurationError, TotpPersistence, TotpUnavailable } from "@yielded/auth/Totp";
|
|
12
12
|
//#region src/drizzle/totp-target.d.ts
|
|
13
13
|
export type TotpCoordinatorError<E> = TransactionCoordinatorError<E, TotpUnavailable> | TotpConfigurationError | PersistenceMappingError$1;
|
|
14
14
|
//#endregion
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { validateDrizzleStorage } from "./storage-validation.mjs";
|
|
2
|
-
import { randomId } from "./crypto.mjs";
|
|
3
|
-
import { coordinateTransactionOwner, makeTransactionExecution, sqlClientTransactionStandaloneGuard } from "./transaction-execution.mjs";
|
|
4
2
|
import { requiredTotpConstraints } from "./totp-model.mjs";
|
|
3
|
+
import { randomId } from "./crypto.mjs";
|
|
5
4
|
import { CurrentTotpTransaction, captureTotp, invariant, mutateTotp, unavailable } from "./totp-state.mjs";
|
|
6
5
|
import { nativeDatabase } from "./native-database.mjs";
|
|
6
|
+
import { coordinateTransactionOwner, makeTransactionExecution, sqlClientTransactionStandaloneGuard } from "./transaction-execution.mjs";
|
|
7
7
|
import { NativeDatabase } from "@yielded/auth-persistence/Adapter";
|
|
8
8
|
import { Context, Effect, Schema } from "effect";
|
|
9
9
|
import { LifecycleHooks } from "@yielded/auth/Hooks";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { TransactionCoordinatorError
|
|
2
|
-
export type { TransactionCoordinatorError
|
|
1
|
+
import { TransactionCoordinatorError } from "@yielded/auth-persistence/Adapter";
|
|
2
|
+
export type { TransactionCoordinatorError };
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
export type { Row, TransactionOwner };
|
|
1
|
+
import "@yielded/auth-persistence/Adapter";
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { OAuthProxyColumns } from "./drizzle/oauth-proxy.mjs";
|
|
1
2
|
import { AnyEmailAddressMapping, AnyEmailRegistrationMapping, AnyEmailSignInMapping, D1EmailAddressMapping, D1EmailRegistrationMapping, EmailAddressMapping, EmailAuthorityCredentialTable, EmailCommandTable, EmailCredentialReadTable, EmailCredentialTable, EmailD1Clock, EmailIdentifierReadTable, EmailIdentifierTable, EmailRegistrationAuthorityCredentialTable, EmailRegistrationCredentialTable, EmailRegistrationIdentifierTable, EmailRegistrationIntent, EmailRegistrationMapping, EmailRegistrationProvisioning, EmailRegistrationState, EmailRegistrationTable, EmailSignInMapping, EmailSubjectReadTable, EmailSubjectTable, RequiredEmailAddressConstraints, RequiredEmailRegistrationConstraints, RequiredEmailSignInConstraints, requiredEmailAddressConstraints, requiredEmailRegistrationConstraints, requiredEmailSignInConstraints } from "./drizzle/email-model.mjs";
|
|
2
|
-
import { AnyPasswordPersistenceMapping, AnyPasswordRegistrationMapping, D1PasswordPersistenceMapping,
|
|
3
|
+
import { AnyPasswordPersistenceMapping, AnyPasswordRegistrationMapping, D1PasswordPersistenceMapping, PasswordAuthorityCredentialTable, PasswordCommandTable, PasswordConstraintClassifier, PasswordCredentialTable, PasswordD1Clock, PasswordIdentifierTable, PasswordPersistenceMapping, PasswordRegistrationConstraintClassifier, PasswordRegistrationIntent, PasswordRegistrationMapping, PasswordRegistrationProvisioning, PasswordRegistrationState, PasswordRegistrationTable, PasswordSubjectTable, RequiredPasswordConstraints, RequiredPasswordRegistrationConstraints, requiredPasswordConstraints, requiredPasswordRegistrationConstraints } from "./drizzle/password-model.mjs";
|
|
3
4
|
import { CommitMode, D1ExternalIdentityMapping, D1GeneratedIdentityMapping, D1SubjectProvisioningMapping, ExternalIdentityTables, IdentityTables, InstantCodec, PersistenceMappingError, RequiredExternalIdentityConstraints, RequiredIdentityConstraints, RequiredSubjectProvisioningConstraints, SubjectIdCodec, SubjectProvisioningTables, column, identityServicesLayer, isMappedConstraintConflict, provisioningFingerprint, requiredExternalIdentityConstraints, requiredIdentityConstraints, requiredSubjectProvisioningConstraints, updateValues } from "./drizzle/model.mjs";
|
|
4
5
|
import { AnyProofPersistenceMapping, D1ProofPersistenceMapping, ProofAbuseEventTable, ProofAction, ProofAuthorityInput, ProofAuthorityTables, ProofCommandDecision, ProofCommandKind, ProofCommandTable, ProofConstraintClassifier, ProofContinuationRecord, ProofContinuationTable, ProofD1Clock, ProofDeliveryState, ProofFailureEventTable, ProofGenerationState, ProofGenerationTable, ProofPersistenceMapping, ProofRateScopeTable, ProofRequestTable, ProofScopeKeys, ProofScopeKind, ProofSeriesTable, RequiredProofConstraints, requiredProofConstraints } from "./drizzle/proof-model.mjs";
|
|
5
6
|
import { AnyPasswordPreparedPersistenceMapping, D1PasswordPreparedPersistenceMapping, D1PasswordPreparedProofMapping, PasswordPreparedAdmissionTable, PasswordPreparedIntentTable, PasswordPreparedPersistenceMapping, PasswordPreparedProofMapping, PasswordPreparedState, RequiredPasswordPreparedConstraints, requiredPasswordPreparedConstraints } from "./drizzle/password-prepared-model.mjs";
|
|
@@ -22,4 +23,4 @@ import { decodeTotpRecord, encodeTotpRecord } from "./drizzle/totp-state.mjs";
|
|
|
22
23
|
import { PasskeyCommandTable, PasskeyCredentialInsert, PasskeyInvalidationInput, PasskeyInvalidationMutation, PasskeyManagementMapping, PasskeyManagementServices, PasskeyRegistrationMapping, PasskeyRegistrationServices, PasskeyRegistrationWriter, PasskeyWriteTables, passkeyInvalidationMutation, requiredPasskeyManagementConstraints, requiredPasskeyRegistrationWriteConstraints } from "./drizzle/passkey-write-model.mjs";
|
|
23
24
|
import { passkeyManagementPersistenceLayer } from "./drizzle/passkey-write-target.mjs";
|
|
24
25
|
import { D1PhoneMapping, PhoneMapping, PhoneMappingSource, PhonePersistenceServices, PhoneProofCompletionMapping, phonePersistenceLayer, phoneProofCompletionMapping, requiredPhoneConstraints } from "./drizzle/phone-model.mjs";
|
|
25
|
-
export { type AnyEmailAddressMapping, type AnyEmailRegistrationMapping, type AnyEmailSignInMapping, type AnyPasswordPersistenceMapping, type AnyPasswordPreparedPersistenceMapping, type AnyPasswordRegistrationMapping, type AnyProofPersistenceMapping, type AuthenticationAuthorityMapping, type CommitMode, type D1AuthenticationAuthorityMapping, type D1EmailAddressMapping, type D1EmailRegistrationMapping, type D1ExternalIdentityMapping, type D1GeneratedIdentityMapping, type D1PasskeyMapping, type D1PasswordPersistenceMapping, type D1PasswordPreparedPersistenceMapping, type D1PasswordPreparedProofMapping, type D1PendingAuthenticationMapping, type D1PhoneMapping, type D1ProofPersistenceMapping, type D1SessionClockMapping, type D1SessionStepUpMapping, type D1SignedSessionValidityMapping, type D1StatefulSessionMapping, type D1SubjectProvisioningMapping, type D1TotpMapping, type EmailAddressMapping, type EmailAuthorityCredentialTable, type EmailCommandTable, type EmailCredentialReadTable, type EmailCredentialTable, type EmailD1Clock, type EmailIdentifierReadTable, type EmailIdentifierTable, type EmailRegistrationAuthorityCredentialTable, type EmailRegistrationCredentialTable, type EmailRegistrationIdentifierTable, type EmailRegistrationIntent, type EmailRegistrationMapping, type EmailRegistrationProvisioning, type EmailRegistrationState, type EmailRegistrationTable, type EmailSignInMapping, type EmailSubjectReadTable, type EmailSubjectTable, type ExternalIdentityTables, type IdentityTables, type InstantCodec, type OAuthAccountsMapping, type OAuthAction, type OAuthAuthorityReadTable, type OAuthAuthorityTable, type OAuthCleanupDescriptor, type OAuthCleanupTable, type OAuthClock, type OAuthConnectedAction, type OAuthConnectedAdmissionTable, type OAuthConnectedAuthorityMapping, type OAuthConnectedClientRegistrationTable, type OAuthConnectedCohortTable, type OAuthConnectedCommandTable, type OAuthConnectedFlowTable, type OAuthConnectedGrantTable, type OAuthConnectedMapping, type OAuthConnectedOrderCodec, type OAuthConnectedOwnershipRead, type OAuthConnectedPolicyGuard, type OAuthConnectedPolicyGuardTable, type OAuthConnectedPolicyInput, type OAuthConnectedRevocationJobTable, type OAuthConnectedRevocationMapping, type OAuthConnectedSqlPolicy, type OAuthConnectedSubjectTable, type OAuthCredentialReadTable, type OAuthCredentialTable, type OAuthD1Mapping, type OAuthEligibilityDescriptor, type OAuthEligibilityFact, type OAuthEligibilityTable, type OAuthFlowState, type OAuthFlowTable, type OAuthMetadataPolicy, type OAuthOwnershipMutation, type OAuthOwnershipReadTable, type OAuthOwnershipTable, type OAuthReferenceGuardDescriptor, type OAuthReferenceGuardTable, type OAuthRegistrationAuthority, type OAuthRegistrationBase, type OAuthRegistrationCommandTable, type OAuthRegistrationEligibility, type OAuthRegistrationGuardDescriptor, type OAuthRegistrationGuardTable, type OAuthRegistrationIntentMapping, type OAuthRegistrationIntentTable, type OAuthRegistrationMapping, type OAuthRegistrationState, type OAuthSignInMapping, type OAuthSubjectReadTable, type OAuthSubjectTable, type OAuthTupleAuthorityTable, type OAuthTupleState, type OAuthUnlinkCommandTable, type PasskeyAdmissionTable, type PasskeyCeremonyMapping, type PasskeyChargeInsert, type PasskeyChargeKind, type PasskeyChargeTable, type PasskeyClock, type PasskeyColumn, type PasskeyCommandTable, type PasskeyCredentialInsert, type PasskeyCredentialMapping, type PasskeyCredentialOwnershipTable, type PasskeyCredentialReadTable, type PasskeyCredentialServices, type PasskeyEnrollmentContextMapping, type PasskeyEnrollmentContextServices, type PasskeyFactorReadTable, type PasskeyFlowInsert, type PasskeyFlowState, type PasskeyFlowTable, type PasskeyHandleOwnershipTable, type PasskeyHandleReadTable, type PasskeyHandleReservationTable, type PasskeyInvalidationInput, type PasskeyInvalidationMutation, type PasskeyManagementMapping, type PasskeyManagementServices, type PasskeyMappingSource, type PasskeyModuleTable, type PasskeyPersistenceMapping, type PasskeyPersistenceServices, type PasskeyPolicyGuard, type PasskeyRegistrationCeremonyCapabilities, type PasskeyRegistrationCeremonyMapping, type PasskeyRegistrationCeremonyServices, type PasskeyRegistrationIntentReadTable, type PasskeyRegistrationMapping, type PasskeyRegistrationServices, type PasskeyRegistrationWriter, type PasskeySubjectIdCodec, type PasskeySubjectReadTable, type PasskeyWriteTables, type
|
|
26
|
+
export { type AnyEmailAddressMapping, type AnyEmailRegistrationMapping, type AnyEmailSignInMapping, type AnyPasswordPersistenceMapping, type AnyPasswordPreparedPersistenceMapping, type AnyPasswordRegistrationMapping, type AnyProofPersistenceMapping, type AuthenticationAuthorityMapping, type CommitMode, type D1AuthenticationAuthorityMapping, type D1EmailAddressMapping, type D1EmailRegistrationMapping, type D1ExternalIdentityMapping, type D1GeneratedIdentityMapping, type D1PasskeyMapping, type D1PasswordPersistenceMapping, type D1PasswordPreparedPersistenceMapping, type D1PasswordPreparedProofMapping, type D1PendingAuthenticationMapping, type D1PhoneMapping, type D1ProofPersistenceMapping, type D1SessionClockMapping, type D1SessionStepUpMapping, type D1SignedSessionValidityMapping, type D1StatefulSessionMapping, type D1SubjectProvisioningMapping, type D1TotpMapping, type EmailAddressMapping, type EmailAuthorityCredentialTable, type EmailCommandTable, type EmailCredentialReadTable, type EmailCredentialTable, type EmailD1Clock, type EmailIdentifierReadTable, type EmailIdentifierTable, type EmailRegistrationAuthorityCredentialTable, type EmailRegistrationCredentialTable, type EmailRegistrationIdentifierTable, type EmailRegistrationIntent, type EmailRegistrationMapping, type EmailRegistrationProvisioning, type EmailRegistrationState, type EmailRegistrationTable, type EmailSignInMapping, type EmailSubjectReadTable, type EmailSubjectTable, type ExternalIdentityTables, type IdentityTables, type InstantCodec, type OAuthAccountsMapping, type OAuthAction, type OAuthAuthorityReadTable, type OAuthAuthorityTable, type OAuthCleanupDescriptor, type OAuthCleanupTable, type OAuthClock, type OAuthConnectedAction, type OAuthConnectedAdmissionTable, type OAuthConnectedAuthorityMapping, type OAuthConnectedClientRegistrationTable, type OAuthConnectedCohortTable, type OAuthConnectedCommandTable, type OAuthConnectedFlowTable, type OAuthConnectedGrantTable, type OAuthConnectedMapping, type OAuthConnectedOrderCodec, type OAuthConnectedOwnershipRead, type OAuthConnectedPolicyGuard, type OAuthConnectedPolicyGuardTable, type OAuthConnectedPolicyInput, type OAuthConnectedRevocationJobTable, type OAuthConnectedRevocationMapping, type OAuthConnectedSqlPolicy, type OAuthConnectedSubjectTable, type OAuthCredentialReadTable, type OAuthCredentialTable, type OAuthD1Mapping, type OAuthEligibilityDescriptor, type OAuthEligibilityFact, type OAuthEligibilityTable, type OAuthFlowState, type OAuthFlowTable, type OAuthMetadataPolicy, type OAuthOwnershipMutation, type OAuthOwnershipReadTable, type OAuthOwnershipTable, type OAuthProxyColumns, type OAuthReferenceGuardDescriptor, type OAuthReferenceGuardTable, type OAuthRegistrationAuthority, type OAuthRegistrationBase, type OAuthRegistrationCommandTable, type OAuthRegistrationEligibility, type OAuthRegistrationGuardDescriptor, type OAuthRegistrationGuardTable, type OAuthRegistrationIntentMapping, type OAuthRegistrationIntentTable, type OAuthRegistrationMapping, type OAuthRegistrationState, type OAuthSignInMapping, type OAuthSubjectReadTable, type OAuthSubjectTable, type OAuthTupleAuthorityTable, type OAuthTupleState, type OAuthUnlinkCommandTable, type PasskeyAdmissionTable, type PasskeyCeremonyMapping, type PasskeyChargeInsert, type PasskeyChargeKind, type PasskeyChargeTable, type PasskeyClock, type PasskeyColumn, type PasskeyCommandTable, type PasskeyCredentialInsert, type PasskeyCredentialMapping, type PasskeyCredentialOwnershipTable, type PasskeyCredentialReadTable, type PasskeyCredentialServices, type PasskeyEnrollmentContextMapping, type PasskeyEnrollmentContextServices, type PasskeyFactorReadTable, type PasskeyFlowInsert, type PasskeyFlowState, type PasskeyFlowTable, type PasskeyHandleOwnershipTable, type PasskeyHandleReadTable, type PasskeyHandleReservationTable, type PasskeyInvalidationInput, type PasskeyInvalidationMutation, type PasskeyManagementMapping, type PasskeyManagementServices, type PasskeyMappingSource, type PasskeyModuleTable, type PasskeyPersistenceMapping, type PasskeyPersistenceServices, type PasskeyPolicyGuard, type PasskeyRegistrationCeremonyCapabilities, type PasskeyRegistrationCeremonyMapping, type PasskeyRegistrationCeremonyServices, type PasskeyRegistrationIntentReadTable, type PasskeyRegistrationMapping, type PasskeyRegistrationServices, type PasskeyRegistrationWriter, type PasskeySubjectIdCodec, type PasskeySubjectReadTable, type PasskeyWriteTables, type PasswordAuthorityCredentialTable, type PasswordCommandTable, type PasswordConstraintClassifier, type PasswordCredentialTable, type PasswordD1Clock, type PasswordIdentifierTable, type PasswordPersistenceMapping, type PasswordPreparedAdmissionTable, type PasswordPreparedIntentTable, type PasswordPreparedPersistenceMapping, type PasswordPreparedProofMapping, type PasswordPreparedState, type PasswordRegistrationConstraintClassifier, type PasswordRegistrationIntent, type PasswordRegistrationMapping, type PasswordRegistrationProvisioning, type PasswordRegistrationState, type PasswordRegistrationTable, type PasswordSubjectTable, type PendingAuthenticationMapping, type PendingAuthenticationTables, type PersistenceMappingError, type PhoneMapping, type PhoneMappingSource, type PhonePersistenceServices, type PhoneProofCompletionMapping, type ProofAbuseEventTable, type ProofAction, type ProofAuthorityInput, type ProofAuthorityTables, type ProofCommandDecision, type ProofCommandKind, type ProofCommandTable, type ProofConstraintClassifier, type ProofContinuationRecord, type ProofContinuationTable, type ProofD1Clock, type ProofDeliveryState, type ProofFailureEventTable, type ProofGenerationState, type ProofGenerationTable, type ProofPersistenceMapping, type ProofRateScopeTable, type ProofRequestTable, type ProofScopeKeys, type ProofScopeKind, type ProofSeriesTable, type RequiredEmailAddressConstraints, type RequiredEmailRegistrationConstraints, type RequiredEmailSignInConstraints, type RequiredExternalIdentityConstraints, type RequiredIdentityConstraints, type RequiredPasswordConstraints, type RequiredPasswordPreparedConstraints, type RequiredPasswordRegistrationConstraints, type RequiredPendingAuthenticationConstraints, type RequiredProofConstraints, type RequiredSessionConstraints, type RequiredSessionStepUpConstraints, type RequiredSignedValidityConstraints, type RequiredStatefulPendingConstraints, type RequiredSubjectProvisioningConstraints, type SessionAuthorityTables, type SessionConstraintClassifier, type SessionFlowTables, type SessionIdCodec, type SessionStepUpIntentTables, type SessionStepUpMapping, type SessionStepUpSourceTables, type SessionSubjectTables, type SignedSessionValidityMapping, type SignedSessionValidityTables, type StatefulSessionMapping, type StatefulSessionTables, type SubjectIdCodec, type SubjectProvisioningTables, type TotpMapping, type TotpMappingSource, type TotpPersistenceServices, authenticationAuthorityLayer, column, decodeTotpRecord, emailAddressPersistenceLayer, emailRegistrationLayer, emailSignInTargetsLayer, encodeTotpRecord, identityServicesLayer, isMappedConstraintConflict, oauthAccountsPersistenceLayer, oauthCleanupTable, oauthConnectedOwnershipReferences, oauthConnectedPersistenceLayer, oauthConnectedPolicyGuard, oauthConnectedRevocationsLayer, oauthEligibilityTable, oauthReferenceGuardTable, oauthRegistrationAuthorityLayer, oauthRegistrationGuardTable, oauthRegistrationIntentsLayer, oauthSignInPersistenceLayer, passkeyCredentialsLayer, passkeyEnrollmentContextLayer, passkeyInvalidationMutation, passkeyManagementPersistenceLayer, passkeyPersistenceLayer, passkeyPolicyGuard, passwordPersistenceLayer, passwordPreparedPersistenceLayer, passwordRegistrationLayer, pendingAuthenticationLayer, phonePersistenceLayer, phoneProofCompletionMapping, proofPersistenceLayer, provisioningFingerprint, requiredEmailAddressConstraints, requiredEmailRegistrationConstraints, requiredEmailSignInConstraints, requiredExternalIdentityConstraints, requiredIdentityConstraints, requiredOAuthAccountsConstraints, requiredOAuthConnectedConstraints, requiredOAuthConnectedRevocationConstraints, requiredOAuthRegistrationConstraints, requiredOAuthSignInConstraints, requiredOAuthTupleConstraints, requiredPasskeyCredentialConstraints, requiredPasskeyManagementConstraints, requiredPasskeyPersistenceConstraints, requiredPasskeyRegistrationCeremonyConstraints, requiredPasskeyRegistrationWriteConstraints, requiredPasswordConstraints, requiredPasswordPreparedConstraints, requiredPasswordRegistrationConstraints, requiredPendingAuthenticationConstraints, requiredPhoneConstraints, requiredProofConstraints, requiredSessionConstraints, requiredSessionStepUpConstraints, requiredSignedValidityConstraints, requiredStatefulPendingConstraints, requiredSubjectProvisioningConstraints, requiredTotpConstraints, signedSessionValidityLayer, statefulSessionLayers, totpPersistenceLayer, updateValues };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { OAuthProxyColumns } from "../drizzle/oauth-proxy.mjs";
|
|
2
|
+
import { PgTable } from "drizzle-orm/pg-core";
|
|
3
|
+
//#region src/internal/drizzle-postgres-oauth-proxy.d.ts
|
|
4
|
+
/** Export the returned table from your Drizzle Kit schema before applying the Layer. */
|
|
5
|
+
declare const table: (name: string) => import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
6
|
+
name: string;
|
|
7
|
+
schema: undefined;
|
|
8
|
+
columns: {
|
|
9
|
+
namespace: import("drizzle-orm/pg-core").PgBuildColumn<string, import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>, {
|
|
10
|
+
name: string;
|
|
11
|
+
tableName: string;
|
|
12
|
+
dataType: "string";
|
|
13
|
+
data: string;
|
|
14
|
+
driverParam: string;
|
|
15
|
+
notNull: true;
|
|
16
|
+
hasDefault: false;
|
|
17
|
+
isPrimaryKey: false;
|
|
18
|
+
isAutoincrement: false;
|
|
19
|
+
hasRuntimeDefault: false;
|
|
20
|
+
enumValues: undefined;
|
|
21
|
+
identity: undefined;
|
|
22
|
+
generated: undefined;
|
|
23
|
+
}>;
|
|
24
|
+
flowId: import("drizzle-orm/pg-core").PgBuildColumn<string, import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>, {
|
|
25
|
+
name: string;
|
|
26
|
+
tableName: string;
|
|
27
|
+
dataType: "string";
|
|
28
|
+
data: string;
|
|
29
|
+
driverParam: string;
|
|
30
|
+
notNull: true;
|
|
31
|
+
hasDefault: false;
|
|
32
|
+
isPrimaryKey: false;
|
|
33
|
+
isAutoincrement: false;
|
|
34
|
+
hasRuntimeDefault: false;
|
|
35
|
+
enumValues: undefined;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}>;
|
|
39
|
+
version: import("drizzle-orm/pg-core").PgBuildColumn<string, import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>, {
|
|
40
|
+
name: string;
|
|
41
|
+
tableName: string;
|
|
42
|
+
dataType: "string";
|
|
43
|
+
data: string;
|
|
44
|
+
driverParam: string;
|
|
45
|
+
notNull: true;
|
|
46
|
+
hasDefault: false;
|
|
47
|
+
isPrimaryKey: false;
|
|
48
|
+
isAutoincrement: false;
|
|
49
|
+
hasRuntimeDefault: false;
|
|
50
|
+
enumValues: undefined;
|
|
51
|
+
identity: undefined;
|
|
52
|
+
generated: undefined;
|
|
53
|
+
}>;
|
|
54
|
+
stage: import("drizzle-orm/pg-core").PgBuildColumn<string, import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>, {
|
|
55
|
+
name: string;
|
|
56
|
+
tableName: string;
|
|
57
|
+
dataType: "string";
|
|
58
|
+
data: string;
|
|
59
|
+
driverParam: string;
|
|
60
|
+
notNull: true;
|
|
61
|
+
hasDefault: false;
|
|
62
|
+
isPrimaryKey: false;
|
|
63
|
+
isAutoincrement: false;
|
|
64
|
+
hasRuntimeDefault: false;
|
|
65
|
+
enumValues: undefined;
|
|
66
|
+
identity: undefined;
|
|
67
|
+
generated: undefined;
|
|
68
|
+
}>;
|
|
69
|
+
context: import("drizzle-orm/pg-core").PgBuildColumn<string, import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>, {
|
|
70
|
+
name: string;
|
|
71
|
+
tableName: string;
|
|
72
|
+
dataType: "string";
|
|
73
|
+
data: string;
|
|
74
|
+
driverParam: string;
|
|
75
|
+
notNull: true;
|
|
76
|
+
hasDefault: false;
|
|
77
|
+
isPrimaryKey: false;
|
|
78
|
+
isAutoincrement: false;
|
|
79
|
+
hasRuntimeDefault: false;
|
|
80
|
+
enumValues: undefined;
|
|
81
|
+
identity: undefined;
|
|
82
|
+
generated: undefined;
|
|
83
|
+
}>;
|
|
84
|
+
expiresAtMillis: import("drizzle-orm/pg-core").PgBuildColumn<string, import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgBigInt53Builder>, {
|
|
85
|
+
name: string;
|
|
86
|
+
tableName: string;
|
|
87
|
+
dataType: "number int53";
|
|
88
|
+
data: number;
|
|
89
|
+
driverParam: string | number;
|
|
90
|
+
notNull: true;
|
|
91
|
+
hasDefault: false;
|
|
92
|
+
isPrimaryKey: false;
|
|
93
|
+
isAutoincrement: false;
|
|
94
|
+
hasRuntimeDefault: false;
|
|
95
|
+
enumValues: undefined;
|
|
96
|
+
identity: undefined;
|
|
97
|
+
generated: undefined;
|
|
98
|
+
}>;
|
|
99
|
+
handoffExpiresAtMillis: import("drizzle-orm/pg-core").PgBuildColumn<string, import("drizzle-orm/pg-core").PgBigInt53Builder, {
|
|
100
|
+
name: string;
|
|
101
|
+
tableName: string;
|
|
102
|
+
dataType: "number int53";
|
|
103
|
+
data: number;
|
|
104
|
+
driverParam: string | number;
|
|
105
|
+
notNull: false;
|
|
106
|
+
hasDefault: false;
|
|
107
|
+
isPrimaryKey: false;
|
|
108
|
+
isAutoincrement: false;
|
|
109
|
+
hasRuntimeDefault: false;
|
|
110
|
+
enumValues: undefined;
|
|
111
|
+
identity: undefined;
|
|
112
|
+
generated: undefined;
|
|
113
|
+
}>;
|
|
114
|
+
payload: import("drizzle-orm/pg-core").PgBuildColumn<string, import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>>, {
|
|
115
|
+
name: string;
|
|
116
|
+
tableName: string;
|
|
117
|
+
dataType: "string";
|
|
118
|
+
data: string;
|
|
119
|
+
driverParam: string;
|
|
120
|
+
notNull: true;
|
|
121
|
+
hasDefault: false;
|
|
122
|
+
isPrimaryKey: false;
|
|
123
|
+
isAutoincrement: false;
|
|
124
|
+
hasRuntimeDefault: false;
|
|
125
|
+
enumValues: undefined;
|
|
126
|
+
identity: undefined;
|
|
127
|
+
generated: undefined;
|
|
128
|
+
}>;
|
|
129
|
+
};
|
|
130
|
+
dialect: 'pg';
|
|
131
|
+
}>;
|
|
132
|
+
declare const layer: <T extends PgTable>(table: T, columns?: OAuthProxyColumns<T>) => import("effect/Layer").Layer<import("@yielded/auth/OAuthProxy").Persistence, import("@yielded/auth/OAuthProxy").ConfigurationError | import("@yielded/auth/OAuthProxy").Unavailable, import("effect/sql/SqlClient").SqlClient>;
|
|
133
|
+
export declare const OAuthProxyPersistence: {
|
|
134
|
+
table: typeof table;
|
|
135
|
+
layer: typeof layer;
|
|
136
|
+
};
|
|
137
|
+
//#endregion
|
|
138
|
+
//# sourceMappingURL=drizzle-postgres-oauth-proxy.d.mts.map
|