angular-auth-oidc-client icon indicating copy to clipboard operation
angular-auth-oidc-client copied to clipboard

[Feature Request]: Be able to implement an async Custom Storage

Open stemlaur opened this issue 1 year ago • 2 comments

Is your feature request related to a problem? Please describe.

Currently, the library allows to implement a custom storage, but it is limited to synchronous implementation, a developer should be able to implement an async custom storage returning Promises.

Describe the solution you'd like

It would be awesome to be able to create a custom storage like this one:

import { AbstractSecurityStorage } from 'angular-auth-oidc-client';

@Injectable()
export class AsyncStorageService implements AbstractSecurityStorage {

  read(key: string): Promise<any> {
    return await ...;
  }

  write(key: string, value: any): Promise<void> {
    await ...
  }

  remove(key: string): Promise<void> {
    await ...
  }

  clear(): void {
    await ...
  }
}

The library should check if the return object is a promise and await it if it is.

stemlaur avatar Apr 25 '24 08:04 stemlaur

Same same for me: i would like to store security data within a local SQLite db, but as all read/write operations are asynchronous, it is impossible to implement a custom storage provider for that use case.

Furthermore the hasStorage() method within BrowserStorageService could be problematic if the provided custom storage provider does not rely on default Storage interface..

jhpetersen avatar Apr 30 '24 09:04 jhpetersen

I would have liked to propose a PR, but just realized that synchronous calls to StoragePersistenceService read/write/remove/clear methods spreads over a lot of services/classes and these in turn are also synchronous methods, and so on.

So i assume implementing an async storage provider will result in huge effort to convert most parts of this library to async code, and thus will be a major/breaking change.

So the question to the creators/maintainers of this library: is this somehow on the roadmap? (is there any roadmap at all? 🤔 😉) Or do you see any possibility how to achieve this with less effort / limited changes?

jhpetersen avatar May 07 '24 07:05 jhpetersen