Skip to content

Add storage provider interface for parallel instance support#16

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/add-storage-provider-interface
Draft

Add storage provider interface for parallel instance support#16
Copilot wants to merge 4 commits intomainfrom
copilot/add-storage-provider-interface

Conversation

Copy link

Copilot AI commented Jan 31, 2026

Multiple OIDCClient instances cannot run in parallel as they overwrite each other's tokens in shared localStorage/sessionStorage.

Changes

Storage Provider Interface

  • StorageProvider interface with getItem, setItem, removeItem methods supporting sync/async operations
  • BrowserStorageProvider: sessionStorage for access tokens, localStorage for refresh tokens, configurable token names
  • InMemoryStorageProvider: Map-based storage, no persistence

OIDCClient Updates

  • Accepts storageProvider and tokenNames options
  • All storage operations abstracted through provider interface
  • verifyTokenValidity now async to support async providers
  • Defaults to BrowserStorageProvider with standard token names (backward compatible)

Usage

Different storage providers:

const client1 = new OIDCClient(); // Browser storage (default)
const client2 = new OIDCClient({ 
  storageProvider: new InMemoryStorageProvider() 
});

Different token names:

const client1 = new OIDCClient({ 
  tokenNames: { token: "token1", refreshToken: "refreshToken1" }
});
const client2 = new OIDCClient({ 
  tokenNames: { token: "token2", refreshToken: "refreshToken2" }
});

Custom provider:

class MongoDBStorageProvider implements StorageProvider {
  async getItem(key: string) { /* ... */ }
  async setItem(key: string, value: string) { /* ... */ }
  async removeItem(key: string) { /* ... */ }
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits January 31, 2026 14:30
…ions

Co-authored-by: rickygarg <3947328+rickygarg@users.noreply.github.com>
Co-authored-by: rickygarg <3947328+rickygarg@users.noreply.github.com>
… assertions

Co-authored-by: rickygarg <3947328+rickygarg@users.noreply.github.com>
Copilot AI changed the title [WIP] Add storage provider interface for flexible OIDC client Add storage provider interface for parallel instance support Jan 31, 2026
Copilot AI requested a review from rickygarg January 31, 2026 14:36
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.

2 participants