-
Notifications
You must be signed in to change notification settings - Fork 84
/
index.d.ts
113 lines (87 loc) · 2.57 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
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
declare module 'fs-cnpm' {
export default class FSClient extends NFSClient {
constructor(options: {
dir: string;
});
}
}
declare module 'ssri' {
export interface Integrity {
algorithm: string;
digest: string;
options?: string[];
}
export interface HashLike {
digest: string;
algorithm: string;
options?: string[];
sha1: {
hexDigest(): string;
}[];
sha512: { toString(): string }[];
}
export interface HashOptions {
algorithms?: string[];
options?: string[];
}
export interface IntegrityOptions {
algorithms?: string[];
options?: string[];
single?: boolean;
}
export interface CreateRes {
update(v: string): { digest: () => { toString() }; };
}
export function fromHex(hexDigest: string, algorithm: string, options?: string[]): Integrity;
export function fromData(data: Buffer | string | Uint8Array, options?: HashOptions): HashLike;
export function fromStream(stream: NodeJS.ReadableStream, options?: HashOptions): Promise<HashLike>;
export function checkData(data: Buffer | string, sri: string | Integrity, options?: IntegrityOptions): boolean;
export function checkStream(stream: NodeJS.ReadableStream, sri: string | Integrity, options?: IntegrityOptions): Promise<boolean>;
export function parse(sri: string): Integrity;
export function create(): CreateRes;
export function stringify(integrity: Integrity, options?: { strict?: boolean }): string;
}
declare module 'oss-cnpm' {
import { Readable } from 'stream';
export interface AppendResult {
name: string;
url: string;
etag: string;
size: number;
}
export interface UploadOptions {
key: string;
content: Readable;
size: number;
}
export interface UploadResult {
name: string;
url: string;
etag: string;
size: number;
}
export interface DownloadOptions {
key: string;
}
export default class OSSClient {
constructor(options: {
cdnBaseUrl?: string;
accessKeyId: string;
accessKeySecret: string;
bucket: string;
internal?: boolean;
secure?: boolean;
timeout?: number;
cname?: boolean;
endpoint?: string;
defaultHeaders?: Record<string, string>;
});
append(options: UploadOptions): Promise<AppendResult>;
upload(options: UploadOptions): Promise<UploadResult>;
download(options: DownloadOptions): Promise<Readable>;
delete(key: string): Promise<void>;
exists(key: string): Promise<boolean>;
stat(key: string): Promise<{ size: number }>;
url(key: string): string;
}
}