iron-webcrypto (beta)
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.