proxy302-sdk 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.
@@ -0,0 +1,113 @@
1
+ /** Errors carry a stable code and one plain-language next step. */
2
+ const ZH = {
3
+ no_key: { what: '没有传 API 密钥', next: '请到 proxy302.com 的「API 密钥」页创建密钥,再用 apiKey 传入' },
4
+ invalid_key: { what: 'API 密钥格式不对', next: '格式是「密钥 ID:密钥」,或 p302_ 加 32 位字母、数字、_、-。请到 proxy302.com 的「API 密钥」页重新复制或新建密钥' },
5
+ bad_argument: { what: '参数不对', next: '请按提示改正参数' },
6
+ unauthorized: { what: 'API 密钥无效或已删除', next: '请到 proxy302.com 的「API 密钥」页核对或新建密钥' },
7
+ account_not_linked: { what: '这个密钥还没有关联 Proxy302 账号', next: '请用 Proxy302 账号登录控制台重新创建密钥,仍不行请联系 Proxy302 客服' },
8
+ not_found: { what: '没有找到这条记录', next: '请核对编号,并确认它属于当前账号' },
9
+ invalid_request: { what: '请求参数没有通过校验', next: '请按接口返回的说明改正参数' },
10
+ conflict: { what: '与现有设置冲突', next: '请刷新数据后再试' },
11
+ rate_limited: { what: '请求太频繁', next: '请等一分钟再试' },
12
+ insufficient_balance: { what: '余额不足', next: '请到 proxy302.com 充值' },
13
+ no_traffic_package: { what: '这个档位没有可用的流量包', next: '请到 proxy302.com 购买流量包,或改用钱包按量计费' },
14
+ ip_unavailable: { what: '这个地区暂时没有可用的 IP', next: '请换一个国家、州或城市,或稍后再试' },
15
+ not_ready: { what: '连接还在准备', next: '请等 10 秒,用同一个 idempotencyKey 再调用一次' },
16
+ idempotency_conflict: { what: '这个防重复编号已经用过,这次的参数和第一次不同', next: '请改回第一次的参数,或换一个新的 idempotencyKey' },
17
+ feature_unavailable: { what: '这个功能暂未开放', next: '请联系 Proxy302 客服' },
18
+ service_unavailable: { what: '服务暂时不可用', next: '请稍后再试,持续出现请联系 Proxy302 客服' },
19
+ state_conflict: { what: '状态刚刚被别处改动', next: '请再调用一次' },
20
+ network: { what: '连不上 Proxy302', next: '请检查网络后再试' },
21
+ timeout: { what: 'Proxy302 没有在限定时间内回应', next: '请稍后再试' },
22
+ bad_response: { what: 'Proxy302 返回了无法识别的内容', next: '请稍后再试,持续出现请联系 Proxy302 客服' },
23
+ api_error: { what: '请求没有成功', next: '请看 apiMessage,或联系 Proxy302 客服' },
24
+ };
25
+ const EN = {
26
+ no_key: { what: 'No API key', next: 'Create a key on the API keys page of proxy302.com and pass it as apiKey' },
27
+ invalid_key: { what: 'The API key is malformed', next: 'It is <key id>:<secret>, or p302_ followed by 32 letters, digits, _ or -. Copy it again or create a new one on the API keys page of proxy302.com' },
28
+ bad_argument: { what: 'Invalid argument', next: 'Fix the argument named above' },
29
+ unauthorized: { what: 'The API key is wrong or was deleted', next: 'Check it or create a new one on the API keys page of proxy302.com' },
30
+ account_not_linked: { what: 'This key is not linked to a Proxy302 account yet', next: 'Sign in to the Proxy302 console and create a new key, or contact Proxy302 support' },
31
+ not_found: { what: 'Not found', next: 'Check the id and that it belongs to this account' },
32
+ invalid_request: { what: 'The request was refused', next: 'Fix the field named in the message' },
33
+ conflict: { what: 'This conflicts with the current settings', next: 'Refresh and try again' },
34
+ rate_limited: { what: 'Too many requests', next: 'Wait a minute and try again' },
35
+ insufficient_balance: { what: 'Insufficient balance', next: 'Top up at proxy302.com' },
36
+ no_traffic_package: { what: 'No traffic package for this line', next: 'Buy one at proxy302.com or bill the wallet as you go' },
37
+ ip_unavailable: { what: 'No IP is available for this place right now', next: 'Choose another country, state or city, or try later' },
38
+ not_ready: { what: 'The connection is still being prepared', next: 'Wait 10 seconds and call again with the same idempotencyKey' },
39
+ idempotency_conflict: { what: 'This idempotency key was already used with different parameters', next: 'Use the parameters of the first call, or a new idempotencyKey' },
40
+ feature_unavailable: { what: 'This feature is not available', next: 'Contact Proxy302 support' },
41
+ service_unavailable: { what: 'The service is temporarily unavailable', next: 'Try again later; contact Proxy302 support if it persists' },
42
+ state_conflict: { what: 'The state was changed elsewhere a moment ago', next: 'Call again' },
43
+ network: { what: 'Could not reach Proxy302', next: 'Check the network and try again' },
44
+ timeout: { what: 'Proxy302 did not answer in time', next: 'Try again later' },
45
+ bad_response: { what: 'Proxy302 returned an unexpected answer', next: 'Try again later; contact Proxy302 support if it persists' },
46
+ api_error: { what: 'The request failed', next: 'See apiMessage, or contact Proxy302 support' },
47
+ };
48
+ /** After a purchase or renewal without an answer the order may have gone through. */
49
+ const UNSURE = {
50
+ zh: '订单可能已经成功:请用同一个 idempotencyKey 再调用一次,不会重复扣款',
51
+ en: 'The order may have gone through: call again with the same idempotencyKey, you are not charged twice',
52
+ };
53
+ export class Proxy302Error extends Error {
54
+ code;
55
+ /** One sentence for the user: what to do next. */
56
+ nextStep;
57
+ /** Envelope code and text of the API, for logs. */
58
+ apiCode;
59
+ apiMessage;
60
+ httpStatus;
61
+ /** Set on purchases and renewals: call again with it and the order is not placed twice. */
62
+ idempotencyKey;
63
+ constructor(code, info = {}) {
64
+ const lang = info.lang ?? 'zh';
65
+ const text = (lang === 'en' ? EN : ZH)[code];
66
+ const unsure = info.idempotencyKey && ['network', 'timeout', 'bad_response', 'service_unavailable'].includes(code);
67
+ const next = unsure ? UNSURE[lang] : text.next;
68
+ super(lang === 'en'
69
+ ? `${text.what}${info.detail ? ` (${info.detail})` : ''}. ${next}.`
70
+ : `${text.what}${info.detail ? `(${info.detail})` : ''},${next}。`);
71
+ this.name = 'Proxy302Error';
72
+ this.code = code;
73
+ this.nextStep = next;
74
+ this.apiCode = info.apiCode;
75
+ this.apiMessage = info.apiMessage;
76
+ this.httpStatus = info.httpStatus;
77
+ this.idempotencyKey = info.idempotencyKey;
78
+ }
79
+ /** True when the same call can succeed later (purchases: with the same idempotencyKey). */
80
+ get retryable() {
81
+ return ['network', 'timeout', 'bad_response', 'service_unavailable', 'rate_limited', 'not_ready', 'state_conflict'].includes(this.code);
82
+ }
83
+ }
84
+ /** Maps an API envelope (code, msg) to an error code. Business refusals share one envelope code, so the text decides. */
85
+ export function classify(apiCode, msg) {
86
+ if (apiCode === 401)
87
+ return 'unauthorized';
88
+ if (/legacy MySQL identity/i.test(msg))
89
+ return 'account_not_linked';
90
+ if (/^A matching prepaid traffic package is required|^No matching traffic package|^No unexpired traffic pool/i.test(msg))
91
+ return 'no_traffic_package';
92
+ if (/insufficient\b.*\bbalance|balance insufficient/i.test(msg))
93
+ return 'insufficient_balance';
94
+ if (/^Requested (static )?IP is unavailable|^No dynamic IP is available|^No fixed static traffic IP/i.test(msg))
95
+ return 'ip_unavailable';
96
+ if (/credential is not ready/i.test(msg))
97
+ return 'not_ready';
98
+ if (/idempotency conflict/i.test(msg))
99
+ return 'idempotency_conflict';
100
+ if (/writes are not configured/i.test(msg))
101
+ return 'feature_unavailable';
102
+ if (apiCode === 404)
103
+ return 'not_found';
104
+ if (apiCode === 400 || apiCode === 422)
105
+ return 'invalid_request';
106
+ if (apiCode === 409)
107
+ return 'conflict';
108
+ if (apiCode === 429)
109
+ return 'rate_limited';
110
+ if (apiCode === 503)
111
+ return 'service_unavailable';
112
+ return 'api_error';
113
+ }
@@ -0,0 +1,45 @@
1
+ /** Transport for the Proxy302 open API (/open_api/v3). Answers are HTTP 200 with {code, msg, data}; success is code 0. */
2
+ import { Proxy302Error, type ErrorCode, type ErrorInfo, type Lang } from './errors.js';
3
+ export declare const CLIENT_ID = "proxy302-sdk-js/0.1.0";
4
+ export interface TransportOptions {
5
+ /** "<key id>:<secret>", a "p302_" key (p302_ and 32 characters), or a ready "Basic ..." / "Bearer ..." value. */
6
+ apiKey?: string | undefined;
7
+ /** Use together with apiKey when apiKey holds only the key id. */
8
+ apiSecret?: string | undefined;
9
+ baseUrl?: string | undefined;
10
+ /** Language of error messages. Default zh. */
11
+ lang?: Lang | undefined;
12
+ /** Timeout of queries. Default 20000. */
13
+ timeoutMs?: number | undefined;
14
+ /** Timeout of purchases and other changes. Default 60000. */
15
+ writeTimeoutMs?: number | undefined;
16
+ /** Extra attempts for queries after a network failure. Purchases and renewals are never repeated. Default 2. */
17
+ queryRetries?: number | undefined;
18
+ /** First wait between attempts; doubles each time. Default 300. */
19
+ retryDelayMs?: number | undefined;
20
+ fetchImpl?: typeof fetch | undefined;
21
+ }
22
+ export declare function buildAuthorization(apiKey: string | undefined, apiSecret?: string, lang?: Lang): string;
23
+ export type Query = Record<string, string | number | undefined>;
24
+ export interface RequestOptions {
25
+ query?: Query | undefined;
26
+ body?: Record<string, unknown> | undefined;
27
+ headers?: Record<string, string> | undefined;
28
+ /** Attached to errors so that the caller can repeat the order safely. */
29
+ idempotencyKey?: string | undefined;
30
+ }
31
+ export declare class Transport {
32
+ readonly baseUrl: string;
33
+ readonly lang: Lang;
34
+ private readonly authorization;
35
+ private readonly fetchImpl;
36
+ private readonly timeoutMs;
37
+ private readonly writeTimeoutMs;
38
+ private readonly queryRetries;
39
+ private readonly retryDelayMs;
40
+ constructor(options: TransportOptions);
41
+ error(code: ErrorCode, info?: ErrorInfo): Proxy302Error;
42
+ /** Only GET is repeated after a network failure. */
43
+ request<T>(method: 'GET' | 'POST' | 'PUT', path: string, options?: RequestOptions): Promise<T>;
44
+ private once;
45
+ }
@@ -0,0 +1,126 @@
1
+ /** Transport for the Proxy302 open API (/open_api/v3). Answers are HTTP 200 with {code, msg, data}; success is code 0. */
2
+ import { classify, Proxy302Error } from './errors.js';
3
+ import { VERSION } from './version.js';
4
+ export const CLIENT_ID = `proxy302-sdk-js/${VERSION}`;
5
+ const BEARER_KEY = /^p302_[A-Za-z0-9_-]{32}$/;
6
+ export function buildAuthorization(apiKey, apiSecret, lang) {
7
+ const key = (apiKey ?? '').trim();
8
+ if (!key)
9
+ throw new Proxy302Error('no_key', { lang });
10
+ const bearer = /^bearer\s+(.*)$/i.exec(key);
11
+ if (bearer && !BEARER_KEY.test(bearer[1]))
12
+ throw new Proxy302Error('invalid_key', { lang });
13
+ if (bearer || /^basic\s+\S+$/i.test(key))
14
+ return key;
15
+ if (/\s/.test(key))
16
+ throw new Proxy302Error('invalid_key', { lang });
17
+ const secret = apiSecret?.trim();
18
+ if (secret)
19
+ return `Basic ${Buffer.from(`${key}:${secret}`).toString('base64')}`;
20
+ if (key.startsWith('p302_')) {
21
+ if (!BEARER_KEY.test(key))
22
+ throw new Proxy302Error('invalid_key', { lang });
23
+ return `Bearer ${key}`;
24
+ }
25
+ if (key.includes(':'))
26
+ return `Basic ${Buffer.from(key).toString('base64')}`;
27
+ if (/^[A-Za-z0-9+/]+={0,2}$/.test(key) && key.length >= 16)
28
+ return `Basic ${key}`;
29
+ throw new Proxy302Error('invalid_key', { lang });
30
+ }
31
+ const RETRIED = new Set(['network', 'timeout', 'rate_limited', 'service_unavailable']);
32
+ function parse(text) {
33
+ try {
34
+ return JSON.parse(text);
35
+ }
36
+ catch {
37
+ return null;
38
+ }
39
+ }
40
+ export class Transport {
41
+ baseUrl;
42
+ lang;
43
+ authorization;
44
+ fetchImpl;
45
+ timeoutMs;
46
+ writeTimeoutMs;
47
+ queryRetries;
48
+ retryDelayMs;
49
+ constructor(options) {
50
+ this.lang = options.lang ?? 'zh';
51
+ this.baseUrl = (options.baseUrl ?? 'https://proxy302.com').replace(/\/+$/, '');
52
+ // The key travels in a header: plain http is accepted for local tests only.
53
+ if (!/^https:\/\//i.test(this.baseUrl) && !/^http:\/\/(127\.0\.0\.1|localhost)(:\d+)?$/i.test(this.baseUrl)) {
54
+ throw this.error('bad_argument', { detail: 'baseUrl must start with https://' });
55
+ }
56
+ this.authorization = buildAuthorization(options.apiKey, options.apiSecret, this.lang);
57
+ this.fetchImpl = options.fetchImpl ?? ((input, init) => globalThis.fetch(input, init));
58
+ this.timeoutMs = options.timeoutMs ?? 20000;
59
+ this.writeTimeoutMs = options.writeTimeoutMs ?? 60000;
60
+ this.queryRetries = Math.max(0, options.queryRetries ?? 2);
61
+ this.retryDelayMs = options.retryDelayMs ?? 300;
62
+ }
63
+ error(code, info = {}) {
64
+ return new Proxy302Error(code, { ...info, lang: this.lang });
65
+ }
66
+ /** Only GET is repeated after a network failure. */
67
+ async request(method, path, options = {}) {
68
+ const attempts = method === 'GET' ? this.queryRetries + 1 : 1;
69
+ for (let attempt = 1;; attempt += 1) {
70
+ try {
71
+ return await this.once(method, path, options);
72
+ }
73
+ catch (e) {
74
+ if (!(e instanceof Proxy302Error) || attempt >= attempts || !RETRIED.has(e.code))
75
+ throw e;
76
+ await new Promise(resolve => setTimeout(resolve, this.retryDelayMs * 2 ** (attempt - 1)));
77
+ }
78
+ }
79
+ }
80
+ async once(method, path, options) {
81
+ const { idempotencyKey } = options;
82
+ const url = new URL(`${this.baseUrl}/open_api/v3/${path.replace(/^\/+/, '')}`);
83
+ for (const [k, v] of Object.entries(options.query ?? {}))
84
+ if (v !== undefined && v !== '')
85
+ url.searchParams.set(k, String(v));
86
+ let status = 0;
87
+ let text;
88
+ try {
89
+ const res = await this.fetchImpl(url, {
90
+ method,
91
+ headers: {
92
+ authorization: this.authorization, accept: 'application/json', 'user-agent': CLIENT_ID, 'x-proxy302-client': CLIENT_ID,
93
+ ...(options.body !== undefined ? { 'content-type': 'application/json' } : {}), ...options.headers,
94
+ },
95
+ redirect: 'manual',
96
+ signal: AbortSignal.timeout(method === 'GET' ? this.timeoutMs : this.writeTimeoutMs),
97
+ ...(options.body !== undefined ? { body: JSON.stringify(options.body) } : {}),
98
+ });
99
+ status = res.status;
100
+ text = await res.text();
101
+ }
102
+ catch (e) {
103
+ const name = e?.name;
104
+ const cause = e?.cause?.code;
105
+ throw this.error(name === 'TimeoutError' || name === 'AbortError' ? 'timeout' : 'network', { detail: cause, idempotencyKey });
106
+ }
107
+ if (status === 401)
108
+ throw this.error('unauthorized', { httpStatus: status, idempotencyKey });
109
+ if (status === 429)
110
+ throw this.error('rate_limited', { httpStatus: status, idempotencyKey });
111
+ const json = parse(text);
112
+ if (!json || typeof json !== 'object' || typeof json.code !== 'number') {
113
+ throw this.error(status >= 500 ? 'service_unavailable' : 'bad_response', { detail: `HTTP ${status}`, httpStatus: status, idempotencyKey });
114
+ }
115
+ if (json.code !== 0) {
116
+ const apiMessage = typeof json.msg === 'string' ? json.msg : '';
117
+ const code = classify(json.code, apiMessage);
118
+ throw this.error(code, {
119
+ // Validation texts name the wrong field; other texts stay in apiMessage.
120
+ detail: code === 'invalid_request' ? apiMessage : undefined,
121
+ apiCode: json.code, apiMessage, httpStatus: status, idempotencyKey,
122
+ });
123
+ }
124
+ return json.data;
125
+ }
126
+ }
@@ -0,0 +1,5 @@
1
+ export { Proxy302, newIdempotencyKey, proxyUrl, type Proxy302Options } from './client.js';
2
+ export { Proxy302Error, type ErrorCode, type Lang } from './errors.js';
3
+ export type { RequestOptions } from './http.js';
4
+ export * from './types.js';
5
+ export { VERSION } from './version.js';
@@ -0,0 +1,4 @@
1
+ export { Proxy302, newIdempotencyKey, proxyUrl } from './client.js';
2
+ export { Proxy302Error } from './errors.js';
3
+ export * from './types.js';
4
+ export { VERSION } from './version.js';
@@ -0,0 +1,195 @@
1
+ export type Protocol = 'http' | 'socks5';
2
+ /** budget = lower price per GB, by country; premium = by country, state, city and ISP. */
3
+ export type Line = 'budget' | 'premium';
4
+ export type SessionMode = 'sticky' | 'rotating';
5
+ export interface Area {
6
+ id: number;
7
+ name: string;
8
+ code?: string | undefined;
9
+ pid?: number | undefined;
10
+ }
11
+ export interface Isp {
12
+ key: string;
13
+ name: string;
14
+ }
15
+ export interface Account {
16
+ uid: string;
17
+ name: string;
18
+ email: string;
19
+ active: boolean;
20
+ }
21
+ export interface Balance {
22
+ balancePtc: number;
23
+ currency: string;
24
+ }
25
+ export interface StaticPlan {
26
+ paywayId: number;
27
+ days: number;
28
+ pricePtc: number;
29
+ name: string;
30
+ }
31
+ export interface Prices {
32
+ usdPerPtc: number;
33
+ dynamic: {
34
+ payAsYouGo: Array<{
35
+ line: string;
36
+ perGbPtc: number;
37
+ }>;
38
+ packages: Array<{
39
+ line: string;
40
+ gb: number;
41
+ perGbPtc: number;
42
+ totalPtc: number;
43
+ }>;
44
+ };
45
+ static: {
46
+ residential: StaticPlan[];
47
+ datacenter: StaticPlan[];
48
+ };
49
+ }
50
+ export interface Connection {
51
+ protocol: Protocol;
52
+ /** Your domain when entryDomains maps it. */
53
+ host: string;
54
+ port: number;
55
+ username: string;
56
+ password: string;
57
+ /** protocol://username:password@host:port */
58
+ url: string;
59
+ }
60
+ export interface Proxy {
61
+ tokenId: number;
62
+ kind: 'dynamic' | 'static';
63
+ billing: 'traffic' | 'ip';
64
+ /** "Country - State - City" */
65
+ area: string;
66
+ ip: string;
67
+ line: Line | null;
68
+ datacenter: boolean;
69
+ status: number;
70
+ active: boolean;
71
+ /** Unix seconds; null = no end date. */
72
+ expiresAt: number | null;
73
+ autoRenew: boolean;
74
+ trafficUsedBytes: number;
75
+ remark: string;
76
+ protocol: Protocol;
77
+ connection: Connection | null;
78
+ }
79
+ export interface ProxyPage {
80
+ total: number;
81
+ page: number;
82
+ hasMore: boolean;
83
+ nextCursor: string | null;
84
+ proxies: Proxy[];
85
+ }
86
+ export interface DynamicOptions {
87
+ /** Country name, two-letter code or id. */
88
+ country: string | number;
89
+ /** Premium line only. */
90
+ state?: string | number | undefined;
91
+ /** Premium line only; needs state. */
92
+ city?: string | number | undefined;
93
+ /** Premium line only: a key from listIsps. */
94
+ isp?: string | undefined;
95
+ /** Default: premium when state, city or isp is given, else budget. */
96
+ line?: Line | undefined;
97
+ protocol?: Protocol | undefined;
98
+ /** sticky (default) keeps one IP; rotating gives a new IP on every new connection. */
99
+ session?: SessionMode | undefined;
100
+ /** Budget line, sticky only: minutes to keep one IP, 1-120. */
101
+ sessionMinutes?: number | undefined;
102
+ /** auto (default): traffic package first, wallet when there is none. */
103
+ billing?: 'auto' | 'package' | 'wallet' | undefined;
104
+ }
105
+ export interface CreateDynamicOptions extends DynamicOptions {
106
+ /** 8-100 letters, digits, _ or -. The same key returns the same proxy until it is deleted; generated when left out. */
107
+ idempotencyKey?: string | undefined;
108
+ }
109
+ export interface GetDynamicOptions extends DynamicOptions {
110
+ /** Default true. */
111
+ createIfMissing?: boolean | undefined;
112
+ }
113
+ export interface DynamicProxy {
114
+ tokenId: number;
115
+ reused: boolean;
116
+ /** Set when the proxy was created by this call. */
117
+ billedFrom: 'traffic_package' | 'wallet' | null;
118
+ area: string;
119
+ line: Line;
120
+ session: SessionMode;
121
+ idempotencyKey: string | null;
122
+ /** Ready to use: the session is in the username. */
123
+ connection: Connection;
124
+ }
125
+ export interface BuyStaticOptions {
126
+ country: string | number;
127
+ state?: string | number | undefined;
128
+ city?: string | number | undefined;
129
+ /** Lease in days (a plan of getPrices), or pass paywayId. */
130
+ days?: number | undefined;
131
+ paywayId?: number | undefined;
132
+ /** Default residential (static ISP). */
133
+ type?: 'residential' | 'datacenter' | undefined;
134
+ protocol?: Protocol | undefined;
135
+ /** asia or us connection address; left out = automatic. Residential only. */
136
+ entry?: 'asia' | 'us' | undefined;
137
+ /** 8-128 letters, digits, _ or -. Generated when left out; save your own to repeat an order safely. */
138
+ idempotencyKey?: string | undefined;
139
+ }
140
+ export interface StaticPurchase {
141
+ tokenId: number;
142
+ area: string;
143
+ /** Known when the plan was chosen with days. */
144
+ days: number | null;
145
+ pricePtc: number | null;
146
+ idempotencyKey: string;
147
+ connection: Connection;
148
+ }
149
+ export interface RenewOptions {
150
+ days?: number | undefined;
151
+ paywayId?: number | undefined;
152
+ autoRenew?: boolean | undefined;
153
+ idempotencyKey?: string | undefined;
154
+ }
155
+ export interface Renewal {
156
+ tokenId: number;
157
+ orderId: string;
158
+ expiresAt: number;
159
+ days: number;
160
+ replayed: boolean;
161
+ idempotencyKey: string;
162
+ }
163
+ export interface RotateResult {
164
+ /** Use these now: the next connection exits through a new IP. */
165
+ connections: Array<{
166
+ tokenId: number;
167
+ connection: Connection;
168
+ }>;
169
+ results: Array<{
170
+ tokenId: number;
171
+ rotatedSessions: number;
172
+ note?: string | undefined;
173
+ }>;
174
+ /** The plain username changes its sticky IP within this time. */
175
+ applyWithinSeconds: number;
176
+ }
177
+ export interface Traffic {
178
+ remainingBytes: number;
179
+ pools: Array<{
180
+ id: number | string;
181
+ name: string;
182
+ usedBytes: number;
183
+ totalBytes: number;
184
+ expiresAt: number | null;
185
+ }>;
186
+ }
187
+ export interface Usage {
188
+ startTime: number;
189
+ endTime: number;
190
+ days: string[];
191
+ /** Bytes by category over the whole period. */
192
+ totalBytes: Record<string, number>;
193
+ /** Bytes by category and day, in the order of days. */
194
+ dailyBytes: Record<string, number[]>;
195
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const VERSION = "0.1.0";
@@ -0,0 +1 @@
1
+ export const VERSION = '0.1.0';
package/package.json CHANGED
@@ -1,6 +1,34 @@
1
1
  {
2
2
  "name": "proxy302-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Official Proxy302 SDK for Node.js: add residential proxies to your own product (accounts, prices, dynamic proxies, static IPs, renewals, usage).",
5
+ "license": "MIT",
6
+ "author": "Proxy302",
7
+ "homepage": "https://proxy302.com",
8
+ "repository": { "type": "git", "url": "git+https://github.com/proxy302/proxy302-sdk.git", "directory": "js" },
9
+ "bugs": { "url": "https://github.com/proxy302/proxy302-sdk/issues" },
10
+ "keywords": ["proxy302", "proxy", "residential-proxy", "static-ip", "sdk", "white-label"],
11
+ "engines": { "node": ">=18" },
12
+ "type": "module",
13
+ "main": "./dist/cjs/index.js",
14
+ "module": "./dist/esm/index.js",
15
+ "types": "./dist/esm/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "import": { "types": "./dist/esm/index.d.ts", "default": "./dist/esm/index.js" },
19
+ "require": { "types": "./dist/cjs/index.d.ts", "default": "./dist/cjs/index.js" }
20
+ },
21
+ "./package.json": "./package.json"
22
+ },
23
+ "files": ["dist", "README.md", "LICENSE"],
24
+ "sideEffects": false,
25
+ "scripts": {
26
+ "build": "node scripts/build.mjs",
27
+ "test": "npm run build && node --test test/*.test.mjs test/*.test.cjs",
28
+ "prepack": "npm run build"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^18.19.0",
32
+ "typescript": "^5.6.0"
33
+ }
34
+ }