@holochain/client 0.17.0-dev.9 → 0.18.0-dev.1
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 +3 -3
- package/lib/api/admin/types.d.ts +52 -22
- package/lib/api/admin/types.js +5 -5
- package/lib/api/admin/websocket.d.ts +4 -3
- package/lib/api/admin/websocket.js +5 -39
- package/lib/api/app/types.d.ts +76 -22
- package/lib/api/app/websocket.d.ts +49 -34
- package/lib/api/app/websocket.js +182 -53
- package/lib/api/client.d.ts +17 -0
- package/lib/api/client.js +24 -17
- package/lib/api/common.d.ts +3 -5
- package/lib/api/common.js +7 -8
- package/lib/api/index.d.ts +1 -2
- package/lib/api/index.js +1 -2
- package/lib/environments/launcher.d.ts +3 -5
- package/lib/environments/launcher.js +0 -60
- package/lib/hdk/capabilities.d.ts +3 -7
- package/lib/hdk/entry.d.ts +1 -5
- package/package.json +4 -4
- package/lib/api/app-agent/index.d.ts +0 -2
- package/lib/api/app-agent/index.js +0 -2
- package/lib/api/app-agent/types.d.ts +0 -59
- package/lib/api/app-agent/types.js +0 -1
- package/lib/api/app-agent/websocket.d.ts +0 -86
- package/lib/api/app-agent/websocket.js +0 -209
package/README.md
CHANGED
|
@@ -15,12 +15,12 @@ A JavaScript client for the Holochain Conductor API (works with browsers as well
|
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
|
|
18
|
-
**JS client v0.
|
|
19
|
-
|
|
20
|
-
**JS client v0.16.x** is compatible with **Holochain v0.2.x**.
|
|
18
|
+
**JS client v0.18.x** is compatible with **Holochain v0.4.x**.
|
|
21
19
|
|
|
22
20
|
**JS client v0.17.x** is compatible with **Holochain v0.3.x**.
|
|
23
21
|
|
|
22
|
+
**JS client v0.16.x** is compatible with **Holochain v0.2.x**.
|
|
23
|
+
|
|
24
24
|
To install from NPM, run
|
|
25
25
|
```bash
|
|
26
26
|
npm install --save-exact @holochain/client
|
package/lib/api/admin/types.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Action, DhtOp, Entry, ZomeCallCapGrant } from "../../hdk/index.js";
|
|
2
2
|
import { ActionHash, AgentPubKey, CellId, DnaHash, DnaProperties, Duration, HoloHash, HoloHashB64, InstalledAppId, KitsuneAgent, KitsuneSpace, RoleName, Signature, Timestamp, WasmHash } from "../../types.js";
|
|
3
3
|
import { Requester } from "../common.js";
|
|
4
|
-
import { DisableCloneCellRequest } from "../index.js";
|
|
5
4
|
/**
|
|
6
5
|
* @public
|
|
7
6
|
*/
|
|
@@ -12,6 +11,10 @@ export type AttachAppInterfaceRequest = {
|
|
|
12
11
|
* For example: `http://localhost:3000,http://localhost:3001`
|
|
13
12
|
*/
|
|
14
13
|
allowed_origins: string;
|
|
14
|
+
/**
|
|
15
|
+
* Optionally, bind this app interface to a specific installed app.
|
|
16
|
+
*/
|
|
17
|
+
installed_app_id?: InstalledAppId;
|
|
15
18
|
};
|
|
16
19
|
/**
|
|
17
20
|
* @public
|
|
@@ -35,11 +38,7 @@ export type EnableAppResponse = {
|
|
|
35
38
|
/**
|
|
36
39
|
* @public
|
|
37
40
|
*/
|
|
38
|
-
export type DeactivationReason = {
|
|
39
|
-
never_activated: null;
|
|
40
|
-
} | {
|
|
41
|
-
normal: null;
|
|
42
|
-
} | {
|
|
41
|
+
export type DeactivationReason = "never_activated" | "normal" | {
|
|
43
42
|
quarantined: {
|
|
44
43
|
error: string;
|
|
45
44
|
};
|
|
@@ -53,11 +52,7 @@ export type PausedAppReason = {
|
|
|
53
52
|
/**
|
|
54
53
|
* @public
|
|
55
54
|
*/
|
|
56
|
-
export type DisabledAppReason = {
|
|
57
|
-
never_started: null;
|
|
58
|
-
} | {
|
|
59
|
-
user: null;
|
|
60
|
-
} | {
|
|
55
|
+
export type DisabledAppReason = "never_started" | "user" | {
|
|
61
56
|
error: string;
|
|
62
57
|
};
|
|
63
58
|
/**
|
|
@@ -71,9 +66,7 @@ export type InstalledAppInfoStatus = {
|
|
|
71
66
|
disabled: {
|
|
72
67
|
reason: DisabledAppReason;
|
|
73
68
|
};
|
|
74
|
-
} |
|
|
75
|
-
running: null;
|
|
76
|
-
};
|
|
69
|
+
} | "running";
|
|
77
70
|
/**
|
|
78
71
|
* @public
|
|
79
72
|
*/
|
|
@@ -447,11 +440,11 @@ export type ListActiveAppsResponse = Array<InstalledAppId>;
|
|
|
447
440
|
* @public
|
|
448
441
|
*/
|
|
449
442
|
export declare enum AppStatusFilter {
|
|
450
|
-
Enabled = "
|
|
451
|
-
Disabled = "
|
|
452
|
-
Running = "
|
|
453
|
-
Stopped = "
|
|
454
|
-
Paused = "
|
|
443
|
+
Enabled = "Enabled",
|
|
444
|
+
Disabled = "Disabled",
|
|
445
|
+
Running = "Running",
|
|
446
|
+
Stopped = "Stopped",
|
|
447
|
+
Paused = "Paused"
|
|
455
448
|
}
|
|
456
449
|
/**
|
|
457
450
|
* @public
|
|
@@ -470,7 +463,15 @@ export type ListAppInterfacesRequest = void;
|
|
|
470
463
|
/**
|
|
471
464
|
* @public
|
|
472
465
|
*/
|
|
473
|
-
export type ListAppInterfacesResponse = Array<
|
|
466
|
+
export type ListAppInterfacesResponse = Array<AppInterfaceInfo>;
|
|
467
|
+
/**
|
|
468
|
+
* @public
|
|
469
|
+
*/
|
|
470
|
+
export interface AppInterfaceInfo {
|
|
471
|
+
port: number;
|
|
472
|
+
allowed_origins: string;
|
|
473
|
+
installed_app_id?: InstalledAppId;
|
|
474
|
+
}
|
|
474
475
|
/**
|
|
475
476
|
* This type is meant to be opaque
|
|
476
477
|
*
|
|
@@ -496,11 +497,20 @@ export type AddAgentInfoRequest = {
|
|
|
496
497
|
/**
|
|
497
498
|
* @public
|
|
498
499
|
*/
|
|
499
|
-
export type AddAgentInfoResponse =
|
|
500
|
+
export type AddAgentInfoResponse = unknown;
|
|
500
501
|
/**
|
|
501
502
|
* @public
|
|
502
503
|
*/
|
|
503
|
-
export
|
|
504
|
+
export interface DeleteCloneCellRequest {
|
|
505
|
+
/**
|
|
506
|
+
* The app id that the clone cell belongs to
|
|
507
|
+
*/
|
|
508
|
+
app_id: InstalledAppId;
|
|
509
|
+
/**
|
|
510
|
+
* The clone id or cell id of the clone cell
|
|
511
|
+
*/
|
|
512
|
+
clone_cell_id: RoleName | CellId;
|
|
513
|
+
}
|
|
504
514
|
/**
|
|
505
515
|
* @public
|
|
506
516
|
*/
|
|
@@ -719,6 +729,25 @@ export type StorageInfoRequest = void;
|
|
|
719
729
|
* @public
|
|
720
730
|
*/
|
|
721
731
|
export type StorageInfoResponse = StorageInfo;
|
|
732
|
+
/**
|
|
733
|
+
* @public
|
|
734
|
+
*/
|
|
735
|
+
export interface IssueAppAuthenticationTokenRequest {
|
|
736
|
+
installed_app_id: InstalledAppId;
|
|
737
|
+
expiry_seconds?: number;
|
|
738
|
+
single_use?: boolean;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* @public
|
|
742
|
+
*/
|
|
743
|
+
export type AppAuthenticationToken = number[];
|
|
744
|
+
/**
|
|
745
|
+
* @public
|
|
746
|
+
*/
|
|
747
|
+
export interface IssueAppAuthenticationTokenResponse {
|
|
748
|
+
token: AppAuthenticationToken;
|
|
749
|
+
expires_at?: Timestamp;
|
|
750
|
+
}
|
|
722
751
|
/**
|
|
723
752
|
* @public
|
|
724
753
|
*/
|
|
@@ -750,5 +779,6 @@ export interface AdminApi {
|
|
|
750
779
|
deleteCloneCell: Requester<DeleteCloneCellRequest, DeleteCloneCellResponse>;
|
|
751
780
|
grantZomeCallCapability: Requester<GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse>;
|
|
752
781
|
storageInfo: Requester<StorageInfoRequest, StorageInfoResponse>;
|
|
782
|
+
issueAppAuthenticationToken: Requester<IssueAppAuthenticationTokenRequest, IssueAppAuthenticationTokenResponse>;
|
|
753
783
|
dumpNetworkStats: Requester<DumpNetworkStatsRequest, DumpNetworkStatsResponse>;
|
|
754
784
|
}
|
package/lib/api/admin/types.js
CHANGED
|
@@ -46,9 +46,9 @@ export var CellProvisioningStrategy;
|
|
|
46
46
|
*/
|
|
47
47
|
export var AppStatusFilter;
|
|
48
48
|
(function (AppStatusFilter) {
|
|
49
|
-
AppStatusFilter["Enabled"] = "
|
|
50
|
-
AppStatusFilter["Disabled"] = "
|
|
51
|
-
AppStatusFilter["Running"] = "
|
|
52
|
-
AppStatusFilter["Stopped"] = "
|
|
53
|
-
AppStatusFilter["Paused"] = "
|
|
49
|
+
AppStatusFilter["Enabled"] = "Enabled";
|
|
50
|
+
AppStatusFilter["Disabled"] = "Disabled";
|
|
51
|
+
AppStatusFilter["Running"] = "Running";
|
|
52
|
+
AppStatusFilter["Stopped"] = "Stopped";
|
|
53
|
+
AppStatusFilter["Paused"] = "Paused";
|
|
54
54
|
})(AppStatusFilter || (AppStatusFilter = {}));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CapSecret, GrantedFunctions } from "../../hdk/
|
|
1
|
+
import { CapSecret, GrantedFunctions } from "../../hdk/index.js";
|
|
2
2
|
import type { AgentPubKey, CellId } from "../../types.js";
|
|
3
3
|
import { WsClient } from "../client.js";
|
|
4
|
-
import {
|
|
5
|
-
import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpNetworkStatsRequest, DumpNetworkStatsResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, StorageInfoRequest, StorageInfoResponse, UninstallAppRequest, UninstallAppResponse, UpdateCoordinatorsRequest, UpdateCoordinatorsResponse } from "./types.js";
|
|
4
|
+
import { Requester, Transformer, WebsocketConnectionOptions } from "../common.js";
|
|
5
|
+
import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpNetworkStatsRequest, DumpNetworkStatsResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, IssueAppAuthenticationTokenRequest, IssueAppAuthenticationTokenResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, StorageInfoRequest, StorageInfoResponse, UninstallAppRequest, UninstallAppResponse, UpdateCoordinatorsRequest, UpdateCoordinatorsResponse } from "./types.js";
|
|
6
6
|
/**
|
|
7
7
|
* A class for interacting with a conductor's Admin API.
|
|
8
8
|
*
|
|
@@ -107,6 +107,7 @@ export declare class AdminWebsocket implements AdminApi {
|
|
|
107
107
|
*/
|
|
108
108
|
grantZomeCallCapability: Requester<GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse>;
|
|
109
109
|
storageInfo: Requester<StorageInfoRequest, StorageInfoResponse>;
|
|
110
|
+
issueAppAuthenticationToken: Requester<IssueAppAuthenticationTokenRequest, IssueAppAuthenticationTokenResponse>;
|
|
110
111
|
dumpNetworkStats: Requester<DumpNetworkStatsRequest, DumpNetworkStatsResponse>;
|
|
111
112
|
/**
|
|
112
113
|
* Grant a capability for signing zome calls.
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { getLauncherEnvironment } from "../../environments/launcher.js";
|
|
2
|
-
import { GrantedFunctionsType, } from "../../hdk/
|
|
2
|
+
import { GrantedFunctionsType, } from "../../hdk/index.js";
|
|
3
3
|
import { WsClient } from "../client.js";
|
|
4
|
-
import {
|
|
4
|
+
import { DEFAULT_TIMEOUT, HolochainError, catchError, promiseTimeout, requesterTransformer, } from "../common.js";
|
|
5
5
|
import { generateSigningKeyPair, randomCapSecret, setSigningCredentials, } from "../zome-call-signing.js";
|
|
6
|
-
import { AppStatusFilter, } from "./types.js";
|
|
7
6
|
/**
|
|
8
7
|
* A class for interacting with a conductor's Admin API.
|
|
9
8
|
*
|
|
@@ -102,7 +101,7 @@ export class AdminWebsocket {
|
|
|
102
101
|
/**
|
|
103
102
|
* List all installed apps.
|
|
104
103
|
*/
|
|
105
|
-
listApps = this._requester("list_apps"
|
|
104
|
+
listApps = this._requester("list_apps");
|
|
106
105
|
/**
|
|
107
106
|
* List all attached app interfaces.
|
|
108
107
|
*/
|
|
@@ -125,6 +124,7 @@ export class AdminWebsocket {
|
|
|
125
124
|
*/
|
|
126
125
|
grantZomeCallCapability = this._requester("grant_zome_call_capability");
|
|
127
126
|
storageInfo = this._requester("storage_info");
|
|
127
|
+
issueAppAuthenticationToken = this._requester("issue_app_authentication_token");
|
|
128
128
|
dumpNetworkStats = this._requester("dump_network_stats");
|
|
129
129
|
// zome call signing related methods
|
|
130
130
|
/**
|
|
@@ -162,47 +162,13 @@ export class AdminWebsocket {
|
|
|
162
162
|
*/
|
|
163
163
|
authorizeSigningCredentials = async (cellId, functions) => {
|
|
164
164
|
const [keyPair, signingKey] = await generateSigningKeyPair();
|
|
165
|
-
const capSecret = await this.grantSigningKey(cellId, functions ||
|
|
165
|
+
const capSecret = await this.grantSigningKey(cellId, functions || GrantedFunctionsType.All, signingKey);
|
|
166
166
|
setSigningCredentials(cellId, { capSecret, keyPair, signingKey });
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
const listAppsTransform = {
|
|
170
|
-
input: (req) => {
|
|
171
|
-
const args = {};
|
|
172
|
-
if (req.status_filter) {
|
|
173
|
-
args.status_filter = getAppStatusInApiForm(req.status_filter);
|
|
174
|
-
}
|
|
175
|
-
return args;
|
|
176
|
-
},
|
|
177
|
-
output: (res) => res,
|
|
178
|
-
};
|
|
179
169
|
const dumpStateTransform = {
|
|
180
170
|
input: (req) => req,
|
|
181
171
|
output: (res) => {
|
|
182
172
|
return JSON.parse(res);
|
|
183
173
|
},
|
|
184
174
|
};
|
|
185
|
-
function getAppStatusInApiForm(status_filter) {
|
|
186
|
-
switch (status_filter) {
|
|
187
|
-
case AppStatusFilter.Running:
|
|
188
|
-
return {
|
|
189
|
-
Running: null,
|
|
190
|
-
};
|
|
191
|
-
case AppStatusFilter.Enabled:
|
|
192
|
-
return {
|
|
193
|
-
Enabled: null,
|
|
194
|
-
};
|
|
195
|
-
case AppStatusFilter.Paused:
|
|
196
|
-
return {
|
|
197
|
-
Paused: null,
|
|
198
|
-
};
|
|
199
|
-
case AppStatusFilter.Disabled:
|
|
200
|
-
return {
|
|
201
|
-
Disabled: null,
|
|
202
|
-
};
|
|
203
|
-
case AppStatusFilter.Stopped:
|
|
204
|
-
return {
|
|
205
|
-
Stopped: null,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
}
|
package/lib/api/app/types.d.ts
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AppInfo, ClonedCell, FunctionName, MembraneProof, NetworkSeed, ZomeName } from "
|
|
3
|
-
|
|
1
|
+
import { UnsubscribeFunction } from "emittery";
|
|
2
|
+
import { AgentPubKey, AppAuthenticationToken, AppInfo, CapSecret, CellId, ClonedCell, DnaHash, DnaProperties, FunctionName, InstalledAppId, MembraneProof, NetworkInfo, NetworkSeed, Nonce256Bit, RoleName, Timestamp, Transformer, WebsocketConnectionOptions, ZomeName } from "../../index.js";
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type NonProvenanceCallZomeRequest = Omit<CallZomeRequest, "provenance">;
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export type RoleNameCallZomeRequest = Omit<NonProvenanceCallZomeRequest, "cell_id"> & {
|
|
11
|
+
role_name: RoleName;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
*/
|
|
16
|
+
export type RoleNameCallZomeRequestSigned = Omit<CallZomeRequestSigned, "cell_id"> & {
|
|
17
|
+
role_name: RoleName;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @public
|
|
21
|
+
*/
|
|
22
|
+
export type AppCallZomeRequest = NonProvenanceCallZomeRequest | RoleNameCallZomeRequest | CallZomeRequestSigned | RoleNameCallZomeRequestSigned;
|
|
23
|
+
/**
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
export type AppCreateCloneCellRequest = Omit<CreateCloneCellRequest, "app_id">;
|
|
27
|
+
/**
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export type AppEnableCloneCellRequest = Omit<EnableCloneCellRequest, "app_id">;
|
|
31
|
+
/**
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export type AppDisableCloneCellRequest = Omit<DisableCloneCellRequest, "app_id">;
|
|
35
|
+
/**
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export type AppNetworkInfoRequest = Omit<NetworkInfoRequest, "agent_pub_key">;
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export interface AppEvents {
|
|
43
|
+
signal: AppSignal;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* @public
|
|
47
|
+
*/
|
|
48
|
+
export interface CallZomeRequestUnsigned extends CallZomeRequest {
|
|
49
|
+
cap_secret: CapSecret | null;
|
|
50
|
+
nonce: Nonce256Bit;
|
|
51
|
+
expires_at: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export interface CallZomeRequestSigned extends CallZomeRequestUnsigned {
|
|
57
|
+
signature: Uint8Array;
|
|
58
|
+
}
|
|
4
59
|
/**
|
|
5
60
|
* @public
|
|
6
61
|
*/
|
|
@@ -23,12 +78,6 @@ export type CallZomeResponseGeneric<Payload> = Payload;
|
|
|
23
78
|
* @public
|
|
24
79
|
*/
|
|
25
80
|
export type CallZomeResponse = CallZomeResponseGeneric<any>;
|
|
26
|
-
/**
|
|
27
|
-
* @public
|
|
28
|
-
*/
|
|
29
|
-
export type AppInfoRequest = {
|
|
30
|
-
installed_app_id: InstalledAppId;
|
|
31
|
-
};
|
|
32
81
|
/**
|
|
33
82
|
* @public
|
|
34
83
|
*/
|
|
@@ -37,10 +86,6 @@ export type AppInfoResponse = AppInfo | null;
|
|
|
37
86
|
* @public
|
|
38
87
|
*/
|
|
39
88
|
export interface CreateCloneCellRequest {
|
|
40
|
-
/**
|
|
41
|
-
* The app id that the DNA to clone belongs to
|
|
42
|
-
*/
|
|
43
|
-
app_id: InstalledAppId;
|
|
44
89
|
/**
|
|
45
90
|
* The DNA's role id to clone.
|
|
46
91
|
*/
|
|
@@ -88,10 +133,6 @@ export type CreateCloneCellResponse = ClonedCell;
|
|
|
88
133
|
* @public
|
|
89
134
|
*/
|
|
90
135
|
export interface DisableCloneCellRequest {
|
|
91
|
-
/**
|
|
92
|
-
* The app id that the clone cell belongs to
|
|
93
|
-
*/
|
|
94
|
-
app_id: InstalledAppId;
|
|
95
136
|
/**
|
|
96
137
|
* The clone id or cell id of the clone cell
|
|
97
138
|
*/
|
|
@@ -168,9 +209,22 @@ export type NetworkInfoResponse = NetworkInfo[];
|
|
|
168
209
|
/**
|
|
169
210
|
* @public
|
|
170
211
|
*/
|
|
171
|
-
export interface
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
212
|
+
export interface AppClient {
|
|
213
|
+
callZome(args: AppCallZomeRequest, timeout?: number): Promise<any>;
|
|
214
|
+
on<Name extends keyof AppEvents>(eventName: Name | readonly Name[], listener: AppSignalCb): UnsubscribeFunction;
|
|
215
|
+
appInfo(): Promise<AppInfoResponse>;
|
|
216
|
+
myPubKey: AgentPubKey;
|
|
217
|
+
installedAppId: InstalledAppId;
|
|
218
|
+
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
|
|
219
|
+
enableCloneCell(args: AppEnableCloneCellRequest): Promise<EnableCloneCellResponse>;
|
|
220
|
+
disableCloneCell(args: AppDisableCloneCellRequest): Promise<DisableCloneCellResponse>;
|
|
221
|
+
networkInfo(args: AppNetworkInfoRequest): Promise<NetworkInfoResponse>;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* @public
|
|
225
|
+
*/
|
|
226
|
+
export interface AppWebsocketConnectionOptions extends WebsocketConnectionOptions {
|
|
227
|
+
token?: AppAuthenticationToken;
|
|
228
|
+
callZomeTransform?: CallZomeTransform;
|
|
176
229
|
}
|
|
230
|
+
export type CallZomeTransform = Transformer<CallZomeRequest | CallZomeRequestSigned, Promise<CallZomeRequestSigned>, CallZomeResponseGeneric<Uint8Array>, CallZomeResponse>;
|
|
@@ -1,35 +1,52 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { UnsubscribeFunction } from "emittery";
|
|
2
|
+
import { AgentPubKey, CellId, InstalledAppId, RoleName } from "../../types.js";
|
|
3
|
+
import { AppInfo } from "../admin/index.js";
|
|
4
|
+
import { AppCallZomeRequest, AppClient, AppEvents, AppNetworkInfoRequest, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest, AppSignalCb, CallZomeRequest, CallZomeRequestSigned, CallZomeResponse, CreateCloneCellResponse, DisableCloneCellResponse, EnableCloneCellResponse, NetworkInfoResponse, AppWebsocketConnectionOptions } from "./types.js";
|
|
4
5
|
import { WsClient } from "../client.js";
|
|
5
|
-
import { WebsocketConnectionOptions, Requester, Transformer } from "../common.js";
|
|
6
|
-
import { Nonce256Bit } from "../zome-call-signing.js";
|
|
7
|
-
import { AppApi, AppInfoRequest, AppInfoResponse, CallZomeRequest, CallZomeResponse, CreateCloneCellRequest, CreateCloneCellResponse, DisableCloneCellRequest, DisableCloneCellResponse, EnableCloneCellRequest, EnableCloneCellResponse, NetworkInfoRequest, NetworkInfoResponse } from "./types.js";
|
|
8
6
|
/**
|
|
9
|
-
* A class to establish a websocket connection to an App interface
|
|
10
|
-
*
|
|
7
|
+
* A class to establish a websocket connection to an App interface, for a
|
|
8
|
+
* specific agent and app.
|
|
11
9
|
*
|
|
12
10
|
* @public
|
|
13
11
|
*/
|
|
14
|
-
export declare class AppWebsocket
|
|
12
|
+
export declare class AppWebsocket implements AppClient {
|
|
15
13
|
readonly client: WsClient;
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
readonly myPubKey: AgentPubKey;
|
|
15
|
+
readonly installedAppId: InstalledAppId;
|
|
16
|
+
private readonly defaultTimeout;
|
|
17
|
+
private readonly emitter;
|
|
18
|
+
private readonly callZomeTransform;
|
|
19
|
+
cachedAppInfo?: AppInfo | null;
|
|
20
|
+
private readonly appInfoRequester;
|
|
21
|
+
private readonly callZomeRequester;
|
|
22
|
+
private readonly createCloneCellRequester;
|
|
23
|
+
private readonly enableCloneCellRequester;
|
|
24
|
+
private readonly disableCloneCellRequester;
|
|
25
|
+
private readonly networkInfoRequester;
|
|
18
26
|
private constructor();
|
|
19
27
|
/**
|
|
20
|
-
* Instance factory for creating
|
|
28
|
+
* Instance factory for creating an {@link AppWebsocket}.
|
|
21
29
|
*
|
|
30
|
+
* @param token - A token to authenticate the websocket connection. Get a token using AdminWebsocket#issueAppAuthenticationToken.
|
|
22
31
|
* @param options - {@link (WebsocketConnectionOptions:interface)}
|
|
23
32
|
* @returns A new instance of an AppWebsocket.
|
|
24
33
|
*/
|
|
25
|
-
static connect(options?:
|
|
26
|
-
_requester<ReqI, ReqO, ResI, ResO>(tag: string, transformer?: Transformer<ReqI, ReqO, ResI, ResO>): (req: ReqI, timeout?: number | undefined) => Promise<ResO>;
|
|
34
|
+
static connect(options?: AppWebsocketConnectionOptions): Promise<AppWebsocket>;
|
|
27
35
|
/**
|
|
28
36
|
* Request the app's info, including all cell infos.
|
|
29
37
|
*
|
|
38
|
+
* @param timeout - A timeout to override the default.
|
|
30
39
|
* @returns The app's {@link AppInfo}.
|
|
31
40
|
*/
|
|
32
|
-
appInfo:
|
|
41
|
+
appInfo(timeout?: number): Promise<AppInfo>;
|
|
42
|
+
/**
|
|
43
|
+
* Get a cell id by its role name or clone id.
|
|
44
|
+
*
|
|
45
|
+
* @param roleName - The role name or clone id of the cell.
|
|
46
|
+
* @param appInfo - The app info containing all cell infos.
|
|
47
|
+
* @returns The cell id or throws an error if not found.
|
|
48
|
+
*/
|
|
49
|
+
getCellIdFromRoleName(roleName: RoleName, appInfo: AppInfo): CellId;
|
|
33
50
|
/**
|
|
34
51
|
* Call a zome.
|
|
35
52
|
*
|
|
@@ -37,45 +54,43 @@ export declare class AppWebsocket extends Emittery implements AppApi {
|
|
|
37
54
|
* @param timeout - A timeout to override the default.
|
|
38
55
|
* @returns The zome call's response.
|
|
39
56
|
*/
|
|
40
|
-
callZome:
|
|
57
|
+
callZome(request: AppCallZomeRequest, timeout?: number): Promise<CallZomeResponse>;
|
|
41
58
|
/**
|
|
42
59
|
* Clone an existing provisioned cell.
|
|
43
60
|
*
|
|
44
61
|
* @param args - Specify the cell to clone.
|
|
45
62
|
* @returns The created clone cell.
|
|
46
63
|
*/
|
|
47
|
-
createCloneCell:
|
|
64
|
+
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
|
|
48
65
|
/**
|
|
49
66
|
* Enable a disabled clone cell.
|
|
50
67
|
*
|
|
51
68
|
* @param args - Specify the clone cell to enable.
|
|
52
69
|
* @returns The enabled clone cell.
|
|
53
70
|
*/
|
|
54
|
-
enableCloneCell:
|
|
71
|
+
enableCloneCell(args: AppEnableCloneCellRequest): Promise<EnableCloneCellResponse>;
|
|
55
72
|
/**
|
|
56
73
|
* Disable an enabled clone cell.
|
|
57
74
|
*
|
|
58
75
|
* @param args - Specify the clone cell to disable.
|
|
59
76
|
*/
|
|
60
|
-
disableCloneCell:
|
|
77
|
+
disableCloneCell(args: AppDisableCloneCellRequest): Promise<DisableCloneCellResponse>;
|
|
61
78
|
/**
|
|
62
79
|
* Request network info about gossip status.
|
|
80
|
+
* @param args - Specify the DNAs for which you want network info
|
|
81
|
+
* @returns Network info for the specified DNAs
|
|
63
82
|
*/
|
|
64
|
-
networkInfo:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* @public
|
|
76
|
-
*/
|
|
77
|
-
export interface CallZomeRequestSigned extends CallZomeRequestUnsigned {
|
|
78
|
-
signature: Uint8Array;
|
|
83
|
+
networkInfo(args: AppNetworkInfoRequest): Promise<NetworkInfoResponse>;
|
|
84
|
+
/**
|
|
85
|
+
* Register an event listener for signals.
|
|
86
|
+
*
|
|
87
|
+
* @param eventName - Event name to listen to (currently only "signal").
|
|
88
|
+
* @param listener - The function to call when event is triggered.
|
|
89
|
+
* @returns A function to unsubscribe the event listener.
|
|
90
|
+
*/
|
|
91
|
+
on<Name extends keyof AppEvents>(eventName: Name | readonly Name[], listener: AppSignalCb): UnsubscribeFunction;
|
|
92
|
+
private static requester;
|
|
93
|
+
private containsCell;
|
|
79
94
|
}
|
|
80
95
|
/**
|
|
81
96
|
* @public
|