@neetru/sdk 3.4.3 → 3.4.5
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 +40 -0
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/auth.cjs +33 -11
- package/dist/auth.cjs.map +1 -1
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.mjs +33 -11
- package/dist/auth.mjs.map +1 -1
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/checkout.cjs +17 -7
- package/dist/checkout.cjs.map +1 -1
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +17 -7
- package/dist/checkout.mjs.map +1 -1
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- 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 +34 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +34 -12
- package/dist/index.mjs.map +1 -1
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/react.cjs +62 -3
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +38 -7
- package/dist/react.d.ts +38 -7
- package/dist/react.mjs +62 -3
- package/dist/react.mjs.map +1 -1
- package/dist/support.d.cts +1 -1
- package/dist/support.d.ts +1 -1
- package/dist/telemetry.cjs +16 -4
- package/dist/telemetry.cjs.map +1 -1
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +16 -4
- package/dist/telemetry.mjs.map +1 -1
- package/dist/{types-D-QdG502.d.cts → types-DIVZl7nO.d.cts} +29 -8
- package/dist/{types-BlOLDMR0.d.ts → types-nnztVk7G.d.ts} +29 -8
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/package.json +1 -1
package/dist/auth.d.cts
CHANGED
package/dist/auth.d.ts
CHANGED
package/dist/auth.mjs
CHANGED
|
@@ -1271,6 +1271,12 @@ function createEntitlementsNamespace(config) {
|
|
|
1271
1271
|
init_errors();
|
|
1272
1272
|
init_http();
|
|
1273
1273
|
var VALID_LOG_LEVELS = ["debug", "info", "warn", "error", "fatal"];
|
|
1274
|
+
function isBrowserContext() {
|
|
1275
|
+
return typeof globalThis !== "undefined" && typeof globalThis.window !== "undefined";
|
|
1276
|
+
}
|
|
1277
|
+
function resolveEventTransport() {
|
|
1278
|
+
return isBrowserContext() ? { path: "/api/sdk/v1/telemetry/event/public", requireAuth: false } : { path: "/api/sdk/v1/telemetry/event", requireAuth: true };
|
|
1279
|
+
}
|
|
1274
1280
|
function consoleFor(level) {
|
|
1275
1281
|
switch (level) {
|
|
1276
1282
|
case "debug":
|
|
@@ -1300,15 +1306,18 @@ function createTelemetryNamespace(config) {
|
|
|
1300
1306
|
batch.map(async (ev) => {
|
|
1301
1307
|
try {
|
|
1302
1308
|
const body = { name: ev.name };
|
|
1309
|
+
const productSlug = ev.productSlug ?? config.productId;
|
|
1310
|
+
if (productSlug) body.productSlug = productSlug;
|
|
1303
1311
|
if (ev.properties && typeof ev.properties === "object") {
|
|
1304
1312
|
body.properties = ev.properties;
|
|
1305
1313
|
}
|
|
1306
1314
|
if (ev.timestamp) body.timestamp = ev.timestamp;
|
|
1315
|
+
const transport = resolveEventTransport();
|
|
1307
1316
|
await httpRequest(config, {
|
|
1308
1317
|
method: "POST",
|
|
1309
|
-
path:
|
|
1318
|
+
path: transport.path,
|
|
1310
1319
|
body,
|
|
1311
|
-
requireAuth:
|
|
1320
|
+
requireAuth: transport.requireAuth,
|
|
1312
1321
|
retries: 1,
|
|
1313
1322
|
// caça-bruxas: retry sem Idempotency-Key duplicava o evento se o
|
|
1314
1323
|
// servidor já tinha persistido antes da falha transiente. Mesmo
|
|
@@ -1361,15 +1370,18 @@ function createTelemetryNamespace(config) {
|
|
|
1361
1370
|
throw new NeetruError("validation_failed", "event.name max 128 chars");
|
|
1362
1371
|
}
|
|
1363
1372
|
const body = { name: input.name };
|
|
1373
|
+
const productSlug = input.productSlug ?? config.productId;
|
|
1374
|
+
if (productSlug) body.productSlug = productSlug;
|
|
1364
1375
|
if (input.properties && typeof input.properties === "object") {
|
|
1365
1376
|
body.properties = input.properties;
|
|
1366
1377
|
}
|
|
1367
1378
|
if (input.timestamp) body.timestamp = input.timestamp;
|
|
1379
|
+
const transport = resolveEventTransport();
|
|
1368
1380
|
const raw = await httpRequest(config, {
|
|
1369
1381
|
method: "POST",
|
|
1370
|
-
path:
|
|
1382
|
+
path: transport.path,
|
|
1371
1383
|
body,
|
|
1372
|
-
requireAuth:
|
|
1384
|
+
requireAuth: transport.requireAuth
|
|
1373
1385
|
});
|
|
1374
1386
|
if (!raw || raw.ok !== true || typeof raw.eventId !== "string") {
|
|
1375
1387
|
throw new NeetruError("invalid_response", "Telemetry response missing eventId");
|
|
@@ -5574,14 +5586,15 @@ function createLazyCollectionRef(name, getDocsPromise) {
|
|
|
5574
5586
|
// src/checkout.ts
|
|
5575
5587
|
init_errors();
|
|
5576
5588
|
init_http();
|
|
5577
|
-
function checkoutAuth(
|
|
5578
|
-
|
|
5589
|
+
function checkoutAuth(auth, method) {
|
|
5590
|
+
const token = auth?.accessToken || auth?.idToken;
|
|
5591
|
+
if (!token || typeof token !== "string") {
|
|
5579
5592
|
throw new NeetruError(
|
|
5580
5593
|
"validation_failed",
|
|
5581
|
-
`checkout.${method} requer o access_token OIDC do usu\xE1rio final (passe \`accessToken\`). 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 OIDC ou cookie de sess\xE3o).`
|
|
5594
|
+
`checkout.${method} 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.`
|
|
5582
5595
|
);
|
|
5583
5596
|
}
|
|
5584
|
-
return { requireAuth: false, headers: { authorization: `Bearer ${
|
|
5597
|
+
return { requireAuth: false, headers: { authorization: `Bearer ${token}` } };
|
|
5585
5598
|
}
|
|
5586
5599
|
function parseStartResponse(raw) {
|
|
5587
5600
|
if (!raw || typeof raw !== "object") {
|
|
@@ -5660,7 +5673,10 @@ function createHttpCheckoutNamespace(config) {
|
|
|
5660
5673
|
};
|
|
5661
5674
|
if (input.tenantType) body.targetTenantType = input.tenantType;
|
|
5662
5675
|
if (input.tenantId) body.targetTenantId = input.tenantId;
|
|
5663
|
-
const { requireAuth, headers } = checkoutAuth(
|
|
5676
|
+
const { requireAuth, headers } = checkoutAuth(
|
|
5677
|
+
{ accessToken: input.accessToken, idToken: input.idToken },
|
|
5678
|
+
"start"
|
|
5679
|
+
);
|
|
5664
5680
|
const raw = await httpRequest(config, {
|
|
5665
5681
|
method: "POST",
|
|
5666
5682
|
path: "/api/v1/checkout/intents",
|
|
@@ -5680,7 +5696,10 @@ function createHttpCheckoutNamespace(config) {
|
|
|
5680
5696
|
if (!intentId || typeof intentId !== "string") {
|
|
5681
5697
|
throw new NeetruError("validation_failed", "checkout.get: intentId is required");
|
|
5682
5698
|
}
|
|
5683
|
-
const { requireAuth, headers } = checkoutAuth(
|
|
5699
|
+
const { requireAuth, headers } = checkoutAuth(
|
|
5700
|
+
{ accessToken: opts?.accessToken, idToken: opts?.idToken },
|
|
5701
|
+
"get"
|
|
5702
|
+
);
|
|
5684
5703
|
const raw = await httpRequest(config, {
|
|
5685
5704
|
method: "GET",
|
|
5686
5705
|
path: `/api/v1/checkout/intents/${encodeURIComponent(intentId)}`,
|
|
@@ -5693,7 +5712,10 @@ function createHttpCheckoutNamespace(config) {
|
|
|
5693
5712
|
if (!intentId || typeof intentId !== "string") {
|
|
5694
5713
|
throw new NeetruError("validation_failed", "checkout.cancel: intentId is required");
|
|
5695
5714
|
}
|
|
5696
|
-
const { requireAuth, headers } = checkoutAuth(
|
|
5715
|
+
const { requireAuth, headers } = checkoutAuth(
|
|
5716
|
+
{ accessToken: opts?.accessToken, idToken: opts?.idToken },
|
|
5717
|
+
"cancel"
|
|
5718
|
+
);
|
|
5697
5719
|
const raw = await httpRequest(config, {
|
|
5698
5720
|
method: "DELETE",
|
|
5699
5721
|
path: `/api/v1/checkout/intents/${encodeURIComponent(intentId)}`,
|