@holochain/client 0.11.8 → 0.11.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -22
- package/lib/api/admin/types.d.ts +14 -13
- package/lib/api/admin/types.js.map +1 -1
- package/lib/api/admin/websocket.d.ts +42 -38
- package/lib/api/admin/websocket.js +50 -26
- package/lib/api/admin/websocket.js.map +1 -1
- package/lib/api/app/types.d.ts +15 -11
- package/lib/api/app/types.js +4 -1
- package/lib/api/app/types.js.map +1 -1
- package/lib/api/app/websocket.d.ts +3 -2
- package/lib/api/app/websocket.js +33 -9
- package/lib/api/app/websocket.js.map +1 -1
- package/lib/api/app-agent/types.d.ts +3 -3
- package/lib/api/app-agent/websocket.d.ts +7 -6
- package/lib/api/app-agent/websocket.js +35 -7
- package/lib/api/app-agent/websocket.js.map +1 -1
- package/lib/api/client.d.ts +12 -8
- package/lib/api/client.js +69 -48
- package/lib/api/client.js.map +1 -1
- package/lib/api/common.d.ts +1 -1
- package/lib/api/common.js.map +1 -1
- package/lib/api/zome-call-signing.d.ts +9 -17
- package/lib/api/zome-call-signing.js +12 -60
- package/lib/api/zome-call-signing.js.map +1 -1
- package/lib/environments/launcher.d.ts +3 -3
- package/lib/environments/launcher.js +1 -1
- package/lib/environments/launcher.js.map +1 -1
- package/lib/hdk/capabilities.d.ts +10 -1
- package/lib/hdk/capabilities.js +5 -1
- package/lib/hdk/capabilities.js.map +1 -1
- package/lib/types.d.ts +4 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -27,61 +27,79 @@ npm install --save-exact @holochain/client
|
|
|
27
27
|
const agentPubKey = await admin.generateAgentPubKey()
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
### Use
|
|
30
|
+
### Use AppAgentWebsocket with implicit zome call signing
|
|
31
31
|
```typescript
|
|
32
32
|
const signalCb = (signal: AppSignal) => {
|
|
33
|
-
//
|
|
33
|
+
// implementation of signal handler
|
|
34
34
|
resolve()
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
// generate and authorize new key pair for signing zome calls,
|
|
38
|
-
// specifying zomes and functions to be authorized
|
|
39
|
-
await authorizeNewSigningKeyPair(admin, cell_id, [
|
|
40
|
-
["test_zome", "test_emitter_fn"],
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
37
|
const TIMEOUT = 12000
|
|
44
38
|
// default timeout is set to 12000
|
|
45
|
-
const
|
|
39
|
+
const appWs = await AppWebsocket.connect(`ws://127.0.0.1:${appPort}`, 12000)
|
|
40
|
+
|
|
41
|
+
const client = new AppAgentWebsocket(appWs, 'installed_app_id');
|
|
42
|
+
client.on("signal", signalCb);
|
|
46
43
|
|
|
47
44
|
// default timeout set here (30000) will overwrite the defaultTimeout(12000) set above
|
|
48
45
|
await client.callZome({
|
|
49
|
-
|
|
46
|
+
role_name: 'dnas_role_name', // role_name is unique per app, so you can unambiguously identify your dna with role_name in this client
|
|
50
47
|
zome_name: "test_zome",
|
|
51
48
|
fn_name: 'test_emitter_fn',
|
|
52
|
-
provenance: agentPubKey,
|
|
53
49
|
payload: null,
|
|
54
50
|
}, 30000)
|
|
55
51
|
```
|
|
56
52
|
|
|
57
|
-
### Use
|
|
53
|
+
### Use AppWebsocket with implicit zome call signing
|
|
58
54
|
```typescript
|
|
59
55
|
const signalCb = (signal: AppSignal) => {
|
|
60
56
|
// impl...
|
|
61
57
|
resolve()
|
|
62
58
|
}
|
|
63
59
|
|
|
64
|
-
// generate and authorize new key pair for signing zome calls,
|
|
65
|
-
// specifying zomes and functions to be authorized
|
|
66
|
-
await authorizeNewSigningKeyPair(admin, cell_id, [
|
|
67
|
-
["test_zome", "test_emitter_fn"],
|
|
68
|
-
]);
|
|
69
|
-
|
|
70
60
|
const TIMEOUT = 12000
|
|
71
61
|
// default timeout is set to 12000
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const client = new AppAgentWebsocket(appWs, 'installed_app_id')
|
|
62
|
+
const client = await AppWebsocket.connect(`ws://127.0.0.1:${appPort}`, TIMEOUT, signalCb)
|
|
75
63
|
|
|
76
64
|
// default timeout set here (30000) will overwrite the defaultTimeout(12000) set above
|
|
77
65
|
await client.callZome({
|
|
78
|
-
|
|
66
|
+
cell_id,
|
|
79
67
|
zome_name: "test_zome",
|
|
80
68
|
fn_name: 'test_emitter_fn',
|
|
69
|
+
provenance: agentPubKey,
|
|
81
70
|
payload: null,
|
|
82
71
|
}, 30000)
|
|
83
72
|
```
|
|
84
73
|
|
|
74
|
+
### Managing zome call signing credentials in a pure JavaScript browser application
|
|
75
|
+
|
|
76
|
+
Here is a pattern to manage signing keys for signing zome calls when running pure JavaScript web hApps in a web browser:
|
|
77
|
+
```typescript
|
|
78
|
+
const cellIdB64 =
|
|
79
|
+
encodeHashToBase64(cell_id[0]) + encodeHashToBase64(cell_id[1]);
|
|
80
|
+
// in case the zome call signing credentials are stored locally in the browser
|
|
81
|
+
const signingCredentialsJson = localStorage.getItem(cellIdB64);
|
|
82
|
+
let signingCredentials: SigningCredentials | null =
|
|
83
|
+
signingCredentialsJson && JSON.parse(signingCredentialsJson);
|
|
84
|
+
|
|
85
|
+
if (!signingCredentials) {
|
|
86
|
+
const [keyPair, signingKey] = generateSigningKeyPair();
|
|
87
|
+
const capSecret = await admin.grantSigningKey(
|
|
88
|
+
cell_id,
|
|
89
|
+
{ [GrantedFunctionsType.All]: null },
|
|
90
|
+
signingKey
|
|
91
|
+
);
|
|
92
|
+
signingCredentials = {
|
|
93
|
+
capSecret,
|
|
94
|
+
keyPair,
|
|
95
|
+
signingKey,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
setSigningCredentials(cell_id, signingCredentials);
|
|
99
|
+
// possibly store the zome call signing credentials locally in the browser
|
|
100
|
+
localStorage.setItem(cellIdB64, JSON.stringify(signingCredentials));
|
|
101
|
+
```
|
|
102
|
+
|
|
85
103
|
## API Reference
|
|
86
104
|
|
|
87
105
|
See [docs/API.md](docs/API.md)
|
package/lib/api/admin/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Action, DhtOp, Entry, ZomeCallCapGrant } from "../../hdk/index.js";
|
|
3
|
-
import { ActionHash, AgentPubKey, CellId, DnaHash, DnaProperties, HoloHash, HoloHashB64, InstalledAppId, KitsuneAgent, KitsuneSpace, RoleName, Signature, Timestamp, WasmHash } from "../../types.js";
|
|
3
|
+
import { ActionHash, AgentPubKey, CellId, DnaHash, DnaProperties, Duration, HoloHash, HoloHashB64, InstalledAppId, KitsuneAgent, KitsuneSpace, RoleName, Signature, Timestamp, WasmHash } from "../../types.js";
|
|
4
4
|
import { Requester } from "../common.js";
|
|
5
5
|
import { DisableCloneCellRequest } from "../index.js";
|
|
6
6
|
export declare type AttachAppInterfaceRequest = {
|
|
@@ -106,6 +106,7 @@ export declare type DnaModifiers = {
|
|
|
106
106
|
network_seed: NetworkSeed;
|
|
107
107
|
properties: DnaProperties;
|
|
108
108
|
origin_time: Timestamp;
|
|
109
|
+
quantum_time: Duration;
|
|
109
110
|
};
|
|
110
111
|
export declare type FunctionName = string;
|
|
111
112
|
export declare type ZomeName = string;
|
|
@@ -130,7 +131,7 @@ export declare type UninstallAppRequest = {
|
|
|
130
131
|
installed_app_id: InstalledAppId;
|
|
131
132
|
};
|
|
132
133
|
export declare type UninstallAppResponse = null;
|
|
133
|
-
export declare type ResourceBytes =
|
|
134
|
+
export declare type ResourceBytes = number[];
|
|
134
135
|
export declare type ResourceMap = {
|
|
135
136
|
[key: string]: ResourceBytes;
|
|
136
137
|
};
|
|
@@ -153,6 +154,13 @@ export declare type CellProvisioning = {
|
|
|
153
154
|
} | {
|
|
154
155
|
disabled: Record<string, never>;
|
|
155
156
|
};
|
|
157
|
+
export declare type Location = {
|
|
158
|
+
bundled: string;
|
|
159
|
+
} | {
|
|
160
|
+
path: string;
|
|
161
|
+
} | {
|
|
162
|
+
url: string;
|
|
163
|
+
};
|
|
156
164
|
export declare type DnaVersionSpec = Array<HoloHashB64>;
|
|
157
165
|
export declare type DnaVersionFlexible = {
|
|
158
166
|
singleton: HoloHashB64;
|
|
@@ -160,11 +168,10 @@ export declare type DnaVersionFlexible = {
|
|
|
160
168
|
multiple: DnaVersionSpec;
|
|
161
169
|
};
|
|
162
170
|
export declare type AppRoleDnaManifest = {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
network_seed?: NetworkSeed;
|
|
171
|
+
clone_limit?: number;
|
|
172
|
+
modifiers?: Partial<DnaModifiers>;
|
|
166
173
|
version?: DnaVersionFlexible;
|
|
167
|
-
};
|
|
174
|
+
} & Location;
|
|
168
175
|
export declare type AppRoleManifest = {
|
|
169
176
|
name: RoleName;
|
|
170
177
|
provisioning?: CellProvisioning;
|
|
@@ -256,13 +263,7 @@ export declare type InstallAppDnaPayload = {
|
|
|
256
263
|
role_name: RoleName;
|
|
257
264
|
membrane_proof?: MembraneProof;
|
|
258
265
|
};
|
|
259
|
-
export declare type ZomeLocation =
|
|
260
|
-
bundled: string;
|
|
261
|
-
} | {
|
|
262
|
-
path: string;
|
|
263
|
-
} | {
|
|
264
|
-
url: string;
|
|
265
|
-
};
|
|
266
|
+
export declare type ZomeLocation = Location;
|
|
266
267
|
export declare type ZomeManifest = {
|
|
267
268
|
name: string;
|
|
268
269
|
hash?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/admin/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/admin/types.ts"],"names":[],"mappings":"AAyEA,MAAM,CAAN,IAAY,QAIX;AAJD,WAAY,QAAQ;IAClB,uCAA2B,CAAA;IAC3B,6BAAiB,CAAA;IACjB,yBAAa,CAAA;AACf,CAAC,EAJW,QAAQ,KAAR,QAAQ,QAInB;AAoLD,MAAM,CAAN,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,sCAAmB,CAAA;IACnB,wCAAqB,CAAA;IACrB,sCAAmB,CAAA;IACnB,sCAAmB,CAAA;IACnB,oCAAiB,CAAA;AACnB,CAAC,EANW,eAAe,KAAf,eAAe,QAM1B"}
|
|
@@ -1,45 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Conductor Admin API
|
|
4
|
-
*
|
|
5
|
-
* const client = AdminWebsocket.connect(
|
|
6
|
-
* 'ws://127.0.0.1:9000'
|
|
7
|
-
* )
|
|
8
|
-
*
|
|
9
|
-
* client.generateAgentPubKey()
|
|
10
|
-
* .then(agentPubKey => {
|
|
11
|
-
* console.log('Agent successfully generated:', agentPubKey)
|
|
12
|
-
* })
|
|
13
|
-
* .catch(err => {
|
|
14
|
-
* console.error('problem generating agent:', err)
|
|
15
|
-
* })
|
|
16
|
-
*/
|
|
17
|
-
import * as Api from "./types.js";
|
|
1
|
+
import { CapSecret, GrantedFunctions } from "../../hdk/capabilities.js";
|
|
2
|
+
import type { AgentPubKey, CellId } from "../../types.js";
|
|
18
3
|
import { WsClient } from "../client.js";
|
|
19
|
-
import {
|
|
20
|
-
|
|
4
|
+
import { Requester, Transformer } from "../common.js";
|
|
5
|
+
import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, StartAppRequest, StartAppResponse, UninstallAppRequest, UninstallAppResponse } from "./types.js";
|
|
6
|
+
export declare class AdminWebsocket implements AdminApi {
|
|
21
7
|
readonly client: WsClient;
|
|
22
8
|
defaultTimeout: number;
|
|
23
9
|
private constructor();
|
|
24
10
|
static connect(url: string, defaultTimeout?: number): Promise<AdminWebsocket>;
|
|
25
11
|
_requester: <ReqO, ReqI, ResI, ResO>(tag: string, transformer?: Transformer<ReqO, ReqI, ResI, ResO> | undefined) => (req: ReqO, timeout?: number | undefined) => Promise<ResO>;
|
|
26
|
-
attachAppInterface: Requester<
|
|
27
|
-
enableApp: Requester<
|
|
28
|
-
disableApp: Requester<
|
|
29
|
-
startApp: Requester<
|
|
30
|
-
dumpState: Requester<
|
|
31
|
-
dumpFullState: Requester<
|
|
32
|
-
generateAgentPubKey: Requester<
|
|
33
|
-
registerDna: Requester<
|
|
34
|
-
getDnaDefinition: Requester<
|
|
35
|
-
uninstallApp: Requester<
|
|
36
|
-
installApp: Requester<
|
|
37
|
-
listDnas: Requester<
|
|
38
|
-
listCellIds: Requester<
|
|
39
|
-
listApps: Requester<
|
|
40
|
-
listAppInterfaces: Requester<
|
|
41
|
-
agentInfo: Requester<
|
|
42
|
-
addAgentInfo: Requester<
|
|
43
|
-
deleteCloneCell: Requester<
|
|
44
|
-
grantZomeCallCapability: Requester<
|
|
12
|
+
attachAppInterface: Requester<AttachAppInterfaceRequest, AttachAppInterfaceResponse>;
|
|
13
|
+
enableApp: Requester<EnableAppRequest, EnableAppResponse>;
|
|
14
|
+
disableApp: Requester<DisableAppRequest, DisableAppResponse>;
|
|
15
|
+
startApp: Requester<StartAppRequest, StartAppResponse>;
|
|
16
|
+
dumpState: Requester<DumpStateRequest, DumpStateResponse>;
|
|
17
|
+
dumpFullState: Requester<DumpFullStateRequest, DumpFullStateResponse>;
|
|
18
|
+
generateAgentPubKey: Requester<GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse>;
|
|
19
|
+
registerDna: Requester<RegisterDnaRequest, RegisterDnaResponse>;
|
|
20
|
+
getDnaDefinition: Requester<GetDnaDefinitionRequest, GetDnaDefinitionResponse>;
|
|
21
|
+
uninstallApp: Requester<UninstallAppRequest, UninstallAppResponse>;
|
|
22
|
+
installApp: Requester<InstallAppRequest, InstallAppResponse>;
|
|
23
|
+
listDnas: Requester<ListDnasRequest, ListDnasResponse>;
|
|
24
|
+
listCellIds: Requester<ListCellIdsRequest, ListCellIdsResponse>;
|
|
25
|
+
listApps: Requester<ListAppsRequest, ListAppsResponse>;
|
|
26
|
+
listAppInterfaces: Requester<ListAppInterfacesRequest, ListAppInterfacesResponse>;
|
|
27
|
+
agentInfo: Requester<AgentInfoRequest, AgentInfoResponse>;
|
|
28
|
+
addAgentInfo: Requester<AddAgentInfoRequest, AddAgentInfoResponse>;
|
|
29
|
+
deleteCloneCell: Requester<DeleteCloneCellRequest, DeleteCloneCellResponse>;
|
|
30
|
+
grantZomeCallCapability: Requester<GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse>;
|
|
31
|
+
/**
|
|
32
|
+
* Grant a capability for signing zome calls.
|
|
33
|
+
*
|
|
34
|
+
* @param cellId - The cell to grant the capability for.
|
|
35
|
+
* @param functions - The zome functions to grant the capability for.
|
|
36
|
+
* @param signingKey - The assignee of the capability.
|
|
37
|
+
* @returns The cap secret of the created capability.
|
|
38
|
+
*/
|
|
39
|
+
grantSigningKey: (cellId: CellId, functions: GrantedFunctions, signingKey: AgentPubKey) => Promise<CapSecret>;
|
|
40
|
+
/**
|
|
41
|
+
* Generate and authorize a new key pair for signing zome calls.
|
|
42
|
+
*
|
|
43
|
+
* @param cellId - The cell id to create the capability grant for.
|
|
44
|
+
* @param functions - Zomes and functions to authorize the signing key for
|
|
45
|
+
* (optional). When no functions are specified, the capability will be
|
|
46
|
+
* granted for all zomes and functions.
|
|
47
|
+
*/
|
|
48
|
+
authorizeSigningCredentials: (cellId: CellId, functions?: GrantedFunctions) => Promise<void>;
|
|
45
49
|
}
|
|
@@ -1,24 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Defines AdminWebsocket, an easy-to-use websocket implementation of the
|
|
3
|
-
* Conductor Admin API
|
|
4
|
-
*
|
|
5
|
-
* const client = AdminWebsocket.connect(
|
|
6
|
-
* 'ws://127.0.0.1:9000'
|
|
7
|
-
* )
|
|
8
|
-
*
|
|
9
|
-
* client.generateAgentPubKey()
|
|
10
|
-
* .then(agentPubKey => {
|
|
11
|
-
* console.log('Agent successfully generated:', agentPubKey)
|
|
12
|
-
* })
|
|
13
|
-
* .catch(err => {
|
|
14
|
-
* console.error('problem generating agent:', err)
|
|
15
|
-
* })
|
|
16
|
-
*/
|
|
17
|
-
import * as Api from "./types.js";
|
|
18
|
-
import { WsClient } from "../client.js";
|
|
19
|
-
import { catchError, promiseTimeout, DEFAULT_TIMEOUT } from "../common.js";
|
|
20
|
-
import { requesterTransformer } from "../common.js";
|
|
21
1
|
import { getLauncherEnvironment } from "../../environments/launcher.js";
|
|
2
|
+
import { GrantedFunctionsType, } from "../../hdk/capabilities.js";
|
|
3
|
+
import { WsClient } from "../client.js";
|
|
4
|
+
import { catchError, DEFAULT_TIMEOUT, promiseTimeout, requesterTransformer, } from "../common.js";
|
|
5
|
+
import { generateSigningKeyPair, randomCapSecret, setSigningCredentials, } from "../zome-call-signing.js";
|
|
6
|
+
import { AppStatusFilter, } from "./types.js";
|
|
22
7
|
export class AdminWebsocket {
|
|
23
8
|
client;
|
|
24
9
|
defaultTimeout;
|
|
@@ -30,7 +15,7 @@ export class AdminWebsocket {
|
|
|
30
15
|
static async connect(url, defaultTimeout) {
|
|
31
16
|
// Check if we are in the launcher's environment, and if so, redirect the url to connect to
|
|
32
17
|
const env = getLauncherEnvironment();
|
|
33
|
-
if (env) {
|
|
18
|
+
if (env?.ADMIN_INTERFACE_PORT) {
|
|
34
19
|
url = `ws://127.0.0.1:${env.ADMIN_INTERFACE_PORT}`;
|
|
35
20
|
}
|
|
36
21
|
const wsClient = await WsClient.connect(url);
|
|
@@ -58,6 +43,45 @@ export class AdminWebsocket {
|
|
|
58
43
|
addAgentInfo = this._requester("add_agent_info");
|
|
59
44
|
deleteCloneCell = this._requester("delete_clone_cell");
|
|
60
45
|
grantZomeCallCapability = this._requester("grant_zome_call_capability");
|
|
46
|
+
// zome call signing related methods
|
|
47
|
+
/**
|
|
48
|
+
* Grant a capability for signing zome calls.
|
|
49
|
+
*
|
|
50
|
+
* @param cellId - The cell to grant the capability for.
|
|
51
|
+
* @param functions - The zome functions to grant the capability for.
|
|
52
|
+
* @param signingKey - The assignee of the capability.
|
|
53
|
+
* @returns The cap secret of the created capability.
|
|
54
|
+
*/
|
|
55
|
+
grantSigningKey = async (cellId, functions, signingKey) => {
|
|
56
|
+
const capSecret = randomCapSecret();
|
|
57
|
+
await this.grantZomeCallCapability({
|
|
58
|
+
cell_id: cellId,
|
|
59
|
+
cap_grant: {
|
|
60
|
+
tag: "zome-call-signing-key",
|
|
61
|
+
functions,
|
|
62
|
+
access: {
|
|
63
|
+
Assigned: {
|
|
64
|
+
secret: capSecret,
|
|
65
|
+
assignees: [signingKey],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
return capSecret;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Generate and authorize a new key pair for signing zome calls.
|
|
74
|
+
*
|
|
75
|
+
* @param cellId - The cell id to create the capability grant for.
|
|
76
|
+
* @param functions - Zomes and functions to authorize the signing key for
|
|
77
|
+
* (optional). When no functions are specified, the capability will be
|
|
78
|
+
* granted for all zomes and functions.
|
|
79
|
+
*/
|
|
80
|
+
authorizeSigningCredentials = async (cellId, functions) => {
|
|
81
|
+
const [keyPair, signingKey] = generateSigningKeyPair();
|
|
82
|
+
const capSecret = await this.grantSigningKey(cellId, functions || { [GrantedFunctionsType.All]: null }, signingKey);
|
|
83
|
+
setSigningCredentials(cellId, { capSecret, keyPair, signingKey });
|
|
84
|
+
};
|
|
61
85
|
}
|
|
62
86
|
const listAppsTransform = {
|
|
63
87
|
input: (req) => {
|
|
@@ -77,23 +101,23 @@ const dumpStateTransform = {
|
|
|
77
101
|
};
|
|
78
102
|
function getAppStatusInApiForm(status_filter) {
|
|
79
103
|
switch (status_filter) {
|
|
80
|
-
case
|
|
104
|
+
case AppStatusFilter.Running:
|
|
81
105
|
return {
|
|
82
106
|
Running: null,
|
|
83
107
|
};
|
|
84
|
-
case
|
|
108
|
+
case AppStatusFilter.Enabled:
|
|
85
109
|
return {
|
|
86
110
|
Enabled: null,
|
|
87
111
|
};
|
|
88
|
-
case
|
|
112
|
+
case AppStatusFilter.Paused:
|
|
89
113
|
return {
|
|
90
114
|
Paused: null,
|
|
91
115
|
};
|
|
92
|
-
case
|
|
116
|
+
case AppStatusFilter.Disabled:
|
|
93
117
|
return {
|
|
94
118
|
Disabled: null,
|
|
95
119
|
};
|
|
96
|
-
case
|
|
120
|
+
case AppStatusFilter.Stopped:
|
|
97
121
|
return {
|
|
98
122
|
Stopped: null,
|
|
99
123
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/admin/websocket.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/admin/websocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAGL,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,UAAU,EACV,eAAe,EACf,cAAc,EAEd,oBAAoB,GAErB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAML,eAAe,GAmChB,MAAM,YAAY,CAAC;AAEpB,MAAM,OAAO,cAAc;IAChB,MAAM,CAAW;IAC1B,cAAc,CAAS;IAEvB,Y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e,CAAC,MAAM;YACzB,OAAO;gBACL,MAAM,EAAE,IAAI;aACb,CAAC;QACJ,KAAK,eAAe,CAAC,QAAQ;YAC3B,OAAO;gBACL,QAAQ,EAAE,IAAI;aACf,CAAC;QACJ,KAAK,eAAe,CAAC,OAAO;YAC1B,OAAO;gBACL,OAAO,EAAE,IAAI;aACd,CAAC;KACL;AACH,CAAC"}
|
package/lib/api/app/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AgentPubKey, CellId, DnaProperties, InstalledAppId, InstalledCell, RoleName, Timestamp
|
|
1
|
+
import { AgentPubKey, CellId, DnaHash, DnaProperties, InstalledAppId, InstalledCell, NetworkInfo, RoleName, Timestamp } from "../../types.js";
|
|
2
|
+
import { AppInfo, FunctionName, MembraneProof, NetworkSeed, ZomeName } from "../admin/index.js";
|
|
2
3
|
import { Requester } from "../common.js";
|
|
3
|
-
import { FunctionName, AppInfo, MembraneProof, NetworkSeed, ZomeName } from "../admin/index.js";
|
|
4
4
|
export declare type CallZomeRequestGeneric<Payload> = {
|
|
5
5
|
cell_id: CellId;
|
|
6
6
|
zome_name: ZomeName;
|
|
@@ -67,20 +67,24 @@ export interface DisableCloneCellRequest {
|
|
|
67
67
|
export declare type DisableCloneCellResponse = void;
|
|
68
68
|
export declare type EnableCloneCellRequest = DisableCloneCellRequest;
|
|
69
69
|
export declare type EnableCloneCellResponse = CreateCloneCellResponse;
|
|
70
|
-
export declare type AppSignal = {
|
|
71
|
-
type: string;
|
|
72
|
-
data: {
|
|
73
|
-
cellId: CellId;
|
|
74
|
-
payload: any;
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
70
|
export interface NetworkInfoRequest {
|
|
78
71
|
/** The DNAs for which to get network info */
|
|
79
72
|
dnas: DnaHash[];
|
|
80
73
|
}
|
|
81
|
-
export declare
|
|
74
|
+
export declare const SignalType: {
|
|
75
|
+
readonly App: "App";
|
|
76
|
+
readonly System: "System";
|
|
77
|
+
};
|
|
78
|
+
export declare type Signal = {
|
|
79
|
+
[SignalType.App]: [CellId, any];
|
|
80
|
+
[SignalType.System]: unknown;
|
|
81
|
+
};
|
|
82
|
+
export declare type AppSignal = {
|
|
83
|
+
cell_id: CellId;
|
|
84
|
+
payload: any;
|
|
85
|
+
};
|
|
82
86
|
export declare type AppSignalCb = (signal: AppSignal) => void;
|
|
83
|
-
export declare type
|
|
87
|
+
export declare type NetworkInfoResponse = NetworkInfo[];
|
|
84
88
|
export interface AppApi {
|
|
85
89
|
appInfo: Requester<AppInfoRequest, AppInfoResponse>;
|
|
86
90
|
callZome: Requester<CallZomeRequest, CallZomeResponse>;
|
package/lib/api/app/types.js
CHANGED
package/lib/api/app/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/app/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/app/types.ts"],"names":[],"mappings":"AAkGA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,QAAQ;CACR,CAAC"}
|
|
@@ -4,13 +4,13 @@ import { InstalledAppId } from "../../types.js";
|
|
|
4
4
|
import { WsClient } from "../client.js";
|
|
5
5
|
import { Requester, Transformer } from "../common.js";
|
|
6
6
|
import { Nonce256Bit } from "../zome-call-signing.js";
|
|
7
|
-
import { AppApi, AppInfoRequest, AppInfoResponse,
|
|
7
|
+
import { AppApi, AppInfoRequest, AppInfoResponse, CallZomeRequest, CallZomeResponse, CreateCloneCellRequest, CreateCloneCellResponse, DisableCloneCellRequest, DisableCloneCellResponse, EnableCloneCellRequest, EnableCloneCellResponse, NetworkInfoRequest, NetworkInfoResponse } from "./types.js";
|
|
8
8
|
export declare class AppWebsocket extends Emittery implements AppApi {
|
|
9
9
|
readonly client: WsClient;
|
|
10
10
|
defaultTimeout: number;
|
|
11
11
|
overrideInstalledAppId?: InstalledAppId;
|
|
12
12
|
private constructor();
|
|
13
|
-
static connect(url: string, defaultTimeout?: number
|
|
13
|
+
static connect(url: string, defaultTimeout?: number): Promise<AppWebsocket>;
|
|
14
14
|
_requester: <ReqI, ReqO, ResI, ResO>(tag: string, transformer?: Transformer<ReqI, ReqO, ResI, ResO> | undefined) => (req: ReqI, timeout?: number | undefined) => Promise<ResO>;
|
|
15
15
|
appInfo: Requester<AppInfoRequest, AppInfoResponse>;
|
|
16
16
|
callZome: Requester<CallZomeRequest | CallZomeRequestSigned, CallZomeResponse>;
|
|
@@ -27,3 +27,4 @@ export interface CallZomeRequestUnsigned extends CallZomeRequest {
|
|
|
27
27
|
export interface CallZomeRequestSigned extends CallZomeRequestUnsigned {
|
|
28
28
|
signature: Uint8Array;
|
|
29
29
|
}
|
|
30
|
+
export declare const signZomeCall: (request: CallZomeRequest) => Promise<CallZomeRequestSigned>;
|
package/lib/api/app/websocket.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hashZomeCall } from "@holochain/serialization";
|
|
2
|
+
import { decode, encode } from "@msgpack/msgpack";
|
|
2
3
|
import Emittery from "emittery";
|
|
4
|
+
import nacl from "tweetnacl";
|
|
3
5
|
import { getLauncherEnvironment, isLauncher, signZomeCallTauri, } from "../../environments/launcher.js";
|
|
4
6
|
import { WsClient } from "../client.js";
|
|
5
7
|
import { catchError, DEFAULT_TIMEOUT, promiseTimeout, requesterTransformer, } from "../common.js";
|
|
6
|
-
import {
|
|
8
|
+
import { getNonceExpiration, getSigningCredentials, randomNonce, } from "../zome-call-signing.js";
|
|
7
9
|
export class AppWebsocket extends Emittery {
|
|
8
10
|
client;
|
|
9
11
|
defaultTimeout;
|
|
@@ -15,17 +17,14 @@ export class AppWebsocket extends Emittery {
|
|
|
15
17
|
defaultTimeout === undefined ? DEFAULT_TIMEOUT : defaultTimeout;
|
|
16
18
|
this.overrideInstalledAppId = overrideInstalledAppId;
|
|
17
19
|
}
|
|
18
|
-
static async connect(url, defaultTimeout
|
|
20
|
+
static async connect(url, defaultTimeout) {
|
|
19
21
|
// Check if we are in the launcher's environment, and if so, redirect the url to connect to
|
|
20
22
|
const env = getLauncherEnvironment();
|
|
21
|
-
if (env) {
|
|
23
|
+
if (env?.APP_INTERFACE_PORT) {
|
|
22
24
|
url = `ws://127.0.0.1:${env.APP_INTERFACE_PORT}`;
|
|
23
25
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
const wsClient = await WsClient.connect(url, signalCb);
|
|
28
|
-
const appWebsocket = new AppWebsocket(wsClient, defaultTimeout, env ? env.INSTALLED_APP_ID : undefined);
|
|
26
|
+
const wsClient = await WsClient.connect(url);
|
|
27
|
+
const appWebsocket = new AppWebsocket(wsClient, defaultTimeout, env?.INSTALLED_APP_ID);
|
|
29
28
|
wsClient.on("signal", (signal) => appWebsocket.emit("signal", signal));
|
|
30
29
|
return appWebsocket;
|
|
31
30
|
}
|
|
@@ -60,4 +59,29 @@ const appInfoTransform = (appWs) => ({
|
|
|
60
59
|
},
|
|
61
60
|
output: (response) => response,
|
|
62
61
|
});
|
|
62
|
+
export const signZomeCall = async (request) => {
|
|
63
|
+
const signingCredentialsForCell = getSigningCredentials(request.cell_id);
|
|
64
|
+
if (!signingCredentialsForCell) {
|
|
65
|
+
throw new Error(`cannot sign zome call: no signing credentials have been authorized for cell ${request.cell_id}`);
|
|
66
|
+
}
|
|
67
|
+
const unsignedZomeCallPayload = {
|
|
68
|
+
cap_secret: signingCredentialsForCell.capSecret,
|
|
69
|
+
cell_id: request.cell_id,
|
|
70
|
+
zome_name: request.zome_name,
|
|
71
|
+
fn_name: request.fn_name,
|
|
72
|
+
provenance: signingCredentialsForCell.signingKey,
|
|
73
|
+
payload: encode(request.payload),
|
|
74
|
+
nonce: randomNonce(),
|
|
75
|
+
expires_at: getNonceExpiration(),
|
|
76
|
+
};
|
|
77
|
+
const hashedZomeCall = await hashZomeCall(unsignedZomeCallPayload);
|
|
78
|
+
const signature = nacl
|
|
79
|
+
.sign(hashedZomeCall, signingCredentialsForCell.keyPair.secretKey)
|
|
80
|
+
.subarray(0, nacl.sign.signatureLength);
|
|
81
|
+
const signedZomeCall = {
|
|
82
|
+
...unsignedZomeCallPayload,
|
|
83
|
+
signature,
|
|
84
|
+
};
|
|
85
|
+
return signedZomeCall;
|
|
86
|
+
};
|
|
63
87
|
//# sourceMappingURL=websocket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app/websocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app/websocket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,UAAU,EACV,iBAAiB,GAClB,MAAM,gCAAgC,CAAC;AAGxC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACL,UAAU,EACV,eAAe,EACf,cAAc,EAEd,oBAAoB,GAErB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EAErB,WAAW,GACZ,MAAM,yBAAyB,CAAC;AAkBjC,MAAM,OAAO,YAAa,SAAQ,QAAQ;IAC/B,MAAM,CAAW;IAC1B,cAAc,CAAS;IACvB,sBAAsB,CAAkB;IAExC,YACE,MAAgB,EAChB,cAAuB,EACvB,sBAAuC;QAEvC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc;YACjB,cAAc,KAAK,SAA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E,OAAO,CAAC,OAAO;QACxB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,UAAU,EAAE,yBAAyB,CAAC,UAAU;QAChD,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;QAChC,KAAK,EAAE,WAAW,EAAE;QACpB,UAAU,EAAE,kBAAkB,EAAE;KACjC,CAAC;IACF,MAAM,cAAc,GAAG,MAAM,YAAY,CAAC,uBAAuB,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,IAAI;SACnB,IAAI,CAAC,cAAc,EAAE,yBAAyB,CAAC,OAAO,CAAC,SAAS,CAAC;SACjE,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAE1C,MAAM,cAAc,GAA0B;QAC5C,GAAG,uBAAuB;QAC1B,SAAS;KACV,CAAC;IACF,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { UnsubscribeFunction } from "emittery";
|
|
2
|
-
import { DisableCloneCellResponse, CreateCloneCellRequest, CreateCloneCellResponse } from "../index.js";
|
|
3
2
|
import { AgentPubKey, RoleName } from "../../index.js";
|
|
4
|
-
import { AppInfoResponse, AppSignal,
|
|
3
|
+
import { AppInfoResponse, AppSignal, AppSignalCb, CallZomeRequest, CallZomeRequestSigned, DisableCloneCellRequest, EnableCloneCellRequest, EnableCloneCellResponse } from "../app/index.js";
|
|
4
|
+
import { CreateCloneCellRequest, CreateCloneCellResponse, DisableCloneCellResponse } from "../index.js";
|
|
5
5
|
export declare type NonProvenanceCallZomeRequest = Omit<CallZomeRequest, "provenance">;
|
|
6
6
|
export declare type RoleNameCallZomeRequest = Omit<NonProvenanceCallZomeRequest, "cell_id"> & {
|
|
7
7
|
role_name: RoleName;
|
|
@@ -18,7 +18,7 @@ export interface AppAgentEvents {
|
|
|
18
18
|
}
|
|
19
19
|
export interface AppAgentClient {
|
|
20
20
|
callZome(args: AppAgentCallZomeRequest, timeout?: number): Promise<any>;
|
|
21
|
-
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener:
|
|
21
|
+
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: AppSignalCb): UnsubscribeFunction;
|
|
22
22
|
appInfo(): Promise<AppInfoResponse>;
|
|
23
23
|
myPubKey: AgentPubKey;
|
|
24
24
|
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Emittery, { UnsubscribeFunction } from "emittery";
|
|
2
|
-
import { AgentPubKey, InstalledAppId, RoleName } from "../../types.js";
|
|
3
|
-
import { AppInfo,
|
|
2
|
+
import { AgentPubKey, CellId, InstalledAppId, RoleName } from "../../types.js";
|
|
3
|
+
import { AppInfo, AppSignalCb, AppWebsocket, CallZomeResponse, CreateCloneCellResponse, DisableCloneCellResponse, EnableCloneCellResponse } from "../index.js";
|
|
4
4
|
import { AppAgentCallZomeRequest, AppAgentClient, AppAgentEvents, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest } from "./types.js";
|
|
5
5
|
export declare class AppAgentWebsocket implements AppAgentClient {
|
|
6
6
|
myPubKey: AgentPubKey;
|
|
@@ -9,12 +9,13 @@ export declare class AppAgentWebsocket implements AppAgentClient {
|
|
|
9
9
|
cachedAppInfo?: AppInfo;
|
|
10
10
|
readonly emitter: Emittery<AppAgentEvents>;
|
|
11
11
|
private constructor();
|
|
12
|
-
appInfo(): Promise<
|
|
13
|
-
static connect(
|
|
14
|
-
getCellIdFromRoleName(roleName: RoleName, appInfo: AppInfo):
|
|
12
|
+
appInfo(): Promise<AppInfo>;
|
|
13
|
+
static connect(url: string, installed_app_id: InstalledAppId, defaultTimeout?: number): Promise<AppAgentWebsocket>;
|
|
14
|
+
getCellIdFromRoleName(roleName: RoleName, appInfo: AppInfo): CellId;
|
|
15
15
|
callZome(request: AppAgentCallZomeRequest, timeout?: number): Promise<CallZomeResponse>;
|
|
16
16
|
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
|
|
17
17
|
enableCloneCell(args: AppEnableCloneCellRequest): Promise<EnableCloneCellResponse>;
|
|
18
18
|
disableCloneCell(args: AppDisableCloneCellRequest): Promise<DisableCloneCellResponse>;
|
|
19
|
-
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener:
|
|
19
|
+
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: AppSignalCb): UnsubscribeFunction;
|
|
20
|
+
private containsCell;
|
|
20
21
|
}
|