Skip to content

Conversation

@bttf
Copy link

@bttf bttf commented Nov 26, 2025

Summary

Fixed bug in the createToken function where getUTCMilliseconds() was incorrectly used instead of getTime().

The Bug

getUTCMilliseconds() returns only the milliseconds component (0-999) of a date, not the full Unix timestamp. This caused the expiry validation to fail incorrectly when comparing timestamps.

Changes

  • Replace expiry.getUTCMilliseconds() with expiry.getTime() to get the full timestamp (line 233)
  • Replace new Date().getUTCMilliseconds() with Date.now() for getting current timestamp (line 242)

Impact

This bug would have caused the expiry validation to always fail since it was comparing millisecond values (0-999) instead of actual Unix timestamps. With this fix, the token expiry validation will work correctly.

bttf and others added 2 commits November 26, 2025 11:49
Fixed critical bug where getUTCMilliseconds() was incorrectly used instead of getTime().

getUTCMilliseconds() returns only the milliseconds component (0-999) of a date, not the full Unix timestamp. This caused the expiry validation to fail incorrectly when comparing timestamps.

Changes:
- Replace expiry.getUTCMilliseconds() with expiry.getTime() to get the full timestamp
- Replace new Date().getUTCMilliseconds() with Date.now() for getting current timestamp

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Added tests to cover the expiry validation logic that was fixed in the previous commit:
- Validates expiry accepts Date objects within next 10 minutes
- Validates expiry rejects past dates
- Validates expiry rejects dates more than 10 minutes in future
- Validates expiry accepts timestamp numbers within next 10 minutes
- Validates expiry rejects past timestamps
- Validates expiry rejects timestamps more than 10 minutes in future
- Validates expiry rejects invalid types (e.g. strings)

These tests ensure the bug fix works correctly and prevent regression.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@changeset-bot
Copy link

changeset-bot bot commented Nov 26, 2025

⚠️ No Changeset found

Latest commit: bb5ad80

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant