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.13 to 0.11.14

lib/tsdoc-metadata.json

1

lib/api/admin/index.js
export * from "./types.js";
export * from "./websocket.js";
//# sourceMappingURL=index.js.map

@@ -6,11 +6,23 @@ /// <reference types="node" />

import { DisableCloneCellRequest } from "../index.js";
/**
* @public
*/
export declare type AttachAppInterfaceRequest = {
port: number;
};
/**
* @public
*/
export declare type AttachAppInterfaceResponse = {
port: number;
};
/**
* @public
*/
export declare type EnableAppRequest = {
installed_app_id: InstalledAppId;
};
/**
* @public
*/
export declare type EnableAppResponse = {

@@ -20,2 +32,5 @@ app: AppInfo;

};
/**
* @public
*/
export declare type DeactivationReason = {

@@ -30,5 +45,11 @@ never_activated: null;

};
/**
* @public
*/
export declare type PausedAppReason = {
error: string;
};
/**
* @public
*/
export declare type DisabledAppReason = {

@@ -41,2 +62,5 @@ never_started: null;

};
/**
* @public
*/
export declare type InstalledAppInfoStatus = {

@@ -53,2 +77,5 @@ paused: {

};
/**
* @public
*/
export interface StemCell {

@@ -59,2 +86,5 @@ dna: DnaHash;

}
/**
* @public
*/
export interface Cell {

@@ -67,2 +97,5 @@ cell_id: CellId;

}
/**
* @public
*/
export declare enum CellType {

@@ -73,2 +106,5 @@ Provisioned = "Provisioned",

}
/**
* @public
*/
export declare type CellInfo = {

@@ -81,2 +117,5 @@ [CellType.Provisioned]: Cell;

};
/**
* @public
*/
export declare type AppInfo = {

@@ -87,15 +126,39 @@ installed_app_id: InstalledAppId;

};
/**
* @public
*/
export declare type MembraneProof = Buffer;
/**
* @public
*/
export declare type DisableAppRequest = {
installed_app_id: InstalledAppId;
};
/**
* @public
*/
export declare type DisableAppResponse = null;
/**
* @public
*/
export declare type StartAppRequest = {
installed_app_id: InstalledAppId;
};
/**
* @public
*/
export declare type StartAppResponse = boolean;
/**
* @public
*/
export declare type DumpStateRequest = {
cell_id: CellId;
};
/**
* @public
*/
export declare type DumpStateResponse = any;
/**
* @public
*/
export declare type DumpFullStateRequest = {

@@ -105,5 +168,17 @@ cell_id: CellId;

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

@@ -115,3 +190,9 @@ modifiers?: {

} & DnaSource;
/**
* @public
*/
export declare type RegisterDnaResponse = HoloHash;
/**
* @public
*/
export declare type DnaModifiers = {

@@ -123,4 +204,13 @@ network_seed: NetworkSeed;

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

@@ -133,4 +223,13 @@ ZomeName,

];
/**
* @public
*/
export declare type IntegrityZome = ZomeDefinition;
/**
* @public
*/
export declare type CoordinatorZome = ZomeDefinition;
/**
* @public
*/
export declare type DnaDefinition = {

@@ -142,39 +241,88 @@ name: string;

};
/**
* @public
*/
export declare type GetDnaDefinitionRequest = DnaHash;
/**
* @public
*/
export declare type GetDnaDefinitionResponse = DnaDefinition;
/**
* @public
*/
export declare type UninstallAppRequest = {
installed_app_id: InstalledAppId;
};
/**
* @public
*/
export declare type UninstallAppResponse = null;
/**
* @public
*/
export declare type ResourceBytes = number[];
/**
* @public
*/
export declare type ResourceMap = {
[key: string]: ResourceBytes;
};
export declare type CellProvisioning = {
create: {
deferred: boolean;
};
} | {
create_clone: {
deferred: boolean;
};
} | {
use_existing: {
deferred: boolean;
};
} | {
create_if_no_exists: {
deferred: boolean;
};
} | {
disabled: Record<string, never>;
};
/**
* @public
*/
export declare enum CellProvisioningStrategy {
/**
* Always create a new Cell when installing this App
*/
Create = "create",
/**
* Always create a new Cell when installing the App,
* and use a unique network seed to ensure a distinct DHT network.
*
* Not implemented
*/
/**
* Require that a Cell is already installed which matches the DNA version
* spec, and which has an Agent that's associated with this App's agent
* via DPKI. If no such Cell exists, *app installation fails*.
*/
UseExisting = "use_existing",
/**
* Try `UseExisting`, and if that fails, fallback to `Create`
*/
CreateIfNoExists = "create_if_no_exists"
}
/**
* @public
*/
export interface CellProvisioning {
strategy: CellProvisioningStrategy;
deferred?: boolean;
}
/**
* @public
*/
export declare type Location = {
/**
* Expect file to be part of this bundle
*/
bundled: string;
} | {
/**
* Get file from local filesystem (not bundled)
*/
path: string;
} | {
/**
* Get file from URL
*/
url: string;
};
/**
* @public
*/
export declare type DnaVersionSpec = Array<HoloHashB64>;
/**
* @public
*/
export declare type DnaVersionFlexible = {

@@ -185,2 +333,5 @@ singleton: HoloHashB64;

};
/**
* @public
*/
export declare type AppRoleDnaManifest = {

@@ -191,2 +342,5 @@ clone_limit?: number;

} & Location;
/**
* @public
*/
export declare type AppRoleManifest = {

@@ -197,2 +351,5 @@ name: RoleName;

};
/**
* @public
*/
export declare type AppManifest = {

@@ -204,2 +361,5 @@ manifest_version: string;

};
/**
* @public
*/
export declare type AppBundle = {

@@ -209,2 +369,5 @@ manifest: AppManifest;

};
/**
* @public
*/
export declare type AppBundleSource = {

@@ -215,3 +378,9 @@ bundle: AppBundle;

};
/**
* @public
*/
export declare type NetworkSeed = string;
/**
* @public
*/
export declare type InstallAppRequest = {

@@ -225,9 +394,33 @@ agent_key: AgentPubKey;

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

@@ -240,45 +433,75 @@ Enabled = "enabled",

}
/**
* @public
*/
export declare type ListAppsRequest = {
status_filter?: AppStatusFilter;
};
/**
* @public
*/
export declare type ListAppsResponse = Array<AppInfo>;
/**
* @public
*/
export declare type ListAppInterfacesRequest = void;
/**
* @public
*/
export declare type ListAppInterfacesResponse = Array<number>;
export declare type AgentInfoSigned = any;
/**
* This type is meant to be opaque
*
* @public
*/
export declare type AgentInfoSigned = unknown;
/**
* @public
*/
export declare type AgentInfoRequest = {
cell_id: CellId | null;
};
/**
* @public
*/
export declare type AgentInfoResponse = Array<AgentInfoSigned>;
/**
* @public
*/
export declare type AddAgentInfoRequest = {
agent_infos: Array<AgentInfoSigned>;
};
/**
* @public
*/
export declare type AddAgentInfoResponse = any;
/**
* @public
*/
export declare type DeleteCloneCellRequest = DisableCloneCellRequest;
/**
* @public
*/
export declare type DeleteCloneCellResponse = void;
/**
* @public
*/
export interface GrantZomeCallCapabilityRequest {
/**
* Cell for which to authorize the capability.
*/
cell_id: CellId;
/**
* Specifies the capability, consisting of zomes and functions to allow
* signing for as well as access level, secret and assignees.
*/
cap_grant: ZomeCallCapGrant;
}
/**
* @public
*/
export declare type GrantZomeCallCapabilityResponse = void;
export interface AdminApi {
attachAppInterface: Requester<AttachAppInterfaceRequest, AttachAppInterfaceResponse>;
enableApp: Requester<EnableAppRequest, EnableAppResponse>;
disableApp: Requester<DisableAppRequest, DisableAppResponse>;
startApp: Requester<StartAppRequest, StartAppResponse>;
dumpState: Requester<DumpStateRequest, DumpStateResponse>;
dumpFullState: Requester<DumpFullStateRequest, DumpFullStateResponse>;
generateAgentPubKey: Requester<GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse>;
registerDna: Requester<RegisterDnaRequest, RegisterDnaResponse>;
getDnaDefinition: Requester<GetDnaDefinitionRequest, GetDnaDefinitionResponse>;
uninstallApp: Requester<UninstallAppRequest, UninstallAppResponse>;
installApp: Requester<InstallAppRequest, InstallAppResponse>;
listDnas: Requester<ListDnasRequest, ListDnasResponse>;
listCellIds: Requester<ListCellIdsRequest, ListCellIdsResponse>;
listApps: Requester<ListAppsRequest, ListAppsResponse>;
listAppInterfaces: Requester<ListAppInterfacesRequest, ListAppInterfacesResponse>;
agentInfo: Requester<AgentInfoRequest, AgentInfoResponse>;
addAgentInfo: Requester<AddAgentInfoRequest, AddAgentInfoResponse>;
deleteCloneCell: Requester<DeleteCloneCellRequest, DeleteCloneCellResponse>;
grantZomeCallCapability: Requester<GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse>;
}
/**
* @public
*/
export declare type InstallAppDnaPayload = {

@@ -289,3 +512,9 @@ hash: HoloHash;

};
/**
* @public
*/
export declare type ZomeLocation = Location;
/**
* @public
*/
export declare type ZomeManifest = {

@@ -295,9 +524,31 @@ name: string;

} & ZomeLocation;
/**
* @public
*/
export declare type DnaManifest = {
/**
* Currently one "1" is supported
*/
manifest_version: string;
/**
* The friendly "name" of a Holochain DNA.
*/
name: string;
/**
* A network seed for uniquifying this DNA.
*/
network_seed?: NetworkSeed;
/**
* Any arbitrary application properties can be included in this object.
*/
properties?: DnaProperties;
/**
* An array of zomes associated with your DNA.
* The order is significant: it determines initialization order.
*/
zomes: Array<ZomeManifest>;
};
/**
* @public
*/
export declare type DnaBundle = {

@@ -307,2 +558,5 @@ manifest: DnaManifest;

};
/**
* @public
*/
export declare type DnaSource = {

@@ -315,8 +569,17 @@ hash: HoloHash;

};
/**
* @public
*/
export declare type Zomes = Array<[string, {
wasm_hash: Array<HoloHash>;
}]>;
/**
* @public
*/
export declare type WasmCode = [HoloHash, {
code: Array<number>;
}];
/**
* @public
*/
export interface AgentInfoDump {

@@ -327,8 +590,26 @@ kitsune_agent: KitsuneAgent;

}
/**
* @public
*/
export interface P2pAgentsDump {
/**
* The info of this agent's cell.
*/
this_agent_info: AgentInfoDump | undefined;
/**
* The dna as a [`DnaHash`] and [`kitsune_p2p::KitsuneSpace`].
*/
this_dna: [DnaHash, KitsuneSpace] | undefined;
/**
* The agent as [`AgentPubKey`] and [`kitsune_p2p::KitsuneAgent`].
*/
this_agent: [AgentPubKey, KitsuneAgent] | undefined;
/**
* All other agent info.
*/
peers: Array<AgentInfoDump>;
}
/**
* @public
*/
export interface FullIntegrationStateDump {

@@ -340,2 +621,5 @@ validation_limbo: Array<DhtOp>;

}
/**
* @public
*/
export interface SourceChainJsonRecord {

@@ -347,2 +631,5 @@ signature: Signature;

}
/**
* @public
*/
export interface SourceChainJsonDump {

@@ -352,2 +639,5 @@ records: Array<SourceChainJsonRecord>;

}
/**
* @public
*/
export interface FullStateDump {

@@ -358,1 +648,25 @@ peer_dump: P2pAgentsDump;

}
/**
* @public
*/
export interface AdminApi {
attachAppInterface: Requester<AttachAppInterfaceRequest, AttachAppInterfaceResponse>;
enableApp: Requester<EnableAppRequest, EnableAppResponse>;
disableApp: Requester<DisableAppRequest, DisableAppResponse>;
startApp: Requester<StartAppRequest, StartAppResponse>;
dumpState: Requester<DumpStateRequest, DumpStateResponse>;
dumpFullState: Requester<DumpFullStateRequest, DumpFullStateResponse>;
generateAgentPubKey: Requester<GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse>;
registerDna: Requester<RegisterDnaRequest, RegisterDnaResponse>;
getDnaDefinition: Requester<GetDnaDefinitionRequest, GetDnaDefinitionResponse>;
uninstallApp: Requester<UninstallAppRequest, UninstallAppResponse>;
installApp: Requester<InstallAppRequest, InstallAppResponse>;
listDnas: Requester<ListDnasRequest, ListDnasResponse>;
listCellIds: Requester<ListCellIdsRequest, ListCellIdsResponse>;
listApps: Requester<ListAppsRequest, ListAppsResponse>;
listAppInterfaces: Requester<ListAppInterfacesRequest, ListAppInterfacesResponse>;
agentInfo: Requester<AgentInfoRequest, AgentInfoResponse>;
addAgentInfo: Requester<AddAgentInfoRequest, AddAgentInfoResponse>;
deleteCloneCell: Requester<DeleteCloneCellRequest, DeleteCloneCellResponse>;
grantZomeCallCapability: Requester<GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse>;
}

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

/**
* @public
*/
export var CellType;

@@ -7,2 +10,39 @@ (function (CellType) {

})(CellType || (CellType = {}));
/**
* @public
*/
export var CellProvisioningStrategy;
(function (CellProvisioningStrategy) {
/**
* Always create a new Cell when installing this App
*/
CellProvisioningStrategy["Create"] = "create";
/**
* Always create a new Cell when installing the App,
* and use a unique network seed to ensure a distinct DHT network.
*
* Not implemented
*/
// CreateClone = "create_clone",
/**
* Require that a Cell is already installed which matches the DNA version
* spec, and which has an Agent that's associated with this App's agent
* via DPKI. If no such Cell exists, *app installation fails*.
*/
CellProvisioningStrategy["UseExisting"] = "use_existing";
/**
* Try `UseExisting`, and if that fails, fallback to `Create`
*/
CellProvisioningStrategy["CreateIfNoExists"] = "create_if_no_exists";
/**
* Disallow provisioning altogether. In this case, we expect
* `clone_limit > 0`: otherwise, no Cells will ever be created.
*
* Not implemented
*/
// Disabled = "disabled",
})(CellProvisioningStrategy || (CellProvisioningStrategy = {}));
/**
* @public
*/
export var AppStatusFilter;

@@ -16,2 +56,1 @@ (function (AppStatusFilter) {

})(AppStatusFilter || (AppStatusFilter = {}));
//# sourceMappingURL=types.js.map

@@ -6,26 +6,105 @@ import { CapSecret, GrantedFunctions } from "../../hdk/capabilities.js";

import { AddAgentInfoRequest, AddAgentInfoResponse, AdminApi, AgentInfoRequest, AgentInfoResponse, AttachAppInterfaceRequest, AttachAppInterfaceResponse, DeleteCloneCellRequest, DeleteCloneCellResponse, DisableAppRequest, DisableAppResponse, DumpFullStateRequest, DumpFullStateResponse, DumpStateRequest, DumpStateResponse, EnableAppRequest, EnableAppResponse, GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse, GetDnaDefinitionRequest, GetDnaDefinitionResponse, GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse, InstallAppRequest, InstallAppResponse, ListAppInterfacesRequest, ListAppInterfacesResponse, ListAppsRequest, ListAppsResponse, ListCellIdsRequest, ListCellIdsResponse, ListDnasRequest, ListDnasResponse, RegisterDnaRequest, RegisterDnaResponse, StartAppRequest, StartAppResponse, UninstallAppRequest, UninstallAppResponse } from "./types.js";
/**
* A class for interacting with a conductor's Admin API.
*
* @public
*/
export declare class AdminWebsocket implements AdminApi {
/**
* The websocket client used for transporting requests and responses.
*/
readonly client: WsClient;
/**
* Default timeout for any request made over the websocket.
*/
defaultTimeout: number;
private constructor();
/**
* Factory mehtod to create a new instance connected to the given URL.
*
* @param url - A `ws://` URL used as the connection address.
* @param defaultTimeout - The default timeout for any request.
* @returns A promise for a new connected instance.
*/
static connect(url: string, defaultTimeout?: number): Promise<AdminWebsocket>;
_requester: <ReqO, ReqI, ResI, ResO>(tag: string, transformer?: Transformer<ReqO, ReqI, ResI, ResO> | undefined) => (req: ReqO, 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>;
/**
* Send a request to open the given port for {@link AppWebsocket} connections.
*/
attachAppInterface: Requester<AttachAppInterfaceRequest, AttachAppInterfaceResponse>;
/**
* Enable a stopped app.
*/
enableApp: Requester<EnableAppRequest, EnableAppResponse>;
/**
* Disable a running app.
*/
disableApp: Requester<DisableAppRequest, DisableAppResponse>;
/**
* Start an app.
*/
startApp: Requester<StartAppRequest, StartAppResponse>;
/**
* Dump the state of the specified cell, including its source chain, as JSON.
*/
dumpState: Requester<DumpStateRequest, DumpStateResponse>;
/**
* Dump the full state of the specified cell, including its chain and DHT
* shard, as JSON.
*/
dumpFullState: Requester<DumpFullStateRequest, DumpFullStateResponse>;
/**
* Generate a new agent pub key.
*/
generateAgentPubKey: Requester<GenerateAgentPubKeyRequest, GenerateAgentPubKeyResponse>;
/**
* Register a DNA for later app installation.
*
* Stores the given DNA into the Holochain DNA database and returns the hash of it.
*/
registerDna: Requester<RegisterDnaRequest, RegisterDnaResponse>;
/**
* Get the DNA definition for the specified DNA hash.
*/
getDnaDefinition: Requester<GetDnaDefinitionRequest, GetDnaDefinitionResponse>;
/**
* Uninstall the specified app from Holochain.
*/
uninstallApp: Requester<UninstallAppRequest, UninstallAppResponse>;
/**
* Install the specified app into Holochain.
*/
installApp: Requester<InstallAppRequest, InstallAppResponse>;
/**
* List all registered DNAs.
*/
listDnas: Requester<ListDnasRequest, ListDnasResponse>;
/**
* List all installed cell ids.
*/
listCellIds: Requester<ListCellIdsRequest, ListCellIdsResponse>;
/**
* List all installed apps.
*/
listApps: Requester<ListAppsRequest, ListAppsResponse>;
/**
* List all attached app interfaces.
*/
listAppInterfaces: Requester<ListAppInterfacesRequest, ListAppInterfacesResponse>;
/**
* Request all available info about an agent.
*/
agentInfo: Requester<AgentInfoRequest, AgentInfoResponse>;
/**
* Add an existing agent to Holochain.
*/
addAgentInfo: Requester<AddAgentInfoRequest, AddAgentInfoResponse>;
/**
* Delete a disabled clone cell.
*/
deleteCloneCell: Requester<DeleteCloneCellRequest, DeleteCloneCellResponse>;
/**
* Grant a zome call capability for an agent, to be used for signing zome
* calls.
*/
grantZomeCallCapability: Requester<GrantZomeCallCapabilityRequest, GrantZomeCallCapabilityResponse>;

@@ -32,0 +111,0 @@ /**

@@ -7,4 +7,15 @@ import { getLauncherEnvironment } from "../../environments/launcher.js";

import { AppStatusFilter, } from "./types.js";
/**
* A class for interacting with a conductor's Admin API.
*
* @public
*/
export class AdminWebsocket {
/**
* The websocket client used for transporting requests and responses.
*/
client;
/**
* Default timeout for any request made over the websocket.
*/
defaultTimeout;

@@ -16,2 +27,9 @@ constructor(client, defaultTimeout) {

}
/**
* Factory mehtod to create a new instance connected to the given URL.
*
* @param url - A `ws://` URL used as the connection address.
* @param defaultTimeout - The default timeout for any request.
* @returns A promise for a new connected instance.
*/
static async connect(url, defaultTimeout) {

@@ -26,23 +44,84 @@ // Check if we are in the launcher's environment, and if so, redirect the url to connect to

}
_requester = (tag, transformer) => requesterTransformer((req, timeout) => promiseTimeout(this.client.request(req), tag, timeout || this.defaultTimeout).then(catchError), tag, transformer);
// the specific request/response types come from the Interface
// which this class implements
_requester(tag, transformer) {
return requesterTransformer((req, timeout) => promiseTimeout(this.client.request(req), tag, timeout || this.defaultTimeout).then(catchError), tag, transformer);
}
/**
* Send a request to open the given port for {@link AppWebsocket} connections.
*/
attachAppInterface = this._requester("attach_app_interface");
/**
* Enable a stopped app.
*/
enableApp = this._requester("enable_app");
/**
* Disable a running app.
*/
disableApp = this._requester("disable_app");
/**
* Start an app.
*/
startApp = this._requester("start_app");
/**
* Dump the state of the specified cell, including its source chain, as JSON.
*/
dumpState = this._requester("dump_state", dumpStateTransform);
/**
* Dump the full state of the specified cell, including its chain and DHT
* shard, as JSON.
*/
dumpFullState = this._requester("dump_full_state");
/**
* Generate a new agent pub key.
*/
generateAgentPubKey = this._requester("generate_agent_pub_key");
/**
* Register a DNA for later app installation.
*
* Stores the given DNA into the Holochain DNA database and returns the hash of it.
*/
registerDna = this._requester("register_dna");
/**
* Get the DNA definition for the specified DNA hash.
*/
getDnaDefinition = this._requester("get_dna_definition");
/**
* Uninstall the specified app from Holochain.
*/
uninstallApp = this._requester("uninstall_app");
/**
* Install the specified app into Holochain.
*/
installApp = this._requester("install_app");
/**
* List all registered DNAs.
*/
listDnas = this._requester("list_dnas");
/**
* List all installed cell ids.
*/
listCellIds = this._requester("list_cell_ids");
/**
* List all installed apps.
*/
listApps = this._requester("list_apps", listAppsTransform);
/**
* List all attached app interfaces.
*/
listAppInterfaces = this._requester("list_app_interfaces");
/**
* Request all available info about an agent.
*/
agentInfo = this._requester("agent_info");
/**
* Add an existing agent to Holochain.
*/
addAgentInfo = this._requester("add_agent_info");
/**
* Delete a disabled clone cell.
*/
deleteCloneCell = this._requester("delete_clone_cell");
/**
* Grant a zome call capability for an agent, to be used for signing zome
* calls.
*/
grantZomeCallCapability = this._requester("grant_zome_call_capability");

@@ -129,2 +208,1 @@ // zome call signing related methods

}
//# sourceMappingURL=websocket.js.map
export * from "./types.js";
export * from "./websocket.js";
//# sourceMappingURL=index.js.map

@@ -5,16 +5,43 @@ import { UnsubscribeFunction } from "emittery";

import { CreateCloneCellRequest, CreateCloneCellResponse, DisableCloneCellResponse } from "../index.js";
/**
* @public
*/
export declare type NonProvenanceCallZomeRequest = Omit<CallZomeRequest, "provenance">;
/**
* @public
*/
export declare type RoleNameCallZomeRequest = Omit<NonProvenanceCallZomeRequest, "cell_id"> & {
role_name: RoleName;
};
/**
* @public
*/
export declare type RoleNameCallZomeRequestSigned = Omit<CallZomeRequestSigned, "cell_id"> & {
role_name: RoleName;
};
/**
* @public
*/
export declare type AppAgentCallZomeRequest = NonProvenanceCallZomeRequest | RoleNameCallZomeRequest | CallZomeRequestSigned | RoleNameCallZomeRequestSigned;
/**
* @public
*/
export declare type AppCreateCloneCellRequest = Omit<CreateCloneCellRequest, "app_id">;
/**
* @public
*/
export declare type AppEnableCloneCellRequest = Omit<EnableCloneCellRequest, "app_id">;
/**
* @public
*/
export declare type AppDisableCloneCellRequest = Omit<DisableCloneCellRequest, "app_id">;
/**
* @public
*/
export interface AppAgentEvents {
signal: AppSignal;
}
/**
* @public
*/
export interface AppAgentClient {

@@ -21,0 +48,0 @@ callZome(args: AppAgentCallZomeRequest, timeout?: number): Promise<any>;

export {};
//# sourceMappingURL=types.js.map

@@ -5,2 +5,8 @@ import Emittery, { UnsubscribeFunction } from "emittery";

import { AppAgentCallZomeRequest, AppAgentClient, AppAgentEvents, AppCreateCloneCellRequest, AppDisableCloneCellRequest, AppEnableCloneCellRequest } from "./types.js";
/**
* A class to establish a websocket connection to an App interface, for a
* specific agent and app.
*
* @public
*/
export declare class AppAgentWebsocket implements AppAgentClient {

@@ -13,11 +19,62 @@ myPubKey: AgentPubKey;

private constructor();
/**
* Request the app's info, including all cell infos.
*
* @returns The app's {@link AppInfo}.
*/
appInfo(): Promise<AppInfo>;
/**
* Instance factory for creating AppAgentWebsockets.
*
* @param url - The `ws://` URL of the App API to connect to.
* @param installed_app_id - ID of the App to link to.
* @param defaultTimeout - Timeout to default to for all operations.
* @returns A new instance of an AppAgentWebsocket.
*/
static connect(url: string, installed_app_id: InstalledAppId, defaultTimeout?: number): Promise<AppAgentWebsocket>;
/**
* Get a cell id by its role name or clone id.
*
* @param roleName - The role name or clone id of the cell.
* @param appInfo - The app info containing all cell infos.
* @returns The cell id or throws an error if not found.
*/
getCellIdFromRoleName(roleName: RoleName, appInfo: AppInfo): CellId;
/**
* Call a zome.
*
* @param request - The zome call arguments.
* @param timeout - A timeout to override the default.
* @returns The zome call's response.
*/
callZome(request: AppAgentCallZomeRequest, timeout?: number): Promise<CallZomeResponse>;
/**
* Clone an existing provisioned cell.
*
* @param args - Specify the cell to clone.
* @returns The created clone cell.
*/
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;
/**
* Enable a disabled clone cell.
*
* @param args - Specify the clone cell to enable.
* @returns The enabled clone cell.
*/
enableCloneCell(args: AppEnableCloneCellRequest): Promise<EnableCloneCellResponse>;
/**
* Disable an enabled clone cell.
*
* @param args - Specify the clone cell to disable.
*/
disableCloneCell(args: AppDisableCloneCellRequest): Promise<DisableCloneCellResponse>;
/**
* Register an event listener for signals.
*
* @param eventName - Event name to listen to (currently only "signal").
* @param listener - The function to call when event is triggered.
* @returns A function to unsubscribe the event listener.
*/
on<Name extends keyof AppAgentEvents>(eventName: Name | readonly Name[], listener: AppSignalCb): UnsubscribeFunction;
private containsCell;
}

@@ -21,2 +21,8 @@ import Emittery from "emittery";

}
/**
* A class to establish a websocket connection to an App interface, for a
* specific agent and app.
*
* @public
*/
export class AppAgentWebsocket {

@@ -40,2 +46,7 @@ myPubKey;

}
/**
* Request the app's info, including all cell infos.
*
* @returns The app's {@link AppInfo}.
*/
async appInfo() {

@@ -48,2 +59,10 @@ const appInfo = await this.appWebsocket.appInfo({

}
/**
* Instance factory for creating AppAgentWebsockets.
*
* @param url - The `ws://` URL of the App API to connect to.
* @param installed_app_id - ID of the App to link to.
* @param defaultTimeout - Timeout to default to for all operations.
* @returns A new instance of an AppAgentWebsocket.
*/
static async connect(url, installed_app_id, defaultTimeout) {

@@ -59,2 +78,9 @@ const appWebsocket = await AppWebsocket.connect(url, defaultTimeout);

}
/**
* Get a cell id by its role name or clone id.
*
* @param roleName - The role name or clone id of the cell.
* @param appInfo - The app info containing all cell infos.
* @returns The cell id or throws an error if not found.
*/
getCellIdFromRoleName(roleName, appInfo) {

@@ -81,2 +107,9 @@ if (isCloneId(roleName)) {

}
/**
* Call a zome.
*
* @param request - The zome call arguments.
* @param timeout - A timeout to override the default.
* @returns The zome call's response.
*/
async callZome(request, timeout) {

@@ -106,2 +139,8 @@ if (!("provenance" in request)) {

}
/**
* Clone an existing provisioned cell.
*
* @param args - Specify the cell to clone.
* @returns The created clone cell.
*/
async createCloneCell(args) {

@@ -115,2 +154,8 @@ const clonedCell = this.appWebsocket.createCloneCell({

}
/**
* Enable a disabled clone cell.
*
* @param args - Specify the clone cell to enable.
* @returns The enabled clone cell.
*/
async enableCloneCell(args) {

@@ -122,2 +167,7 @@ return this.appWebsocket.enableCloneCell({

}
/**
* Disable an enabled clone cell.
*
* @param args - Specify the clone cell to disable.
*/
async disableCloneCell(args) {

@@ -129,2 +179,9 @@ return this.appWebsocket.disableCloneCell({

}
/**
* Register an event listener for signals.
*
* @param eventName - Event name to listen to (currently only "signal").
* @param listener - The function to call when event is triggered.
* @returns A function to unsubscribe the event listener.
*/
on(eventName, listener) {

@@ -155,2 +212,1 @@ return this.emitter.on(eventName, listener);

cellId1[1].every((byte, index) => byte === cellId2[1][index]);
//# sourceMappingURL=websocket.js.map
export * from "./types.js";
export * from "./websocket.js";
//# sourceMappingURL=index.js.map
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";
/**
* @public
*/
export declare type CallZomeRequestGeneric<Payload> = {

@@ -11,9 +14,27 @@ cell_id: CellId;

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

@@ -63,14 +84,43 @@ /**

}
/**
* @public
*/
export declare type CreateCloneCellResponse = InstalledCell;
/**
* @public
*/
export interface DisableCloneCellRequest {
/**
* The app id that the clone cell belongs to
*/
app_id: InstalledAppId;
/**
* The clone id or cell id of the clone cell
*/
clone_cell_id: RoleName | CellId;
}
/**
* @public
*/
export declare type DisableCloneCellResponse = void;
/**
* @public
*/
export declare type EnableCloneCellRequest = DisableCloneCellRequest;
/**
* @public
*/
export declare type EnableCloneCellResponse = CreateCloneCellResponse;
/**
* @public
*/
export interface NetworkInfoRequest {
/** The DNAs for which to get network info */
/**
* The DNAs for which to get network info
*/
dnas: DnaHash[];
}
/**
* @public
*/
export declare const SignalType: {

@@ -80,12 +130,37 @@ readonly App: "App";

};
/**
* @public
*/
export declare type Signal = {
[SignalType.App]: [CellId, any];
[SignalType.App]: EncodedAppSignal;
} | {
[SignalType.System]: unknown;
};
/**
* @public
*/
export declare type EncodedAppSignal = {
cell_id: CellId;
zome_name: string;
signal: Uint8Array;
};
/**
* @public
*/
export declare type AppSignal = {
cell_id: CellId;
payload: any;
zome_name: string;
payload: unknown;
};
/**
* @public
*/
export declare type AppSignalCb = (signal: AppSignal) => void;
/**
* @public
*/
export declare type NetworkInfoResponse = NetworkInfo[];
/**
* @public
*/
export interface AppApi {

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

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

/**
* @public
*/
export const SignalType = {

@@ -5,2 +8,1 @@ App: "App",

};
//# sourceMappingURL=types.js.map

@@ -8,2 +8,8 @@ import Emittery from "emittery";

import { AppApi, AppInfoRequest, AppInfoResponse, CallZomeRequest, CallZomeResponse, CreateCloneCellRequest, CreateCloneCellResponse, DisableCloneCellRequest, DisableCloneCellResponse, EnableCloneCellRequest, EnableCloneCellResponse, NetworkInfoRequest, NetworkInfoResponse } from "./types.js";
/**
* A class to establish a websocket connection to an App interface of a
* Holochain conductor.
*
* @public
*/
export declare class AppWebsocket extends Emittery implements AppApi {

@@ -14,11 +20,53 @@ readonly client: WsClient;

private constructor();
/**
* Instance factory for creating AppWebsockets.
*
* @param url - The `ws://` URL of the App API to connect to.
* @param defaultTimeout - Timeout to default to for all operations.
* @returns A new instance of an 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>;
/**
* Request the app's info, including all cell infos.
*
* @returns The app's {@link AppInfo}.
*/
appInfo: Requester<AppInfoRequest, AppInfoResponse>;
/**
* Call a zome.
*
* @param request - The zome call arguments.
* @param timeout - A timeout to override the default.
* @returns The zome call's response.
*/
callZome: Requester<CallZomeRequest | CallZomeRequestSigned, CallZomeResponse>;
/**
* Clone an existing provisioned cell.
*
* @param args - Specify the cell to clone.
* @returns The created clone cell.
*/
createCloneCell: Requester<CreateCloneCellRequest, CreateCloneCellResponse>;
/**
* Enable a disabled clone cell.
*
* @param args - Specify the clone cell to enable.
* @returns The enabled clone cell.
*/
enableCloneCell: Requester<EnableCloneCellRequest, EnableCloneCellResponse>;
/**
* Disable an enabled clone cell.
*
* @param args - Specify the clone cell to disable.
*/
disableCloneCell: Requester<DisableCloneCellRequest, DisableCloneCellResponse>;
/**
* Request network info about gossip status.
*/
networkInfo: Requester<NetworkInfoRequest, NetworkInfoResponse>;
}
/**
* @public
*/
export interface CallZomeRequestUnsigned extends CallZomeRequest {

@@ -29,5 +77,11 @@ cap_secret: CapSecret | null;

}
/**
* @public
*/
export interface CallZomeRequestSigned extends CallZomeRequestUnsigned {
signature: Uint8Array;
}
/**
* @public
*/
export declare const signZomeCall: (request: CallZomeRequest) => Promise<CallZomeRequestSigned>;

@@ -10,2 +10,8 @@ import { hashZomeCall } from "@holochain/serialization";

import { getNonceExpiration, getSigningCredentials, randomNonce, } from "../zome-call-signing.js";
/**
* A class to establish a websocket connection to an App interface of a
* Holochain conductor.
*
* @public
*/
export class AppWebsocket extends Emittery {

@@ -22,2 +28,9 @@ client;

}
/**
* Instance factory for creating AppWebsockets.
*
* @param url - The `ws://` URL of the App API to connect to.
* @param defaultTimeout - Timeout to default to for all operations.
* @returns A new instance of an AppWebsocket.
*/
static async connect(url, defaultTimeout) {

@@ -35,7 +48,39 @@ // Check if we are in the launcher's environment, and if so, redirect the url to connect to

_requester = (tag, transformer) => requesterTransformer((req, timeout) => promiseTimeout(this.client.request(req), tag, timeout || this.defaultTimeout).then(catchError), tag, transformer);
/**
* Request the app's info, including all cell infos.
*
* @returns The app's {@link AppInfo}.
*/
appInfo = this._requester("app_info", appInfoTransform(this));
/**
* Call a zome.
*
* @param request - The zome call arguments.
* @param timeout - A timeout to override the default.
* @returns The zome call's response.
*/
callZome = this._requester("call_zome", callZomeTransform);
/**
* Clone an existing provisioned cell.
*
* @param args - Specify the cell to clone.
* @returns The created clone cell.
*/
createCloneCell = this._requester("create_clone_cell");
/**
* Enable a disabled clone cell.
*
* @param args - Specify the clone cell to enable.
* @returns The enabled clone cell.
*/
enableCloneCell = this._requester("enable_clone_cell");
/**
* Disable an enabled clone cell.
*
* @param args - Specify the clone cell to disable.
*/
disableCloneCell = this._requester("disable_clone_cell");
/**
* Request network info about gossip status.
*/
networkInfo = this._requester("network_info");

@@ -66,2 +111,5 @@ }

});
/**
* @public
*/
export const signZomeCall = async (request) => {

@@ -92,2 +140,1 @@ const signingCredentialsForCell = getSigningCredentials(request.cell_id);

};
//# sourceMappingURL=websocket.js.map

@@ -5,12 +5,9 @@ /// <reference types="ws" />

import Websocket from "isomorphic-ws";
interface HolochainMessage {
id: number;
type: "response" | "signal";
data: ArrayLike<number> | null;
}
/**
* A Websocket client which can make requests and receive responses,
* as well as send and receive signals
* as well as send and receive signals.
*
* Uses Holochain's websocket WireMessage for communication.
*
* @public
*/

@@ -25,8 +22,27 @@ export declare class WsClient extends Emittery {

constructor(socket: Websocket);
/**
* Instance factory for creating WsClients.
*
* @param url - The `ws://` URL to connect to.
* @returns An new instance of the WsClient.
*/
static connect(url: string): Promise<WsClient>;
/**
* Sends data as a signal.
*
* @param data - Data to send.
*/
emitSignal(data: unknown): void;
request<Req, Res>(data: Req): Promise<Res>;
handleResponse(msg: HolochainMessage): void;
/**
* Send requests to the connected websocket.
*
* @param request - The request to send over the websocket.
* @returns
*/
request<Req, Res>(request: Req): Promise<Res>;
private handleResponse;
/**
* Close the websocket connection.
*/
close(): Promise<void>;
}
export {};

@@ -7,5 +7,7 @@ import { decode, encode } from "@msgpack/msgpack";

* A Websocket client which can make requests and receive responses,
* as well as send and receive signals
* as well as send and receive signals.
*
* Uses Holochain's websocket WireMessage for communication.
*
* @public
*/

@@ -43,15 +45,16 @@ export class WsClient extends Emittery {

}
const derializedSignal = decode(message.data);
assertHolochainSignal(derializedSignal);
if (!(SignalType.App in derializedSignal)) {
const deserializedSignal = decode(message.data);
assertHolochainSignal(deserializedSignal);
if (SignalType.System in deserializedSignal) {
// We have received a system signal, do nothing
return;
}
// 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 cell_id = derializedSignal.App[0];
const encodedAppSignal = deserializedSignal[SignalType.App];
// 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 = { cell_id, payload };
const payload = decode(encodedAppSignal.signal);
const signal = {
cell_id: encodedAppSignal.cell_id,
zome_name: encodedAppSignal.zome_name,
payload,
};
this.emit("signal", signal);

@@ -67,2 +70,8 @@ }

}
/**
* Instance factory for creating WsClients.
*
* @param url - The `ws://` URL to connect to.
* @returns An new instance of the WsClient.
*/
static connect(url) {

@@ -83,2 +92,7 @@ return new Promise((resolve, reject) => {

}
/**
* Sends data as a signal.
*
* @param data - Data to send.
*/
emitSignal(data) {

@@ -91,3 +105,9 @@ const encodedMsg = encode({

}
request(data) {
/**
* Send requests to the connected websocket.
*
* @param request - The request to send over the websocket.
* @returns
*/
request(request) {
const id = this.index;

@@ -98,3 +118,3 @@ this.index += 1;

type: "request",
data: encode(data),
data: encode(request),
});

@@ -127,2 +147,5 @@ const promise = new Promise((resolve, reject) => {

}
/**
* Close the websocket connection.
*/
close() {

@@ -151,2 +174,1 @@ const closedPromise = new Promise((resolve) => this.socket.on("close", resolve));

}
//# sourceMappingURL=client.js.map
import { RoleName } from "../types.js";
export declare const DEFAULT_TIMEOUT = 15000;
/**
* @public
*/
export declare type Transformer<ReqI, ReqO, ResI, ResO> = {

@@ -7,4 +10,13 @@ input: (req: ReqI) => ReqO;

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

@@ -18,2 +30,4 @@ type: string;

* with the optional Transformer applied to further modify the input and output.
*
* @public
*/

@@ -23,3 +37,16 @@ export declare const requesterTransformer: <ReqI, ReqO, ResI, ResO>(requester: Requester<Tagged<ReqO>, Tagged<ResI>>, tag: string, transform?: Transformer<ReqI, ReqO, ResI, ResO>) => (req: ReqI, timeout?: number) => Promise<ResO>;

export declare const promiseTimeout: (promise: Promise<unknown>, tag: string, ms: number) => Promise<unknown>;
/**
* Check if a cell's role name is a valid clone id.
*
* @param roleName - The role name to check.
*
* @public
*/
export declare const isCloneId: (roleName: RoleName) => boolean;
/**
* Parse a clone id and get the role name part of it.
*
* @param roleName - The role name to parse.
* @public
*/
export declare const getBaseRoleNameFromCloneId: (roleName: RoleName) => string;

@@ -31,2 +58,4 @@ /**

* Example: `profiles.0`
*
* @public
*/

@@ -39,3 +68,3 @@ export declare class CloneId {

* Parse a role id of a clone cell to obtain a clone id instance.
* @param roleName Role id to parse.
* @param roleName - Role id to parse.
* @returns A clone id instance.

@@ -42,0 +71,0 @@ */

@@ -7,2 +7,4 @@ const ERROR_TYPE = "error";

* with the optional Transformer applied to further modify the input and output.
*
* @public
*/

@@ -44,3 +46,16 @@ export const requesterTransformer = (requester, tag, transform = identityTransformer) => async (req, timeout) => {

const CLONE_ID_DELIMITER = ".";
/**
* Check if a cell's role name is a valid clone id.
*
* @param roleName - The role name to check.
*
* @public
*/
export const isCloneId = (roleName) => roleName.includes(CLONE_ID_DELIMITER);
/**
* Parse a clone id and get the role name part of it.
*
* @param roleName - The role name to parse.
* @public
*/
export const getBaseRoleNameFromCloneId = (roleName) => {

@@ -57,2 +72,4 @@ if (!isCloneId(roleName)) {

* Example: `profiles.0`
*
* @public
*/

@@ -68,3 +85,3 @@ export class CloneId {

* Parse a role id of a clone cell to obtain a clone id instance.
* @param roleName Role id to parse.
* @param roleName - Role id to parse.
* @returns A clone id instance.

@@ -86,2 +103,1 @@ */

}
//# sourceMappingURL=common.js.map

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

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

@@ -6,3 +6,3 @@ export { hashZomeCall } from "@holochain/serialization";

export { CloneId } from "./common.js";
export { WsClient } from "./client.js";
export * from "./zome-call-signing.js";
//# sourceMappingURL=index.js.map
import nacl from "tweetnacl";
import { CapSecret } from "../hdk/capabilities.js";
import { AgentPubKey, CellId } from "../types.js";
/**
* @public
*/
export declare type Nonce256Bit = Uint8Array;
/**
* @public
*/
export interface SigningCredentials {

@@ -15,2 +21,4 @@ capSecret: CapSecret;

* @returns The keys and cap secret required for signing a zome call.
*
* @public
*/

@@ -22,3 +30,4 @@ export declare const getSigningCredentials: (cellId: CellId) => SigningCredentials | undefined;

* @param cellId - Cell id to set credentials for.
* @param cellId - Cell id to set credentials for.
*
* @public
*/

@@ -30,2 +39,4 @@ export declare const setSigningCredentials: (cellId: CellId, credentials: SigningCredentials) => void;

* @returns The signing key pair and an agent pub key based on the public key.
*
* @public
*/

@@ -36,5 +47,17 @@ export declare const generateSigningKeyPair: () => [

];
/**
* @public
*/
export declare const randomCapSecret: () => Promise<CapSecret>;
/**
* @public
*/
export declare const randomNonce: () => Promise<Nonce256Bit>;
/**
* @public
*/
export declare const randomByteArray: (length: number) => Promise<Uint8Array>;
/**
* @public
*/
export declare const getNonceExpiration: () => number;

@@ -9,2 +9,4 @@ import nacl from "tweetnacl";

* @returns The keys and cap secret required for signing a zome call.
*
* @public
*/

@@ -19,3 +21,4 @@ export const getSigningCredentials = (cellId) => {

* @param cellId - Cell id to set credentials for.
* @param cellId - Cell id to set credentials for.
*
* @public
*/

@@ -30,2 +33,4 @@ export const setSigningCredentials = (cellId, credentials) => {

* @returns The signing key pair and an agent pub key based on the public key.
*
* @public
*/

@@ -37,4 +42,13 @@ export const generateSigningKeyPair = () => {

};
/**
* @public
*/
export const randomCapSecret = () => randomByteArray(64);
/**
* @public
*/
export const randomNonce = async () => randomByteArray(32);
/**
* @public
*/
export const randomByteArray = async (length) => {

@@ -51,3 +65,5 @@ if (typeof window !== "undefined" &&

};
/**
* @public
*/
export const getNonceExpiration = () => (Date.now() + 5 * 60 * 1000) * 1000; // 5 mins from now in microseconds
//# sourceMappingURL=zome-call-signing.js.map

@@ -34,2 +34,1 @@ import { invoke } from "@tauri-apps/api/tauri";

};
//# sourceMappingURL=launcher.js.map
import { AgentPubKey, DnaHash, EntryHash, ActionHash, HoloHashed, Signature, Timestamp } from "../types.js";
import { EntryType } from "./entry.js";
/**
* @public
*/
export interface SignedActionHashed<H extends Action = Action> {

@@ -7,3 +10,9 @@ hashed: HoloHashed<H>;

}
/**
* @public
*/
export declare type ActionHashed = HoloHashed<Action>;
/**
* @public
*/
export declare enum ActionType {

@@ -21,4 +30,13 @@ Dna = "Dna",

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

@@ -30,2 +48,5 @@ type: ActionType.Dna;

}
/**
* @public
*/
export interface AgentValidationPkg {

@@ -39,2 +60,5 @@ type: ActionType.AgentValidationPkg;

}
/**
* @public
*/
export interface InitZomesComplete {

@@ -47,2 +71,5 @@ type: ActionType.InitZomesComplete;

}
/**
* @public
*/
export interface CreateLink {

@@ -59,2 +86,5 @@ type: ActionType.CreateLink;

}
/**
* @public
*/
export interface DeleteLink {

@@ -69,2 +99,5 @@ type: ActionType.DeleteLink;

}
/**
* @public
*/
export interface OpenChain {

@@ -78,2 +111,5 @@ type: ActionType.OpenChain;

}
/**
* @public
*/
export interface CloseChain {

@@ -87,2 +123,5 @@ type: ActionType.CloseChain;

}
/**
* @public
*/
export interface Update {

@@ -99,2 +138,5 @@ type: ActionType.Update;

}
/**
* @public
*/
export interface Delete {

@@ -109,2 +151,5 @@ type: ActionType.Delete;

}
/**
* @public
*/
export interface Create {

@@ -111,0 +156,0 @@ type: ActionType.Create;

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

/**
* @public
*/
export var ActionType;

@@ -14,2 +17,1 @@ (function (ActionType) {

})(ActionType || (ActionType = {}));
//# sourceMappingURL=action.js.map
import { FunctionName, ZomeName } from "../api/index.js";
import { AgentPubKey } from "../types.js";
/**
* @public
*/
export declare type CapSecret = Uint8Array;
/**
* @public
*/
export interface CapClaim {

@@ -9,2 +15,5 @@ tag: string;

}
/**
* @public
*/
export declare enum GrantedFunctionsType {

@@ -14,2 +23,5 @@ All = "All",

}
/**
* @public
*/
export declare type GrantedFunctions = {

@@ -20,2 +32,5 @@ [GrantedFunctionsType.All]: null;

};
/**
* @public
*/
export interface ZomeCallCapGrant {

@@ -26,2 +41,5 @@ tag: string;

}
/**
* @public
*/
export declare type CapAccess = "Unrestricted" | {

@@ -37,2 +55,5 @@ Transferable: {

};
/**
* @public
*/
export declare type CapGrant = {

@@ -39,0 +60,0 @@ ChainAuthor: AgentPubKey;

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

/**
* @public
*/
export var GrantedFunctionsType;

@@ -6,2 +9,1 @@ (function (GrantedFunctionsType) {

})(GrantedFunctionsType || (GrantedFunctionsType = {}));
//# sourceMappingURL=capabilities.js.map
import { ActionHash, AgentPubKey, EntryHash, Signature, Timestamp } from "../types.js";
import { EntryType } from "./entry.js";
/**
* @public
*/
export interface CounterSigningSessionData {

@@ -7,2 +10,5 @@ preflight_request: PreflightRequest;

}
/**
* @public
*/
export interface PreflightRequest {

@@ -16,2 +22,5 @@ app_entry_hash: EntryHash;

}
/**
* @public
*/
export interface CounterSigningSessionTimes {

@@ -21,2 +30,5 @@ start: Timestamp;

}
/**
* @public
*/
export declare type ActionBase = {

@@ -27,5 +39,11 @@ Create: CreateBase;

};
/**
* @public
*/
export interface CreateBase {
entry_type: EntryType;
}
/**
* @public
*/
export interface UpdateBase {

@@ -36,5 +54,17 @@ original_action_address: ActionHash;

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

@@ -41,0 +71,0 @@ agent_index: number;

export {};
//# sourceMappingURL=countersigning.js.map
import { Signature } from "../types.js";
import { Entry } from "./entry.js";
import { CreateLink, Delete, DeleteLink, Action, NewEntryAction, Update } from "./action.js";
/**
* @public
*/
export declare enum DhtOpType {

@@ -15,2 +18,5 @@ StoreRecord = "StoreRecord",

}
/**
* @public
*/
export declare type DhtOp = {

@@ -39,5 +45,17 @@ [DhtOpType.StoreRecord]: [Signature, Action, Entry | undefined];

};
/**
* @public
*/
export declare function getDhtOpType(op: DhtOp): DhtOpType;
/**
* @public
*/
export declare function getDhtOpAction(op: DhtOp): Action;
/**
* @public
*/
export declare function getDhtOpEntry(op: DhtOp): Entry | undefined;
/**
* @public
*/
export declare function getDhtOpSignature(op: DhtOp): Signature;
// https://github.com/holochain/holochain/blob/develop/crates/types/src/dht_op.rs
/**
* @public
*/
export var DhtOpType;

@@ -14,5 +17,11 @@ (function (DhtOpType) {

})(DhtOpType || (DhtOpType = {}));
/**
* @public
*/
export function getDhtOpType(op) {
return Object.keys(op)[0];
}
/**
* @public
*/
export function getDhtOpAction(op) {

@@ -44,8 +53,13 @@ const opType = getDhtOpType(op);

}
/**
* @public
*/
export function getDhtOpEntry(op) {
return Object.values(op)[0][2];
}
/**
* @public
*/
export function getDhtOpSignature(op) {
return Object.values(op)[0][1];
}
//# sourceMappingURL=dht-ops.js.map
import { CapClaim, ZomeCallCapGrant } from "./capabilities.js";
import { AgentPubKey } from "../types.js";
import { CounterSigningSessionData } from "./countersigning.js";
/**
* @public
*/
export declare type EntryVisibility = {

@@ -9,2 +12,5 @@ Public: null;

};
/**
* @public
*/
export declare type AppEntryDef = {

@@ -15,5 +21,11 @@ entry_index: number;

};
/**
* @public
*/
export declare type EntryType = "Agent" | {
App: AppEntryDef;
} | "CapClaim" | "CapGrant";
/**
* @public
*/
export interface EntryContent<E extends string, C> {

@@ -23,2 +35,5 @@ entry_type: E;

}
/**
* @public
*/
export declare type Entry = EntryContent<"Agent", AgentPubKey> | EntryContent<"App", Uint8Array> | EntryContent<"CounterSign", [CounterSigningSessionData, Uint8Array]> | EntryContent<"CapGrant", ZomeCallCapGrant> | EntryContent<"CapClaim", CapClaim>;
export {};
//# sourceMappingURL=entry.js.map
export * from "./action.js";
export * from "./capabilities.js";
export * from "./countersigning.js";
export * from "./dht-ops.js";
export * from "./entry.js";
export * from "./record.js";
export * from "./action.js";
export * from "./capabilities.js";
export * from "./countersigning.js";
export * from "./dht-ops.js";
export * from "./entry.js";
export * from "./record.js";
//# sourceMappingURL=index.js.map
import { SignedActionHashed } from "./action.js";
import { Entry } from "./entry.js";
/**
* @public
*/
export declare type Record = {

@@ -7,2 +10,5 @@ signed_action: SignedActionHashed;

};
/**
* @public
*/
export declare type RecordEntry = {

@@ -9,0 +15,0 @@ Present: Entry;

export {};
//# sourceMappingURL=record.js.map

@@ -5,2 +5,1 @@ export * from "./api/index.js";

export * from "./utils/index.js";
//# sourceMappingURL=index.js.map

@@ -0,23 +1,89 @@

/**
* @public
*/
export declare type HoloHash = Uint8Array;
/**
* @public
*/
export declare type AgentPubKey = HoloHash;
/**
* @public
*/
export declare type DnaHash = HoloHash;
/**
* @public
*/
export declare type WasmHash = HoloHash;
/**
* @public
*/
export declare type EntryHash = HoloHash;
/**
* @public
*/
export declare type ActionHash = HoloHash;
/**
* @public
*/
export declare type AnyDhtHash = HoloHash;
/**
* @public
*/
export declare type KitsuneAgent = Uint8Array;
/**
* @public
*/
export declare type KitsuneSpace = Uint8Array;
/** Base64 hash types */
/**
* @public
*/
export declare type HoloHashB64 = string;
/**
* @public
*/
export declare type AgentPubKeyB64 = HoloHashB64;
/**
* @public
*/
export declare type DnaHashB64 = HoloHashB64;
/**
* @public
*/
export declare type WasmHashB64 = HoloHashB64;
/**
* @public
*/
export declare type EntryHashB64 = HoloHashB64;
/**
* @public
*/
export declare type ActionHashB64 = HoloHashB64;
/**
* @public
*/
export declare type AnyDhtHashB64 = HoloHashB64;
/**
* @public
*/
export declare type InstalledAppId = string;
/**
* @public
*/
export declare type Signature = Uint8Array;
/**
* @public
*/
export declare type CellId = [DnaHash, AgentPubKey];
/**
* @public
*/
export declare type DnaProperties = any;
/**
* @public
*/
export declare type RoleName = string;
/**
* @public
*/
export declare type InstalledCell = {

@@ -27,3 +93,9 @@ cell_id: CellId;

};
/**
* @public
*/
export declare type Timestamp = number;
/**
* @public
*/
export interface Duration {

@@ -33,2 +105,5 @@ secs: number;

}
/**
* @public
*/
export interface HoloHashed<T> {

@@ -38,5 +113,11 @@ hash: HoloHash;

}
/**
* @public
*/
export interface NetworkInfo {
fetch_queue_info: FetchQueueInfo;
}
/**
* @public
*/
export interface FetchQueueInfo {

@@ -43,0 +124,0 @@ op_bytes_to_fetch: number;

export {};
//# sourceMappingURL=types.js.map
import { HoloHash, HoloHashB64 } from "../types.js";
/**
* Decodes a Base64 encoded string to a byte array hash.
*
* @param hash - The Base64 encoded string to decode.
* @returns The hash in byte format.
*
* @public
*/
export declare function decodeHashFromBase64(hash: HoloHashB64): HoloHash;
/**
* Encode a byte array hash to a Base64 string.
*
* @param hash - The hash to encode to a Base64 string.
* @returns The Base64 encoded string
*
* @public
*/
export declare function encodeHashToBase64(hash: HoloHash): HoloHashB64;
import { Base64 } from "js-base64";
/**
* Decodes a Base64 encoded string to a byte array hash.
*
* @param hash - The Base64 encoded string to decode.
* @returns The hash in byte format.
*
* @public
*/
export function decodeHashFromBase64(hash) {
return Base64.toUint8Array(hash.slice(1));
}
/**
* Encode a byte array hash to a Base64 string.
*
* @param hash - The hash to encode to a Base64 string.
* @returns The Base64 encoded string
*
* @public
*/
export function encodeHashToBase64(hash) {
return `u${Base64.fromUint8Array(hash, true)}`;
}
//# sourceMappingURL=base64.js.map
import { ActionHash, AgentPubKey, EntryHash } from "../types.js";
/** From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs */
/**
* Generate a valid hash of a non-existing entry.
*
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
*
* @returns An {@link EntryHash}.
*
* @public
*/
export declare function fakeEntryHash(): Promise<EntryHash>;
/**
* Generate a valid agent key of a non-existing agent.
*
* @returns An {@link AgentPubKey}.
*
* @public
*/
export declare function fakeAgentPubKey(): Promise<AgentPubKey>;
/**
* Generate a valid hash of a non-existing action.
*
* @returns An {@link ActionHash}.
*
* @public
*/
export declare function fakeActionHash(): Promise<ActionHash>;
import { randomByteArray } from "../api/zome-call-signing.js";
/** From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs */
/**
* Generate a valid hash of a non-existing entry.
*
* From https://github.com/holochain/holochain/blob/develop/crates/holo_hash/src/hash_type/primitive.rs
*
* @returns An {@link EntryHash}.
*
* @public
*/
export async function fakeEntryHash() {

@@ -7,2 +15,9 @@ const randomBytes = await randomByteArray(36);

}
/**
* Generate a valid agent key of a non-existing agent.
*
* @returns An {@link AgentPubKey}.
*
* @public
*/
export async function fakeAgentPubKey() {

@@ -12,2 +27,9 @@ const randomBytes = await randomByteArray(36);

}
/**
* Generate a valid hash of a non-existing action.
*
* @returns An {@link ActionHash}.
*
* @public
*/
export async function fakeActionHash() {

@@ -17,2 +39,1 @@ const randomBytes = await randomByteArray(36);

}
//# sourceMappingURL=fake-hash.js.map
export * from "./base64.js";
export * from "./fake-hash.js";
//# sourceMappingURL=index.js.map
{
"name": "@holochain/client",
"version": "0.11.13",
"version": "0.11.14",
"description": "A JavaScript client for the Holochain Conductor API",

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

"test": "RUST_LOG=error RUST_BACKTRACE=1 node --loader ts-node/esm test/index.ts",
"build": "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"
},

@@ -54,2 +55,4 @@ "dependencies": {

"devDependencies": {
"@microsoft/api-documenter": "^7.19.27",
"@microsoft/api-extractor": "^7.33.7",
"@types/js-yaml": "^3.12.7",

@@ -56,0 +59,0 @@ "@types/lodash-es": "^4.17.6",

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

> Holochain's Conductor API is under active development. This client package tracks that development fairly closely but sometimes gets behind.
[Complete API reference](./docs/client.md)

@@ -14,0 +14,0 @@ ## Installation

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