@neoskop/ethereal-secrets-client
Advanced tools
Comparing version 4.0.2 to 4.0.3
@@ -20,2 +20,3 @@ export interface EtherealSecretsClientConfig { | ||
constructor(config: EtherealSecretsClientConfig); | ||
private fromBase64; | ||
private toBase64; | ||
@@ -22,0 +23,0 @@ private decrypt; |
@@ -19,4 +19,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
fromBase64(data) { | ||
return new Uint8Array(window | ||
.atob(data) | ||
.split('') | ||
.map(function (c) { | ||
return c.charCodeAt(0); | ||
})); | ||
} | ||
toBase64(data) { | ||
return Buffer.from(data).toString('base64'); | ||
const chunkSize = 0x1000; | ||
const chunks = []; | ||
for (let i = 0; i < data.length; i += chunkSize) { | ||
chunks.push(String.fromCharCode.apply(null, data.subarray(i, i + chunkSize))); | ||
} | ||
return window.btoa(chunks.join('')); | ||
} | ||
@@ -26,6 +39,6 @@ decrypt(secret, cipherText) { | ||
const encryptedObj = JSON.parse(cipherText); | ||
const iv = Buffer.from(encryptedObj.iv, 'base64'); | ||
const salt = Buffer.from(encryptedObj.salt, 'base64'); | ||
const data = Buffer.from(encryptedObj.encrypted, 'base64'); | ||
const additionalData = Buffer.from(encryptedObj.additionalData, 'base64'); | ||
const iv = this.fromBase64(encryptedObj.iv); | ||
const salt = this.fromBase64(encryptedObj.salt); | ||
const data = this.fromBase64(encryptedObj.encrypted); | ||
const additionalData = this.fromBase64(encryptedObj.additionalData); | ||
const key = yield this.deriveKey(secret, salt); | ||
@@ -55,6 +68,6 @@ const clearText = yield window.crypto.subtle.decrypt({ | ||
return JSON.stringify({ | ||
encrypted: Buffer.from(new Uint8Array(encrypted)).toString('base64'), | ||
salt: Buffer.from(salt).toString('base64'), | ||
iv: Buffer.from(iv).toString('base64'), | ||
additionalData: Buffer.from(additionalData).toString('base64'), | ||
encrypted: this.toBase64(new Uint8Array(encrypted)), | ||
salt: this.toBase64(salt), | ||
iv: this.toBase64(iv), | ||
additionalData: this.toBase64(additionalData), | ||
}); | ||
@@ -61,0 +74,0 @@ }); |
{ | ||
"name": "@neoskop/ethereal-secrets-client", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "typings": "dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
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
33381
394