@holochain/client 0.19.0 → 0.19.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 +15 -11
- package/lib/api/admin/types.d.ts +27 -14
- package/lib/api/admin/websocket.d.ts +5 -1
- package/lib/api/admin/websocket.js +4 -0
- package/lib/api/app/types.d.ts +9 -0
- package/lib/api/app/types.js +3 -0
- package/lib/api/app/websocket.d.ts +18 -2
- package/lib/api/app/websocket.js +24 -0
- package/lib/api/client.d.ts +1 -1
- package/lib/api/client.js +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ import {
|
|
|
38
38
|
CellType,
|
|
39
39
|
type ActionHash,
|
|
40
40
|
type CallZomeRequest,
|
|
41
|
-
} from "
|
|
41
|
+
} from "./lib/index.js";
|
|
42
42
|
|
|
43
43
|
const adminWs = await AdminWebsocket.connect({
|
|
44
44
|
url: new URL("ws://127.0.0.1:65000"),
|
|
@@ -48,16 +48,18 @@ const agent_key = await adminWs.generateAgentPubKey();
|
|
|
48
48
|
const role_name = "foo";
|
|
49
49
|
const installed_app_id = "test-app";
|
|
50
50
|
const appInfo = await adminWs.installApp({
|
|
51
|
+
source: {
|
|
52
|
+
type: "path",
|
|
53
|
+
value: "./test/e2e/fixture/test.happ",
|
|
54
|
+
},
|
|
51
55
|
agent_key,
|
|
52
|
-
path: "./test/e2e/fixture/test.happ",
|
|
53
56
|
installed_app_id,
|
|
54
|
-
membrane_proofs: {},
|
|
55
57
|
});
|
|
56
58
|
await adminWs.enableApp({ installed_app_id });
|
|
57
|
-
if (
|
|
59
|
+
if (appInfo.cell_info[role_name][0].type !== CellType.Provisioned) {
|
|
58
60
|
throw new Error(`No cell found under role name ${role_name}`);
|
|
59
61
|
}
|
|
60
|
-
const { cell_id } = appInfo.cell_info[role_name][0]
|
|
62
|
+
const { cell_id } = appInfo.cell_info[role_name][0].value;
|
|
61
63
|
await adminWs.authorizeSigningCredentials(cell_id);
|
|
62
64
|
await adminWs.attachAppInterface({ port: 65001, allowed_origins: "my-happ" });
|
|
63
65
|
const issuedToken = await adminWs.issueAppAuthenticationToken({
|
|
@@ -86,7 +88,7 @@ await adminWs.client.close();
|
|
|
86
88
|
|
|
87
89
|
### Subscribe to signals
|
|
88
90
|
```typescript
|
|
89
|
-
import { AdminWebsocket, AppWebsocket, CellType } from "
|
|
91
|
+
import { AdminWebsocket, AppWebsocket, CellType, Signal } from "./lib/index.js";
|
|
90
92
|
|
|
91
93
|
const adminWs = await AdminWebsocket.connect({
|
|
92
94
|
url: new URL("ws://127.0.0.1:65000"),
|
|
@@ -96,16 +98,18 @@ const agent_key = await adminWs.generateAgentPubKey();
|
|
|
96
98
|
const role_name = "foo";
|
|
97
99
|
const installed_app_id = "test-app";
|
|
98
100
|
const appInfo = await adminWs.installApp({
|
|
101
|
+
source: {
|
|
102
|
+
type: "path",
|
|
103
|
+
value: "./test/e2e/fixture/test.happ",
|
|
104
|
+
},
|
|
99
105
|
agent_key,
|
|
100
|
-
path: "./test/e2e/fixture/test.happ",
|
|
101
106
|
installed_app_id,
|
|
102
|
-
membrane_proofs: {},
|
|
103
107
|
});
|
|
104
108
|
await adminWs.enableApp({ installed_app_id });
|
|
105
|
-
if (
|
|
109
|
+
if (appInfo.cell_info[role_name][0].type !== CellType.Provisioned) {
|
|
106
110
|
throw new Error(`No cell found under role name ${role_name}`);
|
|
107
111
|
}
|
|
108
|
-
const { cell_id } = appInfo.cell_info[role_name][0]
|
|
112
|
+
const { cell_id } = appInfo.cell_info[role_name][0].value;
|
|
109
113
|
await adminWs.authorizeSigningCredentials(cell_id);
|
|
110
114
|
await adminWs.attachAppInterface({ port: 65001, allowed_origins: "my-happ" });
|
|
111
115
|
const issuedToken = await adminWs.issueAppAuthenticationToken({
|
|
@@ -119,7 +123,7 @@ const appWs = await AppWebsocket.connect({
|
|
|
119
123
|
|
|
120
124
|
let signalCb;
|
|
121
125
|
const signalReceived = new Promise<void>((resolve) => {
|
|
122
|
-
signalCb = (signal) => {
|
|
126
|
+
signalCb = (signal: Signal) => {
|
|
123
127
|
console.log("signal received", signal);
|
|
124
128
|
// act on signal
|
|
125
129
|
resolve();
|
package/lib/api/admin/types.d.ts
CHANGED
|
@@ -573,6 +573,24 @@ export type AddAgentInfoRequest = {
|
|
|
573
573
|
* @public
|
|
574
574
|
*/
|
|
575
575
|
export type AddAgentInfoResponse = unknown;
|
|
576
|
+
/**
|
|
577
|
+
* @public
|
|
578
|
+
*/
|
|
579
|
+
export interface AgentMetaInfoRequest {
|
|
580
|
+
url: string;
|
|
581
|
+
dna_hashes?: DnaHash[];
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* @public
|
|
585
|
+
*/
|
|
586
|
+
export type AgentMetaInfoResponse = Record<DnaHashB64, Record<string, AgentMetaInfo>>;
|
|
587
|
+
/**
|
|
588
|
+
* @public
|
|
589
|
+
*/
|
|
590
|
+
export interface AgentMetaInfo {
|
|
591
|
+
meta_value: string;
|
|
592
|
+
expires_at: number;
|
|
593
|
+
}
|
|
576
594
|
/**
|
|
577
595
|
* @public
|
|
578
596
|
*/
|
|
@@ -936,20 +954,15 @@ export interface DumpNetworkMetricsRequest {
|
|
|
936
954
|
*
|
|
937
955
|
* @public
|
|
938
956
|
*/
|
|
939
|
-
export type DhtArc =
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
* The lower and upper bounds are inclusive.
|
|
949
|
-
*/
|
|
950
|
-
type: "arc";
|
|
951
|
-
value: [number, number];
|
|
952
|
-
};
|
|
957
|
+
export type DhtArc = /**
|
|
958
|
+
* No DHT locations are contained within this arc.
|
|
959
|
+
*/ null
|
|
960
|
+
/**
|
|
961
|
+
* A specific range of DHT locations are contained within this arc.
|
|
962
|
+
*
|
|
963
|
+
* The lower and upper bounds are inclusive.
|
|
964
|
+
*/
|
|
965
|
+
| [number, number];
|
|
953
966
|
/**
|
|
954
967
|
* Summary of a local agent's network state.
|
|
955
968
|
*
|
|
@@ -2,7 +2,7 @@ import { CapSecret, GrantedFunctions } from "../../hdk/index.js";
|
|
|
2
2
|
import type { AgentPubKey, CellId } from "../../types.js";
|
|
3
3
|
import { WsClient } from "../client.js";
|
|
4
4
|
import { Requester, Transformer, WebsocketConnectionOptions } from "../common.js";
|
|
5
|
-
import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpNetworkMetricsRequest, DumpNetworkMetricsResponse, 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, RevokeAgentKeyRequest, RevokeAgentKeyResponse, StorageInfoRequest, StorageInfoResponse, UninstallAppRequest, UninstallAppResponse, UpdateCoordinatorsRequest, UpdateCoordinatorsResponse } from "./types.js";
|
|
5
|
+
import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AgentMetaInfoResponse, AgentMetaInfoRequest, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpNetworkMetricsRequest, DumpNetworkMetricsResponse, 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, RevokeAgentKeyRequest, RevokeAgentKeyResponse, 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
|
*
|
|
@@ -101,6 +101,10 @@ export declare class AdminWebsocket implements AdminApi {
|
|
|
101
101
|
* Add an existing agent to Holochain.
|
|
102
102
|
*/
|
|
103
103
|
addAgentInfo: Requester<AddAgentInfoRequest, AddAgentInfoResponse>;
|
|
104
|
+
/**
|
|
105
|
+
* Request agent meta info about an agent.
|
|
106
|
+
*/
|
|
107
|
+
agentMetaInfo: Requester<AgentMetaInfoRequest, AgentMetaInfoResponse>;
|
|
104
108
|
/**
|
|
105
109
|
* Delete a disabled clone cell.
|
|
106
110
|
*/
|
|
@@ -117,6 +117,10 @@ export class AdminWebsocket {
|
|
|
117
117
|
* Add an existing agent to Holochain.
|
|
118
118
|
*/
|
|
119
119
|
addAgentInfo = this._requester("add_agent_info");
|
|
120
|
+
/**
|
|
121
|
+
* Request agent meta info about an agent.
|
|
122
|
+
*/
|
|
123
|
+
agentMetaInfo = this._requester("agent_meta_info");
|
|
120
124
|
/**
|
|
121
125
|
* Delete a disabled clone cell.
|
|
122
126
|
*/
|
package/lib/api/app/types.d.ts
CHANGED
|
@@ -48,6 +48,12 @@ export type CallZomeResponse = CallZomeResponseGeneric<any>;
|
|
|
48
48
|
* @public
|
|
49
49
|
*/
|
|
50
50
|
export type AppInfoResponse = AppInfo | null;
|
|
51
|
+
/**
|
|
52
|
+
* @public
|
|
53
|
+
*/
|
|
54
|
+
export type AppAgentInfoRequest = {
|
|
55
|
+
dna_hashes: DnaHash[] | null;
|
|
56
|
+
};
|
|
51
57
|
/**
|
|
52
58
|
* @public
|
|
53
59
|
*/
|
|
@@ -345,6 +351,9 @@ export declare enum SessionCompletionDecisionType {
|
|
|
345
351
|
export type SessionCompletionDecision = {
|
|
346
352
|
[SessionCompletionDecisionType.Complete]: SignedActionHashed;
|
|
347
353
|
} | SessionCompletionDecisionType.Abandoned | SessionCompletionDecisionType.Indeterminate | SessionCompletionDecisionType.Failed;
|
|
354
|
+
/**
|
|
355
|
+
* @public
|
|
356
|
+
*/
|
|
348
357
|
export declare enum SignalType {
|
|
349
358
|
App = "app",
|
|
350
359
|
System = "system"
|
package/lib/api/app/types.js
CHANGED
|
@@ -45,6 +45,9 @@ export var SessionCompletionDecisionType;
|
|
|
45
45
|
*/
|
|
46
46
|
SessionCompletionDecisionType["Failed"] = "Failed";
|
|
47
47
|
})(SessionCompletionDecisionType || (SessionCompletionDecisionType = {}));
|
|
48
|
+
/**
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
48
51
|
export var SignalType;
|
|
49
52
|
(function (SignalType) {
|
|
50
53
|
SignalType["App"] = "app";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { UnsubscribeFunction } from "emittery";
|
|
2
2
|
import { AgentPubKey, InstalledAppId, RoleName } from "../../types.js";
|
|
3
|
-
import { AppInfo, ClonedCell, DumpNetworkMetricsRequest, DumpNetworkMetricsResponse, DumpNetworkStatsResponse, MemproofMap } from "../admin/index.js";
|
|
3
|
+
import { AgentInfoResponse, AgentMetaInfoRequest, AppInfo, ClonedCell, DumpNetworkMetricsRequest, DumpNetworkMetricsResponse, DumpNetworkStatsResponse, MemproofMap } from "../admin/index.js";
|
|
4
4
|
import { WsClient } from "../client.js";
|
|
5
|
-
import { AbandonCountersigningSessionStateRequest, AppClient, AppEvents, AppWebsocketConnectionOptions, CallZomeRequest, CallZomeRequestSigned, CreateCloneCellRequest, DisableCloneCellRequest, EnableCloneCellRequest, GetCountersigningSessionStateRequest, GetCountersigningSessionStateResponse, PublishCountersigningSessionStateRequest, RoleNameCallZomeRequest, SignalCb } from "./types.js";
|
|
5
|
+
import { AbandonCountersigningSessionStateRequest, AppAgentInfoRequest, AppClient, AppEvents, AppWebsocketConnectionOptions, CallZomeRequest, CallZomeRequestSigned, CreateCloneCellRequest, DisableCloneCellRequest, EnableCloneCellRequest, GetCountersigningSessionStateRequest, GetCountersigningSessionStateResponse, PublishCountersigningSessionStateRequest, RoleNameCallZomeRequest, SignalCb } from "./types.js";
|
|
6
6
|
/**
|
|
7
7
|
* A class to establish a websocket connection to an App interface, for a
|
|
8
8
|
* specific agent and app.
|
|
@@ -18,6 +18,8 @@ export declare class AppWebsocket implements AppClient {
|
|
|
18
18
|
private readonly callZomeTransform;
|
|
19
19
|
cachedAppInfo?: AppInfo | null;
|
|
20
20
|
private readonly appInfoRequester;
|
|
21
|
+
private readonly agentInfoRequester;
|
|
22
|
+
private readonly agentMetaInfoRequester;
|
|
21
23
|
private readonly callZomeRequester;
|
|
22
24
|
private readonly provideMemproofRequester;
|
|
23
25
|
private readonly enableAppRequester;
|
|
@@ -45,6 +47,20 @@ export declare class AppWebsocket implements AppClient {
|
|
|
45
47
|
* @returns The app's {@link AppInfo}.
|
|
46
48
|
*/
|
|
47
49
|
appInfo(timeout?: number): Promise<AppInfo>;
|
|
50
|
+
/**
|
|
51
|
+
* Request the currently known agents of the app.
|
|
52
|
+
*
|
|
53
|
+
* @param req - An array of DNA hashes or null
|
|
54
|
+
* @returns The app's agent infos as JSON string.
|
|
55
|
+
*/
|
|
56
|
+
agentInfo(req: AppAgentInfoRequest, timeout?: number): Promise<AgentInfoResponse>;
|
|
57
|
+
/**
|
|
58
|
+
* Request agent meta info for an agent by peer Url.
|
|
59
|
+
*
|
|
60
|
+
* @param req - The peer Url of the agent and an optional array of DNA hashes
|
|
61
|
+
* @returns The app's agent infos as JSON string.
|
|
62
|
+
*/
|
|
63
|
+
agentMetaInfo(req: AgentMetaInfoRequest, timeout?: number): Promise<AgentInfoResponse>;
|
|
48
64
|
/**
|
|
49
65
|
* Request network stats.
|
|
50
66
|
*
|
package/lib/api/app/websocket.js
CHANGED
|
@@ -24,6 +24,8 @@ export class AppWebsocket {
|
|
|
24
24
|
callZomeTransform;
|
|
25
25
|
cachedAppInfo;
|
|
26
26
|
appInfoRequester;
|
|
27
|
+
agentInfoRequester;
|
|
28
|
+
agentMetaInfoRequester;
|
|
27
29
|
callZomeRequester;
|
|
28
30
|
provideMemproofRequester;
|
|
29
31
|
enableAppRequester;
|
|
@@ -44,6 +46,8 @@ export class AppWebsocket {
|
|
|
44
46
|
this.emitter = new Emittery();
|
|
45
47
|
this.cachedAppInfo = appInfo;
|
|
46
48
|
this.appInfoRequester = AppWebsocket.requester(this.client, "app_info", this.defaultTimeout);
|
|
49
|
+
this.agentInfoRequester = AppWebsocket.requester(this.client, "agent_info", this.defaultTimeout);
|
|
50
|
+
this.agentMetaInfoRequester = AppWebsocket.requester(this.client, "agent_meta_info", this.defaultTimeout);
|
|
47
51
|
this.callZomeRequester = AppWebsocket.requester(this.client, "call_zome", this.defaultTimeout, this.callZomeTransform);
|
|
48
52
|
this.provideMemproofRequester = AppWebsocket.requester(this.client, "provide_memproofs", this.defaultTimeout);
|
|
49
53
|
this.enableAppRequester = AppWebsocket.requester(this.client, "enable_app", this.defaultTimeout);
|
|
@@ -109,6 +113,26 @@ export class AppWebsocket {
|
|
|
109
113
|
this.cachedAppInfo = appInfo;
|
|
110
114
|
return appInfo;
|
|
111
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Request the currently known agents of the app.
|
|
118
|
+
*
|
|
119
|
+
* @param req - An array of DNA hashes or null
|
|
120
|
+
* @returns The app's agent infos as JSON string.
|
|
121
|
+
*/
|
|
122
|
+
async agentInfo(req, timeout) {
|
|
123
|
+
const agentInfos = await this.agentInfoRequester(req, timeout);
|
|
124
|
+
return agentInfos;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Request agent meta info for an agent by peer Url.
|
|
128
|
+
*
|
|
129
|
+
* @param req - The peer Url of the agent and an optional array of DNA hashes
|
|
130
|
+
* @returns The app's agent infos as JSON string.
|
|
131
|
+
*/
|
|
132
|
+
async agentMetaInfo(req, timeout) {
|
|
133
|
+
const agentInfos = await this.agentMetaInfoRequester(req, timeout);
|
|
134
|
+
return agentInfos;
|
|
135
|
+
}
|
|
112
136
|
/**
|
|
113
137
|
* Request network stats.
|
|
114
138
|
*
|
package/lib/api/client.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export interface AppAuthenticationRequest {
|
|
|
20
20
|
export declare class WsClient extends Emittery {
|
|
21
21
|
socket: IsoWebSocket;
|
|
22
22
|
url: URL | undefined;
|
|
23
|
-
options: WsClientOptions;
|
|
23
|
+
options: WsClientOptions | undefined;
|
|
24
24
|
private pendingRequests;
|
|
25
25
|
private index;
|
|
26
26
|
private authenticationToken;
|
package/lib/api/client.js
CHANGED
package/lib/tsdoc-metadata.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@holochain/client",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.1",
|
|
4
4
|
"description": "A JavaScript client for the Holochain Conductor API",
|
|
5
5
|
"author": "Holochain Foundation <info@holochain.org> (https://holochain.org)",
|
|
6
6
|
"license": "CAL-1.0",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://github.com/holochain/holochain-client-js#readme",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=18.0.0 || >=20.0.0"
|
|
21
|
+
"node": ">=18.0.0 || >=20.0.0 || >=22.0.0"
|
|
22
22
|
},
|
|
23
23
|
"main": "lib/index.js",
|
|
24
24
|
"module": "lib/index.js",
|