@holochain/client
Advanced tools
Comparing version 0.11.15 to 0.11.16
@@ -12,6 +12,6 @@ import Emittery, { UnsubscribeFunction } from "emittery"; | ||
export declare class AppAgentWebsocket implements AppAgentClient { | ||
myPubKey: AgentPubKey; | ||
readonly appWebsocket: AppWebsocket; | ||
installedAppId: InstalledAppId; | ||
cachedAppInfo?: AppInfo; | ||
myPubKey: AgentPubKey; | ||
readonly emitter: Emittery<AppAgentEvents>; | ||
@@ -18,0 +18,0 @@ private constructor(); |
@@ -6,17 +6,2 @@ import Emittery from "emittery"; | ||
import { AppWebsocket, CellType, } from "../index.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 (CellType.Provisioned in cell) { | ||
return cell[CellType.Provisioned].cell_id[1]; | ||
} | ||
else if (CellType.Cloned in cell) { | ||
return cell[CellType.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.`); | ||
} | ||
/** | ||
@@ -29,9 +14,8 @@ * A class to establish a websocket connection to an App interface, for a | ||
export class AppAgentWebsocket { | ||
myPubKey; | ||
appWebsocket; | ||
installedAppId; | ||
cachedAppInfo; | ||
myPubKey; | ||
emitter; | ||
constructor(appWebsocket, installedAppId, myPubKey) { | ||
this.myPubKey = myPubKey; | ||
this.appWebsocket = appWebsocket; | ||
@@ -41,2 +25,3 @@ this.emitter = new Emittery(); | ||
this.installedAppId = env?.INSTALLED_APP_ID || installedAppId; | ||
this.myPubKey = myPubKey; | ||
this.appWebsocket.on("signal", (signal) => { | ||
@@ -73,4 +58,3 @@ if (this.containsCell(signal.cell_id)) { | ||
}); | ||
const myPubKey = getPubKey(appInfo); | ||
const appAgentWs = new AppAgentWebsocket(appWebsocket, installed_app_id, myPubKey); | ||
const appAgentWs = new AppAgentWebsocket(appWebsocket, installed_app_id, appInfo.agent_pub_key); | ||
appAgentWs.cachedAppInfo = appInfo; | ||
@@ -77,0 +61,0 @@ return appAgentWs; |
{ | ||
"name": "@holochain/client", | ||
"version": "0.11.15", | ||
"version": "0.11.16", | ||
"description": "A JavaScript client for the Holochain Conductor API", | ||
@@ -5,0 +5,0 @@ "author": "Holochain Foundation <info@holochain.org> (http://holochain.org)", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94548
3072