@transcend-io/penumbra
Advanced tools
Comparing version 1.1.2 to 1.3.0
@@ -11,5 +11,5 @@ /// <reference types="node" /> | ||
*/ | ||
interface DownloadEncryptedFileOptions { | ||
declare type DownloadEncryptedFileOptions = { | ||
fileName?: string | null; | ||
} | ||
}; | ||
export declare function downloadEncryptedFile(url: string, key: string | Buffer, iv: string | Buffer, authTag: string | Buffer, options?: DownloadEncryptedFileOptions): Promise<void>; | ||
@@ -25,3 +25,6 @@ /** | ||
*/ | ||
export declare function getDecryptedContent(url: string, key: string | Buffer, iv: string | Buffer, authTag: string | Buffer, mime: string): Promise<string | Blob>; | ||
declare type GetDecryptedContentOptions = { | ||
alwaysBlob?: boolean; | ||
}; | ||
export declare function getDecryptedContent(url: string, key: string | Buffer, iv: string | Buffer, authTag: string | Buffer, mime: string, options?: GetDecryptedContentOptions): Promise<string | Blob>; | ||
export {}; |
@@ -219,12 +219,4 @@ "use strict"; | ||
exports.downloadEncryptedFile = downloadEncryptedFile; | ||
/** | ||
* Download, decrypt, and return string, object URL, or Blob to display directly on the webpage | ||
* @param url the URL to fetch an encrypted file from | ||
* @param key the decryption key to use for this encrypted file, as a Buffer or base64-encoded string | ||
* @param iv the initialization vector for this encrypted file, as a Buffer or base64-encoded string | ||
* @param authTag the authentication tag for this encrypted file, as a Buffer or base64-encoded string | ||
* @param mime the mime type of the underlying file | ||
* @returns depending on mime type, a string of text, or an src if it's media | ||
*/ | ||
function getDecryptedContent(url, key, iv, authTag, mime) { | ||
function getDecryptedContent(url, key, iv, authTag, mime, options) { | ||
if (options === void 0) { options = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -240,6 +232,8 @@ var type, rs; | ||
// Return the decrypted content | ||
if (type === 'image' || type === 'video' || type === 'audio') | ||
return [2 /*return*/, getMediaSrcFromRS(rs)]; | ||
if (type === 'text' || mime === 'application/json') | ||
return [2 /*return*/, getTextFromRS(rs)]; | ||
if (!options.alwaysBlob) { | ||
if (type === 'image' || type === 'video' || type === 'audio') | ||
return [2 /*return*/, getMediaSrcFromRS(rs)]; | ||
if (type === 'text' || mime === 'application/json') | ||
return [2 /*return*/, getTextFromRS(rs)]; | ||
} | ||
return [2 /*return*/, new Response(rs).blob()]; | ||
@@ -246,0 +240,0 @@ } |
16
index.ts
@@ -226,3 +226,3 @@ // External modules | ||
interface DownloadEncryptedFileOptions { | ||
type DownloadEncryptedFileOptions = { | ||
fileName?: string | null; | ||
@@ -257,2 +257,7 @@ } | ||
*/ | ||
type GetDecryptedContentOptions = { | ||
// useServiceWorker?: boolean, | ||
alwaysBlob?: boolean, | ||
} | ||
export async function getDecryptedContent( | ||
@@ -264,2 +269,3 @@ url: string, | ||
mime: string, | ||
options: GetDecryptedContentOptions = {}, | ||
): Promise<string | Blob> { | ||
@@ -271,5 +277,7 @@ const type = mime.split('/')[0]; | ||
// Return the decrypted content | ||
if (type === 'image' || type === 'video' || type === 'audio') return getMediaSrcFromRS(rs); | ||
if (type === 'text' || mime === 'application/json') return getTextFromRS(rs); | ||
if (!options.alwaysBlob) { | ||
if (type === 'image' || type === 'video' || type === 'audio') return getMediaSrcFromRS(rs); | ||
if (type === 'text' || mime === 'application/json') return getTextFromRS(rs); | ||
} | ||
return new Response(rs).blob(); | ||
} | ||
} |
{ | ||
"name": "@transcend-io/penumbra", | ||
"version": "1.1.2", | ||
"version": "1.3.0", | ||
"description": "Crypto streams for the browser.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
535
29639