@holochain/client
Advanced tools
Comparing version 0.16.1 to 0.16.2
@@ -197,3 +197,3 @@ import { Action, DhtOp, Entry, ZomeCallCapGrant } from "../../hdk/index.js"; | ||
network_seed: NetworkSeed; | ||
properties: DnaProperties; | ||
properties: Uint8Array; | ||
origin_time: Timestamp; | ||
@@ -200,0 +200,0 @@ quantum_time: Duration; |
import { UnsubscribeFunction } from "emittery"; | ||
import { AgentPubKey, RoleName } from "../../index.js"; | ||
import { AppInfoResponse, AppSignal, AppSignalCb, CallZomeRequest, CallZomeRequestSigned, DisableCloneCellRequest, EnableCloneCellRequest, EnableCloneCellResponse } from "../app/index.js"; | ||
import { AppInfoResponse, AppSignal, AppSignalCb, CallZomeRequest, CallZomeRequestSigned, DisableCloneCellRequest, EnableCloneCellRequest, EnableCloneCellResponse, NetworkInfoRequest, NetworkInfoResponse } from "../app/index.js"; | ||
import { CreateCloneCellRequest, CreateCloneCellResponse, DisableCloneCellResponse } from "../index.js"; | ||
@@ -40,2 +40,6 @@ /** | ||
*/ | ||
export type AppAgentNetworkInfoRequest = Omit<NetworkInfoRequest, "agent_pub_key">; | ||
/** | ||
* @public | ||
*/ | ||
export interface AppAgentEvents { | ||
@@ -55,2 +59,3 @@ signal: AppSignal; | ||
disableCloneCell(args: AppDisableCloneCellRequest): Promise<DisableCloneCellResponse>; | ||
networkInfo(args: AppAgentNetworkInfoRequest): Promise<NetworkInfoResponse>; | ||
} |
import Emittery, { UnsubscribeFunction } from "emittery"; | ||
import { AgentPubKey, CellId, InstalledAppId, RoleName } from "../../types.js"; | ||
import { AppInfo } from "../admin/types.js"; | ||
import { AppSignalCb, CallZomeResponse, CreateCloneCellResponse, DisableCloneCellResponse, EnableCloneCellResponse } from "../app/types.js"; | ||
import { AppSignalCb, CallZomeResponse, CreateCloneCellResponse, DisableCloneCellResponse, EnableCloneCellResponse, NetworkInfoResponse } from "../app/types.js"; | ||
import { AppWebsocket } from "../app/websocket.js"; | ||
import { AppAgentCallZomeRequest, AppAgentClient, AppAgentEvents, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest } from "./types.js"; | ||
import { AppAgentCallZomeRequest, AppAgentClient, AppAgentEvents, AppAgentNetworkInfoRequest, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest } from "./types.js"; | ||
/** | ||
@@ -72,2 +72,8 @@ * A class to establish a websocket connection to an App interface, for a | ||
/** | ||
* Request network info about gossip status. | ||
* @param args - Specify the DNAs for which you want network info | ||
* @returns Network info for the specified DNAs | ||
*/ | ||
networkInfo(args: AppAgentNetworkInfoRequest): Promise<NetworkInfoResponse>; | ||
/** | ||
* Register an event listener for signals. | ||
@@ -74,0 +80,0 @@ * |
@@ -164,2 +164,13 @@ import Emittery from "emittery"; | ||
/** | ||
* Request network info about gossip status. | ||
* @param args - Specify the DNAs for which you want network info | ||
* @returns Network info for the specified DNAs | ||
*/ | ||
async networkInfo(args) { | ||
return this.appWebsocket.networkInfo({ | ||
...args, | ||
agent_pub_key: this.myPubKey, | ||
}); | ||
} | ||
/** | ||
* Register an event listener for signals. | ||
@@ -166,0 +177,0 @@ * |
@@ -5,3 +5,3 @@ import { hashZomeCall } from "@holochain/serialization"; | ||
import Emittery from "emittery"; | ||
import { getLauncherEnvironment, isLauncher, signZomeCallTauri, } from "../../environments/launcher.js"; | ||
import { getLauncherEnvironment, signZomeCallTauri, signZomeCallElectron, } from "../../environments/launcher.js"; | ||
import { encodeHashToBase64 } from "../../utils/base64.js"; | ||
@@ -102,6 +102,10 @@ import { WsClient } from "../client.js"; | ||
} | ||
const signedZomeCall = isLauncher | ||
? await signZomeCallTauri(request) | ||
: await signZomeCall(request); | ||
return signedZomeCall; | ||
const env = getLauncherEnvironment(); | ||
if (!env) { | ||
return signZomeCall(request); | ||
} | ||
else if (env.FRAMEWORK === "electron") { | ||
return signZomeCallElectron(request); | ||
} | ||
return signZomeCallTauri(request); | ||
}, | ||
@@ -108,0 +112,0 @@ output: (response) => decode(response), |
import { CallZomeRequest } from "../api/app/types.js"; | ||
import { CallZomeRequestSigned } from "../api/app/websocket.js"; | ||
import { CallZomeRequestSigned, CallZomeRequestUnsigned } from "../api/app/websocket.js"; | ||
import { InstalledAppId } from "../types.js"; | ||
@@ -8,12 +8,33 @@ export interface LauncherEnvironment { | ||
INSTALLED_APP_ID?: InstalledAppId; | ||
FRAMEWORK?: "tauri" | "electron"; | ||
} | ||
declare const __HC_LAUNCHER_ENV__ = "__HC_LAUNCHER_ENV__"; | ||
export declare const isLauncher: boolean; | ||
export declare const isLauncher: () => boolean; | ||
export declare const getLauncherEnvironment: () => LauncherEnvironment | undefined; | ||
declare global { | ||
interface Window { | ||
[__HC_LAUNCHER_ENV__]: LauncherEnvironment | undefined; | ||
[__HC_LAUNCHER_ENV__]?: LauncherEnvironment; | ||
electronAPI?: { | ||
signZomeCall: (data: CallZomeRequestUnsignedElectron) => CallZomeRequestSignedElectron; | ||
}; | ||
} | ||
} | ||
interface CallZomeRequestSignedElectron extends Omit<CallZomeRequestSigned, "cap_secret" | "cell_id" | "provenance" | "nonce" | "zome_name" | "fn_name" | "expires_at"> { | ||
cellId: [Array<number>, Array<number>]; | ||
provenance: Array<number>; | ||
zomeName: string; | ||
fnName: string; | ||
nonce: Array<number>; | ||
expiresAt: number; | ||
} | ||
interface CallZomeRequestUnsignedElectron extends Omit<CallZomeRequestUnsigned, "cap_secret" | "cell_id" | "provenance" | "nonce" | "zome_name" | "fn_name" | "expires_at"> { | ||
cellId: [Array<number>, Array<number>]; | ||
provenance: Array<number>; | ||
zomeName: string; | ||
fnName: string; | ||
nonce: Array<number>; | ||
expiresAt: number; | ||
} | ||
export declare const signZomeCallTauri: (request: CallZomeRequest) => Promise<CallZomeRequestSigned>; | ||
export declare const signZomeCallElectron: (request: CallZomeRequest) => Promise<CallZomeRequestSigned>; | ||
export {}; |
@@ -5,4 +5,4 @@ import { encode } from "@msgpack/msgpack"; | ||
const __HC_LAUNCHER_ENV__ = "__HC_LAUNCHER_ENV__"; | ||
export const isLauncher = globalThis.window && __HC_LAUNCHER_ENV__ in globalThis.window; | ||
export const getLauncherEnvironment = () => isLauncher ? globalThis.window[__HC_LAUNCHER_ENV__] : undefined; | ||
export const isLauncher = () => globalThis.window && __HC_LAUNCHER_ENV__ in globalThis.window; | ||
export const getLauncherEnvironment = () => isLauncher() ? globalThis.window[__HC_LAUNCHER_ENV__] : undefined; | ||
export const signZomeCallTauri = async (request) => { | ||
@@ -35,1 +35,31 @@ const zomeCallUnsigned = { | ||
}; | ||
export const signZomeCallElectron = async (request) => { | ||
if (!window.electronAPI) { | ||
throw Error("Unable to signZomeCallElectron. window.electronAPI not defined"); | ||
} | ||
const zomeCallUnsignedElectron = { | ||
provenance: Array.from(request.provenance), | ||
cellId: [Array.from(request.cell_id[0]), Array.from(request.cell_id[1])], | ||
zomeName: request.zome_name, | ||
fnName: request.fn_name, | ||
payload: Array.from(encode(request.payload)), | ||
nonce: Array.from(await randomNonce()), | ||
expiresAt: getNonceExpiration(), | ||
}; | ||
const zomeCallSignedElectron = await window.electronAPI.signZomeCall(zomeCallUnsignedElectron); | ||
const zomeCallSigned = { | ||
provenance: Uint8Array.from(zomeCallSignedElectron.provenance), | ||
cap_secret: null, | ||
cell_id: [ | ||
Uint8Array.from(zomeCallSignedElectron.cellId[0]), | ||
Uint8Array.from(zomeCallSignedElectron.cellId[1]), | ||
], | ||
zome_name: zomeCallSignedElectron.zomeName, | ||
fn_name: zomeCallSignedElectron.fnName, | ||
payload: Uint8Array.from(zomeCallSignedElectron.payload), | ||
signature: Uint8Array.from(zomeCallSignedElectron.signature), | ||
expires_at: zomeCallSignedElectron.expiresAt, | ||
nonce: Uint8Array.from(zomeCallSignedElectron.nonce), | ||
}; | ||
return zomeCallSigned; | ||
}; |
{ | ||
"name": "@holochain/client", | ||
"version": "0.16.1", | ||
"version": "0.16.2", | ||
"description": "A JavaScript client for the Holochain Conductor API", | ||
@@ -43,11 +43,10 @@ "author": "Holochain Foundation <info@holochain.org> (http://holochain.org)", | ||
"@holochain/serialization": "^0.1.0-beta-rc.3", | ||
"@msgpack/msgpack": "^2.7.2", | ||
"@noble/ed25519": "^2.0.0", | ||
"@tauri-apps/api": "^1.2.0", | ||
"@msgpack/msgpack": "^2.8.0", | ||
"@tauri-apps/api": "^1.4.0", | ||
"emittery": "^1.0.1", | ||
"isomorphic-ws": "^5.0.0", | ||
"js-base64": "^3.7.3", | ||
"libsodium-wrappers": "^0.7.11", | ||
"js-base64": "^3.7.5", | ||
"libsodium-wrappers": "^0.7.13", | ||
"lodash-es": "^4.17.21", | ||
"ws": "^8.13.0" | ||
"ws": "^8.14.2" | ||
}, | ||
@@ -57,10 +56,9 @@ "devDependencies": { | ||
"@microsoft/api-extractor": "^7.34.4", | ||
"@types/js-yaml": "^3.12.7", | ||
"@types/libsodium-wrappers": "^0.7.10", | ||
"@types/libsodium-wrappers": "^0.7.11", | ||
"@types/lodash-es": "^4.17.6", | ||
"@types/tape": "^4.13.2", | ||
"@types/ws": "^8.5.3", | ||
"@types/ws": "^8.5.5", | ||
"@typescript-eslint/eslint-plugin": "^5.62.0", | ||
"@typescript-eslint/parser": "^5.62.0", | ||
"eslint": "^8.46.0", | ||
"eslint": "^8.49.0", | ||
"eslint-config-prettier": "^8.10.0", | ||
@@ -72,3 +70,3 @@ "eslint-plugin-prettier": "^4.2.1", | ||
"rimraf": "^3.0.2", | ||
"tape": "^5.5.3", | ||
"tape": "^5.6.6", | ||
"ts-node": "^10.9.1", | ||
@@ -75,0 +73,0 @@ "typescript": "^4.9.5" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105780
9
18
3389
- Removed@noble/ed25519@^2.0.0
- Removed@noble/ed25519@2.1.0(transitive)
Updated@msgpack/msgpack@^2.8.0
Updated@tauri-apps/api@^1.4.0
Updatedjs-base64@^3.7.5
Updatedlibsodium-wrappers@^0.7.13
Updatedws@^8.14.2