Skip to content

Commit

Permalink
Adapt to other API changes for app ws security
Browse files Browse the repository at this point in the history
  • Loading branch information
ThetaSinner committed Apr 26, 2024
1 parent 54e7845 commit 63a57b4
Show file tree
Hide file tree
Showing 12 changed files with 169 additions and 7 deletions.
14 changes: 11 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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`.
Expand Down
11 changes: 11 additions & 0 deletions docs/client.appinterfaceinfo.allowed_origins.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [AppInterfaceInfo](./client.appinterfaceinfo.md) &gt; [allowed\_origins](./client.appinterfaceinfo.allowed_origins.md)

## AppInterfaceInfo.allowed\_origins property

**Signature:**

```typescript
allowed_origins: string;
```
11 changes: 11 additions & 0 deletions docs/client.appinterfaceinfo.installed_app_id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [AppInterfaceInfo](./client.appinterfaceinfo.md) &gt; [installed\_app\_id](./client.appinterfaceinfo.installed_app_id.md)

## AppInterfaceInfo.installed\_app\_id property

**Signature:**

```typescript
installed_app_id?: InstalledAppId;
```
90 changes: 90 additions & 0 deletions docs/client.appinterfaceinfo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [AppInterfaceInfo](./client.appinterfaceinfo.md)

## AppInterfaceInfo interface


**Signature:**

```typescript
export interface AppInterfaceInfo
```

## Properties

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[allowed\_origins](./client.appinterfaceinfo.allowed_origins.md)


</td><td>


</td><td>

string


</td><td>


</td></tr>
<tr><td>

[installed\_app\_id?](./client.appinterfaceinfo.installed_app_id.md)


</td><td>


</td><td>

[InstalledAppId](./client.installedappid.md)


</td><td>

_(Optional)_


</td></tr>
<tr><td>

[port](./client.appinterfaceinfo.port.md)


</td><td>


</td><td>

number


</td><td>


</td></tr>
</tbody></table>
11 changes: 11 additions & 0 deletions docs/client.appinterfaceinfo.port.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@holochain/client](./client.md) &gt; [AppInterfaceInfo](./client.appinterfaceinfo.md) &gt; [port](./client.appinterfaceinfo.port.md)

## AppInterfaceInfo.port property

**Signature:**

```typescript
port: number;
```
3 changes: 3 additions & 0 deletions docs/client.attachappinterfacerequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
export type AttachAppInterfaceRequest = {
port?: number;
allowed_origins: string;
installed_app_id?: InstalledAppId;
};
```
**References:** [InstalledAppId](./client.installedappid.md)

4 changes: 3 additions & 1 deletion docs/client.listappinterfacesresponse.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
**Signature:**

```typescript
export type ListAppInterfacesResponse = Array<number>;
export type ListAppInterfacesResponse = Array<AppInterfaceInfo>;
```
**References:** [AppInterfaceInfo](./client.appinterfaceinfo.md)

10 changes: 10 additions & 0 deletions docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,16 @@ Description



</td></tr>
<tr><td>

[AppInterfaceInfo](./client.appinterfaceinfo.md)


</td><td>



</td></tr>
<tr><td>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]> (https://holochain.org)",
"license": "CAL-1.0",
Expand Down
15 changes: 14 additions & 1 deletion src/api/admin/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

/**
Expand Down Expand Up @@ -524,7 +528,16 @@ export type ListAppInterfacesRequest = void;
/**
* @public
*/
export type ListAppInterfacesResponse = Array<number>;
export type ListAppInterfacesResponse = Array<AppInterfaceInfo>;

/**
* @public
*/
export interface AppInterfaceInfo {
port: number;
allowed_origins: string;
installed_app_id?: InstalledAppId;
}

/**
* This type is meant to be opaque
Expand Down
2 changes: 1 addition & 1 deletion src/api/index.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
})
);

Expand Down

0 comments on commit 63a57b4

Please sign in to comment.