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.5.0-rc.7 to 1.5.0-rc.8

52

dist/cjs/index.js

@@ -5,4 +5,4 @@ "use strict";

const tslib_1 = require("tslib");
const isoCrypto = tslib_1.__importStar(require("@pedrouid/iso-crypto"));
const encUtils = tslib_1.__importStar(require("enc-utils"));
const crypto = tslib_1.__importStar(require("@walletconnect/crypto"));
const encoding = tslib_1.__importStar(require("@walletconnect/encoding"));
const utils_1 = require("@walletconnect/utils");

@@ -12,4 +12,4 @@ function generateKey(length) {

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

@@ -21,10 +21,10 @@ });

return tslib_1.__awaiter(this, void 0, void 0, function* () {
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)) {
const cipherText = encoding.hexToArray(payload.data);
const iv = encoding.hexToArray(payload.iv);
const hmac = encoding.hexToArray(payload.hmac);
const hmacHex = encoding.arrayToHex(hmac, false);
const unsigned = encoding.concatArrays(cipherText, iv);
const chmac = yield crypto.hmacSha256Sign(key, unsigned);
const chmacHex = encoding.arrayToHex(chmac, false);
if (encoding.removeHexPrefix(hmacHex) === encoding.removeHexPrefix(chmacHex)) {
return true;

@@ -38,13 +38,13 @@ }

return tslib_1.__awaiter(this, void 0, void 0, function* () {
const _key = encUtils.bufferToArray(utils_1.convertArrayBufferToBuffer(key));
const _key = encoding.bufferToArray(utils_1.convertArrayBufferToBuffer(key));
const ivArrayBuffer = providedIv || (yield generateKey(128));
const iv = encUtils.bufferToArray(utils_1.convertArrayBufferToBuffer(ivArrayBuffer));
const ivHex = encUtils.arrayToHex(iv, false);
const iv = encoding.bufferToArray(utils_1.convertArrayBufferToBuffer(ivArrayBuffer));
const ivHex = encoding.arrayToHex(iv, false);
const contentString = JSON.stringify(data);
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);
const content = encoding.utf8ToArray(contentString);
const cipherText = yield crypto.aesCbcEncrypt(iv, _key, content);
const cipherTextHex = encoding.arrayToHex(cipherText, false);
const unsigned = encoding.concatArrays(cipherText, iv);
const hmac = yield crypto.hmacSha256Sign(_key, unsigned);
const hmacHex = encoding.arrayToHex(hmac, false);
return {

@@ -60,3 +60,3 @@ data: cipherTextHex,

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

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

}
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);
const cipherText = encoding.hexToArray(payload.data);
const iv = encoding.hexToArray(payload.iv);
const buffer = yield crypto.aesCbcDecrypt(iv, _key, cipherText);
const utf8 = encoding.arrayToUtf8(buffer);
let data;

@@ -75,0 +75,0 @@ try {

@@ -1,19 +0,19 @@

import * as isoCrypto from "@pedrouid/iso-crypto";
import * as encUtils from "enc-utils";
import * as crypto from "@walletconnect/crypto";
import * as encoding from "@walletconnect/encoding";
import { convertArrayBufferToBuffer, convertBufferToArrayBuffer } from "@walletconnect/utils";
export async function generateKey(length) {
const _length = (length || 256) / 8;
const bytes = isoCrypto.randomBytes(_length);
const result = convertBufferToArrayBuffer(encUtils.arrayToBuffer(bytes));
const bytes = crypto.randomBytes(_length);
const result = convertBufferToArrayBuffer(encoding.arrayToBuffer(bytes));
return result;
}
export async function verifyHmac(payload, key) {
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 = await isoCrypto.hmacSha256Sign(key, unsigned);
const chmacHex = encUtils.arrayToHex(chmac, false);
if (encUtils.removeHexPrefix(hmacHex) === encUtils.removeHexPrefix(chmacHex)) {
const cipherText = encoding.hexToArray(payload.data);
const iv = encoding.hexToArray(payload.iv);
const hmac = encoding.hexToArray(payload.hmac);
const hmacHex = encoding.arrayToHex(hmac, false);
const unsigned = encoding.concatArrays(cipherText, iv);
const chmac = await crypto.hmacSha256Sign(key, unsigned);
const chmacHex = encoding.arrayToHex(chmac, false);
if (encoding.removeHexPrefix(hmacHex) === encoding.removeHexPrefix(chmacHex)) {
return true;

@@ -24,13 +24,13 @@ }

export async function encrypt(data, key, providedIv) {
const _key = encUtils.bufferToArray(convertArrayBufferToBuffer(key));
const _key = encoding.bufferToArray(convertArrayBufferToBuffer(key));
const ivArrayBuffer = providedIv || (await generateKey(128));
const iv = encUtils.bufferToArray(convertArrayBufferToBuffer(ivArrayBuffer));
const ivHex = encUtils.arrayToHex(iv, false);
const iv = encoding.bufferToArray(convertArrayBufferToBuffer(ivArrayBuffer));
const ivHex = encoding.arrayToHex(iv, false);
const contentString = JSON.stringify(data);
const content = encUtils.utf8ToArray(contentString);
const cipherText = await isoCrypto.aesCbcEncrypt(iv, _key, content);
const cipherTextHex = encUtils.arrayToHex(cipherText, false);
const unsigned = encUtils.concatArrays(cipherText, iv);
const hmac = await isoCrypto.hmacSha256Sign(_key, unsigned);
const hmacHex = encUtils.arrayToHex(hmac, false);
const content = encoding.utf8ToArray(contentString);
const cipherText = await crypto.aesCbcEncrypt(iv, _key, content);
const cipherTextHex = encoding.arrayToHex(cipherText, false);
const unsigned = encoding.concatArrays(cipherText, iv);
const hmac = await crypto.hmacSha256Sign(_key, unsigned);
const hmacHex = encoding.arrayToHex(hmac, false);
return {

@@ -43,3 +43,3 @@ data: cipherTextHex,

export async function decrypt(payload, key) {
const _key = encUtils.bufferToArray(convertArrayBufferToBuffer(key));
const _key = encoding.bufferToArray(convertArrayBufferToBuffer(key));
if (!_key) {

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

}
const cipherText = encUtils.hexToArray(payload.data);
const iv = encUtils.hexToArray(payload.iv);
const buffer = await isoCrypto.aesCbcDecrypt(iv, _key, cipherText);
const utf8 = encUtils.arrayToUtf8(buffer);
const cipherText = encoding.hexToArray(payload.data);
const iv = encoding.hexToArray(payload.iv);
const buffer = await crypto.aesCbcDecrypt(iv, _key, cipherText);
const utf8 = encoding.arrayToUtf8(buffer);
let data;

@@ -58,0 +58,0 @@ try {

{
"name": "@walletconnect/iso-crypto",
"version": "1.5.0-rc.7",
"version": "1.5.0-rc.8",
"description": "Isomorphic Crypto for WalletConnect",

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

"dependencies": {
"@pedrouid/iso-crypto": "^2.0.0-beta.3",
"@walletconnect/types": "^1.5.0-rc.7",
"@walletconnect/utils": "^1.5.0-rc.7"
"@walletconnect/crypto": "^1.0.0-beta.1",
"@walletconnect/types": "^1.5.0-rc.8",
"@walletconnect/utils": "^1.5.0-rc.8"
},
"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 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