@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,8 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import { type IStoredAuthorityAccount, type IStoredAuthorityBinding, type IStoredAuthorityClaudeHandoff, type IStoredAuthorityClaudeHome, type IStoredAuthorityCodexHome, type IStoredAuthorityEnrollment, type IStoredAuthorityEvent, type IStoredAuthorityGrant, type IStoredAuthorityHandoff, type IStoredAuthorityDeviceOperation, type IStoredAuthorityMeta, type IStoredAuthorityMigrationLedger, type IStoredAuthorityOperation, type IStoredAuthorityPreuseOperation } from './classes.authoritymodels.js';
|
|
3
|
+
import type { IAuthSwitchStoredUsage, IAuthSwitchUsageContext } from './classes.authorityusage.js';
|
|
2
4
|
export interface IAuthSwitchAuthorityDatabaseOptions {
|
|
3
5
|
dataDirectory: string;
|
|
4
6
|
socketPath: string;
|
|
5
7
|
}
|
|
8
|
+
type TSession = plugins.nosqldb.SmartdataSession;
|
|
9
|
+
type TStoredAuthorityDeviceOperationAdmission = Omit<IStoredAuthorityDeviceOperation, 'expectedGrantGeneration'>;
|
|
10
|
+
type TClaudeHandoffDraft = {
|
|
11
|
+
home: IStoredAuthorityClaudeHome;
|
|
12
|
+
handoff: IStoredAuthorityClaudeHandoff;
|
|
13
|
+
outgoing: IStoredAuthorityGrant;
|
|
14
|
+
incoming: IStoredAuthorityGrant;
|
|
15
|
+
};
|
|
6
16
|
/** Separate account, grant, binding and journal records; the only global record is a revision counter. */
|
|
7
17
|
export declare class AuthSwitchAuthorityDatabase {
|
|
8
18
|
private readonly options;
|
|
@@ -18,8 +28,10 @@ export declare class AuthSwitchAuthorityDatabase {
|
|
|
18
28
|
readAccount(id: string): Promise<IStoredAuthorityAccount | null>;
|
|
19
29
|
readBinding(id: string): Promise<IStoredAuthorityBinding | null>;
|
|
20
30
|
readCodexHome(id: string): Promise<IStoredAuthorityCodexHome | null>;
|
|
21
|
-
/**
|
|
22
|
-
|
|
31
|
+
/** Durable home claims must be inspected even when the daemon has lost its process map. */
|
|
32
|
+
codexHomesForAccount(accountId: string, after: string | null): Promise<IStoredAuthorityCodexHome[]>;
|
|
33
|
+
/** Home path identity is hashed by the caller; no vendor files or raw paths enter NoSQLDB. */
|
|
34
|
+
reserveCodexHome(accountId: string, grantId: string, scopeId: string, homeId: string, updateId: string): Promise<{
|
|
23
35
|
newlyRegistered: boolean;
|
|
24
36
|
}>;
|
|
25
37
|
/** Pre-spawn claim is durable; the exact socket lets a later daemon detect a child born before PID readback. */
|
|
@@ -34,21 +46,95 @@ export declare class AuthSwitchAuthorityDatabase {
|
|
|
34
46
|
readEnrollment(id: string): Promise<IStoredAuthorityEnrollment | null>;
|
|
35
47
|
readHandoff(id: string): Promise<IStoredAuthorityHandoff | null>;
|
|
36
48
|
readMigrationLedger(id: string): Promise<IStoredAuthorityMigrationLedger | null>;
|
|
49
|
+
readOperation(id: string): Promise<IStoredAuthorityOperation | null>;
|
|
50
|
+
operationsPage(after: string | null, limit?: number): Promise<{
|
|
51
|
+
operations: IStoredAuthorityDeviceOperation[];
|
|
52
|
+
nextCursor: string | null;
|
|
53
|
+
}>;
|
|
54
|
+
operationsByState(state: IStoredAuthorityDeviceOperation['state'], after: string | null, limit?: number): Promise<IStoredAuthorityDeviceOperation[]>;
|
|
55
|
+
preuseOperationsByState(state: IStoredAuthorityPreuseOperation['state'], after: string | null, limit?: number): Promise<IStoredAuthorityPreuseOperation[]>;
|
|
56
|
+
/** Insert-or-read admission for one exact device-login intent. Existing receipts are never replayed. */
|
|
57
|
+
createOperation(intent: TStoredAuthorityDeviceOperationAdmission): Promise<{
|
|
58
|
+
operation: IStoredAuthorityDeviceOperation;
|
|
59
|
+
created: boolean;
|
|
60
|
+
}>;
|
|
61
|
+
/** Revalidate the durable owner and exact reauthentication generation after mutable runtime preparation. */
|
|
62
|
+
confirmOperationMayStart(operationId: string): Promise<IStoredAuthorityDeviceOperation>;
|
|
63
|
+
changeOperation(updateId: string, operationId: string, change: (operation: IStoredAuthorityDeviceOperation) => IStoredAuthorityDeviceOperation): Promise<IStoredAuthorityDeviceOperation>;
|
|
64
|
+
/** Insert-or-read idempotency for one exact preuse request. Existing records are never resumed here. */
|
|
65
|
+
createPreuseOperation(operation: IStoredAuthorityPreuseOperation): Promise<{
|
|
66
|
+
operation: IStoredAuthorityPreuseOperation;
|
|
67
|
+
created: boolean;
|
|
68
|
+
}>;
|
|
69
|
+
/** The committed marker precedes the only quota-consuming provider call. */
|
|
70
|
+
markPreuseRequestMayHaveStarted(operationId: string, updateId: string, model: string, grantGeneration: number, now: string): Promise<IStoredAuthorityPreuseOperation>;
|
|
71
|
+
changePreuseOperation(updateId: string, operationId: string, change: (operation: IStoredAuthorityPreuseOperation) => IStoredAuthorityPreuseOperation): Promise<IStoredAuthorityPreuseOperation>;
|
|
37
72
|
migrationLedgerByStatus(status: IStoredAuthorityMigrationLedger['status'], after: string | null, limit?: number): Promise<IStoredAuthorityMigrationLedger[]>;
|
|
38
73
|
readAccountAndPrimaryGrant(id: string): Promise<{
|
|
39
74
|
account: IStoredAuthorityAccount | null;
|
|
40
75
|
grant: IStoredAuthorityGrant | null;
|
|
41
76
|
}>;
|
|
42
|
-
|
|
77
|
+
readAccountAndGrant(accountId: string, grantId: string): Promise<{
|
|
78
|
+
account: IStoredAuthorityAccount | null;
|
|
79
|
+
grant: IStoredAuthorityGrant | null;
|
|
80
|
+
}>;
|
|
81
|
+
/** Epoch, account and exact login are read from one authority snapshot. */
|
|
82
|
+
readUsageContext(accountId: string, loginId: string): Promise<IAuthSwitchUsageContext | null>;
|
|
83
|
+
/** Backend-only view used to validate a usage token before and after unsealing. */
|
|
84
|
+
readUsageAccessView(accountId: string, loginId: string): Promise<{
|
|
85
|
+
context: IAuthSwitchUsageContext;
|
|
86
|
+
account: IStoredAuthorityAccount;
|
|
87
|
+
grant: IStoredAuthorityGrant;
|
|
88
|
+
} | null>;
|
|
89
|
+
/** Coherent native source ownership, including the home handoff fence. */
|
|
90
|
+
readClaudeNativeUsageView(homeId: string, accountId: string, loginId: string): Promise<{
|
|
91
|
+
context: IAuthSwitchUsageContext;
|
|
92
|
+
account: IStoredAuthorityAccount;
|
|
93
|
+
grant: IStoredAuthorityGrant;
|
|
94
|
+
home: IStoredAuthorityClaudeHome;
|
|
95
|
+
} | null>;
|
|
96
|
+
readUsage(accountId: string, loginId: string): Promise<IAuthSwitchStoredUsage | null>;
|
|
97
|
+
/** Publish one credential-free usage result only if its authority and predecessor still match. */
|
|
98
|
+
publishUsageIfCurrent(context: IAuthSwitchUsageContext, previousUpdateId: string | null, next: IAuthSwitchStoredUsage): Promise<boolean>;
|
|
99
|
+
page(accountAfter: string | null, grantAfter: string | null, bindingAfter: string | null, limit: number): Promise<{
|
|
43
100
|
meta: IStoredAuthorityMeta;
|
|
44
|
-
accounts:
|
|
45
|
-
|
|
46
|
-
grant: IStoredAuthorityGrant | null;
|
|
47
|
-
}>;
|
|
101
|
+
accounts: IStoredAuthorityAccount[];
|
|
102
|
+
grants: IStoredAuthorityGrant[];
|
|
48
103
|
bindings: IStoredAuthorityBinding[];
|
|
49
104
|
nextAccountCursor: string | null;
|
|
105
|
+
nextGrantCursor: string | null;
|
|
50
106
|
nextBindingCursor: string | null;
|
|
51
107
|
}>;
|
|
108
|
+
/**
|
|
109
|
+
* One bounded, repeatable-read diagnostic page. Its metadata revision is authority state,
|
|
110
|
+
* not a complete change clock for every native-home record.
|
|
111
|
+
*/
|
|
112
|
+
doctorPage(cursors: {
|
|
113
|
+
accountAfter: string | null;
|
|
114
|
+
loginAfter: string | null;
|
|
115
|
+
codexHomeAfter: string | null;
|
|
116
|
+
claudeHomeAfter: string | null;
|
|
117
|
+
claudeHandoffAfter: string | null;
|
|
118
|
+
nativeHandoffAfter: string | null;
|
|
119
|
+
migrationAfter: string | null;
|
|
120
|
+
}, limit: number): Promise<{
|
|
121
|
+
observedAt: string;
|
|
122
|
+
meta: IStoredAuthorityMeta;
|
|
123
|
+
accounts: IStoredAuthorityAccount[];
|
|
124
|
+
logins: IStoredAuthorityGrant[];
|
|
125
|
+
codexHomes: IStoredAuthorityCodexHome[];
|
|
126
|
+
claudeHomes: IStoredAuthorityClaudeHome[];
|
|
127
|
+
claudeHandoffs: IStoredAuthorityClaudeHandoff[];
|
|
128
|
+
nativeHandoffs: IStoredAuthorityHandoff[];
|
|
129
|
+
migrations: IStoredAuthorityMigrationLedger[];
|
|
130
|
+
nextAccountCursor: string | null;
|
|
131
|
+
nextLoginCursor: string | null;
|
|
132
|
+
nextCodexHomeCursor: string | null;
|
|
133
|
+
nextClaudeHomeCursor: string | null;
|
|
134
|
+
nextClaudeHandoffCursor: string | null;
|
|
135
|
+
nextNativeHandoffCursor: string | null;
|
|
136
|
+
nextMigrationCursor: string | null;
|
|
137
|
+
}>;
|
|
52
138
|
grantsByState(state: IStoredAuthorityGrant['state'], after: string | null, limit?: number): Promise<IStoredAuthorityGrant[]>;
|
|
53
139
|
grantsForAccount(accountId: string, after: string | null, limit?: number): Promise<IStoredAuthorityGrant[]>;
|
|
54
140
|
eventsAfter(revision: number, limit?: number): Promise<IStoredAuthorityEvent[]>;
|
|
@@ -64,6 +150,15 @@ export declare class AuthSwitchAuthorityDatabase {
|
|
|
64
150
|
account: IStoredAuthorityAccount;
|
|
65
151
|
grant: IStoredAuthorityGrant;
|
|
66
152
|
}>;
|
|
153
|
+
/** Device-login result, account and grant are one commit; a lost RPC response remains discoverable by operation ID. */
|
|
154
|
+
commitLoginOperation(updateId: string, operationId: string, accountId: string, grantId: string, change: (account: IStoredAuthorityAccount | null, grant: IStoredAuthorityGrant | null) => {
|
|
155
|
+
account: IStoredAuthorityAccount;
|
|
156
|
+
grant: IStoredAuthorityGrant;
|
|
157
|
+
}): Promise<{
|
|
158
|
+
account: IStoredAuthorityAccount;
|
|
159
|
+
grant: IStoredAuthorityGrant;
|
|
160
|
+
operation: IStoredAuthorityDeviceOperation;
|
|
161
|
+
}>;
|
|
67
162
|
/** Grant transition and public account revision share a transaction and one event. */
|
|
68
163
|
changeGrant(updateId: string, grantId: string, change: (grant: IStoredAuthorityGrant, account: IStoredAuthorityAccount) => IStoredAuthorityGrant): Promise<{
|
|
69
164
|
meta: IStoredAuthorityMeta;
|
|
@@ -81,12 +176,15 @@ export declare class AuthSwitchAuthorityDatabase {
|
|
|
81
176
|
meta: IStoredAuthorityMeta;
|
|
82
177
|
account: IStoredAuthorityAccount;
|
|
83
178
|
}>;
|
|
84
|
-
changeBinding(updateId: string, bindingId: string, accountId: string, change: (draft: IStoredAuthorityBinding | null, account: IStoredAuthorityAccount, grant: IStoredAuthorityGrant | null) => IStoredAuthorityBinding): Promise<{
|
|
179
|
+
changeBinding(updateId: string, bindingId: string, accountId: string, grantId: string, change: (draft: IStoredAuthorityBinding | null, account: IStoredAuthorityAccount, grant: IStoredAuthorityGrant | null) => IStoredAuthorityBinding): Promise<{
|
|
85
180
|
meta: IStoredAuthorityMeta;
|
|
86
181
|
binding: IStoredAuthorityBinding;
|
|
87
182
|
}>;
|
|
88
|
-
|
|
183
|
+
private revokeBindingExact;
|
|
184
|
+
/** Closing an authority-owned runtime revokes its exact capability after owned cleanup. */
|
|
89
185
|
revokeBinding(updateId: string, bindingId: string, capabilityHash: string): Promise<boolean>;
|
|
186
|
+
/** External callers can release only Flex/OpenCode bindings; managed Codex cleanup stays daemon-owned. */
|
|
187
|
+
releaseExternalBinding(updateId: string, bindingId: string, capabilityHash: string): Promise<boolean>;
|
|
90
188
|
/** Enrollment metadata is sealed by the caller and cannot become detached from an account. */
|
|
91
189
|
changeEnrollment(updateId: string, enrollmentId: string, accountId: string, change: (current: IStoredAuthorityEnrollment | null) => IStoredAuthorityEnrollment): Promise<IStoredAuthorityEnrollment>;
|
|
92
190
|
/** Journal and grant advance together; no intermediate phase may expose an active daemon grant. */
|
|
@@ -97,7 +195,53 @@ export declare class AuthSwitchAuthorityDatabase {
|
|
|
97
195
|
handoff: IStoredAuthorityHandoff;
|
|
98
196
|
grant: IStoredAuthorityGrant;
|
|
99
197
|
}>;
|
|
100
|
-
|
|
198
|
+
readClaudeHome(homeId: string): Promise<IStoredAuthorityClaudeHome | null>;
|
|
199
|
+
readClaudeHandoff(operationId: string): Promise<IStoredAuthorityClaudeHandoff | null>;
|
|
200
|
+
/** A verified backend import receipt, not an account snapshot, authorizes an inactive Claude grant. */
|
|
201
|
+
hasVerifiedClaudeGrantReceipt(accountId: string, grantId: string, session?: TSession): Promise<boolean>;
|
|
202
|
+
claudeHandoffsByPhase(phase: IStoredAuthorityClaudeHandoff['phase'], after: string | null): Promise<IStoredAuthorityClaudeHandoff[]>;
|
|
203
|
+
claudeHandoffsPage(after: string | null, limit?: number): Promise<{
|
|
204
|
+
handoffs: IStoredAuthorityClaudeHandoff[];
|
|
205
|
+
nextCursor: string | null;
|
|
206
|
+
}>;
|
|
207
|
+
/** Only a verified backend import receipt may adopt a native home. No startup autodiscovery exists. */
|
|
208
|
+
registerClaudeHomeFromReceipt(input: {
|
|
209
|
+
homeId: string;
|
|
210
|
+
accountId: string;
|
|
211
|
+
grantId: string;
|
|
212
|
+
receiptId: string;
|
|
213
|
+
sourceDigest: string;
|
|
214
|
+
accountUuid: string;
|
|
215
|
+
organizationUuid: string;
|
|
216
|
+
updateId: string;
|
|
217
|
+
now: string;
|
|
218
|
+
}): Promise<IStoredAuthorityClaudeHome>;
|
|
219
|
+
readClaudeHandoffContext(operationId: string): Promise<{
|
|
220
|
+
handoff: IStoredAuthorityClaudeHandoff;
|
|
221
|
+
home: IStoredAuthorityClaudeHome;
|
|
222
|
+
outgoing: IStoredAuthorityGrant;
|
|
223
|
+
incoming: IStoredAuthorityGrant;
|
|
224
|
+
outgoingAccount: IStoredAuthorityAccount;
|
|
225
|
+
incomingAccount: IStoredAuthorityAccount;
|
|
226
|
+
} | null>;
|
|
227
|
+
/** One phase advances both grants, home, journal and both account events atomically. */
|
|
228
|
+
changeClaudeHandoff(input: {
|
|
229
|
+
operationId: string;
|
|
230
|
+
homeId: string;
|
|
231
|
+
incomingGrantId: string;
|
|
232
|
+
updateId: string;
|
|
233
|
+
eventIds: readonly [string, string];
|
|
234
|
+
change: (current: {
|
|
235
|
+
home: IStoredAuthorityClaudeHome;
|
|
236
|
+
handoff: IStoredAuthorityClaudeHandoff | null;
|
|
237
|
+
outgoing: IStoredAuthorityGrant;
|
|
238
|
+
incoming: IStoredAuthorityGrant;
|
|
239
|
+
outgoingAccount: IStoredAuthorityAccount;
|
|
240
|
+
incomingAccount: IStoredAuthorityAccount;
|
|
241
|
+
}) => TClaudeHandoffDraft;
|
|
242
|
+
}): Promise<TClaudeHandoffDraft>;
|
|
243
|
+
/** Ledger transitions never silently replace an active credential or waive the verified import. */
|
|
101
244
|
changeMigrationLedger(updateId: string, ledgerId: string, change: (current: IStoredAuthorityMigrationLedger | null) => IStoredAuthorityMigrationLedger): Promise<IStoredAuthorityMigrationLedger>;
|
|
102
245
|
stop(): Promise<void>;
|
|
103
246
|
}
|
|
247
|
+
export {};
|