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

iron-webcrypto

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iron-webcrypto

a cryptographic utility for sealing-unsealing a JSON object using symmetric key encryption with message integrity verification

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1M
decreased by-22.49%
Maintainers
1
Weekly downloads
 
Created
Source

iron-webcrypto (beta) jsDocs.io npm

This module is a replacement for @hapi/iron, written using the Web Crypto API that makes it compatible with browser and edge environments.

Check out vvo/iron-session to see this module in use!


Installation

To use this module, run:

npm add iron-webcrypto
npm remove @hapi/iron

and update imports.

Then modify function calls to pass a Web Crypto implementation as the first param. For example:

Iron.seal(obj, password, Iron.defaults)

becomes:

Iron.seal(_crypto, obj, password, Iron.defaults)

where _crypto is your Web Crypto implementation. Generally, this will available in your context (for example, globalThis.crypto in browsers, edge runtimes, Deno1, Bun and Node.js v19+; require('crypto').webcrypto in Node.js v15+). However, you may also need to polyfill this for older Node.js versions. We recommend using @peculiar/webcrypto for that.

Footnotes

  1. You can use esm.sh for importing this module in Deno (and browsers). Example:

    import * as Iron from 'https://esm.sh/iron-webcrypto@0.2.6'
    
    const obj = { a: 1, b: 2, c: [3, 4, 5], d: { e: 'f' } }
    const password = 'some_not_random_password_that_is_also_long_enough'
    
    const sealed = await Iron.seal(crypto, obj, password, Iron.defaults)
    const unsealed = await Iron.unseal(crypto, sealed, password, Iron.defaults)
    
    console.log(unsealed)
    

Keywords

FAQs

Package last updated on 07 Feb 2023

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