@holochain/client 0.19.0-dev.4 → 0.19.0-dev.6

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.
@@ -130,7 +130,38 @@ export type MembraneProof = Uint8Array;
130
130
  * @public
131
131
  */
132
132
  export type MemproofMap = {
133
- [key: string]: MembraneProof;
133
+ [key: RoleName]: MembraneProof;
134
+ };
135
+ /**
136
+ * @public
137
+ */
138
+ export type RoleSettingsMap = {
139
+ [key: RoleName]: RoleSettings;
140
+ };
141
+ /**
142
+ * @public
143
+ */
144
+ export type RoleSettings = {
145
+ type: "UseExisting";
146
+ cell_id: CellId;
147
+ } | {
148
+ type: "Provisioned";
149
+ membrane_proof?: MembraneProof;
150
+ modifiers?: DnaModifiersOpt;
151
+ };
152
+ /**
153
+ * @public
154
+ * Any value that is serializable to a Yaml value
155
+ */
156
+ export type YamlProperties = unknown;
157
+ /**
158
+ * @public
159
+ */
160
+ export type DnaModifiersOpt = {
161
+ network_seed?: NetworkSeed;
162
+ properties?: YamlProperties;
163
+ origin_time?: Timestamp;
164
+ quantum_time?: Duration;
134
165
  };
135
166
  /**
136
167
  * @public
@@ -425,16 +456,15 @@ export type InstallAppRequest = {
425
456
  * If not specified, it will be derived from the app name in the bundle manifest.
426
457
  */
427
458
  installed_app_id?: InstalledAppId;
428
- /**
429
- * Include proof-of-membrane-membership data for cells that require it,
430
- * keyed by the CellNick specified in the app bundle manifest.
431
- */
432
- membrane_proofs: MemproofMap;
433
459
  /**
434
460
  * Optional global network seed override. If set will override the network seed value for all
435
461
  * DNAs in the bundle.
436
462
  */
437
463
  network_seed?: NetworkSeed;
464
+ /**
465
+ * Specify role specific settings or modifiers that will override any settings in the dna manifest.
466
+ */
467
+ roles_settings?: RoleSettingsMap;
438
468
  /**
439
469
  * Optional: If app installation fails due to genesis failure, normally the app will be immediately uninstalled.
440
470
  * When this flag is set, the app is left installed with empty cells intact. This can be useful for
@@ -1,25 +1,5 @@
1
1
  import { UnsubscribeFunction } from "emittery";
2
2
  import { AgentPubKey, AppAuthenticationToken, AppInfo, CapSecret, CellId, ClonedCell, DnaHash, DnaProperties, EntryHash, FunctionName, InstalledAppId, MembraneProof, MemproofMap, NetworkInfo, NetworkSeed, Nonce256Bit, RoleName, Timestamp, Transformer, WebsocketConnectionOptions, ZomeName, PreflightRequest, SignedAction, SignedActionHashed } 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 | CallZomeRequest | CallZomeRequestAllParams;
23
3
  /**
24
4
  * @public
25
5
  */
@@ -45,32 +25,33 @@ export interface AppEvents {
45
25
  /**
46
26
  * @public
47
27
  */
48
- export interface CallZomeRequestAllParams extends CallZomeRequest {
49
- cap_secret: CapSecret | null;
50
- nonce: Nonce256Bit;
51
- expires_at: number;
52
- }
28
+ export type CallZomeRequestGeneric<Payload> = {
29
+ cell_id: CellId;
30
+ zome_name: ZomeName;
31
+ fn_name: FunctionName;
32
+ provenance?: AgentPubKey;
33
+ payload?: Payload;
34
+ cap_secret?: CapSecret;
35
+ nonce?: Nonce256Bit;
36
+ expires_at?: number;
37
+ };
53
38
  /**
54
39
  * @public
55
40
  */
56
- export interface CallZomeRequestSigned {
57
- bytes: Uint8Array;
58
- signature: Uint8Array;
59
- }
41
+ export type CallZomeRequest = CallZomeRequestGeneric<any>;
60
42
  /**
61
43
  * @public
62
44
  */
63
- export type CallZomeRequestGeneric<Payload> = {
64
- cell_id: CellId;
65
- zome_name: ZomeName;
66
- fn_name: FunctionName;
67
- payload: Payload;
68
- provenance: AgentPubKey;
45
+ export type RoleNameCallZomeRequest = Omit<CallZomeRequest, "cell_id"> & {
46
+ role_name: RoleName;
69
47
  };
70
48
  /**
71
49
  * @public
72
50
  */
73
- export type CallZomeRequest = CallZomeRequestGeneric<any>;
51
+ export interface CallZomeRequestSigned {
52
+ bytes: Uint8Array;
53
+ signature: Uint8Array;
54
+ }
74
55
  /**
75
56
  * @public
76
57
  */
@@ -446,7 +427,7 @@ export type NetworkInfoResponse = NetworkInfo[];
446
427
  * @public
447
428
  */
448
429
  export interface AppClient {
449
- callZome(args: AppCallZomeRequest, timeout?: number): Promise<any>;
430
+ callZome(args: CallZomeRequest | RoleNameCallZomeRequest, timeout?: number): Promise<any>;
450
431
  on<Name extends keyof AppEvents>(eventName: Name | readonly Name[], listener: SignalCb): UnsubscribeFunction;
451
432
  appInfo(): Promise<AppInfoResponse>;
452
433
  myPubKey: AgentPubKey;
@@ -1,7 +1,7 @@
1
1
  import { UnsubscribeFunction } from "emittery";
2
2
  import { AgentPubKey, CellId, InstalledAppId, RoleName } from "../../types.js";
3
3
  import { AppInfo, MemproofMap } from "../admin/index.js";
4
- import { AppCallZomeRequest, AppClient, AppEvents, AppNetworkInfoRequest, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest, SignalCb, CallZomeRequest, CallZomeRequestSigned, NetworkInfoResponse, AppWebsocketConnectionOptions, GetCountersigningSessionStateRequest, GetCountersigningSessionStateResponse, AbandonCountersigningSessionStateRequest, PublishCountersigningSessionStateRequest } from "./types.js";
4
+ import { AppClient, AppEvents, AppNetworkInfoRequest, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest, SignalCb, CallZomeRequest, CallZomeRequestSigned, NetworkInfoResponse, AppWebsocketConnectionOptions, GetCountersigningSessionStateRequest, GetCountersigningSessionStateResponse, AbandonCountersigningSessionStateRequest, PublishCountersigningSessionStateRequest, RoleNameCallZomeRequest } from "./types.js";
5
5
  import { WsClient } from "../client.js";
6
6
  /**
7
7
  * A class to establish a websocket connection to an App interface, for a
@@ -70,7 +70,7 @@ export declare class AppWebsocket implements AppClient {
70
70
  * @param timeout - A timeout to override the default.
71
71
  * @returns The zome call's response.
72
72
  */
73
- callZome<ReturnType>(request: AppCallZomeRequest, timeout?: number): Promise<ReturnType>;
73
+ callZome<ReturnType>(request: CallZomeRequest | RoleNameCallZomeRequest, timeout?: number): Promise<ReturnType>;
74
74
  /**
75
75
  * Clone an existing provisioned cell.
76
76
  *
@@ -167,17 +167,16 @@ export class AppWebsocket {
167
167
  if ("role_name" in request && request.role_name) {
168
168
  const appInfo = this.cachedAppInfo || (await this.appInfo());
169
169
  const cell_id = this.getCellIdFromRoleName(request.role_name, appInfo);
170
- const zomeCallPayload = {
170
+ request = {
171
171
  ...omit(request, "role_name"),
172
- provenance: this.myPubKey,
172
+ // Some problem here with the launcher with just the `cell_id`.
173
173
  cell_id: [cell_id[0], cell_id[1]],
174
174
  };
175
- return this.callZomeRequester(zomeCallPayload, timeout);
176
175
  }
177
- else if ("cell_id" in request && request.cell_id) {
178
- return this.callZomeRequester(request, timeout);
176
+ else if (!("cell_id" in request)) {
177
+ throw new HolochainError("MissingRoleNameOrCellId", "callZome requires a role_name or cell_id argument");
179
178
  }
180
- throw new HolochainError("MissingRoleNameOrCellId", "callZome requires a role_name or cell_id argument");
179
+ return this.callZomeRequester(request, timeout);
181
180
  }
182
181
  /**
183
182
  * Clone an existing provisioned cell.
@@ -345,7 +344,7 @@ export const signZomeCall = async (request) => {
345
344
  if (!signingCredentialsForCell) {
346
345
  throw new HolochainError("NoSigningCredentialsForCell", `no signing credentials have been authorized for cell [${encodeHashToBase64(request.cell_id[0])}, ${encodeHashToBase64(request.cell_id[1])}]`);
347
346
  }
348
- const unsignedZomeCallPayload = {
347
+ const zome_call_params = {
349
348
  cap_secret: signingCredentialsForCell.capSecret,
350
349
  cell_id: request.cell_id,
351
350
  zome_name: request.zome_name,
@@ -355,7 +354,7 @@ export const signZomeCall = async (request) => {
355
354
  nonce: await randomNonce(),
356
355
  expires_at: getNonceExpiration(),
357
356
  };
358
- const bytes = encode(unsignedZomeCallPayload);
357
+ const bytes = encode(zome_call_params);
359
358
  const bytesHash = new Uint8Array(sha512.array(bytes));
360
359
  await _sodium.ready;
361
360
  const sodium = _sodium;
@@ -1,5 +1,5 @@
1
1
  import { AppAuthenticationToken, CallZomeRequest } from "../api/index.js";
2
- import { CallZomeRequestSigned, CallZomeRequestAllParams } from "../api/index.js";
2
+ import { CallZomeRequestSigned } from "../api/index.js";
3
3
  import { InstalledAppId } from "../types.js";
4
4
  export interface LauncherEnvironment {
5
5
  APP_INTERFACE_PORT?: number;
@@ -32,7 +32,7 @@ interface CallZomeRequestSignedElectron extends Omit<CallZomeRequestSigned, "cap
32
32
  nonce: Array<number>;
33
33
  expiresAt: number;
34
34
  }
35
- interface CallZomeRequestUnsignedElectron extends Omit<CallZomeRequestAllParams, "cap_secret" | "cell_id" | "provenance" | "nonce" | "zome_name" | "fn_name" | "expires_at"> {
35
+ interface CallZomeRequestUnsignedElectron extends Omit<CallZomeRequest, "cap_secret" | "cell_id" | "provenance" | "nonce" | "zome_name" | "fn_name" | "expires_at"> {
36
36
  cellId: [Array<number>, Array<number>];
37
37
  provenance: Array<number>;
38
38
  zomeName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holochain/client",
3
- "version": "0.19.0-dev.4",
3
+ "version": "0.19.0-dev.6",
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",
@@ -55,6 +55,7 @@
55
55
  "devDependencies": {
56
56
  "@microsoft/api-documenter": "^7.21.7",
57
57
  "@microsoft/api-extractor": "^7.34.4",
58
+ "@types/js-yaml": "4.0.9",
58
59
  "@types/libsodium-wrappers": "^0.7.11",
59
60
  "@types/lodash-es": "^4.17.6",
60
61
  "@types/tape": "^4.13.2",
@@ -65,7 +66,7 @@
65
66
  "eslint-config-prettier": "^8.10.0",
66
67
  "eslint-plugin-prettier": "^4.2.1",
67
68
  "eslint-plugin-tsdoc": "^0.2.17",
68
- "js-yaml": "^3.14.1",
69
+ "js-yaml": "^4.1.0",
69
70
  "prettier": "^2.8.8",
70
71
  "rimraf": "^3.0.2",
71
72
  "tape": "^5.6.6",