@holochain/client 0.19.0 → 0.19.2

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 CHANGED
@@ -38,7 +38,7 @@ import {
38
38
  CellType,
39
39
  type ActionHash,
40
40
  type CallZomeRequest,
41
- } from "@holochain/client";
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 (!(CellType.Provisioned in appInfo.cell_info[role_name][0])) {
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][CellType.Provisioned];
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 "@holochain/client";
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 (!(CellType.Provisioned in appInfo.cell_info[role_name][0])) {
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][CellType.Provisioned];
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();
@@ -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
- * No DHT locations are contained within this arc.
942
- */
943
- type: "empty";
944
- } | {
945
- /**
946
- * A specific range of DHT locations are contained within this arc.
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
  */
@@ -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"
@@ -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, AgentMetaInfoResponse, AppInfo, 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;
@@ -33,7 +35,6 @@ export declare class AppWebsocket implements AppClient {
33
35
  /**
34
36
  * Instance factory for creating an {@link AppWebsocket}.
35
37
  *
36
- * @param token - A token to authenticate the websocket connection. Get a token using AdminWebsocket#issueAppAuthenticationToken.
37
38
  * @param options - {@link (WebsocketConnectionOptions:interface)}
38
39
  * @returns A new instance of an AppWebsocket.
39
40
  */
@@ -45,6 +46,22 @@ export declare class AppWebsocket implements AppClient {
45
46
  * @returns The app's {@link AppInfo}.
46
47
  */
47
48
  appInfo(timeout?: number): Promise<AppInfo>;
49
+ /**
50
+ * Request the currently known agents of the app.
51
+ *
52
+ * @param req - An array of DNA hashes or null
53
+ * @param timeout - A timeout to override the default.
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
+ * @param timeout - A timeout to override the default.
62
+ * @returns The meta info stored for this peer URL.
63
+ */
64
+ agentMetaInfo(req: AgentMetaInfoRequest, timeout?: number): Promise<AgentMetaInfoResponse>;
48
65
  /**
49
66
  * Request network stats.
50
67
  *
@@ -90,14 +107,14 @@ export declare class AppWebsocket implements AppClient {
90
107
  * @param args - Specify the cell to clone.
91
108
  * @returns The created clone cell.
92
109
  */
93
- createCloneCell(args: CreateCloneCellRequest): Promise<ClonedCell>;
110
+ createCloneCell(args: CreateCloneCellRequest): Promise<import("../admin/types.js").ClonedCell>;
94
111
  /**
95
112
  * Enable a disabled clone cell.
96
113
  *
97
114
  * @param args - Specify the clone cell to enable.
98
115
  * @returns The enabled clone cell.
99
116
  */
100
- enableCloneCell(args: EnableCloneCellRequest): Promise<ClonedCell>;
117
+ enableCloneCell(args: EnableCloneCellRequest): Promise<import("../admin/types.js").ClonedCell>;
101
118
  /**
102
119
  * Disable an enabled clone cell.
103
120
  *
@@ -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);
@@ -71,7 +75,6 @@ export class AppWebsocket {
71
75
  /**
72
76
  * Instance factory for creating an {@link AppWebsocket}.
73
77
  *
74
- * @param token - A token to authenticate the websocket connection. Get a token using AdminWebsocket#issueAppAuthenticationToken.
75
78
  * @param options - {@link (WebsocketConnectionOptions:interface)}
76
79
  * @returns A new instance of an AppWebsocket.
77
80
  */
@@ -109,6 +112,26 @@ export class AppWebsocket {
109
112
  this.cachedAppInfo = appInfo;
110
113
  return appInfo;
111
114
  }
115
+ /**
116
+ * Request the currently known agents of the app.
117
+ *
118
+ * @param req - An array of DNA hashes or null
119
+ * @param timeout - A timeout to override the default.
120
+ * @returns The app's agent infos as JSON string.
121
+ */
122
+ async agentInfo(req, timeout) {
123
+ return await this.agentInfoRequester(req, timeout);
124
+ }
125
+ /**
126
+ * Request agent meta info for an agent by peer Url.
127
+ *
128
+ * @param req - The peer Url of the agent and an optional array of DNA hashes
129
+ * @param timeout - A timeout to override the default.
130
+ * @returns The meta info stored for this peer URL.
131
+ */
132
+ async agentMetaInfo(req, timeout) {
133
+ return await this.agentMetaInfoRequester(req, timeout);
134
+ }
112
135
  /**
113
136
  * Request network stats.
114
137
  *
@@ -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
@@ -25,7 +25,7 @@ export class WsClient extends Emittery {
25
25
  this.registerCloseListener(socket);
26
26
  this.socket = socket;
27
27
  this.url = url;
28
- this.options = options || {};
28
+ this.options = options;
29
29
  this.pendingRequests = {};
30
30
  this.index = 0;
31
31
  }
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.3"
8
+ "packageVersion": "7.52.8"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holochain/client",
3
- "version": "0.19.0",
3
+ "version": "0.19.2",
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",