-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathglobals.d.ts
135 lines (130 loc) · 3.27 KB
/
globals.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* Augment global objects
*/
interface Window {
Promise: PromiseConstructor;
msCrypto: Crypto;
}
/*
* Declare types for modules without build in types
*/
declare module "utf-8" {
export function setBytesFromString(val: string): number[];
export function getStringFromBytes(bytes: Uint8Array): string;
}
declare module "worker-loader?*" {
const content: any;
export = content;
}
declare const _WORKER_PATH_LOCATION_: string;
/*
* Common types and object shapes
*/
type Base64String = string;
type PrivateKey<T> = T;
type SigningPublicKey<T> = T;
type AugmentationFactor = Uint8Array;
type JWTCallbackToPromise = () => Promise<string>;
type PasscodeCallbackToPromise = (userExists: boolean) => Promise<string>;
type DerivedKey = CryptoKey | Uint8Array;
interface PublicKey<T> {
x: T;
y: T;
}
interface DerivedKeyResults {
key: DerivedKey;
salt: Uint8Array;
}
interface MessageSignature {
userContextHeader: string;
requestHeaderSignature: string;
authHeaderSignature: string;
}
interface KeyPair {
publicKey: PublicKey<Uint8Array>;
privateKey: PrivateKey<Uint8Array>;
}
interface SigningKeyPair {
publicKey: SigningPublicKey<Uint8Array>;
privateKey: PrivateKey<Uint8Array>;
}
interface KeyPairSet {
userKeys: KeyPair;
deviceKeys: KeyPair;
signingKeys: SigningKeyPair;
}
interface EncryptedDocument {
iv: Uint8Array;
content: Uint8Array;
}
interface PREEncryptedMessage {
encryptedMessage: Base64String;
ephemeralPublicKey: PublicKey<Base64String>;
authHash: Base64String;
publicSigningKey: Base64String;
signature: Base64String;
}
interface TransformBlock {
encryptedTempKey: Base64String;
publicKey: PublicKey<Base64String>;
randomTransformEncryptedTempKey: Base64String;
randomTransformPublicKey: PublicKey<Base64String>;
}
interface TransformedEncryptedMessage extends PREEncryptedMessage {
transformBlocks: TransformBlock[];
}
interface EncryptedLocalKeys {
encryptedDeviceKey: Uint8Array;
encryptedSigningKey: Uint8Array;
symmetricKey: Uint8Array;
iv: Uint8Array;
}
interface WorkerEvent<T> {
replyID: number;
data: T;
}
interface EncryptedAccessKey {
encryptedPlaintext: PREEncryptedMessage;
publicKey: PublicKey<string>;
id: string;
}
interface DocumentHeader {
_did_: string;
_sid_: number;
}
/*
* API response types
*/
interface ApiUserResponse {
id: string;
segmentId: number;
status: number;
userMasterPublicKey: PublicKey<Base64String>;
userPrivateKey: PrivateKey<Base64String>;
currentKeyId: number;
needsRotation: boolean;
groupsNeedingRotation: string[];
}
interface UserOrGroupPublicKey {
id: string;
masterPublicKey: PublicKey<Base64String>;
}
interface GroupApiBasicResponse {
id: string;
name: string | null;
status: number;
permissions: string[];
created: string;
updated: string;
}
interface GroupApiFullResponse extends GroupApiBasicResponse {
groupMasterPublicKey: PublicKey<string>;
encryptedPrivateKey?: TransformedEncryptedMessage;
}
interface GroupApiFullDetailResponse extends GroupApiFullResponse {
currentKeyId: number;
adminIds: string[];
memberIds: string[];
encryptedPrivateKey: TransformedEncryptedMessage;
needsRotation?: boolean;
}