Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

@holochain/client

Package Overview
Dependencies
12
Maintainers
13
Versions
83
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.11.6 to 0.11.7

4

lib/api/admin/websocket.d.ts

@@ -21,5 +21,5 @@ /**

export declare class AdminWebsocket implements Api.AdminApi {
client: WsClient;
readonly client: WsClient;
defaultTimeout: number;
constructor(client: WsClient, defaultTimeout?: number);
private constructor();
static connect(url: string, defaultTimeout?: number): Promise<AdminWebsocket>;

@@ -26,0 +26,0 @@ _requester: <ReqO, ReqI, ResI, ResO>(tag: string, transformer?: Transformer<ReqO, ReqI, ResI, ResO> | undefined) => (req: ReqO, timeout?: number | undefined) => Promise<ResO>;

@@ -23,3 +23,3 @@ import { UnsubscribeFunction } from "emittery";

appInfo(): Promise<AppInfoResponse>;
myPubKey(): Promise<AgentPubKey>;
myPubKey: AgentPubKey;
createCloneCell(args: AppCreateCloneCellRequest): Promise<CreateCloneCellResponse>;

@@ -26,0 +26,0 @@ enableCloneCell(args: AppEnableCloneCellRequest): Promise<EnableCloneCellResponse>;

@@ -1,22 +0,1 @@

/**
* Defines AppAgentWebsocket, an easy-to-use websocket implementation of the
* Conductor API for apps, restricted to a single app provided on initialization
*
* const appWs = AppWebsocket.connect('ws://127.0.0.1:9000')
*
* const client = new AppAgentWebsocket(appWs, 'my_installed_app_id')
*
* client.callZome({
* role_name: 'my_role_name' // role_name is unique per app, so you can unambiguously identify your dna with role_name in this client,
* zome_name: 'zome',
* fn_name: 'fn',
* payload: { value: 'v' }
* })
* .then(result => {
* console.log('callZome returned with:', result)
* })
* .catch(err => {
* console.error('callZome errored with:', err)
* })
*/
import Emittery, { UnsubscribeFunction } from "emittery";

@@ -27,9 +6,10 @@ import { AgentPubKey, InstalledAppId, RoleName } from "../../types.js";

export declare class AppAgentWebsocket implements AppAgentClient {
appWebsocket: AppWebsocket;
myPubKey: AgentPubKey;
readonly appWebsocket: AppWebsocket;
installedAppId: InstalledAppId;
cachedAppInfo?: AppInfo;
emitter: Emittery<AppAgentEvents, AppAgentEvents & import("emittery").OmnipresentEventData, never>;
constructor(appWebsocket: AppWebsocket, installedAppId: InstalledAppId);
readonly emitter: Emittery<AppAgentEvents>;
private constructor();
appInfo(): Promise<AppInfoResponse>;
myPubKey(): Promise<AgentPubKey>;
static connect(appWebsocket: AppWebsocket, installedAppId: InstalledAppId): Promise<AppAgentWebsocket>;
getCellIdFromRoleName(roleName: RoleName, appInfo: AppInfo): import("../../types.js").CellId;

@@ -36,0 +16,0 @@ callZome(request: AppAgentCallZomeRequest, timeout?: number): Promise<CallZomeResponse>;

@@ -1,22 +0,1 @@

/**
* Defines AppAgentWebsocket, an easy-to-use websocket implementation of the
* Conductor API for apps, restricted to a single app provided on initialization
*
* const appWs = AppWebsocket.connect('ws://127.0.0.1:9000')
*
* const client = new AppAgentWebsocket(appWs, 'my_installed_app_id')
*
* client.callZome({
* role_name: 'my_role_name' // role_name is unique per app, so you can unambiguously identify your dna with role_name in this client,
* zome_name: 'zome',
* fn_name: 'fn',
* payload: { value: 'v' }
* })
* .then(result => {
* console.log('callZome returned with:', result)
* })
* .catch(err => {
* console.error('callZome errored with:', err)
* })
*/
import Emittery from "emittery";

@@ -26,9 +5,27 @@ import { omit } from "lodash-es";

import { getBaseRoleNameFromCloneId, isCloneId } from "../common.js";
function getPubKey(appInfo) {
// This is fine for now cause `UseExisting` as a provisioning strategy doesn't work yet.
// TODO: change this when AppInfo contains the `AgentPubKey` for this app, like `return appInfo.my_pub_key`
for (const cells of Object.values(appInfo.cell_info)) {
for (const cell of cells) {
if ("Provisioned" in cell) {
return cell.Provisioned.cell_id[1];
}
else if ("Cloned" in cell) {
return cell.Cloned.cell_id[1];
}
}
}
throw new Error(`This app doesn't have any cells, so we can't return the agent public key for it. This is a known issue, and is going to be fixed in the near future.`);
}
export class AppAgentWebsocket {
myPubKey;
appWebsocket;
installedAppId;
cachedAppInfo;
emitter = new Emittery();
constructor(appWebsocket, installedAppId) {
emitter;
constructor(appWebsocket, installedAppId, myPubKey) {
this.myPubKey = myPubKey;
this.appWebsocket = appWebsocket;
this.emitter = new Emittery();
const env = getLauncherEnvironment();

@@ -45,17 +42,8 @@ this.installedAppId = env?.INSTALLED_APP_ID || installedAppId;

}
async myPubKey() {
const appInfo = this.cachedAppInfo || (await this.appInfo());
// This is fine for now cause `UseExisting` as a provisioning strategy doesn't work yet.
// TODO: change this when AppInfo contains the `AgentPubKey` for this app, like `return appInfo.my_pub_key`
for (const cells of Object.values(appInfo.cell_info)) {
for (const cell of cells) {
if ("Provisioned" in cell) {
return cell.Provisioned.cell_id[1];
}
else if ("Cloned" in cell) {
return cell.Cloned.cell_id[1];
}
}
}
throw new Error(`This app doesn't have any cells, so we can't return the agent public key for it. This is a known issue, and is going to be fixed in the near future.`);
static async connect(appWebsocket, installedAppId) {
const appInfo = await appWebsocket.appInfo({
installed_app_id: installedAppId,
});
const myPubKey = getPubKey(appInfo);
return new AppAgentWebsocket(appWebsocket, installedAppId, myPubKey);
}

@@ -87,3 +75,3 @@ getCellIdFromRoleName(roleName, appInfo) {

...request,
provenance: await this.myPubKey(),
provenance: this.myPubKey,
};

@@ -96,3 +84,3 @@ }

...omit(request, "role_name"),
provenance: await this.myPubKey(),
provenance: this.myPubKey,
cell_id,

@@ -99,0 +87,0 @@ };

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

export declare class AppWebsocket extends Emittery implements AppApi {
client: WsClient;
readonly client: WsClient;
defaultTimeout: number;
overrideInstalledAppId?: InstalledAppId;
constructor(client: WsClient, defaultTimeout?: number, overrideInstalledAppId?: InstalledAppId);
private constructor();
static connect(url: string, defaultTimeout?: number, signalCb?: AppSignalCb): Promise<AppWebsocket>;

@@ -14,0 +14,0 @@ _requester: <ReqI, ReqO, ResI, ResO>(tag: string, transformer?: Transformer<ReqI, ReqO, ResI, ResO> | undefined) => (req: ReqI, timeout?: number | undefined) => Promise<ResO>;

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc