Showing 61 of 106 total issues
Function fromJwk
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export const fromJwk = async (
publicJwk: JsonWebKey,
privateJwk: JsonWebKey,
format: AsnFormat = 'pem',
options: X509EncodingOptions = {}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function compute
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
export const compute = async (msg: Uint8Array, hash: HashTypes = 'SHA-256') : Promise<Uint8Array> => {
const env = util.getCrypto();
let msgHash;
let errMsg;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function assertAlgorithms
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
const assertAlgorithms = ({name, iv, tagLength}: aesAlgorithm) => {
if(params.ciphers[name].ivLength){
if(!(iv instanceof Uint8Array)) throw new Error('InvalidArguments');
if(iv.byteLength < 2 || iv.byteLength > 16) throw new Error('InvalidIVLength');
if(params.ciphers[name].staticIvLength && (params.ciphers[name].ivLength !== iv.byteLength)) throw new Error('InvalidIVLength');
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function fromJwk
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const fromJwk = async (
publicJwk: JsonWebKey,
privateJwk: JsonWebKey,
format: AsnFormat = 'pem',
options: X509EncodingOptions = {}
Function export
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
async export(format: KeyFormat = 'jwk', options: KeyExportOptions = {}): Promise<JsonWebKey|PEM|DER|OctetEC>{
// return 'as is' without passphrase when nothing is given as 'options'
// only for the case to export der key from der key (considering encrypted key). expect to be called from getter
if(this._isEncrypted && this._type === 'private'){
if((format === 'der' || format === 'pem') && Object.keys(options).length === 0 && this._current.der) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function encryptPBES2
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
const encryptPBES2 = async (
binKey: any,
passphrase: string,
kdfAlgorithm: string,
prf: string,
Function toJwk
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const toJwk = (
decoded: DecodedAsn1Key,
type: PublicOrPrivate
): JsonWebKey => {
Function constructor
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
constructor(format: KeyFormat, key: JsonWebKey|PEM|DER|OctetEC, options: {namedCurve?: CurveTypes}={}){
const localKey = cloneDeep(key);
const localOpt = cloneDeep(options);
this._type = null;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function toJwk
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export const toJwk = async (
key: PEM|DER,
format: 'pem'|'der',
{outputPublic, passphrase}: {outputPublic?: boolean, passphrase: string}
): Promise<JsonWebKey> => {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function fromJwk
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export const fromJwk = (
jwkey: JsonWebKey,
{outputPublic, outputFormat='binary', compact=false}: {outputPublic?: boolean, outputFormat?: OctetFormat, compact?: boolean}
): Uint8Array|string => {
// original key type
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function compute
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export const compute = async (key: Uint8Array, data: Uint8Array, hash: HashTypes = 'SHA-256'): Promise<Uint8Array> => {
const env = util.getCrypto();
let msgKeyedHash;
let errMsg;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function sign
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export const sign = async (
msg: Uint8Array,
privateJwk: JsonWebKey,
hash: HashTypes = 'SHA-256',
algorithm: RSASignAlgorithm = {name: 'RSA-PSS', saltLength: params.hashes[hash].hashSize}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function fromJwkTo
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export const fromJwkTo = async (
output = 'pem',
jwkey: JsonWebKey,
options: KeyExportOptions = {}
): Promise<PEM|DER|OctetEC> => {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function deriveSecret
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export const deriveSecret = async (publicJwk: JsonWebKey, privateJwk: JsonWebKey): Promise<Uint8Array> => {
// assertion
if(publicJwk.crv !== privateJwk.crv) throw new Error('UnmatchedCurveName');
const env = util.getCrypto();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function generateKey
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export const generateKey = async (namedCurve: CurveTypes ='P-256'): Promise<JsonWebKeyPair> => {
const env = util.getCrypto();
let pure: boolean = false;
let keyPair: JsonWebKeyPair;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function sign
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export const sign = async (
msg: Uint8Array,
privateJwk: JsonWebKey,
hash: HashTypes = 'SHA-256',
signatureFormat: SignatureFormat ='raw'
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function verify
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export const verify = async (
msg: Uint8Array,
signature: Uint8Array,
publicJwk: JsonWebKey,
hash: HashTypes = 'SHA-256',
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function checkLength
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export const checkLength = (mode: 'sign'|'verify', {k, hash, saltLength}: PssParams) => {
if(mode === 'sign'){
if (k > (1 << params.hashes[hash].maxInput) - 1) throw new Error('Inconsistent');
if (k < params.hashes[hash].hashSize + saltLength + 2 || saltLength < 0) throw new Error('EncodingError');
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function compute
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export const compute = async (key: Uint8Array, data: Uint8Array, hash: HashTypes = 'SHA-256'): Promise<Uint8Array> => {
const env = util.getCrypto();
let msgKeyedHash;
let errMsg;
Consider simplifying this complex logical expression. Open
if (jwkey.n && jwkey.e && jwkey.d && jwkey.p && jwkey.q && jwkey.dp && jwkey.dq && jwkey.qi) return 'private';
else if (jwkey.n && jwkey.e) return 'public';
else throw new Error('InvalidRSAKey');