@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,278 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
OAuthConnectedPersistence,
|
|
4
|
-
OAuthConnectedRevocations,
|
|
5
|
-
OAuthConnectedRevocationDecision,
|
|
6
|
-
OAuthExternalIdentity,
|
|
7
|
-
snapshotOAuthSync,
|
|
8
|
-
type PrepareOAuthCommit,
|
|
9
|
-
} from "@yielded/auth/OAuth";
|
|
10
|
-
/* oxlint-disable no-explicit-any -- concrete adapters retain the native database, table and ID types. */
|
|
11
|
-
import { type Crypto, Effect, Layer, type PlatformError, Schema } from "effect";
|
|
12
|
-
import type { Statement } from "effect/sql/Statement";
|
|
1
|
+
import type { OAuthKernel } from "@yielded/auth-persistence/Adapter";
|
|
13
2
|
|
|
14
|
-
import
|
|
15
|
-
import * as A from "./oauth-connected-access";
|
|
16
|
-
import * as F from "./oauth-connected-flow";
|
|
17
|
-
import { connectedInputs, connectedRevocationInputs } from "./oauth-connected-input";
|
|
18
|
-
import * as Maintenance from "./oauth-connected-maintenance";
|
|
19
|
-
import * as Management from "./oauth-connected-management";
|
|
20
|
-
import { settle } from "./oauth-connected-settlement";
|
|
21
|
-
import * as SignIn from "./oauth-connected-sign-in";
|
|
22
|
-
import * as S from "./oauth-connected-state";
|
|
23
|
-
import { capturedOAuthService } from "./oauth-input";
|
|
24
|
-
import { CurrentOAuthTransaction } from "./oauth-owner";
|
|
25
|
-
import { captureOAuthMapping } from "./oauth-state";
|
|
26
|
-
import {
|
|
27
|
-
coordinateOAuthOwner,
|
|
28
|
-
makeOAuthExecution,
|
|
29
|
-
type OAuthExecution,
|
|
30
|
-
type OAuthTargetConfiguration,
|
|
31
|
-
} from "./oauth-target";
|
|
3
|
+
import { oauthKernel } from "./oauth-kernel";
|
|
32
4
|
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
codec = retained.subjectId;
|
|
5
|
+
export const makeTargetOAuthConnectedServices: OAuthKernel["connectedTarget"]["makeTargetOAuthConnectedServices"] =
|
|
6
|
+
oauthKernel.connectedTarget.makeTargetOAuthConnectedServices;
|
|
36
7
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
toNative: (subject: Parameters<typeof codec.toNative>[0]) =>
|
|
40
|
-
Effect.map(codec.toNative(subject), S.nativeCopy),
|
|
41
|
-
toSubject: (native: unknown) => codec.toSubject(S.nativeCopy(native)),
|
|
42
|
-
equals: (a: unknown, b: unknown) => codec.equals(S.nativeCopy(a), S.nativeCopy(b)),
|
|
43
|
-
};
|
|
8
|
+
export const makeTargetOAuthConnectedRevocationServices: OAuthKernel["connectedTarget"]["makeTargetOAuthConnectedRevocationServices"] =
|
|
9
|
+
oauthKernel.connectedTarget.makeTargetOAuthConnectedRevocationServices;
|
|
44
10
|
|
|
45
|
-
|
|
11
|
+
export const coordinateTargetOAuthConnected: OAuthKernel["connectedTarget"]["coordinateTargetOAuthConnected"] =
|
|
12
|
+
oauthKernel.connectedTarget.coordinateTargetOAuthConnected;
|
|
46
13
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
readonly identity: typeof OAuthExternalIdentity.Type;
|
|
50
|
-
readonly identityKey: string;
|
|
51
|
-
readonly subjectId: unknown;
|
|
52
|
-
}) => import("./oauth-owner").Row;
|
|
14
|
+
export const coordinateTargetOAuthConnectedRevocations: OAuthKernel["connectedTarget"]["coordinateTargetOAuthConnectedRevocations"] =
|
|
15
|
+
oauthKernel.connectedTarget.coordinateTargetOAuthConnectedRevocations;
|
|
53
16
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
subjectId,
|
|
57
|
-
ownership: {
|
|
58
|
-
...ownership,
|
|
59
|
-
external: {
|
|
60
|
-
...ownership.external,
|
|
61
|
-
encodeInsert: (input: Parameters<typeof encode>[0]) =>
|
|
62
|
-
encode({
|
|
63
|
-
...input,
|
|
64
|
-
identity: snapshotOAuthSync(OAuthExternalIdentity, input.identity),
|
|
65
|
-
subjectId: S.nativeCopy(input.subjectId),
|
|
66
|
-
}),
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
}
|
|
17
|
+
export const oauthConnectedPersistenceLayer: OAuthKernel["connectedTarget"]["oauthConnectedPersistenceLayer"] =
|
|
18
|
+
oauthKernel.connectedTarget.oauthConnectedPersistenceLayer;
|
|
71
19
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const prepare = <Value, Encoded, A>(
|
|
76
|
-
schema: Schema.Codec<Value, Encoded, never, never>,
|
|
77
|
-
value: Value,
|
|
78
|
-
callback: PrepareOAuthCommit<Value, A>,
|
|
79
|
-
) =>
|
|
80
|
-
Effect.flatMap(CurrentOAuthTransaction, (owner) =>
|
|
81
|
-
Effect.sync(() => {
|
|
82
|
-
owner.guards.push(owner.journal.prepare(undefined));
|
|
83
|
-
|
|
84
|
-
return callback(snapshotOAuthSync(schema, value), owner.journal);
|
|
85
|
-
}),
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
const mutation =
|
|
89
|
-
<Input, Value, Encoded>(
|
|
90
|
-
mapping: S.Mapping,
|
|
91
|
-
execute: OAuthExecution,
|
|
92
|
-
body: (
|
|
93
|
-
mapping: S.Mapping,
|
|
94
|
-
input: Input,
|
|
95
|
-
) => Effect.Effect<
|
|
96
|
-
Value,
|
|
97
|
-
| import("@yielded/auth/OAuth").OAuthUnavailable
|
|
98
|
-
| PersistenceMappingError
|
|
99
|
-
| PlatformError.PlatformError,
|
|
100
|
-
CurrentOAuthTransaction | Crypto.Crypto
|
|
101
|
-
>,
|
|
102
|
-
schema: Schema.Codec<Value, Encoded, never, never>,
|
|
103
|
-
) =>
|
|
104
|
-
<A>(input: Input, callback: PrepareOAuthCommit<Value, A>) =>
|
|
105
|
-
execute.run(Effect.flatMap(body(mapping, input), (value) => prepare(schema, value, callback)));
|
|
106
|
-
|
|
107
|
-
const read =
|
|
108
|
-
<Input, Value>(
|
|
109
|
-
mapping: S.Mapping,
|
|
110
|
-
execute: OAuthExecution,
|
|
111
|
-
body: (
|
|
112
|
-
mapping: S.Mapping,
|
|
113
|
-
input: Input,
|
|
114
|
-
) => Effect.Effect<
|
|
115
|
-
Value,
|
|
116
|
-
| import("@yielded/auth/OAuth").OAuthUnavailable
|
|
117
|
-
| PersistenceMappingError
|
|
118
|
-
| PlatformError.PlatformError,
|
|
119
|
-
CurrentOAuthTransaction | Crypto.Crypto
|
|
120
|
-
>,
|
|
121
|
-
) =>
|
|
122
|
-
(input: Input) =>
|
|
123
|
-
execute.run(body(mapping, input), false);
|
|
124
|
-
|
|
125
|
-
export const makeConnected = (
|
|
126
|
-
mapping: S.Mapping,
|
|
127
|
-
execute: OAuthExecution,
|
|
128
|
-
): OAuthConnectedPersistence["Service"] =>
|
|
129
|
-
capturedOAuthService<OAuthConnectedPersistence["Service"]>(
|
|
130
|
-
{
|
|
131
|
-
claimSignIn: mutation(mapping, execute, SignIn.claimSignIn, M.OAuthSignInAccessClaim),
|
|
132
|
-
inspectSignIn: read(mapping, execute, SignIn.inspectSignIn),
|
|
133
|
-
settleSignIn: mutation(
|
|
134
|
-
mapping,
|
|
135
|
-
execute,
|
|
136
|
-
SignIn.settleSignIn,
|
|
137
|
-
M.OAuthConnectedSettlementDecision,
|
|
138
|
-
),
|
|
139
|
-
capture: read(mapping, execute, F.capture),
|
|
140
|
-
issue: mutation(mapping, execute, F.issue, M.OAuthConnectedIssueDecision),
|
|
141
|
-
prepare: mutation(mapping, execute, F.prepare, M.OAuthConnectedIssueDecision),
|
|
142
|
-
inspectPrepared: read(mapping, execute, F.inspectPrepared),
|
|
143
|
-
preflight: read(mapping, execute, F.preflight),
|
|
144
|
-
claim: mutation(mapping, execute, F.claim, M.OAuthConnectedClaimDecision),
|
|
145
|
-
inspectGrant: read(mapping, execute, F.inspectGrant),
|
|
146
|
-
settle: mutation(mapping, execute, settle, M.OAuthConnectedSettlementDecision),
|
|
147
|
-
list: read(mapping, execute, Management.list),
|
|
148
|
-
inspectDisconnect: read(mapping, execute, Management.inspectDisconnect),
|
|
149
|
-
disconnect: mutation(
|
|
150
|
-
mapping,
|
|
151
|
-
execute,
|
|
152
|
-
Management.disconnect,
|
|
153
|
-
M.OAuthConnectedDisconnectDecision,
|
|
154
|
-
),
|
|
155
|
-
inspectAccess: read(mapping, execute, A.inspectAccess),
|
|
156
|
-
claimRefresh: mutation(mapping, execute, A.claimRefresh, M.OAuthConnectedRefreshDecision),
|
|
157
|
-
settleRefresh: mutation(mapping, execute, A.settleRefresh, M.OAuthConnectedRefreshSettlement),
|
|
158
|
-
admitUse: mutation(mapping, execute, A.admitUse, M.OAuthConnectedUseAdmission),
|
|
159
|
-
cleanup: mutation(mapping, execute, Maintenance.cleanup, M.OAuthConnectedCleanupResult),
|
|
160
|
-
},
|
|
161
|
-
connectedInputs,
|
|
162
|
-
execute.active,
|
|
163
|
-
execute.poison,
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
const settled = Schema.Struct({ settled: Schema.Boolean });
|
|
167
|
-
|
|
168
|
-
export const makeRevocations = (
|
|
169
|
-
mapping: S.Revocations,
|
|
170
|
-
execute: OAuthExecution,
|
|
171
|
-
): OAuthConnectedRevocations["Service"] =>
|
|
172
|
-
capturedOAuthService<OAuthConnectedRevocations["Service"]>(
|
|
173
|
-
{
|
|
174
|
-
claim: (input, callback) =>
|
|
175
|
-
execute.run(
|
|
176
|
-
Effect.flatMap(Maintenance.claimRevocation(mapping, input), (value) =>
|
|
177
|
-
prepare(OAuthConnectedRevocationDecision, value, callback),
|
|
178
|
-
),
|
|
179
|
-
),
|
|
180
|
-
settle: (input, callback) =>
|
|
181
|
-
execute.run(
|
|
182
|
-
Effect.flatMap(Maintenance.settleRevocation(mapping, input), (value) =>
|
|
183
|
-
prepare(settled, value, callback),
|
|
184
|
-
),
|
|
185
|
-
),
|
|
186
|
-
},
|
|
187
|
-
connectedRevocationInputs,
|
|
188
|
-
execute.active,
|
|
189
|
-
execute.poison,
|
|
190
|
-
);
|
|
191
|
-
|
|
192
|
-
export const makeTargetOAuthConnectedServices = (
|
|
193
|
-
mapping: S.Mapping,
|
|
194
|
-
configuration: OAuthTargetConfiguration,
|
|
195
|
-
) => {
|
|
196
|
-
const retained = captured(mapping);
|
|
197
|
-
|
|
198
|
-
return Effect.map(makeOAuthExecution(configuration, retained), (execution) => ({
|
|
199
|
-
oauthConnectedPersistence: makeConnected(retained, execution),
|
|
200
|
-
}));
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export const makeTargetOAuthConnectedRevocationServices = (
|
|
204
|
-
mapping: S.Revocations,
|
|
205
|
-
configuration: OAuthTargetConfiguration,
|
|
206
|
-
) => {
|
|
207
|
-
const retained = captured(mapping);
|
|
208
|
-
|
|
209
|
-
return Effect.map(makeOAuthExecution(configuration, retained), (execution) => ({
|
|
210
|
-
oauthConnectedRevocations: makeRevocations(retained, execution),
|
|
211
|
-
}));
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
export const coordinateTargetOAuthConnected = <Transaction, A, E, R>(
|
|
215
|
-
database: any,
|
|
216
|
-
mapping: S.Mapping,
|
|
217
|
-
configuration: OAuthTargetConfiguration,
|
|
218
|
-
owner: (
|
|
219
|
-
transaction: Transaction,
|
|
220
|
-
services: { readonly oauthConnectedPersistence: OAuthConnectedPersistence["Service"] },
|
|
221
|
-
append: (statement: Statement<any>) => void,
|
|
222
|
-
) => Effect.Effect<A, E, R>,
|
|
223
|
-
) =>
|
|
224
|
-
coordinateOAuthOwner(
|
|
225
|
-
database,
|
|
226
|
-
captured(mapping),
|
|
227
|
-
configuration,
|
|
228
|
-
() => Effect.void,
|
|
229
|
-
(value: S.Mapping, execution) => ({
|
|
230
|
-
oauthConnectedPersistence: makeConnected(value, execution),
|
|
231
|
-
}),
|
|
232
|
-
owner,
|
|
233
|
-
);
|
|
234
|
-
|
|
235
|
-
export const coordinateTargetOAuthConnectedRevocations = <Transaction, A, E, R>(
|
|
236
|
-
database: any,
|
|
237
|
-
mapping: S.Revocations,
|
|
238
|
-
configuration: OAuthTargetConfiguration,
|
|
239
|
-
owner: (
|
|
240
|
-
transaction: Transaction,
|
|
241
|
-
services: { readonly oauthConnectedRevocations: OAuthConnectedRevocations["Service"] },
|
|
242
|
-
append: (statement: Statement<any>) => void,
|
|
243
|
-
) => Effect.Effect<A, E, R>,
|
|
244
|
-
) =>
|
|
245
|
-
coordinateOAuthOwner(
|
|
246
|
-
database,
|
|
247
|
-
captured(mapping),
|
|
248
|
-
configuration,
|
|
249
|
-
() => Effect.void,
|
|
250
|
-
(value: S.Revocations, execution) => ({
|
|
251
|
-
oauthConnectedRevocations: makeRevocations(value, execution),
|
|
252
|
-
}),
|
|
253
|
-
owner,
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
export const oauthConnectedPersistenceLayer = <E, R>(
|
|
257
|
-
services: Effect.Effect<
|
|
258
|
-
Effect.Success<ReturnType<typeof makeTargetOAuthConnectedServices>>,
|
|
259
|
-
E,
|
|
260
|
-
R
|
|
261
|
-
>,
|
|
262
|
-
) =>
|
|
263
|
-
Layer.effect(
|
|
264
|
-
OAuthConnectedPersistence,
|
|
265
|
-
Effect.map(services, (value) => value.oauthConnectedPersistence),
|
|
266
|
-
);
|
|
267
|
-
|
|
268
|
-
export const oauthConnectedRevocationsLayer = <E, R>(
|
|
269
|
-
services: Effect.Effect<
|
|
270
|
-
Effect.Success<ReturnType<typeof makeTargetOAuthConnectedRevocationServices>>,
|
|
271
|
-
E,
|
|
272
|
-
R
|
|
273
|
-
>,
|
|
274
|
-
) =>
|
|
275
|
-
Layer.effect(
|
|
276
|
-
OAuthConnectedRevocations,
|
|
277
|
-
Effect.map(services, (value) => value.oauthConnectedRevocations),
|
|
278
|
-
);
|
|
20
|
+
export const oauthConnectedRevocationsLayer: OAuthKernel["connectedTarget"]["oauthConnectedRevocationsLayer"] =
|
|
21
|
+
oauthKernel.connectedTarget.oauthConnectedRevocationsLayer;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { makeOAuthKernel, type OAuthKernel } from "@yielded/auth-persistence/Adapter";
|
|
2
|
+
import { is } from "drizzle-orm";
|
|
3
|
+
import { MySqlTable } from "drizzle-orm/mysql-core";
|
|
4
|
+
import { PgTable } from "drizzle-orm/pg-core";
|
|
5
|
+
|
|
6
|
+
import { drizzleQueryOperations } from "./query-operations";
|
|
7
|
+
|
|
8
|
+
export const oauthKernel: OAuthKernel = makeOAuthKernel(drizzleQueryOperations, (table) =>
|
|
9
|
+
is(table, MySqlTable) ? "mysql" : is(table, PgTable) ? "pg" : "sqlite",
|
|
10
|
+
);
|