Socket
Socket
Sign inDemoInstall

@walletconnect/iso-crypto

Package Overview
Dependencies
Maintainers
1
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@walletconnect/iso-crypto - npm Package Compare versions

Comparing version 1.3.2-rc.2 to 1.3.2-rc.3

3

dist/cjs/index.d.ts

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

/// <reference types="node" />
import { IJsonRpcRequest, IJsonRpcResponseSuccess, IJsonRpcResponseError, IEncryptionPayload } from "@walletconnect/types";
export declare function generateKey(length?: number): Promise<ArrayBuffer>;
export declare function verifyHmac(payload: IEncryptionPayload, key: Buffer): Promise<boolean>;
export declare function verifyHmac(payload: IEncryptionPayload, key: Uint8Array): Promise<boolean>;
export declare function encrypt(data: IJsonRpcRequest | IJsonRpcResponseSuccess | IJsonRpcResponseError, key: ArrayBuffer, providedIv?: ArrayBuffer): Promise<IEncryptionPayload>;
export declare function decrypt(payload: IEncryptionPayload, key: ArrayBuffer): Promise<IJsonRpcRequest | IJsonRpcResponseSuccess | IJsonRpcResponseError | null>;
//# sourceMappingURL=index.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const eccryptoJS = tslib_1.__importStar(require("eccrypto-js"));
const isoCrypto = tslib_1.__importStar(require("@pedrouid/iso-crypto"));
const encUtils = tslib_1.__importStar(require("enc-utils"));
const utils_1 = require("@walletconnect/utils");

@@ -9,4 +10,4 @@ function generateKey(length) {

const _length = (length || 256) / 8;
const buffer = eccryptoJS.randomBytes(_length);
const result = utils_1.convertBufferToArrayBuffer(buffer);
const bytes = isoCrypto.randomBytes(_length);
const result = utils_1.convertBufferToArrayBuffer(encUtils.arrayToBuffer(bytes));
return result;

@@ -18,10 +19,10 @@ });

return tslib_1.__awaiter(this, void 0, void 0, function* () {
const cipherText = utils_1.convertHexToBuffer(payload.data);
const iv = utils_1.convertHexToBuffer(payload.iv);
const hmac = utils_1.convertHexToBuffer(payload.hmac);
const hmacHex = utils_1.convertBufferToHex(hmac, true);
const unsigned = utils_1.concatBuffers(cipherText, iv);
const chmac = yield eccryptoJS.hmacSha256Sign(key, unsigned);
const chmacHex = utils_1.convertBufferToHex(chmac, true);
if (utils_1.removeHexPrefix(hmacHex) === utils_1.removeHexPrefix(chmacHex)) {
const cipherText = encUtils.hexToArray(payload.data);
const iv = encUtils.hexToArray(payload.iv);
const hmac = encUtils.hexToArray(payload.hmac);
const hmacHex = encUtils.arrayToHex(hmac, false);
const unsigned = encUtils.concatArrays(cipherText, iv);
const chmac = yield isoCrypto.hmacSha256Sign(key, unsigned);
const chmacHex = encUtils.arrayToHex(chmac, false);
if (encUtils.removeHexPrefix(hmacHex) === encUtils.removeHexPrefix(chmacHex)) {
return true;

@@ -35,13 +36,13 @@ }

return tslib_1.__awaiter(this, void 0, void 0, function* () {
const _key = utils_1.convertArrayBufferToBuffer(key);
const _key = encUtils.bufferToArray(utils_1.convertArrayBufferToBuffer(key));
const ivArrayBuffer = providedIv || (yield generateKey(128));
const iv = utils_1.convertArrayBufferToBuffer(ivArrayBuffer);
const ivHex = utils_1.convertBufferToHex(iv, true);
const iv = encUtils.bufferToArray(utils_1.convertArrayBufferToBuffer(ivArrayBuffer));
const ivHex = encUtils.arrayToHex(iv, false);
const contentString = JSON.stringify(data);
const content = utils_1.convertUtf8ToBuffer(contentString);
const cipherText = yield eccryptoJS.aesCbcEncrypt(iv, _key, content);
const cipherTextHex = utils_1.convertBufferToHex(cipherText, true);
const unsigned = utils_1.concatBuffers(cipherText, iv);
const hmac = yield eccryptoJS.hmacSha256Sign(_key, unsigned);
const hmacHex = utils_1.convertBufferToHex(hmac, true);
const content = encUtils.utf8ToArray(contentString);
const cipherText = yield isoCrypto.aesCbcEncrypt(iv, _key, content);
const cipherTextHex = encUtils.arrayToHex(cipherText, false);
const unsigned = encUtils.concatArrays(cipherText, iv);
const hmac = yield isoCrypto.hmacSha256Sign(_key, unsigned);
const hmacHex = encUtils.arrayToHex(hmac, false);
return {

@@ -57,3 +58,3 @@ data: cipherTextHex,

return tslib_1.__awaiter(this, void 0, void 0, function* () {
const _key = utils_1.convertArrayBufferToBuffer(key);
const _key = encUtils.bufferToArray(utils_1.convertArrayBufferToBuffer(key));
if (!_key) {

@@ -66,6 +67,6 @@ throw new Error("Missing key: required for decryption");

}
const cipherText = utils_1.convertHexToBuffer(payload.data);
const iv = utils_1.convertHexToBuffer(payload.iv);
const buffer = yield eccryptoJS.aesCbcDecrypt(iv, _key, cipherText);
const utf8 = utils_1.convertBufferToUtf8(buffer);
const cipherText = encUtils.hexToArray(payload.data);
const iv = encUtils.hexToArray(payload.iv);
const buffer = yield isoCrypto.aesCbcDecrypt(iv, _key, cipherText);
const utf8 = encUtils.arrayToUtf8(buffer);
let data;

@@ -72,0 +73,0 @@ try {

{
"name": "@walletconnect/iso-crypto",
"version": "1.3.2-rc.2",
"version": "1.3.2-rc.3",
"description": "Isomorphic Crypto for WalletConnect",

@@ -59,7 +59,7 @@ "scripts": {

"dependencies": {
"@walletconnect/types": "^1.3.2-rc.2",
"@walletconnect/utils": "^1.3.2-rc.2",
"eccrypto-js": "5.2.0"
"@pedrouid/iso-crypto": "^1.0.0",
"@walletconnect/types": "^1.3.2-rc.3",
"@walletconnect/utils": "^1.3.2-rc.3"
},
"gitHead": "165f7993c2acc907c653c02847fb02721052c6e7"
}

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

Sorry, the diff of this file is too big to display

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