We need both
This commit is contained in:
@@ -31,6 +31,8 @@ export const _encryptMetadataJSON = ({ jsonValue, keyB64 }: EncryptJSON) =>
|
||||
keyB64,
|
||||
});
|
||||
|
||||
export const _decryptBox = libsodium.decryptBox2;
|
||||
|
||||
export const _decryptBoxB64 = libsodium.decryptBoxB64;
|
||||
|
||||
export const _decryptAssociatedData = libsodium.decryptBlob;
|
||||
|
||||
@@ -142,8 +142,15 @@ export const encryptMetadataJSON = async (r: EncryptJSON) =>
|
||||
: sharedCryptoWorker().then((w) => w.encryptMetadataJSON(r));
|
||||
|
||||
/**
|
||||
* Decrypt a box encrypted using {@link encryptBoxB64}, and return the result as
|
||||
* a base64 string.
|
||||
* Decrypt a box encrypted using {@link encryptBoxB64}.
|
||||
*/
|
||||
export const decryptBox = (box: EncryptedBox2, key: BytesOrB64) =>
|
||||
inWorker()
|
||||
? ei._decryptBox(box, key)
|
||||
: sharedCryptoWorker().then((w) => w.decryptBox(box, key));
|
||||
|
||||
/**
|
||||
* Variant of {@link decryptBoxlink} that returns the result as a base64 string.
|
||||
*/
|
||||
export const decryptBoxB64 = (box: EncryptedBox2, key: BytesOrB64) =>
|
||||
inWorker()
|
||||
|
||||
@@ -380,12 +380,7 @@ export const decryptBox = async ({
|
||||
/**
|
||||
* Decrypt the result of {@link encryptBoxB64}.
|
||||
*/
|
||||
export const decryptBoxB64 = (
|
||||
box: EncryptedBox2,
|
||||
key: BytesOrB64,
|
||||
): Promise<string> => _decryptBox(box, key).then(toB64);
|
||||
|
||||
export const _decryptBox = async (
|
||||
export const decryptBox2 = async (
|
||||
{ encryptedData, nonce }: EncryptedBox2,
|
||||
key: BytesOrB64,
|
||||
): Promise<Uint8Array> => {
|
||||
@@ -397,6 +392,14 @@ export const _decryptBox = async (
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Variant of {@link decryptBox} that returns the data as a base64 string.
|
||||
*/
|
||||
export const decryptBoxB64 = (
|
||||
box: EncryptedBox2,
|
||||
key: BytesOrB64,
|
||||
): Promise<string> => decryptBox2(box, key).then(toB64);
|
||||
|
||||
/**
|
||||
* Decrypt the result of {@link encryptBlob}.
|
||||
*/
|
||||
|
||||
@@ -15,6 +15,7 @@ export class CryptoWorker {
|
||||
encryptBoxB64 = ei._encryptBoxB64;
|
||||
encryptThumbnail = ei._encryptThumbnail;
|
||||
encryptMetadataJSON = ei._encryptMetadataJSON;
|
||||
decryptBox = ei._decryptBox;
|
||||
decryptBoxB64 = ei._decryptBoxB64;
|
||||
decryptThumbnail = ei._decryptThumbnail;
|
||||
decryptAssociatedDataB64 = ei._decryptAssociatedDataB64;
|
||||
|
||||
Reference in New Issue
Block a user