Socket
Socket
Sign inDemoInstall

@holochain/client

Package Overview
Dependencies
Maintainers
13
Versions
93
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.13.0 to 0.14.0

lib/hdk/link.d.ts

162

lib/api/admin/types.d.ts

@@ -9,3 +9,3 @@ /// <reference types="node" />

*/
export declare type AttachAppInterfaceRequest = {
export type AttachAppInterfaceRequest = {
port: number;

@@ -16,3 +16,3 @@ };

*/
export declare type AttachAppInterfaceResponse = {
export type AttachAppInterfaceResponse = {
port: number;

@@ -23,3 +23,3 @@ };

*/
export declare type EnableAppRequest = {
export type EnableAppRequest = {
installed_app_id: InstalledAppId;

@@ -30,3 +30,3 @@ };

*/
export declare type EnableAppResponse = {
export type EnableAppResponse = {
app: AppInfo;

@@ -38,3 +38,3 @@ errors: Array<[CellId, string]>;

*/
export declare type DeactivationReason = {
export type DeactivationReason = {
never_activated: null;

@@ -51,3 +51,3 @@ } | {

*/
export declare type PausedAppReason = {
export type PausedAppReason = {
error: string;

@@ -58,3 +58,3 @@ };

*/
export declare type DisabledAppReason = {
export type DisabledAppReason = {
never_started: null;

@@ -69,3 +69,3 @@ } | {

*/
export declare type InstalledAppInfoStatus = {
export type InstalledAppInfoStatus = {
paused: {

@@ -119,3 +119,3 @@ reason: PausedAppReason;

*/
export declare type CellInfo = {
export type CellInfo = {
[CellType.Provisioned]: ProvisionedCell;

@@ -130,3 +130,3 @@ } | {

*/
export declare type AppInfo = {
export type AppInfo = {
agent_pub_key: AgentPubKey;

@@ -140,7 +140,7 @@ installed_app_id: InstalledAppId;

*/
export declare type MembraneProof = Buffer;
export type MembraneProof = Buffer;
/**
* @public
*/
export declare type DisableAppRequest = {
export type DisableAppRequest = {
installed_app_id: InstalledAppId;

@@ -151,7 +151,7 @@ };

*/
export declare type DisableAppResponse = null;
export type DisableAppResponse = null;
/**
* @public
*/
export declare type StartAppRequest = {
export type StartAppRequest = {
installed_app_id: InstalledAppId;

@@ -162,7 +162,7 @@ };

*/
export declare type StartAppResponse = boolean;
export type StartAppResponse = boolean;
/**
* @public
*/
export declare type DumpStateRequest = {
export type DumpStateRequest = {
cell_id: CellId;

@@ -173,7 +173,7 @@ };

*/
export declare type DumpStateResponse = any;
export type DumpStateResponse = any;
/**
* @public
*/
export declare type DumpFullStateRequest = {
export type DumpFullStateRequest = {
cell_id: CellId;

@@ -185,15 +185,15 @@ dht_ops_cursor: number | undefined;

*/
export declare type DumpFullStateResponse = FullStateDump;
export type DumpFullStateResponse = FullStateDump;
/**
* @public
*/
export declare type GenerateAgentPubKeyRequest = void;
export type GenerateAgentPubKeyRequest = void;
/**
* @public
*/
export declare type GenerateAgentPubKeyResponse = AgentPubKey;
export type GenerateAgentPubKeyResponse = AgentPubKey;
/**
* @public
*/
export declare type RegisterDnaRequest = {
export type RegisterDnaRequest = {
modifiers?: {

@@ -207,7 +207,7 @@ network_seed?: string;

*/
export declare type RegisterDnaResponse = HoloHash;
export type RegisterDnaResponse = HoloHash;
/**
* @public
*/
export declare type DnaModifiers = {
export type DnaModifiers = {
network_seed: NetworkSeed;

@@ -221,11 +221,11 @@ properties: DnaProperties;

*/
export declare type FunctionName = string;
export type FunctionName = string;
/**
* @public
*/
export declare type ZomeName = string;
export type ZomeName = string;
/**
* @public
*/
export declare type ZomeDefinition = [
export type ZomeDefinition = [
ZomeName,

@@ -240,11 +240,11 @@ {

*/
export declare type IntegrityZome = ZomeDefinition;
export type IntegrityZome = ZomeDefinition;
/**
* @public
*/
export declare type CoordinatorZome = ZomeDefinition;
export type CoordinatorZome = ZomeDefinition;
/**
* @public
*/
export declare type DnaDefinition = {
export type DnaDefinition = {
name: string;

@@ -258,11 +258,11 @@ modifiers: DnaModifiers;

*/
export declare type GetDnaDefinitionRequest = DnaHash;
export type GetDnaDefinitionRequest = DnaHash;
/**
* @public
*/
export declare type GetDnaDefinitionResponse = DnaDefinition;
export type GetDnaDefinitionResponse = DnaDefinition;
/**
* @public
*/
export declare type UninstallAppRequest = {
export type UninstallAppRequest = {
installed_app_id: InstalledAppId;

@@ -273,7 +273,7 @@ };

*/
export declare type UninstallAppResponse = null;
export type UninstallAppResponse = null;
/**
* @public
*/
export declare type UpdateCoordinatorsRequest = {
export type UpdateCoordinatorsRequest = {
dna_hash: DnaHash;

@@ -284,11 +284,11 @@ } & CoordinatorSource;

*/
export declare type UpdateCoordinatorsResponse = void;
export type UpdateCoordinatorsResponse = void;
/**
* @public
*/
export declare type ResourceBytes = Uint8Array;
export type ResourceBytes = Uint8Array;
/**
* @public
*/
export declare type ResourceMap = {
export type ResourceMap = {
[key: string]: ResourceBytes;

@@ -331,3 +331,3 @@ };

*/
export declare type Location = {
export type Location = {
/**

@@ -351,7 +351,7 @@ * Expect file to be part of this bundle

*/
export declare type DnaVersionSpec = Array<HoloHashB64>;
export type DnaVersionSpec = Array<HoloHashB64>;
/**
* @public
*/
export declare type DnaVersionFlexible = {
export type DnaVersionFlexible = {
singleton: HoloHashB64;

@@ -364,3 +364,3 @@ } | {

*/
export declare type AppRoleDnaManifest = {
export type AppRoleDnaManifest = {
clone_limit?: number;

@@ -373,3 +373,3 @@ modifiers?: Partial<DnaModifiers>;

*/
export declare type AppRoleManifest = {
export type AppRoleManifest = {
name: RoleName;

@@ -382,3 +382,3 @@ provisioning?: CellProvisioning;

*/
export declare type AppManifest = {
export type AppManifest = {
manifest_version: string;

@@ -392,3 +392,3 @@ name: string;

*/
export declare type AppBundle = {
export type AppBundle = {
manifest: AppManifest;

@@ -400,3 +400,3 @@ resources: ResourceMap;

*/
export declare type AppBundleSource = {
export type AppBundleSource = {
bundle: AppBundle;

@@ -409,7 +409,7 @@ } | {

*/
export declare type NetworkSeed = string;
export type NetworkSeed = string;
/**
* @public
*/
export declare type InstallAppRequest = {
export type InstallAppRequest = {
agent_key: AgentPubKey;

@@ -425,27 +425,27 @@ installed_app_id?: InstalledAppId;

*/
export declare type InstallAppResponse = AppInfo;
export type InstallAppResponse = AppInfo;
/**
* @public
*/
export declare type ListDnasRequest = void;
export type ListDnasRequest = void;
/**
* @public
*/
export declare type ListDnasResponse = Array<string>;
export type ListDnasResponse = Array<string>;
/**
* @public
*/
export declare type ListCellIdsRequest = void;
export type ListCellIdsRequest = void;
/**
* @public
*/
export declare type ListCellIdsResponse = Array<CellId>;
export type ListCellIdsResponse = Array<CellId>;
/**
* @public
*/
export declare type ListActiveAppsRequest = void;
export type ListActiveAppsRequest = void;
/**
* @public
*/
export declare type ListActiveAppsResponse = Array<InstalledAppId>;
export type ListActiveAppsResponse = Array<InstalledAppId>;
/**

@@ -464,3 +464,3 @@ * @public

*/
export declare type ListAppsRequest = {
export type ListAppsRequest = {
status_filter?: AppStatusFilter;

@@ -471,11 +471,11 @@ };

*/
export declare type ListAppsResponse = Array<AppInfo>;
export type ListAppsResponse = Array<AppInfo>;
/**
* @public
*/
export declare type ListAppInterfacesRequest = void;
export type ListAppInterfacesRequest = void;
/**
* @public
*/
export declare type ListAppInterfacesResponse = Array<number>;
export type ListAppInterfacesResponse = Array<number>;
/**

@@ -486,7 +486,7 @@ * This type is meant to be opaque

*/
export declare type AgentInfoSigned = unknown;
export type AgentInfoSigned = unknown;
/**
* @public
*/
export declare type AgentInfoRequest = {
export type AgentInfoRequest = {
cell_id: CellId | null;

@@ -497,7 +497,7 @@ };

*/
export declare type AgentInfoResponse = Array<AgentInfoSigned>;
export type AgentInfoResponse = Array<AgentInfoSigned>;
/**
* @public
*/
export declare type AddAgentInfoRequest = {
export type AddAgentInfoRequest = {
agent_infos: Array<AgentInfoSigned>;

@@ -508,11 +508,11 @@ };

*/
export declare type AddAgentInfoResponse = any;
export type AddAgentInfoResponse = any;
/**
* @public
*/
export declare type DeleteCloneCellRequest = DisableCloneCellRequest;
export type DeleteCloneCellRequest = DisableCloneCellRequest;
/**
* @public
*/
export declare type DeleteCloneCellResponse = void;
export type DeleteCloneCellResponse = void;
/**

@@ -535,7 +535,7 @@ * @public

*/
export declare type GrantZomeCallCapabilityResponse = void;
export type GrantZomeCallCapabilityResponse = void;
/**
* @public
*/
export declare type InstallAppDnaPayload = {
export type InstallAppDnaPayload = {
hash: HoloHash;

@@ -548,3 +548,3 @@ role_name: RoleName;

*/
export declare type ZomeLocation = Location;
export type ZomeLocation = Location;
/**

@@ -559,3 +559,3 @@ * @public

*/
export declare type ZomeManifest = {
export type ZomeManifest = {
name: string;

@@ -581,3 +581,3 @@ hash?: string;

*/
export declare type CoordinatorSource = {
export type CoordinatorSource = {
path: string;

@@ -590,3 +590,3 @@ } | {

*/
export declare type DnaManifest = {
export type DnaManifest = {
/**

@@ -617,3 +617,3 @@ * Currently one "1" is supported

*/
export declare type DnaBundle = {
export type DnaBundle = {
manifest: DnaManifest;

@@ -625,3 +625,3 @@ resources: ResourceMap;

*/
export declare type DnaSource = {
export type DnaSource = {
hash: HoloHash;

@@ -636,3 +636,3 @@ } | {

*/
export declare type Zomes = Array<[string, {
export type Zomes = Array<[string, {
wasm_hash: Array<HoloHash>;

@@ -643,3 +643,3 @@ }]>;

*/
export declare type WasmCode = [HoloHash, {
export type WasmCode = [HoloHash, {
code: Array<number>;

@@ -725,3 +725,3 @@ }];

export interface DnaStorageBlob {
Dna: DnaStorageInfo;
dna: DnaStorageInfo;
}

@@ -737,15 +737,15 @@ /**

*/
export declare type StorageInfoRequest = void;
export type StorageInfoRequest = void;
/**
* @public
*/
export declare type StorageInfoResponse = StorageInfo;
export type StorageInfoResponse = StorageInfo;
/**
* @public
*/
export declare type DumpNetworkStatsRequest = void;
export type DumpNetworkStatsRequest = void;
/**
* @public
*/
export declare type DumpNetworkStatsResponse = string;
export type DumpNetworkStatsResponse = string;
/**

@@ -752,0 +752,0 @@ * @public

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

grantSigningKey = async (cellId, functions, signingKey) => {
const capSecret = await randomCapSecret();
const capSecret = randomCapSecret();
await this.grantZomeCallCapability({

@@ -163,3 +163,3 @@ cell_id: cellId,

authorizeSigningCredentials = async (cellId, functions) => {
const [keyPair, signingKey] = generateSigningKeyPair();
const [keyPair, signingKey] = await generateSigningKeyPair();
const capSecret = await this.grantSigningKey(cellId, functions || { [GrantedFunctionsType.All]: null }, signingKey);

@@ -166,0 +166,0 @@ setSigningCredentials(cellId, { capSecret, keyPair, signingKey });

@@ -8,7 +8,7 @@ import { UnsubscribeFunction } from "emittery";

*/
export declare type NonProvenanceCallZomeRequest = Omit<CallZomeRequest, "provenance">;
export type NonProvenanceCallZomeRequest = Omit<CallZomeRequest, "provenance">;
/**
* @public
*/
export declare type RoleNameCallZomeRequest = Omit<NonProvenanceCallZomeRequest, "cell_id"> & {
export type RoleNameCallZomeRequest = Omit<NonProvenanceCallZomeRequest, "cell_id"> & {
role_name: RoleName;

@@ -19,3 +19,3 @@ };

*/
export declare type RoleNameCallZomeRequestSigned = Omit<CallZomeRequestSigned, "cell_id"> & {
export type RoleNameCallZomeRequestSigned = Omit<CallZomeRequestSigned, "cell_id"> & {
role_name: RoleName;

@@ -26,15 +26,15 @@ };

*/
export declare type AppAgentCallZomeRequest = NonProvenanceCallZomeRequest | RoleNameCallZomeRequest | CallZomeRequestSigned | RoleNameCallZomeRequestSigned;
export type AppAgentCallZomeRequest = NonProvenanceCallZomeRequest | RoleNameCallZomeRequest | CallZomeRequestSigned | RoleNameCallZomeRequestSigned;
/**
* @public
*/
export declare type AppCreateCloneCellRequest = Omit<CreateCloneCellRequest, "app_id">;
export type AppCreateCloneCellRequest = Omit<CreateCloneCellRequest, "app_id">;
/**
* @public
*/
export declare type AppEnableCloneCellRequest = Omit<EnableCloneCellRequest, "app_id">;
export type AppEnableCloneCellRequest = Omit<EnableCloneCellRequest, "app_id">;
/**
* @public
*/
export declare type AppDisableCloneCellRequest = Omit<DisableCloneCellRequest, "app_id">;
export type AppDisableCloneCellRequest = Omit<DisableCloneCellRequest, "app_id">;
/**

@@ -41,0 +41,0 @@ * @public

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

@@ -5,0 +7,0 @@ /**

import Emittery from "emittery";
import { omit } from "lodash-es";
import { getLauncherEnvironment } from "../../environments/launcher.js";
import { CellType } from "../admin/types.js";
import { AppWebsocket } from "../app/websocket.js";
import { getBaseRoleNameFromCloneId, isCloneId } from "../common.js";
import { AppWebsocket, CellType, } from "../index.js";
/**

@@ -7,0 +8,0 @@ * A class to establish a websocket connection to an App interface, for a

import { AgentPubKey, CellId, DnaHash, DnaProperties, InstalledAppId, NetworkInfo, RoleName, Timestamp } from "../../types.js";
import { AppInfo, ClonedCell, FunctionName, MembraneProof, NetworkSeed, ZomeName } from "../admin/index.js";
import { AppInfo, ClonedCell, FunctionName, MembraneProof, NetworkSeed, ZomeName } from "../admin/types.js";
import { Requester } from "../common.js";

@@ -7,3 +7,3 @@ /**

*/
export declare type CallZomeRequestGeneric<Payload> = {
export type CallZomeRequestGeneric<Payload> = {
cell_id: CellId;

@@ -18,15 +18,15 @@ zome_name: ZomeName;

*/
export declare type CallZomeRequest = CallZomeRequestGeneric<any>;
export type CallZomeRequest = CallZomeRequestGeneric<any>;
/**
* @public
*/
export declare type CallZomeResponseGeneric<Payload> = Payload;
export type CallZomeResponseGeneric<Payload> = Payload;
/**
* @public
*/
export declare type CallZomeResponse = CallZomeResponseGeneric<any>;
export type CallZomeResponse = CallZomeResponseGeneric<any>;
/**
* @public
*/
export declare type AppInfoRequest = {
export type AppInfoRequest = {
installed_app_id: InstalledAppId;

@@ -37,3 +37,3 @@ };

*/
export declare type AppInfoResponse = AppInfo;
export type AppInfoResponse = AppInfo;
/**

@@ -89,3 +89,3 @@ * @public

*/
export declare type CreateCloneCellResponse = ClonedCell;
export type CreateCloneCellResponse = ClonedCell;
/**

@@ -107,11 +107,11 @@ * @public

*/
export declare type DisableCloneCellResponse = void;
export type DisableCloneCellResponse = void;
/**
* @public
*/
export declare type EnableCloneCellRequest = DisableCloneCellRequest;
export type EnableCloneCellRequest = DisableCloneCellRequest;
/**
* @public
*/
export declare type EnableCloneCellResponse = CreateCloneCellResponse;
export type EnableCloneCellResponse = CreateCloneCellResponse;
/**

@@ -122,5 +122,13 @@ * @public

/**
* The DNAs for which to get network info
* The calling agent
*/
agent_pub_key: AgentPubKey;
/**
* Get network info for these DNAs
*/
dnas: DnaHash[];
/**
* Timestamp in ms since which received amount of bytes from peers will be returned. Defaults to UNIX_EPOCH.
*/
last_time_queried?: number;
}

@@ -137,3 +145,3 @@ /**

*/
export declare type Signal = {
export type Signal = {
[SignalType.App]: EncodedAppSignal;

@@ -146,3 +154,3 @@ } | {

*/
export declare type EncodedAppSignal = {
export type EncodedAppSignal = {
cell_id: CellId;

@@ -155,3 +163,3 @@ zome_name: string;

*/
export declare type AppSignal = {
export type AppSignal = {
cell_id: CellId;

@@ -164,7 +172,7 @@ zome_name: string;

*/
export declare type AppSignalCb = (signal: AppSignal) => void;
export type AppSignalCb = (signal: AppSignal) => void;
/**
* @public
*/
export declare type NetworkInfoResponse = NetworkInfo[];
export type NetworkInfoResponse = NetworkInfo[];
/**

@@ -171,0 +179,0 @@ * @public

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

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>;
_requester<ReqI, ReqO, ResI, ResO>(tag: string, transformer?: Transformer<ReqI, ReqO, ResI, ResO>): (req: ReqI, timeout?: number | undefined) => Promise<ResO>;
/**

@@ -30,0 +30,0 @@ * Request the app's info, including all cell infos.

import { hashZomeCall } from "@holochain/serialization";
import { decode, encode } from "@msgpack/msgpack";
import * as ed25519 from "@noble/ed25519";
import Emittery from "emittery";
import nacl from "tweetnacl";
import { getLauncherEnvironment, isLauncher, signZomeCallTauri, } from "../../environments/launcher.js";
import { encodeHashToBase64 } from "../../utils/base64.js";
import { WsClient } from "../client.js";
import { catchError, DEFAULT_TIMEOUT, promiseTimeout, requesterTransformer, } from "../common.js";
import { DEFAULT_TIMEOUT, catchError, promiseTimeout, requesterTransformer, } from "../common.js";
import { getNonceExpiration, getSigningCredentials, randomNonce, } from "../zome-call-signing.js";

@@ -45,3 +45,5 @@ /**

}
_requester = (tag, transformer) => requesterTransformer((req, timeout) => promiseTimeout(this.client.request(req), tag, timeout || this.defaultTimeout).then(catchError), tag, transformer);
_requester(tag, transformer) {
return requesterTransformer((req, timeout) => promiseTimeout(this.client.request(req), tag, timeout || this.defaultTimeout).then(catchError), tag, transformer);
}
/**

@@ -124,9 +126,7 @@ * Request the app's info, including all cell infos.

payload: encode(request.payload),
nonce: await randomNonce(),
nonce: randomNonce(),
expires_at: getNonceExpiration(),
};
const hashedZomeCall = await hashZomeCall(unsignedZomeCallPayload);
const signature = nacl
.sign(hashedZomeCall, signingCredentialsForCell.keyPair.secretKey)
.subarray(0, nacl.sign.signatureLength);
const signature = await ed25519.signAsync(hashedZomeCall, signingCredentialsForCell.keyPair.privateKey);
const signedZomeCall = {

@@ -133,0 +133,0 @@ ...unsignedZomeCallPayload,

/// <reference types="ws" />
import { decode } from "@msgpack/msgpack";
import Emittery from "emittery";
import Websocket from "isomorphic-ws";
import IsoWebSocket from "isomorphic-ws";
/**
* A Websocket client which can make requests and receive responses,
* A WebSocket client which can make requests and receive responses,
* as well as send and receive signals.

@@ -14,3 +14,3 @@ *

export declare class WsClient extends Emittery {
socket: Websocket;
socket: IsoWebSocket;
pendingRequests: Record<number, {

@@ -21,3 +21,3 @@ resolve: (msg: unknown) => ReturnType<typeof decode>;

index: number;
constructor(socket: Websocket);
constructor(socket: IsoWebSocket);
/**

@@ -47,3 +47,4 @@ * Instance factory for creating WsClients.

*/
close(code?: number): Promise<void>;
close(code?: number): Promise<CloseEvent>;
}
export { IsoWebSocket };
import { decode, encode } from "@msgpack/msgpack";
import Emittery from "emittery";
import Websocket from "isomorphic-ws";
import IsoWebSocket from "isomorphic-ws";
import { SignalType } from "./app/types.js";
/**
* A Websocket client which can make requests and receive responses,
* A WebSocket client which can make requests and receive responses,
* as well as send and receive signals.

@@ -25,4 +25,4 @@ *

let deserializedData;
if (typeof window === "object" &&
serializedMessage.data instanceof window.Blob) {
if (globalThis.window &&
serializedMessage.data instanceof globalThis.window.Blob) {
deserializedData = await serializedMessage.data.arrayBuffer();

@@ -87,3 +87,3 @@ }

return new Promise((resolve, reject) => {
const socket = new Websocket(url);
const socket = new IsoWebSocket(url);
// make sure that there are no uncaught connection

@@ -156,4 +156,10 @@ // errors because that causes nodejs thread to crash

*/
close(code) {
const closedPromise = new Promise((resolve) => this.socket.on("close", resolve));
close(code = 1000) {
const closedPromise = new Promise((resolve) =>
// for an unknown reason "addEventListener" is seen as a non-callable
// property and gives a ts2349 error
// type assertion as workaround
this.socket.addEventListener("close", (event) => resolve(event))
// }
);
this.socket.close(code);

@@ -180,1 +186,2 @@ return closedPromise;

}
export { IsoWebSocket };
import { RoleName } from "../types.js";
export declare const DEFAULT_TIMEOUT = 15000;
export declare const DEFAULT_TIMEOUT = 60000;
/**
* @public
*/
export declare type Transformer<ReqI, ReqO, ResI, ResO> = {
export type Transformer<ReqI, ReqO, ResI, ResO> = {
input: (req: ReqI) => ReqO;

@@ -13,11 +13,11 @@ output: (res: ResI) => ResO;

*/
export declare type Requester<Req, Res> = (req: Req, timeout?: number) => Promise<Res>;
export type Requester<Req, Res> = (req: Req, timeout?: number) => Promise<Res>;
/**
* @public
*/
export declare type RequesterUnit<Res> = () => Promise<Res>;
export type RequesterUnit<Res> = () => Promise<Res>;
/**
* @public
*/
export declare type Tagged<T> = {
export type Tagged<T> = {
type: string;

@@ -24,0 +24,0 @@ data: T;

const ERROR_TYPE = "error";
export const DEFAULT_TIMEOUT = 15000;
export const DEFAULT_TIMEOUT = 60000;
/**

@@ -4,0 +4,0 @@ * Take a Requester function which deals with tagged requests and responses,

@@ -5,4 +5,4 @@ export { hashZomeCall } from "@holochain/serialization";

export * from "./app/index.js";
export { IsoWebSocket, WsClient } from "./client.js";
export { CloneId, Requester, Transformer } from "./common.js";
export { WsClient } from "./client.js";
export * from "./zome-call-signing.js";

@@ -5,4 +5,4 @@ export { hashZomeCall } from "@holochain/serialization";

export * from "./app/index.js";
export { IsoWebSocket, WsClient } from "./client.js";
export { CloneId } from "./common.js";
export { WsClient } from "./client.js";
export * from "./zome-call-signing.js";

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

import nacl from "tweetnacl";
import { CapSecret } from "../hdk/capabilities.js";

@@ -7,9 +6,16 @@ import { AgentPubKey, CellId } from "../types.js";

*/
export declare type Nonce256Bit = Uint8Array;
export type Nonce256Bit = Uint8Array;
/**
* @public
*/
export interface KeyPair {
privateKey: Uint8Array;
publicKey: Uint8Array;
}
/**
* @public
*/
export interface SigningCredentials {
capSecret: CapSecret;
keyPair: nacl.SignKeyPair;
keyPair: KeyPair;
signingKey: AgentPubKey;

@@ -41,18 +47,18 @@ }

*/
export declare const generateSigningKeyPair: () => [
nacl.SignKeyPair,
export declare const generateSigningKeyPair: () => Promise<[
KeyPair,
AgentPubKey
];
]>;
/**
* @public
*/
export declare const randomCapSecret: () => Promise<CapSecret>;
export declare const randomCapSecret: () => CapSecret;
/**
* @public
*/
export declare const randomNonce: () => Promise<Nonce256Bit>;
export declare const randomNonce: () => Nonce256Bit;
/**
* @public
*/
export declare const randomByteArray: (length: number) => Promise<Uint8Array>;
export declare const randomByteArray: (length: number) => Uint8Array;
/**

@@ -59,0 +65,0 @@ * @public

@@ -1,3 +0,7 @@

import nacl from "tweetnacl";
import * as ed25519 from "@noble/ed25519";
import { encodeHashToBase64 } from "../utils/base64.js";
import { webcrypto } from "crypto";
if (!globalThis.crypto) {
globalThis.crypto = webcrypto;
}
const signingCredentials = new Map();

@@ -34,5 +38,7 @@ /**

*/
export const generateSigningKeyPair = () => {
const keyPair = nacl.sign.keyPair();
const signingKey = new Uint8Array([132, 32, 36].concat(...keyPair.publicKey).concat(...[0, 0, 0, 0]));
export const generateSigningKeyPair = async () => {
const privateKey = ed25519.utils.randomPrivateKey();
const publicKey = await ed25519.getPublicKeyAsync(privateKey);
const keyPair = { privateKey, publicKey };
const signingKey = new Uint8Array([132, 32, 36].concat(...publicKey).concat(...[0, 0, 0, 0]));
return [keyPair, signingKey];

@@ -47,17 +53,7 @@ };

*/
export const randomNonce = async () => randomByteArray(32);
export const randomNonce = () => randomByteArray(32);
/**
* @public
*/
export const randomByteArray = async (length) => {
if (typeof window !== "undefined" &&
"crypto" in window &&
"getRandomValues" in window.crypto) {
return window.crypto.getRandomValues(new Uint8Array(length));
}
else {
const crypto = await import("crypto");
return new Uint8Array(crypto.randomBytes(length));
}
};
export const randomByteArray = (length) => globalThis.crypto.getRandomValues(new Uint8Array(length));
/**

@@ -64,0 +60,0 @@ * @public

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

import { CallZomeRequest } from "../api/app/types.js";
import { CallZomeRequestSigned } from "../api/app/websocket.js";
import { InstalledAppId } from "../types.js";
import { CallZomeRequest, CallZomeRequestSigned } from "../api/index.js";
export interface LauncherEnvironment {

@@ -4,0 +5,0 @@ APP_INTERFACE_PORT?: number;

@@ -0,7 +1,7 @@

import { encode } from "@msgpack/msgpack";
import { invoke } from "@tauri-apps/api/tauri";
import { getNonceExpiration, randomNonce, } from "../api/index.js";
import { encode } from "@msgpack/msgpack";
import { getNonceExpiration, randomNonce } from "../api/zome-call-signing.js";
const __HC_LAUNCHER_ENV__ = "__HC_LAUNCHER_ENV__";
export const isLauncher = typeof window === "object" && __HC_LAUNCHER_ENV__ in window;
export const getLauncherEnvironment = () => isLauncher ? 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) => {

@@ -14,3 +14,3 @@ const zomeCallUnsigned = {

payload: Array.from(encode(request.payload)),
nonce: Array.from(await randomNonce()),
nonce: Array.from(randomNonce()),
expires_at: getNonceExpiration(),

@@ -17,0 +17,0 @@ };

@@ -13,3 +13,3 @@ import { AgentPubKey, DnaHash, EntryHash, ActionHash, HoloHashed, Signature, Timestamp } from "../types.js";

*/
export declare type ActionHashed = HoloHashed<Action>;
export type ActionHashed = HoloHashed<Action>;
/**

@@ -33,7 +33,7 @@ * @public

*/
export declare type Action = Dna | AgentValidationPkg | InitZomesComplete | CreateLink | DeleteLink | OpenChain | CloseChain | Delete | NewEntryAction;
export type Action = Dna | AgentValidationPkg | InitZomesComplete | CreateLink | DeleteLink | OpenChain | CloseChain | Delete | NewEntryAction;
/**
* @public
*/
export declare type NewEntryAction = Create | Update;
export type NewEntryAction = Create | Update;
/**

@@ -40,0 +40,0 @@ * @public

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

import { FunctionName, ZomeName } from "../api/index.js";
import { FunctionName, ZomeName } from "../api/admin/types.js";
import { AgentPubKey } from "../types.js";

@@ -6,3 +6,3 @@ /**

*/
export declare type CapSecret = Uint8Array;
export type CapSecret = Uint8Array;
/**

@@ -26,3 +26,3 @@ * @public

*/
export declare type GrantedFunctions = {
export type GrantedFunctions = {
[GrantedFunctionsType.All]: null;

@@ -43,3 +43,3 @@ } | {

*/
export declare type CapAccess = "Unrestricted" | {
export type CapAccess = "Unrestricted" | {
Transferable: {

@@ -57,3 +57,3 @@ secret: CapSecret;

*/
export declare type CapGrant = {
export type CapGrant = {
ChainAuthor: AgentPubKey;

@@ -60,0 +60,0 @@ } | {

@@ -31,3 +31,3 @@ import { ActionHash, AgentPubKey, EntryHash, Signature, Timestamp } from "../types.js";

*/
export declare type ActionBase = {
export type ActionBase = {
Create: CreateBase;

@@ -54,11 +54,11 @@ } | {

*/
export declare type CounterSigningAgents = Array<[AgentPubKey, Array<Role>]>;
export type CounterSigningAgents = Array<[AgentPubKey, Array<Role>]>;
/**
* @public
*/
export declare type PreflightBytes = Uint8Array;
export type PreflightBytes = Uint8Array;
/**
* @public
*/
export declare type Role = number;
export type Role = number;
/**

@@ -65,0 +65,0 @@ * @public

@@ -21,3 +21,3 @@ import { Signature } from "../types.js";

*/
export declare type DhtOp = {
export type DhtOp = {
[DhtOpType.StoreRecord]: [Signature, Action, Entry | undefined];

@@ -24,0 +24,0 @@ } | {

@@ -7,3 +7,3 @@ import { CapClaim, ZomeCallCapGrant } from "./capabilities.js";

*/
export declare type EntryVisibility = {
export type EntryVisibility = {
Public: null;

@@ -16,3 +16,3 @@ } | {

*/
export declare type AppEntryDef = {
export type AppEntryDef = {
entry_index: number;

@@ -25,3 +25,3 @@ zome_index: number;

*/
export declare type EntryType = "Agent" | {
export type EntryType = "Agent" | {
App: AppEntryDef;

@@ -39,2 +39,2 @@ } | "CapClaim" | "CapGrant";

*/
export declare type Entry = EntryContent<"Agent", AgentPubKey> | EntryContent<"App", Uint8Array> | EntryContent<"CounterSign", [CounterSigningSessionData, Uint8Array]> | EntryContent<"CapGrant", ZomeCallCapGrant> | EntryContent<"CapClaim", CapClaim>;
export type Entry = EntryContent<"Agent", AgentPubKey> | EntryContent<"App", Uint8Array> | EntryContent<"CounterSign", [CounterSigningSessionData, Uint8Array]> | EntryContent<"CapGrant", ZomeCallCapGrant> | EntryContent<"CapClaim", CapClaim>;

@@ -6,3 +6,3 @@ import { SignedActionHashed } from "./action.js";

*/
export declare type Record = {
export type Record = {
signed_action: SignedActionHashed;

@@ -14,3 +14,3 @@ entry: RecordEntry;

*/
export declare type RecordEntry = {
export type RecordEntry = {
Present: Entry;

@@ -17,0 +17,0 @@ } | {

@@ -8,5 +8,5 @@ // This file is read by tools that parse documentation comments conforming to the TSDoc standard.

"packageName": "@microsoft/api-extractor",
"packageVersion": "7.33.7"
"packageVersion": "7.34.4"
}
]
}
/**
* @public
*/
export declare type HoloHash = Uint8Array;
export type HoloHash = Uint8Array;
/**
* @public
*/
export declare type AgentPubKey = HoloHash;
export type AgentPubKey = HoloHash;
/**
* @public
*/
export declare type DnaHash = HoloHash;
export type DnaHash = HoloHash;
/**
* @public
*/
export declare type WasmHash = HoloHash;
export type WasmHash = HoloHash;
/**
* @public
*/
export declare type EntryHash = HoloHash;
export type EntryHash = HoloHash;
/**
* @public
*/
export declare type ActionHash = HoloHash;
export type ActionHash = HoloHash;
/**
* @public
*/
export declare type AnyDhtHash = HoloHash;
export type AnyDhtHash = HoloHash;
/**
* @public
*/
export declare type KitsuneAgent = Uint8Array;
export type ExternalHash = HoloHash;
/**
* @public
*/
export declare type KitsuneSpace = Uint8Array;
export type KitsuneAgent = Uint8Array;
/**
* @public
*/
export type KitsuneSpace = Uint8Array;
/** Base64 hash types */

@@ -41,51 +45,51 @@ /**

*/
export declare type HoloHashB64 = string;
export type HoloHashB64 = string;
/**
* @public
*/
export declare type AgentPubKeyB64 = HoloHashB64;
export type AgentPubKeyB64 = HoloHashB64;
/**
* @public
*/
export declare type DnaHashB64 = HoloHashB64;
export type DnaHashB64 = HoloHashB64;
/**
* @public
*/
export declare type WasmHashB64 = HoloHashB64;
export type WasmHashB64 = HoloHashB64;
/**
* @public
*/
export declare type EntryHashB64 = HoloHashB64;
export type EntryHashB64 = HoloHashB64;
/**
* @public
*/
export declare type ActionHashB64 = HoloHashB64;
export type ActionHashB64 = HoloHashB64;
/**
* @public
*/
export declare type AnyDhtHashB64 = HoloHashB64;
export type AnyDhtHashB64 = HoloHashB64;
/**
* @public
*/
export declare type InstalledAppId = string;
export type InstalledAppId = string;
/**
* @public
*/
export declare type Signature = Uint8Array;
export type Signature = Uint8Array;
/**
* @public
*/
export declare type CellId = [DnaHash, AgentPubKey];
export type CellId = [DnaHash, AgentPubKey];
/**
* @public
*/
export declare type DnaProperties = unknown;
export type DnaProperties = unknown;
/**
* @public
*/
export declare type RoleName = string;
export type RoleName = string;
/**
* @public
*/
export declare type InstalledCell = {
export type InstalledCell = {
cell_id: CellId;

@@ -97,3 +101,3 @@ role_name: RoleName;

*/
export declare type Timestamp = number;
export type Timestamp = number;
/**

@@ -100,0 +104,0 @@ * @public

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

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

"engines": {
"node": "^14.13.1 || >=16.0.0 || >=18.0.0"
"node": ">=16.0.0 || >=18.0.0"
},

@@ -34,5 +34,2 @@ "main": "lib/index.js",

],
"browser": {
"crypto": false
},
"scripts": {

@@ -42,4 +39,5 @@ "lint": "eslint --fix --ext .ts src test .eslintrc.cjs",

"test": "RUST_LOG=error RUST_BACKTRACE=1 node --loader ts-node/esm test/index.ts",
"build:lib": "rimraf ./lib && tsc -p tsconfig.build.json",
"build:docs": "api-extractor run --local && api-documenter markdown -i docs/temp -o docs",
"build": "rimraf ./lib && tsc -p tsconfig.build.json && npm run build:docs"
"build": "npm run build:lib && npm run build:docs"
},

@@ -49,2 +47,3 @@ "dependencies": {

"@msgpack/msgpack": "^2.7.2",
"@noble/ed25519": "^2.0.0",
"@tauri-apps/api": "^1.2.0",

@@ -55,7 +54,7 @@ "emittery": "^1.0.1",

"lodash-es": "^4.17.21",
"tweetnacl": "^1.0.3"
"ws": "^8.13.0"
},
"devDependencies": {
"@microsoft/api-documenter": "^7.19.27",
"@microsoft/api-extractor": "^7.33.7",
"@microsoft/api-documenter": "^7.21.7",
"@microsoft/api-extractor": "^7.34.4",
"@types/js-yaml": "^3.12.7",

@@ -75,5 +74,5 @@ "@types/lodash-es": "^4.17.6",

"tape": "^5.5.3",
"ts-node": "^10.8.1",
"typescript": "^4.7.2"
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
}
}
[![Project](https://img.shields.io/badge/Project-Holochain-blue.svg?style=flat-square)](http://holochain.org/)
[![Discord](https://img.shields.io/badge/Discord-DEV.HC-blue.svg?style=flat-square)](https://discord.gg/k55DS5dmPH)
[![License: CAL 1.0](https://img.shields.io/badge/License-CAL%201.0-blue.svg)](https://github.com/holochain/cryptographic-autonomy-license)
![Test](https://github.com/holochain/holochain-client-js/actions/workflows/test.yml/badge.svg?branch=main)
![Integration Tests](https://github.com/holochain/holochain-client-js/actions/workflows/integration-test.yml/badge.svg?branch=main)
![Bundling Tests](https://github.com/holochain/holochain-client-js/actions/workflows/bundling-test.yml/badge.svg?branch=main)
[![Twitter Follow](https://img.shields.io/twitter/follow/holochain.svg?style=social&label=Follow)](https://twitter.com/holochain)

@@ -17,3 +18,3 @@

**JS client v0.12.x** is compatible with **Holochain v0.1.x**.
**JS client v0.12.x** is compatible with **Holochain v0.1.x**.
**JS client v0.13.x** is compatible with **Holochain v0.2.x**.

@@ -20,0 +21,0 @@

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