@holochain/client
Advanced tools
Comparing version 0.18.0-dev.1 to 0.18.0-dev.2
@@ -69,3 +69,3 @@ import { Action, DhtOp, Entry, ZomeCallCapGrant } from "../../hdk/index.js"; | ||
}; | ||
} | "running"; | ||
} | "awaiting_memproofs" | "running"; | ||
/** | ||
@@ -132,2 +132,8 @@ * @public | ||
*/ | ||
export type MemproofMap = { | ||
[key: string]: MembraneProof; | ||
}; | ||
/** | ||
* @public | ||
*/ | ||
export type DisableAppRequest = { | ||
@@ -361,2 +367,3 @@ installed_app_id: InstalledAppId; | ||
roles: Array<AppRoleManifest>; | ||
membrane_proofs_deferred: boolean; | ||
}; | ||
@@ -399,5 +406,3 @@ /** | ||
*/ | ||
membrane_proofs: { | ||
[key: string]: MembraneProof; | ||
}; | ||
membrane_proofs: MemproofMap; | ||
/** | ||
@@ -404,0 +409,0 @@ * Optional global network seed override. If set will override the network seed value for all |
import { UnsubscribeFunction } from "emittery"; | ||
import { AgentPubKey, AppAuthenticationToken, AppInfo, CapSecret, CellId, ClonedCell, DnaHash, DnaProperties, FunctionName, InstalledAppId, MembraneProof, NetworkInfo, NetworkSeed, Nonce256Bit, RoleName, Timestamp, Transformer, WebsocketConnectionOptions, ZomeName } from "../../index.js"; | ||
import { AgentPubKey, AppAuthenticationToken, AppInfo, CapSecret, CellId, ClonedCell, DnaHash, DnaProperties, FunctionName, InstalledAppId, MembraneProof, MemproofMap, NetworkInfo, NetworkSeed, Nonce256Bit, RoleName, Timestamp, Transformer, WebsocketConnectionOptions, ZomeName } from "../../index.js"; | ||
/** | ||
@@ -88,2 +88,10 @@ * @public | ||
*/ | ||
export type ProvideMemproofsRequest = MemproofMap; | ||
/** | ||
* @public | ||
*/ | ||
export type ProvideMemproofsResponse = void; | ||
/** | ||
* @public | ||
*/ | ||
export interface CreateCloneCellRequest { | ||
@@ -231,2 +239,5 @@ /** | ||
} | ||
/** | ||
* @public | ||
*/ | ||
export type CallZomeTransform = Transformer<CallZomeRequest | CallZomeRequestSigned, Promise<CallZomeRequestSigned>, CallZomeResponseGeneric<Uint8Array>, CallZomeResponse>; |
import { UnsubscribeFunction } from "emittery"; | ||
import { AgentPubKey, CellId, InstalledAppId, RoleName } from "../../types.js"; | ||
import { AppInfo } from "../admin/index.js"; | ||
import { AppInfo, MemproofMap } from "../admin/index.js"; | ||
import { AppCallZomeRequest, AppClient, AppEvents, AppNetworkInfoRequest, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest, AppSignalCb, CallZomeRequest, CallZomeRequestSigned, CallZomeResponse, CreateCloneCellResponse, DisableCloneCellResponse, EnableCloneCellResponse, NetworkInfoResponse, AppWebsocketConnectionOptions } from "./types.js"; | ||
@@ -22,2 +22,3 @@ import { WsClient } from "../client.js"; | ||
private readonly callZomeRequester; | ||
private readonly provideMemproofRequester; | ||
private readonly createCloneCellRequester; | ||
@@ -44,2 +45,8 @@ private readonly enableCloneCellRequester; | ||
/** | ||
* Provide membrane proofs for the app. | ||
* | ||
* @param memproofs - A map of {@link MembraneProof}s. | ||
*/ | ||
provideMemproofs(memproofs: MemproofMap): Promise<void>; | ||
/** | ||
* Get a cell id by its role name or clone id. | ||
@@ -46,0 +53,0 @@ * |
@@ -28,2 +28,3 @@ import Emittery from "emittery"; | ||
callZomeRequester; | ||
provideMemproofRequester; | ||
createCloneCellRequester; | ||
@@ -43,2 +44,3 @@ enableCloneCellRequester; | ||
this.callZomeRequester = AppWebsocket.requester(this.client, "call_zome", this.defaultTimeout, this.callZomeTransform); | ||
this.provideMemproofRequester = AppWebsocket.requester(this.client, "provide_memproofs", this.defaultTimeout); | ||
this.createCloneCellRequester = AppWebsocket.requester(this.client, "create_clone_cell", this.defaultTimeout); | ||
@@ -111,2 +113,10 @@ this.enableCloneCellRequester = AppWebsocket.requester(this.client, "enable_clone_cell", this.defaultTimeout); | ||
/** | ||
* Provide membrane proofs for the app. | ||
* | ||
* @param memproofs - A map of {@link MembraneProof}s. | ||
*/ | ||
async provideMemproofs(memproofs) { | ||
await this.provideMemproofRequester(memproofs); | ||
} | ||
/** | ||
* Get a cell id by its role name or clone id. | ||
@@ -113,0 +123,0 @@ * |
{ | ||
"name": "@holochain/client", | ||
"version": "0.18.0-dev.1", | ||
"version": "0.18.0-dev.2", | ||
"description": "A JavaScript client for the Holochain Conductor API", | ||
@@ -5,0 +5,0 @@ "author": "Holochain Foundation <info@holochain.org> (https://holochain.org)", |
@@ -33,13 +33,22 @@ [![Project](https://img.shields.io/badge/Project-Holochain-blue.svg?style=flat-square)](http://holochain.org/) | ||
### Use AppAgentWebsocket with implicit zome call signing | ||
### Use AppWebsocket with implicit zome call signing | ||
```typescript | ||
import { ActionHash, AdminWebsocket, AppAgentWebsocket, CellType } from "@holochain/client"; | ||
import { | ||
AdminWebsocket, | ||
AppWebsocket, | ||
CellType, | ||
type ActionHash, | ||
type CallZomeRequest, | ||
} from "@holochain/client"; | ||
const adminWs = await AdminWebsocket.connect({url: "ws://127.0.0.1:65000"}); | ||
const adminWs = await AdminWebsocket.connect({ | ||
url: new URL("ws://127.0.0.1:65000"), | ||
wsClientOptions: { origin: "my-happ" }, | ||
}); | ||
const agent_key = await adminWs.generateAgentPubKey(); | ||
const role_name = "role"; | ||
const role_name = "foo"; | ||
const installed_app_id = "test-app"; | ||
const appInfo = await adminWs.installApp({ | ||
agent_key, | ||
path: "path/to/happ/file", | ||
path: "./test/e2e/fixture/test.happ", | ||
installed_app_id, | ||
@@ -50,33 +59,45 @@ membrane_proofs: {}, | ||
if (!(CellType.Provisioned in appInfo.cell_info[role_name][0])) { | ||
process.exit(); | ||
throw new Error(`No cell found under role name ${role_name}`); | ||
} | ||
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(installed_app_id, {url: "ws://127.0.0.1:65001"}); | ||
await adminWs.attachAppInterface({ port: 65001, allowed_origins: "my-happ" }); | ||
const issuedToken = await adminWs.issueAppAuthenticationToken({ | ||
installed_app_id, | ||
}); | ||
const appWs = await AppWebsocket.connect({ | ||
url: new URL("ws://127.0.0.1:65001"), | ||
token: issuedToken.token, | ||
wsClientOptions: { origin: "my-happ" }, | ||
}); | ||
const zomeCallPayload: CallZomeRequest = { | ||
cell_id, | ||
zome_name: "zome_name", | ||
fn_name: "create_entry", | ||
zome_name: "foo", | ||
fn_name: "foo", | ||
provenance: agent_key, | ||
payload: "some_content", | ||
payload: null, | ||
}; | ||
const response: ActionHash = await appAgentWs.callZome(zomeCallPayload, 30000); | ||
const response: ActionHash = await appWs.callZome(zomeCallPayload, 30000); | ||
console.log("zome call response is", response); | ||
await appAgentWs.appWebsocket.client.close(); | ||
await appWs.client.close(); | ||
await adminWs.client.close(); | ||
``` | ||
### Use AppWebsocket with implicit zome call signing | ||
### Subscribe to signals | ||
```typescript | ||
import { AdminWebsocket, AppWebsocket, CellType } from "@holochain/client"; | ||
const adminWs = await AdminWebsocket.connect({url: "ws://127.0.0.1:65000"}); | ||
const adminWs = await AdminWebsocket.connect({ | ||
url: new URL("ws://127.0.0.1:65000"), | ||
wsClientOptions: { origin: "my-happ" }, | ||
}); | ||
const agent_key = await adminWs.generateAgentPubKey(); | ||
const role_name = "foo"; | ||
const installed_app_id = "test-app"; | ||
const appInfo = await adminWs.installApp({ | ||
agent_key, | ||
path: "path/to/happ/file", | ||
path: "./test/e2e/fixture/test.happ", | ||
installed_app_id, | ||
@@ -86,9 +107,16 @@ membrane_proofs: {}, | ||
await adminWs.enableApp({ installed_app_id }); | ||
if (!(CellType.Provisioned in appInfo.cell_info["role"][0])) { | ||
process.exit(); | ||
if (!(CellType.Provisioned in appInfo.cell_info[role_name][0])) { | ||
throw new Error(`No cell found under role name ${role_name}`); | ||
} | ||
const { cell_id } = appInfo.cell_info["role"][0][CellType.Provisioned]; | ||
const { cell_id } = appInfo.cell_info[role_name][0][CellType.Provisioned]; | ||
await adminWs.authorizeSigningCredentials(cell_id); | ||
await adminWs.attachAppInterface({ port: 65001 }); | ||
const appWs = await AppWebsocket.connect({url: "ws://127.0.0.1:65001"}); | ||
await adminWs.attachAppInterface({ port: 65001, allowed_origins: "my-happ" }); | ||
const issuedToken = await adminWs.issueAppAuthenticationToken({ | ||
installed_app_id, | ||
}); | ||
const appWs = await AppWebsocket.connect({ | ||
url: new URL("ws://127.0.0.1:65001"), | ||
token: issuedToken.token, | ||
wsClientOptions: { origin: "my-happ" }, | ||
}); | ||
@@ -109,3 +137,3 @@ let signalCb; | ||
cell_id, | ||
zome_name: "zome", | ||
zome_name: "foo", | ||
fn_name: "emitter", | ||
@@ -172,3 +200,3 @@ provenance: agent_key, | ||
Copyright (C) 2020-2023, Holochain Foundation | ||
Copyright (C) 2020-2024, Holochain Foundation | ||
@@ -175,0 +203,0 @@ This program is free software: you can redistribute it and/or modify it under the terms of the license |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
127670
3522
202