@getpaseo/client 0.2.2 → 0.2.3
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/daemon-client-relay-e2ee-transport.js +4 -4
- package/dist/daemon-client-transport-types.d.ts +1 -1
- package/dist/daemon-client-transport-utils.d.ts +5 -1
- package/dist/daemon-client-transport-utils.js +8 -6
- package/dist/daemon-client-transport.d.ts +1 -1
- package/dist/daemon-client-transport.js +1 -1
- package/dist/daemon-client-websocket-transport.js +9 -1
- package/dist/daemon-client.d.ts +9 -0
- package/dist/daemon-client.js +21 -0
- package/package.json +3 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createClientChannel, } from "@getpaseo/relay/e2ee";
|
|
2
|
-
import {
|
|
2
|
+
import { extractRelayMessage, normalizeTransportPayload } from "./daemon-client-transport-utils.js";
|
|
3
3
|
export function createRelayE2eeTransportFactory(args) {
|
|
4
4
|
return ({ url, headers }) => {
|
|
5
5
|
const base = args.baseFactory({ url, headers });
|
|
@@ -38,7 +38,7 @@ export function createEncryptedTransport(base, daemonPublicKeyB64, logger) {
|
|
|
38
38
|
if (closed) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
-
emitHandlers(messageHandlers, data);
|
|
41
|
+
emitHandlers(messageHandlers, data, data instanceof ArrayBuffer);
|
|
42
42
|
};
|
|
43
43
|
const relayTransport = {
|
|
44
44
|
send: (data) => {
|
|
@@ -81,8 +81,8 @@ export function createEncryptedTransport(base, daemonPublicKeyB64, logger) {
|
|
|
81
81
|
base.onOpen(() => {
|
|
82
82
|
void startHandshake();
|
|
83
83
|
});
|
|
84
|
-
base.onMessage((
|
|
85
|
-
relayTransport.onmessage?.(
|
|
84
|
+
base.onMessage((data, isBinary) => {
|
|
85
|
+
relayTransport.onmessage?.(extractRelayMessage(data, isBinary));
|
|
86
86
|
});
|
|
87
87
|
base.onClose((event) => {
|
|
88
88
|
const record = event;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface DaemonTransport {
|
|
2
2
|
send: (data: string | Uint8Array | ArrayBuffer) => void;
|
|
3
3
|
close: (code?: number, reason?: string) => void;
|
|
4
|
-
onMessage: (handler: (data: unknown) => void) => () => void;
|
|
4
|
+
onMessage: (handler: (data: unknown, isBinary: boolean) => void) => () => void;
|
|
5
5
|
onOpen: (handler: () => void) => () => void;
|
|
6
6
|
onClose: (handler: (event?: unknown) => void) => () => void;
|
|
7
7
|
onError: (handler: (event?: unknown) => void) => () => void;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
export declare function copyArrayBufferViewToBuffer(data: ArrayBufferView): ArrayBuffer;
|
|
2
2
|
export declare function normalizeTransportPayload(data: string | Uint8Array | ArrayBuffer): string | ArrayBuffer;
|
|
3
|
-
export
|
|
3
|
+
export interface RelayTransportMessage {
|
|
4
|
+
data: string | ArrayBuffer;
|
|
5
|
+
isBinary: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function extractRelayMessage(event: unknown, nodeIsBinary?: boolean): RelayTransportMessage;
|
|
4
8
|
export declare function describeTransportClose(event?: unknown): string;
|
|
5
9
|
export declare function describeTransportError(event?: unknown): string;
|
|
6
10
|
export declare function safeRandomId(): string;
|
|
@@ -10,18 +10,20 @@ export function normalizeTransportPayload(data) {
|
|
|
10
10
|
}
|
|
11
11
|
return copyArrayBufferViewToBuffer(data);
|
|
12
12
|
}
|
|
13
|
-
export function
|
|
13
|
+
export function extractRelayMessage(event, nodeIsBinary) {
|
|
14
14
|
const raw = event && typeof event === "object" && "data" in event
|
|
15
15
|
? event.data
|
|
16
16
|
: event;
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const isBinary = nodeIsBinary ?? typeof raw !== "string";
|
|
18
|
+
if (!isBinary) {
|
|
19
|
+
return { data: decodeMessageData(raw) ?? String(raw ?? ""), isBinary: false };
|
|
20
|
+
}
|
|
19
21
|
if (raw instanceof ArrayBuffer)
|
|
20
|
-
return raw;
|
|
22
|
+
return { data: raw, isBinary: true };
|
|
21
23
|
if (ArrayBuffer.isView(raw)) {
|
|
22
|
-
return copyArrayBufferViewToBuffer(raw);
|
|
24
|
+
return { data: copyArrayBufferViewToBuffer(raw), isBinary: true };
|
|
23
25
|
}
|
|
24
|
-
return String(raw ?? "");
|
|
26
|
+
return { data: String(raw ?? ""), isBinary: true };
|
|
25
27
|
}
|
|
26
28
|
export function describeTransportClose(event) {
|
|
27
29
|
if (!event) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { DaemonTransport, DaemonTransportFactory, TransportLogger, WebSocketFactory, WebSocketLike, } from "./daemon-client-transport-types.js";
|
|
2
|
-
export { decodeMessageData, describeTransportClose, describeTransportError, encodeUtf8String,
|
|
2
|
+
export { decodeMessageData, describeTransportClose, describeTransportError, encodeUtf8String, extractRelayMessage, normalizeTransportPayload, safeRandomId, } from "./daemon-client-transport-utils.js";
|
|
3
3
|
export { createEncryptedTransport, createRelayE2eeTransportFactory, } from "./daemon-client-relay-e2ee-transport.js";
|
|
4
4
|
export { bindWsHandler, createWebSocketTransportFactory, defaultWebSocketFactory, } from "./daemon-client-websocket-transport.js";
|
|
5
5
|
//# sourceMappingURL=daemon-client-transport.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { decodeMessageData, describeTransportClose, describeTransportError, encodeUtf8String,
|
|
1
|
+
export { decodeMessageData, describeTransportClose, describeTransportError, encodeUtf8String, extractRelayMessage, normalizeTransportPayload, safeRandomId, } from "./daemon-client-transport-utils.js";
|
|
2
2
|
export { createEncryptedTransport, createRelayE2eeTransportFactory, } from "./daemon-client-relay-e2ee-transport.js";
|
|
3
3
|
export { bindWsHandler, createWebSocketTransportFactory, defaultWebSocketFactory, } from "./daemon-client-websocket-transport.js";
|
|
4
4
|
//# sourceMappingURL=daemon-client-transport.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { extractRelayMessage } from "./daemon-client-transport-utils.js";
|
|
1
2
|
export function defaultWebSocketFactory(url, options) {
|
|
2
3
|
const globalWs = globalThis.WebSocket;
|
|
3
4
|
if (!globalWs) {
|
|
@@ -40,10 +41,17 @@ export function createWebSocketTransportFactory(factory) {
|
|
|
40
41
|
onOpen: (handler) => bindWsHandler(ws, "open", handler),
|
|
41
42
|
onClose: (handler) => bindWsHandler(ws, "close", handler),
|
|
42
43
|
onError: (handler) => bindWsHandler(ws, "error", handler),
|
|
43
|
-
onMessage: (handler) =>
|
|
44
|
+
onMessage: (handler) => bindWsMessageHandler(ws, handler),
|
|
44
45
|
};
|
|
45
46
|
};
|
|
46
47
|
}
|
|
48
|
+
function bindWsMessageHandler(ws, handler) {
|
|
49
|
+
const listener = (...args) => {
|
|
50
|
+
const message = extractRelayMessage(args[0], typeof args[1] === "boolean" ? args[1] : undefined);
|
|
51
|
+
handler(message.data, message.isBinary);
|
|
52
|
+
};
|
|
53
|
+
return bindWsHandler(ws, "message", listener);
|
|
54
|
+
}
|
|
47
55
|
function bindTemporaryEarlyCloseErrorHandler(ws) {
|
|
48
56
|
const noop = () => { };
|
|
49
57
|
if (typeof ws.addEventListener === "function") {
|
package/dist/daemon-client.d.ts
CHANGED
|
@@ -719,6 +719,15 @@ export declare class DaemonClient {
|
|
|
719
719
|
startWorkspaceScript(workspaceId: string, scriptName: string, requestId?: string): Promise<Extract<SessionOutboundMessage, {
|
|
720
720
|
type: "start_workspace_script_response";
|
|
721
721
|
}>["payload"]>;
|
|
722
|
+
listWorkspaceScripts(workspaceId: string, requestId?: string): Promise<Extract<SessionOutboundMessage, {
|
|
723
|
+
type: "workspace.script.list.response";
|
|
724
|
+
}>["payload"]>;
|
|
725
|
+
startWorkspaceScriptWithStatus(workspaceId: string, scriptName: string, requestId?: string): Promise<Extract<SessionOutboundMessage, {
|
|
726
|
+
type: "workspace.script.start.response";
|
|
727
|
+
}>["payload"]>;
|
|
728
|
+
stopWorkspaceScript(workspaceId: string, scriptName: string, requestId?: string): Promise<Extract<SessionOutboundMessage, {
|
|
729
|
+
type: "workspace.script.stop.response";
|
|
730
|
+
}>["payload"]>;
|
|
722
731
|
archiveWorkspace(workspaceId: string, requestId?: string): Promise<ArchiveWorkspacePayload>;
|
|
723
732
|
fetchWorkspaceSetupStatus(workspaceId: string, requestId?: string): Promise<WorkspaceSetupStatusPayload>;
|
|
724
733
|
fetchAgent(options: FetchAgentOptions): Promise<FetchAgentResult | null>;
|
package/dist/daemon-client.js
CHANGED
|
@@ -1128,6 +1128,27 @@ export class DaemonClient {
|
|
|
1128
1128
|
responseType: "start_workspace_script_response",
|
|
1129
1129
|
});
|
|
1130
1130
|
}
|
|
1131
|
+
async listWorkspaceScripts(workspaceId, requestId) {
|
|
1132
|
+
return this.sendCorrelatedSessionRequest({
|
|
1133
|
+
requestId,
|
|
1134
|
+
message: { type: "workspace.script.list.request", workspaceId },
|
|
1135
|
+
responseType: "workspace.script.list.response",
|
|
1136
|
+
});
|
|
1137
|
+
}
|
|
1138
|
+
async startWorkspaceScriptWithStatus(workspaceId, scriptName, requestId) {
|
|
1139
|
+
return this.sendCorrelatedSessionRequest({
|
|
1140
|
+
requestId,
|
|
1141
|
+
message: { type: "workspace.script.start.request", workspaceId, scriptName },
|
|
1142
|
+
responseType: "workspace.script.start.response",
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
async stopWorkspaceScript(workspaceId, scriptName, requestId) {
|
|
1146
|
+
return this.sendCorrelatedSessionRequest({
|
|
1147
|
+
requestId,
|
|
1148
|
+
message: { type: "workspace.script.stop.request", workspaceId, scriptName },
|
|
1149
|
+
responseType: "workspace.script.stop.response",
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1131
1152
|
async archiveWorkspace(workspaceId, requestId) {
|
|
1132
1153
|
return this.sendCorrelatedSessionRequest({
|
|
1133
1154
|
requestId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpaseo/client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Paseo client SDK package",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"test": "vitest run"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@getpaseo/protocol": "0.2.
|
|
39
|
-
"@getpaseo/relay": "0.2.
|
|
38
|
+
"@getpaseo/protocol": "0.2.3",
|
|
39
|
+
"@getpaseo/relay": "0.2.3",
|
|
40
40
|
"zod": "^4.4.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|