{"name":"isomorphic-webcrypto","version":"0.0.2","description":"","browser":"cjs/browser.js","main":"cjs/node.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/kevlened/isomorphic-webcrypto.git"},"keywords":[],"author":{"name":"Len Boyette"},"license":"MIT","bugs":{"url":"https://github.com/kevlened/isomorphic-webcrypto/issues"},"homepage":"https://github.com/kevlened/isomorphic-webcrypto#readme","dependencies":{"@trust/webcrypto":"^0.8.2","webcrypto-shim":"^0.1.2"},"gitHead":"3086a5d04876672fad4c4d9f8c1f077f69a1ab48","_id":"isomorphic-webcrypto@0.0.2","_npmVersion":"5.6.0","_nodeVersion":"8.9.3","_npmUser":{"name":"kevlened","email":"boyettel@gmail.com"},"dist":{"integrity":"sha512-+G9aFcZSd6gvYM1BJVLudHLeoRegZqn5vIP39+X0FrQci9t+MJGtPePNDHSwzcXEvI1vvf5LVT8/Wxd3ZirHaA==","shasum":"60c4030b361be515dc785697687a2c8fe56db747","tarball":"http://registry-npm.ywwl.com/isomorphic-webcrypto/download/isomorphic-webcrypto-0.0.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDDLI0aGLq705yV9/37TedrOiFJ9DKeEfw9R7PV5XM0VgIgC0hMXxLXw1GU8DRCVKJSlzKekJi68XHBxtnjyerwerg="}],"size":1235,"noattachment":false,"key":"/isomorphic-webcrypto/-/isomorphic-webcrypto-0.0.2.tgz"},"maintainers":[{"name":"kevlened","email":"boyettel@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/isomorphic-webcrypto-0.0.2.tgz_1513353033741_0.2403184394352138"},"directories":{},"readme":"# isomorphic-webcrypto [![NPM](https://img.shields.io/npm/v/isomorphic-webcrypto.svg)](https://npmjs.com/package/isomorphic-webcrypto) [![bundlephobia](https://img.shields.io/bundlephobia/minzip/isomorphic-webcrypto.svg)](https://bundlephobia.com/result?p=isomorphic-webcrypto)\nwebcrypto library for Node, React Native and IE11+\n\n## What?\n\nThere's [a great Node polyfill](https://github.com/PeculiarVentures/webcrypto) for the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API), but it's not isomorphic.\n\nIE11 and versions of Safari < 11 use an older version of the spec, so the browser implementation includes a [webcrypto-shim](https://github.com/vibornoff/webcrypto-shim) to iron out the differences. You'll still need to provide your own Promise polyfill.\n\nThere's currently no native crypto support in React Native, so [the Microsoft Research library](https://github.com/kevlened/msrCrypto) is exposed.\n\n> **Note:** If you're performing cross-platform jwt operations, consider [jwt-lite](https://www.npmjs.com/package/jwt-lite) or [jwt-verifier-lite](https://www.npmjs.com/package/jwt-verifier-lite) (for OpenID Connect), which build on `isomorphic-webcrypto`\n\n## Install\n\n`npm install isomorphic-webcrypto`\n\n## Usage\n\nThere's a simple hashing example below, but [there are many more WebCrypto examples here](https://github.com/diafygi/webcrypto-examples). This example requires you to `npm install hex-lite`.\n\n```javascript\nconst crypto = require('isomorphic-webcrypto')\nconst hex = require('hex-lite')\n// or\nimport crypto from 'isomorphic-webcrypto'\nimport hex from 'hex-lite'\n\ncrypto.subtle.digest(\n  { name: 'SHA-256' },\n  new Uint8Array([1,2,3]).buffer\n)\n.then(hash => {\n  // hashes are usually represented as hex strings\n  // hex-lite makes this easier\n  const hashString = hex.fromBuffer(hash);\n})\n```\n\n### React Native\n\nReact Native support is implemented using [the Microsoft Research library](https://github.com/kevlened/msrCrypto). The React Native environment only supports `Math.random()`, so [react-native-securerandom](https://github.com/rh389/react-native-securerandom) is used to provide proper entropy. This is handled automatically, except for `crypto.getRandomValues()`, which requires you wait:\n\n```javascript\nconst crypto = require('isomorphic-webcrypto')\n\n(async () => {\n  // Only needed for crypto.getRandomValues\n  // but only wait once, future calls are secure\n  await crypto.ensureSecure();\n  const array = new Uint8Array(1);\n  crypto.getRandomValues(array);\n  const safeValue = array[0];\n})()\n```\n\nWorking React Native examples:\n\n* Using [create-react-native-app](https://github.com/kevlened/webcrypto-react-native-examples/tree/master/crna) with Expo\n* Using an ejected [create-react-native-app](https://github.com/kevlened/webcrypto-react-native-examples/blob/master/crna-ejected)\n\n## I just want to drop in a script tag\n\nYou should use [the webcrypto-shim](https://github.com/vibornoff/webcrypto-shim) library directly:\n\n```html\n<!-- Any Promise polyfill will do -->\n<script src=\"https://unpkg.com/bluebird\"></script>\n<script src=\"https://unpkg.com/webcrypto-shim\"></script>\n```\n\n## Compatibility\n\n* IE11+\n* Safari 8+\n* Edge 12+\n* Chrome 43+\n* Opera 24+\n* Firefox 34+\n* Node 8+\n* React Native\n\nAlthough the library runs on IE11+, the level of functionality varies between implementations. The grid below shows the discrepancies between the latest versions of each environment.\n\n> __Legend__\n>\n> * **~** works with some caveats - see the \\_\\_tests__ directory for the caveats\n> * **?** untested\n> * **x** unsupported algorithm\n> * **strikethrough** broken method\n\n| Key                | Node                                                        | React Native                                                | Chrome/Firefox                                          | Safari                                                      | Edge                                                          | IE11                                                            |\n| ------------------ | ----------------------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------- | ----------------------------------------------------------- | ------------------------------------------------------------- | --------------------------------------------------------------- |\n| HS256              | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify       | importKey<br>exportKey<br>generateKey<br>sign<br>verify         |\n| HS384              | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify       | importKey<br>exportKey<br>generateKey<br>sign<br>verify         |\n| HS512              | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify       | x                                                               |\n| RS256              | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>~~generateKey~~<br>sign<br>verify | importKey<br>exportKey<br>generateKey<br>sign<br>verify | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | ~importKey<br>exportKey<br>~generateKey<br>~~sign~~<br>verify | ~importKey<br>~exportKey<br>generateKey<br>~~sign~~<br>verify   |\n| RS384              | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>~~generateKey~~<br>sign<br>verify | importKey<br>exportKey<br>generateKey<br>sign<br>verify | importKey<br>~~exportKey~~<br>generateKey<br>sign<br>verify | ~importKey<br>exportKey<br>~generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify         |\n| RS512              | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>~~generateKey~~<br>sign<br>verify | importKey<br>exportKey<br>generateKey<br>sign<br>verify | importKey<br>~~exportKey~~<br>generateKey<br>sign<br>verify | ~importKey<br>exportKey<br>~generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>~~sign~~<br>~~verify~~ |\n| PS256              | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>~~generateKey~~<br>sign<br>verify | importKey<br>exportKey<br>generateKey<br>sign<br>verify | importKey<br>~~exportKey~~<br>generateKey<br>sign<br>verify | ? | ? |\n| PS384              | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>~~generateKey~~<br>sign<br>verify | importKey<br>exportKey<br>generateKey<br>sign<br>verify | importKey<br>~~exportKey~~<br>generateKey<br>sign<br>verify | ? | ? |\n| PS512              | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>~~generateKey~~<br>sign<br>verify | importKey<br>exportKey<br>generateKey<br>sign<br>verify | importKey<br>~~exportKey~~<br>generateKey<br>sign<br>verify | ? | ? |\n| ES256              | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | x                                                             | x                                                               |\n| ES384              | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | x                                                             | x                                                               |\n| ES512              | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify     | importKey<br>exportKey<br>generateKey<br>sign<br>verify | x                                                           | x                                                             | x                                                               |\n| RSA1_5             | ? | ? | ? | ? | ? | ? |\n| RSA-OAEP           | ? | ? | ? | ? | ? | ? |\n| RSA-OAEP-256       | ? | ? | ? | ? | ? | ? |\n| A128KW             | ? | ? | ? | ? | ? | ? |\n| A192KW             | ? | ? | ? | ? | ? | ? |\n| A256KW             | ? | ? | ? | ? | ? | ? |\n| dir                | ? | ? | ? | ? | ? | ? |\n| ECDH-ES            | ? | ? | ? | ? | ? | ? |\n| ECDH-ES+A128KW     | ? | ? | ? | ? | ? | ? |\n| ECDH-ES+A192KW     | ? | ? | ? | ? | ? | ? |\n| ECDH-ES+A256KW     | ? | ? | ? | ? | ? | ? |\n| A128GCMKW          | ? | ? | ? | ? | ? | ? |\n| A192GCMKW          | ? | ? | ? | ? | ? | ? |\n| A256GCMKW          | ? | ? | ? | ? | ? | ? |\n| PBES2-HS256+A128KW | ? | ? | ? | ? | ? | ? |\n| PBES2-HS384+A192KW | ? | ? | ? | ? | ? | ? |\n| PBES2-HS512+A256KW | ? | ? | ? | ? | ? | ? |\n\nHere's a legend for the [JWA alg abbreviations](https://tools.ietf.org/html/rfc7518#section-3.1):\n\n| Key                | Signature, MAC or Key Management Algorithm                                    |\n| ------------------ | ----------------------------------------------------------------------------- |\n| HS256              | HMAC using SHA-256                                                            |\n| HS384              | HMAC using SHA-384                                                            |\n| HS512              | HMAC using SHA-512                                                            |\n| RS256              | RSASSA-PKCS1-v1_5 using SHA-256                                               |\n| RS384              | RSASSA-PKCS1-v1_5 using SHA-384                                               |\n| RS512              | RSASSA-PKCS1-v1_5 using SHA-512                                               |\n| ES256              | ECDSA using P-256 and SHA-256                                                 |\n| ES384              | ECDSA using P-384 and SHA-384                                                 |\n| ES512              | ECDSA using P-521 and SHA-512                                                 |\n| PS256              | RSASSA-PSS using SHA-256 and MGF1 with SHA-256                                |\n| PS384              | RSASSA-PSS using SHA-384 and MGF1 with SHA-384                                |\n| PS512              | RSASSA-PSS using SHA-512 and MGF1 with SHA-512                                |\n| RSA1_5             | RSAES-PKCS1-v1_5                                                              |\n| RSA-OAEP           | RSAES OAEP using default parameters                                           |\n| RSA-OAEP-256       | RSAES OAEP using SHA-256 and MGF1 with SHA-256                                |\n| A128KW             | AES Key Wrap with default initial value using 128-bit key                     |\n| A192KW             | AES Key Wrap with default initial value using 192-bit key                     |\n| A256KW             | AES Key Wrap with default initial value using 256-bit key                     |\n| dir                | Direct use of a shared symmetric key as the CEK                               |\n| ECDH-ES            | Elliptic Curve Diffie-Hellman Ephemeral Static key agreement using Concat KDF |\n| ECDH-ES+A128KW     | ECDH-ES using Concat KDF and CEK wrapped with \"A128KW\"                        |\n| ECDH-ES+A192KW     | ECDH-ES using Concat KDF and CEK wrapped with \"A192KW\"                        |\n| ECDH-ES+A256KW     | ECDH-ES using Concat KDF and CEK wrapped with \"A256KW\"                        |\n| A128GCMKW          | Key wrapping with AES GCM using 128-bit key                                   |\n| A192GCMKW          | Key wrapping with AES GCM using 192-bit key                                   |\n| A256GCMKW          | Key wrapping with AES GCM using 256-bit key                                   |\n| PBES2-HS256+A128KW | PBES2 with HMAC SHA-256 and \"A128KW\" wrapping                                 |\n| PBES2-HS384+A192KW | PBES2 with HMAC SHA-384 and \"A192KW\" wrapping                                 |\n| PBES2-HS512+A256KW | PBES2 with HMAC SHA-512 and \"A256KW\" wrapping                                 |\n\n## License\n\nMIT\n","publish_time":1513353033817,"_cnpm_publish_time":1513353033817,"dist-tags":{"latest":"2.3.8"}}