-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
6 changed files
with
50 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/passport/sdk/src/storage/LocalForageAsyncStorage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { AsyncStorage } from 'oidc-client-ts'; | ||
import localForage from 'localforage'; | ||
|
||
export class LocalForageAsyncStorage implements AsyncStorage { | ||
private storage: LocalForage; | ||
|
||
constructor(name: string, driver: string | string[]) { | ||
this.storage = localForage.createInstance({ name, driver }); | ||
} | ||
|
||
get length(): Promise<number> { | ||
return this.storage.length(); | ||
} | ||
|
||
clear(): Promise<void> { | ||
return this.storage.clear(); | ||
} | ||
|
||
getItem(key: string): Promise<string | null> { | ||
return this.storage.getItem<string>(key); | ||
} | ||
|
||
key(index: number): Promise<string | null> { | ||
return this.storage.key(index); | ||
} | ||
|
||
async removeItem(key: string): Promise<void> { | ||
await this.storage.removeItem(key); | ||
} | ||
|
||
async setItem(key: string, value: string): Promise<void> { | ||
await this.storage.setItem(key, value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters