@holochain/client 0.10.4 → 0.11.0
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 +22 -12
- package/lib/api/admin/types.d.ts +36 -30
- package/lib/api/admin/types.js.map +1 -1
- package/lib/api/admin/websocket.d.ts +4 -6
- package/lib/api/admin/websocket.js +6 -8
- package/lib/api/admin/websocket.js.map +1 -1
- package/lib/api/app/index.js +1 -0
- package/lib/api/app/index.js.map +1 -1
- package/lib/api/app/types.d.ts +14 -12
- package/lib/api/app/util.d.ts +18 -0
- package/lib/api/app/util.js +74 -0
- package/lib/api/app/util.js.map +1 -0
- package/lib/api/app/websocket.d.ts +16 -5
- package/lib/api/app/websocket.js +75 -21
- package/lib/api/app/websocket.js.map +1 -1
- package/lib/api/app-agent/types.d.ts +11 -6
- package/lib/api/app-agent/websocket.d.ts +8 -6
- package/lib/api/app-agent/websocket.js +39 -14
- package/lib/api/app-agent/websocket.js.map +1 -1
- package/lib/api/client.js +5 -5
- package/lib/api/client.js.map +1 -1
- package/lib/api/common.d.ts +5 -4
- package/lib/api/common.js +12 -4
- package/lib/api/common.js.map +1 -1
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +1 -0
- package/lib/api/index.js.map +1 -1
- package/lib/api/zome-call-signing.d.ts +25 -0
- package/lib/api/zome-call-signing.js +28 -0
- package/lib/api/zome-call-signing.js.map +1 -0
- package/lib/hdk/capabilities.d.ts +2 -2
- package/lib/hdk/countersigning.d.ts +2 -2
- package/lib/types.d.ts +7 -13
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -17,34 +17,39 @@ To install from NPM, run
|
|
|
17
17
|
npm install --save-exact @holochain/client
|
|
18
18
|
```
|
|
19
19
|
|
|
20
|
-
> This code is
|
|
20
|
+
> This code is under beta development and you may wish to lock to an exact version of the library for that reason, as shown in the above command.
|
|
21
21
|
|
|
22
22
|
## Sample usage
|
|
23
23
|
|
|
24
24
|
### Use AdminWebsocket
|
|
25
25
|
```typescript
|
|
26
|
-
const admin = await AdminWebsocket.connect(`ws://
|
|
27
|
-
await admin.generateAgentPubKey()
|
|
26
|
+
const admin = await AdminWebsocket.connect(`ws://127.0.0.1:8000`, TIMEOUT)
|
|
27
|
+
const agentPubKey = await admin.generateAgentPubKey()
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
### Use AppWebsocket
|
|
30
|
+
### Use AppWebsocket with implicit zome call signing
|
|
31
31
|
```typescript
|
|
32
32
|
const signalCb = (signal: AppSignal) => {
|
|
33
33
|
// impl...
|
|
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
|
+
|
|
37
43
|
const TIMEOUT = 12000
|
|
38
44
|
// default timeout is set to 12000
|
|
39
|
-
const client = await AppWebsocket.connect(`ws://
|
|
45
|
+
const client = await AppWebsocket.connect(`ws://127.0.0.1:${appPort}`, TIMEOUT, signalCb)
|
|
40
46
|
|
|
41
47
|
// default timeout set here (30000) will overwrite the defaultTimeout(12000) set above
|
|
42
48
|
await client.callZome({
|
|
43
|
-
cap: null,
|
|
44
49
|
cell_id,
|
|
45
50
|
zome_name: "test_zome",
|
|
46
51
|
fn_name: 'test_emitter_fn',
|
|
47
|
-
provenance:
|
|
52
|
+
provenance: agentPubKey,
|
|
48
53
|
payload: null,
|
|
49
54
|
}, 30000)
|
|
50
55
|
```
|
|
@@ -56,19 +61,24 @@ npm install --save-exact @holochain/client
|
|
|
56
61
|
resolve()
|
|
57
62
|
}
|
|
58
63
|
|
|
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
|
+
|
|
59
70
|
const TIMEOUT = 12000
|
|
60
71
|
// default timeout is set to 12000
|
|
61
|
-
const appWs = await AppWebsocket.connect(`ws://
|
|
72
|
+
const appWs = await AppWebsocket.connect(`ws://127.0.0.1:${appPort}`, 12000, signalCb)
|
|
62
73
|
|
|
63
74
|
const client = new AppAgentWebsocket(appWs, 'installed_app_id')
|
|
64
75
|
|
|
65
76
|
// default timeout set here (30000) will overwrite the defaultTimeout(12000) set above
|
|
66
77
|
await client.callZome({
|
|
67
|
-
|
|
68
|
-
role_name: 'dnas_role_name', // role_name is unique per app, so you can unambiguously identify your dna with role_name in this client,
|
|
78
|
+
role_name: 'dnas_role_name', // role_name is unique per app, so you can unambiguously identify your dna with role_name in this client
|
|
69
79
|
zome_name: "test_zome",
|
|
70
80
|
fn_name: 'test_emitter_fn',
|
|
71
|
-
provenance:
|
|
81
|
+
provenance: agentPubKey,
|
|
72
82
|
payload: null,
|
|
73
83
|
}, 30000)
|
|
74
84
|
```
|
|
@@ -107,7 +117,7 @@ Holochain is an open source project. We welcome all sorts of participation and
|
|
|
107
117
|
|
|
108
118
|
[](https://github.com/holochain/cryptographic-autonomy-license)
|
|
109
119
|
|
|
110
|
-
Copyright (C) 2020-
|
|
120
|
+
Copyright (C) 2020-2023, Holochain Foundation
|
|
111
121
|
|
|
112
122
|
This program is free software: you can redistribute it and/or modify it under the terms of the license
|
|
113
123
|
provided in the LICENSE file (CAL-1.0). This program is distributed in the hope that it will be useful,
|
package/lib/api/admin/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Action, DhtOp, Entry, ZomeCallCapGrant } from "../../hdk/index.js";
|
|
3
|
+
import { ActionHash, AgentPubKey, CellId, DnaHash, DnaProperties, HoloHash, InstalledAppId, KitsuneAgent, KitsuneSpace, RoleName, Signature, Timestamp, WasmHash } from "../../types.js";
|
|
4
4
|
import { Requester } from "../common.js";
|
|
5
|
-
import {
|
|
5
|
+
import { DisableCloneCellRequest } from "../index.js";
|
|
6
6
|
export declare type AttachAppInterfaceRequest = {
|
|
7
7
|
port: number;
|
|
8
8
|
};
|
|
@@ -19,7 +19,7 @@ export declare type EnableAppRequest = {
|
|
|
19
19
|
installed_app_id: InstalledAppId;
|
|
20
20
|
};
|
|
21
21
|
export declare type EnableAppResponse = {
|
|
22
|
-
app:
|
|
22
|
+
app: AppInfo;
|
|
23
23
|
errors: Array<[CellId, string]>;
|
|
24
24
|
};
|
|
25
25
|
export declare type DeactivationReason = {
|
|
@@ -52,9 +52,28 @@ export declare type InstalledAppInfoStatus = {
|
|
|
52
52
|
} | {
|
|
53
53
|
running: null;
|
|
54
54
|
};
|
|
55
|
-
export
|
|
55
|
+
export interface StemCell {
|
|
56
|
+
dna: DnaHash;
|
|
57
|
+
name?: string;
|
|
58
|
+
dna_modifiers: DnaModifiers;
|
|
59
|
+
}
|
|
60
|
+
export interface Cell {
|
|
61
|
+
cell_id: CellId;
|
|
62
|
+
clone_id?: RoleName;
|
|
63
|
+
dna_modifiers: DnaModifiers;
|
|
64
|
+
name: string;
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
}
|
|
67
|
+
export declare type CellInfo = {
|
|
68
|
+
Provisioned: Cell;
|
|
69
|
+
} | {
|
|
70
|
+
Cloned: Cell;
|
|
71
|
+
} | {
|
|
72
|
+
Stem: StemCell;
|
|
73
|
+
};
|
|
74
|
+
export declare type AppInfo = {
|
|
56
75
|
installed_app_id: InstalledAppId;
|
|
57
|
-
|
|
76
|
+
cell_info: Record<RoleName, Array<CellInfo>>;
|
|
58
77
|
status: InstalledAppInfoStatus;
|
|
59
78
|
};
|
|
60
79
|
export declare type MembraneProof = Buffer;
|
|
@@ -89,7 +108,7 @@ export declare type DnaModifiers = {
|
|
|
89
108
|
properties: DnaProperties;
|
|
90
109
|
origin_time: Timestamp;
|
|
91
110
|
};
|
|
92
|
-
export declare type
|
|
111
|
+
export declare type FunctionName = string;
|
|
93
112
|
export declare type ZomeName = string;
|
|
94
113
|
export declare type ZomeDefinition = [
|
|
95
114
|
ZomeName,
|
|
@@ -108,12 +127,6 @@ export declare type DnaDefinition = {
|
|
|
108
127
|
};
|
|
109
128
|
export declare type GetDnaDefinitionRequest = DnaHash;
|
|
110
129
|
export declare type GetDnaDefinitionResponse = DnaDefinition;
|
|
111
|
-
export declare type InstallAppRequest = {
|
|
112
|
-
installed_app_id: InstalledAppId;
|
|
113
|
-
agent_key: AgentPubKey;
|
|
114
|
-
dnas: Array<InstallAppDnaPayload>;
|
|
115
|
-
};
|
|
116
|
-
export declare type InstallAppResponse = InstalledAppInfo;
|
|
117
130
|
export declare type UninstallAppRequest = {
|
|
118
131
|
installed_app_id: InstalledAppId;
|
|
119
132
|
};
|
|
@@ -175,7 +188,7 @@ export declare type AppBundleSource = {
|
|
|
175
188
|
path: string;
|
|
176
189
|
};
|
|
177
190
|
export declare type NetworkSeed = string;
|
|
178
|
-
export declare type
|
|
191
|
+
export declare type InstallAppRequest = {
|
|
179
192
|
agent_key: AgentPubKey;
|
|
180
193
|
installed_app_id?: InstalledAppId;
|
|
181
194
|
membrane_proofs: {
|
|
@@ -183,7 +196,7 @@ export declare type InstallAppBundleRequest = {
|
|
|
183
196
|
};
|
|
184
197
|
network_seed?: NetworkSeed;
|
|
185
198
|
} & AppBundleSource;
|
|
186
|
-
export declare type
|
|
199
|
+
export declare type InstallAppResponse = AppInfo;
|
|
187
200
|
export declare type ListDnasRequest = void;
|
|
188
201
|
export declare type ListDnasResponse = Array<string>;
|
|
189
202
|
export declare type ListCellIdsRequest = void;
|
|
@@ -200,25 +213,20 @@ export declare enum AppStatusFilter {
|
|
|
200
213
|
export declare type ListAppsRequest = {
|
|
201
214
|
status_filter?: AppStatusFilter;
|
|
202
215
|
};
|
|
203
|
-
export declare type ListAppsResponse = Array<
|
|
216
|
+
export declare type ListAppsResponse = Array<AppInfo>;
|
|
204
217
|
export declare type ListAppInterfacesRequest = void;
|
|
205
218
|
export declare type ListAppInterfacesResponse = Array<number>;
|
|
206
219
|
export declare type AgentInfoSigned = any;
|
|
207
|
-
export declare type
|
|
220
|
+
export declare type AgentInfoRequest = {
|
|
208
221
|
cell_id: CellId | null;
|
|
209
222
|
};
|
|
210
|
-
export declare type
|
|
223
|
+
export declare type AgentInfoResponse = Array<AgentInfoSigned>;
|
|
211
224
|
export declare type AddAgentInfoRequest = {
|
|
212
225
|
agent_infos: Array<AgentInfoSigned>;
|
|
213
226
|
};
|
|
214
227
|
export declare type AddAgentInfoResponse = any;
|
|
215
|
-
export declare type
|
|
216
|
-
export declare type
|
|
217
|
-
export interface DeleteArchivedCloneCellsRequest {
|
|
218
|
-
app_id: InstalledAppId;
|
|
219
|
-
role_name: RoleName;
|
|
220
|
-
}
|
|
221
|
-
export declare type DeleteArchivedCloneCellsResponse = void;
|
|
228
|
+
export declare type DeleteCloneCellRequest = DisableCloneCellRequest;
|
|
229
|
+
export declare type DeleteCloneCellResponse = void;
|
|
222
230
|
export interface GrantZomeCallCapabilityRequest {
|
|
223
231
|
cell_id: CellId;
|
|
224
232
|
cap_grant: ZomeCallCapGrant;
|
|
@@ -236,18 +244,16 @@ export interface AdminApi {
|
|
|
236
244
|
generateAgentPubKey: Requester<GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse>;
|
|
237
245
|
registerDna: Requester<RegisterDnaRequest, RegisterDnaResponse>;
|
|
238
246
|
getDnaDefinition: Requester<GetDnaDefinitionRequest, GetDnaDefinitionResponse>;
|
|
239
|
-
installApp: Requester<InstallAppRequest, InstallAppResponse>;
|
|
240
247
|
uninstallApp: Requester<UninstallAppRequest, UninstallAppResponse>;
|
|
241
|
-
|
|
248
|
+
installApp: Requester<InstallAppRequest, InstallAppResponse>;
|
|
242
249
|
listDnas: Requester<ListDnasRequest, ListDnasResponse>;
|
|
243
250
|
listCellIds: Requester<ListCellIdsRequest, ListCellIdsResponse>;
|
|
244
251
|
listActiveApps: Requester<ListActiveAppsRequest, ListActiveAppsResponse>;
|
|
245
252
|
listApps: Requester<ListAppsRequest, ListAppsResponse>;
|
|
246
253
|
listAppInterfaces: Requester<ListAppInterfacesRequest, ListAppInterfacesResponse>;
|
|
247
|
-
|
|
254
|
+
agentInfo: Requester<AgentInfoRequest, AgentInfoResponse>;
|
|
248
255
|
addAgentInfo: Requester<AddAgentInfoRequest, AddAgentInfoResponse>;
|
|
249
|
-
|
|
250
|
-
deleteArchivedCloneCells: Requester<DeleteArchivedCloneCellsRequest, DeleteArchivedCloneCellsResponse>;
|
|
256
|
+
deleteCloneCell: Requester<DeleteCloneCellRequest, DeleteCloneCellResponse>;
|
|
251
257
|
grantZomeCallCapability: Requester<GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse>;
|
|
252
258
|
}
|
|
253
259
|
export declare type InstallAppDnaPayload = {
|
|
@@ -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":"AAwPA,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"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Conductor Admin API
|
|
4
4
|
*
|
|
5
5
|
* const client = AdminWebsocket.connect(
|
|
6
|
-
* 'ws://
|
|
6
|
+
* 'ws://127.0.0.1:9000'
|
|
7
7
|
* )
|
|
8
8
|
*
|
|
9
9
|
* client.generateAgentPubKey()
|
|
@@ -34,17 +34,15 @@ export declare class AdminWebsocket implements Api.AdminApi {
|
|
|
34
34
|
generateAgentPubKey: Requester<Api.GenerateAgentPubKeyRequest, Api.GenerateAgentPubKeyResponse>;
|
|
35
35
|
registerDna: Requester<Api.RegisterDnaRequest, Api.RegisterDnaResponse>;
|
|
36
36
|
getDnaDefinition: Requester<Api.GetDnaDefinitionRequest, Api.GetDnaDefinitionResponse>;
|
|
37
|
-
installApp: Requester<Api.InstallAppRequest, Api.InstallAppResponse>;
|
|
38
37
|
uninstallApp: Requester<Api.UninstallAppRequest, Api.UninstallAppResponse>;
|
|
39
|
-
|
|
38
|
+
installApp: Requester<Api.InstallAppRequest, Api.InstallAppResponse>;
|
|
40
39
|
listDnas: Requester<Api.ListDnasRequest, Api.ListDnasResponse>;
|
|
41
40
|
listCellIds: Requester<Api.ListCellIdsRequest, Api.ListCellIdsResponse>;
|
|
42
41
|
listActiveApps: Requester<Api.ListActiveAppsRequest, Api.ListActiveAppsResponse>;
|
|
43
42
|
listApps: Requester<Api.ListAppsRequest, Api.ListAppsResponse>;
|
|
44
43
|
listAppInterfaces: Requester<Api.ListAppInterfacesRequest, Api.ListAppInterfacesResponse>;
|
|
45
|
-
|
|
44
|
+
agentInfo: Requester<Api.AgentInfoRequest, Api.AgentInfoResponse>;
|
|
46
45
|
addAgentInfo: Requester<Api.AddAgentInfoRequest, Api.AddAgentInfoResponse>;
|
|
47
|
-
|
|
48
|
-
deleteArchivedCloneCells: Requester<Api.DeleteArchivedCloneCellsRequest, Api.DeleteArchivedCloneCellsResponse>;
|
|
46
|
+
deleteCloneCell: Requester<Api.DeleteCloneCellRequest, Api.DeleteCloneCellResponse>;
|
|
49
47
|
grantZomeCallCapability: Requester<Api.GrantZomeCallCapabilityRequest, Api.GrantZomeCallCapabilityResponse>;
|
|
50
48
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Conductor Admin API
|
|
4
4
|
*
|
|
5
5
|
* const client = AdminWebsocket.connect(
|
|
6
|
-
* 'ws://
|
|
6
|
+
* 'ws://127.0.0.1:9000'
|
|
7
7
|
* )
|
|
8
8
|
*
|
|
9
9
|
* client.generateAgentPubKey()
|
|
@@ -29,9 +29,9 @@ export class AdminWebsocket {
|
|
|
29
29
|
}
|
|
30
30
|
static async connect(url, defaultTimeout) {
|
|
31
31
|
// Check if we are in the launcher's environment, and if so, redirect the url to connect to
|
|
32
|
-
const env =
|
|
32
|
+
const env = getLauncherEnvironment();
|
|
33
33
|
if (env) {
|
|
34
|
-
url = `ws://
|
|
34
|
+
url = `ws://127.0.0.1:${env.ADMIN_INTERFACE_PORT}`;
|
|
35
35
|
}
|
|
36
36
|
const wsClient = await WsClient.connect(url);
|
|
37
37
|
return new AdminWebsocket(wsClient, defaultTimeout);
|
|
@@ -52,19 +52,17 @@ export class AdminWebsocket {
|
|
|
52
52
|
generateAgentPubKey = this._requester("generate_agent_pub_key");
|
|
53
53
|
registerDna = this._requester("register_dna");
|
|
54
54
|
getDnaDefinition = this._requester("get_dna_definition");
|
|
55
|
-
installApp = this._requester("install_app");
|
|
56
55
|
uninstallApp = this._requester("uninstall_app");
|
|
57
|
-
|
|
56
|
+
installApp = this._requester("install_app");
|
|
58
57
|
listDnas = this._requester("list_dnas");
|
|
59
58
|
listCellIds = this._requester("list_cell_ids");
|
|
60
59
|
// Deprecated
|
|
61
60
|
listActiveApps = this._requester("list_active_apps");
|
|
62
61
|
listApps = this._requester("list_apps", listAppsTransform);
|
|
63
62
|
listAppInterfaces = this._requester("list_app_interfaces");
|
|
64
|
-
|
|
63
|
+
agentInfo = this._requester("agent_info");
|
|
65
64
|
addAgentInfo = this._requester("add_agent_info");
|
|
66
|
-
|
|
67
|
-
deleteArchivedCloneCells = this._requester("delete_archived_clone_cells");
|
|
65
|
+
deleteCloneCell = this._requester("delete_clone_cell");
|
|
68
66
|
grantZomeCallCapability = this._requester("grant_zome_call_capability");
|
|
69
67
|
}
|
|
70
68
|
const listAppsTransform = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/admin/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;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F,MAAM,kBAAkB,GAKpB;IACF,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG;IACnB,MAAM,EAAE,CAAC,GAAW,EAAyB,EAAE;QAC7C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;CACF,CAAC;AAEF,SAAS,qBAAqB,CAAC,aAAkC;IAC/D,QAAQ,aAAa,EAAE;QACrB,KAAK,GAAG,CAAC,eAAe,CAAC,OAAO;YAC9B,OAAO;gBACL,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,KAAK,GAAG,CAAC,eAAe,CAAC,OAAO;YAC9B,OAAO;gBACL,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,KAAK,GAAG,CAAC,eAAe,CAAC,MAAM;YAC7B,OAAO;gBACL,MAAM,EAAE,IAAI;aACb,CAAC;QACJ,KAAK,GAAG,CAAC,eAAe,CAAC,QAAQ;YAC/B,OAAO;gBACL,QAAQ,EAAE,IAAI;aACf,CAAC;QACJ,KAAK,GAAG,CAAC,eAAe,CAAC,OAAO;YAC9B,OAAO;gBACL,OAAO,EAAE,IAAI;aACd,CAAC;KACL;AACH,CAAC"}
|
package/lib/api/app/index.js
CHANGED
package/lib/api/app/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/app/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/api/app/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAE/B,0EAA0E"}
|
package/lib/api/app/types.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AgentPubKey, CellId, DnaProperties, InstalledAppId, InstalledCell, RoleName, Timestamp, DnaHash, DnaGossipInfo } from "../../types.js";
|
|
1
|
+
import { AgentPubKey, CellId, DnaProperties, InstalledAppId, InstalledCell, RoleName, Timestamp, DnaHash, NetworkInfo } from "../../types.js";
|
|
3
2
|
import { Requester } from "../common.js";
|
|
4
|
-
import {
|
|
3
|
+
import { FunctionName, AppInfo, MembraneProof, NetworkSeed, ZomeName } from "../admin/index.js";
|
|
5
4
|
export declare type CallZomeRequestGeneric<Payload> = {
|
|
6
|
-
cap_secret: CapSecret | null;
|
|
7
5
|
cell_id: CellId;
|
|
8
|
-
zome_name:
|
|
9
|
-
fn_name:
|
|
6
|
+
zome_name: ZomeName;
|
|
7
|
+
fn_name: FunctionName;
|
|
10
8
|
payload: Payload;
|
|
11
9
|
provenance: AgentPubKey;
|
|
12
10
|
};
|
|
@@ -16,7 +14,7 @@ export declare type CallZomeResponse = CallZomeResponseGeneric<any>;
|
|
|
16
14
|
export declare type AppInfoRequest = {
|
|
17
15
|
installed_app_id: InstalledAppId;
|
|
18
16
|
};
|
|
19
|
-
export declare type AppInfoResponse =
|
|
17
|
+
export declare type AppInfoResponse = AppInfo;
|
|
20
18
|
export interface CreateCloneCellRequest {
|
|
21
19
|
/**
|
|
22
20
|
* The app id that the DNA to clone belongs to
|
|
@@ -62,11 +60,13 @@ export interface CreateCloneCellRequest {
|
|
|
62
60
|
name?: string;
|
|
63
61
|
}
|
|
64
62
|
export declare type CreateCloneCellResponse = InstalledCell;
|
|
65
|
-
export interface
|
|
63
|
+
export interface DisableCloneCellRequest {
|
|
66
64
|
app_id: InstalledAppId;
|
|
67
65
|
clone_cell_id: RoleName | CellId;
|
|
68
66
|
}
|
|
69
|
-
export declare type
|
|
67
|
+
export declare type DisableCloneCellResponse = void;
|
|
68
|
+
export declare type EnableCloneCellRequest = DisableCloneCellRequest;
|
|
69
|
+
export declare type EnableCloneCellResponse = CreateCloneCellResponse;
|
|
70
70
|
export declare type AppSignal = {
|
|
71
71
|
type: string;
|
|
72
72
|
data: {
|
|
@@ -74,14 +74,16 @@ export declare type AppSignal = {
|
|
|
74
74
|
payload: any;
|
|
75
75
|
};
|
|
76
76
|
};
|
|
77
|
-
export interface
|
|
78
|
-
/** The DNAs for which to get
|
|
77
|
+
export interface NetworkInfoRequest {
|
|
78
|
+
/** The DNAs for which to get network info */
|
|
79
79
|
dnas: DnaHash[];
|
|
80
80
|
}
|
|
81
|
-
export declare type
|
|
81
|
+
export declare type NetworkInfoResponse = NetworkInfo[];
|
|
82
82
|
export declare type AppSignalCb = (signal: AppSignal) => void;
|
|
83
83
|
export declare type SignalResponseGeneric<Payload> = Payload;
|
|
84
84
|
export interface AppApi {
|
|
85
85
|
appInfo: Requester<AppInfoRequest, AppInfoResponse>;
|
|
86
86
|
callZome: Requester<CallZomeRequest, CallZomeResponse>;
|
|
87
|
+
enableCloneCell: Requester<EnableCloneCellRequest, EnableCloneCellResponse>;
|
|
88
|
+
disableCloneCell: Requester<DisableCloneCellRequest, DisableCloneCellResponse>;
|
|
87
89
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import nacl from "tweetnacl";
|
|
2
|
+
import { CapSecret } from "../../hdk/capabilities.js";
|
|
3
|
+
import { AgentPubKey, CellId } from "../../types.js";
|
|
4
|
+
import { FunctionName, ZomeName } from "../admin/types.js";
|
|
5
|
+
import { AdminWebsocket } from "../admin/websocket.js";
|
|
6
|
+
import { CallZomeRequestSigned, Nonce256Bit } from "./websocket.js";
|
|
7
|
+
/**
|
|
8
|
+
* Generates a key pair for signing zome calls.
|
|
9
|
+
*
|
|
10
|
+
* @returns The signing key pair and an agent pub key based on the public key.
|
|
11
|
+
*/
|
|
12
|
+
export declare const generateSigningKeyPair: () => [nacl.SignKeyPair, Uint8Array];
|
|
13
|
+
export declare const randomCapSecret: () => CapSecret;
|
|
14
|
+
export declare const randomNonce: () => Nonce256Bit;
|
|
15
|
+
export declare const getNonceExpiration: () => number;
|
|
16
|
+
export declare const grantSigningKey: (admin: AdminWebsocket, cellId: CellId, functions: Array<[ZomeName, FunctionName]>, signingKey: AgentPubKey) => Promise<CapSecret>;
|
|
17
|
+
export declare const signZomeCall: (capSecret: CapSecret, signingKey: AgentPubKey, keyPair: nacl.SignKeyPair, payload: any) => Promise<CallZomeRequestSigned>;
|
|
18
|
+
export declare const grantSigningKeyAndSignZomeCall: (admin: AdminWebsocket, payload: any) => Promise<CallZomeRequestSigned>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { hashZomeCall } from "@holochain/serialization";
|
|
2
|
+
import { encode } from "@msgpack/msgpack";
|
|
3
|
+
import crypto from "crypto";
|
|
4
|
+
import nacl from "tweetnacl";
|
|
5
|
+
/**
|
|
6
|
+
* Generates a key pair for signing zome calls.
|
|
7
|
+
*
|
|
8
|
+
* @returns The signing key pair and an agent pub key based on the public key.
|
|
9
|
+
*/
|
|
10
|
+
export const generateSigningKeyPair = () => {
|
|
11
|
+
const keyPair = nacl.sign.keyPair();
|
|
12
|
+
const signingKey = new Uint8Array([132, 32, 36].concat(...keyPair.publicKey).concat(...[0, 0, 0, 0]));
|
|
13
|
+
const keys = [keyPair, signingKey];
|
|
14
|
+
return keys;
|
|
15
|
+
};
|
|
16
|
+
export const randomCapSecret = () => randomByteArray(64);
|
|
17
|
+
export const randomNonce = () => randomByteArray(32);
|
|
18
|
+
const randomByteArray = (length) => {
|
|
19
|
+
if (typeof window !== "undefined" &&
|
|
20
|
+
"crypto" in window &&
|
|
21
|
+
"getRandomValues" in window.crypto) {
|
|
22
|
+
return window.crypto.getRandomValues(new Uint8Array(length));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return new Uint8Array(crypto.randomBytes(length));
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export const getNonceExpiration = () => (Date.now() + 5 * 60 * 1000) * 1000; // 5 mins from now in microseconds
|
|
29
|
+
export const grantSigningKey = async (admin, cellId, functions, signingKey) => {
|
|
30
|
+
const capSecret = randomCapSecret();
|
|
31
|
+
await admin.grantZomeCallCapability({
|
|
32
|
+
cell_id: cellId,
|
|
33
|
+
cap_grant: {
|
|
34
|
+
tag: "zome-call-signing-key",
|
|
35
|
+
functions,
|
|
36
|
+
access: {
|
|
37
|
+
Assigned: {
|
|
38
|
+
secret: capSecret,
|
|
39
|
+
assignees: [signingKey],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
return capSecret;
|
|
45
|
+
};
|
|
46
|
+
export const signZomeCall = async (capSecret, signingKey, keyPair, payload) => {
|
|
47
|
+
const unsignedZomeCallPayload = {
|
|
48
|
+
cap_secret: capSecret,
|
|
49
|
+
cell_id: payload.cell_id,
|
|
50
|
+
zome_name: payload.zome_name,
|
|
51
|
+
fn_name: payload.fn_name,
|
|
52
|
+
provenance: signingKey,
|
|
53
|
+
payload: encode(payload.payload),
|
|
54
|
+
nonce: randomNonce(),
|
|
55
|
+
expires_at: getNonceExpiration(),
|
|
56
|
+
};
|
|
57
|
+
const hashedZomeCall = await hashZomeCall(unsignedZomeCallPayload);
|
|
58
|
+
const signature = nacl
|
|
59
|
+
.sign(hashedZomeCall, keyPair.secretKey)
|
|
60
|
+
.subarray(0, nacl.sign.signatureLength);
|
|
61
|
+
const signedZomeCall = {
|
|
62
|
+
...unsignedZomeCallPayload,
|
|
63
|
+
signature,
|
|
64
|
+
};
|
|
65
|
+
return signedZomeCall;
|
|
66
|
+
};
|
|
67
|
+
export const grantSigningKeyAndSignZomeCall = async (admin, payload) => {
|
|
68
|
+
const [keyPair, signingKey] = generateSigningKeyPair();
|
|
69
|
+
const capSecret = await grantSigningKey(admin, payload.cell_id, [[payload.zome_name, payload.fn_name]], signingKey);
|
|
70
|
+
payload = { ...payload, cap_secret: capSecret };
|
|
71
|
+
const signedZomeCall = signZomeCall(capSecret, signingKey, keyPair, payload);
|
|
72
|
+
return signedZomeCall;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceR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AAc,GAA0B;QAC5C,GAAG,uBAAuB;QAC1B,SAAS;KACV,CAAC;IACF,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,8BAA8B,GAAG,KAAK,EACjD,KAAqB,EACrB,OAAY,EACZ,EAAE;IACF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,sBAAsB,EAAE,CAAC;IACvD,MAAM,SAAS,GAAG,MAAM,eAAe,CACrC,KAAK,EACL,OAAO,CAAC,OAAO,EACf,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,EACtC,UAAU,CACX,CAAC;IACF,OAAO,GAAG,EAAE,GAAG,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IAChD,MAAM,cAAc,GAAG,YAAY,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC7E,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -1,18 +1,29 @@
|
|
|
1
1
|
import Emittery from "emittery";
|
|
2
|
+
import { CapSecret } from "../../hdk/capabilities.js";
|
|
2
3
|
import { InstalledAppId } from "../../types.js";
|
|
3
4
|
import { WsClient } from "../client.js";
|
|
4
5
|
import { Requester, Transformer } from "../common.js";
|
|
5
|
-
import { AppApi, AppInfoRequest, AppInfoResponse, AppSignalCb,
|
|
6
|
+
import { AppApi, AppInfoRequest, AppInfoResponse, AppSignalCb, CallZomeRequest, CallZomeResponse, CreateCloneCellRequest, CreateCloneCellResponse, DisableCloneCellRequest, DisableCloneCellResponse, EnableCloneCellRequest, EnableCloneCellResponse, NetworkInfoRequest, NetworkInfoResponse } from "./types.js";
|
|
6
7
|
export declare class AppWebsocket extends Emittery implements AppApi {
|
|
7
8
|
client: WsClient;
|
|
8
9
|
defaultTimeout: number;
|
|
9
10
|
overrideInstalledAppId?: InstalledAppId;
|
|
10
11
|
constructor(client: WsClient, defaultTimeout?: number, overrideInstalledAppId?: InstalledAppId);
|
|
11
12
|
static connect(url: string, defaultTimeout?: number, signalCb?: AppSignalCb): Promise<AppWebsocket>;
|
|
12
|
-
_requester: <
|
|
13
|
+
_requester: <ReqI, ReqO, ResI, ResO>(tag: string, transformer?: Transformer<ReqI, ReqO, ResI, ResO> | undefined) => (req: ReqI, timeout?: number | undefined) => Promise<ResO>;
|
|
13
14
|
appInfo: Requester<AppInfoRequest, AppInfoResponse>;
|
|
14
|
-
callZome: Requester<
|
|
15
|
+
callZome: Requester<CallZomeRequest | CallZomeRequestSigned, CallZomeResponse>;
|
|
15
16
|
createCloneCell: Requester<CreateCloneCellRequest, CreateCloneCellResponse>;
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
enableCloneCell: Requester<EnableCloneCellRequest, EnableCloneCellResponse>;
|
|
18
|
+
disableCloneCell: Requester<DisableCloneCellRequest, DisableCloneCellResponse>;
|
|
19
|
+
networkInfo: Requester<NetworkInfoRequest, NetworkInfoResponse>;
|
|
20
|
+
}
|
|
21
|
+
export declare type Nonce256Bit = Uint8Array;
|
|
22
|
+
export interface CallZomeRequestUnsigned extends CallZomeRequest {
|
|
23
|
+
cap_secret: CapSecret | null;
|
|
24
|
+
nonce: Nonce256Bit;
|
|
25
|
+
expires_at: number;
|
|
26
|
+
}
|
|
27
|
+
export interface CallZomeRequestSigned extends CallZomeRequestUnsigned {
|
|
28
|
+
signature: Uint8Array;
|
|
18
29
|
}
|
package/lib/api/app/websocket.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Defines AppWebsocket, an easy-to-use websocket implementation of the
|
|
3
3
|
* Conductor API for apps
|
|
4
4
|
*
|
|
5
|
-
* const client = AppWebsocket.connect('ws://
|
|
5
|
+
* const client = AppWebsocket.connect('ws://127.0.0.1:9000');
|
|
6
6
|
*
|
|
7
7
|
* client.callZome({...})
|
|
8
8
|
* .then(() => {
|
|
@@ -12,11 +12,16 @@
|
|
|
12
12
|
* console.error('problem installing DNA:', err)
|
|
13
13
|
* });
|
|
14
14
|
*/
|
|
15
|
+
import { hashZomeCall } from "@holochain/serialization";
|
|
15
16
|
import { decode, encode } from "@msgpack/msgpack";
|
|
17
|
+
import { invoke } from "@tauri-apps/api/tauri";
|
|
16
18
|
import Emittery from "emittery";
|
|
17
|
-
import
|
|
19
|
+
import nacl from "tweetnacl";
|
|
20
|
+
import { getLauncherEnvironment, isLauncher, } from "../../environments/launcher.js";
|
|
18
21
|
import { WsClient } from "../client.js";
|
|
19
22
|
import { catchError, DEFAULT_TIMEOUT, promiseTimeout, requesterTransformer, } from "../common.js";
|
|
23
|
+
import { getSigningPropsForCell } from "../zome-call-signing.js";
|
|
24
|
+
import { getNonceExpiration, randomNonce } from "./util.js";
|
|
20
25
|
export class AppWebsocket extends Emittery {
|
|
21
26
|
client;
|
|
22
27
|
defaultTimeout;
|
|
@@ -28,13 +33,14 @@ export class AppWebsocket extends Emittery {
|
|
|
28
33
|
defaultTimeout === undefined ? DEFAULT_TIMEOUT : defaultTimeout;
|
|
29
34
|
this.overrideInstalledAppId = overrideInstalledAppId;
|
|
30
35
|
}
|
|
31
|
-
static async connect(url, defaultTimeout,
|
|
32
|
-
//** @deprecated */
|
|
33
|
-
signalCb) {
|
|
36
|
+
static async connect(url, defaultTimeout, signalCb) {
|
|
34
37
|
// Check if we are in the launcher's environment, and if so, redirect the url to connect to
|
|
35
|
-
const env =
|
|
38
|
+
const env = getLauncherEnvironment();
|
|
36
39
|
if (env) {
|
|
37
|
-
url = `ws://
|
|
40
|
+
url = `ws://127.0.0.1:${env.APP_INTERFACE_PORT}`;
|
|
41
|
+
}
|
|
42
|
+
if (signalCb) {
|
|
43
|
+
console.warn("Providing a signal callback on client initialization is deprecated. Instead add an event handler using `.on('signal', signalCb)`.");
|
|
38
44
|
}
|
|
39
45
|
const wsClient = await WsClient.connect(url, signalCb);
|
|
40
46
|
const appWebsocket = new AppWebsocket(wsClient, defaultTimeout, env ? env.INSTALLED_APP_ID : undefined);
|
|
@@ -43,21 +49,71 @@ export class AppWebsocket extends Emittery {
|
|
|
43
49
|
}
|
|
44
50
|
_requester = (tag, transformer) => requesterTransformer((req, timeout) => promiseTimeout(this.client.request(req), tag, timeout || this.defaultTimeout).then(catchError), tag, transformer);
|
|
45
51
|
appInfo = this._requester("app_info", appInfoTransform(this));
|
|
46
|
-
callZome = this._requester("
|
|
52
|
+
callZome = this._requester("call_zome", callZomeTransform);
|
|
47
53
|
createCloneCell = this._requester("create_clone_cell");
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
enableCloneCell = this._requester("enable_clone_cell");
|
|
55
|
+
disableCloneCell = this._requester("disable_clone_cell");
|
|
56
|
+
networkInfo = this._requester("network_info");
|
|
50
57
|
}
|
|
51
58
|
const callZomeTransform = {
|
|
52
|
-
input: (req) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
input: async (req) => {
|
|
60
|
+
if (isLauncher) {
|
|
61
|
+
const zomeCallUnsigned = {
|
|
62
|
+
provenance: Array.from(req.provenance),
|
|
63
|
+
cell_id: [Array.from(req.cell_id[0]), Array.from(req.cell_id[1])],
|
|
64
|
+
zome_name: req.zome_name,
|
|
65
|
+
fn_name: req.fn_name,
|
|
66
|
+
payload: Array.from(encode(req.payload)),
|
|
67
|
+
nonce: Array.from(randomNonce()),
|
|
68
|
+
expires_at: getNonceExpiration(),
|
|
69
|
+
};
|
|
70
|
+
const signedZomeCallTauri = await invoke("sign_zome_call", { zomeCallUnsigned });
|
|
71
|
+
const signedZomeCall = {
|
|
72
|
+
provenance: Uint8Array.from(signedZomeCallTauri.provenance),
|
|
73
|
+
cap_secret: null,
|
|
74
|
+
cell_id: [
|
|
75
|
+
Uint8Array.from(signedZomeCallTauri.cell_id[0]),
|
|
76
|
+
Uint8Array.from(signedZomeCallTauri.cell_id[1]),
|
|
77
|
+
],
|
|
78
|
+
zome_name: signedZomeCallTauri.zome_name,
|
|
79
|
+
fn_name: signedZomeCallTauri.fn_name,
|
|
80
|
+
payload: Uint8Array.from(signedZomeCallTauri.payload),
|
|
81
|
+
signature: Uint8Array.from(signedZomeCallTauri.signature),
|
|
82
|
+
expires_at: signedZomeCallTauri.expires_at,
|
|
83
|
+
nonce: Uint8Array.from(signedZomeCallTauri.nonce),
|
|
84
|
+
};
|
|
85
|
+
return signedZomeCall;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
if ("signature" in req) {
|
|
89
|
+
return req;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const signingPropsForCell = getSigningPropsForCell(req.cell_id);
|
|
93
|
+
if (!signingPropsForCell) {
|
|
94
|
+
throw new Error("cannot sign zome call: signing properties have not been set");
|
|
95
|
+
}
|
|
96
|
+
const unsignedZomeCall = {
|
|
97
|
+
...req,
|
|
98
|
+
cap_secret: signingPropsForCell.capSecret,
|
|
99
|
+
provenance: signingPropsForCell.signingKey,
|
|
100
|
+
payload: encode(req.payload),
|
|
101
|
+
nonce: randomNonce(),
|
|
102
|
+
expires_at: getNonceExpiration(),
|
|
103
|
+
};
|
|
104
|
+
const hashedZomeCall = await hashZomeCall(unsignedZomeCall);
|
|
105
|
+
const signature = nacl
|
|
106
|
+
.sign(hashedZomeCall, signingPropsForCell.keyPair.secretKey)
|
|
107
|
+
.subarray(0, nacl.sign.signatureLength);
|
|
108
|
+
const signedZomeCall = {
|
|
109
|
+
...unsignedZomeCall,
|
|
110
|
+
signature,
|
|
111
|
+
};
|
|
112
|
+
return signedZomeCall;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
60
115
|
},
|
|
116
|
+
output: (res) => decode(res),
|
|
61
117
|
};
|
|
62
118
|
const appInfoTransform = (appWs) => ({
|
|
63
119
|
input: (req) => {
|
|
@@ -68,8 +124,6 @@ const appInfoTransform = (appWs) => ({
|
|
|
68
124
|
}
|
|
69
125
|
return req;
|
|
70
126
|
},
|
|
71
|
-
output: (res) =>
|
|
72
|
-
return res;
|
|
73
|
-
},
|
|
127
|
+
output: (res) => res,
|
|
74
128
|
});
|
|
75
129
|
//# sourceMappingURL=websocket.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,sBAAsB,EACtB,UAAU,GACX,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,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AAkBjE,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE5D,MAAM,OAAO,YAAa,SAAQ,QAAQ;IACxC,MAAM,CAAW;IACjB,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,cA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AE1C,MAAM,cAAc,GAA0B;oBAC5C,GAAG,gBAAgB;oBACnB,SAAS;iBACV,CAAC;gBACF,OAAO,cAAc,CAAC;aACvB;SACF;IACH,CAAC;IACD,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC;CAC7B,CAAC;AAEF,MAAM,gBAAgB,GAAG,CACvB,KAAmB,EAMnB,EAAE,CAAC,CAAC;IACJ,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE;QACb,IAAI,KAAK,CAAC,sBAAsB,EAAE;YAChC,OAAO;gBACL,gBAAgB,EAAE,KAAK,CAAC,sBAAsB;aAC/C,CAAC;SACH;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IACD,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG;CACrB,CAAC,CAAC"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { UnsubscribeFunction } from "emittery";
|
|
2
|
-
import {
|
|
3
|
-
import { RoleName } from "
|
|
4
|
-
import { CallZomeRequest,
|
|
2
|
+
import { DisableCloneCellResponse, CreateCloneCellRequest, CreateCloneCellResponse } from "../index.js";
|
|
3
|
+
import { RoleName } from "../../index.js";
|
|
4
|
+
import { AppInfoResponse, AppSignal, DisableCloneCellRequest, CallZomeRequest, EnableCloneCellRequest, EnableCloneCellResponse, CallZomeRequestSigned } from "../app/index.js";
|
|
5
5
|
export declare type RoleNameCallZomeRequest = Omit<CallZomeRequest, "cell_id"> & {
|
|
6
6
|
role_name: RoleName;
|
|
7
7
|
};
|
|
8
|
-
export declare type
|
|
8
|
+
export declare type RoleNameCallZomeRequestSigned = Omit<CallZomeRequestSigned, "cell_id"> & {
|
|
9
|
+
role_name: RoleName;
|
|
10
|
+
};
|
|
11
|
+
export declare type AppAgentCallZomeRequest = CallZomeRequest | RoleNameCallZomeRequest | CallZomeRequestSigned | RoleNameCallZomeRequestSigned;
|
|
9
12
|
export declare type AppCreateCloneCellRequest = Omit<CreateCloneCellRequest, "app_id">;
|
|
10
|
-
export declare type
|
|
13
|
+
export declare type AppEnableCloneCellRequest = Omit<EnableCloneCellRequest, "app_id">;
|
|
14
|
+
export declare type AppDisableCloneCellRequest = Omit<DisableCloneCellRequest, "app_id">;
|
|
11
15
|
export interface AppAgentEvents {
|
|
12
16
|
signal: AppSignal;
|
|
13
17
|
}
|
|
@@ -16,5 +20,6 @@ export interface AppAgentClient {
|
|
|
16
20
|
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: (eventData: AppAgentEvents[Name]) => void | Promise<void>): UnsubscribeFunction;
|
|
17
21
|
appInfo(): Promise<AppInfoResponse>;
|
|
18
22
|
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
|
|
19
|
-
|
|
23
|
+
enableCloneCell(args: AppEnableCloneCellRequest): Promise<EnableCloneCellResponse>;
|
|
24
|
+
disableCloneCell(args: AppDisableCloneCellRequest): Promise<DisableCloneCellResponse>;
|
|
20
25
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Defines AppAgentWebsocket, an easy-to-use websocket implementation of the
|
|
3
3
|
* Conductor API for apps, restricted to a single app provided on initialization
|
|
4
4
|
*
|
|
5
|
-
* const appWs = AppWebsocket.connect('ws://
|
|
5
|
+
* const appWs = AppWebsocket.connect('ws://127.0.0.1:9000')
|
|
6
6
|
*
|
|
7
7
|
* const client = new AppAgentWebsocket(appWs, 'my_installed_app_id')
|
|
8
8
|
*
|
|
@@ -20,18 +20,20 @@
|
|
|
20
20
|
* })
|
|
21
21
|
*/
|
|
22
22
|
import Emittery, { UnsubscribeFunction } from "emittery";
|
|
23
|
-
import { InstalledAppId } from "../../types.js";
|
|
24
|
-
import { AppInfoResponse, AppWebsocket,
|
|
25
|
-
import { AppAgentCallZomeRequest, AppAgentClient, AppAgentEvents,
|
|
23
|
+
import { InstalledAppId, RoleName } from "../../types.js";
|
|
24
|
+
import { AppInfo, AppInfoResponse, AppWebsocket, CallZomeResponse, CreateCloneCellResponse, DisableCloneCellResponse, EnableCloneCellResponse } from "../index.js";
|
|
25
|
+
import { AppAgentCallZomeRequest, AppAgentClient, AppAgentEvents, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest } from "./types.js";
|
|
26
26
|
export declare class AppAgentWebsocket implements AppAgentClient {
|
|
27
27
|
appWebsocket: AppWebsocket;
|
|
28
28
|
installedAppId: InstalledAppId;
|
|
29
|
-
cachedAppInfo?:
|
|
29
|
+
cachedAppInfo?: AppInfo;
|
|
30
30
|
emitter: Emittery<AppAgentEvents, AppAgentEvents & import("emittery").OmnipresentEventData, never>;
|
|
31
31
|
constructor(appWebsocket: AppWebsocket, installedAppId: InstalledAppId);
|
|
32
32
|
appInfo(): Promise<AppInfoResponse>;
|
|
33
|
+
getCellIdFromRoleName(roleName: RoleName, appInfo: AppInfo): import("../../types.js").CellId;
|
|
33
34
|
callZome(request: AppAgentCallZomeRequest, timeout?: number): Promise<CallZomeResponse>;
|
|
34
35
|
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
|
|
35
|
-
|
|
36
|
+
enableCloneCell(args: AppEnableCloneCellRequest): Promise<EnableCloneCellResponse>;
|
|
37
|
+
disableCloneCell(args: AppDisableCloneCellRequest): Promise<DisableCloneCellResponse>;
|
|
36
38
|
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: (eventData: AppAgentEvents[Name]) => void | Promise<void>): UnsubscribeFunction;
|
|
37
39
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Defines AppAgentWebsocket, an easy-to-use websocket implementation of the
|
|
3
3
|
* Conductor API for apps, restricted to a single app provided on initialization
|
|
4
4
|
*
|
|
5
|
-
* const appWs = AppWebsocket.connect('ws://
|
|
5
|
+
* const appWs = AppWebsocket.connect('ws://127.0.0.1:9000')
|
|
6
6
|
*
|
|
7
7
|
* const client = new AppAgentWebsocket(appWs, 'my_installed_app_id')
|
|
8
8
|
*
|
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
*/
|
|
22
22
|
import Emittery from "emittery";
|
|
23
23
|
import { omit } from "lodash-es";
|
|
24
|
+
import { getLauncherEnvironment } from "../../environments/launcher.js";
|
|
25
|
+
import { getBaseRoleNameFromCloneId, isCloneId } from "../common.js";
|
|
24
26
|
export class AppAgentWebsocket {
|
|
25
27
|
appWebsocket;
|
|
26
28
|
installedAppId;
|
|
@@ -28,7 +30,8 @@ export class AppAgentWebsocket {
|
|
|
28
30
|
emitter = new Emittery();
|
|
29
31
|
constructor(appWebsocket, installedAppId) {
|
|
30
32
|
this.appWebsocket = appWebsocket;
|
|
31
|
-
|
|
33
|
+
const env = getLauncherEnvironment();
|
|
34
|
+
this.installedAppId = env?.INSTALLED_APP_ID || installedAppId;
|
|
32
35
|
this.appWebsocket.on("signal", (signal) => this.emitter.emit("signal", signal));
|
|
33
36
|
}
|
|
34
37
|
async appInfo() {
|
|
@@ -38,22 +41,38 @@ export class AppAgentWebsocket {
|
|
|
38
41
|
this.cachedAppInfo = appInfo;
|
|
39
42
|
return appInfo;
|
|
40
43
|
}
|
|
44
|
+
getCellIdFromRoleName(roleName, appInfo) {
|
|
45
|
+
if (isCloneId(roleName)) {
|
|
46
|
+
const baseRoleName = getBaseRoleNameFromCloneId(roleName);
|
|
47
|
+
if (!(baseRoleName in appInfo.cell_info)) {
|
|
48
|
+
throw new Error(`No cell found with role_name ${roleName}`);
|
|
49
|
+
}
|
|
50
|
+
const cloneCell = appInfo.cell_info[baseRoleName].find((c) => "Cloned" in c && c.Cloned.clone_id === roleName);
|
|
51
|
+
if (!cloneCell || !("Cloned" in cloneCell)) {
|
|
52
|
+
throw new Error(`No clone cell found with clone id ${roleName}`);
|
|
53
|
+
}
|
|
54
|
+
return cloneCell.Cloned.cell_id;
|
|
55
|
+
}
|
|
56
|
+
if (!(roleName in appInfo.cell_info)) {
|
|
57
|
+
throw new Error(`No cell found with role_name ${roleName}`);
|
|
58
|
+
}
|
|
59
|
+
const cell = appInfo.cell_info[roleName].find((c) => "Provisioned" in c);
|
|
60
|
+
if (!cell || !("Provisioned" in cell)) {
|
|
61
|
+
throw new Error(`No provisioned cell found with role_name ${roleName}`);
|
|
62
|
+
}
|
|
63
|
+
return cell.Provisioned.cell_id;
|
|
64
|
+
}
|
|
41
65
|
async callZome(request, timeout) {
|
|
42
|
-
|
|
43
|
-
.role_name;
|
|
44
|
-
if (role_name) {
|
|
66
|
+
if ("role_name" in request && request.role_name) {
|
|
45
67
|
const appInfo = this.cachedAppInfo || (await this.appInfo());
|
|
46
|
-
const cell_id =
|
|
47
|
-
|
|
48
|
-
throw new Error(`No cell found with role_name ${role_name}`);
|
|
49
|
-
}
|
|
50
|
-
const callZomeRequest = {
|
|
68
|
+
const cell_id = this.getCellIdFromRoleName(request.role_name, appInfo);
|
|
69
|
+
const zomeCallPayload = {
|
|
51
70
|
...omit(request, "role_name"),
|
|
52
71
|
cell_id,
|
|
53
72
|
};
|
|
54
|
-
return this.appWebsocket.callZome(
|
|
73
|
+
return this.appWebsocket.callZome(zomeCallPayload, timeout);
|
|
55
74
|
}
|
|
56
|
-
else if (request.cell_id) {
|
|
75
|
+
else if ("cell_id" in request && request.cell_id) {
|
|
57
76
|
return this.appWebsocket.callZome(request, timeout);
|
|
58
77
|
}
|
|
59
78
|
else {
|
|
@@ -68,8 +87,14 @@ export class AppAgentWebsocket {
|
|
|
68
87
|
this.cachedAppInfo = undefined;
|
|
69
88
|
return clonedCell;
|
|
70
89
|
}
|
|
71
|
-
async
|
|
72
|
-
return this.appWebsocket.
|
|
90
|
+
async enableCloneCell(args) {
|
|
91
|
+
return this.appWebsocket.enableCloneCell({
|
|
92
|
+
app_id: this.installedAppId,
|
|
93
|
+
...args,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
async disableCloneCell(args) {
|
|
97
|
+
return this.appWebsocket.disableCloneCell({
|
|
73
98
|
app_id: this.installedAppId,
|
|
74
99
|
...args,
|
|
75
100
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app-agent/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,QAAiC,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"websocket.js","sourceRoot":"","sources":["../../../src/api/app-agent/websocket.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,QAAiC,MAAM,UAAU,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAGxE,OAAO,EAAE,0BAA0B,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAoBrE,MAAM,OAAO,iBAAiB;IAC5B,YAAY,CAAe;IAC3B,cAAc,CAAiB;IAC/B,aAAa,CAAW;IAExB,OAAO,GAAG,IAAI,QAAQ,EAAkB,CAAC;IAEzC,YAAY,YAA0B,EAAE,cAA8B;QACpE,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QAEjC,MAAM,GAAG,GAAG,sBAAsB,EAAE,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,GAAG,EAAE,gBAAgB,IAAI,cAAc,CAAC;QAE9D,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CACxC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CACpC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;YAC9C,gBAAgB,EAAE,IAAI,CAAC,cAAc;SACtC,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QA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IACL,CAAC;IAED,EAAE,CACA,SAAiC,EACjC,QAAmE;QAEnE,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;CACF"}
|
package/lib/api/client.js
CHANGED
|
@@ -17,7 +17,7 @@ export class WsClient extends Emittery {
|
|
|
17
17
|
this.pendingRequests = {};
|
|
18
18
|
this.index = 0;
|
|
19
19
|
if (signalCb) {
|
|
20
|
-
console.log("Providing a signal callback on client initialization is deprecated. Instead
|
|
20
|
+
console.log("Providing a signal callback on client initialization is deprecated. Instead add an event handler using `.on('signal', signalCb)`.");
|
|
21
21
|
this.on("signal", signalCb);
|
|
22
22
|
}
|
|
23
23
|
socket.onmessage = async (encodedMsg) => {
|
|
@@ -27,7 +27,7 @@ export class WsClient extends Emittery {
|
|
|
27
27
|
data = await data.arrayBuffer();
|
|
28
28
|
}
|
|
29
29
|
const msg = decode(data);
|
|
30
|
-
if (msg.type === "
|
|
30
|
+
if (msg.type === "signal") {
|
|
31
31
|
const decodedMessage = decode(msg.data);
|
|
32
32
|
if (!decodedMessage.App) {
|
|
33
33
|
// We have received a system signal, do nothing
|
|
@@ -45,7 +45,7 @@ export class WsClient extends Emittery {
|
|
|
45
45
|
};
|
|
46
46
|
this.emit("signal", signal);
|
|
47
47
|
}
|
|
48
|
-
else if (msg.type === "
|
|
48
|
+
else if (msg.type === "response") {
|
|
49
49
|
this.handleResponse(msg);
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
@@ -55,7 +55,7 @@ export class WsClient extends Emittery {
|
|
|
55
55
|
}
|
|
56
56
|
emitSignal(data) {
|
|
57
57
|
const encodedMsg = encode({
|
|
58
|
-
type: "
|
|
58
|
+
type: "signal",
|
|
59
59
|
data: encode(data),
|
|
60
60
|
});
|
|
61
61
|
this.socket.send(encodedMsg);
|
|
@@ -65,7 +65,7 @@ export class WsClient extends Emittery {
|
|
|
65
65
|
this.index += 1;
|
|
66
66
|
const encodedMsg = encode({
|
|
67
67
|
id,
|
|
68
|
-
type: "
|
|
68
|
+
type: "request",
|
|
69
69
|
data: encode(data),
|
|
70
70
|
});
|
|
71
71
|
const promise = new Promise((fulfill, reject) => {
|
package/lib/api/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,SAAS,MAAM,eAAe,CAAC;AACtC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAGhC;;;;;GAKG;AACH,MAAM,OAAO,QAAS,SAAQ,QAAQ;IACpC,MAAM,CAAY;IAClB,eAAe,CAMb;IACF,KAAK,CAAS;IAEd,YAAY,MAAW,EAAE,QAAsB;QAC7C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAEf,IAAI,QAAQ,EAAE;YACZ,OAAO,CAAC,GAAG,CACT,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,SAAS,MAAM,eAAe,CAAC;AACtC,OAAO,QAAQ,MAAM,UAAU,CAAC;AAGhC;;;;;GAKG;AACH,MAAM,OAAO,QAAS,SAAQ,QAAQ;IACpC,MAAM,CAAY;IAClB,eAAe,CAMb;IACF,KAAK,CAAS;IAEd,YAAY,MAAW,EAAE,QAAsB;QAC7C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;QAEf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AAC,CAAC"}
|
package/lib/api/common.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RoleName } from "../types.js";
|
|
2
2
|
export declare const DEFAULT_TIMEOUT = 15000;
|
|
3
|
-
export declare type Transformer<
|
|
4
|
-
input: (req:
|
|
3
|
+
export declare type Transformer<ReqI, ReqO, ResI, ResO> = {
|
|
4
|
+
input: (req: ReqI) => ReqO;
|
|
5
5
|
output: (res: ResI) => ResO;
|
|
6
6
|
};
|
|
7
7
|
export declare type Requester<Req, Res> = (req: Req, timeout?: number) => Promise<Res>;
|
|
@@ -15,9 +15,11 @@ export declare type Tagged<T> = {
|
|
|
15
15
|
* and return a Requester which deals only with the inner data types, also
|
|
16
16
|
* with the optional Transformer applied to further modify the input and output.
|
|
17
17
|
*/
|
|
18
|
-
export declare const requesterTransformer: <
|
|
18
|
+
export declare const requesterTransformer: <ReqI, ReqO, ResI, ResO>(requester: Requester<Tagged<ReqO>, Tagged<ResI>>, tag: string, transform?: Transformer<ReqI, ReqO, ResI, ResO>) => (req: ReqI, timeout?: number) => Promise<ResO>;
|
|
19
19
|
export declare const catchError: (res: any) => Promise<any>;
|
|
20
20
|
export declare const promiseTimeout: (promise: Promise<any>, tag: string, ms: number) => Promise<unknown>;
|
|
21
|
+
export declare const isCloneId: (roleName: RoleName) => boolean;
|
|
22
|
+
export declare const getBaseRoleNameFromCloneId: (roleName: RoleName) => string;
|
|
21
23
|
/**
|
|
22
24
|
* Identifier of a clone cell, composed of the DNA's role id and the index
|
|
23
25
|
* of the clone, starting at 0.
|
|
@@ -25,7 +27,6 @@ export declare const promiseTimeout: (promise: Promise<any>, tag: string, ms: nu
|
|
|
25
27
|
* Example: `profiles.0`
|
|
26
28
|
*/
|
|
27
29
|
export declare class CloneId {
|
|
28
|
-
private static readonly CLONE_ID_DELIMITER;
|
|
29
30
|
private readonly roleName;
|
|
30
31
|
private readonly index;
|
|
31
32
|
constructor(roleName: RoleName, index: number);
|
package/lib/api/common.js
CHANGED
|
@@ -6,7 +6,8 @@ export const DEFAULT_TIMEOUT = 15000;
|
|
|
6
6
|
* with the optional Transformer applied to further modify the input and output.
|
|
7
7
|
*/
|
|
8
8
|
export const requesterTransformer = (requester, tag, transform = identityTransformer) => async (req, timeout) => {
|
|
9
|
-
const
|
|
9
|
+
const transformedInput = await transform.input(req);
|
|
10
|
+
const input = { type: tag, data: transformedInput };
|
|
10
11
|
const response = await requester(input, timeout);
|
|
11
12
|
const output = transform.output(response.data);
|
|
12
13
|
return output;
|
|
@@ -38,6 +39,14 @@ export const promiseTimeout = (promise, tag, ms) => {
|
|
|
38
39
|
});
|
|
39
40
|
});
|
|
40
41
|
};
|
|
42
|
+
const CLONE_ID_DELIMITER = ".";
|
|
43
|
+
export const isCloneId = (roleName) => roleName.includes(CLONE_ID_DELIMITER);
|
|
44
|
+
export const getBaseRoleNameFromCloneId = (roleName) => {
|
|
45
|
+
if (!isCloneId(roleName)) {
|
|
46
|
+
throw new Error("invalid clone id: no clone id delimiter found in role name");
|
|
47
|
+
}
|
|
48
|
+
return roleName.split(CLONE_ID_DELIMITER)[0];
|
|
49
|
+
};
|
|
41
50
|
/**
|
|
42
51
|
* Identifier of a clone cell, composed of the DNA's role id and the index
|
|
43
52
|
* of the clone, starting at 0.
|
|
@@ -45,7 +54,6 @@ export const promiseTimeout = (promise, tag, ms) => {
|
|
|
45
54
|
* Example: `profiles.0`
|
|
46
55
|
*/
|
|
47
56
|
export class CloneId {
|
|
48
|
-
static CLONE_ID_DELIMITER = ".";
|
|
49
57
|
roleName;
|
|
50
58
|
index;
|
|
51
59
|
constructor(roleName, index) {
|
|
@@ -58,14 +66,14 @@ export class CloneId {
|
|
|
58
66
|
* @returns A clone id instance.
|
|
59
67
|
*/
|
|
60
68
|
static fromRoleName(roleName) {
|
|
61
|
-
const parts = roleName.split(
|
|
69
|
+
const parts = roleName.split(CLONE_ID_DELIMITER);
|
|
62
70
|
if (parts.length !== 2) {
|
|
63
71
|
throw new Error("Malformed clone id: must consist of {role id.clone index}");
|
|
64
72
|
}
|
|
65
73
|
return new CloneId(parts[0], parseInt(parts[1]));
|
|
66
74
|
}
|
|
67
75
|
toString() {
|
|
68
|
-
return `${this.roleName}${
|
|
76
|
+
return `${this.roleName}${CLONE_ID_DELIMITER}${this.index}`;
|
|
69
77
|
}
|
|
70
78
|
getBaseRoleName() {
|
|
71
79
|
return this.roleName;
|
package/lib/api/common.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/api/common.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,OAAO,CAAC;AAC3B,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AAWrC;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAC/B,CACE,SAAgD,EAChD,GAAW,EACX,YAAiD,mBAAmB,EACpE,EAAE,CACJ,KAAK,EAAE,GAAS,EAAE,OAAgB,EAAE,EAAE;IACpC,MAAM,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/api/common.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAAG,OAAO,CAAC;AAC3B,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AAWrC;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAC/B,CACE,SAAgD,EAChD,GAAW,EACX,YAAiD,mBAAmB,EACpE,EAAE,CACJ,KAAK,EAAE,GAAS,EAAE,OAAgB,EAAE,EAAE;IACpC,MAAM,gBAAgB,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpD,MAAM,KAAK,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACpD,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CA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/api/index.d.ts
CHANGED
package/lib/api/index.js
CHANGED
package/lib/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import nacl from "tweetnacl";
|
|
2
|
+
import { CapSecret } from "../hdk/capabilities.js";
|
|
3
|
+
import { AgentPubKey, CellId } from "../types.js";
|
|
4
|
+
import { FunctionName, ZomeName } from "./admin/types.js";
|
|
5
|
+
import { AdminWebsocket } from "./admin/websocket.js";
|
|
6
|
+
/**
|
|
7
|
+
* Generate and authorize a new key pair for signing zome calls.
|
|
8
|
+
*
|
|
9
|
+
* @param adminWs - An admin websocket connection to use for granting a
|
|
10
|
+
* capability for signing.
|
|
11
|
+
* @param cellId - The cell id to create the capability grant for.
|
|
12
|
+
* @param functions - Zomes and functions to authorize the signing key for.
|
|
13
|
+
*/
|
|
14
|
+
export declare const authorizeNewSigningKeyPair: (adminWs: AdminWebsocket, cellId: CellId, functions: [[ZomeName, FunctionName]]) => Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Get properties for signing a zome call to a cell.
|
|
17
|
+
*
|
|
18
|
+
* @param cellId - Cell id to be called.
|
|
19
|
+
* @returns The keys and cap secret required for signing a zome call.
|
|
20
|
+
*/
|
|
21
|
+
export declare const getSigningPropsForCell: (cellId: CellId) => {
|
|
22
|
+
capSecret: CapSecret;
|
|
23
|
+
keyPair: nacl.SignKeyPair;
|
|
24
|
+
signingKey: AgentPubKey;
|
|
25
|
+
} | undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { fromUint8Array } from "js-base64";
|
|
2
|
+
import { generateSigningKeyPair, grantSigningKey } from "./app/util.js";
|
|
3
|
+
const signingProps = new Map();
|
|
4
|
+
/**
|
|
5
|
+
* Generate and authorize a new key pair for signing zome calls.
|
|
6
|
+
*
|
|
7
|
+
* @param adminWs - An admin websocket connection to use for granting a
|
|
8
|
+
* capability for signing.
|
|
9
|
+
* @param cellId - The cell id to create the capability grant for.
|
|
10
|
+
* @param functions - Zomes and functions to authorize the signing key for.
|
|
11
|
+
*/
|
|
12
|
+
export const authorizeNewSigningKeyPair = async (adminWs, cellId, functions) => {
|
|
13
|
+
const [keyPair, signingKey] = generateSigningKeyPair();
|
|
14
|
+
const capSecret = await grantSigningKey(adminWs, cellId, functions, signingKey);
|
|
15
|
+
const cellIdB64 = fromUint8Array(cellId[0]).concat(fromUint8Array(cellId[1]));
|
|
16
|
+
signingProps.set(cellIdB64, { capSecret, keyPair, signingKey });
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Get properties for signing a zome call to a cell.
|
|
20
|
+
*
|
|
21
|
+
* @param cellId - Cell id to be called.
|
|
22
|
+
* @returns The keys and cap secret required for signing a zome call.
|
|
23
|
+
*/
|
|
24
|
+
export const getSigningPropsForCell = (cellId) => {
|
|
25
|
+
const cellIdB64 = fromUint8Array(cellId[0]).concat(fromUint8Array(cellId[1]));
|
|
26
|
+
return signingProps.get(cellIdB64);
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=zome-call-signing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zome-call-signing.js","sourceRoot":"","sources":["../../src/api/zome-call-signing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAM3C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAExE,MAAM,YAAY,GAOd,IAAI,GAAG,EAAE,CAAC;AAEd;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,EAC7C,OAAuB,EACvB,MAAc,EACd,SAAqC,EACrC,EAAE;IACF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,sBAAsB,EAAE,CAAC;IACvD,MAAM,SAAS,GAAG,MAAM,eAAe,CACrC,OAAO,EACP,MAAM,EACN,SAAS,EACT,UAAU,CACX,CAAC;IACF,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,MAAc,EAAE,EAAE;IACvD,MAAM,SAAS,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,OAAO,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FunctionName, ZomeName } from "../api/index.js";
|
|
2
2
|
import { AgentPubKey } from "../types.js";
|
|
3
3
|
export declare type CapSecret = Uint8Array;
|
|
4
4
|
export interface CapClaim {
|
|
@@ -9,7 +9,7 @@ export interface CapClaim {
|
|
|
9
9
|
export interface ZomeCallCapGrant {
|
|
10
10
|
tag: string;
|
|
11
11
|
access: CapAccess;
|
|
12
|
-
functions: Array<[ZomeName,
|
|
12
|
+
functions: Array<[ZomeName, FunctionName]>;
|
|
13
13
|
}
|
|
14
14
|
export declare type CapAccess = "Unrestricted" | {
|
|
15
15
|
Transferable: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ActionHash, AgentPubKey, EntryHash, Signature, Timestamp } from "../types";
|
|
2
|
-
import { EntryType } from "./entry";
|
|
1
|
+
import { ActionHash, AgentPubKey, EntryHash, Signature, Timestamp } from "../types.js";
|
|
2
|
+
import { EntryType } from "./entry.js";
|
|
3
3
|
export interface CounterSigningSessionData {
|
|
4
4
|
preflight_request: PreflightRequest;
|
|
5
5
|
responses: Array<[CountersigningAgentState, Signature]>;
|
package/lib/types.d.ts
CHANGED
|
@@ -21,16 +21,10 @@ export interface HoloHashed<T> {
|
|
|
21
21
|
hash: HoloHash;
|
|
22
22
|
content: T;
|
|
23
23
|
}
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
op_count: InOut;
|
|
32
|
-
};
|
|
33
|
-
export declare type InOut = {
|
|
34
|
-
incoming: number;
|
|
35
|
-
outgoing: number;
|
|
36
|
-
};
|
|
24
|
+
export interface NetworkInfo {
|
|
25
|
+
fetch_queue_info: FetchQueueInfo;
|
|
26
|
+
}
|
|
27
|
+
export interface FetchQueueInfo {
|
|
28
|
+
op_bytes_to_fetch: number;
|
|
29
|
+
num_ops_to_fetch: number;
|
|
30
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holochain/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "A JavaScript client for the Holochain Conductor API",
|
|
5
5
|
"author": "Holochain Foundation <info@holochain.org> (http://holochain.org)",
|
|
6
6
|
"license": "CAL-1.0",
|
|
@@ -30,15 +30,21 @@
|
|
|
30
30
|
"files": [
|
|
31
31
|
"lib"
|
|
32
32
|
],
|
|
33
|
+
"browser": {
|
|
34
|
+
"crypto": false
|
|
35
|
+
},
|
|
33
36
|
"scripts": {
|
|
34
37
|
"lint": "eslint --fix --ext .ts src test .eslintrc.cjs",
|
|
35
38
|
"test": "RUST_LOG=error RUST_BACKTRACE=1 node --experimental-wasm-modules --loader ts-node/esm test/index.ts",
|
|
36
39
|
"build": "rimraf ./lib && tsc -p tsconfig.build.json"
|
|
37
40
|
},
|
|
38
41
|
"dependencies": {
|
|
42
|
+
"@holochain/serialization": "^0.1.0-beta-rc.0",
|
|
39
43
|
"@msgpack/msgpack": "^2.7.2",
|
|
44
|
+
"@tauri-apps/api": "^1.2.0",
|
|
40
45
|
"emittery": "^1.0.1",
|
|
41
46
|
"isomorphic-ws": "^5.0.0",
|
|
47
|
+
"js-base64": "^3.7.3",
|
|
42
48
|
"lodash-es": "^4.17.21",
|
|
43
49
|
"tweetnacl": "^1.0.3"
|
|
44
50
|
},
|