Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ansible-vault

commenthol13.6kMIT1.3.0TypeScript support: included

An ansible vault compatible en- and decryption library for javascript

ansible, vault

readme

NPM version npm Build Status

ansible-vault

An Ansible vault compatible en- and decryption library for javascript

usage

encrypt

import { Vault } from 'ansible-vault'

const v = new Vault({ password: 'pa$$w0rd' })
v.encrypt('superSecret123').then(console.log)
//> $ANSIBLE_VAULT;1.1;AES256
//> 33383239333036363833303565653032383832663162356533343630623030613133623032636566
//> 6536303436646561356461623866386133623462383832620a646363626137626635353462386430
//> 34333937313366383038346135656563316236313139333933383139376333353266666436316536
//> 6335376265313432610a313537363637383264646261303637646631346137393964386432313633
//> 3666

// or for synchronous operation
const vault = v.encryptSync('superSecret123')

decrypt

import { Vault } from 'ansible-vault'

const vault = `$ANSIBLE_VAULT;1.1;AES256
33383239333036363833303565653032383832663162356533343630623030613133623032636566
6536303436646561356461623866386133623462383832620a646363626137626635353462386430
34333937313366383038346135656563316236313139333933383139376333353266666436316536
6335376265313432610a313537363637383264646261303637646631346137393964386432313633
3666`

const v = new Vault({ password: 'pa$$w0rd' })
v.decrypt(vault).then(console.log)
//> superSecret123

// or for synchronous operation
const secret = v.decryptSync(vault)

license

MIT Licensed

references

Ansible® is a registered trademark of RedHat® (I hope this is correct...)

changelog

1.3.0 (2024-07-27)

  • feat: add binascii functions for zero dependencies (#633af73)
  • feat: change to ESM (#0316412)
  • docs: fix CI status badge (#a9f74c7)

1.2.0 (2024-07-27)

  • feat: fix pkcs7 padding for encryption to match compatibility with ansible-vault (#5dc1426)
  • Refactor test/index.spec.js (#bc2ae9b)
  • Add test for encryption/decryption with special characters (#7d88ba0)
  • chore: github actions with node 20, 22 (#6fb9e28)
  • chore: bump dev dependencies (#9c2e721)
  • Fix padding issue with Ansible vault for special chars (#9ee4d4a)

1.1.1 (2023-09-29)

  • chore: bump devDependencies (#b1ce09a)
  • Add test (#90151de)
  • Split on CLRF (#570081e)

1.1.0 (2022-02-22)

  • docs: Add synchronous methods in examples (#4037750)
  • chore: remove ignore-scripts with .npmrc (#04c2b51)
  • chore: add prepublishOnly script (#d8b6b3b)
  • docs: add typescript types (#d228b04)
  • chore: enable github actions (#e63f647)
  • Review Comments (#c8b58d8)
  • Undo version change - use npm version (#5bccbcf)
  • v1.4 Sync Operations (#18d2973)

1.0.3 (2021-09-05)

  • chore: fix travis badge link (#40ec8fc)
  • chore: bump dependencies (#1a22648)
  • fix: pkcs7 un-padding if block size fits (#8800d87)

1.0.2 (2021-08-07)

  • chore: bump dependencies (#1b2b218)
  • Pad data even if aligned (#8ffa510)

1.0.1 (2019-06-16)

  • fix: pkcs7 padding (#6ccd2cc)
  • chore: remove tests from package (#433c72e)

1.0.0 (2019-06-13)

  • docu: add badges (#5970c9e)
  • feat: initial version (#079e3ad)
  • chore: initial commit (#2d0cf84)