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

Crypto streams for the browser.

  • 2.0.4
  • Source
  • npm
  • Socket score

Version published
Maintainers
8
Created
Source

Usage

Display an encrypted file

// Decrypt and display text
getDecryptedContent({
  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==',
  },
})
  .then(decryptedText => {
    document.getElementById('my-paragraph').innerText = decryptedText;
  });

// Decrypt and display media
getDecryptedContent({
  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==',
  },
})
  .then(imageSrc => {
    document.getElementById('my-img').src = imageSrc;
  });

Download an encrypted file

downloadEncryptedFile({
  url: 'https://s3-us-west-2.amazonaws.com/bencmbrook/africa.topo.json.enc',
  filePrefix: 'africa',
  mimetype: 'image/jpeg',
  decryptionOptions: {
    key: 'vScyqmJKqGl73mJkuwm/zPBQk0wct9eQ5wPE8laGcWM=',
    iv: '6lNU+2vxJw6SFgse',
    authTag: 'ELry8dZ3djg8BRB+7TyXZA==',
  },
  progressEventName: 'download-progress' // defaults to the url
});

Prepare connections for file downloads in advance

// 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==',
  },
}, {
  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);

// or preload all of the URLS
preload(...resources);

Download Progress Event Emitter

You can listen to a download progress event. The event name is the same as the url parameter

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

Note: this feature requires the Content-Length response header to be exposed. This works by adding Access-Control-Expose-Headers: Content-Length to the response header (read more here and here)

On Amazon S3, this means adding the following line to your bucket policy, inside the <CORSRule> block:

<ExposeHeader>Content-Length</ExposeHeader>

Keywords

FAQs

Package last updated on 09 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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