Showing 31 of 107 total issues
File crypto_explore_certificate.ts
has 472 lines of code (exceeds 250 allowed). Consider refactoring. Open
/**
* @module node_opcua_crypto
*/
// ---------------------------------------------------------------------------------------------------------------------
// node-opcua-crypto
File test_crypto.ts
has 391 lines of code (exceeds 250 allowed). Consider refactoring. Open
// ---------------------------------------------------------------------------------------------------------------------
// node-opcua-crypto
// ---------------------------------------------------------------------------------------------------------------------
// Copyright (c) 2014-2022 - Etienne Rossignon - etienne.rossignon (at) gadz.org
// Copyright (c) 2022-2024 - Sterfive.com
File test_peculiar_edge_case.ts
has 336 lines of code (exceeds 250 allowed). Consider refactoring. Open
import path from "node:path";
import fs from "node:fs";
import { tmpdir } from "node:os";
import { Crypto as PeculiarWebCrypto } from "@peculiar/webcrypto";
import * as x509 from "@peculiar/x509";
Function make_suite
has 95 lines of code (exceeds 25 allowed). Consider refactoring. Open
function make_suite(algorithm: string, signatureLength: number) {
it("should sign with a private key and verify with the public key - " + algorithm, function () {
const alice_private_key = readPrivateKey(alice_private_key_filename);
const options1 = {
algorithm,
File oid_map.ts
has 297 lines of code (exceeds 250 allowed). Consider refactoring. Open
// https://github.com/lapo-luchini/asn1js/blob/master/oids.js
export const oid_map: { [key: string]: { d: string; c: string; w?: boolean } } = {
"0.9.2342.19200300.100.1.1": { d: "userID", c: "Some oddball X.500 attribute collection" },
"0.9.2342.19200300.100.1.3": { d: "rfc822Mailbox", c: "Some oddball X.500 attribute collection" },
"0.9.2342.19200300.100.1.25": { d: "domainComponent", c: "Men are from Mars, this OID is from Pluto" },
Function explorePrivateKey
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function explorePrivateKey(privateKey2: PrivateKey): PrivateKeyInternals {
const privateKey1 = privateKey2.hidden;
const privateKey =
typeof privateKey1 === "string" ? convertPEMtoDER(privateKey1) : privateKey1.export({ format: "der", type: "pkcs1" });
File asn1.ts
has 278 lines of code (exceeds 250 allowed). Consider refactoring. Open
import assert from "assert";
import { oid_map } from "./oid_map.js";
import { DirectoryName } from "./directory_name.js";
// https://github.com/lapo-luchini/asn1js/blob/master/asn1.js
export enum TagType {
Function readTbsCertificate
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function readTbsCertificate(buffer: Buffer, block: BlockInfo): TbsCertificate {
const blocks = readStruct(buffer, block);
let version, serialNumber, signature, issuer, validity, subject, subjectFingerPrint, extensions;
let subjectPublicKeyInfo: SubjectPublicKeyInfo;
Function parseOID
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function parseOID(buffer: Buffer, start: number, end: number): string {
// ASN.1 JavaScript decoder
// Copyright (c) 2008-2014 Lapo Luchini <lapo@lapo.it>
let s = "",
n = 0,
- 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 _readGeneralNames
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _readGeneralNames(buffer: Buffer, block: BlockInfo) {
const _data: { [key: number]: { name: string; type: string } } = {
1: { name: "rfc822Name", type: "IA5String" },
2: { name: "dNSName", type: "IA5String" },
3: { name: "x400Address", type: "ORAddress" },
Function verifyCertificateChain
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function verifyCertificateChain(certificateChain: Certificate[]): Promise<{ status: _VerifyStatus; reason: string }> {
// verify that all the certificate
// second certificate must be used for CertificateSign
for (let index = 1; index < certificateChain.length; index++) {
Function _readTbsCertList
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _readTbsCertList(buffer: Buffer, blockInfo: BlockInfo): TBSCertList {
const blocks = readStruct(buffer, blockInfo);
const hasOptionalVersion = blocks[0].tag === TagType.INTEGER;
Function _readTbsCertList
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function _readTbsCertList(buffer: Buffer, blockInfo: BlockInfo): TBSCertList {
const blocks = readStruct(buffer, blockInfo);
const hasOptionalVersion = blocks[0].tag === TagType.INTEGER;
- 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 _readAuthorityKeyIdentifier
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
function _readAuthorityKeyIdentifier(buffer: Buffer): AuthorityKeyIdentifier {
/**
* where a CA distributes its public key in the form of a "self-signed"
* certificate, the authority key identifier MAY be omitted. Th
* signature on a self-signed certificate is generated with the private
- 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 _readAuthorityKeyIdentifier
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function _readAuthorityKeyIdentifier(buffer: Buffer): AuthorityKeyIdentifier {
/**
* where a CA distributes its public key in the form of a "self-signed"
* certificate, the authority key identifier MAY be omitted. Th
* signature on a self-signed certificate is generated with the private
Function readExtension
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function readExtension(buffer: Buffer, block: BlockInfo): { identifier: { oid: string; name: string }; value: any } {
const inner_blocks = readStruct(buffer, block);
if (inner_blocks.length === 3) {
assert(inner_blocks[1].tag === TagType.BOOLEAN);
Function verifyCertificateChain
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
export async function verifyCertificateChain(certificateChain: Certificate[]): Promise<{ status: _VerifyStatus; reason: string }> {
// verify that all the certificate
// second certificate must be used for CertificateSign
for (let index = 1; index < certificateChain.length; index++) {
- 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 generate
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function generate(event: any) {
event.preventDefault();
const keySize = document.getElementById("keySize").value;
const applicationUri = document.getElementById("applicationUri").value;
const subject = document.getElementById("subject").value;
Function investigateCertificateSignature
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function investigateCertificateSignature(certificate: Certificate, caPrivateKey?: PrivateKey): void {
const block_info = asn1.readTag(certificate, 0);
const blocks = asn1.readStruct(certificate, block_info);
// console.log(block_info, blocks[0], blocks[1], blocks[2]);
Function publicEncrypt_long
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
export function publicEncrypt_long(
buffer: Buffer,
publicKey: KeyLike,
blockSize: number,
padding?: number,
- 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"