/
types.ts
169 lines (149 loc) · 4.79 KB
/
types.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import {
VIRGIL_STREAM_SIGNING_STATE,
VIRGIL_STREAM_ENCRYPTING_STATE,
VIRGIL_STREAM_VERIFYING_STATE,
VIRGIL_STREAM_DECRYPTING_STATE,
} from './constants';
export type NodeBuffer = import('@virgilsecurity/e3kit-base').NodeBuffer;
export type Data = import('@virgilsecurity/e3kit-base').Data;
export type StringEncoding = import('@virgilsecurity/e3kit-base').StringEncoding;
export type ICard = import('@virgilsecurity/e3kit-base').ICard;
export type IPublicKey = import('@virgilsecurity/e3kit-base').IPublicKey;
export type EThreeBaseInitializeOptions = import('@virgilsecurity/e3kit-base').EThreeInitializeOptions;
export type EThreeBaseCtorOptions = import('@virgilsecurity/e3kit-base').EThreeCtorOptions;
export type FindUsersResult = import('@virgilsecurity/e3kit-base').FindUsersResult;
export type LookupResult = import('@virgilsecurity/e3kit-base').LookupResult;
export type KeyPairType = import('virgil-crypto').KeyPairType;
export type VirgilCrypto = import('virgil-crypto').VirgilCrypto;
export type VirgilPrivateKey = import('virgil-crypto').VirgilPrivateKey;
export interface FoundationLibraryOptions {
foundationWasmPath?: string;
}
export interface PythiaLibraryOptions {
pythiaWasmPath?: string;
}
export interface EThreeInitializeOptions
extends EThreeBaseInitializeOptions,
FoundationLibraryOptions,
PythiaLibraryOptions {
keyPairType?: KeyPairType;
}
export interface EThreeCtorOptions extends EThreeBaseCtorOptions {
keyPairType?: KeyPairType;
}
/**
* Callback invoked for each chunk being processed in encryptFile method.
*/
export type onEncryptProgressCallback = (snapshot: onEncryptProgressSnapshot) => void;
/**
* Callback invoked for each chunk being processed in decryptFile method.
*/
export type onDecryptProgressCallback = (snapshot: onDecryptProgressSnapshot) => void;
/**
* Callback invoked for each chunk being processed in decryptFile method.
*/
export type onProgressCallback = (snapshot: onProgressSnapshot) => void;
/**
* `eThree.encryptSharedFile` method resulting object.
*/
export type EncryptSharedFileResult = {
encryptedSharedFile: File | Blob;
fileKey: Data;
};
// eslint-disable-next-line @typescript-eslint/class-name-casing
export interface onProgressSnapshot {
/**
* Total size of the file being processed.
*/
fileSize: number;
/**
* Size of the file being encrypted in bytes.
*/
bytesProcessed: number;
}
/**
* An argument of the onEncryptProgressCallback.
*/
// eslint-disable-next-line @typescript-eslint/class-name-casing
export interface onEncryptProgressSnapshot extends onProgressSnapshot {
/**
* Current status of processing. Can be "Signing" then "Encrypting".
*/
state: VIRGIL_STREAM_SIGNING_STATE | VIRGIL_STREAM_ENCRYPTING_STATE;
}
// eslint-disable-next-line @typescript-eslint/class-name-casing
export interface onDecryptProgressSnapshot extends onProgressSnapshot {
/**
* Current status of processing. Can be "Decrypting" then "Verifying".
*/
state: VIRGIL_STREAM_DECRYPTING_STATE | VIRGIL_STREAM_VERIFYING_STATE;
}
interface FileOptions {
/**
* Size of chunk being processed at one time. Bigger chunks make function execute faster, but
* consume more memory in one time and can cause a performance hit. Default value is 64kb.
*/
chunkSize?: number;
/**
* Instance of `AbortSignal` which can be received from `AbortController`. Used to cancel encryptFile
* operation.
*/
signal?: AbortSignal;
}
/**
* Options for encryptedFile method.
*/
export interface EncryptFileOptions extends FileOptions {
/**
* `onEncryptProgressCallback` parameter.
*/
onProgress?: onEncryptProgressCallback;
}
/**
* Options for decryptedFile method.
*/
export interface DecryptFileOptions extends FileOptions {
/**
* `onDecryptProgressCallback` parameter.
*/
onProgress?: onDecryptProgressCallback;
encryptedOn?: Date;
}
/**
* Options for authEncryptFile method.
*/
export interface AuthEncryptFileOptions extends FileOptions {
/**
* `onEncryptProgressCallback` parameter.
*/
onProgress?: onProgressCallback;
}
/**
* Options for authDecryptFile method.
*/
export interface AuthDecryptFileOptions extends FileOptions {
/**
* `onDecryptProgressCallback` parameter.
*/
onProgress?: onProgressCallback;
encryptedOn?: Date;
}
/**
* Options for encryptSharedFile method.
*/
export interface EncryptSharedFileOptions extends FileOptions {
/**
* `onEncryptProgressCallback` parameter.
*/
onProgress?: onProgressCallback;
}
/**
* Options for decryptSharedFile method.
*/
export interface DecryptSharedFileOptions extends FileOptions {
/**
* `onDecryptProgressCallback` parameter.
*/
onProgress?: onProgressCallback;
encryptedOn?: Date;
}