Constructor
new TeraBoxApp(authData, authTypeopt)
Properties:
Name | Type | Description | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FormUrlEncoded |
FormUrlEncoded | Form URL encoding utility | |||||||||||||||||||||
SignDownload |
signDownload | Download signature generator | |||||||||||||||||||||
CheckMd5Val |
checkMd5val | MD5 hash validator (single) | |||||||||||||||||||||
CheckMd5Arr |
checkMd5arr | MD5 hash validator (array) | |||||||||||||||||||||
DecodeMd5 |
decodeMd5 | Custom MD5 transformation | |||||||||||||||||||||
ChangeBase64Type |
changeBase64Type | Base64 format converter | |||||||||||||||||||||
DecryptAES |
decryptAES | AES decryption utility | |||||||||||||||||||||
EncryptRSA |
encryptRSA | RSA encryption utility | |||||||||||||||||||||
PRandGen |
prandGen | Pseudo-random hash generator | |||||||||||||||||||||
TERABOX_DOMAIN |
string | Default TeraBox domain | |||||||||||||||||||||
TERABOX_TIMEOUT |
number | Default API timeout (10 seconds) | |||||||||||||||||||||
data |
Object | Application data including tokens and keys
Properties
|
|||||||||||||||||||||
params |
TeraBoxAppParams | Application parameters and configuration |
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
authData |
string | Authentication data (NDUS token) | ||
authType |
string |
<optional> |
'ndus'
|
Authentication type (currently only 'ndus' supported) |
Throws:
-
Throws error if authType is not supported
- Type
- Error
Methods
(async) updateAppData(customPathopt, retriesopt) → {Promise.<Object>}
- Description:
- Updates application data including tokens and user information
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
customPath |
string |
<optional> |
Custom path to use for the update request | |
retries |
number |
<optional> |
4
|
Number of retry attempts |
Throws:
-
Throws error if request fails or parsing fails
- Type
- Error
Returns:
The updated template data
- Type
- Promise.<Object>
setVipDefaults() → {void}
Returns:
- Type
- void
(async) doReq(req_url, req_optionsopt, retriesopt) → {Promise.<Object>}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
req_url |
string | The request URL (relative to whost) | ||
req_options |
Object |
<optional> |
{}
|
Request options (headers, body, etc.) |
retries |
number |
<optional> |
4
|
Number of retry attempts |
Throws:
-
Throws error if all retries fail
- Type
- Error
Returns:
The JSON-parsed response data
- Type
- Promise.<Object>
(async) getSysCfg() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The system configuration JSON data
- Type
- Promise.<Object>
(async) checkLogin() → {Promise.<CheckLoginResponse>}
Throws:
-
Throws error if HTTP status is not 200 or request fails.
- Type
- Error
Returns:
The login status JSON data.
- Type
- Promise.<CheckLoginResponse>
(async) passportPreLogin(email) → {Promise.<Object>}
Parameters:
Name | Type | Description |
---|---|---|
email |
string | The user's email address |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The pre-login data JSON (includes seval, random, timestamp)
- Type
- Promise.<Object>
(async) passportLogin(preLoginData, email, pass) → {Promise.<Object>}
- Description:
- Completes the passport login process using preLoginData and password
- Source:
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
preLoginData |
Object | Data returned from passportPreLogin
Properties
|
||||||||||||
email |
string | The user's email address | ||||||||||||
pass |
string | The user's plaintext password |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The login response JSON (includes ndus token on success)
- Type
- Promise.<Object>
(async) regSendCode(email) → {Promise.<Object>}
Parameters:
Name | Type | Description |
---|---|---|
email |
string | The email address to send the code to |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The send code response JSON (includes code and message)
- Type
- Promise.<Object>
(async) regVerify(regToken, code) → {Promise.<Object>}
Parameters:
Name | Type | Description |
---|---|---|
regToken |
string | Registration token from send code response |
code |
string | number | The verification code sent to email |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The verification response JSON
- Type
- Promise.<Object>
(async) regFinish(regToken, pass) → {Promise.<Object>}
Parameters:
Name | Type | Description |
---|---|---|
regToken |
string | Registration token from verification step |
pass |
string | The new password to set, length is 6-15 and contains at least 1 Latin letter |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The finish registration response JSON (includes ndus token on success)
- Type
- Promise.<Object>
(async) passportGetInfo() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The passport user info JSON (includes display_name)
- Type
- Promise.<Object>
(async) userMembership() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The membership JSON (includes VIP status)
- Type
- Promise.<Object>
(async) getCurrentUserInfo() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The user info JSON (includes records array)
- Type
- Promise.<Object>
(async) getUserInfo(user_id) → {Promise.<Object>}
Parameters:
Name | Type | Description |
---|---|---|
user_id |
number | string | The user ID to look up |
Throws:
-
Throws error if user_id is invalid, HTTP status is not 200, or request fails
- Type
- Error
Returns:
The user info JSON (includes data)
- Type
- Promise.<Object>
(async) getQuota() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The quota JSON (includes total, used, available)
- Type
- Promise.<Object>
(async) getCoinsCount() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The coins count JSON (includes records of coin usage)
- Type
- Promise.<Object>
(async) getRemoteDir(remoteDir, pageopt) → {Promise.<Object>}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
remoteDir |
string | Remote directory path to list | ||
page |
number |
<optional> |
1
|
Page number for pagination |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The directory listing JSON (includes entries array)
- Type
- Promise.<Object>
(async) getCategoryList(categoryIdopt, remoteDir, pageopt) → {Promise.<Object>}
- Description:
- Retrieves the contents of a remote directory with specific file category
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
categoryId |
number |
<optional> |
1
|
selected category:
1: video 2: audio 3: pictures 4: documents 5: apps 6: other 7: torrent |
remoteDir |
string |
/
|
Remote directory path to list | |
page |
number |
<optional> |
1
|
Page number for pagination |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The directory listing JSON (includes entries array)
- Type
- Promise.<Object>
(async) getRecycleBin() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The recycle bin listing JSON (includes entries array)
- Type
- Promise.<Object>
(async) clearRecycleBin() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The clear recycle bin response JSON
- Type
- Promise.<Object>
(async) precreateFile(data) → {Promise.<Object>}
- Description:
- Initiates a precreate request for a file (reserve upload ID and pre-upload checks)
- Source:
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | File data including remote_dir, file, size, upload_id (optional), and hash info
Properties
|
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The precreate response JSON (includes upload_id, etc.)
- Type
- Promise.<Object>
(async) rapidUpload(data) → {Promise.<Object>}
- Description:
- Attempts a rapid upload using existing file hashes (skip actual upload if file already on server)
- Source:
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | File data including remote_dir, file, size, and hash info
Properties
|
Throws:
-
Throws error if file size < 256KB, invalid hashes, HTTP status is not 200, or request fails
- Type
- Error
Returns:
The rapid upload response JSON (indicates success or fallback)
- Type
- Promise.<Object>
(async) remoteUpload(urls, remote_dir) → {Promise.<Object>}
Parameters:
Name | Type | Default | Description |
---|---|---|---|
urls |
string | Source urls (coma-separated) | |
remote_dir |
string |
/Remote Upload
|
Remote directory path |
Throws:
-
Throws error if HTTP status is not 200, or request fails
- Type
- Error
Returns:
The remote upload response JSON (indicates success or fallback)
- Type
- Promise.<Object>
(async) getUploadHost() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The upload host response JSON (includes host field)
- Type
- Promise.<Object>
(async) uploadChunk(data, partseq, blob, reqHandleropt, externalAbortopt) → {Promise.<Object>}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
data |
Object | File data including remote_dir, file, upload_id | |
partseq |
number | The sequence number of this chunk (0-based) | |
blob |
Blob | Buffer | The binary data of the chunk | |
reqHandler |
function |
<optional> |
Optional request progress handler |
externalAbort |
AbortSignal |
<optional> |
Optional external abort signal |
Throws:
-
Throws error if HTTP status is not 200, chunk upload fails, or request times out
- Type
- Error
Returns:
The upload chunk response JSON (includes MD5 for chunk)
- Type
- Promise.<Object>
(async) createDir(remoteDir) → {Promise.<Object>}
Parameters:
Name | Type | Description |
---|---|---|
remoteDir |
string | The path of the directory to create |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The create directory response JSON
- Type
- Promise.<Object>
(async) createFile(data) → {Promise.<Object>}
- Description:
- Creates a new file entry on the server after uploading chunks
- Source:
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | File data including remote_dir, file, size, hash, upload_id, and chunks
Properties
|
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The create file response JSON (includes MD5 and ETag)
- Type
- Promise.<Object>
(async) filemanager(operation, fmparams) → {Promise.<Object>}
- Description:
- Performs file management operations (delete, copy, move, rename)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
operation |
string | Operation type: 'delete', 'copy', 'move', 'rename' |
fmparams |
Array | Parameters for the operation (array of paths or objects) |
Throws:
-
Throws error if fmparams is not an array, HTTP status is not 200, or request fails
- Type
- Error
Returns:
The file manager response JSON
- Type
- Promise.<Object>
(async) shareList() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The share list JSON (includes share entries)
- Type
- Promise.<Object>
(async) shareSet(filelist, passopt, periodopt) → {Promise.<Object>}
- Description:
- Sets sharing parameters (e.g., password, expiration) for specified files
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
filelist |
Array.<string> | Array of file paths to share | ||
pass |
string |
<optional> |
''
|
Optional 4-character alphanumeric password |
period |
number |
<optional> |
0
|
Sharing period in days (0 for no expiration) |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The share set response JSON (includes share IDs)
- Type
- Promise.<Object>
(async) shareCancel(shareid_listopt) → {Promise.<Object>}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
shareid_list |
Array.<number> |
<optional> |
[]
|
Array of share IDs to cancel |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The share cancel response JSON
- Type
- Promise.<Object>
(async) shortUrlInfo(shortUrl) → {Promise.<Object>}
Parameters:
Name | Type | Description |
---|---|---|
shortUrl |
string | The short url: after "surl=" |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The short URL info JSON (includes file list, permissions)
- Type
- Promise.<Object>
(async) shortUrlList(shortUrl, remoteDiropt, pageopt) → {Promise.<Object>}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
shortUrl |
string | The short url: after "surl=" | ||
remoteDir |
string |
<optional> |
''
|
Remote directory under share (empty for root) |
page |
number |
<optional> |
1
|
Page number for pagination |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The short URL file list JSON (includes entries array)
- Type
- Promise.<Object>
(async) fileDiff() → {Promise.<Object>}
- Description:
- Retrieves file difference (delta) information for synchronization
- Source:
Throws:
-
Throws error if HTTP status is not 200, request fails, or on recursive errors
- Type
- Error
Returns:
The file diff JSON (includes entries, request_id, has_more flag)
- Type
- Promise.<Object>
(async) genPanToken() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The PAN token response JSON (includes pan token and expire)
- Type
- Promise.<Object>
(async) getHomeInfo() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The home info JSON (includes sign1, sign3, data.signb)
- Type
- Promise.<Object>
(async) download(fs_ids, signb) → {Promise.<Object>}
Parameters:
Name | Type | Description |
---|---|---|
fs_ids |
Array.<number> | Array of file system IDs to download |
signb |
string | Base64-encoded signature from getHomeInfo |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The download response JSON (includes dlink URLs)
- Type
- Promise.<Object>
(async) getStream(remotePath, type) → {Promise.<Object>}
Parameters:
Name | Type | Default | Description |
---|---|---|---|
remotePath |
string |
/video.mp4
|
Remote video file |
type |
string |
M3U8_AUTO_480
|
Streaming type:
M3U8_FLV_264_480 M3U8_AUTO_240 M3U8_AUTO_360 M3U8_AUTO_480 M3U8_AUTO_720 M3U8_AUTO_1080 M3U8_SUBTITLE_SRT |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
m3u8 playlist, or JSON with error
- Type
- Promise.<Object>
(async) getFileMeta(remote_file_list) → {Promise.<Object>}
Parameters:
Name | Type | Description |
---|---|---|
remote_file_list |
Array.<Object> | Array of file descriptor objects { fs_id, path, etc. } |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The file metadata JSON (includes size, md5, etc.)
- Type
- Promise.<Object>
(async) getRecentUploads(pageopt) → {Promise.<Object>}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
page |
number |
<optional> |
1
|
Page number for pagination |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The recent uploads JSON (includes records array)
- Type
- Promise.<Object>
(async) getPublicKey() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The public key response JSON (includes pp1 and pp2)
- Type
- Promise.<Object>