From b4b4aeab04d0c81ac7b4b8daea9474e47c5e912b Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 14 Jun 2017 22:45:25 +0000 Subject: [PATCH] add versioning and storage --- js/issuer.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/js/issuer.js b/js/issuer.js index 626da4a..582f2c8 100644 --- a/js/issuer.js +++ b/js/issuer.js @@ -1,6 +1,11 @@ $(function () { 'use strict'; + if ('1' !== window.localStorage.getItem('version')) { + window.localStorage.clear(); + window.localStorage.setItem('version', '1'); + } + var OAUTH3 = window.OAUTH3; var CONFIG = { host: OAUTH3.utils.clientUri(window.location) @@ -14,6 +19,20 @@ $(function () { }; $('.js-scopes-container').html(''); + /* + OAUTH3._hooks.sessions.all = function (providerUri) { + }; + */ + OAUTH3._hooks = { sessions: {} }; + OAUTH3._hooks.sessions.get = function (providerUri, id) { + return JSON.parse(window.localStorage.getItem('session-' + providerUri + (id || '')) || 'null'); + }; + OAUTH3._hooks.sessions.set = function (providerUri, newSession, id) { + window.localStorage.setItem('session-' + providerUri, JSON.stringify(newSession)); + window.localStorage.setItem('session-' + providerUri + (id || newSession.id || newSession.token.id || ''), JSON.stringify(newSession)); + return newSession; + }; + // TODO let query.parse do location.hash || location.search || location var clientParams = OAUTH3.query.parse(window.location.hash || window.location.search); if (/authorization_dialog/.test(window.location.href)) {