@types/k6 0.50.1 → 0.51.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://grafana.com/docs/k6/lates
8
8
  Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6.
9
9
 
10
10
  ### Additional Details
11
- * Last updated: Tue, 23 Apr 2024 12:10:41 GMT
11
+ * Last updated: Mon, 13 May 2024 13:35:56 GMT
12
12
  * Dependencies: none
13
13
 
14
14
  # Credits
@@ -1363,7 +1363,7 @@ export interface ElementHandle extends JSHandle {
1363
1363
  * or at the specified position.
1364
1364
  * @param options Tap options.
1365
1365
  */
1366
- tap(options?: MouseMoveOptions): void;
1366
+ tap(options?: MouseMoveOptions): Promise<void>;
1367
1367
 
1368
1368
  /**
1369
1369
  * Returns the `node.textContent`.
@@ -1477,7 +1477,7 @@ export interface Frame {
1477
1477
  * @param selector The selector to use.
1478
1478
  * @param options The options to use.
1479
1479
  */
1480
- tap(selector: string, options?: ElementClickOptions & KeyboardModifierOptions & StrictnessOptions): void;
1480
+ tap(selector: string, options?: ElementClickOptions & KeyboardModifierOptions & StrictnessOptions): Promise<void>;
1481
1481
 
1482
1482
  /**
1483
1483
  * Press the given key for the first element found that matches the selector.
@@ -2049,7 +2049,7 @@ export interface Locator {
2049
2049
  * Tap on the chosen element.
2050
2050
  * @param options Options to use.
2051
2051
  */
2052
- tap(options?: MouseMoveOptions): void;
2052
+ tap(options?: MouseMoveOptions): Promise<void>;
2053
2053
 
2054
2054
  /**
2055
2055
  * Dispatches HTML DOM event types e.g. `click`.
@@ -3285,7 +3285,7 @@ export interface Page {
3285
3285
  */
3286
3286
  trial?: boolean;
3287
3287
  },
3288
- ): void;
3288
+ ): Promise<void>;
3289
3289
 
3290
3290
  /**
3291
3291
  * **NOTE** Use locator-based locator.textContent([options]) instead.
@@ -3893,7 +3893,7 @@ export interface Touchscreen {
3893
3893
  * @param x The x position.
3894
3894
  * @param y The y position.
3895
3895
  */
3896
- tap(x: number, y: number): void;
3896
+ tap(x: number, y: number): Promise<void>;
3897
3897
  }
3898
3898
 
3899
3899
  /**
@@ -91,24 +91,23 @@ export interface SubtleCrypto {
91
91
  *
92
92
  * To export a key, the key must have `CryptoKey.extractable` set to `true`.
93
93
  *
94
- * @param format the format in which to export the key. Currently, only "raw" and "jwk" are supported.
94
+ * @param format the format in which to export the key.
95
95
  * @param key the key to export.
96
96
  * @throws {InvalidAccessError} - if the key is not extractable.
97
97
  * @throws {NotSupportedError} - if the format is not supported.
98
98
  * @throws {TypeError} - when trying to use an invalid format.
99
99
  * @returns A promise that resolves with the exported key.
100
100
  */
101
- exportKey(format: "raw" | "jwk", key: CryptoKey): Promise<ArrayBuffer | JWK>;
101
+ exportKey(format: "raw" | "jwk" | "spki" | "pkcs8", key: CryptoKey): Promise<ArrayBuffer | JWK>;
102
102
 
103
103
  /**
104
- * Use the `generateKey()` method to generate a new key (for symmetric
105
- * algorithms) or key pair (for public-key algorithms).
104
+ * Use the `generateKey()` method to generate a new key.
106
105
  *
107
106
  * @param algorithm defines the type of key to generate and providing extra algorithm-specific parameters.
108
107
  * @param extractable indicates whether it will be possible to export the key using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey`.
109
108
  * @param keyUsages indicates what can be done with the newly generated key.
110
109
  * @throws {SyntaxError} - if the result is a `CryptoKey` of type `secret` or `private` but `keyUsages is empty.
111
- * @returns A promise that resolves with the newly generated `CryptoKey` or `CryptoKeyPair`.
110
+ * @returns A promise that resolves with the newly generated `CryptoKey`.
112
111
  */
113
112
  generateKey(
114
113
  algorithm: AesKeyGenParams | HmacKeyGenParams,
@@ -116,12 +115,27 @@ export interface SubtleCrypto {
116
115
  keyUsages: Array<"encrypt" | "decrypt" | "sign" | "verify">,
117
116
  ): Promise<CryptoKey>;
118
117
 
118
+ /**
119
+ * Use the `generateKey()` method to generate a new key pair for asymmetric algorithms.
120
+ *
121
+ * @param algorithm defines the type of key to generate and providing extra algorithm-specific parameters.
122
+ * @param extractable indicates whether it will be possible to export the key using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey`.
123
+ * @param keyUsages indicates what can be done with the newly generated key.
124
+ * @throws {SyntaxError} - if the result is a `CryptoKey` of type `secret` or `private` but `keyUsages is empty.
125
+ * @returns A promise that resolves with the newly generated CryptoKeyPair`.
126
+ */
127
+ generateKey(
128
+ algorithm: EcKeyGenParams,
129
+ extractable: boolean,
130
+ keyUsages: Array<"sign" | "verify" | "deriveKey" | "deriveBits">,
131
+ ): Promise<CryptoKeyPair>;
132
+
119
133
  /**
120
134
  * The `importKey()` method imports a key into a `CryptoKey` object.
121
135
  * It takes as input a key in an external, portable format and gives you
122
136
  * a `CryptoKey` object that can be used in the Web Crypto API.
123
137
  *
124
- * @param format the format of the key to import. Currently, only "raw" and "jwk" are supported.
138
+ * @param format the format of the key to import.
125
139
  * @param keyData the key data to import.
126
140
  * @param algorithm defines the algorithm to use and any extra-parameters.
127
141
  * @param extractable indicates whether it will be possible to export the key using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey`.
@@ -131,11 +145,17 @@ export interface SubtleCrypto {
131
145
  * @returns A promise that resolves with the imported `CryptoKey`.
132
146
  */
133
147
  importKey(
134
- format: "raw" | "jwk",
148
+ format: "raw" | "jwk" | "spki" | "pkcs8",
135
149
  keyData: ArrayBuffer | ArrayBufferView | DataView | JWK,
136
- algorithm: "AES-CBC" | "AES-CTR" | "AES-GCM" | Algorithm<"AES-CBC" | "AES-CTR" | "AES-GCM"> | HmacImportParams,
150
+ algorithm:
151
+ | "AES-CBC"
152
+ | "AES-CTR"
153
+ | "AES-GCM"
154
+ | Algorithm<"AES-CBC" | "AES-CTR" | "AES-GCM">
155
+ | HmacImportParams
156
+ | EcKeyImportParams,
137
157
  extractable: boolean,
138
- keyUsages: Array<"encrypt" | "decrypt" | "sign" | "verify">,
158
+ keyUsages: Array<"encrypt" | "decrypt" | "sign" | "verify" | "deriveKey" | "deriveBits">,
139
159
  ): Promise<CryptoKey>;
140
160
 
141
161
  /**
@@ -151,7 +171,7 @@ export interface SubtleCrypto {
151
171
  * @returns A promise that resolves with the signature.
152
172
  */
153
173
  sign(
154
- algorithm: "HMAC" | Algorithm<"HMAC">,
174
+ algorithm: "HMAC" | Algorithm<"HMAC"> | EcdsaParams,
155
175
  key: CryptoKey,
156
176
  data: ArrayBuffer | ArrayBufferView | DataView,
157
177
  ): Promise<ArrayBuffer>;
@@ -167,11 +187,24 @@ export interface SubtleCrypto {
167
187
  * @returns A promise that resolves with a boolean indicating whether the signature is valid.
168
188
  */
169
189
  verify(
170
- algorithm: "HMAC" | Algorithm<"HMAC">,
190
+ algorithm: "HMAC" | Algorithm<"HMAC"> | EcdsaParams,
171
191
  key: CryptoKey,
172
192
  signature: ArrayBuffer | ArrayBufferView | DataView,
173
193
  data: ArrayBuffer | ArrayBufferView | DataView,
174
194
  ): Promise<boolean>;
195
+
196
+ /**
197
+ * The `deriveBits()` method derives an array of bits from a base key.
198
+ *
199
+ * @param algorithm defines the derivation algorithm to use.
200
+ * @param baseKey A `CryptoKey` representing the input to the derivation algorithm. Currently, only an ECDH private key is possible.
201
+ * @param length A number representing the number of bits to derive. Currently, the number should be a multiple of 8.
202
+ */
203
+ deriveBits(
204
+ algorithm: EcdhKeyDeriveParams,
205
+ baseKey: CryptoKey,
206
+ length?: number,
207
+ ): Promise<ArrayBuffer>;
175
208
  }
176
209
 
177
210
  export interface CryptoKey {
@@ -196,7 +229,27 @@ export interface CryptoKey {
196
229
  /**
197
230
  * An array of strings, indicating what can be done with the key.
198
231
  */
199
- readonly usages: Array<"encrypt" | "decrypt" | "sign" | "verify">;
232
+ readonly usages: Array<"encrypt" | "decrypt" | "sign" | "verify" | "deriveKey" | "deriveBits">;
233
+ }
234
+
235
+ /**
236
+ * The `CryptoKeyPair` dictionary represents a key pair
237
+ * for an asymmetric cryptography algorithm,
238
+ * also known as a public-key algorithm.
239
+ */
240
+ export interface CryptoKeyPair {
241
+ /**
242
+ * A `CryptoKey` object representing the private key.
243
+ * For encryption and decryption algorithms, this key is used to decrypt.
244
+ * For signing and verification algorithms it is used to sign.
245
+ */
246
+ readonly privateKey: CryptoKey;
247
+ /**
248
+ * A CryptoKey object representing the public key.
249
+ * For encryption and decryption algorithms, this key is used to encrypt.
250
+ * For signing and verification algorithms it is used to verify signatures.
251
+ */
252
+ readonly publicKey: CryptoKey;
200
253
  }
201
254
 
202
255
  /**
@@ -353,6 +406,26 @@ export interface HmacKeyGenParams extends Algorithm<AlgorithmIdentifier> {
353
406
  length?: number;
354
407
  }
355
408
 
409
+ /**
410
+ * The EcKeyGenParams dictionary of the Web Crypto API represents the
411
+ * object that should be passed as the algorithm parameter into
412
+ * `SubtleCrypto.generateKey()`, when generating
413
+ * any elliptic-curve-based key pair:
414
+ * that is, when the algorithm is identified as either of ECDSA or ECDH.
415
+ */
416
+ export interface EcKeyGenParams extends Algorithm<AlgorithmIdentifier> {
417
+ /**
418
+ * The name of the algorithm to use.
419
+ */
420
+ name: "ECDSA" | "ECDH";
421
+
422
+ /**
423
+ * The name of the elliptic curve to use.
424
+ * This may be any of the following names for NIST-approved curves.
425
+ */
426
+ namedCurve: "P-256" | "P-384" | "P-521";
427
+ }
428
+
356
429
  /**
357
430
  * The `HmacImportParams` dictionary of the Web Crypto API represents the
358
431
  * object that should be passed as the `algorithm` parameter of the
@@ -378,6 +451,61 @@ export interface HmacImportParams extends Algorithm<AlgorithmIdentifier> {
378
451
  length?: number;
379
452
  }
380
453
 
454
+ /**
455
+ * The `EcKeyImportParams` dictionary of the Web Crypto API represents
456
+ * the object that should be passed as the algorithm parameter
457
+ * into SubtleCrypto.importKey() or SubtleCrypto.unwrapKey(),
458
+ * when generating any elliptic-curve-based key pair:
459
+ * that is, when the algorithm is identified as either of ECDSA or ECDH.
460
+ */
461
+ export interface EcKeyImportParams extends Algorithm<AlgorithmIdentifier> {
462
+ /**
463
+ * The name of the algorithm to use.
464
+ */
465
+ name: "ECDSA" | "ECDH";
466
+
467
+ /**
468
+ * The name of the elliptic curve to use.
469
+ * This may be any of the following names for NIST-approved curves.
470
+ */
471
+ namedCurve: "P-256" | "P-384" | "P-521";
472
+ }
473
+
474
+ /**
475
+ * The `EcdsaParams` dictionary of the Web Crypto API represents
476
+ * the object that should be passed as the algorithm parameter
477
+ * into SubtleCrypto.sign() or SubtleCrypto.verify()
478
+ * when using the ECDSA algorithm.
479
+ */
480
+ export interface EcdsaParams extends Algorithm<AlgorithmIdentifier> {
481
+ /**
482
+ * The name of the algorithm to use.
483
+ */
484
+ name: "ECDSA";
485
+
486
+ /**
487
+ * An identifier for the digest algorithm to use.
488
+ */
489
+ hash: "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512";
490
+ }
491
+
492
+ /**
493
+ * The `EcdhKeyDeriveParams` dictionary of the Web Crypto API represents
494
+ * the object that should be passed as the algorithm parameter
495
+ * into `SubtleCrypto.deriveKey()`, when using the ECDH algorithm.
496
+ */
497
+ export interface EcdhKeyDeriveParams extends Algorithm<AlgorithmIdentifier> {
498
+ /**
499
+ * The name of the algorithm to use. Only the "ECDH" value is possible.
500
+ */
501
+ name: "ECDH";
502
+
503
+ /**
504
+ * A `CryptoKey` object representing the public key of the other entity.
505
+ */
506
+ public: CryptoKey;
507
+ }
508
+
381
509
  /**
382
510
  * The TypedArray interface represents an array-like view of an underlying
383
511
  * binary data buffer. It is used to represent a generic, fixed-length
@@ -180,7 +180,7 @@ export enum BinaryType {
180
180
  /**
181
181
  * Binary data is returned in ArrayBuffer form. k6 supports only this type.
182
182
  */
183
- ArrayBuffer = "ArrayBuffer",
183
+ ArrayBuffer = "arraybuffer",
184
184
  }
185
185
 
186
186
  /**
k6/index.d.ts CHANGED
@@ -35,7 +35,6 @@ import "./experimental/timers";
35
35
  import "./experimental/tracing";
36
36
  import "./experimental/webcrypto";
37
37
  import "./experimental/websockets";
38
- import "./experimental/grpc";
39
38
  import "./timers";
40
39
  import "./ws";
41
40
  import "./net/grpc";
k6/net/grpc.d.ts CHANGED
@@ -121,6 +121,9 @@ declare namespace grpc {
121
121
  /** Invokes an unary RPC request. */
122
122
  invoke(url: string, request: object, params?: Params): Response;
123
123
 
124
+ /** Asynchronously invokes an unary RPC request. */
125
+ asyncInvoke(url: string, request: object, params?: Params): Promise<Response>;
126
+
124
127
  /** Close the connection. */
125
128
  close(): void;
126
129
  }
k6/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@types/k6",
3
- "version": "0.50.1",
3
+ "version": "0.51.0",
4
4
  "description": "TypeScript definitions for k6",
5
5
  "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
6
6
  "license": "MIT",
@@ -60,6 +60,6 @@
60
60
  },
61
61
  "scripts": {},
62
62
  "dependencies": {},
63
- "typesPublisherContentHash": "2a8f07e9cc2b17f1c90d400665135022e7c3b213f384fe82ffa9ae439704d942",
63
+ "typesPublisherContentHash": "fd17fedc4161ea6cdb1d78db41100cc597d5c251769b71a824af1faaabbe4ff1",
64
64
  "typeScriptVersion": "4.7"
65
65
  }
k6/experimental/grpc.d.ts DELETED
@@ -1,205 +0,0 @@
1
- // === Response ===
2
- // ----------------
3
-
4
- /**
5
- * gRPC response.
6
- */
7
- export interface Response {
8
- status: number;
9
-
10
- message: object;
11
-
12
- headers: object;
13
-
14
- trailers: object;
15
-
16
- error: object;
17
- }
18
-
19
- export interface ConnectParams {
20
- /**
21
- * If `true` will connect to the gRPC server using plaintext i.e. insecure.
22
- */
23
- plaintext?: boolean;
24
-
25
- /**
26
- * If `true` connection will try to use the gRPC server reflection protocol.
27
- * https://github.com/grpc/grpc/blob/master/doc/server-reflection.md
28
- */
29
- reflect?: boolean;
30
-
31
- /**
32
- * Metadata to send with reflection request.
33
- */
34
- reflectMetadata?: object;
35
-
36
- /**
37
- * Connection timeout to use.
38
- */
39
- timeout?: string | number;
40
-
41
- /**
42
- * Maximum message size in bytes the client can receive.
43
- */
44
- maxReceiveSize?: number;
45
-
46
- /**
47
- * Maximum message size in bytes the client can send.
48
- */
49
- maxSendSize?: number;
50
-
51
- /**
52
- * TLS settings of the connection.
53
- */
54
- tls?: TLSParams;
55
- }
56
-
57
- export interface TLSParams {
58
- /**
59
- * PEM formatted client certificate.
60
- */
61
- cert: string;
62
-
63
- /**
64
- * PEM formatted client private key.
65
- */
66
- key: string;
67
-
68
- /**
69
- * Password for decrypting the client's private key.
70
- */
71
- password?: string;
72
-
73
- /**
74
- * PEM formatted string/strings of the certificate authorities.
75
- */
76
- cacerts?: string | string[];
77
- }
78
-
79
- export interface Params {
80
- /**
81
- * @deprecated Use metadata instead.
82
- */
83
- headers?: object;
84
-
85
- metadata?: object;
86
-
87
- tags?: object;
88
-
89
- timeout?: string | number;
90
- }
91
-
92
- export interface GrpcError {
93
- code: number;
94
- details: string[] | object[];
95
- message: string;
96
- }
97
-
98
- /**
99
- * This module provides classes for Remote Procedure Calls over HTTP/2.
100
- * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/grpc/
101
- *
102
- * @deprecated Use the `k6/net/grpc` module instead.
103
- */
104
- declare namespace grpc {
105
- /**
106
- * gRPC client to interact with a gRPC server.
107
- * https://grafana.com/docs/k6/latest/javascript-api/k6-experimental/grpc/client/
108
- *
109
- * @deprecated Use the `k6/net/grpc` module instead.
110
- */
111
- class Client {
112
- protected __brand: never;
113
-
114
- constructor();
115
-
116
- /** Opens a connection to a gRPC server. */
117
- connect(address: string, params?: ConnectParams): void;
118
-
119
- /** Loads and parses the protocol buffer descriptors. */
120
- load(importPaths: string[], ...protoFiles: string[]): void;
121
-
122
- /** Loads a protoset and parses the protocol buffer descriptors */
123
- loadProtoset(protosetPath: string): void;
124
-
125
- /** Invokes an unary RPC request. */
126
- invoke(url: string, request: object, params?: Params): Response;
127
-
128
- /** Close the connection. */
129
- close(): void;
130
- }
131
-
132
- /**
133
- * StreamEvent describes the possible events that can be emitted
134
- * by a gRPC stream.
135
- */
136
- type StreamEvent =
137
- /**
138
- * Event fired when data has been received from the server.
139
- */
140
- | "data"
141
- /**
142
- * Event fired when a stream has been closed due to an error.
143
- */
144
- | "error"
145
- /**
146
- * Event fired when the stream closes.
147
- */
148
- | "end";
149
-
150
- /**
151
- * Stream allows you to use streaming RPCs.
152
- *
153
- * @deprecated Use the `k6/net/grpc` module instead.
154
- */
155
- class Stream {
156
- /**
157
- * The gRPC stream constructor, representing a single gRPC stream.
158
- *
159
- * @param client - the gRPC client to use, it must be connected.
160
- * @param url - the RPC method to call.
161
- * @param params - the parameters to use for the RPC call.
162
- */
163
- constructor(client: Client, url: string, params?: Params);
164
-
165
- /**
166
- * Set up handler functions for various events on the gRPC stream.
167
- *
168
- * @param event - the event to listen for
169
- * @param listener - the callback to invoke when the event is emitted
170
- */
171
- on(event: StreamEvent, listener: (data: object | GrpcError | undefined) => void): void;
172
-
173
- /**
174
- * Writes a request to the stream.
175
- *
176
- * @param request - the request (message) to send to the server
177
- */
178
- write(request: object): void;
179
-
180
- /**
181
- * Signals to the server that the client has finished sending messages.
182
- */
183
- end(): void;
184
- }
185
-
186
- const StatusOK: number;
187
- const StatusCanceled: number;
188
- const StatusUnknown: number;
189
- const StatusInvalidArgument: number;
190
- const StatusDeadlineExceeded: number;
191
- const StatusNotFound: number;
192
- const StatusAlreadyExists: number;
193
- const StatusPermissionDenied: number;
194
- const StatusResourceExhausted: number;
195
- const StatusFailedPrecondition: number;
196
- const StatusAborted: number;
197
- const StatusOutOfRange: number;
198
- const StatusUnimplemented: number;
199
- const StatusInternal: number;
200
- const StatusUnavailable: number;
201
- const StatusDataLoss: number;
202
- const StatusUnauthenticated: number;
203
- }
204
-
205
- export default grpc;