@modelprofile.com/authswitch 9.0.0 → 9.2.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 (38) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/authority-contract.d.ts +71 -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/authority-runtime-contract.d.ts +29 -0
  6. package/dist_ts/classes.authoritybroker.d.ts +37 -15
  7. package/dist_ts/classes.authoritybroker.js +121 -35
  8. package/dist_ts/classes.authorityclient.d.ts +28 -3
  9. package/dist_ts/classes.authorityclient.js +101 -18
  10. package/dist_ts/classes.authoritydaemon.d.ts +24 -0
  11. package/dist_ts/classes.authoritydaemon.js +87 -40
  12. package/dist_ts/classes.authoritydatabase.d.ts +29 -4
  13. package/dist_ts/classes.authoritydatabase.js +98 -13
  14. package/dist_ts/classes.authorityimport.js +2 -2
  15. package/dist_ts/classes.authoritymodels.js +5 -3
  16. package/dist_ts/classes.codexmanaged.d.ts +0 -9
  17. package/dist_ts/classes.codexmanaged.js +8 -28
  18. package/dist_ts/codexcontract.d.ts +30 -0
  19. package/dist_ts/codexcontract.js +174 -0
  20. package/dist_ts/ts_migration/0004_container_setup_owner.d.ts +12 -0
  21. package/dist_ts/ts_migration/0004_container_setup_owner.js +19 -0
  22. package/dist_ts/ts_migration/index.js +3 -1
  23. package/package.json +8 -8
  24. package/readme.md +102 -25
  25. package/ts/00_commitinfo_data.ts +1 -1
  26. package/ts/authority-contract.ts +75 -4
  27. package/ts/authority-import-contract.ts +6 -0
  28. package/ts/authority-runtime-contract.ts +30 -0
  29. package/ts/classes.authoritybroker.ts +122 -36
  30. package/ts/classes.authorityclient.ts +107 -21
  31. package/ts/classes.authoritydaemon.ts +91 -33
  32. package/ts/classes.authoritydatabase.ts +100 -14
  33. package/ts/classes.authorityimport.ts +1 -1
  34. package/ts/classes.authoritymodels.ts +4 -1
  35. package/ts/classes.codexmanaged.ts +6 -26
  36. package/ts/codexcontract.ts +200 -0
  37. package/ts/ts_migration/0004_container_setup_owner.ts +19 -0
  38. package/ts/ts_migration/index.ts +2 -0
@@ -19,6 +19,7 @@ export declare class AuthSwitchAuthorityDatabase {
19
19
  private engine?;
20
20
  private database?;
21
21
  private started;
22
+ private readonly deviceOperationObservers;
22
23
  constructor(options: IAuthSwitchAuthorityDatabaseOptions);
23
24
  private privateDirectory;
24
25
  start(): Promise<void>;
@@ -46,6 +47,13 @@ export declare class AuthSwitchAuthorityDatabase {
46
47
  readEnrollment(id: string): Promise<IStoredAuthorityEnrollment | null>;
47
48
  readHandoff(id: string): Promise<IStoredAuthorityHandoff | null>;
48
49
  readMigrationLedger(id: string): Promise<IStoredAuthorityMigrationLedger | null>;
50
+ /**
51
+ * Calls `observer` with the id of every device sign-in this database writes, after the write committed or
52
+ * was proven. The writers below are the only ones, so an observer misses no change; it runs synchronously
53
+ * and must only wake a reader. Returns the unsubscribe.
54
+ */
55
+ observeDeviceOperations(observer: (operationId: string) => void): () => void;
56
+ private deviceOperationChanged;
49
57
  readOperation(id: string): Promise<IStoredAuthorityOperation | null>;
50
58
  operationsPage(after: string | null, limit?: number): Promise<{
51
59
  operations: IStoredAuthorityDeviceOperation[];
@@ -101,14 +109,20 @@ export declare class AuthSwitchAuthorityDatabase {
101
109
  readUsage(accountId: string, loginId: string): Promise<IAuthSwitchStoredUsage | null>;
102
110
  /** Publish one credential-free usage result only if its authority and predecessor still match. */
103
111
  publishUsageIfCurrent(context: IAuthSwitchUsageContext, previousUpdateId: string | null, next: IAuthSwitchStoredUsage): Promise<boolean>;
104
- page(accountAfter: string | null, grantAfter: string | null, bindingAfter: string | null, limit: number): Promise<{
112
+ /**
113
+ * One repeatable-read page of the published authority state. Native homes are part of it: every write that
114
+ * changes which account a home runs on appends an account event, so the metadata revision covers them.
115
+ */
116
+ page(accountAfter: string | null, grantAfter: string | null, bindingAfter: string | null, claudeHomeAfter: string | null, limit: number): Promise<{
105
117
  meta: IStoredAuthorityMeta;
106
118
  accounts: IStoredAuthorityAccount[];
107
119
  grants: IStoredAuthorityGrant[];
108
120
  bindings: IStoredAuthorityBinding[];
121
+ claudeHomes: IStoredAuthorityClaudeHome[];
109
122
  nextAccountCursor: string | null;
110
123
  nextGrantCursor: string | null;
111
124
  nextBindingCursor: string | null;
125
+ nextClaudeHomeCursor: string | null;
112
126
  }>;
113
127
  /**
114
128
  * One bounded, repeatable-read diagnostic page. Its metadata revision is authority state,
@@ -175,20 +189,31 @@ export declare class AuthSwitchAuthorityDatabase {
175
189
  account: IStoredAuthorityAccount;
176
190
  grant: IStoredAuthorityGrant;
177
191
  }>;
178
- /** Remove all managed grants in one transaction; native owners must be stopped and handed off first. */
192
+ /**
193
+ * Remove all managed grants in one transaction. Native owners must be stopped and handed off first, and a
194
+ * runtime binding its holder releases must be released first; the daemon's own managed Codex bindings go
195
+ * with the account.
196
+ */
179
197
  removeAccountAndGrants(updateId: string, accountId: string, expectedRevision: number, statusObservedAt: string): Promise<IStoredAuthorityAccount>;
180
198
  changeAccount(updateId: string, accountId: string, change: (draft: IStoredAuthorityAccount | null) => IStoredAuthorityAccount): Promise<{
181
199
  meta: IStoredAuthorityMeta;
182
200
  account: IStoredAuthorityAccount;
183
201
  }>;
184
- changeBinding(updateId: string, bindingId: string, accountId: string, grantId: string, change: (draft: IStoredAuthorityBinding | null, account: IStoredAuthorityAccount, grant: IStoredAuthorityGrant | null) => IStoredAuthorityBinding): Promise<{
202
+ /**
203
+ * Binds a runtime and scope, or rebinds them. The binding's revision is the authority revision of the event
204
+ * that writes it, handed to `change` as `revision`: the authority revision never repeats, so no two binds of
205
+ * a runtime and scope ever share one -- not even across a release, which deletes the record, followed by a
206
+ * bind that inserts it again -- and a holder that names a binding by the revision it read never names its
207
+ * successor. Records written before carry smaller revisions, which a later bind therefore still exceeds.
208
+ */
209
+ changeBinding(updateId: string, bindingId: string, accountId: string, grantId: string, change: (draft: IStoredAuthorityBinding | null, account: IStoredAuthorityAccount, grant: IStoredAuthorityGrant | null, revision: number) => IStoredAuthorityBinding): Promise<{
185
210
  meta: IStoredAuthorityMeta;
186
211
  binding: IStoredAuthorityBinding;
187
212
  }>;
188
213
  private revokeBindingExact;
189
214
  /** Closing an authority-owned runtime revokes its exact capability after owned cleanup. */
190
215
  revokeBinding(updateId: string, bindingId: string, capabilityHash: string): Promise<boolean>;
191
- /** External callers can release only Flex/OpenCode bindings; managed Codex cleanup stays daemon-owned. */
216
+ /** External callers release only Flex, OpenCode and Claude bindings; managed Codex cleanup stays daemon-owned. */
192
217
  releaseExternalBinding(updateId: string, bindingId: string, capabilityHash: string): Promise<boolean>;
193
218
  /** Enrollment metadata is sealed by the caller and cannot become detached from an account. */
194
219
  changeEnrollment(updateId: string, enrollmentId: string, accountId: string, change: (current: IStoredAuthorityEnrollment | null) => IStoredAuthorityEnrollment): Promise<IStoredAuthorityEnrollment>;