@aurabase/aurabase-js 0.3.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.
- package/.changeset/config.json +11 -0
- package/CHANGELOG.md +30 -0
- package/LICENSE +21 -0
- package/README.md +833 -0
- package/package.json +90 -0
- package/packages/ai/LICENSE +21 -0
- package/packages/ai/README.md +106 -0
- package/packages/ai/dist/index.cjs +229 -0
- package/packages/ai/dist/index.d.cts +139 -0
- package/packages/ai/dist/index.d.ts +139 -0
- package/packages/ai/dist/index.js +226 -0
- package/packages/ai/node_modules/.bin/esbuild +19 -0
- package/packages/ai/node_modules/.bin/tsc +22 -0
- package/packages/ai/node_modules/.bin/tsserver +22 -0
- package/packages/ai/node_modules/.bin/tsup +22 -0
- package/packages/ai/node_modules/.bin/tsup-node +22 -0
- package/packages/ai/node_modules/.bin/vite +22 -0
- package/packages/ai/node_modules/.bin/vitest +22 -0
- package/packages/ai/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/packages/ai/package.json +61 -0
- package/packages/ai/src/AiService.ts +226 -0
- package/packages/ai/src/index.ts +18 -0
- package/packages/ai/src/sse.ts +141 -0
- package/packages/ai/src/types.ts +30 -0
- package/packages/ai/tests/chat-stream.test.ts +151 -0
- package/packages/ai/tests/rag-namespaces.test.ts +54 -0
- package/packages/ai/tests/sse.test.ts +69 -0
- package/packages/ai/tsconfig.json +5 -0
- package/packages/ai/tsup.config.ts +11 -0
- package/packages/aurabase/LICENSE +21 -0
- package/packages/aurabase/README.md +64 -0
- package/packages/aurabase/dist/AuraClient-DAtDbfPB.d.cts +77 -0
- package/packages/aurabase/dist/AuraClient-DAtDbfPB.d.ts +77 -0
- package/packages/aurabase/dist/index.cjs +237 -0
- package/packages/aurabase/dist/index.d.cts +46 -0
- package/packages/aurabase/dist/index.d.ts +46 -0
- package/packages/aurabase/dist/index.js +177 -0
- package/packages/aurabase/dist/ssr.cjs +224 -0
- package/packages/aurabase/dist/ssr.d.cts +65 -0
- package/packages/aurabase/dist/ssr.d.ts +65 -0
- package/packages/aurabase/dist/ssr.js +214 -0
- package/packages/aurabase/node_modules/.bin/esbuild +19 -0
- package/packages/aurabase/node_modules/.bin/tsc +22 -0
- package/packages/aurabase/node_modules/.bin/tsserver +22 -0
- package/packages/aurabase/node_modules/.bin/tsup +22 -0
- package/packages/aurabase/node_modules/.bin/tsup-node +22 -0
- package/packages/aurabase/node_modules/.bin/vite +22 -0
- package/packages/aurabase/node_modules/.bin/vitest +22 -0
- package/packages/aurabase/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/packages/aurabase/package.json +80 -0
- package/packages/aurabase/src/AuraClient.ts +237 -0
- package/packages/aurabase/src/index.ts +152 -0
- package/packages/aurabase/src/ssr.ts +156 -0
- package/packages/aurabase/tests/ai-streaming-rag-e2e.test.ts +82 -0
- package/packages/aurabase/tests/ai.test.ts +111 -0
- package/packages/aurabase/tests/auth-admin.test.ts +515 -0
- package/packages/aurabase/tests/auth-e2e.test.ts +135 -0
- package/packages/aurabase/tests/auth-hardening.test.ts +206 -0
- package/packages/aurabase/tests/auth.test.ts +947 -0
- package/packages/aurabase/tests/database.test.ts +230 -0
- package/packages/aurabase/tests/db-types-e2e.test.ts +217 -0
- package/packages/aurabase/tests/dispose.test.ts +23 -0
- package/packages/aurabase/tests/foreign-token.e2e.test.ts +129 -0
- package/packages/aurabase/tests/functions.test.ts +107 -0
- package/packages/aurabase/tests/integration.test.ts +413 -0
- package/packages/aurabase/tests/live-production-validation.js +241 -0
- package/packages/aurabase/tests/live-sdk-production-validation.js +293 -0
- package/packages/aurabase/tests/mocks.ts +139 -0
- package/packages/aurabase/tests/notifications.test.ts +314 -0
- package/packages/aurabase/tests/observability-backup.test.ts +186 -0
- package/packages/aurabase/tests/observability-hook.test.ts +130 -0
- package/packages/aurabase/tests/production-robustness.test.ts +268 -0
- package/packages/aurabase/tests/public-api-surface.test.ts +53 -0
- package/packages/aurabase/tests/query-builder.test.ts +329 -0
- package/packages/aurabase/tests/readme-smoke-e2e.test.ts +231 -0
- package/packages/aurabase/tests/realtime-filter-e2e.test.ts +344 -0
- package/packages/aurabase/tests/refresh-locks.test.ts +210 -0
- package/packages/aurabase/tests/retry-option.test.ts +17 -0
- package/packages/aurabase/tests/rpc-e2e.test.ts +254 -0
- package/packages/aurabase/tests/rs256-local-e2e.test.ts +114 -0
- package/packages/aurabase/tests/rt-alias-public-e2e.test.ts +235 -0
- package/packages/aurabase/tests/rt-http-broadcast-e2e.test.ts +124 -0
- package/packages/aurabase/tests/service-role-guard.test.ts +99 -0
- package/packages/aurabase/tests/ssr.test.ts +91 -0
- package/packages/aurabase/tests/storage-backend-e2e.test.ts +481 -0
- package/packages/aurabase/tests/storage-sdk-parity-e2e.test.ts +104 -0
- package/packages/aurabase/tests/storage-transform-e2e.test.ts +684 -0
- package/packages/aurabase/tests/storage.test.ts +55 -0
- package/packages/aurabase/tests/types/client-generic.test-d.ts +79 -0
- package/packages/aurabase/tests/types/docs-snippets.test-d.ts +571 -0
- package/packages/aurabase/tests/types/error-code.test-d.ts +53 -0
- package/packages/aurabase/tsconfig.json +5 -0
- package/packages/aurabase/tsconfig.test-d.json +5 -0
- package/packages/aurabase/tsup.config.ts +11 -0
- package/packages/aurabase/vitest.config.ts +16 -0
- package/packages/aurabase/vitest.e2e.config.ts +9 -0
- package/packages/auth/LICENSE +21 -0
- package/packages/auth/README.md +215 -0
- package/packages/auth/dist/index.cjs +1175 -0
- package/packages/auth/dist/index.d.cts +397 -0
- package/packages/auth/dist/index.d.ts +397 -0
- package/packages/auth/dist/index.js +1170 -0
- package/packages/auth/node_modules/.bin/esbuild +19 -0
- package/packages/auth/node_modules/.bin/tsc +22 -0
- package/packages/auth/node_modules/.bin/tsserver +22 -0
- package/packages/auth/node_modules/.bin/tsup +22 -0
- package/packages/auth/node_modules/.bin/tsup-node +22 -0
- package/packages/auth/node_modules/.bin/vite +22 -0
- package/packages/auth/node_modules/.bin/vitest +22 -0
- package/packages/auth/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/packages/auth/package.json +61 -0
- package/packages/auth/src/AuthAdminService.ts +149 -0
- package/packages/auth/src/AuthService.ts +1166 -0
- package/packages/auth/src/SessionManager.ts +92 -0
- package/packages/auth/src/index.ts +17 -0
- package/packages/auth/src/jwks.ts +337 -0
- package/packages/auth/src/pkce.ts +27 -0
- package/packages/auth/src/types.ts +89 -0
- package/packages/auth/tests/auth-lifecycle.test.ts +149 -0
- package/packages/auth/tests/detect-session.test.ts +361 -0
- package/packages/auth/tests/getclaims.test.ts +780 -0
- package/packages/auth/tests/is-mfa-challenge.test.ts +27 -0
- package/packages/auth/tests/password-recovery.test.ts +124 -0
- package/packages/auth/tests/pkce.test.ts +192 -0
- package/packages/auth/tests/session-manager.test.ts +103 -0
- package/packages/auth/tests/set-session.test.ts +139 -0
- package/packages/auth/tests/verify-otp.test.ts +153 -0
- package/packages/auth/tsconfig.json +5 -0
- package/packages/auth/tsup.config.ts +11 -0
- package/packages/core/LICENSE +21 -0
- package/packages/core/README.md +132 -0
- package/packages/core/dist/index.cjs +695 -0
- package/packages/core/dist/index.d.cts +1137 -0
- package/packages/core/dist/index.d.ts +1137 -0
- package/packages/core/dist/index.js +673 -0
- package/packages/core/node_modules/.bin/esbuild +22 -0
- package/packages/core/node_modules/.bin/tsc +22 -0
- package/packages/core/node_modules/.bin/tsserver +22 -0
- package/packages/core/node_modules/.bin/tsup +22 -0
- package/packages/core/node_modules/.bin/tsup-node +22 -0
- package/packages/core/node_modules/.bin/vite +22 -0
- package/packages/core/node_modules/.bin/vitest +22 -0
- package/packages/core/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/packages/core/package.json +57 -0
- package/packages/core/src/AuraError.ts +89 -0
- package/packages/core/src/BaseService.ts +44 -0
- package/packages/core/src/client.ts +34 -0
- package/packages/core/src/cookie-utils.ts +42 -0
- package/packages/core/src/fetch.ts +435 -0
- package/packages/core/src/index.ts +22 -0
- package/packages/core/src/retry.ts +63 -0
- package/packages/core/src/serialize.ts +6 -0
- package/packages/core/src/stores/BaseAuthStore.ts +164 -0
- package/packages/core/src/stores/LocalAuthStore.ts +199 -0
- package/packages/core/src/types.ts +1042 -0
- package/packages/core/tests/auth-store.test.ts +300 -0
- package/packages/core/tests/error-code.test.ts +61 -0
- package/packages/core/tests/error.test.ts +24 -0
- package/packages/core/tests/fetch.test.ts +286 -0
- package/packages/core/tests/mocks.ts +139 -0
- package/packages/core/tests/observability.test.ts +86 -0
- package/packages/core/tests/refresh-hardening.test.ts +164 -0
- package/packages/core/tests/refresh-observability.test.ts +111 -0
- package/packages/core/tests/retry.test.ts +106 -0
- package/packages/core/tests/serialize.test.ts +12 -0
- package/packages/core/tests/timeout.test.ts +79 -0
- package/packages/core/tsconfig.json +5 -0
- package/packages/core/tsup.config.ts +11 -0
- package/packages/db/LICENSE +21 -0
- package/packages/db/README.md +152 -0
- package/packages/db/VENDORED.md +93 -0
- package/packages/db/dist/index.cjs +544 -0
- package/packages/db/dist/index.d.cts +1111 -0
- package/packages/db/dist/index.d.ts +1111 -0
- package/packages/db/dist/index.js +541 -0
- package/packages/db/node_modules/.bin/esbuild +19 -0
- package/packages/db/node_modules/.bin/tsc +22 -0
- package/packages/db/node_modules/.bin/tsserver +22 -0
- package/packages/db/node_modules/.bin/tsup +22 -0
- package/packages/db/node_modules/.bin/tsup-node +22 -0
- package/packages/db/node_modules/.bin/vite +22 -0
- package/packages/db/node_modules/.bin/vitest +22 -0
- package/packages/db/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/packages/db/package.json +62 -0
- package/packages/db/src/DatabaseService.ts +170 -0
- package/packages/db/src/QueryBuilder.ts +830 -0
- package/packages/db/src/index.ts +2 -0
- package/packages/db/src/pgrst-types/common/common.ts +86 -0
- package/packages/db/src/pgrst-types/common/rpc.ts +151 -0
- package/packages/db/src/pgrst-types/feature-flags.ts +20 -0
- package/packages/db/src/pgrst-types/types.ts +134 -0
- package/packages/db/src/select-query-parser/parser.ts +479 -0
- package/packages/db/src/select-query-parser/result.ts +553 -0
- package/packages/db/src/select-query-parser/types.ts +132 -0
- package/packages/db/src/select-query-parser/utils.ts +707 -0
- package/packages/db/tests/filters.test.ts +81 -0
- package/packages/db/tests/mutations-filtered.e2e.test.ts +132 -0
- package/packages/db/tests/mutations-filtered.test.ts +188 -0
- package/packages/db/tests/order.test.ts +45 -0
- package/packages/db/tests/rpc.test.ts +41 -0
- package/packages/db/tests/scale/build-large-schema.ts +94 -0
- package/packages/db/tests/scale/scale-compile.test.ts +167 -0
- package/packages/db/tests/schema.test.ts +77 -0
- package/packages/db/tests/single-accept.e2e.test.ts +123 -0
- package/packages/db/tests/single.test.ts +211 -0
- package/packages/db/tests/types/filters.test-d.ts +52 -0
- package/packages/db/tests/types/fixtures.ts +40 -0
- package/packages/db/tests/types/from-views.test-d.ts +18 -0
- package/packages/db/tests/types/mutations.test-d.ts +23 -0
- package/packages/db/tests/types/rpc.test-d.ts +60 -0
- package/packages/db/tests/types/schema-shape.test-d.ts +8 -0
- package/packages/db/tests/types/select-inference.test-d.ts +38 -0
- package/packages/db/tests/vendored/fixtures.ts +83 -0
- package/packages/db/tests/vendored/get-result.test-d.ts +75 -0
- package/packages/db/tsconfig.json +5 -0
- package/packages/db/tsconfig.test-d.json +5 -0
- package/packages/db/tsup.config.ts +11 -0
- package/packages/db/vitest.config.ts +8 -0
- package/packages/functions/LICENSE +21 -0
- package/packages/functions/README.md +96 -0
- package/packages/functions/dist/index.cjs +173 -0
- package/packages/functions/dist/index.d.cts +81 -0
- package/packages/functions/dist/index.d.ts +81 -0
- package/packages/functions/dist/index.js +168 -0
- package/packages/functions/node_modules/.bin/esbuild +19 -0
- package/packages/functions/node_modules/.bin/tsc +22 -0
- package/packages/functions/node_modules/.bin/tsserver +22 -0
- package/packages/functions/node_modules/.bin/tsup +22 -0
- package/packages/functions/node_modules/.bin/tsup-node +22 -0
- package/packages/functions/node_modules/.bin/vite +22 -0
- package/packages/functions/node_modules/.bin/vitest +22 -0
- package/packages/functions/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/packages/functions/package.json +60 -0
- package/packages/functions/src/FunctionsService.ts +188 -0
- package/packages/functions/src/errors.ts +70 -0
- package/packages/functions/src/index.ts +6 -0
- package/packages/functions/tests/invoke.test.ts +97 -0
- package/packages/functions/tests/response-type-errors.test.ts +135 -0
- package/packages/functions/tsconfig.json +5 -0
- package/packages/functions/tsup.config.ts +11 -0
- package/packages/gen/LICENSE +21 -0
- package/packages/gen/README.md +84 -0
- package/packages/gen/dist/cli.cjs +334 -0
- package/packages/gen/dist/cli.d.cts +1 -0
- package/packages/gen/dist/cli.d.ts +1 -0
- package/packages/gen/dist/cli.js +332 -0
- package/packages/gen/dist/index.cjs +257 -0
- package/packages/gen/dist/index.d.cts +12 -0
- package/packages/gen/dist/index.d.ts +12 -0
- package/packages/gen/dist/index.js +255 -0
- package/packages/gen/node_modules/.bin/esbuild +19 -0
- package/packages/gen/node_modules/.bin/tsc +22 -0
- package/packages/gen/node_modules/.bin/tsserver +22 -0
- package/packages/gen/node_modules/.bin/tsup +22 -0
- package/packages/gen/node_modules/.bin/tsup-node +22 -0
- package/packages/gen/node_modules/.bin/vite +22 -0
- package/packages/gen/node_modules/.bin/vitest +22 -0
- package/packages/gen/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/packages/gen/package.json +66 -0
- package/packages/gen/src/cli.ts +67 -0
- package/packages/gen/src/generate.ts +0 -0
- package/packages/gen/src/index.ts +2 -0
- package/packages/gen/tests/compile.test.ts +213 -0
- package/packages/gen/tests/e2e.test.ts +130 -0
- package/packages/gen/tests/generate.test.ts +396 -0
- package/packages/gen/tsconfig.json +5 -0
- package/packages/gen/tsup.config.ts +11 -0
- package/packages/notifications/LICENSE +21 -0
- package/packages/notifications/README.md +134 -0
- package/packages/notifications/dist/index.cjs +128 -0
- package/packages/notifications/dist/index.d.cts +81 -0
- package/packages/notifications/dist/index.d.ts +81 -0
- package/packages/notifications/dist/index.js +125 -0
- package/packages/notifications/node_modules/.bin/esbuild +19 -0
- package/packages/notifications/node_modules/.bin/tsc +22 -0
- package/packages/notifications/node_modules/.bin/tsserver +22 -0
- package/packages/notifications/node_modules/.bin/tsup +22 -0
- package/packages/notifications/node_modules/.bin/tsup-node +22 -0
- package/packages/notifications/node_modules/.bin/vite +22 -0
- package/packages/notifications/node_modules/.bin/vitest +22 -0
- package/packages/notifications/package.json +60 -0
- package/packages/notifications/src/NotificationsService.ts +230 -0
- package/packages/notifications/src/index.ts +19 -0
- package/packages/notifications/tsconfig.json +5 -0
- package/packages/notifications/tsup.config.ts +11 -0
- package/packages/realtime/LICENSE +21 -0
- package/packages/realtime/README.md +183 -0
- package/packages/realtime/dist/index.cjs +977 -0
- package/packages/realtime/dist/index.d.cts +259 -0
- package/packages/realtime/dist/index.d.ts +259 -0
- package/packages/realtime/dist/index.js +973 -0
- package/packages/realtime/node_modules/.bin/esbuild +19 -0
- package/packages/realtime/node_modules/.bin/tsc +22 -0
- package/packages/realtime/node_modules/.bin/tsserver +22 -0
- package/packages/realtime/node_modules/.bin/tsup +22 -0
- package/packages/realtime/node_modules/.bin/tsup-node +22 -0
- package/packages/realtime/node_modules/.bin/vite +22 -0
- package/packages/realtime/node_modules/.bin/vitest +22 -0
- package/packages/realtime/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/packages/realtime/package.json +60 -0
- package/packages/realtime/src/AuraChannel.ts +485 -0
- package/packages/realtime/src/HeartbeatManager.ts +73 -0
- package/packages/realtime/src/RealtimeService.ts +505 -0
- package/packages/realtime/src/columnFilter.ts +301 -0
- package/packages/realtime/src/index.ts +4 -0
- package/packages/realtime/tests/ack-routing.test.ts +81 -0
- package/packages/realtime/tests/column-filter.test.ts +144 -0
- package/packages/realtime/tests/dispatch.test.ts +191 -0
- package/packages/realtime/tests/heartbeat.test.ts +67 -0
- package/packages/realtime/tests/http-broadcast.test.ts +68 -0
- package/packages/realtime/tests/realtime-token.test.ts +43 -0
- package/packages/realtime/tests/reconnect-race.test.ts +149 -0
- package/packages/realtime/tests/ref-id.test.ts +34 -0
- package/packages/realtime/tests/set-auth.test.ts +70 -0
- package/packages/realtime/tsconfig.json +5 -0
- package/packages/realtime/tsup.config.ts +11 -0
- package/packages/storage/LICENSE +21 -0
- package/packages/storage/README.md +141 -0
- package/packages/storage/dist/index.cjs +333 -0
- package/packages/storage/dist/index.d.cts +185 -0
- package/packages/storage/dist/index.d.ts +185 -0
- package/packages/storage/dist/index.js +329 -0
- package/packages/storage/node_modules/.bin/esbuild +19 -0
- package/packages/storage/node_modules/.bin/tsc +22 -0
- package/packages/storage/node_modules/.bin/tsserver +22 -0
- package/packages/storage/node_modules/.bin/tsup +22 -0
- package/packages/storage/node_modules/.bin/tsup-node +22 -0
- package/packages/storage/node_modules/.bin/vite +22 -0
- package/packages/storage/node_modules/.bin/vitest +22 -0
- package/packages/storage/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/packages/storage/package.json +60 -0
- package/packages/storage/src/DownloadBuilder.ts +60 -0
- package/packages/storage/src/StorageService.ts +323 -0
- package/packages/storage/src/index.ts +2 -0
- package/packages/storage/src/path.ts +35 -0
- package/packages/storage/src/transform.ts +15 -0
- package/packages/storage/tests/download.test.ts +64 -0
- package/packages/storage/tests/parity.test.ts +154 -0
- package/packages/storage/tests/path.test.ts +87 -0
- package/packages/storage/tests/transform.test.ts +79 -0
- package/packages/storage/tsconfig.json +5 -0
- package/packages/storage/tsup.config.ts +11 -0
- package/pnpm-workspace.yaml +24 -0
- package/tsconfig.base.json +15 -0
|
@@ -0,0 +1,1137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codes d'erreur produits par le SDK (LOT 3, finding I4 : taxonomie ad hoc non
|
|
3
|
+
* typée). Union fermée de tous les codes émis SDK-side (`grep new AuraError` sur
|
|
4
|
+
* `packages/*\/src`) + les codes backend usuels rencontrés (`PGRST116`), plus
|
|
5
|
+
* `(string & {})` pour rester ouvert à tout code backend arbitraire (`error.error.code`)
|
|
6
|
+
* sans perdre l'autocomplétion sur les codes connus (pattern "LiteralUnion").
|
|
7
|
+
*
|
|
8
|
+
* Provenance des codes SDK-side :
|
|
9
|
+
* - fetch.ts (core) : no_session, network_error, invalid_response, refresh_discarded, timeout
|
|
10
|
+
* - AuthService.ts : no_session, pkce_generation_failed, no_code_verifier, missing_email,
|
|
11
|
+
* unverifiable_token, invalid_issuer, invalid_audience
|
|
12
|
+
* - jwks.ts : jwks_fetch_failed, no_matching_key, signature_invalid, token_expired,
|
|
13
|
+
* token_not_yet_valid, invalid_jwt, unsupported_alg
|
|
14
|
+
* - storage/path.ts : invalid_path
|
|
15
|
+
* - db/QueryBuilder.ts: PGRST116 (parité PostgREST : `.single()` sur 0/plusieurs lignes)
|
|
16
|
+
*/
|
|
17
|
+
type AuraErrorCode = 'no_session' | 'timeout' | 'network_error' | 'invalid_response' | 'refresh_discarded' | 'unverifiable_token' | 'no_code_verifier' | 'pkce_generation_failed' | 'missing_email' | 'jwks_fetch_failed' | 'signature_invalid' | 'token_expired' | 'token_not_yet_valid' | 'invalid_jwt' | 'unsupported_alg' | 'no_matching_key' | 'invalid_issuer' | 'invalid_audience' | 'invalid_path' | 'PGRST116' | (string & {});
|
|
18
|
+
/**
|
|
19
|
+
* Structured error thrown/returned by the Aurabase SDK.
|
|
20
|
+
* Mirrors the backend's `AuraError` JSON shape.
|
|
21
|
+
*/
|
|
22
|
+
declare class AuraError extends Error {
|
|
23
|
+
readonly status: number;
|
|
24
|
+
readonly code: AuraErrorCode;
|
|
25
|
+
readonly details: unknown;
|
|
26
|
+
/** Marqueur runtime pour `isAuraError` (détection cross-realm/cross-bundle). */
|
|
27
|
+
protected readonly __isAuraError = true;
|
|
28
|
+
constructor(status: number, body?: {
|
|
29
|
+
error?: {
|
|
30
|
+
code?: string;
|
|
31
|
+
message?: string;
|
|
32
|
+
};
|
|
33
|
+
message?: string;
|
|
34
|
+
} | null);
|
|
35
|
+
get isNotFound(): boolean;
|
|
36
|
+
get isUnauthorized(): boolean;
|
|
37
|
+
get isForbidden(): boolean;
|
|
38
|
+
get isRateLimited(): boolean;
|
|
39
|
+
}
|
|
40
|
+
declare function isAuraError(error: unknown): error is AuraError;
|
|
41
|
+
|
|
42
|
+
interface Meta {
|
|
43
|
+
total?: number;
|
|
44
|
+
next_cursor?: string;
|
|
45
|
+
}
|
|
46
|
+
interface AuraResponse<T> {
|
|
47
|
+
data: T | null;
|
|
48
|
+
error: AuraError | null;
|
|
49
|
+
meta?: Meta;
|
|
50
|
+
}
|
|
51
|
+
interface User {
|
|
52
|
+
id: string;
|
|
53
|
+
email: string | null;
|
|
54
|
+
phone?: string | null;
|
|
55
|
+
role: string;
|
|
56
|
+
email_verified: boolean;
|
|
57
|
+
is_banned: boolean;
|
|
58
|
+
is_anonymous: boolean;
|
|
59
|
+
mfa_enabled: boolean;
|
|
60
|
+
avatar_url?: string | null;
|
|
61
|
+
name?: string | null;
|
|
62
|
+
user_metadata: Record<string, unknown>;
|
|
63
|
+
app_metadata: Record<string, unknown>;
|
|
64
|
+
created_at: string;
|
|
65
|
+
last_sign_in_at?: string | null;
|
|
66
|
+
}
|
|
67
|
+
interface TokenPair {
|
|
68
|
+
access_token: string;
|
|
69
|
+
refresh_token: string;
|
|
70
|
+
token_type: string;
|
|
71
|
+
expires_in: number;
|
|
72
|
+
user: User;
|
|
73
|
+
provider_token?: string | null;
|
|
74
|
+
provider_refresh_token?: string | null;
|
|
75
|
+
}
|
|
76
|
+
interface MfaChallenge {
|
|
77
|
+
mfa_required: true;
|
|
78
|
+
mfa_token: string;
|
|
79
|
+
mfa_setup_required?: boolean;
|
|
80
|
+
}
|
|
81
|
+
type LoginResponse = TokenPair | MfaChallenge;
|
|
82
|
+
type AuthEvent = 'INITIAL_SESSION' | 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED' | 'MFA_CHALLENGE' | 'PASSWORD_RECOVERY';
|
|
83
|
+
/**
|
|
84
|
+
* Payload émis par `onAuthStateChange`. NOTE (LOT 3, 3.4) : `mfaToken`/`mfaSetupRequired`
|
|
85
|
+
* ne sont présents QUE lorsque `event === 'MFA_CHALLENGE'` (posés par `AuthService`
|
|
86
|
+
* uniquement sur cet événement — voir `_emitEvent` dans `AuthService.ts`) ; sur tout
|
|
87
|
+
* autre `event`, ces deux champs sont `undefined`. Le type reste une interface plate
|
|
88
|
+
* (pas une union discriminée) pour ne pas casser les consommateurs existants qui
|
|
89
|
+
* déstructurent `{event, user, accessToken}` sans varier selon `event` — mais un
|
|
90
|
+
* consommateur qui lit `mfaToken` DOIT d'abord vérifier `event === 'MFA_CHALLENGE'`.
|
|
91
|
+
*/
|
|
92
|
+
interface AuthChangePayload {
|
|
93
|
+
event: AuthEvent;
|
|
94
|
+
user: User | null;
|
|
95
|
+
accessToken: string | null;
|
|
96
|
+
/** Présent uniquement si `event === 'MFA_CHALLENGE'`. */
|
|
97
|
+
mfaToken?: string;
|
|
98
|
+
/** Présent uniquement si `event === 'MFA_CHALLENGE'`. */
|
|
99
|
+
mfaSetupRequired?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Token de récupération opaque à passer à `resetPassword(token, newPassword)`.
|
|
102
|
+
* Présent uniquement si `event === 'PASSWORD_RECOVERY'` (extrait du lien email
|
|
103
|
+
* `?token=…&type=recovery` par `detectSessionInUrl`). `undefined` sur tout autre
|
|
104
|
+
* événement.
|
|
105
|
+
*/
|
|
106
|
+
recoveryToken?: string;
|
|
107
|
+
}
|
|
108
|
+
interface SignUpRequest {
|
|
109
|
+
email: string;
|
|
110
|
+
password: string;
|
|
111
|
+
captcha_token?: string;
|
|
112
|
+
}
|
|
113
|
+
interface SignInRequest {
|
|
114
|
+
email: string;
|
|
115
|
+
password: string;
|
|
116
|
+
captcha_token?: string;
|
|
117
|
+
}
|
|
118
|
+
interface MagicLinkRequest {
|
|
119
|
+
email: string;
|
|
120
|
+
create_user?: boolean;
|
|
121
|
+
captcha_token?: string;
|
|
122
|
+
redirect_url?: string;
|
|
123
|
+
}
|
|
124
|
+
interface OAuthSignInOptions {
|
|
125
|
+
redirectTo?: string;
|
|
126
|
+
scopes?: string;
|
|
127
|
+
queryParams?: Record<string, string>;
|
|
128
|
+
/**
|
|
129
|
+
* Active le flux PKCE (génère + stocke un `code_verifier`, envoie
|
|
130
|
+
* `code_challenge`/`code_challenge_method=S256` au provider). Opt-in :
|
|
131
|
+
* absent ou `'implicit'` conserve le comportement existant (aucun
|
|
132
|
+
* paramètre PKCE) pour ne pas casser silencieusement les consommateurs
|
|
133
|
+
* actuels du flux implicite.
|
|
134
|
+
*/
|
|
135
|
+
flowType?: 'pkce' | 'implicit';
|
|
136
|
+
}
|
|
137
|
+
interface PasswordResetRequest {
|
|
138
|
+
email: string;
|
|
139
|
+
}
|
|
140
|
+
interface UpdateUserRequest {
|
|
141
|
+
email?: string;
|
|
142
|
+
phone?: string;
|
|
143
|
+
password?: string;
|
|
144
|
+
current_password?: string;
|
|
145
|
+
data?: Record<string, unknown>;
|
|
146
|
+
}
|
|
147
|
+
interface MfaEnrollResponse {
|
|
148
|
+
otpauth_url: string;
|
|
149
|
+
secret: string;
|
|
150
|
+
}
|
|
151
|
+
interface MfaVerifyRequest {
|
|
152
|
+
mfa_token: string;
|
|
153
|
+
code: string;
|
|
154
|
+
}
|
|
155
|
+
interface SessionInfo {
|
|
156
|
+
id: string;
|
|
157
|
+
device_info?: string | null;
|
|
158
|
+
ip_address?: string | null;
|
|
159
|
+
created_at: string;
|
|
160
|
+
expires_at: string;
|
|
161
|
+
last_used_at: string;
|
|
162
|
+
is_current: boolean;
|
|
163
|
+
}
|
|
164
|
+
type FilterOp = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'not_in' | 'like' | 'ilike' | 'is_null' | 'is_not_null' | 'between';
|
|
165
|
+
interface QueryFilter {
|
|
166
|
+
column: string;
|
|
167
|
+
op: string;
|
|
168
|
+
value: unknown;
|
|
169
|
+
}
|
|
170
|
+
type CountMode = 'exact' | 'estimated';
|
|
171
|
+
interface QueryOptions {
|
|
172
|
+
select?: string[];
|
|
173
|
+
filters?: QueryFilter[];
|
|
174
|
+
sort_by?: string;
|
|
175
|
+
sort_order?: 'asc' | 'desc';
|
|
176
|
+
limit?: number;
|
|
177
|
+
offset?: number;
|
|
178
|
+
count?: CountMode;
|
|
179
|
+
}
|
|
180
|
+
interface SchemaColumn {
|
|
181
|
+
name: string;
|
|
182
|
+
col_type: string;
|
|
183
|
+
nullable: boolean;
|
|
184
|
+
unique: boolean;
|
|
185
|
+
default_val?: string | null;
|
|
186
|
+
references?: {
|
|
187
|
+
table: string;
|
|
188
|
+
column: string;
|
|
189
|
+
constraint_name?: string | null;
|
|
190
|
+
} | null;
|
|
191
|
+
}
|
|
192
|
+
interface SchemaIndex {
|
|
193
|
+
name: string;
|
|
194
|
+
columns: string[];
|
|
195
|
+
unique: boolean;
|
|
196
|
+
}
|
|
197
|
+
interface SchemaTable {
|
|
198
|
+
name: string;
|
|
199
|
+
columns: SchemaColumn[];
|
|
200
|
+
primary_key?: string;
|
|
201
|
+
indexes: SchemaIndex[];
|
|
202
|
+
rls_enabled: boolean;
|
|
203
|
+
realtime_enabled: boolean;
|
|
204
|
+
}
|
|
205
|
+
interface SchemaFunctionArg {
|
|
206
|
+
name: string;
|
|
207
|
+
data_type: string;
|
|
208
|
+
mode: string;
|
|
209
|
+
}
|
|
210
|
+
interface SchemaFunction {
|
|
211
|
+
name: string;
|
|
212
|
+
args: SchemaFunctionArg[];
|
|
213
|
+
returns: string;
|
|
214
|
+
is_set_returning: boolean;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Type enum Postgres (`pg_type.typtype='e'`) exposé par `GET /schema` (LOT B).
|
|
218
|
+
* `values` est ordonné (`enumsortorder`). Le générateur SDK (`@aurabase/gen`)
|
|
219
|
+
* en dérive une union de littéraux `Database['public']['Enums'][name]`.
|
|
220
|
+
*/
|
|
221
|
+
interface SchemaEnum {
|
|
222
|
+
name: string;
|
|
223
|
+
values: string[];
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Options de transformation d'image (vocabulaire façon Supabase) appliquées
|
|
227
|
+
* côté rendu backend (`GET /v1/storage/{pid}/{bucket}/{key}?width=&height=&
|
|
228
|
+
* fit=&format=&quality=`). Voir `renderTransformParams` (`@aurabase/storage`)
|
|
229
|
+
* pour le mapping vers les query params du backend.
|
|
230
|
+
*/
|
|
231
|
+
interface ImageTransform {
|
|
232
|
+
width?: number;
|
|
233
|
+
height?: number;
|
|
234
|
+
resize?: 'cover' | 'contain' | 'fill';
|
|
235
|
+
quality?: number;
|
|
236
|
+
format?: 'origin' | 'jpeg' | 'png' | 'webp' | 'gif';
|
|
237
|
+
}
|
|
238
|
+
interface StorageBucket {
|
|
239
|
+
id: string;
|
|
240
|
+
name: string;
|
|
241
|
+
public: boolean;
|
|
242
|
+
file_size_limit?: number | null;
|
|
243
|
+
allowed_mime_types?: string[] | null;
|
|
244
|
+
created_at: string;
|
|
245
|
+
updated_at: string;
|
|
246
|
+
}
|
|
247
|
+
interface UploadResult {
|
|
248
|
+
/** Clé unique de l'objet (`<uuid>.<ext>`) relative au bucket. */
|
|
249
|
+
key: string;
|
|
250
|
+
url: string;
|
|
251
|
+
size: number;
|
|
252
|
+
mime_type: string;
|
|
253
|
+
}
|
|
254
|
+
interface FileEntry {
|
|
255
|
+
name: string;
|
|
256
|
+
id?: string;
|
|
257
|
+
bucket_id: string;
|
|
258
|
+
size: number;
|
|
259
|
+
mime_type: string;
|
|
260
|
+
created_at: string;
|
|
261
|
+
updated_at: string;
|
|
262
|
+
metadata?: Record<string, unknown>;
|
|
263
|
+
}
|
|
264
|
+
/** Métadonnées d'un objet storage — forme réelle retournée par getMetadata() */
|
|
265
|
+
interface ObjectMeta {
|
|
266
|
+
key: string;
|
|
267
|
+
bucket: string;
|
|
268
|
+
size: number;
|
|
269
|
+
content_type: string;
|
|
270
|
+
etag?: string | null;
|
|
271
|
+
last_modified?: string | null;
|
|
272
|
+
metadata: Record<string, string>;
|
|
273
|
+
}
|
|
274
|
+
/** Événement serveur brut reçu via WebSocket (union discriminée par type) */
|
|
275
|
+
type ServerMessage = ServerSubscribedMsg | ServerEventMsg | ServerPongMsg | ServerErrorMsg | ServerTokenRefreshedMsg | ServerPresenceStateMsg | BroadcastAckMessage;
|
|
276
|
+
interface ServerSubscribedMsg {
|
|
277
|
+
type: 'subscribed';
|
|
278
|
+
channel: string;
|
|
279
|
+
subscription_id?: string;
|
|
280
|
+
history: RealtimeEvent[];
|
|
281
|
+
ref_id?: string;
|
|
282
|
+
}
|
|
283
|
+
interface ServerEventMsg {
|
|
284
|
+
type: 'event';
|
|
285
|
+
id: string;
|
|
286
|
+
event: 'insert' | 'update' | 'delete' | 'broadcast' | 'presence' | 'system';
|
|
287
|
+
topic: string;
|
|
288
|
+
payload: Record<string, unknown>;
|
|
289
|
+
timestamp: string;
|
|
290
|
+
allowed_sub_ids?: string[];
|
|
291
|
+
}
|
|
292
|
+
interface ServerPongMsg {
|
|
293
|
+
type: 'pong';
|
|
294
|
+
}
|
|
295
|
+
interface ServerErrorMsg {
|
|
296
|
+
type: 'error';
|
|
297
|
+
message: string;
|
|
298
|
+
}
|
|
299
|
+
interface ServerTokenRefreshedMsg {
|
|
300
|
+
type: 'token_refreshed';
|
|
301
|
+
}
|
|
302
|
+
interface ServerPresenceStateMsg {
|
|
303
|
+
type: 'presence_state';
|
|
304
|
+
channel: string;
|
|
305
|
+
presences: PresenceInfo[];
|
|
306
|
+
}
|
|
307
|
+
/** Événement realtime (CDC, broadcast, presence) */
|
|
308
|
+
interface RealtimeEvent<T = Record<string, unknown>> {
|
|
309
|
+
id: string;
|
|
310
|
+
event: 'insert' | 'update' | 'delete' | 'broadcast' | 'presence' | 'system';
|
|
311
|
+
topic: string;
|
|
312
|
+
payload: T;
|
|
313
|
+
timestamp: string;
|
|
314
|
+
/** IDs des subscriptions autorisées par RLS. Absent = pas de filtre. */
|
|
315
|
+
allowed_sub_ids?: string[];
|
|
316
|
+
/** Ref ID corrélé à la requête client (si fourni) */
|
|
317
|
+
ref_id?: string;
|
|
318
|
+
}
|
|
319
|
+
/** Accusé de réception d'un broadcast (envoyé si config.broadcast.ack = true) */
|
|
320
|
+
interface BroadcastAckMessage {
|
|
321
|
+
type: 'broadcast_ack';
|
|
322
|
+
message_id: string;
|
|
323
|
+
ref_id?: string;
|
|
324
|
+
}
|
|
325
|
+
/** Payload CDC (postgres_changes) avec old_record et type d'operation */
|
|
326
|
+
interface CdcPayload {
|
|
327
|
+
schema: string;
|
|
328
|
+
table: string;
|
|
329
|
+
type: 'INSERT' | 'UPDATE' | 'DELETE';
|
|
330
|
+
record: Record<string, unknown>;
|
|
331
|
+
old_record: Record<string, unknown> | null;
|
|
332
|
+
_truncated?: boolean;
|
|
333
|
+
}
|
|
334
|
+
/** Status de subscription */
|
|
335
|
+
type RealtimeSubscribeStatus = 'SUBSCRIBED' | 'CLOSED' | 'CHANNEL_ERROR' | 'TIMED_OUT';
|
|
336
|
+
/** Callback de subscription */
|
|
337
|
+
type SubscribeCallback = (status: RealtimeSubscribeStatus, err?: Error) => void;
|
|
338
|
+
/** Types d'écoute supportés (pattern Supabase) */
|
|
339
|
+
type RealtimeListenType = 'postgres_changes' | 'broadcast' | 'presence';
|
|
340
|
+
/** Config pour postgres_changes */
|
|
341
|
+
interface PostgresChangesFilter {
|
|
342
|
+
event: 'INSERT' | 'UPDATE' | 'DELETE' | '*';
|
|
343
|
+
schema?: string;
|
|
344
|
+
table?: string;
|
|
345
|
+
/**
|
|
346
|
+
* Filtre sur colonne, syntaxe PostgREST/Supabase : `"column=operator.value"`.
|
|
347
|
+
*
|
|
348
|
+
* **Opérateurs supportés** : `eq, neq, lt, lte, gt, gte, in, like, ilike, is,
|
|
349
|
+
* match, imatch, isdistinct`.
|
|
350
|
+
*
|
|
351
|
+
* - `eq`/`neq` : égalité/inégalité (comparaison textuelle).
|
|
352
|
+
* - `lt`/`lte`/`gt`/`gte` : comparaison numérique (échoue — pas de match — si
|
|
353
|
+
* la valeur n'est pas numérique).
|
|
354
|
+
* - `in` : appartenance à une liste, `"status=in.(active,pending)"`.
|
|
355
|
+
* - `like`/`ilike` : motif SQL (`%` = sous-chaîne, `_` = 1 caractère), `ilike`
|
|
356
|
+
* insensible à la casse. Ex: `"name=like.jo%"`.
|
|
357
|
+
* - `is` : `"col=is.null"` / `"col=is.true"` / `"col=is.false"` — compare la
|
|
358
|
+
* valeur JSON réelle, pas sa représentation texte.
|
|
359
|
+
* - `match`/`imatch` : expression régulière (`imatch` insensible à la casse).
|
|
360
|
+
* - `isdistinct` : distinct au sens SQL — `NULL` est distinct de toute valeur
|
|
361
|
+
* non-NULL.
|
|
362
|
+
*
|
|
363
|
+
* **Négation** : préfixer l'opérateur par `not.`, ex: `"status=not.eq.done"`.
|
|
364
|
+
*
|
|
365
|
+
* **AND** : plusieurs conditions séparées par des virgules, ex:
|
|
366
|
+
* `"room_id=eq.42,qty=gt.5"` (toutes doivent matcher). Les virgules internes
|
|
367
|
+
* d'un `in.(a,b,c)` ne séparent PAS les conditions.
|
|
368
|
+
*
|
|
369
|
+
* **Où c'est évalué** : le serveur `aura-realtime` filtre ces conditions de
|
|
370
|
+
* façon **autoritaire** avant l'envoi au client — un `filter` invalide y est
|
|
371
|
+
* fail-closed (l'event est exclu, jamais laissé passer par défaut). Le SDK
|
|
372
|
+
* réévalue ensuite la même syntaxe côté client comme second rideau
|
|
373
|
+
* (defense-in-depth) : il ne peut que sur-filtrer, jamais faire fuiter un
|
|
374
|
+
* event que le serveur aurait dû exclure.
|
|
375
|
+
*
|
|
376
|
+
* **DELETE** : le prédicat est évalué sur l'**ancienne ligne** (`old_record`),
|
|
377
|
+
* puisque le `record` d'un DELETE est vide côté CDC. Si votre table utilise
|
|
378
|
+
* `REPLICA IDENTITY DEFAULT`, `old_record` ne contient que la clé primaire —
|
|
379
|
+
* un filtre sur une autre colonne exclura systématiquement les DELETE, **sauf
|
|
380
|
+
* `is.null`/`isdistinct`** qui traitent une colonne absente comme `NULL` et
|
|
381
|
+
* peuvent donc matcher même sans cette colonne dans `old_record`.
|
|
382
|
+
*/
|
|
383
|
+
filter?: string;
|
|
384
|
+
}
|
|
385
|
+
/** Config pour broadcast */
|
|
386
|
+
interface BroadcastFilter {
|
|
387
|
+
event: string;
|
|
388
|
+
}
|
|
389
|
+
/** Config pour presence */
|
|
390
|
+
interface PresenceFilter {
|
|
391
|
+
event: 'sync' | 'join' | 'leave';
|
|
392
|
+
}
|
|
393
|
+
/** Options de channel — compatible Supabase */
|
|
394
|
+
interface ChannelConfig {
|
|
395
|
+
private?: boolean;
|
|
396
|
+
/** Configuration broadcast pour ce channel */
|
|
397
|
+
broadcast?: {
|
|
398
|
+
/** Si true, le serveur ACK chaque send() (résout la Promise) */
|
|
399
|
+
ack?: boolean;
|
|
400
|
+
/** Si true, le client reçoit ses propres broadcasts (self-echo) */
|
|
401
|
+
self?: boolean;
|
|
402
|
+
};
|
|
403
|
+
/** Configuration présence */
|
|
404
|
+
config?: {
|
|
405
|
+
presence?: {
|
|
406
|
+
/** Clé de présence — permet de regrouper plusieurs onglets/devices du même user */
|
|
407
|
+
key?: string;
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
/** Payload d'un broadcast à envoyer */
|
|
412
|
+
interface BroadcastPayload {
|
|
413
|
+
type: 'broadcast';
|
|
414
|
+
event: string;
|
|
415
|
+
payload: Record<string, unknown>;
|
|
416
|
+
/** Ref ID pour la corrélation request/response (optionnel) */
|
|
417
|
+
ref_id?: string;
|
|
418
|
+
}
|
|
419
|
+
/** Presence state (map de key → presences) */
|
|
420
|
+
type PresenceState = Record<string, PresenceInfo[]>;
|
|
421
|
+
interface PresenceInfo {
|
|
422
|
+
client_id: string;
|
|
423
|
+
user_id?: string | null;
|
|
424
|
+
metadata: Record<string, unknown>;
|
|
425
|
+
joined_at: string;
|
|
426
|
+
last_seen: string;
|
|
427
|
+
}
|
|
428
|
+
interface ChatMessage {
|
|
429
|
+
role: 'system' | 'user' | 'assistant';
|
|
430
|
+
content: string;
|
|
431
|
+
}
|
|
432
|
+
interface ChatResponse {
|
|
433
|
+
model: string;
|
|
434
|
+
content: string;
|
|
435
|
+
input_tokens?: number;
|
|
436
|
+
output_tokens?: number;
|
|
437
|
+
}
|
|
438
|
+
interface EmbedRequest {
|
|
439
|
+
text: string;
|
|
440
|
+
namespace: string;
|
|
441
|
+
metadata?: Record<string, unknown>;
|
|
442
|
+
}
|
|
443
|
+
interface EmbedResponse {
|
|
444
|
+
id: string;
|
|
445
|
+
dimensions: number;
|
|
446
|
+
}
|
|
447
|
+
interface RagRequest {
|
|
448
|
+
question: string;
|
|
449
|
+
namespace: string;
|
|
450
|
+
history?: ChatMessage[];
|
|
451
|
+
system?: string;
|
|
452
|
+
}
|
|
453
|
+
interface RagResponse {
|
|
454
|
+
answer: string;
|
|
455
|
+
sources: Array<{
|
|
456
|
+
id: string;
|
|
457
|
+
content: string;
|
|
458
|
+
metadata: Record<string, unknown>;
|
|
459
|
+
similarity: number;
|
|
460
|
+
}>;
|
|
461
|
+
model: string;
|
|
462
|
+
tokens?: number;
|
|
463
|
+
}
|
|
464
|
+
interface RagIngestRequest {
|
|
465
|
+
namespace: string;
|
|
466
|
+
content: string;
|
|
467
|
+
metadata?: Record<string, unknown>;
|
|
468
|
+
}
|
|
469
|
+
interface RagIngestResponse {
|
|
470
|
+
id: string;
|
|
471
|
+
chunks: number;
|
|
472
|
+
}
|
|
473
|
+
interface SemanticSearchResult {
|
|
474
|
+
id: string;
|
|
475
|
+
content: string;
|
|
476
|
+
metadata: Record<string, unknown>;
|
|
477
|
+
similarity: number;
|
|
478
|
+
}
|
|
479
|
+
interface FunctionDef {
|
|
480
|
+
id: string;
|
|
481
|
+
project_id: string;
|
|
482
|
+
name: string;
|
|
483
|
+
runtime: string;
|
|
484
|
+
code: string;
|
|
485
|
+
code_hash: string;
|
|
486
|
+
env_vars: Record<string, unknown>;
|
|
487
|
+
is_active: boolean;
|
|
488
|
+
created_at: string;
|
|
489
|
+
updated_at: string;
|
|
490
|
+
}
|
|
491
|
+
interface Job {
|
|
492
|
+
id: string;
|
|
493
|
+
project_id: string;
|
|
494
|
+
function_name: string;
|
|
495
|
+
status: 'pending' | 'running' | 'completed' | 'failed' | 'dead';
|
|
496
|
+
payload: unknown;
|
|
497
|
+
attempts: number;
|
|
498
|
+
max_attempts: number;
|
|
499
|
+
error?: string | null;
|
|
500
|
+
scheduled_at: string;
|
|
501
|
+
started_at?: string | null;
|
|
502
|
+
created_at: string;
|
|
503
|
+
completed_at?: string | null;
|
|
504
|
+
}
|
|
505
|
+
interface CronJob {
|
|
506
|
+
id: string;
|
|
507
|
+
project_id: string;
|
|
508
|
+
name: string;
|
|
509
|
+
schedule: string;
|
|
510
|
+
function_name: string;
|
|
511
|
+
payload: unknown;
|
|
512
|
+
is_active: boolean;
|
|
513
|
+
last_run?: string | null;
|
|
514
|
+
next_run?: string | null;
|
|
515
|
+
created_at: string;
|
|
516
|
+
}
|
|
517
|
+
interface Notification {
|
|
518
|
+
id: string;
|
|
519
|
+
project_id?: string;
|
|
520
|
+
channel: 'email' | 'sms' | 'push' | 'webhook';
|
|
521
|
+
recipient: string;
|
|
522
|
+
subject?: string | null;
|
|
523
|
+
body: string;
|
|
524
|
+
status: 'queued' | 'processing' | 'sent' | 'failed' | 'delivered' | 'expired' | 'dead_lettered';
|
|
525
|
+
error?: string | null;
|
|
526
|
+
metadata?: Record<string, unknown>;
|
|
527
|
+
attempt_count?: number;
|
|
528
|
+
last_attempt_at?: string | null;
|
|
529
|
+
next_attempt_at?: string | null;
|
|
530
|
+
locked_until?: string | null;
|
|
531
|
+
lock_owner?: string | null;
|
|
532
|
+
provider_message_id?: string | null;
|
|
533
|
+
delivered_at?: string | null;
|
|
534
|
+
expires_at?: string | null;
|
|
535
|
+
idempotency_key?: string | null;
|
|
536
|
+
payload_hash?: string | null;
|
|
537
|
+
last_error?: string | null;
|
|
538
|
+
last_error_code?: string | null;
|
|
539
|
+
last_provider_response?: string | null;
|
|
540
|
+
processing_started_at?: string | null;
|
|
541
|
+
completed_at?: string | null;
|
|
542
|
+
updated_at?: string;
|
|
543
|
+
sent_at?: string | null;
|
|
544
|
+
created_at: string;
|
|
545
|
+
}
|
|
546
|
+
interface SendNotificationRequest {
|
|
547
|
+
channel: 'email' | 'sms' | 'push' | 'webhook';
|
|
548
|
+
recipient: string;
|
|
549
|
+
body?: string;
|
|
550
|
+
subject?: string;
|
|
551
|
+
template_id?: string;
|
|
552
|
+
variables?: Record<string, unknown>;
|
|
553
|
+
metadata?: Record<string, unknown>;
|
|
554
|
+
idempotency_key?: string;
|
|
555
|
+
}
|
|
556
|
+
interface BatchSendItemResult {
|
|
557
|
+
index: number;
|
|
558
|
+
status: 'queued' | 'error';
|
|
559
|
+
notification?: Notification | null;
|
|
560
|
+
error?: string | null;
|
|
561
|
+
}
|
|
562
|
+
interface BatchSendResponse {
|
|
563
|
+
items: BatchSendItemResult[];
|
|
564
|
+
}
|
|
565
|
+
interface NotificationTemplate {
|
|
566
|
+
id: string;
|
|
567
|
+
name: string;
|
|
568
|
+
channel: 'email' | 'sms' | 'push' | 'webhook';
|
|
569
|
+
subject?: string | null;
|
|
570
|
+
body: string;
|
|
571
|
+
variables?: string[];
|
|
572
|
+
created_at: string;
|
|
573
|
+
updated_at: string;
|
|
574
|
+
}
|
|
575
|
+
interface NotificationTemplatePreview {
|
|
576
|
+
subject?: string | null;
|
|
577
|
+
body: string;
|
|
578
|
+
}
|
|
579
|
+
interface NotificationAttempt {
|
|
580
|
+
id: string;
|
|
581
|
+
notification_id: string;
|
|
582
|
+
project_id: string;
|
|
583
|
+
channel: 'email' | 'sms' | 'push' | 'webhook';
|
|
584
|
+
provider: string;
|
|
585
|
+
attempt_number: number;
|
|
586
|
+
status: 'processing' | 'sent' | 'failed' | 'retry_scheduled' | 'dead_lettered';
|
|
587
|
+
started_at: string;
|
|
588
|
+
completed_at?: string | null;
|
|
589
|
+
duration_ms?: number | null;
|
|
590
|
+
error_code?: string | null;
|
|
591
|
+
error_message?: string | null;
|
|
592
|
+
provider_response?: string | null;
|
|
593
|
+
created_at: string;
|
|
594
|
+
}
|
|
595
|
+
interface NotificationDeadLetter {
|
|
596
|
+
id: string;
|
|
597
|
+
notification_id: string;
|
|
598
|
+
project_id: string;
|
|
599
|
+
channel: 'email' | 'sms' | 'push' | 'webhook';
|
|
600
|
+
recipient: string;
|
|
601
|
+
subject?: string | null;
|
|
602
|
+
body: string;
|
|
603
|
+
metadata?: Record<string, unknown>;
|
|
604
|
+
payload_hash?: string | null;
|
|
605
|
+
idempotency_key?: string | null;
|
|
606
|
+
attempt_count: number;
|
|
607
|
+
last_error: string;
|
|
608
|
+
last_error_code: string;
|
|
609
|
+
last_provider_response?: string | null;
|
|
610
|
+
failed_at: string;
|
|
611
|
+
created_at: string;
|
|
612
|
+
}
|
|
613
|
+
interface NotificationEvent {
|
|
614
|
+
id: string;
|
|
615
|
+
project_id: string;
|
|
616
|
+
subject: string;
|
|
617
|
+
event_type: string;
|
|
618
|
+
status: 'received' | 'matched' | 'ignored' | 'failed' | 'enqueued';
|
|
619
|
+
rule_id?: string | null;
|
|
620
|
+
notification_id?: string | null;
|
|
621
|
+
error?: string | null;
|
|
622
|
+
metadata?: Record<string, unknown>;
|
|
623
|
+
created_at: string;
|
|
624
|
+
}
|
|
625
|
+
interface NotificationProviderLog {
|
|
626
|
+
timestamp: string;
|
|
627
|
+
notification_id: string;
|
|
628
|
+
channel: 'email' | 'sms' | 'push' | 'webhook';
|
|
629
|
+
provider: string;
|
|
630
|
+
status: string;
|
|
631
|
+
duration_ms?: number | null;
|
|
632
|
+
error_code?: string | null;
|
|
633
|
+
error_message?: string | null;
|
|
634
|
+
provider_response?: string | null;
|
|
635
|
+
provider_message_id?: string | null;
|
|
636
|
+
}
|
|
637
|
+
interface NotificationQueueStats {
|
|
638
|
+
queued_count: number;
|
|
639
|
+
processing_count: number;
|
|
640
|
+
retry_scheduled_count: number;
|
|
641
|
+
expired_processing_count: number;
|
|
642
|
+
next_retry_at_min?: string | null;
|
|
643
|
+
}
|
|
644
|
+
interface NotificationChannelStats {
|
|
645
|
+
channel: 'email' | 'sms' | 'push' | 'webhook';
|
|
646
|
+
total: number;
|
|
647
|
+
sent: number;
|
|
648
|
+
delivered: number;
|
|
649
|
+
failed: number;
|
|
650
|
+
dead_lettered: number;
|
|
651
|
+
queued: number;
|
|
652
|
+
processing: number;
|
|
653
|
+
success_rate: number;
|
|
654
|
+
failure_rate: number;
|
|
655
|
+
}
|
|
656
|
+
interface NotificationStats {
|
|
657
|
+
window: string;
|
|
658
|
+
channel?: 'email' | 'sms' | 'push' | 'webhook' | null;
|
|
659
|
+
total: number;
|
|
660
|
+
sent: number;
|
|
661
|
+
delivered: number;
|
|
662
|
+
failed: number;
|
|
663
|
+
dead_lettered: number;
|
|
664
|
+
queued: number;
|
|
665
|
+
processing: number;
|
|
666
|
+
success_rate: number;
|
|
667
|
+
failure_rate: number;
|
|
668
|
+
by_status: Array<{
|
|
669
|
+
status: string;
|
|
670
|
+
count: number;
|
|
671
|
+
}>;
|
|
672
|
+
by_channel: NotificationChannelStats[];
|
|
673
|
+
timeline: Array<{
|
|
674
|
+
bucket: string;
|
|
675
|
+
total: number;
|
|
676
|
+
sent: number;
|
|
677
|
+
delivered: number;
|
|
678
|
+
failed: number;
|
|
679
|
+
dead_lettered: number;
|
|
680
|
+
}>;
|
|
681
|
+
}
|
|
682
|
+
interface NotificationSettings {
|
|
683
|
+
project_id: string;
|
|
684
|
+
smtp?: Record<string, unknown>;
|
|
685
|
+
twilio?: Record<string, unknown>;
|
|
686
|
+
fcm?: Record<string, unknown>;
|
|
687
|
+
apns?: Record<string, unknown>;
|
|
688
|
+
webhook?: Record<string, unknown>;
|
|
689
|
+
quotas?: Record<string, unknown>;
|
|
690
|
+
updated_at?: string | null;
|
|
691
|
+
}
|
|
692
|
+
interface NotificationRule {
|
|
693
|
+
id: string;
|
|
694
|
+
project_id: string;
|
|
695
|
+
name: string;
|
|
696
|
+
trigger_type: string;
|
|
697
|
+
condition: Record<string, unknown>;
|
|
698
|
+
template_id?: string | null;
|
|
699
|
+
channel: 'email' | 'sms' | 'push' | 'webhook';
|
|
700
|
+
recipient_expr: string;
|
|
701
|
+
enabled: boolean;
|
|
702
|
+
delay_seconds: number;
|
|
703
|
+
fire_count: number;
|
|
704
|
+
last_fired_at?: string | null;
|
|
705
|
+
created_at: string;
|
|
706
|
+
updated_at: string;
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Événement d'observabilité interne du SDK. Émis best-effort via le hook `onEvent`
|
|
710
|
+
* (option client) et/ou `console.debug` (option `debug: true`) — voir `emitAuraEvent`.
|
|
711
|
+
* Les erreurs sont massivement avalées ailleurs dans le SDK (`catch {}` JWKS/storage/
|
|
712
|
+
* cookie/subscribers) : ce hook rend visibles les retries, timeouts, refresh
|
|
713
|
+
* silencieux et échecs JWKS/storage sans changer le contrat `AuraResponse`.
|
|
714
|
+
*/
|
|
715
|
+
type AuraObservabilityEvent = {
|
|
716
|
+
kind: 'retry';
|
|
717
|
+
attempt: number;
|
|
718
|
+
status?: number;
|
|
719
|
+
url: string;
|
|
720
|
+
} | {
|
|
721
|
+
kind: 'timeout';
|
|
722
|
+
url: string;
|
|
723
|
+
} | {
|
|
724
|
+
kind: 'refresh-success';
|
|
725
|
+
} | {
|
|
726
|
+
kind: 'refresh-discarded';
|
|
727
|
+
reason: string;
|
|
728
|
+
} | {
|
|
729
|
+
kind: 'jwks-fetch-failed';
|
|
730
|
+
baseUrl: string;
|
|
731
|
+
} | {
|
|
732
|
+
kind: 'storage-blocked';
|
|
733
|
+
op: string;
|
|
734
|
+
};
|
|
735
|
+
declare function emitAuraEvent(onEvent: ((event: AuraObservabilityEvent) => void) | undefined, debug: boolean | undefined, event: AuraObservabilityEvent): void;
|
|
736
|
+
interface AuraClientOptions {
|
|
737
|
+
auth?: {
|
|
738
|
+
persistSession?: boolean;
|
|
739
|
+
storage?: BaseAuthStore;
|
|
740
|
+
/** Refresh proactif en arrière-plan + synchro multi-onglets (défaut true). */
|
|
741
|
+
autoRefresh?: boolean;
|
|
742
|
+
/**
|
|
743
|
+
* Détecte et consomme automatiquement une session présente dans l'URL au boot
|
|
744
|
+
* du client (callback OAuth) : fragment `#access_token=…` (flux implicit) ou
|
|
745
|
+
* query `?code=…` (flux PKCE), puis nettoie l'URL via `history.replaceState`.
|
|
746
|
+
* Défaut : `true` en navigateur, no-op hors navigateur (SSR/Node).
|
|
747
|
+
*/
|
|
748
|
+
detectSessionInUrl?: boolean;
|
|
749
|
+
};
|
|
750
|
+
apiKey?: string;
|
|
751
|
+
fetch?: typeof globalThis.fetch;
|
|
752
|
+
/**
|
|
753
|
+
* SEC-F5 : si une clé `service_role` (`aura_sk_…`) est fournie en contexte NAVIGATEUR
|
|
754
|
+
* (thread principal ou Web Worker navigateur), `true` (DÉFAUT) fait ÉCHOUER la
|
|
755
|
+
* construction du client (`throw`) — cette clé à privilèges élevés (BYPASSRLS)
|
|
756
|
+
* fuiterait dans le bundle JS = compromission totale du projet. `false` rétrograde
|
|
757
|
+
* en simple `console.warn` (échappatoire explicite, à n'utiliser qu'en connaissance
|
|
758
|
+
* de cause). Sans effet côté serveur (où service_role est légitime).
|
|
759
|
+
*/
|
|
760
|
+
refuseServiceRoleInBrowser?: boolean;
|
|
761
|
+
/** Retry transitoire des GET/HEAD (activé par défaut). `false` désactive. */
|
|
762
|
+
retry?: boolean | {
|
|
763
|
+
enabled?: boolean;
|
|
764
|
+
maxRetries?: number;
|
|
765
|
+
};
|
|
766
|
+
/**
|
|
767
|
+
* Timeout par défaut (ms) des requêtes JSON sans `signal` fourni (borne un serveur
|
|
768
|
+
* qui « hang »). N'affecte ni les uploads FormData ni les appels gérant leur propre
|
|
769
|
+
* annulation (invoke, download). `0` désactive. Défaut : 30 000 ms.
|
|
770
|
+
*/
|
|
771
|
+
requestTimeoutMs?: number;
|
|
772
|
+
/**
|
|
773
|
+
* Hook d'observabilité (LOT 3, finding I8) : reçoit chaque `AuraObservabilityEvent`
|
|
774
|
+
* (retry transitoire, timeout, refresh de session réussi/écarté, échec fetch JWKS,
|
|
775
|
+
* storage bloqué). Best-effort — le SDK l'appelle dans un try/catch, ce hook ne
|
|
776
|
+
* peut jamais faire échouer une requête. `undefined` par défaut (aucune émission).
|
|
777
|
+
*/
|
|
778
|
+
onEvent?: (event: AuraObservabilityEvent) => void;
|
|
779
|
+
/**
|
|
780
|
+
* Si `true`, chaque `AuraObservabilityEvent` est aussi journalisé via
|
|
781
|
+
* `console.debug('[aurabase]', event)`, en plus (ou à la place) du hook `onEvent`.
|
|
782
|
+
* Défaut `false`.
|
|
783
|
+
*/
|
|
784
|
+
debug?: boolean;
|
|
785
|
+
}
|
|
786
|
+
interface IdentityInfo {
|
|
787
|
+
id: string;
|
|
788
|
+
provider: string;
|
|
789
|
+
provider_id: string;
|
|
790
|
+
identity_data: Record<string, unknown>;
|
|
791
|
+
auto_linked: boolean;
|
|
792
|
+
created_at: string;
|
|
793
|
+
}
|
|
794
|
+
interface AdminUser extends User {
|
|
795
|
+
}
|
|
796
|
+
interface AuditLogEntry {
|
|
797
|
+
id: string;
|
|
798
|
+
user_id?: string | null;
|
|
799
|
+
action: string;
|
|
800
|
+
ip_address?: string | null;
|
|
801
|
+
user_agent?: string | null;
|
|
802
|
+
created_at: string;
|
|
803
|
+
}
|
|
804
|
+
interface UserStats {
|
|
805
|
+
total: number;
|
|
806
|
+
verified: number;
|
|
807
|
+
banned: number;
|
|
808
|
+
mfa_enabled: number;
|
|
809
|
+
new_7d: number;
|
|
810
|
+
}
|
|
811
|
+
/**
|
|
812
|
+
* Sessions vues depuis l'admin (endpoint `admin/sessions`) : contient `user_id`
|
|
813
|
+
* (toutes sessions, tous utilisateurs) mais pas `is_current` (contrairement à
|
|
814
|
+
* `SessionInfo`, qui décrit les sessions de l'utilisateur courant).
|
|
815
|
+
*/
|
|
816
|
+
interface AdminSessionInfo {
|
|
817
|
+
id: string;
|
|
818
|
+
user_id: string;
|
|
819
|
+
device_info?: string | null;
|
|
820
|
+
ip_address?: string | null;
|
|
821
|
+
created_at: string;
|
|
822
|
+
expires_at: string;
|
|
823
|
+
last_used_at: string;
|
|
824
|
+
}
|
|
825
|
+
interface AuthSettings {
|
|
826
|
+
allow_signup: boolean;
|
|
827
|
+
email_confirmation_required: boolean;
|
|
828
|
+
password_min_length: number;
|
|
829
|
+
mfa_enabled: boolean;
|
|
830
|
+
allow_anonymous_users: boolean;
|
|
831
|
+
jwt_expiry_seconds: number;
|
|
832
|
+
refresh_token_expiry_days: number;
|
|
833
|
+
site_url?: string | null;
|
|
834
|
+
oauth_providers: Record<string, {
|
|
835
|
+
enabled?: boolean;
|
|
836
|
+
client_id?: string;
|
|
837
|
+
client_secret?: string;
|
|
838
|
+
}>;
|
|
839
|
+
new_device_alerts_enabled: boolean;
|
|
840
|
+
webhook_url?: string | null;
|
|
841
|
+
smtp_host?: string | null;
|
|
842
|
+
smtp_port?: number | null;
|
|
843
|
+
smtp_username?: string | null;
|
|
844
|
+
smtp_password_set?: boolean;
|
|
845
|
+
smtp_from_email?: string | null;
|
|
846
|
+
smtp_from_name?: string | null;
|
|
847
|
+
oauth_credentials: Record<string, Record<string, string>>;
|
|
848
|
+
captcha_enabled: boolean;
|
|
849
|
+
captcha_provider?: string | null;
|
|
850
|
+
captcha_site_key?: string | null;
|
|
851
|
+
captcha_secret_key_set?: boolean;
|
|
852
|
+
password_check_hibp: boolean;
|
|
853
|
+
sms_provider?: string | null;
|
|
854
|
+
sms_api_key_set?: boolean;
|
|
855
|
+
sms_from_number?: string | null;
|
|
856
|
+
redirect_urls: string[];
|
|
857
|
+
session_inactivity_timeout_seconds: number;
|
|
858
|
+
hook_send_sms_url?: string | null;
|
|
859
|
+
hook_send_email_url?: string | null;
|
|
860
|
+
hook_mfa_verification_url?: string | null;
|
|
861
|
+
hook_password_verification_url?: string | null;
|
|
862
|
+
auto_link_by_email: boolean;
|
|
863
|
+
revoke_on_new_device: boolean;
|
|
864
|
+
enforce_ip_binding: boolean;
|
|
865
|
+
allowed_email_domains: string[];
|
|
866
|
+
blocked_email_domains: string[];
|
|
867
|
+
updated_at: string;
|
|
868
|
+
}
|
|
869
|
+
interface EmailTemplateUpdate {
|
|
870
|
+
subject: string;
|
|
871
|
+
html_body: string;
|
|
872
|
+
}
|
|
873
|
+
interface AdminCreateUserRequest {
|
|
874
|
+
email: string;
|
|
875
|
+
password?: string;
|
|
876
|
+
role?: string;
|
|
877
|
+
email_verified?: boolean;
|
|
878
|
+
user_metadata?: Record<string, unknown>;
|
|
879
|
+
}
|
|
880
|
+
interface AdminUpdateUserRequest {
|
|
881
|
+
password?: string;
|
|
882
|
+
role?: string;
|
|
883
|
+
is_active?: boolean;
|
|
884
|
+
is_banned?: boolean;
|
|
885
|
+
email_verified?: boolean;
|
|
886
|
+
user_metadata?: Record<string, unknown>;
|
|
887
|
+
app_metadata?: Record<string, unknown>;
|
|
888
|
+
mfa_enabled?: boolean;
|
|
889
|
+
revoke_sessions?: boolean;
|
|
890
|
+
}
|
|
891
|
+
type GenerateLinkType = 'magic' | 'recovery' | 'invite';
|
|
892
|
+
interface GenerateLinkResult {
|
|
893
|
+
link: string;
|
|
894
|
+
token: string;
|
|
895
|
+
}
|
|
896
|
+
interface JwtClaims {
|
|
897
|
+
sub: string;
|
|
898
|
+
exp?: number;
|
|
899
|
+
iat?: number;
|
|
900
|
+
nbf?: number;
|
|
901
|
+
iss?: string;
|
|
902
|
+
aud?: string | string[];
|
|
903
|
+
role?: string;
|
|
904
|
+
[key: string]: unknown;
|
|
905
|
+
}
|
|
906
|
+
interface GetClaimsResult {
|
|
907
|
+
claims: JwtClaims;
|
|
908
|
+
header: {
|
|
909
|
+
alg: string;
|
|
910
|
+
kid?: string;
|
|
911
|
+
typ?: string;
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
type AuthChangeCallback = (token: string | null, user: User | null) => void;
|
|
916
|
+
/**
|
|
917
|
+
* Check whether a JWT has expired (or will expire within `marginSec` seconds).
|
|
918
|
+
*/
|
|
919
|
+
declare function isTokenExpired(token: string, marginSec?: number): boolean;
|
|
920
|
+
/**
|
|
921
|
+
* In-memory auth store with an event-emitter pattern.
|
|
922
|
+
* Can be extended (see LocalAuthStore) for persistence.
|
|
923
|
+
*/
|
|
924
|
+
declare class BaseAuthStore {
|
|
925
|
+
/**
|
|
926
|
+
* True si le store survit à un redirect pleine page (persistance disque, ex.
|
|
927
|
+
* localStorage). Le store de base est en mémoire → non persistant. Exploité par
|
|
928
|
+
* le flux PKCE : le `code_verifier` doit survivre au redirect OAuth.
|
|
929
|
+
*/
|
|
930
|
+
readonly persistent: boolean;
|
|
931
|
+
private _token;
|
|
932
|
+
private _refreshToken;
|
|
933
|
+
private _user;
|
|
934
|
+
private _listeners;
|
|
935
|
+
private _removalEpoch;
|
|
936
|
+
/** Stockage générique clé/valeur (ex: PKCE `code_verifier`). En mémoire par défaut. */
|
|
937
|
+
private _kv;
|
|
938
|
+
/** Hook d'observabilité (LOT 3) — câblé par `AuraClient` via `setObservabilityHook`. */
|
|
939
|
+
private _onEvent?;
|
|
940
|
+
private _debug;
|
|
941
|
+
/** Compteur incrémenté à chaque `clear()` — sert au commit-guard anti-race du refresh. */
|
|
942
|
+
get removalEpoch(): number;
|
|
943
|
+
get token(): string | null;
|
|
944
|
+
get refreshToken(): string | null;
|
|
945
|
+
get user(): User | null;
|
|
946
|
+
/** True if a non-expired access token is present. */
|
|
947
|
+
get isValid(): boolean;
|
|
948
|
+
save(token: string, refreshToken: string, user: User): void;
|
|
949
|
+
clear(): void;
|
|
950
|
+
setItem(key: string, value: string): void;
|
|
951
|
+
getItem(key: string): string | null;
|
|
952
|
+
removeItem(key: string): void;
|
|
953
|
+
/**
|
|
954
|
+
* Câble le hook d'observabilité (appelé par `AuraClient` à la construction).
|
|
955
|
+
* Permet à `LocalAuthStore` d'émettre `storage-blocked` quand `localStorage` est
|
|
956
|
+
* indisponible (navigation privée Safari, quota dépassé, storage désactivé…).
|
|
957
|
+
* Sans effet sur `BaseAuthStore` elle-même (en mémoire, jamais "bloquée").
|
|
958
|
+
*/
|
|
959
|
+
setObservabilityHook(onEvent: ((event: AuraObservabilityEvent) => void) | undefined, debug: boolean | undefined): void;
|
|
960
|
+
/** Émet `{kind:'storage-blocked', op}` — ne throw jamais (voir `emitAuraEvent`). */
|
|
961
|
+
protected _emitStorageBlocked(op: string): void;
|
|
962
|
+
/**
|
|
963
|
+
* Register a callback that fires whenever the auth state changes.
|
|
964
|
+
* Returns an unsubscribe function.
|
|
965
|
+
*/
|
|
966
|
+
onChange(callback: AuthChangeCallback): () => void;
|
|
967
|
+
protected _triggerChange(): void;
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* Forme minimale du client consommée par `fetchWithAuth`, `BaseService`,
|
|
972
|
+
* le `QueryBuilder` et les services. Le `AuraClient` concret (meta-package)
|
|
973
|
+
* satisfait cette interface structurellement — ce qui casse le cycle de
|
|
974
|
+
* dépendance core → meta (les services n'importent plus la classe concrète).
|
|
975
|
+
*/
|
|
976
|
+
interface AuraClientLike {
|
|
977
|
+
readonly baseUrl: string;
|
|
978
|
+
readonly projectId: string;
|
|
979
|
+
readonly apiKey: string | null;
|
|
980
|
+
readonly fetchFn: typeof globalThis.fetch;
|
|
981
|
+
readonly authStore: BaseAuthStore;
|
|
982
|
+
/** Consommé uniquement par le service realtime (refresh proactif du token). */
|
|
983
|
+
readonly auth: {
|
|
984
|
+
refreshSession(): Promise<AuraResponse<TokenPair>>;
|
|
985
|
+
};
|
|
986
|
+
/** Config du retry transitoire. Défauts appliqués si absent : enabled=true, maxRetries=3. */
|
|
987
|
+
readonly retryConfig?: {
|
|
988
|
+
enabled: boolean;
|
|
989
|
+
maxRetries: number;
|
|
990
|
+
};
|
|
991
|
+
/**
|
|
992
|
+
* Timeout par défaut (ms) des requêtes HTTP. Appliqué UNIQUEMENT aux requêtes
|
|
993
|
+
* JSON sans `signal` fourni (donc pas aux uploads FormData ni aux appels qui
|
|
994
|
+
* gèrent déjà leur propre annulation). `0` désactive. Défaut : 30 000 ms.
|
|
995
|
+
*/
|
|
996
|
+
readonly requestTimeoutMs?: number;
|
|
997
|
+
/**
|
|
998
|
+
* Hook d'observabilité (LOT 3, finding I8), optionnel — n'importe quelle implémentation
|
|
999
|
+
* structurelle de `AuraClientLike` reste compatible sans le fournir (pas de breaking
|
|
1000
|
+
* change). Consommé par `fetchWithAuth`/`refreshOnce` pour émettre retry/timeout/refresh.
|
|
1001
|
+
*/
|
|
1002
|
+
readonly onEvent?: (event: AuraObservabilityEvent) => void;
|
|
1003
|
+
/** Si `true`, chaque `AuraObservabilityEvent` est aussi journalisé via `console.debug`. */
|
|
1004
|
+
readonly debug?: boolean;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
/** Point d'entrée unique du refresh, dédupliqué par client (single-flight). */
|
|
1008
|
+
declare function refreshOnce(client: AuraClientLike): Promise<AuraResponse<TokenPair>>;
|
|
1009
|
+
interface FetchInit {
|
|
1010
|
+
method?: string;
|
|
1011
|
+
headers?: Record<string, string>;
|
|
1012
|
+
body?: unknown;
|
|
1013
|
+
signal?: AbortSignal;
|
|
1014
|
+
skipAuthRefresh?: boolean;
|
|
1015
|
+
/**
|
|
1016
|
+
* Override explicite du `Authorization: Bearer` (LOT D). S'il est fourni, il
|
|
1017
|
+
* GAGNE sur `store.token` — permet de valider un token ARBITRAIRE (foreign)
|
|
1018
|
+
* plutôt que celui de la session courante (ex. `getUser(jwt)`). Sans lui, le
|
|
1019
|
+
* comportement historique s'applique (`Authorization = Bearer store.token`).
|
|
1020
|
+
*/
|
|
1021
|
+
authToken?: string;
|
|
1022
|
+
/** Désactive le retry transitoire pour cette requête (override). */
|
|
1023
|
+
skipRetry?: boolean;
|
|
1024
|
+
/** Interne (E19) : marque une requête déjà rejouée après refresh pour borner la récursion. */
|
|
1025
|
+
_retried?: boolean;
|
|
1026
|
+
}
|
|
1027
|
+
/**
|
|
1028
|
+
* Core fetch wrapper that handles:
|
|
1029
|
+
* - Lazy token refresh before expiry
|
|
1030
|
+
* - Authorization / API key injection
|
|
1031
|
+
* - Content-Type defaulting
|
|
1032
|
+
* - Structured AuraResponse parsing
|
|
1033
|
+
*/
|
|
1034
|
+
declare function fetchWithAuth<T>(url: string, init: FetchInit, client: AuraClientLike): Promise<AuraResponse<T>>;
|
|
1035
|
+
|
|
1036
|
+
/**
|
|
1037
|
+
* Abstract base class for all service modules.
|
|
1038
|
+
* Provides the shared HTTP helper and URL builder.
|
|
1039
|
+
*/
|
|
1040
|
+
declare abstract class BaseService {
|
|
1041
|
+
protected readonly client: AuraClientLike;
|
|
1042
|
+
constructor(client: AuraClientLike);
|
|
1043
|
+
/** Build a full URL for the given path. */
|
|
1044
|
+
protected url(path: string): string;
|
|
1045
|
+
/** Convenience HTTP helper that delegates to fetchWithAuth. */
|
|
1046
|
+
protected request<T>(method: string, path: string, body?: unknown, options?: {
|
|
1047
|
+
headers?: Record<string, string>;
|
|
1048
|
+
signal?: AbortSignal;
|
|
1049
|
+
skipAuthRefresh?: boolean;
|
|
1050
|
+
/** Override explicite du Bearer (LOT D) — valide un token arbitraire. */
|
|
1051
|
+
authToken?: string;
|
|
1052
|
+
}): Promise<AuraResponse<T>>;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
interface CookieOptions {
|
|
1056
|
+
path?: string;
|
|
1057
|
+
domain?: string;
|
|
1058
|
+
maxAge?: number;
|
|
1059
|
+
secure?: boolean;
|
|
1060
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
1061
|
+
httpOnly?: boolean;
|
|
1062
|
+
}
|
|
1063
|
+
/**
|
|
1064
|
+
* Auth store backed by `localStorage` (browser) with cookie helpers for SSR.
|
|
1065
|
+
*/
|
|
1066
|
+
declare class LocalAuthStore extends BaseAuthStore {
|
|
1067
|
+
/** Persiste en localStorage → survit au redirect pleine page (cf. PKCE). */
|
|
1068
|
+
readonly persistent = true;
|
|
1069
|
+
private readonly key;
|
|
1070
|
+
constructor(key?: string);
|
|
1071
|
+
save(token: string, refreshToken: string, user: User): void;
|
|
1072
|
+
clear(): void;
|
|
1073
|
+
/**
|
|
1074
|
+
* Supprime de localStorage tous les artefacts d'auth éphémères sur disque :
|
|
1075
|
+
* - `code_verifier` PKCE (`aura-<projectId>-pkce-code-verifier`),
|
|
1076
|
+
* - marqueur d'initiation OAuth implicit (`aura-<projectId>-oauth-implicit-initiated`,
|
|
1077
|
+
* SEC-F3). Un `signOut`/`clear()` ne doit laisser aucun résidu réutilisable (parité
|
|
1078
|
+
* `@supabase/ssr` : ces artefacts sont éphémères). On itère les clés préfixées pour
|
|
1079
|
+
* couvrir un store partagé entre plusieurs projets, sans dépendre du `projectId` courant.
|
|
1080
|
+
*/
|
|
1081
|
+
private _removePkceVerifiers;
|
|
1082
|
+
setItem(key: string, value: string): void;
|
|
1083
|
+
getItem(key: string): string | null;
|
|
1084
|
+
removeItem(key: string): void;
|
|
1085
|
+
/**
|
|
1086
|
+
* Populate the store from a raw `Cookie` header string (server-side).
|
|
1087
|
+
* Looks for the key matching `this.key`.
|
|
1088
|
+
*/
|
|
1089
|
+
loadFromCookie(cookieString: string): void;
|
|
1090
|
+
/**
|
|
1091
|
+
* Serialize current auth state into a `Set-Cookie` value.
|
|
1092
|
+
*/
|
|
1093
|
+
exportToCookie(options?: CookieOptions): string;
|
|
1094
|
+
private _loadFromStorage;
|
|
1095
|
+
private _persist;
|
|
1096
|
+
private _removeStorage;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
/** JSON.stringify avec support des bigint (sérialisés en string). */
|
|
1100
|
+
declare function serializeBody(body: unknown): string;
|
|
1101
|
+
|
|
1102
|
+
/**
|
|
1103
|
+
* Parse a raw Cookie header string into key-value pairs.
|
|
1104
|
+
*/
|
|
1105
|
+
declare function parseCookieHeader(header: string): Record<string, string>;
|
|
1106
|
+
interface SerializeCookieOptions {
|
|
1107
|
+
path?: string;
|
|
1108
|
+
domain?: string;
|
|
1109
|
+
maxAge?: number;
|
|
1110
|
+
secure?: boolean;
|
|
1111
|
+
sameSite?: 'Strict' | 'Lax' | 'None';
|
|
1112
|
+
httpOnly?: boolean;
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Serialize a cookie name + value + options into a Set-Cookie header value.
|
|
1116
|
+
*/
|
|
1117
|
+
declare function serializeCookieHeader(name: string, value: string, options?: SerializeCookieOptions): string;
|
|
1118
|
+
|
|
1119
|
+
/**
|
|
1120
|
+
* Primitives de résilience réseau (module pur, sans I/O).
|
|
1121
|
+
* `Math.random`/`Date.now` sont injectables pour des tests déterministes.
|
|
1122
|
+
*/
|
|
1123
|
+
declare const RETRYABLE_STATUS: Set<number>;
|
|
1124
|
+
declare const RETRYABLE_METHODS: Set<string>;
|
|
1125
|
+
declare const DEFAULT_MAX_RETRIES = 3;
|
|
1126
|
+
declare function isRetryableStatus(status: number): boolean;
|
|
1127
|
+
declare function isRetryableMethod(method: string): boolean;
|
|
1128
|
+
/** Full jitter : random(0, min(BASE·2^attempt, CAP)). `attempt` commence à 0. */
|
|
1129
|
+
declare function computeBackoff(attempt: number, rand?: () => number): number;
|
|
1130
|
+
/** Parse un header `Retry-After` (secondes OU HTTP-date) → délai en ms, ou null. */
|
|
1131
|
+
declare function parseRetryAfter(header: string | null, now?: number): number | null;
|
|
1132
|
+
/** `sleep(ms)` qui résout tôt (sans rejeter) si `signal` s'annule. */
|
|
1133
|
+
declare function abortableSleep(ms: number, signal?: AbortSignal): Promise<void>;
|
|
1134
|
+
/** True si l'erreur `fetch` est une annulation utilisateur (jamais rejouée). */
|
|
1135
|
+
declare function isAbortError(err: unknown): boolean;
|
|
1136
|
+
|
|
1137
|
+
export { type AdminCreateUserRequest, type AdminSessionInfo, type AdminUpdateUserRequest, type AdminUser, type AuditLogEntry, type AuraClientLike, type AuraClientOptions, AuraError, type AuraErrorCode, type AuraObservabilityEvent, type AuraResponse, type AuthChangePayload, type AuthEvent, type AuthSettings, BaseAuthStore, BaseService, type BatchSendItemResult, type BatchSendResponse, type BroadcastAckMessage, type BroadcastFilter, type BroadcastPayload, type CdcPayload, type ChannelConfig, type ChatMessage, type ChatResponse, type CountMode, type CronJob, DEFAULT_MAX_RETRIES, type EmailTemplateUpdate, type EmbedRequest, type EmbedResponse, type FetchInit, type FileEntry, type FilterOp, type FunctionDef, type GenerateLinkResult, type GenerateLinkType, type GetClaimsResult, type IdentityInfo, type ImageTransform, type Job, type JwtClaims, LocalAuthStore, type LoginResponse, type MagicLinkRequest, type Meta, type MfaChallenge, type MfaEnrollResponse, type MfaVerifyRequest, type Notification, type NotificationAttempt, type NotificationChannelStats, type NotificationDeadLetter, type NotificationEvent, type NotificationProviderLog, type NotificationQueueStats, type NotificationRule, type NotificationSettings, type NotificationStats, type NotificationTemplate, type NotificationTemplatePreview, type OAuthSignInOptions, type ObjectMeta, type PasswordResetRequest, type PostgresChangesFilter, type PresenceFilter, type PresenceInfo, type PresenceState, type QueryFilter, type QueryOptions, RETRYABLE_METHODS, RETRYABLE_STATUS, type RagIngestRequest, type RagIngestResponse, type RagRequest, type RagResponse, type RealtimeEvent, type RealtimeListenType, type RealtimeSubscribeStatus, type SchemaColumn, type SchemaEnum, type SchemaFunction, type SchemaFunctionArg, type SchemaIndex, type SchemaTable, type SemanticSearchResult, type SendNotificationRequest, type SerializeCookieOptions, type ServerErrorMsg, type ServerEventMsg, type ServerMessage, type ServerPongMsg, type ServerPresenceStateMsg, type ServerSubscribedMsg, type ServerTokenRefreshedMsg, type SessionInfo, type SignInRequest, type SignUpRequest, type StorageBucket, type SubscribeCallback, type TokenPair, type UpdateUserRequest, type UploadResult, type User, type UserStats, abortableSleep, computeBackoff, emitAuraEvent, fetchWithAuth, isAbortError, isAuraError, isRetryableMethod, isRetryableStatus, isTokenExpired, parseCookieHeader, parseRetryAfter, refreshOnce, serializeBody, serializeCookieHeader };
|