@types/k6 0.43.3 → 0.44.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.
k6/README.md CHANGED
@@ -8,7 +8,7 @@ This package contains type definitions for k6 (https://k6.io/docs/).
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Thu, 13 Apr 2023 08:32:47 GMT
11
+ * Last updated: Thu, 27 Apr 2023 08:02:47 GMT
12
12
  * Dependencies: none
13
13
  * Global values: none
14
14
 
@@ -36,7 +36,7 @@ export class Client {
36
36
  * @param expiration - time to live in seconds. `0` means no expiration.
37
37
  * @returns a promise that resolves to "OK" if the operation succeeded.
38
38
  */
39
- set(key: string, value: any, expiration: number): Promise<string>;
39
+ set(key: string, value: string | number | boolean, expiration: number): Promise<string>;
40
40
 
41
41
  /**
42
42
  * Gets the value of a key.
@@ -58,7 +58,7 @@ export class Client {
58
58
  * @param value - value to set
59
59
  * @returns a promise that resolves to the old value of the key.
60
60
  */
61
- getSet(key: string, value: any): Promise<string>;
61
+ getSet(key: string, value: string | number | boolean): Promise<string>;
62
62
 
63
63
  /**
64
64
  * Removes the specified keys.
@@ -212,7 +212,7 @@ export class Client {
212
212
  * @param values - values to prepend to the list
213
213
  * @returns a promise that resolves to the number of elements in the list after the prepend operation.
214
214
  */
215
- lpsuh(key: string, values: any[]): Promise<number>;
215
+ lpsuh(key: string, ...values: Array<string | number | boolean>): Promise<number>;
216
216
 
217
217
  /**
218
218
  * Appends values to a list, creating the list if it does not already exist.
@@ -225,7 +225,7 @@ export class Client {
225
225
  * @param values - values to append to the list
226
226
  * @returns a promise that resolves to the number of elements in the list after the append operation.
227
227
  */
228
- rpush(key: string, values: any[]): Promise<number>;
228
+ rpush(key: string, ...values: Array<string | number | boolean>): Promise<number>;
229
229
 
230
230
  /**
231
231
  * Removes and returns the value at the head of the list stored at key.
@@ -329,7 +329,7 @@ export class Client {
329
329
  * @param value - value to set the field to
330
330
  * @returns a promise that resolves to the the number of fields that were changed.
331
331
  */
332
- hset(key: string, field: string, value: string): Promise<number>;
332
+ hset(key: string, field: string, value: string | number | boolean): Promise<number>;
333
333
 
334
334
  /**
335
335
  * Sets the value of a hash field to the specified value, if and only if the field does not yet exist.
@@ -437,7 +437,7 @@ export class Client {
437
437
  * @param members - the members to add to the set
438
438
  * @returns a promise that resolves to the number of members that were added to the set; excluding those that were already present.
439
439
  */
440
- sadd(key: string, members: any[]): Promise<number>;
440
+ sadd(key: string, ...members: Array<string | number | boolean>): Promise<number>;
441
441
 
442
442
  /**
443
443
  * Removes the specified members from the set stored at key.
@@ -451,7 +451,7 @@ export class Client {
451
451
  * @param members - the members to remove from the set
452
452
  * @returns a promise that resolves to the number of members that were removed from the set.
453
453
  */
454
- srem(key: string, members: any[]): Promise<number>;
454
+ srem(key: string, ...members: Array<string | number | boolean>): Promise<number>;
455
455
 
456
456
  /**
457
457
  * Returns whether or not the specified member is a member of the set stored at key.
@@ -462,7 +462,7 @@ export class Client {
462
462
  * @param member - the member to check the belonging of
463
463
  * @returns a promise that resolves to true if the member is a member of the set, false otherwise.
464
464
  */
465
- sismember(key: string, member: any): Promise<boolean>;
465
+ sismember(key: string, member: string | number | boolean): Promise<boolean>;
466
466
 
467
467
  /**
468
468
  * Returns the members of the set stored at key.
@@ -0,0 +1,401 @@
1
+ /**
2
+ * This module provides a subset of the Web Crypto API. It is an interface
3
+ * allowing a k6 script to use cryptographic primitives.
4
+ *
5
+ * https://k6.io/docs/javascript-api/k6-experimental/webcrypto/
6
+ */
7
+
8
+ export const crypto: Crypto;
9
+
10
+ export interface Crypto extends SubtleCrypto {
11
+ /**
12
+ * Returns a SubtleCrypto object providing access to common cryptographic
13
+ * primitives, like hashing, signing, encryption, or decryption.
14
+ */
15
+ readonly subtle: SubtleCrypto;
16
+
17
+ /**
18
+ * Fills the passed TypedArray with cryptographically sound random values.
19
+ *
20
+ *
21
+ * @param typedArray - The TypedArray to fill with random values.
22
+ * @throws {QuotaExceededError} - thrown if the `byteLength` of `typedArray` exceeds 65536.
23
+ * @returns The typedArray argument.
24
+ */
25
+ getRandomValues(typedArray: TypedArray): TypedArray;
26
+
27
+ /**
28
+ * Returns a 36 character long string containing a cryptographically random UUID v4.
29
+ *
30
+ * @returns A 36 character long string containing a cryptographically random UUID v4.
31
+ */
32
+ randomUUID(): string;
33
+ }
34
+
35
+ export interface SubtleCrypto {
36
+ /**
37
+ * The `decrypt()` method decrypts some encrypted data.
38
+ *
39
+ * @param algorithm defines the algorithm to use and any extra-parameters.
40
+ * @param key the key to use for decryption.
41
+ * @param data the data to decrypt (also known as "ciphertext").
42
+ * @throws {InvalidAccessError} - if the provided key cannot be used for the decrypt operation.
43
+ * @throws {OperationError} - if the operation failed for an operation-specific reason.
44
+ * @returns A promise that resolves with the decrypted data (also known as "plaintext").
45
+ */
46
+ decrypt(
47
+ algorithm: AesCtrParams | AesCbcParams | AesGcmParams,
48
+ key: CryptoKey,
49
+ data: ArrayBuffer | ArrayBufferView | DataView
50
+ ): Promise<ArrayBuffer>;
51
+
52
+ /**
53
+ * The `digest()` method computes a cryptographic digest of the given data using the
54
+ * given algorithm.
55
+ *
56
+ * A digest is a fixed-length hash of the original data. It is often used
57
+ * to verify the integrity of the original data, or to create a
58
+ * "fingerprint" or "summary" of the original data that can be used to
59
+ * identify it.
60
+ *
61
+ * Cryptographic digests should exhibit collision-resistance, meaning that it's hard to
62
+ * come up with two different inputs that have the same digest value.
63
+ *
64
+ * @param algorithm names the algorithm to use.
65
+ * @param data the data to be digested
66
+ * @returns A promise that resolves with the digest value.
67
+ */
68
+ digest(
69
+ algorithm: HashAlgorithmIdentifier | Algorithm<HashAlgorithmIdentifier>,
70
+ data: ArrayBuffer | ArrayBufferView | DataView
71
+ ): Promise<ArrayBuffer>;
72
+
73
+ /**
74
+ * The `encrypt()` method encrypts data.
75
+ *
76
+ * @param algorithm defines the algorithm to use and any extra-parameters.
77
+ * @param key the key to use for encryption.
78
+ * @param data the data to encrypt (also known as "plaintext").
79
+ * @throws {InvalidAccessError} - if the provided key cannot be used for the encrypt operation.
80
+ * @throws {OperationError} - if the operation failed for an operation-specific reason.
81
+ * @returns A promise that resolves with the encrypted data (also known as "ciphertext").
82
+ */
83
+ encrypt(
84
+ algorithm: AesCtrParams | AesCbcParams | AesGcmParams,
85
+ key: CryptoKey,
86
+ data: ArrayBuffer | ArrayBufferView | DataView
87
+ ): Promise<ArrayBuffer>;
88
+
89
+ /**
90
+ * The `exportKey()` method exports a key: that is, it takes as input a `CryptoKey`
91
+ * object and gives you the key in an external, portable format.
92
+ *
93
+ * To export a key, the key must have `CryptoKey.extractable` set to `true`.
94
+ *
95
+ * @param format the format in which to export the key. Currently, only "raw" is supported.
96
+ * @param key the key to export.
97
+ * @throws {InvalidAccessError} - if the key is not extractable.
98
+ * @throws {NotSupportedError} - if the format is not supported.
99
+ * @throws {TypeError} - when trying to use an invalid format.
100
+ * @returns A promise that resolves with the exported key.
101
+ */
102
+ exportKey(
103
+ format: "raw",
104
+ key: CryptoKey
105
+ ): Promise<ArrayBuffer>;
106
+
107
+ /**
108
+ * Use the `generateKey()` method to generate a new key (for symmetric
109
+ * algorithms) or key pair (for public-key algorithms).
110
+ *
111
+ * @param algorithm defines the type of key to generate and providing extra algorithm-specific parameters.
112
+ * @param extractable indicates whether it will be possible to export the key using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey`.
113
+ * @param keyUsages indicates what can be done with the newly generated key.
114
+ * @throws {SyntaxError} - if the result is a `CryptoKey` of type `secret` or `private` but `keyUsages is empty.
115
+ * @returns A promise that resolves with the newly generated `CryptoKey` or `CryptoKeyPair`.
116
+ */
117
+ generateKey(
118
+ algorithm: AesKeyGenParams | HmacKeyGenParams,
119
+ extractable: boolean,
120
+ keyUsages: Array<"encrypt" | "decrypt" | "sign" | "verify">
121
+ ): Promise<CryptoKey>;
122
+
123
+ /**
124
+ * The `importKey()` method imports a key into a `CryptoKey` object.
125
+ * It takes as input a key in an external, portable format and gives you
126
+ * a `CryptoKey` object that can be used in the Web Crypto API.
127
+ *
128
+ * @param format the format of the key to import. Currently, only "raw" is supported.
129
+ * @param keyData the key data to import.
130
+ * @param algorithm defines the algorithm to use and any extra-parameters.
131
+ * @param extractable indicates whether it will be possible to export the key using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey`.
132
+ * @param keyUsages indicates what can be done with the newly generated key.
133
+ * @throws {SyntaxError} - if the result is a `CryptoKey` of type `secret` or `private` but `keyUsages is empty.
134
+ * @throws {TypeError} - when trying to use an invalid format or if the `keyData` is not suited for that format.
135
+ * @returns A promise that resolves with the imported `CryptoKey`.
136
+ */
137
+ importKey(
138
+ format: "raw",
139
+ keyData: ArrayBuffer | ArrayBufferView | DataView,
140
+ algorithm: "AES-CBC" | "AES-CTR" | "AES-GCM" | Algorithm<"AES-CBC" | "AES-CTR" | "AES-GCM"> | HmacImportParams,
141
+ extractable: boolean,
142
+ keyUsages: Array<"encrypt" | "decrypt" | "sign" | "verify">
143
+ ): Promise<CryptoKey>;
144
+
145
+ /**
146
+ * The `sign()` method generates a digital signature.
147
+ *
148
+ * It takes as its argument a key to sign with, some algorithm-identifier
149
+ * specific parameters, and the data to sign.
150
+ *
151
+ * @param algorithm defines the algorithm to use and any extra-parameters.
152
+ * @param key the key to use for signing. If `algorithm` identifies a public-key cryptosystem, this is the private key.
153
+ * @param data the data to sign.
154
+ * @throws {InvalidAccessError} - if the provided key cannot be used for the sign operation.
155
+ * @returns A promise that resolves with the signature.
156
+ */
157
+ sign(
158
+ algorithm: "HMAC" | Algorithm<"HMAC">,
159
+ key: CryptoKey,
160
+ data: ArrayBuffer | ArrayBufferView | DataView
161
+ ): Promise<ArrayBuffer>;
162
+
163
+ /**
164
+ * The `verify()` method verifies a digital signature.
165
+ *
166
+ * @param algorithm defines the algorithm to use and any extra-parameters.
167
+ * @param key the key to use for verifying. It is the secret key for a symmetric algorithm and the public key for a public-key system.
168
+ * @param signature the signature to verify.
169
+ * @param data the data to verify.
170
+ * @throws {InvalidAccessError} - if the provided key cannot be used for the verify operation.
171
+ * @returns A promise that resolves with a boolean indicating whether the signature is valid.
172
+ */
173
+ verify(
174
+ algorithm: "HMAC" | Algorithm<"HMAC">,
175
+ key: CryptoKey,
176
+ signature: ArrayBuffer | ArrayBufferView | DataView,
177
+ data: ArrayBuffer | ArrayBufferView | DataView
178
+ ): Promise<boolean>;
179
+ }
180
+
181
+ export interface CryptoKey {
182
+ /**
183
+ * The type of key the object represents.
184
+ */
185
+ readonly type: "secret" | "private" | "public";
186
+
187
+ /**
188
+ * A boolean value indicating whether or not the
189
+ * key may be extracted using `SubtleCrypto.exportKey()` or
190
+ * `SubtleCrypto.wrapKey()`.
191
+ */
192
+ readonly extractable: boolean;
193
+
194
+ /**
195
+ * An object describing the algorithm for which this key can be used
196
+ * and any associated extra parameters.
197
+ */
198
+ readonly algorithm: object;
199
+
200
+ /**
201
+ * An array of strings, indicating what can be done with the key.
202
+ */
203
+ readonly usages: Array<"encrypt" | "decrypt" | "sign" | "verify">;
204
+ }
205
+
206
+ /**
207
+ * The `Algorithm` dictionary of the Web Crypto API represents the
208
+ * object that should be passed as the `algorithm` parameter of
209
+ * most `SubtleCrypto` methods.
210
+ */
211
+ export interface Algorithm<I extends AlgorithmIdentifier | HashAlgorithmIdentifier> {
212
+ /**
213
+ * The name of the algorithm to use.
214
+ */
215
+ name: I;
216
+ }
217
+
218
+ /**
219
+ * The `AlgorithmIdentifier` type of the Web Crypto API represents
220
+ * the name of an algorithm.
221
+ */
222
+ export type AlgorithmIdentifier = string;
223
+
224
+ /**
225
+ * The `HashAlgorithmIdentifier` type of the Web Crypto API represents
226
+ * the name of a hash algorithm.
227
+ */
228
+ export type HashAlgorithmIdentifier = "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512";
229
+
230
+ /**
231
+ * The `AesKeyGenParams` dictionary of the Web Crypto API represents the
232
+ * object that should be passed as the `algorithm` parameter of the
233
+ * `SubtleCrypto.generateKey()` method when generating a new AES key.
234
+ */
235
+ export interface AesKeyGenParams extends Algorithm<AlgorithmIdentifier> {
236
+ /**
237
+ * The name of the algorithm to use.
238
+ */
239
+ name: "AES-GCM" | "AES-CBC" | "AES-CTR" | "AES-CFB" | "AES-KW";
240
+
241
+ /**
242
+ * The length of the key, in bits.
243
+ */
244
+ length: 128 | 192 | 256;
245
+ }
246
+
247
+ /**
248
+ * The `AesCtrParams` dictionary of the Web Crypto API represents the
249
+ * object that should be passed as the `algorithm` parameter of the
250
+ * `SubtleCrypto.encrypt()` and `SubtleCrypto.decrypt()`, `SubtleCrypto.wrapKey()` and
251
+ * `SubtleCrypto.unwrapKey()` methods when using the AES-CTR algorithm.
252
+ */
253
+ export interface AesCtrParams extends Algorithm<AlgorithmIdentifier> {
254
+ /**
255
+ * The name of the algorithm to use.
256
+ */
257
+ name: "AES-CTR";
258
+
259
+ /**
260
+ * The initial value of the counter block. This must be 16-byte
261
+ * long (the AES block size). The rightmost `length` bits of this
262
+ * block are used for the counter, and the rest is used for the
263
+ * nonce.
264
+ */
265
+ counter: ArrayBuffer | ArrayBufferView | DataView;
266
+
267
+ /**
268
+ * The number of bits in the counter block that are used for the actual
269
+ * counter. The counter must be big enough that it doesn't wrap. If the
270
+ * message is `n` blocks and the counter is `m` bits long, then the following
271
+ * must be true: `n < 2^m`.
272
+ */
273
+ length: number;
274
+ }
275
+
276
+ /**
277
+ * The `AesCbcParams` dictionary of the Web Crypto API represents the
278
+ * object that should be passed as the `algorithm` parameter of the
279
+ * `SubtleCrypto.encrypt()` and `SubtleCrypto.decrypt()`, `SubtleCrypto.wrapKey()` and
280
+ * `SubtleCrypto.unwrapKey()` methods when using the AES-CBC algorithm.
281
+ */
282
+ export interface AesCbcParams extends Algorithm<AlgorithmIdentifier> {
283
+ /**
284
+ * The name of the algorithm to use.
285
+ */
286
+ name: "AES-CBC";
287
+
288
+ /**
289
+ * The initialization vector to use for the operation.
290
+ * This must be 16-byte long (the AES block size), unpredictable, and
291
+ * preferably cryptographically random. However, it is not required to be
292
+ * secret (it may be transmitted unencrypted along with the ciphertext).
293
+ */
294
+ iv: ArrayBuffer | ArrayBufferView | DataView;
295
+ }
296
+
297
+ /**
298
+ * The `AesGcmParams` dictionary of the Web Crypto API represents the
299
+ * object that should be passed as the `algorithm` parameter of the
300
+ * `SubtleCrypto.encrypt()` and `SubtleCrypto.decrypt()`, `SubtleCrypto.wrapKey()` and
301
+ * `SubtleCrypto.unwrapKey()` methods when using the AES-GCM algorithm.
302
+ */
303
+ export interface AesGcmParams extends Algorithm<AlgorithmIdentifier> {
304
+ /**
305
+ * The name of the algorithm to use.
306
+ */
307
+ name: "AES-GCM";
308
+
309
+ /**
310
+ * The initialization vector to use for the operation.
311
+ * This must be 12-byte long (the GCM block size), unpredictable, and
312
+ * preferably cryptographically random. This must be unique for every
313
+ * encryption operation carried out with a given key. Put another way,
314
+ * never reuse an IV with the same key.
315
+ */
316
+ iv: ArrayBuffer | ArrayBufferView | DataView;
317
+
318
+ /**
319
+ * Contains additional data that will not be encrypted but will be
320
+ * authenticated. This is optional, and can be omitted if you don't
321
+ * need to pass any additional data. If `additionalData` is specified,
322
+ * then the same data must be given in the corresponding call to `decrypt()`.
323
+ * If the data is not the same, then the decryption will fail. This gives
324
+ * you a way to authenticate the data, without having to encrypt it.
325
+ */
326
+ additionalData?: ArrayBuffer | ArrayBufferView | DataView;
327
+
328
+ /**
329
+ * The length of the authentication tag, in bits. This must be of size
330
+ * 96.
331
+ */
332
+ tagLength?: number;
333
+ }
334
+
335
+ /**
336
+ * The `HmacKeyGenParams` dictionary of the Web Crypto API represents the
337
+ * object that should be passed as the `algorithm` parameter of the
338
+ * `SubtleCrypto.generateKey()` method when generating a new HMAC key.
339
+ */
340
+ export interface HmacKeyGenParams extends Algorithm<AlgorithmIdentifier> {
341
+ /**
342
+ * The name of the algorithm to use.
343
+ */
344
+ name: "HMAC";
345
+
346
+ /**
347
+ * A string representing the name of the digest function to use.
348
+ */
349
+ hash: "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512";
350
+
351
+ /**
352
+ * The length of the key, in bits. If the length is not specified,
353
+ * then the generated key will be as long as the block size of
354
+ * the hash function you have chosen. Unless you have a good reason
355
+ * to use a different length, omit this property and use the default.
356
+ */
357
+ length?: number;
358
+ }
359
+
360
+ /**
361
+ * The `HmacImportParams` dictionary of the Web Crypto API represents the
362
+ * object that should be passed as the `algorithm` parameter of the
363
+ * `SubtleCrypto.importKey()` method when importing an HMAC key.
364
+ */
365
+ export interface HmacImportParams extends Algorithm<AlgorithmIdentifier> {
366
+ /**
367
+ * The name of the algorithm to use.
368
+ */
369
+ name: "HMAC";
370
+
371
+ /**
372
+ * The name of the digest function to use.
373
+ */
374
+ hash: HashAlgorithmIdentifier;
375
+
376
+ /**
377
+ * The length of the key, in bits. If the length is not specified,
378
+ * then the generated key will be as long as the block size of
379
+ * the hash function you have chosen. Unless you have a good reason
380
+ * to use a different length, omit this property and use the default.
381
+ */
382
+ length?: number;
383
+ }
384
+
385
+ /**
386
+ * The TypedArray interface represents an array-like view of an underlying
387
+ * binary data buffer. It is used to represent a generic, fixed-length
388
+ * raw binary data buffer. The ArrayBuffer that underlies a typed array
389
+ * can be accessed and modified by using the ArrayBufferView methods.
390
+ *
391
+ * Note that this type does not include Float32Array and Float64Array, which
392
+ * makes it differ from the ArrayBufferView type.
393
+ */
394
+ export type TypedArray =
395
+ | Int8Array
396
+ | Uint8Array
397
+ | Uint8ClampedArray
398
+ | Int16Array
399
+ | Uint16Array
400
+ | Int32Array
401
+ | Uint32Array;
k6/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // Type definitions for k6 0.43
1
+ // Type definitions for k6 0.44
2
2
  // Project: https://k6.io/docs/
3
3
  // Definitions by: na-- <https://github.com/na-->
4
4
  // Mihail Stoykov <https://github.com/MStoykov>
@@ -44,6 +44,7 @@ import './options';
44
44
  import './experimental/redis';
45
45
  import './experimental/timers';
46
46
  import './experimental/tracing';
47
+ import './experimental/webcrypto';
47
48
  import './experimental/websockets';
48
49
  import './ws';
49
50
  import './net/grpc';
k6/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/k6",
3
- "version": "0.43.3",
3
+ "version": "0.44.0",
4
4
  "description": "TypeScript definitions for k6",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
6
6
  "license": "MIT",
@@ -55,6 +55,6 @@
55
55
  },
56
56
  "scripts": {},
57
57
  "dependencies": {},
58
- "typesPublisherContentHash": "2cbfa702b37e2f3d5238d3b1b9b10788b402594bf74c75209901da48c302472c",
58
+ "typesPublisherContentHash": "92c6c2a3dccdbe70533df0c3369945b153cf09bb0afa792f32e28b579e963c64",
59
59
  "typeScriptVersion": "4.3"
60
60
  }