Skip to content

fix(auth): upgrade explicit legacy sessions - #1756

Merged
Baskarayelu merged 2 commits into
Remitwise-Org:mainfrom
Killerjunior:codex/fix-session-migration-v2
Oct 22, 2026
Merged

Baskarayelu merged 2 commits into
Remitwise-Org:mainfrom
Killerjunior:codex/fix-session-migration-v2

Conversation

@Killerjunior

Copy link
Copy Markdown
Contributor

Description

Closes #1745

migrateV1ToV2 previously only set schemaVersion when the existing value was not a number. An explicit schemaVersion: 1 was therefore left unchanged, even though the result was typed as SessionDataV2.

This change upgrades unversioned, V0, and explicit V1 sessions to V2; rejects invalid shapes and unsupported future versions with a discriminated result; validates Stellar addresses and timestamp ranges; and records migration attempts and failures. Unknown fields are preserved during upgrades.

The result type now distinguishes success from failure:

type MigrationResult =
  | { ok: true; data: SessionDataV2; migrated: boolean; fromVersion: number; toVersion: number }
  | {
      ok: false;
      reason: "INVALID_SHAPE" | "UNSUPPORTED_FUTURE_VERSION" | "UNSUPPORTED_LEGACY_VERSION";
      fromVersion: number;
    };

Tests were updated to import the module by relative path, cover explicit V0/V1 and future versions, invalid addresses and timestamps, stats, and generated idempotency cases. Fixtures with equal timestamps are now expected to be invalid because expiresAt must be greater than createdAt.

@Baskarayelu
Baskarayelu merged commit 31e18b5 into Remitwise-Org:main Oct 22, 2026
1 check passed
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.

fix(auth): migrateSession never upgrades explicit v1/v0 sessions, passes through future versions and labels invalid data as V2

2 participants