@walletconnect/iso-crypto
Advanced tools
Comparing version 1.0.0-beta.87 to 1.0.0-beta.88
@@ -5,4 +5,4 @@ /// <reference types="node" /> | ||
export declare function verifyHmac(payload: IEncryptionPayload, key: Buffer): Promise<boolean>; | ||
export declare function encrypt(data: IJsonRpcRequest | IJsonRpcResponseSuccess | IJsonRpcResponseError, key: ArrayBuffer): Promise<IEncryptionPayload>; | ||
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 |
@@ -22,3 +22,3 @@ "use strict"; | ||
const unsigned = utils_1.concatBuffers(cipherText, iv); | ||
const chmac = yield eccryptoJS.hmacSha256Sign(unsigned, key); | ||
const chmac = yield eccryptoJS.hmacSha256Sign(key, unsigned); | ||
const chmacHex = utils_1.convertBufferToHex(chmac, true); | ||
@@ -32,6 +32,6 @@ if (utils_1.removeHexPrefix(hmacHex) === utils_1.removeHexPrefix(chmacHex)) { | ||
exports.verifyHmac = verifyHmac; | ||
function encrypt(data, key) { | ||
function encrypt(data, key, providedIv) { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const _key = utils_1.convertArrayBufferToBuffer(key); | ||
const ivArrayBuffer = yield generateKey(128); | ||
const ivArrayBuffer = providedIv || (yield generateKey(128)); | ||
const iv = utils_1.convertArrayBufferToBuffer(ivArrayBuffer); | ||
@@ -41,6 +41,6 @@ const ivHex = utils_1.convertBufferToHex(iv, true); | ||
const content = utils_1.convertUtf8ToBuffer(contentString); | ||
const cipherText = yield eccryptoJS.aesCbcEncrypt(content, _key, iv); | ||
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(unsigned, _key); | ||
const hmac = yield eccryptoJS.hmacSha256Sign(_key, unsigned); | ||
const hmacHex = utils_1.convertBufferToHex(hmac, true); | ||
@@ -67,3 +67,3 @@ return { | ||
const iv = utils_1.convertHexToBuffer(payload.iv); | ||
const buffer = yield eccryptoJS.aesCbcDecrypt(cipherText, _key, iv); | ||
const buffer = yield eccryptoJS.aesCbcDecrypt(iv, _key, cipherText); | ||
const utf8 = utils_1.convertBufferToUtf8(buffer); | ||
@@ -70,0 +70,0 @@ let data; |
{ | ||
"name": "@walletconnect/iso-crypto", | ||
"version": "1.0.0-beta.87", | ||
"version": "1.0.0-beta.88", | ||
"description": "Isomorphic Crypto for WalletConnect", | ||
@@ -58,4 +58,4 @@ "scripts": { | ||
"dependencies": { | ||
"@walletconnect/types": "^1.0.0-beta.87", | ||
"@walletconnect/utils": "^1.0.0-beta.87", | ||
"@walletconnect/types": "^1.0.0-beta.88", | ||
"@walletconnect/utils": "^1.0.0-beta.88", | ||
"eccrypto-js": "4.5.2" | ||
@@ -62,0 +62,0 @@ }, |
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
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
703621
1903