@neetru/sdk 3.7.0 → 3.8.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +66 -1
  3. package/dist/ai.cjs +221 -177
  4. package/dist/ai.d.cts +1 -1
  5. package/dist/ai.d.ts +1 -1
  6. package/dist/ai.mjs +221 -177
  7. package/dist/auth.cjs +1227 -1064
  8. package/dist/auth.d.cts +1 -1
  9. package/dist/auth.d.ts +1 -1
  10. package/dist/auth.mjs +1224 -1061
  11. package/dist/catalog.cjs +164 -97
  12. package/dist/catalog.d.cts +1 -1
  13. package/dist/catalog.d.ts +1 -1
  14. package/dist/catalog.mjs +164 -97
  15. package/dist/checkout.cjs +182 -115
  16. package/dist/checkout.d.cts +1 -1
  17. package/dist/checkout.d.ts +1 -1
  18. package/dist/checkout.mjs +181 -114
  19. package/dist/db-react.d.cts +1 -1
  20. package/dist/db-react.d.ts +1 -1
  21. package/dist/db.cjs +370 -298
  22. package/dist/db.d.cts +1 -1
  23. package/dist/db.d.ts +1 -1
  24. package/dist/db.mjs +362 -290
  25. package/dist/entitlements.cjs +17 -10
  26. package/dist/entitlements.d.cts +1 -1
  27. package/dist/entitlements.d.ts +1 -1
  28. package/dist/entitlements.mjs +17 -10
  29. package/dist/errors.cjs +15 -8
  30. package/dist/errors.d.cts +24 -3
  31. package/dist/errors.d.ts +24 -3
  32. package/dist/errors.mjs +14 -7
  33. package/dist/firestore-compat.d.cts +1 -1
  34. package/dist/firestore-compat.d.ts +1 -1
  35. package/dist/index.cjs +1409 -1075
  36. package/dist/index.d.cts +177 -3
  37. package/dist/index.d.ts +177 -3
  38. package/dist/index.mjs +1544 -1217
  39. package/dist/mobile.cjs +400 -181
  40. package/dist/mobile.d.cts +59 -4
  41. package/dist/mobile.d.ts +59 -4
  42. package/dist/mobile.mjs +400 -181
  43. package/dist/mocks.cjs +9 -2
  44. package/dist/mocks.d.cts +1 -1
  45. package/dist/mocks.d.ts +1 -1
  46. package/dist/mocks.mjs +9 -2
  47. package/dist/notifications.cjs +197 -130
  48. package/dist/notifications.d.cts +1 -1
  49. package/dist/notifications.d.ts +1 -1
  50. package/dist/notifications.mjs +196 -129
  51. package/dist/react.cjs +303 -282
  52. package/dist/react.d.cts +1 -1
  53. package/dist/react.d.ts +1 -1
  54. package/dist/react.mjs +295 -274
  55. package/dist/support.cjs +299 -229
  56. package/dist/support.d.cts +8 -4
  57. package/dist/support.d.ts +8 -4
  58. package/dist/support.mjs +298 -228
  59. package/dist/telemetry.cjs +234 -167
  60. package/dist/telemetry.d.cts +1 -1
  61. package/dist/telemetry.d.ts +1 -1
  62. package/dist/telemetry.mjs +234 -167
  63. package/dist/{types-Bx4kTLmk.d.cts → types-D-9bjlM0.d.cts} +48 -1
  64. package/dist/{types-Dx0IrOSF.d.ts → types-bVztFQTI.d.ts} +48 -1
  65. package/dist/usage.cjs +183 -116
  66. package/dist/usage.d.cts +1 -1
  67. package/dist/usage.d.ts +1 -1
  68. package/dist/usage.mjs +183 -116
  69. package/dist/webhooks.cjs +215 -148
  70. package/dist/webhooks.d.cts +1 -1
  71. package/dist/webhooks.d.ts +1 -1
  72. package/dist/webhooks.mjs +212 -145
  73. package/package.json +2 -1
package/dist/checkout.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  // src/errors.ts
4
- var o = class t extends Error {
4
+ var i = class t extends Error {
5
5
  code;
6
6
  status;
7
7
  requestId;
@@ -14,8 +14,15 @@ var o = class t extends Error {
14
14
  * para um `NeetruDbErrorCode` mais específico (recuperável vs não).
15
15
  */
16
16
  reason;
17
- constructor(e, n, r, s, a) {
18
- super(n), this.name = "NeetruError", this.code = e, this.status = r, this.requestId = s, this.reason = a, Object.setPrototypeOf(this, t.prototype);
17
+ /**
18
+ * 3.8.0: `x-correlation-id` da requisição que falhou. O SDK gera um UUID por
19
+ * chamada (ou usa o que o chamador passou) e manda no header; o Core grava o
20
+ * mesmo id nos logs/auditoria — cite-o ao abrir um ticket de suporte.
21
+ * `undefined` em erros que acontecem antes de qualquer requisição.
22
+ */
23
+ correlationId;
24
+ constructor(e, n, r, o, a, c) {
25
+ super(n), this.name = "NeetruError", this.code = e, this.status = r, this.requestId = o, this.reason = a, this.correlationId = c, Object.setPrototypeOf(this, t.prototype);
19
26
  }
20
27
  };
21
28
 
@@ -24,14 +31,66 @@ function E() {
24
31
  let t = typeof globalThis < "u" && "crypto" in globalThis ? globalThis.crypto : void 0;
25
32
  if (t && typeof t.randomUUID == "function")
26
33
  return t.randomUUID();
27
- throw new o(
34
+ throw new i(
28
35
  "runtime_unsupported",
29
36
  "crypto.randomUUID not available in this runtime. SDK 3.0 requires Node \u226520 or modern browser/Edge."
30
37
  );
31
38
  }
32
39
 
40
+ // src/correlation.ts
41
+ var A = "x-correlation-id";
42
+ var L = /^[A-Za-z0-9._:\-]+$/;
43
+ function x(t) {
44
+ return typeof t == "string" && t.length > 0 && t.length <= 128 && L.test(t);
45
+ }
46
+ function H() {
47
+ let t = globalThis.crypto;
48
+ try {
49
+ if (t && typeof t.randomUUID == "function") return t.randomUUID();
50
+ } catch {
51
+ }
52
+ let e = new Uint8Array(16), n = false;
53
+ try {
54
+ t && typeof t.getRandomValues == "function" && (t.getRandomValues(e), n = !0);
55
+ } catch {
56
+ n = false;
57
+ }
58
+ if (!n)
59
+ for (let o = 0; o < e.length; o++) e[o] = Math.floor(Math.random() * 256);
60
+ e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128;
61
+ let r = Array.from(e, (o) => o.toString(16).padStart(2, "0")).join("");
62
+ return `${r.slice(0, 8)}-${r.slice(8, 12)}-${r.slice(12, 16)}-${r.slice(16, 20)}-${r.slice(20)}`;
63
+ }
64
+ function N(t, e) {
65
+ let n, r = {};
66
+ for (let [a, c] of Object.entries(t)) {
67
+ if (a.toLowerCase() === A) {
68
+ x(c) && (n = c);
69
+ continue;
70
+ }
71
+ r[a] = c;
72
+ }
73
+ let o = n ?? (x(e) ? e : void 0) ?? H();
74
+ return r[A] = o, { headers: r, correlationId: o };
75
+ }
76
+
77
+ // src/server-only-key.ts
78
+ function D() {
79
+ try {
80
+ let t = globalThis.navigator;
81
+ if (t && t.product === "ReactNative") return "react-native";
82
+ } catch {
83
+ }
84
+ try {
85
+ let t = globalThis;
86
+ if (typeof t.window < "u" && typeof t.document < "u") return "browser";
87
+ } catch {
88
+ }
89
+ return null;
90
+ }
91
+
33
92
  // src/http.ts
34
- var P = {
93
+ var B = {
35
94
  // SDK major 3.x requer Core ≥ 2026.05.1 (suporte a X-Neetru-Version header,
36
95
  // runTransaction write-after-read, verifyWebhookRequest, webhooks 3.0+)
37
96
  3: "2026.05.1"
@@ -39,73 +98,77 @@ var P = {
39
98
  function b(t) {
40
99
  return t.split("+")[0] ?? t;
41
100
  }
42
- function M(t, e) {
43
- let n = b(t).split(".").map(Number), r = b(e).split(".").map(Number), s = Math.max(n.length, r.length);
44
- for (let a = 0; a < s; a++) {
45
- let d = n[a] ?? 0, u = r[a] ?? 0;
46
- if (d !== u) return d - u;
101
+ function G(t, e) {
102
+ let n = b(t).split(".").map(Number), r = b(e).split(".").map(Number), o = Math.max(n.length, r.length);
103
+ for (let a = 0; a < o; a++) {
104
+ let c = n[a] ?? 0, u = r[a] ?? 0;
105
+ if (c !== u) return c - u;
47
106
  }
48
107
  return 0;
49
108
  }
50
- function D() {
109
+ function M() {
51
110
  try {
52
- return "3.7.0";
111
+ return "3.8.0";
53
112
  } catch {
54
113
  return;
55
114
  }
56
115
  }
57
- function $() {
58
- let t = D();
116
+ function F() {
117
+ let t = M();
59
118
  return t ? parseInt(t.split(".")[0] ?? "3", 10) : 3;
60
119
  }
61
- var v = /* @__PURE__ */ new Set();
62
- function K(t) {
120
+ var U = /* @__PURE__ */ new Set();
121
+ function V(t) {
63
122
  if (!t) return;
64
- let e = $(), n = P[e];
123
+ let e = F(), n = B[e];
65
124
  if (!n) return;
66
125
  let r = b(t);
67
- if (M(r, n) < 0) {
68
- let s = `${e}:${r}`;
69
- v.has(s) || (v.add(s), console.warn(
126
+ if (G(r, n) < 0) {
127
+ let o = `${e}:${r}`;
128
+ U.has(o) || (U.add(o), console.warn(
70
129
  `[Neetru SDK] Aten\xE7\xE3o: Core vers\xE3o "${t}" \xE9 anterior ao m\xEDnimo recomendado "${n}" para SDK major ${e}. Alguns recursos podem n\xE3o funcionar corretamente. Atualize o Core para a vers\xE3o mais recente.`
71
130
  ));
72
131
  }
73
132
  }
74
- var j = 2, G = 0, H = /* @__PURE__ */ new Set(["GET", "HEAD"]), F = /* @__PURE__ */ new Set([
133
+ function z() {
134
+ let t = "This operation requires an apiKey. Pass it to createNeetruClient({ apiKey }) or set NEETRU_API_KEY env var.";
135
+ return D() ? "Esta opera\xE7\xE3o exige a credencial nrt_ do produto, que \xE9 S\xD3 DE SERVIDOR. No navegador/app, chame a API do seu produto (ex.: https://<produto>.neetru.com/api/v1) com o token do usu\xE1rio \u2014 o backend do produto faz esta chamada com o SDK e a chave. (" + t + ")" : t;
136
+ }
137
+ var X = 2, Y = 0, J = /* @__PURE__ */ new Set(["GET", "HEAD"]), W = /* @__PURE__ */ new Set([
75
138
  "rate_limited",
76
139
  "server_error",
77
140
  "network_error"
78
141
  ]);
79
- function x(t) {
142
+ function O(t) {
80
143
  let e = 200 * Math.pow(4, t), n = e * 0.2 * (Math.random() * 2 - 1);
81
144
  return Math.max(50, Math.round(e + n));
82
145
  }
83
- var A = 6e4;
84
- function B(t) {
146
+ var q = 6e4;
147
+ function Z(t) {
85
148
  if (!t) return null;
86
149
  let e = Number(t);
87
- if (Number.isFinite(e) && e >= 0) return Math.min(Math.round(e * 1e3), A);
150
+ if (Number.isFinite(e) && e >= 0) return Math.min(Math.round(e * 1e3), q);
88
151
  let n = Date.parse(t);
89
152
  if (Number.isFinite(n)) {
90
153
  let r = n - Date.now();
91
- if (r > 0) return Math.min(r, A);
154
+ if (r > 0) return Math.min(r, q);
92
155
  }
93
156
  return null;
94
157
  }
95
- function U(t) {
158
+ function K(t) {
96
159
  return new Promise((e) => setTimeout(e, t));
97
160
  }
98
- function L(t) {
161
+ function Q(t) {
99
162
  return t === 401 ? "unauthorized" : t === 403 ? "forbidden" : t === 404 ? "not_found" : t === 409 ? "conflict" : t === 410 ? "gone" : t === 422 || t === 400 ? "validation_failed" : t === 429 ? "rate_limited" : t >= 500 ? "server_error" : "unknown";
100
163
  }
101
- function z(t, e, n) {
102
- let r = t.replace(/\/+$/, ""), s = e.startsWith("/") ? e : `/${e}`, a = new URL(`${r}${s}`);
164
+ function ee(t, e, n) {
165
+ let r = t.replace(/\/+$/, ""), o = e.startsWith("/") ? e : `/${e}`, a = new URL(`${r}${o}`);
103
166
  if (n)
104
- for (let [d, u] of Object.entries(n))
105
- u !== void 0 && a.searchParams.set(d, String(u));
167
+ for (let [c, u] of Object.entries(n))
168
+ u !== void 0 && a.searchParams.set(c, String(u));
106
169
  return a.toString();
107
170
  }
108
- async function q(t) {
171
+ async function P(t) {
109
172
  let e = await t.text();
110
173
  if (e)
111
174
  try {
@@ -115,91 +178,95 @@ async function q(t) {
115
178
  }
116
179
  }
117
180
  async function y(t, e) {
118
- let n = e.method ?? "GET", r = z(t.baseUrl, e.path, e.query), s = H.has(n) ? j : G, a = e.retries ?? s, d = {
119
- accept: "application/json",
120
- ...e.headers
121
- }, u = D();
122
- if (u && (d["x-neetru-sdk-version"] = u), e.requireAuth) {
181
+ let n = e.method ?? "GET", r = ee(t.baseUrl, e.path, e.query), o = J.has(n) ? X : Y, a = e.retries ?? o, { headers: c, correlationId: u } = N(
182
+ { accept: "application/json", ...e.headers },
183
+ e.correlationId
184
+ ), C = M();
185
+ if (C && (c["x-neetru-sdk-version"] = C), e.requireAuth) {
123
186
  if (!t.apiKey)
124
- throw new o(
125
- "missing_api_key",
126
- "This operation requires an apiKey. Pass it to createNeetruClient({ apiKey }) or set NEETRU_API_KEY env var."
127
- );
128
- d.authorization = `Bearer ${t.apiKey}`;
187
+ throw new i("missing_api_key", z());
188
+ c.authorization = `Bearer ${t.apiKey}`;
129
189
  }
130
190
  if (e.idempotencyKey) {
131
191
  let f = typeof e.idempotencyKey == "string" ? e.idempotencyKey : E();
132
- d["idempotency-key"] = f;
192
+ c["idempotency-key"] = f;
133
193
  }
134
194
  let I = e.body !== void 0 && n !== "GET" && n !== "DELETE" ? JSON.stringify(e.body) : void 0;
135
- I !== void 0 && (d["content-type"] = "application/json");
195
+ I !== void 0 && (c["content-type"] = "application/json");
136
196
  let g = null, p = e.deadlineMs != null ? Date.now() + e.deadlineMs : null;
137
197
  for (let f = 0; f <= a; f++) {
138
198
  if (p != null && Date.now() >= p)
139
- throw g ?? new o("network_error", "Deadline excedido antes de completar a request");
140
- let w = { method: n, headers: d };
141
- I !== void 0 && (w.body = I);
142
- let N = p != null ? Math.max(1, Math.min(3e4, p - Date.now())) : 3e4;
143
- w.signal = AbortSignal.timeout(N);
144
- let c;
199
+ throw g ?? new i(
200
+ "network_error",
201
+ "Deadline excedido antes de completar a request",
202
+ void 0,
203
+ void 0,
204
+ void 0,
205
+ u
206
+ );
207
+ let _ = { method: n, headers: c };
208
+ I !== void 0 && (_.body = I);
209
+ let $ = p != null ? Math.max(1, Math.min(3e4, p - Date.now())) : 3e4;
210
+ _.signal = AbortSignal.timeout($);
211
+ let d;
145
212
  try {
146
- c = await t.fetch(r, w);
147
- } catch (i) {
148
- let k = i instanceof DOMException && i.name === "TimeoutError" ? "Network error: timeout after 30s" : `Network error: ${i instanceof Error ? i.message : "fetch failed"}`;
149
- if (g = new o("network_error", k), f < a) {
150
- let S = x(f);
213
+ d = await t.fetch(r, _);
214
+ } catch (s) {
215
+ let m = s instanceof DOMException && s.name === "TimeoutError" ? "Network error: timeout after 30s" : `Network error: ${s instanceof Error ? s.message : "fetch failed"}`;
216
+ if (g = new i("network_error", m, void 0, void 0, void 0, u), f < a) {
217
+ let S = O(f);
151
218
  if (p == null || Date.now() + S < p) {
152
- await U(S);
219
+ await K(S);
153
220
  continue;
154
221
  }
155
222
  }
156
223
  throw g;
157
224
  }
158
- let O = c.headers.get("x-request-id") ?? c.headers.get("x-correlation-id") ?? void 0;
159
- if (c.ok) {
160
- let i = c.headers.get("x-neetru-version");
161
- return i && K(i), await q(c);
225
+ let j = d.headers.get("x-request-id") ?? d.headers.get("x-correlation-id") ?? void 0;
226
+ if (d.ok) {
227
+ let s = d.headers.get("x-neetru-version");
228
+ return s && V(s), await P(d);
162
229
  }
163
- let l = await q(c), m = L(c.status), h = `HTTP ${c.status}`, T;
230
+ let l = await P(d), k = Q(d.status), h = `HTTP ${d.status}`, w;
164
231
  if (l && typeof l == "object") {
165
- let i = l.error;
166
- typeof i == "string" ? h = i : i && typeof i == "object" ? (typeof i.code == "string" && (m = i.code), typeof i.message == "string" && (h = i.message), typeof i.reason == "string" && (T = i.reason)) : (typeof l.code == "string" && (m = l.code), typeof l.message == "string" && (h = l.message)), typeof l.reason == "string" && (T = l.reason);
232
+ let s = l.error;
233
+ typeof s == "string" ? h = s : s && typeof s == "object" ? (typeof s.code == "string" && (k = s.code), typeof s.message == "string" && (h = s.message), typeof s.reason == "string" && (w = s.reason)) : (typeof l.code == "string" && (k = l.code), typeof l.message == "string" && (h = l.message)), typeof l.reason == "string" && (w = l.reason);
167
234
  }
168
- if (c.status === 410) {
169
- let i = c.headers.get("x-neetru-replacement");
170
- h === `HTTP ${c.status}` && (h = `Endpoint ${e.path} foi removido do Core (HTTP 410 Gone) \u2014 atualize o @neetru/sdk e migre para a API substituta.`), i && !h.includes(i) && (h += ` Substituto: ${i}.`);
235
+ if (d.status === 410) {
236
+ let s = d.headers.get("x-neetru-replacement");
237
+ h === `HTTP ${d.status}` && (h = `Endpoint ${e.path} foi removido do Core (HTTP 410 Gone) \u2014 atualize o @neetru/sdk e migre para a API substituta.`), s && !h.includes(s) && (h += ` Substituto: ${s}.`);
171
238
  }
172
- let R = new o(m, h, c.status, O, T);
173
- if (g = R, F.has(m) && f < a) {
174
- let k = B(c.headers.get("retry-after")) ?? x(f);
175
- if (p == null || Date.now() + k < p) {
176
- await U(k);
239
+ let v = new i(k, h, d.status, j, w, u);
240
+ if (g = v, W.has(k) && f < a) {
241
+ let m = Z(d.headers.get("retry-after")) ?? O(f);
242
+ if (p == null || Date.now() + m < p) {
243
+ await K(m);
177
244
  continue;
178
245
  }
179
246
  }
180
- throw R;
247
+ throw v;
181
248
  }
182
- throw g ?? new o("unknown", "unexpected httpRequest exit");
249
+ throw g ?? new i("unknown", "unexpected httpRequest exit", void 0, void 0, void 0, u);
183
250
  }
184
251
 
185
252
  // src/checkout.ts
186
- function _(t, e) {
253
+ function T(t, e) {
187
254
  let n = t?.accessToken || t?.idToken;
188
255
  if (!n || typeof n != "string")
189
- throw new o(
256
+ throw new i(
190
257
  "validation_failed",
191
258
  `checkout.${e} requer o access_token OU o id_token OIDC do usu\xE1rio final (passe \`accessToken\` ou \`idToken\`). A chave de API do SDK (nrt_*) N\xC3O \xE9 aceita pelo endpoint de checkout \u2014 ele autentica a identidade do cliente que est\xE1 assinando (Bearer access_token/id_token OIDC ou cookie de sess\xE3o). No padr\xE3o BFF/cookie, passe o \`idToken\` que seu servidor guardou no cookie httpOnly.`
192
259
  );
193
260
  return { requireAuth: false, headers: { authorization: `Bearer ${n}` } };
194
261
  }
195
- function V(t) {
262
+ function te(t) {
196
263
  if (!t || typeof t != "object")
197
- throw new o("invalid_response", "checkout.start response is not an object");
264
+ throw new i("invalid_response", "checkout.start response is not an object");
198
265
  let e = t;
199
266
  if (typeof e.intentId != "string" || !e.intentId)
200
- throw new o("invalid_response", "checkout.start response missing intentId");
267
+ throw new i("invalid_response", "checkout.start response missing intentId");
201
268
  if (typeof e.redirectUrl != "string" || !e.redirectUrl)
202
- throw new o("invalid_response", "checkout.start response missing redirectUrl");
269
+ throw new i("invalid_response", "checkout.start response missing redirectUrl");
203
270
  return {
204
271
  intentId: e.intentId,
205
272
  redirectUrl: e.redirectUrl,
@@ -208,14 +275,14 @@ function V(t) {
208
275
  requiresKyc: e.requiresKyc === true
209
276
  };
210
277
  }
211
- function J(t) {
278
+ function ne(t) {
212
279
  if (!t || typeof t != "object")
213
- throw new o("invalid_response", "checkout.get response is not an object");
280
+ throw new i("invalid_response", "checkout.get response is not an object");
214
281
  let e = t, n = e.intent;
215
282
  if (!n || typeof n != "object")
216
- throw new o("invalid_response", "checkout.get response missing intent");
283
+ throw new i("invalid_response", "checkout.get response missing intent");
217
284
  if (typeof n.intentId != "string")
218
- throw new o("invalid_response", "checkout.get response missing intentId");
285
+ throw new i("invalid_response", "checkout.get response missing intentId");
219
286
  return {
220
287
  intentId: n.intentId,
221
288
  uid: n.uid ?? "",
@@ -230,35 +297,35 @@ function J(t) {
230
297
  isStale: e.isStale === true
231
298
  };
232
299
  }
233
- function Y() {
300
+ function re() {
234
301
  try {
235
302
  return typeof globalThis < "u" && typeof globalThis.window < "u" && typeof globalThis.location < "u" && typeof globalThis.location.assign == "function";
236
303
  } catch {
237
304
  return false;
238
305
  }
239
306
  }
240
- function W(t) {
307
+ function oe(t) {
241
308
  try {
242
309
  globalThis.location.assign(t);
243
310
  } catch {
244
311
  }
245
312
  }
246
- function X(t) {
313
+ function ie(t) {
247
314
  return {
248
315
  async start(e) {
249
316
  if (!e?.productId)
250
- throw new o("validation_failed", "checkout.start: productId is required");
317
+ throw new i("validation_failed", "checkout.start: productId is required");
251
318
  if (!e?.planId)
252
- throw new o("validation_failed", "checkout.start: planId is required");
319
+ throw new i("validation_failed", "checkout.start: planId is required");
253
320
  if (!e?.callbackUrl)
254
- throw new o("validation_failed", "checkout.start: callbackUrl is required");
321
+ throw new i("validation_failed", "checkout.start: callbackUrl is required");
255
322
  let n = {
256
323
  productId: e.productId,
257
324
  planId: e.planId,
258
325
  callbackUrl: e.callbackUrl
259
326
  };
260
327
  e.tenantType && (n.targetTenantType = e.tenantType), e.tenantId && (n.targetTenantId = e.tenantId);
261
- let { requireAuth: r, headers: s } = _(
328
+ let { requireAuth: r, headers: o } = T(
262
329
  { accessToken: e.accessToken, idToken: e.idToken },
263
330
  "start"
264
331
  ), a = await y(t, {
@@ -266,29 +333,29 @@ function X(t) {
266
333
  path: "/api/v1/checkout/intents",
267
334
  body: n,
268
335
  requireAuth: r,
269
- headers: s,
336
+ headers: o,
270
337
  idempotencyKey: true
271
- }), d = V(a);
272
- return e.autoRedirect !== false && Y() && W(d.redirectUrl), d;
338
+ }), c = te(a);
339
+ return e.autoRedirect !== false && re() && oe(c.redirectUrl), c;
273
340
  },
274
341
  async get(e, n) {
275
342
  if (!e || typeof e != "string")
276
- throw new o("validation_failed", "checkout.get: intentId is required");
277
- let { requireAuth: r, headers: s } = _(
343
+ throw new i("validation_failed", "checkout.get: intentId is required");
344
+ let { requireAuth: r, headers: o } = T(
278
345
  { accessToken: n?.accessToken, idToken: n?.idToken },
279
346
  "get"
280
347
  ), a = await y(t, {
281
348
  method: "GET",
282
349
  path: `/api/v1/checkout/intents/${encodeURIComponent(e)}`,
283
350
  requireAuth: r,
284
- headers: s
351
+ headers: o
285
352
  });
286
- return J(a);
353
+ return ne(a);
287
354
  },
288
355
  async cancel(e, n) {
289
356
  if (!e || typeof e != "string")
290
- throw new o("validation_failed", "checkout.cancel: intentId is required");
291
- let { requireAuth: r, headers: s } = _(
357
+ throw new i("validation_failed", "checkout.cancel: intentId is required");
358
+ let { requireAuth: r, headers: o } = T(
292
359
  { accessToken: n?.accessToken, idToken: n?.idToken },
293
360
  "cancel"
294
361
  );
@@ -298,22 +365,22 @@ function X(t) {
298
365
  method: "DELETE",
299
366
  path: `/api/v1/checkout/intents/${encodeURIComponent(e)}`,
300
367
  requireAuth: r,
301
- headers: s
368
+ headers: o
302
369
  }))?.alreadyCancelled === true
303
370
  };
304
371
  }
305
372
  };
306
373
  }
307
- var C = class {
374
+ var R = class {
308
375
  intents = /* @__PURE__ */ new Map();
309
376
  async start(e) {
310
377
  if (!e?.productId)
311
- throw new o("validation_failed", "checkout.start: productId is required");
378
+ throw new i("validation_failed", "checkout.start: productId is required");
312
379
  if (!e?.planId)
313
- throw new o("validation_failed", "checkout.start: planId is required");
380
+ throw new i("validation_failed", "checkout.start: planId is required");
314
381
  if (!e?.callbackUrl)
315
- throw new o("validation_failed", "checkout.start: callbackUrl is required");
316
- let n = `chk_mock_${Math.random().toString(36).slice(2, 10)}`, r = new Date(Date.now() + 900 * 1e3).toISOString(), s = `https://localhost:9003/portal/checkout/${n}`;
382
+ throw new i("validation_failed", "checkout.start: callbackUrl is required");
383
+ let n = `chk_mock_${Math.random().toString(36).slice(2, 10)}`, r = new Date(Date.now() + 900 * 1e3).toISOString(), o = `https://localhost:9003/portal/checkout/${n}`;
317
384
  return this.intents.set(n, {
318
385
  intentId: n,
319
386
  uid: "dev-fixture-uid",
@@ -327,7 +394,7 @@ var C = class {
327
394
  expiresAt: r
328
395
  }), {
329
396
  intentId: n,
330
- redirectUrl: s,
397
+ redirectUrl: o,
331
398
  status: "pending",
332
399
  expiresAt: r,
333
400
  requiresKyc: false
@@ -336,20 +403,20 @@ var C = class {
336
403
  async get(e, n) {
337
404
  let r = this.intents.get(e);
338
405
  if (!r)
339
- throw new o("not_found", `Mock intent ${e} not found`);
406
+ throw new i("not_found", `Mock intent ${e} not found`);
340
407
  return { ...r };
341
408
  }
342
409
  async cancel(e, n) {
343
410
  let r = this.intents.get(e);
344
411
  if (!r)
345
- throw new o("not_found", `Mock intent ${e} not found`);
346
- let s = r.status === "cancelled";
347
- return this.intents.set(e, { ...r, status: "cancelled" }), { ok: true, alreadyCancelled: s };
412
+ throw new i("not_found", `Mock intent ${e} not found`);
413
+ let o = r.status === "cancelled";
414
+ return this.intents.set(e, { ...r, status: "cancelled" }), { ok: true, alreadyCancelled: o };
348
415
  }
349
416
  };
350
- function ae(t) {
351
- return t.env === "dev" ? new C() : X(t);
417
+ function Ie(t) {
418
+ return t.env === "dev" ? new R() : ie(t);
352
419
  }
353
420
 
354
- exports.MockCheckout = C;
355
- exports.createCheckoutNamespace = ae;
421
+ exports.MockCheckout = R;
422
+ exports.createCheckoutNamespace = Ie;
@@ -1,3 +1,3 @@
1
- export { o as CheckoutAuthOpts, p as CheckoutIntentInfo, q as CheckoutIntentStatus, r as CheckoutNamespace, s as CheckoutStartInput, t as CheckoutStartResult, u as CheckoutTenantType, S as MockCheckout, aK as createCheckoutNamespace } from './types-Bx4kTLmk.cjs';
1
+ export { o as CheckoutAuthOpts, p as CheckoutIntentInfo, q as CheckoutIntentStatus, r as CheckoutNamespace, s as CheckoutStartInput, t as CheckoutStartResult, u as CheckoutTenantType, T as MockCheckout, aL as createCheckoutNamespace } from './types-D-9bjlM0.cjs';
2
2
  import 'drizzle-orm/node-postgres';
3
3
  import './errors.cjs';
@@ -1,3 +1,3 @@
1
- export { o as CheckoutAuthOpts, p as CheckoutIntentInfo, q as CheckoutIntentStatus, r as CheckoutNamespace, s as CheckoutStartInput, t as CheckoutStartResult, u as CheckoutTenantType, S as MockCheckout, aK as createCheckoutNamespace } from './types-Dx0IrOSF.js';
1
+ export { o as CheckoutAuthOpts, p as CheckoutIntentInfo, q as CheckoutIntentStatus, r as CheckoutNamespace, s as CheckoutStartInput, t as CheckoutStartResult, u as CheckoutTenantType, T as MockCheckout, aL as createCheckoutNamespace } from './types-bVztFQTI.js';
2
2
  import 'drizzle-orm/node-postgres';
3
3
  import './errors.js';