Gathering detailed insights and metrics for isomorphic-webcrypto
Gathering detailed insights and metrics for isomorphic-webcrypto
Gathering detailed insights and metrics for isomorphic-webcrypto
Gathering detailed insights and metrics for isomorphic-webcrypto
npm install isomorphic-webcrypto
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
118 Stars
94 Commits
43 Forks
3 Watchers
33 Branches
3 Contributors
Updated on Jun 16, 2025
Latest Version
2.3.8
Package Id
isomorphic-webcrypto@2.3.8
Size
54.99 kB
NPM Version
6.14.8
Node Version
14.3.0
Published on
Feb 27, 2021
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
11
19
4
webcrypto library for Node, React Native and IE11+
There's a great Node polyfill for the Web Crypto API, but it's not isomorphic.
IE11 and versions of Safari < 11 use an older version of the spec, so the browser implementation includes a webcrypto-shim to iron out the differences. You'll still need to provide your own Promise polyfill.
There's currently no native crypto support in React Native, so the Microsoft Research library is exposed.
Note: If you're performing cross-platform jwt operations, consider jwt-lite or jwt-verifier-lite (for OpenID Connect), which build on
isomorphic-webcrypto
npm install isomorphic-webcrypto
There's a simple hashing example below, but there are many more WebCrypto examples here. This example requires you to npm install hex-lite
.
1const crypto = require('isomorphic-webcrypto') 2const hex = require('hex-lite') 3// or 4import crypto from 'isomorphic-webcrypto' 5import hex from 'hex-lite' 6 7crypto.subtle.digest( 8 { name: 'SHA-256' }, 9 new Uint8Array([1,2,3]).buffer 10) 11.then(hash => { 12 // hashes are usually represented as hex strings 13 // hex-lite makes this easier 14 const hashString = hex.fromBuffer(hash); 15})
React Native support is implemented using the Microsoft Research library. The React Native environment only supports Math.random()
, so react-native-securerandom is used to provide proper entropy. This is handled automatically, except for crypto.getRandomValues()
, which requires you wait:
1const crypto = require('isomorphic-webcrypto') 2 3(async () => { 4 // Only needed for crypto.getRandomValues 5 // but only wait once, future calls are secure 6 await crypto.ensureSecure(); 7 const array = new Uint8Array(1); 8 crypto.getRandomValues(array); 9 const safeValue = array[0]; 10})()
Working React Native examples:
You should use the webcrypto-shim library directly:
1<!-- Any Promise polyfill will do --> 2<script src="https://unpkg.com/bluebird"></script> 3<script src="https://unpkg.com/webcrypto-shim"></script>
Although 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.
Legend
- ~ works with some caveats - see the __tests__ directory for the caveats
- ? untested
- x unsupported algorithm
- strikethrough broken method
Key | Node | React Native | Chrome/Firefox | Safari | Edge | IE11 |
---|---|---|---|---|---|---|
HS256 | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify |
HS384 | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify |
HS512 | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | x |
RS256 | importKey exportKey generateKey sign verify | importKey exportKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | ~importKey exportKey ~generateKey verify | ~importKey ~exportKey generateKey verify |
RS384 | importKey exportKey generateKey sign verify | importKey exportKey sign verify | importKey exportKey generateKey sign verify | importKey generateKey sign verify | ~importKey exportKey ~generateKey sign verify | importKey exportKey generateKey sign verify |
RS512 | importKey exportKey generateKey sign verify | importKey exportKey sign verify | importKey exportKey generateKey sign verify | importKey generateKey sign verify | ~importKey exportKey ~generateKey sign verify | importKey exportKey generateKey |
PS256 | importKey exportKey generateKey sign verify | importKey exportKey sign verify | importKey exportKey generateKey sign verify | importKey generateKey sign verify | ? | ? |
PS384 | importKey exportKey generateKey sign verify | importKey exportKey sign verify | importKey exportKey generateKey sign verify | importKey generateKey sign verify | ? | ? |
PS512 | importKey exportKey generateKey sign verify | importKey exportKey sign verify | importKey exportKey generateKey sign verify | importKey generateKey sign verify | ? | ? |
ES256 | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | x | x |
ES384 | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | x | x |
ES512 | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | importKey exportKey generateKey sign verify | x | x | x |
RSA1_5 | ? | ? | ? | ? | ? | ? |
RSA-OAEP | ? | ? | ? | ? | ? | ? |
RSA-OAEP-256 | ? | ? | ? | ? | ? | ? |
A128KW | ? | ? | ? | ? | ? | ? |
A192KW | ? | ? | ? | ? | ? | ? |
A256KW | ? | ? | ? | ? | ? | ? |
dir | ? | ? | ? | ? | ? | ? |
ECDH-ES | ? | ? | ? | ? | ? | ? |
ECDH-ES+A128KW | ? | ? | ? | ? | ? | ? |
ECDH-ES+A192KW | ? | ? | ? | ? | ? | ? |
ECDH-ES+A256KW | ? | ? | ? | ? | ? | ? |
A128GCMKW | ? | ? | ? | ? | ? | ? |
A192GCMKW | ? | ? | ? | ? | ? | ? |
A256GCMKW | ? | ? | ? | ? | ? | ? |
PBES2-HS256+A128KW | ? | ? | ? | ? | ? | ? |
PBES2-HS384+A192KW | ? | ? | ? | ? | ? | ? |
PBES2-HS512+A256KW | ? | ? | ? | ? | ? | ? |
Here's a legend for the JWA alg abbreviations:
Key | Signature, MAC or Key Management Algorithm |
---|---|
HS256 | HMAC using SHA-256 |
HS384 | HMAC using SHA-384 |
HS512 | HMAC using SHA-512 |
RS256 | RSASSA-PKCS1-v1_5 using SHA-256 |
RS384 | RSASSA-PKCS1-v1_5 using SHA-384 |
RS512 | RSASSA-PKCS1-v1_5 using SHA-512 |
ES256 | ECDSA using P-256 and SHA-256 |
ES384 | ECDSA using P-384 and SHA-384 |
ES512 | ECDSA using P-521 and SHA-512 |
PS256 | RSASSA-PSS using SHA-256 and MGF1 with SHA-256 |
PS384 | RSASSA-PSS using SHA-384 and MGF1 with SHA-384 |
PS512 | RSASSA-PSS using SHA-512 and MGF1 with SHA-512 |
RSA1_5 | RSAES-PKCS1-v1_5 |
RSA-OAEP | RSAES OAEP using default parameters |
RSA-OAEP-256 | RSAES OAEP using SHA-256 and MGF1 with SHA-256 |
A128KW | AES Key Wrap with default initial value using 128-bit key |
A192KW | AES Key Wrap with default initial value using 192-bit key |
A256KW | AES Key Wrap with default initial value using 256-bit key |
dir | Direct use of a shared symmetric key as the CEK |
ECDH-ES | Elliptic Curve Diffie-Hellman Ephemeral Static key agreement using Concat KDF |
ECDH-ES+A128KW | ECDH-ES using Concat KDF and CEK wrapped with "A128KW" |
ECDH-ES+A192KW | ECDH-ES using Concat KDF and CEK wrapped with "A192KW" |
ECDH-ES+A256KW | ECDH-ES using Concat KDF and CEK wrapped with "A256KW" |
A128GCMKW | Key wrapping with AES GCM using 128-bit key |
A192GCMKW | Key wrapping with AES GCM using 192-bit key |
A256GCMKW | Key wrapping with AES GCM using 256-bit key |
PBES2-HS256+A128KW | PBES2 with HMAC SHA-256 and "A128KW" wrapping |
PBES2-HS384+A192KW | PBES2 with HMAC SHA-384 and "A192KW" wrapping |
PBES2-HS512+A256KW | PBES2 with HMAC SHA-512 and "A256KW" wrapping |
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/24 approved changesets -- score normalized to 0
Reason
project is archived
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
100 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More