@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.
@@ -1100,7 +1100,7 @@ var Payments = class {
1100
1100
 
1101
1101
  // package.json
1102
1102
  var package_default = {
1103
- version: "0.1.0"};
1103
+ version: "0.1.1"};
1104
1104
 
1105
1105
  // src/version.ts
1106
1106
  var SDK_VERSION = package_default.version;
@@ -1152,7 +1152,13 @@ var deviceStartResponseSchema = zod.z.object({
1152
1152
  expiresAt: zod.z.number()
1153
1153
  });
1154
1154
  var devicePollResponseSchema = zod.z.union([
1155
- zod.z.object({ error: zod.z.literal("authorization_pending") }),
1155
+ // userCode + verificationUri are optional: older API deployments don't
1156
+ // echo them on pending.
1157
+ zod.z.object({
1158
+ error: zod.z.literal("authorization_pending"),
1159
+ userCode: zod.z.string().optional(),
1160
+ verificationUri: zod.z.string().optional()
1161
+ }),
1156
1162
  zod.z.object({ error: zod.z.literal("expired_token") }),
1157
1163
  zod.z.object({
1158
1164
  accessToken: zod.z.string(),
@@ -1426,7 +1432,11 @@ var AuthDevice = class {
1426
1432
  devicePollResponseSchema
1427
1433
  );
1428
1434
  if ("error" in parsed) {
1429
- return parsed.error === "authorization_pending" ? { status: "pending" } : { status: "expired" };
1435
+ return parsed.error === "authorization_pending" ? {
1436
+ status: "pending",
1437
+ userCode: parsed.userCode,
1438
+ verificationUri: parsed.verificationUri
1439
+ } : { status: "expired" };
1430
1440
  }
1431
1441
  return {
1432
1442
  status: "ok",
@@ -2360,11 +2370,34 @@ var recordErrorFetchRun = async (client, opts, result) => {
2360
2370
  } catch {
2361
2371
  }
2362
2372
  };
2373
+ var sniffJsonShapeBytes = (buf) => {
2374
+ let i = 0;
2375
+ if (buf.length >= 3 && buf[0] === 239 && buf[1] === 187 && buf[2] === 191) {
2376
+ i = 3;
2377
+ }
2378
+ while (i < buf.length && (buf[i] === 32 || buf[i] === 9 || buf[i] === 10 || buf[i] === 13)) {
2379
+ i++;
2380
+ }
2381
+ if (i >= buf.length) return false;
2382
+ return buf[i] === 123 || buf[i] === 91;
2383
+ };
2384
+ var withDefaultContentType = (headers, body) => {
2385
+ if (!headers && body === void 0) return void 0;
2386
+ const next = headers ? { ...headers } : {};
2387
+ if (body === void 0) return next;
2388
+ const hasContentType = Object.keys(next).some(
2389
+ (k) => k.toLowerCase() === "content-type"
2390
+ );
2391
+ if (!hasContentType) {
2392
+ next["content-type"] = typeof body === "string" || sniffJsonShapeBytes(body) ? "application/json" : "application/octet-stream";
2393
+ }
2394
+ return next;
2395
+ };
2363
2396
  var clientFetch = async (client, url, opts = {}) => {
2364
2397
  const startedAt = Date.now();
2365
2398
  const capabilityIdRequested = opts.capabilityId !== void 0;
2366
2399
  const method = opts.method ?? (opts.body !== void 0 ? "POST" : "GET");
2367
- const probeHeaders = opts.headers ? { ...opts.headers } : void 0;
2400
+ const probeHeaders = withDefaultContentType(opts.headers, opts.body);
2368
2401
  const requestInit = {
2369
2402
  method,
2370
2403
  headers: probeHeaders,
@@ -2402,8 +2435,9 @@ var clientFetch = async (client, url, opts = {}) => {
2402
2435
  url,
2403
2436
  method,
2404
2437
  // Fresh clone for the paid retry — same rationale as
2405
- // the probe-side clone above.
2406
- headers: opts.headers ? { ...opts.headers } : void 0,
2438
+ // the probe-side clone above. Re-derives the default
2439
+ // Content-Type so the paid leg matches the probe.
2440
+ headers: withDefaultContentType(opts.headers, opts.body),
2407
2441
  body: opts.body,
2408
2442
  maxPay: opts.maxPay,
2409
2443
  account: opts.account,
@@ -3044,5 +3078,5 @@ exports.coerceTempoChainId = coerceTempoChainId;
3044
3078
  exports.createManagedAccount = createManagedAccount;
3045
3079
  exports.paymentHasAnchor = paymentHasAnchor;
3046
3080
  exports.tempoChainLabelFromId = tempoChainLabelFromId;
3047
- //# sourceMappingURL=chunk-7STN754W.cjs.map
3048
- //# sourceMappingURL=chunk-7STN754W.cjs.map
3081
+ //# sourceMappingURL=chunk-XQRINGOJ.cjs.map
3082
+ //# sourceMappingURL=chunk-XQRINGOJ.cjs.map