@modelprofile.com/authswitch 6.4.0 → 7.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.
Files changed (98) hide show
  1. package/dist_ts/00_commitinfo_data.js +1 -1
  2. package/dist_ts/authority-contract.d.ts +302 -6
  3. package/dist_ts/authority-contract.js +1 -1
  4. package/dist_ts/authority-runtime-contract.d.ts +15 -0
  5. package/dist_ts/authorityrehearsal.child.d.ts +1 -0
  6. package/dist_ts/authorityrehearsal.child.js +395 -0
  7. package/dist_ts/classes.accountlist.js +4 -3
  8. package/dist_ts/classes.authoritybackup.d.ts +134 -0
  9. package/dist_ts/classes.authoritybackup.js +769 -0
  10. package/dist_ts/classes.authoritybroker.d.ts +29 -6
  11. package/dist_ts/classes.authoritybroker.js +413 -122
  12. package/dist_ts/classes.authoritycli.d.ts +24 -0
  13. package/dist_ts/classes.authoritycli.js +675 -0
  14. package/dist_ts/classes.authorityclient.d.ts +34 -9
  15. package/dist_ts/classes.authorityclient.js +136 -38
  16. package/dist_ts/classes.authoritydaemon.d.ts +47 -0
  17. package/dist_ts/classes.authoritydaemon.js +705 -16
  18. package/dist_ts/classes.authoritydatabase.d.ts +182 -8
  19. package/dist_ts/classes.authoritydatabase.js +1188 -41
  20. package/dist_ts/classes.authoritymodels.d.ts +247 -1
  21. package/dist_ts/classes.authoritymodels.js +870 -6
  22. package/dist_ts/classes.authoritypreuse.d.ts +47 -0
  23. package/dist_ts/classes.authoritypreuse.js +278 -0
  24. package/dist_ts/classes.authorityregistry.d.ts +24 -0
  25. package/dist_ts/classes.authorityregistry.js +88 -0
  26. package/dist_ts/classes.authorityrehearsal.d.ts +127 -0
  27. package/dist_ts/classes.authorityrehearsal.js +632 -0
  28. package/dist_ts/classes.authorityusage.d.ts +160 -0
  29. package/dist_ts/classes.authorityusage.js +429 -0
  30. package/dist_ts/classes.claudeauthority.d.ts +66 -0
  31. package/dist_ts/classes.claudeauthority.js +532 -0
  32. package/dist_ts/classes.claudecodeharness.js +3 -2
  33. package/dist_ts/classes.claudecodelocks.d.ts +13 -0
  34. package/dist_ts/classes.claudecodelocks.js +75 -3
  35. package/dist_ts/classes.claudenative.d.ts +137 -0
  36. package/dist_ts/classes.claudenative.js +731 -0
  37. package/dist_ts/classes.claudestatus.d.ts +9 -0
  38. package/dist_ts/classes.claudestatus.js +26 -9
  39. package/dist_ts/classes.claudetokenrefresh.d.ts +15 -1
  40. package/dist_ts/classes.claudetokenrefresh.js +74 -21
  41. package/dist_ts/classes.codexharness.js +4 -2
  42. package/dist_ts/classes.codexmanaged.d.ts +91 -0
  43. package/dist_ts/classes.codexmanaged.js +404 -0
  44. package/dist_ts/classes.codexpreuse.d.ts +8 -0
  45. package/dist_ts/classes.codexpreuse.js +24 -6
  46. package/dist_ts/classes.fileharness.d.ts +2 -0
  47. package/dist_ts/classes.fileharness.js +6 -4
  48. package/dist_ts/classes.limits.js +12 -7
  49. package/dist_ts/classes.opencodeharness.js +2 -2
  50. package/dist_ts/claudehttp.d.ts +10 -0
  51. package/dist_ts/claudehttp.js +29 -3
  52. package/dist_ts/index.d.ts +2 -0
  53. package/dist_ts/index.js +8 -1
  54. package/dist_ts/interfaces.harness.d.ts +6 -0
  55. package/dist_ts/interfaces.list.d.ts +9 -3
  56. package/dist_ts/plugins.d.ts +7 -3
  57. package/dist_ts/plugins.js +9 -4
  58. package/dist_ts/ts_migration/0001_authority_meta.d.ts +3 -0
  59. package/dist_ts/ts_migration/0001_authority_meta.js +32 -0
  60. package/dist_ts/ts_migration/index.d.ts +3 -0
  61. package/dist_ts/ts_migration/index.js +6 -0
  62. package/package.json +12 -2
  63. package/readme.md +205 -13
  64. package/ts/00_commitinfo_data.ts +1 -1
  65. package/ts/authority-contract.ts +264 -9
  66. package/ts/authority-runtime-contract.ts +21 -1
  67. package/ts/authorityrehearsal.child.ts +330 -0
  68. package/ts/classes.accountlist.ts +3 -2
  69. package/ts/classes.authoritybackup.ts +780 -0
  70. package/ts/classes.authoritybroker.ts +410 -120
  71. package/ts/classes.authoritycli.ts +719 -0
  72. package/ts/classes.authorityclient.ts +164 -38
  73. package/ts/classes.authoritydaemon.ts +614 -17
  74. package/ts/classes.authoritydatabase.ts +1229 -44
  75. package/ts/classes.authoritymodels.ts +579 -4
  76. package/ts/classes.authoritypreuse.ts +297 -0
  77. package/ts/classes.authorityregistry.ts +118 -0
  78. package/ts/classes.authorityrehearsal.ts +625 -0
  79. package/ts/classes.authorityusage.ts +527 -0
  80. package/ts/classes.claudeauthority.ts +541 -0
  81. package/ts/classes.claudecodeharness.ts +2 -1
  82. package/ts/classes.claudecodelocks.ts +70 -1
  83. package/ts/classes.claudenative.ts +816 -0
  84. package/ts/classes.claudestatus.ts +38 -9
  85. package/ts/classes.claudetokenrefresh.ts +82 -19
  86. package/ts/classes.codexharness.ts +3 -1
  87. package/ts/classes.codexmanaged.ts +402 -0
  88. package/ts/classes.codexpreuse.ts +33 -5
  89. package/ts/classes.fileharness.ts +7 -3
  90. package/ts/classes.limits.ts +11 -6
  91. package/ts/classes.opencodeharness.ts +1 -1
  92. package/ts/claudehttp.ts +31 -2
  93. package/ts/index.ts +7 -0
  94. package/ts/interfaces.harness.ts +6 -0
  95. package/ts/interfaces.list.ts +9 -3
  96. package/ts/plugins.ts +9 -3
  97. package/ts/ts_migration/0001_authority_meta.ts +33 -0
  98. package/ts/ts_migration/index.ts +7 -0
@@ -2,7 +2,7 @@ import type { IAccountType, IHarnessAccount, IHarnessAccountStatus, IHarnessBill
2
2
 
3
3
  /** Credential-free, versioned output of list --json. Missing status fields stay omitted. */
4
4
  export interface IAccountList {
5
- schemaVersion: 2;
5
+ schemaVersion: 3;
6
6
  generatedAt: string;
7
7
  complete: boolean;
8
8
  harnesses: IHarnessAccountList[];
@@ -22,7 +22,7 @@ export interface IHarnessAccountList {
22
22
 
23
23
  /** Credential-free, versioned output of limits --json. One entry per account and limit type. */
24
24
  export interface IAccountLimits {
25
- schemaVersion: 1;
25
+ schemaVersion: 2;
26
26
  generatedAt: string;
27
27
  complete: boolean;
28
28
  limits: IAccountLimitRow[];
@@ -36,6 +36,9 @@ export interface IAccountLimitRow {
36
36
  provider: string;
37
37
  /** The account's public label, which is its email wherever the provider reports one. */
38
38
  account: string | null;
39
+ /** Exact provider-native account identifier; null when unavailable or this row names no account. */
40
+ providerAccountId: string | null;
41
+ /** Opaque authswitch account identifier used for harness operations. */
39
42
  accountId: string | null;
40
43
  slotId?: string;
41
44
  isActive: boolean;
@@ -61,7 +64,7 @@ export interface IAccountLimitRow {
61
64
 
62
65
  /** Credential-free, versioned output of active --json. One entry per active credential slot. */
63
66
  export interface IActiveAccounts {
64
- schemaVersion: 1;
67
+ schemaVersion: 2;
65
68
  generatedAt: string;
66
69
  complete: boolean;
67
70
  active: IActiveAccountRow[];
@@ -72,6 +75,9 @@ export interface IActiveAccountRow {
72
75
  harnessId: string;
73
76
  provider: string;
74
77
  account: string | null;
78
+ /** Exact provider-native account identifier; null when unavailable or this row names no account. */
79
+ providerAccountId: string | null;
80
+ /** Opaque authswitch account identifier used for harness operations. */
75
81
  accountId: string | null;
76
82
  slotId?: string;
77
83
  /** The adapter's plan name (`max`, `pro`), sanitised but not display-formatted; null when none is known or the row names no account. */
package/ts/plugins.ts CHANGED
@@ -5,11 +5,12 @@ import * as path from 'node:path';
5
5
  import * as childProcess from 'node:child_process';
6
6
  import * as crypto from 'node:crypto';
7
7
  import * as net from 'node:net';
8
+ import * as stream from 'node:stream';
8
9
  import { createRequire } from 'node:module';
9
10
  import { fileURLToPath } from 'node:url';
10
11
  import type { DatabaseSync } from 'node:sqlite';
11
12
 
12
- export { childProcess, crypto, fileURLToPath, fs, net, os, path };
13
+ export { childProcess, crypto, fileURLToPath, fs, net, os, path, stream };
13
14
  export type { DatabaseSync };
14
15
  const nativeRequire = createRequire(import.meta.url);
15
16
  /** SQLite is needed only when accessing a Codex state database, not when hosting account APIs. */
@@ -24,18 +25,23 @@ export type TProperLockfile = typeof properLockfile;
24
25
  */
25
26
  export const loadProperLockfile = (): Promise<TProperLockfile> => import('proper-lockfile');
26
27
 
28
+ // @lossless.org modules
29
+ import * as smartbucket from '@lossless.org/client/objectstorage';
30
+
27
31
  // @push.rocks modules
28
32
  import * as smartconsole from '@push.rocks/smartconsole';
33
+ import * as smartcrypto from '@push.rocks/smartcrypto';
29
34
  import * as smartdata from '@push.rocks/smartdata';
30
35
  import * as smartdb from '@push.rocks/smartdb';
31
36
  import * as smartsecret from '@push.rocks/smartsecret';
32
37
  import * as smartdaemon from '@push.rocks/smartdaemon';
33
38
  import * as typedrequest from '@api.global/typedrequest';
34
- export { smartconsole, smartdata, smartdb, smartsecret, smartdaemon, typedrequest };
39
+ export { smartbucket, smartconsole, smartcrypto, smartdata, smartdb, smartsecret, smartdaemon, typedrequest };
35
40
 
36
41
  // @modelprofile.com modules
37
42
  import * as flexModels from '@modelprofile.com/flexharness-models';
38
43
  import * as flexOpenAi from '@modelprofile.com/flexharness-providers/openai';
39
44
  import * as flexAuth from '@modelprofile.com/flexharness-providers/auth';
40
45
  import * as flexAccounts from '@modelprofile.com/flexharness-providers/accounts';
41
- export { flexModels, flexOpenAi, flexAuth, flexAccounts };
46
+ import * as crossharness from '@modelprofile.com/mcp-crossharness';
47
+ export { flexModels, flexOpenAi, flexAuth, flexAccounts, crossharness };
@@ -0,0 +1,33 @@
1
+ import type { SmartdataDb } from '@push.rocks/smartdata';
2
+ import { assertStoredAuthorityMeta } from '../classes.authoritymodels.js';
3
+
4
+ const reserved = new Set(['_id', '_smartdataRevision', '_createdAt', '_updatedAt']);
5
+ const keys = ['id', 'epoch', 'revision', 'updateId'];
6
+ const uuid = (value: unknown): boolean => typeof value === 'string' && /^[a-f0-9-]{36}$/.test(value);
7
+
8
+ /** One-time published 6.4/6.5 metadata upgrade, under the exclusive LocalSmartDb root owner. */
9
+ export const migrateAuthorityMetaV1 = async (db: SmartdataDb): Promise<void> => {
10
+ const collection = db.mongoDb.collection('authswitch_authority_meta');
11
+ const stored = await collection.findOne({ id: 'authswitch-authority' });
12
+ if (!stored) throw new Error('Existing authswitch authority database has no metadata.');
13
+ const body = Object.fromEntries(Object.entries(stored).filter(([key]) => !reserved.has(key)));
14
+ if (body.schemaVersion === 2) {
15
+ assertStoredAuthorityMeta(body);
16
+ return;
17
+ }
18
+ if (Object.keys(body).length !== keys.length || !keys.every(key => Object.hasOwn(body, key))
19
+ || body.id !== 'authswitch-authority' || !uuid(body.epoch) || !uuid(body.updateId)
20
+ || !Number.isSafeInteger(body.revision) || Number(body.revision) < 0) {
21
+ throw new Error('Existing authswitch authority metadata has an unknown schema.');
22
+ }
23
+ const result = await collection.updateOne({ _id: stored._id, id: 'authswitch-authority',
24
+ schemaVersion: { $exists: false }, admission: { $exists: false } },
25
+ { $set: { schemaVersion: 2, admission: 'open' } });
26
+ if (result.matchedCount !== 1 || result.modifiedCount !== 1) {
27
+ throw new Error('Authswitch authority metadata migration did not commit exactly once.');
28
+ }
29
+ const migrated = await collection.findOne({ _id: stored._id });
30
+ if (!migrated) throw new Error('Authswitch authority metadata disappeared during migration.');
31
+ assertStoredAuthorityMeta(Object.fromEntries(Object.entries(migrated)
32
+ .filter(([key]) => !reserved.has(key))));
33
+ };
@@ -0,0 +1,7 @@
1
+ import type { SmartdataDb } from '@push.rocks/smartdata';
2
+ import { migrateAuthorityMetaV1 } from './0001_authority_meta.js';
3
+
4
+ /** The persisted metadata schema version records completion. Order is fixed for later migrations. */
5
+ export const runAuthorityMigrations = async (db: SmartdataDb): Promise<void> => {
6
+ await migrateAuthorityMetaV1(db);
7
+ };