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.15.1 to 0.16.0

2

lib/api/admin/websocket.js

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

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

@@ -140,0 +140,0 @@ cell_id: cellId,

import { hashZomeCall } from "@holochain/serialization";
import { decode, encode } from "@msgpack/msgpack";
import * as ed25519 from "@noble/ed25519";
import _sodium from "libsodium-wrappers";
import Emittery from "emittery";

@@ -26,4 +26,5 @@ import { getLauncherEnvironment, isLauncher, signZomeCallTauri, } from "../../environments/launcher.js";

const to_bind = this[name];
if (typeof to_bind === 'function') {
this[name] = to_bind.bind(this);
if (typeof to_bind === "function") {
this[name] =
to_bind.bind(this);
}

@@ -134,7 +135,11 @@ });

payload: encode(request.payload),
nonce: randomNonce(),
nonce: await randomNonce(),
expires_at: getNonceExpiration(),
};
const hashedZomeCall = await hashZomeCall(unsignedZomeCallPayload);
const signature = await ed25519.signAsync(hashedZomeCall, signingCredentialsForCell.keyPair.privateKey);
await _sodium.ready;
const sodium = _sodium;
const signature = sodium
.crypto_sign(hashedZomeCall, signingCredentialsForCell.keyPair.privateKey)
.subarray(0, sodium.crypto_sign_BYTES);
const signedZomeCall = {

@@ -141,0 +146,0 @@ ...unsignedZomeCallPayload,

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

import { CapSecret } from "../hdk/capabilities.js";
import { AgentPubKey, CellId } from "../types.js";
import { type KeyPair } from "libsodium-wrappers";
import type { CapSecret } from "../hdk/capabilities.js";
import type { AgentPubKey, CellId } from "../types.js";
/**

@@ -10,9 +11,2 @@ * @public

*/
export interface KeyPair {
privateKey: Uint8Array;
publicKey: Uint8Array;
}
/**
* @public
*/
export interface SigningCredentials {

@@ -43,2 +37,4 @@ capSecret: CapSecret;

*
* @param agentPubKey - The agent pub key to take 4 last bytes (= DHT location)
* from (optional).
* @returns The signing key pair and an agent pub key based on the public key.

@@ -48,18 +44,15 @@ *

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

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

@@ -1,6 +0,3 @@

import * as ed25519 from "@noble/ed25519";
import _sodium from "libsodium-wrappers";
import { encodeHashToBase64 } from "../utils/base64.js";
if (!globalThis.crypto) {
import("node:crypto").then((webcrypto) => (globalThis.crypto = webcrypto));
}
const signingCredentials = new Map();

@@ -33,2 +30,4 @@ /**

*
* @param agentPubKey - The agent pub key to take 4 last bytes (= DHT location)
* from (optional).
* @returns The signing key pair and an agent pub key based on the public key.

@@ -38,7 +37,8 @@ *

*/
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]));
export const generateSigningKeyPair = async (agentPubKey) => {
await _sodium.ready;
const sodium = _sodium;
const keyPair = sodium.crypto_sign_keypair();
const locationBytes = agentPubKey ? agentPubKey.subarray(35) : [0, 0, 0, 0];
const signingKey = new Uint8Array([132, 32, 36].concat(...keyPair.publicKey).concat(...locationBytes));
return [keyPair, signingKey];

@@ -49,11 +49,18 @@ };

*/
export const randomCapSecret = () => randomByteArray(64);
export const randomCapSecret = async () => randomByteArray(64);
/**
* @public
*/
export const randomNonce = () => randomByteArray(32);
export const randomNonce = async () => randomByteArray(32);
/**
* @public
*/
export const randomByteArray = (length) => globalThis.crypto.getRandomValues(new Uint8Array(length));
export const randomByteArray = async (length) => {
if (globalThis.crypto && "getRandomValues" in globalThis.crypto) {
return globalThis.crypto.getRandomValues(new Uint8Array(length));
}
await _sodium.ready;
const sodium = _sodium;
return sodium.randombytes_buf(length);
};
/**

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

@@ -14,3 +14,3 @@ import { encode } from "@msgpack/msgpack";

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

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

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

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

"js-base64": "^3.7.3",
"libsodium-wrappers": "^0.7.11",
"lodash-es": "^4.17.21",

@@ -57,13 +58,14 @@ "ws": "^8.13.0"

"@types/js-yaml": "^3.12.7",
"@types/libsodium-wrappers": "^0.7.10",
"@types/lodash-es": "^4.17.6",
"@types/tape": "^4.13.2",
"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^5.27.0",
"@typescript-eslint/parser": "^5.27.0",
"eslint": "^8.16.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-tsdoc": "^0.2.16",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"eslint": "^8.46.0",
"eslint-config-prettier": "^8.10.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-tsdoc": "^0.2.17",
"js-yaml": "^3.14.1",
"prettier": "^2.6.2",
"prettier": "^2.8.8",
"rimraf": "^3.0.2",

@@ -70,0 +72,0 @@ "tape": "^5.5.3",

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

## Compatibility
## Installation
**JS client v0.12.x** is compatible with **Holochain v0.1.x**.
**JS client v0.14.x** is compatible with **Holochain v0.2.x**.
*As target, ES2020 or higher is required when bundling for production*.
**JS client v0.16.x** are compatible with **Holochain v0.2.x**.
## Installation
To install from NPM, run

@@ -161,9 +158,2 @@ ```bash

# Holochain Compatibility
See [default.nix](./default.nix) for the Holochain version this package is compatible with.
If updating the Holochain version included in holonix, please use `niv update` as explained in the
[Holochain Installation Guide](https://developer.holochain.org/install-advanced/#upgrading-the-holochain-version).
## Running tests

@@ -170,0 +160,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