From 63a57b48ed3d302268e461d3f29633c7b497ba11 Mon Sep 17 00:00:00 2001 From: ThetaSinner Date: Fri, 26 Apr 2024 11:55:25 +0100 Subject: [PATCH] Adapt to other API changes for app ws security --- CHANGELOG.md | 14 ++- ...client.appinterfaceinfo.allowed_origins.md | 11 +++ ...lient.appinterfaceinfo.installed_app_id.md | 11 +++ docs/client.appinterfaceinfo.md | 90 +++++++++++++++++++ docs/client.appinterfaceinfo.port.md | 11 +++ docs/client.attachappinterfacerequest.md | 3 + docs/client.listappinterfacesresponse.md | 4 +- docs/client.md | 10 +++ package.json | 2 +- src/api/admin/types.ts | 15 +++- src/api/index.ts | 2 +- test/e2e/index.ts | 3 + 12 files changed, 169 insertions(+), 7 deletions(-) create mode 100644 docs/client.appinterfaceinfo.allowed_origins.md create mode 100644 docs/client.appinterfaceinfo.installed_app_id.md create mode 100644 docs/client.appinterfaceinfo.md create mode 100644 docs/client.appinterfaceinfo.port.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 542351fb..ae574283 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## \[Unreleased\] +### Added +### Changed +### Fixed +### Removed + +## 2024-04-26: v0.17.0-dev.11 +### Changed +- New optional parameter to `attachAppInterface` to bind the app interface to a specific app. +- **BREAKING** The admin call `listAppInterfaces` now returns a list of `AppInterfaceInfo` instead of a list of ports. + +## 2024-04-25: v0.17.0-dev.10 ### Added - **BREAKING** Connecting an app websocket now requires an authentication token which can be obtained from the admin websocket using `AdminWebsocket#issueAppAuthenticationToken`. @@ -14,9 +25,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - **BREAKING** App calls that previously required an `InstalledAppId` no longer require one because the websocket will be authenticated with an app already, so the app interface no longer requires you to tell it which app you are calling. -### Fixed -### Removed - ## 2024-04-16: v0.17.0-dev.9 ### Fixed - Replace all IPv4 addresses `127.0.0.1` by `localhost`. diff --git a/docs/client.appinterfaceinfo.allowed_origins.md b/docs/client.appinterfaceinfo.allowed_origins.md new file mode 100644 index 00000000..18c1c907 --- /dev/null +++ b/docs/client.appinterfaceinfo.allowed_origins.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@holochain/client](./client.md) > [AppInterfaceInfo](./client.appinterfaceinfo.md) > [allowed\_origins](./client.appinterfaceinfo.allowed_origins.md) + +## AppInterfaceInfo.allowed\_origins property + +**Signature:** + +```typescript +allowed_origins: string; +``` diff --git a/docs/client.appinterfaceinfo.installed_app_id.md b/docs/client.appinterfaceinfo.installed_app_id.md new file mode 100644 index 00000000..828cabbf --- /dev/null +++ b/docs/client.appinterfaceinfo.installed_app_id.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@holochain/client](./client.md) > [AppInterfaceInfo](./client.appinterfaceinfo.md) > [installed\_app\_id](./client.appinterfaceinfo.installed_app_id.md) + +## AppInterfaceInfo.installed\_app\_id property + +**Signature:** + +```typescript +installed_app_id?: InstalledAppId; +``` diff --git a/docs/client.appinterfaceinfo.md b/docs/client.appinterfaceinfo.md new file mode 100644 index 00000000..babd21c8 --- /dev/null +++ b/docs/client.appinterfaceinfo.md @@ -0,0 +1,90 @@ + + +[Home](./index.md) > [@holochain/client](./client.md) > [AppInterfaceInfo](./client.appinterfaceinfo.md) + +## AppInterfaceInfo interface + + +**Signature:** + +```typescript +export interface AppInterfaceInfo +``` + +## Properties + + + + + +
+ +Property + + + + +Modifiers + + + + +Type + + + + +Description + + +
+ +[allowed\_origins](./client.appinterfaceinfo.allowed_origins.md) + + + + + + + +string + + + + + +
+ +[installed\_app\_id?](./client.appinterfaceinfo.installed_app_id.md) + + + + + + + +[InstalledAppId](./client.installedappid.md) + + + + +_(Optional)_ + + +
+ +[port](./client.appinterfaceinfo.port.md) + + + + + + + +number + + + + + +
diff --git a/docs/client.appinterfaceinfo.port.md b/docs/client.appinterfaceinfo.port.md new file mode 100644 index 00000000..ef5be6a0 --- /dev/null +++ b/docs/client.appinterfaceinfo.port.md @@ -0,0 +1,11 @@ + + +[Home](./index.md) > [@holochain/client](./client.md) > [AppInterfaceInfo](./client.appinterfaceinfo.md) > [port](./client.appinterfaceinfo.port.md) + +## AppInterfaceInfo.port property + +**Signature:** + +```typescript +port: number; +``` diff --git a/docs/client.attachappinterfacerequest.md b/docs/client.attachappinterfacerequest.md index f7ce5f5d..053d90fa 100644 --- a/docs/client.attachappinterfacerequest.md +++ b/docs/client.attachappinterfacerequest.md @@ -11,5 +11,8 @@ export type AttachAppInterfaceRequest = { port?: number; allowed_origins: string; + installed_app_id?: InstalledAppId; }; ``` +**References:** [InstalledAppId](./client.installedappid.md) + diff --git a/docs/client.listappinterfacesresponse.md b/docs/client.listappinterfacesresponse.md index 1a2c1c64..0063d521 100644 --- a/docs/client.listappinterfacesresponse.md +++ b/docs/client.listappinterfacesresponse.md @@ -8,5 +8,7 @@ **Signature:** ```typescript -export type ListAppInterfacesResponse = Array; +export type ListAppInterfacesResponse = Array; ``` +**References:** [AppInterfaceInfo](./client.appinterfaceinfo.md) + diff --git a/docs/client.md b/docs/client.md index 1054a6da..0e409a3a 100644 --- a/docs/client.md +++ b/docs/client.md @@ -528,6 +528,16 @@ Description + + + +[AppInterfaceInfo](./client.appinterfaceinfo.md) + + + + + + diff --git a/package.json b/package.json index 202bcd03..90bb9c4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@holochain/client", - "version": "0.17.0-dev.10", + "version": "0.17.0-dev.11", "description": "A JavaScript client for the Holochain Conductor API", "author": "Holochain Foundation (https://holochain.org)", "license": "CAL-1.0", diff --git a/src/api/admin/types.ts b/src/api/admin/types.ts index 38fb5501..26ae6963 100644 --- a/src/api/admin/types.ts +++ b/src/api/admin/types.ts @@ -28,6 +28,10 @@ export type AttachAppInterfaceRequest = { * For example: `http://localhost:3000,http://localhost:3001` */ allowed_origins: string; + /** + * Optionally, bind this app interface to a specific installed app. + */ + installed_app_id?: InstalledAppId; }; /** @@ -524,7 +528,16 @@ export type ListAppInterfacesRequest = void; /** * @public */ -export type ListAppInterfacesResponse = Array; +export type ListAppInterfacesResponse = Array; + +/** + * @public + */ +export interface AppInterfaceInfo { + port: number; + allowed_origins: string; + installed_app_id?: InstalledAppId; +} /** * This type is meant to be opaque diff --git a/src/api/index.ts b/src/api/index.ts index a7b12457..08d8ecb2 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,7 +1,7 @@ export { hashZomeCall } from "@holochain/serialization"; export * from "./admin/index.js"; export * from "./app/index.js"; -export { IsoWebSocket, WsClient, AppAuthenticationRequest } from "./client.js"; +export { IsoWebSocket, WsClient, type AppAuthenticationRequest } from "./client.js"; export { CloneId, HolochainError, diff --git a/test/e2e/index.ts b/test/e2e/index.ts index d9cb9f1e..05d4b7ee 100644 --- a/test/e2e/index.ts +++ b/test/e2e/index.ts @@ -920,6 +920,9 @@ test( interfaces = await admin.listAppInterfaces(); t.equal(interfaces.length, 1); + t.true(interfaces[0].port > 0); + t.equal(interfaces[0].allowed_origins, "client-test-app"); + t.equal(interfaces[0].installed_app_id, null); }) );