@modelprofile.com/authswitch 7.0.0 → 8.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.
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/authority-contract.d.ts +1 -3
- package/dist_ts/authority-contract.js +1 -1
- package/dist_ts/authority-import-contract.d.ts +207 -0
- package/dist_ts/authority-import-contract.js +18 -0
- package/dist_ts/classes.authoritybroker.js +1 -5
- package/dist_ts/classes.authoritycli.d.ts +4 -0
- package/dist_ts/classes.authoritycli.js +149 -12
- package/dist_ts/classes.authorityclient.d.ts +7 -0
- package/dist_ts/classes.authorityclient.js +13 -1
- package/dist_ts/classes.authoritydaemon.d.ts +4 -0
- package/dist_ts/classes.authoritydaemon.js +75 -9
- package/dist_ts/classes.authoritydatabase.d.ts +10 -26
- package/dist_ts/classes.authoritydatabase.js +68 -133
- package/dist_ts/classes.authorityimport.d.ts +161 -0
- package/dist_ts/classes.authorityimport.js +638 -0
- package/dist_ts/classes.authoritymodels.d.ts +39 -43
- package/dist_ts/classes.authoritymodels.js +209 -243
- package/dist_ts/classes.authoritypreuse.js +1 -2
- package/dist_ts/classes.authorityregistry.d.ts +2 -17
- package/dist_ts/classes.authorityregistry.js +18 -74
- package/dist_ts/classes.authoritysecrets.d.ts +1 -1
- package/dist_ts/classes.authoritysecrets.js +2 -2
- package/dist_ts/classes.authorityusage.d.ts +3 -3
- package/dist_ts/classes.claudeauthority.js +3 -7
- package/dist_ts/classes.claudenative.d.ts +1 -8
- package/dist_ts/classes.claudenative.js +2 -25
- package/dist_ts/classes.codexmanaged.d.ts +1 -1
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +6 -3
- package/dist_ts/plugins.d.ts +7 -7
- package/dist_ts/plugins.js +8 -8
- package/dist_ts/ts_migration/0001_authority_meta.d.ts +13 -3
- package/dist_ts/ts_migration/0001_authority_meta.js +29 -17
- 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 -3
- package/dist_ts/ts_migration/index.js +10 -4
- package/dist_ts/ts_migration/legacysources/authswitchstores.d.ts +2 -0
- package/dist_ts/ts_migration/legacysources/authswitchstores.js +244 -0
- package/dist_ts/ts_migration/legacysources/index.d.ts +18 -0
- package/dist_ts/ts_migration/legacysources/index.js +24 -0
- package/dist_ts/ts_migration/legacysources/material.d.ts +37 -0
- package/dist_ts/ts_migration/legacysources/material.js +120 -0
- package/dist_ts/ts_migration/legacysources/nativestores.d.ts +2 -0
- package/dist_ts/ts_migration/legacysources/nativestores.js +207 -0
- package/dist_ts/ts_migration/legacysources/shared.d.ts +124 -0
- package/dist_ts/ts_migration/legacysources/shared.js +142 -0
- package/package.json +6 -5
- package/readme.md +68 -26
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/authority-contract.ts +1 -3
- package/ts/authority-import-contract.ts +216 -0
- package/ts/classes.authoritybroker.ts +0 -4
- package/ts/classes.authoritycli.ts +165 -11
- package/ts/classes.authorityclient.ts +22 -0
- package/ts/classes.authoritydaemon.ts +75 -8
- package/ts/classes.authoritydatabase.ts +70 -145
- package/ts/classes.authorityimport.ts +718 -0
- package/ts/classes.authoritymodels.ts +253 -269
- package/ts/classes.authoritypreuse.ts +0 -1
- package/ts/classes.authorityregistry.ts +20 -91
- package/ts/classes.authoritysecrets.ts +1 -1
- package/ts/classes.authorityusage.ts +3 -3
- package/ts/classes.claudeauthority.ts +2 -6
- package/ts/classes.claudenative.ts +1 -32
- package/ts/classes.codexmanaged.ts +1 -1
- package/ts/index.ts +5 -2
- package/ts/plugins.ts +7 -7
- package/ts/ts_migration/0001_authority_meta.ts +29 -17
- package/ts/ts_migration/0002_remove_backup_records.ts +49 -0
- package/ts/ts_migration/index.ts +10 -5
- package/ts/ts_migration/legacysources/authswitchstores.ts +211 -0
- package/ts/ts_migration/legacysources/index.ts +35 -0
- package/ts/ts_migration/legacysources/material.ts +134 -0
- package/ts/ts_migration/legacysources/nativestores.ts +204 -0
- package/ts/ts_migration/legacysources/shared.ts +220 -0
- package/dist_ts/authorityrehearsal.child.d.ts +0 -1
- package/dist_ts/authorityrehearsal.child.js +0 -395
- package/dist_ts/classes.authoritybackup.d.ts +0 -134
- package/dist_ts/classes.authoritybackup.js +0 -769
- package/dist_ts/classes.authorityrehearsal.d.ts +0 -127
- package/dist_ts/classes.authorityrehearsal.js +0 -632
- package/ts/authorityrehearsal.child.ts +0 -330
- package/ts/classes.authoritybackup.ts +0 -780
- package/ts/classes.authorityrehearsal.ts +0 -625
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import type { AuthSwitchAuthorityDatabase } from './classes.authoritydatabase.js';
|
|
3
|
+
import { type IAuthSwitchSecretCodec } from './classes.authoritysecrets.js';
|
|
4
|
+
import { type IClaudeLogin, type IClaudeStatusRead } from './classes.claudestatus.js';
|
|
5
|
+
import { type TClaudeAuthorityRefreshResult } from './classes.claudetokenrefresh.js';
|
|
6
|
+
import { type THarnessBinary } from './classes.harnessprocesses.js';
|
|
7
|
+
import type { IAuthSwitchImportInventory, IAuthSwitchImportResult, IAuthSwitchImportStatus, TAuthSwitchImportSubmission } from './authority-import-contract.js';
|
|
8
|
+
/**
|
|
9
|
+
* What this daemon can observe about writers of the legacy stores.
|
|
10
|
+
*
|
|
11
|
+
* It cannot observe every writer: a host that uses the legacy library inside its own process is invisible
|
|
12
|
+
* here, which is why a submission also carries the caller's own assertion. Unknown is never idle.
|
|
13
|
+
*/
|
|
14
|
+
export interface IAuthSwitchImportQuiescence {
|
|
15
|
+
/** The live pid of the authswitch watch that owns the legacy stores, or null when none runs. */
|
|
16
|
+
watchHolderPid(): number | null;
|
|
17
|
+
runningHarnessPids(binary: THarnessBinary): readonly number[];
|
|
18
|
+
/** Codex's own answer about its app-server. `null` means unknown, which counts as running. */
|
|
19
|
+
codexAppServerRunning(): boolean | null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Exactly the two provider operations an import needs, so nothing here can reach for a third.
|
|
23
|
+
*
|
|
24
|
+
* `OpenAiProviderAdapter` satisfies this; naming only what is used keeps the rotating call countable and
|
|
25
|
+
* makes it visible that a projection never touches `refreshCredential`.
|
|
26
|
+
*/
|
|
27
|
+
export interface IAuthSwitchImportOpenAiOperations {
|
|
28
|
+
refreshCredential(credential: plugins.flexAccounts.IOpenAiChatGptOAuthCredential): Promise<plugins.flexAccounts.TSmartAiProviderRefreshResult>;
|
|
29
|
+
getAccountRateLimits(credential: plugins.flexAccounts.TOpenAiChatGptReadCredential): Promise<plugins.flexAccounts.TSmartAiProviderAccountRateLimitsResult>;
|
|
30
|
+
}
|
|
31
|
+
/** The non-rotating Claude proof: one profile read that must name the expected immutable identity. */
|
|
32
|
+
export interface IAuthSwitchImportClaudeStatus {
|
|
33
|
+
readDetailed(login: IClaudeLogin): Promise<IClaudeStatusRead>;
|
|
34
|
+
}
|
|
35
|
+
/** The rotating Claude refresh, with its own explicit uncertain outcome. */
|
|
36
|
+
export interface IAuthSwitchImportClaudeTokens {
|
|
37
|
+
refreshForAuthority(oauth: Record<string, unknown>): Promise<TClaudeAuthorityRefreshResult>;
|
|
38
|
+
}
|
|
39
|
+
export interface IAuthSwitchAuthorityImportOptions {
|
|
40
|
+
/** Locates the legacy stores, exactly as each owning class locates its own. */
|
|
41
|
+
env?: NodeJS.ProcessEnv;
|
|
42
|
+
homeDirectory?: string;
|
|
43
|
+
now?: () => number;
|
|
44
|
+
/** The one rotating refresh of an imported ChatGPT login, and the non-rotating read that proves one. */
|
|
45
|
+
openAi?: IAuthSwitchImportOpenAiOperations;
|
|
46
|
+
claudeStatus?: IAuthSwitchImportClaudeStatus;
|
|
47
|
+
claudeTokens?: IAuthSwitchImportClaudeTokens;
|
|
48
|
+
secrets?: IAuthSwitchSecretCodec;
|
|
49
|
+
quiescence?: IAuthSwitchImportQuiescence;
|
|
50
|
+
}
|
|
51
|
+
/** Reads the host: the watch lock file, the process table and Codex's own daemon status. */
|
|
52
|
+
export declare class AuthSwitchImportHostQuiescence implements IAuthSwitchImportQuiescence {
|
|
53
|
+
private readonly authSwitchHome;
|
|
54
|
+
private readonly codexHome;
|
|
55
|
+
constructor(authSwitchHome: string, codexHome: string);
|
|
56
|
+
watchHolderPid(): number | null;
|
|
57
|
+
runningHarnessPids(binary: THarnessBinary): readonly number[];
|
|
58
|
+
codexAppServerRunning(): boolean | null;
|
|
59
|
+
}
|
|
60
|
+
/** A refusal the owner can act on. It never leaves a half-written import behind. */
|
|
61
|
+
export declare class AuthSwitchImportRefusal extends Error {
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The one-time account import.
|
|
65
|
+
*
|
|
66
|
+
* It reads the legacy stores through the isolated migration readers and reports them against the authority's
|
|
67
|
+
* migration ledger. Nothing here is a runtime fallback: no ordinary authority operation reaches this class,
|
|
68
|
+
* and it never writes to a legacy store.
|
|
69
|
+
*/
|
|
70
|
+
export declare class AuthSwitchAuthorityImport {
|
|
71
|
+
private readonly database;
|
|
72
|
+
private readonly env;
|
|
73
|
+
private readonly homeDirectory;
|
|
74
|
+
private readonly now;
|
|
75
|
+
private readonly openAi;
|
|
76
|
+
private readonly claudeStatus;
|
|
77
|
+
private readonly claudeTokens;
|
|
78
|
+
private readonly secrets;
|
|
79
|
+
private readonly quiescence;
|
|
80
|
+
constructor(database: AuthSwitchAuthorityDatabase, options?: IAuthSwitchAuthorityImportOptions);
|
|
81
|
+
/** The credential-free report. Reads the legacy stores and the ledger; writes nothing. */
|
|
82
|
+
inventory(): Promise<IAuthSwitchImportInventory>;
|
|
83
|
+
/**
|
|
84
|
+
* Where every source the authority knows about stands.
|
|
85
|
+
*
|
|
86
|
+
* Read from the migration ledger, the grants and the handoffs only: it opens no legacy store, so it stays
|
|
87
|
+
* truthful about what the authority decided even if a source has since been moved or deleted on the host.
|
|
88
|
+
* A source that was never submitted has no ledger row and belongs to the inventory, not here.
|
|
89
|
+
*/
|
|
90
|
+
status(request?: {
|
|
91
|
+
after?: string;
|
|
92
|
+
limit?: number;
|
|
93
|
+
}): Promise<IAuthSwitchImportStatus>;
|
|
94
|
+
/**
|
|
95
|
+
* Imports one source.
|
|
96
|
+
*
|
|
97
|
+
* A source whose grant the authority takes over is verified by one real refresh, which rotates its token
|
|
98
|
+
* and is the point of no return; a source a native tool keeps refreshing is verified by a provider read
|
|
99
|
+
* that rotates nothing. Every step before the refresh is durable, and the marker that says "the exchange
|
|
100
|
+
* may have been sent" is the handoff's own `source_stopped` phase: a restart that finds it never replays
|
|
101
|
+
* the grant, it asks for a device sign-in instead.
|
|
102
|
+
*/
|
|
103
|
+
submit(request: {
|
|
104
|
+
submission: TAuthSwitchImportSubmission;
|
|
105
|
+
callerQuiescent: true;
|
|
106
|
+
acknowledgeRunOrder: true;
|
|
107
|
+
}): Promise<IAuthSwitchImportResult>;
|
|
108
|
+
/** The source a submission names, proven to be the one that was inventoried. */
|
|
109
|
+
private resolveSource;
|
|
110
|
+
private externalIdentity;
|
|
111
|
+
/** Reads the credential the daemon will seal. Only an external submission brings its own. */
|
|
112
|
+
private material;
|
|
113
|
+
/**
|
|
114
|
+
* Refuses while anything that could refresh this source is running.
|
|
115
|
+
*
|
|
116
|
+
* Unknown counts as running: an import that guessed idle could rotate a token another owner is using.
|
|
117
|
+
*/
|
|
118
|
+
private assertQuiescent;
|
|
119
|
+
private beginLedger;
|
|
120
|
+
private moveLedger;
|
|
121
|
+
private stamp;
|
|
122
|
+
private account;
|
|
123
|
+
/** Writes the account and its grant, choosing the primary or the secondary transaction by identity. */
|
|
124
|
+
private putGrant;
|
|
125
|
+
private baseGrant;
|
|
126
|
+
/** Refuses a source whose grant another owner already holds, in either direction. */
|
|
127
|
+
private assertOwnable;
|
|
128
|
+
/**
|
|
129
|
+
* A projected source: the account is registered, the grant stays with its native owner, and the proof is a
|
|
130
|
+
* provider read that rotates nothing. No refresh is ever sent here.
|
|
131
|
+
*/
|
|
132
|
+
private project;
|
|
133
|
+
/** The non-rotating proof: the stored access token is asked about itself and must name this account. */
|
|
134
|
+
private proveWithoutRotation;
|
|
135
|
+
/**
|
|
136
|
+
* A source the authority takes over.
|
|
137
|
+
*
|
|
138
|
+
* The handoff row is the durable record of how far this went. `source_stopped` is written before the
|
|
139
|
+
* refresh is sent, so a lost answer is always visible afterwards and is never retried.
|
|
140
|
+
*/
|
|
141
|
+
private adopt;
|
|
142
|
+
private moveHandoff;
|
|
143
|
+
private failHandoff;
|
|
144
|
+
/**
|
|
145
|
+
* Marks a source whose sign-in exchange may already have been consumed. That is its only meaning, so the
|
|
146
|
+
* refusal a later submission gets needs no further reason: the repair is always a device sign-in.
|
|
147
|
+
*/
|
|
148
|
+
private quarantine;
|
|
149
|
+
/**
|
|
150
|
+
* The one rotating refresh. `null` means the outcome is unknown and the grant must never be replayed.
|
|
151
|
+
*
|
|
152
|
+
* A thrown error is the same answer as a failed one: once the request left this process, whether the
|
|
153
|
+
* provider consumed the token is unknowable, so both end in a device sign-in rather than a retry.
|
|
154
|
+
*/
|
|
155
|
+
private rotate;
|
|
156
|
+
private rotateOnce;
|
|
157
|
+
private seal;
|
|
158
|
+
/** Codex remote-control enrollments travel with the credential; losing them is losing a pairing. */
|
|
159
|
+
private storeEnrollments;
|
|
160
|
+
private result;
|
|
161
|
+
}
|