-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.d.ts
More file actions
47 lines (36 loc) · 1.49 KB
/
types.d.ts
File metadata and controls
47 lines (36 loc) · 1.49 KB
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
import { ApiResponse } from '@gratio/api';
export type SerializablePrimitive = string | number | boolean | null;
export type SerializableArray = Serializable[];
export type SerializableObject = { [key: string]: Serializable };
export type Serializable = SerializablePrimitive | SerializableArray | SerializableObject;
export type CryptedData = { data: string; v: string };
export type EncryptParams = { message: Serializable; pass: string };
export type DecryptParams = { message: CryptedData; pass: string };
// Типы для шифрованных ответов
export type ApiResponseCrypted = ApiResponse<CryptedData>;
export interface ServerCrypt {
encryptMsg: (params: EncryptParams) => CryptedData;
decryptMsg: (params: DecryptParams) => string;
unpack: (base64Key: string) => Buffer;
pack: (bufferKey: Buffer) => string;
}
export interface FrontCrypt {
packToBase64: (bufferKey: ArrayBuffer) => string; // Уточнить тип
unpackBase64: (base64: string) => ArrayBuffer; // Uint8Array?
}
/* Разбираться! Не работает в старых версиях
// Объявляем экспорт модуля
declare const serverCrypt: ServerCrypt;
declare const frontCrypt: FrontCrypt;
export default {
serverCrypt,
frontCrypt,
};
// Чтобы использовать именованные методы
export { serverCrypt, frontCrypt };
*/
declare namespace Crypt {
export const serverCrypt: ServerCrypt;
export const frontCrypt: FrontCrypt;
}
export default Crypt;