@boxline/sdk 1.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/CHANGELOG.md +187 -0
- package/LICENSE +21 -0
- package/README.md +495 -0
- package/dist/client.d.ts +529 -0
- package/dist/client.js +874 -0
- package/dist/client.js.map +1 -0
- package/dist/core.d.ts +77 -0
- package/dist/core.js +223 -0
- package/dist/core.js.map +1 -0
- package/dist/errors.d.ts +300 -0
- package/dist/errors.js +403 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/pagination.d.ts +34 -0
- package/dist/pagination.js +67 -0
- package/dist/pagination.js.map +1 -0
- package/dist/session.d.ts +252 -0
- package/dist/session.js +345 -0
- package/dist/session.js.map +1 -0
- package/dist/streaming.d.ts +7 -0
- package/dist/streaming.js +71 -0
- package/dist/streaming.js.map +1 -0
- package/dist/types.d.ts +2147 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +3 -0
- package/dist/version.js.map +1 -0
- package/dist/webhooks.d.ts +27 -0
- package/dist/webhooks.js +184 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +59 -0
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/version.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { WebhookEvent } from "./types.js";
|
|
2
|
+
export declare const WEBHOOK_SIGNATURE_HEADER = "Boxline-Signature";
|
|
3
|
+
/** How far a delivery's timestamp may be from the receiver's clock (seconds). */
|
|
4
|
+
export declare const WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
5
|
+
export interface VerifyWebhookOptions {
|
|
6
|
+
/** How far the signature's timestamp may be from now, in seconds (default 300). */
|
|
7
|
+
toleranceSeconds?: number;
|
|
8
|
+
/** "Now" in milliseconds (default Date.now()), for tests. */
|
|
9
|
+
now?: number;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Checks a webhook delivery and returns its event (the parsed body); throws WebhookSignatureError otherwise.
|
|
13
|
+
*
|
|
14
|
+
* - `body`: the raw request body exactly as received (a Buffer, Uint8Array or string): re-serialised JSON will not
|
|
15
|
+
* match.
|
|
16
|
+
* - `header`: the `Boxline-Signature` header.
|
|
17
|
+
* - `secret`: the endpoint's `whsec_…` secret, or several (e.g. `[newSecret, oldSecret]` while you switch after a
|
|
18
|
+
* rotation): the delivery is accepted when any of them signed it.
|
|
19
|
+
*
|
|
20
|
+
* A delivery can arrive more than once: after verifying, drop an event `id` you have handled already.
|
|
21
|
+
*/
|
|
22
|
+
export declare function verifyWebhook<T = Record<string, unknown>>(body: string | Uint8Array | ArrayBuffer, header: string | null | undefined, secret: string | string[], opts?: VerifyWebhookOptions): WebhookEvent<T>;
|
|
23
|
+
/**
|
|
24
|
+
* A `Boxline-Signature` value for `body`, as the API signs deliveries: for testing your own receiver. With several
|
|
25
|
+
* secrets it has one v1 per secret, the first one first (as during a rotation).
|
|
26
|
+
*/
|
|
27
|
+
export declare function webhookSignatureHeader(secret: string | string[], body: string | Uint8Array | ArrayBuffer, timestamp?: number): string;
|
package/dist/webhooks.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Verifying webhook deliveries (docs/CONTRACT.md "Webhooks", "Signatures"). Every delivery carries
|
|
3
|
+
*
|
|
4
|
+
* Boxline-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">[,v1=…]
|
|
5
|
+
*
|
|
6
|
+
* keyed with the endpoint's secret (the whole `whsec_…` string as UTF-8); for 24 hours after a rotation a second v1
|
|
7
|
+
* signed with the old secret follows. verifyWebhook accepts and refuses exactly what the API's reference
|
|
8
|
+
* (apps/api/src/webhooks/signing.ts) does; tests/unit/sdk-webhooks.test.ts checks it against vectors from that signer.
|
|
9
|
+
*
|
|
10
|
+
* HMAC-SHA256 is computed here without node:crypto or Web Crypto, so the check is synchronous and works the same in
|
|
11
|
+
* Node 18+, Deno, Bun, edge runtimes and browsers.
|
|
12
|
+
*/
|
|
13
|
+
import { WebhookSignatureError } from "./errors.js";
|
|
14
|
+
export const WEBHOOK_SIGNATURE_HEADER = "Boxline-Signature";
|
|
15
|
+
/** How far a delivery's timestamp may be from the receiver's clock (seconds). */
|
|
16
|
+
export const WEBHOOK_TOLERANCE_SECONDS = 300;
|
|
17
|
+
// ---------------------------------------------------------------- HMAC-SHA256 (FIPS 180-4, RFC 2104)
|
|
18
|
+
const K = new Uint32Array([
|
|
19
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
|
20
|
+
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
21
|
+
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
|
22
|
+
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
23
|
+
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
|
24
|
+
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
25
|
+
]);
|
|
26
|
+
const rotr = (x, n) => (x >>> n) | (x << (32 - n));
|
|
27
|
+
function sha256(data) {
|
|
28
|
+
const H = new Uint32Array([0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19]);
|
|
29
|
+
const blocks = Math.ceil((data.length + 9) / 64);
|
|
30
|
+
const padded = new Uint8Array(blocks * 64);
|
|
31
|
+
padded.set(data);
|
|
32
|
+
padded[data.length] = 0x80;
|
|
33
|
+
const view = new DataView(padded.buffer);
|
|
34
|
+
view.setUint32(padded.length - 8, Math.floor(data.length / 0x20000000)); // bit length, high word
|
|
35
|
+
view.setUint32(padded.length - 4, (data.length * 8) >>> 0); // bit length, low word
|
|
36
|
+
const W = new Uint32Array(64);
|
|
37
|
+
for (let off = 0; off < padded.length; off += 64) {
|
|
38
|
+
for (let i = 0; i < 16; i++)
|
|
39
|
+
W[i] = view.getUint32(off + i * 4);
|
|
40
|
+
for (let i = 16; i < 64; i++) {
|
|
41
|
+
const s0 = rotr(W[i - 15], 7) ^ rotr(W[i - 15], 18) ^ (W[i - 15] >>> 3);
|
|
42
|
+
const s1 = rotr(W[i - 2], 17) ^ rotr(W[i - 2], 19) ^ (W[i - 2] >>> 10);
|
|
43
|
+
W[i] = (W[i - 16] + s0 + W[i - 7] + s1) >>> 0;
|
|
44
|
+
}
|
|
45
|
+
let [a, b, c, d, e, f, g, h] = H;
|
|
46
|
+
for (let i = 0; i < 64; i++) {
|
|
47
|
+
const t1 = (h + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + ((e & f) ^ (~e & g)) + K[i] + W[i]) >>> 0;
|
|
48
|
+
const t2 = ((rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + ((a & b) ^ (a & c) ^ (b & c))) >>> 0;
|
|
49
|
+
h = g;
|
|
50
|
+
g = f;
|
|
51
|
+
f = e;
|
|
52
|
+
e = (d + t1) >>> 0;
|
|
53
|
+
d = c;
|
|
54
|
+
c = b;
|
|
55
|
+
b = a;
|
|
56
|
+
a = (t1 + t2) >>> 0;
|
|
57
|
+
}
|
|
58
|
+
H[0] = (H[0] + a) >>> 0;
|
|
59
|
+
H[1] = (H[1] + b) >>> 0;
|
|
60
|
+
H[2] = (H[2] + c) >>> 0;
|
|
61
|
+
H[3] = (H[3] + d) >>> 0;
|
|
62
|
+
H[4] = (H[4] + e) >>> 0;
|
|
63
|
+
H[5] = (H[5] + f) >>> 0;
|
|
64
|
+
H[6] = (H[6] + g) >>> 0;
|
|
65
|
+
H[7] = (H[7] + h) >>> 0;
|
|
66
|
+
}
|
|
67
|
+
const out = new Uint8Array(32);
|
|
68
|
+
const outView = new DataView(out.buffer);
|
|
69
|
+
for (let i = 0; i < 8; i++)
|
|
70
|
+
outView.setUint32(i * 4, H[i]);
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
function concat(...parts) {
|
|
74
|
+
const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
|
|
75
|
+
let at = 0;
|
|
76
|
+
for (const p of parts) {
|
|
77
|
+
out.set(p, at);
|
|
78
|
+
at += p.length;
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
function hmacSha256(key, message) {
|
|
83
|
+
const block = new Uint8Array(64);
|
|
84
|
+
block.set(key.length > 64 ? sha256(key) : key);
|
|
85
|
+
const inner = block.map((b) => b ^ 0x36);
|
|
86
|
+
const outer = block.map((b) => b ^ 0x5c);
|
|
87
|
+
return sha256(concat(outer, sha256(concat(inner, message))));
|
|
88
|
+
}
|
|
89
|
+
const utf8 = (s) => new TextEncoder().encode(s);
|
|
90
|
+
const toHex = (bytes) => Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
91
|
+
/** Raw body bytes: a string is taken as UTF-8, like the API's signer does. */
|
|
92
|
+
function bodyBytes(body) {
|
|
93
|
+
if (typeof body === "string")
|
|
94
|
+
return utf8(body);
|
|
95
|
+
return body instanceof Uint8Array ? body : new Uint8Array(body);
|
|
96
|
+
}
|
|
97
|
+
/** hex HMAC-SHA256 of `${timestamp}.${body}`, keyed with the secret string. */
|
|
98
|
+
function signature(secret, timestamp, body) {
|
|
99
|
+
return toHex(hmacSha256(utf8(secret), concat(utf8(`${timestamp}.`), body)));
|
|
100
|
+
}
|
|
101
|
+
/** Compares two strings of equal length without stopping at the first difference. */
|
|
102
|
+
function constantTimeEqual(a, b) {
|
|
103
|
+
if (a.length !== b.length)
|
|
104
|
+
return false;
|
|
105
|
+
let diff = 0;
|
|
106
|
+
for (let i = 0; i < a.length; i++)
|
|
107
|
+
diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
108
|
+
return diff === 0;
|
|
109
|
+
}
|
|
110
|
+
// ---------------------------------------------------------------- the header
|
|
111
|
+
/** Reads `t=…,v1=…[,v1=…]` exactly as the API does; other keys are ignored. null when there is no usable t or v1. */
|
|
112
|
+
function parseHeader(header) {
|
|
113
|
+
if (typeof header !== "string" || header.length > 4096)
|
|
114
|
+
return null;
|
|
115
|
+
let timestamp = null;
|
|
116
|
+
const v1 = [];
|
|
117
|
+
for (const part of header.split(",")) {
|
|
118
|
+
const i = part.indexOf("=");
|
|
119
|
+
if (i <= 0)
|
|
120
|
+
continue;
|
|
121
|
+
const key = part.slice(0, i).trim();
|
|
122
|
+
const value = part.slice(i + 1).trim();
|
|
123
|
+
if (key === "t" && /^\d{1,12}$/.test(value))
|
|
124
|
+
timestamp = Number(value);
|
|
125
|
+
else if (key === "v1" && /^[0-9a-f]{64}$/.test(value))
|
|
126
|
+
v1.push(value);
|
|
127
|
+
}
|
|
128
|
+
return timestamp !== null && v1.length ? { timestamp, v1 } : null;
|
|
129
|
+
}
|
|
130
|
+
function failure(reason, tolerance, several) {
|
|
131
|
+
const message = reason === "malformed"
|
|
132
|
+
? `the ${WEBHOOK_SIGNATURE_HEADER} header is missing or malformed`
|
|
133
|
+
: reason === "timestamp_out_of_range"
|
|
134
|
+
? `the ${WEBHOOK_SIGNATURE_HEADER} timestamp is more than ${tolerance % 60 === 0 ? `${tolerance / 60} minutes` : `${tolerance} seconds`} from now`
|
|
135
|
+
: `no signature matches ${several ? "these secrets" : "this secret"} (check the secret, and that the body is the raw bytes as received)`;
|
|
136
|
+
return new WebhookSignatureError(reason, message);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Checks a webhook delivery and returns its event (the parsed body); throws WebhookSignatureError otherwise.
|
|
140
|
+
*
|
|
141
|
+
* - `body`: the raw request body exactly as received (a Buffer, Uint8Array or string): re-serialised JSON will not
|
|
142
|
+
* match.
|
|
143
|
+
* - `header`: the `Boxline-Signature` header.
|
|
144
|
+
* - `secret`: the endpoint's `whsec_…` secret, or several (e.g. `[newSecret, oldSecret]` while you switch after a
|
|
145
|
+
* rotation): the delivery is accepted when any of them signed it.
|
|
146
|
+
*
|
|
147
|
+
* A delivery can arrive more than once: after verifying, drop an event `id` you have handled already.
|
|
148
|
+
*/
|
|
149
|
+
export function verifyWebhook(body, header, secret, opts = {}) {
|
|
150
|
+
const secrets = Array.isArray(secret) ? secret : [secret];
|
|
151
|
+
const tolerance = opts.toleranceSeconds ?? WEBHOOK_TOLERANCE_SECONDS;
|
|
152
|
+
const parsed = parseHeader(header);
|
|
153
|
+
if (!parsed)
|
|
154
|
+
throw failure("malformed", tolerance, secrets.length > 1);
|
|
155
|
+
const now = Math.floor((opts.now ?? Date.now()) / 1000);
|
|
156
|
+
if (Math.abs(now - parsed.timestamp) > tolerance)
|
|
157
|
+
throw failure("timestamp_out_of_range", tolerance, secrets.length > 1);
|
|
158
|
+
const bytes = bodyBytes(body);
|
|
159
|
+
let match = false;
|
|
160
|
+
for (const s of secrets) {
|
|
161
|
+
const want = signature(s, parsed.timestamp, bytes);
|
|
162
|
+
// Every signature is compared, so the time taken does not say which one (or how much of it) matched.
|
|
163
|
+
for (const got of parsed.v1)
|
|
164
|
+
if (constantTimeEqual(got, want))
|
|
165
|
+
match = true;
|
|
166
|
+
}
|
|
167
|
+
if (!match)
|
|
168
|
+
throw failure("no_matching_signature", tolerance, secrets.length > 1);
|
|
169
|
+
// Kept byte for byte like the API's reference: a leading byte-order mark stays (and JSON.parse refuses it).
|
|
170
|
+
const text = typeof body === "string" ? body : new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes);
|
|
171
|
+
return JSON.parse(text);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* A `Boxline-Signature` value for `body`, as the API signs deliveries: for testing your own receiver. With several
|
|
175
|
+
* secrets it has one v1 per secret, the first one first (as during a rotation).
|
|
176
|
+
*/
|
|
177
|
+
export function webhookSignatureHeader(secret, body, timestamp = Math.floor(Date.now() / 1000)) {
|
|
178
|
+
const secrets = Array.isArray(secret) ? secret : [secret];
|
|
179
|
+
if (!secrets.length)
|
|
180
|
+
throw new Error("no signing secret");
|
|
181
|
+
const bytes = bodyBytes(body);
|
|
182
|
+
return [`t=${timestamp}`, ...secrets.map((s) => `v1=${signature(s, timestamp, bytes)}`)].join(",");
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=webhooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../src/webhooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,qBAAqB,EAAgC,MAAM,aAAa,CAAC;AAGlF,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAC5D,iFAAiF;AACjF,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAE7C,sGAAsG;AAEtG,MAAM,CAAC,GAAG,IAAI,W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AAK,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACrG,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@boxline/sdk",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Node and TypeScript SDK for Boxline: cloud browsers and shell sandboxes for AI agents, with retries, cursor pages and typed errors.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"boxline",
|
|
7
|
+
"browser",
|
|
8
|
+
"headless",
|
|
9
|
+
"chrome",
|
|
10
|
+
"playwright",
|
|
11
|
+
"puppeteer",
|
|
12
|
+
"cdp",
|
|
13
|
+
"sandbox",
|
|
14
|
+
"ai-agents",
|
|
15
|
+
"automation"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"author": "Boxline",
|
|
19
|
+
"homepage": "https://docs.boxline.dev",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "dist/index.js",
|
|
22
|
+
"types": "dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"CHANGELOG.md"
|
|
34
|
+
],
|
|
35
|
+
"sideEffects": false,
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
},
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/Boxline-dev/sdk-node.git"
|
|
45
|
+
},
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/Boxline-dev/sdk-node/issues"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"build": "tsc -p tsconfig.json",
|
|
51
|
+
"typecheck": "tsc -p tsconfig.json --noEmit && tsc -p examples/tsconfig.json",
|
|
52
|
+
"prepublishOnly": "tsc -p tsconfig.json"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"typescript": "~6.0.3",
|
|
56
|
+
"@types/node": "^22.15.0",
|
|
57
|
+
"playwright-core": "^1.63.0"
|
|
58
|
+
}
|
|
59
|
+
}
|