@holochain/client 0.11.14 → 0.11.16

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
@@ -8,6 +8,8 @@
8
8
 
9
9
  A JavaScript client for the Holochain Conductor API (works with browsers as well as Nodejs).
10
10
 
11
+ ## API Reference
12
+
11
13
  [Complete API reference](./docs/client.md)
12
14
 
13
15
  ## Installation
@@ -21,12 +23,6 @@ npm install --save-exact @holochain/client
21
23
 
22
24
  ## Sample usage
23
25
 
24
- ### Use AdminWebsocket
25
- ```typescript
26
- const admin = await AdminWebsocket.connect(`ws://127.0.0.1:8000`, TIMEOUT)
27
- const agentPubKey = await admin.generateAgentPubKey()
28
- ```
29
-
30
26
  ### Use AppAgentWebsocket with implicit zome call signing
31
27
  ```typescript
32
28
  const signalCb = (signal: AppSignal) => {
@@ -100,17 +96,12 @@ setSigningCredentials(cell_id, signingCredentials);
100
96
  localStorage.setItem(cellIdB64, JSON.stringify(signingCredentials));
101
97
  ```
102
98
 
103
- ## API Reference
104
-
105
- See [docs/API.md](docs/API.md)
106
-
107
-
108
99
  # Holochain Compatibility
109
100
 
110
101
  See [default.nix](./default.nix) for the Holochain version this package is compatible with.
111
102
 
112
103
  If updating the Holochain version included in holonix, please use `niv update` as explained in the
113
- [Holochain Installation Guide](https://developer.holochain.org/install/#upgrading-the-holochain-version).
104
+ [Holochain Installation Guide](https://developer.holochain.org/install-advanced/#upgrading-the-holochain-version).
114
105
 
115
106
  ## Running tests
116
107
 
@@ -81,9 +81,18 @@ export interface StemCell {
81
81
  /**
82
82
  * @public
83
83
  */
84
- export interface Cell {
84
+ export interface ProvisionedCell {
85
85
  cell_id: CellId;
86
- clone_id?: RoleName;
86
+ dna_modifiers: DnaModifiers;
87
+ name: string;
88
+ }
89
+ /**
90
+ * @public
91
+ */
92
+ export interface ClonedCell {
93
+ cell_id: CellId;
94
+ clone_id: RoleName;
95
+ original_dna_hash: DnaHash;
87
96
  dna_modifiers: DnaModifiers;
88
97
  name: string;
89
98
  enabled: boolean;
@@ -92,17 +101,17 @@ export interface Cell {
92
101
  * @public
93
102
  */
94
103
  export declare enum CellType {
95
- Provisioned = "Provisioned",
96
- Cloned = "Cloned",
97
- Stem = "Stem"
104
+ Provisioned = "provisioned",
105
+ Cloned = "cloned",
106
+ Stem = "stem"
98
107
  }
99
108
  /**
100
109
  * @public
101
110
  */
102
111
  export declare type CellInfo = {
103
- [CellType.Provisioned]: Cell;
112
+ [CellType.Provisioned]: ProvisionedCell;
104
113
  } | {
105
- [CellType.Cloned]: Cell;
114
+ [CellType.Cloned]: ClonedCell;
106
115
  } | {
107
116
  [CellType.Stem]: StemCell;
108
117
  };
@@ -110,6 +119,7 @@ export declare type CellInfo = {
110
119
  * @public
111
120
  */
112
121
  export declare type AppInfo = {
122
+ agent_pub_key: AgentPubKey;
113
123
  installed_app_id: InstalledAppId;
114
124
  cell_info: Record<RoleName, Array<CellInfo>>;
115
125
  status: InstalledAppInfoStatus;
@@ -245,7 +255,7 @@ export declare type UninstallAppResponse = null;
245
255
  /**
246
256
  * @public
247
257
  */
248
- export declare type ResourceBytes = number[];
258
+ export declare type ResourceBytes = Uint8Array;
249
259
  /**
250
260
  * @public
251
261
  */
@@ -621,7 +631,6 @@ export interface AdminApi {
621
631
  attachAppInterface: Requester<AttachAppInterfaceRequest, AttachAppInterfaceResponse>;
622
632
  enableApp: Requester<EnableAppRequest, EnableAppResponse>;
623
633
  disableApp: Requester<DisableAppRequest, DisableAppResponse>;
624
- startApp: Requester<StartAppRequest, StartAppResponse>;
625
634
  dumpState: Requester<DumpStateRequest, DumpStateResponse>;
626
635
  dumpFullState: Requester<DumpFullStateRequest, DumpFullStateResponse>;
627
636
  generateAgentPubKey: Requester<GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse>;
@@ -3,9 +3,9 @@
3
3
  */
4
4
  export var CellType;
5
5
  (function (CellType) {
6
- CellType["Provisioned"] = "Provisioned";
7
- CellType["Cloned"] = "Cloned";
8
- CellType["Stem"] = "Stem";
6
+ CellType["Provisioned"] = "provisioned";
7
+ CellType["Cloned"] = "cloned";
8
+ CellType["Stem"] = "stem";
9
9
  })(CellType || (CellType = {}));
10
10
  /**
11
11
  * @public
@@ -2,7 +2,7 @@ import { CapSecret, GrantedFunctions } from "../../hdk/capabilities.js";
2
2
  import type { AgentPubKey, CellId } from "../../types.js";
3
3
  import { WsClient } from "../client.js";
4
4
  import { Requester, Transformer } from "../common.js";
5
- import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, StartAppRequest, StartAppResponse, UninstallAppRequest, UninstallAppResponse } from "./types.js";
5
+ import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, UninstallAppRequest, UninstallAppResponse } from "./types.js";
6
6
  /**
7
7
  * A class for interacting with a conductor's Admin API.
8
8
  *
@@ -39,10 +39,6 @@ export declare class AdminWebsocket implements AdminApi {
39
39
  * Disable a running app.
40
40
  */
41
41
  disableApp: Requester<DisableAppRequest, DisableAppResponse>;
42
- /**
43
- * Start an app.
44
- */
45
- startApp: Requester<StartAppRequest, StartAppResponse>;
46
42
  /**
47
43
  * Dump the state of the specified cell, including its source chain, as JSON.
48
44
  */
@@ -54,10 +54,6 @@ export class AdminWebsocket {
54
54
  * Disable a running app.
55
55
  */
56
56
  disableApp = this._requester("disable_app");
57
- /**
58
- * Start an app.
59
- */
60
- startApp = this._requester("start_app");
61
57
  /**
62
58
  * Dump the state of the specified cell, including its source chain, as JSON.
63
59
  */
@@ -1,5 +1,5 @@
1
- import { AgentPubKey, CellId, DnaHash, DnaProperties, InstalledAppId, InstalledCell, NetworkInfo, RoleName, Timestamp } from "../../types.js";
2
- import { AppInfo, FunctionName, MembraneProof, NetworkSeed, ZomeName } from "../admin/index.js";
1
+ import { AgentPubKey, CellId, DnaHash, DnaProperties, InstalledAppId, NetworkInfo, RoleName, Timestamp } from "../../types.js";
2
+ import { AppInfo, ClonedCell, FunctionName, MembraneProof, NetworkSeed, ZomeName } from "../admin/index.js";
3
3
  import { Requester } from "../common.js";
4
4
  /**
5
5
  * @public
@@ -83,7 +83,7 @@ export interface CreateCloneCellRequest {
83
83
  /**
84
84
  * @public
85
85
  */
86
- export declare type CreateCloneCellResponse = InstalledCell;
86
+ export declare type CreateCloneCellResponse = ClonedCell;
87
87
  /**
88
88
  * @public
89
89
  */
@@ -9,10 +9,10 @@ import { AppAgentCallZomeRequest, AppAgentClient, AppAgentEvents, AppCreateClone
9
9
  * @public
10
10
  */
11
11
  export declare class AppAgentWebsocket implements AppAgentClient {
12
- myPubKey: AgentPubKey;
13
12
  readonly appWebsocket: AppWebsocket;
14
13
  installedAppId: InstalledAppId;
15
14
  cachedAppInfo?: AppInfo;
15
+ myPubKey: AgentPubKey;
16
16
  readonly emitter: Emittery<AppAgentEvents>;
17
17
  private constructor();
18
18
  /**
@@ -3,21 +3,6 @@ import { omit } from "lodash-es";
3
3
  import { getLauncherEnvironment } from "../../environments/launcher.js";
4
4
  import { getBaseRoleNameFromCloneId, isCloneId } from "../common.js";
5
5
  import { AppWebsocket, CellType, } from "../index.js";
6
- function getPubKey(appInfo) {
7
- // This is fine for now cause `UseExisting` as a provisioning strategy doesn't work yet.
8
- // TODO: change this when AppInfo contains the `AgentPubKey` for this app, like `return appInfo.my_pub_key`
9
- for (const cells of Object.values(appInfo.cell_info)) {
10
- for (const cell of cells) {
11
- if (CellType.Provisioned in cell) {
12
- return cell.Provisioned.cell_id[1];
13
- }
14
- else if (CellType.Cloned in cell) {
15
- return cell.Cloned.cell_id[1];
16
- }
17
- }
18
- }
19
- throw new Error(`This app doesn't have any cells, so we can't return the agent public key for it. This is a known issue, and is going to be fixed in the near future.`);
20
- }
21
6
  /**
22
7
  * A class to establish a websocket connection to an App interface, for a
23
8
  * specific agent and app.
@@ -25,17 +10,17 @@ function getPubKey(appInfo) {
25
10
  * @public
26
11
  */
27
12
  export class AppAgentWebsocket {
28
- myPubKey;
29
13
  appWebsocket;
30
14
  installedAppId;
31
15
  cachedAppInfo;
16
+ myPubKey;
32
17
  emitter;
33
18
  constructor(appWebsocket, installedAppId, myPubKey) {
34
- this.myPubKey = myPubKey;
35
19
  this.appWebsocket = appWebsocket;
36
20
  this.emitter = new Emittery();
37
21
  const env = getLauncherEnvironment();
38
22
  this.installedAppId = env?.INSTALLED_APP_ID || installedAppId;
23
+ this.myPubKey = myPubKey;
39
24
  this.appWebsocket.on("signal", (signal) => {
40
25
  if (this.containsCell(signal.cell_id)) {
41
26
  this.emitter.emit("signal", signal);
@@ -67,8 +52,7 @@ export class AppAgentWebsocket {
67
52
  const appInfo = await appWebsocket.appInfo({
68
53
  installed_app_id: installed_app_id,
69
54
  });
70
- const myPubKey = getPubKey(appInfo);
71
- const appAgentWs = new AppAgentWebsocket(appWebsocket, installed_app_id, myPubKey);
55
+ const appAgentWs = new AppAgentWebsocket(appWebsocket, installed_app_id, appInfo.agent_pub_key);
72
56
  appAgentWs.cachedAppInfo = appInfo;
73
57
  return appAgentWs;
74
58
  }
@@ -85,11 +69,11 @@ export class AppAgentWebsocket {
85
69
  if (!(baseRoleName in appInfo.cell_info)) {
86
70
  throw new Error(`No cell found with role_name ${roleName}`);
87
71
  }
88
- const cloneCell = appInfo.cell_info[baseRoleName].find((c) => CellType.Cloned in c && c.Cloned.clone_id === roleName);
72
+ const cloneCell = appInfo.cell_info[baseRoleName].find((c) => CellType.Cloned in c && c[CellType.Cloned].clone_id === roleName);
89
73
  if (!cloneCell || !(CellType.Cloned in cloneCell)) {
90
74
  throw new Error(`No clone cell found with clone id ${roleName}`);
91
75
  }
92
- return cloneCell.Cloned.cell_id;
76
+ return cloneCell[CellType.Cloned].cell_id;
93
77
  }
94
78
  if (!(roleName in appInfo.cell_info)) {
95
79
  throw new Error(`No cell found with role_name ${roleName}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holochain/client",
3
- "version": "0.11.14",
3
+ "version": "0.11.16",
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",