@neetru/sdk 3.1.4 → 3.1.6
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 +9 -0
- package/README.md +8 -4
- package/dist/auth.cjs +35 -9
- 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 +35 -9
- package/dist/auth.mjs.map +1 -1
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +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 +36 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +36 -10
- package/dist/index.mjs.map +1 -1
- package/dist/mocks.cjs +26 -7
- package/dist/mocks.cjs.map +1 -1
- package/dist/mocks.d.cts +24 -7
- package/dist/mocks.d.ts +24 -7
- package/dist/mocks.mjs +26 -7
- package/dist/mocks.mjs.map +1 -1
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/support.d.cts +1 -1
- package/dist/support.d.ts +1 -1
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/{types-DvMdYbfV.d.cts → types-BXvGHppn.d.cts} +8 -0
- package/dist/{types-CRIIjqzC.d.ts → types-CQVak2a3.d.ts} +8 -0
- 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/catalog.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a3 as ResolvedConfig, C as CatalogListOptions, b as CatalogListResponse, X as Product } from './types-
|
|
1
|
+
import { a3 as ResolvedConfig, C as CatalogListOptions, b as CatalogListResponse, X as Product } from './types-BXvGHppn.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 { a3 as ResolvedConfig, C as CatalogListOptions, b as CatalogListResponse, X as Product } from './types-
|
|
1
|
+
import { a3 as ResolvedConfig, C as CatalogListOptions, b as CatalogListResponse, X as Product } from './types-CQVak2a3.js';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.js';
|
|
4
4
|
|
package/dist/checkout.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { c as CheckoutAuthOpts, d as CheckoutIntentInfo, e as CheckoutIntentStatus, f as CheckoutNamespace, g as CheckoutStartInput, h as CheckoutStartResult, i as CheckoutTenantType, M as MockCheckout, au as createCheckoutNamespace } from './types-
|
|
1
|
+
export { c as CheckoutAuthOpts, d as CheckoutIntentInfo, e as CheckoutIntentStatus, f as CheckoutNamespace, g as CheckoutStartInput, h as CheckoutStartResult, i as CheckoutTenantType, M as MockCheckout, au as createCheckoutNamespace } from './types-BXvGHppn.cjs';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.cjs';
|
package/dist/checkout.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { c as CheckoutAuthOpts, d as CheckoutIntentInfo, e as CheckoutIntentStatus, f as CheckoutNamespace, g as CheckoutStartInput, h as CheckoutStartResult, i as CheckoutTenantType, M as MockCheckout, au as createCheckoutNamespace } from './types-
|
|
1
|
+
export { c as CheckoutAuthOpts, d as CheckoutIntentInfo, e as CheckoutIntentStatus, f as CheckoutNamespace, g as CheckoutStartInput, h as CheckoutStartResult, i as CheckoutTenantType, M as MockCheckout, au as createCheckoutNamespace } from './types-CQVak2a3.js';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.js';
|
package/dist/db-react.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ac as SyncState, ah as Unsubscribe, p as DbDoc, B as NeetruClient, o as DbCollectionRef, u as DbQuery } from './types-
|
|
1
|
+
import { ac as SyncState, ah as Unsubscribe, p as DbDoc, B as NeetruClient, o as DbCollectionRef, u as DbQuery } from './types-BXvGHppn.cjs';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.cjs';
|
|
4
4
|
|
package/dist/db-react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ac as SyncState, ah as Unsubscribe, p as DbDoc, B as NeetruClient, o as DbCollectionRef, u as DbQuery } from './types-
|
|
1
|
+
import { ac as SyncState, ah as Unsubscribe, p as DbDoc, B as NeetruClient, o as DbCollectionRef, u as DbQuery } from './types-CQVak2a3.js';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.js';
|
|
4
4
|
|
package/dist/db.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { j as ConflictRecord, k as CreateOfflineDocumentsOptions, m as DbBatchOp, n as DbChangeType, o as DbCollectionRef, p as DbDoc, q as DbDocRef, r as DbGetResult, s as DbListResult, u as DbQuery, v as DbSqlLease, x as DbWhereFilter, F as FieldSentinel, I as IncrementSentinel, N as NEETRU_SENTINEL_KEY, H as NeetruDb, J as NeetruDbDocuments, K as NeetruDbEngine, O as NeetruDbError, P as NeetruDbErrorCode, Q as NeetruDbOptions, R as NeetruDbTransport, T as NeetruSqlClient, a0 as RealtimeTransport, a5 as ServerTimestampSentinel, a7 as SqlOptions, ac as SyncState, at as WithFieldSentinels, av as createNeetruDb, ax as createRestSyncTransport, az as getWebSocketRealtimeClient, aA as increment, aB as isFieldSentinel, aC as isIncrementSentinel, aD as isServerTimestampSentinel, aE as serverTimestamp } from './types-
|
|
1
|
+
export { j as ConflictRecord, k as CreateOfflineDocumentsOptions, m as DbBatchOp, n as DbChangeType, o as DbCollectionRef, p as DbDoc, q as DbDocRef, r as DbGetResult, s as DbListResult, u as DbQuery, v as DbSqlLease, x as DbWhereFilter, F as FieldSentinel, I as IncrementSentinel, N as NEETRU_SENTINEL_KEY, H as NeetruDb, J as NeetruDbDocuments, K as NeetruDbEngine, O as NeetruDbError, P as NeetruDbErrorCode, Q as NeetruDbOptions, R as NeetruDbTransport, T as NeetruSqlClient, a0 as RealtimeTransport, a5 as ServerTimestampSentinel, a7 as SqlOptions, ac as SyncState, at as WithFieldSentinels, av as createNeetruDb, ax as createRestSyncTransport, az as getWebSocketRealtimeClient, aA as increment, aB as isFieldSentinel, aC as isIncrementSentinel, aD as isServerTimestampSentinel, aE as serverTimestamp } from './types-BXvGHppn.cjs';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.cjs';
|
package/dist/db.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { j as ConflictRecord, k as CreateOfflineDocumentsOptions, m as DbBatchOp, n as DbChangeType, o as DbCollectionRef, p as DbDoc, q as DbDocRef, r as DbGetResult, s as DbListResult, u as DbQuery, v as DbSqlLease, x as DbWhereFilter, F as FieldSentinel, I as IncrementSentinel, N as NEETRU_SENTINEL_KEY, H as NeetruDb, J as NeetruDbDocuments, K as NeetruDbEngine, O as NeetruDbError, P as NeetruDbErrorCode, Q as NeetruDbOptions, R as NeetruDbTransport, T as NeetruSqlClient, a0 as RealtimeTransport, a5 as ServerTimestampSentinel, a7 as SqlOptions, ac as SyncState, at as WithFieldSentinels, av as createNeetruDb, ax as createRestSyncTransport, az as getWebSocketRealtimeClient, aA as increment, aB as isFieldSentinel, aC as isIncrementSentinel, aD as isServerTimestampSentinel, aE as serverTimestamp } from './types-
|
|
1
|
+
export { j as ConflictRecord, k as CreateOfflineDocumentsOptions, m as DbBatchOp, n as DbChangeType, o as DbCollectionRef, p as DbDoc, q as DbDocRef, r as DbGetResult, s as DbListResult, u as DbQuery, v as DbSqlLease, x as DbWhereFilter, F as FieldSentinel, I as IncrementSentinel, N as NEETRU_SENTINEL_KEY, H as NeetruDb, J as NeetruDbDocuments, K as NeetruDbEngine, O as NeetruDbError, P as NeetruDbErrorCode, Q as NeetruDbOptions, R as NeetruDbTransport, T as NeetruSqlClient, a0 as RealtimeTransport, a5 as ServerTimestampSentinel, a7 as SqlOptions, ac as SyncState, at as WithFieldSentinels, av as createNeetruDb, ax as createRestSyncTransport, az as getWebSocketRealtimeClient, aA as increment, aB as isFieldSentinel, aC as isIncrementSentinel, aD as isServerTimestampSentinel, aE as serverTimestamp } from './types-CQVak2a3.js';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.js';
|
package/dist/entitlements.d.cts
CHANGED
package/dist/entitlements.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as NeetruDb, o as DbCollectionRef, F as FieldSentinel, u as DbQuery } from './types-
|
|
1
|
+
import { H as NeetruDb, o as DbCollectionRef, F as FieldSentinel, u as DbQuery } from './types-BXvGHppn.cjs';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.cjs';
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as NeetruDb, o as DbCollectionRef, F as FieldSentinel, u as DbQuery } from './types-
|
|
1
|
+
import { H as NeetruDb, o as DbCollectionRef, F as FieldSentinel, u as DbQuery } from './types-CQVak2a3.js';
|
|
2
2
|
import 'drizzle-orm/node-postgres';
|
|
3
3
|
import './errors.js';
|
|
4
4
|
|
package/dist/index.cjs
CHANGED
|
@@ -5567,9 +5567,19 @@ var DEV_FIXTURE_USER = Object.freeze({
|
|
|
5567
5567
|
var MockAuth = class {
|
|
5568
5568
|
_user;
|
|
5569
5569
|
_listeners;
|
|
5570
|
-
|
|
5570
|
+
_allowUnsignedDecode;
|
|
5571
|
+
constructor(initialUser = null, options) {
|
|
5571
5572
|
this._user = initialUser;
|
|
5572
5573
|
this._listeners = /* @__PURE__ */ new Set();
|
|
5574
|
+
this._allowUnsignedDecode = options?.allowUnsignedDecode ?? false;
|
|
5575
|
+
if (this._allowUnsignedDecode) {
|
|
5576
|
+
const isTestEnv = typeof process !== "undefined" && (process.env?.NODE_ENV === "test" || process.env?.VITEST === "true" || process.env?.VITEST != null);
|
|
5577
|
+
if (!isTestEnv && typeof console !== "undefined") {
|
|
5578
|
+
console.warn(
|
|
5579
|
+
"[neetru-sdk] MockAuth.verifyToken est\xE1 em modo allowUnsignedDecode=true: tokens N\xC3O t\xEAm assinatura verificada. Este modo \xE9 exclusivo para testes \u2014 NUNCA use como security boundary em c\xF3digo deployado."
|
|
5580
|
+
);
|
|
5581
|
+
}
|
|
5582
|
+
}
|
|
5573
5583
|
}
|
|
5574
5584
|
async signIn(_options) {
|
|
5575
5585
|
if (!this._user) this._user = { ...DEV_FIXTURE_USER };
|
|
@@ -5594,18 +5604,27 @@ var MockAuth = class {
|
|
|
5594
5604
|
};
|
|
5595
5605
|
}
|
|
5596
5606
|
/**
|
|
5597
|
-
* Mock de `verifyToken` —
|
|
5598
|
-
*
|
|
5599
|
-
*
|
|
5607
|
+
* Mock de `verifyToken` — por default lança `unauthorized` pra prevenir uso
|
|
5608
|
+
* acidental como security boundary em código deployado.
|
|
5609
|
+
*
|
|
5610
|
+
* Para decodificar JWTs sem verificar assinatura em testes, crie a instância
|
|
5611
|
+
* com `new MockAuth(user, { allowUnsignedDecode: true })`. Isso é um opt-in
|
|
5612
|
+
* explícito — nunca acontece silenciosamente.
|
|
5600
5613
|
*
|
|
5601
|
-
* Para simular falhas
|
|
5614
|
+
* Para simular falhas ou resultados customizados, use `__mockVerifyToken(fn)`.
|
|
5602
5615
|
*/
|
|
5603
5616
|
async verifyToken(token) {
|
|
5604
5617
|
if (this._verifyTokenOverride) {
|
|
5605
5618
|
return this._verifyTokenOverride(token);
|
|
5606
5619
|
}
|
|
5607
5620
|
if (!token) {
|
|
5608
|
-
throw
|
|
5621
|
+
throw new exports.NeetruError("token_invalid_signature", "Token inv\xE1lido: string vazia");
|
|
5622
|
+
}
|
|
5623
|
+
if (!this._allowUnsignedDecode) {
|
|
5624
|
+
throw new exports.NeetruError(
|
|
5625
|
+
"unauthorized",
|
|
5626
|
+
"MockAuth.verifyToken n\xE3o verifica assinaturas JWT e N\xC3O deve ser usado como security boundary em c\xF3digo deployado. Em testes, use new MockAuth(user, { allowUnsignedDecode: true }) para habilitar decodifica\xE7\xE3o sem assinatura, ou __mockVerifyToken(fn) para injetar resultado customizado."
|
|
5627
|
+
);
|
|
5609
5628
|
}
|
|
5610
5629
|
try {
|
|
5611
5630
|
const parts = token.split(".");
|
|
@@ -5632,7 +5651,7 @@ var MockAuth = class {
|
|
|
5632
5651
|
} catch {
|
|
5633
5652
|
}
|
|
5634
5653
|
if (this._user) return this._user;
|
|
5635
|
-
throw
|
|
5654
|
+
throw new exports.NeetruError("token_invalid_signature", "Nenhum user mock dispon\xEDvel e JWT sem sub v\xE1lido");
|
|
5636
5655
|
}
|
|
5637
5656
|
/**
|
|
5638
5657
|
* Mock de `handleRedirectCallback` (Bug 2 / 3.1.3) — não há redirect real no
|
|
@@ -6503,13 +6522,20 @@ function createOidcAuthNamespace(config) {
|
|
|
6503
6522
|
const issuer = idpOrigin;
|
|
6504
6523
|
const jwksUrl = `${idpOrigin}/api/v1/oauth/.well-known/jwks.json`;
|
|
6505
6524
|
const cacheTtlMs = options?.jwksCacheTtlMs ?? DEFAULT_JWKS_TTL_MS;
|
|
6525
|
+
const audienceFromOptions = options?.audience;
|
|
6506
6526
|
const parsedKey = tryParseApiKey(config.apiKey);
|
|
6507
|
-
const audience = parsedKey?.keyId;
|
|
6527
|
+
const audience = audienceFromOptions ?? parsedKey?.keyId;
|
|
6528
|
+
if (!audience) {
|
|
6529
|
+
throw new exports.NeetruError(
|
|
6530
|
+
"invalid_config",
|
|
6531
|
+
"verifyToken requires an audience: provide apiKey on the client or pass options.audience. Calling jwtVerify without an audience allows tokens issued for other OIDC clients to pass."
|
|
6532
|
+
);
|
|
6533
|
+
}
|
|
6508
6534
|
const jwks = _getJwks(jwksUrl, cacheTtlMs);
|
|
6509
6535
|
try {
|
|
6510
6536
|
const { payload } = await jose.jwtVerify(token, jwks, {
|
|
6511
6537
|
issuer,
|
|
6512
|
-
|
|
6538
|
+
audience,
|
|
6513
6539
|
algorithms: ["RS256"]
|
|
6514
6540
|
});
|
|
6515
6541
|
return _jwtPayloadToUser(payload);
|
|
@@ -6585,7 +6611,7 @@ function createNeetruClient(config = {}) {
|
|
|
6585
6611
|
init_errors();
|
|
6586
6612
|
init_db_errors();
|
|
6587
6613
|
init_http();
|
|
6588
|
-
var VERSION = "3.1.
|
|
6614
|
+
var VERSION = "3.1.6";
|
|
6589
6615
|
|
|
6590
6616
|
exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL;
|
|
6591
6617
|
exports.DEV_FIXTURE_USER = DEV_FIXTURE_USER;
|