Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App ws auth #240

Merged
merged 11 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
run: nix develop -c $SHELL -c "npm ci"

- name: Run tests
run: nix develop -c $SHELL -c "npm t"
run: nix develop --override-input versions/holochain "github:holochain/holochain/holochain-0.3.0-beta-dev.48" -c $SHELL -c "npm t"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until Holonix is updated we need to test against a specific Holochain that is newer than the one in weekly.

As we work up to automatically testing new releases before releasing Holonix updates, we should find a way to make this simpler than changing the workflow file... Not sure how!


- name: Setup tmate session if a previous step failed
if: ${{ failure() }}
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## \[Unreleased\]

### Added
- **BREAKING** Connecting an app websocket now requires an authentication token which can be obtained from the admin
websocket using `AdminWebsocket#issueAppAuthenticationToken`.

### Changed
- **BREAKING** Merged the app and app-agent websockets into a single `AppWebsocket` class. Following the addition of the
authentication token, the two types were well enough aligned that there was no longer a need to keep them separate.
- **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

Expand Down
44 changes: 22 additions & 22 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
],
"scripts": {
"lint": "eslint --fix --ext .ts src test .eslintrc.cjs",
"test:app-agent": "RUST_LOG=error RUST_BACKTRACE=1 tsx test/e2e/app-agent-websocket.ts",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

"test:app-agent": "RUST_LOG=error RUST_BACKTRACE=1 tsx test/e2e/app-websocket.ts",
"test:utils": "RUST_LOG=error RUST_BACKTRACE=1 tsx test/e2e/utils.ts",
"test": "RUST_LOG=error RUST_BACKTRACE=1 tsx test/index.ts",
"build:lib": "rimraf ./lib && tsc -p tsconfig.build.json",
Expand Down
37 changes: 34 additions & 3 deletions src/api/admin/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Action, DhtOp, Entry, ZomeCallCapGrant } from "../../hdk/index.js";
import { Action, DhtOp, Entry, ZomeCallCapGrant } from "../../hdk";
import {
ActionHash,
AgentPubKey,
Expand All @@ -17,7 +17,6 @@ import {
WasmHash,
} from "../../types.js";
import { Requester } from "../common.js";
import { DisableCloneCellRequest } from "../index.js";

/**
* @public
Expand Down Expand Up @@ -562,7 +561,16 @@ export type AddAgentInfoResponse = any;
/**
* @public
*/
export type DeleteCloneCellRequest = DisableCloneCellRequest;
export interface DeleteCloneCellRequest {
/**
* The app id that the clone cell belongs to
*/
app_id: InstalledAppId;
/**
* The clone id or cell id of the clone cell
*/
clone_cell_id: RoleName | CellId;
}

/**
* @public
Expand Down Expand Up @@ -813,6 +821,25 @@ export type StorageInfoRequest = void;
*/
export type StorageInfoResponse = StorageInfo;

/**
* @public
*/
export interface IssueAppAuthenticationTokenRequest {
installed_app_id: InstalledAppId;
expiry_seconds?: number;
single_use?: boolean;
}

export type AppAuthenticationToken = number[];

/**
* @public
*/
export interface IssueAppAuthenticationTokenResponse {
token: AppAuthenticationToken;
expires_at?: Timestamp;
}

/**
* @public
*/
Expand Down Expand Up @@ -861,6 +888,10 @@ export interface AdminApi {
GrantZomeCallCapabilityResponse
>;
storageInfo: Requester<StorageInfoRequest, StorageInfoResponse>;
issueAppAuthenticationToken: Requester<
IssueAppAuthenticationTokenRequest,
IssueAppAuthenticationTokenResponse
>;
dumpNetworkStats: Requester<
DumpNetworkStatsRequest,
DumpNetworkStatsResponse
Expand Down
7 changes: 7 additions & 0 deletions src/api/admin/websocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ import {
GrantZomeCallCapabilityResponse,
InstallAppRequest,
InstallAppResponse,
IssueAppAuthenticationTokenRequest,
IssueAppAuthenticationTokenResponse,
ListAppInterfacesRequest,
ListAppInterfacesResponse,
ListAppsRequest,
Expand Down Expand Up @@ -272,6 +274,11 @@ export class AdminWebsocket implements AdminApi {
storageInfo: Requester<StorageInfoRequest, StorageInfoResponse> =
this._requester("storage_info");

issueAppAuthenticationToken: Requester<
IssueAppAuthenticationTokenRequest,
IssueAppAuthenticationTokenResponse
> = this._requester("issue_app_authentication_token");

dumpNetworkStats: Requester<
DumpNetworkStatsRequest,
DumpNetworkStatsResponse
Expand Down
2 changes: 0 additions & 2 deletions src/api/app-agent/index.ts

This file was deleted.

111 changes: 0 additions & 111 deletions src/api/app-agent/types.ts

This file was deleted.

Loading
Loading