@chahakshah/terabox-api 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts ADDED
@@ -0,0 +1,434 @@
1
+ // index.d.ts
2
+
3
+ declare module "@chahakshah/terabox-api" {
4
+ export interface FormUrlEncodedParams {
5
+ [key: string]: string;
6
+ }
7
+
8
+ export class FormUrlEncoded {
9
+ constructor(params?: FormUrlEncodedParams);
10
+ set(param: string, value: string): void;
11
+ append(param: string, value: string): void;
12
+ delete(param: string): void;
13
+ str(): string;
14
+ url(): URLSearchParams;
15
+ }
16
+
17
+ export function signDownload(s1: string, s2: string): string;
18
+ export function checkMd5val(md5: any): boolean;
19
+ export function checkMd5arr(arr: any): boolean;
20
+ export function decodeMd5(md5: string): string;
21
+ export function changeBase64Type(str: string, mode?: 1 | 2): string;
22
+ export function decryptAES(pp1: string, pp2: string): string;
23
+ export function encryptRSA(
24
+ message: string,
25
+ publicKeyPEM: string | Buffer,
26
+ mode?: 1 | 2
27
+ ): string;
28
+ export function prandGen(
29
+ seval: string,
30
+ encpwd: string,
31
+ email: string,
32
+ random: string,
33
+ browserid?: string,
34
+ client?: string
35
+ ): string;
36
+
37
+ export interface TeraBoxAppData {
38
+ csrf: string;
39
+ logid: string;
40
+ pcftoken: string;
41
+ bdstoken: string;
42
+ jsToken: string;
43
+ pubkey: string;
44
+ }
45
+
46
+ export interface TeraBoxAppParams {
47
+ whost: string;
48
+ uhost: string;
49
+ lang: string;
50
+ app: {
51
+ app_id: number;
52
+ web: number;
53
+ channel: string;
54
+ clienttype: number;
55
+ };
56
+ ver_android: string;
57
+ ua: string;
58
+ cookie: string;
59
+ auth: Record<string, unknown>;
60
+ account_id: number;
61
+ account_name: string;
62
+ is_vip: boolean;
63
+ vip_type: number;
64
+ space_used: number;
65
+ space_total: number;
66
+ space_available: number;
67
+ cursor: string;
68
+ }
69
+
70
+ export interface FileHashData {
71
+ crc32: number;
72
+ slice: string;
73
+ file: string;
74
+ etag: string;
75
+ chunks: string[];
76
+ }
77
+
78
+ export interface UploadData {
79
+ remote_dir: string;
80
+ file: string;
81
+ size: number;
82
+ upload_id?: string;
83
+ hash: FileHashData;
84
+ uploaded?: boolean[];
85
+ hash_check?: boolean;
86
+ }
87
+
88
+ export interface ProgressData {
89
+ all: number;
90
+ start: number;
91
+ parts: Record<number, number>;
92
+ maxTries?: number;
93
+ }
94
+
95
+ export interface PassportInfo {
96
+ code: number;
97
+ data: PassportInfoData;
98
+ logid: number;
99
+ msg: string;
100
+ }
101
+ export interface PassportInfoData {
102
+ display_name: string;
103
+ head_url: string;
104
+ region_domain_prefix: string;
105
+ url_domain_prefix: string;
106
+ }
107
+
108
+ export interface UserMembership {
109
+ data: UserMembershipData;
110
+ error_code: number;
111
+ error_msg: string;
112
+ request_id: string;
113
+ }
114
+ export interface UserMembershipData {
115
+ cur_country: CurCountry;
116
+ member_info: MemberInfo;
117
+ pay_center_version: number;
118
+ privilege_infos: any[];
119
+ reg_country: RegCountry;
120
+ reminder: Reminder;
121
+ }
122
+
123
+ export interface CurCountry {
124
+ name: string;
125
+ speed_show_ratio: number;
126
+ support_vip: number;
127
+ upload_speed_ratio: number;
128
+ }
129
+
130
+ export interface MemberInfo {
131
+ can_cancel_renew: number;
132
+ can_trial: number;
133
+ has_iap_record: boolean;
134
+ is_auto_renew: number;
135
+ is_vip: number;
136
+ is_vip_level: number;
137
+ platform: number;
138
+ price_currency: string;
139
+ raw_price: number;
140
+ renew_price: number;
141
+ renew_time: number;
142
+ show_grace_tips: number;
143
+ vip_end_time: number;
144
+ vip_end_time_without_grace: number;
145
+ vip_left_time: number;
146
+ }
147
+
148
+ export interface RegCountry {
149
+ name: string;
150
+ speed_show_ratio: number;
151
+ support_vip: number;
152
+ upload_speed_ratio: number;
153
+ }
154
+
155
+ export interface Reminder {
156
+ vip_expire_time: number;
157
+ }
158
+
159
+ export interface AccountQuota {
160
+ errmsg: string;
161
+ errno: number;
162
+ expire: boolean;
163
+ free: number;
164
+ newno: string;
165
+ request_id: number;
166
+ sbox_used: number;
167
+ server_time: number;
168
+ total: number;
169
+ used: number;
170
+ available: number;
171
+ }
172
+
173
+ export interface CoinsCount {
174
+ errno: number;
175
+ errmsg: string;
176
+ data: CoinsCountData;
177
+ logid: string;
178
+ }
179
+
180
+ export interface CoinsCountData {
181
+ can_used_cnt: number;
182
+ will_expire_cnt: number;
183
+ }
184
+
185
+ export interface PassportPreLogin {
186
+ code: number;
187
+ data: PassportPreLoginData;
188
+ logid: number;
189
+ msg: string;
190
+ }
191
+
192
+ export interface PassportPreLoginData {
193
+ random: number;
194
+ seval: string;
195
+ timestamp: number;
196
+ }
197
+
198
+ export interface RemoteDirectory {
199
+ errno: number;
200
+ guid_info: string;
201
+ list: RemoteDirectoryList[];
202
+ request_id: number;
203
+ guid: number;
204
+ }
205
+ export interface RemoteDirectoryList {
206
+ tkbind_id: number;
207
+ server_filename: string;
208
+ category: number;
209
+ unlist: number;
210
+ isdir: number;
211
+ dir_empty?: number;
212
+ play_forbid: number;
213
+ wpfile: number;
214
+ local_mtime: number;
215
+ share: number;
216
+ pl: number;
217
+ local_ctime: number;
218
+ empty?: number;
219
+ real_category: string;
220
+ extent_int2: number;
221
+ server_ctime: number;
222
+ extent_tinyint7: number;
223
+ extent_tinyint9: number;
224
+ size: number;
225
+ fs_id: number;
226
+ owner_type: number;
227
+ path: string;
228
+ owner_id: number;
229
+ from_type: number;
230
+ server_atime: number;
231
+ server_mtime: number;
232
+ oper_id: number;
233
+ thumbs?: RemoteDirectoryThumbs;
234
+ lodocpreview?: string;
235
+ docpreview?: string;
236
+ md5?: string;
237
+ }
238
+
239
+ export interface RemoteDirectoryThumbs {
240
+ url3: string;
241
+ url2: string;
242
+ url1: string;
243
+ }
244
+
245
+ export interface CheckLogin {
246
+ errno: number;
247
+ newno: string;
248
+ request_id: number;
249
+ show_msg: string;
250
+ uk: number;
251
+ }
252
+
253
+ export interface FileMeta {
254
+ errno: number;
255
+ info: FileMetaInfo[];
256
+ request_id: number;
257
+ }
258
+
259
+ export interface FileMetaInfo {
260
+ extent_tinyint4: number;
261
+ extent_tinyint1: number;
262
+ category: number;
263
+ fs_id: number;
264
+ ifhassubdir?: number;
265
+ videotag: number;
266
+ oper_id: number;
267
+ play_forbid: number;
268
+ wpfile: number;
269
+ local_mtime: number;
270
+ share: number;
271
+ extent_tinyint3: number;
272
+ errno: number;
273
+ local_ctime: number;
274
+ extent_tinyint5: number;
275
+ owner_type: number;
276
+ privacy: number;
277
+ real_category: string;
278
+ path_md5: number;
279
+ server_ctime: number;
280
+ extent_tinyint9: number;
281
+ upload_type: number;
282
+ size: number;
283
+ tkbind_id: number;
284
+ isdir: number;
285
+ extent_int3: number;
286
+ path: string;
287
+ owner_id: number;
288
+ from_type: number;
289
+ extent_tinyint2: number;
290
+ server_filename: string;
291
+ server_mtime: number;
292
+ dlink?: string;
293
+ thumbs?: FileMetaInfoThumbs;
294
+ docpreview?: string;
295
+ lodocpreview?: string;
296
+ md5?: string;
297
+ file_key?: string;
298
+ }
299
+
300
+ export interface FileMetaInfoThumbs {
301
+ icon: string;
302
+ url3: string; // Large
303
+ url2: string; // Medium
304
+ url1: string; // Small
305
+ }
306
+
307
+ export interface FileManager {
308
+ errno: number;
309
+ info: any[];
310
+ request_id: number;
311
+ taskid: number;
312
+ }
313
+
314
+ export interface PrecreateFile {
315
+ block_list: number[];
316
+ errmsg: string;
317
+ errno: number;
318
+ newno: string;
319
+ path: string;
320
+ request_id: number;
321
+ return_type: number;
322
+ server_time: number;
323
+ uploadid: string;
324
+ }
325
+
326
+ export interface CreateFile {
327
+ category: number;
328
+ ctime: number;
329
+ errmsg: string;
330
+ errno: number;
331
+ from_type: number;
332
+ fs_id: number;
333
+ isdir: number;
334
+ md5: string;
335
+ mtime: number;
336
+ name: string;
337
+ newno: string;
338
+ path: string;
339
+ request_id: number;
340
+ server_filename: string;
341
+ server_time: number;
342
+ size: number;
343
+ emd5: string;
344
+ etag: string;
345
+ }
346
+
347
+ class TeraBoxApp {
348
+ TERABOX_DOMAIN: string;
349
+ TERABOX_TIMEOUT: number;
350
+ data: TeraBoxAppData;
351
+ params: TeraBoxAppParams;
352
+
353
+ FormUrlEncoded: typeof FormUrlEncoded;
354
+ SignDownload: typeof signDownload;
355
+ CheckMd5Val: typeof checkMd5val;
356
+ CheckMd5Arr: typeof checkMd5arr;
357
+ DecodeMd5: typeof decodeMd5;
358
+ ChangeBase64Type: typeof changeBase64Type;
359
+ DecryptAES: typeof decryptAES;
360
+ EncryptRSA: typeof encryptRSA;
361
+ PRandGen: typeof prandGen;
362
+
363
+ constructor(authData: string, authType?: string);
364
+
365
+ updateAppData(customPath?: string, retries?: number): Promise<any>;
366
+ setVipDefaults(): void;
367
+ doReq(req_url: string, req_options?: any, retries?: number): Promise<any>;
368
+ getSysCfg(): Promise<any>;
369
+ checkLogin(): Promise<CheckLogin>;
370
+ passportPreLogin(email: string): Promise<PassportPreLogin>;
371
+ passportLogin(preLoginData: any, email: string, pass: string): Promise<any>;
372
+ regSendCode(email: string): Promise<any>;
373
+ regVerify(regToken: string, code: string | number): Promise<any>;
374
+ regFinish(regToken: string, pass: string): Promise<any>;
375
+ passportGetInfo(): Promise<PassportInfo>;
376
+ userMembership(): Promise<UserMembership>;
377
+ getCurrentUserInfo(): Promise<any>;
378
+ getUserInfo(user_id: number | string): Promise<any>;
379
+ getQuota(): Promise<AccountQuota>;
380
+ getCoinsCount(): Promise<any>;
381
+ getRemoteDir(remoteDir: string, page?: number): Promise<RemoteDirectory>;
382
+ getRecycleBin(page?: number): Promise<any>;
383
+ clearRecycleBin(): Promise<any>;
384
+ precreateFile(data: UploadData): Promise<PrecreateFile>;
385
+ rapidUpload(data: UploadData): Promise<any>;
386
+ remoteUpload(urls: string, remote_dir?: string): Promise<any>;
387
+ getUploadHost(): Promise<any>;
388
+ uploadChunk(
389
+ data: UploadData,
390
+ partseq: number,
391
+ blob: Blob | Buffer,
392
+ reqHandler?: Function,
393
+ externalAbort?: AbortSignal
394
+ ): Promise<any>;
395
+ createDir(remoteDir: string): Promise<any>;
396
+ createFile(data: UploadData): Promise<CreateFile>;
397
+ filemanager(operation: string, fmparams: any[]): Promise<FileManager>;
398
+ shareList(page?: number): Promise<any>;
399
+ shareSet(filelist: string[], pass?: string, period?: number): Promise<any>;
400
+ shareCancel(shareid_list?: number[]): Promise<any>;
401
+ shortUrlInfo(shortUrl: string): Promise<any>;
402
+ shortUrlList(
403
+ shortUrl: string,
404
+ remoteDir?: string,
405
+ page?: number
406
+ ): Promise<any>;
407
+ fileDiff(): Promise<any>;
408
+ genPanToken(): Promise<any>;
409
+ getHomeInfo(): Promise<any>;
410
+ download(fs_ids: number[]): Promise<any>;
411
+ getFileMeta(remote_file_list: string[]): Promise<FileMeta>;
412
+ getRecentUploads(page?: number): Promise<any>;
413
+ getPublicKey(): Promise<any>;
414
+ }
415
+
416
+ export default TeraBoxApp;
417
+ }
418
+ declare module "@chahakshah/terabox-api/helper" {
419
+ export function getChunkSize(fileSize: number, is_vip?: boolean): number;
420
+ export function hashFile(
421
+ filePath: string
422
+ ): Promise<import("@chahakshah/terabox-api").FileHashData>;
423
+ export function uploadChunks(
424
+ app: import("@chahakshah/terabox-api").default,
425
+ data: import("@chahakshah/terabox-api").UploadData,
426
+ filePath: string,
427
+ maxTasks?: number,
428
+ maxTries?: number
429
+ ): Promise<{
430
+ ok: boolean;
431
+ data: import("@chahakshah/terabox-api").UploadData;
432
+ }>;
433
+ export function unwrapErrorMessage(err: any): string | undefined;
434
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@chahakshah/terabox-api",
3
+ "name_ext": "TeraBox API",
4
+ "version": "2.5.0",
5
+ "main": "api.js",
6
+ "type": "module",
7
+ "scripts": {
8
+ "html": "python docs/apidoc.py",
9
+ "test": "echo \"Error: no test specified\" && exit 1"
10
+ },
11
+ "keywords": [
12
+ "terabox"
13
+ ],
14
+ "author": "Chahak Shah",
15
+ "license": "MIT",
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "description": "NodeJS tool for interacting with the TeraBox cloud service without the need to use the website or app ☁️",
20
+ "homepage": "https://github.com/seiya-npm/terabox-api#readme",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/seiya-npm/terabox-api.git"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/seiya-npm/terabox-api/issues"
27
+ },
28
+ "dependencies": {
29
+ "crc-32": "^1.2.2",
30
+ "filesize": "^11.0.2",
31
+ "tough-cookie": "^6.0.0",
32
+ "undici": "^7.12.0"
33
+ },
34
+ "devDependencies": {
35
+ "docdash": "^2.0.2",
36
+ "jsdoc": "^4.0.4"
37
+ }
38
+ }