@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/auth.mjs CHANGED
@@ -221,6 +221,10 @@ function buildKeycloakCallbacks(config) {
221
221
  */
222
222
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
223
223
  async session({ session, token }) {
224
+ if (token.error === "RefreshTokenError") {
225
+ const { user: _revoked, accessToken: _stale, ...rest } = session;
226
+ return { ...rest, idToken: token.idToken, error: token.error };
227
+ }
224
228
  const user = session.user;
225
229
  if (user) {
226
230
  user.id = token.id || token.sub;
@@ -698,11 +702,24 @@ async function checkRateLimit(operation, identifier, rule, options = {}) {
698
702
  retryAfterSeconds: 0
699
703
  };
700
704
  } catch (error) {
701
- options.logger?.error("Rate limit check failed, allowing request", {
702
- error: error instanceof Error ? error.message : String(error),
703
- operation,
704
- identifier
705
- });
705
+ options.logger?.error(
706
+ rule.failClosed ? "Rate limit check failed, denying request (fail-closed rule)" : "Rate limit check failed, allowing request",
707
+ {
708
+ error: error instanceof Error ? error.message : String(error),
709
+ operation,
710
+ identifier
711
+ }
712
+ );
713
+ if (rule.failClosed) {
714
+ return {
715
+ allowed: false,
716
+ remaining: 0,
717
+ resetAt,
718
+ current: 0,
719
+ limit,
720
+ retryAfterSeconds: 30
721
+ };
722
+ }
706
723
  return {
707
724
  allowed: true,
708
725
  remaining: limit,