Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@transcend-io/penumbra

Package Overview
Dependencies
Maintainers
8
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@transcend-io/penumbra - npm Package Compare versions

Comparing version 2.0.4 to 2.0.7

build/src/tests/fetchAndDecrypt.test.d.ts

9

build/src/decryptStream.js
"use strict";
/* tslint:disable completed-docs */
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const toBuffer = require("typedarray-to-buffer");
const typedarray_to_buffer_1 = __importDefault(require("typedarray-to-buffer"));
// utils

@@ -27,3 +30,3 @@ const utils_1 = require("./utils");

transform: async (chunk, controller) => {
const bufferChunk = toBuffer(chunk);
const bufferChunk = typedarray_to_buffer_1.default(chunk);
// Decrypt chunk and send it out

@@ -54,3 +57,3 @@ const decryptedChunk = decipher.update(bufferChunk);

}
const chunk = toBuffer(value);
const chunk = typedarray_to_buffer_1.default(value);
// Decrypt chunk

@@ -57,0 +60,0 @@ const decValue = decipher.update(chunk);

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -8,3 +11,3 @@ // external modules

// local
const fetchAndDecrypt_1 = require("./fetchAndDecrypt");
const fetchAndDecrypt_1 = __importDefault(require("./fetchAndDecrypt"));
/**

@@ -11,0 +14,0 @@ * Streams a readable stream to disk

@@ -1,4 +0,4 @@

import { RemoteResource } from './types';
import { RemoteResourceWithoutFile } from './types';
/**
* Fetches an encrypted file from a URL deciphers it, and returns a ReadableStream
* Fetches a remote file from a URL, deciphers it (if encrypted), and returns a ReadableStream
*

@@ -8,3 +8,3 @@ * @param resource - The remote resource to download

*/
export default function fetchAndDecrypt({ url, decryptionOptions, progressEventName, }: RemoteResource): Promise<ReadableStream>;
export default function fetchAndDecrypt({ url, decryptionOptions, progressEventName, }: RemoteResourceWithoutFile): Promise<ReadableStream>;
//# sourceMappingURL=fetchAndDecrypt.d.ts.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,6 +9,6 @@ // external modules

// local
const decryptStream_1 = require("./decryptStream");
const decryptStream_1 = __importDefault(require("./decryptStream"));
const utils_1 = require("./utils");
/**
* Fetches an encrypted file from a URL deciphers it, and returns a ReadableStream
* Fetches a remote file from a URL, deciphers it (if encrypted), and returns a ReadableStream
*

@@ -12,0 +15,0 @@ * @param resource - The remote resource to download

@@ -30,3 +30,3 @@ import { RemoteResource } from './types';

* @param urls - The URLs to preload
* @returns A function removing the links that were appended to the DOM
* @returns A function that removes the link tags that were appended to the DOM
*/

@@ -41,6 +41,6 @@ export declare function preload(...resources: RemoteResource[]): () => void;

*
* @param resources - The decrpyted files to download
* @returns The resources primed to be zipped together
* @param resources - The remote files to download
* @returns Readable streams of the decrypted files
*/
export default function fetchMany(...resources: RemoteResource[]): Promise<ReadableStream[]>;
//# sourceMappingURL=fetchMany.d.ts.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// local
const fetchAndDecrypt_1 = require("./fetchAndDecrypt");
const fetchAndDecrypt_1 = __importDefault(require("./fetchAndDecrypt"));
const utils_1 = require("./utils");

@@ -41,3 +44,3 @@ /**

* @param urls - The URLs to preload
* @returns A function removing the links that were appended to the DOM
* @returns A function that removes the link tags that were appended to the DOM
*/

@@ -55,4 +58,4 @@ function preload(...resources) {

*
* @param resources - The decrpyted files to download
* @returns The resources primed to be zipped together
* @param resources - The remote files to download
* @returns Readable streams of the decrypted files
*/

@@ -59,0 +62,0 @@ async function fetchMany(...resources) {

@@ -1,2 +0,2 @@

import { RemoteResource } from './types';
import { RemoteResourceWithoutFile } from './types';
/**

@@ -8,3 +8,3 @@ * Get the contents of an encrypted file

*/
export default function getDecryptedContent(resource: RemoteResource, alwaysBlob?: boolean): Promise<string | Blob>;
export default function getDecryptedContent(resource: RemoteResourceWithoutFile, alwaysBlob?: boolean): Promise<string | Blob>;
//# sourceMappingURL=getDecryptedContent.d.ts.map
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// local
const fetchAndDecrypt_1 = require("./fetchAndDecrypt");
const fetchAndDecrypt_1 = __importDefault(require("./fetchAndDecrypt"));
const utils_1 = require("./utils");

@@ -6,0 +9,0 @@ const MEDIA_TYPES = ['image', 'video', 'audio'];

@@ -11,2 +11,6 @@ /**

/**
* Make selected object keys defined by K optional in type T
*/
export declare type Optionalize<T, K extends keyof T> = Omit<T, K> & Partial<T>;
/**
* A file to download from a remote resource, that is optionally encrypted

@@ -34,17 +38,18 @@ */

/**
* File is optional
*/
export declare type RemoteResourceWithoutFile = Optionalize<RemoteResource, 'filePrefix'>;
/**
* The type that is emitted as progress continues
*/
export declare type ProgressEmit = {
/** Detailed emit */
detail: {
/** Percentage completed */
percent: number;
/** Total bytes read */
totalBytesRead: number;
/** Total number of bytes to read */
contentLength: number;
/** The URL downloading from */
url: string;
};
};
export declare type ProgressEmit = CustomEvent<{
/** Percentage completed */
percent: number;
/** Total bytes read */
totalBytesRead: number;
/** Total number of bytes to read */
contentLength: number;
/** The URL downloading from */
url: string;
}>;
//# sourceMappingURL=types.d.ts.map
{
"name": "@transcend-io/penumbra",
"version": "2.0.4",
"version": "2.0.7",
"description": "Crypto streams for the browser.",

@@ -11,11 +11,19 @@ "main": "build/src/index.js",

"scripts": {
"prepare": "npm run build",
"####### Linting #######": "",
"lint": "eslint . --cache --ext .js,.ts,.tsx,.jsx",
"lint:fresh": "rm .eslintcache; npm run lint",
"lint:fix": "eslint . --ext .js,.ts,.tsx,.jsx --fix",
"ts:lint": "tslint --project .",
"####### Testing #######": "",
"test": "echo \"Error: no test specified\" && exit 1",
"test:interactive": "airtap --local build/src/tests/*.test.js",
"browser-test": "airtap --loopback airtap.local --coverage build/src/tests/*.test.js",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov",
"####### Check Dependencies #######": "",
"check:deps": "npm-check --ignore \"{}\"",
"check:deps:interactive": "npm-check -u",
"####### Build #######": "",
"prepare": "npm run build",
"build": "rimraf build && tsc",
"build:watch": "tsc --watch"
"build:watch": "tsc --watch",
"build-example": "npm install && cd example && npm install && npm run build-prod"
},

@@ -32,4 +40,4 @@ "repository": {

],
"author": "Transcend Privacy Inc.",
"license": "MIT",
"author": "Transcend Inc.",
"license": "Apache-2.0",
"bugs": {

@@ -54,6 +62,9 @@ "url": "https://github.com/transcend-io/penumbra/issues"

"@types/mime-types": "^2.1.0",
"@types/node": "^10.14.12",
"@types/node": "^12.6.2",
"@types/tape": "^4.2.33",
"@typescript-eslint/eslint-plugin": "^1.11.0",
"@typescript-eslint/parser": "^1.11.0",
"airtap": "^2.0.2",
"babel-eslint": "^10.0.2",
"check-deps": "^1.4.1",
"eslint": "^6.0.1",

@@ -65,10 +76,12 @@ "eslint-config-airbnb-base": "^13.1.0",

"eslint-plugin-prettier": "^3.1.0",
"fetch-mock": "^7.3.3",
"fetch-mock": "^7.3.6",
"npm-check": "^5.9.0",
"nyc": "^14.1.1",
"prettier": "^1.17.1",
"rimraf": "^2.6.3",
"tape": "^4.11.0",
"tslint": "^5.18.0",
"tslint-microsoft-contrib": "^6.2.0",
"typescript": "^3.5.2"
"typescript": "^3.5.3"
}
}

@@ -1,3 +0,14 @@

# Usage
# Penumbra (work in progress)
Note: this repo is a work in progress and should not be used in production yet.
[![Build Status](https://travis-ci.com/transcend-io/penumbra.svg?token=XTquxQxQzsVSbyH7sopX&branch=master)](https://travis-ci.com/transcend-io/penumbra)
[![Known Vulnerabilities](https://snyk.io//test/github/transcend-io/penumbra/badge.svg?targetFile=package.json)](https://snyk.io//test/github/transcend-io/penumbra?targetFile=package.json)
[![codecov](https://codecov.io/gh/transcend-io/penumbra/branch/master/graph/badge.svg)](https://codecov.io/gh/transcend-io/penumbra)
[![Netlify Status](https://api.netlify.com/api/v1/badges/533125dc-c7af-4442-af32-df7283c7322b/deploy-status)](https://app.netlify.com/sites/penumbra-demo/deploys)
[![Sauce Test Status](https://saucelabs.com/browser-matrix/penumbra.svg?auth=c2b96594999df3d684c9af8d63a0c61e)](https://saucelabs.com/u/penumbra)
## Usage
Display an encrypted file

@@ -7,3 +18,3 @@

// Decrypt and display text
getDecryptedContent({
const decryptedText = await penumbra.getDecryptedContent({
url: 'https://s3-us-west-2.amazonaws.com/bencmbrook/NYT.txt.enc',

@@ -17,9 +28,9 @@ filePrefix: 'NYT',

},
})
.then(decryptedText => {
document.getElementById('my-paragraph').innerText = decryptedText;
});
});
document.getElementById('my-paragraph').innerText = decryptedText;
// Decrypt and display media
getDecryptedContent({
const imageSrc = await penumbra.getDecryptedContent({
url: 'https://s3-us-west-2.amazonaws.com/bencmbrook/tortoise.jpg.enc',

@@ -34,5 +45,4 @@ filePrefix: 'tortoise',

})
.then(imageSrc => {
document.getElementById('my-img').src = imageSrc;
});
document.getElementById('my-img').src = imageSrc;
```

@@ -43,3 +53,3 @@

```js
downloadEncryptedFile({
penumbra.downloadEncryptedFile({
url: 'https://s3-us-west-2.amazonaws.com/bencmbrook/africa.topo.json.enc',

@@ -61,27 +71,30 @@ filePrefix: 'africa',

// Resources to load
const resources = [{
url: 'https://s3-us-west-2.amazonaws.com/bencmbrook/NYT.txt.enc',
filePrefix: 'NYT',
mimetype: 'text/plain',
decryptionOptions: {
key: 'vScyqmJKqGl73mJkuwm/zPBQk0wct9eQ5wPE8laGcWM=',
iv: '6lNU+2vxJw6SFgse',
authTag: 'gadZhS1QozjEmfmHLblzbg==',
const resources = [
{
url: 'https://s3-us-west-2.amazonaws.com/bencmbrook/NYT.txt.enc',
filePrefix: 'NYT',
mimetype: 'text/plain',
decryptionOptions: {
key: 'vScyqmJKqGl73mJkuwm/zPBQk0wct9eQ5wPE8laGcWM=',
iv: '6lNU+2vxJw6SFgse',
authTag: 'gadZhS1QozjEmfmHLblzbg==',
},
},
}, {
url: 'https://s3-us-west-2.amazonaws.com/bencmbrook/tortoise.jpg.enc',
filePrefix: 'tortoise',
mimetype: 'image/jpeg',
decryptionOptions: {
key: 'vScyqmJKqGl73mJkuwm/zPBQk0wct9eQ5wPE8laGcWM=',
iv: '6lNU+2vxJw6SFgse',
authTag: 'ELry8dZ3djg8BRB+7TyXZA==',
},
}]
{
url: 'https://s3-us-west-2.amazonaws.com/bencmbrook/tortoise.jpg.enc',
filePrefix: 'tortoise',
mimetype: 'image/jpeg',
decryptionOptions: {
key: 'vScyqmJKqGl73mJkuwm/zPBQk0wct9eQ5wPE8laGcWM=',
iv: '6lNU+2vxJw6SFgse',
authTag: 'ELry8dZ3djg8BRB+7TyXZA==',
},
}
]
// preconnect to the origins
preconnect(...resources);
penumbra.preconnect(...resources);
// or preload all of the URLS
preload(...resources);
penumbra.preload(...resources);
```

@@ -95,3 +108,3 @@

window.addEventListener(url, e => {
console.log(`${e.detail}% done`);
console.log(`${e.detail.percent}% done`);
});

@@ -107,1 +120,7 @@ ```

```
### Big Thanks
Cross-browser Testing Platform and Open Source <3 Provided by [Sauce Labs][homepage]
[homepage]: https://saucelabs.com

@@ -5,3 +5,3 @@ /* tslint:disable completed-docs */

import { Decipher } from 'crypto';
import * as toBuffer from 'typedarray-to-buffer';
import toBuffer from 'typedarray-to-buffer';

@@ -8,0 +8,0 @@ // utils

@@ -6,7 +6,7 @@ // external modules

import decryptStream from './decryptStream';
import { RemoteResource } from './types';
import { RemoteResourceWithoutFile } from './types';
import { toBuff } from './utils';
/**
* Fetches an encrypted file from a URL deciphers it, and returns a ReadableStream
* Fetches a remote file from a URL, deciphers it (if encrypted), and returns a ReadableStream
*

@@ -20,3 +20,3 @@ * @param resource - The remote resource to download

progressEventName = url,
}: RemoteResource): Promise<ReadableStream> {
}: RemoteResourceWithoutFile): Promise<ReadableStream> {
return (

@@ -23,0 +23,0 @@ fetch(url)

@@ -54,3 +54,3 @@ // local

* @param urls - The URLs to preload
* @returns A function removing the links that were appended to the DOM
* @returns A function that removes the link tags that were appended to the DOM
*/

@@ -71,4 +71,4 @@ export function preload(...resources: RemoteResource[]): () => void {

*
* @param resources - The decrpyted files to download
* @returns The resources primed to be zipped together
* @param resources - The remote files to download
* @returns Readable streams of the decrypted files
*/

@@ -75,0 +75,0 @@ export default async function fetchMany(

// local
import fetchAndDecrypt from './fetchAndDecrypt';
import { RemoteResource } from './types';
import { RemoteResourceWithoutFile } from './types';
import { getMediaSrcFromRS, getTextFromRS } from './utils';

@@ -16,3 +16,3 @@

export default async function getDecryptedContent(
resource: RemoteResource,
resource: RemoteResourceWithoutFile,
alwaysBlob = false,

@@ -19,0 +19,0 @@ ): Promise<string | Blob> {

@@ -11,2 +11,7 @@ /**

/**
* Make selected object keys defined by K optional in type T
*/
export type Optionalize<T, K extends keyof T> = Omit<T, K> & Partial<T>;
/**
* A file to download from a remote resource, that is optionally encrypted

@@ -35,16 +40,21 @@ */

/**
* File is optional
*/
export type RemoteResourceWithoutFile = Optionalize<
RemoteResource,
'filePrefix'
>;
/**
* The type that is emitted as progress continues
*/
export type ProgressEmit = {
/** Detailed emit */
detail: {
/** Percentage completed */
percent: number;
/** Total bytes read */
totalBytesRead: number;
/** Total number of bytes to read */
contentLength: number;
/** The URL downloading from */
url: string;
};
};
export type ProgressEmit = CustomEvent<{
/** Percentage completed */
percent: number;
/** Total bytes read */
totalBytesRead: number;
/** Total number of bytes to read */
contentLength: number;
/** The URL downloading from */
url: string;
}>;

@@ -19,3 +19,3 @@ // penumbra

const percent = Math.round((totalBytesRead / contentLength) * 100);
const emitContent: ProgressEmit = {
const emitContent: Pick<ProgressEmit, 'detail'> = {
detail: {

@@ -22,0 +22,0 @@ percent,

@@ -13,2 +13,3 @@ {

"removeComments": false,
"esModuleInterop": true,
"baseUrl": ".",

@@ -28,2 +29,2 @@ "outDir": "build",

]
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc