@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,12 +1,16 @@
|
|
|
1
1
|
import type { ITypedRequest } from '@api.global/typedrequest-interfaces';
|
|
2
2
|
import * as plugins from './plugins.js';
|
|
3
3
|
import type {
|
|
4
|
-
IAuthSwitchAccountEvent, IAuthSwitchSnapshot, IReq_AuthSwitchBeginAdd,
|
|
5
|
-
IReq_AuthSwitchBeginReauth, IReq_AuthSwitchCancelOperation,
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
IAuthSwitchAccountEvent, IAuthSwitchSnapshot, IReq_AuthSwitchBeginAdd, IReq_AuthSwitchDoctor,
|
|
5
|
+
IReq_AuthSwitchBeginReauth, IReq_AuthSwitchCancelOperation,
|
|
6
|
+
IReq_AuthSwitchClaudeNativeHandoff, IReq_AuthSwitchClaudeNativeHandoffs,
|
|
7
|
+
IReq_AuthSwitchSwitchClaudeNative, IReq_AuthSwitchEvents,
|
|
8
|
+
IReq_AuthSwitchGetOperation, IReq_AuthSwitchListOperations, IReq_AuthSwitchRemoveAccount, IReq_AuthSwitchRenameAccount,
|
|
9
|
+
IReq_AuthSwitchCancelPreuse, IReq_AuthSwitchGetPreuse, IReq_AuthSwitchSnapshot,
|
|
10
|
+
IReq_AuthSwitchStartPreuse, IReq_AuthSwitchUsage,
|
|
8
11
|
} from './authority-contract.js';
|
|
9
|
-
import type { IReq_AuthSwitchBindAccount,
|
|
12
|
+
import type { IReq_AuthSwitchBindAccount, IReq_AuthSwitchReleaseBinding,
|
|
13
|
+
IReq_AuthSwitchResolveAccess } from './authority-runtime-contract.js';
|
|
10
14
|
import { AuthSwitchAuthorityFrameReader, authSwitchAuthorityFrameBytes,
|
|
11
15
|
maxAuthSwitchAuthorityFrameBytes } from './classes.authorityframing.js';
|
|
12
16
|
|
|
@@ -88,28 +92,41 @@ export class AuthSwitchClient {
|
|
|
88
92
|
return (await this.request<IReq_AuthSwitchSnapshot>('authswitch.authority.snapshot', options, 35_000, false, signal)).snapshot;
|
|
89
93
|
}
|
|
90
94
|
|
|
95
|
+
/** One independently stamped diagnostic page; callers may continue with its independent cursors. */
|
|
96
|
+
public async doctorPage(options: IReq_AuthSwitchDoctor['request'] = {}, signal?: AbortSignal): Promise<IReq_AuthSwitchDoctor['response']['page']> {
|
|
97
|
+
return (await this.request<IReq_AuthSwitchDoctor>('authswitch.authority.doctor', options, 35_000, false, signal)).page;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public async getUsage(accountId: string, loginId: string, force = false): Promise<IReq_AuthSwitchUsage['response']['usage']> {
|
|
101
|
+
return (await this.request<IReq_AuthSwitchUsage>('authswitch.authority.usage',
|
|
102
|
+
{ accountId, loginId, force })).usage;
|
|
103
|
+
}
|
|
104
|
+
|
|
91
105
|
/** Assemble a consistent view from bounded database pages; restart if a writer changes the revision. */
|
|
92
106
|
public async snapshotAll(options: { limit?: number; signal?: AbortSignal } = {}): Promise<IAuthSwitchSnapshot> {
|
|
93
107
|
while (true) {
|
|
94
108
|
if (options.signal?.aborted) throw options.signal.reason ?? new Error('Account snapshot cancelled.');
|
|
95
109
|
let accountAfter: string | undefined;
|
|
110
|
+
let loginAfter: string | undefined;
|
|
96
111
|
let bindingAfter: string | undefined;
|
|
97
112
|
let aggregate: IAuthSwitchSnapshot | undefined;
|
|
98
113
|
let changed = false;
|
|
99
114
|
while (true) {
|
|
100
|
-
const page = await this.snapshot({ accountAfter, bindingAfter, limit: options.limit }, options.signal);
|
|
101
|
-
if (!aggregate) aggregate = { ...page, accounts: [...page.accounts], bindings: [...page.bindings] };
|
|
115
|
+
const page = await this.snapshot({ accountAfter, loginAfter, bindingAfter, limit: options.limit }, options.signal);
|
|
116
|
+
if (!aggregate) aggregate = { ...page, accounts: [...page.accounts], logins: [...page.logins], bindings: [...page.bindings] };
|
|
102
117
|
else if (aggregate.epoch !== page.epoch || aggregate.revision !== page.revision) {
|
|
103
118
|
changed = true;
|
|
104
119
|
break;
|
|
105
120
|
} else {
|
|
106
121
|
aggregate.accounts.push(...page.accounts);
|
|
122
|
+
aggregate.logins.push(...page.logins);
|
|
107
123
|
aggregate.bindings.push(...page.bindings);
|
|
108
124
|
}
|
|
109
125
|
accountAfter = page.nextAccountCursor ?? accountAfter ?? page.accounts.at(-1)?.id;
|
|
126
|
+
loginAfter = page.nextLoginCursor ?? loginAfter ?? page.logins.at(-1)?.id;
|
|
110
127
|
bindingAfter = page.nextBindingCursor ?? bindingAfter ?? page.bindings.at(-1)?.id;
|
|
111
|
-
if (!page.nextAccountCursor && !page.nextBindingCursor) {
|
|
112
|
-
return { ...aggregate, nextAccountCursor: null, nextBindingCursor: null };
|
|
128
|
+
if (!page.nextAccountCursor && !page.nextLoginCursor && !page.nextBindingCursor) {
|
|
129
|
+
return { ...aggregate, nextAccountCursor: null, nextLoginCursor: null, nextBindingCursor: null };
|
|
113
130
|
}
|
|
114
131
|
}
|
|
115
132
|
if (!changed) throw new Error('Authority snapshot could not complete.');
|
|
@@ -210,17 +227,40 @@ export class AuthSwitchClient {
|
|
|
210
227
|
}
|
|
211
228
|
}
|
|
212
229
|
|
|
213
|
-
public async beginAddOpenAi(): Promise<IReq_AuthSwitchBeginAdd['response']['operation']> {
|
|
214
|
-
return (await this.request<IReq_AuthSwitchBeginAdd>('authswitch.authority.add',
|
|
230
|
+
public async beginAddOpenAi(operationId: string, signal?: AbortSignal): Promise<IReq_AuthSwitchBeginAdd['response']['operation']> {
|
|
231
|
+
return (await this.request<IReq_AuthSwitchBeginAdd>('authswitch.authority.add',
|
|
232
|
+
{ operationId, providerId: 'openai', flow: 'device' }, 35_000, false, signal)).operation;
|
|
233
|
+
}
|
|
234
|
+
public async beginReauthOpenAi(operationId: string, accountId: string, loginId: string,
|
|
235
|
+
purpose: 'openai_managed', signal?: AbortSignal): Promise<IReq_AuthSwitchBeginReauth['response']['operation']> {
|
|
236
|
+
return (await this.request<IReq_AuthSwitchBeginReauth>('authswitch.authority.reauth',
|
|
237
|
+
{ operationId, accountId, loginId, purpose, flow: 'device' }, 35_000, false, signal)).operation;
|
|
238
|
+
}
|
|
239
|
+
public listOperations(after?: string, limit?: number): Promise<IReq_AuthSwitchListOperations['response']> {
|
|
240
|
+
return this.request<IReq_AuthSwitchListOperations>('authswitch.authority.operations', { after, limit });
|
|
241
|
+
}
|
|
242
|
+
public async getOperation(operationId: string, signal?: AbortSignal): Promise<IReq_AuthSwitchGetOperation['response']['operation']> {
|
|
243
|
+
return (await this.request<IReq_AuthSwitchGetOperation>('authswitch.authority.operation',
|
|
244
|
+
{ operationId }, 35_000, false, signal)).operation;
|
|
215
245
|
}
|
|
216
|
-
public async
|
|
217
|
-
return (await this.request<
|
|
246
|
+
public async cancelOperation(operationId: string, signal?: AbortSignal): Promise<IReq_AuthSwitchCancelOperation['response']['operation']> {
|
|
247
|
+
return (await this.request<IReq_AuthSwitchCancelOperation>('authswitch.authority.cancel',
|
|
248
|
+
{ operationId }, 35_000, false, signal)).operation;
|
|
218
249
|
}
|
|
219
|
-
public async
|
|
220
|
-
|
|
250
|
+
public async startPreuse(input: IReq_AuthSwitchStartPreuse['request'],
|
|
251
|
+
signal?: AbortSignal): Promise<IReq_AuthSwitchStartPreuse['response']['operation']> {
|
|
252
|
+
return (await this.request<IReq_AuthSwitchStartPreuse>(
|
|
253
|
+
'authswitch.authority.preuse.start', input, 35_000, false, signal)).operation;
|
|
221
254
|
}
|
|
222
|
-
public async
|
|
223
|
-
|
|
255
|
+
public async getPreuse(operationId: string,
|
|
256
|
+
signal?: AbortSignal): Promise<IReq_AuthSwitchGetPreuse['response']['operation']> {
|
|
257
|
+
return (await this.request<IReq_AuthSwitchGetPreuse>(
|
|
258
|
+
'authswitch.authority.preuse.operation', { operationId }, 35_000, false, signal)).operation;
|
|
259
|
+
}
|
|
260
|
+
public async cancelPreuse(operationId: string,
|
|
261
|
+
signal?: AbortSignal): Promise<IReq_AuthSwitchCancelPreuse['response']['operation']> {
|
|
262
|
+
return (await this.request<IReq_AuthSwitchCancelPreuse>(
|
|
263
|
+
'authswitch.authority.preuse.cancel', { operationId }, 35_000, false, signal)).operation;
|
|
224
264
|
}
|
|
225
265
|
public async renameAccount(accountId: string, expectedRevision: number, label: string): Promise<IReq_AuthSwitchRenameAccount['response']['account']> {
|
|
226
266
|
return (await this.request<IReq_AuthSwitchRenameAccount>('authswitch.authority.rename', { accountId, expectedRevision, label })).account;
|
|
@@ -228,15 +268,28 @@ export class AuthSwitchClient {
|
|
|
228
268
|
public async removeAccount(accountId: string, expectedRevision: number): Promise<IReq_AuthSwitchRemoveAccount['response']['account']> {
|
|
229
269
|
return (await this.request<IReq_AuthSwitchRemoveAccount>('authswitch.authority.remove', { accountId, expectedRevision })).account;
|
|
230
270
|
}
|
|
271
|
+
public async switchClaudeNative(accountId: string, loginId: string): Promise<IReq_AuthSwitchSwitchClaudeNative['response']['handoff']> {
|
|
272
|
+
return (await this.request<IReq_AuthSwitchSwitchClaudeNative>('authswitch.authority.claude.switch',
|
|
273
|
+
{ accountId, loginId, purpose: 'claude_host_native' })).handoff;
|
|
274
|
+
}
|
|
275
|
+
public async getClaudeNativeHandoff(operationId: string): Promise<IReq_AuthSwitchClaudeNativeHandoff['response']['handoff']> {
|
|
276
|
+
return (await this.request<IReq_AuthSwitchClaudeNativeHandoff>('authswitch.authority.claude.handoff', { operationId })).handoff;
|
|
277
|
+
}
|
|
278
|
+
public listClaudeNativeHandoffs(after?: string, limit?: number): Promise<IReq_AuthSwitchClaudeNativeHandoffs['response']> {
|
|
279
|
+
return this.request<IReq_AuthSwitchClaudeNativeHandoffs>('authswitch.authority.claude.handoffs', { after, limit });
|
|
280
|
+
}
|
|
231
281
|
public bindAccount(input: IReq_AuthSwitchBindAccount['request']): Promise<IReq_AuthSwitchBindAccount['response']> {
|
|
232
282
|
return this.request<IReq_AuthSwitchBindAccount>('authswitch.authority.bind', input);
|
|
233
283
|
}
|
|
234
284
|
public resolveAccess(input: IReq_AuthSwitchResolveAccess['request']): Promise<IReq_AuthSwitchResolveAccess['response']> {
|
|
235
285
|
return this.request<IReq_AuthSwitchResolveAccess>('authswitch.authority.resolveAccess', input, 35_000, true);
|
|
236
286
|
}
|
|
287
|
+
public releaseBinding(input: IReq_AuthSwitchReleaseBinding['request'], signal?: AbortSignal): Promise<IReq_AuthSwitchReleaseBinding['response']> {
|
|
288
|
+
return this.request<IReq_AuthSwitchReleaseBinding>('authswitch.authority.release', input, 35_000, true, signal);
|
|
289
|
+
}
|
|
237
290
|
}
|
|
238
291
|
|
|
239
|
-
/** Container-facing client. It can only resolve a previously issued binding capability. */
|
|
292
|
+
/** Container-facing client. It can only resolve or release a previously issued binding capability. */
|
|
240
293
|
export class AuthSwitchRuntimeClient {
|
|
241
294
|
private readonly target: plugins.typedrequest.TypedTarget;
|
|
242
295
|
constructor(runtimeSocketPath: string) {
|
|
@@ -249,4 +302,8 @@ export class AuthSwitchRuntimeClient {
|
|
|
249
302
|
return new plugins.typedrequest.TypedRequest<IReq_AuthSwitchResolveAccess>(this.target,
|
|
250
303
|
'authswitch.authority.resolveAccess').fire(input, { timeoutMs: 35_000, maxRetries: 0 });
|
|
251
304
|
}
|
|
305
|
+
public releaseBinding(input: IReq_AuthSwitchReleaseBinding['request'], signal?: AbortSignal): Promise<IReq_AuthSwitchReleaseBinding['response']> {
|
|
306
|
+
return new plugins.typedrequest.TypedRequest<IReq_AuthSwitchReleaseBinding>(this.target,
|
|
307
|
+
'authswitch.authority.release').fire(input, { timeoutMs: 35_000, maxRetries: 0, abortSignal: signal });
|
|
308
|
+
}
|
|
252
309
|
}
|