vak-sms-client 0.0.0-stage → 0.1.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/LICENSE +15 -0
- package/README.md +83 -2
- package/dist/index.d.ts +285 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +370 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 api-kit contributors
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,84 @@
|
|
|
1
|
-
#
|
|
1
|
+
# vak-sms-client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript and Node.js client for the [VAK-SMS API](https://vak-sms.com/en/api/).
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Virtual phone numbers and SMS OTP reception across international countries and operators
|
|
8
|
+
- Complete activation lifecycle management (`send`, `end`, `bad`, and automatic polling)
|
|
9
|
+
- Real-time stock counts and prices per service
|
|
10
|
+
- Written in TypeScript with full type declarations and TSDoc
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install vak-sms-client
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { VakSmsClient } from 'vak-sms-client';
|
|
22
|
+
|
|
23
|
+
const client = new VakSmsClient({
|
|
24
|
+
apiKey: process.env.VAK_SMS_API_KEY!,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
async function main() {
|
|
28
|
+
// Check account balance
|
|
29
|
+
const balance = await client.getBalance();
|
|
30
|
+
console.log(`Account balance: ${balance} RUB`);
|
|
31
|
+
|
|
32
|
+
// List supported countries and network operators
|
|
33
|
+
const countries = await client.getCountryList();
|
|
34
|
+
console.log(`Supported countries count: ${countries.length}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
main().catch(console.error);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Ordering a Virtual Number and Receiving SMS
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { VakSmsClient } from 'vak-sms-client';
|
|
44
|
+
|
|
45
|
+
const client = new VakSmsClient({ apiKey: 'YOUR_API_KEY' });
|
|
46
|
+
|
|
47
|
+
async function activateNumber() {
|
|
48
|
+
// Order a number for Telegram in Russia
|
|
49
|
+
const order = await client.getNumber({
|
|
50
|
+
service: 'tg',
|
|
51
|
+
country: 'ru',
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
console.log(`Phone: ${order.tel}`);
|
|
55
|
+
console.log(`Operation ID: ${order.idNum}`);
|
|
56
|
+
|
|
57
|
+
// Wait for incoming SMS code (polls every 3 seconds up to 2 minutes)
|
|
58
|
+
const code = await client.waitForCode(order.idNum, { timeoutMs: 120000 });
|
|
59
|
+
if (code) {
|
|
60
|
+
console.log(`Received SMS code: ${code}`);
|
|
61
|
+
// Complete activation
|
|
62
|
+
await client.setStatus(order.idNum, 'end');
|
|
63
|
+
} else {
|
|
64
|
+
// If no code arrived, cancel/release the number
|
|
65
|
+
await client.setStatus(order.idNum, 'bad');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## API Methods
|
|
71
|
+
|
|
72
|
+
- `getBalance(): Promise<number>` — Returns the current balance in RUB.
|
|
73
|
+
- `getNumber(options: GetNumberOptions): Promise<VakNumber>` — Orders a virtual phone number.
|
|
74
|
+
- `prolongNumber(service, tel, softId?): Promise<VakNumber>` — Extends the duration of an existing number.
|
|
75
|
+
- `getSmsCode(idNum, all?): Promise<string | string[] | null>` — Retrieves received SMS code(s).
|
|
76
|
+
- `waitForCode(idNum, options?): Promise<string | null>` — Polls until SMS code arrives or times out.
|
|
77
|
+
- `setStatus(idNum, status): Promise<string>` — Updates activation status (`send`, `end`, `bad`).
|
|
78
|
+
- `getCountNumber(service, country?, operator?): Promise<CountNumber>` — Returns quantity and price for a service.
|
|
79
|
+
- `getCountryList(): Promise<CountryOperator[]>` — Retrieves all supported countries and operators.
|
|
80
|
+
- `getCountNumbersList(country?, operator?, rent?): Promise<Record<string, unknown>>` — Retrieves inventory catalog.
|
|
81
|
+
|
|
82
|
+
## License
|
|
83
|
+
|
|
84
|
+
ISC
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default software/affiliate identifier (empty if none assigned).
|
|
3
|
+
*/
|
|
4
|
+
export declare const DEFAULT_SOFT_ID = "";
|
|
5
|
+
/**
|
|
6
|
+
* Configuration options for the VakSmsClient.
|
|
7
|
+
*/
|
|
8
|
+
export interface VakSmsClientOptions {
|
|
9
|
+
/**
|
|
10
|
+
* API key obtained from VAK-SMS dashboard.
|
|
11
|
+
*/
|
|
12
|
+
apiKey: string;
|
|
13
|
+
/**
|
|
14
|
+
* Base URL for the VAK-SMS API. Defaults to https://vak-sms.com.
|
|
15
|
+
*/
|
|
16
|
+
baseURL?: string;
|
|
17
|
+
/**
|
|
18
|
+
* Request timeout in milliseconds. Defaults to 30000 ms.
|
|
19
|
+
*/
|
|
20
|
+
timeout?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Optional partner/software identifier.
|
|
23
|
+
*/
|
|
24
|
+
softId?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for requesting a virtual phone number.
|
|
28
|
+
*/
|
|
29
|
+
export interface GetNumberOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Service code (e.g. 'tg' for Telegram, 'wa' for WhatsApp) or an array of two codes.
|
|
32
|
+
*/
|
|
33
|
+
service: string | string[];
|
|
34
|
+
/**
|
|
35
|
+
* Country code (e.g. 'ru', 'kz', 'ua').
|
|
36
|
+
*/
|
|
37
|
+
country?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Mobile operator name (e.g. 'megafon', 'beeline', 'tele2').
|
|
40
|
+
*/
|
|
41
|
+
operator?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to order a prolonged rental number (e.g. 4 hours).
|
|
44
|
+
*/
|
|
45
|
+
rent?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Optional partner/software ID override.
|
|
48
|
+
*/
|
|
49
|
+
softId?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Acquired virtual phone number details.
|
|
53
|
+
*/
|
|
54
|
+
export interface VakNumber {
|
|
55
|
+
/**
|
|
56
|
+
* Full phone number with country dial code.
|
|
57
|
+
*/
|
|
58
|
+
tel: string | number;
|
|
59
|
+
/**
|
|
60
|
+
* Unique operation/order identifier.
|
|
61
|
+
*/
|
|
62
|
+
idNum: string;
|
|
63
|
+
/**
|
|
64
|
+
* Service code requested.
|
|
65
|
+
*/
|
|
66
|
+
service?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Whether the number was leased under a prolonged rental.
|
|
69
|
+
*/
|
|
70
|
+
rent?: boolean;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Available number count and unit price for a service.
|
|
74
|
+
*/
|
|
75
|
+
export interface CountNumber {
|
|
76
|
+
/**
|
|
77
|
+
* Service short code.
|
|
78
|
+
*/
|
|
79
|
+
service: string;
|
|
80
|
+
/**
|
|
81
|
+
* Number of available phone numbers currently in stock.
|
|
82
|
+
*/
|
|
83
|
+
count: number;
|
|
84
|
+
/**
|
|
85
|
+
* Unit cost per activation.
|
|
86
|
+
*/
|
|
87
|
+
price?: number;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Supported country metadata and available operators.
|
|
91
|
+
*/
|
|
92
|
+
export interface CountryOperator {
|
|
93
|
+
/**
|
|
94
|
+
* Human-readable country name.
|
|
95
|
+
*/
|
|
96
|
+
countryName: string;
|
|
97
|
+
/**
|
|
98
|
+
* Country 2-letter ISO code.
|
|
99
|
+
*/
|
|
100
|
+
countryCode: string;
|
|
101
|
+
/**
|
|
102
|
+
* List of supported mobile network operators.
|
|
103
|
+
*/
|
|
104
|
+
operatorList: string[];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Error dictionary for known VAK-SMS error codes.
|
|
108
|
+
*/
|
|
109
|
+
export declare const VAK_SMS_ERROR_DESCRIPTIONS: Record<string, string>;
|
|
110
|
+
/**
|
|
111
|
+
* Error thrown by the VAK-SMS client when API calls fail.
|
|
112
|
+
*/
|
|
113
|
+
export declare class VakSmsError extends Error {
|
|
114
|
+
/**
|
|
115
|
+
* Error code identifier returned by VAK-SMS.
|
|
116
|
+
*/
|
|
117
|
+
readonly code?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Raw response payload from the server.
|
|
120
|
+
*/
|
|
121
|
+
readonly responseBody?: unknown;
|
|
122
|
+
constructor(message: string, code?: string, responseBody?: unknown);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Client for the VAK-SMS temporary number and SMS OTP receiving service.
|
|
126
|
+
*/
|
|
127
|
+
export declare class VakSmsClient {
|
|
128
|
+
private readonly apiKey;
|
|
129
|
+
private readonly softId;
|
|
130
|
+
private readonly http;
|
|
131
|
+
/**
|
|
132
|
+
* Creates a new VakSmsClient.
|
|
133
|
+
*
|
|
134
|
+
* @param options - API key string or configuration object.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* import { VakSmsClient } from 'vak-sms-client';
|
|
139
|
+
*
|
|
140
|
+
* const client = new VakSmsClient({ apiKey: 'YOUR_API_KEY' });
|
|
141
|
+
* const balance = await client.getBalance();
|
|
142
|
+
* console.log(`Balance: ${balance} RUB`);
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
constructor(options: VakSmsClientOptions | string);
|
|
146
|
+
/**
|
|
147
|
+
* Retrieves the current account balance.
|
|
148
|
+
*
|
|
149
|
+
* @returns Current balance in RUB.
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* const balance = await client.getBalance();
|
|
154
|
+
* console.log(`Current balance: ${balance}`);
|
|
155
|
+
* ```
|
|
156
|
+
*/
|
|
157
|
+
getBalance(): Promise<number>;
|
|
158
|
+
/**
|
|
159
|
+
* Requests a temporary virtual phone number.
|
|
160
|
+
*
|
|
161
|
+
* @param options - Order parameters including service, country, operator, and rental status.
|
|
162
|
+
* @returns Number details with idNum and phone number.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const order = await client.getNumber({
|
|
167
|
+
* service: 'tg',
|
|
168
|
+
* country: 'ru',
|
|
169
|
+
* });
|
|
170
|
+
* console.log(`Phone: ${order.tel}, ID: ${order.idNum}`);
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
getNumber(options: GetNumberOptions): Promise<VakNumber>;
|
|
174
|
+
/**
|
|
175
|
+
* Extends the rental duration for an existing number.
|
|
176
|
+
*
|
|
177
|
+
* @param service - Service code.
|
|
178
|
+
* @param tel - Phone number without plus sign (e.g. 79991234567).
|
|
179
|
+
* @param softId - Optional software referral ID.
|
|
180
|
+
* @returns Prolonged number details.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* const res = await client.prolongNumber('tg', '79991234567');
|
|
185
|
+
* console.log(`Prolonged ID: ${res.idNum}`);
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
prolongNumber(service: string, tel: string | number, softId?: string): Promise<VakNumber>;
|
|
189
|
+
/**
|
|
190
|
+
* Retrieves incoming SMS code(s) for an active order.
|
|
191
|
+
*
|
|
192
|
+
* @param idNum - Activation ID returned by getNumber.
|
|
193
|
+
* @param all - Whether to return an array of all received codes.
|
|
194
|
+
* @returns Code string, array of codes, or null if code not yet arrived.
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* const code = await client.getSmsCode('abcd1234ef');
|
|
199
|
+
* if (code) {
|
|
200
|
+
* console.log('Received SMS code:', code);
|
|
201
|
+
* }
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
getSmsCode(idNum: string, all?: boolean): Promise<string | string[] | null>;
|
|
205
|
+
/**
|
|
206
|
+
* Polls until an SMS code arrives or timeout occurs.
|
|
207
|
+
*
|
|
208
|
+
* @param idNum - Activation identifier.
|
|
209
|
+
* @param options - Polling options with timeoutMs (default 120s) and intervalMs (default 3s).
|
|
210
|
+
* @returns Code string or null on timeout.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const code = await client.waitForCode('abcd1234ef', { timeoutMs: 60000 });
|
|
215
|
+
* console.log('Code:', code);
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
waitForCode(idNum: string, options?: {
|
|
219
|
+
timeoutMs?: number;
|
|
220
|
+
intervalMs?: number;
|
|
221
|
+
}): Promise<string | null>;
|
|
222
|
+
/**
|
|
223
|
+
* Updates activation status.
|
|
224
|
+
*
|
|
225
|
+
* Status actions:
|
|
226
|
+
* - 'send': Ready to receive another SMS code
|
|
227
|
+
* - 'end': Successfully complete the activation
|
|
228
|
+
* - 'bad': Ban/report number as defective to release it
|
|
229
|
+
*
|
|
230
|
+
* @param idNum - Activation identifier.
|
|
231
|
+
* @param status - Action name ('send', 'end', 'bad').
|
|
232
|
+
* @returns Status response string.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```typescript
|
|
236
|
+
* await client.setStatus('abcd1234ef', 'end');
|
|
237
|
+
* console.log('Activation completed');
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
setStatus(idNum: string, status: 'send' | 'end' | 'bad'): Promise<string>;
|
|
241
|
+
/**
|
|
242
|
+
* Checks available phone number quantity and price for a service.
|
|
243
|
+
*
|
|
244
|
+
* @param service - Service code.
|
|
245
|
+
* @param country - Country code (default: 'ru').
|
|
246
|
+
* @param operator - Optional mobile operator filter.
|
|
247
|
+
* @returns Quantity and unit price.
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* ```typescript
|
|
251
|
+
* const count = await client.getCountNumber('tg', 'ru');
|
|
252
|
+
* console.log(`Available: ${count.count}, Price: ${count.price} RUB`);
|
|
253
|
+
* ```
|
|
254
|
+
*/
|
|
255
|
+
getCountNumber(service: string, country?: string, operator?: string): Promise<CountNumber>;
|
|
256
|
+
/**
|
|
257
|
+
* Retrieves the catalog of supported countries and operators.
|
|
258
|
+
*
|
|
259
|
+
* @returns List of country and operator listings.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const countries = await client.getCountryList();
|
|
264
|
+
* console.log(`Supported countries: ${countries.length}`);
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
getCountryList(): Promise<CountryOperator[]>;
|
|
268
|
+
/**
|
|
269
|
+
* Retrieves full catalog of available services and stock for a country.
|
|
270
|
+
*
|
|
271
|
+
* @param country - Country code (default 'ru').
|
|
272
|
+
* @param operator - Optional mobile operator filter.
|
|
273
|
+
* @param rent - Whether to query prolonged rental service stock.
|
|
274
|
+
* @returns Map of services and stock.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* const catalog = await client.getCountNumbersList('ru');
|
|
279
|
+
* console.log(catalog);
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
getCountNumbersList(country?: string, operator?: string, rent?: boolean): Promise<Record<string, unknown>>;
|
|
283
|
+
private request;
|
|
284
|
+
}
|
|
285
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,eAAe,KAAK,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,EAAE,M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Aa,CACjB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,GAAG,MAAM,EACpB,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,SAAS,CAAC;IAyBrB;;;;;;;;;;;;;;OAcG;IACG,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IAcjF;;;;;;;;;;;;OAYG;IACG,WAAW,CACf,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GACpD,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAkBzB;;;;;;;;;;;;;;;;;OAiBG;IACG,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAY/E;;;;;;;;;;;;;OAaG;IACG,cAAc,CAClB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,MAAa,EACtB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,WAAW,CAAC;IAwBvB;;;;;;;;;;OAUG;IACG,cAAc,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAQlD;;;;;;;;;;;;;OAaG;IACG,mBAAmB,CACvB,OAAO,GAAE,MAAa,EACtB,QAAQ,CAAC,EAAE,MAAM,EACjB,IAAI,CAAC,EAAE,OAAO,GACb,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAcrB,OAAO;CAmCtB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.VakSmsClient = exports.VakSmsError = exports.VAK_SMS_ERROR_DESCRIPTIONS = exports.DEFAULT_SOFT_ID = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
/**
|
|
9
|
+
* Default software/affiliate identifier (empty if none assigned).
|
|
10
|
+
*/
|
|
11
|
+
exports.DEFAULT_SOFT_ID = '';
|
|
12
|
+
/**
|
|
13
|
+
* Error dictionary for known VAK-SMS error codes.
|
|
14
|
+
*/
|
|
15
|
+
exports.VAK_SMS_ERROR_DESCRIPTIONS = {
|
|
16
|
+
apiKeyNotFound: 'API key not found',
|
|
17
|
+
noService: 'Service not found or invalid',
|
|
18
|
+
noNumber: 'No numbers available, try again later',
|
|
19
|
+
noMoney: 'Insufficient funds, please top up balance',
|
|
20
|
+
noCountry: 'Country not found',
|
|
21
|
+
noOperator: 'No operator was found for the requested country',
|
|
22
|
+
badStatus: 'Status not correct',
|
|
23
|
+
idNumNotFound: 'idNum not found',
|
|
24
|
+
badService: 'Incorrect website or service code',
|
|
25
|
+
badData: 'Invalid request data sent',
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Error thrown by the VAK-SMS client when API calls fail.
|
|
29
|
+
*/
|
|
30
|
+
class VakSmsError extends Error {
|
|
31
|
+
/**
|
|
32
|
+
* Error code identifier returned by VAK-SMS.
|
|
33
|
+
*/
|
|
34
|
+
code;
|
|
35
|
+
/**
|
|
36
|
+
* Raw response payload from the server.
|
|
37
|
+
*/
|
|
38
|
+
responseBody;
|
|
39
|
+
constructor(message, code, responseBody) {
|
|
40
|
+
super(message);
|
|
41
|
+
this.name = 'VakSmsError';
|
|
42
|
+
this.code = code;
|
|
43
|
+
this.responseBody = responseBody;
|
|
44
|
+
Object.setPrototypeOf(this, VakSmsError.prototype);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.VakSmsError = VakSmsError;
|
|
48
|
+
/**
|
|
49
|
+
* Client for the VAK-SMS temporary number and SMS OTP receiving service.
|
|
50
|
+
*/
|
|
51
|
+
class VakSmsClient {
|
|
52
|
+
apiKey;
|
|
53
|
+
softId;
|
|
54
|
+
http;
|
|
55
|
+
/**
|
|
56
|
+
* Creates a new VakSmsClient.
|
|
57
|
+
*
|
|
58
|
+
* @param options - API key string or configuration object.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* import { VakSmsClient } from 'vak-sms-client';
|
|
63
|
+
*
|
|
64
|
+
* const client = new VakSmsClient({ apiKey: 'YOUR_API_KEY' });
|
|
65
|
+
* const balance = await client.getBalance();
|
|
66
|
+
* console.log(`Balance: ${balance} RUB`);
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
constructor(options) {
|
|
70
|
+
if (typeof options === 'string') {
|
|
71
|
+
this.apiKey = options.trim();
|
|
72
|
+
this.softId = exports.DEFAULT_SOFT_ID;
|
|
73
|
+
this.http = axios_1.default.create({
|
|
74
|
+
baseURL: 'https://vak-sms.com',
|
|
75
|
+
timeout: 30000,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
if (!options || !options.apiKey || !options.apiKey.trim()) {
|
|
80
|
+
throw new VakSmsError('API key is required to initialize VakSmsClient', 'apiKeyNotFound');
|
|
81
|
+
}
|
|
82
|
+
this.apiKey = options.apiKey.trim();
|
|
83
|
+
this.softId = options.softId ?? exports.DEFAULT_SOFT_ID;
|
|
84
|
+
this.http = axios_1.default.create({
|
|
85
|
+
baseURL: options.baseURL || 'https://vak-sms.com',
|
|
86
|
+
timeout: options.timeout || 30000,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Retrieves the current account balance.
|
|
92
|
+
*
|
|
93
|
+
* @returns Current balance in RUB.
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* const balance = await client.getBalance();
|
|
98
|
+
* console.log(`Current balance: ${balance}`);
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
async getBalance() {
|
|
102
|
+
const data = (await this.request('/api/getBalance/'));
|
|
103
|
+
if (typeof data === 'object' && data !== null && typeof data.balance === 'number') {
|
|
104
|
+
return data.balance;
|
|
105
|
+
}
|
|
106
|
+
throw new VakSmsError('Invalid getBalance response', 'INVALID_RESPONSE', data);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Requests a temporary virtual phone number.
|
|
110
|
+
*
|
|
111
|
+
* @param options - Order parameters including service, country, operator, and rental status.
|
|
112
|
+
* @returns Number details with idNum and phone number.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const order = await client.getNumber({
|
|
117
|
+
* service: 'tg',
|
|
118
|
+
* country: 'ru',
|
|
119
|
+
* });
|
|
120
|
+
* console.log(`Phone: ${order.tel}, ID: ${order.idNum}`);
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
async getNumber(options) {
|
|
124
|
+
const service = Array.isArray(options.service) ? options.service.join(',') : options.service;
|
|
125
|
+
const params = {
|
|
126
|
+
service,
|
|
127
|
+
};
|
|
128
|
+
if (options.country)
|
|
129
|
+
params.country = options.country;
|
|
130
|
+
if (options.operator)
|
|
131
|
+
params.operator = options.operator;
|
|
132
|
+
if (options.rent)
|
|
133
|
+
params.rent = 'true';
|
|
134
|
+
const softId = options.softId ?? this.softId;
|
|
135
|
+
if (softId)
|
|
136
|
+
params.softId = softId;
|
|
137
|
+
const data = (await this.request('/api/getNumber/', params));
|
|
138
|
+
if (data && data.idNum && data.tel) {
|
|
139
|
+
return {
|
|
140
|
+
idNum: String(data.idNum),
|
|
141
|
+
tel: data.tel,
|
|
142
|
+
service,
|
|
143
|
+
rent: options.rent,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
throw new VakSmsError('Invalid getNumber response', 'INVALID_RESPONSE', data);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Extends the rental duration for an existing number.
|
|
150
|
+
*
|
|
151
|
+
* @param service - Service code.
|
|
152
|
+
* @param tel - Phone number without plus sign (e.g. 79991234567).
|
|
153
|
+
* @param softId - Optional software referral ID.
|
|
154
|
+
* @returns Prolonged number details.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* const res = await client.prolongNumber('tg', '79991234567');
|
|
159
|
+
* console.log(`Prolonged ID: ${res.idNum}`);
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
async prolongNumber(service, tel, softId) {
|
|
163
|
+
const params = {
|
|
164
|
+
service,
|
|
165
|
+
tel,
|
|
166
|
+
};
|
|
167
|
+
const effectiveSoftId = softId ?? this.softId;
|
|
168
|
+
if (effectiveSoftId)
|
|
169
|
+
params.softId = effectiveSoftId;
|
|
170
|
+
const data = (await this.request('/api/prolongNumber/', params));
|
|
171
|
+
if (data && data.idNum && data.tel) {
|
|
172
|
+
return {
|
|
173
|
+
idNum: String(data.idNum),
|
|
174
|
+
tel: data.tel,
|
|
175
|
+
service,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
throw new VakSmsError('Invalid prolongNumber response', 'INVALID_RESPONSE', data);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Retrieves incoming SMS code(s) for an active order.
|
|
182
|
+
*
|
|
183
|
+
* @param idNum - Activation ID returned by getNumber.
|
|
184
|
+
* @param all - Whether to return an array of all received codes.
|
|
185
|
+
* @returns Code string, array of codes, or null if code not yet arrived.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* const code = await client.getSmsCode('abcd1234ef');
|
|
190
|
+
* if (code) {
|
|
191
|
+
* console.log('Received SMS code:', code);
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
async getSmsCode(idNum, all) {
|
|
196
|
+
const params = { idNum };
|
|
197
|
+
if (all)
|
|
198
|
+
params.all = 'true';
|
|
199
|
+
const data = (await this.request('/api/getSmsCode/', params));
|
|
200
|
+
if (data && 'smsCode' in data) {
|
|
201
|
+
return data.smsCode ?? null;
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Polls until an SMS code arrives or timeout occurs.
|
|
207
|
+
*
|
|
208
|
+
* @param idNum - Activation identifier.
|
|
209
|
+
* @param options - Polling options with timeoutMs (default 120s) and intervalMs (default 3s).
|
|
210
|
+
* @returns Code string or null on timeout.
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const code = await client.waitForCode('abcd1234ef', { timeoutMs: 60000 });
|
|
215
|
+
* console.log('Code:', code);
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
async waitForCode(idNum, options) {
|
|
219
|
+
const timeoutMs = options?.timeoutMs ?? 120000;
|
|
220
|
+
const intervalMs = options?.intervalMs ?? 3000;
|
|
221
|
+
const start = Date.now();
|
|
222
|
+
while (Date.now() - start < timeoutMs) {
|
|
223
|
+
const res = await this.getSmsCode(idNum);
|
|
224
|
+
if (res) {
|
|
225
|
+
if (Array.isArray(res)) {
|
|
226
|
+
return res[res.length - 1] ?? null;
|
|
227
|
+
}
|
|
228
|
+
return res;
|
|
229
|
+
}
|
|
230
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
231
|
+
}
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Updates activation status.
|
|
236
|
+
*
|
|
237
|
+
* Status actions:
|
|
238
|
+
* - 'send': Ready to receive another SMS code
|
|
239
|
+
* - 'end': Successfully complete the activation
|
|
240
|
+
* - 'bad': Ban/report number as defective to release it
|
|
241
|
+
*
|
|
242
|
+
* @param idNum - Activation identifier.
|
|
243
|
+
* @param status - Action name ('send', 'end', 'bad').
|
|
244
|
+
* @returns Status response string.
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```typescript
|
|
248
|
+
* await client.setStatus('abcd1234ef', 'end');
|
|
249
|
+
* console.log('Activation completed');
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
async setStatus(idNum, status) {
|
|
253
|
+
const data = (await this.request('/api/setStatus/', {
|
|
254
|
+
idNum,
|
|
255
|
+
status,
|
|
256
|
+
}));
|
|
257
|
+
if (data && typeof data.status === 'string') {
|
|
258
|
+
return data.status;
|
|
259
|
+
}
|
|
260
|
+
return 'ok';
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Checks available phone number quantity and price for a service.
|
|
264
|
+
*
|
|
265
|
+
* @param service - Service code.
|
|
266
|
+
* @param country - Country code (default: 'ru').
|
|
267
|
+
* @param operator - Optional mobile operator filter.
|
|
268
|
+
* @returns Quantity and unit price.
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```typescript
|
|
272
|
+
* const count = await client.getCountNumber('tg', 'ru');
|
|
273
|
+
* console.log(`Available: ${count.count}, Price: ${count.price} RUB`);
|
|
274
|
+
* ```
|
|
275
|
+
*/
|
|
276
|
+
async getCountNumber(service, country = 'ru', operator) {
|
|
277
|
+
const params = {
|
|
278
|
+
service,
|
|
279
|
+
country,
|
|
280
|
+
price: 1,
|
|
281
|
+
};
|
|
282
|
+
if (operator)
|
|
283
|
+
params.operator = operator;
|
|
284
|
+
const data = (await this.request('/api/getCountNumber/', params));
|
|
285
|
+
if (data && typeof data === 'object') {
|
|
286
|
+
const countVal = data[service];
|
|
287
|
+
const count = typeof countVal === 'number' ? countVal : 0;
|
|
288
|
+
const price = typeof data.price === 'number' ? data.price : undefined;
|
|
289
|
+
return {
|
|
290
|
+
service,
|
|
291
|
+
count,
|
|
292
|
+
price,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
throw new VakSmsError('Invalid getCountNumber response', 'INVALID_RESPONSE', data);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Retrieves the catalog of supported countries and operators.
|
|
299
|
+
*
|
|
300
|
+
* @returns List of country and operator listings.
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```typescript
|
|
304
|
+
* const countries = await client.getCountryList();
|
|
305
|
+
* console.log(`Supported countries: ${countries.length}`);
|
|
306
|
+
* ```
|
|
307
|
+
*/
|
|
308
|
+
async getCountryList() {
|
|
309
|
+
const data = await this.request('/api/getCountryList/');
|
|
310
|
+
if (Array.isArray(data)) {
|
|
311
|
+
return data;
|
|
312
|
+
}
|
|
313
|
+
throw new VakSmsError('Invalid getCountryList response', 'INVALID_RESPONSE', data);
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Retrieves full catalog of available services and stock for a country.
|
|
317
|
+
*
|
|
318
|
+
* @param country - Country code (default 'ru').
|
|
319
|
+
* @param operator - Optional mobile operator filter.
|
|
320
|
+
* @param rent - Whether to query prolonged rental service stock.
|
|
321
|
+
* @returns Map of services and stock.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* ```typescript
|
|
325
|
+
* const catalog = await client.getCountNumbersList('ru');
|
|
326
|
+
* console.log(catalog);
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
async getCountNumbersList(country = 'ru', operator, rent) {
|
|
330
|
+
const params = {
|
|
331
|
+
country,
|
|
332
|
+
};
|
|
333
|
+
if (operator)
|
|
334
|
+
params.operator = operator;
|
|
335
|
+
if (rent)
|
|
336
|
+
params.rent = 'true';
|
|
337
|
+
const data = (await this.request('/api/getCountNumbersList/', params));
|
|
338
|
+
return data && typeof data === 'object' ? data : {};
|
|
339
|
+
}
|
|
340
|
+
async request(endpoint, params = {}) {
|
|
341
|
+
try {
|
|
342
|
+
const response = await this.http.get(endpoint, {
|
|
343
|
+
params: {
|
|
344
|
+
apiKey: this.apiKey,
|
|
345
|
+
...params,
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
const data = response.data;
|
|
349
|
+
if (data && typeof data === 'object') {
|
|
350
|
+
if ('error' in data && data.error) {
|
|
351
|
+
const errCode = String(data.error);
|
|
352
|
+
const desc = exports.VAK_SMS_ERROR_DESCRIPTIONS[errCode] || `VAK-SMS API error: ${errCode}`;
|
|
353
|
+
throw new VakSmsError(desc, errCode, data);
|
|
354
|
+
}
|
|
355
|
+
if ('code' in data && data.code && 'message' in data) {
|
|
356
|
+
throw new VakSmsError(String(data.message), String(data.code), data);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return data;
|
|
360
|
+
}
|
|
361
|
+
catch (err) {
|
|
362
|
+
if (err instanceof VakSmsError) {
|
|
363
|
+
throw err;
|
|
364
|
+
}
|
|
365
|
+
throw new VakSmsError(`VAK-SMS request failed: ${err instanceof Error ? err.message : String(err)}`, 'NETWORK_ERROR');
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
exports.VakSmsClient = VakSmsClient;
|
|
370
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA6C;AAE7C;;GAEG;AACU,QAAA,eAAe,GAAG,EAAE,CAAC;AA4GlC;;GAEG;AACU,QAAA,0BAA0B,GAA2B;IAChE,cAAc,EAAE,mBAAmB;IACnC,SAAS,EAAE,8BAA8B;IACzC,QAAQ,EAAE,uCAAuC;IACjD,OAAO,EAAE,2CAA2C;IACpD,SAAS,EAAE,mBAAmB;IAC9B,UAAU,EAAE,iDAAiD;IAC7D,SAAS,EAAE,oBAAoB;IAC/B,aAAa,EAAE,iBAAiB;IAChC,UAAU,EAAE,mCAAmC;IAC/C,OAAO,EAAE,2BAA2B;CACrC,CAAC;AAEF;;GAEG;AACH,MAAa,WAAY,SAAQ,KAAK;IACpC;;OAEG;IACM,IAAI,CAAU;IACvB;;OAEG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,IAAI,IAAI,EAAE,CAAC;oBACrD,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;gBACvE,CAAC;YACH,CAAC;YAED,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,IAAI,GAAG,YAAY,WAAW,EAAE,CAAC;gBAC/B,MAAM,GAAG,CAAC;YACZ,CAAC;YACD,MAAM,IAAI,WAAW,CACnB,2BAA2B,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAC7E,eAAe,CAChB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAjXD,oCAiXC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vak-sms-client",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript client for the VAK-SMS virtual number and SMS activation API",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc -p tsconfig.json",
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"test:live": "jest --testPathPattern=test/live --testPathIgnorePatterns=/node_modules/",
|
|
20
|
+
"docs": "typedoc --options typedoc.json"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/TysikGG/api-kit.git",
|
|
25
|
+
"directory": "vak-sms/js"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"vak-sms",
|
|
29
|
+
"vaksms",
|
|
30
|
+
"sms-activation",
|
|
31
|
+
"virtual-numbers",
|
|
32
|
+
"sms-verification",
|
|
33
|
+
"otp"
|
|
34
|
+
],
|
|
35
|
+
"license": "ISC",
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"axios": "^1.20.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@types/jest": "^29.5.14",
|
|
44
|
+
"@types/node": "^22.10.2",
|
|
45
|
+
"axios-mock-adapter": "^2.1.0",
|
|
46
|
+
"jest": "^29.7.0",
|
|
47
|
+
"ts-jest": "^29.2.5",
|
|
48
|
+
"typedoc": "^0.28.1",
|
|
49
|
+
"typedoc-plugin-markdown": "^4.6.0",
|
|
50
|
+
"typescript": "^5.7.2"
|
|
51
|
+
}
|
|
52
|
+
}
|