@luckystack/core 0.6.3 → 0.6.4
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 +13 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.js +25 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -18,19 +18,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
18
18
|
- **Decoupled secrets-resolved hook** (ADR 0026): `notifySecretsResolved(changedKeys?)`
|
|
19
19
|
+ `registerSecretsResolvedListener(fn)`. A secret resolver (e.g.
|
|
20
20
|
`@luckystack/secret-manager` via `onApplied: notifySecretsResolved`) fires it after
|
|
21
|
-
overwriting `process.env`; `redis.ts` self-registers a listener that
|
|
22
|
-
default client when a `REDIS_` credential changed, so Redis auth via a
|
|
23
|
-
POINTER survives boot AND rotation with no hand-wiring. Generic — Prisma
|
|
24
|
-
clients can subscribe too. Also adds
|
|
25
|
-
`ProjectConfig` (`SecretManagerConfigRef`)
|
|
21
|
+
overwriting `process.env`; `redis.ts` self-registers a listener that EAGERLY REBUILDS +
|
|
22
|
+
registers the default client when a `REDIS_` credential changed, so Redis auth via a
|
|
23
|
+
secret-manager POINTER survives boot AND rotation with no hand-wiring. Generic — Prisma
|
|
24
|
+
pools / SDK clients can subscribe too. Also adds `rebuildDefaultRedisClient()` and an
|
|
25
|
+
optional structural `secretManager?` field on `ProjectConfig` (`SecretManagerConfigRef`)
|
|
26
|
+
so the server boot can detect a resolver.
|
|
26
27
|
|
|
27
28
|
### Fixed
|
|
28
29
|
|
|
29
30
|
- **Redis secret-manager pointer boot** (ADR 0026): the default Redis client no longer
|
|
30
31
|
fails auth with a baked-in `REDIS_PASSWORD_V<n>` pointer when it was built (during an
|
|
31
|
-
early import) before secrets resolved
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
early import) before secrets resolved. **Correction over 0.6.3:** a plain
|
|
33
|
+
`resetDefaultRedisClient()` was INSUFFICIENT (it defers the lazy rebuild, so the stale
|
|
34
|
+
value resurfaced, and never overrode an already-registered client). The framework now
|
|
35
|
+
EAGERLY REBUILDS + registers a fresh client from the resolved env
|
|
36
|
+
(`rebuildDefaultRedisClient()`), so the boot-UUID write authenticates with the real
|
|
37
|
+
password — no consumer code. The `WRONGPASS` diagnostic points at the automatic handling
|
|
38
|
+
+ the `envNames` allowlist requirement.
|
|
34
39
|
- **CORE-2** — `tryCatchSync<T, P = void>` now mirrors `tryCatch`'s `P` default,
|
|
35
40
|
so a params-less call can pass only the result type (`tryCatchSync<URL>(() =>
|
|
36
41
|
new URL(raw))`) instead of failing with TS2558.
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { z } from 'zod';
|
|
|
6
6
|
import * as _prisma_client_runtime_library from '@prisma/client/runtime/library';
|
|
7
7
|
import * as _prisma_client from '@prisma/client';
|
|
8
8
|
import { PrismaClient } from '@prisma/client';
|
|
9
|
-
import Redis, { Redis
|
|
9
|
+
import Redis$1, { Redis } from 'ioredis';
|
|
10
10
|
import { RedisAdapterOptions } from '@socket.io/redis-adapter';
|
|
11
11
|
import { ServerResponse, IncomingMessage, IncomingHttpHeaders } from 'node:http';
|
|
12
12
|
import 'socket.io-client';
|
|
@@ -679,6 +679,7 @@ declare const isDbHealthCheckRegistered: () => boolean;
|
|
|
679
679
|
declare const resetDbHealthCheckForTests: () => void;
|
|
680
680
|
|
|
681
681
|
declare const resetDefaultRedisClient: () => void;
|
|
682
|
+
declare const rebuildDefaultRedisClient: () => Redis;
|
|
682
683
|
interface RedisConnectionOptions {
|
|
683
684
|
host: string;
|
|
684
685
|
port: number;
|
|
@@ -687,7 +688,7 @@ interface RedisConnectionOptions {
|
|
|
687
688
|
}
|
|
688
689
|
declare const getRedisConnectionOptions: () => RedisConnectionOptions;
|
|
689
690
|
declare const registerStrayPrefixCommand: (...commands: string[]) => void;
|
|
690
|
-
declare const redis: Redis;
|
|
691
|
+
declare const redis: Redis$1;
|
|
691
692
|
|
|
692
693
|
type SecretsResolvedListener = (changedKeys: readonly string[] | undefined) => void;
|
|
693
694
|
declare const registerSecretsResolvedListener: (listener: SecretsResolvedListener) => (() => void);
|
|
@@ -722,15 +723,15 @@ declare const releaseLease: (name: string, token: string) => Promise<boolean>;
|
|
|
722
723
|
|
|
723
724
|
declare const DEFAULT_CLIENT_KEY = "default";
|
|
724
725
|
declare const registerPrismaClient: (client: PrismaClient, key?: string) => PrismaClient;
|
|
725
|
-
declare const registerRedisClient: (client: Redis
|
|
726
|
+
declare const registerRedisClient: (client: Redis, key?: string) => Redis;
|
|
726
727
|
declare const isPrismaClientRegistered: () => boolean;
|
|
727
728
|
declare const isRedisClientRegistered: () => boolean;
|
|
728
729
|
declare const getPrismaClientKeys: () => string[];
|
|
729
730
|
declare const getRedisClientKeys: () => string[];
|
|
730
731
|
declare const getPrismaClientFor: (key?: string) => PrismaClient;
|
|
731
|
-
declare const getRedisClientFor: (key?: string) => Redis
|
|
732
|
+
declare const getRedisClientFor: (key?: string) => Redis;
|
|
732
733
|
declare const getPrismaClient: () => PrismaClient;
|
|
733
|
-
declare const getRedisClient: () => Redis
|
|
734
|
+
declare const getRedisClient: () => Redis;
|
|
734
735
|
declare const resetClientsForTests: () => void;
|
|
735
736
|
|
|
736
737
|
interface AttachSocketRedisAdapterOptions {
|
|
@@ -744,9 +745,9 @@ interface AttachSocketRedisAdapterOptions {
|
|
|
744
745
|
* a dedicated adapter connection, custom auth, or a sentinel/cluster handle.
|
|
745
746
|
* When omitted the framework duplicates the default `redis` handle.
|
|
746
747
|
*/
|
|
747
|
-
pubClient?: Redis
|
|
748
|
+
pubClient?: Redis;
|
|
748
749
|
/** Pre-built sub client (see `pubClient`). */
|
|
749
|
-
subClient?: Redis
|
|
750
|
+
subClient?: Redis;
|
|
750
751
|
}
|
|
751
752
|
declare const attachSocketRedisAdapter: (io: Server, options?: AttachSocketRedisAdapterOptions) => void;
|
|
752
753
|
|
|
@@ -1894,4 +1895,4 @@ declare const clearAllHooks: () => void;
|
|
|
1894
1895
|
declare const registerSyncHook: <TName extends SyncHookName>(name: TName, handler: SyncHookHandler<SyncHookPayloads[TName]>) => (() => void);
|
|
1895
1896
|
declare const dispatchSyncHook: <TName extends SyncHookName>(name: TName, payload: SyncHookPayloads[TName]) => void;
|
|
1896
1897
|
|
|
1897
|
-
export { type ApiAuthRejectedPayload, type ApiErrorPayload, type ApiResponseEnvelope, AuthProps, type AvatarConfig, type AvatarConfigInput, BOOT_KEY_PREFIX, BaseSessionLayout, type CheckRateLimitParams, type CookiePrefixConstraints, type CorsRejectedPayload, type CreateLocalizedNormalizerInput, type CsrfConfig, type CsrfCookieOptions, type CsrfMismatchPayload, DEFAULT_AVATAR_CONFIG, DEFAULT_CLIENT_KEY, DEFAULT_CSRF_CONFIG, DEFAULT_ENV_FILES, DEFAULT_REDACTED_LOG_KEYS, DEPTH_TRUNCATED_PLACEHOLDER, type DbHealthCheck, type DbHealthResult, DeepPartial, type DeployConfigShape, type DeployDevelopmentShape, type DeployEnvironmentShape, type DeployResourceShape, type DeployRoutingShape, type DispatchResult, type EmailAttachment, type EmailMessage, type EmailResult, type EmailSender, type EmailSenderRegistry, type ErrorFormatter, type ErrorFormatterContext, ErrorParam, ErrorResponseInput, type ErrorTracker, type ErrorTrackerContext, type ErrorTrackerEvent, type ErrorTrackerUser, type FormatterEnvelope, GENERATED_API_DOCS_PATH, GENERATED_API_SCHEMAS_PATH, GENERATED_SOCKET_TYPES_PATH, HealthHashConfig, type HealthHashDescriptor, type HookHandler, type HookName, type HookPayloads, type HookResult, type HookSessionShape, type HookStopSignal, type HttpMethod, type LanguageCode, type LocaleReloader, type LocalizedNormalizer, type NormalizeErrorResponseInput, NormalizedErrorResponse, type OnUploadCompletePayload, type OnUploadStartPayload, type OneTimeTokenHandle, PUBLIC_DIR, type PeerRequire, type PostApiExecutePayload, type PostApiRespondPayload, type PostApiValidatePayload, type PostAvatarServePayload, type PostErrorNormalizePayload, type PostHttpRequestPayload, type PostSessionRefreshPayload, type PostSyncAuthorizePayload, type PostSyncExecutePayload, type PostSyncFanoutPayload, type PostSyncValidatePayload, type PreApiExecutePayload, type PreApiRespondPayload, type PreApiValidatePayload, type PreAvatarServePayload, type PreCaptureFilter, type PreErrorNormalizePayload, type PreHttpRequestPayload, type PreServerStopPayload, type PreSessionRefreshPayload, type PreSocketMessagePayload, type PreSyncAuthorizePayload, type PreSyncExecutePayload, type PreSyncFanoutPayload, type PreSyncRecipientPayload, type PreSyncValidatePayload, type PresetDefinition, type ProcessUploadInput, type ProcessUploadResult, REDACTED_PLACEHOLDER, ROOT_DIR, type RateLimitExceededPayload, type RateLimitResult, type RateLimitStrategy, type RedisConnectionOptions, type RedisKeyFormatter, type Registry, type RegistryOptions, type ResolveClientIpParams, type RoomNameFormatter, type RoomNameFormatterContext, type RuntimeApiMapsResult, type RuntimeEnv, type RuntimeMapsProvider, type RuntimeSyncMapsResult, SERVER_DIR, SERVER_FUNCTIONS_DIR, SHARED_DIR, SRC_DIR, type SecretsResolvedListener, type ServiceDefinition, type ServicesConfigShape, type SessionCreatedPayload, type SessionLogoutInput, type SessionProvider, type SessionRevokedPayload, type SessionSaveResult, type SocketMiddleware, type SpanHandle, type SpanResult, type SyncErrorPayload, type SyncHookHandler, type SyncHookName, type SyncHookPayloads, TSCONFIG_ALIAS_FILES, type TranslateFunction, type TranslateInput, UNKNOWN_CLIENT_IP, UPLOADS_DIR, type ValidationResult$1 as ValidationResult, abortAllForSocket, abortApiByResponseIndex, abortSyncByCb, acquireLease, allowedOrigin, type apiMessage, appendErrorTracker, applyCookiePrefixConstraints, applyErrorFormatter, applySocketMiddlewares, applyStrayKeyPrefix, attachSocketRedisAdapter, bootstrapEnv, captureException, captureExceptionAcrossTrackers, captureMessage, captureMessageAcrossTrackers, checkRateLimit, clearAllHooks, clearAllRateLimits, clearRateLimit, clearSocketMiddlewares, collectSynchronizedEnvKeys, computeSynchronizedEnvHashes, consumeOneTimeToken, consumeOneTimeTokenJson, createLocalizedNormalizer, createRegistry, defaultRateLimitStrategy, defaultRedisKeyFormatter, defaultRoomNameFormatter, deriveTokenBucketId, describeHealthHashConfig, dispatchHook, dispatchSyncHook, ensurePeerDepInstalled, env, escapeHtml, extractLanguageFromHeader, extractTokenFromRequest, extractTokenFromSocket, flushErrorTrackers, formatKey, formatRoomName, getActiveErrorTrackers, getAvatarConfig, getBindAddress, getCookieValue, getCsrfConfig, getCurrentErrorTrackerIdentity, getDbHealthCheck, getDeployConfig, getEffectiveHttpMethod, getEmailSender, getEmailSenderByName, getEnv, getEnvFiles, getErrorFormatter, getGeneratedApiDocsPath, getGeneratedApiSchemasPath, getGeneratedSocketTypesPath, getIoInstance, getLocaleReloader, getLocalizedNormalizer, getParams, getPrismaClient, getPrismaClientFor, getPrismaClientKeys, getPublicDir, getRateLimitStatus, getRateLimitStrategy, getRedactedLogKeys, getRedisClient, getRedisClientFor, getRedisClientKeys, getRedisConnectionOptions, getRedisKeyFormatter, getRegisteredSessionProvider, getRoomNameFormatter, getRuntimeApiMaps, getRuntimeSyncMaps, getServerDir, getServerFunctionDirs, getServerFunctionsDir, getServicesConfig, getSharedDir, getSocketMiddlewares, getSrcDir, getUploadsDir, hasCookie, hashSynchronizedValue, hashSynchronizedValueWith, inferHttpMethod, initConsolelog, initSharedSentry, isDbHealthCheckRegistered, isDeployConfigRegistered, isEmailSenderRegistered, isFalsy, isGetMethodName, isLocalizedNormalizerRegistered, isLoopbackIp, isMethodAllowed, isPrismaClientRegistered, isPrismaClientResolvable, isProduction, isRedactedLogKey, isRedisClientRegistered, isRuntimeMapsProviderRegistered, isServicesConfigRegistered, isSessionProviderRegistered, issueOneTimeToken, listEmailSenderNames, loadEnvFiles, loadPeer, normalizeErrorResponse, normalizeOrigin, notifySecretsResolved, oneTimeTokenKey, performLogout, prisma, processUpload, readBootUuid, readSession, recordMetricAcrossTrackers, redis, registerApiAbortController, registerAvatarConfig, registerBindAddress, registerCsrfConfig, registerDbHealthCheck, registerDeployConfig, registerEmailSender, registerEmailSenders, registerErrorFormatter, registerErrorTracker, registerErrorTrackers, registerHook, registerLocaleReloader, registerLocalizedNormalizer, registerPreCaptureFilter, registerPrismaClient, registerRateLimitStrategy, registerRedactedLogKeys, registerRedisClient, registerRedisKeyFormatter, registerRoomNameFormatter, registerRuntimeMapsProvider, registerSecretsResolvedListener, registerServicesConfig, registerSessionProvider, registerSocketMiddleware, registerStrayPrefixCommand, registerSyncAbortController, registerSyncHook, releaseLease, removeSession, renewLease, resetClientsForTests, resetCsrfConfigForTests, resetDbHealthCheckForTests, resetDefaultRedisClient, resetRedactedLogKeysForTests, resetRedisKeyFormatterForTests, resetSessionProviderForTests, resolveClientIp, resolveEnvKey, resolveErrorMessage, resolveFromRoot, resolveHealthHashConfig, resolveHealthHashConfigFromDescriptor, runWithErrorTrackerIdentity, runWithErrorTrackerIdentityScope, sanitizeErrorString, sanitizeErrorStrings, sanitizeForLog, serveAvatar, setCurrentErrorTrackerIdentity, setErrorTrackerUser, setIoInstance, setSentryUser, startSpan, startSpanAcrossTrackers, startSpanHandle, type syncMessage, tryCatch, tryCatchSync, unregisterApiAbortController, unregisterSyncAbortController, validateInputByType, validateRequest, writeBootUuid, writeSession };
|
|
1898
|
+
export { type ApiAuthRejectedPayload, type ApiErrorPayload, type ApiResponseEnvelope, AuthProps, type AvatarConfig, type AvatarConfigInput, BOOT_KEY_PREFIX, BaseSessionLayout, type CheckRateLimitParams, type CookiePrefixConstraints, type CorsRejectedPayload, type CreateLocalizedNormalizerInput, type CsrfConfig, type CsrfCookieOptions, type CsrfMismatchPayload, DEFAULT_AVATAR_CONFIG, DEFAULT_CLIENT_KEY, DEFAULT_CSRF_CONFIG, DEFAULT_ENV_FILES, DEFAULT_REDACTED_LOG_KEYS, DEPTH_TRUNCATED_PLACEHOLDER, type DbHealthCheck, type DbHealthResult, DeepPartial, type DeployConfigShape, type DeployDevelopmentShape, type DeployEnvironmentShape, type DeployResourceShape, type DeployRoutingShape, type DispatchResult, type EmailAttachment, type EmailMessage, type EmailResult, type EmailSender, type EmailSenderRegistry, type ErrorFormatter, type ErrorFormatterContext, ErrorParam, ErrorResponseInput, type ErrorTracker, type ErrorTrackerContext, type ErrorTrackerEvent, type ErrorTrackerUser, type FormatterEnvelope, GENERATED_API_DOCS_PATH, GENERATED_API_SCHEMAS_PATH, GENERATED_SOCKET_TYPES_PATH, HealthHashConfig, type HealthHashDescriptor, type HookHandler, type HookName, type HookPayloads, type HookResult, type HookSessionShape, type HookStopSignal, type HttpMethod, type LanguageCode, type LocaleReloader, type LocalizedNormalizer, type NormalizeErrorResponseInput, NormalizedErrorResponse, type OnUploadCompletePayload, type OnUploadStartPayload, type OneTimeTokenHandle, PUBLIC_DIR, type PeerRequire, type PostApiExecutePayload, type PostApiRespondPayload, type PostApiValidatePayload, type PostAvatarServePayload, type PostErrorNormalizePayload, type PostHttpRequestPayload, type PostSessionRefreshPayload, type PostSyncAuthorizePayload, type PostSyncExecutePayload, type PostSyncFanoutPayload, type PostSyncValidatePayload, type PreApiExecutePayload, type PreApiRespondPayload, type PreApiValidatePayload, type PreAvatarServePayload, type PreCaptureFilter, type PreErrorNormalizePayload, type PreHttpRequestPayload, type PreServerStopPayload, type PreSessionRefreshPayload, type PreSocketMessagePayload, type PreSyncAuthorizePayload, type PreSyncExecutePayload, type PreSyncFanoutPayload, type PreSyncRecipientPayload, type PreSyncValidatePayload, type PresetDefinition, type ProcessUploadInput, type ProcessUploadResult, REDACTED_PLACEHOLDER, ROOT_DIR, type RateLimitExceededPayload, type RateLimitResult, type RateLimitStrategy, type RedisConnectionOptions, type RedisKeyFormatter, type Registry, type RegistryOptions, type ResolveClientIpParams, type RoomNameFormatter, type RoomNameFormatterContext, type RuntimeApiMapsResult, type RuntimeEnv, type RuntimeMapsProvider, type RuntimeSyncMapsResult, SERVER_DIR, SERVER_FUNCTIONS_DIR, SHARED_DIR, SRC_DIR, type SecretsResolvedListener, type ServiceDefinition, type ServicesConfigShape, type SessionCreatedPayload, type SessionLogoutInput, type SessionProvider, type SessionRevokedPayload, type SessionSaveResult, type SocketMiddleware, type SpanHandle, type SpanResult, type SyncErrorPayload, type SyncHookHandler, type SyncHookName, type SyncHookPayloads, TSCONFIG_ALIAS_FILES, type TranslateFunction, type TranslateInput, UNKNOWN_CLIENT_IP, UPLOADS_DIR, type ValidationResult$1 as ValidationResult, abortAllForSocket, abortApiByResponseIndex, abortSyncByCb, acquireLease, allowedOrigin, type apiMessage, appendErrorTracker, applyCookiePrefixConstraints, applyErrorFormatter, applySocketMiddlewares, applyStrayKeyPrefix, attachSocketRedisAdapter, bootstrapEnv, captureException, captureExceptionAcrossTrackers, captureMessage, captureMessageAcrossTrackers, checkRateLimit, clearAllHooks, clearAllRateLimits, clearRateLimit, clearSocketMiddlewares, collectSynchronizedEnvKeys, computeSynchronizedEnvHashes, consumeOneTimeToken, consumeOneTimeTokenJson, createLocalizedNormalizer, createRegistry, defaultRateLimitStrategy, defaultRedisKeyFormatter, defaultRoomNameFormatter, deriveTokenBucketId, describeHealthHashConfig, dispatchHook, dispatchSyncHook, ensurePeerDepInstalled, env, escapeHtml, extractLanguageFromHeader, extractTokenFromRequest, extractTokenFromSocket, flushErrorTrackers, formatKey, formatRoomName, getActiveErrorTrackers, getAvatarConfig, getBindAddress, getCookieValue, getCsrfConfig, getCurrentErrorTrackerIdentity, getDbHealthCheck, getDeployConfig, getEffectiveHttpMethod, getEmailSender, getEmailSenderByName, getEnv, getEnvFiles, getErrorFormatter, getGeneratedApiDocsPath, getGeneratedApiSchemasPath, getGeneratedSocketTypesPath, getIoInstance, getLocaleReloader, getLocalizedNormalizer, getParams, getPrismaClient, getPrismaClientFor, getPrismaClientKeys, getPublicDir, getRateLimitStatus, getRateLimitStrategy, getRedactedLogKeys, getRedisClient, getRedisClientFor, getRedisClientKeys, getRedisConnectionOptions, getRedisKeyFormatter, getRegisteredSessionProvider, getRoomNameFormatter, getRuntimeApiMaps, getRuntimeSyncMaps, getServerDir, getServerFunctionDirs, getServerFunctionsDir, getServicesConfig, getSharedDir, getSocketMiddlewares, getSrcDir, getUploadsDir, hasCookie, hashSynchronizedValue, hashSynchronizedValueWith, inferHttpMethod, initConsolelog, initSharedSentry, isDbHealthCheckRegistered, isDeployConfigRegistered, isEmailSenderRegistered, isFalsy, isGetMethodName, isLocalizedNormalizerRegistered, isLoopbackIp, isMethodAllowed, isPrismaClientRegistered, isPrismaClientResolvable, isProduction, isRedactedLogKey, isRedisClientRegistered, isRuntimeMapsProviderRegistered, isServicesConfigRegistered, isSessionProviderRegistered, issueOneTimeToken, listEmailSenderNames, loadEnvFiles, loadPeer, normalizeErrorResponse, normalizeOrigin, notifySecretsResolved, oneTimeTokenKey, performLogout, prisma, processUpload, readBootUuid, readSession, rebuildDefaultRedisClient, recordMetricAcrossTrackers, redis, registerApiAbortController, registerAvatarConfig, registerBindAddress, registerCsrfConfig, registerDbHealthCheck, registerDeployConfig, registerEmailSender, registerEmailSenders, registerErrorFormatter, registerErrorTracker, registerErrorTrackers, registerHook, registerLocaleReloader, registerLocalizedNormalizer, registerPreCaptureFilter, registerPrismaClient, registerRateLimitStrategy, registerRedactedLogKeys, registerRedisClient, registerRedisKeyFormatter, registerRoomNameFormatter, registerRuntimeMapsProvider, registerSecretsResolvedListener, registerServicesConfig, registerSessionProvider, registerSocketMiddleware, registerStrayPrefixCommand, registerSyncAbortController, registerSyncHook, releaseLease, removeSession, renewLease, resetClientsForTests, resetCsrfConfigForTests, resetDbHealthCheckForTests, resetDefaultRedisClient, resetRedactedLogKeysForTests, resetRedisKeyFormatterForTests, resetSessionProviderForTests, resolveClientIp, resolveEnvKey, resolveErrorMessage, resolveFromRoot, resolveHealthHashConfig, resolveHealthHashConfigFromDescriptor, runWithErrorTrackerIdentity, runWithErrorTrackerIdentityScope, sanitizeErrorString, sanitizeErrorStrings, sanitizeForLog, serveAvatar, setCurrentErrorTrackerIdentity, setErrorTrackerUser, setIoInstance, setSentryUser, startSpan, startSpanAcrossTrackers, startSpanHandle, type syncMessage, tryCatch, tryCatchSync, unregisterApiAbortController, unregisterSyncAbortController, validateInputByType, validateRequest, writeBootUuid, writeSession };
|
package/dist/index.js
CHANGED
|
@@ -624,11 +624,10 @@ var readPositiveIntEnv = (name, fallback) => {
|
|
|
624
624
|
const parsed = Number.parseInt(raw, 10);
|
|
625
625
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
626
626
|
};
|
|
627
|
-
var
|
|
628
|
-
if (cachedDefault) return cachedDefault;
|
|
627
|
+
var constructRedisClient = () => {
|
|
629
628
|
const maxReconnectAttempts = readPositiveIntEnv("LUCKYSTACK_REDIS_MAX_RECONNECTS", DEFAULT_MAX_REDIS_RECONNECT_ATTEMPTS);
|
|
630
629
|
const maxBackoffMs = readPositiveIntEnv("LUCKYSTACK_REDIS_MAX_BACKOFF_MS", DEFAULT_MAX_REDIS_BACKOFF_MS);
|
|
631
|
-
|
|
630
|
+
const client = new Redis({
|
|
632
631
|
host: env.REDIS_HOST,
|
|
633
632
|
port: Number.parseInt(env.REDIS_PORT, 10),
|
|
634
633
|
...process.env.REDIS_USER && { username: process.env.REDIS_USER },
|
|
@@ -643,21 +642,26 @@ var buildDefaultRedisClient = () => {
|
|
|
643
642
|
return Math.min(times * 50, maxBackoffMs);
|
|
644
643
|
}
|
|
645
644
|
});
|
|
646
|
-
|
|
645
|
+
client.on("ready", async () => {
|
|
647
646
|
getLogger().info("Connected to Redis");
|
|
648
647
|
});
|
|
649
|
-
|
|
648
|
+
client.on("error", (err) => {
|
|
650
649
|
const message = String(err?.message ?? err);
|
|
651
650
|
const password = process.env.REDIS_PASSWORD ?? "";
|
|
652
651
|
if (/WRONGPASS|NOAUTH|invalid username-password/i.test(message) && /_V\d+$/i.test(password)) {
|
|
653
652
|
getLogger().error(
|
|
654
|
-
`Redis auth failed and REDIS_PASSWORD ("${password}") looks like an UNRESOLVED secret-manager pointer. The default Redis client was likely built before secret-manager init ran. The framework now
|
|
653
|
+
`Redis auth failed and REDIS_PASSWORD ("${password}") looks like an UNRESOLVED secret-manager pointer. The default Redis client was likely built before secret-manager init ran. The framework now EAGERLY REBUILDS + registers a fresh client automatically when \`config.secretManager.url\` is set (server boot) and when \`initSecretManager\` is wired with \`onApplied: notifySecretsResolved\`; if you resolve secrets by other means, call \`rebuildDefaultRedisClient()\` (or \`registerRedisClient(new Redis(getRedisConnectionOptions()))\`) after resolution. Also confirm \`REDIS_PASSWORD\` is listed in the secret-manager \`envNames\` allowlist (unset resolves nothing). See docs/luckystack/ARCHITECTURE_SECRET_MANAGER.md.`,
|
|
655
654
|
err
|
|
656
655
|
);
|
|
657
656
|
return;
|
|
658
657
|
}
|
|
659
658
|
getLogger().error("Error connecting to Redis", err);
|
|
660
659
|
});
|
|
660
|
+
return client;
|
|
661
|
+
};
|
|
662
|
+
var buildDefaultRedisClient = () => {
|
|
663
|
+
if (cachedDefault) return cachedDefault;
|
|
664
|
+
cachedDefault = constructRedisClient();
|
|
661
665
|
return cachedDefault;
|
|
662
666
|
};
|
|
663
667
|
var resetDefaultRedisClient = () => {
|
|
@@ -669,10 +673,23 @@ var resetDefaultRedisClient = () => {
|
|
|
669
673
|
} catch {
|
|
670
674
|
}
|
|
671
675
|
};
|
|
676
|
+
var rebuildDefaultRedisClient = () => {
|
|
677
|
+
const previousRegistered = isRedisClientRegistered() ? getRedisClient() : null;
|
|
678
|
+
resetDefaultRedisClient();
|
|
679
|
+
const client = constructRedisClient();
|
|
680
|
+
registerRedisClient(client);
|
|
681
|
+
if (previousRegistered && previousRegistered !== client) {
|
|
682
|
+
try {
|
|
683
|
+
previousRegistered.disconnect();
|
|
684
|
+
} catch {
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
return client;
|
|
688
|
+
};
|
|
672
689
|
setDefaultRedisResolver(buildDefaultRedisClient);
|
|
673
690
|
registerSecretsResolvedListener((changedKeys) => {
|
|
674
691
|
if (changedKeys === void 0 || changedKeys.some((key) => /^REDIS_/i.test(key))) {
|
|
675
|
-
|
|
692
|
+
rebuildDefaultRedisClient();
|
|
676
693
|
}
|
|
677
694
|
});
|
|
678
695
|
var getRedisConnectionOptions = () => ({
|
|
@@ -2295,6 +2312,7 @@ export {
|
|
|
2295
2312
|
processUpload,
|
|
2296
2313
|
readBootUuid,
|
|
2297
2314
|
readSession,
|
|
2315
|
+
rebuildDefaultRedisClient,
|
|
2298
2316
|
recordMetricAcrossTrackers,
|
|
2299
2317
|
redis,
|
|
2300
2318
|
registerApiAbortController,
|