@holochain/client
Advanced tools
Comparing version 0.19.0-dev.4 to 0.19.0-dev.5
@@ -6,22 +6,2 @@ import { UnsubscribeFunction } from "emittery"; | ||
*/ | ||
export type NonProvenanceCallZomeRequest = Omit<CallZomeRequest, "provenance">; | ||
/** | ||
* @public | ||
*/ | ||
export type RoleNameCallZomeRequest = Omit<NonProvenanceCallZomeRequest, "cell_id"> & { | ||
role_name: RoleName; | ||
}; | ||
/** | ||
* @public | ||
*/ | ||
export type RoleNameCallZomeRequestSigned = Omit<CallZomeRequestSigned, "cell_id"> & { | ||
role_name: RoleName; | ||
}; | ||
/** | ||
* @public | ||
*/ | ||
export type AppCallZomeRequest = NonProvenanceCallZomeRequest | RoleNameCallZomeRequest | CallZomeRequest | CallZomeRequestAllParams; | ||
/** | ||
* @public | ||
*/ | ||
export type AppCreateCloneCellRequest = Omit<CreateCloneCellRequest, "app_id">; | ||
@@ -49,23 +29,21 @@ /** | ||
*/ | ||
export interface CallZomeRequestAllParams extends CallZomeRequest { | ||
cap_secret: CapSecret | null; | ||
nonce: Nonce256Bit; | ||
expires_at: number; | ||
} | ||
export type CallZomeRequestGeneric<Payload> = { | ||
cell_id: CellId; | ||
zome_name: ZomeName; | ||
fn_name: FunctionName; | ||
provenance?: AgentPubKey; | ||
payload?: Payload; | ||
cap_secret?: CapSecret; | ||
nonce?: Nonce256Bit; | ||
expires_at?: number; | ||
}; | ||
/** | ||
* @public | ||
*/ | ||
export interface CallZomeRequestSigned { | ||
bytes: Uint8Array; | ||
signature: Uint8Array; | ||
} | ||
export type CallZomeRequest = CallZomeRequestGeneric<any>; | ||
/** | ||
* @public | ||
*/ | ||
export type CallZomeRequestGeneric<Payload> = { | ||
cell_id: CellId; | ||
zome_name: ZomeName; | ||
fn_name: FunctionName; | ||
payload: Payload; | ||
provenance: AgentPubKey; | ||
export type RoleNameCallZomeRequest = Omit<CallZomeRequest, "cell_id"> & { | ||
role_name: RoleName; | ||
}; | ||
@@ -75,3 +53,6 @@ /** | ||
*/ | ||
export type CallZomeRequest = CallZomeRequestGeneric<any>; | ||
export interface CallZomeRequestSigned { | ||
bytes: Uint8Array; | ||
signature: Uint8Array; | ||
} | ||
/** | ||
@@ -452,3 +433,3 @@ * @public | ||
export interface AppClient { | ||
callZome(args: AppCallZomeRequest, timeout?: number): Promise<any>; | ||
callZome(args: CallZomeRequest | RoleNameCallZomeRequest, timeout?: number): Promise<any>; | ||
on<Name extends keyof AppEvents>(eventName: Name | readonly Name[], listener: SignalCb): UnsubscribeFunction; | ||
@@ -455,0 +436,0 @@ appInfo(): Promise<AppInfoResponse>; |
import { UnsubscribeFunction } from "emittery"; | ||
import { AgentPubKey, CellId, InstalledAppId, RoleName } from "../../types.js"; | ||
import { AppInfo, MemproofMap } from "../admin/index.js"; | ||
import { AppCallZomeRequest, AppClient, AppEvents, AppNetworkInfoRequest, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest, SignalCb, CallZomeRequest, CallZomeRequestSigned, NetworkInfoResponse, AppWebsocketConnectionOptions, GetCountersigningSessionStateRequest, GetCountersigningSessionStateResponse, AbandonCountersigningSessionStateRequest, PublishCountersigningSessionStateRequest } from "./types.js"; | ||
import { AppClient, AppEvents, AppNetworkInfoRequest, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest, SignalCb, CallZomeRequest, CallZomeRequestSigned, NetworkInfoResponse, AppWebsocketConnectionOptions, GetCountersigningSessionStateRequest, GetCountersigningSessionStateResponse, AbandonCountersigningSessionStateRequest, PublishCountersigningSessionStateRequest, RoleNameCallZomeRequest } from "./types.js"; | ||
import { WsClient } from "../client.js"; | ||
@@ -73,3 +73,3 @@ /** | ||
*/ | ||
callZome<ReturnType>(request: AppCallZomeRequest, timeout?: number): Promise<ReturnType>; | ||
callZome<ReturnType>(request: CallZomeRequest | RoleNameCallZomeRequest, timeout?: number): Promise<ReturnType>; | ||
/** | ||
@@ -76,0 +76,0 @@ * Clone an existing provisioned cell. |
@@ -170,13 +170,12 @@ import Emittery from "emittery"; | ||
const cell_id = this.getCellIdFromRoleName(request.role_name, appInfo); | ||
const zomeCallPayload = { | ||
request = { | ||
...omit(request, "role_name"), | ||
provenance: this.myPubKey, | ||
// Some problem here with the launcher with just the `cell_id`. | ||
cell_id: [cell_id[0], cell_id[1]], | ||
}; | ||
return this.callZomeRequester(zomeCallPayload, timeout); | ||
} | ||
else if ("cell_id" in request && request.cell_id) { | ||
return this.callZomeRequester(request, timeout); | ||
else if (!("cell_id" in request)) { | ||
throw new HolochainError("MissingRoleNameOrCellId", "callZome requires a role_name or cell_id argument"); | ||
} | ||
throw new HolochainError("MissingRoleNameOrCellId", "callZome requires a role_name or cell_id argument"); | ||
return this.callZomeRequester(request, timeout); | ||
} | ||
@@ -349,3 +348,3 @@ /** | ||
} | ||
const unsignedZomeCallPayload = { | ||
const zome_call_params = { | ||
cap_secret: signingCredentialsForCell.capSecret, | ||
@@ -360,3 +359,3 @@ cell_id: request.cell_id, | ||
}; | ||
const bytes = encode(unsignedZomeCallPayload); | ||
const bytes = encode(zome_call_params); | ||
const bytesHash = new Uint8Array(sha512.array(bytes)); | ||
@@ -363,0 +362,0 @@ await _sodium.ready; |
import { AppAuthenticationToken, CallZomeRequest } from "../api/index.js"; | ||
import { CallZomeRequestSigned, CallZomeRequestAllParams } from "../api/index.js"; | ||
import { CallZomeRequestSigned } from "../api/index.js"; | ||
import { InstalledAppId } from "../types.js"; | ||
@@ -35,3 +35,3 @@ export interface LauncherEnvironment { | ||
} | ||
interface CallZomeRequestUnsignedElectron extends Omit<CallZomeRequestAllParams, "cap_secret" | "cell_id" | "provenance" | "nonce" | "zome_name" | "fn_name" | "expires_at"> { | ||
interface CallZomeRequestUnsignedElectron extends Omit<CallZomeRequest, "cap_secret" | "cell_id" | "provenance" | "nonce" | "zome_name" | "fn_name" | "expires_at"> { | ||
cellId: [Array<number>, Array<number>]; | ||
@@ -38,0 +38,0 @@ provenance: Array<number>; |
{ | ||
"name": "@holochain/client", | ||
"version": "0.19.0-dev.4", | ||
"version": "0.19.0-dev.5", | ||
"description": "A JavaScript client for the Holochain Conductor API", | ||
@@ -5,0 +5,0 @@ "author": "Holochain Foundation <info@holochain.org> (https://holochain.org)", |
156036
4179