diff --git a/README.md b/README.md index ecbf6ba3..ce19a4a6 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ npm install --save-exact @holochain/client ```typescript import { ActionHash, AdminWebsocket, AppAgentWebsocket, CellType } from "@holochain/client"; -const adminWs = await AdminWebsocket.connect("ws://127.0.0.1:65000"); +const adminWs = await AdminWebsocket.connect({url: "ws://127.0.0.1:65000"}); const agent_key = await adminWs.generateAgentPubKey(); const role_name = "role"; const installed_app_id = "test-app"; @@ -51,10 +51,7 @@ if (!(CellType.Provisioned in appInfo.cell_info[role_name][0])) { const { cell_id } = appInfo.cell_info[role_name][0][CellType.Provisioned]; await adminWs.authorizeSigningCredentials(cell_id); await adminWs.attachAppInterface({ port: 65001 }); -const appAgentWs = await AppAgentWebsocket.connect( - "ws://127.0.0.1:65001", - installed_app_id -); +const appAgentWs = await AppAgentWebsocket.connect(installed_app_id, {url: "ws://127.0.0.1:65001"}); const zomeCallPayload: CallZomeRequest = { cell_id, @@ -74,7 +71,7 @@ await adminWs.client.close(); ```typescript import { AdminWebsocket, AppWebsocket, CellType } from "@holochain/client"; -const adminWs = await AdminWebsocket.connect("ws://127.0.0.1:65000"); +const adminWs = await AdminWebsocket.connect({url: "ws://127.0.0.1:65000"}); const agent_key = await adminWs.generateAgentPubKey(); const installed_app_id = "test-app"; const appInfo = await adminWs.installApp({ @@ -90,7 +87,7 @@ if (!(CellType.Provisioned in appInfo.cell_info["role"][0])) { const { cell_id } = appInfo.cell_info["role"][0][CellType.Provisioned]; await adminWs.authorizeSigningCredentials(cell_id); await adminWs.attachAppInterface({ port: 65001 }); -const appWs = await AppWebsocket.connect("ws://127.0.0.1:65001"); +const appWs = await AppWebsocket.connect({url: "ws://127.0.0.1:65001"}); let signalCb; const signalReceived = new Promise((resolve) => { diff --git a/docs/client.adminwebsocket.connect.md b/docs/client.adminwebsocket.connect.md index 50e90417..83b9497c 100644 --- a/docs/client.adminwebsocket.connect.md +++ b/docs/client.adminwebsocket.connect.md @@ -9,15 +9,14 @@ Factory mehtod to create a new instance connected to the given URL. **Signature:** ```typescript -static connect(url: URL, defaultTimeout?: number): Promise; +static connect(options?: WebsocketConnectionOptions): Promise; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| url | URL | A ws:// URL used as the connection address. | -| defaultTimeout | number | _(Optional)_ The default timeout for any request. | +| options | [WebsocketConnectionOptions](./client.websocketconnectionoptions.md) | _(Optional)_ [WebsocketConnectionOptions](./client.websocketconnectionoptions.md) | **Returns:** diff --git a/docs/client.adminwebsocket.md b/docs/client.adminwebsocket.md index 8665dcea..d10a004c 100644 --- a/docs/client.adminwebsocket.md +++ b/docs/client.adminwebsocket.md @@ -48,5 +48,5 @@ export declare class AdminWebsocket implements AdminApi | Method | Modifiers | Description | | --- | --- | --- | | [\_requester(tag, transformer)](./client.adminwebsocket._requester.md) | | | -| [connect(url, defaultTimeout)](./client.adminwebsocket.connect.md) | static | Factory mehtod to create a new instance connected to the given URL. | +| [connect(options)](./client.adminwebsocket.connect.md) | static | Factory mehtod to create a new instance connected to the given URL. | diff --git a/docs/client.appagentwebsocket.connect.md b/docs/client.appagentwebsocket.connect.md index 7247c423..bde94b3c 100644 --- a/docs/client.appagentwebsocket.connect.md +++ b/docs/client.appagentwebsocket.connect.md @@ -9,16 +9,15 @@ Instance factory for creating AppAgentWebsockets. **Signature:** ```typescript -static connect(url: URL, installed_app_id: InstalledAppId, defaultTimeout?: number): Promise; +static connect(installed_app_id: InstalledAppId, options?: WebsocketConnectionOptions): Promise; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| url | URL | The ws:// URL of the App API to connect to. | | installed\_app\_id | [InstalledAppId](./client.installedappid.md) | ID of the App to link to. | -| defaultTimeout | number | _(Optional)_ Timeout to default to for all operations. | +| options | [WebsocketConnectionOptions](./client.websocketconnectionoptions.md) | _(Optional)_ [WebsocketConnectionOptions](./client.websocketconnectionoptions.md) | **Returns:** diff --git a/docs/client.appagentwebsocket.md b/docs/client.appagentwebsocket.md index 168edb58..63b28752 100644 --- a/docs/client.appagentwebsocket.md +++ b/docs/client.appagentwebsocket.md @@ -29,7 +29,7 @@ export declare class AppAgentWebsocket implements AppAgentClient | --- | --- | --- | | [appInfo()](./client.appagentwebsocket.appinfo.md) | | Request the app's info, including all cell infos. | | [callZome(request, timeout)](./client.appagentwebsocket.callzome.md) | | Call a zome. | -| [connect(url, installed\_app\_id, defaultTimeout)](./client.appagentwebsocket.connect.md) | static | Instance factory for creating AppAgentWebsockets. | +| [connect(installed\_app\_id, options)](./client.appagentwebsocket.connect.md) | static | Instance factory for creating AppAgentWebsockets. | | [createCloneCell(args)](./client.appagentwebsocket.createclonecell.md) | | Clone an existing provisioned cell. | | [disableCloneCell(args)](./client.appagentwebsocket.disableclonecell.md) | | Disable an enabled clone cell. | | [enableCloneCell(args)](./client.appagentwebsocket.enableclonecell.md) | | Enable a disabled clone cell. | diff --git a/docs/client.appwebsocket.connect.md b/docs/client.appwebsocket.connect.md index d011f0c5..cae06b32 100644 --- a/docs/client.appwebsocket.connect.md +++ b/docs/client.appwebsocket.connect.md @@ -9,15 +9,14 @@ Instance factory for creating AppWebsockets. **Signature:** ```typescript -static connect(url: URL, defaultTimeout?: number): Promise; +static connect(options?: WebsocketConnectionOptions): Promise; ``` ## Parameters | Parameter | Type | Description | | --- | --- | --- | -| url | URL | The ws:// URL of the App API to connect to. | -| defaultTimeout | number | _(Optional)_ Timeout to default to for all operations. | +| options | [WebsocketConnectionOptions](./client.websocketconnectionoptions.md) | _(Optional)_ [WebsocketConnectionOptions](./client.websocketconnectionoptions.md) | **Returns:** diff --git a/docs/client.appwebsocket.md b/docs/client.appwebsocket.md index 14062131..b004e6e0 100644 --- a/docs/client.appwebsocket.md +++ b/docs/client.appwebsocket.md @@ -34,5 +34,5 @@ export declare class AppWebsocket extends Emittery implements AppApi | Method | Modifiers | Description | | --- | --- | --- | | [\_requester(tag, transformer)](./client.appwebsocket._requester.md) | | | -| [connect(url, defaultTimeout)](./client.appwebsocket.connect.md) | static | Instance factory for creating AppWebsockets. | +| [connect(options)](./client.appwebsocket.connect.md) | static | Instance factory for creating AppWebsockets. | diff --git a/docs/client.md b/docs/client.md index 0ff8e6bf..ef864cce 100644 --- a/docs/client.md +++ b/docs/client.md @@ -103,6 +103,7 @@ | [StorageInfo](./client.storageinfo.md) | | | [Update](./client.update.md) | | | [UpdateBase](./client.updatebase.md) | | +| [WebsocketConnectionOptions](./client.websocketconnectionoptions.md) | Options for a Websocket connection. | | [ZomeCallCapGrant](./client.zomecallcapgrant.md) | | | [ZomeDependency](./client.zomedependency.md) | | diff --git a/docs/client.websocketconnectionoptions.defaulttimeout.md b/docs/client.websocketconnectionoptions.defaulttimeout.md new file mode 100644 index 00000000..6605849e --- /dev/null +++ b/docs/client.websocketconnectionoptions.defaulttimeout.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@holochain/client](./client.md) > [WebsocketConnectionOptions](./client.websocketconnectionoptions.md) > [defaultTimeout](./client.websocketconnectionoptions.defaulttimeout.md) + +## WebsocketConnectionOptions.defaultTimeout property + +Timeout to default to for all operations. + +**Signature:** + +```typescript +defaultTimeout?: number; +``` diff --git a/docs/client.websocketconnectionoptions.md b/docs/client.websocketconnectionoptions.md new file mode 100644 index 00000000..7a577518 --- /dev/null +++ b/docs/client.websocketconnectionoptions.md @@ -0,0 +1,21 @@ + + +[Home](./index.md) > [@holochain/client](./client.md) > [WebsocketConnectionOptions](./client.websocketconnectionoptions.md) + +## WebsocketConnectionOptions interface + +Options for a Websocket connection. + +**Signature:** + +```typescript +export interface WebsocketConnectionOptions +``` + +## Properties + +| Property | Modifiers | Type | Description | +| --- | --- | --- | --- | +| [defaultTimeout?](./client.websocketconnectionoptions.defaulttimeout.md) | | number | _(Optional)_ Timeout to default to for all operations. | +| [url?](./client.websocketconnectionoptions.url.md) | | URL | _(Optional)_ The ws:// URL of the Websocket server to connect to. Not required when connecting to App API from a Launcher or Kangaroo environment. | + diff --git a/docs/client.websocketconnectionoptions.url.md b/docs/client.websocketconnectionoptions.url.md new file mode 100644 index 00000000..315c6bd4 --- /dev/null +++ b/docs/client.websocketconnectionoptions.url.md @@ -0,0 +1,13 @@ + + +[Home](./index.md) > [@holochain/client](./client.md) > [WebsocketConnectionOptions](./client.websocketconnectionoptions.md) > [url](./client.websocketconnectionoptions.url.md) + +## WebsocketConnectionOptions.url property + +The `ws://` URL of the Websocket server to connect to. Not required when connecting to App API from a Launcher or Kangaroo environment. + +**Signature:** + +```typescript +url?: URL; +``` diff --git a/docs/client.wsclient._constructor_.md b/docs/client.wsclient._constructor_.md index c44eb82b..bdbd805a 100644 --- a/docs/client.wsclient._constructor_.md +++ b/docs/client.wsclient._constructor_.md @@ -9,7 +9,7 @@ Constructs a new instance of the `WsClient` class **Signature:** ```typescript -constructor(socket: IsoWebSocket, url: URL); +constructor(socket: IsoWebSocket, url?: URL); ``` ## Parameters @@ -17,5 +17,5 @@ constructor(socket: IsoWebSocket, url: URL); | Parameter | Type | Description | | --- | --- | --- | | socket | IsoWebSocket | | -| url | URL | | +| url | URL | _(Optional)_ | diff --git a/src/api/admin/websocket.ts b/src/api/admin/websocket.ts index 7aeeb2c9..c21e522e 100644 --- a/src/api/admin/websocket.ts +++ b/src/api/admin/websocket.ts @@ -7,6 +7,7 @@ import { import type { AgentPubKey, CellId } from "../../types.js"; import { WsClient } from "../client.js"; import { + WebsocketConnectionOptions, catchError, DEFAULT_TIMEOUT, promiseTimeout, @@ -90,23 +91,27 @@ export class AdminWebsocket implements AdminApi { /** * Factory mehtod to create a new instance connected to the given URL. * - * @param url - A `ws://` URL used as the connection address. - * @param defaultTimeout - The default timeout for any request. + * @param options - {@link (WebsocketConnectionOptions:interface)} * @returns A promise for a new connected instance. */ static async connect( - url: URL, - defaultTimeout?: number + options: WebsocketConnectionOptions = {} ): Promise { // Check if we are in the launcher's environment, and if so, redirect the url to connect to const env = getLauncherEnvironment(); if (env?.ADMIN_INTERFACE_PORT) { - url = new URL(`ws://127.0.0.1:${env.ADMIN_INTERFACE_PORT}`); + options.url = new URL(`ws://127.0.0.1:${env.ADMIN_INTERFACE_PORT}`); } - const wsClient = await WsClient.connect(url); - return new AdminWebsocket(wsClient, defaultTimeout); + if (!options.url) { + throw new Error( + "Unable to connect to Admin Websocket: No url provided and not in a Launcher environment." + ); + } + + const wsClient = await WsClient.connect(options.url); + return new AdminWebsocket(wsClient, options.defaultTimeout); } _requester( diff --git a/src/api/app-agent/websocket.ts b/src/api/app-agent/websocket.ts index bbee8bd7..9060f252 100644 --- a/src/api/app-agent/websocket.ts +++ b/src/api/app-agent/websocket.ts @@ -15,7 +15,11 @@ import { NetworkInfoResponse, } from "../app/types.js"; import { AppWebsocket } from "../app/websocket.js"; -import { getBaseRoleNameFromCloneId, isCloneId } from "../common.js"; +import { + WebsocketConnectionOptions, + getBaseRoleNameFromCloneId, + isCloneId, +} from "../common.js"; import { AppAgentCallZomeRequest, AppAgentClient, @@ -88,17 +92,15 @@ export class AppAgentWebsocket implements AppAgentClient { /** * Instance factory for creating AppAgentWebsockets. * - * @param url - The `ws://` URL of the App API to connect to. * @param installed_app_id - ID of the App to link to. - * @param defaultTimeout - Timeout to default to for all operations. + * @param options - {@link (WebsocketConnectionOptions:interface)} * @returns A new instance of an AppAgentWebsocket. */ static async connect( - url: URL, installed_app_id: InstalledAppId, - defaultTimeout?: number + options: WebsocketConnectionOptions = {} ) { - const appWebsocket = await AppWebsocket.connect(url, defaultTimeout); + const appWebsocket = await AppWebsocket.connect(options); const appInfo = await appWebsocket.appInfo({ installed_app_id: installed_app_id, }); diff --git a/src/api/app/websocket.ts b/src/api/app/websocket.ts index 67c1709c..f8222d35 100644 --- a/src/api/app/websocket.ts +++ b/src/api/app/websocket.ts @@ -13,6 +13,7 @@ import { InstalledAppId } from "../../types.js"; import { encodeHashToBase64 } from "../../utils/base64.js"; import { WsClient } from "../client.js"; import { + WebsocketConnectionOptions, DEFAULT_TIMEOUT, Requester, Transformer, @@ -79,23 +80,28 @@ export class AppWebsocket extends Emittery implements AppApi { /** * Instance factory for creating AppWebsockets. * - * @param url - The `ws://` URL of the App API to connect to. - * @param defaultTimeout - Timeout to default to for all operations. + * @param options - {@link (WebsocketConnectionOptions:interface)} * @returns A new instance of an AppWebsocket. */ - static async connect(url: URL, defaultTimeout?: number) { + static async connect(options: WebsocketConnectionOptions = {}) { // Check if we are in the launcher's environment, and if so, redirect the url to connect to const env = getLauncherEnvironment(); if (env?.APP_INTERFACE_PORT) { - url = new URL(`ws://127.0.0.1:${env.APP_INTERFACE_PORT}`); + options.url = new URL(`ws://127.0.0.1:${env.APP_INTERFACE_PORT}`); } - const wsClient = await WsClient.connect(url); + if (!options.url) { + throw new Error( + "Unable to connect to App Websocket: No url provided and not in a Launcher environment." + ); + } + + const wsClient = await WsClient.connect(options.url); const appWebsocket = new AppWebsocket( wsClient, - defaultTimeout, + options.defaultTimeout, env?.INSTALLED_APP_ID ); diff --git a/src/api/client.ts b/src/api/client.ts index 2f67fc00..54eee4b2 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -31,7 +31,7 @@ export class WsClient extends Emittery { private pendingRequests: Record; private index: number; - constructor(socket: IsoWebSocket, url: URL) { + constructor(socket: IsoWebSocket, url?: URL) { super(); this.socket = socket; this.url = url; diff --git a/src/api/common.ts b/src/api/common.ts index 19293d74..7e067cee 100644 --- a/src/api/common.ts +++ b/src/api/common.ts @@ -168,3 +168,20 @@ export class CloneId { return this.roleName; } } + +/** + * Options for a Websocket connection. + * + * @public + */ +export interface WebsocketConnectionOptions { + /** + * The `ws://` URL of the Websocket server to connect to. Not required when connecting to App API from a Launcher or Kangaroo environment. + */ + url?: URL; + + /** + * Timeout to default to for all operations. + */ + defaultTimeout?: number; +} diff --git a/src/api/index.ts b/src/api/index.ts index c48d28bb..d949049a 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -8,6 +8,7 @@ export { HolochainError, Requester, Transformer, + WebsocketConnectionOptions, getBaseRoleNameFromCloneId, isCloneId, } from "./common.js"; diff --git a/test/e2e/app-agent-websocket.ts b/test/e2e/app-agent-websocket.ts index 39915eef..8404d035 100644 --- a/test/e2e/app-agent-websocket.ts +++ b/test/e2e/app-agent-websocket.ts @@ -1,5 +1,5 @@ import assert from "node:assert"; -import test, { Test } from "tape"; +import test from "tape"; import { AdminWebsocket, AppAgentCallZomeRequest, @@ -127,9 +127,9 @@ test( "cells only receive their own signals", withConductor(ADMIN_PORT, async (t) => { const role_name = "foo"; - const admin = await AdminWebsocket.connect( - new URL(`ws://127.0.0.1:${ADMIN_PORT}`) - ); + const admin = await AdminWebsocket.connect({ + url: new URL(`ws://127.0.0.1:${ADMIN_PORT}`), + }); const path = `${FIXTURE_PATH}/test.happ`; const { port: appPort } = await admin.attachAppInterface({ port: 0 }); @@ -168,8 +168,12 @@ test( await admin.authorizeSigningCredentials(cell_id1); const clientUrl = new URL(`ws://127.0.0.1:${appPort}`); - const appAgentWs1 = await AppAgentWebsocket.connect(clientUrl, app_id1); - const appAgentWs2 = await AppAgentWebsocket.connect(clientUrl, app_id2); + const appAgentWs1 = await AppAgentWebsocket.connect(app_id1, { + url: clientUrl, + }); + const appAgentWs2 = await AppAgentWebsocket.connect(app_id2, { + url: clientUrl, + }); appAgentWs1.on("signal", signalCb1); appAgentWs2.on("signal", signalCb2); diff --git a/test/e2e/common.ts b/test/e2e/common.ts index 047155be..6f34c11d 100644 --- a/test/e2e/common.ts +++ b/test/e2e/common.ts @@ -104,9 +104,9 @@ export const installAppAndDna = async ( }> => { const role_name = "foo"; const installed_app_id = "app"; - const admin = await AdminWebsocket.connect( - new URL(`ws://127.0.0.1:${adminPort}`) - ); + const admin = await AdminWebsocket.connect({ + url: new URL(`ws://127.0.0.1:${adminPort}`), + }); const path = `${FIXTURE_PATH}/test.happ`; const agent = await admin.generateAgentPubKey(); const app = await admin.installApp({ @@ -120,9 +120,9 @@ export const installAppAndDna = async ( await admin.enableApp({ installed_app_id }); // destructure to get whatever open port was assigned to the interface const { port: appPort } = await admin.attachAppInterface({ port: 0 }); - const client = await AppWebsocket.connect( - new URL(`ws://127.0.0.1:${appPort}`) - ); + const client = await AppWebsocket.connect({ + url: new URL(`ws://127.0.0.1:${appPort}`), + }); return { installed_app_id, cell_id, client, admin }; }; @@ -136,9 +136,9 @@ export const createAppAgentWsAndInstallApp = async ( }> => { const role_name = "foo"; const installed_app_id = "app"; - const admin = await AdminWebsocket.connect( - new URL(`ws://127.0.0.1:${adminPort}`) - ); + const admin = await AdminWebsocket.connect({ + url: new URL(`ws://127.0.0.1:${adminPort}`), + }); const path = `${FIXTURE_PATH}/test.happ`; const agent = await admin.generateAgentPubKey(); const app = await admin.installApp({ @@ -151,11 +151,10 @@ export const createAppAgentWsAndInstallApp = async ( const cell_id = app.cell_info[role_name][0][CellType.Provisioned].cell_id; await admin.enableApp({ installed_app_id }); const { port: appPort } = await admin.attachAppInterface({ port: 0 }); - const client = await AppAgentWebsocket.connect( - new URL(`ws://127.0.0.1:${appPort}`), - installed_app_id, - 12000 - ); + const client = await AppAgentWebsocket.connect(installed_app_id, { + url: new URL(`ws://127.0.0.1:${appPort}`), + defaultTimeout: 12000, + }); return { installed_app_id, cell_id, client, admin }; }; diff --git a/test/e2e/index.ts b/test/e2e/index.ts index d1918d4c..1b1d4ae2 100644 --- a/test/e2e/index.ts +++ b/test/e2e/index.ts @@ -58,7 +58,10 @@ test( "admin smoke test: registerDna + installApp + uninstallApp", withConductor(ADMIN_PORT, async (t) => { const installed_app_id = "app"; - const admin = await AdminWebsocket.connect(ADMIN_WS_URL, 12000); + const admin = await AdminWebsocket.connect({ + url: ADMIN_WS_URL, + defaultTimeout: 12000, + }); const agent_key = await admin.generateAgentPubKey(); t.ok(agent_key); @@ -183,7 +186,10 @@ test( "admin smoke test: installBundle", withConductor(ADMIN_PORT, async (t) => { const installed_app_id = "app"; - const admin = await AdminWebsocket.connect(ADMIN_WS_URL, 12000); + const admin = await AdminWebsocket.connect({ + url: ADMIN_WS_URL, + defaultTimeout: 12000, + }); const agent_key = await admin.generateAgentPubKey(); t.ok(agent_key); @@ -241,7 +247,10 @@ test( "admin register dna with full binary bundle + get dna def", withConductor(ADMIN_PORT, async (t) => { const installed_app_id = "app"; - const admin = await AdminWebsocket.connect(ADMIN_WS_URL, 12000); + const admin = await AdminWebsocket.connect({ + url: ADMIN_WS_URL, + defaultTimeout: 12000, + }); const agent_key = await admin.generateAgentPubKey(); t.ok(agent_key); @@ -366,7 +375,7 @@ test( const { admin } = await installAppAndDna(ADMIN_PORT); const { port } = await admin.attachAppInterface({}); t.assert(typeof port === "number", "returned a valid app port"); - await AppWebsocket.connect(new URL(`ws://127.0.0.1:${port}`)); + await AppWebsocket.connect({ url: new URL(`ws://127.0.0.1:${port}`) }); t.pass("can connect an app websocket to attached port"); }) ); @@ -406,7 +415,7 @@ test( test( "generated signing key has same location bytes as original agent pub key", withConductor(ADMIN_PORT, async (t) => { - const admin = await AdminWebsocket.connect(ADMIN_WS_URL); + const admin = await AdminWebsocket.connect({ url: ADMIN_WS_URL }); const agent = await admin.generateAgentPubKey(); const [, signingKey] = await generateSigningKeyPair(agent); t.deepEqual(signingKey.subarray(35), Uint8Array.from(agent.subarray(35))); @@ -418,7 +427,7 @@ test( withConductor(ADMIN_PORT, async (t) => { const role_name = "foo"; const installed_app_id = "app"; - const admin = await AdminWebsocket.connect(ADMIN_WS_URL); + const admin = await AdminWebsocket.connect({ url: ADMIN_WS_URL }); const agent = await admin.generateAgentPubKey(); const app = await admin.installApp({ @@ -448,9 +457,9 @@ test( }); await admin.enableApp({ installed_app_id }); const { port: appPort } = await admin.attachAppInterface({ port: 0 }); - const client = await AppWebsocket.connect( - new URL(`ws://127.0.0.1:${appPort}`) - ); + const client = await AppWebsocket.connect({ + url: new URL(`ws://127.0.0.1:${appPort}`), + }); assert(CellType.Provisioned in app.cell_info[role_name][0]); const cell_id = app.cell_info[role_name][0][CellType.Provisioned].cell_id; @@ -475,7 +484,7 @@ test( withConductor(ADMIN_PORT, async (t) => { const role_name = "foo"; const installed_app_id = "app"; - const admin = await AdminWebsocket.connect(ADMIN_WS_URL); + const admin = await AdminWebsocket.connect({ url: ADMIN_WS_URL }); const agent = await admin.generateAgentPubKey(); const dnaPath = `${FIXTURE_PATH}/test.dna`; @@ -509,9 +518,9 @@ test( }); await admin.enableApp({ installed_app_id }); const { port: appPort } = await admin.attachAppInterface({ port: 0 }); - const client = await AppWebsocket.connect( - new URL(`ws://127.0.0.1:${appPort}`) - ); + const client = await AppWebsocket.connect({ + url: new URL(`ws://127.0.0.1:${appPort}`), + }); assert(CellType.Provisioned in app.cell_info[role_name][0]); const cell_id = app.cell_info[role_name][0][CellType.Provisioned].cell_id; @@ -601,7 +610,7 @@ test( // no conductor test("error is catchable when holochain socket is unavailable", async (t) => { try { - await AdminWebsocket.connect(ADMIN_WS_URL); + await AdminWebsocket.connect({ url: ADMIN_WS_URL }); } catch (e) { t.equal( e.message, @@ -610,7 +619,7 @@ test("error is catchable when holochain socket is unavailable", async (t) => { } try { - await AppWebsocket.connect(ADMIN_WS_URL); + await AppWebsocket.connect({ url: ADMIN_WS_URL }); } catch (e) { t.equal( e.message, @@ -644,10 +653,10 @@ test("can inject agents", async (t) => { const conductor1 = await launch(ADMIN_PORT); const conductor2 = await launch(ADMIN_PORT_1); const installed_app_id = "app"; - const admin1 = await AdminWebsocket.connect(ADMIN_WS_URL); - const admin2 = await AdminWebsocket.connect( - new URL(`ws://127.0.0.1:${ADMIN_PORT_1}`) - ); + const admin1 = await AdminWebsocket.connect({ url: ADMIN_WS_URL }); + const admin2 = await AdminWebsocket.connect({ + url: new URL(`ws://127.0.0.1:${ADMIN_PORT_1}`), + }); const agent_key_1 = await admin1.generateAgentPubKey(); t.ok(agent_key_1); const agent_key_2 = await admin2.generateAgentPubKey(); @@ -812,7 +821,7 @@ test.only( test( "admin smoke test: listAppInterfaces + attachAppInterface", withConductor(ADMIN_PORT, async (t) => { - const admin = await AdminWebsocket.connect(ADMIN_WS_URL); + const admin = await AdminWebsocket.connect({ url: ADMIN_WS_URL }); let interfaces = await admin.listAppInterfaces(); t.equal(interfaces.length, 0); @@ -858,7 +867,7 @@ test( test( "admin smoke test: install 2 hApp bundles with different network seeds", withConductor(ADMIN_PORT, async (t) => { - const admin = await AdminWebsocket.connect(ADMIN_WS_URL); + const admin = await AdminWebsocket.connect({ url: ADMIN_WS_URL }); const agent_key = await admin.generateAgentPubKey(); const installedApp1 = await admin.installApp({