CSRF-X Auth Library - v1.0.3
    Preparing search index...

    Function sessionWithCsrfToken

    • Creates a new SessionData object with an updated CSRF token.

      Parameters

      • session: SessionData

        The original session data.

      • newToken: string

        The new CSRF token to set.

      Returns SessionData

      A new SessionData object with the updated token and the current timestamp.

      The timestamp is reset to Date.now() to reflect the update time.
      All other fields (cookies, loggedIn flag) are copied from the original session.
      The original session object is not mutated.

      const oldSession = await cacheManager.load();
      const updated = sessionWithCsrfToken(oldSession, 'new_csrf_token_123');
      await cacheManager.save(updated);

      0.1.1