smswire 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 +21 -0
- package/README.md +115 -2
- package/dist/index.cjs +309 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +819 -0
- package/dist/index.d.ts +819 -0
- package/dist/index.js +277 -0
- package/dist/index.js.map +1 -0
- package/package.json +34 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var SMSWireError = class extends Error {
|
|
3
|
+
constructor(status, code, message, retryAfter2 = null, options) {
|
|
4
|
+
super(message, options);
|
|
5
|
+
this.status = status;
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.retryAfter = retryAfter2;
|
|
8
|
+
}
|
|
9
|
+
status;
|
|
10
|
+
code;
|
|
11
|
+
retryAfter;
|
|
12
|
+
name = "SMSWireError";
|
|
13
|
+
};
|
|
14
|
+
var SMSWireSignatureError = class extends Error {
|
|
15
|
+
name = "SMSWireSignatureError";
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/http.ts
|
|
19
|
+
var sleep = (seconds) => new Promise((r) => setTimeout(r, seconds * 1e3));
|
|
20
|
+
function retryAfter(header) {
|
|
21
|
+
if (!header) return null;
|
|
22
|
+
const n = Number(header);
|
|
23
|
+
if (Number.isFinite(n)) return Math.max(0, n);
|
|
24
|
+
const at = Date.parse(header);
|
|
25
|
+
return Number.isNaN(at) ? null : Math.max(0, (at - Date.now()) / 1e3);
|
|
26
|
+
}
|
|
27
|
+
var backoff = (attempt) => Math.min(8, 0.5 * 2 ** attempt) * (1 + Math.random() * 0.25);
|
|
28
|
+
async function errorFrom(res) {
|
|
29
|
+
const text = await res.text().catch(() => "");
|
|
30
|
+
let code = "http_error";
|
|
31
|
+
let message = `HTTP ${res.status}`;
|
|
32
|
+
try {
|
|
33
|
+
const body = JSON.parse(text);
|
|
34
|
+
if (typeof body.error === "string" && typeof body.message === "string") {
|
|
35
|
+
code = body.error;
|
|
36
|
+
message = body.message;
|
|
37
|
+
}
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
return new SMSWireError(res.status, code, message, retryAfter(res.headers.get("retry-after")));
|
|
41
|
+
}
|
|
42
|
+
function retryDelay(err, req, attempt, opts) {
|
|
43
|
+
if (attempt >= opts.maxRetries) return null;
|
|
44
|
+
const retryable = err.status === 429 || req.idempotent && (err.status === null || err.status >= 500);
|
|
45
|
+
if (!retryable) return null;
|
|
46
|
+
if (err.retryAfter !== null) return err.retryAfter <= opts.maxRetryWait ? err.retryAfter : null;
|
|
47
|
+
return backoff(attempt);
|
|
48
|
+
}
|
|
49
|
+
async function send(opts, req) {
|
|
50
|
+
const url = new URL(opts.baseUrl.replace(/\/+$/, "") + req.path);
|
|
51
|
+
for (const [k, v] of Object.entries(req.query ?? {})) {
|
|
52
|
+
if (v !== void 0 && v !== null) url.searchParams.set(k, String(v));
|
|
53
|
+
}
|
|
54
|
+
const headers = {
|
|
55
|
+
Authorization: `Bearer ${opts.apiKey}`,
|
|
56
|
+
Accept: "application/json",
|
|
57
|
+
"User-Agent": opts.userAgent,
|
|
58
|
+
...req.headers
|
|
59
|
+
};
|
|
60
|
+
if (req.body !== void 0) headers["Content-Type"] = "application/json";
|
|
61
|
+
const body = req.body === void 0 ? void 0 : JSON.stringify(req.body);
|
|
62
|
+
for (let attempt = 0; ; attempt++) {
|
|
63
|
+
let res;
|
|
64
|
+
let err;
|
|
65
|
+
try {
|
|
66
|
+
res = await opts.fetch(url, { method: req.method, headers, body, signal: AbortSignal.timeout(opts.timeout) });
|
|
67
|
+
} catch (e) {
|
|
68
|
+
const timedOut = e instanceof Error && e.name === "TimeoutError";
|
|
69
|
+
err = new SMSWireError(
|
|
70
|
+
null,
|
|
71
|
+
timedOut ? "timeout" : "network_error",
|
|
72
|
+
timedOut ? `No answer within ${opts.timeout} ms` : `Could not reach ${url.origin}: ${e.message}`,
|
|
73
|
+
null,
|
|
74
|
+
{ cause: e }
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
if (res?.ok) {
|
|
78
|
+
const text = await res.text();
|
|
79
|
+
return text ? JSON.parse(text) : void 0;
|
|
80
|
+
}
|
|
81
|
+
if (res) err = await errorFrom(res);
|
|
82
|
+
const wait = retryDelay(err, req, attempt, opts);
|
|
83
|
+
if (wait === null) throw err;
|
|
84
|
+
await sleep(wait);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// src/resources/messages.ts
|
|
89
|
+
var Messages = class {
|
|
90
|
+
constructor(call, base) {
|
|
91
|
+
this.call = call;
|
|
92
|
+
this.base = base;
|
|
93
|
+
}
|
|
94
|
+
call;
|
|
95
|
+
base;
|
|
96
|
+
/** Queues one SMS for the project's phone. */
|
|
97
|
+
send(params, options = {}) {
|
|
98
|
+
return this.call({
|
|
99
|
+
method: "POST",
|
|
100
|
+
path: this.base,
|
|
101
|
+
body: params,
|
|
102
|
+
headers: { "Idempotency-Key": options.idempotencyKey ?? crypto.randomUUID() },
|
|
103
|
+
idempotent: true
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/** Queues a batch. Invalid or opted-out items come back in `rejected`; the rest go out as one batch. */
|
|
107
|
+
sendBulk(params) {
|
|
108
|
+
return this.call({ method: "POST", path: `${this.base}/bulk`, body: params, idempotent: false });
|
|
109
|
+
}
|
|
110
|
+
get(id) {
|
|
111
|
+
return this.call({ method: "GET", path: `${this.base}/${encodeURIComponent(id)}`, idempotent: true });
|
|
112
|
+
}
|
|
113
|
+
/** Stops a message that hasn't reached a phone yet. */
|
|
114
|
+
cancel(id) {
|
|
115
|
+
return this.call({ method: "DELETE", path: `${this.base}/${encodeURIComponent(id)}`, idempotent: true });
|
|
116
|
+
}
|
|
117
|
+
/** One page, newest first. Pass `next_cursor` back as `cursor` for the next. */
|
|
118
|
+
list(params = {}) {
|
|
119
|
+
return this.call({ method: "GET", path: this.base, query: params, idempotent: true });
|
|
120
|
+
}
|
|
121
|
+
/** Every matching message, newest first, fetching pages as you go. */
|
|
122
|
+
async *listAll(params = {}) {
|
|
123
|
+
let cursor;
|
|
124
|
+
do {
|
|
125
|
+
const page = await this.list({ ...params, cursor: cursor ?? void 0 });
|
|
126
|
+
yield* page.data;
|
|
127
|
+
cursor = page.next_cursor;
|
|
128
|
+
} while (cursor);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// src/resources/otp.ts
|
|
133
|
+
var OneTimeCodes = class {
|
|
134
|
+
constructor(call, base) {
|
|
135
|
+
this.call = call;
|
|
136
|
+
this.base = base;
|
|
137
|
+
}
|
|
138
|
+
call;
|
|
139
|
+
base;
|
|
140
|
+
/** Texts a fresh code to `to`. Keep the returned `id` for verify(). */
|
|
141
|
+
send(params) {
|
|
142
|
+
return this.call({ method: "POST", path: this.base, body: params, idempotent: false });
|
|
143
|
+
}
|
|
144
|
+
/** Checks what the user typed. `valid` is false with a `reason` when it's wrong, expired or used. */
|
|
145
|
+
verify(params) {
|
|
146
|
+
return this.call({ method: "POST", path: `${this.base}/verify`, body: params, idempotent: false });
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// src/resources/schedules.ts
|
|
151
|
+
var Schedules = class {
|
|
152
|
+
constructor(call, base) {
|
|
153
|
+
this.call = call;
|
|
154
|
+
this.base = base;
|
|
155
|
+
}
|
|
156
|
+
call;
|
|
157
|
+
base;
|
|
158
|
+
/** A message (or batch) sent again and again on a cron schedule. */
|
|
159
|
+
create(params) {
|
|
160
|
+
return this.call({ method: "POST", path: this.base, body: params, idempotent: false });
|
|
161
|
+
}
|
|
162
|
+
list() {
|
|
163
|
+
return this.call({ method: "GET", path: this.base, idempotent: true });
|
|
164
|
+
}
|
|
165
|
+
/** One schedule, with its recent runs. */
|
|
166
|
+
get(id) {
|
|
167
|
+
return this.call({ method: "GET", path: `${this.base}/${encodeURIComponent(id)}`, idempotent: true });
|
|
168
|
+
}
|
|
169
|
+
/** Absent fields stay as they are; recipients can't change. */
|
|
170
|
+
update(id, params) {
|
|
171
|
+
return this.call({ method: "PATCH", path: `${this.base}/${encodeURIComponent(id)}`, body: params, idempotent: true });
|
|
172
|
+
}
|
|
173
|
+
async delete(id) {
|
|
174
|
+
await this.call({ method: "DELETE", path: `${this.base}/${encodeURIComponent(id)}`, idempotent: true });
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// src/webhooks.ts
|
|
179
|
+
var SIGNATURE_HEADER = "X-SMSWire-Signature";
|
|
180
|
+
var encoder = new TextEncoder();
|
|
181
|
+
function bytes(body) {
|
|
182
|
+
if (typeof body === "string") return encoder.encode(body);
|
|
183
|
+
return body instanceof Uint8Array ? body : new Uint8Array(body);
|
|
184
|
+
}
|
|
185
|
+
function parse(header) {
|
|
186
|
+
let t = null;
|
|
187
|
+
const signatures = [];
|
|
188
|
+
for (const part of header.split(",")) {
|
|
189
|
+
const i = part.indexOf("=");
|
|
190
|
+
if (i < 0) continue;
|
|
191
|
+
const key = part.slice(0, i).trim();
|
|
192
|
+
const value = part.slice(i + 1).trim();
|
|
193
|
+
if (key === "t" && /^\d+$/.test(value)) t = Number(value);
|
|
194
|
+
else if (key === "v1" && /^[0-9a-f]{64}$/i.test(value)) signatures.push(value.toLowerCase());
|
|
195
|
+
}
|
|
196
|
+
return t === null || !signatures.length ? null : { t, signatures };
|
|
197
|
+
}
|
|
198
|
+
async function hmacHex(secret, message) {
|
|
199
|
+
const key = await crypto.subtle.importKey("raw", encoder.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
200
|
+
const mac = new Uint8Array(await crypto.subtle.sign("HMAC", key, message));
|
|
201
|
+
return Array.from(mac, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
202
|
+
}
|
|
203
|
+
function constantTimeEqual(a, b) {
|
|
204
|
+
if (a.length !== b.length) return false;
|
|
205
|
+
let diff = 0;
|
|
206
|
+
for (let i = 0; i < a.length; i++) diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
207
|
+
return diff === 0;
|
|
208
|
+
}
|
|
209
|
+
async function verifyWebhook(rawBody, signature, secret, options = {}) {
|
|
210
|
+
if (!secret) throw new SMSWireSignatureError("No webhook signing secret given");
|
|
211
|
+
const parsed = parse(signature ?? "");
|
|
212
|
+
if (!parsed) throw new SMSWireSignatureError(`Missing or malformed ${SIGNATURE_HEADER} header`);
|
|
213
|
+
const now = options.now ?? Math.floor(Date.now() / 1e3);
|
|
214
|
+
if (Math.abs(now - parsed.t) > (options.tolerance ?? 300)) {
|
|
215
|
+
throw new SMSWireSignatureError("Signature timestamp is outside the tolerance");
|
|
216
|
+
}
|
|
217
|
+
const body = bytes(rawBody);
|
|
218
|
+
const prefix = encoder.encode(`${parsed.t}.`);
|
|
219
|
+
const signed = new Uint8Array(prefix.length + body.length);
|
|
220
|
+
signed.set(prefix);
|
|
221
|
+
signed.set(body, prefix.length);
|
|
222
|
+
const expected = await hmacHex(secret, signed);
|
|
223
|
+
if (!parsed.signatures.some((s) => constantTimeEqual(s, expected))) {
|
|
224
|
+
throw new SMSWireSignatureError("Signature does not match");
|
|
225
|
+
}
|
|
226
|
+
return JSON.parse(new TextDecoder().decode(body));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// src/client.ts
|
|
230
|
+
var VERSION = "0.1.0";
|
|
231
|
+
var env = (name) => typeof process === "undefined" ? void 0 : process.env?.[name] || void 0;
|
|
232
|
+
var SMSWire = class {
|
|
233
|
+
messages;
|
|
234
|
+
otp;
|
|
235
|
+
schedules;
|
|
236
|
+
webhooks;
|
|
237
|
+
constructor(options = {}) {
|
|
238
|
+
const apiKey = options.apiKey ?? env("SMSWIRE_KEY");
|
|
239
|
+
const project = options.project ?? env("SMSWIRE_PROJECT");
|
|
240
|
+
if (!apiKey) throw new Error("SMSWire: pass apiKey or set SMSWIRE_KEY");
|
|
241
|
+
if (!project) throw new Error("SMSWire: pass project or set SMSWIRE_PROJECT");
|
|
242
|
+
const http = {
|
|
243
|
+
apiKey,
|
|
244
|
+
baseUrl: options.baseUrl ?? env("SMSWIRE_URL") ?? "https://api.smswire.app",
|
|
245
|
+
maxRetries: options.maxRetries ?? 2,
|
|
246
|
+
maxRetryWait: options.maxRetryWait ?? 60,
|
|
247
|
+
timeout: options.timeout ?? 3e4,
|
|
248
|
+
fetch: options.fetch ?? globalThis.fetch.bind(globalThis),
|
|
249
|
+
userAgent: `smswire-node/${VERSION}`
|
|
250
|
+
};
|
|
251
|
+
const call = (req) => send(http, req);
|
|
252
|
+
const p = `/v1/p/${encodeURIComponent(project)}`;
|
|
253
|
+
this.messages = new Messages(call, `${p}/messages`);
|
|
254
|
+
this.otp = new OneTimeCodes(call, `${p}/otp`);
|
|
255
|
+
this.schedules = new Schedules(call, `${p}/schedules`);
|
|
256
|
+
const secret = options.webhookSecret ?? env("SMSWIRE_WEBHOOK_SECRET");
|
|
257
|
+
this.webhooks = {
|
|
258
|
+
verify: (rawBody, signature, opts) => {
|
|
259
|
+
if (!secret) throw new Error("SMSWire: pass webhookSecret or set SMSWIRE_WEBHOOK_SECRET");
|
|
260
|
+
return verifyWebhook(rawBody, signature, secret, opts);
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
// src/index.ts
|
|
267
|
+
var index_default = SMSWire;
|
|
268
|
+
export {
|
|
269
|
+
SIGNATURE_HEADER,
|
|
270
|
+
SMSWire,
|
|
271
|
+
SMSWireError,
|
|
272
|
+
SMSWireSignatureError,
|
|
273
|
+
VERSION,
|
|
274
|
+
index_default as default,
|
|
275
|
+
verifyWebhook
|
|
276
|
+
};
|
|
277
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/http.ts","../src/resources/messages.ts","../src/resources/otp.ts","../src/resources/schedules.ts","../src/webhooks.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["/** A request that failed: the API's answer (status, code, message) or a network problem (status null). */\nexport class SMSWireError extends Error {\n override readonly name: string = 'SMSWireError';\n\n constructor(\n /** HTTP status, or null when no answer arrived. */\n readonly status: number | null,\n /** Stable machine code, e.g. `invalid_request`, `rate_limited`, `network_error`, `timeout`. */\n readonly code: string,\n message: string,\n /** Seconds until trying again makes sense (from Retry-After), when the API said. */\n readonly retryAfter: number | null = null,\n options?: { cause?: unknown },\n ) {\n super(message, options);\n }\n}\n\n/** A webhook whose signature is missing, wrong or too old. Answer it with 400. */\nexport class SMSWireSignatureError extends Error {\n override readonly name = 'SMSWireSignatureError';\n}\n","import { SMSWireError } from './errors';\n\nexport interface HttpOptions {\n apiKey: string;\n baseUrl: string;\n maxRetries: number;\n maxRetryWait: number;\n timeout: number;\n fetch: typeof fetch;\n userAgent: string;\n}\n\nexport interface Request {\n method: 'GET' | 'POST' | 'PATCH' | 'DELETE';\n path: string;\n query?: Record<string, unknown>;\n body?: unknown;\n headers?: Record<string, string>;\n /** Safe to repeat after a 5xx or a dropped connection (GET, PATCH, DELETE, or a POST with an Idempotency-Key). */\n idempotent: boolean;\n}\n\nconst sleep = (seconds: number) => new Promise((r) => setTimeout(r, seconds * 1000));\n\n/** Seconds from a Retry-After header (seconds or an HTTP date). */\nfunction retryAfter(header: string | null): number | null {\n if (!header) return null;\n const n = Number(header);\n if (Number.isFinite(n)) return Math.max(0, n);\n const at = Date.parse(header);\n return Number.isNaN(at) ? null : Math.max(0, (at - Date.now()) / 1000);\n}\n\n/** Exponential backoff from 0.5 s, capped at 8 s, with up to 25% jitter. */\nconst backoff = (attempt: number) => Math.min(8, 0.5 * 2 ** attempt) * (1 + Math.random() * 0.25);\n\n/** The SDK's error for a non-2xx answer. */\nexport async function errorFrom(res: Response): Promise<SMSWireError> {\n const text = await res.text().catch(() => '');\n let code = 'http_error';\n let message = `HTTP ${res.status}`;\n try {\n const body = JSON.parse(text) as { error?: unknown; message?: unknown };\n if (typeof body.error === 'string' && typeof body.message === 'string') {\n code = body.error;\n message = body.message;\n }\n } catch {\n // Not JSON (a proxy's error page): keep the generic code.\n }\n return new SMSWireError(res.status, code, message, retryAfter(res.headers.get('retry-after')));\n}\n\n/** Whether to try [err] again on attempt [attempt] (0-based), and after how long. */\nexport function retryDelay(err: SMSWireError, req: Pick<Request, 'idempotent'>, attempt: number, opts: Pick<HttpOptions, 'maxRetries' | 'maxRetryWait'>): number | null {\n if (attempt >= opts.maxRetries) return null;\n const retryable = err.status === 429 || (req.idempotent && (err.status === null || err.status >= 500));\n if (!retryable) return null;\n if (err.retryAfter !== null) return err.retryAfter <= opts.maxRetryWait ? err.retryAfter : null;\n return backoff(attempt);\n}\n\nexport async function send<T>(opts: HttpOptions, req: Request): Promise<T> {\n const url = new URL(opts.baseUrl.replace(/\\/+$/, '') + req.path);\n for (const [k, v] of Object.entries(req.query ?? {})) {\n if (v !== undefined && v !== null) url.searchParams.set(k, String(v));\n }\n const headers: Record<string, string> = {\n Authorization: `Bearer ${opts.apiKey}`,\n Accept: 'application/json',\n 'User-Agent': opts.userAgent,\n ...req.headers,\n };\n if (req.body !== undefined) headers['Content-Type'] = 'application/json';\n const body = req.body === undefined ? undefined : JSON.stringify(req.body);\n\n for (let attempt = 0; ; attempt++) {\n let res: Response | undefined;\n let err: SMSWireError;\n try {\n res = await opts.fetch(url, { method: req.method, headers, body, signal: AbortSignal.timeout(opts.timeout) });\n } catch (e) {\n const timedOut = e instanceof Error && e.name === 'TimeoutError';\n err = new SMSWireError(\n null,\n timedOut ? 'timeout' : 'network_error',\n timedOut ? `No answer within ${opts.timeout} ms` : `Could not reach ${url.origin}: ${(e as Error).message}`,\n null,\n { cause: e },\n );\n }\n if (res?.ok) {\n const text = await res.text();\n return (text ? JSON.parse(text) : undefined) as T;\n }\n if (res) err = await errorFrom(res);\n const wait = retryDelay(err!, req, attempt, opts);\n if (wait === null) throw err!;\n await sleep(wait);\n }\n}\n","import type { Request } from '../http';\nimport type { BulkResult, ListMessagesParams, Message, MessagePage, SendBulkParams, SendMessageParams } from '../types';\n\nexport type Call = <T>(req: Request) => Promise<T>;\n\nexport interface SendOptions {\n /**\n * Repeating a send with the same key returns the first message instead of sending again.\n * Defaults to a fresh random key, so the SDK's own retries never send twice; pass your own\n * (an order id, say) to make your retries safe too.\n */\n idempotencyKey?: string;\n}\n\nexport class Messages {\n constructor(\n private readonly call: Call,\n private readonly base: string,\n ) {}\n\n /** Queues one SMS for the project's phone. */\n send(params: SendMessageParams, options: SendOptions = {}): Promise<Message> {\n return this.call({\n method: 'POST',\n path: this.base,\n body: params,\n headers: { 'Idempotency-Key': options.idempotencyKey ?? crypto.randomUUID() },\n idempotent: true,\n });\n }\n\n /** Queues a batch. Invalid or opted-out items come back in `rejected`; the rest go out as one batch. */\n sendBulk(params: SendBulkParams): Promise<BulkResult> {\n return this.call({ method: 'POST', path: `${this.base}/bulk`, body: params, idempotent: false });\n }\n\n get(id: string): Promise<Message> {\n return this.call({ method: 'GET', path: `${this.base}/${encodeURIComponent(id)}`, idempotent: true });\n }\n\n /** Stops a message that hasn't reached a phone yet. */\n cancel(id: string): Promise<Message> {\n return this.call({ method: 'DELETE', path: `${this.base}/${encodeURIComponent(id)}`, idempotent: true });\n }\n\n /** One page, newest first. Pass `next_cursor` back as `cursor` for the next. */\n list(params: ListMessagesParams = {}): Promise<MessagePage> {\n return this.call({ method: 'GET', path: this.base, query: params, idempotent: true });\n }\n\n /** Every matching message, newest first, fetching pages as you go. */\n async *listAll(params: Omit<ListMessagesParams, 'cursor'> = {}): AsyncGenerator<Message> {\n let cursor: string | null | undefined;\n do {\n const page = await this.list({ ...params, cursor: cursor ?? undefined });\n yield* page.data;\n cursor = page.next_cursor;\n } while (cursor);\n }\n}\n","import type { Otp, OtpVerification, SendOtpParams, VerifyOtpParams } from '../types';\nimport type { Call } from './messages';\n\nexport class OneTimeCodes {\n constructor(\n private readonly call: Call,\n private readonly base: string,\n ) {}\n\n /** Texts a fresh code to `to`. Keep the returned `id` for verify(). */\n send(params: SendOtpParams): Promise<Otp> {\n return this.call({ method: 'POST', path: this.base, body: params, idempotent: false });\n }\n\n /** Checks what the user typed. `valid` is false with a `reason` when it's wrong, expired or used. */\n verify(params: VerifyOtpParams): Promise<OtpVerification> {\n return this.call({ method: 'POST', path: `${this.base}/verify`, body: params, idempotent: false });\n }\n}\n","import type { CreateScheduleParams, Schedule, SchedulePage, UpdateScheduleParams } from '../types';\nimport type { Call } from './messages';\n\nexport class Schedules {\n constructor(\n private readonly call: Call,\n private readonly base: string,\n ) {}\n\n /** A message (or batch) sent again and again on a cron schedule. */\n create(params: CreateScheduleParams): Promise<Schedule> {\n return this.call({ method: 'POST', path: this.base, body: params, idempotent: false });\n }\n\n list(): Promise<SchedulePage> {\n return this.call({ method: 'GET', path: this.base, idempotent: true });\n }\n\n /** One schedule, with its recent runs. */\n get(id: string): Promise<Schedule> {\n return this.call({ method: 'GET', path: `${this.base}/${encodeURIComponent(id)}`, idempotent: true });\n }\n\n /** Absent fields stay as they are; recipients can't change. */\n update(id: string, params: UpdateScheduleParams): Promise<Schedule> {\n return this.call({ method: 'PATCH', path: `${this.base}/${encodeURIComponent(id)}`, body: params, idempotent: true });\n }\n\n async delete(id: string): Promise<void> {\n await this.call({ method: 'DELETE', path: `${this.base}/${encodeURIComponent(id)}`, idempotent: true });\n }\n}\n","import { SMSWireSignatureError } from './errors';\nimport type { WebhookEvent } from './types';\n\nexport interface VerifyOptions {\n /** Oldest (and furthest in the future) signature accepted, in seconds. Default 300. */\n tolerance?: number;\n /** The current time in unix seconds; for tests. */\n now?: number;\n}\n\n/** The header the signature arrives in. */\nexport const SIGNATURE_HEADER = 'X-SMSWire-Signature';\n\nconst encoder = new TextEncoder();\n\nfunction bytes(body: string | Uint8Array | ArrayBuffer): Uint8Array {\n if (typeof body === 'string') return encoder.encode(body);\n return body instanceof Uint8Array ? body : new Uint8Array(body);\n}\n\n/** `t=<unix>,v1=<hex>[,v1=<hex>…]`, in any order; null when it isn't one. */\nfunction parse(header: string): { t: number; signatures: string[] } | null {\n let t: number | null = null;\n const signatures: string[] = [];\n for (const part of header.split(',')) {\n const i = part.indexOf('=');\n if (i < 0) continue;\n const key = part.slice(0, i).trim();\n const value = part.slice(i + 1).trim();\n if (key === 't' && /^\\d+$/.test(value)) t = Number(value);\n else if (key === 'v1' && /^[0-9a-f]{64}$/i.test(value)) signatures.push(value.toLowerCase());\n }\n return t === null || !signatures.length ? null : { t, signatures };\n}\n\nasync function hmacHex(secret: string, message: Uint8Array<ArrayBuffer>): Promise<string> {\n const key = await crypto.subtle.importKey('raw', encoder.encode(secret), { name: 'HMAC', hash: 'SHA-256' }, false, ['sign']);\n const mac = new Uint8Array(await crypto.subtle.sign('HMAC', key, message));\n return Array.from(mac, (b) => b.toString(16).padStart(2, '0')).join('');\n}\n\n/** Compares two equal-length strings without stopping at the first difference. */\nfunction constantTimeEqual(a: string, b: string): boolean {\n if (a.length !== b.length) return false;\n let diff = 0;\n for (let i = 0; i < a.length; i++) diff |= a.charCodeAt(i) ^ b.charCodeAt(i);\n return diff === 0;\n}\n\n/**\n * Checks a webhook's X-SMSWire-Signature against the **raw** request body (not re-serialised JSON)\n * and returns the parsed event. Throws SMSWireSignatureError when the signature is missing,\n * wrong, or more than `tolerance` seconds off.\n */\nexport async function verifyWebhook(\n rawBody: string | Uint8Array | ArrayBuffer,\n signature: string | null | undefined,\n secret: string,\n options: VerifyOptions = {},\n): Promise<WebhookEvent> {\n if (!secret) throw new SMSWireSignatureError('No webhook signing secret given');\n const parsed = parse(signature ?? '');\n if (!parsed) throw new SMSWireSignatureError(`Missing or malformed ${SIGNATURE_HEADER} header`);\n const now = options.now ?? Math.floor(Date.now() / 1000);\n if (Math.abs(now - parsed.t) > (options.tolerance ?? 300)) {\n throw new SMSWireSignatureError('Signature timestamp is outside the tolerance');\n }\n const body = bytes(rawBody);\n const prefix = encoder.encode(`${parsed.t}.`);\n const signed = new Uint8Array(prefix.length + body.length);\n signed.set(prefix);\n signed.set(body, prefix.length);\n const expected = await hmacHex(secret, signed);\n if (!parsed.signatures.some((s) => constantTimeEqual(s, expected))) {\n throw new SMSWireSignatureError('Signature does not match');\n }\n return JSON.parse(new TextDecoder().decode(body)) as WebhookEvent;\n}\n","import { send, type HttpOptions, type Request } from './http';\nimport { Messages } from './resources/messages';\nimport { OneTimeCodes } from './resources/otp';\nimport { Schedules } from './resources/schedules';\nimport type { WebhookEvent } from './types';\nimport { verifyWebhook, type VerifyOptions } from './webhooks';\n\nexport const VERSION = '0.1.0';\n\nexport interface ClientOptions {\n /** The project's API key (`smswire_live_…`). Defaults to SMSWIRE_KEY. */\n apiKey?: string;\n /** The project's slug, the part after /p/ in its endpoint. Defaults to SMSWIRE_PROJECT. */\n project?: string;\n /** Defaults to SMSWIRE_URL, then https://api.smswire.app. */\n baseUrl?: string;\n /** Signing secret (`whsec_…`) for webhooks.verify(). Defaults to SMSWIRE_WEBHOOK_SECRET. */\n webhookSecret?: string;\n /** Retries after a 429, a 5xx or a network error (see the README for which calls). Default 2. */\n maxRetries?: number;\n /** Longest Retry-After worth waiting for, in seconds; longer ones throw at once. Default 60. */\n maxRetryWait?: number;\n /** Per-attempt timeout in milliseconds. Default 30 000. */\n timeout?: number;\n /** A fetch implementation, for runtimes or tests that need their own. */\n fetch?: typeof fetch;\n}\n\nconst env = (name: string): string | undefined =>\n typeof process === 'undefined' ? undefined : process.env?.[name] || undefined;\n\nexport class SMSWire {\n readonly messages: Messages;\n readonly otp: OneTimeCodes;\n readonly schedules: Schedules;\n readonly webhooks: { verify(rawBody: string | Uint8Array | ArrayBuffer, signature: string | null | undefined, options?: VerifyOptions): Promise<WebhookEvent> };\n\n constructor(options: ClientOptions = {}) {\n const apiKey = options.apiKey ?? env('SMSWIRE_KEY');\n const project = options.project ?? env('SMSWIRE_PROJECT');\n if (!apiKey) throw new Error('SMSWire: pass apiKey or set SMSWIRE_KEY');\n if (!project) throw new Error('SMSWire: pass project or set SMSWIRE_PROJECT');\n\n const http: HttpOptions = {\n apiKey,\n baseUrl: options.baseUrl ?? env('SMSWIRE_URL') ?? 'https://api.smswire.app',\n maxRetries: options.maxRetries ?? 2,\n maxRetryWait: options.maxRetryWait ?? 60,\n timeout: options.timeout ?? 30_000,\n fetch: options.fetch ?? globalThis.fetch.bind(globalThis),\n userAgent: `smswire-node/${VERSION}`,\n };\n const call = <T>(req: Request) => send<T>(http, req);\n const p = `/v1/p/${encodeURIComponent(project)}`;\n this.messages = new Messages(call, `${p}/messages`);\n this.otp = new OneTimeCodes(call, `${p}/otp`);\n this.schedules = new Schedules(call, `${p}/schedules`);\n\n const secret = options.webhookSecret ?? env('SMSWIRE_WEBHOOK_SECRET');\n this.webhooks = {\n verify: (rawBody, signature, opts) => {\n if (!secret) throw new Error('SMSWire: pass webhookSecret or set SMSWIRE_WEBHOOK_SECRET');\n return verifyWebhook(rawBody, signature, secret, opts);\n },\n };\n }\n}\n","import { SMSWire } from './client';\n\nexport { SMSWire, VERSION, type ClientOptions } from './client';\nexport { SMSWireError, SMSWireSignatureError } from './errors';\nexport { verifyWebhook, SIGNATURE_HEADER, type VerifyOptions } from './webhooks';\nexport type { SendOptions } from './resources/messages';\nexport type * from './types';\nexport default SMSWire;\n"],"mappings":";AACO,IAAM,eAAN,cAA2B,MAAM;AAAA,EAGtC,YAEW,QAEA,MACT,SAESA,cAA4B,MACrC,SACA;AACA,UAAM,SAAS,OAAO;AARb;AAEA;AAGA,sBAAAA;AAAA,EAIX;AAAA,EATW;AAAA,EAEA;AAAA,EAGA;AAAA,EATO,OAAe;AAcnC;AAGO,IAAM,wBAAN,cAAoC,MAAM;AAAA,EAC7B,OAAO;AAC3B;;;ACCA,IAAM,QAAQ,CAAC,YAAoB,IAAI,QAAQ,CAAC,MAAM,WAAW,GAAG,UAAU,GAAI,CAAC;AAGnF,SAAS,WAAW,QAAsC;AACxD,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,IAAI,OAAO,MAAM;AACvB,MAAI,OAAO,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B;AAAA,MACtC,SAAS,QAAQ,WAAW;AAAA,MAC5B,OAAO,QAAQ,SAAS,WAAW,MAAM,KAAK,UAAU;AAAA,MACxD,WAAW,gBAAgB,OAAO;AAAA,IACpC;AACA,UAAM,OAAO,CAAI,QAAiB,KAAQ,MAAM,GAAG;AACnD,UAAM,IAAI,SAAS,mBAAmB,OAAO,CAAC;AAC9C,SAAK,WAAW,IAAI,SAAS,MAAM,GAAG,CAAC,WAAW;AAClD,SAAK,MAAM,IAAI,aAAa,MAAM,GAAG,CAAC,MAAM;AAC5C,SAAK,YAAY,IAAI,UAAU,MAAM,GAAG,CAAC,YAAY;AAErD,UAAM,SAAS,QAAQ,iBAAiB,IAAI,wBAAwB;AACpE,SAAK,WAAW;AAAA,MACd,QAAQ,CAAC,SAAS,WAAW,SAAS;AACpC,YAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,2DAA2D;AACxF,eAAO,cAAc,SAAS,WAAW,QAAQ,IAAI;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AACF;;;AC3DA,IAAO,gBAAQ;","names":["retryAfter"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smswire",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official Node.js SDK for SMSWire: send SMS and one-time codes through your own Android phones.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"homepage": "https://smswire.app/docs",
|
|
7
|
+
"repository": { "type": "git", "url": "git+https://github.com/jolabs-io/smswire-node.git" },
|
|
8
|
+
"keywords": ["sms", "otp", "android", "gateway", "smswire"],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"engines": { "node": ">=20" },
|
|
11
|
+
"main": "./dist/index.cjs",
|
|
12
|
+
"module": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": { "types": "./dist/index.d.ts", "default": "./dist/index.js" },
|
|
17
|
+
"require": { "types": "./dist/index.d.cts", "default": "./dist/index.cjs" }
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
21
|
+
"sideEffects": false,
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsup",
|
|
24
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
25
|
+
"test": "vitest run",
|
|
26
|
+
"generate": "UPDATE_TYPES=1 vitest run test/types.test.ts",
|
|
27
|
+
"prepublishOnly": "pnpm build"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^22.10.0",
|
|
31
|
+
"openapi-typescript": "^7.8.0",
|
|
32
|
+
"tsup": "^8.5.0",
|
|
33
|
+
"typescript": "~5.9.3",
|
|
34
|
+
"vitest": "^3.2.7"
|
|
35
|
+
}
|
|
36
|
+
}
|