# @adorsys/jwe-codec

> Codec to encrypt any javascript value into a JsonWebEncryption (JWE)

Latest version **1.0.2** (published 2020-11-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @adorsys/jwe-codec
pnpm add @adorsys/jwe-codec
yarn add @adorsys/jwe-codec
bun add @adorsys/jwe-codec
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-11-05 |
| First published | 2018-09-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Gunnar Radzom |
| Maintainers | jkroepke, gra |
| Keywords | jwe, encrypt, decrypt, codec |

## Links

- npm: https://www.npmjs.com/package/@adorsys/jwe-codec
- Repository: https://github.com/adorsys/jwe-codec
- Homepage: https://github.com/adorsys/jwe-codec#readme
- Issues: https://github.com/adorsys/jwe-codec/issues
- npm.io page: https://npm.io/package/@adorsys/jwe-codec

## Dependencies (2)

- [hydration](https://npm.io/package/hydration.md) ^1.0.0
- [node-jose](https://npm.io/package/node-jose.md) ^2.0.0

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-11-05
- 0.0.1-beta.1 (beta) — 2018-09-23
- 1.0.1 — 2020-01-07
- 1.0.0 — 2018-09-26
- 0.0.2 — 2018-09-23
- 0.0.1-beta.0 — 2018-09-23

## README

# :closed_lock_with_key: jwe-codec :closed_lock_with_key:


[![Travis](https://img.shields.io/travis/adorsys/jwe-codec.svg)](https://travis-ci.org/adorsys/jwe-codec)
[![Coveralls](https://img.shields.io/coveralls/adorsys/jwe-codec.svg)](https://coveralls.io/github/adorsys/jwe-codec)
[![npm](https://img.shields.io/npm/v/@adorsys/jwe-codec.svg)](https://www.npmjs.com/package/@adorsys/jwe-codec)
[![npm](https://img.shields.io/npm/dt/@adorsys/jwe-codec.svg)](https://www.npmjs.com/package/@adorsys/jwe-codec)
[![Conventional Commits](https://img.shields.io/badge/Conventional_Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier#readme)
[![NpmLicense](https://img.shields.io/npm/l/@adorsys/jwe-codec.svg)](https://github.com/adorsys/jwe-codec/blob/master/LICENSE)


<!-- 

[![Dev Dependencies](https://david-dm.org/adorsys/crypto-codecs/dev-status.svg)](https://david-dm.org/adorsys/crypto-codecs?type=dev) 
-->


A library for encrypting/decrypting any JavaScript value as JsonWebEncryption (JWE)

### Features

 - Promise based interface
 - Encrypting/Decrypting anything from (number, string, boolean, array, date, regex, buffer, object)
 - TypeScript support
 - support for symetric JsonWebKeys { kty: 'oct' }
 - supported algorithms 'A256KW', 'A256GCM', 'A256GCMKW', 'A128CBC-HS256'
 - Continous integration with [Travis](https://travis-ci.org/adorsys/jwe-codec)

### Installation

```bash
npm install @adorsys/jwe-codec
```

### Usage


```js
const jwe = require('@adorsys/jwe-codec')

const key = {
  kty: 'oct',
    alg: 'A256GCM',
    use: 'enc',
    k: '123456789abcdefghijklmnopqrstuvwxyz12345678'
}

...
```

#### with async/await

```js
...

;(async () => {
    const codec = await jwe(key)
    const cipher = await codec.encrypt(42)
    // => eyJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIiwia2lkIjoialpESEVqN0ZhR3N5OHNUSUZLRWlnejB4TjFEVWlBZWp0S1ZNcEl2Z3dqOCJ9..lipFQHmBiBhsTRqE.4rLjRCOj7JZIKOpToIhOp8cJgvfNWl4Yo__VnkO7yRIYjrCLdGRl5fcR.9S_DwYmkpdLap1yyYYq44A​​​​​
    const answer = await codec.decrypt(cipher) 
    // => 42
})()
``` 

#### with Promises

```js
...

jwe(key).then(codec => {
    codec.encrypt(42).then(cipher => {
        codec.decrypt(cipher).then(answer => {
            console.log(answer) // 42
        })
    })
})
```

## Credits

Made with :heart: by [radzom](https://github.com/radzom) and all these wonderful contributors ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore -->
| <img src="https://avatars.githubusercontent.com/u/1225651?v=3" width="100px;"/><br /><sub><b>Francis Pouatcha</b></sub><br />🤔 | <img src="https://avatars.githubusercontent.com/u/1560587?v=3" width="100px;"/><br /><sub><b>jkroepke</b></sub><br />💻🐛 | | | | | |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome!

---
_Source: https://npm.io/package/@adorsys/jwe-codec · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
