-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.d.ts
69 lines (53 loc) · 1.69 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
import { Transform, TransformOptions } from 'bare-stream'
import Buffer, { BufferEncoding } from 'bare-buffer'
type Algorithm = 'MD5' | 'SHA1' | 'SHA256' | 'SHA512' | 'BLAKE2B256'
export const constants: { hash: Record<Algorithm, number> }
declare class CryptoError extends Error {
static UNSUPPORTED_DIGEST_METHOD(msg: string): CryptoError
}
export class Hash extends Transform {
constructor(
algorithm: Algorithm | Lowercase<Algorithm> | number,
opts?: TransformOptions<Hash>
)
update(data: string, encoding?: BufferEncoding): this
update(data: Buffer): this
digest(encoding: BufferEncoding): string
digest(): Buffer
}
export function createHash(
algorithm: Algorithm | Lowercase<Algorithm> | number,
opts?: TransformOptions<Hash>
): Hash
export function randomBytes(size: number): Buffer
export function randomBytes(
size: number,
callback: (err: Error | null, buffer: Buffer) => void
): void
export function randomFill<B extends ArrayBuffer | ArrayBufferView>(
buffer: B,
offset?: number,
size?: number
): B
export function randomFill<B extends ArrayBuffer | ArrayBufferView>(
buffer: B,
callback: (err: Error | null, buffer: B) => void
): void
export function randomFill<B extends ArrayBuffer | ArrayBufferView>(
buffer: B,
offset: number,
callback: (err: Error | null, buffer: B) => void
): void
export function randomFill<B extends ArrayBuffer | ArrayBufferView>(
buffer: B,
offset: number,
size: number,
callback: (err: Error | null, buffer: B) => void
): void
export function randomFillSync<B extends ArrayBuffer | ArrayBufferView>(
buffer: B,
offset?: number,
size?: number
): B
export { CryptoError as errors }
export * as webcrypto from './web'