@yielded/auth-persistence 0.1.0-beta.23 → 0.1.0-beta.25
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 +11 -0
- package/dist/Adapter.d.mts +12 -6
- package/dist/Adapter.mjs +8 -3
- package/dist/OAuthPersistence.d.mts +87 -0
- package/dist/OAuthPersistence.mjs +125 -0
- package/dist/OAuthPersistence.mjs.map +1 -0
- package/dist/_virtual/_rolldown/runtime.mjs +13 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +3 -1
- package/dist/internal/configuration.d.mts +1 -1
- package/dist/internal/configuration.mjs.map +1 -1
- package/dist/internal/email-kernel.d.mts +1 -1
- package/dist/internal/email-kernel.mjs +1 -1
- package/dist/internal/email-kernel.mjs.map +1 -1
- package/dist/internal/models/oauth-connected-model.d.mts +294 -0
- package/dist/internal/models/oauth-connected-model.mjs +22 -0
- package/dist/internal/models/oauth-connected-model.mjs.map +1 -0
- package/dist/internal/models/oauth-model.d.mts +467 -0
- package/dist/internal/models/oauth-model.mjs +49 -0
- package/dist/internal/models/oauth-model.mjs.map +1 -0
- package/dist/internal/models/password-model.d.mts +6 -48
- package/dist/internal/models/password-model.mjs +0 -1
- package/dist/internal/models/password-model.mjs.map +1 -1
- package/dist/internal/native-sql-table.d.mts +4 -0
- package/dist/internal/native-sql-table.mjs +7 -0
- package/dist/internal/native-sql-table.mjs.map +1 -1
- package/dist/internal/oauth/accounts.d.mts +8 -0
- package/dist/internal/oauth/accounts.mjs +379 -0
- package/dist/internal/oauth/accounts.mjs.map +1 -0
- package/dist/internal/oauth/connected-access.d.mts +9 -0
- package/dist/internal/oauth/connected-access.mjs +229 -0
- package/dist/internal/oauth/connected-access.mjs.map +1 -0
- package/dist/internal/oauth/connected-collection.d.mts +7 -0
- package/dist/internal/oauth/connected-collection.mjs +214 -0
- package/dist/internal/oauth/connected-collection.mjs.map +1 -0
- package/dist/internal/oauth/connected-custody.d.mts +6 -0
- package/dist/internal/oauth/connected-custody.mjs +165 -0
- package/dist/internal/oauth/connected-custody.mjs.map +1 -0
- package/dist/internal/oauth/connected-flow.d.mts +7 -0
- package/dist/internal/oauth/connected-flow.mjs +324 -0
- package/dist/internal/oauth/connected-flow.mjs.map +1 -0
- package/dist/internal/oauth/connected-input.mjs +122 -0
- package/dist/internal/oauth/connected-input.mjs.map +1 -0
- package/dist/internal/oauth/connected-keys.d.mts +2 -0
- package/dist/internal/oauth/connected-keys.mjs +22 -0
- package/dist/internal/oauth/connected-keys.mjs.map +1 -0
- package/dist/internal/oauth/connected-maintenance.d.mts +9 -0
- package/dist/internal/oauth/connected-maintenance.mjs +226 -0
- package/dist/internal/oauth/connected-maintenance.mjs.map +1 -0
- package/dist/internal/oauth/connected-management.d.mts +9 -0
- package/dist/internal/oauth/connected-management.mjs +243 -0
- package/dist/internal/oauth/connected-management.mjs.map +1 -0
- package/dist/internal/oauth/connected-reference.mjs +63 -0
- package/dist/internal/oauth/connected-reference.mjs.map +1 -0
- package/dist/internal/oauth/connected-settlement.d.mts +8 -0
- package/dist/internal/oauth/connected-settlement.mjs +141 -0
- package/dist/internal/oauth/connected-settlement.mjs.map +1 -0
- package/dist/internal/oauth/connected-sign-in.d.mts +10 -0
- package/dist/internal/oauth/connected-sign-in.mjs +281 -0
- package/dist/internal/oauth/connected-sign-in.mjs.map +1 -0
- package/dist/internal/oauth/connected-state.d.mts +14 -0
- package/dist/internal/oauth/connected-state.mjs +469 -0
- package/dist/internal/oauth/connected-state.mjs.map +1 -0
- package/dist/internal/oauth/connected-target.d.mts +21 -0
- package/dist/internal/oauth/connected-target.mjs +117 -0
- package/dist/internal/oauth/connected-target.mjs.map +1 -0
- package/dist/internal/oauth/flow.d.mts +5 -0
- package/dist/internal/oauth/flow.mjs +279 -0
- package/dist/internal/oauth/flow.mjs.map +1 -0
- package/dist/internal/oauth/input.mjs +127 -0
- package/dist/internal/oauth/input.mjs.map +1 -0
- package/dist/internal/oauth/owner.d.mts +10 -0
- package/dist/internal/oauth/owner.mjs +10 -0
- package/dist/internal/oauth/owner.mjs.map +1 -0
- package/dist/internal/oauth/query-compiler.d.mts +7 -0
- package/dist/internal/oauth/query-compiler.mjs +9 -0
- package/dist/internal/oauth/query-compiler.mjs.map +1 -0
- package/dist/internal/oauth/registration.d.mts +7 -0
- package/dist/internal/oauth/registration.mjs +393 -0
- package/dist/internal/oauth/registration.mjs.map +1 -0
- package/dist/internal/oauth/state.mjs +107 -0
- package/dist/internal/oauth/state.mjs.map +1 -0
- package/dist/internal/oauth/target.d.mts +31 -0
- package/dist/internal/oauth/target.mjs +273 -0
- package/dist/internal/oauth/target.mjs.map +1 -0
- package/dist/internal/oauth-kernel.d.mts +1423 -0
- package/dist/internal/oauth-kernel.mjs +187 -0
- package/dist/internal/oauth-kernel.mjs.map +1 -0
- package/dist/internal/oauth-proxy.d.mts +31 -0
- package/dist/internal/oauth-proxy.mjs +129 -0
- package/dist/internal/oauth-proxy.mjs.map +1 -0
- package/dist/internal/passkey/write-state.mjs +9 -1
- package/dist/internal/passkey/write-state.mjs.map +1 -1
- package/dist/internal/passkey-kernel.d.mts +9 -9
- package/dist/internal/{password-attempts.d.mts → password-credentials.d.mts} +3 -4
- package/dist/internal/password-credentials.mjs +121 -0
- package/dist/internal/password-credentials.mjs.map +1 -0
- package/dist/internal/password-kernel.d.mts +8 -24
- package/dist/internal/password-kernel.mjs +5 -43
- package/dist/internal/password-kernel.mjs.map +1 -1
- package/dist/internal/persistence.d.mts +1 -1
- package/dist/internal/persistence.mjs +2 -2
- package/dist/internal/persistence.mjs.map +1 -1
- package/dist/internal/query-operations.d.mts +2 -0
- package/dist/internal/session-kernel.d.mts +2 -2
- package/dist/internal/session-kernel.mjs +74 -18
- package/dist/internal/session-kernel.mjs.map +1 -1
- package/dist/internal/sql-oauth-connected-model.d.mts +29 -0
- package/dist/internal/sql-oauth-connected-model.mjs +7 -0
- package/dist/internal/sql-oauth-connected-model.mjs.map +1 -0
- package/dist/internal/sql-oauth-model.d.mts +60 -0
- package/dist/internal/sql-oauth-model.mjs +10 -0
- package/dist/internal/sql-oauth-model.mjs.map +1 -0
- package/dist/internal/sql-query.d.mts +12 -0
- package/dist/internal/sql-query.mjs +15 -18
- package/dist/internal/sql-query.mjs.map +1 -1
- package/dist/internal/sql-storage-validation.mjs +54 -0
- package/dist/internal/sql-storage-validation.mjs.map +1 -0
- package/dist/internal/storage-mapping.mjs +1 -37
- package/dist/internal/storage-mapping.mjs.map +1 -1
- package/dist/internal/storage-plans.d.mts +7 -0
- package/dist/internal/storage-plans.mjs +189 -0
- package/dist/internal/storage-plans.mjs.map +1 -0
- package/dist/internal/storage-tables.d.mts +0 -56
- package/dist/internal/storage-tables.mjs +0 -17
- package/dist/internal/storage-tables.mjs.map +1 -1
- package/dist/internal/storage-validation.d.mts +6 -1
- package/dist/internal/storage-validation.mjs +42 -1
- package/dist/internal/storage-validation.mjs.map +1 -1
- package/dist/internal/transaction-kernel.mjs +3 -2
- package/dist/internal/transaction-kernel.mjs.map +1 -1
- package/package.json +1 -1
- package/src/Adapter.ts +89 -5
- package/src/OAuthPersistence.ts +427 -0
- package/src/index.ts +3 -0
- package/src/internal/configuration.ts +1 -3
- package/src/internal/email-kernel.ts +2 -1
- package/src/internal/models/oauth-connected-model.ts +396 -0
- package/src/internal/models/oauth-model.ts +708 -0
- package/src/internal/models/password-model.ts +2 -57
- package/src/internal/native-sql-table.ts +14 -0
- package/src/internal/oauth/accounts.ts +839 -0
- package/src/internal/oauth/connected-access.ts +388 -0
- package/src/internal/oauth/connected-collection.ts +345 -0
- package/src/internal/oauth/connected-custody.ts +308 -0
- package/src/internal/oauth/connected-flow.ts +562 -0
- package/src/internal/oauth/connected-input.ts +147 -0
- package/src/internal/oauth/connected-keys.ts +31 -0
- package/src/internal/oauth/connected-maintenance.ts +379 -0
- package/src/internal/oauth/connected-management.ts +391 -0
- package/src/internal/oauth/connected-reference.ts +135 -0
- package/src/internal/oauth/connected-settlement.ts +278 -0
- package/src/internal/oauth/connected-sign-in.ts +472 -0
- package/src/internal/oauth/connected-state.ts +924 -0
- package/src/internal/oauth/connected-target.ts +307 -0
- package/src/internal/oauth/flow.ts +505 -0
- package/src/internal/oauth/input.ts +201 -0
- package/src/internal/oauth/owner.ts +22 -0
- package/src/internal/oauth/query-compiler.ts +15 -0
- package/src/internal/oauth/registration.ts +676 -0
- package/src/internal/oauth/state.ts +218 -0
- package/src/internal/oauth/target.ts +803 -0
- package/src/internal/oauth-kernel.ts +294 -0
- package/src/internal/oauth-proxy.ts +176 -0
- package/src/internal/passkey/write-state.ts +18 -4
- package/src/internal/password-credentials.ts +245 -0
- package/src/internal/password-kernel.ts +7 -99
- package/src/internal/persistence.ts +1 -1
- package/src/internal/query-operations.ts +2 -0
- package/src/internal/session-kernel.ts +143 -55
- package/src/internal/sql-oauth-connected-model.ts +145 -0
- package/src/internal/sql-oauth-model.ts +263 -0
- package/src/internal/sql-query.ts +16 -13
- package/src/internal/sql-storage-validation.ts +64 -0
- package/src/internal/storage-mapping.ts +0 -37
- package/src/internal/storage-plans.ts +218 -0
- package/src/internal/storage-tables.ts +0 -20
- package/src/internal/storage-validation.ts +58 -0
- package/src/internal/transaction-kernel.ts +6 -2
- package/dist/internal/password-attempts.mjs +0 -197
- package/dist/internal/password-attempts.mjs.map +0 -1
- package/src/internal/password-attempts.ts +0 -466
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
2
|
+
import * as M from "@yielded/auth/OAuth";
|
|
3
|
+
import { OAuthClaimId, OAuthCleanupInput, OAuthCommandId, OAuthConnectedRevocationClaim, OAuthExternalIdentity, OAuthInstant, OAuthModuleId, snapshotOAuthSync } from "@yielded/auth/OAuth";
|
|
4
|
+
//#region src/internal/oauth/connected-input.ts
|
|
5
|
+
const capture = Schema.Struct({
|
|
6
|
+
moduleId: OAuthModuleId,
|
|
7
|
+
subjectId: M.OAuthConnectedUseAuthorization.fields.revision.fields.subjectId,
|
|
8
|
+
grantId: Schema.optionalKey(M.OAuthGrantId)
|
|
9
|
+
});
|
|
10
|
+
const issue = Schema.Struct({
|
|
11
|
+
flow: M.OAuthConnectedPendingFlow,
|
|
12
|
+
authorization: M.OAuthConnectedActionAuthorization
|
|
13
|
+
});
|
|
14
|
+
const preparation = Schema.Struct({
|
|
15
|
+
flow: M.OAuthConnectedPendingFlow,
|
|
16
|
+
authorization: M.OAuthConnectedUseAuthorization
|
|
17
|
+
});
|
|
18
|
+
const claim = Schema.Struct({
|
|
19
|
+
...issue.fields,
|
|
20
|
+
access: M.OAuthConnectedAccess,
|
|
21
|
+
claimId: OAuthClaimId
|
|
22
|
+
});
|
|
23
|
+
const inspectGrant = Schema.Struct({
|
|
24
|
+
claim: M.OAuthConnectedClaim,
|
|
25
|
+
identity: OAuthExternalIdentity
|
|
26
|
+
});
|
|
27
|
+
const settle = Schema.Struct({
|
|
28
|
+
claim: M.OAuthConnectedClaim,
|
|
29
|
+
outcome: M.OAuthConnectedOutcome,
|
|
30
|
+
authorization: M.OAuthConnectedActionAuthorization,
|
|
31
|
+
nowMillis: OAuthInstant
|
|
32
|
+
});
|
|
33
|
+
const list = Schema.Struct({
|
|
34
|
+
...M.OAuthConnectedList.fields,
|
|
35
|
+
authorization: M.OAuthConnectedUseAuthorization
|
|
36
|
+
});
|
|
37
|
+
const inspectDisconnect = Schema.Struct({
|
|
38
|
+
moduleId: OAuthModuleId,
|
|
39
|
+
subjectId: capture.fields.subjectId,
|
|
40
|
+
authorization: M.OAuthConnectedUseAuthorization,
|
|
41
|
+
commandId: OAuthCommandId,
|
|
42
|
+
grantId: M.OAuthGrantId
|
|
43
|
+
});
|
|
44
|
+
const disconnect = Schema.Struct({
|
|
45
|
+
moduleId: OAuthModuleId,
|
|
46
|
+
commandId: OAuthCommandId,
|
|
47
|
+
grant: M.OAuthConnectedDisconnectGrant,
|
|
48
|
+
authorization: M.OAuthConnectedActionAuthorization,
|
|
49
|
+
revocation: Schema.optionalKey(M.OAuthConnectedRevocationJob),
|
|
50
|
+
retentionUntilMillis: OAuthInstant
|
|
51
|
+
});
|
|
52
|
+
const inspectAccess = Schema.Struct({
|
|
53
|
+
authorization: M.OAuthConnectedUseAuthorization,
|
|
54
|
+
...M.OAuthConnectedUse.fields
|
|
55
|
+
});
|
|
56
|
+
const claimRefresh = Schema.Struct({
|
|
57
|
+
grant: M.OAuthConnectedStoredGrant,
|
|
58
|
+
authorization: M.OAuthConnectedUseAuthorization,
|
|
59
|
+
claimId: OAuthClaimId,
|
|
60
|
+
nextTokenVersion: M.OAuthConnectedRefreshClaim.fields.nextTokenVersion,
|
|
61
|
+
lifetimeMillis: M.OAuthConnectedPolicy.fields.refreshClaimLifetimeMillis
|
|
62
|
+
});
|
|
63
|
+
const settleRefresh = Schema.Struct({
|
|
64
|
+
claim: M.OAuthConnectedRefreshClaim,
|
|
65
|
+
authorization: M.OAuthConnectedUseAuthorization,
|
|
66
|
+
outcome: M.OAuthConnectedRefreshOutcome
|
|
67
|
+
});
|
|
68
|
+
const admitUse = Schema.Struct({
|
|
69
|
+
grant: M.OAuthConnectedStoredGrant,
|
|
70
|
+
authorization: M.OAuthConnectedUseAuthorization,
|
|
71
|
+
admissionId: OAuthClaimId,
|
|
72
|
+
lifetimeMillis: M.OAuthConnectedPolicy.fields.useAdmissionLifetimeMillis
|
|
73
|
+
});
|
|
74
|
+
const revocationClaim = Schema.Struct({
|
|
75
|
+
moduleId: OAuthModuleId,
|
|
76
|
+
claimId: OAuthClaimId,
|
|
77
|
+
lifetimeMillis: M.OAuthConnectedPolicy.fields.refreshClaimLifetimeMillis
|
|
78
|
+
});
|
|
79
|
+
const revocationSettle = Schema.Struct({
|
|
80
|
+
claim: OAuthConnectedRevocationClaim,
|
|
81
|
+
outcome: Schema.Literals(["Confirmed", "Unknown"])
|
|
82
|
+
});
|
|
83
|
+
const snapshot = (schema) => (input) => snapshotOAuthSync(schema, input);
|
|
84
|
+
const connectedInputs = {
|
|
85
|
+
claimSignIn: snapshot(Schema.Struct({
|
|
86
|
+
claim: M.OAuthClaim,
|
|
87
|
+
configuration: M.OAuthConnectedConfiguration
|
|
88
|
+
})),
|
|
89
|
+
inspectSignIn: snapshot(Schema.Struct({
|
|
90
|
+
reservation: M.OAuthSignInAccessClaim,
|
|
91
|
+
credential: M.OAuthCredentialSnapshot,
|
|
92
|
+
grantId: M.OAuthGrantId
|
|
93
|
+
})),
|
|
94
|
+
settleSignIn: snapshot(Schema.Struct({
|
|
95
|
+
reservation: M.OAuthSignInAccessClaim,
|
|
96
|
+
outcome: M.OAuthSignInAccessOutcome
|
|
97
|
+
})),
|
|
98
|
+
capture: snapshot(capture),
|
|
99
|
+
issue: snapshot(issue),
|
|
100
|
+
prepare: snapshot(preparation),
|
|
101
|
+
inspectPrepared: snapshot(M.OAuthConnectedPreparedAccess),
|
|
102
|
+
preflight: snapshot(M.OAuthConnectedAccess),
|
|
103
|
+
claim: snapshot(claim),
|
|
104
|
+
inspectGrant: snapshot(inspectGrant),
|
|
105
|
+
settle: snapshot(settle),
|
|
106
|
+
list: snapshot(list),
|
|
107
|
+
inspectDisconnect: snapshot(inspectDisconnect),
|
|
108
|
+
disconnect: snapshot(disconnect),
|
|
109
|
+
inspectAccess: snapshot(inspectAccess),
|
|
110
|
+
claimRefresh: snapshot(claimRefresh),
|
|
111
|
+
settleRefresh: snapshot(settleRefresh),
|
|
112
|
+
admitUse: snapshot(admitUse),
|
|
113
|
+
cleanup: snapshot(OAuthCleanupInput)
|
|
114
|
+
};
|
|
115
|
+
const connectedRevocationInputs = {
|
|
116
|
+
claim: snapshot(revocationClaim),
|
|
117
|
+
settle: snapshot(revocationSettle)
|
|
118
|
+
};
|
|
119
|
+
//#endregion
|
|
120
|
+
export { connectedInputs, connectedRevocationInputs };
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=connected-input.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connected-input.mjs","names":[],"sources":["../../../src/internal/oauth/connected-input.ts"],"sourcesContent":["import * as M from \"@yielded/auth/OAuth\";\nimport {\n OAuthConnectedRevocationClaim,\n OAuthClaimId,\n OAuthCleanupInput,\n OAuthCommandId,\n OAuthExternalIdentity,\n OAuthInstant,\n OAuthModuleId,\n snapshotOAuthSync,\n} from \"@yielded/auth/OAuth\";\nimport { Schema } from \"effect\";\n\nconst capture = Schema.Struct({\n moduleId: OAuthModuleId,\n subjectId: M.OAuthConnectedUseAuthorization.fields.revision.fields.subjectId,\n grantId: Schema.optionalKey(M.OAuthGrantId),\n});\n\nconst issue = Schema.Struct({\n flow: M.OAuthConnectedPendingFlow,\n authorization: M.OAuthConnectedActionAuthorization,\n});\n\nconst preparation = Schema.Struct({\n flow: M.OAuthConnectedPendingFlow,\n authorization: M.OAuthConnectedUseAuthorization,\n});\n\nconst claim = Schema.Struct({\n ...issue.fields,\n access: M.OAuthConnectedAccess,\n claimId: OAuthClaimId,\n});\n\nconst inspectGrant = Schema.Struct({\n claim: M.OAuthConnectedClaim,\n identity: OAuthExternalIdentity,\n});\n\nconst settle = Schema.Struct({\n claim: M.OAuthConnectedClaim,\n outcome: M.OAuthConnectedOutcome,\n authorization: M.OAuthConnectedActionAuthorization,\n nowMillis: OAuthInstant,\n});\n\nconst list = Schema.Struct({\n ...M.OAuthConnectedList.fields,\n authorization: M.OAuthConnectedUseAuthorization,\n});\n\nconst inspectDisconnect = Schema.Struct({\n moduleId: OAuthModuleId,\n subjectId: capture.fields.subjectId,\n authorization: M.OAuthConnectedUseAuthorization,\n commandId: OAuthCommandId,\n grantId: M.OAuthGrantId,\n});\n\nconst disconnect = Schema.Struct({\n moduleId: OAuthModuleId,\n commandId: OAuthCommandId,\n grant: M.OAuthConnectedDisconnectGrant,\n authorization: M.OAuthConnectedActionAuthorization,\n revocation: Schema.optionalKey(M.OAuthConnectedRevocationJob),\n retentionUntilMillis: OAuthInstant,\n});\n\nconst inspectAccess = Schema.Struct({\n authorization: M.OAuthConnectedUseAuthorization,\n ...M.OAuthConnectedUse.fields,\n});\n\nconst claimRefresh = Schema.Struct({\n grant: M.OAuthConnectedStoredGrant,\n authorization: M.OAuthConnectedUseAuthorization,\n claimId: OAuthClaimId,\n nextTokenVersion: M.OAuthConnectedRefreshClaim.fields.nextTokenVersion,\n lifetimeMillis: M.OAuthConnectedPolicy.fields.refreshClaimLifetimeMillis,\n});\n\nconst settleRefresh = Schema.Struct({\n claim: M.OAuthConnectedRefreshClaim,\n authorization: M.OAuthConnectedUseAuthorization,\n outcome: M.OAuthConnectedRefreshOutcome,\n});\n\nconst admitUse = Schema.Struct({\n grant: M.OAuthConnectedStoredGrant,\n authorization: M.OAuthConnectedUseAuthorization,\n admissionId: OAuthClaimId,\n lifetimeMillis: M.OAuthConnectedPolicy.fields.useAdmissionLifetimeMillis,\n});\n\nconst revocationClaim = Schema.Struct({\n moduleId: OAuthModuleId,\n claimId: OAuthClaimId,\n lifetimeMillis: M.OAuthConnectedPolicy.fields.refreshClaimLifetimeMillis,\n});\n\nconst revocationSettle = Schema.Struct({\n claim: OAuthConnectedRevocationClaim,\n outcome: Schema.Literals([\"Confirmed\", \"Unknown\"]),\n});\n\nconst snapshot =\n <A, I>(schema: Schema.Codec<A, I, never, never>) =>\n (input: A) =>\n snapshotOAuthSync(schema, input);\n\nexport const connectedInputs = {\n claimSignIn: snapshot(\n Schema.Struct({ claim: M.OAuthClaim, configuration: M.OAuthConnectedConfiguration }),\n ),\n inspectSignIn: snapshot(\n Schema.Struct({\n reservation: M.OAuthSignInAccessClaim,\n credential: M.OAuthCredentialSnapshot,\n grantId: M.OAuthGrantId,\n }),\n ),\n settleSignIn: snapshot(\n Schema.Struct({ reservation: M.OAuthSignInAccessClaim, outcome: M.OAuthSignInAccessOutcome }),\n ),\n capture: snapshot(capture),\n issue: snapshot(issue),\n prepare: snapshot(preparation),\n inspectPrepared: snapshot(M.OAuthConnectedPreparedAccess),\n preflight: snapshot(M.OAuthConnectedAccess),\n claim: snapshot(claim),\n inspectGrant: snapshot(inspectGrant),\n settle: snapshot(settle),\n list: snapshot(list),\n inspectDisconnect: snapshot(inspectDisconnect),\n disconnect: snapshot(disconnect),\n inspectAccess: snapshot(inspectAccess),\n claimRefresh: snapshot(claimRefresh),\n settleRefresh: snapshot(settleRefresh),\n admitUse: snapshot(admitUse),\n cleanup: snapshot(OAuthCleanupInput),\n};\n\nexport const connectedRevocationInputs = {\n claim: snapshot(revocationClaim),\n settle: snapshot(revocationSettle),\n};\n"],"mappings":";;;;AAaA,MAAM,UAAU,OAAO,OAAO;CAC5B,UAAU;CACV,WAAW,EAAE,+BAA+B,OAAO,SAAS,OAAO;CACnE,SAAS,OAAO,YAAY,EAAE,YAAY;AAC5C,CAAC;AAED,MAAM,QAAQ,OAAO,OAAO;CAC1B,MAAM,EAAE;CACR,eAAe,EAAE;AACnB,CAAC;AAED,MAAM,cAAc,OAAO,OAAO;CAChC,MAAM,EAAE;CACR,eAAe,EAAE;AACnB,CAAC;AAED,MAAM,QAAQ,OAAO,OAAO;CAC1B,GAAG,MAAM;CACT,QAAQ,EAAE;CACV,SAAS;AACX,CAAC;AAED,MAAM,eAAe,OAAO,OAAO;CACjC,OAAO,EAAE;CACT,UAAU;AACZ,CAAC;AAED,MAAM,SAAS,OAAO,OAAO;CAC3B,OAAO,EAAE;CACT,SAAS,EAAE;CACX,eAAe,EAAE;CACjB,WAAW;AACb,CAAC;AAED,MAAM,OAAO,OAAO,OAAO;CACzB,GAAG,EAAE,mBAAmB;CACxB,eAAe,EAAE;AACnB,CAAC;AAED,MAAM,oBAAoB,OAAO,OAAO;CACtC,UAAU;CACV,WAAW,QAAQ,OAAO;CAC1B,eAAe,EAAE;CACjB,WAAW;CACX,SAAS,EAAE;AACb,CAAC;AAED,MAAM,aAAa,OAAO,OAAO;CAC/B,UAAU;CACV,WAAW;CACX,OAAO,EAAE;CACT,eAAe,EAAE;CACjB,YAAY,OAAO,YAAY,EAAE,2BAA2B;CAC5D,sBAAsB;AACxB,CAAC;AAED,MAAM,gBAAgB,OAAO,OAAO;CA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;CAC7C,YAAY,SAAS,UAAU;CAC/B,eAAe,SAAS,aAAa;CACrC,cAAc,SAAS,YAAY;CACnC,eAAe,SAAS,aAAa;CACrC,UAAU,SAAS,QAAQ;CAC3B,SAAS,SAAS,iBAAiB;AACrC;AAEA,MAAa,4BAA4B;CACvC,OAAO,SAAS,eAAe;CAC/B,QAAQ,SAAS,gBAAgB;AACnC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { digest } from "../crypto.mjs";
|
|
2
|
+
import { invariant, storage } from "./state.mjs";
|
|
3
|
+
import { Effect, Schema } from "effect";
|
|
4
|
+
//#region src/internal/oauth/connected-keys.ts
|
|
5
|
+
const strings = storage(Schema.Array(Schema.String));
|
|
6
|
+
const encoder = new TextEncoder();
|
|
7
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
8
|
+
const key = Effect.fnUntraced(function* (domain, fields) {
|
|
9
|
+
for (const value of fields) invariant(decoder.decode(encoder.encode(value)) === value);
|
|
10
|
+
return "v1:" + (yield* digest(strings.encode([domain, ...fields])));
|
|
11
|
+
});
|
|
12
|
+
const clientKey = (configuration) => key("effect-auth/oauth-connected-client/v1", [
|
|
13
|
+
configuration.provider,
|
|
14
|
+
configuration.issuer,
|
|
15
|
+
configuration.profile.clientRegistrationId
|
|
16
|
+
]);
|
|
17
|
+
const cohortKey = (client, identity) => key("effect-auth/oauth-connected-cohort/v1", [client, identity]);
|
|
18
|
+
const scopeKey = (provider, issuer) => key("effect-auth/oauth-connected-provider-issuer/v1", [provider, issuer]).pipe(Effect.map((value) => "scope:" + value));
|
|
19
|
+
//#endregion
|
|
20
|
+
export { clientKey, cohortKey, key, scopeKey, strings };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=connected-keys.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connected-keys.mjs","names":[],"sources":["../../../src/internal/oauth/connected-keys.ts"],"sourcesContent":["import type * as M from \"@yielded/auth/OAuth\";\nimport { Effect, Schema } from \"effect\";\n\nimport { digest, invariant, storage } from \"./state\";\n\nexport const strings = storage(Schema.Array(Schema.String));\n\nconst encoder = new TextEncoder();\n\nconst decoder = new TextDecoder(\"utf-8\", { fatal: true });\n\nexport const key = Effect.fnUntraced(function* (domain: string, fields: ReadonlyArray<string>) {\n for (const value of fields) invariant(decoder.decode(encoder.encode(value)) === value);\n\n return \"v1:\" + (yield* digest(strings.encode([domain, ...fields])));\n});\n\nexport const clientKey = (configuration: M.OAuthConnectedConfiguration) =>\n key(\"effect-auth/oauth-connected-client/v1\", [\n configuration.provider,\n configuration.issuer,\n configuration.profile.clientRegistrationId,\n ]);\n\nexport const cohortKey = (client: string, identity: string) =>\n key(\"effect-auth/oauth-connected-cohort/v1\", [client, identity]);\n\nexport const scopeKey = (provider: string, issuer: string) =>\n key(\"effect-auth/oauth-connected-provider-issuer/v1\", [provider, issuer]).pipe(\n Effect.map((value) => \"scope:\" + value),\n );\n"],"mappings":";;;;AAKA,MAAa,UAAU,QAAQ,OAAO,MAAM,OAAO,MAAM,CAAC;AAE1D,MAAM,UAAU,IAAI,YAAY;AAEhC,MAAM,UAAU,IAAI,YAAY,SAAS,EAAE,OAAO,KAAK,CAAC;AAExD,MAAa,MAAM,OAAO,WAAW,WAAW,QAAgB,QAA+B;CAC7F,KAAK,MAAM,SAAS,QAAQ,UAAU,QAAQ,OAAO,QAAQ,OAAO,KAAK,CAAC,MAAM,KAAK;CAErF,OAAO,SAAS,OAAO,OAAO,QAAQ,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,CAAC;AACnE,CAAC;AAED,MAAa,aAAa,kBACxB,IAAI,yCAAyC;CAC3C,cAAc;CACd,cAAc;CACd,cAAc,QAAQ;AACxB,CAAC;AAEH,MAAa,aAAa,QAAgB,aACxC,IAAI,yCAAyC,CAAC,QAAQ,QAAQ,CAAC;AAEjE,MAAa,YAAY,UAAkB,WACzC,IAAI,kDAAkD,CAAC,UAAU,MAAM,CAAC,CAAC,CAAC,KACxE,OAAO,KAAK,UAAU,WAAW,KAAK,CACxC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../mapping-error.mjs";
|
|
2
|
+
import "./owner.mjs";
|
|
3
|
+
import "./connected-state.mjs";
|
|
4
|
+
import "./query-compiler.mjs";
|
|
5
|
+
import "./connected-custody.mjs";
|
|
6
|
+
import "./connected-flow.mjs";
|
|
7
|
+
import "./connected-collection.mjs";
|
|
8
|
+
import { Context, Effect, Layer } from "effect";
|
|
9
|
+
import { OAuthConnectedRevocationClaim } from "@yielded/auth/OAuth";
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { CurrentOAuthTransaction } from "./owner.mjs";
|
|
2
|
+
import { OAuthQueryCompiler } from "./query-compiler.mjs";
|
|
3
|
+
import { invariant, storage } from "./state.mjs";
|
|
4
|
+
import { OAuthConnectedState } from "./connected-state.mjs";
|
|
5
|
+
import { OAuthConnectedCustody } from "./connected-custody.mjs";
|
|
6
|
+
import { OAuthConnectedFlow } from "./connected-flow.mjs";
|
|
7
|
+
import { OAuthConnectedCollection } from "./connected-collection.mjs";
|
|
8
|
+
import { Context, Effect, Layer } from "effect";
|
|
9
|
+
import { OAuthConnectedRevocationClaim, snapshotOAuthSync } from "@yielded/auth/OAuth";
|
|
10
|
+
//#region src/internal/oauth/connected-maintenance.ts
|
|
11
|
+
const make = Effect.gen(function* () {
|
|
12
|
+
const operations = yield* OAuthQueryCompiler;
|
|
13
|
+
const connectedCollection = yield* OAuthConnectedCollection;
|
|
14
|
+
const C = yield* OAuthConnectedCustody;
|
|
15
|
+
const F = yield* OAuthConnectedFlow;
|
|
16
|
+
const S = yield* OAuthConnectedState;
|
|
17
|
+
const { asc, eq, lte, sql } = operations;
|
|
18
|
+
const { collect, discover } = connectedCollection;
|
|
19
|
+
const { both, col, equal } = operations;
|
|
20
|
+
const revocationClaimStorage = storage(OAuthConnectedRevocationClaim);
|
|
21
|
+
const jobLocks = Effect.fn("oauthConnected.jobLocks")(function* (mapping, job) {
|
|
22
|
+
const owner = yield* CurrentOAuthTransaction;
|
|
23
|
+
const token = job.context.token, client = yield* S.client(mapping, token.configuration, false);
|
|
24
|
+
if (client === void 0) return void 0;
|
|
25
|
+
const tuple = yield* F.inspectTuple(mapping, token.identity), t = mapping.ownership.tuple;
|
|
26
|
+
const native = yield* mapping.subjectId.toNative(token.subjectId);
|
|
27
|
+
if (tuple.row?.[t.state] !== "Owned" || !mapping.subjectId.equals(tuple.row[t.subjectId], native)) return void 0;
|
|
28
|
+
const cohort = yield* S.cohort(mapping, client.id, tuple.key, false);
|
|
29
|
+
invariant(cohort.row !== void 0);
|
|
30
|
+
const j = mapping.job, row = (yield* owner.read(j.table, equal(j.table, { [j.jobId]: job.context.jobId }), { limit: 1 })).rows[0];
|
|
31
|
+
if (row === void 0) return void 0;
|
|
32
|
+
invariant(row[j.state] === "Confirmed" || cohort.blocked);
|
|
33
|
+
invariant(row[j.snapshot] === S.jobStorage.encode(job) && row[j.moduleId] === token.moduleId && mapping.subjectId.equals(native, row[j.subjectId]) && row[j.identityKey] === tuple.key && row[j.clientKey] === client.id && row[j.cohortKey] === cohort.id && row[j.grantId] === token.grantId && [
|
|
34
|
+
"Pending",
|
|
35
|
+
"Claimed",
|
|
36
|
+
"Unknown",
|
|
37
|
+
"Confirmed"
|
|
38
|
+
].includes(row[j.state]));
|
|
39
|
+
return {
|
|
40
|
+
client,
|
|
41
|
+
cohort,
|
|
42
|
+
row
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
return {
|
|
46
|
+
claimRevocation: Effect.fn("oauthConnected.claimRevocation")(function* (mapping, input) {
|
|
47
|
+
const owner = yield* CurrentOAuthTransaction;
|
|
48
|
+
invariant(Number.isSafeInteger(input.lifetimeMillis) && input.lifetimeMillis >= 1e3 && input.lifetimeMillis <= 12e4);
|
|
49
|
+
const j = mapping.job;
|
|
50
|
+
const row = (yield* owner.read(j.table, equal(j.table, {
|
|
51
|
+
[j.moduleId]: input.moduleId,
|
|
52
|
+
[j.state]: "Pending"
|
|
53
|
+
}), {
|
|
54
|
+
limit: 1,
|
|
55
|
+
takeOnly: true,
|
|
56
|
+
lock: false,
|
|
57
|
+
observe: false,
|
|
58
|
+
orderBy: asc(col(j.table, j.jobId))
|
|
59
|
+
})).rows[0];
|
|
60
|
+
if (row === void 0) return { _tag: "Empty" };
|
|
61
|
+
const job = S.jobStorage.decode(row[j.snapshot]);
|
|
62
|
+
const locks = yield* jobLocks(mapping, job);
|
|
63
|
+
if (locks === void 0 || locks.row[j.state] !== "Pending") return { _tag: "Empty" };
|
|
64
|
+
invariant(locks.row[j.claimId] === null && locks.row[j.claimedAt] === null && locks.row[j.claimExpiresAt] === null);
|
|
65
|
+
const now = yield* owner.now(mapping.clock), expires = now + input.lifetimeMillis;
|
|
66
|
+
invariant(Number.isSafeInteger(expires));
|
|
67
|
+
const claim = snapshotOAuthSync(OAuthConnectedRevocationClaim, {
|
|
68
|
+
job,
|
|
69
|
+
claimId: input.claimId,
|
|
70
|
+
claimedAtMillis: now,
|
|
71
|
+
claimExpiresAtMillis: expires
|
|
72
|
+
});
|
|
73
|
+
yield* owner.update(j.table, {
|
|
74
|
+
[j.jobId]: job.context.jobId,
|
|
75
|
+
[j.state]: "Pending"
|
|
76
|
+
}, {
|
|
77
|
+
[j.state]: "Claimed",
|
|
78
|
+
[j.claimId]: input.claimId,
|
|
79
|
+
[j.claimedAt]: mapping.clock.encodeInstant(now),
|
|
80
|
+
[j.claimExpiresAt]: mapping.clock.encodeInstant(expires),
|
|
81
|
+
[j.retentionUntil]: mapping.clock.encodeInstant(S.retainedUntil(mapping, expires)),
|
|
82
|
+
[j.version]: owner.marker
|
|
83
|
+
});
|
|
84
|
+
owner.postconditions.push(sql`${mapping.clock.engineNowMillis} >= ${now} and ${mapping.clock.engineNowMillis} < ${expires}`);
|
|
85
|
+
return {
|
|
86
|
+
_tag: "Claimed",
|
|
87
|
+
claim
|
|
88
|
+
};
|
|
89
|
+
}),
|
|
90
|
+
settleRevocation: Effect.fn("oauthConnected.settleRevocation")(function* (mapping, input) {
|
|
91
|
+
const owner = yield* CurrentOAuthTransaction;
|
|
92
|
+
const locks = yield* jobLocks(mapping, input.claim.job);
|
|
93
|
+
if (locks === void 0) return { settled: false };
|
|
94
|
+
const j = mapping.job, row = locks.row;
|
|
95
|
+
if (row[j.state] !== "Claimed" || row[j.claimId] !== input.claim.claimId) return { settled: false };
|
|
96
|
+
invariant(revocationClaimStorage.encode({
|
|
97
|
+
job: input.claim.job,
|
|
98
|
+
claimId: row[j.claimId],
|
|
99
|
+
claimedAtMillis: mapping.clock.decodeInstant(row[j.claimedAt]),
|
|
100
|
+
claimExpiresAtMillis: mapping.clock.decodeInstant(row[j.claimExpiresAt])
|
|
101
|
+
}) === revocationClaimStorage.encode(input.claim));
|
|
102
|
+
const now = yield* owner.now(mapping.clock);
|
|
103
|
+
invariant(now >= input.claim.claimedAtMillis);
|
|
104
|
+
const confirmed = input.outcome === "Confirmed" && now < input.claim.claimExpiresAtMillis;
|
|
105
|
+
yield* owner.update(j.table, {
|
|
106
|
+
[j.jobId]: input.claim.job.context.jobId,
|
|
107
|
+
[j.state]: "Claimed",
|
|
108
|
+
[j.claimId]: input.claim.claimId
|
|
109
|
+
}, {
|
|
110
|
+
[j.state]: confirmed ? "Confirmed" : "Unknown",
|
|
111
|
+
[j.version]: owner.marker
|
|
112
|
+
});
|
|
113
|
+
if (confirmed) {
|
|
114
|
+
owner.postconditions.push(sql`${mapping.clock.engineNowMillis} >= ${now} and ${mapping.clock.engineNowMillis} < ${input.claim.claimExpiresAtMillis}`);
|
|
115
|
+
yield* C.clear(mapping, locks.client, locks.cohort, input.claim.job.context.jobId);
|
|
116
|
+
}
|
|
117
|
+
return { settled: true };
|
|
118
|
+
}),
|
|
119
|
+
cleanup: Effect.fn("oauthConnected.cleanup")(function* (mapping, input) {
|
|
120
|
+
const owner = yield* CurrentOAuthTransaction;
|
|
121
|
+
invariant(Number.isSafeInteger(input.limit) && input.limit >= 1 && input.limit <= 1e3);
|
|
122
|
+
const f = mapping.flow, a = mapping.admission, d = mapping.command;
|
|
123
|
+
let terminalized = 0, removed = 0, visited = 0, hasMore = false;
|
|
124
|
+
const at = yield* owner.now(mapping.clock);
|
|
125
|
+
const candidates = yield* owner.read(f.table, both(eq(col(f.table, f.moduleId), input.moduleId), sql`((${col(f.table, f.state)} in ('Prepared','Pending') and ${col(f.table, f.expiresAt)} <= ${mapping.clock.encodeInstant(at)}) or (${col(f.table, f.state)} = 'Claimed' and ${col(f.table, f.claimExpiresAt)} <= ${mapping.clock.encodeInstant(at)}) or (${col(f.table, f.state)} not in ('Prepared','Pending','Claimed') and ${col(f.table, f.work)} <> 'Unresolved' and ${col(f.table, f.retentionUntil)} <= ${mapping.clock.encodeInstant(at)}))`), {
|
|
126
|
+
limit: input.limit + 1,
|
|
127
|
+
takeOnly: true,
|
|
128
|
+
observe: false,
|
|
129
|
+
lock: false,
|
|
130
|
+
orderBy: asc(col(f.table, f.flowId))
|
|
131
|
+
});
|
|
132
|
+
const collectionCandidates = yield* discover(mapping, input.moduleId, input.limit);
|
|
133
|
+
const g = mapping.grant, j = S.jobTable(mapping), h = mapping.cohort;
|
|
134
|
+
yield* S.prelockClients(mapping, [
|
|
135
|
+
...candidates.rows.slice(0, input.limit).map((row) => row[f.clientKey]),
|
|
136
|
+
...collectionCandidates.jobs.slice(0, input.limit).map((row) => row[j.clientKey]),
|
|
137
|
+
...collectionCandidates.grants.slice(0, input.limit).map((row) => row[g.clientKey]),
|
|
138
|
+
...collectionCandidates.cohorts.slice(0, input.limit).map((row) => row[h.clientKey])
|
|
139
|
+
], collectionCandidates.tuples.slice(0, input.limit).map((row) => ({
|
|
140
|
+
provider: row[mapping.ownership.tuple.provider],
|
|
141
|
+
issuer: row[mapping.ownership.tuple.issuer]
|
|
142
|
+
})));
|
|
143
|
+
hasMore = candidates.rows.length > input.limit;
|
|
144
|
+
for (const candidate of candidates.rows.slice(0, input.limit)) {
|
|
145
|
+
visited++;
|
|
146
|
+
const heldClient = yield* S.lockClientById(mapping, candidate[f.clientKey]);
|
|
147
|
+
const row = (yield* owner.read(f.table, equal(f.table, {
|
|
148
|
+
[f.moduleId]: input.moduleId,
|
|
149
|
+
[f.flowId]: candidate[f.flowId]
|
|
150
|
+
}), { limit: 1 })).rows[0];
|
|
151
|
+
if (row === void 0) continue;
|
|
152
|
+
invariant(row[f.clientKey] === heldClient.id);
|
|
153
|
+
const now = yield* owner.now(mapping.clock), state = row[f.state];
|
|
154
|
+
const expires = mapping.clock.decodeInstant(state === "Claimed" ? row[f.claimExpiresAt] : row[f.expiresAt]);
|
|
155
|
+
if ((state === "Prepared" || state === "Pending" || state === "Claimed") && now >= expires) {
|
|
156
|
+
yield* owner.update(f.table, {
|
|
157
|
+
[f.moduleId]: input.moduleId,
|
|
158
|
+
[f.flowId]: row[f.flowId],
|
|
159
|
+
[f.version]: row[f.version]
|
|
160
|
+
}, {
|
|
161
|
+
[f.state]: state === "Claimed" ? "Ambiguous" : "Expired",
|
|
162
|
+
[f.snapshot]: null,
|
|
163
|
+
[f.version]: owner.marker
|
|
164
|
+
});
|
|
165
|
+
owner.postconditions.push(sql`${mapping.clock.engineNowMillis} >= ${expires}`);
|
|
166
|
+
terminalized++;
|
|
167
|
+
} else if (state !== "Prepared" && state !== "Pending" && state !== "Claimed" && row[f.work] !== "Unresolved" && now >= mapping.clock.decodeInstant(row[f.retentionUntil])) {
|
|
168
|
+
yield* owner.remove(f.table, {
|
|
169
|
+
[f.moduleId]: input.moduleId,
|
|
170
|
+
[f.flowId]: row[f.flowId],
|
|
171
|
+
[f.version]: row[f.version]
|
|
172
|
+
});
|
|
173
|
+
owner.postconditions.push(sql`${mapping.clock.engineNowMillis} >= ${mapping.clock.decodeInstant(row[f.retentionUntil])}`);
|
|
174
|
+
removed++;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
for (const table of [a, d]) {
|
|
178
|
+
if (visited >= input.limit) {
|
|
179
|
+
hasMore = true;
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
const deadline = "expiresAt" in table ? table.expiresAt : table.retentionUntil, key = "admissionId" in table ? table.admissionId : table.commandId;
|
|
183
|
+
const rows = yield* owner.read(table.table, both(eq(col(table.table, table.moduleId), input.moduleId), lte(col(table.table, deadline), mapping.clock.encodeInstant(at))), {
|
|
184
|
+
limit: input.limit - visited + 1,
|
|
185
|
+
takeOnly: true,
|
|
186
|
+
observe: false,
|
|
187
|
+
lock: false,
|
|
188
|
+
orderBy: asc(col(table.table, key))
|
|
189
|
+
});
|
|
190
|
+
if (rows.rows.length > input.limit - visited) hasMore = true;
|
|
191
|
+
for (const candidate of rows.rows.slice(0, input.limit - visited)) {
|
|
192
|
+
visited++;
|
|
193
|
+
const row = (yield* owner.read(table.table, equal(table.table, {
|
|
194
|
+
[table.moduleId]: input.moduleId,
|
|
195
|
+
[key]: candidate[key]
|
|
196
|
+
}), { limit: 1 })).rows[0];
|
|
197
|
+
const now = yield* owner.now(mapping.clock);
|
|
198
|
+
if (row !== void 0 && now >= mapping.clock.decodeInstant(row[deadline])) {
|
|
199
|
+
yield* owner.remove(table.table, {
|
|
200
|
+
[table.moduleId]: input.moduleId,
|
|
201
|
+
[key]: row[key],
|
|
202
|
+
[table.version]: row[table.version]
|
|
203
|
+
});
|
|
204
|
+
owner.postconditions.push(sql`${mapping.clock.engineNowMillis} >= ${mapping.clock.decodeInstant(row[deadline])}`);
|
|
205
|
+
removed++;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const collection = yield* collect(mapping, input.moduleId, input.limit - visited, collectionCandidates);
|
|
210
|
+
removed += collection.removed;
|
|
211
|
+
hasMore ||= collection.hasMore;
|
|
212
|
+
return {
|
|
213
|
+
terminalized,
|
|
214
|
+
removed,
|
|
215
|
+
hasMore
|
|
216
|
+
};
|
|
217
|
+
})
|
|
218
|
+
};
|
|
219
|
+
});
|
|
220
|
+
var OAuthConnectedMaintenance = class OAuthConnectedMaintenance extends Context.Service()("effect-auth/persistence/OAuthConnectedMaintenance") {
|
|
221
|
+
static layer = Layer.effect(OAuthConnectedMaintenance, make);
|
|
222
|
+
};
|
|
223
|
+
//#endregion
|
|
224
|
+
export { OAuthConnectedMaintenance };
|
|
225
|
+
|
|
226
|
+
//# sourceMappingURL=connected-maintenance.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connected-maintenance.mjs","names":[],"sources":["../../../src/internal/oauth/connected-maintenance.ts"],"sourcesContent":["import type * as M from \"@yielded/auth/OAuth\";\nimport {\n OAuthConnectedRevocationClaim,\n type OAuthConnectedRevocations,\n snapshotOAuthSync,\n} from \"@yielded/auth/OAuth\";\nimport { Effect, Context, Layer } from \"effect\";\n\nimport { OAuthConnectedCollection } from \"./connected-collection\";\nimport { OAuthConnectedCustody } from \"./connected-custody\";\nimport { OAuthConnectedFlow } from \"./connected-flow\";\nimport type * as FTypes from \"./connected-flow\";\nimport { OAuthConnectedState } from \"./connected-state\";\nimport type * as STypes from \"./connected-state\";\nimport { CurrentOAuthTransaction } from \"./owner\";\nimport { OAuthQueryCompiler } from \"./query-compiler\";\nimport { invariant, storage } from \"./state\";\n\ntype WorkerInput<K extends keyof OAuthConnectedRevocations[\"Service\"]> = Parameters<\n OAuthConnectedRevocations[\"Service\"][K]\n>[0];\n\nconst make = Effect.gen(function* () {\n const operations = yield* OAuthQueryCompiler;\n const connectedCollection = yield* OAuthConnectedCollection;\n const C = yield* OAuthConnectedCustody;\n const F = yield* OAuthConnectedFlow;\n const S = yield* OAuthConnectedState;\n\n const { asc, eq, lte, sql } = operations;\n const { collect, discover } = connectedCollection;\n const { both, col, equal } = operations;\n\n const revocationClaimStorage = storage(OAuthConnectedRevocationClaim);\n\n const jobLocks = Effect.fn(\"oauthConnected.jobLocks\")(function* (\n mapping: STypes.Revocations,\n job: M.OAuthConnectedRevocationJob,\n ) {\n const owner = yield* CurrentOAuthTransaction;\n\n const token = job.context.token,\n client = yield* S.client(mapping, token.configuration, false);\n\n if (client === undefined) return undefined;\n\n const tuple = yield* F.inspectTuple(mapping, token.identity),\n t = mapping.ownership.tuple;\n\n const native = yield* mapping.subjectId.toNative(token.subjectId);\n\n if (\n tuple.row?.[t.state] !== \"Owned\" ||\n !mapping.subjectId.equals(tuple.row[t.subjectId], native)\n )\n return undefined;\n const cohort = yield* S.cohort(mapping, client.id, tuple.key, false);\n\n invariant(cohort.row !== undefined);\n\n const j = mapping.job,\n read = yield* owner.read(j.table, equal(j.table, { [j.jobId]: job.context.jobId }), {\n limit: 1,\n }),\n row = read.rows[0];\n\n if (row === undefined) return undefined;\n invariant(row[j.state] === \"Confirmed\" || cohort.blocked);\n invariant(\n row[j.snapshot] === S.jobStorage.encode(job) &&\n row[j.moduleId] === token.moduleId &&\n mapping.subjectId.equals(native, row[j.subjectId]) &&\n row[j.identityKey] === tuple.key &&\n row[j.clientKey] === client.id &&\n row[j.cohortKey] === cohort.id &&\n row[j.grantId] === token.grantId &&\n [\"Pending\", \"Claimed\", \"Unknown\", \"Confirmed\"].includes(row[j.state]),\n );\n\n return { client, cohort, row };\n });\n\n const claimRevocation = Effect.fn(\"oauthConnected.claimRevocation\")(function* (\n mapping: STypes.Revocations,\n input: WorkerInput<\"claim\">,\n ) {\n const owner = yield* CurrentOAuthTransaction;\n\n invariant(\n Number.isSafeInteger(input.lifetimeMillis) &&\n input.lifetimeMillis >= 1000 &&\n input.lifetimeMillis <= 120000,\n );\n const j = mapping.job;\n\n const candidate = yield* owner.read(\n j.table,\n equal(j.table, { [j.moduleId]: input.moduleId, [j.state]: \"Pending\" }),\n {\n limit: 1,\n takeOnly: true,\n lock: false,\n observe: false,\n orderBy: asc(col(j.table, j.jobId)),\n },\n );\n\n const row = candidate.rows[0];\n\n if (row === undefined) return { _tag: \"Empty\" } as const;\n const job = S.jobStorage.decode(row[j.snapshot]);\n const locks = yield* jobLocks(mapping, job);\n\n if (locks === undefined || locks.row[j.state] !== \"Pending\") return { _tag: \"Empty\" } as const;\n invariant(\n locks.row[j.claimId] === null &&\n locks.row[j.claimedAt] === null &&\n locks.row[j.claimExpiresAt] === null,\n );\n\n const now = yield* owner.now(mapping.clock),\n expires = now + input.lifetimeMillis;\n\n invariant(Number.isSafeInteger(expires));\n\n const claim = snapshotOAuthSync(OAuthConnectedRevocationClaim, {\n job,\n claimId: input.claimId,\n claimedAtMillis: now,\n claimExpiresAtMillis: expires,\n });\n\n yield* owner.update(\n j.table,\n { [j.jobId]: job.context.jobId, [j.state]: \"Pending\" },\n {\n [j.state]: \"Claimed\",\n [j.claimId]: input.claimId,\n [j.claimedAt]: mapping.clock.encodeInstant(now),\n [j.claimExpiresAt]: mapping.clock.encodeInstant(expires),\n [j.retentionUntil]: mapping.clock.encodeInstant(S.retainedUntil(mapping, expires)),\n [j.version]: owner.marker,\n },\n );\n owner.postconditions.push(\n sql`${mapping.clock.engineNowMillis} >= ${now} and ${mapping.clock.engineNowMillis} < ${expires}`,\n );\n\n return { _tag: \"Claimed\", claim } as const;\n });\n\n const settleRevocation = Effect.fn(\"oauthConnected.settleRevocation\")(function* (\n mapping: STypes.Revocations,\n input: WorkerInput<\"settle\">,\n ) {\n const owner = yield* CurrentOAuthTransaction;\n const locks = yield* jobLocks(mapping, input.claim.job);\n\n if (locks === undefined) return { settled: false };\n\n const j = mapping.job,\n row = locks.row;\n\n if (row[j.state] !== \"Claimed\" || row[j.claimId] !== input.claim.claimId)\n return { settled: false };\n invariant(\n revocationClaimStorage.encode({\n job: input.claim.job,\n claimId: row[j.claimId],\n claimedAtMillis: mapping.clock.decodeInstant(row[j.claimedAt]),\n claimExpiresAtMillis: mapping.clock.decodeInstant(row[j.claimExpiresAt]),\n }) === revocationClaimStorage.encode(input.claim),\n );\n const now = yield* owner.now(mapping.clock);\n\n invariant(now >= input.claim.claimedAtMillis);\n const confirmed = input.outcome === \"Confirmed\" && now < input.claim.claimExpiresAtMillis;\n\n yield* owner.update(\n j.table,\n {\n [j.jobId]: input.claim.job.context.jobId,\n [j.state]: \"Claimed\",\n [j.claimId]: input.claim.claimId,\n },\n { [j.state]: confirmed ? \"Confirmed\" : \"Unknown\", [j.version]: owner.marker },\n );\n if (confirmed) {\n owner.postconditions.push(\n sql`${mapping.clock.engineNowMillis} >= ${now} and ${mapping.clock.engineNowMillis} < ${input.claim.claimExpiresAtMillis}`,\n );\n yield* C.clear(mapping, locks.client, locks.cohort, input.claim.job.context.jobId);\n }\n\n return { settled: true };\n });\n\n /** Candidate discovery is not authority. Each conditional write re-reads its row\n * and engine time under the client/tuple/cohort order and retains a final guard. */\n const cleanup = Effect.fn(\"oauthConnected.cleanup\")(function* (\n mapping: STypes.Mapping,\n input: FTypes.Input<\"cleanup\">,\n ) {\n const owner = yield* CurrentOAuthTransaction;\n\n invariant(Number.isSafeInteger(input.limit) && input.limit >= 1 && input.limit <= 1000);\n\n const f = mapping.flow,\n a = mapping.admission,\n d = mapping.command;\n\n let terminalized = 0,\n removed = 0,\n visited = 0,\n hasMore = false;\n\n const at = yield* owner.now(mapping.clock);\n\n const candidates = yield* owner.read(\n f.table,\n both(\n eq(col(f.table, f.moduleId), input.moduleId),\n sql`((${col(f.table, f.state)} in ('Prepared','Pending') and ${col(f.table, f.expiresAt)} <= ${mapping.clock.encodeInstant(at)}) or (${col(f.table, f.state)} = 'Claimed' and ${col(f.table, f.claimExpiresAt)} <= ${mapping.clock.encodeInstant(at)}) or (${col(f.table, f.state)} not in ('Prepared','Pending','Claimed') and ${col(f.table, f.work)} <> 'Unresolved' and ${col(f.table, f.retentionUntil)} <= ${mapping.clock.encodeInstant(at)}))`,\n ),\n {\n limit: input.limit + 1,\n takeOnly: true,\n observe: false,\n lock: false,\n orderBy: asc(col(f.table, f.flowId)),\n },\n );\n\n const collectionCandidates = yield* discover(mapping, input.moduleId, input.limit);\n\n const g = mapping.grant,\n j = S.jobTable(mapping),\n h = mapping.cohort;\n\n yield* S.prelockClients(\n mapping,\n [\n ...candidates.rows.slice(0, input.limit).map((row) => row[f.clientKey]),\n ...collectionCandidates.jobs.slice(0, input.limit).map((row) => row[j!.clientKey]),\n ...collectionCandidates.grants.slice(0, input.limit).map((row) => row[g.clientKey]),\n ...collectionCandidates.cohorts.slice(0, input.limit).map((row) => row[h.clientKey]),\n ],\n collectionCandidates.tuples.slice(0, input.limit).map((row) => ({\n provider: row[mapping.ownership.tuple.provider],\n issuer: row[mapping.ownership.tuple.issuer],\n })),\n );\n hasMore = candidates.rows.length > input.limit;\n for (const candidate of candidates.rows.slice(0, input.limit)) {\n visited++;\n // A terminal ledger retains client key but may erase the decryptable browser snapshot.\n const heldClient = yield* S.lockClientById(mapping, candidate[f.clientKey]);\n\n const read = yield* owner.read(\n f.table,\n equal(f.table, { [f.moduleId]: input.moduleId, [f.flowId]: candidate[f.flowId] }),\n { limit: 1 },\n ),\n row = read.rows[0];\n\n if (row === undefined) continue;\n invariant(row[f.clientKey] === heldClient.id);\n\n const now = yield* owner.now(mapping.clock),\n state = row[f.state];\n\n const expires = mapping.clock.decodeInstant(\n state === \"Claimed\" ? row[f.claimExpiresAt] : row[f.expiresAt],\n );\n\n if ((state === \"Prepared\" || state === \"Pending\" || state === \"Claimed\") && now >= expires) {\n yield* owner.update(\n f.table,\n { [f.moduleId]: input.moduleId, [f.flowId]: row[f.flowId], [f.version]: row[f.version] },\n {\n [f.state]: state === \"Claimed\" ? \"Ambiguous\" : \"Expired\",\n [f.snapshot]: null,\n [f.version]: owner.marker,\n },\n );\n owner.postconditions.push(sql`${mapping.clock.engineNowMillis} >= ${expires}`);\n terminalized++;\n } else if (\n state !== \"Prepared\" &&\n state !== \"Pending\" &&\n state !== \"Claimed\" &&\n row[f.work] !== \"Unresolved\" &&\n now >= mapping.clock.decodeInstant(row[f.retentionUntil])\n ) {\n yield* owner.remove(f.table, {\n [f.moduleId]: input.moduleId,\n [f.flowId]: row[f.flowId],\n [f.version]: row[f.version],\n });\n owner.postconditions.push(\n sql`${mapping.clock.engineNowMillis} >= ${mapping.clock.decodeInstant(row[f.retentionUntil])}`,\n );\n removed++;\n }\n }\n // Expired admission and command metadata have no external-operation obligation.\n for (const table of [a, d]) {\n if (visited >= input.limit) {\n hasMore = true;\n break;\n }\n\n const deadline = \"expiresAt\" in table ? table.expiresAt : table.retentionUntil,\n key = \"admissionId\" in table ? table.admissionId : table.commandId;\n\n const rows = yield* owner.read(\n table.table,\n both(\n eq(col(table.table, table.moduleId), input.moduleId),\n lte(col(table.table, deadline), mapping.clock.encodeInstant(at)),\n ),\n {\n limit: input.limit - visited + 1,\n takeOnly: true,\n observe: false,\n lock: false,\n orderBy: asc(col(table.table, key)),\n },\n );\n\n if (rows.rows.length > input.limit - visited) hasMore = true;\n for (const candidate of rows.rows.slice(0, input.limit - visited)) {\n visited++;\n\n const read = yield* owner.read(\n table.table,\n equal(table.table, { [table.moduleId]: input.moduleId, [key]: candidate[key] }),\n { limit: 1 },\n ),\n row = read.rows[0];\n\n const now = yield* owner.now(mapping.clock);\n\n if (row !== undefined && now >= mapping.clock.decodeInstant(row[deadline])) {\n yield* owner.remove(table.table, {\n [table.moduleId]: input.moduleId,\n [key]: row[key],\n [table.version]: row[table.version],\n });\n owner.postconditions.push(\n sql`${mapping.clock.engineNowMillis} >= ${mapping.clock.decodeInstant(row[deadline])}`,\n );\n removed++;\n }\n }\n }\n\n const collection = yield* collect(\n mapping,\n input.moduleId,\n input.limit - visited,\n collectionCandidates,\n );\n\n removed += collection.removed;\n hasMore ||= collection.hasMore;\n\n return { terminalized, removed, hasMore };\n });\n\n return { claimRevocation, settleRevocation, cleanup };\n});\n\nexport class OAuthConnectedMaintenance extends Context.Service<\n OAuthConnectedMaintenance,\n Effect.Success<typeof make>\n>()(\"effect-auth/persistence/OAuthConnectedMaintenance\") {\n static readonly layer = Layer.effect(OAuthConnectedMaintenance, make);\n}\n"],"mappings":";;;;;;;;;;AAsBA,MAAM,OAAO,OAAO,IAAI,aAAa;CACnC,MAAM,aAAa,OAAO;CAC1B,MAAM,sBAAsB,OAAO;CACnC,MAAM,IAAI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CAAC;CACvD,OAAgB,QAAQ,MAAM,OAAO,2BAA2B,IAAI;AACtE"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../mapping-error.mjs";
|
|
2
|
+
import "./owner.mjs";
|
|
3
|
+
import "./connected-state.mjs";
|
|
4
|
+
import "./query-compiler.mjs";
|
|
5
|
+
import "./connected-custody.mjs";
|
|
6
|
+
import "./connected-flow.mjs";
|
|
7
|
+
import "./connected-access.mjs";
|
|
8
|
+
import { Context, Effect, Layer } from "effect";
|
|
9
|
+
import "@yielded/auth/OAuth";
|