Skip to content

[PB-6601]: feat/add-token-refresh-functionality#32

Merged
larryrider merged 11 commits into
masterfrom
feat/add-token-refresh-functionality
Jul 8, 2026
Merged

[PB-6601]: feat/add-token-refresh-functionality#32
larryrider merged 11 commits into
masterfrom
feat/add-token-refresh-functionality

Conversation

@larryrider

Copy link
Copy Markdown
Contributor

Adds JWT expiration/refresh logic to @internxt/lib's auth module, so any consuming project (CLI, drive-web, etc.) can share a single source of truth instead of re-implementing this logic per repo.

Public API surface is intentionally kept small, only the two functions consumers actually need:

  • checkTokenExpiration(expirationTimestamp, issuedAtTimestamp) -> returns a TokenStatus. Refresh is required once the token has consumed 50% of its lifetime (exp - iat) and it falls back to a fixed 6-hour margin when iat is not available.
  • validateTokenAndCheckExpiration(token) -> decodes a raw JWT string and returns the same TokenStatus directly (but INVALID if the token is malformed/unparseable).

export enum TokenStatus {
INVALID = 'INVALID',
EXPIRED = 'EXPIRED',
REFRESH_REQUIRED = 'REFRESH_REQUIRED',
VALID = 'VALID',
}
The lower-level building blocks (isTokenExpired, isTokenRefreshRequired, validateJwtAndCheckExpiration) remain exported from their own modules (not re-exported through the auth namespace) for potential future granular use, but are not part of the current public API.

**I have also migrated the project from yarn to npm as we are doing on all internxt projects progressively

@larryrider larryrider self-assigned this Jul 8, 2026
@larryrider larryrider changed the title [_]: feat/add-token-refresh-functionality [PB-6601]: feat/add-token-refresh-functionality Jul 8, 2026
Comment thread src/auth/checkTokenExpiration.ts Outdated
@larryrider larryrider merged commit cf1e952 into master Jul 8, 2026
1 check passed
@larryrider larryrider deleted the feat/add-token-refresh-functionality branch July 8, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants