chore(frontend): temporarily disable sodium-based frontend cryptography for browser compatibility
This commit is contained in:
parent
25953854c9
commit
8feb408777
@ -5,7 +5,7 @@
|
||||
/* global:writable */
|
||||
|
||||
import semver from 'semver';
|
||||
import sodium from 'sodium-javascript';
|
||||
// import sodium from 'sodium-javascript';
|
||||
|
||||
import { HttpClient } from '../../services/http-client/http-client';
|
||||
|
||||
@ -460,7 +460,7 @@ export class StorageManager {
|
||||
const enc = this.load('encryption', { ...options, encryption: false });
|
||||
const requestBody = {
|
||||
type : options.encryption,
|
||||
length : sodium.crypto_secretbox_KEYBYTES,
|
||||
length : undefined, // sodium.crypto_secretbox_KEYBYTES,
|
||||
salt : enc.salt,
|
||||
timestamp : enc.timestamp,
|
||||
};
|
||||
@ -501,10 +501,10 @@ function encrypt(plaintext, key) {
|
||||
// TODO use const if possible
|
||||
let plaintextB = Buffer.from(plaintext);
|
||||
let cipherB = Buffer.alloc(plaintextB.length + sodium.crypto_secretbox_MACBYTES);
|
||||
let nonceB = Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES);
|
||||
let nonceB = undefined; // Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES);
|
||||
let keyB = Buffer.from(key);
|
||||
|
||||
sodium.crypto_secretbox_easy(cipherB, plaintextB, nonceB, keyB);
|
||||
// sodium.crypto_secretbox_easy(cipherB, plaintextB, nonceB, keyB);
|
||||
|
||||
const result = cipherB;
|
||||
console.log('encrypt result', result);
|
||||
@ -520,11 +520,11 @@ function decrypt(ciphertext, key) {
|
||||
|
||||
// TODO use const if possible
|
||||
let cipherB = Buffer.from(ciphertext);
|
||||
let plaintextB = Buffer.alloc(cipherB.length - sodium.crypto_secretbox_MACBYTES);
|
||||
let nonceB = Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES);
|
||||
let plaintextB = undefined; Buffer.alloc(cipherB.length - sodium.crypto_secretbox_MACBYTES);
|
||||
let nonceB = undefined; Buffer.alloc(sodium.crypto_secretbox_NONCEBYTES);
|
||||
let keyB = Buffer.from(key);
|
||||
|
||||
sodium.crypto_secretbox_open_easy(plaintextB, cipherB, nonceB, keyB);
|
||||
// sodium.crypto_secretbox_open_easy(plaintextB, cipherB, nonceB, keyB);
|
||||
|
||||
const result = plaintextB.toString();
|
||||
console.log('decrypt result', result);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user