-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add JWT parsing on sw, separate IndexedDB logic, and implement named …
…responses cache by did
- Loading branch information
1 parent
f2824b2
commit 1275244
Showing
2 changed files
with
65 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { openDB } from 'idb'; | ||
|
||
const DB_NAME = "wwwallet-db"; | ||
const DB_VERSION = 1; | ||
const DB_STORAGE_VC_NAME = "storage"; | ||
|
||
const dbPromise = openDB(DB_NAME, DB_VERSION, { | ||
upgrade(db) { | ||
db.createObjectStore(DB_STORAGE_VC_NAME); | ||
}, | ||
}); | ||
|
||
export async function saveResponseToIndexedDB(did, url, responseText) { | ||
const db = await dbPromise; | ||
const key = `${did}-${url}`; | ||
await db.put(DB_STORAGE_VC_NAME, responseText, key); | ||
} | ||
|
||
export async function getResponseFromIndexedDB(did, url) { | ||
const db = await dbPromise; | ||
const key = `${did}-${url}`; | ||
return db.get(DB_STORAGE_VC_NAME, key); | ||
} |
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