Socket
Socket
Sign inDemoInstall

@hapi/iron

Package Overview
Dependencies
5
Maintainers
7
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @hapi/iron

Encapsulated tokens (encrypted and mac'ed objects)


Version published
Weekly downloads
1.4M
increased by0.77%
Maintainers
7
Install size
123 kB
Created
Weekly downloads
 

Package description

What is @hapi/iron?

The @hapi/iron package is designed for encapsulated tokens (Sealed objects) creation and management. It provides a robust suite of tools for encrypting and decrypting data, creating tamper-proof, time-limited tokens that can securely transmit information between parties. This is particularly useful for creating authentication tokens, secure cookies, and other forms of secure data exchange in web applications.

What are @hapi/iron's main functionalities?

Data Sealing

This feature allows you to encrypt an object, turning it into a sealed string. This string can then be safely transmitted or stored, with the assurance that it cannot be tampered with without detection.

const Iron = require('@hapi/iron');

async function sealData() {
  const object = { a: 1, b: 2, c: 3 };
  const password = 'some-not-very-secret-password';
  const sealed = await Iron.seal(object, password, Iron.defaults);
  console.log(sealed);
}

sealData();

Data Unsealing

This feature allows you to decrypt a previously sealed string, returning it to its original object form. This is crucial for accessing the data in a secure manner after it has been transmitted or stored.

const Iron = require('@hapi/iron');

async function unsealData(sealed) {
  const password = 'some-not-very-secret-password';
  const unsealed = await Iron.unseal(sealed, password, Iron.defaults);
  console.log(unsealed);
}

// Assume 'sealed' is obtained from the sealData function
// unsealData(sealed);

Other packages similar to @hapi/iron

Readme

Source

@hapi/iron

Encapsulated tokens (encrypted and mac'ed objects).

iron is part of the hapi ecosystem and was designed to work seamlessly with the hapi web framework and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out hapi – they work even better together.

Visit the hapi.dev Developer Portal for tutorials, documentation, and support

Useful resources

Keywords

FAQs

Last updated on 11 Feb 2023

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc