@modelprofile.com/authswitch 6.3.0 → 6.5.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 +34 -0
- package/dist_ts/authority-runtime-contract.js +2 -0
- package/dist_ts/classes.authoritybroker.d.ts +76 -0
- package/dist_ts/classes.authoritybroker.js +570 -0
- package/dist_ts/classes.authorityclient.d.ts +47 -0
- package/dist_ts/classes.authorityclient.js +261 -0
- package/dist_ts/classes.authoritydaemon.d.ts +46 -0
- package/dist_ts/classes.authoritydaemon.js +492 -0
- package/dist_ts/classes.authoritydatabase.d.ts +103 -0
- package/dist_ts/classes.authoritydatabase.js +835 -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 +239 -0
- package/dist_ts/classes.authoritymodels.js +893 -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/classes.codexmanaged.d.ts +80 -0
- package/dist_ts/classes.codexmanaged.js +343 -0
- package/dist_ts/index.d.ts +3 -0
- package/dist_ts/index.js +27 -1
- package/dist_ts/plugins.d.ts +11 -3
- package/dist_ts/plugins.js +12 -4
- package/package.json +25 -4
- package/readme.md +59 -0
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/authority-contract.ts +109 -0
- package/ts/authority-runtime-contract.ts +33 -0
- package/ts/classes.authoritybroker.ts +552 -0
- package/ts/classes.authorityclient.ts +252 -0
- package/ts/classes.authoritydaemon.ts +403 -0
- package/ts/classes.authoritydatabase.ts +818 -0
- package/ts/classes.authorityframing.ts +21 -0
- package/ts/classes.authoritymodels.ts +407 -0
- package/ts/classes.authoritysecrets.ts +27 -0
- package/ts/classes.authorityservice.ts +83 -0
- package/ts/classes.codexmanaged.ts +339 -0
- package/ts/index.ts +26 -0
- package/ts/plugins.ts +11 -3
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@modelprofile.com/authswitch',
|
|
6
|
-
version: '6.
|
|
6
|
+
version: '6.5.0',
|
|
7
7
|
description: 'Manage Codex, OpenCode and Claude Code accounts with guided switching and live usage status'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSw4QkFBOEI7SUFDcEMsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLDZGQUE2RjtDQUMzRyxDQUFBIn0=
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { ITypedRequest } from '@api.global/typedrequest-interfaces';
|
|
2
|
+
/** Credential-free account management contract. Safe to import in browser code. */
|
|
3
|
+
export type TAuthSwitchAccountHealth = 'ready' | 'refreshing' | 'retry_wait' | 'needs_reauth' | 'native' | 'legacy_native_pending' | 'removed';
|
|
4
|
+
export interface IAuthSwitchAccount {
|
|
5
|
+
id: string;
|
|
6
|
+
providerId: string;
|
|
7
|
+
label: string;
|
|
8
|
+
email: string | null;
|
|
9
|
+
plan: string | null;
|
|
10
|
+
health: TAuthSwitchAccountHealth;
|
|
11
|
+
owner: 'daemon' | 'claude_native' | 'legacy_native' | 'none';
|
|
12
|
+
grantGeneration: number;
|
|
13
|
+
revision: number;
|
|
14
|
+
accessExpiresAt: string | null;
|
|
15
|
+
retryAt: string | null;
|
|
16
|
+
problem: 'none' | 'provider_unavailable' | 'exchange_uncertain' | 'provider_rejected' | 'native_owner';
|
|
17
|
+
statusObservedAt: string;
|
|
18
|
+
}
|
|
19
|
+
export interface IAuthSwitchBinding {
|
|
20
|
+
id: string;
|
|
21
|
+
accountId: string;
|
|
22
|
+
runtime: 'flex' | 'codex' | 'opencode' | 'claude';
|
|
23
|
+
scopeId: string;
|
|
24
|
+
incarnationId: string;
|
|
25
|
+
revision: number;
|
|
26
|
+
}
|
|
27
|
+
export interface IAuthSwitchSnapshot {
|
|
28
|
+
schemaVersion: 1;
|
|
29
|
+
epoch: string;
|
|
30
|
+
revision: number;
|
|
31
|
+
generatedAt: string;
|
|
32
|
+
accounts: IAuthSwitchAccount[];
|
|
33
|
+
bindings: IAuthSwitchBinding[];
|
|
34
|
+
nextAccountCursor: string | null;
|
|
35
|
+
nextBindingCursor: string | null;
|
|
36
|
+
}
|
|
37
|
+
export interface IAuthSwitchAccountEvent {
|
|
38
|
+
epoch: string;
|
|
39
|
+
revision: number;
|
|
40
|
+
kind: 'account' | 'binding';
|
|
41
|
+
accountId: string;
|
|
42
|
+
}
|
|
43
|
+
export type TAuthSwitchLoginPrompt = {
|
|
44
|
+
flow: 'device';
|
|
45
|
+
verificationUrl: string;
|
|
46
|
+
userCode: string;
|
|
47
|
+
} | {
|
|
48
|
+
flow: 'browser';
|
|
49
|
+
authUrl: string;
|
|
50
|
+
};
|
|
51
|
+
export interface IAuthSwitchOperation {
|
|
52
|
+
id: string;
|
|
53
|
+
state: 'pending' | 'complete' | 'failed' | 'cancelled';
|
|
54
|
+
prompt: TAuthSwitchLoginPrompt | null;
|
|
55
|
+
account: IAuthSwitchAccount | null;
|
|
56
|
+
error: string | null;
|
|
57
|
+
}
|
|
58
|
+
export interface IReq_AuthSwitchSnapshot extends ITypedRequest {
|
|
59
|
+
method: 'authswitch.authority.snapshot';
|
|
60
|
+
request: {
|
|
61
|
+
accountAfter?: string;
|
|
62
|
+
bindingAfter?: string;
|
|
63
|
+
limit?: number;
|
|
64
|
+
};
|
|
65
|
+
response: {
|
|
66
|
+
snapshot: IAuthSwitchSnapshot;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
export interface IReq_AuthSwitchEvents extends ITypedRequest {
|
|
70
|
+
method: 'authswitch.authority.events';
|
|
71
|
+
request: {
|
|
72
|
+
epoch: string;
|
|
73
|
+
afterRevision: number;
|
|
74
|
+
waitMs: number;
|
|
75
|
+
};
|
|
76
|
+
response: {
|
|
77
|
+
epoch: string;
|
|
78
|
+
revision: number;
|
|
79
|
+
resyncRequired: boolean;
|
|
80
|
+
events: IAuthSwitchAccountEvent[];
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export interface IReq_AuthSwitchBeginAdd extends ITypedRequest {
|
|
84
|
+
method: 'authswitch.authority.add';
|
|
85
|
+
request: {
|
|
86
|
+
providerId: 'openai';
|
|
87
|
+
flow: 'device';
|
|
88
|
+
};
|
|
89
|
+
response: {
|
|
90
|
+
operation: IAuthSwitchOperation;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
export interface IReq_AuthSwitchBeginReauth extends ITypedRequest {
|
|
94
|
+
method: 'authswitch.authority.reauth';
|
|
95
|
+
request: {
|
|
96
|
+
accountId: string;
|
|
97
|
+
flow: 'device';
|
|
98
|
+
};
|
|
99
|
+
response: {
|
|
100
|
+
operation: IAuthSwitchOperation;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export interface IReq_AuthSwitchGetOperation extends ITypedRequest {
|
|
104
|
+
method: 'authswitch.authority.operation';
|
|
105
|
+
request: {
|
|
106
|
+
operationId: string;
|
|
107
|
+
};
|
|
108
|
+
response: {
|
|
109
|
+
operation: IAuthSwitchOperation;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export interface IReq_AuthSwitchCancelOperation extends ITypedRequest {
|
|
113
|
+
method: 'authswitch.authority.cancel';
|
|
114
|
+
request: {
|
|
115
|
+
operationId: string;
|
|
116
|
+
};
|
|
117
|
+
response: {
|
|
118
|
+
operation: IAuthSwitchOperation;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
export interface IReq_AuthSwitchRenameAccount extends ITypedRequest {
|
|
122
|
+
method: 'authswitch.authority.rename';
|
|
123
|
+
request: {
|
|
124
|
+
accountId: string;
|
|
125
|
+
expectedRevision: number;
|
|
126
|
+
label: string;
|
|
127
|
+
};
|
|
128
|
+
response: {
|
|
129
|
+
account: IAuthSwitchAccount;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
export interface IReq_AuthSwitchRemoveAccount extends ITypedRequest {
|
|
133
|
+
method: 'authswitch.authority.remove';
|
|
134
|
+
request: {
|
|
135
|
+
accountId: string;
|
|
136
|
+
expectedRevision: number;
|
|
137
|
+
};
|
|
138
|
+
response: {
|
|
139
|
+
account: IAuthSwitchAccount;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/** Runtime capability is returned only to trusted backend callers; do not expose this response in a browser API. */
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export {};
|
|
2
|
+
/** Runtime capability is returned only to trusted backend callers; do not expose this response in a browser API. */
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXV0aG9yaXR5LWNvbnRyYWN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvYXV0aG9yaXR5LWNvbnRyYWN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUE0R0Esb0hBQW9IIn0=
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ITypedRequest } from '@api.global/typedrequest-interfaces';
|
|
2
|
+
import type { IAuthSwitchBinding } from './authority-contract.js';
|
|
3
|
+
/** Backend-only binding operation. The capability must never enter a browser-facing response. */
|
|
4
|
+
export interface IReq_AuthSwitchBindAccount extends ITypedRequest {
|
|
5
|
+
method: 'authswitch.authority.bind';
|
|
6
|
+
request: {
|
|
7
|
+
accountId: string;
|
|
8
|
+
runtime: IAuthSwitchBinding['runtime'];
|
|
9
|
+
scopeId: string;
|
|
10
|
+
incarnationId: string;
|
|
11
|
+
};
|
|
12
|
+
response: {
|
|
13
|
+
binding: IAuthSwitchBinding;
|
|
14
|
+
capability: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
/** Backend-only access operation. Refresh grants never cross this interface. */
|
|
18
|
+
export interface IReq_AuthSwitchResolveAccess extends ITypedRequest {
|
|
19
|
+
method: 'authswitch.authority.resolveAccess';
|
|
20
|
+
request: {
|
|
21
|
+
bindingId: string;
|
|
22
|
+
capability: string;
|
|
23
|
+
minValidityMs: number;
|
|
24
|
+
/** The provider rejected this exact access-token generation. */
|
|
25
|
+
rejectedGrantGeneration?: number;
|
|
26
|
+
};
|
|
27
|
+
response: {
|
|
28
|
+
accessToken: string;
|
|
29
|
+
accountId: string;
|
|
30
|
+
isFedrampAccount: boolean;
|
|
31
|
+
expiresAt: string;
|
|
32
|
+
grantGeneration: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
import type { IAuthSwitchAccount, IAuthSwitchAccountEvent, IAuthSwitchBinding, IAuthSwitchOperation, IAuthSwitchSnapshot } from './authority-contract.js';
|
|
3
|
+
import { AuthSwitchAuthorityDatabase } from './classes.authoritydatabase.js';
|
|
4
|
+
import { type IAuthSwitchSecretCodec } from './classes.authoritysecrets.js';
|
|
5
|
+
type TOpenAiProvider = Pick<plugins.flexAccounts.ISmartAiProviderAdapter, 'beginLogin' | 'refreshCredential' | 'inspectCredential' | 'dispose'>;
|
|
6
|
+
export interface IAuthSwitchAuthorityBrokerOptions {
|
|
7
|
+
provider?: TOpenAiProvider;
|
|
8
|
+
secrets?: IAuthSwitchSecretCodec;
|
|
9
|
+
now?: () => number;
|
|
10
|
+
proactive?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface IAuthSwitchResolvedAccess {
|
|
13
|
+
accessToken: string;
|
|
14
|
+
accountId: string;
|
|
15
|
+
isFedrampAccount: boolean;
|
|
16
|
+
expiresAt: string;
|
|
17
|
+
grantGeneration: number;
|
|
18
|
+
}
|
|
19
|
+
/** One daemon-owned authority. No management DTO contains a refresh grant. */
|
|
20
|
+
export declare class AuthSwitchAuthorityBroker {
|
|
21
|
+
private readonly database;
|
|
22
|
+
private readonly provider;
|
|
23
|
+
private readonly secrets;
|
|
24
|
+
private readonly now;
|
|
25
|
+
private readonly proactive;
|
|
26
|
+
private readonly operations;
|
|
27
|
+
private readonly refreshes;
|
|
28
|
+
private readonly listeners;
|
|
29
|
+
private timer?;
|
|
30
|
+
private closed;
|
|
31
|
+
constructor(database: AuthSwitchAuthorityDatabase, options?: IAuthSwitchAuthorityBrokerOptions);
|
|
32
|
+
start(): Promise<void>;
|
|
33
|
+
private schedule;
|
|
34
|
+
refreshDueAccounts(): Promise<void>;
|
|
35
|
+
private isDue;
|
|
36
|
+
private publish;
|
|
37
|
+
snapshot(options?: {
|
|
38
|
+
accountAfter?: string;
|
|
39
|
+
bindingAfter?: string;
|
|
40
|
+
limit?: number;
|
|
41
|
+
}): Promise<IAuthSwitchSnapshot>;
|
|
42
|
+
events(epoch: string, afterRevision: number, waitMs: number, signal?: AbortSignal): Promise<{
|
|
43
|
+
epoch: string;
|
|
44
|
+
revision: number;
|
|
45
|
+
resyncRequired: boolean;
|
|
46
|
+
events: IAuthSwitchAccountEvent[];
|
|
47
|
+
}>;
|
|
48
|
+
private identity;
|
|
49
|
+
private sealCredential;
|
|
50
|
+
private unsealCredential;
|
|
51
|
+
beginAddOpenAi(): Promise<IAuthSwitchOperation>;
|
|
52
|
+
beginReauthOpenAi(accountId: string): Promise<IAuthSwitchOperation>;
|
|
53
|
+
private beginLogin;
|
|
54
|
+
getOperation(operationId: string): IAuthSwitchOperation;
|
|
55
|
+
/** Trusted daemon lifecycle hook: hold new managed runtimes out until targeted reauth settles. */
|
|
56
|
+
waitOperation(operationId: string): Promise<void>;
|
|
57
|
+
private pruneOperations;
|
|
58
|
+
cancelOperation(operationId: string): Promise<IAuthSwitchOperation>;
|
|
59
|
+
renameAccount(accountId: string, expectedRevision: number, label: string): Promise<IAuthSwitchAccount>;
|
|
60
|
+
removeAccount(accountId: string, expectedRevision: number): Promise<IAuthSwitchAccount>;
|
|
61
|
+
bindAccount(input: {
|
|
62
|
+
accountId: string;
|
|
63
|
+
runtime: IAuthSwitchBinding['runtime'];
|
|
64
|
+
scopeId: string;
|
|
65
|
+
incarnationId: string;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
binding: IAuthSwitchBinding;
|
|
68
|
+
capability: string;
|
|
69
|
+
}>;
|
|
70
|
+
revokeBinding(bindingId: string, capability: string): Promise<boolean>;
|
|
71
|
+
resolveAccess(bindingId: string, capability: string, minValidityMs: number, rejectedGrantGeneration?: number): Promise<IAuthSwitchResolvedAccess>;
|
|
72
|
+
private refreshAccount;
|
|
73
|
+
private performRefresh;
|
|
74
|
+
close(): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
export {};
|