Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-opcua-crypto

Package Overview
Dependencies
Maintainers
1
Versions
99
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-opcua-crypto - npm Package Compare versions

Comparing version 1.3.6 to 1.3.7

4

.eslintrc.js

@@ -8,2 +8,3 @@ module.exports = {

'plugin:prettier/recommended', // Enables eslint-plugin-prettier and displays prettier errors as ESLint errors. Make sure this is always the last configuration in the extends array.
'prettier'
],

@@ -21,4 +22,5 @@ parserOptions: {

"@typescript-eslint/no-empty-interface": "off",
"@typescript-eslint/no-var-requires": "off"
"@typescript-eslint/no-var-requires": "off",
"@typescript-eslint/no-explicit-any": "off"
},
};

@@ -135,3 +135,2 @@ "use strict";

}
;
const a = asn1_1._readStruct(buffer, directoryName_block);

@@ -144,3 +143,5 @@ if (a.length < 1) {

const authorityCertIssuer = authorityCertIssuer_block ? _readAuthorityCertIssuer(authorityCertIssuer_block) : null;
const authorityCertIssuerFingerPrint = authorityCertIssuer_block ? _readAuthorityCertIssuerFingerPrint(authorityCertIssuer_block) : "";
const authorityCertIssuerFingerPrint = authorityCertIssuer_block
? _readAuthorityCertIssuerFingerPrint(authorityCertIssuer_block)
: "";
return {

@@ -147,0 +148,0 @@ authorityCertIssuer,

@@ -6,4 +6,3 @@ /// <reference types="node" />

export declare type CertificateSerialNumber = string;
export interface Extensions {
}
export declare type Extensions = Record<string, unknown>;
export interface RevokedCertificate {

@@ -10,0 +9,0 @@ userCertificate: CertificateSerialNumber;

@@ -10,3 +10,3 @@ "use strict";

var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};

@@ -13,0 +13,0 @@ Object.defineProperty(exports, "__esModule", { value: true });

@@ -260,4 +260,4 @@ "use strict";

"2.16.840.1.113730.1.13": { d: "netscapeComment", c: "Netscape certificate extension" },
"done": { d: "", c: "" },
done: { d: "", c: "" },
};
//# sourceMappingURL=oid_map.js.map

@@ -146,7 +146,7 @@ import * as assert from "assert";

export function _readIntegerAsByteString(buffer: Buffer, block: BlockInfo) {
export function _readIntegerAsByteString(buffer: Buffer, block: BlockInfo): Buffer {
return _getBlock(buffer, block);
}
export function _readListOfInteger(buffer: Buffer) {
export function _readListOfInteger(buffer: Buffer): Buffer[] {
const block = readTag(buffer, 0);

@@ -159,3 +159,3 @@ const inner_blocks = _readStruct(buffer, block);

function parseOID(buffer: Buffer, start: number, end: number) {
function parseOID(buffer: Buffer, start: number, end: number): string {
// ASN.1 JavaScript decoder

@@ -191,4 +191,3 @@ // Copyright (c) 2008-2014 Lapo Luchini <lapo@lapo.it>

export function _readObjectIdentifier(buffer: Buffer, block: BlockInfo) {
export function _readObjectIdentifier(buffer: Buffer, block: BlockInfo): { oid: string; name: string } {
assert(block.tag === TagType.OBJECT_IDENTIFIER);

@@ -255,4 +254,2 @@ const b = buffer.slice(block.position, block.position + block.length);

/*

@@ -293,4 +290,2 @@ 4.1.2.5.2 GeneralizedTime

/*

@@ -360,3 +355,2 @@ http://tools.ietf.org/html/rfc5280

export interface DirectoryName {

@@ -370,3 +364,3 @@ stateOrProvinceName?: string;

}
export function compactDirectoryName(d: DirectoryName) {
export function compactDirectoryName(d: DirectoryName): string {
return JSON.stringify(d);

@@ -404,5 +398,4 @@ }

export function _readTime(buffer: Buffer, block: BlockInfo) {
export function _readTime(buffer: Buffer, block: BlockInfo): any {
return _readValue(buffer, block);
}

@@ -16,4 +16,4 @@ //

: (size: number): Buffer => {
// istanbul ignore next
return new Buffer(size);
};
// istanbul ignore next
return new Buffer(size);
};

@@ -80,3 +80,3 @@ /**

_findBlockAtIndex,
_readDirectoryName
_readDirectoryName,
} from "./asn1";

@@ -87,3 +87,2 @@ import { Certificate, PrivateKey } from "./common";

// Converted from: https://www.cs.auckland.ac.nz/~pgut001/dumpasn1.cfg

@@ -96,3 +95,2 @@ // which is made by Peter Gutmann and whose license states:

export interface AttributeTypeAndValue {

@@ -102,3 +100,2 @@ [key: string]: any;

function _readAttributeTypeAndValue(buffer: Buffer, block: BlockInfo): AttributeTypeAndValue {

@@ -115,5 +112,4 @@ let inner_blocks = _readStruct(buffer, block);

for(const [key, value] of Object.entries(data)) {
for (const [key, value] of Object.entries(data)) {
result[key] = value;
}

@@ -141,3 +137,2 @@ return result;

export interface Validity {

@@ -156,3 +151,2 @@ notBefore: Date;

function _readAuthorityKeyIdentifier(buffer: Buffer): AuthorithyKeyIdentifier {

@@ -196,5 +190,9 @@ /**

const directoryName_block = _findBlockAtIndex(inner_blocks, 4)!;
if (!directoryName_block) { return "" };
if (!directoryName_block) {
return "";
}
const a = _readStruct(buffer, directoryName_block);
if (a.length < 1) { return ""; }
if (a.length < 1) {
return "";
}
return directoryName_block ? formatBuffer2DigitHexWithColum(makeSHA1Thumbprint(_getBlock(buffer, a[0]))) : "";

@@ -204,3 +202,5 @@ }

const authorityCertIssuer = authorityCertIssuer_block ? _readAuthorityCertIssuer(authorityCertIssuer_block) : null;
const authorityCertIssuerFingerPrint = authorityCertIssuer_block ? _readAuthorityCertIssuerFingerPrint(authorityCertIssuer_block) : "";
const authorityCertIssuerFingerPrint = authorityCertIssuer_block
? _readAuthorityCertIssuerFingerPrint(authorityCertIssuer_block)
: "";

@@ -495,4 +495,2 @@ return {

function _readSubjectPublicKeyInfo(buffer: Buffer, block: BlockInfo): SubjectPublicKeyInfo {

@@ -562,8 +560,3 @@ const inner_blocks = _readStruct(buffer, block);

let version, serialNumber,
signature, issuer,
validity, subject,
subjectFingerPrint,
subjectPublicKeyInfo,
extensions;
let version, serialNumber, signature, issuer, validity, subject, subjectFingerPrint, subjectPublicKeyInfo, extensions;

@@ -719,3 +712,2 @@ if (blocks.length === 6) {

export function combine_der(certificates: Certificate[]): Certificate {
// perform some sanity check

@@ -722,0 +714,0 @@ for (const cert of certificates) {

@@ -142,3 +142,3 @@ // tslint:disabled:no-var-requires

// istanbul ignore next
export function hexDump(buffer: Buffer, width?: number) {
export function hexDump(buffer: Buffer, width?: number): string {
if (!buffer) {

@@ -208,3 +208,3 @@ return "<>";

options: VerifyMessageChunkSignatureOptions
) {
): boolean {
assert(blockToVerify instanceof Buffer);

@@ -226,3 +226,3 @@ assert(signature instanceof Buffer);

export function setCertificateStore(store: string) {
export function setCertificateStore(store: string): string {
const old_store = __certificate_store;

@@ -280,3 +280,3 @@ __certificate_store = store;

// small buffer that depends of the key size.
export function publicEncrypt_native(buffer: Buffer, publicKey: PublicKeyPEM, algorithm?: PaddingAlgorithm) {
export function publicEncrypt_native(buffer: Buffer, publicKey: PublicKeyPEM, algorithm?: PaddingAlgorithm): Buffer {
if (algorithm === undefined) {

@@ -296,3 +296,3 @@ algorithm = PaddingAlgorithm.RSA_PKCS1_PADDING;

export function privateDecrypt_native(buffer: Buffer, privateKey: PrivateKeyPEM, algorithm?: PaddingAlgorithm) {
export function privateDecrypt_native(buffer: Buffer, privateKey: PrivateKeyPEM, algorithm?: PaddingAlgorithm): Buffer {
if (algorithm === undefined) {

@@ -326,3 +326,3 @@ algorithm = PaddingAlgorithm.RSA_PKCS1_PADDING;

algorithm?: PaddingAlgorithm
) {
): Buffer {
if (algorithm === undefined) {

@@ -346,3 +346,3 @@ algorithm = PaddingAlgorithm.RSA_PKCS1_PADDING;

export function privateDecrypt_long(buffer: Buffer, privateKey: PrivateKeyPEM, blockSize: number, algorithm?: number) {
export function privateDecrypt_long(buffer: Buffer, privateKey: PrivateKeyPEM, blockSize: number, algorithm?: number): Buffer {
algorithm = algorithm || RSA_PKCS1_PADDING;

@@ -411,3 +411,3 @@ assert(algorithm === RSA_PKCS1_PADDING || algorithm === RSA_PKCS1_OAEP_PADDING);

callback: (err: Error | null, publicKeyPEM?: PublicKeyPEM) => void
) {
): void {
let err1: any = null;

@@ -414,0 +414,0 @@ let keyPem: PublicKeyPEM;

@@ -67,3 +67,3 @@ /**

// http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
export function makePseudoRandomBuffer(secret: Nonce, seed: Nonce, minLength: number, sha1or256: "SHA1" | "SHA256") {
export function makePseudoRandomBuffer(secret: Nonce, seed: Nonce, minLength: number, sha1or256: "SHA1" | "SHA256"): Buffer {
assert(seed instanceof Buffer);

@@ -176,3 +176,3 @@ assert(sha1or256 === "SHA1" || sha1or256 === "SHA256");

*/
export function verifyChunkSignature(chunk: Buffer, options: VerifyChunkSignatureOptions) {
export function verifyChunkSignature(chunk: Buffer, options: VerifyChunkSignatureOptions): boolean {
assert(chunk instanceof Buffer);

@@ -179,0 +179,0 @@ let signatureLength = options.signatureLength || 0;

@@ -31,3 +31,3 @@ import * as fs from "fs";

export type CertificateSerialNumber = string;
export interface Extensions { }
export type Extensions = Record<string, unknown>;
export interface RevokedCertificate {

@@ -34,0 +34,0 @@ userCertificate: CertificateSerialNumber;

@@ -7,3 +7,3 @@ /**

import { exploreCertificate, SubjectPublicKeyInfo } from "./crypto_explore_certificate";
import { DirectoryName, } from "./asn1";
import { DirectoryName } from "./asn1";
import { convertPEMtoDER } from "./crypto_utils";

@@ -10,0 +10,0 @@ import * as assert from "assert";

@@ -10,2 +10,2 @@ /**

export * from "./verify_cerficate_signature";
export * from "./explore_certificate_revocation_list";
export * from "./explore_certificate_revocation_list";

@@ -1,4 +0,3 @@

// https://github.com/lapo-luchini/asn1js/blob/master/oids.js
export const oid_map: { [key: string]: { d: string, c: string, w?: boolean } } = {
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" },

@@ -265,3 +264,3 @@ "0.9.2342.19200300.100.1.3": { d: "rfc822Mailbox", c: "Some oddball X.500 attribute collection" },

"done": { d: "", c: "" },
done: { d: "", c: "" },
};

@@ -11,25 +11,7 @@ // tslint:disable: no-console

import { Certificate, PrivateKey } from "./common";
import {
split_der,
exploreCertificate,
} from "./crypto_explore_certificate";
import { split_der, exploreCertificate } from "./crypto_explore_certificate";
import { toPem } from "./crypto_utils";
import {
_readAlgorithmIdentifier,
_readSignatureValueBin,
TagType,
readTag,
_readStruct,
_getBlock
} from "./asn1";
import { _readAlgorithmIdentifier, _readSignatureValueBin, TagType, readTag, _readStruct, _getBlock } from "./asn1";
export function verifyCertificateOrClrSignature(
certificateOrCrl: Buffer,
parentCerticate: Certificate,
): boolean {
export function verifyCertificateOrClrSignature(certificateOrCrl: Buffer, parentCerticate: Certificate): boolean {
const block_info = readTag(certificateOrCrl, 0);

@@ -52,7 +34,4 @@ const blocks = _readStruct(certificateOrCrl, block_info);

export function verifyCertificateSignature(
certificate: Certificate,
parentCerticate: Certificate
): boolean {
return verifyCertificateOrClrSignature(certificate, parentCerticate)
export function verifyCertificateSignature(certificate: Certificate, parentCerticate: Certificate): boolean {
return verifyCertificateOrClrSignature(certificate, parentCerticate);
}

@@ -63,6 +42,5 @@ export function verifyCertificateRevocationListSignature(

): boolean {
return verifyCertificateOrClrSignature(certificateRevocationList, parentCerticate)
return verifyCertificateOrClrSignature(certificateRevocationList, parentCerticate);
}
export type _VerifyStatus = "BadCertificateIssuerUseNotAllowed" | "BadCertificateInvalid" | "Good";

@@ -69,0 +47,0 @@ export async function verifyCertificateChain(certificateChain: Certificate[]): Promise<{ status: _VerifyStatus; reason: string }> {

{
"name": "node-opcua-crypto",
"version": "1.3.6",
"version": "1.3.7",
"description": "Crypto tools for Node-OPCUA",

@@ -10,2 +10,3 @@ "main": "./dist/index.js",

"prepare": "npm run build",
"tslint": "tslint --project . --fix",
"lint": "eslint . --ext .ts",

@@ -15,3 +16,4 @@ "test": "mocha test -r ts-node/register -r source-map-support/register -R spec --recursive --timeout 200000 --bail test/**/*.ts",

"cost-of-modules": "npx cost-of-modules --no-install",
"release-it": "npx release-it"
"release-it": "npx release-it",
"prettier-format": "prettier --config .prettierrc.js lib/**/*.ts test/**/*.ts --write"
},

@@ -29,20 +31,20 @@ "keywords": [

"devDependencies": {
"@types/mocha": "^7.0.2",
"@types/node": "^14.0.27",
"@types/mocha": "^8.0.3",
"@types/node": "^14.11.1",
"@types/should": "^13.0.0",
"@types/underscore": "^1.10.20",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"eslint": "^7.6.0",
"@typescript-eslint/eslint-plugin": "^4.1.1",
"@typescript-eslint/parser": "^4.1.1",
"eslint": "^7.9.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-prettier": "^3.1.4",
"lorem-ipsum": "^2.0.3",
"mocha": "^7.2.0",
"prettier": "^2.0.5",
"mocha": "^8.1.3",
"prettier": "^2.1.2",
"should": "^13.2.3",
"source-map": "^0.7.3",
"source-map-support": "^0.5.19",
"ts-node": "^8.10.2",
"ts-node": "^9.0.0",
"tslint": "^6.1.3",
"typescript": "^3.9.7"
"typescript": "^4.0.3",
"tslint-config-prettier": "^1.18.0"
},

@@ -53,3 +55,3 @@ "dependencies": {

"hexy": "^0.3.0",
"jsrsasign": "^8.0.23",
"jsrsasign": "^9.1.9",
"sshpk": "^1.16.1"

@@ -56,0 +58,0 @@ },

{
"extends": [
"tslint:recommended"
"tslint:recommended",
"tslint-config-prettier"
],

@@ -34,2 +35,2 @@ "jsRules": {},

"rulesDirectory": []
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc