@types/k6 1.0.1 → 1.1.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 +2 -2
- k6/browser/index.d.ts +53 -0
- k6/package.json +3 -9
- k6/experimental/webcrypto/index.d.ts +0 -646
k6/README.md
CHANGED
|
@@ -8,8 +8,8 @@ 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:
|
|
11
|
+
* Last updated: Tue, 01 Jul 2025 22:02:09 GMT
|
|
12
12
|
* Dependencies: none
|
|
13
13
|
|
|
14
14
|
# Credits
|
|
15
|
-
These definitions were written by [Mihail Stoykov](https://github.com/MStoykov), [Ivan](https://github.com/codebien), [Théo Crevon](https://github.com/oleiade), [
|
|
15
|
+
These definitions were written by [Mihail Stoykov](https://github.com/MStoykov), [Ivan](https://github.com/codebien), [Théo Crevon](https://github.com/oleiade), [Ankur Agarwal](https://github.com/ankur22), [İnanç Gümüş](https://github.com/inancgumus), and [Joan López de la Franca Beltran](https://github.com/joanlopez).
|
k6/browser/index.d.ts
CHANGED
|
@@ -1986,6 +1986,19 @@ export interface Locator {
|
|
|
1986
1986
|
*/
|
|
1987
1987
|
click(options?: MouseMoveOptions & MouseMultiClickOptions): Promise<void>;
|
|
1988
1988
|
|
|
1989
|
+
/**
|
|
1990
|
+
* Returns the number of elements matching the selector.
|
|
1991
|
+
*
|
|
1992
|
+
* **Usage**
|
|
1993
|
+
*
|
|
1994
|
+
* ```js
|
|
1995
|
+
* const count = await page.locator('input').count();
|
|
1996
|
+
* ```
|
|
1997
|
+
*
|
|
1998
|
+
* @returns Promise which resolves with the number of elements matching the selector.
|
|
1999
|
+
*/
|
|
2000
|
+
count(): Promise<number>;
|
|
2001
|
+
|
|
1989
2002
|
/**
|
|
1990
2003
|
* Mouse double click on the chosen element.
|
|
1991
2004
|
* @param options Options to use.
|
|
@@ -2051,6 +2064,19 @@ export interface Locator {
|
|
|
2051
2064
|
*/
|
|
2052
2065
|
fill(value: string, options?: ElementHandleOptions): Promise<void>;
|
|
2053
2066
|
|
|
2067
|
+
/**
|
|
2068
|
+
* Returns locator to the first matching element.
|
|
2069
|
+
*
|
|
2070
|
+
* **Usage**
|
|
2071
|
+
*
|
|
2072
|
+
* ```js
|
|
2073
|
+
* const firstRow = await page.locator('tr').first();
|
|
2074
|
+
* ```
|
|
2075
|
+
*
|
|
2076
|
+
* @returns Locator.
|
|
2077
|
+
*/
|
|
2078
|
+
first(): Locator;
|
|
2079
|
+
|
|
2054
2080
|
/**
|
|
2055
2081
|
* Focuses the element using locator's selector.
|
|
2056
2082
|
* @param options Options to use.
|
|
@@ -2093,6 +2119,33 @@ export interface Locator {
|
|
|
2093
2119
|
*/
|
|
2094
2120
|
inputValue(options?: TimeoutOptions): Promise<string>;
|
|
2095
2121
|
|
|
2122
|
+
/**
|
|
2123
|
+
* Returns locator to the last matching element.
|
|
2124
|
+
*
|
|
2125
|
+
* **Usage**
|
|
2126
|
+
*
|
|
2127
|
+
* ```js
|
|
2128
|
+
* const lastRow = await page.locator('tr').last();
|
|
2129
|
+
* ```
|
|
2130
|
+
*
|
|
2131
|
+
* @returns Locator.
|
|
2132
|
+
*/
|
|
2133
|
+
last(): Locator;
|
|
2134
|
+
|
|
2135
|
+
/**
|
|
2136
|
+
* Returns locator to the n-th matching element. It's zero based, `nth(0)` selects the first element.
|
|
2137
|
+
*
|
|
2138
|
+
* **Usage**
|
|
2139
|
+
*
|
|
2140
|
+
* ```js
|
|
2141
|
+
* const secondRow = await page.locator('tr').nth(1);
|
|
2142
|
+
* ```
|
|
2143
|
+
*
|
|
2144
|
+
* @param index
|
|
2145
|
+
* @returns Locator
|
|
2146
|
+
*/
|
|
2147
|
+
nth(index: number): Locator;
|
|
2148
|
+
|
|
2096
2149
|
/**
|
|
2097
2150
|
* Select one or more options which match the values. If the select has the multiple attribute, all matching options are selected,
|
|
2098
2151
|
* otherwise only the first option matching one of the passed options is selected.
|
k6/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@types/k6",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "TypeScript definitions for k6",
|
|
5
5
|
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/k6",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,11 +20,6 @@
|
|
|
20
20
|
"githubUsername": "oleiade",
|
|
21
21
|
"url": "https://github.com/oleiade"
|
|
22
22
|
},
|
|
23
|
-
{
|
|
24
|
-
"name": "Oleg Bespalov",
|
|
25
|
-
"githubUsername": "olegbespalov",
|
|
26
|
-
"url": "https://github.com/olegbespalov"
|
|
27
|
-
},
|
|
28
23
|
{
|
|
29
24
|
"name": "Ankur Agarwal",
|
|
30
25
|
"githubUsername": "ankur22",
|
|
@@ -62,7 +57,6 @@
|
|
|
62
57
|
"./experimental/csv": "./experimental/csv/index.d.ts",
|
|
63
58
|
"./experimental/fs": "./experimental/fs/index.d.ts",
|
|
64
59
|
"./experimental/redis": "./experimental/redis/index.d.ts",
|
|
65
|
-
"./experimental/webcrypto": "./experimental/webcrypto/index.d.ts",
|
|
66
60
|
"./experimental/streams": "./experimental/streams/index.d.ts",
|
|
67
61
|
"./experimental/websockets": "./experimental/websockets/index.d.ts",
|
|
68
62
|
"./package.json": "./package.json"
|
|
@@ -75,6 +69,6 @@
|
|
|
75
69
|
"scripts": {},
|
|
76
70
|
"dependencies": {},
|
|
77
71
|
"peerDependencies": {},
|
|
78
|
-
"typesPublisherContentHash": "
|
|
79
|
-
"typeScriptVersion": "5.
|
|
72
|
+
"typesPublisherContentHash": "96515089683437758fefd2c656f0f92f85fe68f378af7dbdfaad6cf5321acd13",
|
|
73
|
+
"typeScriptVersion": "5.1"
|
|
80
74
|
}
|
|
@@ -1,646 +0,0 @@
|
|
|
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://grafana.com/docs/k6/latest/javascript-api/k6-experimental/webcrypto/
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated use global crypto instead.
|
|
10
|
-
*/
|
|
11
|
-
export const crypto: Crypto;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated use global crypto instead.
|
|
15
|
-
*/
|
|
16
|
-
export interface Crypto extends SubtleCrypto {
|
|
17
|
-
/**
|
|
18
|
-
* Returns a SubtleCrypto object providing access to common cryptographic
|
|
19
|
-
* primitives, like hashing, signing, encryption, or decryption.
|
|
20
|
-
*
|
|
21
|
-
* @deprecated use global crypto.subtle instead.
|
|
22
|
-
*/
|
|
23
|
-
readonly subtle: SubtleCrypto;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Fills the passed TypedArray with cryptographically sound random values.
|
|
27
|
-
*
|
|
28
|
-
* @param typedArray - The TypedArray to fill with random values.
|
|
29
|
-
* @throws {QuotaExceededError} - thrown if the `byteLength` of `typedArray` exceeds 65536.
|
|
30
|
-
* @returns The typedArray argument.
|
|
31
|
-
*
|
|
32
|
-
* @deprecated use global crypto.getRandomValues crypto instead.
|
|
33
|
-
*/
|
|
34
|
-
getRandomValues(typedArray: TypedArray): TypedArray;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Returns a 36 character long string containing a cryptographically random UUID v4.
|
|
38
|
-
*
|
|
39
|
-
* @returns A 36 character long string containing a cryptographically random UUID v4.
|
|
40
|
-
*
|
|
41
|
-
* @deprecated use global crypto.randomUUID instead.
|
|
42
|
-
*/
|
|
43
|
-
randomUUID(): string;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* @deprecated use global crypto.subtle instead.
|
|
48
|
-
*/
|
|
49
|
-
export interface SubtleCrypto {
|
|
50
|
-
/**
|
|
51
|
-
* The `decrypt()` method decrypts some encrypted data.
|
|
52
|
-
*
|
|
53
|
-
* @param algorithm defines the algorithm to use and any extra-parameters.
|
|
54
|
-
* @param key the key to use for decryption.
|
|
55
|
-
* @param data the data to decrypt (also known as "ciphertext").
|
|
56
|
-
* @throws {InvalidAccessError} - if the provided key cannot be used for the decrypt operation.
|
|
57
|
-
* @throws {OperationError} - if the operation failed for an operation-specific reason.
|
|
58
|
-
* @returns A promise that resolves with the decrypted data (also known as "plaintext").
|
|
59
|
-
* @deprecated use global crypto.subtle.decrypt instead.
|
|
60
|
-
*/
|
|
61
|
-
decrypt(
|
|
62
|
-
algorithm: AesCtrParams | AesCbcParams | AesGcmParams | RsaOaepParams,
|
|
63
|
-
key: CryptoKey,
|
|
64
|
-
data: ArrayBuffer | ArrayBufferView | DataView,
|
|
65
|
-
): Promise<ArrayBuffer>;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* The `digest()` method computes a cryptographic digest of the given data using the
|
|
69
|
-
* given algorithm.
|
|
70
|
-
*
|
|
71
|
-
* A digest is a fixed-length hash of the original data. It is often used
|
|
72
|
-
* to verify the integrity of the original data, or to create a
|
|
73
|
-
* "fingerprint" or "summary" of the original data that can be used to
|
|
74
|
-
* identify it.
|
|
75
|
-
*
|
|
76
|
-
* Cryptographic digests should exhibit collision-resistance, meaning that it's hard to
|
|
77
|
-
* come up with two different inputs that have the same digest value.
|
|
78
|
-
*
|
|
79
|
-
* @param algorithm names the algorithm to use.
|
|
80
|
-
* @param data the data to be digested
|
|
81
|
-
* @returns A promise that resolves with the digest value.
|
|
82
|
-
* @deprecated use global crypto.subtle.digest instead.
|
|
83
|
-
*/
|
|
84
|
-
digest(
|
|
85
|
-
algorithm: HashAlgorithmIdentifier | Algorithm<HashAlgorithmIdentifier>,
|
|
86
|
-
data: ArrayBuffer | ArrayBufferView | DataView,
|
|
87
|
-
): Promise<ArrayBuffer>;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* The `encrypt()` method encrypts data.
|
|
91
|
-
*
|
|
92
|
-
* @param algorithm defines the algorithm to use and any extra-parameters.
|
|
93
|
-
* @param key the key to use for encryption.
|
|
94
|
-
* @param data the data to encrypt (also known as "plaintext").
|
|
95
|
-
* @throws {InvalidAccessError} - if the provided key cannot be used for the encrypt operation.
|
|
96
|
-
* @throws {OperationError} - if the operation failed for an operation-specific reason.
|
|
97
|
-
* @returns A promise that resolves with the encrypted data (also known as "ciphertext").
|
|
98
|
-
* @deprecated use global crypto.subtle.encrypt instead.
|
|
99
|
-
*/
|
|
100
|
-
encrypt(
|
|
101
|
-
algorithm: AesCtrParams | AesCbcParams | AesGcmParams | RsaOaepParams,
|
|
102
|
-
key: CryptoKey,
|
|
103
|
-
data: ArrayBuffer | ArrayBufferView | DataView,
|
|
104
|
-
): Promise<ArrayBuffer>;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* The `exportKey()` method exports a key: that is, it takes as input a `CryptoKey`
|
|
108
|
-
* object and gives you the key in an external, portable format.
|
|
109
|
-
*
|
|
110
|
-
* To export a key, the key must have `CryptoKey.extractable` set to `true`.
|
|
111
|
-
*
|
|
112
|
-
* @param format the format in which to export the key.
|
|
113
|
-
* @param key the key to export.
|
|
114
|
-
* @throws {InvalidAccessError} - if the key is not extractable.
|
|
115
|
-
* @throws {NotSupportedError} - if the format is not supported.
|
|
116
|
-
* @throws {TypeError} - when trying to use an invalid format.
|
|
117
|
-
* @returns A promise that resolves with the exported key.
|
|
118
|
-
* @deprecated use global crypto.subtle.exportKey instead.
|
|
119
|
-
*/
|
|
120
|
-
exportKey(format: "raw" | "jwk" | "spki" | "pkcs8", key: CryptoKey): Promise<ArrayBuffer | JWK>;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Use the `generateKey()` method to generate a new key.
|
|
124
|
-
*
|
|
125
|
-
* @param algorithm defines the type of key to generate and providing extra algorithm-specific parameters.
|
|
126
|
-
* @param extractable indicates whether it will be possible to export the key using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey`.
|
|
127
|
-
* @param keyUsages indicates what can be done with the newly generated key.
|
|
128
|
-
* @throws {SyntaxError} - if the result is a `CryptoKey` of type `secret` or `private` but `keyUsages is empty.
|
|
129
|
-
* @returns A promise that resolves with the newly generated `CryptoKey`.
|
|
130
|
-
* @deprecated use global crypto.subtle.generateKey instead.
|
|
131
|
-
*/
|
|
132
|
-
generateKey(
|
|
133
|
-
algorithm: AesKeyGenParams | HmacKeyGenParams,
|
|
134
|
-
extractable: boolean,
|
|
135
|
-
keyUsages: Array<"encrypt" | "decrypt" | "sign" | "verify">,
|
|
136
|
-
): Promise<CryptoKey>;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Use the `generateKey()` method to generate a new key pair for asymmetric algorithms.
|
|
140
|
-
*
|
|
141
|
-
* @param algorithm defines the type of key to generate and providing extra algorithm-specific parameters.
|
|
142
|
-
* @param extractable indicates whether it will be possible to export the key using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey`.
|
|
143
|
-
* @param keyUsages indicates what can be done with the newly generated key.
|
|
144
|
-
* @throws {SyntaxError} - if the result is a `CryptoKey` of type `secret` or `private` but `keyUsages is empty.
|
|
145
|
-
* @returns A promise that resolves with the newly generated `CryptoKeyPair`.
|
|
146
|
-
* @deprecated use global crypto.subtle.generateKey instead.
|
|
147
|
-
*/
|
|
148
|
-
generateKey(
|
|
149
|
-
algorithm: EcKeyGenParams | RSAHashedKeyGenParams,
|
|
150
|
-
extractable: boolean,
|
|
151
|
-
keyUsages: Array<"sign" | "verify" | "deriveKey" | "deriveBits" | "encrypt" | "decrypt">,
|
|
152
|
-
): Promise<CryptoKeyPair>;
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* The `importKey()` method imports a key into a `CryptoKey` object.
|
|
156
|
-
* It takes as input a key in an external, portable format and gives you
|
|
157
|
-
* a `CryptoKey` object that can be used in the Web Crypto API.
|
|
158
|
-
*
|
|
159
|
-
* @param format the format of the key to import.
|
|
160
|
-
* @param keyData the key data to import.
|
|
161
|
-
* @param algorithm defines the algorithm to use and any extra-parameters.
|
|
162
|
-
* @param extractable indicates whether it will be possible to export the key using `SubtleCrypto.exportKey()` or `SubtleCrypto.wrapKey`.
|
|
163
|
-
* @param keyUsages indicates what can be done with the newly generated key.
|
|
164
|
-
* @throws {SyntaxError} - if the result is a `CryptoKey` of type `secret` or `private` but `keyUsages is empty.
|
|
165
|
-
* @throws {TypeError} - when trying to use an invalid format or if the `keyData` is not suited for that format.
|
|
166
|
-
* @returns A promise that resolves with the imported `CryptoKey`.
|
|
167
|
-
* @deprecated use global crypto.subtle.importKey instead.
|
|
168
|
-
*/
|
|
169
|
-
importKey(
|
|
170
|
-
format: "raw" | "jwk" | "spki" | "pkcs8",
|
|
171
|
-
keyData: ArrayBuffer | ArrayBufferView | DataView | JWK,
|
|
172
|
-
algorithm:
|
|
173
|
-
| "AES-CBC"
|
|
174
|
-
| "AES-CTR"
|
|
175
|
-
| "AES-GCM"
|
|
176
|
-
| Algorithm<"AES-CBC" | "AES-CTR" | "AES-GCM">
|
|
177
|
-
| HmacImportParams
|
|
178
|
-
| EcKeyImportParams
|
|
179
|
-
| RsaHashedImportParams,
|
|
180
|
-
extractable: boolean,
|
|
181
|
-
keyUsages: Array<"encrypt" | "decrypt" | "sign" | "verify" | "deriveKey" | "deriveBits">,
|
|
182
|
-
): Promise<CryptoKey>;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* The `sign()` method generates a digital signature.
|
|
186
|
-
*
|
|
187
|
-
* It takes as its argument a key to sign with, some algorithm-identifier
|
|
188
|
-
* specific parameters, and the data to sign.
|
|
189
|
-
*
|
|
190
|
-
* @param algorithm defines the algorithm to use and any extra-parameters.
|
|
191
|
-
* @param key the key to use for signing. If `algorithm` identifies a public-key cryptosystem, this is the private key.
|
|
192
|
-
* @param data the data to sign.
|
|
193
|
-
* @throws {InvalidAccessError} - if the provided key cannot be used for the sign operation.
|
|
194
|
-
* @returns A promise that resolves with the signature.
|
|
195
|
-
* @deprecated use global crypto.subtle.sign instead.
|
|
196
|
-
*/
|
|
197
|
-
sign(
|
|
198
|
-
algorithm: "HMAC" | Algorithm<"HMAC"> | EcdsaParams | RsaPssParams,
|
|
199
|
-
key: CryptoKey,
|
|
200
|
-
data: ArrayBuffer | ArrayBufferView | DataView,
|
|
201
|
-
): Promise<ArrayBuffer>;
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* The `verify()` method verifies a digital signature.
|
|
205
|
-
*
|
|
206
|
-
* @param algorithm defines the algorithm to use and any extra-parameters.
|
|
207
|
-
* @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.
|
|
208
|
-
* @param signature the signature to verify.
|
|
209
|
-
* @param data the data to verify.
|
|
210
|
-
* @throws {InvalidAccessError} - if the provided key cannot be used for the verify operation.
|
|
211
|
-
* @returns A promise that resolves with a boolean indicating whether the signature is valid.
|
|
212
|
-
* @deprecated use global crypto.subtle.verify instead.
|
|
213
|
-
*/
|
|
214
|
-
verify(
|
|
215
|
-
algorithm: "HMAC" | Algorithm<"HMAC"> | EcdsaParams | RsaPssParams,
|
|
216
|
-
key: CryptoKey,
|
|
217
|
-
signature: ArrayBuffer | ArrayBufferView | DataView,
|
|
218
|
-
data: ArrayBuffer | ArrayBufferView | DataView,
|
|
219
|
-
): Promise<boolean>;
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* The `deriveBits()` method derives an array of bits from a base key.
|
|
223
|
-
*
|
|
224
|
-
* @param algorithm defines the derivation algorithm to use.
|
|
225
|
-
* @param baseKey A `CryptoKey` representing the input to the derivation algorithm. Currently, only an ECDH private key is possible.
|
|
226
|
-
* @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.
|
|
228
|
-
*/
|
|
229
|
-
deriveBits(
|
|
230
|
-
algorithm: EcdhKeyDeriveParams,
|
|
231
|
-
baseKey: CryptoKey,
|
|
232
|
-
length?: number,
|
|
233
|
-
): Promise<ArrayBuffer>;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export interface CryptoKey {
|
|
237
|
-
/**
|
|
238
|
-
* The type of key the object represents.
|
|
239
|
-
*/
|
|
240
|
-
readonly type: "secret" | "private" | "public";
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* A boolean value indicating whether or not the
|
|
244
|
-
* key may be extracted using `SubtleCrypto.exportKey()` or
|
|
245
|
-
* `SubtleCrypto.wrapKey()`.
|
|
246
|
-
*/
|
|
247
|
-
readonly extractable: boolean;
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* An object describing the algorithm for which this key can be used
|
|
251
|
-
* and any associated extra parameters.
|
|
252
|
-
*/
|
|
253
|
-
readonly algorithm: object;
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* An array of strings, indicating what can be done with the key.
|
|
257
|
-
*/
|
|
258
|
-
readonly usages: Array<"encrypt" | "decrypt" | "sign" | "verify" | "deriveKey" | "deriveBits">;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* The `CryptoKeyPair` dictionary represents a key pair
|
|
263
|
-
* for an asymmetric cryptography algorithm,
|
|
264
|
-
* also known as a public-key algorithm.
|
|
265
|
-
*/
|
|
266
|
-
export interface CryptoKeyPair {
|
|
267
|
-
/**
|
|
268
|
-
* A `CryptoKey` object representing the private key.
|
|
269
|
-
* For encryption and decryption algorithms, this key is used to decrypt.
|
|
270
|
-
* For signing and verification algorithms it is used to sign.
|
|
271
|
-
*/
|
|
272
|
-
readonly privateKey: CryptoKey;
|
|
273
|
-
/**
|
|
274
|
-
* A CryptoKey object representing the public key.
|
|
275
|
-
* For encryption and decryption algorithms, this key is used to encrypt.
|
|
276
|
-
* For signing and verification algorithms it is used to verify signatures.
|
|
277
|
-
*/
|
|
278
|
-
readonly publicKey: CryptoKey;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
/**
|
|
282
|
-
* The `Algorithm` dictionary of the Web Crypto API represents the
|
|
283
|
-
* object that should be passed as the `algorithm` parameter of
|
|
284
|
-
* most `SubtleCrypto` methods.
|
|
285
|
-
*/
|
|
286
|
-
export interface Algorithm<I extends AlgorithmIdentifier | HashAlgorithmIdentifier> {
|
|
287
|
-
/**
|
|
288
|
-
* The name of the algorithm to use.
|
|
289
|
-
*/
|
|
290
|
-
name: I;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/**
|
|
294
|
-
* The `AlgorithmIdentifier` type of the Web Crypto API represents
|
|
295
|
-
* the name of an algorithm.
|
|
296
|
-
*/
|
|
297
|
-
export type AlgorithmIdentifier = string;
|
|
298
|
-
|
|
299
|
-
/**
|
|
300
|
-
* The `HashAlgorithmIdentifier` type of the Web Crypto API represents
|
|
301
|
-
* the name of a hash algorithm.
|
|
302
|
-
*/
|
|
303
|
-
export type HashAlgorithmIdentifier = "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512";
|
|
304
|
-
|
|
305
|
-
/**
|
|
306
|
-
* The `AesKeyGenParams` dictionary of the Web Crypto API represents the
|
|
307
|
-
* object that should be passed as the `algorithm` parameter of the
|
|
308
|
-
* `SubtleCrypto.generateKey()` method when generating a new AES key.
|
|
309
|
-
*/
|
|
310
|
-
export interface AesKeyGenParams extends Algorithm<AlgorithmIdentifier> {
|
|
311
|
-
/**
|
|
312
|
-
* The name of the algorithm to use.
|
|
313
|
-
*/
|
|
314
|
-
name: "AES-GCM" | "AES-CBC" | "AES-CTR" | "AES-CFB" | "AES-KW";
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* The length of the key, in bits.
|
|
318
|
-
*/
|
|
319
|
-
length: 128 | 192 | 256;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* The `AesCtrParams` dictionary of the Web Crypto API represents the
|
|
324
|
-
* object that should be passed as the `algorithm` parameter of the
|
|
325
|
-
* `SubtleCrypto.encrypt()` and `SubtleCrypto.decrypt()`, `SubtleCrypto.wrapKey()` and
|
|
326
|
-
* `SubtleCrypto.unwrapKey()` methods when using the AES-CTR algorithm.
|
|
327
|
-
*/
|
|
328
|
-
export interface AesCtrParams extends Algorithm<AlgorithmIdentifier> {
|
|
329
|
-
/**
|
|
330
|
-
* The name of the algorithm to use.
|
|
331
|
-
*/
|
|
332
|
-
name: "AES-CTR";
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* The initial value of the counter block. This must be 16-byte
|
|
336
|
-
* long (the AES block size). The rightmost `length` bits of this
|
|
337
|
-
* block are used for the counter, and the rest is used for the
|
|
338
|
-
* nonce.
|
|
339
|
-
*/
|
|
340
|
-
counter: ArrayBuffer | ArrayBufferView | DataView;
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* The number of bits in the counter block that are used for the actual
|
|
344
|
-
* counter. The counter must be big enough that it doesn't wrap. If the
|
|
345
|
-
* message is `n` blocks and the counter is `m` bits long, then the following
|
|
346
|
-
* must be true: `n < 2^m`.
|
|
347
|
-
*/
|
|
348
|
-
length: number;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* The `AesCbcParams` dictionary of the Web Crypto API represents the
|
|
353
|
-
* object that should be passed as the `algorithm` parameter of the
|
|
354
|
-
* `SubtleCrypto.encrypt()` and `SubtleCrypto.decrypt()`, `SubtleCrypto.wrapKey()` and
|
|
355
|
-
* `SubtleCrypto.unwrapKey()` methods when using the AES-CBC algorithm.
|
|
356
|
-
*/
|
|
357
|
-
export interface AesCbcParams extends Algorithm<AlgorithmIdentifier> {
|
|
358
|
-
/**
|
|
359
|
-
* The name of the algorithm to use.
|
|
360
|
-
*/
|
|
361
|
-
name: "AES-CBC";
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* The initialization vector to use for the operation.
|
|
365
|
-
* This must be 16-byte long (the AES block size), unpredictable, and
|
|
366
|
-
* preferably cryptographically random. However, it is not required to be
|
|
367
|
-
* secret (it may be transmitted unencrypted along with the ciphertext).
|
|
368
|
-
*/
|
|
369
|
-
iv: ArrayBuffer | ArrayBufferView | DataView;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* The `AesGcmParams` dictionary of the Web Crypto API represents the
|
|
374
|
-
* object that should be passed as the `algorithm` parameter of the
|
|
375
|
-
* `SubtleCrypto.encrypt()` and `SubtleCrypto.decrypt()`, `SubtleCrypto.wrapKey()` and
|
|
376
|
-
* `SubtleCrypto.unwrapKey()` methods when using the AES-GCM algorithm.
|
|
377
|
-
*/
|
|
378
|
-
export interface AesGcmParams extends Algorithm<AlgorithmIdentifier> {
|
|
379
|
-
/**
|
|
380
|
-
* The name of the algorithm to use.
|
|
381
|
-
*/
|
|
382
|
-
name: "AES-GCM";
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* The initialization vector to use for the operation.
|
|
386
|
-
* This must be 12-byte long (the GCM block size), unpredictable, and
|
|
387
|
-
* preferably cryptographically random. This must be unique for every
|
|
388
|
-
* encryption operation carried out with a given key. Put another way,
|
|
389
|
-
* never reuse an IV with the same key.
|
|
390
|
-
*/
|
|
391
|
-
iv: ArrayBuffer | ArrayBufferView | DataView;
|
|
392
|
-
|
|
393
|
-
/**
|
|
394
|
-
* Contains additional data that will not be encrypted but will be
|
|
395
|
-
* authenticated. This is optional, and can be omitted if you don't
|
|
396
|
-
* need to pass any additional data. If `additionalData` is specified,
|
|
397
|
-
* then the same data must be given in the corresponding call to `decrypt()`.
|
|
398
|
-
* If the data is not the same, then the decryption will fail. This gives
|
|
399
|
-
* you a way to authenticate the data, without having to encrypt it.
|
|
400
|
-
*/
|
|
401
|
-
additionalData?: ArrayBuffer | ArrayBufferView | DataView;
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* The length of the authentication tag, in bits. This must be of size
|
|
405
|
-
* 96.
|
|
406
|
-
*/
|
|
407
|
-
tagLength?: number;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* The `RsaOaepParams` dictionary of the Web Crypto API represents the
|
|
412
|
-
* object that should be passed as the `algorithm` parameter of the
|
|
413
|
-
* `SubtleCrypto.encrypt()` and `SubtleCrypto.decrypt()` methods when
|
|
414
|
-
* using the RSA-OAEP algorithm.
|
|
415
|
-
*/
|
|
416
|
-
export interface RsaOaepParams extends Algorithm<AlgorithmIdentifier> {
|
|
417
|
-
/**
|
|
418
|
-
* The name of the algorithm to use.
|
|
419
|
-
*/
|
|
420
|
-
name: "RSA-OAEP";
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* The label to use. If not provided, it will default to an empty ArrayBuffer.
|
|
424
|
-
*/
|
|
425
|
-
label?: ArrayBuffer | ArrayBufferView | DataView;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* The `HmacKeyGenParams` dictionary of the Web Crypto API represents the
|
|
430
|
-
* object that should be passed as the `algorithm` parameter of the
|
|
431
|
-
* `SubtleCrypto.generateKey()` method when generating a new HMAC key.
|
|
432
|
-
*/
|
|
433
|
-
export interface HmacKeyGenParams extends Algorithm<AlgorithmIdentifier> {
|
|
434
|
-
/**
|
|
435
|
-
* The name of the algorithm to use.
|
|
436
|
-
*/
|
|
437
|
-
name: "HMAC";
|
|
438
|
-
|
|
439
|
-
/**
|
|
440
|
-
* A string representing the name of the digest function to use.
|
|
441
|
-
*/
|
|
442
|
-
hash: "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512";
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* The length of the key, in bits. If the length is not specified,
|
|
446
|
-
* then the generated key will be as long as the block size of
|
|
447
|
-
* the hash function you have chosen. Unless you have a good reason
|
|
448
|
-
* to use a different length, omit this property and use the default.
|
|
449
|
-
*/
|
|
450
|
-
length?: number;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* The EcKeyGenParams dictionary of the Web Crypto API represents the
|
|
455
|
-
* object that should be passed as the algorithm parameter into
|
|
456
|
-
* `SubtleCrypto.generateKey()`, when generating
|
|
457
|
-
* any elliptic-curve-based key pair:
|
|
458
|
-
* that is, when the algorithm is identified as either of ECDSA or ECDH.
|
|
459
|
-
*/
|
|
460
|
-
export interface EcKeyGenParams extends Algorithm<AlgorithmIdentifier> {
|
|
461
|
-
/**
|
|
462
|
-
* The name of the algorithm to use.
|
|
463
|
-
*/
|
|
464
|
-
name: "ECDSA" | "ECDH";
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* The name of the elliptic curve to use.
|
|
468
|
-
* This may be any of the following names for NIST-approved curves.
|
|
469
|
-
*/
|
|
470
|
-
namedCurve: "P-256" | "P-384" | "P-521";
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
/**
|
|
474
|
-
* The RSAHashedKeyGenParams dictionary of the Web Crypto API represents the
|
|
475
|
-
* object that should be passed as the algorithm parameter into
|
|
476
|
-
* `SubtleCrypto.generateKey()`, when the algorithm is identified
|
|
477
|
-
* as either of RSASSA-PKCS1-v1_5, RSA-PSS or RSA-OAEP.
|
|
478
|
-
*/
|
|
479
|
-
export interface RSAHashedKeyGenParams extends Algorithm<AlgorithmIdentifier> {
|
|
480
|
-
/**
|
|
481
|
-
* The name of the algorithm to use.
|
|
482
|
-
*/
|
|
483
|
-
name: "RSASSA-PKCS1-v1_5" | "RSA-PSS" | "RSA-OAEP";
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
* The modulus length, in bits.
|
|
487
|
-
*/
|
|
488
|
-
modulusLength: number;
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* The public exponent.
|
|
492
|
-
*/
|
|
493
|
-
publicExponent: Uint8Array;
|
|
494
|
-
|
|
495
|
-
/**
|
|
496
|
-
* The hash algorithm to use.
|
|
497
|
-
*/
|
|
498
|
-
hash: HashAlgorithmIdentifier;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
/**
|
|
502
|
-
* The `HmacImportParams` dictionary of the Web Crypto API represents the
|
|
503
|
-
* object that should be passed as the `algorithm` parameter of the
|
|
504
|
-
* `SubtleCrypto.importKey()` method when importing an HMAC key.
|
|
505
|
-
*/
|
|
506
|
-
export interface HmacImportParams extends Algorithm<AlgorithmIdentifier> {
|
|
507
|
-
/**
|
|
508
|
-
* The name of the algorithm to use.
|
|
509
|
-
*/
|
|
510
|
-
name: "HMAC";
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* The name of the digest function to use.
|
|
514
|
-
*/
|
|
515
|
-
hash: HashAlgorithmIdentifier;
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* The length of the key, in bits. If the length is not specified,
|
|
519
|
-
* then the generated key will be as long as the block size of
|
|
520
|
-
* the hash function you have chosen. Unless you have a good reason
|
|
521
|
-
* to use a different length, omit this property and use the default.
|
|
522
|
-
*/
|
|
523
|
-
length?: number;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* The `EcKeyImportParams` dictionary of the Web Crypto API represents
|
|
528
|
-
* the object that should be passed as the algorithm parameter
|
|
529
|
-
* into SubtleCrypto.importKey() or SubtleCrypto.unwrapKey(),
|
|
530
|
-
* when generating any elliptic-curve-based key pair:
|
|
531
|
-
* that is, when the algorithm is identified as either of ECDSA or ECDH.
|
|
532
|
-
*/
|
|
533
|
-
export interface EcKeyImportParams extends Algorithm<AlgorithmIdentifier> {
|
|
534
|
-
/**
|
|
535
|
-
* The name of the algorithm to use.
|
|
536
|
-
*/
|
|
537
|
-
name: "ECDSA" | "ECDH";
|
|
538
|
-
|
|
539
|
-
/**
|
|
540
|
-
* The name of the elliptic curve to use.
|
|
541
|
-
* This may be any of the following names for NIST-approved curves.
|
|
542
|
-
*/
|
|
543
|
-
namedCurve: "P-256" | "P-384" | "P-521";
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* The `RsaHashedImportParams` dictionary of the Web Crypto API represents
|
|
548
|
-
* the object that should be passed as the algorithm parameter
|
|
549
|
-
* into SubtleCrypto.importKey(), when the algorithm is identified
|
|
550
|
-
* as either of RSASSA-PKCS1-v1_5, RSA-PSS or RSA-OAEP.
|
|
551
|
-
*/
|
|
552
|
-
export interface RsaHashedImportParams extends Algorithm<AlgorithmIdentifier> {
|
|
553
|
-
/**
|
|
554
|
-
* The name of the algorithm to use.
|
|
555
|
-
*/
|
|
556
|
-
name: "RSASSA-PKCS1-v1_5" | "RSA-PSS" | "RSA-OAEP";
|
|
557
|
-
|
|
558
|
-
/**
|
|
559
|
-
* The hash algorithm to use.
|
|
560
|
-
*/
|
|
561
|
-
hash: HashAlgorithmIdentifier;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
/**
|
|
565
|
-
* The `EcdsaParams` dictionary of the Web Crypto API represents
|
|
566
|
-
* the object that should be passed as the algorithm parameter
|
|
567
|
-
* into SubtleCrypto.sign() or SubtleCrypto.verify()
|
|
568
|
-
* when using the ECDSA algorithm.
|
|
569
|
-
*/
|
|
570
|
-
export interface EcdsaParams extends Algorithm<AlgorithmIdentifier> {
|
|
571
|
-
/**
|
|
572
|
-
* The name of the algorithm to use.
|
|
573
|
-
*/
|
|
574
|
-
name: "ECDSA";
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* An identifier for the digest algorithm to use.
|
|
578
|
-
*/
|
|
579
|
-
hash: "SHA-1" | "SHA-256" | "SHA-384" | "SHA-512";
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
/**
|
|
583
|
-
* The `RsaPssParams` dictionary of the Web Crypto API represents
|
|
584
|
-
* the object that should be passed as the algorithm parameter
|
|
585
|
-
* into SubtleCrypto.sign() or SubtleCrypto.verify()
|
|
586
|
-
* when using the RSA-PSS algorithm.
|
|
587
|
-
*/
|
|
588
|
-
export interface RsaPssParams extends Algorithm<AlgorithmIdentifier> {
|
|
589
|
-
/**
|
|
590
|
-
* The name of the algorithm to use.
|
|
591
|
-
*/
|
|
592
|
-
name: "RSA-PSS";
|
|
593
|
-
|
|
594
|
-
/**
|
|
595
|
-
* The length of the salt to use.
|
|
596
|
-
*/
|
|
597
|
-
saltLength: number;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
/**
|
|
601
|
-
* The `EcdhKeyDeriveParams` dictionary of the Web Crypto API represents
|
|
602
|
-
* the object that should be passed as the algorithm parameter
|
|
603
|
-
* into `SubtleCrypto.deriveKey()`, when using the ECDH algorithm.
|
|
604
|
-
*/
|
|
605
|
-
export interface EcdhKeyDeriveParams extends Algorithm<AlgorithmIdentifier> {
|
|
606
|
-
/**
|
|
607
|
-
* The name of the algorithm to use. Only the "ECDH" value is possible.
|
|
608
|
-
*/
|
|
609
|
-
name: "ECDH";
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* A `CryptoKey` object representing the public key of the other entity.
|
|
613
|
-
*/
|
|
614
|
-
public: CryptoKey;
|
|
615
|
-
}
|
|
616
|
-
|
|
617
|
-
/**
|
|
618
|
-
* The TypedArray interface represents an array-like view of an underlying
|
|
619
|
-
* binary data buffer. It is used to represent a generic, fixed-length
|
|
620
|
-
* raw binary data buffer. The ArrayBuffer that underlies a typed array
|
|
621
|
-
* can be accessed and modified by using the ArrayBufferView methods.
|
|
622
|
-
*
|
|
623
|
-
* Note that this type does not include Float32Array and Float64Array, which
|
|
624
|
-
* makes it differ from the ArrayBufferView type.
|
|
625
|
-
*/
|
|
626
|
-
export type TypedArray =
|
|
627
|
-
| Int8Array
|
|
628
|
-
| Uint8Array
|
|
629
|
-
| Uint8ClampedArray
|
|
630
|
-
| Int16Array
|
|
631
|
-
| Uint16Array
|
|
632
|
-
| Int32Array
|
|
633
|
-
| Uint32Array;
|
|
634
|
-
|
|
635
|
-
/**
|
|
636
|
-
* JSON Web Key Value.
|
|
637
|
-
* JWKs are not supported for now, since webcrypto doesn't support exporting key/pairs
|
|
638
|
-
*/
|
|
639
|
-
export type JWKValue = null | boolean | number | string | string[] | JWK;
|
|
640
|
-
|
|
641
|
-
/**
|
|
642
|
-
* Object representable with JSON Web Key.
|
|
643
|
-
*/
|
|
644
|
-
export interface JWK {
|
|
645
|
-
[key: string]: JWKValue;
|
|
646
|
-
}
|