@neetru/sdk 3.8.1 → 3.9.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 +46 -0
- package/README.md +14 -1
- package/dist/ai.cjs +1 -1
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.mjs +1 -1
- package/dist/auth.cjs +844 -803
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.mjs +841 -800
- package/dist/build-guard.cjs +186 -82
- package/dist/build-guard.d.cts +53 -1
- package/dist/build-guard.d.ts +53 -1
- package/dist/build-guard.mjs +175 -74
- package/dist/catalog.cjs +1 -1
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.mjs +1 -1
- package/dist/checkout.cjs +62 -49
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +62 -49
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db.cjs +200 -187
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.mjs +193 -180
- package/dist/entitlements.d.cts +1 -1
- package/dist/entitlements.d.ts +1 -1
- package/dist/firestore-compat.d.cts +1 -1
- package/dist/firestore-compat.d.ts +1 -1
- package/dist/index.cjs +880 -839
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +847 -806
- package/dist/mobile.cjs +328 -276
- package/dist/mobile.d.cts +12 -2
- package/dist/mobile.d.ts +12 -2
- package/dist/mobile.mjs +328 -276
- package/dist/mocks.cjs +5 -5
- package/dist/mocks.d.cts +2 -2
- package/dist/mocks.d.ts +2 -2
- package/dist/mocks.mjs +4 -4
- package/dist/notifications.cjs +1 -1
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/notifications.mjs +1 -1
- package/dist/react.cjs +119 -119
- package/dist/react.d.cts +8 -2
- package/dist/react.d.ts +8 -2
- package/dist/react.mjs +119 -119
- package/dist/support.cjs +1 -1
- package/dist/support.d.cts +1 -1
- package/dist/support.d.ts +1 -1
- package/dist/support.mjs +1 -1
- package/dist/telemetry.cjs +62 -49
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +62 -49
- package/dist/{types-yv3EDKg2.d.cts → types-Bl_4HROd.d.cts} +62 -3
- package/dist/{types-BYPk_3HR.d.ts → types-Bqnsqvow.d.ts} +62 -3
- package/dist/usage.cjs +1 -1
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/usage.mjs +1 -1
- package/dist/webhooks.cjs +1 -1
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.mjs +1 -1
- package/package.json +9 -1
package/dist/build-guard.mjs
CHANGED
|
@@ -1,149 +1,250 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import * as
|
|
1
|
+
import * as a from 'fs';
|
|
2
|
+
import * as l from 'path';
|
|
3
3
|
|
|
4
4
|
// src/build-guard.ts
|
|
5
|
-
var
|
|
6
|
-
constructor(
|
|
7
|
-
super(
|
|
5
|
+
var p = class extends Error {
|
|
6
|
+
constructor(t) {
|
|
7
|
+
super(t), this.name = "NeetruBuildGuardError";
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
function
|
|
10
|
+
function g(e) {
|
|
11
11
|
return e == null || e.trim() === "";
|
|
12
12
|
}
|
|
13
13
|
function k(e) {
|
|
14
14
|
if (e.builtEnv !== "prod") return;
|
|
15
|
-
let
|
|
16
|
-
if (
|
|
17
|
-
let
|
|
18
|
-
throw new
|
|
15
|
+
let t = [];
|
|
16
|
+
if (g(e.oidcClientId) && t.push("NEXT_PUBLIC_NEETRU_OIDC_CLIENT_ID"), g(e.productId) && t.push("NEXT_PUBLIC_NEETRU_PRODUCT_ID"), t.length === 0) return;
|
|
17
|
+
let n = t.length > 1;
|
|
18
|
+
throw new p(
|
|
19
19
|
[
|
|
20
20
|
"[neetru-sdk] BUILD DE PRODU\xC7\xC3O ABORTADO (withNeetruBuildGuard).",
|
|
21
21
|
"",
|
|
22
|
-
`Vari\xE1ve${
|
|
23
|
-
...
|
|
22
|
+
`Vari\xE1ve${n ? "is" : "l"} de ambiente obrigat\xF3ri${n ? "as" : "a"} ausente${n ? "s" : ""}/vazia${n ? "s" : ""} no build de produ\xE7\xE3o (NEXT_PUBLIC_NEETRU_ENV=prod):`,
|
|
23
|
+
...t.map((r) => ` \u2022 ${r}`),
|
|
24
24
|
"",
|
|
25
|
-
`Sem ${
|
|
25
|
+
`Sem ${n ? "essas vari\xE1veis" : "essa vari\xE1vel"} o SDK n\xE3o consegue montar o client_id do login OIDC \u2014 o bot\xE3o "Entrar com Neetru" (NeetruLoginButton) N\xC3O redireciona e o login do produto quebra EM SIL\xCANCIO em produ\xE7\xE3o (incidente gestovendas 2026-09-06: workspace recriado perdeu a env var e shippou um build de prod com o client_id vazio).`,
|
|
26
26
|
"",
|
|
27
27
|
"Como corrigir \u2014 defina no .env.production do produto (ou no ambiente do build de deploy):",
|
|
28
|
-
...
|
|
28
|
+
...t.map((r) => ` ${r}=<valor real vindo do cat\xE1logo do produto no Core>`),
|
|
29
29
|
"",
|
|
30
30
|
"dev/workspace N\xC3O exigem essas vari\xE1veis (usam MockAuth/sandbox) \u2014 s\xF3 o build de produ\xE7\xE3o enfor\xE7a."
|
|
31
31
|
].join(`
|
|
32
32
|
`)
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
var w = [
|
|
36
|
+
"script-src-elem",
|
|
37
|
+
"script-src",
|
|
38
|
+
"default-src"
|
|
39
|
+
], E = /^\/(?:api|_next)(?:\/|$)/, m = /^'sha(?:256|384|512)-/;
|
|
40
|
+
function N(e) {
|
|
41
|
+
let t = /* @__PURE__ */ new Map();
|
|
42
|
+
for (let n of e.split(";")) {
|
|
43
|
+
let r = n.trim().split(/\s+/).filter(Boolean);
|
|
44
|
+
if (r.length === 0) continue;
|
|
45
|
+
let o = r[0].toLowerCase();
|
|
46
|
+
t.has(o) || t.set(o, { raw: r.join(" "), sources: r.slice(1) });
|
|
47
|
+
}
|
|
48
|
+
return t;
|
|
49
|
+
}
|
|
50
|
+
function I(e, t) {
|
|
51
|
+
let n = t.filter((o) => {
|
|
52
|
+
let s = o.toLowerCase();
|
|
53
|
+
return s !== "'none'" && !m.test(s);
|
|
54
|
+
});
|
|
55
|
+
return n.some((o) => o.toLowerCase() === "'unsafe-inline'") || n.push("'unsafe-inline'"), n.length === 1 && n.unshift("'self'"), `${e === "default-src" ? "script-src" : e} ${n.join(" ")}`;
|
|
56
|
+
}
|
|
57
|
+
function C(e) {
|
|
58
|
+
let t = N(e), n = w.find((c) => t.has(c));
|
|
59
|
+
if (!n) return null;
|
|
60
|
+
let { raw: r, sources: o } = t.get(n), s = o.map((c) => c.toLowerCase());
|
|
61
|
+
if (s.some((c) => c.startsWith("'nonce-")) || s.includes("'strict-dynamic'")) return null;
|
|
62
|
+
let i = s.includes("'unsafe-inline'"), u = s.some((c) => m.test(c));
|
|
63
|
+
return i && !u ? null : {
|
|
64
|
+
directiveName: n,
|
|
65
|
+
directive: r,
|
|
66
|
+
suggestion: I(n, o),
|
|
67
|
+
unsafeInlineIgnoredByHash: i && u
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function S(e) {
|
|
71
|
+
if (!Array.isArray(e)) return [];
|
|
72
|
+
let t = [];
|
|
73
|
+
for (let n of e) {
|
|
74
|
+
if (!n || typeof n != "object") continue;
|
|
75
|
+
let { source: r, headers: o } = n, s = typeof r == "string" ? r : "";
|
|
76
|
+
if (!E.test(s) && Array.isArray(o))
|
|
77
|
+
for (let i of o) {
|
|
78
|
+
if (!i || typeof i != "object") continue;
|
|
79
|
+
let { key: u, value: c } = i;
|
|
80
|
+
if (!(typeof u != "string" || typeof c != "string") && u.trim().toLowerCase() === "content-security-policy")
|
|
81
|
+
for (let d of c.split(",")) {
|
|
82
|
+
let f = C(d);
|
|
83
|
+
f && t.push({ source: s, headerKey: u.trim(), ...f });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return t;
|
|
88
|
+
}
|
|
89
|
+
function _(e) {
|
|
90
|
+
if (typeof e != "string" || e.trim() === "") return false;
|
|
91
|
+
try {
|
|
92
|
+
return a.existsSync(l.join(e, "app")) || a.existsSync(l.join(e, "src", "app"));
|
|
93
|
+
} catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function b(e) {
|
|
98
|
+
let t = S(e);
|
|
99
|
+
if (t.length === 0) return;
|
|
100
|
+
let n = [
|
|
101
|
+
"[neetru-sdk] BUILD ABORTADO (withNeetruBuildGuard): a Content-Security-Policy do headers() do next.config bloqueia os scripts embutidos do App Router.",
|
|
102
|
+
"",
|
|
103
|
+
"O App Router p\xF5e <script> embutidos em toda p\xE1gina (self.__next_f.push, com o payload do React Server Components). Com a CSP abaixo o navegador bloqueia esses scripts, a hidrata\xE7\xE3o falha e o React desmonta a \xE1rvore: o servidor responde 200 com o HTML certo e a tela fica EM BRANCO (incidente Zelo 2026-10-22).",
|
|
104
|
+
"",
|
|
105
|
+
`Linha${t.length > 1 ? "s" : ""} a trocar no next.config:`
|
|
106
|
+
];
|
|
107
|
+
throw t.forEach((r, o) => {
|
|
108
|
+
n.push(""), n.push(`${o + 1}) headers() \u2192 source "${r.source}" \u2192 ${r.headerKey}`), r.directiveName === "default-src" ? (n.push(` a CSP n\xE3o tem script-src, ent\xE3o quem decide os scripts \xE9 o: ${r.directive}`), n.push(` acrescente: ${r.suggestion}`)) : (n.push(` troque: ${r.directive}`), n.push(` por: ${r.suggestion}`), r.unsafeInlineIgnoredByHash && n.push(" (com um hash 'sha\u2026-' na lista, o navegador ignora o 'unsafe-inline' \u2014 por isso o hash sai)"));
|
|
109
|
+
}), n.push(
|
|
110
|
+
"",
|
|
111
|
+
"Sem 'unsafe-inline': use nonce por requisi\xE7\xE3o \u2014 o middleware gera o nonce e manda a CSP com 'nonce-<valor>' 'strict-dynamic' (https://nextjs.org/docs/app/guides/content-security-policy). CSP com nonce ou 'strict-dynamic' passa nesta checagem."
|
|
112
|
+
), new p(n.join(`
|
|
113
|
+
`));
|
|
114
|
+
}
|
|
115
|
+
function R(e) {
|
|
116
|
+
if (_(process.cwd()))
|
|
117
|
+
try {
|
|
118
|
+
b(e);
|
|
119
|
+
} catch (t) {
|
|
120
|
+
if (t instanceof p && process.env.NODE_ENV === "development") {
|
|
121
|
+
typeof console < "u" && console.warn(t.message);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
throw t;
|
|
125
|
+
}
|
|
38
126
|
}
|
|
39
|
-
|
|
40
|
-
|
|
127
|
+
var y = ["pg", "drizzle-orm"], h = "*";
|
|
128
|
+
function v(e) {
|
|
129
|
+
return Array.isArray(e) ? e.filter((t) => typeof t == "string") : [];
|
|
130
|
+
}
|
|
131
|
+
function T(e, t, n) {
|
|
132
|
+
let r = [], o = t;
|
|
41
133
|
for (; ; ) {
|
|
42
134
|
r.push(o);
|
|
43
|
-
let
|
|
44
|
-
if (
|
|
45
|
-
o =
|
|
135
|
+
let s = l.dirname(o);
|
|
136
|
+
if (s === o) break;
|
|
137
|
+
o = s;
|
|
46
138
|
}
|
|
47
|
-
r.includes(
|
|
48
|
-
for (let
|
|
49
|
-
let
|
|
139
|
+
r.includes(n) || r.push(n);
|
|
140
|
+
for (let s of r) {
|
|
141
|
+
let i = l.join(s, "node_modules", e, "package.json");
|
|
50
142
|
try {
|
|
51
|
-
if (
|
|
143
|
+
if (a.existsSync(i)) return i;
|
|
52
144
|
} catch {
|
|
53
145
|
}
|
|
54
146
|
}
|
|
55
147
|
return null;
|
|
56
148
|
}
|
|
57
|
-
function
|
|
149
|
+
function B(e) {
|
|
58
150
|
if (typeof e != "string" || e.trim() === "") return [];
|
|
59
|
-
let
|
|
60
|
-
if (
|
|
61
|
-
n.add(o);
|
|
62
|
-
let s = _(o, i, e);
|
|
63
|
-
if (!s) return;
|
|
151
|
+
let t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = (o, s) => {
|
|
152
|
+
if (t.has(o)) return;
|
|
64
153
|
t.add(o);
|
|
65
|
-
let
|
|
154
|
+
let i = T(o, s, e);
|
|
155
|
+
if (!i) return;
|
|
156
|
+
n.add(o);
|
|
157
|
+
let u;
|
|
66
158
|
try {
|
|
67
|
-
|
|
159
|
+
u = JSON.parse(a.readFileSync(i, "utf8"));
|
|
68
160
|
} catch {
|
|
69
161
|
return;
|
|
70
162
|
}
|
|
71
163
|
let c = {
|
|
72
|
-
...
|
|
73
|
-
...
|
|
74
|
-
},
|
|
75
|
-
for (let
|
|
164
|
+
...u.dependencies ?? {},
|
|
165
|
+
...u.optionalDependencies ?? {}
|
|
166
|
+
}, d = l.dirname(i);
|
|
167
|
+
for (let f of Object.keys(c)) r(f, d);
|
|
76
168
|
};
|
|
77
169
|
try {
|
|
78
|
-
for (let o of
|
|
170
|
+
for (let o of y) r(o, e);
|
|
79
171
|
} catch {
|
|
80
172
|
return [];
|
|
81
173
|
}
|
|
82
|
-
return [...
|
|
174
|
+
return [...n].sort();
|
|
83
175
|
}
|
|
84
|
-
function
|
|
85
|
-
return e.map((
|
|
176
|
+
function x(e) {
|
|
177
|
+
return e.map((t) => `./node_modules/${t}/**`);
|
|
86
178
|
}
|
|
87
|
-
function
|
|
88
|
-
let
|
|
89
|
-
for (let
|
|
90
|
-
|
|
91
|
-
return
|
|
179
|
+
function A(e) {
|
|
180
|
+
let t = v(e);
|
|
181
|
+
for (let n of y)
|
|
182
|
+
t.includes(n) || t.push(n);
|
|
183
|
+
return t;
|
|
92
184
|
}
|
|
93
|
-
function
|
|
94
|
-
let
|
|
185
|
+
function O(e, t) {
|
|
186
|
+
let n = {};
|
|
95
187
|
if (e && typeof e == "object" && !Array.isArray(e))
|
|
96
|
-
for (let [o,
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
let r = [...
|
|
100
|
-
for (let o of
|
|
188
|
+
for (let [o, s] of Object.entries(e))
|
|
189
|
+
n[o] = v(s);
|
|
190
|
+
if (t.length === 0) return n;
|
|
191
|
+
let r = [...n[h] ?? []];
|
|
192
|
+
for (let o of t)
|
|
101
193
|
r.includes(o) || r.push(o);
|
|
102
|
-
return
|
|
194
|
+
return n[h] = r, n;
|
|
103
195
|
}
|
|
104
|
-
function
|
|
105
|
-
let
|
|
196
|
+
function P(e, t = {}) {
|
|
197
|
+
let n = e.webpack, r = e.headers, o = [];
|
|
106
198
|
try {
|
|
107
|
-
|
|
199
|
+
o = x(B(process.cwd()));
|
|
108
200
|
} catch {
|
|
109
|
-
|
|
201
|
+
o = [];
|
|
110
202
|
}
|
|
111
203
|
return {
|
|
112
204
|
...e,
|
|
113
205
|
// `serverExternalPackages` é reforço (não o conserto do caso webpackIgnore);
|
|
114
206
|
// o `outputFileTracingIncludes` computado é o que realmente inclui o closure.
|
|
115
|
-
serverExternalPackages:
|
|
116
|
-
outputFileTracingIncludes:
|
|
207
|
+
serverExternalPackages: A(e.serverExternalPackages),
|
|
208
|
+
outputFileTracingIncludes: O(
|
|
117
209
|
e.outputFileTracingIncludes,
|
|
118
|
-
|
|
210
|
+
o
|
|
119
211
|
),
|
|
120
|
-
|
|
121
|
-
|
|
212
|
+
// CSP x App Router (incidente Zelo 2026-10-22): só embrulha quando o produto
|
|
213
|
+
// TEM `headers()`. Sem ele não há CSP do next.config a checar, e o config
|
|
214
|
+
// continua sem a chave (não inventa um `headers` que o Next não pediu).
|
|
215
|
+
...typeof r == "function" ? {
|
|
216
|
+
async headers(...s) {
|
|
217
|
+
let i = await r.apply(this, s);
|
|
218
|
+
return R(i), i;
|
|
219
|
+
}
|
|
220
|
+
} : {},
|
|
221
|
+
webpack(s, i) {
|
|
222
|
+
let u = typeof n == "function" ? n(s, i) : s;
|
|
122
223
|
if (!i.dev && i.isServer) {
|
|
123
|
-
let
|
|
224
|
+
let c = {
|
|
124
225
|
builtEnv: process.env.NEXT_PUBLIC_NEETRU_ENV ?? null,
|
|
125
226
|
productId: process.env.NEXT_PUBLIC_NEETRU_PRODUCT_ID ?? null,
|
|
126
227
|
oidcClientId: process.env.NEXT_PUBLIC_NEETRU_OIDC_CLIENT_ID ?? null,
|
|
127
228
|
builtAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
128
229
|
};
|
|
129
230
|
try {
|
|
130
|
-
let
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
JSON.stringify(
|
|
231
|
+
let d = l.resolve(process.cwd(), t.outputDir ?? ".next");
|
|
232
|
+
a.mkdirSync(d, { recursive: !0 }), a.writeFileSync(
|
|
233
|
+
l.join(d, "neetru-build-manifest.json"),
|
|
234
|
+
JSON.stringify(c, null, 2),
|
|
134
235
|
"utf8"
|
|
135
236
|
);
|
|
136
|
-
} catch (
|
|
237
|
+
} catch (d) {
|
|
137
238
|
typeof console < "u" && console.warn(
|
|
138
239
|
"[neetru-sdk] withNeetruBuildGuard: falha ao gravar neetru-build-manifest.json (ignorado, build segue):",
|
|
139
|
-
|
|
240
|
+
d
|
|
140
241
|
);
|
|
141
242
|
}
|
|
142
|
-
k(
|
|
243
|
+
k(c);
|
|
143
244
|
}
|
|
144
|
-
return
|
|
245
|
+
return u;
|
|
145
246
|
}
|
|
146
247
|
};
|
|
147
248
|
}
|
|
148
249
|
|
|
149
|
-
export {
|
|
250
|
+
export { y as NEETRU_SQL_SERVER_EXTERNAL_PACKAGES, h as NEETRU_SQL_TRACE_INCLUDE_KEY, p as NeetruBuildGuardError, b as assertNeetruCspAllowsAppRouterScripts, k as assertNeetruProdBuildEnv, S as findCspInlineScriptBlocks, _ as hasNextAppRouter, O as mergeOutputFileTracingIncludes, A as mergeServerExternalPackages, B as resolveSqlRuntimeClosure, x as sqlClosureToTraceGlobs, P as withNeetruBuildGuard };
|
package/dist/catalog.cjs
CHANGED
package/dist/catalog.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ai as ResolvedConfig, C as CatalogListOptions, n as CatalogListResponse, a9 as Product } from './types-Bl_4HROd.cjs';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.cjs';
|
|
4
4
|
|
package/dist/catalog.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ai as ResolvedConfig, C as CatalogListOptions, n as CatalogListResponse, a9 as Product } from './types-Bqnsqvow.js';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.js';
|
|
4
4
|
|
package/dist/catalog.mjs
CHANGED
package/dist/checkout.cjs
CHANGED
|
@@ -39,11 +39,11 @@ function E() {
|
|
|
39
39
|
|
|
40
40
|
// src/correlation.ts
|
|
41
41
|
var A = "x-correlation-id";
|
|
42
|
-
var
|
|
42
|
+
var H = /^[A-Za-z0-9._:\-]+$/;
|
|
43
43
|
function x(t) {
|
|
44
|
-
return typeof t == "string" && t.length > 0 && t.length <= 128 &&
|
|
44
|
+
return typeof t == "string" && t.length > 0 && t.length <= 128 && H.test(t);
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function B() {
|
|
47
47
|
let t = globalThis.crypto;
|
|
48
48
|
try {
|
|
49
49
|
if (t && typeof t.randomUUID == "function") return t.randomUUID();
|
|
@@ -70,7 +70,7 @@ function N(t, e) {
|
|
|
70
70
|
}
|
|
71
71
|
r[a] = c;
|
|
72
72
|
}
|
|
73
|
-
let o = n ?? (x(e) ? e : void 0) ??
|
|
73
|
+
let o = n ?? (x(e) ? e : void 0) ?? B();
|
|
74
74
|
return r[A] = o, { headers: r, correlationId: o };
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -90,7 +90,7 @@ function D() {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
// src/http.ts
|
|
93
|
-
var
|
|
93
|
+
var G = {
|
|
94
94
|
// SDK major 3.x requer Core ≥ 2026.05.1 (suporte a X-Neetru-Version header,
|
|
95
95
|
// runTransaction write-after-read, verifyWebhookRequest, webhooks 3.0+)
|
|
96
96
|
3: "2026.05.1"
|
|
@@ -98,7 +98,7 @@ var B = {
|
|
|
98
98
|
function b(t) {
|
|
99
99
|
return t.split("+")[0] ?? t;
|
|
100
100
|
}
|
|
101
|
-
function
|
|
101
|
+
function F(t, e) {
|
|
102
102
|
let n = b(t).split(".").map(Number), r = b(e).split(".").map(Number), o = Math.max(n.length, r.length);
|
|
103
103
|
for (let a = 0; a < o; a++) {
|
|
104
104
|
let c = n[a] ?? 0, u = r[a] ?? 0;
|
|
@@ -108,43 +108,43 @@ function G(t, e) {
|
|
|
108
108
|
}
|
|
109
109
|
function M() {
|
|
110
110
|
try {
|
|
111
|
-
return "3.
|
|
111
|
+
return "3.9.1";
|
|
112
112
|
} catch {
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function V() {
|
|
117
117
|
let t = M();
|
|
118
118
|
return t ? parseInt(t.split(".")[0] ?? "3", 10) : 3;
|
|
119
119
|
}
|
|
120
|
-
var
|
|
121
|
-
function
|
|
120
|
+
var O = /* @__PURE__ */ new Set();
|
|
121
|
+
function z(t) {
|
|
122
122
|
if (!t) return;
|
|
123
|
-
let e =
|
|
123
|
+
let e = V(), n = G[e];
|
|
124
124
|
if (!n) return;
|
|
125
125
|
let r = b(t);
|
|
126
|
-
if (
|
|
126
|
+
if (F(r, n) < 0) {
|
|
127
127
|
let o = `${e}:${r}`;
|
|
128
|
-
|
|
128
|
+
O.has(o) || (O.add(o), console.warn(
|
|
129
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.`
|
|
130
130
|
));
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
|
-
function
|
|
133
|
+
function X() {
|
|
134
134
|
let t = "This operation requires an apiKey. Pass it to createNeetruClient({ apiKey }) or set NEETRU_API_KEY env var.";
|
|
135
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
136
|
}
|
|
137
|
-
var
|
|
137
|
+
var Y = 2, J = 0, W = /* @__PURE__ */ new Set(["GET", "HEAD"]), Z = /* @__PURE__ */ new Set([
|
|
138
138
|
"rate_limited",
|
|
139
139
|
"server_error",
|
|
140
140
|
"network_error"
|
|
141
141
|
]);
|
|
142
|
-
function
|
|
142
|
+
function U(t) {
|
|
143
143
|
let e = 200 * Math.pow(4, t), n = e * 0.2 * (Math.random() * 2 - 1);
|
|
144
144
|
return Math.max(50, Math.round(e + n));
|
|
145
145
|
}
|
|
146
146
|
var q = 6e4;
|
|
147
|
-
function
|
|
147
|
+
function Q(t) {
|
|
148
148
|
if (!t) return null;
|
|
149
149
|
let e = Number(t);
|
|
150
150
|
if (Number.isFinite(e) && e >= 0) return Math.min(Math.round(e * 1e3), q);
|
|
@@ -158,10 +158,10 @@ function Z(t) {
|
|
|
158
158
|
function K(t) {
|
|
159
159
|
return new Promise((e) => setTimeout(e, t));
|
|
160
160
|
}
|
|
161
|
-
function
|
|
161
|
+
function ee(t) {
|
|
162
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";
|
|
163
163
|
}
|
|
164
|
-
function
|
|
164
|
+
function te(t, e, n) {
|
|
165
165
|
let r = t.replace(/\/+$/, ""), o = e.startsWith("/") ? e : `/${e}`, a = new URL(`${r}${o}`);
|
|
166
166
|
if (n)
|
|
167
167
|
for (let [c, u] of Object.entries(n))
|
|
@@ -177,14 +177,14 @@ async function P(t) {
|
|
|
177
177
|
return;
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
async function
|
|
181
|
-
let n = e.method ?? "GET", r =
|
|
180
|
+
async function k(t, e) {
|
|
181
|
+
let n = e.method ?? "GET", r = te(t.baseUrl, e.path, e.query), o = W.has(n) ? Y : J, a = e.retries ?? o, { headers: c, correlationId: u } = N(
|
|
182
182
|
{ accept: "application/json", ...e.headers },
|
|
183
183
|
e.correlationId
|
|
184
|
-
),
|
|
185
|
-
if (
|
|
184
|
+
), v = M();
|
|
185
|
+
if (v && (c["x-neetru-sdk-version"] = v), e.requireAuth) {
|
|
186
186
|
if (!t.apiKey)
|
|
187
|
-
throw new i("missing_api_key",
|
|
187
|
+
throw new i("missing_api_key", X());
|
|
188
188
|
c.authorization = `Bearer ${t.apiKey}`;
|
|
189
189
|
}
|
|
190
190
|
if (e.idempotencyKey) {
|
|
@@ -206,15 +206,15 @@ async function y(t, e) {
|
|
|
206
206
|
);
|
|
207
207
|
let _ = { method: n, headers: c };
|
|
208
208
|
I !== void 0 && (_.body = I);
|
|
209
|
-
let
|
|
210
|
-
_.signal = AbortSignal.timeout(
|
|
209
|
+
let j = p != null ? Math.max(1, Math.min(3e4, p - Date.now())) : 3e4;
|
|
210
|
+
_.signal = AbortSignal.timeout(j);
|
|
211
211
|
let d;
|
|
212
212
|
try {
|
|
213
213
|
d = await t.fetch(r, _);
|
|
214
214
|
} catch (s) {
|
|
215
215
|
let m = s instanceof DOMException && s.name === "TimeoutError" ? "Network error: timeout after 30s" : `Network error: ${s instanceof Error ? s.message : "fetch failed"}`;
|
|
216
216
|
if (g = new i("network_error", m, void 0, void 0, void 0, u), f < a) {
|
|
217
|
-
let S =
|
|
217
|
+
let S = U(f);
|
|
218
218
|
if (p == null || Date.now() + S < p) {
|
|
219
219
|
await K(S);
|
|
220
220
|
continue;
|
|
@@ -222,33 +222,46 @@ async function y(t, e) {
|
|
|
222
222
|
}
|
|
223
223
|
throw g;
|
|
224
224
|
}
|
|
225
|
-
let
|
|
225
|
+
let L = d.headers.get("x-request-id") ?? d.headers.get("x-correlation-id") ?? void 0;
|
|
226
226
|
if (d.ok) {
|
|
227
227
|
let s = d.headers.get("x-neetru-version");
|
|
228
|
-
return s &&
|
|
228
|
+
return s && z(s), await P(d);
|
|
229
229
|
}
|
|
230
|
-
let l = await P(d),
|
|
230
|
+
let l = await P(d), y = ee(d.status), h = `HTTP ${d.status}`, w;
|
|
231
231
|
if (l && typeof l == "object") {
|
|
232
232
|
let s = l.error;
|
|
233
|
-
typeof s == "string" ? h = s : s && typeof s == "object" ? (typeof s.code == "string" && (
|
|
233
|
+
typeof s == "string" ? h = s : s && typeof s == "object" ? (typeof s.code == "string" && (y = s.code), typeof s.message == "string" && (h = s.message), typeof s.reason == "string" && (w = s.reason)) : (typeof l.code == "string" && (y = l.code), typeof l.message == "string" && (h = l.message)), typeof l.reason == "string" && (w = l.reason);
|
|
234
234
|
}
|
|
235
235
|
if (d.status === 410) {
|
|
236
236
|
let s = d.headers.get("x-neetru-replacement");
|
|
237
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}.`);
|
|
238
238
|
}
|
|
239
|
-
let
|
|
240
|
-
if (g =
|
|
241
|
-
let m =
|
|
239
|
+
let C = new i(y, h, d.status, L, w, u);
|
|
240
|
+
if (g = C, Z.has(y) && f < a) {
|
|
241
|
+
let m = Q(d.headers.get("retry-after")) ?? U(f);
|
|
242
242
|
if (p == null || Date.now() + m < p) {
|
|
243
243
|
await K(m);
|
|
244
244
|
continue;
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
throw
|
|
247
|
+
throw C;
|
|
248
248
|
}
|
|
249
249
|
throw g ?? new i("unknown", "unexpected httpRequest exit", void 0, void 0, void 0, u);
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
+
// src/runtime-env.ts
|
|
253
|
+
function ne() {
|
|
254
|
+
try {
|
|
255
|
+
if (typeof process < "u" && process.env)
|
|
256
|
+
return process.env.NODE_ENV === "production";
|
|
257
|
+
} catch {
|
|
258
|
+
}
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
function $(t) {
|
|
262
|
+
return t === "dev" && !ne();
|
|
263
|
+
}
|
|
264
|
+
|
|
252
265
|
// src/checkout.ts
|
|
253
266
|
function T(t, e) {
|
|
254
267
|
let n = t?.accessToken || t?.idToken;
|
|
@@ -259,7 +272,7 @@ function T(t, e) {
|
|
|
259
272
|
);
|
|
260
273
|
return { requireAuth: false, headers: { authorization: `Bearer ${n}` } };
|
|
261
274
|
}
|
|
262
|
-
function
|
|
275
|
+
function re(t) {
|
|
263
276
|
if (!t || typeof t != "object")
|
|
264
277
|
throw new i("invalid_response", "checkout.start response is not an object");
|
|
265
278
|
let e = t;
|
|
@@ -275,7 +288,7 @@ function te(t) {
|
|
|
275
288
|
requiresKyc: e.requiresKyc === true
|
|
276
289
|
};
|
|
277
290
|
}
|
|
278
|
-
function
|
|
291
|
+
function oe(t) {
|
|
279
292
|
if (!t || typeof t != "object")
|
|
280
293
|
throw new i("invalid_response", "checkout.get response is not an object");
|
|
281
294
|
let e = t, n = e.intent;
|
|
@@ -297,20 +310,20 @@ function ne(t) {
|
|
|
297
310
|
isStale: e.isStale === true
|
|
298
311
|
};
|
|
299
312
|
}
|
|
300
|
-
function
|
|
313
|
+
function ie() {
|
|
301
314
|
try {
|
|
302
315
|
return typeof globalThis < "u" && typeof globalThis.window < "u" && typeof globalThis.location < "u" && typeof globalThis.location.assign == "function";
|
|
303
316
|
} catch {
|
|
304
317
|
return false;
|
|
305
318
|
}
|
|
306
319
|
}
|
|
307
|
-
function
|
|
320
|
+
function se(t) {
|
|
308
321
|
try {
|
|
309
322
|
globalThis.location.assign(t);
|
|
310
323
|
} catch {
|
|
311
324
|
}
|
|
312
325
|
}
|
|
313
|
-
function
|
|
326
|
+
function ae(t) {
|
|
314
327
|
return {
|
|
315
328
|
async start(e) {
|
|
316
329
|
if (!e?.productId)
|
|
@@ -328,15 +341,15 @@ function ie(t) {
|
|
|
328
341
|
let { requireAuth: r, headers: o } = T(
|
|
329
342
|
{ accessToken: e.accessToken, idToken: e.idToken },
|
|
330
343
|
"start"
|
|
331
|
-
), a = await
|
|
344
|
+
), a = await k(t, {
|
|
332
345
|
method: "POST",
|
|
333
346
|
path: "/api/v1/checkout/intents",
|
|
334
347
|
body: n,
|
|
335
348
|
requireAuth: r,
|
|
336
349
|
headers: o,
|
|
337
350
|
idempotencyKey: true
|
|
338
|
-
}), c =
|
|
339
|
-
return e.autoRedirect !== false &&
|
|
351
|
+
}), c = re(a);
|
|
352
|
+
return e.autoRedirect !== false && ie() && se(c.redirectUrl), c;
|
|
340
353
|
},
|
|
341
354
|
async get(e, n) {
|
|
342
355
|
if (!e || typeof e != "string")
|
|
@@ -344,13 +357,13 @@ function ie(t) {
|
|
|
344
357
|
let { requireAuth: r, headers: o } = T(
|
|
345
358
|
{ accessToken: n?.accessToken, idToken: n?.idToken },
|
|
346
359
|
"get"
|
|
347
|
-
), a = await
|
|
360
|
+
), a = await k(t, {
|
|
348
361
|
method: "GET",
|
|
349
362
|
path: `/api/v1/checkout/intents/${encodeURIComponent(e)}`,
|
|
350
363
|
requireAuth: r,
|
|
351
364
|
headers: o
|
|
352
365
|
});
|
|
353
|
-
return
|
|
366
|
+
return oe(a);
|
|
354
367
|
},
|
|
355
368
|
async cancel(e, n) {
|
|
356
369
|
if (!e || typeof e != "string")
|
|
@@ -361,7 +374,7 @@ function ie(t) {
|
|
|
361
374
|
);
|
|
362
375
|
return {
|
|
363
376
|
ok: true,
|
|
364
|
-
alreadyCancelled: (await
|
|
377
|
+
alreadyCancelled: (await k(t, {
|
|
365
378
|
method: "DELETE",
|
|
366
379
|
path: `/api/v1/checkout/intents/${encodeURIComponent(e)}`,
|
|
367
380
|
requireAuth: r,
|
|
@@ -414,9 +427,9 @@ var R = class {
|
|
|
414
427
|
return this.intents.set(e, { ...r, status: "cancelled" }), { ok: true, alreadyCancelled: o };
|
|
415
428
|
}
|
|
416
429
|
};
|
|
417
|
-
function
|
|
418
|
-
return t.env
|
|
430
|
+
function Te(t) {
|
|
431
|
+
return $(t.env) ? new R() : ae(t);
|
|
419
432
|
}
|
|
420
433
|
|
|
421
434
|
exports.MockCheckout = R;
|
|
422
|
-
exports.createCheckoutNamespace =
|
|
435
|
+
exports.createCheckoutNamespace = Te;
|
package/dist/checkout.d.cts
CHANGED
|
@@ -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, T as MockCheckout,
|
|
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, aN as createCheckoutNamespace } from './types-Bl_4HROd.cjs';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.cjs';
|