Skip to content

Commit 8126622

Browse files
authored
Improved compatibility with react-native (#284)
* polyfills and zlib-browserify * bump version * minor format * fix zlib dependency * add react-zlib-js * undo version bump * remove trailing slash * more consistent syntax
1 parent 7aae198 commit 8126622

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/index.js

+12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ if (typeof Promise === "undefined") {
99
require("es6-promise").polyfill();
1010
}
1111

12+
if (typeof Buffer === "undefined") {
13+
(global || window).Buffer = require("buffer").Buffer;
14+
}
15+
16+
if (typeof process === "undefined") {
17+
(global || window).process = require("process");
18+
}
19+
20+
if (!process.version) {
21+
process.version = "";
22+
}
23+
1224
var JWS = require("./jws");
1325

1426
module.exports = {

package.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,23 @@
2727
"test": "gulp test:nodejs"
2828
},
2929
"browser": {
30-
"crypto": false
30+
"crypto": false,
31+
"zlib": "browserify-zlib"
32+
},
33+
"react-native": {
34+
"crypto": false,
35+
"zlib": "react-zlib-js"
3136
},
3237
"dependencies": {
3338
"base64url": "^3.0.1",
39+
"browserify-zlib": "^0.2.0",
40+
"buffer": "^5.5.0",
3441
"es6-promise": "^4.2.8",
3542
"lodash": "^4.17.15",
3643
"long": "^4.0.0",
3744
"node-forge": "^0.8.5",
45+
"process": "^0.11.10",
46+
"react-zlib-js": "^1.0.4",
3847
"uuid": "^3.3.3"
3948
},
4049
"devDependencies": {

0 commit comments

Comments
 (0)