55 * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/webcrypto/
66 */
77
8+ /**
9+ * @deprecated use global crypto instead.
10+ */
811export const crypto : Crypto ;
912
13+ /**
14+ * @deprecated use global crypto instead.
15+ */
1016export interface Crypto extends SubtleCrypto {
1117 /**
1218 * Returns a SubtleCrypto object providing access to common cryptographic
1319 * primitives, like hashing, signing, encryption, or decryption.
20+ *
21+ * @deprecated use global crypto.subtle instead.
1422 */
1523 readonly subtle : SubtleCrypto ;
1624
@@ -20,17 +28,24 @@ export interface Crypto extends SubtleCrypto {
2028 * @param typedArray - The TypedArray to fill with random values.
2129 * @throws {QuotaExceededError } - thrown if the `byteLength` of `typedArray` exceeds 65536.
2230 * @returns The typedArray argument.
31+ *
32+ * @deprecated use global crypto.getRandomValues crypto instead.
2333 */
2434 getRandomValues ( typedArray : TypedArray ) : TypedArray ;
2535
2636 /**
2737 * Returns a 36 character long string containing a cryptographically random UUID v4.
2838 *
2939 * @returns A 36 character long string containing a cryptographically random UUID v4.
40+ *
41+ * @deprecated use global crypto.randomUUID instead.
3042 */
3143 randomUUID ( ) : string ;
3244}
3345
46+ /**
47+ * @deprecated use global crypto.subtle instead.
48+ */
3449export interface SubtleCrypto {
3550 /**
3651 * The `decrypt()` method decrypts some encrypted data.
@@ -41,6 +56,7 @@ export interface SubtleCrypto {
4156 * @throws {InvalidAccessError } - if the provided key cannot be used for the decrypt operation.
4257 * @throws {OperationError } - if the operation failed for an operation-specific reason.
4358 * @returns A promise that resolves with the decrypted data (also known as "plaintext").
59+ * @deprecated use global crypto.subtle.decrypt instead.
4460 */
4561 decrypt (
4662 algorithm : AesCtrParams | AesCbcParams | AesGcmParams | RsaOaepParams ,
@@ -63,6 +79,7 @@ export interface SubtleCrypto {
6379 * @param algorithm names the algorithm to use.
6480 * @param data the data to be digested
6581 * @returns A promise that resolves with the digest value.
82+ * @deprecated use global crypto.subtle.digest instead.
6683 */
6784 digest (
6885 algorithm : HashAlgorithmIdentifier | Algorithm < HashAlgorithmIdentifier > ,
@@ -78,6 +95,7 @@ export interface SubtleCrypto {
7895 * @throws {InvalidAccessError } - if the provided key cannot be used for the encrypt operation.
7996 * @throws {OperationError } - if the operation failed for an operation-specific reason.
8097 * @returns A promise that resolves with the encrypted data (also known as "ciphertext").
98+ * @deprecated use global crypto.subtle.encrypt instead.
8199 */
82100 encrypt (
83101 algorithm : AesCtrParams | AesCbcParams | AesGcmParams | RsaOaepParams ,
@@ -97,6 +115,7 @@ export interface SubtleCrypto {
97115 * @throws {NotSupportedError } - if the format is not supported.
98116 * @throws {TypeError } - when trying to use an invalid format.
99117 * @returns A promise that resolves with the exported key.
118+ * @deprecated use global crypto.subtle.exportKey instead.
100119 */
101120 exportKey ( format : "raw" | "jwk" | "spki" | "pkcs8" , key : CryptoKey ) : Promise < ArrayBuffer | JWK > ;
102121
@@ -108,6 +127,7 @@ export interface SubtleCrypto {
108127 * @param keyUsages indicates what can be done with the newly generated key.
109128 * @throws {SyntaxError } - if the result is a `CryptoKey` of type `secret` or `private` but `keyUsages is empty.
110129 * @returns A promise that resolves with the newly generated `CryptoKey`.
130+ * @deprecated use global crypto.subtle.generateKey instead.
111131 */
112132 generateKey (
113133 algorithm : AesKeyGenParams | HmacKeyGenParams ,
@@ -123,6 +143,7 @@ export interface SubtleCrypto {
123143 * @param keyUsages indicates what can be done with the newly generated key.
124144 * @throws {SyntaxError } - if the result is a `CryptoKey` of type `secret` or `private` but `keyUsages is empty.
125145 * @returns A promise that resolves with the newly generated `CryptoKeyPair`.
146+ * @deprecated use global crypto.subtle.generateKey instead.
126147 */
127148 generateKey (
128149 algorithm : EcKeyGenParams | RSAHashedKeyGenParams ,
@@ -143,6 +164,7 @@ export interface SubtleCrypto {
143164 * @throws {SyntaxError } - if the result is a `CryptoKey` of type `secret` or `private` but `keyUsages is empty.
144165 * @throws {TypeError } - when trying to use an invalid format or if the `keyData` is not suited for that format.
145166 * @returns A promise that resolves with the imported `CryptoKey`.
167+ * @deprecated use global crypto.subtle.importKey instead.
146168 */
147169 importKey (
148170 format : "raw" | "jwk" | "spki" | "pkcs8" ,
@@ -170,6 +192,7 @@ export interface SubtleCrypto {
170192 * @param data the data to sign.
171193 * @throws {InvalidAccessError } - if the provided key cannot be used for the sign operation.
172194 * @returns A promise that resolves with the signature.
195+ * @deprecated use global crypto.subtle.sign instead.
173196 */
174197 sign (
175198 algorithm : "HMAC" | Algorithm < "HMAC" > | EcdsaParams | RsaPssParams ,
@@ -186,6 +209,7 @@ export interface SubtleCrypto {
186209 * @param data the data to verify.
187210 * @throws {InvalidAccessError } - if the provided key cannot be used for the verify operation.
188211 * @returns A promise that resolves with a boolean indicating whether the signature is valid.
212+ * @deprecated use global crypto.subtle.verify instead.
189213 */
190214 verify (
191215 algorithm : "HMAC" | Algorithm < "HMAC" > | EcdsaParams | RsaPssParams ,
@@ -200,6 +224,7 @@ export interface SubtleCrypto {
200224 * @param algorithm defines the derivation algorithm to use.
201225 * @param baseKey A `CryptoKey` representing the input to the derivation algorithm. Currently, only an ECDH private key is possible.
202226 * @param length A number representing the number of bits to derive. Currently, the number should be a multiple of 8.
227+ * @deprecated use global crypto.subtle.deriveBits instead.
203228 */
204229 deriveBits (
205230 algorithm : EcdhKeyDeriveParams ,
0 commit comments