@zeroxyz/sdk 0.1.0 → 0.1.1
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 +6 -0
- package/dist/{chunk-XQEHJX2X.js → chunk-JFORV7AV.js} +42 -8
- package/dist/chunk-JFORV7AV.js.map +1 -0
- package/dist/{chunk-7STN754W.cjs → chunk-XQRINGOJ.cjs} +42 -8
- package/dist/chunk-XQRINGOJ.cjs.map +1 -0
- package/dist/{client-B50UYxPr.d.cts → client-B-Sw9o2m.d.cts} +2 -0
- package/dist/{client-B50UYxPr.d.ts → client-B-Sw9o2m.d.ts} +2 -0
- package/dist/index.cjs +31 -31
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/testing.cjs +2 -2
- package/dist/testing.d.cts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-7STN754W.cjs.map +0 -1
- package/dist/chunk-XQEHJX2X.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,12 @@ All notable changes to `@zeroxyz/sdk` will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) — with the pre-1.0 caveat that minor versions may include breaking changes.
|
|
6
6
|
|
|
7
|
+
## 0.1.1
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- `client.fetch()` now defaults the request `Content-Type` when a body is present and the caller set none — string bodies use `application/json`, byte bodies are sniffed (`{`/`[` ⇒ `application/json`, otherwise `application/octet-stream`). This mirrors the CLI's existing inference. Without it, strict providers (e.g. Locus MPP's `express.json()`) leave `req.body` undefined and crash reading a field off it (`Cannot read properties of undefined (reading '…')`), while lenient providers tolerate the omission — a confusing, provider-dependent failure. A caller-supplied `Content-Type` (any casing) always wins. (#560)
|
|
12
|
+
|
|
7
13
|
## 0.1.0
|
|
8
14
|
|
|
9
15
|
Initial public release.
|
|
@@ -1098,7 +1098,7 @@ var Payments = class {
|
|
|
1098
1098
|
|
|
1099
1099
|
// package.json
|
|
1100
1100
|
var package_default = {
|
|
1101
|
-
version: "0.1.
|
|
1101
|
+
version: "0.1.1"};
|
|
1102
1102
|
|
|
1103
1103
|
// src/version.ts
|
|
1104
1104
|
var SDK_VERSION = package_default.version;
|
|
@@ -1150,7 +1150,13 @@ var deviceStartResponseSchema = z.object({
|
|
|
1150
1150
|
expiresAt: z.number()
|
|
1151
1151
|
});
|
|
1152
1152
|
var devicePollResponseSchema = z.union([
|
|
1153
|
-
|
|
1153
|
+
// userCode + verificationUri are optional: older API deployments don't
|
|
1154
|
+
// echo them on pending.
|
|
1155
|
+
z.object({
|
|
1156
|
+
error: z.literal("authorization_pending"),
|
|
1157
|
+
userCode: z.string().optional(),
|
|
1158
|
+
verificationUri: z.string().optional()
|
|
1159
|
+
}),
|
|
1154
1160
|
z.object({ error: z.literal("expired_token") }),
|
|
1155
1161
|
z.object({
|
|
1156
1162
|
accessToken: z.string(),
|
|
@@ -1424,7 +1430,11 @@ var AuthDevice = class {
|
|
|
1424
1430
|
devicePollResponseSchema
|
|
1425
1431
|
);
|
|
1426
1432
|
if ("error" in parsed) {
|
|
1427
|
-
return parsed.error === "authorization_pending" ? {
|
|
1433
|
+
return parsed.error === "authorization_pending" ? {
|
|
1434
|
+
status: "pending",
|
|
1435
|
+
userCode: parsed.userCode,
|
|
1436
|
+
verificationUri: parsed.verificationUri
|
|
1437
|
+
} : { status: "expired" };
|
|
1428
1438
|
}
|
|
1429
1439
|
return {
|
|
1430
1440
|
status: "ok",
|
|
@@ -2358,11 +2368,34 @@ var recordErrorFetchRun = async (client, opts, result) => {
|
|
|
2358
2368
|
} catch {
|
|
2359
2369
|
}
|
|
2360
2370
|
};
|
|
2371
|
+
var sniffJsonShapeBytes = (buf) => {
|
|
2372
|
+
let i = 0;
|
|
2373
|
+
if (buf.length >= 3 && buf[0] === 239 && buf[1] === 187 && buf[2] === 191) {
|
|
2374
|
+
i = 3;
|
|
2375
|
+
}
|
|
2376
|
+
while (i < buf.length && (buf[i] === 32 || buf[i] === 9 || buf[i] === 10 || buf[i] === 13)) {
|
|
2377
|
+
i++;
|
|
2378
|
+
}
|
|
2379
|
+
if (i >= buf.length) return false;
|
|
2380
|
+
return buf[i] === 123 || buf[i] === 91;
|
|
2381
|
+
};
|
|
2382
|
+
var withDefaultContentType = (headers, body) => {
|
|
2383
|
+
if (!headers && body === void 0) return void 0;
|
|
2384
|
+
const next = headers ? { ...headers } : {};
|
|
2385
|
+
if (body === void 0) return next;
|
|
2386
|
+
const hasContentType = Object.keys(next).some(
|
|
2387
|
+
(k) => k.toLowerCase() === "content-type"
|
|
2388
|
+
);
|
|
2389
|
+
if (!hasContentType) {
|
|
2390
|
+
next["content-type"] = typeof body === "string" || sniffJsonShapeBytes(body) ? "application/json" : "application/octet-stream";
|
|
2391
|
+
}
|
|
2392
|
+
return next;
|
|
2393
|
+
};
|
|
2361
2394
|
var clientFetch = async (client, url, opts = {}) => {
|
|
2362
2395
|
const startedAt = Date.now();
|
|
2363
2396
|
const capabilityIdRequested = opts.capabilityId !== void 0;
|
|
2364
2397
|
const method = opts.method ?? (opts.body !== void 0 ? "POST" : "GET");
|
|
2365
|
-
const probeHeaders = opts.headers
|
|
2398
|
+
const probeHeaders = withDefaultContentType(opts.headers, opts.body);
|
|
2366
2399
|
const requestInit = {
|
|
2367
2400
|
method,
|
|
2368
2401
|
headers: probeHeaders,
|
|
@@ -2400,8 +2433,9 @@ var clientFetch = async (client, url, opts = {}) => {
|
|
|
2400
2433
|
url,
|
|
2401
2434
|
method,
|
|
2402
2435
|
// Fresh clone for the paid retry — same rationale as
|
|
2403
|
-
// the probe-side clone above.
|
|
2404
|
-
|
|
2436
|
+
// the probe-side clone above. Re-derives the default
|
|
2437
|
+
// Content-Type so the paid leg matches the probe.
|
|
2438
|
+
headers: withDefaultContentType(opts.headers, opts.body),
|
|
2405
2439
|
body: opts.body,
|
|
2406
2440
|
maxPay: opts.maxPay,
|
|
2407
2441
|
account: opts.account,
|
|
@@ -3013,5 +3047,5 @@ var ZeroClient = class _ZeroClient {
|
|
|
3013
3047
|
};
|
|
3014
3048
|
|
|
3015
3049
|
export { Auth, AuthDevice, BUG_REPORT_CATEGORIES, BugReports, Capabilities, DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT_MS, FETCH_SKIP_REASONS, FETCH_WARNINGS, Payments, Runs, SDK_VERSION, TEMPO_CHAIN_ID, TEMPO_TESTNET_CHAIN_ID, Wallet, ZeroApiError, ZeroAuthError, ZeroClient, ZeroConfigurationError, ZeroError, ZeroPaymentError, ZeroSessionCloseFailedError, ZeroTimeoutError, ZeroValidationError, ZeroWalletError, coerceTempoChainId, createManagedAccount, paymentHasAnchor, tempoChainLabelFromId };
|
|
3016
|
-
//# sourceMappingURL=chunk-
|
|
3017
|
-
//# sourceMappingURL=chunk-
|
|
3050
|
+
//# sourceMappingURL=chunk-JFORV7AV.js.map
|
|
3051
|
+
//# sourceMappingURL=chunk-JFORV7AV.js.map
|