-
Notifications
You must be signed in to change notification settings - Fork 271
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added caching to well-known configuration (#48)
Resolves: OKTA-100724
- Loading branch information
1 parent
e39e6cd
commit af21c3b
Showing
12 changed files
with
223 additions
and
93 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
var AuthSdkError = require('./errors/AuthSdkError'); | ||
|
||
// storage must have getItem and setItem | ||
function storageBuilder(webstorage, storageName) { | ||
function getStorage() { | ||
var storageString = webstorage.getItem(storageName); | ||
storageString = storageString || '{}'; | ||
try { | ||
return JSON.parse(storageString); | ||
} catch(e) { | ||
throw new AuthSdkError('Unable to parse storage string: ' + storageName); | ||
} | ||
} | ||
|
||
function setStorage(storage) { | ||
try { | ||
var storageString = JSON.stringify(storage); | ||
webstorage.setItem(storageName, storageString); | ||
} catch(e) { | ||
throw new AuthSdkError('Unable to set storage: ' + storageName); | ||
} | ||
} | ||
|
||
function clearStorage() { | ||
setStorage({}); | ||
} | ||
|
||
function updateStorage(key, value) { | ||
var storage = getStorage(); | ||
storage[key] = value; | ||
setStorage(storage); | ||
} | ||
|
||
return { | ||
getStorage: getStorage, | ||
setStorage: setStorage, | ||
clearStorage: clearStorage, | ||
updateStorage: updateStorage | ||
}; | ||
} | ||
|
||
module.exports = storageBuilder; |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.