Socket
Socket
Sign inDemoInstall

@holochain/client

Package Overview
Dependencies
Maintainers
13
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@holochain/client - npm Package Compare versions

Comparing version 0.11.9 to 0.11.10

27

lib/api/admin/types.d.ts
/// <reference types="node" />
import { Action, DhtOp, Entry, ZomeCallCapGrant } from "../../hdk/index.js";
import { ActionHash, AgentPubKey, CellId, DnaHash, DnaProperties, HoloHash, HoloHashB64, InstalledAppId, KitsuneAgent, KitsuneSpace, RoleName, Signature, Timestamp, WasmHash } from "../../types.js";
import { ActionHash, AgentPubKey, CellId, DnaHash, DnaProperties, Duration, HoloHash, HoloHashB64, InstalledAppId, KitsuneAgent, KitsuneSpace, RoleName, Signature, Timestamp, WasmHash } from "../../types.js";
import { Requester } from "../common.js";

@@ -109,2 +109,3 @@ import { DisableCloneCellRequest } from "../index.js";

origin_time: Timestamp;
quantum_time: Duration;
};

@@ -134,3 +135,3 @@ export declare type FunctionName = string;

export declare type UninstallAppResponse = null;
export declare type ResourceBytes = Buffer;
export declare type ResourceBytes = number[];
export declare type ResourceMap = {

@@ -158,2 +159,9 @@ [key: string]: ResourceBytes;

};
export declare type Location = {
bundled: string;
} | {
path: string;
} | {
url: string;
};
export declare type DnaVersionSpec = Array<HoloHashB64>;

@@ -166,7 +174,6 @@ export declare type DnaVersionFlexible = {

export declare type AppRoleDnaManifest = {
location?: Location;
properties?: DnaProperties;
network_seed?: NetworkSeed;
clone_limit?: number;
modifiers?: Partial<DnaModifiers>;
version?: DnaVersionFlexible;
};
} & Location;
export declare type AppRoleManifest = {

@@ -263,9 +270,3 @@ name: RoleName;

};
export declare type ZomeLocation = {
bundled: string;
} | {
path: string;
} | {
url: string;
};
export declare type ZomeLocation = Location;
export declare type ZomeManifest = {

@@ -272,0 +273,0 @@ name: string;

@@ -18,3 +18,3 @@ import { getLauncherEnvironment } from "../../environments/launcher.js";

const env = getLauncherEnvironment();
if (env) {
if (env?.ADMIN_INTERFACE_PORT) {
url = `ws://127.0.0.1:${env.ADMIN_INTERFACE_PORT}`;

@@ -21,0 +21,0 @@ }

import { UnsubscribeFunction } from "emittery";
import { DisableCloneCellResponse, CreateCloneCellRequest, CreateCloneCellResponse } from "../index.js";
import { AgentPubKey, RoleName } from "../../index.js";
import { AppInfoResponse, AppSignal, DisableCloneCellRequest, CallZomeRequest, EnableCloneCellRequest, EnableCloneCellResponse, CallZomeRequestSigned } from "../app/index.js";
import { AppInfoResponse, AppSignal, AppSignalCb, CallZomeRequest, CallZomeRequestSigned, DisableCloneCellRequest, EnableCloneCellRequest, EnableCloneCellResponse } from "../app/index.js";
import { CreateCloneCellRequest, CreateCloneCellResponse, DisableCloneCellResponse } from "../index.js";
export declare type NonProvenanceCallZomeRequest = Omit<CallZomeRequest, "provenance">;

@@ -21,3 +21,3 @@ export declare type RoleNameCallZomeRequest = Omit<NonProvenanceCallZomeRequest, "cell_id"> & {

callZome(args: AppAgentCallZomeRequest, timeout?: number): Promise<any>;
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: (eventData: AppAgentEvents[Name]) => void | Promise<void>): UnsubscribeFunction;
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: AppSignalCb): UnsubscribeFunction;
appInfo(): Promise<AppInfoResponse>;

@@ -24,0 +24,0 @@ myPubKey: AgentPubKey;

import Emittery, { UnsubscribeFunction } from "emittery";
import { AgentPubKey, InstalledAppId, RoleName } from "../../types.js";
import { AppInfo, AppInfoResponse, AppWebsocket, CallZomeResponse, CreateCloneCellResponse, DisableCloneCellResponse, EnableCloneCellResponse } from "../index.js";
import { AgentPubKey, CellId, InstalledAppId, RoleName } from "../../types.js";
import { AppInfo, AppSignalCb, AppWebsocket, CallZomeResponse, CreateCloneCellResponse, DisableCloneCellResponse, EnableCloneCellResponse } from "../index.js";
import { AppAgentCallZomeRequest, AppAgentClient, AppAgentEvents, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest } from "./types.js";

@@ -12,5 +12,5 @@ export declare class AppAgentWebsocket implements AppAgentClient {

private constructor();
appInfo(): Promise<AppInfoResponse>;
static connect(appWebsocket: AppWebsocket, installedAppId: InstalledAppId): Promise<AppAgentWebsocket>;
getCellIdFromRoleName(roleName: RoleName, appInfo: AppInfo): import("../../types.js").CellId;
appInfo(): Promise<AppInfo>;
static connect(url: string, installed_app_id: InstalledAppId, defaultTimeout?: number): Promise<AppAgentWebsocket>;
getCellIdFromRoleName(roleName: RoleName, appInfo: AppInfo): CellId;
callZome(request: AppAgentCallZomeRequest, timeout?: number): Promise<CallZomeResponse>;

@@ -20,3 +20,4 @@ createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;

disableCloneCell(args: AppDisableCloneCellRequest): Promise<DisableCloneCellResponse>;
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: (eventData: AppAgentEvents[Name]) => void | Promise<void>): UnsubscribeFunction;
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: AppSignalCb): UnsubscribeFunction;
private containsCell;
}

@@ -5,3 +5,3 @@ import Emittery from "emittery";

import { getBaseRoleNameFromCloneId, isCloneId } from "../common.js";
import { CellType, } from "../index.js";
import { AppWebsocket, CellType, } from "../index.js";
function getPubKey(appInfo) {

@@ -34,3 +34,7 @@ // This is fine for now cause `UseExisting` as a provisioning strategy doesn't work yet.

this.installedAppId = env?.INSTALLED_APP_ID || installedAppId;
this.appWebsocket.on("signal", (signal) => this.emitter.emit("signal", signal));
this.appWebsocket.on("signal", (signal) => {
if (this.containsCell(signal.cell_id)) {
this.emitter.emit("signal", signal);
}
});
}

@@ -44,8 +48,11 @@ async appInfo() {

}
static async connect(appWebsocket, installedAppId) {
static async connect(url, installed_app_id, defaultTimeout) {
const appWebsocket = await AppWebsocket.connect(url, defaultTimeout);
const appInfo = await appWebsocket.appInfo({
installed_app_id: installedAppId,
installed_app_id: installed_app_id,
});
const myPubKey = getPubKey(appInfo);
return new AppAgentWebsocket(appWebsocket, installedAppId, myPubKey);
const appAgentWs = new AppAgentWebsocket(appWebsocket, installed_app_id, myPubKey);
appAgentWs.cachedAppInfo = appInfo;
return appAgentWs;
}

@@ -58,4 +65,4 @@ getCellIdFromRoleName(roleName, appInfo) {

}
const cloneCell = appInfo.cell_info[baseRoleName].find((c) => "Cloned" in c && c.Cloned.clone_id === roleName);
if (!cloneCell || !("Cloned" in cloneCell)) {
const cloneCell = appInfo.cell_info[baseRoleName].find((c) => CellType.Cloned in c && c.Cloned.clone_id === roleName);
if (!cloneCell || !(CellType.Cloned in cloneCell)) {
throw new Error(`No clone cell found with clone id ${roleName}`);

@@ -121,3 +128,24 @@ }

}
containsCell(cellId) {
const appInfo = this.cachedAppInfo;
if (!appInfo) {
return false;
}
for (const roleName of Object.keys(appInfo.cell_info)) {
for (const cellInfo of appInfo.cell_info[roleName]) {
const currentCellId = CellType.Provisioned in cellInfo
? cellInfo[CellType.Provisioned].cell_id
: CellType.Cloned in cellInfo
? cellInfo[CellType.Cloned].cell_id
: undefined;
if (currentCellId && isSameCell(currentCellId, cellId)) {
return true;
}
}
}
return false;
}
}
const isSameCell = (cellId1, cellId2) => cellId1[0].every((byte, index) => byte === cellId2[0][index]) &&
cellId1[1].every((byte, index) => byte === cellId2[1][index]);
//# sourceMappingURL=websocket.js.map

@@ -1,4 +0,4 @@

import { AgentPubKey, CellId, DnaProperties, InstalledAppId, InstalledCell, RoleName, Timestamp, DnaHash, NetworkInfo } from "../../types.js";
import { AgentPubKey, CellId, DnaHash, DnaProperties, InstalledAppId, InstalledCell, NetworkInfo, RoleName, Timestamp } from "../../types.js";
import { AppInfo, FunctionName, MembraneProof, NetworkSeed, ZomeName } from "../admin/index.js";
import { Requester } from "../common.js";
import { FunctionName, AppInfo, MembraneProof, NetworkSeed, ZomeName } from "../admin/index.js";
export declare type CallZomeRequestGeneric<Payload> = {

@@ -70,9 +70,2 @@ cell_id: CellId;

export declare type EnableCloneCellResponse = CreateCloneCellResponse;
export declare type AppSignal = {
type: string;
data: {
cellId: CellId;
payload: any;
};
};
export interface NetworkInfoRequest {

@@ -82,5 +75,16 @@ /** The DNAs for which to get network info */

}
export declare const SignalType: {
readonly App: "App";
readonly System: "System";
};
export declare type Signal = {
[SignalType.App]: [CellId, any];
[SignalType.System]: unknown;
};
export declare type AppSignal = {
cell_id: CellId;
payload: any;
};
export declare type AppSignalCb = (signal: AppSignal) => void;
export declare type NetworkInfoResponse = NetworkInfo[];
export declare type AppSignalCb = (signal: AppSignal) => void;
export declare type SignalResponseGeneric<Payload> = Payload;
export interface AppApi {

@@ -87,0 +91,0 @@ appInfo: Requester<AppInfoRequest, AppInfoResponse>;

@@ -1,2 +0,5 @@

export {};
export const SignalType = {
App: "App",
System: "System",
};
//# sourceMappingURL=types.js.map

@@ -7,3 +7,3 @@ import Emittery from "emittery";

import { Nonce256Bit } from "../zome-call-signing.js";
import { AppApi, AppInfoRequest, AppInfoResponse, AppSignalCb, CallZomeRequest, CallZomeResponse, CreateCloneCellRequest, CreateCloneCellResponse, DisableCloneCellRequest, DisableCloneCellResponse, EnableCloneCellRequest, EnableCloneCellResponse, NetworkInfoRequest, NetworkInfoResponse } from "./types.js";
import { AppApi, AppInfoRequest, AppInfoResponse, CallZomeRequest, CallZomeResponse, CreateCloneCellRequest, CreateCloneCellResponse, DisableCloneCellRequest, DisableCloneCellResponse, EnableCloneCellRequest, EnableCloneCellResponse, NetworkInfoRequest, NetworkInfoResponse } from "./types.js";
export declare class AppWebsocket extends Emittery implements AppApi {

@@ -14,3 +14,3 @@ readonly client: WsClient;

private constructor();
static connect(url: string, defaultTimeout?: number, signalCb?: AppSignalCb): Promise<AppWebsocket>;
static connect(url: string, defaultTimeout?: number): Promise<AppWebsocket>;
_requester: <ReqI, ReqO, ResI, ResO>(tag: string, transformer?: Transformer<ReqI, ReqO, ResI, ResO> | undefined) => (req: ReqI, timeout?: number | undefined) => Promise<ResO>;

@@ -17,0 +17,0 @@ appInfo: Requester<AppInfoRequest, AppInfoResponse>;

@@ -20,13 +20,10 @@ import { hashZomeCall } from "@holochain/serialization";

}
static async connect(url, defaultTimeout, signalCb) {
static async connect(url, defaultTimeout) {
// Check if we are in the launcher's environment, and if so, redirect the url to connect to
const env = getLauncherEnvironment();
if (env) {
if (env?.APP_INTERFACE_PORT) {
url = `ws://127.0.0.1:${env.APP_INTERFACE_PORT}`;
}
if (signalCb) {
console.warn("Providing a signal callback on client initialization is deprecated. Instead add an event handler using `.on('signal', signalCb)`.");
}
const wsClient = await WsClient.connect(url, signalCb);
const appWebsocket = new AppWebsocket(wsClient, defaultTimeout, env ? env.INSTALLED_APP_ID : undefined);
const wsClient = await WsClient.connect(url);
const appWebsocket = new AppWebsocket(wsClient, defaultTimeout, env?.INSTALLED_APP_ID);
wsClient.on("signal", (signal) => appWebsocket.emit("signal", signal));

@@ -33,0 +30,0 @@ return appWebsocket;

/// <reference types="ws" />
import { decode } from "@msgpack/msgpack";
import Emittery from "emittery";
import Websocket from "isomorphic-ws";
import Emittery from "emittery";
import { AppSignalCb } from "./app/types.js";
interface HolochainMessage {
id: number;
type: "response" | "signal";
data: ArrayLike<number> | null;
}
/**

@@ -15,13 +19,13 @@ * A Websocket client which can make requests and receive responses,

pendingRequests: Record<number, {
fulfill: (msg: unknown) => ReturnType<typeof decode>;
resolve: (msg: unknown) => ReturnType<typeof decode>;
reject: (error: Error) => void;
}>;
index: number;
constructor(socket: any, signalCb?: AppSignalCb);
emitSignal(data: any): void;
constructor(socket: Websocket);
static connect(url: string): Promise<WsClient>;
emitSignal(data: unknown): void;
request<Req, Res>(data: Req): Promise<Res>;
handleResponse(msg: any): void;
handleResponse(msg: HolochainMessage): void;
close(): Promise<void>;
awaitClose(): Promise<void>;
static connect(url: string, signalCb?: AppSignalCb): Promise<WsClient>;
}
export {};
import { decode, encode } from "@msgpack/msgpack";
import Emittery from "emittery";
import Websocket from "isomorphic-ws";
import Emittery from "emittery";
import { SignalType } from "./app/types.js";
/**

@@ -14,3 +15,3 @@ * A Websocket client which can make requests and receive responses,

index;
constructor(socket, signalCb) {
constructor(socket) {
super();

@@ -20,39 +21,61 @@ this.socket = socket;

this.index = 0;
if (signalCb) {
console.log("Providing a signal callback on client initialization is deprecated. Instead add an event handler using `.on('signal', signalCb)`.");
this.on("signal", signalCb);
}
socket.onmessage = async (encodedMsg) => {
let data = encodedMsg.data;
socket.onmessage = async (serializedMessage) => {
// If data is not a buffer (nodejs), it will be a blob (browser)
if (typeof Buffer === "undefined" || !Buffer.isBuffer(data)) {
data = await data.arrayBuffer();
let deserializedData;
if (serializedMessage.data instanceof Blob) {
deserializedData = await serializedMessage.data.arrayBuffer();
}
const msg = decode(data);
if (msg.type === "signal") {
const decodedMessage = decode(msg.data);
if (!decodedMessage.App) {
else {
if (typeof Buffer !== "undefined" &&
Buffer.isBuffer(serializedMessage.data)) {
deserializedData = serializedMessage.data;
}
else {
throw new Error("websocket client: unknown message format");
}
}
const message = decode(deserializedData);
assertHolochainMessage(message);
if (message.type === "signal") {
if (message.data === null) {
throw new Error("received a signal without data");
}
const derializedSignal = decode(message.data);
assertHolochainSignal(derializedSignal);
if (!(SignalType.App in derializedSignal)) {
// We have received a system signal, do nothing
return;
}
// Note: holochain currently returns signals as an array of two values: cellId and the serialized signal payload
// Holochain currently returns signals as an array of two values: cellId and the serialized signal payload
// and this array is nested within the App key within the returned message.
const decodedCellId = decodedMessage.App[0];
// Note:In order to return readible content to the UI, the signal payload must also be decoded.
const decodedPayload = signalTransform(decodedMessage.App[1]);
const cell_id = derializedSignal.App[0];
// In order to return readible content to the UI, the signal payload must also be deserialized.
const payload = decode(derializedSignal.App[1]);
// Return a uniform format to UI (ie: { type, data } - the same format as with callZome and appInfo...)
const signal = {
type: msg.type,
data: { cellId: decodedCellId, payload: decodedPayload },
};
const signal = { cell_id, payload };
this.emit("signal", signal);
}
else if (msg.type === "response") {
this.handleResponse(msg);
else if (message.type === "response") {
this.handleResponse(message);
}
else {
console.error(`Got unrecognized Websocket message type: ${msg.type}`);
console.error(`Got unrecognized Websocket message type: ${message.type}`);
}
};
}
static connect(url) {
return new Promise((resolve, reject) => {
const socket = new Websocket(url);
// make sure that there are no uncaught connection
// errors because that causes nodejs thread to crash
// with uncaught exception
socket.onerror = () => {
reject(new Error(`could not connect to holochain conductor, please check that a conductor service is running and available at ${url}`));
};
socket.onopen = () => {
const client = new WsClient(socket);
resolve(client);
};
});
}
emitSignal(data) {

@@ -73,4 +96,4 @@ const encodedMsg = encode({

});
const promise = new Promise((fulfill, reject) => {
this.pendingRequests[id] = { fulfill, reject };
const promise = new Promise((resolve, reject) => {
this.pendingRequests[id] = { resolve, reject };
});

@@ -88,3 +111,2 @@ if (this.socket.readyState === this.socket.OPEN) {

if (this.pendingRequests[id]) {
// resolve response
if (msg.data === null || msg.data === undefined) {

@@ -94,4 +116,5 @@ this.pendingRequests[id].reject(new Error("Response canceled by responder"));

else {
this.pendingRequests[id].fulfill(decode(msg.data));
this.pendingRequests[id].resolve(decode(msg.data));
}
delete this.pendingRequests[id];
}

@@ -103,26 +126,24 @@ else {

close() {
const closedPromise = new Promise((resolve) => this.socket.on("close", resolve));
this.socket.close();
return this.awaitClose();
return closedPromise;
}
awaitClose() {
return new Promise((resolve) => this.socket.on("close", resolve));
}
function assertHolochainMessage(message) {
if (typeof message === "object" &&
message !== null &&
"type" in message &&
"data" in message) {
return;
}
static connect(url, signalCb) {
return new Promise((resolve, reject) => {
const socket = new Websocket(url);
// make sure that there are no uncaught connection
// errors because that causes nodejs thread to crash
// with uncaught exception
socket.onerror = () => {
reject(new Error(`could not connect to holochain conductor, please check that a conductor service is running and available at ${url}`));
};
socket.onopen = () => {
resolve(new WsClient(socket, signalCb));
};
});
throw new Error(`unknown message format ${JSON.stringify(message, null, 4)}`);
}
function assertHolochainSignal(signal) {
if (typeof signal === "object" &&
signal !== null &&
Object.values(SignalType).some((type) => type in signal)) {
return;
}
throw new Error(`unknown signal format ${JSON.stringify(signal, null, 4)}`);
}
const signalTransform = (res) => {
return decode(res);
};
//# sourceMappingURL=client.js.map

@@ -20,3 +20,3 @@ import { RoleName } from "../types.js";

export declare const catchError: (res: any) => Promise<any>;
export declare const promiseTimeout: (promise: Promise<any>, tag: string, ms: number) => Promise<unknown>;
export declare const promiseTimeout: (promise: Promise<unknown>, tag: string, ms: number) => Promise<unknown>;
export declare const isCloneId: (roleName: RoleName) => boolean;

@@ -23,0 +23,0 @@ export declare const getBaseRoleNameFromCloneId: (roleName: RoleName) => string;

@@ -5,3 +5,3 @@ import nacl from "tweetnacl";

export declare type Nonce256Bit = Uint8Array;
interface SigningCredentials {
export interface SigningCredentials {
capSecret: CapSecret;

@@ -38,2 +38,1 @@ keyPair: nacl.SignKeyPair;

export declare const getNonceExpiration: () => number;
export {};
import { InstalledAppId } from "../types.js";
import { CallZomeRequest, CallZomeRequestSigned } from "../api/index.js";
export interface LauncherEnvironment {
APP_INTERFACE_PORT: number;
ADMIN_INTERFACE_PORT: number;
INSTALLED_APP_ID: InstalledAppId;
APP_INTERFACE_PORT?: number;
ADMIN_INTERFACE_PORT?: number;
INSTALLED_APP_ID?: InstalledAppId;
}

@@ -8,0 +8,0 @@ declare const __HC_LAUNCHER_ENV__ = "__HC_LAUNCHER_ENV__";

@@ -28,2 +28,6 @@ export declare type HoloHash = Uint8Array;

export declare type Timestamp = number;
export interface Duration {
secs: number;
nanos: number;
}
export interface HoloHashed<T> {

@@ -30,0 +34,0 @@ hash: HoloHash;

{
"name": "@holochain/client",
"version": "0.11.9",
"version": "0.11.10",
"description": "A JavaScript client for the Holochain Conductor API",

@@ -38,3 +38,4 @@ "author": "Holochain Foundation <info@holochain.org> (http://holochain.org)",

"lint": "eslint --fix --ext .ts src test .eslintrc.cjs",
"test": "RUST_LOG=error RUST_BACKTRACE=1 node --experimental-wasm-modules --loader ts-node/esm test/index.ts",
"test:app-agent": "RUST_LOG=error RUST_BACKTRACE=1 node --loader ts-node/esm test/e2e/app-agent-websocket.ts",
"test": "RUST_LOG=error RUST_BACKTRACE=1 node --loader ts-node/esm test/index.ts",
"build": "rimraf ./lib && tsc -p tsconfig.build.json"

@@ -41,0 +42,0 @@ },

@@ -30,6 +30,6 @@ [![Project](https://img.shields.io/badge/Project-Holochain-blue.svg?style=flat-square)](http://holochain.org/)

### Use AppWebsocket with implicit zome call signing
### Use AppAgentWebsocket with implicit zome call signing
```typescript
const signalCb = (signal: AppSignal) => {
// impl...
// implementation of signal handler
resolve()

@@ -40,10 +40,12 @@ }

// default timeout is set to 12000
const client = await AppWebsocket.connect(`ws://127.0.0.1:${appPort}`, TIMEOUT, signalCb)
const appWs = await AppWebsocket.connect(`ws://127.0.0.1:${appPort}`, 12000)
const client = new AppAgentWebsocket(appWs, 'installed_app_id');
client.on("signal", signalCb);
// default timeout set here (30000) will overwrite the defaultTimeout(12000) set above
await client.callZome({
cell_id,
role_name: 'dnas_role_name', // role_name is unique per app, so you can unambiguously identify your dna with role_name in this client
zome_name: "test_zome",
fn_name: 'test_emitter_fn',
provenance: agentPubKey,
payload: null,

@@ -53,3 +55,3 @@ }, 30000)

### Use AppAgentWebsocket
### Use AppWebsocket with implicit zome call signing
```typescript

@@ -63,11 +65,10 @@ const signalCb = (signal: AppSignal) => {

// default timeout is set to 12000
const appWs = await AppWebsocket.connect(`ws://127.0.0.1:${appPort}`, 12000, signalCb)
const client = await AppWebsocket.connect(`ws://127.0.0.1:${appPort}`, TIMEOUT, signalCb)
const client = new AppAgentWebsocket(appWs, 'installed_app_id')
// default timeout set here (30000) will overwrite the defaultTimeout(12000) set above
await client.callZome({
role_name: 'dnas_role_name', // role_name is unique per app, so you can unambiguously identify your dna with role_name in this client
cell_id,
zome_name: "test_zome",
fn_name: 'test_emitter_fn',
provenance: agentPubKey,
payload: null,

@@ -77,2 +78,31 @@ }, 30000)

### Managing zome call signing credentials in a pure JavaScript browser application
Here is a pattern to manage signing keys for signing zome calls when running pure JavaScript web hApps in a web browser:
```typescript
const cellIdB64 =
encodeHashToBase64(cell_id[0]) + encodeHashToBase64(cell_id[1]);
// in case the zome call signing credentials are stored locally in the browser
const signingCredentialsJson = localStorage.getItem(cellIdB64);
let signingCredentials: SigningCredentials | null =
signingCredentialsJson && JSON.parse(signingCredentialsJson);
if (!signingCredentials) {
const [keyPair, signingKey] = generateSigningKeyPair();
const capSecret = await admin.grantSigningKey(
cell_id,
{ [GrantedFunctionsType.All]: null },
signingKey
);
signingCredentials = {
capSecret,
keyPair,
signingKey,
};
}
setSigningCredentials(cell_id, signingCredentials);
// possibly store the zome call signing credentials locally in the browser
localStorage.setItem(cellIdB64, JSON.stringify(signingCredentials));
```
## API Reference

@@ -79,0 +109,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc