@modelprofile.com/authswitch 9.0.0 → 9.1.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.
Files changed (36) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/authority-contract.d.ts +67 -1
  3. package/dist_ts/authority-contract.js +13 -2
  4. package/dist_ts/authority-import-contract.d.ts +6 -0
  5. package/dist_ts/classes.authoritybroker.d.ts +21 -15
  6. package/dist_ts/classes.authoritybroker.js +94 -31
  7. package/dist_ts/classes.authorityclient.d.ts +22 -2
  8. package/dist_ts/classes.authorityclient.js +79 -13
  9. package/dist_ts/classes.authoritydaemon.d.ts +7 -0
  10. package/dist_ts/classes.authoritydaemon.js +45 -31
  11. package/dist_ts/classes.authoritydatabase.d.ts +21 -3
  12. package/dist_ts/classes.authoritydatabase.js +88 -11
  13. package/dist_ts/classes.authorityimport.js +2 -2
  14. package/dist_ts/classes.authoritymodels.js +5 -3
  15. package/dist_ts/classes.codexmanaged.d.ts +0 -9
  16. package/dist_ts/classes.codexmanaged.js +8 -28
  17. package/dist_ts/codexcontract.d.ts +30 -0
  18. package/dist_ts/codexcontract.js +174 -0
  19. package/dist_ts/ts_migration/0004_container_setup_owner.d.ts +12 -0
  20. package/dist_ts/ts_migration/0004_container_setup_owner.js +19 -0
  21. package/dist_ts/ts_migration/index.js +3 -1
  22. package/package.json +8 -8
  23. package/readme.md +75 -17
  24. package/ts/00_commitinfo_data.ts +1 -1
  25. package/ts/authority-contract.ts +71 -4
  26. package/ts/authority-import-contract.ts +6 -0
  27. package/ts/classes.authoritybroker.ts +94 -32
  28. package/ts/classes.authorityclient.ts +86 -15
  29. package/ts/classes.authoritydaemon.ts +44 -23
  30. package/ts/classes.authoritydatabase.ts +88 -11
  31. package/ts/classes.authorityimport.ts +1 -1
  32. package/ts/classes.authoritymodels.ts +4 -1
  33. package/ts/classes.codexmanaged.ts +6 -26
  34. package/ts/codexcontract.ts +200 -0
  35. package/ts/ts_migration/0004_container_setup_owner.ts +19 -0
  36. package/ts/ts_migration/index.ts +2 -0
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@modelprofile.com/authswitch',
6
- version: '9.0.0',
6
+ version: '9.1.0',
7
7
  description: 'Manage Codex, OpenCode and Claude Code accounts with guided switching and live usage status'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSw4QkFBOEI7SUFDcEMsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLDZGQUE2RjtDQUMzRyxDQUFBIn0=
@@ -14,7 +14,15 @@ export type TAuthSwitchRefusalCode = 'authority_closing' | 'not_found' | 'accoun
14
14
  /** The authority holds this login, so the legacy path that used to move it no longer may. */
15
15
  | 'authority_holds_login'
16
16
  /** An authority is installed on this host and is not answering, so nothing may assume it holds nothing. */
17
- | 'authority_unavailable' | 'native_owner_holds_login' | 'claude_home_unregistered' | 'claude_handoff_pending' | 'claude_receipt_missing' | 'import_refusal';
17
+ | 'authority_unavailable' | 'native_owner_holds_login' | 'claude_home_unregistered' | 'claude_handoff_pending' | 'claude_receipt_missing' | 'import_refusal'
18
+ /** The Codex on this host is older than managed Codex runs, or no longer offers a surface it uses. */
19
+ | 'codex_unsupported'
20
+ /** A value the owner typed breaks a rule the instruction states, such as an account label. */
21
+ | 'invalid_input'
22
+ /** The account's login has ended and only a new device sign-in brings it back. */
23
+ | 'login_needs_reauth'
24
+ /** The login is intact, but the provider could not renew its access yet; the same request can succeed later. */
25
+ | 'access_not_fresh';
18
26
  /** The marker the importer has published since 8.1.0; it keeps its own value on the wire. */
19
27
  export declare const authSwitchImportRefusalMarker = "authswitch_import_refusal";
20
28
  export declare const authSwitchRefusalReason = "authswitch_refusal";
@@ -53,6 +61,14 @@ export declare class AuthSwitchRefusal extends Error {
53
61
  * refusal that release could answer with -- which is why it is read rather than treated as a fault.
54
62
  */
55
63
  export declare const asAuthSwitchRefusal: (error: unknown) => IAuthSwitchRefusal | null;
64
+ /** The longest account label, in UTF-16 code units. */
65
+ export declare const authSwitchAccountLabelMaxLength = 128;
66
+ /**
67
+ * The account label rule, the one the authority applies to a rename: one to `authSwitchAccountLabelMaxLength`
68
+ * characters, no space at either end, no control character. A consumer validates with this rather than
69
+ * restating it; the authority answers a label that breaks it with the `invalid_input` refusal.
70
+ */
71
+ export declare const isAuthSwitchAccountLabel: (value: unknown) => value is string;
56
72
  /** Credential-free account management contract. Safe to import in browser code. */
57
73
  export type TAuthSwitchLoginPurpose = 'openai_managed' | 'claude_host_native' | 'claude_container_setup' | 'opencode_native';
58
74
  export type TAuthSwitchLoginHealth = 'ready' | 'refreshing' | 'retry_wait' | 'needs_reauth' | 'unverified' | 'pending_handoff' | 'handoff_quarantined' | 'removed';
@@ -100,11 +116,33 @@ export interface IAuthSwitchLogin {
100
116
  export interface IAuthSwitchBinding {
101
117
  id: string;
102
118
  accountId: string;
119
+ /**
120
+ * The runtime an OpenAI (ChatGPT) login backs. `flex`, `opencode` and `claude` bindings are held and
121
+ * released by their caller over the runtime socket; `codex` is the daemon's own managed Codex. A Claude
122
+ * account never binds: it reaches Claude Code through the native switch.
123
+ */
103
124
  runtime: 'flex' | 'codex' | 'opencode' | 'claude';
104
125
  scopeId: string;
105
126
  incarnationId: string;
106
127
  revision: number;
107
128
  }
129
+ /**
130
+ * Which account a vendor tool's own home on this host runs on. Credential-free: the home is named by the
131
+ * hash the authority registered it under, never by its path.
132
+ *
133
+ * Only homes the authority itself switches are recorded: Claude Code homes adopted by a verified import.
134
+ * A Codex or OpenCode store that a native tool still refreshes appears as its login instead, with
135
+ * `owner: 'legacy_native'` and its `ownerTool`, because the authority does not decide what that store holds.
136
+ */
137
+ export interface IAuthSwitchNativeAssignment {
138
+ id: string;
139
+ tool: TAuthSwitchLoginOwnerTool;
140
+ accountId: string;
141
+ loginId: string;
142
+ /** `switching` while a handoff to another account is in flight; `quarantined` until it is resolved. */
143
+ state: 'ready' | 'switching' | 'quarantined';
144
+ revision: number;
145
+ }
108
146
  export interface IAuthSwitchSnapshot {
109
147
  schemaVersion: 2;
110
148
  epoch: string;
@@ -113,9 +151,11 @@ export interface IAuthSwitchSnapshot {
113
151
  accounts: IAuthSwitchAccount[];
114
152
  logins: IAuthSwitchLogin[];
115
153
  bindings: IAuthSwitchBinding[];
154
+ nativeAssignments: IAuthSwitchNativeAssignment[];
116
155
  nextAccountCursor: string | null;
117
156
  nextLoginCursor: string | null;
118
157
  nextBindingCursor: string | null;
158
+ nextNativeAssignmentCursor: string | null;
119
159
  }
120
160
  /** Persisted account evidence. No provider request is made while collecting diagnostics. */
121
161
  export interface IAuthSwitchDoctorAccountEvidence {
@@ -352,7 +392,13 @@ export interface IReq_AuthSwitchSnapshot extends ITypedRequest {
352
392
  accountAfter?: string;
353
393
  loginAfter?: string;
354
394
  bindingAfter?: string;
395
+ nativeAssignmentAfter?: string;
355
396
  limit?: number;
397
+ /**
398
+ * Also publish removed accounts (`removed: true`) and their removed logins (`health: 'removed'`), so a
399
+ * consumer can show them apart. Absent or false keeps the snapshot to what is live.
400
+ */
401
+ includeRemoved?: boolean;
356
402
  };
357
403
  response: {
358
404
  snapshot: IAuthSwitchSnapshot;
@@ -435,10 +481,17 @@ export interface IReq_AuthSwitchListOperations extends ITypedRequest {
435
481
  nextCursor: string | null;
436
482
  };
437
483
  }
484
+ /**
485
+ * One device sign-in. `afterRevision` and `waitMs` come together or not at all: with them the read is a long
486
+ * poll that answers once the operation's revision passes `afterRevision`, at once for a finished sign-in, or
487
+ * with the unchanged operation after `waitMs` (at most 30000).
488
+ */
438
489
  export interface IReq_AuthSwitchGetOperation extends ITypedRequest {
439
490
  method: 'authswitch.authority.operation';
440
491
  request: {
441
492
  operationId: string;
493
+ afterRevision?: number;
494
+ waitMs?: number;
442
495
  };
443
496
  response: {
444
497
  operation: IAuthSwitchOperation;
@@ -496,6 +549,19 @@ export interface IReq_AuthSwitchRenameAccount extends ITypedRequest {
496
549
  account: IAuthSwitchAccount;
497
550
  };
498
551
  }
552
+ /**
553
+ * One binding by the id `bind` returned, credential-free, or `null` when this authority holds no binding by
554
+ * that id. A backend checks that its binding still stands without reading the whole snapshot.
555
+ */
556
+ export interface IReq_AuthSwitchGetBinding extends ITypedRequest {
557
+ method: 'authswitch.authority.binding';
558
+ request: {
559
+ bindingId: string;
560
+ };
561
+ response: {
562
+ binding: IAuthSwitchBinding | null;
563
+ };
564
+ }
499
565
  export interface IReq_AuthSwitchRemoveAccount extends ITypedRequest {
500
566
  method: 'authswitch.authority.remove';
501
567
  request: {
@@ -5,7 +5,8 @@ const refusalCodes = new Set([
5
5
  'authority_closing', 'not_found', 'account_changed', 'account_busy',
6
6
  'login_unavailable', 'binding_unauthorized', 'native_owner_holds_login', 'claude_home_unregistered',
7
7
  'claude_handoff_pending', 'claude_receipt_missing', 'import_refusal',
8
- 'authority_holds_login', 'authority_unavailable',
8
+ 'authority_holds_login', 'authority_unavailable', 'codex_unsupported', 'invalid_input',
9
+ 'login_needs_reauth', 'access_not_fresh',
9
10
  ]);
10
11
  const isRefusalCode = (value) => typeof value === 'string' && refusalCodes.has(value);
11
12
  /** The importer keeps the marker it published; every other code shares the authority's own. */
@@ -52,5 +53,15 @@ export const asAuthSwitchRefusal = (error) => {
52
53
  return null;
53
54
  return { code, instruction };
54
55
  };
56
+ /** The longest account label, in UTF-16 code units. */
57
+ export const authSwitchAccountLabelMaxLength = 128;
58
+ /**
59
+ * The account label rule, the one the authority applies to a rename: one to `authSwitchAccountLabelMaxLength`
60
+ * characters, no space at either end, no control character. A consumer validates with this rather than
61
+ * restating it; the authority answers a label that breaks it with the `invalid_input` refusal.
62
+ */
63
+ export const isAuthSwitchAccountLabel = (value) => typeof value === 'string'
64
+ && value.trim() === value && value.length > 0 && value.length <= authSwitchAccountLabelMaxLength
65
+ && !/[\u0000-\u001f\u007f]/.test(value);
55
66
  /** Runtime capability is returned only to trusted backend callers; do not expose this response in a browser API. */
56
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aG9yaXR5LWNvbnRyYWN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvYXV0aG9yaXR5LWNvbnRyYWN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQTZCQSw2RkFBNkY7QUFDN0YsTUFBTSxDQUFDLE1BQU0sNkJBQTZCLEdBQUcsMkJBQTJCLENBQUM7QUFDekUsTUFBTSxDQUFDLE1BQU0sdUJBQXVCLEdBQUcsb0JBQW9CLENBQUM7QUFpQjVELE1BQU0sWUFBWSxHQUF3QixJQUFJLEdBQUcsQ0FBeUI7SUFDeEUsbUJBQW1CLEVBQUUsV0FBVyxFQUFFLGlCQUFpQixFQUFFLGNBQWM7SUFDbkUsbUJBQW1CLEVBQUUsc0JBQXNCLEVBQUUsMEJBQTBCLEVBQUUsMEJBQTBCO0lBQ25HLHdCQUF3QixFQUFFLHdCQUF3QixFQUFFLGdCQUFnQjtJQUNwRSx1QkFBdUIsRUFBRSx1QkFBdUI7Q0FDakQsQ0FBQyxDQUFDO0FBRUgsTUFBTSxhQUFhLEdBQUcsQ0FBQyxLQUFjLEVBQW1DLEVBQUUsQ0FDeEUsT0FBTyxLQUFLLEtBQUssUUFBUSxJQUFJLFlBQVksQ0FBQyxHQUFHLENBQUMsS0FBSyxDQUFDLENBQUM7QUFFdkQsK0ZBQStGO0FBQy9GLE1BQU0sUUFBUSxHQUFHLENBQUMsSUFBNEIsRUFBNEIsRUFBRSxDQUMxRSxJQU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kFBZ0IsQ0FBQyxDQUFDLENBQUMsRUFBRSxJQUFJLEVBQUUsZ0JBQWdCLEVBQUUsV0FBVyxFQUFFLENBQUMsQ0FBQyxDQUFDLElBQUksQ0FBQztJQUMxRyxDQUFDO0lBQ0QsSUFBSSxJQUFJLENBQUMsTUFBTSxLQUFLLHVCQUF1QixJQUFJLENBQUMsYUFBYSxDQUFDLElBQUksQ0FBQztRQUFFLE9BQU8sSUFBSSxDQUFDO0lBQ2pGLE9BQU8sRUFBRSxJQUFJLEVBQUUsV0FBVyxFQUFFLENBQUM7QUFDL0IsQ0FBQyxDQUFDO0FBRUYsdURBQXVEO0FBQ3ZELE1BQU0sQ0FBQyxNQUFNLCtCQUErQixHQUFHLEdBQUcsQ0FBQztBQUVuRDs7OztHQUlHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sd0JBQXdCLEdBQUcsQ0FBQyxLQUFjLEVBQW1CLEVBQUUsQ0FBQyxPQUFPLEtBQUssS0FBSyxRQUFRO09BQ2pHLEtBQUssQ0FBQyxJQUFJLEVBQUUsS0FBSyxLQUFLLElBQUksS0FBSyxDQUFDLE1BQU0sR0FBRyxDQUFDLElBQUksS0FBSyxDQUFDLE1BQU0sSUFBSSwrQkFBK0I7T0FDN0YsQ0FBQyx1QkFBdUIsQ0FBQyxJQUFJLENBQUMsS0FBSyxDQUFDLENBQUM7QUE4YTFDLG9IQUFvSCJ9
@@ -163,6 +163,12 @@ export declare const isAuthSwitchImportRefusal: (error: unknown) => boolean;
163
163
  export interface IAuthSwitchImportStatusEntry {
164
164
  sourceId: string;
165
165
  sourceKind: TAuthSwitchImportSourceKind;
166
+ /**
167
+ * The source location as a hash, exactly as it was submitted or inventoried. A backend that submits an
168
+ * external source finds its own record here by `sourceKind` and this hash, including after a submit whose
169
+ * outcome it never learned.
170
+ */
171
+ sourcePathHash: string;
166
172
  status: TAuthSwitchImportLedgerStatus;
167
173
  accountId: string | null;
168
174
  loginId: string | null;
@@ -1,5 +1,5 @@
1
1
  import * as plugins from './plugins.js';
2
- import type { IAuthSwitchAccount, IAuthSwitchAccountEvent, IAuthSwitchBinding, IAuthSwitchOperation, IAuthSwitchSnapshot } from './authority-contract.js';
2
+ import type { IAuthSwitchAccount, IAuthSwitchAccountEvent, IAuthSwitchBinding, IAuthSwitchOperation, IAuthSwitchSnapshot, IReq_AuthSwitchSnapshot } from './authority-contract.js';
3
3
  import { AuthSwitchAuthorityDatabase } from './classes.authoritydatabase.js';
4
4
  import type { IAuthSwitchUsageContext } from './classes.authorityusage.js';
5
5
  import { type IAuthSwitchSecretCodec } from './classes.authoritysecrets.js';
@@ -29,6 +29,8 @@ export declare class AuthSwitchAuthorityBroker {
29
29
  private readonly operations;
30
30
  private readonly refreshes;
31
31
  private readonly listeners;
32
+ /** Operation long polls; woken by their operation's own changes, and all of them on close. */
33
+ private readonly operationWaiters;
32
34
  private claudeRefresh?;
33
35
  private maintenance?;
34
36
  private timer?;
@@ -42,12 +44,7 @@ export declare class AuthSwitchAuthorityBroker {
42
44
  refreshDueAccounts(): Promise<void>;
43
45
  private isDue;
44
46
  private publish;
45
- snapshot(options?: {
46
- accountAfter?: string;
47
- loginAfter?: string;
48
- bindingAfter?: string;
49
- limit?: number;
50
- }): Promise<IAuthSwitchSnapshot>;
47
+ snapshot(options?: IReq_AuthSwitchSnapshot['request']): Promise<IAuthSwitchSnapshot>;
51
48
  events(epoch: string, afterRevision: number, waitMs: number, signal?: AbortSignal): Promise<{
52
49
  epoch: string;
53
50
  revision: number;
@@ -62,7 +59,16 @@ export declare class AuthSwitchAuthorityBroker {
62
59
  beginAddOpenAi(operationId: string): Promise<IAuthSwitchOperation>;
63
60
  beginReauthOpenAi(operationId: string, accountId: string, loginId: string, purpose: 'openai_managed', beforeNew?: () => Promise<void>): Promise<IAuthSwitchOperation>;
64
61
  private beginLogin;
65
- getOperation(operationId: string): Promise<IAuthSwitchOperation>;
62
+ /**
63
+ * One device sign-in. With `wait`, the read is a long poll, the way `events` waits: it answers at once when
64
+ * the operation's revision is past `afterRevision` or the sign-in has finished, and otherwise when the
65
+ * operation next changes or `waitMs` runs out, whichever is first -- so a caller follows the prompt and
66
+ * the outcome without polling. A timed-out wait answers with the unchanged operation.
67
+ */
68
+ getOperation(operationId: string, wait?: {
69
+ afterRevision: number;
70
+ waitMs: number;
71
+ }, signal?: AbortSignal): Promise<IAuthSwitchOperation>;
66
72
  listOperations(after: string | null, limit?: number): Promise<{
67
73
  operations: IAuthSwitchOperation[];
68
74
  nextCursor: string | null;
@@ -83,19 +89,19 @@ export declare class AuthSwitchAuthorityBroker {
83
89
  binding: IAuthSwitchBinding;
84
90
  capability: string;
85
91
  }>;
92
+ getBinding(bindingId: string): Promise<IAuthSwitchBinding | null>;
86
93
  revokeBinding(bindingId: string, capability: string): Promise<boolean>;
87
94
  releaseExternalBinding(bindingId: string, capability: string): Promise<'released' | 'inactive'>;
88
95
  resolveAccess(bindingId: string, capability: string, minValidityMs: number, rejectedGrantGeneration?: number): Promise<IAuthSwitchResolvedAccess>;
89
96
  /** Backend-only access for usage; it never creates or bypasses a runtime binding. */
90
97
  resolveUsageAccess(context: IAuthSwitchUsageContext, rejectedGrantGeneration: number | undefined, minValidityMs: number): Promise<IAuthSwitchResolvedAccess>;
91
98
  /**
92
- * The shared managed-access loop, whose refusals are deliberately still unmarked faults.
93
- *
94
- * Its two callers repair differently: a runtime holding a binding binds again, while the usage reader has
95
- * no binding at all and collapses everything into one usage problem. Naming a code here would either say
96
- * "binding" to a caller that has none, or invent a second meaning for one that does, so the decision waits
97
- * for the slice that gives the usage answer its own vocabulary. What a bound runtime can act on is decided
98
- * before this point, in the view `resolveAccess` supplies.
99
+ * The shared managed-access loop. What it decides about the login itself is a marked refusal both callers
100
+ * read the same way: `login_needs_reauth` when only a new sign-in brings the login back, `access_not_fresh`
101
+ * when the login is intact and the provider could not renew it yet. The usage reader still folds either
102
+ * into its own problem; a bound runtime shows the instruction. What only concerns a binding is decided
103
+ * before this point, in the view `resolveAccess` supplies, and a changed identity or a view that keeps
104
+ * moving stays an unmarked fault, because nobody decided it.
99
105
  */
100
106
  private resolveManagedAccess;
101
107
  private refreshAccount;