vk-io
Version:
Modern VK API SDK for Node.js
1,775 lines (1,759 loc) • 257 kB
JavaScript
'use strict';
var createDebug = require('debug');
var abortController = require('abort-controller');
var inspectable = require('inspectable');
var https = require('https');
var formdataNode = require('formdata-node');
var formDataEncoder = require('form-data-encoder');
var fs = require('fs');
var stream = require('stream');
var middlewareIo = require('middleware-io');
var http = require('http');
var util = require('util');
/**
* General error class
*/
class VKError extends Error {
/**
* Constructor
*/
constructor({ code, message, cause }) {
super(message, {
cause,
});
this.code = code;
this.name = this.constructor.name;
Error.captureStackTrace(this, this.constructor);
}
/**
* Returns custom tag
*/
get [Symbol.toStringTag]() {
return this.constructor.name;
}
/**
* Returns property for json
*/
toJSON() {
const json = {};
for (const key of Object.getOwnPropertyNames(this)) {
json[key] = this[key];
}
return json;
}
}
/* eslint-disable */
exports.APIErrorCode = void 0;
(function (APIErrorCode) {
/**
* Unknown error occurred
*
* Code: `1`
*/
APIErrorCode[APIErrorCode["UNKNOWN"] = 1] = "UNKNOWN";
/**
* Application is disabled. Enable your application or use test mode
*
* Code: `2`
*/
APIErrorCode[APIErrorCode["DISABLED"] = 2] = "DISABLED";
/**
* Unknown method passed
*
* Code: `3`
*/
APIErrorCode[APIErrorCode["METHOD"] = 3] = "METHOD";
/**
* Incorrect signature
*
* Code: `4`
*/
APIErrorCode[APIErrorCode["SIGNATURE"] = 4] = "SIGNATURE";
/**
* User authorization failed
*
* Code: `5`
*/
APIErrorCode[APIErrorCode["AUTH"] = 5] = "AUTH";
/**
* Too many requests per second
*
* Code: `6`
*/
APIErrorCode[APIErrorCode["TOO_MANY"] = 6] = "TOO_MANY";
/**
* Permission to perform this action is denied
*
* Code: `7`
*/
APIErrorCode[APIErrorCode["PERMISSION"] = 7] = "PERMISSION";
/**
* Invalid request
*
* Code: `8`
*/
APIErrorCode[APIErrorCode["REQUEST"] = 8] = "REQUEST";
/**
* Flood control
*
* Code: `9`
*/
APIErrorCode[APIErrorCode["FLOOD"] = 9] = "FLOOD";
/**
* Internal server error
*
* Code: `10`
*/
APIErrorCode[APIErrorCode["SERVER"] = 10] = "SERVER";
/**
* In test mode application should be disabled or user should be authorized
*
* Code: `11`
*/
APIErrorCode[APIErrorCode["ENABLED_IN_TEST"] = 11] = "ENABLED_IN_TEST";
/**
* Unable to compile code
*
* Code: `12`
*/
APIErrorCode[APIErrorCode["COMPILE"] = 12] = "COMPILE";
/**
* Runtime error occurred during code invocation
*
* Code: `13`
*/
APIErrorCode[APIErrorCode["RUNTIME"] = 13] = "RUNTIME";
/**
* Captcha needed
*
* Code: `14`
*/
APIErrorCode[APIErrorCode["CAPTCHA"] = 14] = "CAPTCHA";
/**
* Access denied
*
* Code: `15`
*/
APIErrorCode[APIErrorCode["ACCESS"] = 15] = "ACCESS";
/**
* HTTP authorization failed
*
* Code: `16`
*/
APIErrorCode[APIErrorCode["AUTH_HTTPS"] = 16] = "AUTH_HTTPS";
/**
* Validation required
*
* Code: `17`
*/
APIErrorCode[APIErrorCode["AUTH_VALIDATION"] = 17] = "AUTH_VALIDATION";
/**
* User was deleted or banned
*
* Code: `18`
*/
APIErrorCode[APIErrorCode["USER_DELETED"] = 18] = "USER_DELETED";
/**
* Content blocked
*
* Code: `19`
*/
APIErrorCode[APIErrorCode["BLOCKED"] = 19] = "BLOCKED";
/**
* Permission to perform this action is denied for non-standalone applications
*
* Code: `20`
*/
APIErrorCode[APIErrorCode["METHOD_PERMISSION"] = 20] = "METHOD_PERMISSION";
/**
* Permission to perform this action is allowed only for standalone and OpenAPI applications
*
* Code: `21`
*/
APIErrorCode[APIErrorCode["METHOD_ADS"] = 21] = "METHOD_ADS";
/**
* Upload error
*
* Code: `22`
*/
APIErrorCode[APIErrorCode["UPLOAD"] = 22] = "UPLOAD";
/**
* This method was disabled
*
* Code: `23`
*/
APIErrorCode[APIErrorCode["METHOD_DISABLED"] = 23] = "METHOD_DISABLED";
/**
* Confirmation required
*
* Code: `24`
*/
APIErrorCode[APIErrorCode["NEED_CONFIRMATION"] = 24] = "NEED_CONFIRMATION";
/**
* Token confirmation required
*
* Code: `25`
*/
APIErrorCode[APIErrorCode["NEED_TOKEN_CONFIRMATION"] = 25] = "NEED_TOKEN_CONFIRMATION";
/**
* Group authorization failed
*
* Code: `27`
*/
APIErrorCode[APIErrorCode["GROUP_AUTH"] = 27] = "GROUP_AUTH";
/**
* Application authorization failed
*
* Code: `28`
*/
APIErrorCode[APIErrorCode["APP_AUTH"] = 28] = "APP_AUTH";
/**
* Rate limit reached
*
* Code: `29`
*/
APIErrorCode[APIErrorCode["RATE_LIMIT"] = 29] = "RATE_LIMIT";
/**
* This profile is private
*
* Code: `30`
*/
APIErrorCode[APIErrorCode["PRIVATE_PROFILE"] = 30] = "PRIVATE_PROFILE";
/**
* Need wait
*
* Code: `32`
*/
APIErrorCode[APIErrorCode["WAIT"] = 32] = "WAIT";
/**
* Not implemented yet
*
* Code: `33`
*/
APIErrorCode[APIErrorCode["NOT_IMPLEMENTED_YET"] = 33] = "NOT_IMPLEMENTED_YET";
/**
* Client version deprecated
*
* Code: `34`
*/
APIErrorCode[APIErrorCode["CLIENT_VERSION_DEPRECATED"] = 34] = "CLIENT_VERSION_DEPRECATED";
/**
* Client update needed
*
* Code: `35`
*/
APIErrorCode[APIErrorCode["CLIENT_UPDATE_NEEDED"] = 35] = "CLIENT_UPDATE_NEEDED";
/**
* Method execution was interrupted due to timeout
*
* Code: `36`
*/
APIErrorCode[APIErrorCode["TIMEOUT"] = 36] = "TIMEOUT";
/**
* User was banned
*
* Code: `37`
*/
APIErrorCode[APIErrorCode["USER_BANNED"] = 37] = "USER_BANNED";
/**
* Unknown application
*
* Code: `38`
*/
APIErrorCode[APIErrorCode["UNKNOWN_APPLICATION"] = 38] = "UNKNOWN_APPLICATION";
/**
* Unknown user
*
* Code: `39`
*/
APIErrorCode[APIErrorCode["UNKNOWN_USER"] = 39] = "UNKNOWN_USER";
/**
* Unknown group
*
* Code: `40`
*/
APIErrorCode[APIErrorCode["UNKNOWN_GROUP"] = 40] = "UNKNOWN_GROUP";
/**
* Additional signup required
*
* Code: `41`
*/
APIErrorCode[APIErrorCode["ADDITIONAL_SIGNUP_REQUIRED"] = 41] = "ADDITIONAL_SIGNUP_REQUIRED";
/**
* IP is not allowed
*
* Code: `42`
*/
APIErrorCode[APIErrorCode["IP_IS_NOT_ALLOWED"] = 42] = "IP_IS_NOT_ALLOWED";
/**
* This section is temporary unavailable
*
* Code: `43`
*/
APIErrorCode[APIErrorCode["SECTION_DISABLED"] = 43] = "SECTION_DISABLED";
/**
* One of the parameters specified was missing or invalid
*
* Code: `100`
*/
APIErrorCode[APIErrorCode["PARAM"] = 100] = "PARAM";
/**
* Invalid application API ID
*
* Code: `101`
*/
APIErrorCode[APIErrorCode["PARAM_API_ID"] = 101] = "PARAM_API_ID";
/**
* Out of limits
*
* Code: `103`
*/
APIErrorCode[APIErrorCode["LIMITS"] = 103] = "LIMITS";
/**
* Not found
*
* Code: `104`
*/
APIErrorCode[APIErrorCode["NOT_FOUND"] = 104] = "NOT_FOUND";
/**
* Couldn't save file
*
* Code: `105`
*/
APIErrorCode[APIErrorCode["SAVE_FILE"] = 105] = "SAVE_FILE";
/**
* Unable to process action
*
* Code: `106`
*/
APIErrorCode[APIErrorCode["ACTION_FAILED"] = 106] = "ACTION_FAILED";
/**
* Invalid user id
*
* Code: `113`
*/
APIErrorCode[APIErrorCode["PARAM_USER_ID"] = 113] = "PARAM_USER_ID";
/**
* Invalid album id
*
* Code: `114`
*/
APIErrorCode[APIErrorCode["PARAM_ALBUM_ID"] = 114] = "PARAM_ALBUM_ID";
/**
* Invalid server
*
* Code: `118`
*/
APIErrorCode[APIErrorCode["PARAM_SERVER"] = 118] = "PARAM_SERVER";
/**
* Invalid title
*
* Code: `119`
*/
APIErrorCode[APIErrorCode["PARAM_TITLE"] = 119] = "PARAM_TITLE";
/**
* Invalid hash
*
* Code: `121`
*/
APIErrorCode[APIErrorCode["PARAM_HASH"] = 121] = "PARAM_HASH";
/**
* Invalid photos
*
* Code: `122`
*/
APIErrorCode[APIErrorCode["PARAM_PHOTOS"] = 122] = "PARAM_PHOTOS";
/**
* Invalid group id
*
* Code: `125`
*/
APIErrorCode[APIErrorCode["PARAM_GROUP_ID"] = 125] = "PARAM_GROUP_ID";
/**
* Invalid photo
*
* Code: `129`
*/
APIErrorCode[APIErrorCode["PARAM_PHOTO"] = 129] = "PARAM_PHOTO";
/**
* Page not found
*
* Code: `140`
*/
APIErrorCode[APIErrorCode["PARAM_PAGE_ID"] = 140] = "PARAM_PAGE_ID";
/**
* Access to page denied
*
* Code: `141`
*/
APIErrorCode[APIErrorCode["ACCESS_PAGE"] = 141] = "ACCESS_PAGE";
/**
* The mobile number of the user is unknown
*
* Code: `146`
*/
APIErrorCode[APIErrorCode["MOBILE_NOT_ACTIVATED"] = 146] = "MOBILE_NOT_ACTIVATED";
/**
* Application has insufficient funds
*
* Code: `147`
*/
APIErrorCode[APIErrorCode["INSUFFICIENT_FUNDS"] = 147] = "INSUFFICIENT_FUNDS";
/**
* Invalid timestamp
*
* Code: `150`
*/
APIErrorCode[APIErrorCode["PARAM_TIMESTAMP"] = 150] = "PARAM_TIMESTAMP";
/**
* Invalid list id
*
* Code: `171`
*/
APIErrorCode[APIErrorCode["FRIENDS_LIST_ID"] = 171] = "FRIENDS_LIST_ID";
/**
* Reached the maximum number of lists
*
* Code: `173`
*/
APIErrorCode[APIErrorCode["FRIENDS_LIST_LIMIT"] = 173] = "FRIENDS_LIST_LIMIT";
/**
* Cannot add user himself as friend
*
* Code: `174`
*/
APIErrorCode[APIErrorCode["FRIENDS_ADD_YOURSELF"] = 174] = "FRIENDS_ADD_YOURSELF";
/**
* Cannot add this user to friends as they have put you on their blacklist
*
* Code: `175`
*/
APIErrorCode[APIErrorCode["FRIENDS_ADD_IN_ENEMY"] = 175] = "FRIENDS_ADD_IN_ENEMY";
/**
* Cannot add this user to friends as you put him on blacklist
*
* Code: `176`
*/
APIErrorCode[APIErrorCode["FRIENDS_ADD_ENEMY"] = 176] = "FRIENDS_ADD_ENEMY";
/**
* Cannot add this user to friends as user not found
*
* Code: `177`
*/
APIErrorCode[APIErrorCode["FRIENDS_ADD_NOT_FOUND"] = 177] = "FRIENDS_ADD_NOT_FOUND";
/**
* Note not found
*
* Code: `180`
*/
APIErrorCode[APIErrorCode["PARAM_NOTE_ID"] = 180] = "PARAM_NOTE_ID";
/**
* Access to note denied
*
* Code: `181`
*/
APIErrorCode[APIErrorCode["ACCESS_NOTE"] = 181] = "ACCESS_NOTE";
/**
* You can't comment this note
*
* Code: `182`
*/
APIErrorCode[APIErrorCode["ACCESS_NOTE_COMMENT"] = 182] = "ACCESS_NOTE_COMMENT";
/**
* Access to comment denied
*
* Code: `183`
*/
APIErrorCode[APIErrorCode["ACCESS_COMMENT"] = 183] = "ACCESS_COMMENT";
/**
* Access denied
*
* Code: `200`
*/
APIErrorCode[APIErrorCode["ACCESS_ALBUM"] = 200] = "ACCESS_ALBUM";
/**
* Access denied
*
* Code: `201`
*/
APIErrorCode[APIErrorCode["ACCESS_AUDIO"] = 201] = "ACCESS_AUDIO";
/**
* Access to group denied
*
* Code: `203`
*/
APIErrorCode[APIErrorCode["ACCESS_GROUP"] = 203] = "ACCESS_GROUP";
/**
* Access denied
*
* Code: `204`
*/
APIErrorCode[APIErrorCode["ACCESS_VIDEO"] = 204] = "ACCESS_VIDEO";
/**
* Access denied
*
* Code: `205`
*/
APIErrorCode[APIErrorCode["ACCESS_MARKET"] = 205] = "ACCESS_MARKET";
/**
* Access to wall's post denied
*
* Code: `210`
*/
APIErrorCode[APIErrorCode["WALL_ACCESS_POST"] = 210] = "WALL_ACCESS_POST";
/**
* Access to wall's comment denied
*
* Code: `211`
*/
APIErrorCode[APIErrorCode["WALL_ACCESS_COMMENT"] = 211] = "WALL_ACCESS_COMMENT";
/**
* Access to post comments denied
*
* Code: `212`
*/
APIErrorCode[APIErrorCode["WALL_ACCESS_REPLIES"] = 212] = "WALL_ACCESS_REPLIES";
/**
* Access to status replies denied
*
* Code: `213`
*/
APIErrorCode[APIErrorCode["WALL_ACCESS_ADD_REPLY"] = 213] = "WALL_ACCESS_ADD_REPLY";
/**
* Access to adding post denied
*
* Code: `214`
*/
APIErrorCode[APIErrorCode["WALL_ADD_POST"] = 214] = "WALL_ADD_POST";
/**
* Advertisement post was recently added
*
* Code: `219`
*/
APIErrorCode[APIErrorCode["WALL_ADS_PUBLISHED"] = 219] = "WALL_ADS_PUBLISHED";
/**
* Too many recipients
*
* Code: `220`
*/
APIErrorCode[APIErrorCode["WALL_TOO_MANY_RECIPIENTS"] = 220] = "WALL_TOO_MANY_RECIPIENTS";
/**
* User disabled track name broadcast
*
* Code: `221`
*/
APIErrorCode[APIErrorCode["STATUS_NO_AUDIO"] = 221] = "STATUS_NO_AUDIO";
/**
* Hyperlinks are forbidden
*
* Code: `222`
*/
APIErrorCode[APIErrorCode["WALL_LINKS_FORBIDDEN"] = 222] = "WALL_LINKS_FORBIDDEN";
/**
* Too many replies
*
* Code: `223`
*/
APIErrorCode[APIErrorCode["WALL_REPLY_OWNER_FLOOD"] = 223] = "WALL_REPLY_OWNER_FLOOD";
/**
* Too many ads posts
*
* Code: `224`
*/
APIErrorCode[APIErrorCode["WALL_ADS_POST_LIMIT_REACHED"] = 224] = "WALL_ADS_POST_LIMIT_REACHED";
/**
* Donut is disabled
*
* Code: `225`
*/
APIErrorCode[APIErrorCode["WALL_DONUT"] = 225] = "WALL_DONUT";
/**
* Reaction can not be applied to the object
*
* Code: `232`
*/
APIErrorCode[APIErrorCode["LIKES_REACTION_CAN_NOT_BE_APPLIED"] = 232] = "LIKES_REACTION_CAN_NOT_BE_APPLIED";
/**
* Access to poll denied
*
* Code: `250`
*/
APIErrorCode[APIErrorCode["POLLS_ACCESS"] = 250] = "POLLS_ACCESS";
/**
* Invalid poll id
*
* Code: `251`
*/
APIErrorCode[APIErrorCode["POLLS_POLL_ID"] = 251] = "POLLS_POLL_ID";
/**
* Invalid answer id
*
* Code: `252`
*/
APIErrorCode[APIErrorCode["POLLS_ANSWER_ID"] = 252] = "POLLS_ANSWER_ID";
/**
* Access denied, please vote first
*
* Code: `253`
*/
APIErrorCode[APIErrorCode["POLLS_ACCESS_WITHOUT_VOTE"] = 253] = "POLLS_ACCESS_WITHOUT_VOTE";
/**
* Access to the groups list is denied due to the user's privacy settings
*
* Code: `260`
*/
APIErrorCode[APIErrorCode["ACCESS_GROUPS"] = 260] = "ACCESS_GROUPS";
/**
* This album is full
*
* Code: `300`
*/
APIErrorCode[APIErrorCode["ALBUM_FULL"] = 300] = "ALBUM_FULL";
/**
* Albums number limit is reached
*
* Code: `302`
*/
APIErrorCode[APIErrorCode["ALBUMS_LIMIT"] = 302] = "ALBUMS_LIMIT";
/**
* Permission denied. You must enable votes processing in application settings
*
* Code: `500`
*/
APIErrorCode[APIErrorCode["VOTES_PERMISSION"] = 500] = "VOTES_PERMISSION";
/**
* Permission denied. You have no access to operations specified with given object(s)
*
* Code: `600`
*/
APIErrorCode[APIErrorCode["ADS_PERMISSION"] = 600] = "ADS_PERMISSION";
/**
* Permission denied. You have requested too many actions this day. Try later.
*
* Code: `601`
*/
APIErrorCode[APIErrorCode["WEIGHTED_FLOOD"] = 601] = "WEIGHTED_FLOOD";
/**
* Some part of the request has not been completed
*
* Code: `602`
*/
APIErrorCode[APIErrorCode["ADS_PARTIAL_SUCCESS"] = 602] = "ADS_PARTIAL_SUCCESS";
/**
* Some ads error occurs
*
* Code: `603`
*/
APIErrorCode[APIErrorCode["ADS_SPECIFIC"] = 603] = "ADS_SPECIFIC";
/**
* Object deleted
*
* Code: `629`
*/
APIErrorCode[APIErrorCode["ADS_OBJECT_DELETED"] = 629] = "ADS_OBJECT_DELETED";
/**
* Lookalike request with same source already in progress
*
* Code: `630`
*/
APIErrorCode[APIErrorCode["ADS_LOOKALIKE_REQUEST_ALREADY_IN_PROGRESS"] = 630] = "ADS_LOOKALIKE_REQUEST_ALREADY_IN_PROGRESS";
/**
* Max count of lookalike requests per day reached
*
* Code: `631`
*/
APIErrorCode[APIErrorCode["ADS_LOOKALIKE_REQUEST_MAX_COUNT_PER_DAY_REACHED"] = 631] = "ADS_LOOKALIKE_REQUEST_MAX_COUNT_PER_DAY_REACHED";
/**
* Given audience is too small
*
* Code: `632`
*/
APIErrorCode[APIErrorCode["ADS_LOOKALIKE_REQUEST_AUDIENCE_TOO_SMALL"] = 632] = "ADS_LOOKALIKE_REQUEST_AUDIENCE_TOO_SMALL";
/**
* Given audience is too large
*
* Code: `633`
*/
APIErrorCode[APIErrorCode["ADS_LOOKALIKE_REQUEST_AUDIENCE_TOO_LARGE"] = 633] = "ADS_LOOKALIKE_REQUEST_AUDIENCE_TOO_LARGE";
/**
* Lookalike request audience save already in progress
*
* Code: `634`
*/
APIErrorCode[APIErrorCode["ADS_LOOKALIKE_REQUEST_EXPORT_ALREADY_IN_PROGRESS"] = 634] = "ADS_LOOKALIKE_REQUEST_EXPORT_ALREADY_IN_PROGRESS";
/**
* Max count of lookalike request audience saves per day reached
*
* Code: `635`
*/
APIErrorCode[APIErrorCode["ADS_LOOKALIKE_REQUEST_EXPORT_MAX_COUNT_PER_DAY_REACHED"] = 635] = "ADS_LOOKALIKE_REQUEST_EXPORT_MAX_COUNT_PER_DAY_REACHED";
/**
* Max count of retargeting groups reached
*
* Code: `636`
*/
APIErrorCode[APIErrorCode["ADS_LOOKALIKE_REQUEST_EXPORT_RETARGETING_GROUP_LIMIT"] = 636] = "ADS_LOOKALIKE_REQUEST_EXPORT_RETARGETING_GROUP_LIMIT";
/**
* Cannot edit creator role
*
* Code: `700`
*/
APIErrorCode[APIErrorCode["GROUP_CHANGE_CREATOR"] = 700] = "GROUP_CHANGE_CREATOR";
/**
* User should be in club
*
* Code: `701`
*/
APIErrorCode[APIErrorCode["GROUP_NOT_IN_CLUB"] = 701] = "GROUP_NOT_IN_CLUB";
/**
* Too many officers in club
*
* Code: `702`
*/
APIErrorCode[APIErrorCode["GROUP_TOO_MANY_OFFICERS"] = 702] = "GROUP_TOO_MANY_OFFICERS";
/**
* You need to enable 2FA for this action
*
* Code: `703`
*/
APIErrorCode[APIErrorCode["GROUP_NEED_2FA"] = 703] = "GROUP_NEED_2FA";
/**
* User needs to enable 2FA for this action
*
* Code: `704`
*/
APIErrorCode[APIErrorCode["GROUP_HOST_NEED_2FA"] = 704] = "GROUP_HOST_NEED_2FA";
/**
* Too many addresses in club
*
* Code: `706`
*/
APIErrorCode[APIErrorCode["GROUP_TOO_MANY_ADDRESSES"] = 706] = "GROUP_TOO_MANY_ADDRESSES";
/**
* Application is not installed in community
*
* Code: `711`
*/
APIErrorCode[APIErrorCode["GROUP_APP_IS_NOT_INSTALLED_IN_COMMUNITY"] = 711] = "GROUP_APP_IS_NOT_INSTALLED_IN_COMMUNITY";
/**
* Invite link is invalid - expired, deleted or not exists
*
* Code: `714`
*/
APIErrorCode[APIErrorCode["GROUP_INVITE_LINKS_NOT_VALID"] = 714] = "GROUP_INVITE_LINKS_NOT_VALID";
/**
* This video is already added
*
* Code: `800`
*/
APIErrorCode[APIErrorCode["VIDEO_ALREADY_ADDED"] = 800] = "VIDEO_ALREADY_ADDED";
/**
* Comments for this video are closed
*
* Code: `801`
*/
APIErrorCode[APIErrorCode["VIDEO_COMMENTS_CLOSED"] = 801] = "VIDEO_COMMENTS_CLOSED";
/**
* Can't send messages for users from blacklist
*
* Code: `900`
*/
APIErrorCode[APIErrorCode["MESSAGES_USER_BLOCKED"] = 900] = "MESSAGES_USER_BLOCKED";
/**
* Can't send messages for users without permission
*
* Code: `901`
*/
APIErrorCode[APIErrorCode["MESSAGES_DENY_SEND"] = 901] = "MESSAGES_DENY_SEND";
/**
* Can't send messages to this user due to their privacy settings
*
* Code: `902`
*/
APIErrorCode[APIErrorCode["MESSAGES_PRIVACY"] = 902] = "MESSAGES_PRIVACY";
/**
* Value of ts or pts is too old
*
* Code: `907`
*/
APIErrorCode[APIErrorCode["MESSAGES_TOO_OLD_PTS"] = 907] = "MESSAGES_TOO_OLD_PTS";
/**
* Value of ts or pts is too new
*
* Code: `908`
*/
APIErrorCode[APIErrorCode["MESSAGES_TOO_NEW_PTS"] = 908] = "MESSAGES_TOO_NEW_PTS";
/**
* Can't edit this message, because it's too old
*
* Code: `909`
*/
APIErrorCode[APIErrorCode["MESSAGES_EDIT_EXPIRED"] = 909] = "MESSAGES_EDIT_EXPIRED";
/**
* Can't sent this message, because it's too big
*
* Code: `910`
*/
APIErrorCode[APIErrorCode["MESSAGES_TOO_BIG"] = 910] = "MESSAGES_TOO_BIG";
/**
* Keyboard format is invalid
*
* Code: `911`
*/
APIErrorCode[APIErrorCode["MESSAGES_KEYBOARD_INVALID"] = 911] = "MESSAGES_KEYBOARD_INVALID";
/**
* This is a chat bot feature, change this status in settings
*
* Code: `912`
*/
APIErrorCode[APIErrorCode["MESSAGES_CHAT_BOT_FEATURE"] = 912] = "MESSAGES_CHAT_BOT_FEATURE";
/**
* Too many forwarded messages
*
* Code: `913`
*/
APIErrorCode[APIErrorCode["MESSAGES_TOO_LONG_FORWARDS"] = 913] = "MESSAGES_TOO_LONG_FORWARDS";
/**
* Message is too long
*
* Code: `914`
*/
APIErrorCode[APIErrorCode["MESSAGES_TOO_LONG_MESSAGE"] = 914] = "MESSAGES_TOO_LONG_MESSAGE";
/**
* You don't have access to this chat
*
* Code: `917`
*/
APIErrorCode[APIErrorCode["MESSAGES_CHAT_USER_NO_ACCESS"] = 917] = "MESSAGES_CHAT_USER_NO_ACCESS";
/**
* You can't see invite link for this chat
*
* Code: `919`
*/
APIErrorCode[APIErrorCode["MESSAGES_CANT_SEE_INVITE_LINK"] = 919] = "MESSAGES_CANT_SEE_INVITE_LINK";
/**
* Can't edit this kind of message
*
* Code: `920`
*/
APIErrorCode[APIErrorCode["MESSAGES_EDIT_KIND_DISALLOWED"] = 920] = "MESSAGES_EDIT_KIND_DISALLOWED";
/**
* Can't forward these messages
*
* Code: `921`
*/
APIErrorCode[APIErrorCode["MESSAGES_CANT_FWD"] = 921] = "MESSAGES_CANT_FWD";
/**
* You left this chat
*
* Code: `922`
*/
APIErrorCode[APIErrorCode["MESSAGES_CHAT_USER_LEFT"] = 922] = "MESSAGES_CHAT_USER_LEFT";
/**
* Can't delete this message for everybody
*
* Code: `924`
*/
APIErrorCode[APIErrorCode["MESSAGES_CANT_DELETE_FOR_ALL"] = 924] = "MESSAGES_CANT_DELETE_FOR_ALL";
/**
* You are not admin of this chat
*
* Code: `925`
*/
APIErrorCode[APIErrorCode["MESSAGES_CHAT_NOT_ADMIN"] = 925] = "MESSAGES_CHAT_NOT_ADMIN";
/**
* Chat does not exist
*
* Code: `927`
*/
APIErrorCode[APIErrorCode["MESSAGES_CHAT_NOT_EXIST"] = 927] = "MESSAGES_CHAT_NOT_EXIST";
/**
* You can't change invite link for this chat
*
* Code: `931`
*/
APIErrorCode[APIErrorCode["MESSAGES_CANT_CHANGE_INVITE_LINK"] = 931] = "MESSAGES_CANT_CHANGE_INVITE_LINK";
/**
* Your community can't interact with this peer
*
* Code: `932`
*/
APIErrorCode[APIErrorCode["MESSAGES_GROUP_PEER_ACCESS"] = 932] = "MESSAGES_GROUP_PEER_ACCESS";
/**
* User not found in chat
*
* Code: `935`
*/
APIErrorCode[APIErrorCode["MESSAGES_CHAT_USER_NOT_IN_CHAT"] = 935] = "MESSAGES_CHAT_USER_NOT_IN_CHAT";
/**
* Contact not found
*
* Code: `936`
*/
APIErrorCode[APIErrorCode["MESSAGES_CONTACT_NOT_FOUND"] = 936] = "MESSAGES_CONTACT_NOT_FOUND";
/**
* Message request already sent
*
* Code: `939`
*/
APIErrorCode[APIErrorCode["MESSAGES_MESSAGE_REQUEST_ALREADY_SENT"] = 939] = "MESSAGES_MESSAGE_REQUEST_ALREADY_SENT";
/**
* Too many posts in messages
*
* Code: `940`
*/
APIErrorCode[APIErrorCode["MESSAGES_TOO_MANY_POSTS"] = 940] = "MESSAGES_TOO_MANY_POSTS";
/**
* Cannot pin one-time story
*
* Code: `942`
*/
APIErrorCode[APIErrorCode["MESSAGES_CANT_PIN_ONE_TIME_STORY"] = 942] = "MESSAGES_CANT_PIN_ONE_TIME_STORY";
/**
* Cannot use this intent
*
* Code: `943`
*/
APIErrorCode[APIErrorCode["MESSAGES_INTENT_CANT_USE"] = 943] = "MESSAGES_INTENT_CANT_USE";
/**
* Limits overflow for this intent
*
* Code: `944`
*/
APIErrorCode[APIErrorCode["MESSAGES_INTENT_LIMIT_OVERFLOW"] = 944] = "MESSAGES_INTENT_LIMIT_OVERFLOW";
/**
* Chat was disabled
*
* Code: `945`
*/
APIErrorCode[APIErrorCode["MESSAGES_CHAT_DISABLED"] = 945] = "MESSAGES_CHAT_DISABLED";
/**
* Chat not supported
*
* Code: `946`
*/
APIErrorCode[APIErrorCode["MESSAGES_CHAT_UNSUPPORTED"] = 946] = "MESSAGES_CHAT_UNSUPPORTED";
/**
* Can't add user to chat, because user has no access to group
*
* Code: `947`
*/
APIErrorCode[APIErrorCode["MESSAGES_MEMBER_ACCESS_TO_GROUP_DENIED"] = 947] = "MESSAGES_MEMBER_ACCESS_TO_GROUP_DENIED";
/**
* Can't edit pinned message yet
*
* Code: `949`
*/
APIErrorCode[APIErrorCode["MESSAGES_CANT_EDIT_PINNED_YET"] = 949] = "MESSAGES_CANT_EDIT_PINNED_YET";
/**
* Can't send message, reply timed out
*
* Code: `950`
*/
APIErrorCode[APIErrorCode["MESSAGES_PEER_BLOCKED_REASON_BY_TIME"] = 950] = "MESSAGES_PEER_BLOCKED_REASON_BY_TIME";
/**
* You can't access donut chat without subscription
*
* Code: `962`
*/
APIErrorCode[APIErrorCode["MESSAGES_USER_NOT_DON"] = 962] = "MESSAGES_USER_NOT_DON";
/**
* Message cannot be forwarded
*
* Code: `969`
*/
APIErrorCode[APIErrorCode["MESSAGES_MESSAGE_CANNOT_BE_FORWARDED"] = 969] = "MESSAGES_MESSAGE_CANNOT_BE_FORWARDED";
/**
* Cannot pin an expiring message
*
* Code: `970`
*/
APIErrorCode[APIErrorCode["MESSAGES_CANT_PIN_EXPIRING_MESSAGE"] = 970] = "MESSAGES_CANT_PIN_EXPIRING_MESSAGE";
/**
* Unknown reaction passed
*
* Code: `1009`
*/
APIErrorCode[APIErrorCode["MESSAGES_INVALID_REACTION_ID"] = 1009] = "MESSAGES_INVALID_REACTION_ID";
/**
* This reaction has been disabled
*
* Code: `1010`
*/
APIErrorCode[APIErrorCode["MESSAGES_FORBIDDEN_REACTION"] = 1010] = "MESSAGES_FORBIDDEN_REACTION";
/**
* Reactions limit for this message has been reached
*
* Code: `1011`
*/
APIErrorCode[APIErrorCode["MESSAGES_REACTIONS_LIMIT_REACHED"] = 1011] = "MESSAGES_REACTIONS_LIMIT_REACHED";
/**
* Too many auth attempts, try again later
*
* Code: `1105`
*/
APIErrorCode[APIErrorCode["AUTH_FLOOD_ERROR"] = 1105] = "AUTH_FLOOD_ERROR";
/**
* Anonymous token has expired
*
* Code: `1114`
*/
APIErrorCode[APIErrorCode["AUTH_ANONYMOUS_TOKEN_HAS_EXPIRED"] = 1114] = "AUTH_ANONYMOUS_TOKEN_HAS_EXPIRED";
/**
* Anonymous token is invalid
*
* Code: `1116`
*/
APIErrorCode[APIErrorCode["AUTH_ANONYMOUS_TOKEN_IS_INVALID"] = 1116] = "AUTH_ANONYMOUS_TOKEN_IS_INVALID";
/**
* Access token has expired
*
* Code: `1117`
*/
APIErrorCode[APIErrorCode["AUTH_ACCESS_TOKEN_HAS_EXPIRED"] = 1117] = "AUTH_ACCESS_TOKEN_HAS_EXPIRED";
/**
* Anonymous token ip mismatch
*
* Code: `1118`
*/
APIErrorCode[APIErrorCode["AUTH_ANONYMOUS_TOKEN_IP_MISMATCH"] = 1118] = "AUTH_ANONYMOUS_TOKEN_IP_MISMATCH";
/**
* Passkey registration error
*
* Code: `1119`
*/
APIErrorCode[APIErrorCode["PASSKEY_REGISTRATION"] = 1119] = "PASSKEY_REGISTRATION";
/**
* Passkey login error
*
* Code: `1120`
*/
APIErrorCode[APIErrorCode["PASSKEY_LOGIN"] = 1120] = "PASSKEY_LOGIN";
/**
* Invalid document id
*
* Code: `1150`
*/
APIErrorCode[APIErrorCode["PARAM_DOC_ID"] = 1150] = "PARAM_DOC_ID";
/**
* Access to document deleting is denied
*
* Code: `1151`
*/
APIErrorCode[APIErrorCode["PARAM_DOC_DELETE_ACCESS"] = 1151] = "PARAM_DOC_DELETE_ACCESS";
/**
* Invalid document title
*
* Code: `1152`
*/
APIErrorCode[APIErrorCode["PARAM_DOC_TITLE"] = 1152] = "PARAM_DOC_TITLE";
/**
* Access to document is denied
*
* Code: `1153`
*/
APIErrorCode[APIErrorCode["PARAM_DOC_ACCESS"] = 1153] = "PARAM_DOC_ACCESS";
/**
* Original photo was changed
*
* Code: `1160`
*/
APIErrorCode[APIErrorCode["PHOTO_CHANGED"] = 1160] = "PHOTO_CHANGED";
/**
* Too many feed lists
*
* Code: `1170`
*/
APIErrorCode[APIErrorCode["TOO_MANY_LISTS"] = 1170] = "TOO_MANY_LISTS";
/**
* This achievement is already unlocked
*
* Code: `1251`
*/
APIErrorCode[APIErrorCode["APPS_ALREADY_UNLOCKED"] = 1251] = "APPS_ALREADY_UNLOCKED";
/**
* Subscription not found
*
* Code: `1256`
*/
APIErrorCode[APIErrorCode["APPS_SUBSCRIPTION_NOT_FOUND"] = 1256] = "APPS_SUBSCRIPTION_NOT_FOUND";
/**
* Subscription is in invalid status
*
* Code: `1257`
*/
APIErrorCode[APIErrorCode["APPS_SUBSCRIPTION_INVALID_STATUS"] = 1257] = "APPS_SUBSCRIPTION_INVALID_STATUS";
/**
* Invalid screen name
*
* Code: `1260`
*/
APIErrorCode[APIErrorCode["INVALID_ADDRESS"] = 1260] = "INVALID_ADDRESS";
/**
* Too late for restore
*
* Code: `1400`
*/
APIErrorCode[APIErrorCode["MARKET_RESTORE_TOO_LATE"] = 1400] = "MARKET_RESTORE_TOO_LATE";
/**
* Comments for this market are closed
*
* Code: `1401`
*/
APIErrorCode[APIErrorCode["MARKET_COMMENTS_CLOSED"] = 1401] = "MARKET_COMMENTS_CLOSED";
/**
* Album not found
*
* Code: `1402`
*/
APIErrorCode[APIErrorCode["MARKET_ALBUM_NOT_FOUND"] = 1402] = "MARKET_ALBUM_NOT_FOUND";
/**
* Item not found
*
* Code: `1403`
*/
APIErrorCode[APIErrorCode["MARKET_ITEM_NOT_FOUND"] = 1403] = "MARKET_ITEM_NOT_FOUND";
/**
* Item already added to album
*
* Code: `1404`
*/
APIErrorCode[APIErrorCode["MARKET_ITEM_ALREADY_ADDED"] = 1404] = "MARKET_ITEM_ALREADY_ADDED";
/**
* Too many items
*
* Code: `1405`
*/
APIErrorCode[APIErrorCode["MARKET_TOO_MANY_ITEMS"] = 1405] = "MARKET_TOO_MANY_ITEMS";
/**
* Too many items in album
*
* Code: `1406`
*/
APIErrorCode[APIErrorCode["MARKET_TOO_MANY_ITEMS_IN_ALBUM"] = 1406] = "MARKET_TOO_MANY_ITEMS_IN_ALBUM";
/**
* Too many albums
*
* Code: `1407`
*/
APIErrorCode[APIErrorCode["MARKET_TOO_MANY_ALBUMS"] = 1407] = "MARKET_TOO_MANY_ALBUMS";
/**
* Item has bad links in description
*
* Code: `1408`
*/
APIErrorCode[APIErrorCode["MARKET_ITEM_HAS_BAD_LINKS"] = 1408] = "MARKET_ITEM_HAS_BAD_LINKS";
/**
* Extended market not enabled
*
* Code: `1409`
*/
APIErrorCode[APIErrorCode["MARKET_EXTENDED_NOT_ENABLED"] = 1409] = "MARKET_EXTENDED_NOT_ENABLED";
/**
* Grouping items with different properties
*
* Code: `1412`
*/
APIErrorCode[APIErrorCode["MARKET_GROUPING_ITEMS_WITH_DIFFERENT_PROPERTIES"] = 1412] = "MARKET_GROUPING_ITEMS_WITH_DIFFERENT_PROPERTIES";
/**
* Grouping already has such variant
*
* Code: `1413`
*/
APIErrorCode[APIErrorCode["MARKET_GROUPING_ALREADY_HAS_SUCH_VARIANT"] = 1413] = "MARKET_GROUPING_ALREADY_HAS_SUCH_VARIANT";
/**
* Variant not found
*
* Code: `1416`
*/
APIErrorCode[APIErrorCode["MARKET_VARIANT_NOT_FOUND"] = 1416] = "MARKET_VARIANT_NOT_FOUND";
/**
* Property not found
*
* Code: `1417`
*/
APIErrorCode[APIErrorCode["MARKET_PROPERTY_NOT_FOUND"] = 1417] = "MARKET_PROPERTY_NOT_FOUND";
/**
* Grouping must have two or more items
*
* Code: `1425`
*/
APIErrorCode[APIErrorCode["MARKET_GROUPING_MUST_CONTAIN_MORE_THAN_ONE_ITEM"] = 1425] = "MARKET_GROUPING_MUST_CONTAIN_MORE_THAN_ONE_ITEM";
/**
* Item must have distinct properties
*
* Code: `1426`
*/
APIErrorCode[APIErrorCode["MARKET_GROUPING_ITEMS_MUST_HAVE_DISTINCT_PROPERTIES"] = 1426] = "MARKET_GROUPING_ITEMS_MUST_HAVE_DISTINCT_PROPERTIES";
/**
* Cart is empty
*
* Code: `1427`
*/
APIErrorCode[APIErrorCode["MARKET_ORDERS_NO_CART_ITEMS"] = 1427] = "MARKET_ORDERS_NO_CART_ITEMS";
/**
* Specify width, length, height and weight all together
*
* Code: `1429`
*/
APIErrorCode[APIErrorCode["MARKET_INVALID_DIMENSIONS"] = 1429] = "MARKET_INVALID_DIMENSIONS";
/**
* VK Pay status can not be changed
*
* Code: `1430`
*/
APIErrorCode[APIErrorCode["MARKET_CANT_CHANGE_VKPAY_STATUS"] = 1430] = "MARKET_CANT_CHANGE_VKPAY_STATUS";
/**
* Market was already enabled in this group
*
* Code: `1431`
*/
APIErrorCode[APIErrorCode["MARKET_SHOP_ALREADY_ENABLED"] = 1431] = "MARKET_SHOP_ALREADY_ENABLED";
/**
* Market was already disabled in this group
*
* Code: `1432`
*/
APIErrorCode[APIErrorCode["MARKET_SHOP_ALREADY_DISABLED"] = 1432] = "MARKET_SHOP_ALREADY_DISABLED";
/**
* Invalid image crop format
*
* Code: `1433`
*/
APIErrorCode[APIErrorCode["MARKET_PHOTOS_CROP_INVALID_FORMAT"] = 1433] = "MARKET_PHOTOS_CROP_INVALID_FORMAT";
/**
* Crop bottom right corner is outside of the image
*
* Code: `1434`
*/
APIErrorCode[APIErrorCode["MARKET_PHOTOS_CROP_OVERFLOW"] = 1434] = "MARKET_PHOTOS_CROP_OVERFLOW";
/**
* Crop size is less than the minimum
*
* Code: `1435`
*/
APIErrorCode[APIErrorCode["MARKET_PHOTOS_CROP_SIZE_TOO_LOW"] = 1435] = "MARKET_PHOTOS_CROP_SIZE_TOO_LOW";
/**
* Market not enabled
*
* Code: `1438`
*/
APIErrorCode[APIErrorCode["MARKET_NOT_ENABLED"] = 1438] = "MARKET_NOT_ENABLED";
/**
* Main album can not be hidden
*
* Code: `1446`
*/
APIErrorCode[APIErrorCode["MARKET_ALBUM_MAIN_HIDDEN"] = 1446] = "MARKET_ALBUM_MAIN_HIDDEN";
/**
* Order status is invalid
*
* Code: `1456`
*/
APIErrorCode[APIErrorCode["MARKET_ORDERS_INVALID_STATUS"] = 1456] = "MARKET_ORDERS_INVALID_STATUS";
/**
* Story has already expired
*
* Code: `1600`
*/
APIErrorCode[APIErrorCode["STORY_EXPIRED"] = 1600] = "STORY_EXPIRED";
/**
* Incorrect reply privacy
*
* Code: `1602`
*/
APIErrorCode[APIErrorCode["STORY_INCORRECT_REPLY_PRIVACY"] = 1602] = "STORY_INCORRECT_REPLY_PRIVACY";
/**
* Card not found
*
* Code: `1900`
*/
APIErrorCode[APIErrorCode["PRETTY_CARDS_CARD_NOT_FOUND"] = 1900] = "PRETTY_CARDS_CARD_NOT_FOUND";
/**
* Too many cards
*
* Code: `1901`
*/
APIErrorCode[APIErrorCode["PRETTY_CARDS_TOO_MANY_CARDS"] = 1901] = "PRETTY_CARDS_TOO_MANY_CARDS";
/**
* Card is connected to post
*
* Code: `1902`
*/
APIErrorCode[APIErrorCode["PRETTY_CARDS_CARD_IS_CONNECTED_TO_POST"] = 1902] = "PRETTY_CARDS_CARD_IS_CONNECTED_TO_POST";
/**
* Servers number limit is reached
*
* Code: `2000`
*/
APIErrorCode[APIErrorCode["CALLBACK_API_SERVERS_LIMIT"] = 2000] = "CALLBACK_API_SERVERS_LIMIT";
/**
* Stickers are not purchased
*
* Code: `2100`
*/
APIErrorCode[APIErrorCode["STICKERS_NOT_PURCHASED"] = 2100] = "STICKERS_NOT_PURCHASED";
/**
* Too many favorite stickers
*
* Code: `2101`
*/
APIErrorCode[APIErrorCode["STICKERS_TOO_MANY_FAVORITES"] = 2101] = "STICKERS_TOO_MANY_FAVORITES";
/**
* Stickers are not favorite
*
* Code: `2102`
*/
APIErrorCode[APIErrorCode["STICKERS_NOT_FAVORITE"] = 2102] = "STICKERS_NOT_FAVORITE";
/**
* Specified link is incorrect (can't find source)
*
* Code: `3102`
*/
APIErrorCode[APIErrorCode["WALL_CHECK_LINK_CANT_DETERMINE_SOURCE"] = 3102] = "WALL_CHECK_LINK_CANT_DETERMINE_SOURCE";
/**
* Recaptcha needed
*
* Code: `3300`
*/
APIErrorCode[APIErrorCode["RECAPTCHA"] = 3300] = "RECAPTCHA";
/**
* Phone validation needed
*
* Code: `3301`
*/
APIErrorCode[APIErrorCode["PHONE_VALIDATION_NEED"] = 3301] = "PHONE_VALIDATION_NEED";
/**
* Password validation needed
*
* Code: `3302`
*/
APIErrorCode[APIErrorCode["PASSWORD_VALIDATION_NEED"] = 3302] = "PASSWORD_VALIDATION_NEED";
/**
* Otp app validation needed
*
* Code: `3303`
*/
APIErrorCode[APIErrorCode["OTP_VALIDATION_NEED"] = 3303] = "OTP_VALIDATION_NEED";
/**
* Email confirmation needed
*
* Code: `3304`
*/
APIErrorCode[APIErrorCode["EMAIL_CONFIRMATION_NEED"] = 3304] = "EMAIL_CONFIRMATION_NEED";
/**
* Assert votes
*
* Code: `3305`
*/
APIErrorCode[APIErrorCode["ASSERT_VOTES"] = 3305] = "ASSERT_VOTES";
/**
* Token extension required
*
* Code: `3609`
*/
APIErrorCode[APIErrorCode["TOKEN_EXTENSION_REQUIRED"] = 3609] = "TOKEN_EXTENSION_REQUIRED";
/**
* User is deactivated
*
* Code: `3610`
*/
APIErrorCode[APIErrorCode["USER_DEACTIVATED"] = 3610] = "USER_DEACTIVATED";
/**
* Service is deactivated for user
*
* Code: `3611`
*/
APIErrorCode[APIErrorCode["USER_SERVICE_DEACTIVATED"] = 3611] = "USER_SERVICE_DEACTIVATED";
/**
* Can't set AliExpress tag to this type of object
*
* Code: `3800`
*/
APIErrorCode[APIErrorCode["FAVE_ALIEXPRESS_TAG"] = 3800] = "FAVE_ALIEXPRESS_TAG";
/**
* Total audio duration limit reached
*
* Code: `7701`
*/
APIErrorCode[APIErrorCode["ASR_AUDIO_DURATION_FLOODED"] = 7701] = "ASR_AUDIO_DURATION_FLOODED";
/**
* Audio file is too big
*
* Code: `7702`
*/
APIErrorCode[APIErrorCode["ASR_FILE_IS_TOO_BIG"] = 7702] = "ASR_FILE_IS_TOO_BIG";
/**
* Invalid hash
*
* Code: `7703`
*/
APIErrorCode[APIErrorCode["ASR_INVALID_HASH"] = 7703] = "ASR_INVALID_HASH";
/**
* Task not found
*
* Code: `7704`
*/
APIErrorCode[APIErrorCode["ASR_NOT_FOUND"] = 7704] = "ASR_NOT_FOUND";
/**
* Not supported http method
*
* Code: `9999`
*/
APIErrorCode[APIErrorCode["NOT_SUPPORTED_HTTP_METHOD"] = 9999] = "NOT_SUPPORTED_HTTP_METHOD";
/**
* CheckUserAction confirmation required
*
* Code: `11500`
*/
APIErrorCode[APIErrorCode["CUA_CONFIRMATION_REQUIRED"] = 11500] = "CUA_CONFIRMATION_REQUIRED";
})(exports.APIErrorCode || (exports.APIErrorCode = {}));
class APIError extends VKError {
/**
* Constructor
*/
constructor(payload) {
const code = Number(payload.error_code);
const message = `Code №${code} - ${payload.error_msg}`;
super({ code, message });
this.params = payload.request_params;
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
if (code === exports.APIErrorCode.CAPTCHA) {
this.captchaSid = Number(payload.captcha_sid);
this.captchaImg = payload.captcha_img;
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
}
else if (code === exports.APIErrorCode.AUTH_VALIDATION) {
this.redirectUri = payload.redirect_uri;
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
}
else if (code === exports.APIErrorCode.NEED_CONFIRMATION) {
this.confirmationText = payload.confirmation_text;
}
}
}
class UploadError extends VKError {
}
class CollectError extends VKError {
/**
* Constructor
*/
constructor({ message, code, errors }) {
super({ message, code });
this.errors = errors;
}
}
class UpdatesError extends VKError {
}
class ExecuteError extends APIError {
/**
* Constructor
*/
constructor(options) {
super({
error_code: options.error_code,
error_msg: options.error_msg,
request_params: [],
});
this.method = options.method;
}
}
class ResourceError extends VKError {
}
/**
* Chat peer ID
*/
const PEER_CHAT_ID_OFFSET = 2e9;
/**
* Minimum time interval api with error
*/
const MINIMUM_TIME_INTERVAL_API = 1133;
/**
* The attachment types
*/
exports.AttachmentType = void 0;
(function (AttachmentType) {
AttachmentType["ALBUM"] = "album";
AttachmentType["AUDIO"] = "audio";
AttachmentType["AUDIO_MESSAGE"] = "audio_message";
AttachmentType["GRAFFITI"] = "graffiti";
AttachmentType["DOCUMENT"] = "doc";
AttachmentType["GIFT"] = "gift";
AttachmentType["LINK"] = "link";
AttachmentType["MARKET_ALBUM"] = "market_album";
AttachmentType["MARKET"] = "market";
AttachmentType["PHOTO"] = "photo";
AttachmentType["STICKER"] = "sticker";
AttachmentType["VIDEO"] = "video";
AttachmentType["WALL_REPLY"] = "wall_reply";
AttachmentType["WALL"] = "wall";
AttachmentType["POLL"] = "poll";
AttachmentType["PODCAST"] = "podcast";
AttachmentType["STORY"] = "story";
AttachmentType["TEXTLIVE"] = "textlive";
})(exports.AttachmentType || (exports.AttachmentType = {}));
/**
* Default extensions for attachments
*/
var DefaultExtension;
(function (DefaultExtension) {
DefaultExtension["photo"] = "jpg";
DefaultExtension["video"] = "mp4";
DefaultExtension["audio"] = "mp3";
DefaultExtension["graffiti"] = "png";
DefaultExtension["audioMessage"] = "ogg";
})(DefaultExtension || (DefaultExtension = {}));
/**
* Default content type for attachments
*/
var DefaultContentType;
(function (DefaultContentType) {
DefaultContentType["photo"] = "image/jpeg";
DefaultContentType["video"] = "video/mp4";
DefaultContentType["audio"] = "audio/mp3";
DefaultContentType["graffiti"] = "image/png";
DefaultContentType["audioMessage"] = "audio/ogg";
})(DefaultContentType || (DefaultContentType = {}));
/**
* Sources of captcha
*/
exports.CaptchaType = void 0;
(function (CaptchaType) {
CaptchaType["API"] = "API";
CaptchaType["DIRECT_AUTH"] = "DIRECT_AUTH";
CaptchaType["IMPLICIT_FLOW_AUTH"] = "IMPLICIT_FLOW_AUTH";
CaptchaType["ACCOUNT_VERIFICATION"] = "ACCOUNT_VERIFICATION";
})(exports.CaptchaType || (exports.CaptchaType = {}));
/**
* Message source
*/
exports.MessageSource = void 0;
(function (MessageSource) {
MessageSource["USER"] = "user";
MessageSource["CHAT"] = "chat";
MessageSource["GROUP"] = "group";
MessageSource["EMAIL"] = "email";
})(exports.MessageSource || (exports.MessageSource = {}));
/**
* Resource types
*/
exports.ResourceType = void 0;
(function (ResourceType) {
ResourceType["USER"] = "user";
ResourceType["GROUP"] = "group";
ResourceType["APPLICATION"] = "application";
})(exports.ResourceType || (exports.ResourceType = {}));
/**
* Updates sources
*/
exports.UpdateSource = void 0;
(function (UpdateSource) {
UpdateSource["POLLING"] = "POLLING";
UpdateSource["WEBHOOK"] = "WEBHOOK";
UpdateSource["WEBSOCKET"] = "WEBSOCKET";
})(exports.UpdateSource || (exports.UpdateSource = {}));
/**
* Upload error codes
*/
exports.UploadErrorCode = void 0;
(function (UploadErrorCode) {
UploadErrorCode["MISSING_PARAMETERS"] = "MISSING_PARAMETERS";
UploadErrorCode["NO_FILES_TO_UPLOAD"] = "NO_FILES_TO_UPLOAD";
UploadErrorCode["EXCEEDED_MAX_FILES"] = "EXCEEDED_MAX_FILES";
UploadErrorCode["UNSUPPORTED_SOURCE_TYPE"] = "UNSUPPORTED_SOURCE_TYPE";
})(exports.UploadErrorCode || (exports.UploadErrorCode = {}));
/**
* Updates error codes
*/
exports.UpdatesErrorCode = void 0;
(function (UpdatesErrorCode) {
UpdatesErrorCode["NEED_RESTART"] = "NEED_RESTART";
UpdatesErrorCode["POLLING_REQUEST_FAILED"] = "POLLING_REQUEST_FAILED";
})(exports.UpdatesErrorCode || (exports.UpdatesErrorCode = {}));
/**
* Collect error codes
*/
exports.CollectErrorCode = void 0;
(function (CollectErrorCode) {
CollectErrorCode["EXECUTE_ERROR"] = "EXECUTE_ERROR";
})(exports.CollectErrorCode || (exports.CollectErrorCode = {}));
/**
* Snippets error codes
*/
exports.ResourceErrorCode = void 0;
(function (ResourceErrorCode) {
ResourceErrorCode["INVALID_URL"] = "INVALID_URL";
ResourceErrorCode["INVALID_RESOURCE"] = "INVALID_RESOURCE";
ResourceErrorCode["RESOURCE_NOT_FOUND"] = "RESOURCE_NOT_FOUND";
})(exports.ResourceErrorCode || (exports.ResourceErrorCode = {}));
/**
* Snippets error codes
*/
exports.SharedErrorCode = void 0;
(function (SharedErrorCode) {
SharedErrorCode["MISSING_CAPTCHA_HANDLER"] = "MISSING_CAPTCHA_HANDLER";
SharedErrorCode["MISSING_TWO_FACTOR_HANDLER"] = "MISSING_TWO_FACTOR_HANDLER";
})(exports.SharedErrorCode || (exports.SharedErrorCode = {}));
/**
* Symbol of data definition for serialization
*/
const kSerializeData = Symbol('serializeData');
var params = /*#__PURE__*/Object.freeze({
__proto__: null
});
var objects = /*#__PURE__*/Object.freeze({
__proto__: null
});
var responses = /*#__PURE__*/Object.freeze({
__proto__: null
});
class APIWorker {
/**
* Constructor
*/
constructor(api) {
this.busy = false;
this.paused = false;
this.queue = [];
this.api = api;
this.intervalPerRequests = Math.ceil(MINIMUM_TIME_INTERVAL_API / this.api.options.apiLimit);
}
enqueue(request) {
this.queue.push(request);
this.immediateHeat();
}
requeue(request) {
this.queue.unshift(request);
this.immediateHeat();
}
pause() {
this.paused = true;
}
resume() {
this.paused = false;
this.immediateHeat();
}
heat() {
if (this.paused || this.busy || this.queue.length === 0) {
return;
}
this.busy = true;
if (this.api.options.apiRequestMode === 'sequential') {
this.execute();
setTimeout(() => {
this.busy = false;
this.immediateHeat();
}, this.intervalPerRequests);
return;
}
// Burst mode
const limit = Math.min(this.api.options.apiLimit, this.queue.length);
for (let i = 0; i < limit && this.queue.length !== 0; i += 1) {
this.execute();
}
const interval = Math.ceil(MINIMUM_TIME_INTERVAL_API - (limit * this.intervalPerRequests));
setTimeout(() => {
this.busy = false;
this.immediateHeat();
}, interval <= 0
? MINIMUM_TIME_INTERVAL_API
: interval);
}
immediateHeat() {
// Wait next end loop, saves one request or more
setImmediate(() => this.heat());
}
}
/**
* Returns params for execute
*/
const getExecuteParams = (params) => (JSON.stringify(params, (key, value) => (typeof value === 'object' && value !== params
? String(value)
: value)));
/**
* Returns method for execute
*/
const getExecuteMethod = (method, params = {}) => (`API.${method}(${getExecuteParams(params)})`);
/**
* Returns chain for execute
*/
const getChainReturn = (methods) => (`return [${methods.join(',')}];`);
/**
* Resolve task
*/
const resolveExecuteTask = (tasks, result) => {
let errors = 0;
result.response.forEach((response, i) => {
if (response !== false) {
tasks[i].resolve(response);
return;
}
tasks[i].reject(result.errors[errors]);
errors += 1;
});
};
/**
* Returns random ID
*/
const getRandomId = () => (Math.floor(Math.random() * 10000) * Date.now());
/**
* Delay N-ms
*/
const delay = (delayed) => (new Promise((resolve) => {
setTimeout(resolve, delayed);
}));
const lt = /</g;
const qt = />/g;
const br = /<br>/g;
const amp = /&/g;
const quot = /"/g;
/**
* Decodes HTML entities
*/
const unescapeHTML = (text) => (text
.replace(lt, '<')
.replace(qt, '>')
.replace(br, '\n')
.replace(amp, '&')
.replace(quot, '"'));
/**
* Copies object params to new object
*/
const pickProperties = (params, properties) => {
const copies = {};
for (const property of properties) {
copies[property] = params[property];
}
return copies;
};
/**
* Returns peer id type
*/
const getPeerType = (id) => {
if (PEER_CHAT_ID_OFFSET < id) {
return exports.MessageSource.CHAT;
}
if (id < 0) {
return exports.MessageSource.GROUP;
}
return exports.MessageSource.USER;
};
// eslint-disable-next-line max-len
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
const applyMixins = (derivedCtor, baseCtors) => {
for (const baseCtor of baseCtors) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
for (const name of Object.getOwnPropertyNames(baseCtor.prototype)) {
if (name === 'constructor') {
continue;
}
Object.defineProperty(
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
derivedCtor.prototype, name,
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
Object.getOwnPropertyDescriptor(baseCtor.prototype, name));
}
}
};
const debug$4 = createDebug('vk-io:api');
class SequentialW