@modelprofile.com/authswitch 6.3.0 → 6.4.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 +142 -0
- package/dist_ts/authority-contract.js +3 -0
- package/dist_ts/authority-runtime-contract.d.ts +32 -0
- package/dist_ts/authority-runtime-contract.js +2 -0
- package/dist_ts/classes.authoritybroker.d.ts +73 -0
- package/dist_ts/classes.authoritybroker.js +548 -0
- package/dist_ts/classes.authorityclient.d.ts +34 -0
- package/dist_ts/classes.authorityclient.js +200 -0
- package/dist_ts/classes.authoritydaemon.d.ts +26 -0
- package/dist_ts/classes.authoritydaemon.js +249 -0
- package/dist_ts/classes.authoritydatabase.d.ts +94 -0
- package/dist_ts/classes.authoritydatabase.js +736 -0
- package/dist_ts/classes.authorityframing.d.ts +8 -0
- package/dist_ts/classes.authorityframing.js +22 -0
- package/dist_ts/classes.authoritymodels.d.ts +215 -0
- package/dist_ts/classes.authoritymodels.js +818 -0
- package/dist_ts/classes.authoritysecrets.d.ts +9 -0
- package/dist_ts/classes.authoritysecrets.js +30 -0
- package/dist_ts/classes.authorityservice.d.ts +28 -0
- package/dist_ts/classes.authorityservice.js +71 -0
- package/dist_ts/index.d.ts +2 -0
- package/dist_ts/index.js +26 -1
- package/dist_ts/plugins.d.ts +9 -2
- package/dist_ts/plugins.js +10 -3
- package/package.json +17 -3
- package/readme.md +34 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/authority-contract.ts +109 -0
- package/ts/authority-runtime-contract.ts +27 -0
- package/ts/classes.authoritybroker.ts +530 -0
- package/ts/classes.authorityclient.ts +183 -0
- package/ts/classes.authoritydaemon.ts +219 -0
- package/ts/classes.authoritydatabase.ts +725 -0
- package/ts/classes.authorityframing.ts +21 -0
- package/ts/classes.authoritymodels.ts +367 -0
- package/ts/classes.authoritysecrets.ts +27 -0
- package/ts/classes.authorityservice.ts +83 -0
- package/ts/index.ts +25 -0
- package/ts/plugins.ts +9 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** One bounded UTF-8 JSON line. Decode only after the complete byte frame arrives. */
|
|
2
|
+
export declare class AuthSwitchAuthorityFrameReader {
|
|
3
|
+
private readonly chunks;
|
|
4
|
+
private bytes;
|
|
5
|
+
add(chunk: Buffer): string | null;
|
|
6
|
+
}
|
|
7
|
+
export declare const authSwitchAuthorityFrameBytes: (value: string) => number;
|
|
8
|
+
export declare const maxAuthSwitchAuthorityFrameBytes: number;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const maxFrameBytes = 1024 * 1024;
|
|
2
|
+
/** One bounded UTF-8 JSON line. Decode only after the complete byte frame arrives. */
|
|
3
|
+
export class AuthSwitchAuthorityFrameReader {
|
|
4
|
+
chunks = [];
|
|
5
|
+
bytes = 0;
|
|
6
|
+
add(chunk) {
|
|
7
|
+
if (chunk.length > maxFrameBytes - this.bytes)
|
|
8
|
+
throw new Error('Authswitch authority frame is too large.');
|
|
9
|
+
this.chunks.push(chunk);
|
|
10
|
+
this.bytes += chunk.length;
|
|
11
|
+
const end = chunk.indexOf(0x0a);
|
|
12
|
+
if (end < 0)
|
|
13
|
+
return null;
|
|
14
|
+
if (end !== chunk.length - 1)
|
|
15
|
+
throw new Error('Authswitch authority frame contains trailing data.');
|
|
16
|
+
const frame = Buffer.concat(this.chunks, this.bytes);
|
|
17
|
+
return new TextDecoder('utf-8', { fatal: true }).decode(frame.subarray(0, frame.length - 1));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export const authSwitchAuthorityFrameBytes = (value) => Buffer.byteLength(value, 'utf8') + 1;
|
|
21
|
+
export const maxAuthSwitchAuthorityFrameBytes = maxFrameBytes;
|
|
22
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5hdXRob3JpdHlmcmFtaW5nLmpzIiwic291cmNlUm9vdCI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DLFFBQVEsQ0FBQyxDQUFDLEVBQUUsS0FBSyxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUMsQ0FBQyxDQUFDO0lBQy9GLENBQUM7Q0FDRjtBQUVELE1BQU0sQ0FBQyxNQUFNLDZCQUE2QixHQUFHLENBQUMsS0FBYSxFQUFVLEVBQUUsQ0FBQyxNQUFNLENBQUMsVUFBVSxDQUFDLEtBQUssRUFBRSxNQUFNLENBQUMsR0FBRyxDQUFDLENBQUM7QUFDN0csTUFBTSxDQUFDLE1BQU0sZ0NBQWdDLEdBQUcsYUFBYSxDQUFDIn0=
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
export interface IStoredAuthorityMeta {
|
|
3
|
+
id: 'authswitch-authority';
|
|
4
|
+
epoch: string;
|
|
5
|
+
revision: number;
|
|
6
|
+
updateId: string;
|
|
7
|
+
}
|
|
8
|
+
/** Identity and presentation only. No refresh grant or native-home ownership lives here. */
|
|
9
|
+
export interface IStoredAuthorityAccount {
|
|
10
|
+
id: string;
|
|
11
|
+
providerId: string;
|
|
12
|
+
issuer: string;
|
|
13
|
+
subject: string;
|
|
14
|
+
workspaceId: string;
|
|
15
|
+
label: string;
|
|
16
|
+
email: string | null;
|
|
17
|
+
plan: string | null;
|
|
18
|
+
primaryGrantId: string | null;
|
|
19
|
+
removed: boolean;
|
|
20
|
+
revision: number;
|
|
21
|
+
statusObservedAt: string;
|
|
22
|
+
updateId: string;
|
|
23
|
+
}
|
|
24
|
+
export type TStoredGrantPurpose = 'openai_managed' | 'claude_host_native' | 'claude_container_setup' | 'opencode_native';
|
|
25
|
+
/** Each purpose has its own grant, ownership, generation and refresh state. */
|
|
26
|
+
export interface IStoredAuthorityGrant {
|
|
27
|
+
id: string;
|
|
28
|
+
accountId: string;
|
|
29
|
+
providerId: string;
|
|
30
|
+
purpose: TStoredGrantPurpose;
|
|
31
|
+
audience: string;
|
|
32
|
+
state: 'ready' | 'exchange_may_have_been_sent' | 'retry_wait' | 'needs_reauth' | 'native' | 'legacy_native_pending' | 'removed';
|
|
33
|
+
owner: 'daemon' | 'claude_native' | 'legacy_native' | 'none';
|
|
34
|
+
grantGeneration: number;
|
|
35
|
+
authorizationGeneration: number;
|
|
36
|
+
revision: number;
|
|
37
|
+
ciphertext: string | null;
|
|
38
|
+
accessExpiresAt: string | null;
|
|
39
|
+
attemptId: string | null;
|
|
40
|
+
retryAt: string | null;
|
|
41
|
+
retryCount: number;
|
|
42
|
+
problem: 'none' | 'provider_unavailable' | 'exchange_uncertain' | 'provider_rejected' | 'native_owner';
|
|
43
|
+
statusObservedAt: string;
|
|
44
|
+
updateId: string;
|
|
45
|
+
}
|
|
46
|
+
export interface IStoredAuthorityBinding {
|
|
47
|
+
id: string;
|
|
48
|
+
accountId: string;
|
|
49
|
+
grantId: string;
|
|
50
|
+
runtime: 'flex' | 'codex' | 'opencode' | 'claude';
|
|
51
|
+
scopeId: string;
|
|
52
|
+
incarnationId: string;
|
|
53
|
+
revision: number;
|
|
54
|
+
grantAuthorizationGeneration: number;
|
|
55
|
+
capabilityHash: string;
|
|
56
|
+
updateId: string;
|
|
57
|
+
}
|
|
58
|
+
/** Codex enrollment is separate from a refresh grant and sealed under its own record ID. */
|
|
59
|
+
export interface IStoredAuthorityEnrollment {
|
|
60
|
+
id: string;
|
|
61
|
+
accountId: string;
|
|
62
|
+
ciphertext: string;
|
|
63
|
+
revision: number;
|
|
64
|
+
updateId: string;
|
|
65
|
+
}
|
|
66
|
+
/** Journal for a native-home handoff. A prepared grant is never usable. */
|
|
67
|
+
export interface IStoredAuthorityHandoff {
|
|
68
|
+
id: string;
|
|
69
|
+
accountId: string;
|
|
70
|
+
grantId: string;
|
|
71
|
+
nativeHomeId: string;
|
|
72
|
+
direction: 'to_native' | 'to_daemon';
|
|
73
|
+
phase: 'prepared' | 'source_stopped' | 'target_written' | 'verified' | 'committed' | 'needs_reauth' | 'aborted';
|
|
74
|
+
operationId: string;
|
|
75
|
+
sourceDigest: string;
|
|
76
|
+
verifiedSourceDigest: string | null;
|
|
77
|
+
backupDigest: string | null;
|
|
78
|
+
revision: number;
|
|
79
|
+
statusObservedAt: string;
|
|
80
|
+
updateId: string;
|
|
81
|
+
}
|
|
82
|
+
/** One-time legacy source inventory; source path is hashed, never exposed in snapshots. */
|
|
83
|
+
export interface IStoredAuthorityMigrationLedger {
|
|
84
|
+
id: string;
|
|
85
|
+
version: number;
|
|
86
|
+
sourceKind: 'authswitch_stash' | 'authswitch_backup' | 'agl_flex' | 'codex_native' | 'opencode_native' | 'claude_native';
|
|
87
|
+
sourcePathHash: string;
|
|
88
|
+
sourceDigest: string;
|
|
89
|
+
status: 'pending_native_owner' | 'prepared' | 'verified' | 'complete' | 'quarantined';
|
|
90
|
+
accountId: string | null;
|
|
91
|
+
grantId: string | null;
|
|
92
|
+
backupDigest: string | null;
|
|
93
|
+
revision: number;
|
|
94
|
+
statusObservedAt: string;
|
|
95
|
+
updateId: string;
|
|
96
|
+
}
|
|
97
|
+
export interface IStoredAuthorityEvent {
|
|
98
|
+
id: string;
|
|
99
|
+
epoch: string;
|
|
100
|
+
revision: number;
|
|
101
|
+
kind: 'account' | 'binding';
|
|
102
|
+
accountId: string;
|
|
103
|
+
}
|
|
104
|
+
export declare const assertStoredAuthorityMeta: (value: unknown) => asserts value is IStoredAuthorityMeta;
|
|
105
|
+
export declare const assertStoredAuthorityAccount: (value: unknown) => asserts value is IStoredAuthorityAccount;
|
|
106
|
+
export declare const assertStoredAuthorityGrant: (value: unknown) => asserts value is IStoredAuthorityGrant;
|
|
107
|
+
export declare const assertStoredAuthorityBinding: (value: unknown) => asserts value is IStoredAuthorityBinding;
|
|
108
|
+
export declare const assertStoredAuthorityEnrollment: (value: unknown) => asserts value is IStoredAuthorityEnrollment;
|
|
109
|
+
export declare const assertStoredAuthorityHandoff: (value: unknown) => asserts value is IStoredAuthorityHandoff;
|
|
110
|
+
export declare const assertStoredAuthorityMigrationLedger: (value: unknown) => asserts value is IStoredAuthorityMigrationLedger;
|
|
111
|
+
export declare const assertStoredAuthorityEvent: (value: unknown) => asserts value is IStoredAuthorityEvent;
|
|
112
|
+
export declare class AuthSwitchAuthorityMetaModel extends plugins.smartdata.SmartDataDbDoc<AuthSwitchAuthorityMetaModel, IStoredAuthorityMeta> {
|
|
113
|
+
static exact: plugins.smartdata.TExact<AuthSwitchAuthorityMetaModel>;
|
|
114
|
+
id: 'authswitch-authority';
|
|
115
|
+
epoch: string;
|
|
116
|
+
revision: number;
|
|
117
|
+
updateId: string;
|
|
118
|
+
}
|
|
119
|
+
export declare class AuthSwitchAuthorityAccountModel extends plugins.smartdata.SmartDataDbDoc<AuthSwitchAuthorityAccountModel, IStoredAuthorityAccount> {
|
|
120
|
+
static exact: plugins.smartdata.TExact<AuthSwitchAuthorityAccountModel>;
|
|
121
|
+
id: string;
|
|
122
|
+
providerId: string;
|
|
123
|
+
issuer: string;
|
|
124
|
+
subject: string;
|
|
125
|
+
workspaceId: string;
|
|
126
|
+
label: string;
|
|
127
|
+
email: string | null;
|
|
128
|
+
plan: string | null;
|
|
129
|
+
primaryGrantId: string | null;
|
|
130
|
+
removed: boolean;
|
|
131
|
+
revision: number;
|
|
132
|
+
statusObservedAt: string;
|
|
133
|
+
updateId: string;
|
|
134
|
+
}
|
|
135
|
+
export declare class AuthSwitchAuthorityGrantModel extends plugins.smartdata.SmartDataDbDoc<AuthSwitchAuthorityGrantModel, IStoredAuthorityGrant> {
|
|
136
|
+
static exact: plugins.smartdata.TExact<AuthSwitchAuthorityGrantModel>;
|
|
137
|
+
id: string;
|
|
138
|
+
accountId: string;
|
|
139
|
+
providerId: string;
|
|
140
|
+
purpose: TStoredGrantPurpose;
|
|
141
|
+
audience: string;
|
|
142
|
+
state: IStoredAuthorityGrant['state'];
|
|
143
|
+
owner: IStoredAuthorityGrant['owner'];
|
|
144
|
+
grantGeneration: number;
|
|
145
|
+
authorizationGeneration: number;
|
|
146
|
+
revision: number;
|
|
147
|
+
ciphertext: string | null;
|
|
148
|
+
accessExpiresAt: string | null;
|
|
149
|
+
attemptId: string | null;
|
|
150
|
+
retryAt: string | null;
|
|
151
|
+
retryCount: number;
|
|
152
|
+
problem: IStoredAuthorityGrant['problem'];
|
|
153
|
+
statusObservedAt: string;
|
|
154
|
+
updateId: string;
|
|
155
|
+
}
|
|
156
|
+
export declare class AuthSwitchAuthorityBindingModel extends plugins.smartdata.SmartDataDbDoc<AuthSwitchAuthorityBindingModel, IStoredAuthorityBinding> {
|
|
157
|
+
static exact: plugins.smartdata.TExact<AuthSwitchAuthorityBindingModel>;
|
|
158
|
+
id: string;
|
|
159
|
+
accountId: string;
|
|
160
|
+
grantId: string;
|
|
161
|
+
runtime: IStoredAuthorityBinding['runtime'];
|
|
162
|
+
scopeId: string;
|
|
163
|
+
incarnationId: string;
|
|
164
|
+
revision: number;
|
|
165
|
+
grantAuthorizationGeneration: number;
|
|
166
|
+
capabilityHash: string;
|
|
167
|
+
updateId: string;
|
|
168
|
+
}
|
|
169
|
+
export declare class AuthSwitchAuthorityEnrollmentModel extends plugins.smartdata.SmartDataDbDoc<AuthSwitchAuthorityEnrollmentModel, IStoredAuthorityEnrollment> {
|
|
170
|
+
static exact: plugins.smartdata.TExact<AuthSwitchAuthorityEnrollmentModel>;
|
|
171
|
+
id: string;
|
|
172
|
+
accountId: string;
|
|
173
|
+
ciphertext: string;
|
|
174
|
+
revision: number;
|
|
175
|
+
updateId: string;
|
|
176
|
+
}
|
|
177
|
+
export declare class AuthSwitchAuthorityHandoffModel extends plugins.smartdata.SmartDataDbDoc<AuthSwitchAuthorityHandoffModel, IStoredAuthorityHandoff> {
|
|
178
|
+
static exact: plugins.smartdata.TExact<AuthSwitchAuthorityHandoffModel>;
|
|
179
|
+
id: string;
|
|
180
|
+
accountId: string;
|
|
181
|
+
grantId: string;
|
|
182
|
+
nativeHomeId: string;
|
|
183
|
+
direction: IStoredAuthorityHandoff['direction'];
|
|
184
|
+
phase: IStoredAuthorityHandoff['phase'];
|
|
185
|
+
operationId: string;
|
|
186
|
+
sourceDigest: string;
|
|
187
|
+
verifiedSourceDigest: string | null;
|
|
188
|
+
backupDigest: string | null;
|
|
189
|
+
revision: number;
|
|
190
|
+
statusObservedAt: string;
|
|
191
|
+
updateId: string;
|
|
192
|
+
}
|
|
193
|
+
export declare class AuthSwitchAuthorityMigrationLedgerModel extends plugins.smartdata.SmartDataDbDoc<AuthSwitchAuthorityMigrationLedgerModel, IStoredAuthorityMigrationLedger> {
|
|
194
|
+
static exact: plugins.smartdata.TExact<AuthSwitchAuthorityMigrationLedgerModel>;
|
|
195
|
+
id: string;
|
|
196
|
+
version: number;
|
|
197
|
+
sourceKind: IStoredAuthorityMigrationLedger['sourceKind'];
|
|
198
|
+
sourcePathHash: string;
|
|
199
|
+
sourceDigest: string;
|
|
200
|
+
status: IStoredAuthorityMigrationLedger['status'];
|
|
201
|
+
accountId: string | null;
|
|
202
|
+
grantId: string | null;
|
|
203
|
+
backupDigest: string | null;
|
|
204
|
+
revision: number;
|
|
205
|
+
statusObservedAt: string;
|
|
206
|
+
updateId: string;
|
|
207
|
+
}
|
|
208
|
+
export declare class AuthSwitchAuthorityEventModel extends plugins.smartdata.SmartDataDbDoc<AuthSwitchAuthorityEventModel, IStoredAuthorityEvent> {
|
|
209
|
+
static exact: plugins.smartdata.TExact<AuthSwitchAuthorityEventModel>;
|
|
210
|
+
id: string;
|
|
211
|
+
epoch: string;
|
|
212
|
+
revision: number;
|
|
213
|
+
kind: IStoredAuthorityEvent['kind'];
|
|
214
|
+
accountId: string;
|
|
215
|
+
}
|