@modelprofile.com/authswitch 6.5.0 → 8.0.0
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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/authority-contract.d.ts +300 -6
- package/dist_ts/authority-contract.js +1 -1
- package/dist_ts/authority-runtime-contract.d.ts +13 -0
- package/dist_ts/classes.accountlist.js +4 -3
- package/dist_ts/classes.authoritybroker.d.ts +25 -5
- package/dist_ts/classes.authoritybroker.js +388 -123
- package/dist_ts/classes.authoritycli.d.ts +24 -0
- package/dist_ts/classes.authoritycli.js +675 -0
- package/dist_ts/classes.authorityclient.d.ts +19 -7
- package/dist_ts/classes.authorityclient.js +51 -14
- package/dist_ts/classes.authoritydaemon.d.ts +28 -1
- package/dist_ts/classes.authoritydaemon.js +477 -36
- package/dist_ts/classes.authoritydatabase.d.ts +155 -11
- package/dist_ts/classes.authoritydatabase.js +1037 -69
- package/dist_ts/classes.authoritymodels.d.ts +229 -23
- package/dist_ts/classes.authoritymodels.js +867 -128
- package/dist_ts/classes.authoritypreuse.d.ts +47 -0
- package/dist_ts/classes.authoritypreuse.js +277 -0
- package/dist_ts/classes.authorityregistry.d.ts +9 -0
- package/dist_ts/classes.authorityregistry.js +32 -0
- package/dist_ts/classes.authoritysecrets.d.ts +1 -1
- package/dist_ts/classes.authoritysecrets.js +2 -2
- package/dist_ts/classes.authorityusage.d.ts +160 -0
- package/dist_ts/classes.authorityusage.js +429 -0
- package/dist_ts/classes.claudeauthority.d.ts +66 -0
- package/dist_ts/classes.claudeauthority.js +528 -0
- package/dist_ts/classes.claudecodeharness.js +3 -2
- package/dist_ts/classes.claudecodelocks.d.ts +13 -0
- package/dist_ts/classes.claudecodelocks.js +75 -3
- package/dist_ts/classes.claudenative.d.ts +130 -0
- package/dist_ts/classes.claudenative.js +708 -0
- package/dist_ts/classes.claudestatus.d.ts +9 -0
- package/dist_ts/classes.claudestatus.js +26 -9
- package/dist_ts/classes.claudetokenrefresh.d.ts +15 -1
- package/dist_ts/classes.claudetokenrefresh.js +74 -21
- package/dist_ts/classes.codexharness.js +4 -2
- package/dist_ts/classes.codexmanaged.d.ts +12 -1
- package/dist_ts/classes.codexmanaged.js +75 -14
- package/dist_ts/classes.codexpreuse.d.ts +8 -0
- package/dist_ts/classes.codexpreuse.js +24 -6
- package/dist_ts/classes.fileharness.d.ts +2 -0
- package/dist_ts/classes.fileharness.js +6 -4
- package/dist_ts/classes.limits.js +12 -7
- package/dist_ts/classes.opencodeharness.js +2 -2
- package/dist_ts/claudehttp.d.ts +10 -0
- package/dist_ts/claudehttp.js +29 -3
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +7 -1
- package/dist_ts/interfaces.harness.d.ts +6 -0
- package/dist_ts/interfaces.list.d.ts +9 -3
- package/dist_ts/plugins.d.ts +6 -3
- package/dist_ts/plugins.js +8 -4
- package/dist_ts/ts_migration/0001_authority_meta.d.ts +13 -0
- package/dist_ts/ts_migration/0001_authority_meta.js +44 -0
- package/dist_ts/ts_migration/0002_remove_backup_records.d.ts +17 -0
- package/dist_ts/ts_migration/0002_remove_backup_records.js +48 -0
- package/dist_ts/ts_migration/index.d.ts +6 -0
- package/dist_ts/ts_migration/index.js +12 -0
- package/package.json +3 -3
- package/readme.md +177 -14
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/authority-contract.ts +262 -9
- package/ts/authority-runtime-contract.ts +14 -0
- package/ts/classes.accountlist.ts +3 -2
- package/ts/classes.authoritybroker.ts +385 -121
- package/ts/classes.authoritycli.ts +719 -0
- package/ts/classes.authorityclient.ts +75 -18
- package/ts/classes.authoritydaemon.ts +444 -36
- package/ts/classes.authoritydatabase.ts +1076 -75
- package/ts/classes.authoritymodels.ts +642 -144
- package/ts/classes.authoritypreuse.ts +296 -0
- package/ts/classes.authorityregistry.ts +47 -0
- package/ts/classes.authoritysecrets.ts +1 -1
- package/ts/classes.authorityusage.ts +527 -0
- package/ts/classes.claudeauthority.ts +537 -0
- package/ts/classes.claudecodeharness.ts +2 -1
- package/ts/classes.claudecodelocks.ts +70 -1
- package/ts/classes.claudenative.ts +785 -0
- package/ts/classes.claudestatus.ts +38 -9
- package/ts/classes.claudetokenrefresh.ts +82 -19
- package/ts/classes.codexharness.ts +3 -1
- package/ts/classes.codexmanaged.ts +76 -13
- package/ts/classes.codexpreuse.ts +33 -5
- package/ts/classes.fileharness.ts +7 -3
- package/ts/classes.limits.ts +11 -6
- package/ts/classes.opencodeharness.ts +1 -1
- package/ts/claudehttp.ts +31 -2
- package/ts/index.ts +6 -0
- package/ts/interfaces.harness.ts +6 -0
- package/ts/interfaces.list.ts +9 -3
- package/ts/plugins.ts +8 -3
- package/ts/ts_migration/0001_authority_meta.ts +45 -0
- package/ts/ts_migration/0002_remove_backup_records.ts +49 -0
- package/ts/ts_migration/index.ts +12 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as plugins from './plugins.js';
|
|
2
|
+
import type { TAuthSwitchLoginPrompt } from './authority-contract.js';
|
|
3
|
+
import type { IAuthSwitchStoredUsage } from './classes.authorityusage.js';
|
|
2
4
|
|
|
3
5
|
export interface IStoredAuthorityMeta {
|
|
4
6
|
id: 'authswitch-authority';
|
|
@@ -34,7 +36,7 @@ export interface IStoredAuthorityGrant {
|
|
|
34
36
|
providerId: string;
|
|
35
37
|
purpose: TStoredGrantPurpose;
|
|
36
38
|
audience: string;
|
|
37
|
-
state: 'ready' | 'exchange_may_have_been_sent' | 'retry_wait' | 'needs_reauth' | 'native' | 'legacy_native_pending' | 'removed';
|
|
39
|
+
state: 'ready' | 'exchange_may_have_been_sent' | 'retry_wait' | 'needs_reauth' | 'native' | 'legacy_native_pending' | 'handoff_pending' | 'handoff_quarantined' | 'removed';
|
|
38
40
|
owner: 'daemon' | 'claude_native' | 'legacy_native' | 'none';
|
|
39
41
|
grantGeneration: number;
|
|
40
42
|
authorizationGeneration: number;
|
|
@@ -49,6 +51,16 @@ export interface IStoredAuthorityGrant {
|
|
|
49
51
|
updateId: string;
|
|
50
52
|
}
|
|
51
53
|
|
|
54
|
+
/** Credential-free provider usage cached for one exact account/login pair. */
|
|
55
|
+
export interface IStoredAuthorityUsage extends IAuthSwitchStoredUsage {
|
|
56
|
+
id: string;
|
|
57
|
+
accountId: string;
|
|
58
|
+
loginId: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export const authorityUsageId = (accountId: string, loginId: string): string =>
|
|
62
|
+
plugins.crypto.createHash('sha256').update(JSON.stringify(['authswitch-usage-v1', accountId, loginId])).digest('hex');
|
|
63
|
+
|
|
52
64
|
export interface IStoredAuthorityBinding {
|
|
53
65
|
id: string;
|
|
54
66
|
accountId: string;
|
|
@@ -75,12 +87,59 @@ export interface IStoredAuthorityEnrollment {
|
|
|
75
87
|
export interface IStoredAuthorityCodexHome {
|
|
76
88
|
id: string;
|
|
77
89
|
accountId: string;
|
|
90
|
+
grantId: string;
|
|
78
91
|
scopeId: string;
|
|
79
92
|
activeRun: { id: string; socketPath: string; pid: number | null; startedAt: string | null } | null;
|
|
80
93
|
createdAt: string;
|
|
81
94
|
updateId: string;
|
|
82
95
|
}
|
|
83
96
|
|
|
97
|
+
/** One vendor home owns at most one active Claude grant; activeGrantId has a unique index. */
|
|
98
|
+
export interface IStoredAuthorityClaudeHome {
|
|
99
|
+
id: string;
|
|
100
|
+
activeAccountId: string;
|
|
101
|
+
activeGrantId: string;
|
|
102
|
+
pendingOperationId: string | null;
|
|
103
|
+
status: 'ready' | 'quarantined';
|
|
104
|
+
revision: number;
|
|
105
|
+
createdAt: string;
|
|
106
|
+
updateId: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface IStoredAuthorityNativePair {
|
|
110
|
+
credentialDigest: string | null;
|
|
111
|
+
configDigest: string | null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface IStoredAuthorityNativeIdentity {
|
|
115
|
+
accountUuid: string;
|
|
116
|
+
organizationUuid: string;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Backend-only proof for one exact two-grant native transfer. */
|
|
120
|
+
export interface IStoredAuthorityClaudeHandoff {
|
|
121
|
+
id: string;
|
|
122
|
+
homeId: string;
|
|
123
|
+
outgoingAccountId: string;
|
|
124
|
+
outgoingGrantId: string;
|
|
125
|
+
incomingAccountId: string;
|
|
126
|
+
incomingGrantId: string;
|
|
127
|
+
phase: 'reserved' | 'prepared' | 'committed' | 'aborted' | 'quarantined';
|
|
128
|
+
before: IStoredAuthorityNativePair | null;
|
|
129
|
+
after: IStoredAuthorityNativePair | null;
|
|
130
|
+
sourceIdentity: IStoredAuthorityNativeIdentity;
|
|
131
|
+
targetIdentity: IStoredAuthorityNativeIdentity;
|
|
132
|
+
sourceAccessDigest: string | null;
|
|
133
|
+
targetAccessDigest: string | null;
|
|
134
|
+
sealedOutgoing: string | null;
|
|
135
|
+
runningEffectiveAuth: 'no_scoped_sessions' | 'unsupported_effective_auth' | null;
|
|
136
|
+
problem: 'none' | 'native_uncertain' | 'foreign_or_torn' | 'unsupported_effective_auth' | 'database_uncertain';
|
|
137
|
+
startedAt: string;
|
|
138
|
+
updatedAt: string;
|
|
139
|
+
revision: number;
|
|
140
|
+
updateId: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
84
143
|
/** Journal for a native-home handoff. A prepared grant is never usable. */
|
|
85
144
|
export interface IStoredAuthorityHandoff {
|
|
86
145
|
id: string;
|
|
@@ -92,7 +151,6 @@ export interface IStoredAuthorityHandoff {
|
|
|
92
151
|
operationId: string;
|
|
93
152
|
sourceDigest: string;
|
|
94
153
|
verifiedSourceDigest: string | null;
|
|
95
|
-
backupDigest: string | null;
|
|
96
154
|
revision: number;
|
|
97
155
|
statusObservedAt: string;
|
|
98
156
|
updateId: string;
|
|
@@ -108,7 +166,6 @@ export interface IStoredAuthorityMigrationLedger {
|
|
|
108
166
|
status: 'pending_native_owner' | 'prepared' | 'verified' | 'complete' | 'quarantined';
|
|
109
167
|
accountId: string | null;
|
|
110
168
|
grantId: string | null;
|
|
111
|
-
backupDigest: string | null;
|
|
112
169
|
revision: number;
|
|
113
170
|
statusObservedAt: string;
|
|
114
171
|
updateId: string;
|
|
@@ -122,6 +179,82 @@ export interface IStoredAuthorityEvent {
|
|
|
122
179
|
accountId: string;
|
|
123
180
|
}
|
|
124
181
|
|
|
182
|
+
/** A device flow and its immutable result receipt. Provider work is never resumed from this record. */
|
|
183
|
+
export interface IStoredAuthorityDeviceOperation {
|
|
184
|
+
id: string;
|
|
185
|
+
kind: 'add_openai' | 'reauth_openai';
|
|
186
|
+
purpose: 'openai_managed';
|
|
187
|
+
accountId: string | null;
|
|
188
|
+
grantId: string | null;
|
|
189
|
+
expectedGrantGeneration: number | null;
|
|
190
|
+
state: 'starting' | 'pending' | 'committing' | 'complete' | 'failed' | 'cancelled' | 'interrupted' | 'outcome_unknown';
|
|
191
|
+
prompt: TAuthSwitchLoginPrompt | null;
|
|
192
|
+
result: { accountId: string; grantId: string; accountRevision: number; grantGeneration: number } | null;
|
|
193
|
+
error: string | null;
|
|
194
|
+
commitId: string | null;
|
|
195
|
+
createdAt: string;
|
|
196
|
+
updatedAt: string;
|
|
197
|
+
finishedAt: string | null;
|
|
198
|
+
revision: number;
|
|
199
|
+
updateId: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export type TStoredAuthorityPreuseProblem =
|
|
203
|
+
| 'none' | 'target_unavailable' | 'access_unavailable' | 'catalog_unavailable'
|
|
204
|
+
| 'account_busy' | 'cancelled' | 'authority_closing' | 'interrupted'
|
|
205
|
+
| 'request_uncertain';
|
|
206
|
+
|
|
207
|
+
/** One quota-consuming request. The prompt and generated prose never enter persistence. */
|
|
208
|
+
export interface IStoredAuthorityPreuseOperation {
|
|
209
|
+
id: string;
|
|
210
|
+
kind: 'preuse_openai';
|
|
211
|
+
purpose: 'openai_managed';
|
|
212
|
+
accountId: string;
|
|
213
|
+
grantId: string;
|
|
214
|
+
/** Hash of the exact target, prompt and requested model; used only for idempotent admission. */
|
|
215
|
+
requestHash: string;
|
|
216
|
+
requestedModel: string | null;
|
|
217
|
+
model: string | null;
|
|
218
|
+
authorizationGeneration: number;
|
|
219
|
+
grantGeneration: number | null;
|
|
220
|
+
state: 'preparing' | 'request_may_have_started' | 'complete' | 'not_sent' | 'outcome_unknown';
|
|
221
|
+
result: { inputTokens: number | null; outputTokens: number | null; totalTokens: number | null } | null;
|
|
222
|
+
problem: TStoredAuthorityPreuseProblem;
|
|
223
|
+
createdAt: string;
|
|
224
|
+
updatedAt: string;
|
|
225
|
+
finishedAt: string | null;
|
|
226
|
+
revision: number;
|
|
227
|
+
updateId: string;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export type IStoredAuthorityOperation = IStoredAuthorityDeviceOperation | IStoredAuthorityPreuseOperation;
|
|
231
|
+
|
|
232
|
+
/** Decorated storage fields shared by the two exact discriminated operation variants. */
|
|
233
|
+
export interface IStoredAuthorityOperationDocument {
|
|
234
|
+
id: string;
|
|
235
|
+
kind: IStoredAuthorityOperation['kind'];
|
|
236
|
+
purpose: 'openai_managed';
|
|
237
|
+
accountId: string | null;
|
|
238
|
+
grantId: string | null;
|
|
239
|
+
expectedGrantGeneration?: number | null;
|
|
240
|
+
state: IStoredAuthorityOperation['state'];
|
|
241
|
+
prompt?: TAuthSwitchLoginPrompt | null;
|
|
242
|
+
result: IStoredAuthorityOperation['result'];
|
|
243
|
+
error?: string | null;
|
|
244
|
+
commitId?: string | null;
|
|
245
|
+
requestHash?: string;
|
|
246
|
+
requestedModel?: string | null;
|
|
247
|
+
model?: string | null;
|
|
248
|
+
authorizationGeneration?: number;
|
|
249
|
+
grantGeneration?: number | null;
|
|
250
|
+
problem?: TStoredAuthorityPreuseProblem;
|
|
251
|
+
createdAt: string;
|
|
252
|
+
updatedAt: string;
|
|
253
|
+
finishedAt: string | null;
|
|
254
|
+
revision: number;
|
|
255
|
+
updateId: string;
|
|
256
|
+
}
|
|
257
|
+
|
|
125
258
|
const object = (value: unknown): value is Record<string, unknown> =>
|
|
126
259
|
value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
127
260
|
&& [Object.prototype, null].includes(Object.getPrototypeOf(value));
|
|
@@ -137,6 +270,106 @@ const revision = (value: unknown): value is number => Number.isSafeInteger(value
|
|
|
137
270
|
const ciphertext = (value: unknown): boolean => value === null
|
|
138
271
|
|| (typeof value === 'string' && value.length > 0 && value.length <= 131072 && /^[A-Za-z0-9_-]+$/.test(value));
|
|
139
272
|
|
|
273
|
+
const usageWindow = (value: unknown): boolean => object(value)
|
|
274
|
+
&& exactKeys(value, ['usedPercent', 'limitWindowSeconds', 'resetAfterSeconds', 'resetsAt'])
|
|
275
|
+
&& ['usedPercent', 'limitWindowSeconds', 'resetAfterSeconds', 'resetsAt']
|
|
276
|
+
.every(key => typeof value[key] === 'number' && Number.isFinite(value[key]));
|
|
277
|
+
const usageDetails = (value: unknown): boolean => object(value)
|
|
278
|
+
&& Object.keys(value).every(key => ['allowed', 'limitReached', 'primaryWindow', 'secondaryWindow'].includes(key))
|
|
279
|
+
&& typeof value.allowed === 'boolean' && typeof value.limitReached === 'boolean'
|
|
280
|
+
&& (value.primaryWindow === undefined || usageWindow(value.primaryWindow))
|
|
281
|
+
&& (value.secondaryWindow === undefined || usageWindow(value.secondaryWindow));
|
|
282
|
+
const usageRateLimits = (value: unknown): boolean => object(value)
|
|
283
|
+
&& Object.keys(value).every(key => ['providerId', 'plan', 'observedAt', 'rateLimit',
|
|
284
|
+
'additionalRateLimits', 'rateLimitReachedType', 'rateLimitResetCreditsAvailableCount'].includes(key))
|
|
285
|
+
&& value.providerId === 'openai' && bounded(value.plan, 256) && iso(value.observedAt)
|
|
286
|
+
&& (value.rateLimit === undefined || usageDetails(value.rateLimit))
|
|
287
|
+
&& Array.isArray(value.additionalRateLimits) && value.additionalRateLimits.length <= 128
|
|
288
|
+
&& value.additionalRateLimits.every((item: unknown) => object(item)
|
|
289
|
+
&& Object.keys(item).every(key => ['limitName', 'meteredFeature', 'rateLimit'].includes(key))
|
|
290
|
+
&& bounded(item.limitName, 256) && bounded(item.meteredFeature, 256)
|
|
291
|
+
&& (item.rateLimit === undefined || usageDetails(item.rateLimit)))
|
|
292
|
+
&& (value.rateLimitReachedType === undefined || bounded(value.rateLimitReachedType, 256))
|
|
293
|
+
&& (value.rateLimitResetCreditsAvailableCount === undefined
|
|
294
|
+
|| (typeof value.rateLimitResetCreditsAvailableCount === 'number'
|
|
295
|
+
&& Number.isFinite(value.rateLimitResetCreditsAvailableCount)));
|
|
296
|
+
|
|
297
|
+
const usageStatusText = (value: unknown): boolean => typeof value === 'string' && value.length <= 500
|
|
298
|
+
&& !/[\u0000-\u001f\u007f-\u009f]/.test(value);
|
|
299
|
+
const usageClaudeStatus = (value: unknown): boolean => object(value)
|
|
300
|
+
&& exactKeys(value, ['plan', 'windows', 'facts', 'problems', 'rateLimit'])
|
|
301
|
+
&& (value.plan === null || (object(value.plan) && exactKeys(value.plan, ['name', 'source'])
|
|
302
|
+
&& usageStatusText(value.plan.name) && ['live', 'stored'].includes(String(value.plan.source))))
|
|
303
|
+
&& (value.windows === null || (Array.isArray(value.windows) && value.windows.length <= 128
|
|
304
|
+
&& value.windows.every((window: unknown) => object(window)
|
|
305
|
+
&& Object.keys(window).every(key => ['label', 'scope', 'durationSeconds', 'usedPercent',
|
|
306
|
+
'resetAt', 'severity', 'headline'].includes(key))
|
|
307
|
+
&& ['label', 'scope', 'durationSeconds', 'usedPercent', 'resetAt'].every(key => Object.hasOwn(window, key))
|
|
308
|
+
&& usageStatusText(window.label) && ['account', 'feature'].includes(String(window.scope))
|
|
309
|
+
&& Number.isSafeInteger(window.durationSeconds) && Number(window.durationSeconds) > 0
|
|
310
|
+
&& typeof window.usedPercent === 'number' && Number.isFinite(window.usedPercent)
|
|
311
|
+
&& window.usedPercent >= 0 && (window.resetAt === null || iso(window.resetAt))
|
|
312
|
+
&& (window.severity === undefined || ['normal', 'warning', 'critical'].includes(String(window.severity)))
|
|
313
|
+
&& (window.headline === undefined || window.headline === true))))
|
|
314
|
+
&& Array.isArray(value.facts) && value.facts.length <= 128
|
|
315
|
+
&& value.facts.every((fact: unknown) => object(fact)
|
|
316
|
+
&& Object.keys(fact).every(key => ['section', 'label', 'value', 'summaryKey'].includes(key))
|
|
317
|
+
&& ['section', 'label', 'value'].every(key => Object.hasOwn(fact, key))
|
|
318
|
+
&& (fact.section === null || usageStatusText(fact.section))
|
|
319
|
+
&& usageStatusText(fact.label) && usageStatusText(fact.value)
|
|
320
|
+
&& (fact.summaryKey === undefined || ['subscription', 'billing', 'usageWindows', 'resets',
|
|
321
|
+
'resetDetails'].includes(String(fact.summaryKey))))
|
|
322
|
+
&& Array.isArray(value.problems) && value.problems.length <= 32
|
|
323
|
+
&& value.problems.every(usageStatusText)
|
|
324
|
+
&& (value.rateLimit === null || (object(value.rateLimit)
|
|
325
|
+
&& exactKeys(value.rateLimit, ['retryAt'])
|
|
326
|
+
&& (value.rateLimit.retryAt === null || iso(value.rateLimit.retryAt))));
|
|
327
|
+
const usageReading = (value: unknown): boolean => object(value)
|
|
328
|
+
&& (value.kind === 'openai' ? exactKeys(value, ['kind', 'rateLimits']) && usageRateLimits(value.rateLimits)
|
|
329
|
+
: value.kind === 'anthropic' && exactKeys(value, ['kind', 'status'])
|
|
330
|
+
&& usageClaudeStatus(value.status));
|
|
331
|
+
|
|
332
|
+
export const assertStoredAuthorityUsage: (value: unknown) => asserts value is IStoredAuthorityUsage = value => {
|
|
333
|
+
if (!object(value) || !exactKeys(value, ['id', 'accountId', 'loginId', 'context', 'updateId',
|
|
334
|
+
'reading', 'observedAt', 'currentUntil', 'staleUntil', 'lastAttemptAt', 'nextAttemptAt',
|
|
335
|
+
'failures', 'problem']) || !hash(value.accountId) || !hash(value.loginId)
|
|
336
|
+
|| value.id !== authorityUsageId(value.accountId, value.loginId)
|
|
337
|
+
|| !object(value.context) || !exactKeys(value.context, ['epoch', 'accountId', 'loginId',
|
|
338
|
+
'subjectId', 'workspaceId', 'providerId', 'purpose', 'owner', 'grantState', 'removed',
|
|
339
|
+
'authorizationGeneration', 'grantGeneration', 'nativeSource'])
|
|
340
|
+
|| !uuid(value.context.epoch) || value.context.accountId !== value.accountId
|
|
341
|
+
|| value.context.loginId !== value.loginId || !bounded(value.context.subjectId)
|
|
342
|
+
|| !bounded(value.context.workspaceId)
|
|
343
|
+
|| !((value.context.providerId === 'openai' && value.context.purpose === 'openai_managed'
|
|
344
|
+
&& value.context.owner === 'daemon' && value.context.nativeSource === null
|
|
345
|
+
&& ['ready', 'retry_wait'].includes(String(value.context.grantState)))
|
|
346
|
+
|| (value.context.providerId === 'anthropic' && value.context.purpose === 'claude_host_native'
|
|
347
|
+
&& ((value.context.owner === 'daemon' && value.context.nativeSource === null
|
|
348
|
+
&& ['ready', 'retry_wait'].includes(String(value.context.grantState)))
|
|
349
|
+
|| (value.context.owner === 'claude_native' && value.context.grantState === 'native'
|
|
350
|
+
&& object(value.context.nativeSource)
|
|
351
|
+
&& exactKeys(value.context.nativeSource, ['homeId', 'credentialDigest',
|
|
352
|
+
'configDigest', 'accessTokenDigest'])
|
|
353
|
+
&& hash(value.context.nativeSource.homeId)
|
|
354
|
+
&& hash(value.context.nativeSource.credentialDigest)
|
|
355
|
+
&& hash(value.context.nativeSource.configDigest)
|
|
356
|
+
&& hash(value.context.nativeSource.accessTokenDigest)))))
|
|
357
|
+
|| value.context.removed !== false || !revision(value.context.authorizationGeneration)
|
|
358
|
+
|| !revision(value.context.grantGeneration) || !uuid(value.updateId)
|
|
359
|
+
|| (value.reading !== null && (!object(value.reading) || !usageReading(value.reading)
|
|
360
|
+
|| (value.context.providerId === 'openai' ? value.reading.kind !== 'openai'
|
|
361
|
+
: value.reading.kind !== 'anthropic')))
|
|
362
|
+
|| (value.observedAt !== null && !iso(value.observedAt))
|
|
363
|
+
|| (value.currentUntil !== null && !iso(value.currentUntil))
|
|
364
|
+
|| (value.staleUntil !== null && !iso(value.staleUntil))
|
|
365
|
+
|| !iso(value.lastAttemptAt) || !iso(value.nextAttemptAt)
|
|
366
|
+
|| !revision(value.failures) || value.failures > 16
|
|
367
|
+
|| !['none', 'unsupported', 'access_unavailable', 'provider_unavailable', 'provider_rejected',
|
|
368
|
+
'profile_unavailable', 'usage_unavailable'].includes(String(value.problem))) {
|
|
369
|
+
throw new Error('Invalid credential-free authority usage record.');
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
|
|
140
373
|
export const assertStoredAuthorityMeta: (value: unknown) => asserts value is IStoredAuthorityMeta = value => {
|
|
141
374
|
if (!object(value) || !exactKeys(value, ['id', 'epoch', 'revision', 'updateId'])
|
|
142
375
|
|| value.id !== 'authswitch-authority' || !uuid(value.epoch)
|
|
@@ -164,7 +397,7 @@ export const assertStoredAuthorityGrant: (value: unknown) => asserts value is IS
|
|
|
164
397
|
|| typeof value.providerId !== 'string' || !/^[a-z][a-z0-9-]{0,63}$/.test(value.providerId)
|
|
165
398
|
|| !['openai_managed', 'claude_host_native', 'claude_container_setup', 'opencode_native'].includes(String(value.purpose))
|
|
166
399
|
|| !bounded(value.audience)
|
|
167
|
-
|| !['ready', 'exchange_may_have_been_sent', 'retry_wait', 'needs_reauth', 'native', 'legacy_native_pending', 'removed'].includes(String(value.state))
|
|
400
|
+
|| !['ready', 'exchange_may_have_been_sent', 'retry_wait', 'needs_reauth', 'native', 'legacy_native_pending', 'handoff_pending', 'handoff_quarantined', 'removed'].includes(String(value.state))
|
|
168
401
|
|| !['daemon', 'claude_native', 'legacy_native', 'none'].includes(String(value.owner))
|
|
169
402
|
|| !revision(value.grantGeneration) || !revision(value.authorizationGeneration)
|
|
170
403
|
|| !revision(value.revision) || !ciphertext(value.ciphertext)
|
|
@@ -180,6 +413,13 @@ export const assertStoredAuthorityGrant: (value: unknown) => asserts value is IS
|
|
|
180
413
|
if ((value.state === 'retry_wait') !== (value.retryAt !== null)) throw new Error('Invalid refresh retry marker.');
|
|
181
414
|
if (value.state === 'removed' && (value.ciphertext !== null || value.owner !== 'none')) throw new Error('A removed grant was retained.');
|
|
182
415
|
if (value.state === 'legacy_native_pending' && value.owner !== 'legacy_native') throw new Error('A legacy native grant cannot be daemon-owned.');
|
|
416
|
+
if (['handoff_pending', 'handoff_quarantined'].includes(String(value.state))
|
|
417
|
+
&& value.purpose !== 'claude_host_native') throw new Error('Only a Claude host grant may enter native handoff.');
|
|
418
|
+
if (['handoff_pending', 'handoff_quarantined'].includes(String(value.state))
|
|
419
|
+
&& (value.owner === 'daemon' ? value.ciphertext === null
|
|
420
|
+
: value.owner !== 'claude_native' || value.ciphertext !== null)) {
|
|
421
|
+
throw new Error('Claude handoff grant has incompatible custody.');
|
|
422
|
+
}
|
|
183
423
|
if (value.purpose === 'openai_managed' && value.providerId !== 'openai') throw new Error('OpenAI grant provider mismatch.');
|
|
184
424
|
if (value.purpose === 'claude_container_setup' && value.owner === 'claude_native') throw new Error('Container setup grant has a native host owner.');
|
|
185
425
|
};
|
|
@@ -202,8 +442,8 @@ export const assertStoredAuthorityEnrollment: (value: unknown) => asserts value
|
|
|
202
442
|
};
|
|
203
443
|
|
|
204
444
|
export const assertStoredAuthorityCodexHome: (value: unknown) => asserts value is IStoredAuthorityCodexHome = value => {
|
|
205
|
-
if (!object(value) || !exactKeys(value, ['id', 'accountId', 'scopeId', 'activeRun', 'createdAt', 'updateId'])
|
|
206
|
-
|| !hash(value.id) || !hash(value.accountId) || !bounded(value.scopeId)
|
|
445
|
+
if (!object(value) || !exactKeys(value, ['id', 'accountId', 'grantId', 'scopeId', 'activeRun', 'createdAt', 'updateId'])
|
|
446
|
+
|| !hash(value.id) || !hash(value.accountId) || !hash(value.grantId) || !bounded(value.scopeId)
|
|
207
447
|
|| !iso(value.createdAt) || !uuid(value.updateId)) {
|
|
208
448
|
throw new Error('Invalid managed Codex home assignment.');
|
|
209
449
|
}
|
|
@@ -218,37 +458,90 @@ export const assertStoredAuthorityCodexHome: (value: unknown) => asserts value i
|
|
|
218
458
|
}
|
|
219
459
|
};
|
|
220
460
|
|
|
461
|
+
export const assertStoredAuthorityClaudeHome: (value: unknown) => asserts value is IStoredAuthorityClaudeHome = value => {
|
|
462
|
+
if (!object(value) || !exactKeys(value, ['id', 'activeAccountId', 'activeGrantId', 'pendingOperationId',
|
|
463
|
+
'status', 'revision', 'createdAt', 'updateId']) || !hash(value.id) || !hash(value.activeAccountId)
|
|
464
|
+
|| !hash(value.activeGrantId) || (value.pendingOperationId !== null && !uuid(value.pendingOperationId))
|
|
465
|
+
|| !['ready', 'quarantined'].includes(String(value.status)) || !revision(value.revision)
|
|
466
|
+
|| value.revision === 0 || !iso(value.createdAt) || !uuid(value.updateId)
|
|
467
|
+
|| (value.status === 'quarantined' && value.pendingOperationId === null)) {
|
|
468
|
+
throw new Error('Invalid Claude native home assignment.');
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
|
|
472
|
+
const nativePair = (value: unknown): value is IStoredAuthorityNativePair => object(value)
|
|
473
|
+
&& exactKeys(value, ['credentialDigest', 'configDigest'])
|
|
474
|
+
&& (value.credentialDigest === null || hash(value.credentialDigest))
|
|
475
|
+
&& (value.configDigest === null || hash(value.configDigest));
|
|
476
|
+
const nativeIdentity = (value: unknown): value is IStoredAuthorityNativeIdentity => object(value)
|
|
477
|
+
&& exactKeys(value, ['accountUuid', 'organizationUuid'])
|
|
478
|
+
&& bounded(value.accountUuid) && bounded(value.organizationUuid);
|
|
479
|
+
|
|
480
|
+
export const assertStoredAuthorityClaudeHandoff: (value: unknown) => asserts value is IStoredAuthorityClaudeHandoff = value => {
|
|
481
|
+
if (!object(value) || !exactKeys(value, ['id', 'homeId', 'outgoingAccountId', 'outgoingGrantId',
|
|
482
|
+
'incomingAccountId', 'incomingGrantId', 'phase', 'before', 'after', 'sourceIdentity',
|
|
483
|
+
'targetIdentity', 'sourceAccessDigest', 'targetAccessDigest', 'sealedOutgoing',
|
|
484
|
+
'runningEffectiveAuth', 'problem', 'startedAt', 'updatedAt', 'revision', 'updateId'])
|
|
485
|
+
|| !uuid(value.id) || !hash(value.homeId) || !hash(value.outgoingAccountId)
|
|
486
|
+
|| !hash(value.outgoingGrantId) || !hash(value.incomingAccountId) || !hash(value.incomingGrantId)
|
|
487
|
+
|| value.outgoingAccountId === value.incomingAccountId || value.outgoingGrantId === value.incomingGrantId
|
|
488
|
+
|| !['reserved', 'prepared', 'committed', 'aborted', 'quarantined'].includes(String(value.phase))
|
|
489
|
+
|| (value.before !== null && !nativePair(value.before)) || (value.after !== null && !nativePair(value.after))
|
|
490
|
+
|| !nativeIdentity(value.sourceIdentity) || !nativeIdentity(value.targetIdentity)
|
|
491
|
+
|| (value.sourceAccessDigest !== null && !hash(value.sourceAccessDigest))
|
|
492
|
+
|| (value.targetAccessDigest !== null && !hash(value.targetAccessDigest))
|
|
493
|
+
|| !ciphertext(value.sealedOutgoing)
|
|
494
|
+
|| ![null, 'no_scoped_sessions', 'unsupported_effective_auth'].includes(value.runningEffectiveAuth as null)
|
|
495
|
+
|| !['none', 'native_uncertain', 'foreign_or_torn', 'unsupported_effective_auth', 'database_uncertain'].includes(String(value.problem))
|
|
496
|
+
|| !iso(value.startedAt) || !iso(value.updatedAt) || !revision(value.revision)
|
|
497
|
+
|| value.revision === 0 || !uuid(value.updateId)) throw new Error('Invalid Claude native handoff.');
|
|
498
|
+
const hasProof = value.before !== null && value.after !== null
|
|
499
|
+
&& value.sourceAccessDigest !== null && value.targetAccessDigest !== null;
|
|
500
|
+
const hasNoProof = value.before === null && value.after === null
|
|
501
|
+
&& value.sourceAccessDigest === null && value.targetAccessDigest === null;
|
|
502
|
+
if ((value.phase === 'reserved' && (!hasNoProof || value.sealedOutgoing !== null))
|
|
503
|
+
|| (['prepared', 'committed'].includes(String(value.phase)) && !hasProof)
|
|
504
|
+
|| (['aborted', 'quarantined'].includes(String(value.phase)) && !hasProof && !hasNoProof)) {
|
|
505
|
+
throw new Error('Claude handoff phase lacks exact native proof.');
|
|
506
|
+
}
|
|
507
|
+
if (value.phase === 'prepared' && value.sealedOutgoing === null) throw new Error('Prepared Claude handoff lacks sealed outgoing grant.');
|
|
508
|
+
if (['committed', 'aborted'].includes(String(value.phase)) && value.sealedOutgoing !== null) {
|
|
509
|
+
throw new Error('Terminal Claude handoff retained a grant copy.');
|
|
510
|
+
}
|
|
511
|
+
};
|
|
512
|
+
|
|
221
513
|
export const assertStoredAuthorityHandoff: (value: unknown) => asserts value is IStoredAuthorityHandoff = value => {
|
|
222
514
|
if (!object(value) || !exactKeys(value, ['id', 'accountId', 'grantId', 'nativeHomeId', 'direction', 'phase',
|
|
223
|
-
'operationId', 'sourceDigest', 'verifiedSourceDigest', '
|
|
515
|
+
'operationId', 'sourceDigest', 'verifiedSourceDigest', 'revision', 'statusObservedAt', 'updateId'])
|
|
224
516
|
|| !hash(value.id) || !hash(value.accountId) || !hash(value.grantId) || !hash(value.nativeHomeId)
|
|
225
517
|
|| !['to_native', 'to_daemon'].includes(String(value.direction))
|
|
226
518
|
|| !['prepared', 'source_stopped', 'target_written', 'verified', 'committed', 'needs_reauth', 'aborted'].includes(String(value.phase))
|
|
227
519
|
|| !uuid(value.operationId) || !hash(value.sourceDigest)
|
|
228
520
|
|| (value.verifiedSourceDigest !== null && !hash(value.verifiedSourceDigest))
|
|
229
|
-
|| (value.backupDigest !== null && !hash(value.backupDigest))
|
|
230
521
|
|| !revision(value.revision) || !iso(value.statusObservedAt) || !uuid(value.updateId)) {
|
|
231
522
|
throw new Error('Invalid authswitch handoff record.');
|
|
232
523
|
}
|
|
233
|
-
if (['verified', 'committed'].includes(String(value.phase))
|
|
234
|
-
|
|
235
|
-
throw new Error('A verified native handoff requires source and backup proof.');
|
|
524
|
+
if (['verified', 'committed'].includes(String(value.phase)) && value.verifiedSourceDigest === null) {
|
|
525
|
+
throw new Error('A verified native handoff requires source proof.');
|
|
236
526
|
}
|
|
237
527
|
};
|
|
238
528
|
|
|
239
529
|
export const assertStoredAuthorityMigrationLedger: (value: unknown) => asserts value is IStoredAuthorityMigrationLedger = value => {
|
|
240
530
|
if (!object(value) || !exactKeys(value, ['id', 'version', 'sourceKind', 'sourcePathHash', 'sourceDigest',
|
|
241
|
-
'status', 'accountId', 'grantId', '
|
|
531
|
+
'status', 'accountId', 'grantId', 'revision', 'statusObservedAt', 'updateId'])
|
|
242
532
|
|| !hash(value.id) || !revision(value.version) || value.version === 0
|
|
243
533
|
|| !['authswitch_stash', 'authswitch_backup', 'agl_flex', 'codex_native', 'opencode_native', 'claude_native'].includes(String(value.sourceKind))
|
|
244
534
|
|| !hash(value.sourcePathHash) || !hash(value.sourceDigest)
|
|
245
535
|
|| !['pending_native_owner', 'prepared', 'verified', 'complete', 'quarantined'].includes(String(value.status))
|
|
246
536
|
|| (value.accountId !== null && !hash(value.accountId))
|
|
247
537
|
|| (value.grantId !== null && !hash(value.grantId))
|
|
248
|
-
|| (value.backupDigest !== null && !hash(value.backupDigest))
|
|
249
538
|
|| !revision(value.revision) || !iso(value.statusObservedAt) || !uuid(value.updateId)) {
|
|
250
539
|
throw new Error('Invalid authswitch migration ledger record.');
|
|
251
540
|
}
|
|
541
|
+
// Every row carries its source digest; a verified import additionally names the account and grant it produced.
|
|
542
|
+
if (['verified', 'complete'].includes(String(value.status)) && (value.accountId === null || value.grantId === null)) {
|
|
543
|
+
throw new Error('A verified migration requires the imported account and grant.');
|
|
544
|
+
}
|
|
252
545
|
};
|
|
253
546
|
|
|
254
547
|
export const assertStoredAuthorityEvent: (value: unknown) => asserts value is IStoredAuthorityEvent = value => {
|
|
@@ -257,151 +550,356 @@ export const assertStoredAuthorityEvent: (value: unknown) => asserts value is IS
|
|
|
257
550
|
|| !['account', 'binding'].includes(String(value.kind)) || !hash(value.accountId)) throw new Error('Invalid authswitch event record.');
|
|
258
551
|
};
|
|
259
552
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
553
|
+
const assertStoredAuthorityDeviceOperation: (value: unknown) => asserts value is IStoredAuthorityDeviceOperation = value => {
|
|
554
|
+
if (!object(value) || !exactKeys(value, ['id', 'kind', 'purpose', 'accountId', 'grantId',
|
|
555
|
+
'expectedGrantGeneration', 'state', 'prompt', 'result', 'error', 'commitId', 'createdAt',
|
|
556
|
+
'updatedAt', 'finishedAt', 'revision', 'updateId'])
|
|
557
|
+
|| !uuid(value.id) || !['add_openai', 'reauth_openai'].includes(String(value.kind))
|
|
558
|
+
|| value.purpose !== 'openai_managed'
|
|
559
|
+
|| (value.accountId !== null && !hash(value.accountId))
|
|
560
|
+
|| (value.grantId !== null && !hash(value.grantId))
|
|
561
|
+
|| (value.expectedGrantGeneration !== null && !revision(value.expectedGrantGeneration))
|
|
562
|
+
|| !['starting', 'pending', 'committing', 'complete', 'failed', 'cancelled', 'interrupted', 'outcome_unknown'].includes(String(value.state))
|
|
563
|
+
|| (value.commitId !== null && !uuid(value.commitId))
|
|
564
|
+
|| !iso(value.createdAt) || !iso(value.updatedAt)
|
|
565
|
+
|| (value.finishedAt !== null && !iso(value.finishedAt))
|
|
566
|
+
|| !revision(value.revision) || value.revision === 0 || !uuid(value.updateId)) {
|
|
567
|
+
throw new Error('Invalid authswitch operation record.');
|
|
568
|
+
}
|
|
569
|
+
if (value.kind === 'add_openai'
|
|
570
|
+
? value.accountId !== null || value.grantId !== null || value.expectedGrantGeneration !== null
|
|
571
|
+
: value.accountId === null || value.grantId === null || value.expectedGrantGeneration === null) {
|
|
572
|
+
throw new Error('Invalid authswitch operation target.');
|
|
573
|
+
}
|
|
574
|
+
if (value.prompt !== null && (!object(value.prompt)
|
|
575
|
+
|| (value.prompt.flow === 'device'
|
|
576
|
+
? !exactKeys(value.prompt, ['flow', 'verificationUrl', 'userCode'])
|
|
577
|
+
|| !bounded(value.prompt.verificationUrl, 2048) || !bounded(value.prompt.userCode, 128)
|
|
578
|
+
: value.prompt.flow === 'browser'
|
|
579
|
+
? !exactKeys(value.prompt, ['flow', 'authUrl']) || !bounded(value.prompt.authUrl, 2048)
|
|
580
|
+
: true))) throw new Error('Invalid authswitch operation prompt.');
|
|
581
|
+
if (value.result !== null && (!object(value.result)
|
|
582
|
+
|| !exactKeys(value.result, ['accountId', 'grantId', 'accountRevision', 'grantGeneration'])
|
|
583
|
+
|| !hash(value.result.accountId) || !hash(value.result.grantId)
|
|
584
|
+
|| !revision(value.result.accountRevision) || !revision(value.result.grantGeneration))) {
|
|
585
|
+
throw new Error('Invalid authswitch operation result.');
|
|
586
|
+
}
|
|
587
|
+
if (value.error !== null && !bounded(value.error, 512)) throw new Error('Invalid authswitch operation error.');
|
|
588
|
+
if (['starting', 'pending', 'committing'].includes(String(value.state))) {
|
|
589
|
+
if (value.finishedAt !== null || value.result !== null || value.error !== null
|
|
590
|
+
|| (value.state === 'pending') !== (value.prompt !== null)
|
|
591
|
+
|| (value.state === 'committing') !== (value.commitId !== null)) {
|
|
592
|
+
throw new Error('Invalid pending authswitch operation.');
|
|
593
|
+
}
|
|
594
|
+
} else if (value.finishedAt === null || value.prompt !== null
|
|
595
|
+
|| (value.state === 'complete' ? value.result === null || value.error !== null || value.commitId === null
|
|
596
|
+
: value.result !== null || value.error === null)) {
|
|
597
|
+
throw new Error('Invalid terminal authswitch operation.');
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
|
|
601
|
+
const modelId = (value: unknown): value is string => typeof value === 'string'
|
|
602
|
+
&& /^[a-zA-Z0-9][a-zA-Z0-9._:/-]{0,127}$/.test(value);
|
|
603
|
+
const tokenCount = (value: unknown): value is number | null => value === null
|
|
604
|
+
|| (Number.isSafeInteger(value) && Number(value) >= 0);
|
|
605
|
+
|
|
606
|
+
const assertStoredAuthorityPreuseOperation: (value: unknown) => asserts value is IStoredAuthorityPreuseOperation = value => {
|
|
607
|
+
if (!object(value) || !exactKeys(value, ['id', 'kind', 'purpose', 'accountId', 'grantId', 'requestHash',
|
|
608
|
+
'requestedModel', 'model', 'authorizationGeneration', 'grantGeneration', 'state', 'result', 'problem',
|
|
609
|
+
'createdAt', 'updatedAt', 'finishedAt', 'revision', 'updateId'])
|
|
610
|
+
|| !uuid(value.id) || value.kind !== 'preuse_openai' || value.purpose !== 'openai_managed'
|
|
611
|
+
|| !hash(value.accountId) || !hash(value.grantId) || !hash(value.requestHash)
|
|
612
|
+
|| (value.requestedModel !== null && !modelId(value.requestedModel))
|
|
613
|
+
|| (value.model !== null && !modelId(value.model))
|
|
614
|
+
|| !revision(value.authorizationGeneration) || value.authorizationGeneration === 0
|
|
615
|
+
|| (value.grantGeneration !== null && (!revision(value.grantGeneration) || value.grantGeneration === 0))
|
|
616
|
+
|| !['preparing', 'request_may_have_started', 'complete', 'not_sent', 'outcome_unknown'].includes(String(value.state))
|
|
617
|
+
|| !['none', 'target_unavailable', 'access_unavailable', 'catalog_unavailable', 'account_busy', 'cancelled',
|
|
618
|
+
'authority_closing', 'interrupted', 'request_uncertain'].includes(String(value.problem))
|
|
619
|
+
|| !iso(value.createdAt) || !iso(value.updatedAt)
|
|
620
|
+
|| (value.finishedAt !== null && !iso(value.finishedAt))
|
|
621
|
+
|| !revision(value.revision) || value.revision === 0 || !uuid(value.updateId)) {
|
|
622
|
+
throw new Error('Invalid authswitch preuse operation record.');
|
|
623
|
+
}
|
|
624
|
+
if (value.result !== null && (!object(value.result)
|
|
625
|
+
|| !exactKeys(value.result, ['inputTokens', 'outputTokens', 'totalTokens'])
|
|
626
|
+
|| !tokenCount(value.result.inputTokens) || !tokenCount(value.result.outputTokens)
|
|
627
|
+
|| !tokenCount(value.result.totalTokens))) {
|
|
628
|
+
throw new Error('Invalid authswitch preuse operation result.');
|
|
629
|
+
}
|
|
630
|
+
if (value.state === 'preparing') {
|
|
631
|
+
if (value.model !== null || value.grantGeneration !== null || value.result !== null
|
|
632
|
+
|| value.problem !== 'none' || value.finishedAt !== null) {
|
|
633
|
+
throw new Error('Invalid preparing authswitch preuse operation.');
|
|
634
|
+
}
|
|
635
|
+
} else if (value.state === 'request_may_have_started') {
|
|
636
|
+
if (value.model === null || value.grantGeneration === null || value.result !== null
|
|
637
|
+
|| value.problem !== 'none' || value.finishedAt !== null) {
|
|
638
|
+
throw new Error('Invalid active authswitch preuse operation.');
|
|
639
|
+
}
|
|
640
|
+
} else if (value.state === 'complete') {
|
|
641
|
+
if (value.model === null || value.grantGeneration === null || value.result === null
|
|
642
|
+
|| value.problem !== 'none' || value.finishedAt === null) {
|
|
643
|
+
throw new Error('Invalid completed authswitch preuse operation.');
|
|
644
|
+
}
|
|
645
|
+
} else if (value.state === 'not_sent') {
|
|
646
|
+
if (value.model !== null || value.grantGeneration !== null || value.result !== null
|
|
647
|
+
|| value.problem === 'none' || value.problem === 'request_uncertain' || value.finishedAt === null) {
|
|
648
|
+
throw new Error('Invalid unsent authswitch preuse operation.');
|
|
649
|
+
}
|
|
650
|
+
} else if (value.result !== null || value.finishedAt === null || value.model === null
|
|
651
|
+
|| value.grantGeneration === null
|
|
652
|
+
|| !['cancelled', 'authority_closing', 'request_uncertain'].includes(String(value.problem))) {
|
|
653
|
+
throw new Error('Invalid uncertain authswitch preuse operation.');
|
|
654
|
+
}
|
|
655
|
+
};
|
|
656
|
+
|
|
657
|
+
export const assertStoredAuthorityOperation: (value: unknown) => asserts value is IStoredAuthorityOperation = value => {
|
|
658
|
+
if (object(value) && value.kind === 'preuse_openai') assertStoredAuthorityPreuseOperation(value);
|
|
659
|
+
else assertStoredAuthorityDeviceOperation(value);
|
|
660
|
+
};
|
|
661
|
+
export const assertStoredAuthorityOperationDocument: (value: unknown) => asserts value is IStoredAuthorityOperationDocument = value => {
|
|
662
|
+
assertStoredAuthorityOperation(value);
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_meta' })
|
|
666
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityMeta })
|
|
667
|
+
export class AuthSwitchAuthorityMetaModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityMetaModel, IStoredAuthorityMeta> {
|
|
668
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityMetaModel>;
|
|
669
|
+
@plugins.nosqldb.unI() public id!: 'authswitch-authority';
|
|
670
|
+
@plugins.nosqldb.svDb() public epoch!: string;
|
|
671
|
+
@plugins.nosqldb.svDb() public revision!: number;
|
|
672
|
+
@plugins.nosqldb.svDb() public updateId!: string;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_account_provider_id', key: { providerId: 1, id: 1 } })
|
|
676
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_accounts' })
|
|
677
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityAccount })
|
|
678
|
+
export class AuthSwitchAuthorityAccountModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityAccountModel, IStoredAuthorityAccount> {
|
|
679
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityAccountModel>;
|
|
680
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
681
|
+
@plugins.nosqldb.svDb() public providerId!: string;
|
|
682
|
+
@plugins.nosqldb.svDb() public issuer!: string;
|
|
683
|
+
@plugins.nosqldb.svDb() public subject!: string;
|
|
684
|
+
@plugins.nosqldb.svDb() public workspaceId!: string;
|
|
685
|
+
@plugins.nosqldb.svDb() public label!: string;
|
|
686
|
+
@plugins.nosqldb.svDb() public email!: string | null;
|
|
687
|
+
@plugins.nosqldb.svDb() public plan!: string | null;
|
|
688
|
+
@plugins.nosqldb.svDb() public primaryGrantId!: string | null;
|
|
689
|
+
@plugins.nosqldb.svDb() public removed!: boolean;
|
|
690
|
+
@plugins.nosqldb.svDb() public revision!: number;
|
|
691
|
+
@plugins.nosqldb.svDb() public statusObservedAt!: string;
|
|
692
|
+
@plugins.nosqldb.svDb() public updateId!: string;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_grant_state_id', key: { state: 1, id: 1 } })
|
|
696
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_grant_account_id', key: { accountId: 1, id: 1 } })
|
|
697
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_grants' })
|
|
698
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityGrant })
|
|
699
|
+
export class AuthSwitchAuthorityGrantModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityGrantModel, IStoredAuthorityGrant> {
|
|
700
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityGrantModel>;
|
|
701
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
702
|
+
@plugins.nosqldb.svDb() public accountId!: string;
|
|
703
|
+
@plugins.nosqldb.svDb() public providerId!: string;
|
|
704
|
+
@plugins.nosqldb.svDb() public purpose!: TStoredGrantPurpose;
|
|
705
|
+
@plugins.nosqldb.svDb() public audience!: string;
|
|
706
|
+
@plugins.nosqldb.svDb() public state!: IStoredAuthorityGrant['state'];
|
|
707
|
+
@plugins.nosqldb.svDb() public owner!: IStoredAuthorityGrant['owner'];
|
|
708
|
+
@plugins.nosqldb.svDb() public grantGeneration!: number;
|
|
709
|
+
@plugins.nosqldb.svDb() public authorizationGeneration!: number;
|
|
710
|
+
@plugins.nosqldb.svDb() public revision!: number;
|
|
711
|
+
@plugins.nosqldb.svDb() public ciphertext!: string | null;
|
|
712
|
+
@plugins.nosqldb.svDb() public accessExpiresAt!: string | null;
|
|
713
|
+
@plugins.nosqldb.svDb() public attemptId!: string | null;
|
|
714
|
+
@plugins.nosqldb.svDb() public retryAt!: string | null;
|
|
715
|
+
@plugins.nosqldb.svDb() public retryCount!: number;
|
|
716
|
+
@plugins.nosqldb.svDb() public problem!: IStoredAuthorityGrant['problem'];
|
|
717
|
+
@plugins.nosqldb.svDb() public statusObservedAt!: string;
|
|
718
|
+
@plugins.nosqldb.svDb() public updateId!: string;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_usage_account_login', key: { accountId: 1, loginId: 1 }, options: { unique: true } })
|
|
722
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_usage' })
|
|
723
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityUsage })
|
|
724
|
+
export class AuthSwitchAuthorityUsageModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityUsageModel, IStoredAuthorityUsage> {
|
|
725
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityUsageModel>;
|
|
726
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
727
|
+
@plugins.nosqldb.svDb() public accountId!: string;
|
|
728
|
+
@plugins.nosqldb.svDb() public loginId!: string;
|
|
729
|
+
@plugins.nosqldb.svDb() public context!: IAuthSwitchStoredUsage['context'];
|
|
730
|
+
@plugins.nosqldb.svDb() public updateId!: string;
|
|
731
|
+
@plugins.nosqldb.svDb() public reading!: IAuthSwitchStoredUsage['reading'];
|
|
732
|
+
@plugins.nosqldb.svDb() public observedAt!: string | null;
|
|
733
|
+
@plugins.nosqldb.svDb() public currentUntil!: string | null;
|
|
734
|
+
@plugins.nosqldb.svDb() public staleUntil!: string | null;
|
|
735
|
+
@plugins.nosqldb.svDb() public lastAttemptAt!: string;
|
|
736
|
+
@plugins.nosqldb.svDb() public nextAttemptAt!: string;
|
|
737
|
+
@plugins.nosqldb.svDb() public failures!: number;
|
|
738
|
+
@plugins.nosqldb.svDb() public problem!: IAuthSwitchStoredUsage['problem'];
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_binding_account_id', key: { accountId: 1, id: 1 } })
|
|
742
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_bindings' })
|
|
743
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityBinding })
|
|
744
|
+
export class AuthSwitchAuthorityBindingModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityBindingModel, IStoredAuthorityBinding> {
|
|
745
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityBindingModel>;
|
|
746
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
747
|
+
@plugins.nosqldb.svDb() public accountId!: string;
|
|
748
|
+
@plugins.nosqldb.svDb() public grantId!: string;
|
|
749
|
+
@plugins.nosqldb.svDb() public runtime!: IStoredAuthorityBinding['runtime'];
|
|
750
|
+
@plugins.nosqldb.svDb() public scopeId!: string;
|
|
751
|
+
@plugins.nosqldb.svDb() public incarnationId!: string;
|
|
752
|
+
@plugins.nosqldb.svDb() public revision!: number;
|
|
753
|
+
@plugins.nosqldb.svDb() public grantAuthorizationGeneration!: number;
|
|
754
|
+
@plugins.nosqldb.svDb() public capabilityHash!: string;
|
|
755
|
+
@plugins.nosqldb.svDb() public updateId!: string;
|
|
268
756
|
}
|
|
269
757
|
|
|
270
|
-
@plugins.
|
|
271
|
-
@plugins.
|
|
272
|
-
@plugins.
|
|
273
|
-
export class
|
|
274
|
-
declare static exact: plugins.
|
|
275
|
-
@plugins.
|
|
276
|
-
@plugins.
|
|
277
|
-
@plugins.
|
|
278
|
-
@plugins.
|
|
279
|
-
@plugins.
|
|
280
|
-
@plugins.smartdata.svDb() public label!: string;
|
|
281
|
-
@plugins.smartdata.svDb() public email!: string | null;
|
|
282
|
-
@plugins.smartdata.svDb() public plan!: string | null;
|
|
283
|
-
@plugins.smartdata.svDb() public primaryGrantId!: string | null;
|
|
284
|
-
@plugins.smartdata.svDb() public removed!: boolean;
|
|
285
|
-
@plugins.smartdata.svDb() public revision!: number;
|
|
286
|
-
@plugins.smartdata.svDb() public statusObservedAt!: string;
|
|
287
|
-
@plugins.smartdata.svDb() public updateId!: string;
|
|
758
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_enrollment_account_id', key: { accountId: 1, id: 1 } })
|
|
759
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_enrollments' })
|
|
760
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityEnrollment })
|
|
761
|
+
export class AuthSwitchAuthorityEnrollmentModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityEnrollmentModel, IStoredAuthorityEnrollment> {
|
|
762
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityEnrollmentModel>;
|
|
763
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
764
|
+
@plugins.nosqldb.svDb() public accountId!: string;
|
|
765
|
+
@plugins.nosqldb.svDb() public ciphertext!: string;
|
|
766
|
+
@plugins.nosqldb.svDb() public revision!: number;
|
|
767
|
+
@plugins.nosqldb.svDb() public updateId!: string;
|
|
288
768
|
}
|
|
289
769
|
|
|
290
|
-
@plugins.
|
|
291
|
-
@plugins.
|
|
292
|
-
@plugins.
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
@plugins.
|
|
297
|
-
@plugins.
|
|
298
|
-
@plugins.
|
|
299
|
-
@plugins.
|
|
300
|
-
@plugins.
|
|
301
|
-
@plugins.
|
|
302
|
-
@plugins.smartdata.svDb() public owner!: IStoredAuthorityGrant['owner'];
|
|
303
|
-
@plugins.smartdata.svDb() public grantGeneration!: number;
|
|
304
|
-
@plugins.smartdata.svDb() public authorizationGeneration!: number;
|
|
305
|
-
@plugins.smartdata.svDb() public revision!: number;
|
|
306
|
-
@plugins.smartdata.svDb() public ciphertext!: string | null;
|
|
307
|
-
@plugins.smartdata.svDb() public accessExpiresAt!: string | null;
|
|
308
|
-
@plugins.smartdata.svDb() public attemptId!: string | null;
|
|
309
|
-
@plugins.smartdata.svDb() public retryAt!: string | null;
|
|
310
|
-
@plugins.smartdata.svDb() public retryCount!: number;
|
|
311
|
-
@plugins.smartdata.svDb() public problem!: IStoredAuthorityGrant['problem'];
|
|
312
|
-
@plugins.smartdata.svDb() public statusObservedAt!: string;
|
|
313
|
-
@plugins.smartdata.svDb() public updateId!: string;
|
|
770
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_codex_home_account_id', key: { accountId: 1, id: 1 } })
|
|
771
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_codex_homes' })
|
|
772
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityCodexHome })
|
|
773
|
+
export class AuthSwitchAuthorityCodexHomeModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityCodexHomeModel, IStoredAuthorityCodexHome> {
|
|
774
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityCodexHomeModel>;
|
|
775
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
776
|
+
@plugins.nosqldb.svDb() public accountId!: string;
|
|
777
|
+
@plugins.nosqldb.svDb() public grantId!: string;
|
|
778
|
+
@plugins.nosqldb.svDb() public scopeId!: string;
|
|
779
|
+
@plugins.nosqldb.svDb() public activeRun!: IStoredAuthorityCodexHome['activeRun'];
|
|
780
|
+
@plugins.nosqldb.svDb() public createdAt!: string;
|
|
781
|
+
@plugins.nosqldb.svDb() public updateId!: string;
|
|
314
782
|
}
|
|
315
783
|
|
|
316
|
-
@plugins.
|
|
317
|
-
@plugins.
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
@plugins.
|
|
322
|
-
@plugins.
|
|
323
|
-
@plugins.
|
|
324
|
-
@plugins.
|
|
325
|
-
@plugins.
|
|
326
|
-
@plugins.
|
|
327
|
-
@plugins.
|
|
328
|
-
@plugins.smartdata.svDb() public grantAuthorizationGeneration!: number;
|
|
329
|
-
@plugins.smartdata.svDb() public capabilityHash!: string;
|
|
330
|
-
@plugins.smartdata.svDb() public updateId!: string;
|
|
784
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_claude_homes' })
|
|
785
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityClaudeHome })
|
|
786
|
+
export class AuthSwitchAuthorityClaudeHomeModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityClaudeHomeModel, IStoredAuthorityClaudeHome> {
|
|
787
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityClaudeHomeModel>;
|
|
788
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
789
|
+
@plugins.nosqldb.svDb() public activeAccountId!: string;
|
|
790
|
+
@plugins.nosqldb.index({ unique: true }) public activeGrantId!: string;
|
|
791
|
+
@plugins.nosqldb.svDb() public pendingOperationId!: string | null;
|
|
792
|
+
@plugins.nosqldb.svDb() public status!: IStoredAuthorityClaudeHome['status'];
|
|
793
|
+
@plugins.nosqldb.svDb() public revision!: number;
|
|
794
|
+
@plugins.nosqldb.svDb() public createdAt!: string;
|
|
795
|
+
@plugins.nosqldb.svDb() public updateId!: string;
|
|
331
796
|
}
|
|
332
797
|
|
|
333
|
-
@plugins.
|
|
334
|
-
@plugins.
|
|
335
|
-
@plugins.
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
@plugins.
|
|
340
|
-
@plugins.
|
|
341
|
-
@plugins.
|
|
342
|
-
@plugins.
|
|
798
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_claude_handoff_home_phase', key: { homeId: 1, phase: 1, id: 1 } })
|
|
799
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_claude_handoff_phase_id', key: { phase: 1, id: 1 } })
|
|
800
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_claude_handoffs' })
|
|
801
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityClaudeHandoff })
|
|
802
|
+
export class AuthSwitchAuthorityClaudeHandoffModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityClaudeHandoffModel, IStoredAuthorityClaudeHandoff> {
|
|
803
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityClaudeHandoffModel>;
|
|
804
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
805
|
+
@plugins.nosqldb.svDb() public homeId!: string;
|
|
806
|
+
@plugins.nosqldb.svDb() public outgoingAccountId!: string;
|
|
807
|
+
@plugins.nosqldb.svDb() public outgoingGrantId!: string;
|
|
808
|
+
@plugins.nosqldb.svDb() public incomingAccountId!: string;
|
|
809
|
+
@plugins.nosqldb.svDb() public incomingGrantId!: string;
|
|
810
|
+
@plugins.nosqldb.svDb() public phase!: IStoredAuthorityClaudeHandoff['phase'];
|
|
811
|
+
@plugins.nosqldb.svDb() public before!: IStoredAuthorityNativePair | null;
|
|
812
|
+
@plugins.nosqldb.svDb() public after!: IStoredAuthorityNativePair | null;
|
|
813
|
+
@plugins.nosqldb.svDb() public sourceIdentity!: IStoredAuthorityNativeIdentity;
|
|
814
|
+
@plugins.nosqldb.svDb() public targetIdentity!: IStoredAuthorityNativeIdentity;
|
|
815
|
+
@plugins.nosqldb.svDb() public sourceAccessDigest!: string | null;
|
|
816
|
+
@plugins.nosqldb.svDb() public targetAccessDigest!: string | null;
|
|
817
|
+
@plugins.nosqldb.svDb() public sealedOutgoing!: string | null;
|
|
818
|
+
@plugins.nosqldb.svDb() public runningEffectiveAuth!: IStoredAuthorityClaudeHandoff['runningEffectiveAuth'];
|
|
819
|
+
@plugins.nosqldb.svDb() public problem!: IStoredAuthorityClaudeHandoff['problem'];
|
|
820
|
+
@plugins.nosqldb.svDb() public startedAt!: string;
|
|
821
|
+
@plugins.nosqldb.svDb() public updatedAt!: string;
|
|
822
|
+
@plugins.nosqldb.svDb() public revision!: number;
|
|
823
|
+
@plugins.nosqldb.svDb() public updateId!: string;
|
|
343
824
|
}
|
|
344
825
|
|
|
345
|
-
@plugins.
|
|
346
|
-
@plugins.
|
|
347
|
-
@plugins.
|
|
348
|
-
export class
|
|
349
|
-
declare static exact: plugins.
|
|
350
|
-
@plugins.
|
|
351
|
-
@plugins.
|
|
352
|
-
@plugins.
|
|
353
|
-
@plugins.
|
|
354
|
-
@plugins.
|
|
355
|
-
@plugins.
|
|
826
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_handoff_grant_id', key: { grantId: 1, id: 1 } })
|
|
827
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_handoffs' })
|
|
828
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityHandoff })
|
|
829
|
+
export class AuthSwitchAuthorityHandoffModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityHandoffModel, IStoredAuthorityHandoff> {
|
|
830
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityHandoffModel>;
|
|
831
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
832
|
+
@plugins.nosqldb.svDb() public accountId!: string;
|
|
833
|
+
@plugins.nosqldb.svDb() public grantId!: string;
|
|
834
|
+
@plugins.nosqldb.svDb() public nativeHomeId!: string;
|
|
835
|
+
@plugins.nosqldb.svDb() public direction!: IStoredAuthorityHandoff['direction'];
|
|
836
|
+
@plugins.nosqldb.svDb() public phase!: IStoredAuthorityHandoff['phase'];
|
|
837
|
+
@plugins.nosqldb.svDb() public operationId!: string;
|
|
838
|
+
@plugins.nosqldb.svDb() public sourceDigest!: string;
|
|
839
|
+
@plugins.nosqldb.svDb() public verifiedSourceDigest!: string | null;
|
|
840
|
+
@plugins.nosqldb.svDb() public revision!: number;
|
|
841
|
+
@plugins.nosqldb.svDb() public statusObservedAt!: string;
|
|
842
|
+
@plugins.nosqldb.svDb() public updateId!: string;
|
|
356
843
|
}
|
|
357
844
|
|
|
358
|
-
@plugins.
|
|
359
|
-
@plugins.
|
|
360
|
-
@plugins.
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
@plugins.
|
|
365
|
-
@plugins.
|
|
366
|
-
@plugins.
|
|
367
|
-
@plugins.
|
|
368
|
-
@plugins.
|
|
369
|
-
@plugins.
|
|
370
|
-
@plugins.
|
|
371
|
-
@plugins.
|
|
372
|
-
@plugins.
|
|
373
|
-
@plugins.
|
|
374
|
-
@plugins.
|
|
375
|
-
@plugins.smartdata.svDb() public updateId!: string;
|
|
845
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_migration_status_id', key: { status: 1, id: 1 } })
|
|
846
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_migration_grant_status_id', key: { grantId: 1, status: 1, id: 1 } })
|
|
847
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_migration_ledger' })
|
|
848
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityMigrationLedger })
|
|
849
|
+
export class AuthSwitchAuthorityMigrationLedgerModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityMigrationLedgerModel, IStoredAuthorityMigrationLedger> {
|
|
850
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityMigrationLedgerModel>;
|
|
851
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
852
|
+
@plugins.nosqldb.svDb() public version!: number;
|
|
853
|
+
@plugins.nosqldb.svDb() public sourceKind!: IStoredAuthorityMigrationLedger['sourceKind'];
|
|
854
|
+
@plugins.nosqldb.svDb() public sourcePathHash!: string;
|
|
855
|
+
@plugins.nosqldb.svDb() public sourceDigest!: string;
|
|
856
|
+
@plugins.nosqldb.svDb() public status!: IStoredAuthorityMigrationLedger['status'];
|
|
857
|
+
@plugins.nosqldb.svDb() public accountId!: string | null;
|
|
858
|
+
@plugins.nosqldb.svDb() public grantId!: string | null;
|
|
859
|
+
@plugins.nosqldb.svDb() public revision!: number;
|
|
860
|
+
@plugins.nosqldb.svDb() public statusObservedAt!: string;
|
|
861
|
+
@plugins.nosqldb.svDb() public updateId!: string;
|
|
376
862
|
}
|
|
377
863
|
|
|
378
|
-
@plugins.
|
|
379
|
-
@plugins.
|
|
380
|
-
@plugins.
|
|
381
|
-
export class
|
|
382
|
-
declare static exact: plugins.
|
|
383
|
-
@plugins.
|
|
384
|
-
@plugins.
|
|
385
|
-
@plugins.
|
|
386
|
-
@plugins.
|
|
387
|
-
@plugins.
|
|
388
|
-
@plugins.smartdata.svDb() public status!: IStoredAuthorityMigrationLedger['status'];
|
|
389
|
-
@plugins.smartdata.svDb() public accountId!: string | null;
|
|
390
|
-
@plugins.smartdata.svDb() public grantId!: string | null;
|
|
391
|
-
@plugins.smartdata.svDb() public backupDigest!: string | null;
|
|
392
|
-
@plugins.smartdata.svDb() public revision!: number;
|
|
393
|
-
@plugins.smartdata.svDb() public statusObservedAt!: string;
|
|
394
|
-
@plugins.smartdata.svDb() public updateId!: string;
|
|
864
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_event_revision_id', key: { revision: 1, id: 1 } })
|
|
865
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_events' })
|
|
866
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityEvent })
|
|
867
|
+
export class AuthSwitchAuthorityEventModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityEventModel, IStoredAuthorityEvent> {
|
|
868
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityEventModel>;
|
|
869
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
870
|
+
@plugins.nosqldb.svDb() public epoch!: string;
|
|
871
|
+
@plugins.nosqldb.svDb() public revision!: number;
|
|
872
|
+
@plugins.nosqldb.svDb() public kind!: IStoredAuthorityEvent['kind'];
|
|
873
|
+
@plugins.nosqldb.svDb() public accountId!: string;
|
|
395
874
|
}
|
|
396
875
|
|
|
397
|
-
@plugins.
|
|
398
|
-
@plugins.
|
|
399
|
-
@plugins.
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
@plugins.
|
|
405
|
-
@plugins.
|
|
406
|
-
@plugins.
|
|
876
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_operation_state_id', key: { state: 1, id: 1 } })
|
|
877
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_operation_account_id', key: { accountId: 1, id: 1 } })
|
|
878
|
+
@plugins.nosqldb.compoundIndex({ name: 'authority_operation_kind_id', key: { kind: 1, id: 1 } })
|
|
879
|
+
@plugins.nosqldb.managed({ collectionName: 'authswitch_authority_operations' })
|
|
880
|
+
@plugins.nosqldb.exactPersistence({ assertDocument: assertStoredAuthorityOperationDocument })
|
|
881
|
+
export class AuthSwitchAuthorityOperationModel extends plugins.nosqldb.SmartDataDbDoc<AuthSwitchAuthorityOperationModel, IStoredAuthorityOperationDocument> {
|
|
882
|
+
declare static exact: plugins.nosqldb.TExact<AuthSwitchAuthorityOperationModel>;
|
|
883
|
+
@plugins.nosqldb.unI() public id!: string;
|
|
884
|
+
@plugins.nosqldb.svDb() public kind!: IStoredAuthorityOperationDocument['kind'];
|
|
885
|
+
@plugins.nosqldb.svDb() public purpose!: IStoredAuthorityOperation['purpose'];
|
|
886
|
+
@plugins.nosqldb.svDb() public accountId!: string | null;
|
|
887
|
+
@plugins.nosqldb.svDb() public grantId!: string | null;
|
|
888
|
+
@plugins.nosqldb.svDb() public expectedGrantGeneration?: number | null;
|
|
889
|
+
@plugins.nosqldb.svDb() public state!: IStoredAuthorityOperationDocument['state'];
|
|
890
|
+
@plugins.nosqldb.svDb() public prompt?: TAuthSwitchLoginPrompt | null;
|
|
891
|
+
@plugins.nosqldb.svDb() public result!: IStoredAuthorityOperationDocument['result'];
|
|
892
|
+
@plugins.nosqldb.svDb() public error?: string | null;
|
|
893
|
+
@plugins.nosqldb.svDb() public commitId?: string | null;
|
|
894
|
+
@plugins.nosqldb.svDb() public requestHash?: string;
|
|
895
|
+
@plugins.nosqldb.svDb() public requestedModel?: string | null;
|
|
896
|
+
@plugins.nosqldb.svDb() public model?: string | null;
|
|
897
|
+
@plugins.nosqldb.svDb() public authorizationGeneration?: number;
|
|
898
|
+
@plugins.nosqldb.svDb() public grantGeneration?: number | null;
|
|
899
|
+
@plugins.nosqldb.svDb() public problem?: TStoredAuthorityPreuseProblem;
|
|
900
|
+
@plugins.nosqldb.svDb() public createdAt!: string;
|
|
901
|
+
@plugins.nosqldb.svDb() public updatedAt!: string;
|
|
902
|
+
@plugins.nosqldb.svDb() public finishedAt!: string | null;
|
|
903
|
+
@plugins.nosqldb.svDb() public revision!: number;
|
|
904
|
+
@plugins.nosqldb.svDb() public updateId!: string;
|
|
407
905
|
}
|