node-opcua-crypto-web 5.9.0 → 5.11.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 +276 -65
- package/dist/index_web.js +191 -7
- package/package.json +3 -3
package/dist/index_web.d.ts
CHANGED
|
@@ -429,6 +429,26 @@ interface PrivateKeyInternals {
|
|
|
429
429
|
exponent1: Buffer;
|
|
430
430
|
exponent2: Buffer;
|
|
431
431
|
}
|
|
432
|
+
interface ECPrivateKeyInternals {
|
|
433
|
+
version: Buffer;
|
|
434
|
+
/** the curve name, e.g. "prime256v1", resolved from the SEC1 ECParameters OID */
|
|
435
|
+
namedCurve: string;
|
|
436
|
+
/** the private scalar "d" */
|
|
437
|
+
privateKey: Buffer;
|
|
438
|
+
/** the uncompressed public point, when present in the key */
|
|
439
|
+
publicKey?: Buffer;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* explore the internal structure of an EC (SEC1) private key.
|
|
443
|
+
*
|
|
444
|
+
* ECPrivateKey ::= SEQUENCE {
|
|
445
|
+
* version INTEGER { ecPrivKeyVer1(1) },
|
|
446
|
+
* privateKey OCTET STRING,
|
|
447
|
+
* parameters [0] ECParameters {{ NamedCurve }} OPTIONAL,
|
|
448
|
+
* publicKey [1] BIT STRING OPTIONAL
|
|
449
|
+
* }
|
|
450
|
+
*/
|
|
451
|
+
declare function exploreEcPrivateKey(privateKey2: PrivateKey): ECPrivateKeyInternals;
|
|
432
452
|
/**
|
|
433
453
|
*
|
|
434
454
|
* @param privateKey RSAPrivateKey ::= SEQUENCE {
|
|
@@ -471,69 +491,6 @@ type DERContentType = "X509Certificate" | "X509CertificateChain" | "CertificateR
|
|
|
471
491
|
*/
|
|
472
492
|
declare function identifyDERContent(buffer: Buffer): DERContentType;
|
|
473
493
|
|
|
474
|
-
interface SubjectOptions {
|
|
475
|
-
commonName?: string;
|
|
476
|
-
organization?: string;
|
|
477
|
-
organizationalUnit?: string;
|
|
478
|
-
locality?: string;
|
|
479
|
-
state?: string;
|
|
480
|
-
country?: string;
|
|
481
|
-
domainComponent?: string;
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* subjectName The subject name to use for the Certificate.
|
|
485
|
-
* If not specified the ApplicationName and/or domainNames are used to create a suitable default value.
|
|
486
|
-
*/
|
|
487
|
-
declare class Subject implements SubjectOptions {
|
|
488
|
-
readonly commonName?: string;
|
|
489
|
-
readonly organization?: string;
|
|
490
|
-
readonly organizationalUnit?: string;
|
|
491
|
-
readonly locality?: string;
|
|
492
|
-
readonly state?: string;
|
|
493
|
-
readonly country?: string;
|
|
494
|
-
readonly domainComponent?: string;
|
|
495
|
-
constructor(options: SubjectOptions | string);
|
|
496
|
-
static parse(str: string): SubjectOptions;
|
|
497
|
-
toStringInternal(sep: string): string;
|
|
498
|
-
toStringForOPCUA(): string;
|
|
499
|
-
toString(): string;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
declare function verifyCertificateOrClrSignature(certificateOrCrl: Buffer, parentCertificate: Certificate): boolean;
|
|
503
|
-
declare function verifyCertificateSignature(certificate: Certificate, parentCertificate: Certificate): boolean;
|
|
504
|
-
declare function verifyCertificateRevocationListSignature(certificateRevocationList: Certificate, parentCertificate: Certificate): boolean;
|
|
505
|
-
type _VerifyStatus = "BadCertificateIssuerUseNotAllowed" | "BadCertificateInvalid" | "Good";
|
|
506
|
-
declare function verifyCertificateChain(certificateChain: Certificate[]): Promise<{
|
|
507
|
-
status: _VerifyStatus;
|
|
508
|
-
reason: string;
|
|
509
|
-
}>;
|
|
510
|
-
|
|
511
|
-
declare function getCrypto(): Crypto$1 | typeof __crypto;
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* Authority Key Identifier extension identifying the issuer by its public
|
|
515
|
-
* key (`keyid`), matching what {@link createSelfSignedCertificate} already
|
|
516
|
-
* does for the self-signed case, and what openssl's
|
|
517
|
-
* `authorityKeyIdentifier = keyid:always` produces for the issued case.
|
|
518
|
-
*/
|
|
519
|
-
declare function buildAuthorityKeyIdentifierFromIssuer(issuerPublicKey: PublicKeyType, crypto?: Crypto): Promise<x509.AuthorityKeyIdentifierExtension>;
|
|
520
|
-
/** Opt-in CRL Distribution Point / Authority Info Access URLs for a certificate. */
|
|
521
|
-
interface RevocationExtensionsParams {
|
|
522
|
-
crlDistributionUrl?: string;
|
|
523
|
-
ocspResponderUrl?: string;
|
|
524
|
-
caIssuersUrl?: string;
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Builds the CDP (`crlDistributionUrl`) and AIA (`ocspResponderUrl` /
|
|
528
|
-
* `caIssuersUrl`) extensions for a certificate, mirroring the
|
|
529
|
-
* `$ENV::CDP_URL` / `$ENV::AIA_VALUE` opt-in extensions the openssl-backed
|
|
530
|
-
* CA templates emit. Each extension is included only when at least one of
|
|
531
|
-
* its values is set.
|
|
532
|
-
*/
|
|
533
|
-
declare function buildRevocationExtensions(params: RevocationExtensionsParams): x509.Extension[];
|
|
534
|
-
/** The CRL Number extension (RFC 5280 §5.2.3), a plain monotonically-increasing counter. */
|
|
535
|
-
declare function buildCrlNumberExtension(crlNumber: number | bigint): x509.Extension;
|
|
536
|
-
|
|
537
494
|
/**
|
|
538
495
|
* The signing algorithm a {@link CaSigner} operates under. This travels with
|
|
539
496
|
* the signer rather than being inferred from a key, because an HSM/KMS-backed
|
|
@@ -711,6 +668,230 @@ interface ResolvedCaKeyPair {
|
|
|
711
668
|
*/
|
|
712
669
|
declare function resolveCaKeyPair(key: CryptoKey | CaSigner, baseCrypto?: Pick<Crypto, "subtle" | "getRandomValues">): Promise<ResolvedCaKeyPair>;
|
|
713
670
|
|
|
671
|
+
/**
|
|
672
|
+
* The signature scheme an {@link IKeyOperations.sign} call operates under.
|
|
673
|
+
*
|
|
674
|
+
* These are the schemes the OPC UA security policies need — PKCS#1 v1.5 for
|
|
675
|
+
* Basic128Rsa15 through Aes128_Sha256_RsaOaep, PSS for Aes256_Sha256_RsaPss —
|
|
676
|
+
* expressed as parameters rather than OPC UA algorithm URIs so this layer
|
|
677
|
+
* stays policy-agnostic. The mapping from a security policy to its parameters
|
|
678
|
+
* belongs to the caller.
|
|
679
|
+
*
|
|
680
|
+
* For `"RSA-PSS"` the salt length is fixed to the digest length
|
|
681
|
+
* (`RSA_PSS_SALTLEN_DIGEST`), which is what the OPC UA Aes256_Sha256_RsaPss
|
|
682
|
+
* profile — and WebCrypto's `saltLength: 32` convention for SHA-256 —
|
|
683
|
+
* expects. A remote signer whose backend salts differently (e.g. maximum
|
|
684
|
+
* salt) produces signatures peers cannot verify.
|
|
685
|
+
*/
|
|
686
|
+
interface AsymmetricSignParams {
|
|
687
|
+
padding: "RSA-PKCS1-v1_5" | "RSA-PSS";
|
|
688
|
+
hash: "SHA-1" | "SHA-256";
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* The decryption scheme an {@link IKeyOperations.decryptBlock} call operates
|
|
692
|
+
* under. `oaepHash` is required when `padding` is `"RSA-OAEP"` and names the
|
|
693
|
+
* hash used for both the OAEP digest and MGF1.
|
|
694
|
+
*/
|
|
695
|
+
interface AsymmetricDecryptParams {
|
|
696
|
+
padding: "RSA-PKCS1-v1_5" | "RSA-OAEP";
|
|
697
|
+
oaepHash?: "SHA-1" | "SHA-256";
|
|
698
|
+
}
|
|
699
|
+
/**
|
|
700
|
+
* The facts about a key that callers need before performing any operation
|
|
701
|
+
* with it — declared by the implementation, never inferred, because an
|
|
702
|
+
* HSM/KMS-held key exposes no material to inspect (the same reason
|
|
703
|
+
* {@link CaSignAlgorithm} travels with a {@link CaSigner}).
|
|
704
|
+
*
|
|
705
|
+
* Only RSA today. When EC security policies arrive, `keyType: "EC"` gains a
|
|
706
|
+
* `namedCurve` here and an ECDSA variant in {@link AsymmetricSignParams} —
|
|
707
|
+
* additive changes, not a second interface.
|
|
708
|
+
*/
|
|
709
|
+
interface KeyMetadata {
|
|
710
|
+
keyType: "RSA";
|
|
711
|
+
/**
|
|
712
|
+
* The RSA modulus size in **bytes** (256 for a 2048-bit key). For RSA
|
|
713
|
+
* this single number is also the signature length under both paddings
|
|
714
|
+
* and the cipher block size for {@link IKeyOperations.decryptBlock}.
|
|
715
|
+
*/
|
|
716
|
+
modulusLength: number;
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* Opaque private-key operations: an object that can use a private key —
|
|
720
|
+
* sign, decrypt — without the key ever being obtainable through it.
|
|
721
|
+
*
|
|
722
|
+
* This is the secure-channel/session-side sibling of {@link CaSigner}
|
|
723
|
+
* (which covers X509 issuance and is sign-only): shaped after cloud
|
|
724
|
+
* KMS/HSM APIs, so the OPC UA application instance key can live in a TPM,
|
|
725
|
+
* HSM, KMS or OS keystore, non-exportable, while node-opcua drives it
|
|
726
|
+
* through this interface. Implementations wrap a local in-process key, a
|
|
727
|
+
* PKCS#11 token, a cloud KMS client — the caller cannot tell the
|
|
728
|
+
* difference, and this interface never asks for the key itself.
|
|
729
|
+
*
|
|
730
|
+
* The three required methods are asynchronous, because a remote key is.
|
|
731
|
+
* The optional `*Sync` trio is the fast path a local-key implementation
|
|
732
|
+
* provides so that code paths which are synchronous by contract (OPC UA
|
|
733
|
+
* chunk assembly) keep working unchanged with local keys; remote
|
|
734
|
+
* implementations simply omit them, and callers choose a path via
|
|
735
|
+
* {@link hasSyncKeyOperations}.
|
|
736
|
+
*/
|
|
737
|
+
interface IKeyOperations {
|
|
738
|
+
/** Sign `data` and return the signature (`modulusLength` bytes for RSA). */
|
|
739
|
+
sign(data: Uint8Array, params: AsymmetricSignParams): Promise<Buffer>;
|
|
740
|
+
/**
|
|
741
|
+
* Decrypt exactly ONE cipher block — `block.length` must equal
|
|
742
|
+
* {@link KeyMetadata.modulusLength} — and return the plaintext.
|
|
743
|
+
*
|
|
744
|
+
* One call is one HSM/KMS operation by design: callers own the
|
|
745
|
+
* multi-block loop (and may issue blocks concurrently), so a provider
|
|
746
|
+
* never has to reimplement it and round trips stay visible.
|
|
747
|
+
*/
|
|
748
|
+
decryptBlock(block: Uint8Array, params: AsymmetricDecryptParams): Promise<Buffer>;
|
|
749
|
+
/** The declared key facts. Stable for the lifetime of the object. */
|
|
750
|
+
getKeyMetadata(): Promise<KeyMetadata>;
|
|
751
|
+
/**
|
|
752
|
+
* The public half of the key, SPKI-encoded DER.
|
|
753
|
+
*
|
|
754
|
+
* Optional, but strongly recommended: certificate/key match checks and
|
|
755
|
+
* CSR generation over an opaque key both need it, and are unavailable
|
|
756
|
+
* (with a clear error) without it.
|
|
757
|
+
*/
|
|
758
|
+
getPublicKey?(): Promise<ArrayBuffer>;
|
|
759
|
+
/** Synchronous {@link sign}. Local keys only; remote providers omit it. */
|
|
760
|
+
signSync?(data: Uint8Array, params: AsymmetricSignParams): Buffer;
|
|
761
|
+
/** Synchronous {@link decryptBlock}. Local keys only. */
|
|
762
|
+
decryptBlockSync?(block: Uint8Array, params: AsymmetricDecryptParams): Buffer;
|
|
763
|
+
/** Synchronous {@link getKeyMetadata}. Local keys only. */
|
|
764
|
+
getKeyMetadataSync?(): KeyMetadata;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* True when `value` implements {@link IKeyOperations} — the three required
|
|
768
|
+
* methods are present — as opposed to being raw key material (a `PrivateKey`
|
|
769
|
+
* envelope, a `CryptoKey`, a PEM string), none of which carry methods.
|
|
770
|
+
*/
|
|
771
|
+
declare function isKeyOperations(value: unknown): value is IKeyOperations;
|
|
772
|
+
/**
|
|
773
|
+
* True when `ops` provides the complete synchronous fast path, so a caller
|
|
774
|
+
* on a synchronous code path can use it without ever awaiting. All three
|
|
775
|
+
* methods are required together — a partial sync surface would force
|
|
776
|
+
* callers to mix paths mid-operation.
|
|
777
|
+
*/
|
|
778
|
+
declare function hasSyncKeyOperations(ops: IKeyOperations): boolean;
|
|
779
|
+
/**
|
|
780
|
+
* Thrown by `getPrivateKey()`-style accessors when the key is opaque —
|
|
781
|
+
* held by an {@link IKeyOperations} implementation (HSM/KMS) and therefore
|
|
782
|
+
* deliberately not obtainable as material. Catching this specific error is
|
|
783
|
+
* how callers distinguish "the key exists but cannot be read" from "no key
|
|
784
|
+
* is configured".
|
|
785
|
+
*/
|
|
786
|
+
declare class PrivateKeyUnavailableError extends Error {
|
|
787
|
+
constructor(message?: string);
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
/**
|
|
791
|
+
* Expose an {@link IKeyOperations} as a {@link CaSigner}, so ONE HSM/KMS
|
|
792
|
+
* integration serves both worlds: the secure-channel/session operations
|
|
793
|
+
* (native shape) and X509 issuance — CSR, self-signed certificate, CRL —
|
|
794
|
+
* through the existing `CaSigner`-accepting primitives. The concrete use
|
|
795
|
+
* case is an OPC UA application whose instance key is opaque and that must
|
|
796
|
+
* still renew its certificate: a CSR over the existing key, signed through
|
|
797
|
+
* this adapter.
|
|
798
|
+
*
|
|
799
|
+
* RSASSA-PKCS1-v1_5 only — the signature scheme X509 issuance uses here —
|
|
800
|
+
* and SHA-256 only, {@link AsymmetricSignParams} not going higher today;
|
|
801
|
+
* the `hash` parameter exists so a future widening is additive.
|
|
802
|
+
*
|
|
803
|
+
* Requires {@link IKeyOperations.getPublicKey}: a `CaSigner` must produce
|
|
804
|
+
* its public half (a CSR embeds it, an issued certificate's AKI derives
|
|
805
|
+
* from it), and with an opaque key there is nowhere else it can come from.
|
|
806
|
+
*/
|
|
807
|
+
declare function caSignerFromKeyOperations(ops: IKeyOperations, hash?: "SHA-256"): CaSigner;
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* Decrypt a multi-block ciphertext through an {@link IKeyOperations}.
|
|
811
|
+
*
|
|
812
|
+
* This is THE multi-block loop, shipped once so providers never reimplement
|
|
813
|
+
* it and only ever see one block per call — one call, one HSM/KMS operation.
|
|
814
|
+
* Blocks are decrypted concurrently (a remote provider's round trips
|
|
815
|
+
* overlap) and reassembled in order. `blockSize` is the cipher block size,
|
|
816
|
+
* i.e. {@link KeyMetadata.modulusLength}; the buffer must be a whole number
|
|
817
|
+
* of blocks — a partial trailing block is a framing error upstream and is
|
|
818
|
+
* rejected rather than papered over.
|
|
819
|
+
*
|
|
820
|
+
* A block that fails to decrypt rejects the whole call; the caller decides
|
|
821
|
+
* whether that surfaces or degrades (see {@link LocalKeyOperations} on
|
|
822
|
+
* anti-oracle behavior).
|
|
823
|
+
*/
|
|
824
|
+
declare function decryptLong(ops: IKeyOperations, buffer: Uint8Array, params: AsymmetricDecryptParams, blockSize: number): Promise<Buffer>;
|
|
825
|
+
/**
|
|
826
|
+
* Synchronous {@link decryptLong}, for callers that are synchronous by
|
|
827
|
+
* contract. Requires the sync fast path — check {@link hasSyncKeyOperations}
|
|
828
|
+
* first; an async-only provider is rejected with a clear error.
|
|
829
|
+
*/
|
|
830
|
+
declare function decryptLongSync(ops: IKeyOperations, buffer: Uint8Array, params: AsymmetricDecryptParams, blockSize: number): Buffer;
|
|
831
|
+
|
|
832
|
+
interface SubjectOptions {
|
|
833
|
+
commonName?: string;
|
|
834
|
+
organization?: string;
|
|
835
|
+
organizationalUnit?: string;
|
|
836
|
+
locality?: string;
|
|
837
|
+
state?: string;
|
|
838
|
+
country?: string;
|
|
839
|
+
domainComponent?: string;
|
|
840
|
+
}
|
|
841
|
+
/**
|
|
842
|
+
* subjectName The subject name to use for the Certificate.
|
|
843
|
+
* If not specified the ApplicationName and/or domainNames are used to create a suitable default value.
|
|
844
|
+
*/
|
|
845
|
+
declare class Subject implements SubjectOptions {
|
|
846
|
+
readonly commonName?: string;
|
|
847
|
+
readonly organization?: string;
|
|
848
|
+
readonly organizationalUnit?: string;
|
|
849
|
+
readonly locality?: string;
|
|
850
|
+
readonly state?: string;
|
|
851
|
+
readonly country?: string;
|
|
852
|
+
readonly domainComponent?: string;
|
|
853
|
+
constructor(options: SubjectOptions | string);
|
|
854
|
+
static parse(str: string): SubjectOptions;
|
|
855
|
+
toStringInternal(sep: string): string;
|
|
856
|
+
toStringForOPCUA(): string;
|
|
857
|
+
toString(): string;
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
declare function verifyCertificateOrClrSignature(certificateOrCrl: Buffer, parentCertificate: Certificate): boolean;
|
|
861
|
+
declare function verifyCertificateSignature(certificate: Certificate, parentCertificate: Certificate): boolean;
|
|
862
|
+
declare function verifyCertificateRevocationListSignature(certificateRevocationList: Certificate, parentCertificate: Certificate): boolean;
|
|
863
|
+
type _VerifyStatus = "BadCertificateIssuerUseNotAllowed" | "BadCertificateInvalid" | "Good";
|
|
864
|
+
declare function verifyCertificateChain(certificateChain: Certificate[]): Promise<{
|
|
865
|
+
status: _VerifyStatus;
|
|
866
|
+
reason: string;
|
|
867
|
+
}>;
|
|
868
|
+
|
|
869
|
+
declare function getCrypto(): Crypto$1 | typeof __crypto;
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Authority Key Identifier extension identifying the issuer by its public
|
|
873
|
+
* key (`keyid`), matching what {@link createSelfSignedCertificate} already
|
|
874
|
+
* does for the self-signed case, and what openssl's
|
|
875
|
+
* `authorityKeyIdentifier = keyid:always` produces for the issued case.
|
|
876
|
+
*/
|
|
877
|
+
declare function buildAuthorityKeyIdentifierFromIssuer(issuerPublicKey: PublicKeyType, crypto?: Crypto): Promise<x509.AuthorityKeyIdentifierExtension>;
|
|
878
|
+
/** Opt-in CRL Distribution Point / Authority Info Access URLs for a certificate. */
|
|
879
|
+
interface RevocationExtensionsParams {
|
|
880
|
+
crlDistributionUrl?: string;
|
|
881
|
+
ocspResponderUrl?: string;
|
|
882
|
+
caIssuersUrl?: string;
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* Builds the CDP (`crlDistributionUrl`) and AIA (`ocspResponderUrl` /
|
|
886
|
+
* `caIssuersUrl`) extensions for a certificate, mirroring the
|
|
887
|
+
* `$ENV::CDP_URL` / `$ENV::AIA_VALUE` opt-in extensions the openssl-backed
|
|
888
|
+
* CA templates emit. Each extension is included only when at least one of
|
|
889
|
+
* its values is set.
|
|
890
|
+
*/
|
|
891
|
+
declare function buildRevocationExtensions(params: RevocationExtensionsParams): x509.Extension[];
|
|
892
|
+
/** The CRL Number extension (RFC 5280 §5.2.3), a plain monotonically-increasing counter. */
|
|
893
|
+
declare function buildCrlNumberExtension(crlNumber: number | bigint): x509.Extension;
|
|
894
|
+
|
|
714
895
|
/**
|
|
715
896
|
* @param privateKeyInDerOrPem
|
|
716
897
|
* @param passphrase — required if the PEM is an encrypted PKCS#8 key
|
|
@@ -841,7 +1022,8 @@ declare function derToPrivateKey(privDer: ArrayBuffer): Promise<CryptoKey>;
|
|
|
841
1022
|
declare function pemToPrivateKey(pem: string): Promise<CryptoKey>;
|
|
842
1023
|
|
|
843
1024
|
interface CreateSelfSignCertificateOptions {
|
|
844
|
-
|
|
1025
|
+
/** The key that signs the certificate and whose public half it carries — a raw key, or an HSM/KMS-backed {@link CaSigner}. */
|
|
1026
|
+
privateKey: CryptoKey | CaSigner;
|
|
845
1027
|
notBefore?: Date;
|
|
846
1028
|
notAfter?: Date;
|
|
847
1029
|
validity?: number;
|
|
@@ -1025,6 +1207,35 @@ declare function makeMessageChunkSignatureWithDerivedKeys(message: Buffer, deriv
|
|
|
1025
1207
|
*/
|
|
1026
1208
|
declare function verifyChunkSignatureWithDerivedKeys(chunk: Buffer, derivedKeys: DerivedKeys): boolean;
|
|
1027
1209
|
|
|
1210
|
+
/**
|
|
1211
|
+
* Adapts an in-process private key — the {@link PrivateKey} envelope — to
|
|
1212
|
+
* {@link IKeyOperations}, sync fast path included, so callers only ever deal
|
|
1213
|
+
* with one key shape whether the key lives in memory or in an HSM.
|
|
1214
|
+
*
|
|
1215
|
+
* This class is intended to be the ONE place that dereferences
|
|
1216
|
+
* `privateKey.hidden`; everything above it should hold an
|
|
1217
|
+
* {@link IKeyOperations} and stay ignorant of key material.
|
|
1218
|
+
*
|
|
1219
|
+
* Failure behavior differs deliberately from `privateDecrypt_native`, which
|
|
1220
|
+
* swallows errors into a 1-byte buffer: {@link decryptBlock} throws, like any
|
|
1221
|
+
* remote provider would. A caller that needs the swallow-and-return-garbage
|
|
1222
|
+
* anti-oracle behavior implements it above this interface, uniformly for
|
|
1223
|
+
* local and remote keys.
|
|
1224
|
+
*/
|
|
1225
|
+
declare class LocalKeyOperations implements IKeyOperations {
|
|
1226
|
+
#private;
|
|
1227
|
+
constructor(privateKey: PrivateKey);
|
|
1228
|
+
getKeyMetadataSync(): KeyMetadata;
|
|
1229
|
+
getKeyMetadata(): Promise<KeyMetadata>;
|
|
1230
|
+
getPublicKey(): Promise<ArrayBuffer>;
|
|
1231
|
+
signSync(data: Uint8Array, params: AsymmetricSignParams): Buffer;
|
|
1232
|
+
sign(data: Uint8Array, params: AsymmetricSignParams): Promise<Buffer>;
|
|
1233
|
+
decryptBlockSync(block: Uint8Array, params: AsymmetricDecryptParams): Buffer;
|
|
1234
|
+
decryptBlock(block: Uint8Array, params: AsymmetricDecryptParams): Promise<Buffer>;
|
|
1235
|
+
}
|
|
1236
|
+
/** Wraps a {@link PrivateKey} envelope as {@link IKeyOperations}. */
|
|
1237
|
+
declare function keyOperationsFromPrivateKey(privateKey: PrivateKey): LocalKeyOperations;
|
|
1238
|
+
|
|
1028
1239
|
declare function makePrivateKeyFromPem(privateKeyInPem: string): PrivateKey;
|
|
1029
1240
|
|
|
1030
1241
|
declare function makePrivateKeyThumbPrint(_privateKey: PrivateKey): Buffer;
|
|
@@ -1040,4 +1251,4 @@ declare const asn1: {
|
|
|
1040
1251
|
readSignatureValueBin: typeof readSignatureValueBin;
|
|
1041
1252
|
};
|
|
1042
1253
|
|
|
1043
|
-
export { type AttributeTypeAndValue, type AuthorityInformationAccess, type AuthorityKeyIdentifier, type BasicConstraints, type CaSignAlgorithm, type CaSigner, type Certificate, type CertificateExtension, type CertificateInfo, type CertificateInternals, type CertificatePEM, CertificatePurpose, type CertificateRevocationList, type CertificateRevocationListInfo, type CertificateSerialNumber, type CertificateSigningRequestInfo, type ComputeDerivedKeysOptions, type CreateCertificateFromCsrOptions, type CreateCrlEntryOptions, type CreateCrlOptions, type CreateSelfSignCertificateOptions, type DER, type DERContentType, type DerivedKeys, type DirectoryName, type DistinguishedNameAttribute, type ExtensionRequest, type Extensions, type KeyExportOptions, type KeyObject, LocalPrivateKeySigner, 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 ResolvedCaKeyPair, type ResolvedCaSigningKey, type RevocationExtensionsParams, 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 WebCryptoFromSigner, type X509ExtKeyUsage, type X509KeyUsage, type _VerifyStatus, _coercePrivateKey, asn1, buildAuthorityKeyIdentifierFromIssuer, buildCrlNumberExtension, buildRevocationExtensions, certificateMatchesPrivateKey, clearExploreCertificateCache, coerceCertificate, coerceCertificatePem, coercePEMorDerToPrivateKey, coercePrivateKeyPem, coercePublicKeyPem, coerceRsaPublicKeyPem, combine_der, computeDerivedKeys, computePaddingFooter, convertPEMtoDER, createCertificateFromCsr, createCertificateSigningRequest, createCrl, createPrivateKeyFromNodeJSCrypto, createSelfSignedCertificate, decryptBufferWithDerivedKeys, derToPrivateKey, ecdsaSignatureDerToP1363, encryptBufferWithDerivedKeys, exploreAsn1, exploreCertificate, exploreCertificateInfo, exploreCertificateRevocationList, exploreCertificateSigningRequest, explorePrivateKey, extractPublicKeyFromCertificate, extractPublicKeyFromCertificateSync, generateKeyPair, generatePrivateKey, getCrypto, hexDump, identifyDERContent, identifyPemType, isCaSigner, isCrlIssuedByCertificate, isKeyObject, makeMessageChunkSignature, makeMessageChunkSignatureWithDerivedKeys, makePrivateKeyFromPem, makePrivateKeyThumbPrint, makePseudoRandomBuffer, makeSHA1Thumbprint, pemToPrivateKey, privateDecrypt, privateDecrypt_long, privateDecrypt_native, privateKeyToCryptoKey, privateKeyToPEM, publicEncrypt, publicEncrypt_long, publicEncrypt_native, publicKeyAndPrivateKeyMatches, readCertificationRequestInfo, readExtension, readNameForCrl, readTbsCertificate, reduceLength, removePadding, removeTrailingLF, resolveCaKeyPair, resolveCaSigningKey, rsaLengthPrivateKey, rsaLengthPublicKey, rsaLengthRsaPublicKey, split_der, toPem, toPem2, verifyCertificateChain, verifyCertificateOrClrSignature, verifyCertificateRevocationListSignature, verifyCertificateSignature, verifyChunkSignature, verifyChunkSignatureWithDerivedKeys, verifyCrlIssuedByCertificate, verifyMessageChunkSignature, verify_certificate_der_structure, webCryptoFromSigner };
|
|
1254
|
+
export { type AsymmetricDecryptParams, type AsymmetricSignParams, type AttributeTypeAndValue, type AuthorityInformationAccess, type AuthorityKeyIdentifier, type BasicConstraints, type CaSignAlgorithm, type CaSigner, type Certificate, type CertificateExtension, type CertificateInfo, type CertificateInternals, type CertificatePEM, CertificatePurpose, type CertificateRevocationList, type CertificateRevocationListInfo, type CertificateSerialNumber, type CertificateSigningRequestInfo, type ComputeDerivedKeysOptions, type CreateCertificateFromCsrOptions, type CreateCrlEntryOptions, type CreateCrlOptions, type CreateSelfSignCertificateOptions, type DER, type DERContentType, type DerivedKeys, type DirectoryName, type DistinguishedNameAttribute, type ECPrivateKeyInternals, type ExtensionRequest, type Extensions, type IKeyOperations, type KeyExportOptions, type KeyMetadata, type KeyObject, LocalKeyOperations, LocalPrivateKeySigner, type Name, type Nonce, type PEM, PaddingAlgorithm, PfxIntegrityError, PfxMalformedError, Pkcs12UnsupportedAlgorithmError, type PrivateKey, type PrivateKeyInternals, type PrivateKeyPEM, PrivateKeyPassphraseRequiredError, PrivateKeyUnavailableError, type PublicKey, type PublicKeyLength, type PublicKeyPEM, RSA_PKCS1_OAEP_PADDING, RSA_PKCS1_PADDING, type ResolvedCaKeyPair, type ResolvedCaSigningKey, type RevocationExtensionsParams, 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 WebCryptoFromSigner, type X509ExtKeyUsage, type X509KeyUsage, type _VerifyStatus, _coercePrivateKey, asn1, buildAuthorityKeyIdentifierFromIssuer, buildCrlNumberExtension, buildRevocationExtensions, caSignerFromKeyOperations, certificateMatchesPrivateKey, clearExploreCertificateCache, coerceCertificate, coerceCertificatePem, coercePEMorDerToPrivateKey, coercePrivateKeyPem, coercePublicKeyPem, coerceRsaPublicKeyPem, combine_der, computeDerivedKeys, computePaddingFooter, convertPEMtoDER, createCertificateFromCsr, createCertificateSigningRequest, createCrl, createPrivateKeyFromNodeJSCrypto, createSelfSignedCertificate, decryptBufferWithDerivedKeys, decryptLong, decryptLongSync, derToPrivateKey, ecdsaSignatureDerToP1363, encryptBufferWithDerivedKeys, exploreAsn1, exploreCertificate, exploreCertificateInfo, exploreCertificateRevocationList, exploreCertificateSigningRequest, exploreEcPrivateKey, explorePrivateKey, extractPublicKeyFromCertificate, extractPublicKeyFromCertificateSync, generateKeyPair, generatePrivateKey, getCrypto, hasSyncKeyOperations, hexDump, identifyDERContent, identifyPemType, isCaSigner, isCrlIssuedByCertificate, isKeyObject, isKeyOperations, keyOperationsFromPrivateKey, makeMessageChunkSignature, makeMessageChunkSignatureWithDerivedKeys, makePrivateKeyFromPem, makePrivateKeyThumbPrint, makePseudoRandomBuffer, makeSHA1Thumbprint, pemToPrivateKey, privateDecrypt, privateDecrypt_long, privateDecrypt_native, privateKeyToCryptoKey, privateKeyToPEM, publicEncrypt, publicEncrypt_long, publicEncrypt_native, publicKeyAndPrivateKeyMatches, readCertificationRequestInfo, readExtension, readNameForCrl, readTbsCertificate, reduceLength, removePadding, removeTrailingLF, resolveCaKeyPair, resolveCaSigningKey, rsaLengthPrivateKey, rsaLengthPublicKey, rsaLengthRsaPublicKey, split_der, toPem, toPem2, verifyCertificateChain, verifyCertificateOrClrSignature, verifyCertificateRevocationListSignature, verifyCertificateSignature, verifyChunkSignature, verifyChunkSignatureWithDerivedKeys, verifyCrlIssuedByCertificate, verifyMessageChunkSignature, verify_certificate_der_structure, webCryptoFromSigner };
|
package/dist/index_web.js
CHANGED
|
@@ -47854,11 +47854,45 @@ function exploreCertificateSigningRequest(crl) {
|
|
|
47854
47854
|
|
|
47855
47855
|
// ../node-opcua-crypto/source/explore_private_key.ts
|
|
47856
47856
|
init_inject_buffer();
|
|
47857
|
+
function toNodeKeyObject(privateKey2) {
|
|
47858
|
+
const hidden = privateKey2.hidden;
|
|
47859
|
+
return typeof hidden === "string" ? createPrivateKeyFromNodeJSCrypto(hidden) : hidden;
|
|
47860
|
+
}
|
|
47861
|
+
function exploreEcPrivateKey(privateKey2) {
|
|
47862
|
+
const keyObject = toNodeKeyObject(privateKey2);
|
|
47863
|
+
if (keyObject.asymmetricKeyType !== "ec") {
|
|
47864
|
+
throw new Error(`exploreEcPrivateKey: expecting an EC private key but got a "${keyObject.asymmetricKeyType}" key`);
|
|
47865
|
+
}
|
|
47866
|
+
const privateKey = keyObject.export({ format: "der", type: "sec1" });
|
|
47867
|
+
const block_info = readTag(privateKey, 0);
|
|
47868
|
+
const blocks = readStruct(privateKey, block_info);
|
|
47869
|
+
const version = getBlock(privateKey, blocks[0]);
|
|
47870
|
+
const d = getBlock(privateKey, blocks[1]);
|
|
47871
|
+
let namedCurve = "";
|
|
47872
|
+
let publicKey;
|
|
47873
|
+
for (let i = 2; i < blocks.length; i++) {
|
|
47874
|
+
const b = blocks[i];
|
|
47875
|
+
if (b.tag === 160 /* CONTEXT_SPECIFIC0 */) {
|
|
47876
|
+
const oidBlock = readTag(privateKey, b.position);
|
|
47877
|
+
namedCurve = readObjectIdentifier(privateKey, oidBlock).name;
|
|
47878
|
+
} else if (b.tag === 161 /* CONTEXT_SPECIFIC1 */) {
|
|
47879
|
+
const bitStringBlock = readTag(privateKey, b.position);
|
|
47880
|
+
publicKey = readBitString(privateKey, bitStringBlock).data;
|
|
47881
|
+
}
|
|
47882
|
+
}
|
|
47883
|
+
return { version, namedCurve, privateKey: d, publicKey };
|
|
47884
|
+
}
|
|
47857
47885
|
function f(buffer, b) {
|
|
47858
47886
|
return buffer.subarray(b.position + 1, b.position + b.length);
|
|
47859
47887
|
}
|
|
47860
47888
|
var doDebug2 = !!import_process.default.env.DEBUG;
|
|
47861
47889
|
function explorePrivateKey(privateKey2) {
|
|
47890
|
+
const keyType = toNodeKeyObject(privateKey2).asymmetricKeyType;
|
|
47891
|
+
if (keyType && keyType !== "rsa") {
|
|
47892
|
+
throw new Error(
|
|
47893
|
+
`explorePrivateKey: only RSA private keys are supported (got a "${keyType}" key). ` + (keyType === "ec" ? "Use exploreEcPrivateKey() instead." : "")
|
|
47894
|
+
);
|
|
47895
|
+
}
|
|
47862
47896
|
const privateKey1 = privateKey2.hidden;
|
|
47863
47897
|
const privateKey = typeof privateKey1 === "string" ? convertPEMtoDER(privateKey1) : privateKey1.export({ format: "der", type: "pkcs1" });
|
|
47864
47898
|
const block_info = readTag(privateKey, 0);
|
|
@@ -48002,6 +48036,75 @@ function identifyDERContent(buffer) {
|
|
|
48002
48036
|
}
|
|
48003
48037
|
}
|
|
48004
48038
|
|
|
48039
|
+
// ../node-opcua-crypto/source/key_operations/ca_signer_adapter.ts
|
|
48040
|
+
init_inject_buffer();
|
|
48041
|
+
function caSignerFromKeyOperations(ops, hash = "SHA-256") {
|
|
48042
|
+
const getPublicKey = ops.getPublicKey;
|
|
48043
|
+
if (typeof getPublicKey !== "function") {
|
|
48044
|
+
throw new Error(
|
|
48045
|
+
"caSignerFromKeyOperations requires a key-operations provider that implements getPublicKey(): a CaSigner must be able to produce its public key (SPKI DER), and an opaque key has no other source for it"
|
|
48046
|
+
);
|
|
48047
|
+
}
|
|
48048
|
+
return {
|
|
48049
|
+
algorithm: { name: "RSASSA-PKCS1-v1_5", hash: { name: hash } },
|
|
48050
|
+
getPublicKey: () => getPublicKey.call(ops),
|
|
48051
|
+
async sign(tbs) {
|
|
48052
|
+
const signature = await ops.sign(tbs, { padding: "RSA-PKCS1-v1_5", hash });
|
|
48053
|
+
const copy2 = new Uint8Array(signature.byteLength);
|
|
48054
|
+
copy2.set(signature);
|
|
48055
|
+
return copy2.buffer;
|
|
48056
|
+
}
|
|
48057
|
+
};
|
|
48058
|
+
}
|
|
48059
|
+
|
|
48060
|
+
// ../node-opcua-crypto/source/key_operations/decrypt_long.ts
|
|
48061
|
+
init_inject_buffer();
|
|
48062
|
+
function splitBlocks(buffer, blockSize) {
|
|
48063
|
+
if (!Number.isInteger(blockSize) || blockSize <= 0) {
|
|
48064
|
+
throw new Error(`invalid cipher block size ${blockSize}`);
|
|
48065
|
+
}
|
|
48066
|
+
if (buffer.length === 0 || buffer.length % blockSize !== 0) {
|
|
48067
|
+
throw new Error(`encrypted buffer length ${buffer.length} is not a whole number of ${blockSize}-byte cipher blocks`);
|
|
48068
|
+
}
|
|
48069
|
+
const blocks = [];
|
|
48070
|
+
for (let offset = 0; offset < buffer.length; offset += blockSize) {
|
|
48071
|
+
blocks.push(buffer.subarray(offset, offset + blockSize));
|
|
48072
|
+
}
|
|
48073
|
+
return blocks;
|
|
48074
|
+
}
|
|
48075
|
+
async function decryptLong(ops, buffer, params, blockSize) {
|
|
48076
|
+
const blocks = splitBlocks(buffer, blockSize);
|
|
48077
|
+
const decrypted = await Promise.all(blocks.map((block) => ops.decryptBlock(block, params)));
|
|
48078
|
+
return import_buffer.Buffer.concat(decrypted);
|
|
48079
|
+
}
|
|
48080
|
+
function decryptLongSync(ops, buffer, params, blockSize) {
|
|
48081
|
+
const decryptBlockSync = ops.decryptBlockSync;
|
|
48082
|
+
if (typeof decryptBlockSync !== "function") {
|
|
48083
|
+
throw new Error("decryptLongSync requires a key-operations provider with a synchronous fast path (decryptBlockSync)");
|
|
48084
|
+
}
|
|
48085
|
+
const blocks = splitBlocks(buffer, blockSize);
|
|
48086
|
+
return import_buffer.Buffer.concat(blocks.map((block) => decryptBlockSync.call(ops, block, params)));
|
|
48087
|
+
}
|
|
48088
|
+
|
|
48089
|
+
// ../node-opcua-crypto/source/key_operations/key_operations.ts
|
|
48090
|
+
init_inject_buffer();
|
|
48091
|
+
function isKeyOperations(value) {
|
|
48092
|
+
if (value === null || typeof value !== "object") {
|
|
48093
|
+
return false;
|
|
48094
|
+
}
|
|
48095
|
+
const candidate = value;
|
|
48096
|
+
return typeof candidate.sign === "function" && typeof candidate.decryptBlock === "function" && typeof candidate.getKeyMetadata === "function";
|
|
48097
|
+
}
|
|
48098
|
+
function hasSyncKeyOperations(ops) {
|
|
48099
|
+
return typeof ops.signSync === "function" && typeof ops.decryptBlockSync === "function" && typeof ops.getKeyMetadataSync === "function";
|
|
48100
|
+
}
|
|
48101
|
+
var PrivateKeyUnavailableError = class extends Error {
|
|
48102
|
+
constructor(message = "the private key is opaque: it is held by a key-operations provider and cannot be read") {
|
|
48103
|
+
super(message);
|
|
48104
|
+
this.name = "PrivateKeyUnavailableError";
|
|
48105
|
+
}
|
|
48106
|
+
};
|
|
48107
|
+
|
|
48005
48108
|
// ../node-opcua-crypto/source/subject.ts
|
|
48006
48109
|
init_inject_buffer();
|
|
48007
48110
|
var _keys = {
|
|
@@ -62212,12 +62315,7 @@ async function createSelfSignedCertificate({
|
|
|
62212
62315
|
applicationUri,
|
|
62213
62316
|
purpose
|
|
62214
62317
|
}) {
|
|
62215
|
-
const crypto4 =
|
|
62216
|
-
const publicKey = await buildPublicKey(privateKey);
|
|
62217
|
-
const keys = {
|
|
62218
|
-
privateKey,
|
|
62219
|
-
publicKey
|
|
62220
|
-
};
|
|
62318
|
+
const { crypto: crypto4, keys, signingAlgorithm } = await resolveCaKeyPair(privateKey);
|
|
62221
62319
|
const { nsComment, basicConstraints, keyUsageExtension, usages } = getAttributes(purpose);
|
|
62222
62320
|
notBefore = notBefore || /* @__PURE__ */ new Date();
|
|
62223
62321
|
validity = validity || 0;
|
|
@@ -62253,7 +62351,9 @@ async function createSelfSignedCertificate({
|
|
|
62253
62351
|
name,
|
|
62254
62352
|
notBefore,
|
|
62255
62353
|
notAfter,
|
|
62256
|
-
|
|
62354
|
+
// for a raw key resolveCaKeyPair yields exactly the historical
|
|
62355
|
+
// RSASSA-PKCS1-v1_5/SHA-256; for a CaSigner, the signer's declared algorithm
|
|
62356
|
+
signingAlgorithm,
|
|
62257
62357
|
keys,
|
|
62258
62358
|
extensions: [
|
|
62259
62359
|
new x509_es_exports.Extension(ID_NETSCAPE_COMMENT, false, AsnConvert.serialize(AsnUtf8StringConverter.toASN(nsComment))),
|
|
@@ -62458,6 +62558,81 @@ function verifyChunkSignatureWithDerivedKeys(chunk, derivedKeys) {
|
|
|
62458
62558
|
return computedSignature.toString("hex") === expectedSignature.toString("hex");
|
|
62459
62559
|
}
|
|
62460
62560
|
|
|
62561
|
+
// ../node-opcua-crypto/source/key_operations/local_key_operations.ts
|
|
62562
|
+
init_inject_buffer();
|
|
62563
|
+
init_node_crypto_shim();
|
|
62564
|
+
function toNodeHash(hash) {
|
|
62565
|
+
return hash === "SHA-1" ? "RSA-SHA1" : "RSA-SHA256";
|
|
62566
|
+
}
|
|
62567
|
+
var LocalKeyOperations = class {
|
|
62568
|
+
#key;
|
|
62569
|
+
#metadata;
|
|
62570
|
+
constructor(privateKey) {
|
|
62571
|
+
const hidden = privateKey.hidden;
|
|
62572
|
+
this.#key = typeof hidden === "string" ? createPrivateKey(hidden) : createPrivateKey({ key: hidden.export({ type: "pkcs8", format: "der" }), format: "der", type: "pkcs8" });
|
|
62573
|
+
if (this.#key.asymmetricKeyType !== "rsa") {
|
|
62574
|
+
throw new Error(`LocalKeyOperations supports RSA keys only for now, got a "${this.#key.asymmetricKeyType}" key`);
|
|
62575
|
+
}
|
|
62576
|
+
const modulusLength = this.#key.asymmetricKeyDetails?.modulusLength;
|
|
62577
|
+
if (!modulusLength) {
|
|
62578
|
+
throw new Error("cannot determine the modulus length of the private key");
|
|
62579
|
+
}
|
|
62580
|
+
this.#metadata = { keyType: "RSA", modulusLength: modulusLength / 8 };
|
|
62581
|
+
}
|
|
62582
|
+
getKeyMetadataSync() {
|
|
62583
|
+
return this.#metadata;
|
|
62584
|
+
}
|
|
62585
|
+
async getKeyMetadata() {
|
|
62586
|
+
return this.#metadata;
|
|
62587
|
+
}
|
|
62588
|
+
async getPublicKey() {
|
|
62589
|
+
const spki = createPublicKey(this.#key).export({ type: "spki", format: "der" });
|
|
62590
|
+
return spki.buffer.slice(spki.byteOffset, spki.byteOffset + spki.byteLength);
|
|
62591
|
+
}
|
|
62592
|
+
signSync(data, params) {
|
|
62593
|
+
const signer = createSign(toNodeHash(params.hash));
|
|
62594
|
+
signer.update(data);
|
|
62595
|
+
if (params.padding === "RSA-PSS") {
|
|
62596
|
+
return signer.sign({
|
|
62597
|
+
key: this.#key,
|
|
62598
|
+
padding: constants_default.RSA_PKCS1_PSS_PADDING,
|
|
62599
|
+
saltLength: constants_default.RSA_PSS_SALTLEN_DIGEST
|
|
62600
|
+
});
|
|
62601
|
+
}
|
|
62602
|
+
return signer.sign(this.#key);
|
|
62603
|
+
}
|
|
62604
|
+
async sign(data, params) {
|
|
62605
|
+
return this.signSync(data, params);
|
|
62606
|
+
}
|
|
62607
|
+
decryptBlockSync(block, params) {
|
|
62608
|
+
if (block.length !== this.#metadata.modulusLength) {
|
|
62609
|
+
throw new Error(
|
|
62610
|
+
`decryptBlock expects exactly one cipher block of ${this.#metadata.modulusLength} bytes, got ${block.length}`
|
|
62611
|
+
);
|
|
62612
|
+
}
|
|
62613
|
+
if (params.padding === "RSA-OAEP") {
|
|
62614
|
+
if (!params.oaepHash) {
|
|
62615
|
+
throw new Error("RSA-OAEP decryption requires an oaepHash");
|
|
62616
|
+
}
|
|
62617
|
+
return privateDecrypt(
|
|
62618
|
+
{
|
|
62619
|
+
key: this.#key,
|
|
62620
|
+
padding: constants_default.RSA_PKCS1_OAEP_PADDING,
|
|
62621
|
+
oaepHash: params.oaepHash === "SHA-256" ? "sha256" : "sha1"
|
|
62622
|
+
},
|
|
62623
|
+
block
|
|
62624
|
+
);
|
|
62625
|
+
}
|
|
62626
|
+
return privateDecrypt({ key: this.#key, padding: constants_default.RSA_PKCS1_PADDING }, block);
|
|
62627
|
+
}
|
|
62628
|
+
async decryptBlock(block, params) {
|
|
62629
|
+
return this.decryptBlockSync(block, params);
|
|
62630
|
+
}
|
|
62631
|
+
};
|
|
62632
|
+
function keyOperationsFromPrivateKey(privateKey) {
|
|
62633
|
+
return new LocalKeyOperations(privateKey);
|
|
62634
|
+
}
|
|
62635
|
+
|
|
62461
62636
|
// ../node-opcua-crypto/source/make_private_key_from_pem.ts
|
|
62462
62637
|
init_inject_buffer();
|
|
62463
62638
|
function makePrivateKeyFromPem(privateKeyInPem) {
|
|
@@ -62500,12 +62675,14 @@ function certificateMatchesPrivateKey(certificate, privateKey) {
|
|
|
62500
62675
|
var asn1 = { readDirectoryName, readTag, readStruct, readAlgorithmIdentifier, readSignatureValueBin };
|
|
62501
62676
|
export {
|
|
62502
62677
|
CertificatePurpose,
|
|
62678
|
+
LocalKeyOperations,
|
|
62503
62679
|
LocalPrivateKeySigner,
|
|
62504
62680
|
PaddingAlgorithm,
|
|
62505
62681
|
PfxIntegrityError,
|
|
62506
62682
|
PfxMalformedError,
|
|
62507
62683
|
Pkcs12UnsupportedAlgorithmError,
|
|
62508
62684
|
PrivateKeyPassphraseRequiredError,
|
|
62685
|
+
PrivateKeyUnavailableError,
|
|
62509
62686
|
RSA_PKCS1_OAEP_PADDING,
|
|
62510
62687
|
RSA_PKCS1_PADDING,
|
|
62511
62688
|
Subject,
|
|
@@ -62514,6 +62691,7 @@ export {
|
|
|
62514
62691
|
buildAuthorityKeyIdentifierFromIssuer,
|
|
62515
62692
|
buildCrlNumberExtension,
|
|
62516
62693
|
buildRevocationExtensions,
|
|
62694
|
+
caSignerFromKeyOperations,
|
|
62517
62695
|
certificateMatchesPrivateKey,
|
|
62518
62696
|
clearExploreCertificateCache,
|
|
62519
62697
|
coerceCertificate,
|
|
@@ -62532,6 +62710,8 @@ export {
|
|
|
62532
62710
|
createPrivateKeyFromNodeJSCrypto,
|
|
62533
62711
|
createSelfSignedCertificate,
|
|
62534
62712
|
decryptBufferWithDerivedKeys,
|
|
62713
|
+
decryptLong,
|
|
62714
|
+
decryptLongSync,
|
|
62535
62715
|
derToPrivateKey,
|
|
62536
62716
|
ecdsaSignatureDerToP1363,
|
|
62537
62717
|
encryptBufferWithDerivedKeys,
|
|
@@ -62540,18 +62720,22 @@ export {
|
|
|
62540
62720
|
exploreCertificateInfo,
|
|
62541
62721
|
exploreCertificateRevocationList,
|
|
62542
62722
|
exploreCertificateSigningRequest,
|
|
62723
|
+
exploreEcPrivateKey,
|
|
62543
62724
|
explorePrivateKey,
|
|
62544
62725
|
extractPublicKeyFromCertificate,
|
|
62545
62726
|
extractPublicKeyFromCertificateSync,
|
|
62546
62727
|
generateKeyPair,
|
|
62547
62728
|
generatePrivateKey,
|
|
62548
62729
|
getCrypto,
|
|
62730
|
+
hasSyncKeyOperations,
|
|
62549
62731
|
hexDump,
|
|
62550
62732
|
identifyDERContent,
|
|
62551
62733
|
identifyPemType,
|
|
62552
62734
|
isCaSigner,
|
|
62553
62735
|
isCrlIssuedByCertificate,
|
|
62554
62736
|
isKeyObject,
|
|
62737
|
+
isKeyOperations,
|
|
62738
|
+
keyOperationsFromPrivateKey,
|
|
62555
62739
|
makeMessageChunkSignature,
|
|
62556
62740
|
makeMessageChunkSignatureWithDerivedKeys,
|
|
62557
62741
|
makePrivateKeyFromPem,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-opcua-crypto-web",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.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.2",
|
|
46
46
|
"events": "^3.3.0",
|
|
47
|
-
"node-opcua-crypto": "^5.
|
|
47
|
+
"node-opcua-crypto": "^5.11.0",
|
|
48
48
|
"path-browserify": "^1.0.1",
|
|
49
49
|
"process": "^0.11.10",
|
|
50
50
|
"stream-browserify": "^3.0.0",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"LICENSE",
|
|
68
68
|
"README.md"
|
|
69
69
|
],
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "114afd2e134735f5157acd1ee51d578bd596eaa4"
|
|
71
71
|
}
|