Closed Edza closed 1 year ago
Looks like codecOptions is mandatory for nistDecode, if it's left empty there is an error:
node_modules\node-nist\lib\nistDecode.js:314
nistUtils_1.provideDefaults({ nist: nistFile, codecOptions: options.codecOptions });
^
TypeError: Cannot read property 'codecOptions' of undefined
at Object.exports.nistDecode (...\node_modules\node-nist\lib\nistDecode.js:314:73)
at Object.<anonymous> (C:\Users\eduards.vavere\Desktop\size check\index.js:64:18)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:236:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:560:3)
I got it to work, I think. Not sure what this thing is:
MAP: {
2: {
48: {
mandatory: true
}
}
},
SRE: {
2: {
23: {
defaultValue: 'sorry',
mandatory: true
}
}
},
default: {
1: {
2 /* ver */: {
mandatory: true,
maxLength: 4,
minLength: 3,
regexs: [{ regex: '^[0-9]{3,4}$', errMsg: 'Expected three or four digits' }]
},
4 /* tot */: {
mandatory: true,
maxLength: 16
},
5 /* dat */: {
mandatory: true,
regexs: [{ regex: '^[0-9]{8}$', errMsg: 'Expected eight digits' }]
},
6 /* pry */: {
mandatory: false,
regexs: [{ regex: '^[1-9]{1}$', errMsg: 'Expected a number between 1 and 9' }]
},
7 /* dai */: {
mandatory: true
},
8 /* ori */: {
mandatory: true
},
9 /* tcn */: {
mandatory: true
},
10 /* tcr */: {
mandatory: false
},
11 /* nsr */: {
mandatory: true,
regexs: [{ regex: '^[0-9]{2}.[0-9]{2}$', errMsg: 'Expected a string in format dd.dd' }]
},
12 /* ntr */: {
mandatory: true,
regexs: [{ regex: '^[0-9]{2}.[0-9]{2}$', errMsg: 'Expected a string in format dd.dd' }]
}
},
4: {
3 /* imp */: {
mandatory: true
},
4 /* fgp */: {
mandatory: true
},
5 /* isr */: {
mandatory: true
},
6 /* hll */: {
mandatory: true
},
7 /* vll */: {
mandatory: true
},
8 /* cga */: {
mandatory: true
}
}
}
Could you provide some documentation for it? :)
Looks like codecOptions is mandatory for nistDecode, if it's left empty there is an error:
node_modules\node-nist\lib\nistDecode.js:314 nistUtils_1.provideDefaults({ nist: nistFile, codecOptions: options.codecOptions }); ^ TypeError: Cannot read property 'codecOptions' of undefined at Object.exports.nistDecode (...\node_modules\node-nist\lib\nistDecode.js:314:73) at Object.<anonymous> (C:\Users\eduards.vavere\Desktop\size check\index.js:64:18) at Module._compile (internal/modules/cjs/loader.js:689:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10) at Module.load (internal/modules/cjs/loader.js:599:32) at tryModuleLoad (internal/modules/cjs/loader.js:538:12) at Function.Module._load (internal/modules/cjs/loader.js:530:3) at Function.Module.runMain (internal/modules/cjs/loader.js:742:12) at startup (internal/bootstrap/node.js:236:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:560:3)
Well, Typescript compiler should flag such a problem. Refer to https://github.com/ivosh/node-nist/blob/master/src/nistDecode.ts#L533
However making codec options entirely optional for nistDecode
and nistEncode
seems logical.
Fixed in https://github.com/ivosh/node-nist/commit/58f7cee058252b26422c3c13052c2ace4455769a
Thanks for the fix. :D
Hi,
I'm currently trying to get decode to work. Sadly, there is no example. When I figure it out, I might write up an example in my fork and create a pull request. However, it would probably be faster for you to do it.
There are:
Currently trying to understand these options.