Skip to content

[v8] Replace iron-session with iron-webcrypto v2#1416

Merged
nicknisi merged 7 commits intoversion-8from
nicknisi/iron-webcrypto
Dec 15, 2025
Merged

[v8] Replace iron-session with iron-webcrypto v2#1416
nicknisi merged 7 commits intoversion-8from
nicknisi/iron-webcrypto

Conversation

@nicknisi
Copy link
Member

Summary

  • Replaces iron-session dependency with direct iron-webcrypto v2.0.0
  • Creates lightweight seal.ts wrapper providing iron-session compatible API
  • Reduces dependency footprint while maintaining backwards compatibility

Changes

  • Add src/common/crypto/seal.ts with sealData and unsealData functions
  • Update package.json to use iron-webcrypto ^2.0.0
  • Update jest.config.cjs to transform ESM-only uint8array-extras dependency
  • Update imports in session and user-management modules

@nicknisi nicknisi requested a review from a team as a code owner December 12, 2025 23:23
@nicknisi nicknisi requested review from awolfden and removed request for a team December 12, 2025 23:23
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 12, 2025

Greptile Overview

Greptile Summary

Replaces iron-session with direct iron-webcrypto v2.0.0 dependency to reduce package footprint while maintaining backward compatibility.

Key changes:

  • Created src/common/crypto/seal.ts wrapper providing iron-session-compatible API (sealData/unsealData)
  • Added version delimiter (~) to support token migration from v1 to v2 format
  • Updated jest config to transform ESM-only uint8array-extras dependency
  • All imports switched from iron-session to local crypto wrapper

The implementation handles backward compatibility by parsing version suffixes and extracting persistent property for v1 tokens.

Confidence Score: 5/5

  • This PR is safe to merge with no critical issues found
  • Clean dependency migration with proper backward compatibility handling, comprehensive version management, and appropriate error handling. No security concerns detected.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
src/common/crypto/seal.ts 5/5 New wrapper around iron-webcrypto v2 providing backward-compatible API with version handling for token migration
package.json 5/5 Replaced iron-session ^8.0.4 with direct dependency on iron-webcrypto ^2.0.0
jest.config.cjs 5/5 Updated transformIgnorePatterns to handle iron-webcrypto and uint8array-extras ESM modules

Sequence Diagram

sequenceDiagram
    participant Client
    participant UserManagement
    participant CookieSession
    participant SealWrapper as seal.ts
    participant IronWebcrypto as iron-webcrypto v2

    Note over Client,IronWebcrypto: Session Creation Flow
    Client->>UserManagement: authenticateWithCode()
    UserManagement->>SealWrapper: sealData(sessionData, {password, ttl})
    SealWrapper->>IronWebcrypto: ironSeal(data, passwordObj, options)
    IronWebcrypto-->>SealWrapper: encrypted seal
    SealWrapper-->>UserManagement: seal + "~2" (version appended)
    UserManagement-->>Client: return sealedSession

    Note over Client,IronWebcrypto: Session Authentication Flow
    Client->>CookieSession: authenticate()
    CookieSession->>SealWrapper: unsealData(encryptedData, {password, ttl})
    SealWrapper->>SealWrapper: parseSeal(encryptedData)
    Note over SealWrapper: Extracts version and seal<br/>Handles v1/v2 compatibility
    SealWrapper->>IronWebcrypto: ironUnseal(sealWithoutVersion, passwordMap)
    IronWebcrypto-->>SealWrapper: decrypted data
    alt tokenVersion === 2
        SealWrapper-->>CookieSession: return data as-is
    else tokenVersion !== null (v1)
        SealWrapper-->>CookieSession: return record.persistent ?? data
    else no version
        SealWrapper-->>CookieSession: return data as-is
    end
    CookieSession->>CookieSession: validate JWT
    CookieSession-->>Client: authentication result
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@nicknisi nicknisi changed the title Replace iron-session with iron-webcrypto v2 [v8] Replace iron-session with iron-webcrypto v2 Dec 13, 2025
data =
(await ironUnseal(sealWithoutVersion, passwordMap, {
...defaults,
ttl: ttl * 1000,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't really use ttl do we? i'd be ok with just implementing the interface we need if you want to drop that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I'll simplify the interface to just password.

@nicknisi nicknisi force-pushed the nicknisi/iron-webcrypto branch from 311bd00 to 713ee55 Compare December 15, 2025 15:24
@nicknisi nicknisi merged commit f065532 into version-8 Dec 15, 2025
8 checks passed
@nicknisi nicknisi deleted the nicknisi/iron-webcrypto branch December 15, 2025 15:25
nicknisi added a commit that referenced this pull request Dec 16, 2025
## Summary
- Replaces `iron-session` dependency with direct `iron-webcrypto` v2.0.0
- Creates lightweight `seal.ts` wrapper providing iron-session
compatible API
- Reduces dependency footprint while maintaining backwards compatibility

## Changes
- Add `src/common/crypto/seal.ts` with `sealData` and `unsealData`
functions
- Update `package.json` to use `iron-webcrypto` ^2.0.0
- Update `jest.config.cjs` to transform ESM-only `uint8array-extras`
dependency
- Update imports in session and user-management modules
nicknisi added a commit that referenced this pull request Dec 22, 2025
## Summary
- Replaces `iron-session` dependency with direct `iron-webcrypto` v2.0.0
- Creates lightweight `seal.ts` wrapper providing iron-session
compatible API
- Reduces dependency footprint while maintaining backwards compatibility

## Changes
- Add `src/common/crypto/seal.ts` with `sealData` and `unsealData`
functions
- Update `package.json` to use `iron-webcrypto` ^2.0.0
- Update `jest.config.cjs` to transform ESM-only `uint8array-extras`
dependency
- Update imports in session and user-management modules
nicknisi added a commit that referenced this pull request Jan 8, 2026
- Replaces `iron-session` dependency with direct `iron-webcrypto` v2.0.0
- Creates lightweight `seal.ts` wrapper providing iron-session
compatible API
- Reduces dependency footprint while maintaining backwards compatibility

- Add `src/common/crypto/seal.ts` with `sealData` and `unsealData`
functions
- Update `package.json` to use `iron-webcrypto` ^2.0.0
- Update `jest.config.cjs` to transform ESM-only `uint8array-extras`
dependency
- Update imports in session and user-management modules
nicknisi added a commit that referenced this pull request Jan 9, 2026
- Replaces `iron-session` dependency with direct `iron-webcrypto` v2.0.0
- Creates lightweight `seal.ts` wrapper providing iron-session
compatible API
- Reduces dependency footprint while maintaining backwards compatibility

- Add `src/common/crypto/seal.ts` with `sealData` and `unsealData`
functions
- Update `package.json` to use `iron-webcrypto` ^2.0.0
- Update `jest.config.cjs` to transform ESM-only `uint8array-extras`
dependency
- Update imports in session and user-management modules
nicknisi added a commit that referenced this pull request Jan 12, 2026
- Replaces `iron-session` dependency with direct `iron-webcrypto` v2.0.0
- Creates lightweight `seal.ts` wrapper providing iron-session
compatible API
- Reduces dependency footprint while maintaining backwards compatibility

- Add `src/common/crypto/seal.ts` with `sealData` and `unsealData`
functions
- Update `package.json` to use `iron-webcrypto` ^2.0.0
- Update `jest.config.cjs` to transform ESM-only `uint8array-extras`
dependency
- Update imports in session and user-management modules
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.

2 participants