@digilogiclabs/platform-core 1.28.0 → 1.29.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/dist/index.mjs CHANGED
@@ -19123,6 +19123,10 @@ function buildKeycloakCallbacks(config) {
19123
19123
  */
19124
19124
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
19125
19125
  async session({ session, token }) {
19126
+ if (token.error === "RefreshTokenError") {
19127
+ const { user: _revoked, accessToken: _stale, ...rest } = session;
19128
+ return { ...rest, idToken: token.idToken, error: token.error };
19129
+ }
19126
19130
  const user = session.user;
19127
19131
  if (user) {
19128
19132
  user.id = token.id || token.sub;
@@ -19526,11 +19530,24 @@ async function checkRateLimit(operation, identifier, rule, options = {}) {
19526
19530
  retryAfterSeconds: 0
19527
19531
  };
19528
19532
  } catch (error) {
19529
- options.logger?.error("Rate limit check failed, allowing request", {
19530
- error: error instanceof Error ? error.message : String(error),
19531
- operation,
19532
- identifier
19533
- });
19533
+ options.logger?.error(
19534
+ rule.failClosed ? "Rate limit check failed, denying request (fail-closed rule)" : "Rate limit check failed, allowing request",
19535
+ {
19536
+ error: error instanceof Error ? error.message : String(error),
19537
+ operation,
19538
+ identifier
19539
+ }
19540
+ );
19541
+ if (rule.failClosed) {
19542
+ return {
19543
+ allowed: false,
19544
+ remaining: 0,
19545
+ resetAt,
19546
+ current: 0,
19547
+ limit,
19548
+ retryAfterSeconds: 30
19549
+ };
19550
+ }
19534
19551
  return {
19535
19552
  allowed: true,
19536
19553
  remaining: limit,
@@ -33283,9 +33300,12 @@ function createRedisClient(options) {
33283
33300
  const client = new Redis(url, {
33284
33301
  keyPrefix,
33285
33302
  maxRetriesPerRequest: maxRetries,
33303
+ // Never give up reconnecting. Returning null here ends the connection
33304
+ // for good, and a long-lived singleton (rate limiting, caching) would
33305
+ // then stay broken until the process restarts. maxRetriesPerRequest
33306
+ // still makes individual commands fail fast while disconnected.
33286
33307
  retryStrategy(times) {
33287
- if (times > maxRetries) return null;
33288
- return Math.min(times * 200, 2e3);
33308
+ return Math.min(times * 200, 5e3);
33289
33309
  },
33290
33310
  lazyConnect
33291
33311
  });