Have ideas to improve npm?Join in the discussion! »

    @adorsys/jwe-codec
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.2 • Public • Published

    🔐 jwe-codec 🔐

    Travis Coveralls npm npm Conventional Commits JavaScript Style Guide styled with prettier NpmLicense

    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

    Installation

    npm install @adorsys/jwe-codec

    Usage

    const jwe = require('@adorsys/jwe-codec')
     
    const key = {
      kty: 'oct',
        alg: 'A256GCM',
        use: 'enc',
        k: '123456789abcdefghijklmnopqrstuvwxyz12345678'
    }
     
    ...

    with async/await

    ...
     
    ;(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

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

    Credits

    Made with ❤️ by radzom and all these wonderful contributors (emoji key):


    Francis Pouatcha
    🤔

    jkroepke
    💻🐛

    This project follows the all-contributors specification. Contributions of any kind are welcome!

    Install

    npm i @adorsys/jwe-codec

    DownloadsWeekly Downloads

    569

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    11.9 kB

    Total Files

    11

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar