node-forge 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +88 -2
- package/dist/forge.all.min.js +1 -1
- package/dist/forge.min.js +1 -1
- package/lib/baseN.js +186 -0
- package/lib/ed25519.js +996 -0
- package/lib/form.js +1 -1
- package/lib/index.js +1 -0
- package/lib/util.js +32 -13
- package/package.json +3 -3
package/lib/form.js
CHANGED
|
@@ -17,7 +17,7 @@ var form = module.exports = forge.form = forge.form || {};
|
|
|
17
17
|
/**
|
|
18
18
|
* Regex for parsing a single name property (handles array brackets).
|
|
19
19
|
*/
|
|
20
|
-
var _regex = /(
|
|
20
|
+
var _regex = /([^\[]*?)\[(.*?)\]/g;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Parses a single name property into an array with the name and any
|
package/lib/index.js
CHANGED
package/lib/util.js
CHANGED
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @author Dave Longley
|
|
5
5
|
*
|
|
6
|
-
* Copyright (c) 2010-
|
|
6
|
+
* Copyright (c) 2010-2018 Digital Bazaar, Inc.
|
|
7
7
|
*/
|
|
8
8
|
var forge = require('./forge');
|
|
9
|
+
var baseN = require('./baseN');
|
|
9
10
|
|
|
10
11
|
/* Utilities API */
|
|
11
12
|
var util = module.exports = forge.util = forge.util || {};
|
|
@@ -159,14 +160,18 @@ function ByteStringBuffer(b) {
|
|
|
159
160
|
if(typeof b === 'string') {
|
|
160
161
|
this.data = b;
|
|
161
162
|
} else if(util.isArrayBuffer(b) || util.isArrayBufferView(b)) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
this.
|
|
163
|
+
if(typeof Buffer !== 'undefined' && b instanceof Buffer) {
|
|
164
|
+
this.data = b.toString('binary');
|
|
165
|
+
} else {
|
|
166
|
+
// convert native buffer to forge buffer
|
|
167
|
+
// FIXME: support native buffers internally instead
|
|
168
|
+
var arr = new Uint8Array(b);
|
|
169
|
+
try {
|
|
170
|
+
this.data = String.fromCharCode.apply(null, arr);
|
|
171
|
+
} catch(e) {
|
|
172
|
+
for(var i = 0; i < arr.length; ++i) {
|
|
173
|
+
this.putByte(arr[i]);
|
|
174
|
+
}
|
|
170
175
|
}
|
|
171
176
|
}
|
|
172
177
|
} else if(b instanceof ByteStringBuffer ||
|
|
@@ -1541,6 +1546,9 @@ var _base64Idx = [
|
|
|
1541
1546
|
39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
|
|
1542
1547
|
];
|
|
1543
1548
|
|
|
1549
|
+
// base58 characters (Bitcoin alphabet)
|
|
1550
|
+
var _base58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';
|
|
1551
|
+
|
|
1544
1552
|
/**
|
|
1545
1553
|
* Base64 encodes a 'binary' encoded string of bytes.
|
|
1546
1554
|
*
|
|
@@ -1646,7 +1654,12 @@ util.decodeUtf8 = function(str) {
|
|
|
1646
1654
|
util.binary = {
|
|
1647
1655
|
raw: {},
|
|
1648
1656
|
hex: {},
|
|
1649
|
-
base64: {}
|
|
1657
|
+
base64: {},
|
|
1658
|
+
base58: {},
|
|
1659
|
+
baseN : {
|
|
1660
|
+
encode: baseN.encode,
|
|
1661
|
+
decode: baseN.decode
|
|
1662
|
+
}
|
|
1650
1663
|
};
|
|
1651
1664
|
|
|
1652
1665
|
/**
|
|
@@ -1803,9 +1816,15 @@ util.binary.base64.decode = function(input, output, offset) {
|
|
|
1803
1816
|
}
|
|
1804
1817
|
|
|
1805
1818
|
// make sure result is the exact decoded length
|
|
1806
|
-
return output ?
|
|
1807
|
-
|
|
1808
|
-
|
|
1819
|
+
return output ? (j - offset) : out.subarray(0, j);
|
|
1820
|
+
};
|
|
1821
|
+
|
|
1822
|
+
// add support for base58 encoding/decoding with Bitcoin alphabet
|
|
1823
|
+
util.binary.base58.encode = function(input, maxline) {
|
|
1824
|
+
return util.binary.baseN.encode(input, _base58, maxline);
|
|
1825
|
+
};
|
|
1826
|
+
util.binary.base58.decode = function(input, maxline) {
|
|
1827
|
+
return util.binary.baseN.decode(input, _base58, maxline);
|
|
1809
1828
|
};
|
|
1810
1829
|
|
|
1811
1830
|
// text encoding/decoding tools
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-forge",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "JavaScript implementations of network transports, cryptography, ciphers, PKI, message digests, and various utilities.",
|
|
5
5
|
"homepage": "https://github.com/digitalbazaar/forge",
|
|
6
6
|
"author": {
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"karma-sauce-launcher": "^1.2.0",
|
|
35
35
|
"karma-sourcemap-loader": "^0.3.7",
|
|
36
36
|
"karma-tap-reporter": "0.0.6",
|
|
37
|
-
"karma-webpack": "^2.0.
|
|
37
|
+
"karma-webpack": "^2.0.13",
|
|
38
38
|
"mocha": "^5.0.1",
|
|
39
39
|
"mocha-lcov-reporter": "^1.2.0",
|
|
40
40
|
"nodejs-websocket": "^1.7.1",
|
|
41
|
-
"nyc": "^11.
|
|
41
|
+
"nyc": "^11.5.0",
|
|
42
42
|
"opts": "^1.2.2",
|
|
43
43
|
"webpack": "^3.11.0"
|
|
44
44
|
},
|