@enbox/crypto 0.0.2 → 0.0.4
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/README.md +34 -102
- package/dist/browser.mjs +6 -10
- package/dist/browser.mjs.map +4 -4
- package/dist/esm/algorithms/aes-ctr.js +1 -1
- package/dist/esm/algorithms/aes-gcm.js +35 -2
- package/dist/esm/algorithms/aes-gcm.js.map +1 -1
- package/dist/esm/algorithms/aes-kw.js +154 -0
- package/dist/esm/algorithms/aes-kw.js.map +1 -0
- package/dist/esm/algorithms/ecdsa.js +119 -6
- package/dist/esm/algorithms/ecdsa.js.map +1 -1
- package/dist/esm/algorithms/eddsa.js +99 -6
- package/dist/esm/algorithms/eddsa.js.map +1 -1
- package/dist/esm/algorithms/hkdf.js +53 -0
- package/dist/esm/algorithms/hkdf.js.map +1 -0
- package/dist/esm/algorithms/pbkdf2.js +55 -0
- package/dist/esm/algorithms/pbkdf2.js.map +1 -0
- package/dist/esm/algorithms/sha-2.js +2 -2
- package/dist/esm/algorithms/sha-2.js.map +1 -1
- package/dist/esm/algorithms/x25519.js +125 -0
- package/dist/esm/algorithms/x25519.js.map +1 -0
- package/dist/esm/crypto-error.js +41 -0
- package/dist/esm/crypto-error.js.map +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/jose/jwk.js +52 -26
- package/dist/esm/jose/jwk.js.map +1 -1
- package/dist/esm/local-key-manager.js +9 -3
- package/dist/esm/local-key-manager.js.map +1 -1
- package/dist/esm/primitives/aes-ctr.js.map +1 -1
- package/dist/esm/primitives/aes-gcm.js.map +1 -1
- package/dist/esm/primitives/aes-kw.js +246 -0
- package/dist/esm/primitives/aes-kw.js.map +1 -0
- package/dist/esm/primitives/concat-kdf.js +1 -1
- package/dist/esm/primitives/concat-kdf.js.map +1 -1
- package/dist/esm/primitives/ecies-secp256k1.js +79 -0
- package/dist/esm/primitives/ecies-secp256k1.js.map +1 -0
- package/dist/esm/primitives/ed25519.js +3 -3
- package/dist/esm/primitives/ed25519.js.map +1 -1
- package/dist/esm/primitives/hkdf.js +79 -0
- package/dist/esm/primitives/hkdf.js.map +1 -0
- package/dist/esm/primitives/pbkdf2.js +49 -0
- package/dist/esm/primitives/pbkdf2.js.map +1 -1
- package/dist/esm/primitives/secp256k1.js +4 -4
- package/dist/esm/primitives/secp256k1.js.map +1 -1
- package/dist/esm/primitives/secp256r1.js +4 -4
- package/dist/esm/primitives/secp256r1.js.map +1 -1
- package/dist/esm/primitives/x25519.js +10 -17
- package/dist/esm/primitives/x25519.js.map +1 -1
- package/dist/esm/primitives/xchacha20-poly1305.js +48 -3
- package/dist/esm/primitives/xchacha20-poly1305.js.map +1 -1
- package/dist/esm/primitives/xchacha20.js +1 -1
- package/dist/esm/primitives/xchacha20.js.map +1 -1
- package/dist/esm/utils.js +30 -0
- package/dist/esm/utils.js.map +1 -1
- package/dist/types/algorithms/aes-ctr.d.ts +2 -2
- package/dist/types/algorithms/aes-ctr.d.ts.map +1 -1
- package/dist/types/algorithms/aes-gcm.d.ts +25 -5
- package/dist/types/algorithms/aes-gcm.d.ts.map +1 -1
- package/dist/types/algorithms/aes-kw.d.ts +129 -0
- package/dist/types/algorithms/aes-kw.d.ts.map +1 -0
- package/dist/types/algorithms/ecdsa.d.ts +49 -4
- package/dist/types/algorithms/ecdsa.d.ts.map +1 -1
- package/dist/types/algorithms/eddsa.d.ts +49 -4
- package/dist/types/algorithms/eddsa.d.ts.map +1 -1
- package/dist/types/algorithms/hkdf.d.ts +35 -0
- package/dist/types/algorithms/hkdf.d.ts.map +1 -0
- package/dist/types/algorithms/pbkdf2.d.ts +35 -0
- package/dist/types/algorithms/pbkdf2.d.ts.map +1 -0
- package/dist/types/algorithms/sha-2.d.ts +2 -2
- package/dist/types/algorithms/sha-2.d.ts.map +1 -1
- package/dist/types/algorithms/x25519.d.ts +76 -0
- package/dist/types/algorithms/x25519.d.ts.map +1 -0
- package/dist/types/crypto-error.d.ts +29 -0
- package/dist/types/crypto-error.d.ts.map +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/jose/jwk.d.ts.map +1 -1
- package/dist/types/local-key-manager.d.ts +6 -6
- package/dist/types/local-key-manager.d.ts.map +1 -1
- package/dist/types/primitives/aes-kw.d.ts +103 -0
- package/dist/types/primitives/aes-kw.d.ts.map +1 -0
- package/dist/types/primitives/concat-kdf.d.ts +1 -1
- package/dist/types/primitives/concat-kdf.d.ts.map +1 -1
- package/dist/types/primitives/ecies-secp256k1.d.ts +53 -0
- package/dist/types/primitives/ecies-secp256k1.d.ts.map +1 -0
- package/dist/types/primitives/hkdf.d.ts +90 -0
- package/dist/types/primitives/hkdf.d.ts.map +1 -0
- package/dist/types/primitives/pbkdf2.d.ts +58 -0
- package/dist/types/primitives/pbkdf2.d.ts.map +1 -1
- package/dist/types/primitives/x25519.d.ts +9 -16
- package/dist/types/primitives/x25519.d.ts.map +1 -1
- package/dist/types/primitives/xchacha20-poly1305.d.ts +47 -0
- package/dist/types/primitives/xchacha20-poly1305.d.ts.map +1 -1
- package/dist/types/types/cipher.d.ts +1 -1
- package/dist/types/types/crypto-api.d.ts +54 -6
- package/dist/types/types/crypto-api.d.ts.map +1 -1
- package/dist/types/types/key-converter.d.ts +37 -15
- package/dist/types/types/key-converter.d.ts.map +1 -1
- package/dist/types/types/key-deriver.d.ts +41 -0
- package/dist/types/types/key-deriver.d.ts.map +1 -1
- package/dist/types/types/key-io.d.ts +37 -0
- package/dist/types/types/key-io.d.ts.map +1 -1
- package/dist/types/types/params-direct.d.ts +96 -1
- package/dist/types/types/params-direct.d.ts.map +1 -1
- package/dist/types/types/params-kms.d.ts +55 -0
- package/dist/types/types/params-kms.d.ts.map +1 -1
- package/dist/types/utils.d.ts +19 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/utils.js +1 -1
- package/dist/utils.js.map +4 -4
- package/package.json +29 -45
- package/src/algorithms/aes-ctr.ts +2 -2
- package/src/algorithms/aes-gcm.ts +41 -4
- package/src/algorithms/aes-kw.ts +182 -0
- package/src/algorithms/ecdsa.ts +145 -8
- package/src/algorithms/eddsa.ts +117 -10
- package/src/algorithms/hkdf.ts +54 -0
- package/src/algorithms/pbkdf2.ts +57 -0
- package/src/algorithms/sha-2.ts +3 -3
- package/src/algorithms/x25519.ts +153 -0
- package/src/crypto-error.ts +45 -0
- package/src/index.ts +8 -0
- package/src/jose/jwk.ts +32 -32
- package/src/local-key-manager.ts +22 -16
- package/src/primitives/aes-ctr.ts +1 -1
- package/src/primitives/aes-gcm.ts +5 -5
- package/src/primitives/aes-kw.ts +269 -0
- package/src/primitives/concat-kdf.ts +4 -2
- package/src/primitives/ecies-secp256k1.ts +113 -0
- package/src/primitives/ed25519.ts +6 -6
- package/src/primitives/hkdf.ts +121 -0
- package/src/primitives/pbkdf2.ts +91 -0
- package/src/primitives/secp256k1.ts +6 -6
- package/src/primitives/secp256r1.ts +6 -6
- package/src/primitives/x25519.ts +12 -19
- package/src/primitives/xchacha20-poly1305.ts +57 -4
- package/src/primitives/xchacha20.ts +1 -1
- package/src/types/cipher.ts +1 -1
- package/src/types/crypto-api.ts +129 -11
- package/src/types/key-converter.ts +33 -7
- package/src/types/key-deriver.ts +49 -0
- package/src/types/key-io.ts +40 -0
- package/src/types/params-direct.ts +118 -1
- package/src/types/params-kms.ts +67 -0
- package/src/utils.ts +55 -2
- package/dist/browser.js +0 -64
- package/dist/browser.js.map +0 -7
- package/dist/cjs/algorithms/aes-ctr.js +0 -188
- package/dist/cjs/algorithms/aes-ctr.js.map +0 -1
- package/dist/cjs/algorithms/aes-gcm.js +0 -196
- package/dist/cjs/algorithms/aes-gcm.js.map +0 -1
- package/dist/cjs/algorithms/crypto-algorithm.js +0 -13
- package/dist/cjs/algorithms/crypto-algorithm.js.map +0 -1
- package/dist/cjs/algorithms/ecdsa.js +0 -352
- package/dist/cjs/algorithms/ecdsa.js.map +0 -1
- package/dist/cjs/algorithms/eddsa.js +0 -325
- package/dist/cjs/algorithms/eddsa.js.map +0 -1
- package/dist/cjs/algorithms/sha-2.js +0 -119
- package/dist/cjs/algorithms/sha-2.js.map +0 -1
- package/dist/cjs/index.js +0 -41
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/jose/jwe.js +0 -3
- package/dist/cjs/jose/jwe.js.map +0 -1
- package/dist/cjs/jose/jwk.js +0 -278
- package/dist/cjs/jose/jwk.js.map +0 -1
- package/dist/cjs/jose/jws.js +0 -3
- package/dist/cjs/jose/jws.js.map +0 -1
- package/dist/cjs/jose/jwt.js +0 -3
- package/dist/cjs/jose/jwt.js.map +0 -1
- package/dist/cjs/jose/utils.js +0 -60
- package/dist/cjs/jose/utils.js.map +0 -1
- package/dist/cjs/local-key-manager.js +0 -521
- package/dist/cjs/local-key-manager.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/primitives/aes-ctr.js +0 -398
- package/dist/cjs/primitives/aes-ctr.js.map +0 -1
- package/dist/cjs/primitives/aes-gcm.js +0 -425
- package/dist/cjs/primitives/aes-gcm.js.map +0 -1
- package/dist/cjs/primitives/concat-kdf.js +0 -215
- package/dist/cjs/primitives/concat-kdf.js.map +0 -1
- package/dist/cjs/primitives/ed25519.js +0 -651
- package/dist/cjs/primitives/ed25519.js.map +0 -1
- package/dist/cjs/primitives/pbkdf2.js +0 -120
- package/dist/cjs/primitives/pbkdf2.js.map +0 -1
- package/dist/cjs/primitives/secp256k1.js +0 -958
- package/dist/cjs/primitives/secp256k1.js.map +0 -1
- package/dist/cjs/primitives/secp256r1.js +0 -959
- package/dist/cjs/primitives/secp256r1.js.map +0 -1
- package/dist/cjs/primitives/sha256.js +0 -93
- package/dist/cjs/primitives/sha256.js.map +0 -1
- package/dist/cjs/primitives/x25519.js +0 -498
- package/dist/cjs/primitives/x25519.js.map +0 -1
- package/dist/cjs/primitives/xchacha20-poly1305.js +0 -340
- package/dist/cjs/primitives/xchacha20-poly1305.js.map +0 -1
- package/dist/cjs/primitives/xchacha20.js +0 -316
- package/dist/cjs/primitives/xchacha20.js.map +0 -1
- package/dist/cjs/types/cipher.js +0 -3
- package/dist/cjs/types/cipher.js.map +0 -1
- package/dist/cjs/types/crypto-api.js +0 -3
- package/dist/cjs/types/crypto-api.js.map +0 -1
- package/dist/cjs/types/hasher.js +0 -3
- package/dist/cjs/types/hasher.js.map +0 -1
- package/dist/cjs/types/identifier.js +0 -3
- package/dist/cjs/types/identifier.js.map +0 -1
- package/dist/cjs/types/key-compressor.js +0 -3
- package/dist/cjs/types/key-compressor.js.map +0 -1
- package/dist/cjs/types/key-converter.js +0 -3
- package/dist/cjs/types/key-converter.js.map +0 -1
- package/dist/cjs/types/key-deriver.js +0 -3
- package/dist/cjs/types/key-deriver.js.map +0 -1
- package/dist/cjs/types/key-generator.js +0 -3
- package/dist/cjs/types/key-generator.js.map +0 -1
- package/dist/cjs/types/key-io.js +0 -3
- package/dist/cjs/types/key-io.js.map +0 -1
- package/dist/cjs/types/key-wrapper.js +0 -3
- package/dist/cjs/types/key-wrapper.js.map +0 -1
- package/dist/cjs/types/params-direct.js +0 -3
- package/dist/cjs/types/params-direct.js.map +0 -1
- package/dist/cjs/types/params-enclosed.js +0 -3
- package/dist/cjs/types/params-enclosed.js.map +0 -1
- package/dist/cjs/types/params-kms.js +0 -3
- package/dist/cjs/types/params-kms.js.map +0 -1
- package/dist/cjs/types/signer.js +0 -3
- package/dist/cjs/types/signer.js.map +0 -1
- package/dist/cjs/utils.js +0 -173
- package/dist/cjs/utils.js.map +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output of an ECIES-SECP256K1 encryption operation.
|
|
3
|
+
*/
|
|
4
|
+
export type EciesSecp256k1EncryptionOutput = {
|
|
5
|
+
/** The AES-GCM initialization vector. */
|
|
6
|
+
initializationVector: Uint8Array;
|
|
7
|
+
/** The ephemeral secp256k1 public key (compressed, 33 bytes). */
|
|
8
|
+
ephemeralPublicKey: Uint8Array;
|
|
9
|
+
/** The encrypted data. */
|
|
10
|
+
ciphertext: Uint8Array;
|
|
11
|
+
/** The AES-GCM authentication tag (16 bytes). */
|
|
12
|
+
messageAuthenticationCode: Uint8Array;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Input required for ECIES-SECP256K1 decryption.
|
|
16
|
+
*/
|
|
17
|
+
export type EciesSecp256k1EncryptionInput = EciesSecp256k1EncryptionOutput & {
|
|
18
|
+
/** The recipient's secp256k1 private key (raw 32 bytes). */
|
|
19
|
+
privateKey: Uint8Array;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Browser-compatible ECIES (Elliptic Curve Integrated Encryption Scheme) using secp256k1.
|
|
23
|
+
*
|
|
24
|
+
* Wire-format compatible with `eciesjs` v0.4.x configured with
|
|
25
|
+
* `isEphemeralKeyCompressed: true, isHkdfKeyCompressed: false` (the default).
|
|
26
|
+
*
|
|
27
|
+
* Protocol:
|
|
28
|
+
* 1. Generate an ephemeral secp256k1 key pair.
|
|
29
|
+
* 2. ECDH shared secret (uncompressed point).
|
|
30
|
+
* 3. HKDF-SHA-256 key derivation: `hkdf(sha256, ephemeralPubUncompressed || sharedPointUncompressed)`.
|
|
31
|
+
* 4. AES-256-GCM encryption with random 16-byte nonce.
|
|
32
|
+
*
|
|
33
|
+
* All underlying primitives (`@noble/ciphers`, `@noble/curves`, `@noble/hashes`)
|
|
34
|
+
* are pure JavaScript and work in Node, Bun, and browsers.
|
|
35
|
+
*/
|
|
36
|
+
export declare class EciesSecp256k1 {
|
|
37
|
+
/**
|
|
38
|
+
* Encrypt plaintext for a given secp256k1 public key.
|
|
39
|
+
* @param publicKeyBytes - Recipient's public key (compressed 33 bytes or uncompressed 65 bytes).
|
|
40
|
+
* @param plaintext - The data to encrypt.
|
|
41
|
+
*/
|
|
42
|
+
static encrypt(publicKeyBytes: Uint8Array, plaintext: Uint8Array): EciesSecp256k1EncryptionOutput;
|
|
43
|
+
/**
|
|
44
|
+
* Decrypt ciphertext produced by {@link EciesSecp256k1.encrypt}.
|
|
45
|
+
* @param input - The encryption output plus the recipient's private key.
|
|
46
|
+
*/
|
|
47
|
+
static decrypt(input: EciesSecp256k1EncryptionInput): Uint8Array;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the ephemeral public key is compressed (always true for this implementation).
|
|
50
|
+
*/
|
|
51
|
+
static get isEphemeralKeyCompressed(): boolean;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=ecies-secp256k1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecies-secp256k1.d.ts","sourceRoot":"","sources":["../../../src/primitives/ecies-secp256k1.ts"],"names":[],"mappings":"AAiBA;;GAEG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,yCAAyC;IACzC,oBAAoB,EAAE,UAAU,CAAC;IACjC,iEAAiE;IACjE,kBAAkB,EAAE,UAAU,CAAC;IAC/B,0BAA0B;IAC1B,UAAU,EAAE,UAAU,CAAC;IACvB,iDAAiD;IACjD,yBAAyB,EAAE,UAAU,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,8BAA8B,GAAG;IAC3E,4DAA4D;IAC5D,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,qBAAa,cAAc;IACzB;;;;OAIG;WACW,OAAO,CAAC,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,GAAG,8BAA8B;IAyBxG;;;OAGG;WACW,OAAO,CAAC,KAAK,EAAE,6BAA6B,GAAG,UAAU;IAiBvE;;OAEG;IACH,WAAkB,wBAAwB,IAAI,OAAO,CAEpD;CACF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { DeriveKeyBytesParams } from '../types/params-direct.js';
|
|
2
|
+
/**
|
|
3
|
+
* The object that should be passed into `Hkdf.deriveKeyBytes()`, when using the HKDF algorithm.
|
|
4
|
+
*/
|
|
5
|
+
export type HkdfParams = {
|
|
6
|
+
/**
|
|
7
|
+
* A string representing the digest algorithm to use. This may be one of:
|
|
8
|
+
* - 'SHA-256'
|
|
9
|
+
* - 'SHA-384'
|
|
10
|
+
* - 'SHA-512'
|
|
11
|
+
*/
|
|
12
|
+
hash: 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
13
|
+
/**
|
|
14
|
+
* The salt value to use in the derivation process.
|
|
15
|
+
*
|
|
16
|
+
* Ideally, the salt is a random or pseudo-random value with the same length as the output of the
|
|
17
|
+
* digest function. Unlike the input key material passed into deriveKey(), salt does not need to
|
|
18
|
+
* be kept secret.
|
|
19
|
+
*
|
|
20
|
+
* Note: The {@link https://datatracker.ietf.org/doc/html/rfc5869 | HKDF specification} states
|
|
21
|
+
* that adding salt "adds significantly to the strength of HKDF".
|
|
22
|
+
*/
|
|
23
|
+
salt: string | Uint8Array;
|
|
24
|
+
/**
|
|
25
|
+
* Optional application-specific information to use in the HKDF.
|
|
26
|
+
*
|
|
27
|
+
* If given, this value is used to bind the derived key to application-specific contextual
|
|
28
|
+
* information. This makes it possible to derive different keys for different contexts while using
|
|
29
|
+
* the same input key material.
|
|
30
|
+
*
|
|
31
|
+
* If not provided, the `info` value is set to an empty array.
|
|
32
|
+
*
|
|
33
|
+
* Note: It is important that the `info` value be independent and unrelated to the input key
|
|
34
|
+
* material.
|
|
35
|
+
*/
|
|
36
|
+
info?: string | Uint8Array;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The `Hkdf` class provides an interface for HMAC-based Extract-and-Expand Key Derivation Function (HKDF)
|
|
40
|
+
* as defined in RFC 5869.
|
|
41
|
+
*
|
|
42
|
+
* Note: The `baseKeyBytes` that will be the input key material for HKDF should be a high-entropy secret
|
|
43
|
+
* value, such as a cryptographic key. It should be kept confidential and not be derived from a
|
|
44
|
+
* low-entropy value, such as a password.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```ts
|
|
48
|
+
* const info = new Uint8Array([...]);
|
|
49
|
+
* const derivedKeyBytes = await Hkdf.deriveKeyBytes({
|
|
50
|
+
* baseKeyBytes: new Uint8Array([...]), // Input keying material
|
|
51
|
+
* hash: 'SHA-256', // The hash function to use ('SHA-256', 'SHA-384', 'SHA-512')
|
|
52
|
+
* salt: new Uint8Array([...]), // The salt value
|
|
53
|
+
* info: new Uint8Array([...]), // Optional application-specific information
|
|
54
|
+
* length: 256 // The length of the derived key in bits
|
|
55
|
+
* });
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare class Hkdf {
|
|
59
|
+
/**
|
|
60
|
+
* Derives a key using the HMAC-based Extract-and-Expand Key Derivation Function (HKDF).
|
|
61
|
+
*
|
|
62
|
+
* This method generates a derived key using a hash function from input keying material given as
|
|
63
|
+
* `baseKeyBytes`. The length of the derived key can be specified. Optionally, it can also use a salt
|
|
64
|
+
* and info for the derivation process.
|
|
65
|
+
*
|
|
66
|
+
* HKDF is useful in various cryptographic applications and protocols, especially when
|
|
67
|
+
* there's a need to derive multiple keys from a single source of key material.
|
|
68
|
+
*
|
|
69
|
+
* Note: The `baseKeyBytes` that will be the input key material for HKDF should be a high-entropy
|
|
70
|
+
* secret value, such as a cryptographic key. It should be kept confidential and not be derived
|
|
71
|
+
* from a low-entropy value, such as a password.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const info = new Uint8Array([...]);
|
|
76
|
+
* const derivedKeyBytes = await Hkdf.deriveKeyBytes({
|
|
77
|
+
* baseKeyBytes: new Uint8Array([...]), // Input keying material
|
|
78
|
+
* hash: 'SHA-256', // The hash function to use ('SHA-256', 'SHA-384', 'SHA-512')
|
|
79
|
+
* salt: new Uint8Array([...]), // The salt value
|
|
80
|
+
* info: new Uint8Array([...]), // Optional application-specific information
|
|
81
|
+
* length: 256 // The length of the derived key in bits
|
|
82
|
+
* });
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @param params - The parameters for key derivation.
|
|
86
|
+
* @returns A Promise that resolves to the derived key as a byte array.
|
|
87
|
+
*/
|
|
88
|
+
static deriveKeyBytes({ baseKeyBytes, length, hash, salt, info }: DeriveKeyBytesParams & HkdfParams): Promise<Uint8Array>;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=hkdf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hkdf.d.ts","sourceRoot":"","sources":["../../../src/primitives/hkdf.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAMtE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;;;;OAKG;IACH,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAExC;;;;;;;;;OASG;IACH,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAE1B;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CAC5B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,IAAI;IACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;WACiB,cAAc,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAuB,EAAE,EAC9F,oBAAoB,GAAG,UAAU,GAChC,OAAO,CAAC,UAAU,CAAC;CAuBvB"}
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
import type { DeriveKeyBytesParams } from '../types/params-direct.js';
|
|
2
|
+
/**
|
|
3
|
+
* The object that should be passed into `Pbkdf2.deriveKeyBytes()`, when using the PBKDF2 algorithm.
|
|
4
|
+
*/
|
|
5
|
+
export interface Pbkdf2Params {
|
|
6
|
+
/**
|
|
7
|
+
* A string representing the digest algorithm to use. This may be one of:
|
|
8
|
+
* - 'SHA-256'
|
|
9
|
+
* - 'SHA-384'
|
|
10
|
+
* - 'SHA-512'
|
|
11
|
+
*/
|
|
12
|
+
hash: 'SHA-256' | 'SHA-384' | 'SHA-512';
|
|
13
|
+
/**
|
|
14
|
+
* The salt value to use in the derivation process, as a Uint8Array. This should be a random or
|
|
15
|
+
* pseudo-random value of at least 16 bytes. Unlike the `password`, `salt` does not need to be
|
|
16
|
+
* kept secret.
|
|
17
|
+
*/
|
|
18
|
+
salt: Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* A `Number` representing the number of iterations the hash function will be executed in
|
|
21
|
+
* `deriveKey()`. This impacts the computational cost of the `deriveKey()` operation, making it
|
|
22
|
+
* more resistant to dictionary attacks. The higher the number, the more secure, but also slower,
|
|
23
|
+
* the operation. Choose a value that balances security needs and performance for your
|
|
24
|
+
* application.
|
|
25
|
+
*/
|
|
26
|
+
iterations: number;
|
|
27
|
+
}
|
|
1
28
|
/**
|
|
2
29
|
* The object that should be passed into `Pbkdf2.deriveKey()`, when using the PBKDF2 algorithm.
|
|
3
30
|
*/
|
|
@@ -90,5 +117,36 @@ export declare class Pbkdf2 {
|
|
|
90
117
|
* @returns A Promise that resolves to the derived key as a Uint8Array.
|
|
91
118
|
*/
|
|
92
119
|
static deriveKey({ hash, password, salt, iterations, length }: Pbkdf2DeriveKeyParams): Promise<Uint8Array>;
|
|
120
|
+
/**
|
|
121
|
+
* Derives cryptographic key bytes from base key material using the PBKDF2 algorithm.
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* This method is similar to {@link Pbkdf2.deriveKey | `deriveKey()`} but accepts
|
|
125
|
+
* raw key bytes (`baseKeyBytes`) instead of a password. It is intended for use cases
|
|
126
|
+
* where the input key material is already available as a byte array.
|
|
127
|
+
*
|
|
128
|
+
* Notes:
|
|
129
|
+
* - The `baseKeyBytes` that will be the input key material for PBKDF2 is expected to be a
|
|
130
|
+
* low-entropy value, such as a password or passphrase. It should be kept confidential.
|
|
131
|
+
* - In 2023,
|
|
132
|
+
* {@link https://web.archive.org/web/20230123232056/https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_Cheat_Sheet.html#pbkdf2
|
|
133
|
+
* | OWASP recommended}
|
|
134
|
+
* a minimum of 600,000 iterations for PBKDF2-HMAC-SHA256 and 210,000 for PBKDF2-HMAC-SHA512.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```ts
|
|
138
|
+
* const derivedKeyBytes = await Pbkdf2.deriveKeyBytes({
|
|
139
|
+
* baseKeyBytes: new TextEncoder().encode('password'),
|
|
140
|
+
* hash: 'SHA-256',
|
|
141
|
+
* salt: new Uint8Array([...]),
|
|
142
|
+
* iterations: 600_000,
|
|
143
|
+
* length: 256
|
|
144
|
+
* });
|
|
145
|
+
* ```
|
|
146
|
+
*
|
|
147
|
+
* @param params - The parameters for key derivation.
|
|
148
|
+
* @returns A Promise that resolves to the derived key as a byte array.
|
|
149
|
+
*/
|
|
150
|
+
static deriveKeyBytes({ baseKeyBytes, hash, salt, iterations, length }: DeriveKeyBytesParams & Pbkdf2Params): Promise<Uint8Array>;
|
|
93
151
|
}
|
|
94
152
|
//# sourceMappingURL=pbkdf2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pbkdf2.d.ts","sourceRoot":"","sources":["../../../src/primitives/pbkdf2.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pbkdf2.d.ts","sourceRoot":"","sources":["../../../src/primitives/pbkdf2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAMtE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAExC;;;;OAIG;IACH,IAAI,EAAE,UAAU,CAAC;IAEjB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;;OAKG;IACH,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAExC;;OAEG;IACH,QAAQ,EAAE,UAAU,CAAC;IAErB;;;;OAIG;IACH,IAAI,EAAE,UAAU,CAAC;IAEjB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,MAAM;IACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;WACiB,SAAS,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,EACxE,qBAAqB,GACpB,OAAO,CAAC,UAAU,CAAC;IAsBtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;WACiB,cAAc,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,EACjF,oBAAoB,GAAG,YAAY,GAClC,OAAO,CAAC,UAAU,CAAC;CAyBvB"}
|
|
@@ -238,32 +238,25 @@ export declare class X25519 {
|
|
|
238
238
|
publicKey: Jwk;
|
|
239
239
|
}): Promise<Uint8Array>;
|
|
240
240
|
/**
|
|
241
|
-
* Computes an
|
|
242
|
-
* using
|
|
241
|
+
* Computes an X25519 Elliptic Curve Diffie-Hellman (ECDH) shared secret
|
|
242
|
+
* using X25519 private and public keys in JSON Web Key (JWK) format.
|
|
243
243
|
*
|
|
244
244
|
* @remarks
|
|
245
245
|
* This method facilitates the ECDH key agreement protocol, which is a method of securely
|
|
246
246
|
* deriving a shared secret between two parties based on their private and public keys.
|
|
247
247
|
* It takes the private key of one party (privateKeyA) and the public key of another
|
|
248
|
-
* party (publicKeyB) to compute a shared secret. The shared secret is
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
* consists of an x-coordinate and a y-coordinate. With a 256-bit curve like
|
|
255
|
-
* secp256k1, each of these coordinates is 32 bytes (256 bits) long. However,
|
|
256
|
-
* in the ECDH process, it's standard practice to use only the x-coordinate
|
|
257
|
-
* of the shared secret point as the resulting shared key. This is because
|
|
258
|
-
* the y-coordinate does not add to the entropy of the key, and both parties
|
|
259
|
-
* can independently compute the x-coordinate. Consquently, this implementation
|
|
260
|
-
* omits the y-coordinate for simplicity and standard compliance.
|
|
248
|
+
* party (publicKeyB) to compute a shared secret. The shared secret is the raw output
|
|
249
|
+
* of the X25519 function as defined in RFC 7748.
|
|
250
|
+
*
|
|
251
|
+
* Note: Unlike Weierstrass curves (e.g., secp256k1), X25519 is a Montgomery curve
|
|
252
|
+
* where the ECDH output is a single 32-byte scalar value, not an (x, y) point.
|
|
253
|
+
* The result is used directly as the shared secret.
|
|
261
254
|
*
|
|
262
255
|
* @example
|
|
263
256
|
* ```ts
|
|
264
257
|
* const privateKeyA = { ... }; // A Jwk object for party A
|
|
265
258
|
* const publicKeyB = { ... }; // A PublicKeyJwk object for party B
|
|
266
|
-
* const sharedSecret = await
|
|
259
|
+
* const sharedSecret = await X25519.sharedSecret({
|
|
267
260
|
* privateKeyA,
|
|
268
261
|
* publicKeyB
|
|
269
262
|
* });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"x25519.d.ts","sourceRoot":"","sources":["../../../src/primitives/x25519.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAI5F;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,qBAAa,MAAM;IACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;WACiB,iBAAiB,CAAC,EAAE,eAAe,EAAE,EAAE;QACzD,eAAe,EAAE,UAAU,CAAC;KAC7B,GAAG,OAAO,CAAC,GAAG,CAA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AO,CAAC,GAAG,CAAC;IAkBhB;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;WACiB,gBAAgB,CAAC,EAAE,cAAc,EAAE,EAAE;QACvD,cAAc,EAAE,UAAU,CAAC;KAC5B,GAAG,OAAO,CAAC,GAAG,CAAC;IAchB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;WACiB,gBAAgB,CAAC,EAAE,GAAG,EAAE,EAC1C,sBAAsB,GACrB,OAAO,CAAC,GAAG,CAAC;IAoBf;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;WACiB,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;IAa/C;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;WACiB,YAAY,CAAC,EAAE,GAAG,EAAE,EACtC,kBAAkB,GACjB,OAAO,CAAC,GAAG,CAAC;IAef;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;WACiB,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAAE;QACpD,UAAU,EAAE,GAAG,CAAC;KACjB,GAAG,OAAO,CAAC,UAAU,CAAC;IAYvB;;;;;;;;;;;;;;;;;;;;;;OAsBG;WACiB,gBAAgB,CAAC,EAAE,SAAS,EAAE,EAAE;QAClD,SAAS,EAAE,GAAG,CAAC;KAChB,GAAG,OAAO,CAAC,UAAU,CAAC;IAYvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;WACiB,YAAY,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,EAAE;QAC5D,WAAW,EAAE,GAAG,CAAC;QACjB,UAAU,EAAE,GAAG,CAAC;KACjB,GAAG,OAAO,CAAC,UAAU,CAAC;CAexB"}
|
|
@@ -124,6 +124,28 @@ export declare class XChaCha20Poly1305 {
|
|
|
124
124
|
key: Jwk;
|
|
125
125
|
nonce: Uint8Array;
|
|
126
126
|
}): Promise<Uint8Array>;
|
|
127
|
+
/**
|
|
128
|
+
* Decrypts data using XChaCha20-Poly1305 with a raw byte array key.
|
|
129
|
+
*
|
|
130
|
+
* @remarks
|
|
131
|
+
* This is a lower-level method that accepts the key as a raw `Uint8Array` instead of a JWK.
|
|
132
|
+
* It is useful in scenarios where the key material is already in byte form (e.g., derived
|
|
133
|
+
* from ECDH + HKDF) and constructing a JWK would add unnecessary overhead.
|
|
134
|
+
*
|
|
135
|
+
* @param params - The parameters for the decryption operation.
|
|
136
|
+
* @param params.data - The encrypted data including the authentication tag.
|
|
137
|
+
* @param params.keyBytes - The 256-bit (32-byte) decryption key as a Uint8Array.
|
|
138
|
+
* @param params.nonce - The 24-byte nonce used during encryption.
|
|
139
|
+
* @param params.additionalData - Optional additional authenticated data.
|
|
140
|
+
*
|
|
141
|
+
* @returns A Promise that resolves to the decrypted plaintext as a Uint8Array.
|
|
142
|
+
*/
|
|
143
|
+
static decryptRaw({ data, keyBytes, nonce, additionalData }: {
|
|
144
|
+
additionalData?: Uint8Array;
|
|
145
|
+
data: Uint8Array;
|
|
146
|
+
keyBytes: Uint8Array;
|
|
147
|
+
nonce: Uint8Array;
|
|
148
|
+
}): Promise<Uint8Array>;
|
|
127
149
|
/**
|
|
128
150
|
* Encrypts the provided data using XChaCha20-Poly1305.
|
|
129
151
|
*
|
|
@@ -163,6 +185,31 @@ export declare class XChaCha20Poly1305 {
|
|
|
163
185
|
key: Jwk;
|
|
164
186
|
nonce: Uint8Array;
|
|
165
187
|
}): Promise<Uint8Array>;
|
|
188
|
+
/**
|
|
189
|
+
* Encrypts data using XChaCha20-Poly1305 with a raw byte array key.
|
|
190
|
+
*
|
|
191
|
+
* @remarks
|
|
192
|
+
* This is a lower-level method that accepts the key as a raw `Uint8Array` instead of a JWK.
|
|
193
|
+
* It is useful in scenarios where the key material is already in byte form (e.g., derived
|
|
194
|
+
* from ECDH + HKDF) and constructing a JWK would add unnecessary overhead.
|
|
195
|
+
*
|
|
196
|
+
* The returned `Uint8Array` contains the ciphertext followed by the 16-byte Poly1305
|
|
197
|
+
* authentication tag.
|
|
198
|
+
*
|
|
199
|
+
* @param params - The parameters for the encryption operation.
|
|
200
|
+
* @param params.data - The plaintext data to encrypt.
|
|
201
|
+
* @param params.keyBytes - The 256-bit (32-byte) encryption key as a Uint8Array.
|
|
202
|
+
* @param params.nonce - A 24-byte nonce for the encryption process.
|
|
203
|
+
* @param params.additionalData - Optional additional authenticated data.
|
|
204
|
+
*
|
|
205
|
+
* @returns A Promise that resolves to the ciphertext + authentication tag as a Uint8Array.
|
|
206
|
+
*/
|
|
207
|
+
static encryptRaw({ data, keyBytes, nonce, additionalData }: {
|
|
208
|
+
additionalData?: Uint8Array;
|
|
209
|
+
data: Uint8Array;
|
|
210
|
+
keyBytes: Uint8Array;
|
|
211
|
+
nonce: Uint8Array;
|
|
212
|
+
}): Promise<Uint8Array>;
|
|
166
213
|
/**
|
|
167
214
|
* Generates a symmetric key for XChaCha20-Poly1305 in JSON Web Key (JWK) format.
|
|
168
215
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xchacha20-poly1305.d.ts","sourceRoot":"","sources":["../../../src/primitives/xchacha20-poly1305.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAI1C;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,KAAK,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,qBAAa,iBAAiB;IAC5B;;;;;;;;;;;;;;;;;;;;;;;OAuBG;WACiB,iBAAiB,CAAC,EAAE,eAAe,EAAE,EAAE;QACzD,eAAe,EAAE,UAAU,CAAC;KAC7B,GAAG,OAAO,CAAC,GAAG,CAAC;IAahB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;WACiB,OAAO,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;QAChE,cAAc,CAAC,EAAE,UAAU,CAAC;QAC5B,IAAI,EAAE,UAAU,CAAC;QACjB,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,EAAE,EAAE;QAChE,cAAc,CAAC,EAAE,UAAU,CAAC;QAC5B,IAAI,EAAE,UAAU,CAAC;QACjB,GAAG,EAAE,GAAG,CAAC;QACT,KAAK,EAAE,UAAU,CAAC;KACnB,GAAG,OAAO,CAAC,UAAU,CAAC;IAOvB;;;;;;;;;;;;;;;;;;OAkBG;WACiB,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;QACxE,cAAc,CAAC,EAAE,UAAU,CAAC;QAC5B,IAAI,EAAE,UAAU,CAAC;QACjB,QAAQ,EAAE,UAAU,CAAC;QACrB,KAAK,EAAE,UAAU,CAAC;KACnB,GAAG,OAAO,CAAC,UAAU,CAAC;IAOvB;;;;;;;;;;;;;;;;;;;;OAoBG;WACiB,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC;IAkB/C;;;;;;;;;;;;;;;;;OAiBG;WACiB,iBAAiB,CAAC,EAAE,UAAU,EAAE,EAAE;QACpD,UAAU,EAAE,GAAG,CAAC;KACjB,GAAG,OAAO,CAAC,UAAU,CAAC;CAWxB"}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
+
import type { AsymmetricKeyConverter } from './key-converter.js';
|
|
2
|
+
import type { AsymmetricKeyGenerator } from './key-generator.js';
|
|
3
|
+
import type { Cipher } from './cipher.js';
|
|
1
4
|
import type { Hasher } from './hasher.js';
|
|
2
|
-
import type {
|
|
5
|
+
import type { Jwk } from '../jose/jwk.js';
|
|
3
6
|
import type { KeyIdentifier } from './identifier.js';
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
7
|
+
import type { KeyWrapper } from './key-wrapper.js';
|
|
8
|
+
import type { Signer } from './signer.js';
|
|
9
|
+
import type { BytesToPrivateKeyParams, BytesToPublicKeyParams, CipherParams, DeriveKeyBytesParams, DeriveKeyFromBytesParams, DigestParams, GenerateKeyParams, GetPublicKeyParams, PrivateKeyToBytesParams, PublicKeyToBytesParams, SignParams, UnwrapKeyParams, VerifyParams, WrapKeyParams } from './params-direct.js';
|
|
10
|
+
import type { KeyBytesDeriver, SimpleKeyDeriver } from './key-deriver.js';
|
|
11
|
+
import type { KmsCipherParams, KmsDigestParams, KmsGenerateKeyParams, KmsGetKeyUriParams, KmsGetPublicKeyParams, KmsSignParams, KmsVerifyParams } from './params-kms.js';
|
|
6
12
|
/**
|
|
7
|
-
* The `
|
|
13
|
+
* The `DsaApi` interface integrates key generation, hashing, and signing functionalities,
|
|
8
14
|
* designed for use with a Key Management System (KMS). It extends `AsymmetricKeyGenerator` for
|
|
9
15
|
* generating asymmetric keys, `Hasher` for hash digest computations, and `Signer` for signing and
|
|
10
16
|
* verifying operations.
|
|
@@ -24,12 +30,54 @@ import type { KmsSignParams, KmsDigestParams, KmsVerifyParams, KmsGetKeyUriParam
|
|
|
24
30
|
* identifier (e.g. JWK thumbprint, UUID generated by hosted KMS, etc.).
|
|
25
31
|
* - Must support key generation, hashing, signing, and verifying operations.
|
|
26
32
|
* - May be extended to support other cryptographic operations.
|
|
27
|
-
* - Implementations of the `
|
|
33
|
+
* - Implementations of the `DsaApi` interface can be passed as an argument to the public API
|
|
28
34
|
* methods of Web5 libraries that involve key material (e.g., DID creation, VC signing, arbitrary
|
|
29
35
|
* data signing/verification, etc.).
|
|
30
36
|
*/
|
|
31
|
-
export interface
|
|
37
|
+
export interface DsaApi<GenerateKeyInput = KmsGenerateKeyParams, GenerateKeyOutput = KeyIdentifier, GetPublicKeyInput = KmsGetPublicKeyParams, DigestInput = KmsDigestParams, SignInput = KmsSignParams, VerifyInput = KmsVerifyParams> extends AsymmetricKeyGenerator<GenerateKeyInput, GenerateKeyOutput, GetPublicKeyInput>, Hasher<DigestInput>, Signer<SignInput, VerifyInput> {
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The `CryptoApi` interface extends {@link DsaApi} with encryption, key conversion,
|
|
41
|
+
* key derivation, and key wrapping capabilities.
|
|
42
|
+
*
|
|
43
|
+
* This is the full-featured cryptographic API used by agent-level code that needs direct-key
|
|
44
|
+
* cipher, key conversion, and key derivation operations beyond what the base `DsaApi` provides.
|
|
45
|
+
*/
|
|
46
|
+
export interface CryptoApi<GenerateKeyInput = GenerateKeyParams, GenerateKeyOutput = Jwk, GetPublicKeyInput = GetPublicKeyParams, DigestInput = DigestParams, SignInput = SignParams, VerifyInput = VerifyParams, EncryptInput = CipherParams, DecryptInput = CipherParams, BytesToPublicKeyInput = BytesToPublicKeyParams, PublicKeyToBytesInput = PublicKeyToBytesParams, BytesToPrivateKeyInput = BytesToPrivateKeyParams, PrivateKeyToBytesInput = PrivateKeyToBytesParams, DeriveKeyInput = DeriveKeyFromBytesParams, DeriveKeyOutput = Jwk, DeriveKeyBytesInput = DeriveKeyBytesParams, DeriveKeyBytesOutput = Uint8Array, WrapKeyInput = WrapKeyParams, UnwrapKeyInput = UnwrapKeyParams> extends DsaApi<GenerateKeyInput, GenerateKeyOutput, GetPublicKeyInput, DigestInput, SignInput, VerifyInput>, Cipher<EncryptInput, DecryptInput>, AsymmetricKeyConverter<BytesToPublicKeyInput, PublicKeyToBytesInput, BytesToPrivateKeyInput, PrivateKeyToBytesInput>, SimpleKeyDeriver<DeriveKeyInput, DeriveKeyOutput>, KeyBytesDeriver<DeriveKeyBytesInput, DeriveKeyBytesOutput>, KeyWrapper<WrapKeyInput, UnwrapKeyInput> {
|
|
47
|
+
}
|
|
48
|
+
/** @deprecated Use {@link CryptoApi} instead. */
|
|
49
|
+
export type ExtendedCryptoApi<GenerateKeyInput = GenerateKeyParams, GenerateKeyOutput = Jwk, GetPublicKeyInput = GetPublicKeyParams, DigestInput = DigestParams, SignInput = SignParams, VerifyInput = VerifyParams, EncryptInput = CipherParams, DecryptInput = CipherParams, BytesToPublicKeyInput = BytesToPublicKeyParams, PublicKeyToBytesInput = PublicKeyToBytesParams, BytesToPrivateKeyInput = BytesToPrivateKeyParams, PrivateKeyToBytesInput = PrivateKeyToBytesParams, DeriveKeyInput = DeriveKeyFromBytesParams, DeriveKeyOutput = Jwk, DeriveKeyBytesInput = DeriveKeyBytesParams, DeriveKeyBytesOutput = Uint8Array, WrapKeyInput = WrapKeyParams, UnwrapKeyInput = UnwrapKeyParams> = CryptoApi<GenerateKeyInput, GenerateKeyOutput, GetPublicKeyInput, DigestInput, SignInput, VerifyInput, EncryptInput, DecryptInput, BytesToPublicKeyInput, PublicKeyToBytesInput, BytesToPrivateKeyInput, PrivateKeyToBytesInput, DeriveKeyInput, DeriveKeyOutput, DeriveKeyBytesInput, DeriveKeyBytesOutput, WrapKeyInput, UnwrapKeyInput>;
|
|
50
|
+
/**
|
|
51
|
+
* Parameters for configuring a {@link KeyManager} implementation.
|
|
52
|
+
*/
|
|
53
|
+
export interface KeyManagerParams {
|
|
54
|
+
CipherInput?: unknown;
|
|
55
|
+
GenerateKeyInput?: unknown;
|
|
56
|
+
GenerateKeyOutput?: unknown;
|
|
57
|
+
GetPublicKeyInput?: unknown;
|
|
58
|
+
SignInput?: unknown;
|
|
59
|
+
VerifyInput?: unknown;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Default parameter types for {@link KeyManager}, using KMS-oriented types.
|
|
63
|
+
*/
|
|
64
|
+
export interface DefaultKeyManagerParams {
|
|
65
|
+
CipherInput: KmsCipherParams;
|
|
66
|
+
GenerateKeyInput: KmsGenerateKeyParams;
|
|
67
|
+
GenerateKeyOutput: KeyIdentifier;
|
|
68
|
+
GetPublicKeyInput: KmsGetPublicKeyParams;
|
|
69
|
+
SignInput: KmsSignParams;
|
|
70
|
+
VerifyInput: KmsVerifyParams;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The `KeyManager` interface integrates key generation and signing capabilities.
|
|
74
|
+
*
|
|
75
|
+
* Concrete implementations of this interface are intended to be used as a Key Management System
|
|
76
|
+
* (KMS), which is responsible for generating and storing cryptographic keys.
|
|
77
|
+
*/
|
|
78
|
+
export interface KeyManager<T extends KeyManagerParams = DefaultKeyManagerParams> extends DsaApi<T['GenerateKeyInput'], T['GenerateKeyOutput'], T['GetPublicKeyInput'], KmsDigestParams, T['SignInput'], T['VerifyInput']> {
|
|
32
79
|
/**
|
|
80
|
+
* Returns the Key URI for a given JWK.
|
|
33
81
|
*
|
|
34
82
|
* @param params - The parameters for getting the key URI.
|
|
35
83
|
* @param params.key - The key to get the URI for.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-api.d.ts","sourceRoot":"","sources":["../../../src/types/crypto-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"crypto-api.d.ts","sourceRoot":"","sources":["../../../src/types/crypto-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EACV,uBAAuB,EACvB,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,UAAU,EACV,eAAe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AC5B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,WAAW,EAAE,eAAe,CAAC;IAC7B,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,iBAAiB,EAAE,aAAa,CAAC;IACjC,iBAAiB,EAAE,qBAAqB,CAAC;IACzC,SAAS,EAAE,aAAa,CAAC;IACzB,WAAW,EAAE,eAAe,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,gBAAgB,GAAG,uBAAuB,CAC9E,SAAQ,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC,mBAAmB,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC;IAExI;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC/D"}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import type { Jwk } from '../jose/jwk.js';
|
|
2
2
|
/**
|
|
3
3
|
* `KeyConverter` interface for converting private keys between byte array and JWK formats.
|
|
4
|
+
*
|
|
5
|
+
* @typeParam BytesToPrivateKeyInput - The input type for `bytesToPrivateKey`. Defaults to
|
|
6
|
+
* `{ privateKeyBytes: Uint8Array }`.
|
|
7
|
+
* @typeParam PrivateKeyToBytesInput - The input type for `privateKeyToBytes`. Defaults to
|
|
8
|
+
* `{ privateKey: Jwk }`.
|
|
4
9
|
*/
|
|
5
|
-
export interface KeyConverter {
|
|
10
|
+
export interface KeyConverter<BytesToPrivateKeyInput = {
|
|
11
|
+
privateKeyBytes: Uint8Array;
|
|
12
|
+
}, PrivateKeyToBytesInput = {
|
|
13
|
+
privateKey: Jwk;
|
|
14
|
+
}> {
|
|
6
15
|
/**
|
|
7
16
|
* Converts a private key from a byte array to JWK format.
|
|
8
17
|
*
|
|
@@ -11,9 +20,7 @@ export interface KeyConverter {
|
|
|
11
20
|
*
|
|
12
21
|
* @returns A Promise that resolves to the private key in JWK format.
|
|
13
22
|
*/
|
|
14
|
-
bytesToPrivateKey(params:
|
|
15
|
-
privateKeyBytes: Uint8Array;
|
|
16
|
-
}): Promise<Jwk>;
|
|
23
|
+
bytesToPrivateKey(params: BytesToPrivateKeyInput): Promise<Jwk>;
|
|
17
24
|
/**
|
|
18
25
|
* Converts a private key from JWK format to a byte array.
|
|
19
26
|
*
|
|
@@ -22,15 +29,34 @@ export interface KeyConverter {
|
|
|
22
29
|
*
|
|
23
30
|
* @returns A Promise that resolves to the private key as a Uint8Array.
|
|
24
31
|
*/
|
|
25
|
-
privateKeyToBytes(params:
|
|
26
|
-
privateKey: Jwk;
|
|
27
|
-
}): Promise<Uint8Array>;
|
|
32
|
+
privateKeyToBytes(params: PrivateKeyToBytesInput): Promise<Uint8Array>;
|
|
28
33
|
}
|
|
29
34
|
/**
|
|
30
|
-
* `AsymmetricKeyConverter` interface extends {@link KeyConverter
|
|
35
|
+
* `AsymmetricKeyConverter` interface extends {@link KeyConverter | `KeyConverter`}, adding support
|
|
31
36
|
* for public key conversions.
|
|
37
|
+
*
|
|
38
|
+
* When used with default type parameters, this interface includes all four conversion methods
|
|
39
|
+
* (bytes-to/from private key AND bytes-to/from public key). When used with explicit type
|
|
40
|
+
* parameters, both the private and public key conversion types can be customized.
|
|
41
|
+
*
|
|
42
|
+
* @typeParam BytesToPublicKeyInput - The input type for `bytesToPublicKey`. Defaults to
|
|
43
|
+
* `{ publicKeyBytes: Uint8Array }`.
|
|
44
|
+
* @typeParam PublicKeyToBytesInput - The input type for `publicKeyToBytes`. Defaults to
|
|
45
|
+
* `{ publicKey: Jwk }`.
|
|
46
|
+
* @typeParam BytesToPrivateKeyInput - The input type for `bytesToPrivateKey`. Defaults to
|
|
47
|
+
* `{ privateKeyBytes: Uint8Array }`.
|
|
48
|
+
* @typeParam PrivateKeyToBytesInput - The input type for `privateKeyToBytes`. Defaults to
|
|
49
|
+
* `{ privateKey: Jwk }`.
|
|
32
50
|
*/
|
|
33
|
-
export interface AsymmetricKeyConverter
|
|
51
|
+
export interface AsymmetricKeyConverter<BytesToPublicKeyInput = {
|
|
52
|
+
publicKeyBytes: Uint8Array;
|
|
53
|
+
}, PublicKeyToBytesInput = {
|
|
54
|
+
publicKey: Jwk;
|
|
55
|
+
}, BytesToPrivateKeyInput = {
|
|
56
|
+
privateKeyBytes: Uint8Array;
|
|
57
|
+
}, PrivateKeyToBytesInput = {
|
|
58
|
+
privateKey: Jwk;
|
|
59
|
+
}> extends KeyConverter<BytesToPrivateKeyInput, PrivateKeyToBytesInput> {
|
|
34
60
|
/**
|
|
35
61
|
* Converts a public key from a byte array to JWK format.
|
|
36
62
|
*
|
|
@@ -39,9 +65,7 @@ export interface AsymmetricKeyConverter extends KeyConverter {
|
|
|
39
65
|
*
|
|
40
66
|
* @returns A Promise that resolves to the public key in JWK format.
|
|
41
67
|
*/
|
|
42
|
-
bytesToPublicKey(params:
|
|
43
|
-
publicKeyBytes: Uint8Array;
|
|
44
|
-
}): Promise<Jwk>;
|
|
68
|
+
bytesToPublicKey(params: BytesToPublicKeyInput): Promise<Jwk>;
|
|
45
69
|
/**
|
|
46
70
|
* Converts a public key from JWK format to a byte array.
|
|
47
71
|
*
|
|
@@ -50,8 +74,6 @@ export interface AsymmetricKeyConverter extends KeyConverter {
|
|
|
50
74
|
*
|
|
51
75
|
* @returns A Promise that resolves to the public key as a Uint8Array.
|
|
52
76
|
*/
|
|
53
|
-
publicKeyToBytes(params:
|
|
54
|
-
publicKey: Jwk;
|
|
55
|
-
}): Promise<Uint8Array>;
|
|
77
|
+
publicKeyToBytes(params: PublicKeyToBytesInput): Promise<Uint8Array>;
|
|
56
78
|
}
|
|
57
79
|
//# sourceMappingURL=key-converter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-converter.d.ts","sourceRoot":"","sources":["../../../src/types/key-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE1C
|
|
1
|
+
{"version":3,"file":"key-converter.d.ts","sourceRoot":"","sources":["../../../src/types/key-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY,CAC3B,sBAAsB,GAAG;IAAE,eAAe,EAAE,UAAU,CAAA;CAAE,EACxD,sBAAsB,GAAG;IAAE,UAAU,EAAE,GAAG,CAAA;CAAE;IAG5C;;;;;;;OAOG;IACH,iBAAiB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAEhE;;;;;;;OAOG;IACH,iBAAiB,CAAC,MAAM,EAAE,sBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACxE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,sBAAsB,CACrC,qBAAqB,GAAG;IAAE,cAAc,EAAE,UAAU,CAAA;CAAE,EACtD,qBAAqB,GAAG;IAAE,SAAS,EAAE,GAAG,CAAA;CAAE,EAC1C,sBAAsB,GAAG;IAAE,eAAe,EAAE,UAAU,CAAA;CAAE,EACxD,sBAAsB,GAAG;IAAE,UAAU,EAAE,GAAG,CAAA;CAAE,CAC5C,SAAQ,YAAY,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IACpE;;;;;;;OAOG;IACH,gBAAgB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE9D;;;;;;;OAOG;IACH,gBAAgB,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CACtE"}
|
|
@@ -36,4 +36,45 @@ export interface KeyDeriver<DeriveBitsInput, DeriveKeyInput, DeriveKeyOutput> {
|
|
|
36
36
|
*/
|
|
37
37
|
deriveKey(params: DeriveKeyInput): Promise<DeriveKeyOutput>;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* The `SimpleKeyDeriver` interface provides a single `deriveKey()` method for key derivation,
|
|
41
|
+
* without the `deriveBits()` method that {@link KeyDeriver} includes.
|
|
42
|
+
*
|
|
43
|
+
* This is useful for implementations that only need key derivation (not raw bit derivation).
|
|
44
|
+
*/
|
|
45
|
+
export interface SimpleKeyDeriver<DeriveKeyInput, DeriveKeyOutput> {
|
|
46
|
+
/**
|
|
47
|
+
* Derives a cryptographic key based on the provided input parameters.
|
|
48
|
+
*
|
|
49
|
+
* @param params - The parameters for the key derivation process.
|
|
50
|
+
*
|
|
51
|
+
* @returns A Promise resolving to the derived key in the specified output format.
|
|
52
|
+
*/
|
|
53
|
+
deriveKey(params: DeriveKeyInput): Promise<DeriveKeyOutput>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The `KeyBytesDeriver` interface provides a method for deriving a byte array using a key
|
|
57
|
+
* derivation algorithm.
|
|
58
|
+
*
|
|
59
|
+
* The `deriveKeyBytes()` method derives cryptographic bits from input data using the specified
|
|
60
|
+
* key derivation algorithm. This interface is designed to support various key derivation
|
|
61
|
+
* algorithms, accommodating different input and output types.
|
|
62
|
+
*/
|
|
63
|
+
export interface KeyBytesDeriver<DeriveKeyBytesInput, DeriveKeyBytesOutput> {
|
|
64
|
+
/**
|
|
65
|
+
* Generates a specified number of cryptographic bits from given input parameters.
|
|
66
|
+
*
|
|
67
|
+
* @remarks
|
|
68
|
+
* The `deriveKeyBytes()` method of the {@link KeyBytesDeriver | `KeyBytesDeriver`} interface is
|
|
69
|
+
* used to create cryptographic material such as initialization vectors or keys from various
|
|
70
|
+
* sources. The method takes in parameters specific to the chosen key derivation algorithm and
|
|
71
|
+
* outputs a promise that resolves to a `Uint8Array` containing the derived bits.
|
|
72
|
+
*
|
|
73
|
+
* @param params - The parameters for the key derivation process, specific to the chosen
|
|
74
|
+
* algorithm.
|
|
75
|
+
*
|
|
76
|
+
* @returns A Promise resolving to the derived bits in the specified format.
|
|
77
|
+
*/
|
|
78
|
+
deriveKeyBytes(params: DeriveKeyBytesInput): Promise<DeriveKeyBytesOutput>;
|
|
79
|
+
}
|
|
39
80
|
//# sourceMappingURL=key-deriver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key-deriver.d.ts","sourceRoot":"","sources":["../../../src/types/key-deriver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU,CACzB,eAAe,EACf,cAAc,EACd,eAAe;IAEf;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEzD;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7D"}
|
|
1
|
+
{"version":3,"file":"key-deriver.d.ts","sourceRoot":"","sources":["../../../src/types/key-deriver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU,CACzB,eAAe,EACf,cAAc,EACd,eAAe;IAEf;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEzD;;;;;;;;;;;;OAYG;IACH,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7D;AAED;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAC/B,cAAc,EACd,eAAe;IAEf;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAC7D;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe,CAC9B,mBAAmB,EACnB,oBAAoB;IAEpB;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAC5E"}
|
|
@@ -34,4 +34,41 @@ export interface KeyImporterExporter<ImportKeyInput, ImportKeyOutput, ExportKeyI
|
|
|
34
34
|
*/
|
|
35
35
|
importKey(params: ImportKeyInput): Promise<ImportKeyOutput>;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* The `KeyExporter` interface provides a method for exporting cryptographic keys.
|
|
39
|
+
*/
|
|
40
|
+
export interface KeyExporter<ExportKeyInput, ExportKeyOutput = Jwk> {
|
|
41
|
+
/**
|
|
42
|
+
* Exports a cryptographic key to an external JWK object.
|
|
43
|
+
*
|
|
44
|
+
* @param params - The parameters for the key export operation.
|
|
45
|
+
*
|
|
46
|
+
* @returns A Promise resolving to the exported key in JWK format.
|
|
47
|
+
*/
|
|
48
|
+
exportKey(params: ExportKeyInput): Promise<ExportKeyOutput>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The `KeyImporter` interface provides a method for importing cryptographic keys.
|
|
52
|
+
*/
|
|
53
|
+
export interface KeyImporter<ImportKeyInput, ImportKeyOutput = void> {
|
|
54
|
+
/**
|
|
55
|
+
* Imports an external key in JWK format.
|
|
56
|
+
*
|
|
57
|
+
* @param params - The parameters for the key import operation.
|
|
58
|
+
*
|
|
59
|
+
* @returns A Promise resolving to the key identifier of the imported key.
|
|
60
|
+
*/
|
|
61
|
+
importKey(params: ImportKeyInput): Promise<ImportKeyOutput>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The `KeyDeleter` interface provides a method for deleting cryptographic keys.
|
|
65
|
+
*/
|
|
66
|
+
export interface KeyDeleter<DeleteKeyInput> {
|
|
67
|
+
/**
|
|
68
|
+
* Deletes a cryptographic key from the key store.
|
|
69
|
+
*
|
|
70
|
+
* @param params - The parameters for the key deletion operation.
|
|
71
|
+
*/
|
|
72
|
+
deleteKey(params: DeleteKeyInput): Promise<void>;
|
|
73
|
+
}
|
|
37
74
|
//# sourceMappingURL=key-io.d.ts.map
|