@lapo/asn1js 2.0.6 → 2.1.0
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/asn1.js +2 -2
- package/defs.js +8 -6
- package/dumpASN1.js +1 -1
- package/int10.js +13 -7
- package/package.json +31 -74
package/asn1.js
CHANGED
|
@@ -295,7 +295,7 @@ export class Stream {
|
|
|
295
295
|
s = this.parseStringUTF(start, end, maxLength);
|
|
296
296
|
checkPrintable(s.str);
|
|
297
297
|
return { size: end - start, str: s.str };
|
|
298
|
-
} catch (
|
|
298
|
+
} catch (ignore) {
|
|
299
299
|
// ignore
|
|
300
300
|
}
|
|
301
301
|
maxLength /= 2; // we work in bytes
|
|
@@ -638,7 +638,7 @@ export class ASN1 {
|
|
|
638
638
|
throw new Error('Unable to parse content: ' + e);
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
|
-
} catch (
|
|
641
|
+
} catch (ignore) {
|
|
642
642
|
// but silently ignore when they don't
|
|
643
643
|
sub = null;
|
|
644
644
|
//DEBUG console.log('Could not decode structure at ' + start + ':', e);
|
package/defs.js
CHANGED
|
@@ -23,7 +23,7 @@ function translate(def, tn, stats) {
|
|
|
23
23
|
try {
|
|
24
24
|
// hope current OIDs contain the type name (will need to parse from RFC itself)
|
|
25
25
|
def = Defs.searchType(firstUpper(stats.defs[def.definedBy][1]));
|
|
26
|
-
} catch (
|
|
26
|
+
} catch (ignore) { /*ignore*/ }
|
|
27
27
|
while (def?.type == 'defined' || def?.type?.type == 'defined') {
|
|
28
28
|
const name = def?.type?.type ? def.type.name : def.name;
|
|
29
29
|
def = Object.assign({}, def);
|
|
@@ -35,7 +35,8 @@ function translate(def, tn, stats) {
|
|
|
35
35
|
c = translate(c);
|
|
36
36
|
if (tn == c.type.name || tn == c.name) {
|
|
37
37
|
def = Object.assign({}, def);
|
|
38
|
-
if (c.id)
|
|
38
|
+
if (c.id) // show the CHOICE id, but add it to existing one if present
|
|
39
|
+
def.id = def.id ? def.id + ' ' + c.id : c.id;
|
|
39
40
|
def.type = c.type.name ? c.type : c;
|
|
40
41
|
break;
|
|
41
42
|
}
|
|
@@ -69,7 +70,7 @@ export class Defs {
|
|
|
69
70
|
|
|
70
71
|
static match(value, def, stats = { total: 0, recognized: 0, defs: {} }) {
|
|
71
72
|
value.def = {};
|
|
72
|
-
let tn = value.typeName().
|
|
73
|
+
let tn = value.typeName().replace(/_/g, ' ');
|
|
73
74
|
def = translate(def, tn, stats);
|
|
74
75
|
++stats.total;
|
|
75
76
|
if (def?.type) {
|
|
@@ -90,12 +91,13 @@ export class Defs {
|
|
|
90
91
|
if (def.typeOf)
|
|
91
92
|
type = def.content[0];
|
|
92
93
|
else {
|
|
93
|
-
let tn = subval.typeName().
|
|
94
|
+
let tn = subval.typeName().replace(/_/g, ' ');
|
|
94
95
|
for (;;) {
|
|
95
96
|
type = def.content[j++];
|
|
96
97
|
if (!type || typeof type != 'object') break;
|
|
97
98
|
if (type?.type?.type)
|
|
98
|
-
type = type.type;
|
|
99
|
+
// type = type.type;
|
|
100
|
+
type = Object.assign({}, type.type, {id: type.id});
|
|
99
101
|
if (type.type == 'defined') {
|
|
100
102
|
let t2 = translate(type, tn);
|
|
101
103
|
if (t2.type.name == tn) break; // exact match
|
|
@@ -113,7 +115,7 @@ export class Defs {
|
|
|
113
115
|
} else if (type?.definedBy && stats.defs?.[type.definedBy]?.[1]) { // hope current OIDs contain the type name (will need to parse from RFC itself)
|
|
114
116
|
try {
|
|
115
117
|
type = Defs.searchType(firstUpper(stats.defs[type.definedBy][1]));
|
|
116
|
-
} catch (
|
|
118
|
+
} catch (ignore) { /*ignore*/ }
|
|
117
119
|
}
|
|
118
120
|
}
|
|
119
121
|
}
|
package/dumpASN1.js
CHANGED
package/int10.js
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
14
14
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
/** Biggest 10^n integer that can still fit 2^53 when multiplied by 256. */
|
|
17
|
+
const max = 10000000000000;
|
|
17
18
|
|
|
18
19
|
export class Int10 {
|
|
19
20
|
/**
|
|
@@ -26,11 +27,13 @@ export class Int10 {
|
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Multiply value by m and add c.
|
|
29
|
-
* @param {number} m - multiplier, must be <
|
|
30
|
-
* @param {number} c - value to add
|
|
30
|
+
* @param {number} m - multiplier, must be 0<m<=256
|
|
31
|
+
* @param {number} c - value to add, must be c>=0
|
|
31
32
|
*/
|
|
32
33
|
mulAdd(m, c) {
|
|
34
|
+
// assert(m > 0)
|
|
33
35
|
// assert(m <= 256)
|
|
36
|
+
// assert(c >= 0)
|
|
34
37
|
let b = this.buf,
|
|
35
38
|
l = b.length,
|
|
36
39
|
i, t;
|
|
@@ -71,11 +74,12 @@ export class Int10 {
|
|
|
71
74
|
|
|
72
75
|
/**
|
|
73
76
|
* Convert to decimal string representation.
|
|
74
|
-
* @param {
|
|
77
|
+
* @param {number} [base=10] - optional value, only value accepted is 10
|
|
78
|
+
* @returns {string} The decimal string representation.
|
|
75
79
|
*/
|
|
76
|
-
toString(base) {
|
|
77
|
-
if (
|
|
78
|
-
throw 'only base 10 is supported';
|
|
80
|
+
toString(base = 10) {
|
|
81
|
+
if (base != 10)
|
|
82
|
+
throw new Error('only base 10 is supported');
|
|
79
83
|
let b = this.buf,
|
|
80
84
|
s = b[b.length - 1].toString();
|
|
81
85
|
for (let i = b.length - 2; i >= 0; --i)
|
|
@@ -86,6 +90,7 @@ export class Int10 {
|
|
|
86
90
|
/**
|
|
87
91
|
* Convert to Number value representation.
|
|
88
92
|
* Will probably overflow 2^53 and thus become approximate.
|
|
93
|
+
* @returns {number} The numeric value.
|
|
89
94
|
*/
|
|
90
95
|
valueOf() {
|
|
91
96
|
let b = this.buf,
|
|
@@ -97,6 +102,7 @@ export class Int10 {
|
|
|
97
102
|
|
|
98
103
|
/**
|
|
99
104
|
* Return value as a simple Number (if it is <= 10000000000000), or return this.
|
|
105
|
+
* @returns {number | Int10} The simplified value.
|
|
100
106
|
*/
|
|
101
107
|
simplify() {
|
|
102
108
|
let b = this.buf;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lapo/asn1js",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Generic ASN.1 parser/decoder that can decode any valid ASN.1 DER or BER structures.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "asn1.js",
|
|
@@ -8,12 +8,29 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/lapo-luchini/asn1js.git"
|
|
10
10
|
},
|
|
11
|
-
"keywords": [
|
|
11
|
+
"keywords": [
|
|
12
|
+
"asn1",
|
|
13
|
+
"ber",
|
|
14
|
+
"der",
|
|
15
|
+
"pem"
|
|
16
|
+
],
|
|
12
17
|
"author": "Lapo Luchini <lapo@lapo.it>",
|
|
13
18
|
"license": "ISC",
|
|
14
|
-
"bugs": {
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/lapo-luchini/asn1js/issues"
|
|
21
|
+
},
|
|
15
22
|
"homepage": "https://lapo.it/asn1js/",
|
|
16
|
-
"files": [
|
|
23
|
+
"files": [
|
|
24
|
+
"asn1.js",
|
|
25
|
+
"base64.js",
|
|
26
|
+
"hex.js",
|
|
27
|
+
"int10.js",
|
|
28
|
+
"dom.js",
|
|
29
|
+
"defs.js",
|
|
30
|
+
"oids.js",
|
|
31
|
+
"rfcdef.js",
|
|
32
|
+
"dumpASN1.js"
|
|
33
|
+
],
|
|
17
34
|
"scripts": {
|
|
18
35
|
"lint": "npx eslint asn1.js base64.js hex.js int10.js dom.js defs.js oids.js rfcdef.js tags.js context.js index.js parseRFC.js dumpASN1.js test.js testDefs.js vite.config.js theme.js",
|
|
19
36
|
"lint-action": "npx @action-validator/cli .github/workflows/node.js.yml",
|
|
@@ -26,15 +43,20 @@
|
|
|
26
43
|
"dumpASN1": "./dumpASN1.js"
|
|
27
44
|
},
|
|
28
45
|
"engines": {
|
|
29
|
-
"node": ">=
|
|
46
|
+
"node": ">=14.6.0"
|
|
30
47
|
},
|
|
48
|
+
"packageManager": "pnpm@7.33.7",
|
|
31
49
|
"devDependencies": {
|
|
32
|
-
"@
|
|
33
|
-
"eslint": "^
|
|
50
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
51
|
+
"@eslint/js": "^9.32.0",
|
|
52
|
+
"@rollup/wasm-node": "^4.46.2",
|
|
53
|
+
"diff": "^8.0.2",
|
|
54
|
+
"eslint": "^9.32.0",
|
|
55
|
+
"globals": "^16.3.0",
|
|
34
56
|
"htmlparser2": "^9.1.0",
|
|
35
|
-
"vite": "^5.4.
|
|
57
|
+
"vite": "^5.4.19",
|
|
36
58
|
"vite-plugin-dom": "^1.0.4",
|
|
37
|
-
"vite-plugin-singlefile": "^2.0
|
|
59
|
+
"vite-plugin-singlefile": "^2.3.0"
|
|
38
60
|
},
|
|
39
61
|
"overrides": {
|
|
40
62
|
"rollup": "npm:@rollup/wasm-node"
|
|
@@ -43,70 +65,5 @@
|
|
|
43
65
|
"overrides": {
|
|
44
66
|
"rollup": "npm:@rollup/wasm-node"
|
|
45
67
|
}
|
|
46
|
-
},
|
|
47
|
-
"eslintConfig": {
|
|
48
|
-
"env": {
|
|
49
|
-
"es6": true,
|
|
50
|
-
"browser": true,
|
|
51
|
-
"node": true
|
|
52
|
-
},
|
|
53
|
-
"parserOptions": {
|
|
54
|
-
"ecmaVersion": 2015,
|
|
55
|
-
"sourceType": "module"
|
|
56
|
-
},
|
|
57
|
-
"extends": [ "eslint:recommended" ],
|
|
58
|
-
"globals": {
|
|
59
|
-
"Uint8Array": "readonly"
|
|
60
|
-
},
|
|
61
|
-
"rules": {
|
|
62
|
-
"strict": [ "error", "function" ],
|
|
63
|
-
"indent": [ "error", 4 ],
|
|
64
|
-
"no-trailing-spaces": [ "error" ],
|
|
65
|
-
"linebreak-style": [ "error", "unix" ],
|
|
66
|
-
"eol-last": [ "error", "always" ],
|
|
67
|
-
"semi": [ "warn", "always" ],
|
|
68
|
-
"quotes": [ "error", "single", { "avoidEscape": true } ],
|
|
69
|
-
"no-var": [ "warn" ],
|
|
70
|
-
"comma-dangle": [ "error", "always-multiline" ]
|
|
71
|
-
},
|
|
72
|
-
"overrides": [
|
|
73
|
-
{
|
|
74
|
-
"files": [ "defs.js" ],
|
|
75
|
-
"parserOptions": {
|
|
76
|
-
"ecmaVersion": 2020
|
|
77
|
-
}
|
|
78
|
-
}, {
|
|
79
|
-
"files": [ "test.js", "parseRFC.js", "dumpASN1.js" ],
|
|
80
|
-
"parserOptions": {
|
|
81
|
-
"ecmaVersion": 2021
|
|
82
|
-
},
|
|
83
|
-
"rules": {
|
|
84
|
-
"strict": [ "error", "global" ]
|
|
85
|
-
}
|
|
86
|
-
}, {
|
|
87
|
-
"files": [ "oids.js" ],
|
|
88
|
-
"rules": {
|
|
89
|
-
"indent": "off",
|
|
90
|
-
"quotes": [ "warn", "double" ]
|
|
91
|
-
}
|
|
92
|
-
}, {
|
|
93
|
-
"files": [ "tags.js", "rfcdef.js" ],
|
|
94
|
-
"rules": {
|
|
95
|
-
"indent": [ "error", 2, { "ignoredNodes": [ "Program > ExpressionStatement > CallExpression > FunctionExpression > BlockStatement > ExpressionStatement[directive='use strict']:first-child" ] } ],
|
|
96
|
-
"comma-dangle": "off",
|
|
97
|
-
"quotes": [ "warn", "double" ]
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
"files": [ "defs.js" ],
|
|
101
|
-
"parserOptions": {
|
|
102
|
-
"ecmaVersion": 2021
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
"files": [ "testDefs.js" ],
|
|
106
|
-
"parserOptions": {
|
|
107
|
-
"ecmaVersion": 2022
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
]
|
|
111
68
|
}
|
|
112
69
|
}
|