@ne1410s/crypto 0.2.208 → 0.2.209
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.
|
@@ -74,7 +74,7 @@ function __generator(thisArg, body) {
|
|
|
74
74
|
}
|
|
75
75
|
op = body.call(thisArg, _);
|
|
76
76
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
77
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] :
|
|
77
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : undefined, done: true };
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
@@ -93,7 +93,7 @@ var DEF_ALGO = {
|
|
|
93
93
|
hash: { name: 'SHA-256' },
|
|
94
94
|
};
|
|
95
95
|
function randomString() {
|
|
96
|
-
return __awaiter(this,
|
|
96
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
97
97
|
var bytes;
|
|
98
98
|
return __generator(this, function (_a) {
|
|
99
99
|
bytes = new Uint8Array(24);
|
|
@@ -103,7 +103,7 @@ function randomString() {
|
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
105
|
function gen() {
|
|
106
|
-
return __awaiter(this,
|
|
106
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
107
107
|
var keys;
|
|
108
108
|
var _a;
|
|
109
109
|
return __generator(this, function (_b) {
|
|
@@ -123,7 +123,7 @@ function gen() {
|
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
function sign(text, privateJwk) {
|
|
126
|
-
return __awaiter(this,
|
|
126
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
127
127
|
var cKey, buffer, signed;
|
|
128
128
|
return __generator(this, function (_a) {
|
|
129
129
|
switch (_a.label) {
|
|
@@ -139,7 +139,7 @@ function sign(text, privateJwk) {
|
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
141
|
function digest(text) {
|
|
142
|
-
return __awaiter(this,
|
|
142
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
143
143
|
var buffer, digest;
|
|
144
144
|
return __generator(this, function (_a) {
|
|
145
145
|
switch (_a.label) {
|
|
@@ -155,7 +155,7 @@ function digest(text) {
|
|
|
155
155
|
}
|
|
156
156
|
//https://github.com/PeculiarVentures/PKI.js/blob/master/examples/PKCS10ComplexExample/es6.js
|
|
157
157
|
function csr(params) {
|
|
158
|
-
return __awaiter(this,
|
|
158
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
159
159
|
var pkcs10, keys, publicKey, toDigest, pubkeyhash_sha1, privateKey, pkcs10_schema, pkcs10_encoded, exportedPkcs8;
|
|
160
160
|
var _a;
|
|
161
161
|
return __generator(this, function (_b) {
|
|
@@ -263,9 +263,9 @@ function csr(params) {
|
|
|
263
263
|
}
|
|
264
264
|
//https://github.com/PeculiarVentures/PKI.js/blob/master/examples/PKCS12SimpleExample/es6.js
|
|
265
265
|
function pfx(friendlyName_1, cert_b64_1, key_b64_1, password_1) {
|
|
266
|
-
return __awaiter(this, arguments,
|
|
266
|
+
return __awaiter(this, arguments, undefined, function (friendlyName, cert_b64, key_b64, password, hash) {
|
|
267
267
|
var asn1_cer, asn1_key, objc_cer, objc_key, pkcs12;
|
|
268
|
-
if (hash ===
|
|
268
|
+
if (hash === undefined) { hash = 'SHA-256'; }
|
|
269
269
|
return __generator(this, function (_a) {
|
|
270
270
|
switch (_a.label) {
|
|
271
271
|
case 0:
|
|
@@ -52,7 +52,7 @@ function __generator(thisArg, body) {
|
|
|
52
52
|
}
|
|
53
53
|
op = body.call(thisArg, _);
|
|
54
54
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
55
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] :
|
|
55
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : undefined, done: true };
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
@@ -71,7 +71,7 @@ var DEF_ALGO = {
|
|
|
71
71
|
hash: { name: 'SHA-256' },
|
|
72
72
|
};
|
|
73
73
|
function randomString() {
|
|
74
|
-
return __awaiter(this,
|
|
74
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
75
75
|
var bytes;
|
|
76
76
|
return __generator(this, function (_a) {
|
|
77
77
|
bytes = new Uint8Array(24);
|
|
@@ -81,7 +81,7 @@ function randomString() {
|
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
83
|
function gen() {
|
|
84
|
-
return __awaiter(this,
|
|
84
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
85
85
|
var keys;
|
|
86
86
|
var _a;
|
|
87
87
|
return __generator(this, function (_b) {
|
|
@@ -101,7 +101,7 @@ function gen() {
|
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
function sign(text, privateJwk) {
|
|
104
|
-
return __awaiter(this,
|
|
104
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
105
105
|
var cKey, buffer, signed;
|
|
106
106
|
return __generator(this, function (_a) {
|
|
107
107
|
switch (_a.label) {
|
|
@@ -117,7 +117,7 @@ function sign(text, privateJwk) {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
function digest(text) {
|
|
120
|
-
return __awaiter(this,
|
|
120
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
121
121
|
var buffer, digest;
|
|
122
122
|
return __generator(this, function (_a) {
|
|
123
123
|
switch (_a.label) {
|
|
@@ -133,7 +133,7 @@ function digest(text) {
|
|
|
133
133
|
}
|
|
134
134
|
//https://github.com/PeculiarVentures/PKI.js/blob/master/examples/PKCS10ComplexExample/es6.js
|
|
135
135
|
function csr(params) {
|
|
136
|
-
return __awaiter(this,
|
|
136
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
137
137
|
var pkcs10, keys, publicKey, toDigest, pubkeyhash_sha1, privateKey, pkcs10_schema, pkcs10_encoded, exportedPkcs8;
|
|
138
138
|
var _a;
|
|
139
139
|
return __generator(this, function (_b) {
|
|
@@ -241,9 +241,9 @@ function csr(params) {
|
|
|
241
241
|
}
|
|
242
242
|
//https://github.com/PeculiarVentures/PKI.js/blob/master/examples/PKCS12SimpleExample/es6.js
|
|
243
243
|
function pfx(friendlyName_1, cert_b64_1, key_b64_1, password_1) {
|
|
244
|
-
return __awaiter(this, arguments,
|
|
244
|
+
return __awaiter(this, arguments, undefined, function (friendlyName, cert_b64, key_b64, password, hash) {
|
|
245
245
|
var asn1_cer, asn1_key, objc_cer, objc_key, pkcs12;
|
|
246
|
-
if (hash ===
|
|
246
|
+
if (hash === undefined) { hash = 'SHA-256'; }
|
|
247
247
|
return __generator(this, function (_a) {
|
|
248
248
|
switch (_a.label) {
|
|
249
249
|
case 0:
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
}
|
|
56
56
|
op = body.call(thisArg, _);
|
|
57
57
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] :
|
|
58
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : undefined, done: true };
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -393,7 +393,7 @@
|
|
|
393
393
|
return base64;
|
|
394
394
|
}
|
|
395
395
|
static formatString(data) {
|
|
396
|
-
return (data === null || data ===
|
|
396
|
+
return (data === null || data === undefined ? undefined : data.replace(/[\n\r\t ]/g, "")) || "";
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
Convert.DEFAULT_UTF8_ENCODING = "utf8";
|
|
@@ -646,7 +646,7 @@
|
|
|
646
646
|
var _a;
|
|
647
647
|
super(...args);
|
|
648
648
|
const params = args[0] || {};
|
|
649
|
-
this.isHexOnly = (_a = params.isHexOnly) !== null && _a !==
|
|
649
|
+
this.isHexOnly = (_a = params.isHexOnly) !== null && _a !== undefined ? _a : false;
|
|
650
650
|
this.valueHexView = params.valueHex ? BufferSourceConverter.toUint8Array(params.valueHex) : EMPTY_VIEW;
|
|
651
651
|
}
|
|
652
652
|
get valueHex() {
|
|
@@ -736,11 +736,11 @@
|
|
|
736
736
|
var _a, _b, _c, _d;
|
|
737
737
|
super();
|
|
738
738
|
if (idBlock) {
|
|
739
|
-
this.isHexOnly = (_a = idBlock.isHexOnly) !== null && _a !==
|
|
739
|
+
this.isHexOnly = (_a = idBlock.isHexOnly) !== null && _a !== undefined ? _a : false;
|
|
740
740
|
this.valueHexView = idBlock.valueHex ? BufferSourceConverter.toUint8Array(idBlock.valueHex) : EMPTY_VIEW;
|
|
741
|
-
this.tagClass = (_b = idBlock.tagClass) !== null && _b !==
|
|
742
|
-
this.tagNumber = (_c = idBlock.tagNumber) !== null && _c !==
|
|
743
|
-
this.isConstructed = (_d = idBlock.isConstructed) !== null && _d !==
|
|
741
|
+
this.tagClass = (_b = idBlock.tagClass) !== null && _b !== undefined ? _b : -1;
|
|
742
|
+
this.tagNumber = (_c = idBlock.tagNumber) !== null && _c !== undefined ? _c : -1;
|
|
743
|
+
this.isConstructed = (_d = idBlock.isConstructed) !== null && _d !== undefined ? _d : false;
|
|
744
744
|
}
|
|
745
745
|
else {
|
|
746
746
|
this.tagClass = -1;
|
|
@@ -907,9 +907,9 @@
|
|
|
907
907
|
constructor({ lenBlock = {}, } = {}) {
|
|
908
908
|
var _a, _b, _c;
|
|
909
909
|
super();
|
|
910
|
-
this.isIndefiniteForm = (_a = lenBlock.isIndefiniteForm) !== null && _a !==
|
|
911
|
-
this.longFormUsed = (_b = lenBlock.longFormUsed) !== null && _b !==
|
|
912
|
-
this.length = (_c = lenBlock.length) !== null && _c !==
|
|
910
|
+
this.isIndefiniteForm = (_a = lenBlock.isIndefiniteForm) !== null && _a !== undefined ? _a : false;
|
|
911
|
+
this.longFormUsed = (_b = lenBlock.longFormUsed) !== null && _b !== undefined ? _b : false;
|
|
912
|
+
this.length = (_c = lenBlock.length) !== null && _c !== undefined ? _c : 0;
|
|
913
913
|
}
|
|
914
914
|
fromBER(inputBuffer, inputOffset, inputLength) {
|
|
915
915
|
const view = BufferSourceConverter.toUint8Array(inputBuffer);
|
|
@@ -1681,7 +1681,7 @@
|
|
|
1681
1681
|
class OctetString extends BaseBlock {
|
|
1682
1682
|
constructor({ idBlock = {}, lenBlock = {}, ...parameters } = {}) {
|
|
1683
1683
|
var _b, _c;
|
|
1684
|
-
(_b = parameters.isConstructed) !== null && _b !==
|
|
1684
|
+
(_b = parameters.isConstructed) !== null && _b !== undefined ? _b : (parameters.isConstructed = !!((_c = parameters.value) === null || _c === undefined ? undefined : _c.length));
|
|
1685
1685
|
super({
|
|
1686
1686
|
idBlock: {
|
|
1687
1687
|
isConstructed: parameters.isConstructed,
|
|
@@ -1842,7 +1842,7 @@
|
|
|
1842
1842
|
class BitString extends BaseBlock {
|
|
1843
1843
|
constructor({ idBlock = {}, lenBlock = {}, ...parameters } = {}) {
|
|
1844
1844
|
var _b, _c;
|
|
1845
|
-
(_b = parameters.isConstructed) !== null && _b !==
|
|
1845
|
+
(_b = parameters.isConstructed) !== null && _b !== undefined ? _b : (parameters.isConstructed = !!((_c = parameters.value) === null || _c === undefined ? undefined : _c.length));
|
|
1846
1846
|
super({
|
|
1847
1847
|
idBlock: {
|
|
1848
1848
|
isConstructed: parameters.isConstructed,
|
|
@@ -3044,7 +3044,7 @@
|
|
|
3044
3044
|
constructor(parameters = {}) {
|
|
3045
3045
|
var _b;
|
|
3046
3046
|
super(parameters);
|
|
3047
|
-
(_b = this.millisecond) !== null && _b !==
|
|
3047
|
+
(_b = this.millisecond) !== null && _b !== undefined ? _b : (this.millisecond = 0);
|
|
3048
3048
|
this.idBlock.tagClass = 1;
|
|
3049
3049
|
this.idBlock.tagNumber = 24;
|
|
3050
3050
|
}
|
|
@@ -3358,7 +3358,7 @@
|
|
|
3358
3358
|
hash: { name: 'SHA-256' },
|
|
3359
3359
|
};
|
|
3360
3360
|
function randomString() {
|
|
3361
|
-
return __awaiter(this,
|
|
3361
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
3362
3362
|
var bytes;
|
|
3363
3363
|
return __generator(this, function (_a) {
|
|
3364
3364
|
bytes = new Uint8Array(24);
|
|
@@ -3368,7 +3368,7 @@
|
|
|
3368
3368
|
});
|
|
3369
3369
|
}
|
|
3370
3370
|
function gen() {
|
|
3371
|
-
return __awaiter(this,
|
|
3371
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
3372
3372
|
var keys;
|
|
3373
3373
|
var _a;
|
|
3374
3374
|
return __generator(this, function (_b) {
|
|
@@ -3388,7 +3388,7 @@
|
|
|
3388
3388
|
});
|
|
3389
3389
|
}
|
|
3390
3390
|
function sign(text, privateJwk) {
|
|
3391
|
-
return __awaiter(this,
|
|
3391
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
3392
3392
|
var cKey, buffer, signed;
|
|
3393
3393
|
return __generator(this, function (_a) {
|
|
3394
3394
|
switch (_a.label) {
|
|
@@ -3404,7 +3404,7 @@
|
|
|
3404
3404
|
});
|
|
3405
3405
|
}
|
|
3406
3406
|
function digest(text) {
|
|
3407
|
-
return __awaiter(this,
|
|
3407
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
3408
3408
|
var buffer, digest;
|
|
3409
3409
|
return __generator(this, function (_a) {
|
|
3410
3410
|
switch (_a.label) {
|
|
@@ -3420,7 +3420,7 @@
|
|
|
3420
3420
|
}
|
|
3421
3421
|
//https://github.com/PeculiarVentures/PKI.js/blob/master/examples/PKCS10ComplexExample/es6.js
|
|
3422
3422
|
function csr(params) {
|
|
3423
|
-
return __awaiter(this,
|
|
3423
|
+
return __awaiter(this, undefined, undefined, function () {
|
|
3424
3424
|
var pkcs10, keys, publicKey, toDigest, pubkeyhash_sha1, privateKey, pkcs10_schema, pkcs10_encoded, exportedPkcs8;
|
|
3425
3425
|
var _a;
|
|
3426
3426
|
return __generator(this, function (_b) {
|
|
@@ -3528,9 +3528,9 @@
|
|
|
3528
3528
|
}
|
|
3529
3529
|
//https://github.com/PeculiarVentures/PKI.js/blob/master/examples/PKCS12SimpleExample/es6.js
|
|
3530
3530
|
function pfx(friendlyName_1, cert_b64_1, key_b64_1, password_1) {
|
|
3531
|
-
return __awaiter(this, arguments,
|
|
3531
|
+
return __awaiter(this, arguments, undefined, function (friendlyName, cert_b64, key_b64, password, hash) {
|
|
3532
3532
|
var asn1_cer, asn1_key, objc_cer, objc_key, pkcs12;
|
|
3533
|
-
if (hash ===
|
|
3533
|
+
if (hash === undefined) { hash = 'SHA-256'; }
|
|
3534
3534
|
return __generator(this, function (_a) {
|
|
3535
3535
|
switch (_a.label) {
|
|
3536
3536
|
case 0:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ne1410s/crypto",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.209",
|
|
4
4
|
"description": "Lightweight ES5 script to provide crypto utilities",
|
|
5
5
|
"main": "dist/ne14_crypto.cjs.min.js",
|
|
6
6
|
"module": "dist/ne14_crypto.esm.min.js",
|
|
@@ -40,18 +40,18 @@
|
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@rollup/plugin-commonjs": "^25.0.8",
|
|
42
42
|
"@rollup/plugin-node-resolve": "^15.3.1",
|
|
43
|
-
"@types/node": "^20.17.
|
|
43
|
+
"@types/node": "^20.17.12",
|
|
44
44
|
"@types/pkijs": "^3.0.1",
|
|
45
45
|
"chai": "^4.5.0",
|
|
46
46
|
"mocha": "^10.8.2",
|
|
47
47
|
"prettier": "^3.4.2",
|
|
48
48
|
"rimraf": "^5.0.10",
|
|
49
|
-
"rollup": "^4.
|
|
49
|
+
"rollup": "^4.30.0",
|
|
50
50
|
"rollup-plugin-typescript2": "^0.36.0",
|
|
51
51
|
"typescript": "^5.7.2"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@ne1410s/text": "^0.3.
|
|
54
|
+
"@ne1410s/text": "^0.3.170",
|
|
55
55
|
"asn1js": "^3.0.5",
|
|
56
56
|
"pkijs": "^3.2.4"
|
|
57
57
|
}
|