-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.d.ts
85 lines (72 loc) · 3.41 KB
/
index.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
declare namespace RNHash {
function hashFile(uri: string, algorithm: string): Promise<string>;
/**
*
* @param uri uri pointing to File or directory
* @param algorithm algorithm to be used for hashing
* @param minFileSize minimum file size to be hashed in bytes
* @param maxFileSize maximum file size to be hashed in bytes
* @param extensionFilter extension of files to be hashed, pass "" to ignore this option
* @param batchSize event batch size, pass -1 to retrieve all results on .then instead of events
* @returns Promise -- if batchSize is set to -1, the promise.resolve contains all the hashes, otherwise, it resolves to null.
*/
function hashFilesForFolder(
uri: string, algorithm: string, minFileSize: number, maxFileSize: number, extensionFilter: string, batchSize: number, delay: number
): Promise<{ FilesCount: number, isFinalBatch: boolean, batchNumber: number, results: Record<string, string> }>;
function hashFilesForFolders(
uri: Array<string>, algorithm: string, minFileSize: number, maxFileSize: number, extensionFilter: string, batchSize: number, delay: number
): Promise<{ FilesCount: number, isFinalBatch: boolean, batchNumber: number, results: Record<string, string> }>;
function hashUrl(url: string, HTTPMethod: string, headers: Record<string, string>, algorithm: string): Promise<string>;
function hashString(message: string, algorithm: string): Promise<string>;
function generateHmac(message: string, key: string, algorithm: string): Promise<string>;
}
export namespace CONSTANTS {
export namespace HashAlgorithms {
export const md2: 'MD2';
export const md5: 'MD5';
export const sha1: 'SHA-1';
export const sha224: 'SHA-224';
export const sha256: 'SHA-256';
export const sha384: 'SHA-384';
export const sha512: 'SHA-512';
export const keccak: 'keccak';
}
export namespace HmacAlgorithms {
export const HmacMD5: 'HmacMD5';
export const HmacSHA1: 'HmacSHA1';
export const HmacSHA224: 'HmacSHA224';
export const HmacSHA256: 'HmacSHA256';
export const HmacSHA384: 'HmacSHA384';
export const HmacSHA512: 'HmacSHA512';
export const PBEwithHmacSHA: 'PBEwithHmacSHA';
export const PBEwithHmacSHA1: 'PBEwithHmacSHA1';
export const PBEwithHmacSHA224: 'PBEwithHmacSHA224';
export const PBEwithHmacSHA256: 'PBEwithHmacSHA256';
export const PBEwithHmacSHA384: 'PBEwithHmacSHA384';
export const PBEwithHmacSHA512: 'PBEwithHmacSHA512';
}
export namespace Events {
export const onBatchReccieved: string;
}
}
export default RNHash;
export function JSHash(message: string, algorithm: string): Promise<string>;
export function JSHmac(message: string, secret: string, algorithm: string): Promise<string>;
export function useHash(
hmacAlgo?: typeof CONSTANTS.HashAlgorithms[keyof typeof CONSTANTS.HashAlgorithms],
initialMessage?: string
): [
hashed: string,
setMessage: (message: string) => Promise<void>,
setAlgo: (algo: string) => Promise<void>
];
export function useHmac(
hmacAlgo?: typeof CONSTANTS.HmacAlgorithms[keyof typeof CONSTANTS.HmacAlgorithms],
initialMessage?: string,
initialSecret?: string
): [
hashed: string,
setMessage: (message: string) => Promise<void>,
setAlgo: (algo: string) => Promise<void>,
setSecret: (secret: string) => Promise<void>
];