I'm looking at creating a PWA so I'm using Refresh Tokens. I, therefore, desire to move away from the default SessionStorage implementation.
IndexedDB and the CacheStorage API (the current recommendations for storing data within PWA's) are only available as asynchronous promise-based APIs.
I would like the AbstractStorageProvider to implement promise-based methods for Read/Write. When being used with SessionStorage/LocalStorage these can simply be returned with empty promises, not affecting the existing implementations.
I've looked into use LocalStorage but this is no longer recommended.
See here: https://dev.to/rdegges/please-stop-using-local-storage-1i04
Thank you
@jamesikanos Thanks for reporting.
This is a good enhancement. We need this. @FabianGosebrink agree?
Greetings Damien
This also allows using the cordova secure storage - https://github.com/pradeep1991singh/cordova-plugin-secure-key-store#readme
We wanted to redo the storage support anyway so I think this might be a good enhancement.
Do you have any design goals on this? My current work-around is more than a bit of a kludge and I'll take a swing at implementing it.
Just echoing support. I wrote an async storage class using Capacitor (using Ionic so like OP, local storage for refresh tokens isn't great) and their Storage plugin (see https://capacitorjs.com/docs/apis/storage ).
Here's what I wrote. To try and give you an idea of how people might implement an async provider. I'll just have to await v12 :)
import { Injectable } from '@angular/core';
import { AbstractSecurityStorage } from 'angular-auth-oidc-client';
import { Plugins } from '@capacitor/core';
@Injectable()
export class CapacitorStorage implements AbstractSecurityStorage {
public async read(key: string): Promise<any> {
const result = await Plugins.Storage.get({ key });
return JSON.parse(result.value);
}
public async write(key: string, value: any): Promise<boolean> {
await Plugins.Storage.set({ key, value: JSON.stringify(value) });
return true;
}
public async remove(key: string): Promise<boolean> {
await Plugins.Storage.remove({ key });
return true;
}
}
Most helpful comment
This also allows using the cordova secure storage - https://github.com/pradeep1991singh/cordova-plugin-secure-key-store#readme