Skip to content

NewtonJoshua/node-jose-browserify

This branch is 25 commits ahead of, 76 commits behind cisco/node-jose:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

e373379 · Nov 6, 2019
Aug 29, 2019
Feb 28, 2019
Sep 11, 2015
Feb 1, 2019
Nov 5, 2018
Jun 5, 2017
Nov 5, 2018
Jan 31, 2018
Mar 18, 2019
Sep 11, 2015
Aug 30, 2019
Nov 6, 2019
Feb 28, 2019
Sep 4, 2019
Sep 11, 2015

Repository files navigation

published download total

node-jose-browserify

An advanced version of Cisco's node-jose module that works in both browser and the server. It is compatible with node.js and angular

Refer to https://github.com/cisco/node-jose for documentation.

PR

The PR Angular Support: To make node-jose work in angular apps is raised to merge the changes with the node-jose repo.

Since the node-jose repo is not actively maintained now, this PR can't be merged. So this fork is published.

Dependencies Added:

  • browserify-zlib: In the browser if Node's 'zlib' can't be resolved, browserify-zlib can be used.
  • buffer: make buffer, that emulates node's Buffer API, available globally in the browser
  • process: make process, that emulates node's Process API, available globally in the browser
  • stream-browserify: this should be used by zlib/browserify-zlib instead of 'stream'. Should be mentioned in angular compiler options.

The steps to use node-jose in angular app is added in the readme file.

Install

    npm i node-jose-browserify

Angular Usage

Import and use as any other package. All the methods will be supported in the browser, just as in node.js.

import * as jose from 'node-jose-browserify';

The following changes are required to make few node-modules available in the browser

  • angular compilerOptions for stream

    In tsconfig.json , compilerOptions add

    "paths": {
        "stream": ["../node_modules/stream-browserify/index.js"]
    }

    This is to avoid the below error

    ERROR in ./node_modules/browserify-zlib/lib/index.js. Module not found: Error: Can't resolve 'stream' in '***/node_modules/browserify-zlib/lib'

  • polyfil for global object In polyfills.ts add

    // Polyfill for node-jose
    (window as any)['global'] = window;
    

    This is to avoid the below error

    Uncaught ReferenceError: global is not defined

Merging node-jose updates

To pull the latest updates from node-jose into node-jose-browserify

$ git pull https://github.com/cisco/node-jose.git master

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 99.7%
  • Shell 0.3%