node-opcua-crypto-web 5.4.0 → 5.6.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.
- package/dist/index_web.d.ts +117 -4
- package/dist/index_web.js +1718 -622
- package/package.json +4 -3
package/dist/index_web.d.ts
CHANGED
|
@@ -26,6 +26,42 @@ type PrivateKey = {
|
|
|
26
26
|
hidden: KeyObject;
|
|
27
27
|
};
|
|
28
28
|
type PublicKey = KeyObject;
|
|
29
|
+
/**
|
|
30
|
+
* Thrown when a private key is encrypted (PKCS#8 `ENCRYPTED PRIVATE KEY`)
|
|
31
|
+
* and the caller did not supply a passphrase to decrypt it. Reading an
|
|
32
|
+
* encrypted key without a passphrase always fails closed — it never falls
|
|
33
|
+
* back to treating the key as unencrypted or skipping it.
|
|
34
|
+
*/
|
|
35
|
+
declare class PrivateKeyPassphraseRequiredError extends Error {
|
|
36
|
+
constructor(message?: string);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* PKCS#12 integrity check failed: the password is wrong, or the file has
|
|
40
|
+
* been corrupted or tampered with. Raised on a `MacData` HMAC mismatch and
|
|
41
|
+
* on a bag-decryption failure (both are the observable symptom of a wrong
|
|
42
|
+
* password; PKCS#12 does not let the two be distinguished reliably).
|
|
43
|
+
*/
|
|
44
|
+
declare class PfxIntegrityError extends Error {
|
|
45
|
+
constructor(message?: string);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The PKCS#12 file parsed and (where applicable) decrypted correctly, but
|
|
49
|
+
* is not a bundle this API can represent — for example it carries no
|
|
50
|
+
* private key, or no certificate. Distinct from {@link PfxIntegrityError}:
|
|
51
|
+
* the password was fine; the content is what is missing or malformed.
|
|
52
|
+
*/
|
|
53
|
+
declare class PfxMalformedError extends Error {
|
|
54
|
+
constructor(message: string);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The PKCS#12 file uses an encryption or digest algorithm this build does
|
|
58
|
+
* not implement (for example the legacy RC2-40 PBE scheme, which neither
|
|
59
|
+
* WebCrypto nor a default Node build exposes). Not a data error — the file
|
|
60
|
+
* may be perfectly valid; it just needs a capability this code lacks.
|
|
61
|
+
*/
|
|
62
|
+
declare class Pkcs12UnsupportedAlgorithmError extends Error {
|
|
63
|
+
constructor(message: string);
|
|
64
|
+
}
|
|
29
65
|
type Nonce = Buffer;
|
|
30
66
|
type PEM = string;
|
|
31
67
|
type DER = Buffer;
|
|
@@ -70,13 +106,60 @@ declare function isCrlIssuedByCertificate(crl: CertificateRevocationList, certif
|
|
|
70
106
|
*/
|
|
71
107
|
declare function verifyCrlIssuedByCertificate(crl: CertificateRevocationList, certificate: Certificate): boolean;
|
|
72
108
|
|
|
109
|
+
/**
|
|
110
|
+
* One attribute of a Distinguished Name, as it appears in the certificate.
|
|
111
|
+
*
|
|
112
|
+
* Kept as an ordered list alongside the convenience map because a DN is a
|
|
113
|
+
* *sequence*, not a record: an attribute may legitimately repeat (two `OU`s,
|
|
114
|
+
* several `DC`s), and both the repetition and the order carry meaning. Callers
|
|
115
|
+
* that must reproduce a DN faithfully — OPC UA Part 18 §4.4.3 Table 10
|
|
116
|
+
* `X509Subject` role criteria, for instance — cannot do so from the map alone,
|
|
117
|
+
* because the map keeps only the last value for a repeated attribute.
|
|
118
|
+
*/
|
|
119
|
+
interface DistinguishedNameAttribute {
|
|
120
|
+
/** Dotted OID, e.g. `2.5.4.3`. */
|
|
121
|
+
oid: string;
|
|
122
|
+
/** Resolved attribute name, e.g. `commonName`; the OID when unknown. */
|
|
123
|
+
name: string;
|
|
124
|
+
value: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A parsed Distinguished Name.
|
|
128
|
+
*
|
|
129
|
+
* The named properties are a convenience view and keep the **last** value when
|
|
130
|
+
* an attribute repeats. {@link DirectoryName.entries} is the faithful one.
|
|
131
|
+
*/
|
|
73
132
|
interface DirectoryName {
|
|
74
133
|
stateOrProvinceName?: string;
|
|
75
134
|
localityName?: string;
|
|
76
135
|
organizationName?: string;
|
|
136
|
+
/**
|
|
137
|
+
* OU (2.5.4.11). Note the spelling: the OID table resolves this attribute to
|
|
138
|
+
* `organizationalUnitName`, so this is the property that carries the value.
|
|
139
|
+
*/
|
|
140
|
+
organizationalUnitName?: string;
|
|
141
|
+
/**
|
|
142
|
+
* @deprecated Misspelling of {@link DirectoryName.organizationalUnitName}.
|
|
143
|
+
*
|
|
144
|
+
* It was **never populated**. The parser keys properties by the name the OID
|
|
145
|
+
* table returns — `organizationalUnitName` — so every caller reading this got
|
|
146
|
+
* `undefined` and silently lost the OU. It is now filled with the same value,
|
|
147
|
+
* so existing readers start working instead of continuing to miss it.
|
|
148
|
+
*/
|
|
77
149
|
organizationUnitName?: string;
|
|
78
150
|
commonName?: string;
|
|
79
151
|
countryName?: string;
|
|
152
|
+
/**
|
|
153
|
+
* These three were always produced at runtime — the parser assigns whatever
|
|
154
|
+
* name the OID resolves to — but were missing from this interface, so
|
|
155
|
+
* TypeScript hid them from callers.
|
|
156
|
+
*/
|
|
157
|
+
domainComponent?: string;
|
|
158
|
+
dnQualifier?: string;
|
|
159
|
+
/** The DN's own `serialNumber` attribute (2.5.4.5), not the certificate's. */
|
|
160
|
+
serialNumber?: string;
|
|
161
|
+
/** Every attribute in certificate order, repeats included. */
|
|
162
|
+
entries: DistinguishedNameAttribute[];
|
|
80
163
|
}
|
|
81
164
|
declare function readDirectoryName(buffer: Buffer, block: BlockInfo): DirectoryName;
|
|
82
165
|
|
|
@@ -158,6 +241,12 @@ interface Validity {
|
|
|
158
241
|
notBefore: Date;
|
|
159
242
|
notAfter: Date;
|
|
160
243
|
}
|
|
244
|
+
interface AuthorityInformationAccess {
|
|
245
|
+
/** Where to ask for revocation status online (RFC 6960). */
|
|
246
|
+
ocsp?: string[];
|
|
247
|
+
/** Where to fetch the issuer certificate, for chain repair. */
|
|
248
|
+
caIssuers?: string[];
|
|
249
|
+
}
|
|
161
250
|
interface X509KeyUsage {
|
|
162
251
|
digitalSignature: boolean;
|
|
163
252
|
nonRepudiation: boolean;
|
|
@@ -188,7 +277,7 @@ declare function readExtension(buffer: Buffer, block: BlockInfo): {
|
|
|
188
277
|
oid: string;
|
|
189
278
|
name: string;
|
|
190
279
|
};
|
|
191
|
-
value: string | X509KeyUsage | X509ExtKeyUsage | AuthorityKeyIdentifier | BasicConstraints | {
|
|
280
|
+
value: string | X509KeyUsage | X509ExtKeyUsage | AuthorityKeyIdentifier | BasicConstraints | AuthorityInformationAccess | {
|
|
192
281
|
[key: string]: string[];
|
|
193
282
|
};
|
|
194
283
|
};
|
|
@@ -217,6 +306,12 @@ interface CertificateExtension {
|
|
|
217
306
|
subjectAltName?: {
|
|
218
307
|
[key: string]: string[];
|
|
219
308
|
};
|
|
309
|
+
/** RFC 5280 4.2.1.13 -- where the CRL for this certificate is published. */
|
|
310
|
+
cRLDistributionPoints?: {
|
|
311
|
+
[key: string]: string[];
|
|
312
|
+
};
|
|
313
|
+
/** RFC 5280 4.2.2.1 -- OCSP responder and issuer-certificate locations. */
|
|
314
|
+
authorityInfoAccess?: AuthorityInformationAccess;
|
|
220
315
|
}
|
|
221
316
|
interface TbsCertificate {
|
|
222
317
|
version: number;
|
|
@@ -268,7 +363,17 @@ declare function combine_der(certificates: Certificate[]): Certificate;
|
|
|
268
363
|
declare function exploreAsn1(buffer: Buffer): void;
|
|
269
364
|
|
|
270
365
|
type Version = string;
|
|
271
|
-
|
|
366
|
+
/**
|
|
367
|
+
* A Name is an RDNSequence, not a string.
|
|
368
|
+
*
|
|
369
|
+
* This was declared `string` while `readNameForCrl` has always returned a
|
|
370
|
+
* {@link DirectoryName} object — the `as TBSCertList` casts below hid the
|
|
371
|
+
* mismatch, so `tbsCertList.issuer` type-checked as a string while being an
|
|
372
|
+
* object at runtime. Correcting the declaration is a breaking *type* change and
|
|
373
|
+
* no behaviour change at all: callers reading `issuer` as a string were already
|
|
374
|
+
* getting an object.
|
|
375
|
+
*/
|
|
376
|
+
type Name = DirectoryName;
|
|
272
377
|
type CertificateSerialNumber = string;
|
|
273
378
|
type Extensions = Record<string, unknown>;
|
|
274
379
|
interface RevokedCertificate {
|
|
@@ -400,7 +505,15 @@ declare function verifyCertificateChain(certificateChain: Certificate[]): Promis
|
|
|
400
505
|
reason: string;
|
|
401
506
|
}>;
|
|
402
507
|
|
|
403
|
-
|
|
508
|
+
/**
|
|
509
|
+
* @param privateKeyInDerOrPem
|
|
510
|
+
* @param passphrase — required if the PEM is an encrypted PKCS#8 key
|
|
511
|
+
* (`-----BEGIN ENCRYPTED PRIVATE KEY-----`). Throws
|
|
512
|
+
* {@link PrivateKeyPassphraseRequiredError} if the key is encrypted and
|
|
513
|
+
* no passphrase is supplied. Unencrypted input is unaffected by this
|
|
514
|
+
* parameter.
|
|
515
|
+
*/
|
|
516
|
+
declare function coercePEMorDerToPrivateKey(privateKeyInDerOrPem: string | Buffer, passphrase?: string | Buffer): PrivateKey;
|
|
404
517
|
/**
|
|
405
518
|
*
|
|
406
519
|
* @private
|
|
@@ -629,4 +742,4 @@ declare const asn1: {
|
|
|
629
742
|
readSignatureValueBin: typeof readSignatureValueBin;
|
|
630
743
|
};
|
|
631
744
|
|
|
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 };
|
|
745
|
+
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 KeyExportOptions, type KeyObject, type Name, type Nonce, type PEM, PaddingAlgorithm, PfxIntegrityError, PfxMalformedError, Pkcs12UnsupportedAlgorithmError, type PrivateKey, type PrivateKeyInternals, type PrivateKeyPEM, PrivateKeyPassphraseRequiredError, 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 };
|