@openclaw/gateway-client 2026.7.2-beta.7 → 2026.8.1-beta.2
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/README.md +16 -3
- package/dist/browser-device-auth-Dz6H7eXy.d.mts +112 -0
- package/dist/browser.d.mts +6 -4
- package/dist/browser.mjs +3 -3
- package/dist/index.d.mts +5 -3
- package/dist/index.mjs +336 -147
- package/dist/{protocol-client-BfBHwA5H.d.mts → protocol-client-BbN-I582.d.mts} +21 -31
- package/dist/protocol-request-D4mVhLxE.d.mts +32 -0
- package/dist/{readiness-BJT_oUZE.d.mts → readiness--KX7i8Mq.d.mts} +29 -7
- package/dist/readiness.d.mts +1 -1
- package/dist/scope-upgrade.d.mts +38 -0
- package/dist/scope-upgrade.mjs +73 -0
- package/dist/{session-subscriptions-DrhzqL6v.d.mts → session-subscriptions-BTNpXybo.d.mts} +6 -110
- package/dist/{session-subscriptions-BV7MxYiL.mjs → session-subscriptions-uKmTyc3P.mjs} +280 -151
- package/dist/timeouts.mjs +3 -3
- package/dist/websocket-data.d.mts +6 -0
- package/dist/websocket-data.mjs +8 -0
- package/package.json +13 -3
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
import { n as GatewayProtocolRequestOptions, t as GatewayProtocolRequestError } from "./protocol-request-D4mVhLxE.mjs";
|
|
1
2
|
import { ErrorShape, EventFrame, HelloOk } from "@openclaw/gateway-protocol";
|
|
2
3
|
|
|
3
|
-
//#region packages/gateway-client/src/
|
|
4
|
+
//#region packages/gateway-client/src/pending-request.d.ts
|
|
5
|
+
type GatewayProtocolRequestTiming = {
|
|
6
|
+
id: string;
|
|
7
|
+
method: string;
|
|
8
|
+
ok: boolean;
|
|
9
|
+
durationMs: number;
|
|
10
|
+
startedAtMs: number;
|
|
11
|
+
endedAtMs: number;
|
|
12
|
+
errorCode?: string;
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region packages/gateway-client/src/protocol-client-contract.d.ts
|
|
4
16
|
type GatewayProtocolSocket = {
|
|
5
17
|
isOpen: () => boolean;
|
|
6
18
|
send: (data: string) => void;
|
|
@@ -12,16 +24,10 @@ type GatewayProtocolSocketHandlers = {
|
|
|
12
24
|
close: (code: number, reason: string) => void;
|
|
13
25
|
error: (error: Error) => void;
|
|
14
26
|
};
|
|
15
|
-
type GatewayProtocolRequestOptions = {
|
|
16
|
-
timeoutMs?: number | null;
|
|
17
|
-
expectFinal?: boolean;
|
|
18
|
-
onSent?: () => void;
|
|
19
|
-
onAccepted?: (payload: unknown) => void;
|
|
20
|
-
signal?: AbortSignal;
|
|
21
|
-
};
|
|
22
27
|
type GatewayProtocolConnectContext<TPlan> = {
|
|
23
28
|
generation: number;
|
|
24
29
|
nonce: string | null;
|
|
30
|
+
challengeTs: number | null | undefined;
|
|
25
31
|
plan: TPlan;
|
|
26
32
|
};
|
|
27
33
|
type GatewayProtocolCloseContext = {
|
|
@@ -59,23 +65,15 @@ type GatewayProtocolTiming<TPlan> = {
|
|
|
59
65
|
plan?: TPlan;
|
|
60
66
|
detail?: unknown;
|
|
61
67
|
};
|
|
62
|
-
type GatewayProtocolRequestTiming = {
|
|
63
|
-
id: string;
|
|
64
|
-
method: string;
|
|
65
|
-
ok: boolean;
|
|
66
|
-
durationMs: number;
|
|
67
|
-
startedAtMs: number;
|
|
68
|
-
endedAtMs: number;
|
|
69
|
-
errorCode?: string;
|
|
70
|
-
};
|
|
71
68
|
type GatewayProtocolClientOptions<TPlan> = {
|
|
72
69
|
createSocket: (handlers: GatewayProtocolSocketHandlers) => GatewayProtocolSocket;
|
|
73
70
|
createRequestId: () => string;
|
|
74
71
|
createRequestError?: (error: Partial<ErrorShape>) => GatewayProtocolRequestError;
|
|
75
|
-
createRequestTimeoutError?: (method: string, timeoutMs: number) => Error;
|
|
72
|
+
createRequestTimeoutError?: (method: string, timeoutMs: number, requestSent: boolean) => Error;
|
|
76
73
|
createRequestAbortError?: (method: string) => Error;
|
|
77
74
|
buildConnectPlan: (params: {
|
|
78
75
|
nonce: string | null;
|
|
76
|
+
challengeTs: number | null | undefined;
|
|
79
77
|
generation: number;
|
|
80
78
|
}) => TPlan | Promise<TPlan>;
|
|
81
79
|
buildConnectParams: (plan: TPlan) => unknown;
|
|
@@ -116,14 +114,8 @@ type GatewayProtocolClientOptions<TPlan> = {
|
|
|
116
114
|
shouldRetrySocketFactoryError?: (error: Error) => boolean;
|
|
117
115
|
rethrowSocketFactoryError?: (error: Error) => boolean;
|
|
118
116
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
readonly gatewayCode: string;
|
|
122
|
-
readonly details?: unknown;
|
|
123
|
-
readonly retryable: boolean;
|
|
124
|
-
readonly retryAfterMs?: number;
|
|
125
|
-
constructor(error: Partial<ErrorShape>);
|
|
126
|
-
}
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region packages/gateway-client/src/protocol-client.d.ts
|
|
127
119
|
/**
|
|
128
120
|
* Browser-safe gateway wire client. Environment adapters own transport and auth
|
|
129
121
|
* policy; this class owns the single socket/handshake/reconnect/frame state machine.
|
|
@@ -131,12 +123,13 @@ declare class GatewayProtocolRequestError extends Error {
|
|
|
131
123
|
declare class GatewayProtocolClient<TPlan> {
|
|
132
124
|
private readonly opts;
|
|
133
125
|
private socket;
|
|
134
|
-
private readonly
|
|
126
|
+
private readonly requests;
|
|
135
127
|
private readonly listeners;
|
|
136
128
|
private stopped;
|
|
137
129
|
private generation;
|
|
138
130
|
private lastSeq;
|
|
139
131
|
private connectNonce;
|
|
132
|
+
private connectChallengeTs;
|
|
140
133
|
private connectSent;
|
|
141
134
|
private connectRequestSent;
|
|
142
135
|
private handshakeTimer;
|
|
@@ -166,11 +159,8 @@ declare class GatewayProtocolClient<TPlan> {
|
|
|
166
159
|
private handleConnectPlanError;
|
|
167
160
|
private sendConnectPlan;
|
|
168
161
|
private handleMessage;
|
|
169
|
-
private handleResponse;
|
|
170
162
|
private handleClose;
|
|
171
163
|
private handleSocketError;
|
|
172
|
-
private flushRequests;
|
|
173
|
-
private finishRequestTiming;
|
|
174
164
|
private scheduleReconnect;
|
|
175
165
|
private closeContext;
|
|
176
166
|
private isActive;
|
|
@@ -179,4 +169,4 @@ declare class GatewayProtocolClient<TPlan> {
|
|
|
179
169
|
private invoke;
|
|
180
170
|
}
|
|
181
171
|
//#endregion
|
|
182
|
-
export {
|
|
172
|
+
export { GatewayProtocolTiming as a, GatewayProtocolSocketHandlers as i, GatewayProtocolCloseContext as n, GatewayProtocolRequestTiming as o, GatewayProtocolSocket as r, GatewayProtocolClient as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ErrorShape } from "@openclaw/gateway-protocol";
|
|
2
|
+
|
|
3
|
+
//#region packages/gateway-client/src/protocol-request.d.ts
|
|
4
|
+
type GatewayProtocolRequestOptions = {
|
|
5
|
+
timeoutMs?: number | null;
|
|
6
|
+
expectFinal?: boolean;
|
|
7
|
+
onSent?: () => void;
|
|
8
|
+
onAccepted?: (payload: unknown) => void;
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
};
|
|
11
|
+
declare class GatewayProtocolRequestError extends Error {
|
|
12
|
+
readonly code: string;
|
|
13
|
+
readonly gatewayCode: string;
|
|
14
|
+
readonly details?: unknown;
|
|
15
|
+
readonly retryable: boolean;
|
|
16
|
+
readonly retryAfterMs?: number;
|
|
17
|
+
constructor(error: Partial<ErrorShape>);
|
|
18
|
+
}
|
|
19
|
+
/** A local transport deadline, distinct from a Gateway's authoritative rejection. */
|
|
20
|
+
declare class GatewayProtocolRequestTimeoutError extends Error {
|
|
21
|
+
readonly code = "CLIENT_TIMEOUT";
|
|
22
|
+
readonly method: string;
|
|
23
|
+
readonly timeoutMs: number;
|
|
24
|
+
readonly requestSent: boolean;
|
|
25
|
+
constructor(params: {
|
|
26
|
+
method: string;
|
|
27
|
+
timeoutMs: number;
|
|
28
|
+
requestSent: boolean;
|
|
29
|
+
}, message?: string);
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { GatewayProtocolRequestOptions as n, GatewayProtocolRequestTimeoutError as r, GatewayProtocolRequestError as t };
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ErrorShape, EventFrame, HelloOk } from "@openclaw/gateway-protocol/frame-guards";
|
|
1
|
+
import { n as GatewayProtocolRequestOptions, r as GatewayProtocolRequestTimeoutError, t as GatewayProtocolRequestError } from "./protocol-request-D4mVhLxE.mjs";
|
|
2
|
+
import { ConnectParams, ErrorShape, EventFrame, HelloOk } from "@openclaw/gateway-protocol/frame-guards";
|
|
3
3
|
import { GatewayClientMode, GatewayClientName } from "@openclaw/gateway-protocol/client-info";
|
|
4
4
|
|
|
5
|
+
//#region packages/gateway-client/src/request-error.d.ts
|
|
6
|
+
declare class GatewayClientRequestError extends GatewayProtocolRequestError {
|
|
7
|
+
constructor(error: Partial<ErrorShape>);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
5
10
|
//#region packages/gateway-client/src/client.d.ts
|
|
6
11
|
type DeviceIdentity = {
|
|
7
12
|
deviceId: string;
|
|
@@ -50,10 +55,16 @@ type GatewayClientCloseInfo = {
|
|
|
50
55
|
phase: "pre-hello" | "post-hello";
|
|
51
56
|
socketOpened: boolean;
|
|
52
57
|
transportValidated: boolean;
|
|
58
|
+
connectRequestSent?: boolean;
|
|
53
59
|
transientPreHelloCleanClose: boolean;
|
|
60
|
+
connectError?: Error;
|
|
54
61
|
};
|
|
55
|
-
declare class
|
|
56
|
-
constructor(
|
|
62
|
+
declare class GatewayClientRequestTimeoutError extends GatewayProtocolRequestTimeoutError {
|
|
63
|
+
constructor(params: {
|
|
64
|
+
method: string;
|
|
65
|
+
timeoutMs: number;
|
|
66
|
+
requestSent: boolean;
|
|
67
|
+
});
|
|
57
68
|
}
|
|
58
69
|
declare function isGatewayConnectAssemblyError(value: unknown): value is Error;
|
|
59
70
|
type GatewayClientOptions = {
|
|
@@ -69,7 +80,8 @@ type GatewayClientOptions = {
|
|
|
69
80
|
tickWatchTimeoutMs?: number;
|
|
70
81
|
requestTimeoutMs?: number;
|
|
71
82
|
token?: string;
|
|
72
|
-
bootstrapToken?: string;
|
|
83
|
+
bootstrapToken?: string; /** Prefer one setup credential for the first successful device-auth exchange. */
|
|
84
|
+
preferBootstrapToken?: boolean;
|
|
73
85
|
deviceToken?: string;
|
|
74
86
|
password?: string;
|
|
75
87
|
approvalRuntimeToken?: string;
|
|
@@ -78,6 +90,7 @@ type GatewayClientOptions = {
|
|
|
78
90
|
clientName?: GatewayClientName;
|
|
79
91
|
clientDisplayName?: string;
|
|
80
92
|
clientVersion?: string;
|
|
93
|
+
clientBuildId?: string;
|
|
81
94
|
platform?: string;
|
|
82
95
|
deviceFamily?: string;
|
|
83
96
|
mode?: GatewayClientMode;
|
|
@@ -85,6 +98,8 @@ type GatewayClientOptions = {
|
|
|
85
98
|
scopes?: string[];
|
|
86
99
|
caps?: string[];
|
|
87
100
|
commands?: string[];
|
|
101
|
+
computerUse?: ConnectParams["computerUse"];
|
|
102
|
+
workerRuns?: ConnectParams["workerRuns"];
|
|
88
103
|
permissions?: Record<string, boolean>;
|
|
89
104
|
pathEnv?: string;
|
|
90
105
|
env?: NodeJS.ProcessEnv;
|
|
@@ -115,6 +130,9 @@ declare class GatewayClient {
|
|
|
115
130
|
private opts;
|
|
116
131
|
private deps;
|
|
117
132
|
private stopped;
|
|
133
|
+
private useLegacyNodeProtocolEnvelope;
|
|
134
|
+
private nodeProtocolTransitionPending;
|
|
135
|
+
private suppressNextHelloCallback;
|
|
118
136
|
private pendingDeviceTokenRetry;
|
|
119
137
|
private deviceTokenRetryBudgetUsed;
|
|
120
138
|
private approvalRuntimeTokenCompatibilityDisabled;
|
|
@@ -131,6 +149,8 @@ declare class GatewayClient {
|
|
|
131
149
|
updateNodeManifest(manifest: {
|
|
132
150
|
caps: string[];
|
|
133
151
|
commands: string[];
|
|
152
|
+
computerUse?: ConnectParams["computerUse"];
|
|
153
|
+
workerRuns?: ConnectParams["workerRuns"];
|
|
134
154
|
}): void;
|
|
135
155
|
start(): void;
|
|
136
156
|
private createSocket;
|
|
@@ -144,6 +164,9 @@ declare class GatewayClient {
|
|
|
144
164
|
private logDebug;
|
|
145
165
|
private logError;
|
|
146
166
|
private assembleConnectParams;
|
|
167
|
+
private shouldNegotiateLegacyNodeProtocol;
|
|
168
|
+
private shouldRetryWithLegacyNodeProtocol;
|
|
169
|
+
private shouldRetryWithCurrentNodeProtocol;
|
|
147
170
|
private buildDeviceConnectParams;
|
|
148
171
|
private handleConnectHello;
|
|
149
172
|
private handleConnectRequestFailure;
|
|
@@ -157,7 +180,6 @@ declare class GatewayClient {
|
|
|
157
180
|
private isTrustedDeviceRetryEndpoint;
|
|
158
181
|
private selectConnectAuth;
|
|
159
182
|
private startTickWatch;
|
|
160
|
-
private validateTlsFingerprint;
|
|
161
183
|
request<T = Record<string, unknown>>(method: string, params?: unknown, opts?: GatewayClientRequestOptions): Promise<T>;
|
|
162
184
|
}
|
|
163
185
|
//#endregion
|
|
@@ -198,4 +220,4 @@ declare function startGatewayClientWithReadinessWait(waitForReady: EventLoopRead
|
|
|
198
220
|
/** Starts a gateway client after the default event-loop readiness probe succeeds. */
|
|
199
221
|
declare function startGatewayClientWhenEventLoopReady(client: GatewayClientStartable, options?: GatewayClientStartReadinessOptions): Promise<EventLoopReadyResult>;
|
|
200
222
|
//#endregion
|
|
201
|
-
export {
|
|
223
|
+
export { GatewayClientRequestTimeoutError as _, startGatewayClientWithReadinessWait as a, GatewayClientRequestError as b, waitForEventLoopReady as c, GatewayClient as d, GatewayClientCloseInfo as f, GatewayClientRequestOptions as g, GatewayClientOptions as h, startGatewayClientWhenEventLoopReady as i, DeviceAuthTokenRecord as l, GatewayClientHostDeps as m, GatewayClientStartReadinessOptions as n, EventLoopReadyOptions as o, GatewayClientConnectionMetadata as p, GatewayClientStartable as r, EventLoopReadyResult as s, EventLoopReadyWaiter as t, DeviceIdentity as u, GatewayReconnectPausedInfo as v, isGatewayConnectAssemblyError as y };
|
package/dist/readiness.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as startGatewayClientWithReadinessWait, i as startGatewayClientWhenEventLoopReady, n as GatewayClientStartReadinessOptions, r as GatewayClientStartable, t as EventLoopReadyWaiter } from "./readiness
|
|
1
|
+
import { a as startGatewayClientWithReadinessWait, i as startGatewayClientWhenEventLoopReady, n as GatewayClientStartReadinessOptions, r as GatewayClientStartable, t as EventLoopReadyWaiter } from "./readiness--KX7i8Mq.mjs";
|
|
2
2
|
export { EventLoopReadyWaiter, GatewayClientStartReadinessOptions, GatewayClientStartable, startGatewayClientWhenEventLoopReady, startGatewayClientWithReadinessWait };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { a as GatewayBrowserDeviceTokenStore } from "./browser-device-auth-Dz6H7eXy.mjs";
|
|
2
|
+
import { n as GatewayProtocolRequestOptions } from "./protocol-request-D4mVhLxE.mjs";
|
|
3
|
+
|
|
4
|
+
//#region packages/gateway-client/src/scope-upgrade.d.ts
|
|
5
|
+
type ScopeUpgradeBinding = {
|
|
6
|
+
clientId: string;
|
|
7
|
+
deviceId: string;
|
|
8
|
+
role: string;
|
|
9
|
+
};
|
|
10
|
+
type ScopeUpgradeOutcome = {
|
|
11
|
+
status: "approved";
|
|
12
|
+
requestId: string;
|
|
13
|
+
scopes: string[];
|
|
14
|
+
} | {
|
|
15
|
+
status: "rejected" | "expired";
|
|
16
|
+
requestId: string;
|
|
17
|
+
};
|
|
18
|
+
type ScopeUpgradeOptions = {
|
|
19
|
+
binding: ScopeUpgradeBinding;
|
|
20
|
+
scopes: readonly string[];
|
|
21
|
+
onPending?: (requestId: string) => void;
|
|
22
|
+
};
|
|
23
|
+
type UpgradeRequester = (method: string, params?: unknown, options?: GatewayProtocolRequestOptions) => Promise<unknown>;
|
|
24
|
+
/** Runs one browser device scope upgrade and owns rotated-token persistence. */
|
|
25
|
+
declare class GatewayScopeUpgrade {
|
|
26
|
+
private readonly deps;
|
|
27
|
+
private active?;
|
|
28
|
+
constructor(deps: {
|
|
29
|
+
request: UpgradeRequester;
|
|
30
|
+
tokenStore: GatewayBrowserDeviceTokenStore;
|
|
31
|
+
reconnect: () => void;
|
|
32
|
+
});
|
|
33
|
+
requestScopeUpgrade(options: ScopeUpgradeOptions): Promise<ScopeUpgradeOutcome>;
|
|
34
|
+
cancelScopeUpgrade(): void;
|
|
35
|
+
private runUpgrade;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { GatewayScopeUpgrade, ScopeUpgradeBinding, ScopeUpgradeOptions, ScopeUpgradeOutcome };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region packages/gateway-client/src/scope-upgrade.ts
|
|
2
|
+
function readRequestId(value) {
|
|
3
|
+
const requestId = value && typeof value === "object" && "requestId" in value ? value.requestId : void 0;
|
|
4
|
+
if (typeof requestId !== "string" || !requestId.trim()) throw new Error("gateway returned an invalid scope upgrade request id");
|
|
5
|
+
return requestId;
|
|
6
|
+
}
|
|
7
|
+
function readUpgradeResult(value, requestId) {
|
|
8
|
+
if (!value || typeof value !== "object") throw new Error("gateway returned an invalid scope upgrade result");
|
|
9
|
+
const result = value;
|
|
10
|
+
if (result.requestId !== requestId) throw new Error("gateway returned a mismatched scope upgrade result");
|
|
11
|
+
if (result.status === "rejected" || result.status === "expired") return {
|
|
12
|
+
status: result.status,
|
|
13
|
+
requestId
|
|
14
|
+
};
|
|
15
|
+
const deviceToken = result.status === "approved" && typeof result.deviceToken === "string" ? result.deviceToken.trim() : "";
|
|
16
|
+
const rawScopes = result.status === "approved" && Array.isArray(result.scopes) ? result.scopes : [];
|
|
17
|
+
if (!deviceToken || rawScopes.length === 0 || rawScopes.some((scope) => typeof scope !== "string" || !scope.trim())) throw new Error("gateway returned invalid approved scope upgrade credentials");
|
|
18
|
+
return {
|
|
19
|
+
status: "approved",
|
|
20
|
+
requestId,
|
|
21
|
+
deviceToken,
|
|
22
|
+
scopes: rawScopes
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Runs one browser device scope upgrade and owns rotated-token persistence. */
|
|
26
|
+
var GatewayScopeUpgrade = class {
|
|
27
|
+
constructor(deps) {
|
|
28
|
+
this.deps = deps;
|
|
29
|
+
}
|
|
30
|
+
requestScopeUpgrade(options) {
|
|
31
|
+
if (this.active) {
|
|
32
|
+
if (this.active.requestId) options.onPending?.(this.active.requestId);
|
|
33
|
+
return this.active.promise;
|
|
34
|
+
}
|
|
35
|
+
const operation = { controller: new AbortController() };
|
|
36
|
+
const promise = this.runUpgrade(operation, options).finally(() => {
|
|
37
|
+
if (this.active === operation) this.active = void 0;
|
|
38
|
+
});
|
|
39
|
+
operation.promise = promise;
|
|
40
|
+
this.active = operation;
|
|
41
|
+
return promise;
|
|
42
|
+
}
|
|
43
|
+
cancelScopeUpgrade() {
|
|
44
|
+
const operation = this.active;
|
|
45
|
+
this.active = void 0;
|
|
46
|
+
operation?.controller.abort();
|
|
47
|
+
}
|
|
48
|
+
async runUpgrade(operation, options) {
|
|
49
|
+
const requestId = readRequestId(await this.deps.request("device.scopes.requestUpgrade", { scopes: [...options.scopes] }, { signal: operation.controller.signal }));
|
|
50
|
+
operation.requestId = requestId;
|
|
51
|
+
options.onPending?.(requestId);
|
|
52
|
+
const result = readUpgradeResult(await this.deps.request("device.scopes.waitUpgrade", { requestId }, {
|
|
53
|
+
timeoutMs: null,
|
|
54
|
+
signal: operation.controller.signal
|
|
55
|
+
}), requestId);
|
|
56
|
+
if (result.status !== "approved") return result;
|
|
57
|
+
await this.deps.tokenStore.store({
|
|
58
|
+
clientId: options.binding.clientId,
|
|
59
|
+
deviceId: options.binding.deviceId,
|
|
60
|
+
role: options.binding.role,
|
|
61
|
+
token: result.deviceToken,
|
|
62
|
+
scopes: result.scopes
|
|
63
|
+
});
|
|
64
|
+
this.deps.reconnect();
|
|
65
|
+
return {
|
|
66
|
+
status: "approved",
|
|
67
|
+
requestId,
|
|
68
|
+
scopes: result.scopes
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
export { GatewayScopeUpgrade };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { ConnectParams, HelloOk } from "@openclaw/gateway-protocol";
|
|
2
|
-
|
|
3
1
|
//#region packages/gateway-client/src/device-auth.d.ts
|
|
4
2
|
declare function normalizeDeviceMetadataForAuth(value?: string | null): string;
|
|
5
3
|
type DeviceAuthPayloadParams = {
|
|
@@ -19,113 +17,11 @@ type DeviceAuthPayloadV3Params = DeviceAuthPayloadParams & {
|
|
|
19
17
|
declare function buildDeviceAuthPayload(params: DeviceAuthPayloadParams): string;
|
|
20
18
|
declare function buildDeviceAuthPayloadV3(params: DeviceAuthPayloadV3Params): string;
|
|
21
19
|
//#endregion
|
|
22
|
-
//#region packages/gateway-client/src/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
authPassword?: string;
|
|
28
|
-
authApprovalRuntimeToken?: string;
|
|
29
|
-
authAgentRuntimeIdentityToken?: string;
|
|
30
|
-
signatureToken?: string;
|
|
31
|
-
resolvedDeviceToken?: string;
|
|
32
|
-
storedToken?: string;
|
|
33
|
-
storedScopes?: string[];
|
|
34
|
-
usingStoredDeviceToken?: boolean;
|
|
35
|
-
};
|
|
36
|
-
declare function selectGatewayConnectAuth(params: {
|
|
37
|
-
token?: string;
|
|
38
|
-
bootstrapToken?: string;
|
|
39
|
-
deviceToken?: string;
|
|
40
|
-
password?: string;
|
|
41
|
-
approvalRuntimeToken?: string;
|
|
42
|
-
agentRuntimeIdentityToken?: string;
|
|
43
|
-
storedToken?: string;
|
|
44
|
-
storedScopes?: string[];
|
|
45
|
-
pendingDeviceTokenRetry?: boolean;
|
|
46
|
-
trustedDeviceTokenRetry?: boolean;
|
|
47
|
-
preferBootstrapToken?: boolean;
|
|
48
|
-
}): GatewayConnectAuthSelection;
|
|
49
|
-
declare function buildGatewayConnectAuth(selected: GatewayConnectAuthSelection): ConnectParams["auth"];
|
|
50
|
-
declare function resolveGatewayConnectScopes(params: {
|
|
51
|
-
requestedScopes?: string[];
|
|
52
|
-
usingStoredDeviceToken?: boolean;
|
|
53
|
-
storedScopes?: string[];
|
|
54
|
-
defaultScopes: readonly string[];
|
|
55
|
-
}): string[];
|
|
56
|
-
declare function shouldRetryGatewayWithDeviceToken(params: {
|
|
57
|
-
retryBudgetUsed: boolean;
|
|
58
|
-
currentDeviceToken?: string;
|
|
59
|
-
explicitToken?: string;
|
|
60
|
-
storedToken?: string;
|
|
61
|
-
trustedEndpoint: boolean;
|
|
62
|
-
canRetryWithDeviceTokenHint?: boolean;
|
|
63
|
-
errorDetails?: unknown;
|
|
64
|
-
}): boolean;
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region packages/gateway-client/src/browser-device-auth.d.ts
|
|
67
|
-
type GatewayBrowserDeviceIdentity = {
|
|
68
|
-
deviceId: string;
|
|
69
|
-
publicKey: string;
|
|
70
|
-
sign: (payload: string) => Promise<string>;
|
|
71
|
-
};
|
|
72
|
-
type GatewayBrowserDeviceTokenRecord = {
|
|
73
|
-
token: string;
|
|
74
|
-
scopes: string[];
|
|
75
|
-
};
|
|
76
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
77
|
-
type GatewayBrowserDeviceTokenStore = {
|
|
78
|
-
load: (params: {
|
|
79
|
-
clientId: string;
|
|
80
|
-
deviceId: string;
|
|
81
|
-
role: string;
|
|
82
|
-
}) => MaybePromise<GatewayBrowserDeviceTokenRecord | null>;
|
|
83
|
-
store: (params: {
|
|
84
|
-
clientId: string;
|
|
85
|
-
deviceId: string;
|
|
86
|
-
role: string;
|
|
87
|
-
token: string;
|
|
88
|
-
scopes: string[];
|
|
89
|
-
}) => MaybePromise<void>;
|
|
90
|
-
clear: (params: {
|
|
91
|
-
clientId: string;
|
|
92
|
-
deviceId: string;
|
|
93
|
-
role: string;
|
|
94
|
-
}) => MaybePromise<void>;
|
|
95
|
-
};
|
|
96
|
-
type GatewayBrowserDeviceAuthPlan = {
|
|
97
|
-
clientId: string;
|
|
98
|
-
role: string;
|
|
99
|
-
identity: GatewayBrowserDeviceIdentity | null;
|
|
100
|
-
selectedAuth: GatewayConnectAuthSelection;
|
|
101
|
-
scopes: string[];
|
|
102
|
-
device?: NonNullable<ConnectParams["device"]>;
|
|
103
|
-
auth?: ConnectParams["auth"];
|
|
104
|
-
};
|
|
105
|
-
/** Browser-safe device pairing and issued-token lifecycle shared by first-party UI clients. */
|
|
106
|
-
declare class GatewayBrowserDeviceAuthLifecycle {
|
|
107
|
-
private readonly deps;
|
|
108
|
-
constructor(deps: {
|
|
109
|
-
loadIdentity: () => Promise<GatewayBrowserDeviceIdentity | null>;
|
|
110
|
-
tokenStore: GatewayBrowserDeviceTokenStore;
|
|
111
|
-
nowMs?: () => number;
|
|
112
|
-
});
|
|
113
|
-
buildPlan(params: {
|
|
114
|
-
client: ConnectParams["client"];
|
|
115
|
-
role: string;
|
|
116
|
-
defaultScopes: readonly string[];
|
|
117
|
-
bootstrapScopes?: readonly string[];
|
|
118
|
-
token?: string;
|
|
119
|
-
bootstrapToken?: string;
|
|
120
|
-
password?: string;
|
|
121
|
-
pendingDeviceTokenRetry?: boolean;
|
|
122
|
-
trustedDeviceTokenRetry?: boolean;
|
|
123
|
-
preferBootstrapToken?: boolean;
|
|
124
|
-
nonce: string | null;
|
|
125
|
-
}): Promise<GatewayBrowserDeviceAuthPlan>;
|
|
126
|
-
acceptHello(hello: Pick<HelloOk, "auth">, plan: GatewayBrowserDeviceAuthPlan): Promise<void>;
|
|
127
|
-
clearStoredToken(plan: GatewayBrowserDeviceAuthPlan): Promise<void>;
|
|
128
|
-
}
|
|
20
|
+
//#region packages/gateway-client/src/gateway-origin-scope.d.ts
|
|
21
|
+
/** Normalizes the gateway URL scope used for origin-bound device tokens. */
|
|
22
|
+
declare function gatewayOriginScope(gatewayUrl: string): string;
|
|
23
|
+
/** Normalizes the gateway URL scope used for browser credential records. */
|
|
24
|
+
declare function gatewayCredentialScope(gatewayUrl: string): string;
|
|
129
25
|
//#endregion
|
|
130
26
|
//#region packages/gateway-client/src/session-projection.d.ts
|
|
131
27
|
/** Browser-safe identity and replay rules shared by Gateway conversation clients. */
|
|
@@ -279,4 +175,4 @@ declare function getGatewaySessionMessageSubscriptionCoordinator(client: Gateway
|
|
|
279
175
|
declare function resetGatewaySessionMessageSubscriptionCoordinator(client: GatewaySessionMessageRequestClient): void;
|
|
280
176
|
declare function releaseGatewaySessionMessageSubscription(subscription: GatewaySessionMessageSubscription): Promise<void>;
|
|
281
177
|
//#endregion
|
|
282
|
-
export {
|
|
178
|
+
export { gatewayCredentialScope as A, normalizeSessionProjectionRunId as C, reconcileSessionProjectionSnapshot as D, readSessionMessageSequence as E, buildDeviceAuthPayload as M, buildDeviceAuthPayloadV3 as N, reduceSessionProjection as O, normalizeDeviceMetadataForAuth as P, isLocallyOptimisticSessionMessage as S, readSessionMessageIdentity as T, SessionProjectionScope as _, GatewaySessionMessageSubscriptionOptions as a, createSessionProjection as b, resetGatewaySessionMessageSubscriptionCoordinator as c, SessionProjectionEntry as d, SessionProjectionEvent as f, SessionProjectionRunTransition as g, SessionProjectionRunStatus as h, GatewaySessionMessageSubscriptionCoordinatorOptions as i, gatewayOriginScope as j, reduceSessionProjectionRunEvent as k, SessionMessageEnvelope as l, SessionProjectionRun as m, GatewaySessionMessageSubscription as n, getGatewaySessionMessageSubscriptionCoordinator as o, SessionProjectionGatewayRunEvent as p, GatewaySessionMessageSubscriptionCoordinator as r, releaseGatewaySessionMessageSubscription as s, GatewaySessionMessageRequestClient as t, SessionMessageIdentity as u, SessionProjectionSnapshotOptions as v, projectLiveSessionMessage as w, hasSessionProjectionAcceptedFinal as x, SessionProjectionState as y };
|