Update pipeline to Node 24. Update Lerna. Update Vitepress to Beta. Replace...
This commit is contained in:
@@ -36,20 +36,26 @@ export class Encrypter {
|
||||
...opts,
|
||||
};
|
||||
|
||||
// Something about the browser crypto API. It needs a "clean" Uint8Array, where TS could see the construction or something
|
||||
const cleanKey = new Uint8Array(key);
|
||||
|
||||
// Create a key derivation key
|
||||
const keyMaterialBase = await crypto.subtle.importKey(
|
||||
'raw',
|
||||
key,
|
||||
cleanKey,
|
||||
'PBKDF2',
|
||||
false,
|
||||
['deriveBits', 'deriveKey'],
|
||||
);
|
||||
|
||||
// Something about the browser crypto API. It needs a "clean" Uint8Array, where TS could see the construction or something
|
||||
const cleanSalt = new Uint8Array(encryptionOpts.salt);
|
||||
|
||||
// Derive the actual encryption key
|
||||
const derivedKey = await crypto.subtle.deriveKey(
|
||||
{
|
||||
name: 'PBKDF2',
|
||||
salt: encryptionOpts.salt,
|
||||
salt: cleanSalt,
|
||||
iterations: encryptionOpts.iterations,
|
||||
hash: 'SHA-256',
|
||||
},
|
||||
@@ -87,6 +93,9 @@ export class Encrypter {
|
||||
// Generate random IV
|
||||
const iv = crypto.getRandomValues(new Uint8Array(this.opts.ivLength));
|
||||
|
||||
// Something about the browser crypto API. It needs a "clean" Uint8Array, where TS could see the construction or something
|
||||
const cleanData = new Uint8Array(data);
|
||||
|
||||
// Encrypt the data
|
||||
const encryptedData = await crypto.subtle.encrypt(
|
||||
{
|
||||
@@ -94,7 +103,7 @@ export class Encrypter {
|
||||
iv,
|
||||
},
|
||||
this.key,
|
||||
data,
|
||||
cleanData,
|
||||
);
|
||||
|
||||
// Combine IV and encrypted data
|
||||
|
||||
Reference in New Issue
Block a user