-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathWebCrypto.d.ts
76 lines (51 loc) · 2.8 KB
/
WebCrypto.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Type definitions for WebCrypto
// Project: http://www.w3.org/TR/WebCryptoAPI/
// Definitions by: Lucas Dixon <https://github.com/iislucas/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module crypto {
interface AlgorithmIdentifier {
// http://www.w3.org/TR/WebCryptoAPI/#algorithms-index
name : string;
}
interface KeyAlgorithm {
name : string;
}
// http://www.w3.org/TR/WebCryptoAPI/#subtlecrypto-interface-datatypes
interface KeyFormat extends string {
// The recognized key format values are "raw", "pkcs8", "spki" and "jwk"
}
interface CryptoOperationData extends ArrayBuffer {
// typedef (ArrayBuffer or ArrayBufferView) CryptoOperationData;
}
// http://www.w3.org/TR/WebCryptoAPI/#dfn-Key
interface KeyType extends string {
// The recognized key type values are "public", "private" and "secret"
}
interface KeyUsage extends string {
// The recognized key usage values are "encrypt", "decrypt", "sign", "verify", "deriveKey", "deriveBits", "wrapKey" and "unwrapKey".
}
interface Key {
type : KeyType;
extractable : boolean;
algorithm : KeyAlgorithm;
usages : Array<KeyUsage>;
}
// http://www.w3.org/TR/WebCryptoAPI/#subtlecrypto-interface
interface SubtleCrypto {
encrypt( algorithm : AlgorithmIdentifier, key : Key, data : CryptoOperationData) : Promise<any>;
decrypt( algorithm : AlgorithmIdentifier, key : Key, data : CryptoOperationData) : Promise<any>;
sign( algorithm : AlgorithmIdentifier, key : Key, data : CryptoOperationData) : Promise<any>;
verify( algorithm : AlgorithmIdentifier, key : Key, signature : CryptoOperationData, data : CryptoOperationData) : Promise<any>;
digest( algorithm : AlgorithmIdentifier, data : CryptoOperationData) : Promise<any>;
generateKey( algorithm : AlgorithmIdentifier, extractable : boolean, keyUsages : Array<KeyUsage>) : Promise<any>;
deriveKey( algorithm : AlgorithmIdentifier, baseKey : Key, derivedKeyType : AlgorithmIdentifier, extractable : boolean, keyUsages : Array<KeyUsage>) : Promise<any>;
deriveBits( algorithm : AlgorithmIdentifier, baseKey : Key, length : number) : Promise<any>;
importKey( format : KeyFormat, keyData : CryptoOperationData, algorithm? : AlgorithmIdentifier, extractable : boolean, keyUsages : Array<KeyUsage>) : Promise<any>;
exportKey( format : KeyFormat, key : Key ) : Promise<any>;
}
// A cryptographically strong pseudo-random number generator seeded with
// truly random values. The buffer passed in is modified, and a reference to
// argument is returned for convenience.
function getRandomValues(array: ArrayBufferView) : ArrayBufferView
var subtle : SubtleCrypto;
}