@neetru/sdk 3.7.0 → 3.8.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 +75 -0
- package/README.md +66 -1
- package/dist/ai.cjs +221 -177
- package/dist/ai.d.cts +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.mjs +221 -177
- package/dist/auth.cjs +1051 -868
- package/dist/auth.d.cts +1 -1
- package/dist/auth.d.ts +1 -1
- package/dist/auth.mjs +1048 -865
- package/dist/catalog.cjs +164 -97
- package/dist/catalog.d.cts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.mjs +164 -97
- package/dist/checkout.cjs +182 -115
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/checkout.mjs +181 -114
- package/dist/db-react.d.cts +1 -1
- package/dist/db-react.d.ts +1 -1
- package/dist/db.cjs +437 -345
- package/dist/db.d.cts +1 -1
- package/dist/db.d.ts +1 -1
- package/dist/db.mjs +455 -363
- package/dist/entitlements.cjs +17 -10
- package/dist/entitlements.d.cts +1 -1
- package/dist/entitlements.d.ts +1 -1
- package/dist/entitlements.mjs +17 -10
- package/dist/errors.cjs +15 -8
- package/dist/errors.d.cts +24 -3
- package/dist/errors.d.ts +24 -3
- package/dist/errors.mjs +14 -7
- package/dist/firestore-compat.d.cts +1 -1
- package/dist/firestore-compat.d.ts +1 -1
- package/dist/index.cjs +1544 -1190
- package/dist/index.d.cts +177 -3
- package/dist/index.d.ts +177 -3
- package/dist/index.mjs +1676 -1329
- package/dist/mobile.cjs +400 -181
- package/dist/mobile.d.cts +59 -4
- package/dist/mobile.d.ts +59 -4
- package/dist/mobile.mjs +400 -181
- package/dist/mocks.cjs +9 -2
- package/dist/mocks.d.cts +1 -1
- package/dist/mocks.d.ts +1 -1
- package/dist/mocks.mjs +9 -2
- package/dist/notifications.cjs +197 -130
- package/dist/notifications.d.cts +1 -1
- package/dist/notifications.d.ts +1 -1
- package/dist/notifications.mjs +196 -129
- package/dist/react.cjs +303 -282
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.mjs +295 -274
- package/dist/support.cjs +299 -229
- package/dist/support.d.cts +8 -4
- package/dist/support.d.ts +8 -4
- package/dist/support.mjs +298 -228
- package/dist/telemetry.cjs +234 -167
- package/dist/telemetry.d.cts +1 -1
- package/dist/telemetry.d.ts +1 -1
- package/dist/telemetry.mjs +234 -167
- package/dist/{types-Dx0IrOSF.d.ts → types-BYPk_3HR.d.ts} +104 -17
- package/dist/{types-Bx4kTLmk.d.cts → types-yv3EDKg2.d.cts} +104 -17
- package/dist/usage.cjs +183 -116
- package/dist/usage.d.cts +1 -1
- package/dist/usage.d.ts +1 -1
- package/dist/usage.mjs +183 -116
- package/dist/webhooks.cjs +215 -148
- package/dist/webhooks.d.cts +1 -1
- package/dist/webhooks.d.ts +1 -1
- package/dist/webhooks.mjs +212 -145
- package/package.json +2 -1
|
@@ -113,6 +113,28 @@ declare class MockCheckout implements CheckoutNamespace {
|
|
|
113
113
|
}
|
|
114
114
|
declare function createCheckoutNamespace(config: ResolvedConfig): CheckoutNamespace;
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* 3.8.0 — Provedor de token do USUÁRIO FINAL, síncrono OU assíncrono.
|
|
118
|
+
*
|
|
119
|
+
* O namespace `auth` web lê o id_token de `localStorage` (síncrono). Em React
|
|
120
|
+
* Native o storage é assíncrono (`@neetru/sdk/mobile` → `getIdToken():
|
|
121
|
+
* Promise`). Antes desta versão `support` e a barra de conta só aceitavam o
|
|
122
|
+
* contrato síncrono — o módulo mobile ficava solto do `createNeetruClient`.
|
|
123
|
+
*
|
|
124
|
+
* Agora `createNeetruClient({ endUserAuth })` aceita qualquer objeto com
|
|
125
|
+
* `getIdToken()` (sync ou Promise) e, opcionalmente, `refreshTokens()` — o
|
|
126
|
+
* `MobileAuthNamespace` encaixa direto. O provedor fica registrado por client
|
|
127
|
+
* (WeakMap, sem mudar o shape público do `NeetruClient`) para a barra de conta
|
|
128
|
+
* (`fetchNeetruAccountBar`) achá-lo.
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
interface EndUserTokenProvider {
|
|
132
|
+
/** id_token OIDC do usuário logado, ou `null`. Pode ser síncrono ou Promise. */
|
|
133
|
+
getIdToken(): string | null | undefined | Promise<string | null | undefined>;
|
|
134
|
+
/** Renova a sessão (refresh_token → id_token novo). `true` se renovou. */
|
|
135
|
+
refreshTokens?(): Promise<boolean>;
|
|
136
|
+
}
|
|
137
|
+
|
|
116
138
|
/** Bloco de texto de uma mensagem multimodal (OpenAI-compat). */
|
|
117
139
|
interface AiTextPart {
|
|
118
140
|
type: 'text';
|
|
@@ -1390,9 +1412,42 @@ interface RealtimeClientOptions {
|
|
|
1390
1412
|
* Alinhado com `DbSqlLease` do Core (`src/lib/db/lease/types.ts`).
|
|
1391
1413
|
*
|
|
1392
1414
|
* - `port` sempre 5433 — o lease aponta pro PgBouncer, nunca à porta crua.
|
|
1393
|
-
* - `credentialVersion` —
|
|
1394
|
-
* o pool ao detectar versão diferente.
|
|
1415
|
+
* - `credentialVersion` — hoje é um placeholder fixo do Core (ver o campo).
|
|
1395
1416
|
* - `expiresAt` — ISO string; o SDK renova aos ~80% do TTL (12 min em TTL=15 min).
|
|
1417
|
+
*
|
|
1418
|
+
* ── TLS / mTLS (estado real) ───────────────────────────────────────────────
|
|
1419
|
+
*
|
|
1420
|
+
* **O mTLS de cliente ESTÁ ativo.** O Core emite os três materiais em TODO
|
|
1421
|
+
* lease SQL (emissão e renovação — `buildLease`, ramo `sql`, em
|
|
1422
|
+
* `src/lib/db/lease/issuer-core.ts` do Core):
|
|
1423
|
+
* - `sslca` — a CA interna do Core (secret `coredb_ca_cert`). A MESMA CA
|
|
1424
|
+
* assina o cert do servidor PgBouncer (365 dias) e os certs de cliente.
|
|
1425
|
+
* - `clientCert` — X.509 de cliente emitido por lease: CN = `leaseId`, EKU
|
|
1426
|
+
* `clientAuth`, validade = TTL do lease (15 min).
|
|
1427
|
+
* - `clientKey` — chave EC P-256 efêmera, nova a cada emissão/renovação.
|
|
1428
|
+
* Não há flag que desligue isso: sem a CA no Secret Manager a emissão FALHA
|
|
1429
|
+
* (HTTP 500), em vez de devolver esses campos `null`.
|
|
1430
|
+
*
|
|
1431
|
+
* O SDK usa os três ao abrir o `pg.Pool` (`createPgPool` e o `createPool` de
|
|
1432
|
+
* `createSqlClientFromConfig`): com `sslca` presente, `ssl = { ca: sslca,
|
|
1433
|
+
* cert: clientCert, key: clientKey, rejectUnauthorized: true }` — verifica o
|
|
1434
|
+
* servidor (CA + hostname) E apresenta o cert de cliente.
|
|
1435
|
+
*
|
|
1436
|
+
* Do lado da VM, o PgBouncer roda com `client_tls_sslmode = verify-full` e
|
|
1437
|
+
* `client_tls_ca_file` = CA do Core (agente, `src/handlers/db-pgbouncer.ts`):
|
|
1438
|
+
* EXIGE cert de cliente válido. E `auth_type = scram-sha-256` — a conexão
|
|
1439
|
+
* precisa do cert E da senha do lease (o CN não é comparado ao usuário).
|
|
1440
|
+
*
|
|
1441
|
+
* Consequências práticas:
|
|
1442
|
+
* - o cert de cliente expira junto com o lease (~15 min). Pool que não troca
|
|
1443
|
+
* de lease passa a levar `certificate expired` (alerta TLS 45 enviado pelo
|
|
1444
|
+
* PgBouncer) — é o que a renovação proativa (`lease.ts`) e o re-lease
|
|
1445
|
+
* reativo (`resilient-pool.ts`) curam;
|
|
1446
|
+
* - se o install da VM não obteve a CA/assinatura, o Core configura o
|
|
1447
|
+
* PgBouncer SEM TLS (fail-open, com aviso no log). Como o SDK sempre liga
|
|
1448
|
+
* TLS quando o lease traz `sslca`, a conexão falha com "The server does
|
|
1449
|
+
* not support SSL connections" — o conserto é reconfigurar o PgBouncer com
|
|
1450
|
+
* TLS, não desligar TLS no SDK.
|
|
1396
1451
|
*/
|
|
1397
1452
|
interface DbSqlLease {
|
|
1398
1453
|
leaseId: string;
|
|
@@ -1403,31 +1458,38 @@ interface DbSqlLease {
|
|
|
1403
1458
|
/** Plaintext — trafega só sobre HTTPS, NUNCA logado/persistido. */
|
|
1404
1459
|
password: string;
|
|
1405
1460
|
/**
|
|
1406
|
-
* CA do
|
|
1407
|
-
*
|
|
1408
|
-
* (`rejectUnauthorized: true`).
|
|
1461
|
+
* CA interna do Core (PEM) — a mesma que assina o cert do servidor PgBouncer
|
|
1462
|
+
* e o `clientCert`. O pool valida o servidor contra ela
|
|
1463
|
+
* (`rejectUnauthorized: true`). O Core sempre manda em lease SQL; `null` só
|
|
1464
|
+
* se o campo vier ausente, e aí o SDK conecta SEM TLS (`ssl: false`), mesmo
|
|
1465
|
+
* que `clientCert` exista.
|
|
1409
1466
|
*/
|
|
1410
1467
|
sslca: string | null;
|
|
1411
1468
|
/**
|
|
1412
|
-
* Certificado de **cliente** para mTLS
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1469
|
+
* Certificado X.509 de **cliente** (PEM) para mTLS, emitido por lease
|
|
1470
|
+
* (CN = `leaseId`, EKU `clientAuth`, expira com o lease — 15 min). O SDK o
|
|
1471
|
+
* apresenta ao PgBouncer em `ssl.cert`; o PgBouncer o exige
|
|
1472
|
+
* (`client_tls_sslmode = verify-full`). O Core sempre manda em lease SQL —
|
|
1473
|
+
* o `| null` é só tolerância a resposta sem o campo (o pool fica com TLS
|
|
1474
|
+
* só de servidor).
|
|
1417
1475
|
*/
|
|
1418
1476
|
clientCert: string | null;
|
|
1419
1477
|
/**
|
|
1420
|
-
* Chave privada de **cliente**
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1478
|
+
* Chave privada de **cliente** (PEM, EC P-256 efêmera, nova a cada
|
|
1479
|
+
* emissão/renovação) — par de `clientCert`, vai em `ssl.key`. Trafega só
|
|
1480
|
+
* sobre HTTPS, NUNCA logada/persistida. Mesma regra de `null` do
|
|
1481
|
+
* `clientCert`.
|
|
1423
1482
|
*/
|
|
1424
1483
|
clientKey: string | null;
|
|
1425
1484
|
/**
|
|
1426
|
-
* Versão da credencial
|
|
1427
|
-
*
|
|
1485
|
+
* Versão da credencial. HOJE o Core manda sempre o placeholder `1` (TODO de
|
|
1486
|
+
* versionamento no `issuer-core.ts` do Core), então ela NÃO sinaliza
|
|
1487
|
+
* rotação. A troca de pool numa rotação é disparada pela mudança de
|
|
1488
|
+
* `password` (ou de qualquer campo de conexão) — ver `hasConnectionChanged`
|
|
1489
|
+
* em `lease.ts`.
|
|
1428
1490
|
*/
|
|
1429
1491
|
credentialVersion: number;
|
|
1430
|
-
/** Expiração ISO — SDK renova ~
|
|
1492
|
+
/** Expiração ISO — o SDK renova aos ~80% do TTL (~3 min antes, em 15 min). */
|
|
1431
1493
|
expiresAt: string;
|
|
1432
1494
|
}
|
|
1433
1495
|
/**
|
|
@@ -1975,6 +2037,10 @@ interface NeetruClientConfig {
|
|
|
1975
2037
|
*
|
|
1976
2038
|
* Endpoints públicos (catalog) funcionam sem apiKey. Endpoints autenticados
|
|
1977
2039
|
* (entitlements, telemetry) lançam `missing_api_key` se ausente.
|
|
2040
|
+
*
|
|
2041
|
+
* **3.8.0: SÓ DE SERVIDOR.** Nunca coloque a chave no navegador ou no app
|
|
2042
|
+
* (`NEXT_PUBLIC_*`/`EXPO_PUBLIC_*`): o site/app chama a API do próprio produto
|
|
2043
|
+
* e o backend usa o SDK com a chave. Ver `strictServerOnlyKey`.
|
|
1978
2044
|
*/
|
|
1979
2045
|
apiKey?: string;
|
|
1980
2046
|
/**
|
|
@@ -2053,6 +2119,27 @@ interface NeetruClientConfig {
|
|
|
2053
2119
|
* Bypass total: `NEETRU_ALLOW_INSECURE_BASEURL=1` no env.
|
|
2054
2120
|
*/
|
|
2055
2121
|
allowedHosts?: string[];
|
|
2122
|
+
/**
|
|
2123
|
+
* 3.8.0 — a credencial `nrt_` é SÓ DE SERVIDOR. Quando o SDK recebe chave
|
|
2124
|
+
* (via `apiKey` ou `NEETRU_API_KEY`) rodando em navegador ou React Native:
|
|
2125
|
+
* - `false`/omitido (padrão nesta minor): aviso único no console (PT-BR,
|
|
2126
|
+
* sem imprimir a chave) e segue funcionando — pra não quebrar produtos
|
|
2127
|
+
* que ainda estão migrando;
|
|
2128
|
+
* - `true`: falha FECHADO com `NeetruError('server_only_key')`.
|
|
2129
|
+
*
|
|
2130
|
+
* **Na próxima MAJOR (4.0) a falha fechada vira o padrão.** No servidor
|
|
2131
|
+
* (Node/Edge) a opção não tem efeito.
|
|
2132
|
+
*/
|
|
2133
|
+
strictServerOnlyKey?: boolean;
|
|
2134
|
+
/**
|
|
2135
|
+
* 3.8.0 — provedor do token do USUÁRIO FINAL usado pelo `support`
|
|
2136
|
+
* (`X-Neetru-End-User-Token`) e pela barra de conta. Aceita `getIdToken()`
|
|
2137
|
+
* síncrono ou assíncrono (+ `refreshTokens()` opcional). Encaixa direto o
|
|
2138
|
+
* `createMobileAuthNamespace(...)` de `@neetru/sdk/mobile`; no backend do
|
|
2139
|
+
* produto, pode ser `{ getIdToken: () => idTokenQueOAppMandou }`.
|
|
2140
|
+
* Default: `client.auth`.
|
|
2141
|
+
*/
|
|
2142
|
+
endUserAuth?: EndUserTokenProvider;
|
|
2056
2143
|
}
|
|
2057
2144
|
/**
|
|
2058
2145
|
* Status do produto no catálogo público.
|
|
@@ -2721,4 +2808,4 @@ interface CatalogListOptions {
|
|
|
2721
2808
|
includeDrafts?: boolean;
|
|
2722
2809
|
}
|
|
2723
2810
|
|
|
2724
|
-
export {
|
|
2811
|
+
export { type NeetruDbEngine as $, type AiChatChoice as A, type DbChangeType as B, type CatalogListOptions as C, DEFAULT_BASE_URL as D, type DbCollectionRef$1 as E, type DbDoc as F, type DbDocRef as G, type DbGetResult as H, type DbListResult as I, type DbNamespace as J, type DbQuery$1 as K, type DbSqlLease as L, type DbWhereFilter as M, type DbWhereFilter$1 as N, type EndUserTokenProvider as O, type EntitlementCheck as P, type FieldSentinel as Q, type IncrementSentinel as R, type ListNotificationsOptions as S, MockCheckout as T, MockNotifications as U, MockWebhooks as V, NEETRU_SENTINEL_KEY as W, type NeetruClient as X, type NeetruClientConfig as Y, type NeetruDb as Z, type NeetruDbDocuments as _, type AiChatMessage as a, NeetruDbError as a0, type NeetruDbErrorCode as a1, type NeetruDbOptions as a2, type NeetruDbTransport as a3, type NeetruEnv as a4, type NeetruSqlClient as a5, type NeetruUser as a6, type NotificationScopeOptions as a7, type NotificationsNamespace as a8, type Product as a9, type VerifyTokenOptions as aA, type VerifyWebhookRequestOptions as aB, type VerifyWebhookRequestResult as aC, type WebhookEndpoint as aD, type WebhookEvent as aE, type WebhookScopeOptions as aF, type WebhookTestResult as aG, type WebhooksNamespace as aH, type WithFieldSentinels as aI, __resetDbIdWarningForTests as aJ, createAiNamespace as aK, createCheckoutNamespace as aL, createNeetruDb as aM, createNotificationsNamespace as aN, createRestSyncTransport as aO, createWebhooksNamespace as aP, getWebSocketRealtimeClient as aQ, increment as aR, isFieldSentinel as aS, isIncrementSentinel as aT, isServerTimestampSentinel as aU, serverTimestamp as aV, verifyWebhookRequest as aW, verifyWebhookSignature as aX, type ProductNotification as aa, type ProductNotificationSeverity as ab, type ProductPlan as ac, type ProductStatus as ad, type RealtimeTransport as ae, type RedirectCallbackResult as af, type RegisterWebhookInput as ag, type ResolvedConfig as ah, type SendNotificationInput as ai, type ServerTimestampSentinel as aj, type SignInOptions as ak, type SqlOptions as al, type SupportNamespace as am, type SupportSeverity as an, type SupportStatus as ao, type SupportTicket as ap, type SyncErrorEvent as aq, type SyncState as ar, type TelemetryEventAck as as, type TelemetryEventInput as at, type TelemetryLogAck as au, type TelemetryLogInput as av, type Unsubscribe as aw, type UsageEventInput as ax, type UsageNamespace as ay, type UsageQuota as az, type AiChatOptions as b, type AiChatResult as c, type AiChatUsage as d, type AiContentPart as e, type AiImageUrlPart as f, type AiNamespace as g, type AiResponseFormat as h, type AiStreamHandle as i, type AiStreamMeta as j, type AiTextPart as k, type AuthNamespace as l, type AuthStateListener as m, type CatalogListResponse as n, type CheckoutAuthOpts as o, type CheckoutIntentInfo as p, type CheckoutIntentStatus as q, type CheckoutNamespace as r, type CheckoutStartInput as s, type CheckoutStartResult as t, type CheckoutTenantType as u, type CompleteSignInResult as v, type ConflictRecord as w, type CreateOfflineDocumentsOptions as x, type CreateTicketInput as y, type DbBatchOp as z };
|
|
@@ -113,6 +113,28 @@ declare class MockCheckout implements CheckoutNamespace {
|
|
|
113
113
|
}
|
|
114
114
|
declare function createCheckoutNamespace(config: ResolvedConfig): CheckoutNamespace;
|
|
115
115
|
|
|
116
|
+
/**
|
|
117
|
+
* 3.8.0 — Provedor de token do USUÁRIO FINAL, síncrono OU assíncrono.
|
|
118
|
+
*
|
|
119
|
+
* O namespace `auth` web lê o id_token de `localStorage` (síncrono). Em React
|
|
120
|
+
* Native o storage é assíncrono (`@neetru/sdk/mobile` → `getIdToken():
|
|
121
|
+
* Promise`). Antes desta versão `support` e a barra de conta só aceitavam o
|
|
122
|
+
* contrato síncrono — o módulo mobile ficava solto do `createNeetruClient`.
|
|
123
|
+
*
|
|
124
|
+
* Agora `createNeetruClient({ endUserAuth })` aceita qualquer objeto com
|
|
125
|
+
* `getIdToken()` (sync ou Promise) e, opcionalmente, `refreshTokens()` — o
|
|
126
|
+
* `MobileAuthNamespace` encaixa direto. O provedor fica registrado por client
|
|
127
|
+
* (WeakMap, sem mudar o shape público do `NeetruClient`) para a barra de conta
|
|
128
|
+
* (`fetchNeetruAccountBar`) achá-lo.
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
interface EndUserTokenProvider {
|
|
132
|
+
/** id_token OIDC do usuário logado, ou `null`. Pode ser síncrono ou Promise. */
|
|
133
|
+
getIdToken(): string | null | undefined | Promise<string | null | undefined>;
|
|
134
|
+
/** Renova a sessão (refresh_token → id_token novo). `true` se renovou. */
|
|
135
|
+
refreshTokens?(): Promise<boolean>;
|
|
136
|
+
}
|
|
137
|
+
|
|
116
138
|
/** Bloco de texto de uma mensagem multimodal (OpenAI-compat). */
|
|
117
139
|
interface AiTextPart {
|
|
118
140
|
type: 'text';
|
|
@@ -1390,9 +1412,42 @@ interface RealtimeClientOptions {
|
|
|
1390
1412
|
* Alinhado com `DbSqlLease` do Core (`src/lib/db/lease/types.ts`).
|
|
1391
1413
|
*
|
|
1392
1414
|
* - `port` sempre 5433 — o lease aponta pro PgBouncer, nunca à porta crua.
|
|
1393
|
-
* - `credentialVersion` —
|
|
1394
|
-
* o pool ao detectar versão diferente.
|
|
1415
|
+
* - `credentialVersion` — hoje é um placeholder fixo do Core (ver o campo).
|
|
1395
1416
|
* - `expiresAt` — ISO string; o SDK renova aos ~80% do TTL (12 min em TTL=15 min).
|
|
1417
|
+
*
|
|
1418
|
+
* ── TLS / mTLS (estado real) ───────────────────────────────────────────────
|
|
1419
|
+
*
|
|
1420
|
+
* **O mTLS de cliente ESTÁ ativo.** O Core emite os três materiais em TODO
|
|
1421
|
+
* lease SQL (emissão e renovação — `buildLease`, ramo `sql`, em
|
|
1422
|
+
* `src/lib/db/lease/issuer-core.ts` do Core):
|
|
1423
|
+
* - `sslca` — a CA interna do Core (secret `coredb_ca_cert`). A MESMA CA
|
|
1424
|
+
* assina o cert do servidor PgBouncer (365 dias) e os certs de cliente.
|
|
1425
|
+
* - `clientCert` — X.509 de cliente emitido por lease: CN = `leaseId`, EKU
|
|
1426
|
+
* `clientAuth`, validade = TTL do lease (15 min).
|
|
1427
|
+
* - `clientKey` — chave EC P-256 efêmera, nova a cada emissão/renovação.
|
|
1428
|
+
* Não há flag que desligue isso: sem a CA no Secret Manager a emissão FALHA
|
|
1429
|
+
* (HTTP 500), em vez de devolver esses campos `null`.
|
|
1430
|
+
*
|
|
1431
|
+
* O SDK usa os três ao abrir o `pg.Pool` (`createPgPool` e o `createPool` de
|
|
1432
|
+
* `createSqlClientFromConfig`): com `sslca` presente, `ssl = { ca: sslca,
|
|
1433
|
+
* cert: clientCert, key: clientKey, rejectUnauthorized: true }` — verifica o
|
|
1434
|
+
* servidor (CA + hostname) E apresenta o cert de cliente.
|
|
1435
|
+
*
|
|
1436
|
+
* Do lado da VM, o PgBouncer roda com `client_tls_sslmode = verify-full` e
|
|
1437
|
+
* `client_tls_ca_file` = CA do Core (agente, `src/handlers/db-pgbouncer.ts`):
|
|
1438
|
+
* EXIGE cert de cliente válido. E `auth_type = scram-sha-256` — a conexão
|
|
1439
|
+
* precisa do cert E da senha do lease (o CN não é comparado ao usuário).
|
|
1440
|
+
*
|
|
1441
|
+
* Consequências práticas:
|
|
1442
|
+
* - o cert de cliente expira junto com o lease (~15 min). Pool que não troca
|
|
1443
|
+
* de lease passa a levar `certificate expired` (alerta TLS 45 enviado pelo
|
|
1444
|
+
* PgBouncer) — é o que a renovação proativa (`lease.ts`) e o re-lease
|
|
1445
|
+
* reativo (`resilient-pool.ts`) curam;
|
|
1446
|
+
* - se o install da VM não obteve a CA/assinatura, o Core configura o
|
|
1447
|
+
* PgBouncer SEM TLS (fail-open, com aviso no log). Como o SDK sempre liga
|
|
1448
|
+
* TLS quando o lease traz `sslca`, a conexão falha com "The server does
|
|
1449
|
+
* not support SSL connections" — o conserto é reconfigurar o PgBouncer com
|
|
1450
|
+
* TLS, não desligar TLS no SDK.
|
|
1396
1451
|
*/
|
|
1397
1452
|
interface DbSqlLease {
|
|
1398
1453
|
leaseId: string;
|
|
@@ -1403,31 +1458,38 @@ interface DbSqlLease {
|
|
|
1403
1458
|
/** Plaintext — trafega só sobre HTTPS, NUNCA logado/persistido. */
|
|
1404
1459
|
password: string;
|
|
1405
1460
|
/**
|
|
1406
|
-
* CA do
|
|
1407
|
-
*
|
|
1408
|
-
* (`rejectUnauthorized: true`).
|
|
1461
|
+
* CA interna do Core (PEM) — a mesma que assina o cert do servidor PgBouncer
|
|
1462
|
+
* e o `clientCert`. O pool valida o servidor contra ela
|
|
1463
|
+
* (`rejectUnauthorized: true`). O Core sempre manda em lease SQL; `null` só
|
|
1464
|
+
* se o campo vier ausente, e aí o SDK conecta SEM TLS (`ssl: false`), mesmo
|
|
1465
|
+
* que `clientCert` exista.
|
|
1409
1466
|
*/
|
|
1410
1467
|
sslca: string | null;
|
|
1411
1468
|
/**
|
|
1412
|
-
* Certificado de **cliente** para mTLS
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1469
|
+
* Certificado X.509 de **cliente** (PEM) para mTLS, emitido por lease
|
|
1470
|
+
* (CN = `leaseId`, EKU `clientAuth`, expira com o lease — 15 min). O SDK o
|
|
1471
|
+
* apresenta ao PgBouncer em `ssl.cert`; o PgBouncer o exige
|
|
1472
|
+
* (`client_tls_sslmode = verify-full`). O Core sempre manda em lease SQL —
|
|
1473
|
+
* o `| null` é só tolerância a resposta sem o campo (o pool fica com TLS
|
|
1474
|
+
* só de servidor).
|
|
1417
1475
|
*/
|
|
1418
1476
|
clientCert: string | null;
|
|
1419
1477
|
/**
|
|
1420
|
-
* Chave privada de **cliente**
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1478
|
+
* Chave privada de **cliente** (PEM, EC P-256 efêmera, nova a cada
|
|
1479
|
+
* emissão/renovação) — par de `clientCert`, vai em `ssl.key`. Trafega só
|
|
1480
|
+
* sobre HTTPS, NUNCA logada/persistida. Mesma regra de `null` do
|
|
1481
|
+
* `clientCert`.
|
|
1423
1482
|
*/
|
|
1424
1483
|
clientKey: string | null;
|
|
1425
1484
|
/**
|
|
1426
|
-
* Versão da credencial
|
|
1427
|
-
*
|
|
1485
|
+
* Versão da credencial. HOJE o Core manda sempre o placeholder `1` (TODO de
|
|
1486
|
+
* versionamento no `issuer-core.ts` do Core), então ela NÃO sinaliza
|
|
1487
|
+
* rotação. A troca de pool numa rotação é disparada pela mudança de
|
|
1488
|
+
* `password` (ou de qualquer campo de conexão) — ver `hasConnectionChanged`
|
|
1489
|
+
* em `lease.ts`.
|
|
1428
1490
|
*/
|
|
1429
1491
|
credentialVersion: number;
|
|
1430
|
-
/** Expiração ISO — SDK renova ~
|
|
1492
|
+
/** Expiração ISO — o SDK renova aos ~80% do TTL (~3 min antes, em 15 min). */
|
|
1431
1493
|
expiresAt: string;
|
|
1432
1494
|
}
|
|
1433
1495
|
/**
|
|
@@ -1975,6 +2037,10 @@ interface NeetruClientConfig {
|
|
|
1975
2037
|
*
|
|
1976
2038
|
* Endpoints públicos (catalog) funcionam sem apiKey. Endpoints autenticados
|
|
1977
2039
|
* (entitlements, telemetry) lançam `missing_api_key` se ausente.
|
|
2040
|
+
*
|
|
2041
|
+
* **3.8.0: SÓ DE SERVIDOR.** Nunca coloque a chave no navegador ou no app
|
|
2042
|
+
* (`NEXT_PUBLIC_*`/`EXPO_PUBLIC_*`): o site/app chama a API do próprio produto
|
|
2043
|
+
* e o backend usa o SDK com a chave. Ver `strictServerOnlyKey`.
|
|
1978
2044
|
*/
|
|
1979
2045
|
apiKey?: string;
|
|
1980
2046
|
/**
|
|
@@ -2053,6 +2119,27 @@ interface NeetruClientConfig {
|
|
|
2053
2119
|
* Bypass total: `NEETRU_ALLOW_INSECURE_BASEURL=1` no env.
|
|
2054
2120
|
*/
|
|
2055
2121
|
allowedHosts?: string[];
|
|
2122
|
+
/**
|
|
2123
|
+
* 3.8.0 — a credencial `nrt_` é SÓ DE SERVIDOR. Quando o SDK recebe chave
|
|
2124
|
+
* (via `apiKey` ou `NEETRU_API_KEY`) rodando em navegador ou React Native:
|
|
2125
|
+
* - `false`/omitido (padrão nesta minor): aviso único no console (PT-BR,
|
|
2126
|
+
* sem imprimir a chave) e segue funcionando — pra não quebrar produtos
|
|
2127
|
+
* que ainda estão migrando;
|
|
2128
|
+
* - `true`: falha FECHADO com `NeetruError('server_only_key')`.
|
|
2129
|
+
*
|
|
2130
|
+
* **Na próxima MAJOR (4.0) a falha fechada vira o padrão.** No servidor
|
|
2131
|
+
* (Node/Edge) a opção não tem efeito.
|
|
2132
|
+
*/
|
|
2133
|
+
strictServerOnlyKey?: boolean;
|
|
2134
|
+
/**
|
|
2135
|
+
* 3.8.0 — provedor do token do USUÁRIO FINAL usado pelo `support`
|
|
2136
|
+
* (`X-Neetru-End-User-Token`) e pela barra de conta. Aceita `getIdToken()`
|
|
2137
|
+
* síncrono ou assíncrono (+ `refreshTokens()` opcional). Encaixa direto o
|
|
2138
|
+
* `createMobileAuthNamespace(...)` de `@neetru/sdk/mobile`; no backend do
|
|
2139
|
+
* produto, pode ser `{ getIdToken: () => idTokenQueOAppMandou }`.
|
|
2140
|
+
* Default: `client.auth`.
|
|
2141
|
+
*/
|
|
2142
|
+
endUserAuth?: EndUserTokenProvider;
|
|
2056
2143
|
}
|
|
2057
2144
|
/**
|
|
2058
2145
|
* Status do produto no catálogo público.
|
|
@@ -2721,4 +2808,4 @@ interface CatalogListOptions {
|
|
|
2721
2808
|
includeDrafts?: boolean;
|
|
2722
2809
|
}
|
|
2723
2810
|
|
|
2724
|
-
export {
|
|
2811
|
+
export { type NeetruDbEngine as $, type AiChatChoice as A, type DbChangeType as B, type CatalogListOptions as C, DEFAULT_BASE_URL as D, type DbCollectionRef$1 as E, type DbDoc as F, type DbDocRef as G, type DbGetResult as H, type DbListResult as I, type DbNamespace as J, type DbQuery$1 as K, type DbSqlLease as L, type DbWhereFilter as M, type DbWhereFilter$1 as N, type EndUserTokenProvider as O, type EntitlementCheck as P, type FieldSentinel as Q, type IncrementSentinel as R, type ListNotificationsOptions as S, MockCheckout as T, MockNotifications as U, MockWebhooks as V, NEETRU_SENTINEL_KEY as W, type NeetruClient as X, type NeetruClientConfig as Y, type NeetruDb as Z, type NeetruDbDocuments as _, type AiChatMessage as a, NeetruDbError as a0, type NeetruDbErrorCode as a1, type NeetruDbOptions as a2, type NeetruDbTransport as a3, type NeetruEnv as a4, type NeetruSqlClient as a5, type NeetruUser as a6, type NotificationScopeOptions as a7, type NotificationsNamespace as a8, type Product as a9, type VerifyTokenOptions as aA, type VerifyWebhookRequestOptions as aB, type VerifyWebhookRequestResult as aC, type WebhookEndpoint as aD, type WebhookEvent as aE, type WebhookScopeOptions as aF, type WebhookTestResult as aG, type WebhooksNamespace as aH, type WithFieldSentinels as aI, __resetDbIdWarningForTests as aJ, createAiNamespace as aK, createCheckoutNamespace as aL, createNeetruDb as aM, createNotificationsNamespace as aN, createRestSyncTransport as aO, createWebhooksNamespace as aP, getWebSocketRealtimeClient as aQ, increment as aR, isFieldSentinel as aS, isIncrementSentinel as aT, isServerTimestampSentinel as aU, serverTimestamp as aV, verifyWebhookRequest as aW, verifyWebhookSignature as aX, type ProductNotification as aa, type ProductNotificationSeverity as ab, type ProductPlan as ac, type ProductStatus as ad, type RealtimeTransport as ae, type RedirectCallbackResult as af, type RegisterWebhookInput as ag, type ResolvedConfig as ah, type SendNotificationInput as ai, type ServerTimestampSentinel as aj, type SignInOptions as ak, type SqlOptions as al, type SupportNamespace as am, type SupportSeverity as an, type SupportStatus as ao, type SupportTicket as ap, type SyncErrorEvent as aq, type SyncState as ar, type TelemetryEventAck as as, type TelemetryEventInput as at, type TelemetryLogAck as au, type TelemetryLogInput as av, type Unsubscribe as aw, type UsageEventInput as ax, type UsageNamespace as ay, type UsageQuota as az, type AiChatOptions as b, type AiChatResult as c, type AiChatUsage as d, type AiContentPart as e, type AiImageUrlPart as f, type AiNamespace as g, type AiResponseFormat as h, type AiStreamHandle as i, type AiStreamMeta as j, type AiTextPart as k, type AuthNamespace as l, type AuthStateListener as m, type CatalogListResponse as n, type CheckoutAuthOpts as o, type CheckoutIntentInfo as p, type CheckoutIntentStatus as q, type CheckoutNamespace as r, type CheckoutStartInput as s, type CheckoutStartResult as t, type CheckoutTenantType as u, type CompleteSignInResult as v, type ConflictRecord as w, type CreateOfflineDocumentsOptions as x, type CreateTicketInput as y, type DbBatchOp as z };
|