@tothalex/cloud 0.0.40
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/package.json +19 -0
- package/src/abort.d.ts +69 -0
- package/src/assert.d.ts +39 -0
- package/src/buffer.d.ts +556 -0
- package/src/child_process.d.ts +447 -0
- package/src/crypto.d.ts +854 -0
- package/src/database.d.ts +0 -0
- package/src/dns.d.ts +99 -0
- package/src/events.d.ts +245 -0
- package/src/exceptions.d.ts +26 -0
- package/src/http.d.ts +325 -0
- package/src/index.d.ts +22 -0
- package/src/net.d.ts +488 -0
- package/src/os.d.ts +293 -0
- package/src/process.d.ts +379 -0
- package/src/stream.d.ts +366 -0
- package/src/string_decoder.d.ts +63 -0
- package/src/timers.d.ts +72 -0
- package/src/tty.d.ts +10 -0
- package/src/url.d.ts +774 -0
- package/src/util.d.ts +240 -0
- package/src/zlib.d.ts +149 -0
package/src/crypto.d.ts
ADDED
|
@@ -0,0 +1,854 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `crypto` module provides cryptographic functionality that includes a
|
|
3
|
+
* set of wrappers for OpenSSL's hash, HMAC.
|
|
4
|
+
*
|
|
5
|
+
* ```js
|
|
6
|
+
* import { createHmac } from 'crypto';
|
|
7
|
+
*
|
|
8
|
+
* const secret = 'abcdefg';
|
|
9
|
+
* const hash = createHmac('sha256', secret)
|
|
10
|
+
* .update('I love cupcakes')
|
|
11
|
+
* .digest('hex');
|
|
12
|
+
* console.log(hash);
|
|
13
|
+
* // Prints:
|
|
14
|
+
* // c0fa1bc00531bd78ef38c628449c5102aeabd49b5dc3a2a516ea6ea959d6658e
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
declare module "crypto" {
|
|
18
|
+
import { Buffer } from "buffer";
|
|
19
|
+
type BinaryLike = string | QuickJS.ArrayBufferView;
|
|
20
|
+
type BinaryToTextEncoding = "base64" | "hex";
|
|
21
|
+
type CharacterEncoding = "utf8" | "utf-8" | "utf16le" | "utf-16le" | "latin1";
|
|
22
|
+
type LegacyCharacterEncoding = "ascii";
|
|
23
|
+
type Encoding =
|
|
24
|
+
| BinaryToTextEncoding
|
|
25
|
+
| CharacterEncoding
|
|
26
|
+
| LegacyCharacterEncoding;
|
|
27
|
+
/**
|
|
28
|
+
* Creates and returns a `Hash` object that can be used to generate hash digests
|
|
29
|
+
* using the given `algorithm`.
|
|
30
|
+
*
|
|
31
|
+
* The `algorithm` is supported by `'sha1'`, `'sha256'`,`'sha384'` and `'sha512'`.
|
|
32
|
+
*/
|
|
33
|
+
function createHash(algorithm: string): Hash;
|
|
34
|
+
/**
|
|
35
|
+
* Creates and returns an `Hmac` object that uses the given `algorithm` and `key`.
|
|
36
|
+
*
|
|
37
|
+
* The `algorithm` is supported by `'sha1'`, `'sha256'`,`'sha384'` and `'sha512'`.
|
|
38
|
+
*
|
|
39
|
+
* The `key` is the HMAC key used to generate the cryptographic HMAC hash.
|
|
40
|
+
* If it is a string, please consider `caveats when using strings as inputs to cryptographic APIs`.
|
|
41
|
+
* If it was obtained from a cryptographically secure source of entropy, such as {@link randomBytes}
|
|
42
|
+
* or {@link generateKey}, its length should not exceed the block size of `algorithm`
|
|
43
|
+
* (e.g., 512 bits for SHA-256).
|
|
44
|
+
*/
|
|
45
|
+
function createHmac(algorithm: string, key: BinaryLike): Hmac;
|
|
46
|
+
/**
|
|
47
|
+
* The `Hash` class is a utility for creating hash digests of data.
|
|
48
|
+
*
|
|
49
|
+
* Using the `hash.update()` and `hash.digest()` methods to produce the
|
|
50
|
+
* computed hash.
|
|
51
|
+
*
|
|
52
|
+
* The {@link createHash} method is used to create `Hash` instances.
|
|
53
|
+
* `Hash`objects are not to be created directly using the `new` keyword.
|
|
54
|
+
*
|
|
55
|
+
* Example: Using the `hash.update()` and `hash.digest()` methods:
|
|
56
|
+
*
|
|
57
|
+
* ```js
|
|
58
|
+
* import { createHash } from 'crypto';
|
|
59
|
+
*
|
|
60
|
+
* const hash = createHash('sha256');
|
|
61
|
+
*
|
|
62
|
+
* hash.update('some data to hash');
|
|
63
|
+
* console.log(hash.digest('hex'));
|
|
64
|
+
* // Prints:
|
|
65
|
+
* // 6a2da20943931e9834fc12cfe5bb47bbd9ae43489a30726962b576f4e3993e50
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
class Hash {
|
|
69
|
+
private constructor();
|
|
70
|
+
/**
|
|
71
|
+
* Updates the hash content with the given `data`, the encoding of which
|
|
72
|
+
* is given in `inputEncoding`.
|
|
73
|
+
* If `encoding` is not provided, and the `data` is a string, an
|
|
74
|
+
* encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`,
|
|
75
|
+
* then `inputEncoding` is ignored.
|
|
76
|
+
*
|
|
77
|
+
* This can be called many times with new data as it is streamed.
|
|
78
|
+
* @param inputEncoding The `encoding` of the `data` string.
|
|
79
|
+
*/
|
|
80
|
+
update(data: BinaryLike): Hash;
|
|
81
|
+
update(data: string, inputEncoding: Encoding): Hash;
|
|
82
|
+
/**
|
|
83
|
+
* Calculates the digest of all of the data passed to be hashed (using the `hash.update()` method).
|
|
84
|
+
* If `encoding` is provided a string will be returned; otherwise
|
|
85
|
+
* a `Buffer` is returned.
|
|
86
|
+
*
|
|
87
|
+
* The `Hash` object can not be used again after `hash.digest()` method has been
|
|
88
|
+
* called. Multiple calls will cause an error to be thrown.
|
|
89
|
+
* @param encoding The `encoding` of the return value.
|
|
90
|
+
*/
|
|
91
|
+
digest(): Buffer;
|
|
92
|
+
digest(encoding: BinaryToTextEncoding): string;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The `Hmac` class is a utility for creating cryptographic HMAC digests.
|
|
96
|
+
*
|
|
97
|
+
* Using the `hmac.update()` and `hmac.digest()` methods to produce the
|
|
98
|
+
* computed HMAC digest.
|
|
99
|
+
*
|
|
100
|
+
* The {@link createHmac} method is used to create `Hmac` instances.
|
|
101
|
+
* `Hmac`objects are not to be created directly using the `new` keyword.
|
|
102
|
+
*
|
|
103
|
+
* Example: Using the `hmac.update()` and `hmac.digest()` methods:
|
|
104
|
+
*
|
|
105
|
+
* ```js
|
|
106
|
+
* import { createHmac } from 'crypto';
|
|
107
|
+
*
|
|
108
|
+
* const hmac = createHmac('sha256', 'a secret');
|
|
109
|
+
*
|
|
110
|
+
* hmac.update('some data to hash');
|
|
111
|
+
* console.log(hmac.digest('hex'));
|
|
112
|
+
* // Prints:
|
|
113
|
+
* // 7fd04df92f636fd450bc841c9418e5825c17f33ad9c87c518115a45971f7f77e
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
class Hmac {
|
|
117
|
+
private constructor();
|
|
118
|
+
/**
|
|
119
|
+
* Updates the `Hmac` content with the given `data`, the encoding of which
|
|
120
|
+
* is given in `inputEncoding`.
|
|
121
|
+
* If `encoding` is not provided, and the `data` is a string, an
|
|
122
|
+
* encoding of `'utf8'` is enforced. If `data` is a `Buffer`, `TypedArray`, or`DataView`,
|
|
123
|
+
* then `inputEncoding` is ignored.
|
|
124
|
+
*
|
|
125
|
+
* This can be called many times with new data as it is streamed.
|
|
126
|
+
* @param inputEncoding The `encoding` of the `data` string.
|
|
127
|
+
*/
|
|
128
|
+
update(data: BinaryLike): Hmac;
|
|
129
|
+
update(data: string, inputEncoding: Encoding): Hmac;
|
|
130
|
+
/**
|
|
131
|
+
* Calculates the HMAC digest of all of the data passed using `hmac.update()`.
|
|
132
|
+
* If `encoding` is
|
|
133
|
+
* provided a string is returned; otherwise a `Buffer` is returned;
|
|
134
|
+
*
|
|
135
|
+
* The `Hmac` object can not be used again after `hmac.digest()` has been
|
|
136
|
+
* called. Multiple calls to `hmac.digest()` will result in an error being thrown.
|
|
137
|
+
* @param encoding The `encoding` of the return value.
|
|
138
|
+
*/
|
|
139
|
+
digest(): Buffer;
|
|
140
|
+
digest(encoding: BinaryToTextEncoding): string;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Generates cryptographically strong pseudorandom data. The `size` argument
|
|
144
|
+
* is a number indicating the number of bytes to generate.
|
|
145
|
+
*
|
|
146
|
+
* the random bytes are generated synchronously and returned as a `Buffer`.
|
|
147
|
+
* An error will be thrown if there is a problem generating the bytes.
|
|
148
|
+
*
|
|
149
|
+
* ```js
|
|
150
|
+
* // Synchronous
|
|
151
|
+
* import { randomBytes } from 'crypto';
|
|
152
|
+
*
|
|
153
|
+
* const buf = randomBytes(256);
|
|
154
|
+
* console.log(
|
|
155
|
+
* `${buf.length} bytes of random data: ${buf.toString('hex')}`);
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* The `crypto.randomBytes()` method will not complete until there is
|
|
159
|
+
* sufficient entropy available.
|
|
160
|
+
* This should normally never take longer than a few milliseconds. The only time
|
|
161
|
+
* when generating the random bytes may conceivably block for a longer period of
|
|
162
|
+
* time is right after boot, when the whole system is still low on entropy.
|
|
163
|
+
*
|
|
164
|
+
* @param size The number of bytes to generate. The `size` must not be larger than `2**31 - 1`.
|
|
165
|
+
*/
|
|
166
|
+
function randomBytes(size: number): Buffer;
|
|
167
|
+
/**
|
|
168
|
+
* Return a random integer `n` such that `min <= n < max`. This
|
|
169
|
+
* implementation avoids [modulo bias](https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#Modulo_bias).
|
|
170
|
+
*
|
|
171
|
+
* The range (`max - min`) must be less than 2**48. `min` and `max` must
|
|
172
|
+
* be [safe integers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger).
|
|
173
|
+
*
|
|
174
|
+
* ```js
|
|
175
|
+
* // Synchronous
|
|
176
|
+
* import { randomInt } from 'crypto';
|
|
177
|
+
*
|
|
178
|
+
* const n = randomInt(3);
|
|
179
|
+
* console.log(`Random number chosen from (0, 1, 2): ${n}`);
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* ```js
|
|
183
|
+
* // With `min` argument
|
|
184
|
+
* import { randomInt } from 'crypto';
|
|
185
|
+
*
|
|
186
|
+
* const n = randomInt(1, 7);
|
|
187
|
+
* console.log(`The dice rolled: ${n}`);
|
|
188
|
+
* ```
|
|
189
|
+
* @param [min=0] Start of random range (inclusive).
|
|
190
|
+
* @param max End of random range (exclusive).
|
|
191
|
+
*/
|
|
192
|
+
function randomInt(max: number): number;
|
|
193
|
+
function randomInt(min: number, max: number): number;
|
|
194
|
+
/**
|
|
195
|
+
* Synchronous version of {@link randomFill}.
|
|
196
|
+
*
|
|
197
|
+
* ```js
|
|
198
|
+
* import { Buffer } from 'buffer';
|
|
199
|
+
* import { randomFillSync } from 'crypto';
|
|
200
|
+
*
|
|
201
|
+
* const buf = Buffer.alloc(10);
|
|
202
|
+
* console.log(randomFillSync(buf).toString('hex'));
|
|
203
|
+
*
|
|
204
|
+
* randomFillSync(buf, 5);
|
|
205
|
+
* console.log(buf.toString('hex'));
|
|
206
|
+
*
|
|
207
|
+
* // The above is equivalent to the following:
|
|
208
|
+
* randomFillSync(buf, 5, 5);
|
|
209
|
+
* console.log(buf.toString('hex'));
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* Any `ArrayBuffer`, `TypedArray` or `DataView` instance may be passed as`buffer`.
|
|
213
|
+
*
|
|
214
|
+
* ```js
|
|
215
|
+
* import { Buffer } from 'buffer';
|
|
216
|
+
* import { randomFillSync } from 'crypto';
|
|
217
|
+
*
|
|
218
|
+
* const a = new Uint32Array(10);
|
|
219
|
+
* console.log(Buffer.from(randomFillSync(a).buffer,
|
|
220
|
+
* a.byteOffset, a.byteLength).toString('hex'));
|
|
221
|
+
*
|
|
222
|
+
* const b = new DataView(new ArrayBuffer(10));
|
|
223
|
+
* console.log(Buffer.from(randomFillSync(b).buffer,
|
|
224
|
+
* b.byteOffset, b.byteLength).toString('hex'));
|
|
225
|
+
*
|
|
226
|
+
* const c = new ArrayBuffer(10);
|
|
227
|
+
* console.log(Buffer.from(randomFillSync(c)).toString('hex'));
|
|
228
|
+
* ```
|
|
229
|
+
* @param buffer Must be supplied. The size of the provided `buffer` must not be larger than `2**31 - 1`.
|
|
230
|
+
* @param [offset=0]
|
|
231
|
+
* @param [size=buffer.length - offset]
|
|
232
|
+
* @return The object passed as `buffer` argument.
|
|
233
|
+
*/
|
|
234
|
+
function randomFillSync<T extends QuickJS.ArrayBufferView>(
|
|
235
|
+
buffer: T,
|
|
236
|
+
offset?: number,
|
|
237
|
+
size?: number
|
|
238
|
+
): T;
|
|
239
|
+
/**
|
|
240
|
+
* This function is similar to {@link randomBytes} but requires the first
|
|
241
|
+
* argument to be a `Buffer` that will be filled. It also
|
|
242
|
+
* requires that a callback is passed in.
|
|
243
|
+
*
|
|
244
|
+
* If the `callback` function is not provided, an error will be thrown.
|
|
245
|
+
*
|
|
246
|
+
* ```js
|
|
247
|
+
* import { Buffer } from 'buffer';
|
|
248
|
+
* import { randomFill } from 'crypto';
|
|
249
|
+
*
|
|
250
|
+
* const buf = Buffer.alloc(10);
|
|
251
|
+
* randomFill(buf, (err, buf) => {
|
|
252
|
+
* if (err) throw err;
|
|
253
|
+
* console.log(buf.toString('hex'));
|
|
254
|
+
* });
|
|
255
|
+
*
|
|
256
|
+
* randomFill(buf, 5, (err, buf) => {
|
|
257
|
+
* if (err) throw err;
|
|
258
|
+
* console.log(buf.toString('hex'));
|
|
259
|
+
* });
|
|
260
|
+
*
|
|
261
|
+
* // The above is equivalent to the following:
|
|
262
|
+
* randomFill(buf, 5, 5, (err, buf) => {
|
|
263
|
+
* if (err) throw err;
|
|
264
|
+
* console.log(buf.toString('hex'));
|
|
265
|
+
* });
|
|
266
|
+
* ```
|
|
267
|
+
*
|
|
268
|
+
* Any `ArrayBuffer`, `TypedArray`, or `DataView` instance may be passed as `buffer`.
|
|
269
|
+
*
|
|
270
|
+
* While this includes instances of `Float32Array` and `Float64Array`, this
|
|
271
|
+
* function should not be used to generate random floating-point numbers. The
|
|
272
|
+
* result may contain `+Infinity`, `-Infinity`, and `NaN`, and even if the array
|
|
273
|
+
* contains finite numbers only, they are not drawn from a uniform random
|
|
274
|
+
* distribution and have no meaningful lower or upper bounds.
|
|
275
|
+
*
|
|
276
|
+
* ```js
|
|
277
|
+
* import { Buffer } from 'buffer';
|
|
278
|
+
* import { randomFill } from 'crypto';
|
|
279
|
+
*
|
|
280
|
+
* const a = new Uint32Array(10);
|
|
281
|
+
* randomFill(a, (err, buf) => {
|
|
282
|
+
* if (err) throw err;
|
|
283
|
+
* console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
284
|
+
* .toString('hex'));
|
|
285
|
+
* });
|
|
286
|
+
*
|
|
287
|
+
* const b = new DataView(new ArrayBuffer(10));
|
|
288
|
+
* randomFill(b, (err, buf) => {
|
|
289
|
+
* if (err) throw err;
|
|
290
|
+
* console.log(Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
291
|
+
* .toString('hex'));
|
|
292
|
+
* });
|
|
293
|
+
*
|
|
294
|
+
* const c = new ArrayBuffer(10);
|
|
295
|
+
* randomFill(c, (err, buf) => {
|
|
296
|
+
* if (err) throw err;
|
|
297
|
+
* console.log(Buffer.from(buf).toString('hex'));
|
|
298
|
+
* });
|
|
299
|
+
* ```
|
|
300
|
+
* @param buffer Must be supplied. The size of the provided `buffer` must not be larger than `2**31 - 1`.
|
|
301
|
+
* @param [offset=0]
|
|
302
|
+
* @param [size=buffer.length - offset]
|
|
303
|
+
* @param callback `function(err, buf) {}`.
|
|
304
|
+
*/
|
|
305
|
+
function randomFill<T extends QuickJS.ArrayBufferView>(
|
|
306
|
+
buffer: T,
|
|
307
|
+
callback: (err: Error | null, buf: T) => void
|
|
308
|
+
): void;
|
|
309
|
+
function randomFill<T extends QuickJS.ArrayBufferView>(
|
|
310
|
+
buffer: T,
|
|
311
|
+
offset: number,
|
|
312
|
+
callback: (err: Error | null, buf: T) => void
|
|
313
|
+
): void;
|
|
314
|
+
function randomFill<T extends QuickJS.ArrayBufferView>(
|
|
315
|
+
buffer: T,
|
|
316
|
+
offset: number,
|
|
317
|
+
size: number,
|
|
318
|
+
callback: (err: Error | null, buf: T) => void
|
|
319
|
+
): void;
|
|
320
|
+
type UUID = `${string}-${string}-${string}-${string}-${string}`;
|
|
321
|
+
/**
|
|
322
|
+
* A convenient alias for {@link webcrypto.getRandomValues}. This
|
|
323
|
+
* implementation is not compliant with the Web Crypto spec, to write
|
|
324
|
+
* web-compatible code use {@link webcrypto.getRandomValues} instead.
|
|
325
|
+
* @return Returns `typedArray`.
|
|
326
|
+
*/
|
|
327
|
+
function getRandomValues<T extends QuickJS.ArrayBufferView>(typedArray: T): T;
|
|
328
|
+
/**
|
|
329
|
+
* Generates a random {@link https://www.rfc-editor.org/rfc/rfc4122.txt RFC 4122} version 4 UUID.
|
|
330
|
+
* The UUID is generated using a cryptographic pseudorandom number generator.
|
|
331
|
+
*/
|
|
332
|
+
function randomUUID(): UUID;
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* A convenient alias for `crypto.webcrypto.subtle`.
|
|
336
|
+
* @since v17.4.0
|
|
337
|
+
*/
|
|
338
|
+
const subtle: webcrypto.SubtleCrypto;
|
|
339
|
+
/**
|
|
340
|
+
* An implementation of the Web Crypto API standard.
|
|
341
|
+
*
|
|
342
|
+
* See the {@link https://nodejs.org/docs/latest/api/webcrypto.html Web Crypto API documentation} for details.
|
|
343
|
+
*/
|
|
344
|
+
namespace webcrypto {
|
|
345
|
+
type BufferSource = ArrayBufferView | ArrayBuffer;
|
|
346
|
+
type KeyFormat = "jwk" | "pkcs8" | "raw" | "spki";
|
|
347
|
+
type KeyType = "private" | "public" | "secret";
|
|
348
|
+
type KeyUsage =
|
|
349
|
+
| "decrypt"
|
|
350
|
+
| "deriveBits"
|
|
351
|
+
| "deriveKey"
|
|
352
|
+
| "encrypt"
|
|
353
|
+
| "sign"
|
|
354
|
+
| "unwrapKey"
|
|
355
|
+
| "verify"
|
|
356
|
+
| "wrapKey";
|
|
357
|
+
type AlgorithmIdentifier = Algorithm | string;
|
|
358
|
+
type HashAlgorithmIdentifier = AlgorithmIdentifier;
|
|
359
|
+
type NamedCurve = string;
|
|
360
|
+
type BigInteger = Uint8Array;
|
|
361
|
+
interface AesCbcParams extends Algorithm {
|
|
362
|
+
iv: BufferSource;
|
|
363
|
+
}
|
|
364
|
+
interface AesCtrParams extends Algorithm {
|
|
365
|
+
counter: BufferSource;
|
|
366
|
+
length: number;
|
|
367
|
+
}
|
|
368
|
+
interface AesDerivedKeyParams extends Algorithm {
|
|
369
|
+
length: number;
|
|
370
|
+
}
|
|
371
|
+
interface AesGcmParams extends Algorithm {
|
|
372
|
+
additionalData?: BufferSource;
|
|
373
|
+
iv: BufferSource;
|
|
374
|
+
tagLength?: number;
|
|
375
|
+
}
|
|
376
|
+
interface AesKeyAlgorithm extends KeyAlgorithm {
|
|
377
|
+
length: number;
|
|
378
|
+
}
|
|
379
|
+
interface AesKeyGenParams extends Algorithm {
|
|
380
|
+
length: number;
|
|
381
|
+
}
|
|
382
|
+
interface Algorithm {
|
|
383
|
+
name: string;
|
|
384
|
+
}
|
|
385
|
+
interface EcKeyAlgorithm extends KeyAlgorithm {
|
|
386
|
+
namedCurve: NamedCurve;
|
|
387
|
+
}
|
|
388
|
+
interface EcKeyGenParams extends Algorithm {
|
|
389
|
+
namedCurve: NamedCurve;
|
|
390
|
+
}
|
|
391
|
+
interface EcKeyImportParams extends Algorithm {
|
|
392
|
+
namedCurve: NamedCurve;
|
|
393
|
+
}
|
|
394
|
+
interface EcdhKeyDeriveParams extends Algorithm {
|
|
395
|
+
public: CryptoKey;
|
|
396
|
+
}
|
|
397
|
+
interface EcdsaParams extends Algorithm {
|
|
398
|
+
hash: HashAlgorithmIdentifier;
|
|
399
|
+
}
|
|
400
|
+
interface Ed448Params extends Algorithm {
|
|
401
|
+
context?: BufferSource;
|
|
402
|
+
}
|
|
403
|
+
interface HkdfParams extends Algorithm {
|
|
404
|
+
hash: HashAlgorithmIdentifier;
|
|
405
|
+
info: BufferSource;
|
|
406
|
+
salt: BufferSource;
|
|
407
|
+
}
|
|
408
|
+
interface HmacImportParams extends Algorithm {
|
|
409
|
+
hash: HashAlgorithmIdentifier;
|
|
410
|
+
length?: number;
|
|
411
|
+
}
|
|
412
|
+
interface HmacKeyAlgorithm extends KeyAlgorithm {
|
|
413
|
+
hash: KeyAlgorithm;
|
|
414
|
+
length: number;
|
|
415
|
+
}
|
|
416
|
+
interface HmacKeyGenParams extends Algorithm {
|
|
417
|
+
hash: HashAlgorithmIdentifier;
|
|
418
|
+
length?: number;
|
|
419
|
+
}
|
|
420
|
+
interface JsonWebKey {
|
|
421
|
+
alg?: string;
|
|
422
|
+
crv?: string;
|
|
423
|
+
d?: string;
|
|
424
|
+
dp?: string;
|
|
425
|
+
dq?: string;
|
|
426
|
+
e?: string;
|
|
427
|
+
ext?: boolean;
|
|
428
|
+
k?: string;
|
|
429
|
+
key_ops?: string[];
|
|
430
|
+
kty?: string;
|
|
431
|
+
n?: string;
|
|
432
|
+
oth?: RsaOtherPrimesInfo[];
|
|
433
|
+
p?: string;
|
|
434
|
+
q?: string;
|
|
435
|
+
qi?: string;
|
|
436
|
+
use?: string;
|
|
437
|
+
x?: string;
|
|
438
|
+
y?: string;
|
|
439
|
+
}
|
|
440
|
+
interface KeyAlgorithm {
|
|
441
|
+
name: string;
|
|
442
|
+
}
|
|
443
|
+
interface Pbkdf2Params extends Algorithm {
|
|
444
|
+
hash: HashAlgorithmIdentifier;
|
|
445
|
+
iterations: number;
|
|
446
|
+
salt: BufferSource;
|
|
447
|
+
}
|
|
448
|
+
interface RsaHashedImportParams extends Algorithm {
|
|
449
|
+
hash: HashAlgorithmIdentifier;
|
|
450
|
+
}
|
|
451
|
+
interface RsaHashedKeyAlgorithm extends RsaKeyAlgorithm {
|
|
452
|
+
hash: KeyAlgorithm;
|
|
453
|
+
}
|
|
454
|
+
interface RsaHashedKeyGenParams extends RsaKeyGenParams {
|
|
455
|
+
hash: HashAlgorithmIdentifier;
|
|
456
|
+
}
|
|
457
|
+
interface RsaKeyAlgorithm extends KeyAlgorithm {
|
|
458
|
+
modulusLength: number;
|
|
459
|
+
publicExponent: BigInteger;
|
|
460
|
+
}
|
|
461
|
+
interface RsaKeyGenParams extends Algorithm {
|
|
462
|
+
modulusLength: number;
|
|
463
|
+
publicExponent: BigInteger;
|
|
464
|
+
}
|
|
465
|
+
interface RsaOaepParams extends Algorithm {
|
|
466
|
+
label?: BufferSource;
|
|
467
|
+
}
|
|
468
|
+
interface RsaOtherPrimesInfo {
|
|
469
|
+
d?: string;
|
|
470
|
+
r?: string;
|
|
471
|
+
t?: string;
|
|
472
|
+
}
|
|
473
|
+
interface RsaPssParams extends Algorithm {
|
|
474
|
+
saltLength: number;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
interface CryptoKey {
|
|
478
|
+
/**
|
|
479
|
+
* An object detailing the algorithm for which the key can be used along with additional algorithm-specific parameters.
|
|
480
|
+
*/
|
|
481
|
+
readonly algorithm: KeyAlgorithm;
|
|
482
|
+
/**
|
|
483
|
+
* When `true`, the {@link CryptoKey} can be extracted using either `subtleCrypto.exportKey()` or `subtleCrypto.wrapKey()`.
|
|
484
|
+
*/
|
|
485
|
+
readonly extractable: boolean;
|
|
486
|
+
/**
|
|
487
|
+
* A string identifying whether the key is a symmetric (`'secret'`) or asymmetric (`'private'` or `'public'`) key.
|
|
488
|
+
*/
|
|
489
|
+
readonly type: KeyType;
|
|
490
|
+
/**
|
|
491
|
+
* An array of strings identifying the operations for which the key may be used.
|
|
492
|
+
*
|
|
493
|
+
* The possible usages are:
|
|
494
|
+
* - `'encrypt'` - The key may be used to encrypt data.
|
|
495
|
+
* - `'decrypt'` - The key may be used to decrypt data.
|
|
496
|
+
* - `'sign'` - The key may be used to generate digital signatures.
|
|
497
|
+
* - `'verify'` - The key may be used to verify digital signatures.
|
|
498
|
+
* - `'deriveKey'` - The key may be used to derive a new key.
|
|
499
|
+
* - `'deriveBits'` - The key may be used to derive bits.
|
|
500
|
+
* - `'wrapKey'` - The key may be used to wrap another key.
|
|
501
|
+
* - `'unwrapKey'` - The key may be used to unwrap another key.
|
|
502
|
+
*
|
|
503
|
+
* Valid key usages depend on the key algorithm (identified by `cryptokey.algorithm.name`).
|
|
504
|
+
* @since v15.0.0
|
|
505
|
+
*/
|
|
506
|
+
readonly usages: KeyUsage[];
|
|
507
|
+
}
|
|
508
|
+
/**
|
|
509
|
+
* The `CryptoKeyPair` is a simple dictionary object with `publicKey` and `privateKey` properties, representing an asymmetric key pair.
|
|
510
|
+
*/
|
|
511
|
+
interface CryptoKeyPair {
|
|
512
|
+
/**
|
|
513
|
+
* A {@link CryptoKey} whose type will be `'private'`.
|
|
514
|
+
*/
|
|
515
|
+
privateKey: CryptoKey;
|
|
516
|
+
/**
|
|
517
|
+
* A {@link CryptoKey} whose type will be `'public'`.
|
|
518
|
+
*/
|
|
519
|
+
publicKey: CryptoKey;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
interface SubtleCrypto {
|
|
523
|
+
/**
|
|
524
|
+
* Using the method and parameters specified in `algorithm` and the keying material provided by `key`,
|
|
525
|
+
* `subtle.decrypt()` attempts to decipher the provided `data`. If successful,
|
|
526
|
+
* the returned promise will be resolved with an `<ArrayBuffer>` containing the plaintext result.
|
|
527
|
+
*
|
|
528
|
+
* The algorithms currently supported include:
|
|
529
|
+
*
|
|
530
|
+
* - `'RSA-OAEP'`
|
|
531
|
+
* - `'AES-CTR'`
|
|
532
|
+
* - `'AES-CBC'`
|
|
533
|
+
* - `'AES-GCM'`
|
|
534
|
+
*/
|
|
535
|
+
decrypt(
|
|
536
|
+
algorithm:
|
|
537
|
+
| AlgorithmIdentifier
|
|
538
|
+
| RsaOaepParams
|
|
539
|
+
| AesCtrParams
|
|
540
|
+
| AesCbcParams
|
|
541
|
+
| AesGcmParams,
|
|
542
|
+
key: CryptoKey,
|
|
543
|
+
data: BufferSource
|
|
544
|
+
): Promise<ArrayBuffer>;
|
|
545
|
+
/**
|
|
546
|
+
* Using the method and parameters specified in `algorithm` and the keying material provided by `baseKey`,
|
|
547
|
+
* `subtle.deriveBits()` attempts to generate `length` bits.
|
|
548
|
+
* The LLRT implementation requires that when `length` is a number it must be multiple of `8`.
|
|
549
|
+
* When `length` is `null` the maximum number of bits for a given algorithm is generated. This is allowed
|
|
550
|
+
* for the `'ECDH'`, `'X25519'`, and `'X448'` algorithms.
|
|
551
|
+
* If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the generated data.
|
|
552
|
+
*
|
|
553
|
+
* The algorithms currently supported include:
|
|
554
|
+
*
|
|
555
|
+
* - `'ECDH'`
|
|
556
|
+
* - `'X25519'`
|
|
557
|
+
* - `'X448'`
|
|
558
|
+
* - `'HKDF'`
|
|
559
|
+
* - `'PBKDF2'`
|
|
560
|
+
*/
|
|
561
|
+
deriveBits(
|
|
562
|
+
algorithm: EcdhKeyDeriveParams,
|
|
563
|
+
baseKey: CryptoKey,
|
|
564
|
+
length: number | null
|
|
565
|
+
): Promise<ArrayBuffer>;
|
|
566
|
+
deriveBits(
|
|
567
|
+
algorithm: AlgorithmIdentifier | HkdfParams | Pbkdf2Params,
|
|
568
|
+
baseKey: CryptoKey,
|
|
569
|
+
length: number
|
|
570
|
+
): Promise<ArrayBuffer>;
|
|
571
|
+
/**
|
|
572
|
+
* Using the method and parameters specified in `algorithm`, and the keying material provided by `baseKey`,
|
|
573
|
+
* `subtle.deriveKey()` attempts to generate a new <CryptoKey>` based on the method and parameters in `derivedKeyAlgorithm`.
|
|
574
|
+
*
|
|
575
|
+
* Calling `subtle.deriveKey()` is equivalent to calling `subtle.deriveBits()` to generate raw keying material,
|
|
576
|
+
* then passing the result into the `subtle.importKey()` method using the `deriveKeyAlgorithm`, `extractable`, and `keyUsages` parameters as input.
|
|
577
|
+
*
|
|
578
|
+
* The algorithms currently supported include:
|
|
579
|
+
*
|
|
580
|
+
* - `'ECDH'`
|
|
581
|
+
* - `'X25519'`
|
|
582
|
+
* - `'X448'`
|
|
583
|
+
* - `'HKDF'`
|
|
584
|
+
* - `'PBKDF2'`
|
|
585
|
+
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
586
|
+
*/
|
|
587
|
+
deriveKey(
|
|
588
|
+
algorithm:
|
|
589
|
+
| AlgorithmIdentifier
|
|
590
|
+
| EcdhKeyDeriveParams
|
|
591
|
+
| HkdfParams
|
|
592
|
+
| Pbkdf2Params,
|
|
593
|
+
baseKey: CryptoKey,
|
|
594
|
+
derivedKeyAlgorithm:
|
|
595
|
+
| AlgorithmIdentifier
|
|
596
|
+
| AesDerivedKeyParams
|
|
597
|
+
| HmacImportParams
|
|
598
|
+
| HkdfParams
|
|
599
|
+
| Pbkdf2Params,
|
|
600
|
+
extractable: boolean,
|
|
601
|
+
keyUsages: readonly KeyUsage[]
|
|
602
|
+
): Promise<CryptoKey>;
|
|
603
|
+
/**
|
|
604
|
+
* Using the method identified by `algorithm`, `subtle.digest()` attempts to generate a digest of `data`.
|
|
605
|
+
* If successful, the returned promise is resolved with an `<ArrayBuffer>` containing the computed digest.
|
|
606
|
+
*
|
|
607
|
+
* If `algorithm` is provided as a `<string>`, it must be one of:
|
|
608
|
+
*
|
|
609
|
+
* - `'SHA-1'`
|
|
610
|
+
* - `'SHA-256'`
|
|
611
|
+
* - `'SHA-384'`
|
|
612
|
+
* - `'SHA-512'`
|
|
613
|
+
*
|
|
614
|
+
* If `algorithm` is provided as an `<Object>`, it must have a `name` property whose value is one of the above.
|
|
615
|
+
*/
|
|
616
|
+
digest(
|
|
617
|
+
algorithm: AlgorithmIdentifier,
|
|
618
|
+
data: BufferSource
|
|
619
|
+
): Promise<ArrayBuffer>;
|
|
620
|
+
/**
|
|
621
|
+
* Using the method and parameters specified by `algorithm` and the keying material provided by `key`,
|
|
622
|
+
* `subtle.encrypt()` attempts to encipher `data`. If successful,
|
|
623
|
+
* the returned promise is resolved with an `<ArrayBuffer>` containing the encrypted result.
|
|
624
|
+
*
|
|
625
|
+
* The algorithms currently supported include:
|
|
626
|
+
*
|
|
627
|
+
* - `'RSA-OAEP'`
|
|
628
|
+
* - `'AES-CTR'`
|
|
629
|
+
* - `'AES-CBC'`
|
|
630
|
+
* - `'AES-GCM'`
|
|
631
|
+
*/
|
|
632
|
+
encrypt(
|
|
633
|
+
algorithm:
|
|
634
|
+
| AlgorithmIdentifier
|
|
635
|
+
| RsaOaepParams
|
|
636
|
+
| AesCtrParams
|
|
637
|
+
| AesCbcParams
|
|
638
|
+
| AesGcmParams,
|
|
639
|
+
key: CryptoKey,
|
|
640
|
+
data: BufferSource
|
|
641
|
+
): Promise<ArrayBuffer>;
|
|
642
|
+
/**
|
|
643
|
+
* Exports the given key into the specified format, if supported.
|
|
644
|
+
*
|
|
645
|
+
* If the `<CryptoKey>` is not extractable, the returned promise will reject.
|
|
646
|
+
*
|
|
647
|
+
* When `format` is either `'pkcs8'` or `'spki'` and the export is successful,
|
|
648
|
+
* the returned promise will be resolved with an `<ArrayBuffer>` containing the exported key data.
|
|
649
|
+
*
|
|
650
|
+
* When `format` is `'jwk'` and the export is successful, the returned promise will be resolved with a
|
|
651
|
+
* JavaScript object conforming to the {@link https://tools.ietf.org/html/rfc7517 JSON Web Key} specification.
|
|
652
|
+
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
653
|
+
* @returns `<Promise>` containing `<ArrayBuffer>`.
|
|
654
|
+
*/
|
|
655
|
+
exportKey(format: "jwk", key: CryptoKey): Promise<JsonWebKey>;
|
|
656
|
+
exportKey(
|
|
657
|
+
format: Exclude<KeyFormat, "jwk">,
|
|
658
|
+
key: CryptoKey
|
|
659
|
+
): Promise<ArrayBuffer>;
|
|
660
|
+
/**
|
|
661
|
+
* Using the method and parameters provided in `algorithm`,
|
|
662
|
+
* `subtle.generateKey()` attempts to generate new keying material.
|
|
663
|
+
* Depending the method used, the method may generate either a single `<CryptoKey>` or a `<CryptoKeyPair>`.
|
|
664
|
+
*
|
|
665
|
+
* The `<CryptoKeyPair>` (public and private key) generating algorithms supported include:
|
|
666
|
+
*
|
|
667
|
+
* - `'RSASSA-PKCS1-v1_5'`
|
|
668
|
+
* - `'RSA-PSS'`
|
|
669
|
+
* - `'RSA-OAEP'`
|
|
670
|
+
* - `'ECDSA'`
|
|
671
|
+
* - `'ECDH'`
|
|
672
|
+
* - `'Ed25519'`
|
|
673
|
+
* The `<CryptoKey>` (secret key) generating algorithms supported include:
|
|
674
|
+
*
|
|
675
|
+
* - `'HMAC'`
|
|
676
|
+
* - `'AES-CTR'`
|
|
677
|
+
* - `'AES-CBC'`
|
|
678
|
+
* - `'AES-GCM'`
|
|
679
|
+
* - `'AES-KW'`
|
|
680
|
+
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
681
|
+
*/
|
|
682
|
+
generateKey(
|
|
683
|
+
algorithm: RsaHashedKeyGenParams | EcKeyGenParams,
|
|
684
|
+
extractable: boolean,
|
|
685
|
+
keyUsages: readonly KeyUsage[]
|
|
686
|
+
): Promise<CryptoKeyPair>;
|
|
687
|
+
generateKey(
|
|
688
|
+
algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params,
|
|
689
|
+
extractable: boolean,
|
|
690
|
+
keyUsages: readonly KeyUsage[]
|
|
691
|
+
): Promise<CryptoKey>;
|
|
692
|
+
generateKey(
|
|
693
|
+
algorithm: AlgorithmIdentifier,
|
|
694
|
+
extractable: boolean,
|
|
695
|
+
keyUsages: KeyUsage[]
|
|
696
|
+
): Promise<CryptoKeyPair | CryptoKey>;
|
|
697
|
+
/**
|
|
698
|
+
* The `subtle.importKey()` method attempts to interpret the provided `keyData` as the given `format`
|
|
699
|
+
* to create a `<CryptoKey>` instance using the provided `algorithm`, `extractable`, and `keyUsages` arguments.
|
|
700
|
+
* If the import is successful, the returned promise will be resolved with the created `<CryptoKey>`.
|
|
701
|
+
*
|
|
702
|
+
* If importing a `'PBKDF2'` key, `extractable` must be `false`.
|
|
703
|
+
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
704
|
+
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
705
|
+
*/
|
|
706
|
+
importKey(
|
|
707
|
+
format: "jwk",
|
|
708
|
+
keyData: JsonWebKey,
|
|
709
|
+
algorithm:
|
|
710
|
+
| AlgorithmIdentifier
|
|
711
|
+
| RsaHashedImportParams
|
|
712
|
+
| EcKeyImportParams
|
|
713
|
+
| HmacImportParams
|
|
714
|
+
| AesKeyAlgorithm,
|
|
715
|
+
extractable: boolean,
|
|
716
|
+
keyUsages: readonly KeyUsage[]
|
|
717
|
+
): Promise<CryptoKey>;
|
|
718
|
+
importKey(
|
|
719
|
+
format: Exclude<KeyFormat, "jwk">,
|
|
720
|
+
keyData: BufferSource,
|
|
721
|
+
algorithm:
|
|
722
|
+
| AlgorithmIdentifier
|
|
723
|
+
| RsaHashedImportParams
|
|
724
|
+
| EcKeyImportParams
|
|
725
|
+
| HmacImportParams
|
|
726
|
+
| AesKeyAlgorithm,
|
|
727
|
+
extractable: boolean,
|
|
728
|
+
keyUsages: KeyUsage[]
|
|
729
|
+
): Promise<CryptoKey>;
|
|
730
|
+
/**
|
|
731
|
+
* Using the method and parameters given by `algorithm` and the keying material provided by `key`,
|
|
732
|
+
* `subtle.sign()` attempts to generate a cryptographic signature of `data`. If successful,
|
|
733
|
+
* the returned promise is resolved with an `<ArrayBuffer>` containing the generated signature.
|
|
734
|
+
*
|
|
735
|
+
* The algorithms currently supported include:
|
|
736
|
+
*
|
|
737
|
+
* - `'RSASSA-PKCS1-v1_5'`
|
|
738
|
+
* - `'RSA-PSS'`
|
|
739
|
+
* - `'ECDSA'`
|
|
740
|
+
* - `'Ed25519'`
|
|
741
|
+
* - `'HMAC'`
|
|
742
|
+
*/
|
|
743
|
+
sign(
|
|
744
|
+
algorithm:
|
|
745
|
+
| AlgorithmIdentifier
|
|
746
|
+
| RsaPssParams
|
|
747
|
+
| EcdsaParams
|
|
748
|
+
| Ed448Params,
|
|
749
|
+
key: CryptoKey,
|
|
750
|
+
data: BufferSource
|
|
751
|
+
): Promise<ArrayBuffer>;
|
|
752
|
+
/**
|
|
753
|
+
* In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
|
|
754
|
+
* The `subtle.unwrapKey()` method attempts to decrypt a wrapped key and create a `<CryptoKey>` instance.
|
|
755
|
+
* It is equivalent to calling `subtle.decrypt()` first on the encrypted key data (using the `wrappedKey`, `unwrapAlgo`, and `unwrappingKey` arguments as input)
|
|
756
|
+
* then passing the results in to the `subtle.importKey()` method using the `unwrappedKeyAlgo`, `extractable`, and `keyUsages` arguments as inputs.
|
|
757
|
+
* If successful, the returned promise is resolved with a `<CryptoKey>` object.
|
|
758
|
+
*
|
|
759
|
+
* The wrapping algorithms currently supported include:
|
|
760
|
+
*
|
|
761
|
+
* - `'RSA-OAEP'`
|
|
762
|
+
* - `'AES-CTR'`
|
|
763
|
+
* - `'AES-CBC'`
|
|
764
|
+
* - `'AES-GCM'`
|
|
765
|
+
* - `'AES-KW'`
|
|
766
|
+
*
|
|
767
|
+
* The unwrapped key algorithms supported include:
|
|
768
|
+
*
|
|
769
|
+
* - `'RSASSA-PKCS1-v1_5'`
|
|
770
|
+
* - `'RSA-PSS'`
|
|
771
|
+
* - `'RSA-OAEP'`
|
|
772
|
+
* - `'ECDSA'`
|
|
773
|
+
* - `'ECDH'`
|
|
774
|
+
* - `'HMAC'`
|
|
775
|
+
* - `'AES-CTR'`
|
|
776
|
+
* - `'AES-CBC'`
|
|
777
|
+
* - `'AES-GCM'`
|
|
778
|
+
* - `'AES-KW'`
|
|
779
|
+
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
780
|
+
* @param keyUsages See {@link https://nodejs.org/docs/latest/api/webcrypto.html#cryptokeyusages Key usages}.
|
|
781
|
+
*/
|
|
782
|
+
unwrapKey(
|
|
783
|
+
format: KeyFormat,
|
|
784
|
+
wrappedKey: BufferSource,
|
|
785
|
+
unwrappingKey: CryptoKey,
|
|
786
|
+
unwrapAlgorithm:
|
|
787
|
+
| AlgorithmIdentifier
|
|
788
|
+
| RsaOaepParams
|
|
789
|
+
| AesCtrParams
|
|
790
|
+
| AesCbcParams
|
|
791
|
+
| AesGcmParams,
|
|
792
|
+
unwrappedKeyAlgorithm:
|
|
793
|
+
| AlgorithmIdentifier
|
|
794
|
+
| RsaHashedImportParams
|
|
795
|
+
| EcKeyImportParams
|
|
796
|
+
| HmacImportParams
|
|
797
|
+
| AesKeyAlgorithm,
|
|
798
|
+
extractable: boolean,
|
|
799
|
+
keyUsages: KeyUsage[]
|
|
800
|
+
): Promise<CryptoKey>;
|
|
801
|
+
/**
|
|
802
|
+
* Using the method and parameters given in `algorithm` and the keying material provided by `key`,
|
|
803
|
+
* `subtle.verify()` attempts to verify that `signature` is a valid cryptographic signature of `data`.
|
|
804
|
+
* The returned promise is resolved with either `true` or `false`.
|
|
805
|
+
*
|
|
806
|
+
* The algorithms currently supported include:
|
|
807
|
+
*
|
|
808
|
+
* - `'RSASSA-PKCS1-v1_5'`
|
|
809
|
+
* - `'RSA-PSS'`
|
|
810
|
+
* - `'ECDSA'`
|
|
811
|
+
* - `'Ed25519'`
|
|
812
|
+
* - `'HMAC'`
|
|
813
|
+
*/
|
|
814
|
+
verify(
|
|
815
|
+
algorithm:
|
|
816
|
+
| AlgorithmIdentifier
|
|
817
|
+
| RsaPssParams
|
|
818
|
+
| EcdsaParams
|
|
819
|
+
| Ed448Params,
|
|
820
|
+
key: CryptoKey,
|
|
821
|
+
signature: BufferSource,
|
|
822
|
+
data: BufferSource
|
|
823
|
+
): Promise<boolean>;
|
|
824
|
+
/**
|
|
825
|
+
* In cryptography, "wrapping a key" refers to exporting and then encrypting the keying material.
|
|
826
|
+
* The `subtle.wrapKey()` method exports the keying material into the format identified by `format`,
|
|
827
|
+
* then encrypts it using the method and parameters specified by `wrapAlgo` and the keying material provided by `wrappingKey`.
|
|
828
|
+
* It is the equivalent to calling `subtle.exportKey()` using `format` and `key` as the arguments,
|
|
829
|
+
* then passing the result to the `subtle.encrypt()` method using `wrappingKey` and `wrapAlgo` as inputs.
|
|
830
|
+
* If successful, the returned promise will be resolved with an `<ArrayBuffer>` containing the encrypted key data.
|
|
831
|
+
*
|
|
832
|
+
* The wrapping algorithms currently supported include:
|
|
833
|
+
*
|
|
834
|
+
* - `'RSA-OAEP'`
|
|
835
|
+
* - `'AES-CTR'`
|
|
836
|
+
* - `'AES-CBC'`
|
|
837
|
+
* - `'AES-GCM'`
|
|
838
|
+
* - `'AES-KW'`
|
|
839
|
+
* @param format Must be one of `'raw'`, `'pkcs8'`, `'spki'`, or `'jwk'`.
|
|
840
|
+
*/
|
|
841
|
+
wrapKey(
|
|
842
|
+
format: KeyFormat,
|
|
843
|
+
key: CryptoKey,
|
|
844
|
+
wrappingKey: CryptoKey,
|
|
845
|
+
wrapAlgorithm:
|
|
846
|
+
| AlgorithmIdentifier
|
|
847
|
+
| RsaOaepParams
|
|
848
|
+
| AesCtrParams
|
|
849
|
+
| AesCbcParams
|
|
850
|
+
| AesGcmParams
|
|
851
|
+
): Promise<ArrayBuffer>;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}
|