1 | declare namespace objectHash {
|
2 | type NotUndefined = object | string | number | boolean | null | NotUndefined[];
|
3 |
|
4 | |
5 |
|
6 |
|
7 | function sha1(object: NotUndefined): string;
|
8 | |
9 |
|
10 |
|
11 | function keys(object: NotUndefined): string;
|
12 | |
13 |
|
14 |
|
15 | function MD5(object: NotUndefined): string;
|
16 | |
17 |
|
18 |
|
19 | function keysMD5(object: NotUndefined): string;
|
20 | |
21 |
|
22 |
|
23 | function writeToStream(value: any, stream: Stream): void;
|
24 | function writeToStream(value: any, options: Options, stream: Stream): void;
|
25 |
|
26 | type BufferEncoding =
|
27 | | "ascii"
|
28 | | "base64"
|
29 | | "binary"
|
30 | | "hex"
|
31 | | "latin1"
|
32 | | "ucs-2"
|
33 | | "ucs2"
|
34 | | "utf-8"
|
35 | | "utf16le"
|
36 | | "utf8";
|
37 |
|
38 | interface Stream {
|
39 | update?(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
40 | write?(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
41 | }
|
42 |
|
43 | type HashName =
|
44 | | "md4"
|
45 | | "md4WithRSAEncryption"
|
46 | | "md5"
|
47 | | "md5WithRSAEncryption"
|
48 | | "ripemd"
|
49 | | "ripemd160"
|
50 | | "ripemd160WithRSA"
|
51 | | "rmd160"
|
52 | | "rsa-md4"
|
53 | | "rsa-md5"
|
54 | | "rsa-ripemd160"
|
55 | | "rsa-sha1"
|
56 | | "rsa-sha1-2"
|
57 | | "rsa-sha224"
|
58 | | "rsa-sha256"
|
59 | | "rsa-sha3-224"
|
60 | | "rsa-sha3-256"
|
61 | | "rsa-sha3-384"
|
62 | | "rsa-sha3-512"
|
63 | | "rsa-sha384"
|
64 | | "rsa-sha512"
|
65 | | "sha1"
|
66 | | "sha1WithRSAEncryption"
|
67 | | "sha224"
|
68 | | "sha224WithRSAEncryption"
|
69 | | "sha256"
|
70 | | "sha256WithRSAEncryption"
|
71 | | "sha3-224"
|
72 | | "sha3-256"
|
73 | | "sha3-384"
|
74 | | "sha3-512"
|
75 | | "sha384"
|
76 | | "sha384WithRSAEncryption"
|
77 | | "sha512"
|
78 | | "sha512WithRSAEncryption";
|
79 |
|
80 | interface BaseOptions {
|
81 | /**
|
82 | * @default 'sha1'
|
83 | */
|
84 | algorithm?: HashName | "passthrough" | undefined;
|
85 |
|
86 | excludeKeys?: ((key: string) => boolean) | undefined;
|
87 | /**
|
88 | * @default false
|
89 | */
|
90 | excludeValues?: boolean | undefined;
|
91 | /**
|
92 | * @default false
|
93 | */
|
94 | ignoreUnknown?: boolean | undefined;
|
95 |
|
96 | replacer?: ((value: any) => any) | undefined;
|
97 | /**
|
98 | * @default true
|
99 | */
|
100 | respectFunctionNames?: boolean | undefined;
|
101 | /**
|
102 | * @default true
|
103 | */
|
104 | respectFunctionProperties?: boolean | undefined;
|
105 | /**
|
106 | * @default true
|
107 | */
|
108 | respectType?: boolean | undefined;
|
109 | /**
|
110 | * @default false
|
111 | */
|
112 | unorderedArrays?: boolean | undefined;
|
113 | /**
|
114 | * @default true
|
115 | */
|
116 | unorderedObjects?: boolean | undefined;
|
117 | /**
|
118 | * @default true
|
119 | */
|
120 | unorderedSets?: boolean | undefined;
|
121 | }
|
122 |
|
123 | interface NormalOption extends BaseOptions {
|
124 | /**
|
125 | * @default 'hex'
|
126 | */
|
127 | encoding?: "hex" | "binary" | "base64" | undefined;
|
128 | }
|
129 |
|
130 | interface WithBufferOption extends BaseOptions {
|
131 | encoding: "buffer";
|
132 | }
|
133 |
|
134 | type Options = NormalOption | WithBufferOption;
|
135 | }
|
136 |
|
137 | /**
|
138 | * @see https://github.com/puleos/object-hash#hashvalue-options
|
139 | */
|
140 | declare function objectHash(object: objectHash.NotUndefined, options?: objectHash.NormalOption): string;
|
141 | declare function objectHash(object: objectHash.NotUndefined, options?: objectHash.WithBufferOption): Buffer;
|
142 |
|
143 | export = objectHash;
|
144 |
|
\ | No newline at end of file |