node-opcua-crypto-web 5.4.0 → 5.5.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.
@@ -70,13 +70,60 @@ declare function isCrlIssuedByCertificate(crl: CertificateRevocationList, certif
70
70
  */
71
71
  declare function verifyCrlIssuedByCertificate(crl: CertificateRevocationList, certificate: Certificate): boolean;
72
72
 
73
+ /**
74
+ * One attribute of a Distinguished Name, as it appears in the certificate.
75
+ *
76
+ * Kept as an ordered list alongside the convenience map because a DN is a
77
+ * *sequence*, not a record: an attribute may legitimately repeat (two `OU`s,
78
+ * several `DC`s), and both the repetition and the order carry meaning. Callers
79
+ * that must reproduce a DN faithfully — OPC UA Part 18 §4.4.3 Table 10
80
+ * `X509Subject` role criteria, for instance — cannot do so from the map alone,
81
+ * because the map keeps only the last value for a repeated attribute.
82
+ */
83
+ interface DistinguishedNameAttribute {
84
+ /** Dotted OID, e.g. `2.5.4.3`. */
85
+ oid: string;
86
+ /** Resolved attribute name, e.g. `commonName`; the OID when unknown. */
87
+ name: string;
88
+ value: string;
89
+ }
90
+ /**
91
+ * A parsed Distinguished Name.
92
+ *
93
+ * The named properties are a convenience view and keep the **last** value when
94
+ * an attribute repeats. {@link DirectoryName.entries} is the faithful one.
95
+ */
73
96
  interface DirectoryName {
74
97
  stateOrProvinceName?: string;
75
98
  localityName?: string;
76
99
  organizationName?: string;
100
+ /**
101
+ * OU (2.5.4.11). Note the spelling: the OID table resolves this attribute to
102
+ * `organizationalUnitName`, so this is the property that carries the value.
103
+ */
104
+ organizationalUnitName?: string;
105
+ /**
106
+ * @deprecated Misspelling of {@link DirectoryName.organizationalUnitName}.
107
+ *
108
+ * It was **never populated**. The parser keys properties by the name the OID
109
+ * table returns — `organizationalUnitName` — so every caller reading this got
110
+ * `undefined` and silently lost the OU. It is now filled with the same value,
111
+ * so existing readers start working instead of continuing to miss it.
112
+ */
77
113
  organizationUnitName?: string;
78
114
  commonName?: string;
79
115
  countryName?: string;
116
+ /**
117
+ * These three were always produced at runtime — the parser assigns whatever
118
+ * name the OID resolves to — but were missing from this interface, so
119
+ * TypeScript hid them from callers.
120
+ */
121
+ domainComponent?: string;
122
+ dnQualifier?: string;
123
+ /** The DN's own `serialNumber` attribute (2.5.4.5), not the certificate's. */
124
+ serialNumber?: string;
125
+ /** Every attribute in certificate order, repeats included. */
126
+ entries: DistinguishedNameAttribute[];
80
127
  }
81
128
  declare function readDirectoryName(buffer: Buffer, block: BlockInfo): DirectoryName;
82
129
 
@@ -158,6 +205,12 @@ interface Validity {
158
205
  notBefore: Date;
159
206
  notAfter: Date;
160
207
  }
208
+ interface AuthorityInformationAccess {
209
+ /** Where to ask for revocation status online (RFC 6960). */
210
+ ocsp?: string[];
211
+ /** Where to fetch the issuer certificate, for chain repair. */
212
+ caIssuers?: string[];
213
+ }
161
214
  interface X509KeyUsage {
162
215
  digitalSignature: boolean;
163
216
  nonRepudiation: boolean;
@@ -188,7 +241,7 @@ declare function readExtension(buffer: Buffer, block: BlockInfo): {
188
241
  oid: string;
189
242
  name: string;
190
243
  };
191
- value: string | X509KeyUsage | X509ExtKeyUsage | AuthorityKeyIdentifier | BasicConstraints | {
244
+ value: string | X509KeyUsage | X509ExtKeyUsage | AuthorityKeyIdentifier | BasicConstraints | AuthorityInformationAccess | {
192
245
  [key: string]: string[];
193
246
  };
194
247
  };
@@ -217,6 +270,12 @@ interface CertificateExtension {
217
270
  subjectAltName?: {
218
271
  [key: string]: string[];
219
272
  };
273
+ /** RFC 5280 4.2.1.13 -- where the CRL for this certificate is published. */
274
+ cRLDistributionPoints?: {
275
+ [key: string]: string[];
276
+ };
277
+ /** RFC 5280 4.2.2.1 -- OCSP responder and issuer-certificate locations. */
278
+ authorityInfoAccess?: AuthorityInformationAccess;
220
279
  }
221
280
  interface TbsCertificate {
222
281
  version: number;
@@ -268,7 +327,17 @@ declare function combine_der(certificates: Certificate[]): Certificate;
268
327
  declare function exploreAsn1(buffer: Buffer): void;
269
328
 
270
329
  type Version = string;
271
- type Name = string;
330
+ /**
331
+ * A Name is an RDNSequence, not a string.
332
+ *
333
+ * This was declared `string` while `readNameForCrl` has always returned a
334
+ * {@link DirectoryName} object — the `as TBSCertList` casts below hid the
335
+ * mismatch, so `tbsCertList.issuer` type-checked as a string while being an
336
+ * object at runtime. Correcting the declaration is a breaking *type* change and
337
+ * no behaviour change at all: callers reading `issuer` as a string were already
338
+ * getting an object.
339
+ */
340
+ type Name = DirectoryName;
272
341
  type CertificateSerialNumber = string;
273
342
  type Extensions = Record<string, unknown>;
274
343
  interface RevokedCertificate {
@@ -629,4 +698,4 @@ declare const asn1: {
629
698
  readSignatureValueBin: typeof readSignatureValueBin;
630
699
  };
631
700
 
632
- export { type AttributeTypeAndValue, type AuthorityKeyIdentifier, type BasicConstraints, type Certificate, type CertificateExtension, type CertificateInfo, type CertificateInternals, type CertificatePEM, CertificatePurpose, type CertificateRevocationList, type CertificateRevocationListInfo, type CertificateSerialNumber, type CertificateSigningRequestInfo, type ComputeDerivedKeysOptions, type CreateSelfSignCertificateOptions, type DER, type DERContentType, type DerivedKeys, type DirectoryName, type ExtensionRequest, type Extensions, type KeyObject, type Name, type Nonce, type PEM, PaddingAlgorithm, type PrivateKey, type PrivateKeyInternals, type PrivateKeyPEM, type PublicKey, type PublicKeyLength, type PublicKeyPEM, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, type RevokedCertificate, type Signature, Subject, type SubjectAltName, type SubjectOptions, type SubjectPublicKey, type SubjectPublicKeyInfo, type TBSCertList, type TbsCertificate, type Validity, type VerifyChunkSignatureOptions, type VerifyMessageChunkSignatureOptions, type Version, type X509ExtKeyUsage, type X509KeyUsage, type _VerifyStatus, _coercePrivateKey, asn1, certificateMatchesPrivateKey, clearExploreCertificateCache, coerceCertificate, coerceCertificatePem, coercePEMorDerToPrivateKey, coercePrivateKeyPem, coercePublicKeyPem, coerceRsaPublicKeyPem, combine_der, computeDerivedKeys, computePaddingFooter, convertPEMtoDER, createCertificateSigningRequest, createPrivateKeyFromNodeJSCrypto, createSelfSignedCertificate, decryptBufferWithDerivedKeys, derToPrivateKey, encryptBufferWithDerivedKeys, exploreAsn1, exploreCertificate, exploreCertificateInfo, exploreCertificateRevocationList, exploreCertificateSigningRequest, explorePrivateKey, extractPublicKeyFromCertificate, extractPublicKeyFromCertificateSync, generateKeyPair, generatePrivateKey, hexDump, identifyDERContent, identifyPemType, isCrlIssuedByCertificate, isKeyObject, makeMessageChunkSignature, makeMessageChunkSignatureWithDerivedKeys, makePrivateKeyFromPem, makePrivateKeyThumbPrint, makePseudoRandomBuffer, makeSHA1Thumbprint, pemToPrivateKey, privateDecrypt, privateDecrypt_long, privateDecrypt_native, privateKeyToPEM, publicEncrypt, publicEncrypt_long, publicEncrypt_native, publicKeyAndPrivateKeyMatches, readCertificationRequestInfo, readExtension, readNameForCrl, readTbsCertificate, reduceLength, removePadding, removeTrailingLF, rsaLengthPrivateKey, rsaLengthPublicKey, rsaLengthRsaPublicKey, split_der, toPem, toPem2, verifyCertificateChain, verifyCertificateOrClrSignature, verifyCertificateRevocationListSignature, verifyCertificateSignature, verifyChunkSignature, verifyChunkSignatureWithDerivedKeys, verifyCrlIssuedByCertificate, verifyMessageChunkSignature, verify_certificate_der_structure };
701
+ export { type AttributeTypeAndValue, type AuthorityInformationAccess, type AuthorityKeyIdentifier, type BasicConstraints, type Certificate, type CertificateExtension, type CertificateInfo, type CertificateInternals, type CertificatePEM, CertificatePurpose, type CertificateRevocationList, type CertificateRevocationListInfo, type CertificateSerialNumber, type CertificateSigningRequestInfo, type ComputeDerivedKeysOptions, type CreateSelfSignCertificateOptions, type DER, type DERContentType, type DerivedKeys, type DirectoryName, type DistinguishedNameAttribute, type ExtensionRequest, type Extensions, type KeyObject, type Name, type Nonce, type PEM, PaddingAlgorithm, type PrivateKey, type PrivateKeyInternals, type PrivateKeyPEM, type PublicKey, type PublicKeyLength, type PublicKeyPEM, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, type RevokedCertificate, type Signature, Subject, type SubjectAltName, type SubjectOptions, type SubjectPublicKey, type SubjectPublicKeyInfo, type TBSCertList, type TbsCertificate, type Validity, type VerifyChunkSignatureOptions, type VerifyMessageChunkSignatureOptions, type Version, type X509ExtKeyUsage, type X509KeyUsage, type _VerifyStatus, _coercePrivateKey, asn1, certificateMatchesPrivateKey, clearExploreCertificateCache, coerceCertificate, coerceCertificatePem, coercePEMorDerToPrivateKey, coercePrivateKeyPem, coercePublicKeyPem, coerceRsaPublicKeyPem, combine_der, computeDerivedKeys, computePaddingFooter, convertPEMtoDER, createCertificateSigningRequest, createPrivateKeyFromNodeJSCrypto, createSelfSignedCertificate, decryptBufferWithDerivedKeys, derToPrivateKey, encryptBufferWithDerivedKeys, exploreAsn1, exploreCertificate, exploreCertificateInfo, exploreCertificateRevocationList, exploreCertificateSigningRequest, explorePrivateKey, extractPublicKeyFromCertificate, extractPublicKeyFromCertificateSync, generateKeyPair, generatePrivateKey, hexDump, identifyDERContent, identifyPemType, isCrlIssuedByCertificate, isKeyObject, makeMessageChunkSignature, makeMessageChunkSignatureWithDerivedKeys, makePrivateKeyFromPem, makePrivateKeyThumbPrint, makePseudoRandomBuffer, makeSHA1Thumbprint, pemToPrivateKey, privateDecrypt, privateDecrypt_long, privateDecrypt_native, privateKeyToPEM, publicEncrypt, publicEncrypt_long, publicEncrypt_native, publicKeyAndPrivateKeyMatches, readCertificationRequestInfo, readExtension, readNameForCrl, readTbsCertificate, reduceLength, removePadding, removeTrailingLF, rsaLengthPrivateKey, rsaLengthPublicKey, rsaLengthRsaPublicKey, split_der, toPem, toPem2, verifyCertificateChain, verifyCertificateOrClrSignature, verifyCertificateRevocationListSignature, verifyCertificateSignature, verifyChunkSignature, verifyChunkSignatureWithDerivedKeys, verifyCrlIssuedByCertificate, verifyMessageChunkSignature, verify_certificate_der_structure };
package/dist/index_web.js CHANGED
@@ -46160,6 +46160,7 @@ var oid_map = {
46160
46160
  "1.3.6.1.4.1.311.10.3.1": { d: "1.3.6.1.4.1.311.10.3.1", c: "Signer of CTLs -- szOID_KP_CTL_USAGE_SIGNING" },
46161
46161
  "1.3.6.1.4.1.311.10.3.4": { d: "1.3.6.1.4.1.311.10.3.4", c: "szOID_EFS_RECOVERY (Encryption File System)" },
46162
46162
  "1.3.6.1.4.1.311.20.2.3": { d: "1.3.6.1.4.1.311.20.2.3", c: "id-on-personalData" },
46163
+ "1.3.6.1.5.5.7.1.1": { d: "authorityInfoAccess", c: "PKIX private extension", w: false },
46163
46164
  "1.3.6.1.5.5.7.3.17": { d: "1.3.6.1.5.5.7.3.17", c: "Internet Key Exchange (IKE)" },
46164
46165
  "1.3.6.1.5.5.7.3.1": { d: "serverAuth", c: "PKIX key purpose" },
46165
46166
  "1.3.6.1.5.5.7.3.2": { d: "clientAuth", c: "PKIX key purpose" },
@@ -47093,46 +47094,34 @@ init_inject_buffer();
47093
47094
  var import_node_assert3 = __toESM(require_assert(), 1);
47094
47095
  function readDirectoryName(buffer, block) {
47095
47096
  const set_blocks = readStruct(buffer, block);
47096
- const names2 = {};
47097
+ const entries = [];
47097
47098
  for (const set_block of set_blocks) {
47098
47099
  (0, import_node_assert3.default)(set_block.tag === 49);
47099
47100
  const blocks = readStruct(buffer, set_block);
47100
- (0, import_node_assert3.default)(blocks.length === 1);
47101
- (0, import_node_assert3.default)(blocks[0].tag === 48);
47102
- const sequenceBlock = readStruct(buffer, blocks[0]);
47103
- (0, import_node_assert3.default)(sequenceBlock.length === 2);
47104
- const type = readObjectIdentifier(buffer, sequenceBlock[0]);
47105
- names2[type.name] = readValue(buffer, sequenceBlock[1]);
47101
+ for (const attribute_block of blocks) {
47102
+ (0, import_node_assert3.default)(attribute_block.tag === 48);
47103
+ const sequenceBlock = readStruct(buffer, attribute_block);
47104
+ (0, import_node_assert3.default)(sequenceBlock.length === 2);
47105
+ const type = readObjectIdentifier(buffer, sequenceBlock[0]);
47106
+ const value = readValue(buffer, sequenceBlock[1]);
47107
+ entries.push({ oid: type.oid, name: type.name, value });
47108
+ }
47109
+ }
47110
+ const names2 = { entries };
47111
+ const asRecord = names2;
47112
+ for (const entry of entries) {
47113
+ asRecord[entry.name] = entry.value;
47114
+ if (entry.name === "organizationalUnitName") {
47115
+ asRecord.organizationUnitName = entry.value;
47116
+ }
47106
47117
  }
47107
47118
  return names2;
47108
47119
  }
47109
47120
 
47110
47121
  // ../node-opcua-crypto/source/crypto_explore_certificate.ts
47111
47122
  var doDebug = false;
47112
- function _readAttributeTypeAndValue(buffer, block) {
47113
- let inner_blocks = readStruct(buffer, block);
47114
- inner_blocks = readStruct(buffer, inner_blocks[0]);
47115
- const data = {
47116
- identifier: readObjectIdentifier(buffer, inner_blocks[0]).name,
47117
- value: readValue(buffer, inner_blocks[1])
47118
- };
47119
- const result = {};
47120
- for (const [key, value] of Object.entries(data)) {
47121
- result[key] = value;
47122
- }
47123
- return result;
47124
- }
47125
- function _readRelativeDistinguishedName(buffer, block) {
47126
- const inner_blocks = readStruct(buffer, block);
47127
- const data = inner_blocks.map((block2) => _readAttributeTypeAndValue(buffer, block2));
47128
- const result = {};
47129
- for (const e of data) {
47130
- result[e.identifier] = e.value;
47131
- }
47132
- return result;
47133
- }
47134
47123
  function _readName(buffer, block) {
47135
- return _readRelativeDistinguishedName(buffer, block);
47124
+ return readDirectoryName(buffer, block);
47136
47125
  }
47137
47126
  function _readValidity(buffer, block) {
47138
47127
  const inner_blocks = readStruct(buffer, block);
@@ -47255,6 +47244,43 @@ function _readSubjectAltNames(buffer) {
47255
47244
  const block_info = readTag(buffer, 0);
47256
47245
  return _readGeneralNames(buffer, block_info);
47257
47246
  }
47247
+ function _readCrlDistributionPoints(buffer) {
47248
+ const result = {};
47249
+ const outer = readTag(buffer, 0);
47250
+ for (const distributionPoint of readStruct(buffer, outer)) {
47251
+ for (const member of readStruct(buffer, distributionPoint)) {
47252
+ if ((member.tag & 31) !== 0) continue;
47253
+ for (const choice of readStruct(buffer, member)) {
47254
+ if ((choice.tag & 31) !== 0) continue;
47255
+ const names2 = _readGeneralNames(buffer, choice);
47256
+ for (const key of Object.keys(names2)) {
47257
+ result[key] = (result[key] || []).concat(names2[key]);
47258
+ }
47259
+ }
47260
+ }
47261
+ }
47262
+ return result;
47263
+ }
47264
+ var OID_AD_OCSP = "1.3.6.1.5.5.7.48.1";
47265
+ var OID_AD_CA_ISSUERS = "1.3.6.1.5.5.7.48.2";
47266
+ function _readAuthorityInformationAccess(buffer) {
47267
+ const result = {};
47268
+ const outer = readTag(buffer, 0);
47269
+ for (const accessDescription of readStruct(buffer, outer)) {
47270
+ const parts = readStruct(buffer, accessDescription);
47271
+ if (parts.length < 2 || parts[0].tag !== 6 /* OBJECT_IDENTIFIER */) continue;
47272
+ const accessMethod = readObjectIdentifier(buffer, parts[0]);
47273
+ const accessLocation = parts[1];
47274
+ if ((accessLocation.tag & 31) !== 6) continue;
47275
+ const uri = buffer.subarray(accessLocation.position, accessLocation.position + accessLocation.length).toString("ascii");
47276
+ if (accessMethod.oid === OID_AD_OCSP) {
47277
+ result.ocsp = (result.ocsp || []).concat(uri);
47278
+ } else if (accessMethod.oid === OID_AD_CA_ISSUERS) {
47279
+ result.caIssuers = (result.caIssuers || []).concat(uri);
47280
+ }
47281
+ }
47282
+ return result;
47283
+ }
47258
47284
  function readKeyUsage(_oid, buffer) {
47259
47285
  const block_info = readTag(buffer, 0);
47260
47286
  let b2 = 0;
@@ -47331,6 +47357,12 @@ function readExtension(buffer, block) {
47331
47357
  case "extKeyUsage":
47332
47358
  value = readExtKeyUsage(identifier.oid, buf);
47333
47359
  break;
47360
+ case "cRLDistributionPoints":
47361
+ value = _readCrlDistributionPoints(buf);
47362
+ break;
47363
+ case "authorityInfoAccess":
47364
+ value = _readAuthorityInformationAccess(buf);
47365
+ break;
47334
47366
  case "keyUsage":
47335
47367
  value = readKeyUsage(identifier.oid, buf);
47336
47368
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-crypto-web",
3
- "version": "5.4.0",
3
+ "version": "5.5.0",
4
4
  "type": "module",
5
5
  "description": "Pre-bundled, zero-config browser build of node-opcua-crypto",
6
6
  "//why": "This package exists so node-opcua-crypto can stay lean for Node. The pre-bundled browser build inlines its polyfills (crypto-browserify, stream-browserify, ...) and weighs ~344 KB gzip - more than the entire node-opcua-crypto tarball. Shipping it there would make every Node consumer download a browser bundle they never import. Browser consumers install this package explicitly, or let node-opcua-crypto's \"browser\" export condition redirect to it (see node-opcua-crypto/browser/index.js).",
@@ -44,7 +44,7 @@
44
44
  "crypto-browserify": "^3.12.1",
45
45
  "esbuild": "^0.28.1",
46
46
  "events": "^3.3.0",
47
- "node-opcua-crypto": "^5.4.0",
47
+ "node-opcua-crypto": "^5.5.0",
48
48
  "path-browserify": "^1.0.1",
49
49
  "process": "^0.11.10",
50
50
  "stream-browserify": "^3.0.0",
@@ -66,5 +66,6 @@
66
66
  "!dist/*.d.cts",
67
67
  "LICENSE",
68
68
  "README.md"
69
- ]
69
+ ],
70
+ "gitHead": "089c1a602d34d516c64a447c66731dd0f96a7f4a"
70
71
  }