@modelprofile.com/authswitch 6.5.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.
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/authority-contract.d.ts +302 -6
- package/dist_ts/authority-contract.js +1 -1
- package/dist_ts/authority-runtime-contract.d.ts +13 -0
- package/dist_ts/authorityrehearsal.child.d.ts +1 -0
- package/dist_ts/authorityrehearsal.child.js +395 -0
- package/dist_ts/classes.accountlist.js +4 -3
- package/dist_ts/classes.authoritybackup.d.ts +134 -0
- package/dist_ts/classes.authoritybackup.js +769 -0
- package/dist_ts/classes.authoritybroker.d.ts +25 -5
- package/dist_ts/classes.authoritybroker.js +392 -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 +482 -36
- package/dist_ts/classes.authoritydatabase.d.ts +175 -10
- package/dist_ts/classes.authoritydatabase.js +1100 -52
- package/dist_ts/classes.authoritymodels.d.ts +223 -1
- package/dist_ts/classes.authoritymodels.js +798 -9
- package/dist_ts/classes.authoritypreuse.d.ts +47 -0
- package/dist_ts/classes.authoritypreuse.js +278 -0
- package/dist_ts/classes.authorityregistry.d.ts +24 -0
- package/dist_ts/classes.authorityregistry.js +88 -0
- package/dist_ts/classes.authorityrehearsal.d.ts +127 -0
- package/dist_ts/classes.authorityrehearsal.js +632 -0
- 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 +532 -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 +137 -0
- package/dist_ts/classes.claudenative.js +731 -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 +11 -0
- 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 +5 -2
- package/dist_ts/plugins.js +7 -3
- package/dist_ts/ts_migration/0001_authority_meta.d.ts +3 -0
- package/dist_ts/ts_migration/0001_authority_meta.js +32 -0
- package/dist_ts/ts_migration/index.d.ts +3 -0
- package/dist_ts/ts_migration/index.js +6 -0
- package/package.json +4 -1
- package/readme.md +181 -14
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/authority-contract.ts +264 -9
- package/ts/authority-runtime-contract.ts +14 -0
- package/ts/authorityrehearsal.child.ts +330 -0
- package/ts/classes.accountlist.ts +3 -2
- package/ts/classes.authoritybackup.ts +780 -0
- package/ts/classes.authoritybroker.ts +389 -121
- package/ts/classes.authoritycli.ts +719 -0
- package/ts/classes.authorityclient.ts +75 -18
- package/ts/classes.authoritydaemon.ts +449 -36
- package/ts/classes.authoritydatabase.ts +1147 -55
- package/ts/classes.authoritymodels.ts +541 -6
- package/ts/classes.authoritypreuse.ts +297 -0
- package/ts/classes.authorityregistry.ts +118 -0
- package/ts/classes.authorityrehearsal.ts +625 -0
- package/ts/classes.authorityusage.ts +527 -0
- package/ts/classes.claudeauthority.ts +541 -0
- package/ts/classes.claudecodeharness.ts +2 -1
- package/ts/classes.claudecodelocks.ts +70 -1
- package/ts/classes.claudenative.ts +816 -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 +75 -12
- 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 +7 -2
- package/ts/ts_migration/0001_authority_meta.ts +33 -0
- package/ts/ts_migration/index.ts +7 -0
package/ts/interfaces.list.ts
CHANGED
|
@@ -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:
|
|
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:
|
|
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:
|
|
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,14 +25,18 @@ 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';
|
|
@@ -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
|
+
};
|