@okta/okta-auth-js 6.1.0 → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +53 -23
- package/cjs/AuthStateManager.js +5 -4
- package/cjs/AuthStateManager.js.map +1 -1
- package/cjs/OktaAuth.js +30 -14
- package/cjs/OktaAuth.js.map +1 -1
- package/cjs/OktaUserAgent.js +2 -2
- package/cjs/ServiceManager.js +195 -0
- package/cjs/ServiceManager.js.map +1 -0
- package/cjs/TokenManager.js +6 -14
- package/cjs/TokenManager.js.map +1 -1
- package/cjs/browser/browserStorage.js +12 -7
- package/cjs/browser/browserStorage.js.map +1 -1
- package/cjs/crypto/node.js +19 -13
- package/cjs/crypto/node.js.map +1 -1
- package/cjs/idx/remediators/AuthenticatorVerificationData.js +44 -7
- package/cjs/idx/remediators/AuthenticatorVerificationData.js.map +1 -1
- package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
- package/cjs/idx/run.js +6 -0
- package/cjs/idx/run.js.map +1 -1
- package/cjs/options/browser.js +81 -0
- package/cjs/options/browser.js.map +1 -0
- package/cjs/{options.js → options/index.js} +12 -78
- package/cjs/options/index.js.map +1 -0
- package/cjs/options/node.js +46 -0
- package/cjs/options/node.js.map +1 -0
- package/cjs/server/serverStorage.js +7 -4
- package/cjs/server/serverStorage.js.map +1 -1
- package/cjs/services/AutoRenewService.js +94 -0
- package/cjs/services/AutoRenewService.js.map +1 -0
- package/cjs/services/SyncStorageService.js +93 -0
- package/cjs/services/SyncStorageService.js.map +1 -0
- package/cjs/services/index.js +30 -0
- package/cjs/services/index.js.map +1 -0
- package/cjs/types/Service.js +2 -0
- package/cjs/types/Service.js.map +1 -0
- package/cjs/types/index.js +13 -0
- package/cjs/types/index.js.map +1 -1
- package/dist/okta-auth-js.min.js +1 -1
- package/dist/okta-auth-js.min.js.LICENSE.txt +0 -8
- package/dist/okta-auth-js.min.js.map +1 -1
- package/dist/okta-auth-js.umd.js +1 -1
- package/dist/okta-auth-js.umd.js.LICENSE.txt +1 -7
- package/dist/okta-auth-js.umd.js.map +1 -1
- package/esm/{index.js → esm.browser.js} +1184 -2399
- package/esm/esm.browser.js.map +1 -0
- package/esm/esm.node.mjs +9277 -0
- package/esm/esm.node.mjs.map +1 -0
- package/lib/AuthStateManager.d.ts +1 -3
- package/lib/OktaAuth.d.ts +5 -4
- package/lib/ServiceManager.d.ts +38 -0
- package/lib/TokenManager.d.ts +0 -1
- package/lib/idx/remediators/AuthenticatorVerificationData.d.ts +5 -5
- package/lib/idx/remediators/Base/AuthenticatorData.d.ts +5 -6
- package/lib/options/browser.d.ts +16 -0
- package/lib/{options.d.ts → options/index.d.ts} +1 -1
- package/lib/options/node.d.ts +16 -0
- package/lib/services/AutoRenewService.d.ts +27 -0
- package/lib/services/{TokenService.d.ts → SyncStorageService.d.ts} +8 -5
- package/lib/services/index.d.ts +13 -0
- package/lib/types/OktaAuthOptions.d.ts +5 -0
- package/lib/types/Service.d.ts +23 -0
- package/lib/types/api.d.ts +5 -2
- package/lib/types/index.d.ts +1 -0
- package/package.json +24 -10
- package/cjs/options.js.map +0 -1
- package/cjs/services/TokenService.js +0 -111
- package/cjs/services/TokenService.js.map +0 -1
- package/esm/index.js.map +0 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.AutoRenewService = void 0;
|
|
6
|
+
|
|
7
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
8
|
+
|
|
9
|
+
var _TokenManager = require("../TokenManager");
|
|
10
|
+
|
|
11
|
+
var _errors = require("../errors");
|
|
12
|
+
|
|
13
|
+
var _features = require("../features");
|
|
14
|
+
|
|
15
|
+
/*!
|
|
16
|
+
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
17
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
18
|
+
*
|
|
19
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
20
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
21
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
22
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
+
*
|
|
24
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
25
|
+
*/
|
|
26
|
+
class AutoRenewService {
|
|
27
|
+
constructor(tokenManager, options = {}) {
|
|
28
|
+
(0, _defineProperty2.default)(this, "started", false);
|
|
29
|
+
this.tokenManager = tokenManager;
|
|
30
|
+
this.options = options;
|
|
31
|
+
this.renewTimeQueue = [];
|
|
32
|
+
this.onTokenExpiredHandler = this.onTokenExpiredHandler.bind(this);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
shouldThrottleRenew() {
|
|
36
|
+
let res = false;
|
|
37
|
+
this.renewTimeQueue.push(Date.now());
|
|
38
|
+
|
|
39
|
+
if (this.renewTimeQueue.length >= 10) {
|
|
40
|
+
// get and remove first item from queue
|
|
41
|
+
const firstTime = this.renewTimeQueue.shift();
|
|
42
|
+
const lastTime = this.renewTimeQueue[this.renewTimeQueue.length - 1];
|
|
43
|
+
res = lastTime - firstTime < 30 * 1000;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return res;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
requiresLeadership() {
|
|
50
|
+
// If tokens sync storage is enabled, handle tokens expiration only in 1 leader tab
|
|
51
|
+
return !!this.options.syncStorage && (0, _features.isBrowser)();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
onTokenExpiredHandler(key) {
|
|
55
|
+
if (this.options.autoRenew) {
|
|
56
|
+
if (this.shouldThrottleRenew()) {
|
|
57
|
+
const error = new _errors.AuthSdkError('Too many token renew requests');
|
|
58
|
+
this.tokenManager.emitError(error);
|
|
59
|
+
} else {
|
|
60
|
+
this.tokenManager.renew(key).catch(() => {}); // Renew errors will emit an "error" event
|
|
61
|
+
}
|
|
62
|
+
} else if (this.options.autoRemove) {
|
|
63
|
+
this.tokenManager.remove(key);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
canStart() {
|
|
68
|
+
return !!this.options.autoRenew || !!this.options.autoRemove;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
start() {
|
|
72
|
+
if (this.canStart()) {
|
|
73
|
+
this.stop();
|
|
74
|
+
this.tokenManager.on(_TokenManager.EVENT_EXPIRED, this.onTokenExpiredHandler);
|
|
75
|
+
this.started = true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
stop() {
|
|
80
|
+
if (this.started) {
|
|
81
|
+
this.tokenManager.off(_TokenManager.EVENT_EXPIRED, this.onTokenExpiredHandler);
|
|
82
|
+
this.renewTimeQueue = [];
|
|
83
|
+
this.started = false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
isStarted() {
|
|
88
|
+
return this.started;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
exports.AutoRenewService = AutoRenewService;
|
|
94
|
+
//# sourceMappingURL=AutoRenewService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../lib/services/AutoRenewService.ts"],"names":["AutoRenewService","constructor","tokenManager","options","renewTimeQueue","onTokenExpiredHandler","bind","shouldThrottleRenew","res","push","Date","now","length","firstTime","shift","lastTime","requiresLeadership","syncStorage","key","autoRenew","error","AuthSdkError","emitError","renew","catch","autoRemove","remove","canStart","start","stop","on","EVENT_EXPIRED","started","off","isStarted"],"mappings":";;;;;;;;AAaA;;AACA;;AAEA;;AAhBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAQO,MAAMA,gBAAN,CAAmD;AAMxDC,EAAAA,WAAW,CAACC,YAAD,EAA6BC,OAA8B,GAAG,EAA9D,EAAkE;AAAA,mDAF3D,KAE2D;AAC3E,SAAKD,YAAL,GAAoBA,YAApB;AACA,SAAKC,OAAL,GAAeA,OAAf;AACA,SAAKC,cAAL,GAAsB,EAAtB;AACA,SAAKC,qBAAL,GAA6B,KAAKA,qBAAL,CAA2BC,IAA3B,CAAgC,IAAhC,CAA7B;AACD;;AAEOC,EAAAA,mBAAmB,GAAY;AACrC,QAAIC,GAAG,GAAG,KAAV;AACA,SAAKJ,cAAL,CAAoBK,IAApB,CAAyBC,IAAI,CAACC,GAAL,EAAzB;;AACA,QAAI,KAAKP,cAAL,CAAoBQ,MAApB,IAA8B,EAAlC,EAAsC;AACpC;AACA,YAAMC,SAAS,GAAG,KAAKT,cAAL,CAAoBU,KAApB,EAAlB;AACA,YAAMC,QAAQ,GAAG,KAAKX,cAAL,CAAoB,KAAKA,cAAL,CAAoBQ,MAApB,GAA6B,CAAjD,CAAjB;AACAJ,MAAAA,GAAG,GAAIO,QAAQ,GAAGF,SAAZ,GAAyB,KAAK,IAApC;AACD;;AACD,WAAOL,GAAP;AACD;;AAEDQ,EAAAA,kBAAkB,GAAG;AACnB;AACA,WAAO,CAAC,CAAC,KAAKb,OAAL,CAAac,WAAf,IAA8B,0BAArC;AACD;;AAEOZ,EAAAA,qBAAqB,CAACa,GAAD,EAAc;AACzC,QAAI,KAAKf,OAAL,CAAagB,SAAjB,EAA4B;AAC1B,UAAI,KAAKZ,mBAAL,EAAJ,EAAgC;AAC9B,cAAMa,KAAK,GAAG,IAAIC,oBAAJ,CAAiB,+BAAjB,CAAd;AACA,aAAKnB,YAAL,CAAkBoB,SAAlB,CAA4BF,KAA5B;AACD,OAHD,MAGO;AACL,aAAKlB,YAAL,CAAkBqB,KAAlB,CAAwBL,GAAxB,EAA6BM,KAA7B,CAAmC,MAAM,CAAE,CAA3C,EADK,CACyC;AAC/C;AACF,KAPD,MAOO,IAAI,KAAKrB,OAAL,CAAasB,UAAjB,EAA6B;AAClC,WAAKvB,YAAL,CAAkBwB,MAAlB,CAAyBR,GAAzB;AACD;AACF;;AAEDS,EAAAA,QAAQ,GAAG;AACT,WAAQ,CAAC,CAAC,KAAKxB,OAAL,CAAagB,SAAf,IAA4B,CAAC,CAAC,KAAKhB,OAAL,CAAasB,UAAnD;AACD;;AAEDG,EAAAA,KAAK,GAAG;AACN,QAAI,KAAKD,QAAL,EAAJ,EAAqB;AACnB,WAAKE,IAAL;AACA,WAAK3B,YAAL,CAAkB4B,EAAlB,CAAqBC,2BAArB,EAAoC,KAAK1B,qBAAzC;AACA,WAAK2B,OAAL,GAAe,IAAf;AACD;AACF;;AAEDH,EAAAA,IAAI,GAAG;AACL,QAAI,KAAKG,OAAT,EAAkB;AAChB,WAAK9B,YAAL,CAAkB+B,GAAlB,CAAsBF,2BAAtB,EAAqC,KAAK1B,qBAA1C;AACA,WAAKD,cAAL,GAAsB,EAAtB;AACA,WAAK4B,OAAL,GAAe,KAAf;AACD;AACF;;AAEDE,EAAAA,SAAS,GAAG;AACV,WAAO,KAAKF,OAAZ;AACD;;AAjEuD","sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nimport { TokenManager, EVENT_EXPIRED } from '../TokenManager';\nimport { AuthSdkError } from '../errors';\nimport { ServiceInterface, ServiceManagerOptions } from '../types';\nimport { isBrowser } from '../features';\n\nexport class AutoRenewService implements ServiceInterface {\n private tokenManager: TokenManager;\n private options: ServiceManagerOptions;\n private renewTimeQueue: Array<number>;\n private started = false;\n\n constructor(tokenManager: TokenManager, options: ServiceManagerOptions = {}) {\n this.tokenManager = tokenManager;\n this.options = options;\n this.renewTimeQueue = [];\n this.onTokenExpiredHandler = this.onTokenExpiredHandler.bind(this);\n }\n \n private shouldThrottleRenew(): boolean {\n let res = false;\n this.renewTimeQueue.push(Date.now());\n if (this.renewTimeQueue.length >= 10) {\n // get and remove first item from queue\n const firstTime = this.renewTimeQueue.shift() as number;\n const lastTime = this.renewTimeQueue[this.renewTimeQueue.length - 1];\n res = (lastTime - firstTime) < 30 * 1000;\n }\n return res;\n }\n\n requiresLeadership() {\n // If tokens sync storage is enabled, handle tokens expiration only in 1 leader tab\n return !!this.options.syncStorage && isBrowser();\n }\n\n private onTokenExpiredHandler(key: string) {\n if (this.options.autoRenew) {\n if (this.shouldThrottleRenew()) {\n const error = new AuthSdkError('Too many token renew requests');\n this.tokenManager.emitError(error);\n } else {\n this.tokenManager.renew(key).catch(() => {}); // Renew errors will emit an \"error\" event \n }\n } else if (this.options.autoRemove) {\n this.tokenManager.remove(key);\n }\n }\n\n canStart() {\n return (!!this.options.autoRenew || !!this.options.autoRemove);\n }\n\n start() {\n if (this.canStart()) {\n this.stop();\n this.tokenManager.on(EVENT_EXPIRED, this.onTokenExpiredHandler);\n this.started = true;\n }\n }\n\n stop() {\n if (this.started) {\n this.tokenManager.off(EVENT_EXPIRED, this.onTokenExpiredHandler);\n this.renewTimeQueue = [];\n this.started = false;\n }\n }\n\n isStarted() {\n return this.started;\n }\n}\n"],"file":"AutoRenewService.js"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.SyncStorageService = void 0;
|
|
6
|
+
|
|
7
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
8
|
+
|
|
9
|
+
var _features = require("../features");
|
|
10
|
+
|
|
11
|
+
/*!
|
|
12
|
+
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
13
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
14
|
+
*
|
|
15
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
16
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
18
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
+
*
|
|
20
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/* global window */
|
|
24
|
+
class SyncStorageService {
|
|
25
|
+
constructor(tokenManager, options = {}) {
|
|
26
|
+
(0, _defineProperty2.default)(this, "started", false);
|
|
27
|
+
this.tokenManager = tokenManager;
|
|
28
|
+
this.options = options;
|
|
29
|
+
this.storageListener = this.storageListener.bind(this);
|
|
30
|
+
} // Sync authState cross multiple tabs when localStorage is used as the storageProvider
|
|
31
|
+
// A StorageEvent is sent to a window when a storage area it has access to is changed
|
|
32
|
+
// within the context of another document.
|
|
33
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
storageListener({
|
|
37
|
+
key,
|
|
38
|
+
newValue,
|
|
39
|
+
oldValue
|
|
40
|
+
}) {
|
|
41
|
+
const opts = this.tokenManager.getOptions();
|
|
42
|
+
|
|
43
|
+
const handleCrossTabsStorageChange = () => {
|
|
44
|
+
this.tokenManager.resetExpireEventTimeoutAll();
|
|
45
|
+
this.tokenManager.emitEventsForCrossTabsStorageUpdate(newValue, oldValue);
|
|
46
|
+
}; // Skip if:
|
|
47
|
+
// not from localStorage.clear (event.key is null)
|
|
48
|
+
// event.key is not the storageKey
|
|
49
|
+
// oldValue === newValue
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
if (key && (key !== opts.storageKey || newValue === oldValue)) {
|
|
53
|
+
return;
|
|
54
|
+
} // LocalStorage cross tabs update is not synced in IE, set a 1s timer by default to read latest value
|
|
55
|
+
// https://stackoverflow.com/questions/24077117/localstorage-in-win8-1-ie11-does-not-synchronize
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
this.syncTimeout = setTimeout(() => handleCrossTabsStorageChange(), opts._storageEventDelay);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
requiresLeadership() {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
isStarted() {
|
|
66
|
+
return this.started;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
canStart() {
|
|
70
|
+
return !!this.options.syncStorage && (0, _features.isBrowser)();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
start() {
|
|
74
|
+
if (this.canStart()) {
|
|
75
|
+
this.stop();
|
|
76
|
+
window.addEventListener('storage', this.storageListener);
|
|
77
|
+
this.started = true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
stop() {
|
|
82
|
+
if (this.started) {
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
84
|
+
window.removeEventListener('storage', this.storageListener);
|
|
85
|
+
clearTimeout(this.syncTimeout);
|
|
86
|
+
this.started = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
exports.SyncStorageService = SyncStorageService;
|
|
93
|
+
//# sourceMappingURL=SyncStorageService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../lib/services/SyncStorageService.ts"],"names":["SyncStorageService","constructor","tokenManager","options","storageListener","bind","key","newValue","oldValue","opts","getOptions","handleCrossTabsStorageChange","resetExpireEventTimeoutAll","emitEventsForCrossTabsStorageUpdate","storageKey","syncTimeout","setTimeout","_storageEventDelay","requiresLeadership","isStarted","started","canStart","syncStorage","start","stop","window","addEventListener","removeEventListener","clearTimeout"],"mappings":";;;;;;;;AAeA;;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AAMO,MAAMA,kBAAN,CAAqD;AAM1DC,EAAAA,WAAW,CAACC,YAAD,EAA6BC,OAA8B,GAAG,EAA9D,EAAkE;AAAA,mDAF3D,KAE2D;AAC3E,SAAKD,YAAL,GAAoBA,YAApB;AACA,SAAKC,OAAL,GAAeA,OAAf;AACA,SAAKC,eAAL,GAAuB,KAAKA,eAAL,CAAqBC,IAArB,CAA0B,IAA1B,CAAvB;AACD,GAVyD,CAY1D;AACA;AACA;AACA;;;AACQD,EAAAA,eAAe,CAAC;AAAEE,IAAAA,GAAF;AAAOC,IAAAA,QAAP;AAAiBC,IAAAA;AAAjB,GAAD,EAA4C;AACjE,UAAMC,IAAI,GAAG,KAAKP,YAAL,CAAkBQ,UAAlB,EAAb;;AAEA,UAAMC,4BAA4B,GAAG,MAAM;AACzC,WAAKT,YAAL,CAAkBU,0BAAlB;AACA,WAAKV,YAAL,CAAkBW,mCAAlB,CAAsDN,QAAtD,EAAgEC,QAAhE;AACD,KAHD,CAHiE,CAQjE;AACA;AACA;AACA;;;AACA,QAAIF,GAAG,KAAKA,GAAG,KAAKG,IAAI,CAACK,UAAb,IAA2BP,QAAQ,KAAKC,QAA7C,CAAP,EAA+D;AAC7D;AACD,KAdgE,CAgBjE;AACA;;;AACA,SAAKO,WAAL,GAAmBC,UAAU,CAAC,MAAML,4BAA4B,EAAnC,EAAuCF,IAAI,CAACQ,kBAA5C,CAA7B;AACD;;AAEDC,EAAAA,kBAAkB,GAAG;AACnB,WAAO,KAAP;AACD;;AAEDC,EAAAA,SAAS,GAAG;AACV,WAAO,KAAKC,OAAZ;AACD;;AAEDC,EAAAA,QAAQ,GAAG;AACT,WAAO,CAAC,CAAC,KAAKlB,OAAL,CAAamB,WAAf,IAA8B,0BAArC;AACD;;AAEDC,EAAAA,KAAK,GAAG;AACN,QAAI,KAAKF,QAAL,EAAJ,EAAqB;AACnB,WAAKG,IAAL;AACAC,MAAAA,MAAM,CAACC,gBAAP,CAAwB,SAAxB,EAAmC,KAAKtB,eAAxC;AACA,WAAKgB,OAAL,GAAe,IAAf;AACD;AACF;;AAEDI,EAAAA,IAAI,GAAG;AACL,QAAI,KAAKJ,OAAT,EAAkB;AAChB;AACAK,MAAAA,MAAM,CAACE,mBAAP,CAA2B,SAA3B,EAAsC,KAAKvB,eAA3C;AACAwB,MAAAA,YAAY,CAAC,KAAKb,WAAN,CAAZ;AACA,WAAKK,OAAL,GAAe,KAAf;AACD;AACF;;AAhEyD","sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\n/* global window */\nimport { TokenManager } from '../TokenManager';\nimport { isBrowser } from '../features';\nimport { ServiceManagerOptions, ServiceInterface } from '../types';\n\n\nexport class SyncStorageService implements ServiceInterface {\n private tokenManager: TokenManager;\n private options: ServiceManagerOptions;\n private syncTimeout: unknown;\n private started = false;\n\n constructor(tokenManager: TokenManager, options: ServiceManagerOptions = {}) {\n this.tokenManager = tokenManager;\n this.options = options;\n this.storageListener = this.storageListener.bind(this);\n }\n\n // Sync authState cross multiple tabs when localStorage is used as the storageProvider\n // A StorageEvent is sent to a window when a storage area it has access to is changed \n // within the context of another document.\n // https://developer.mozilla.org/en-US/docs/Web/API/StorageEvent\n private storageListener({ key, newValue, oldValue }: StorageEvent) {\n const opts = this.tokenManager.getOptions();\n\n const handleCrossTabsStorageChange = () => {\n this.tokenManager.resetExpireEventTimeoutAll();\n this.tokenManager.emitEventsForCrossTabsStorageUpdate(newValue, oldValue);\n };\n\n // Skip if:\n // not from localStorage.clear (event.key is null)\n // event.key is not the storageKey\n // oldValue === newValue\n if (key && (key !== opts.storageKey || newValue === oldValue)) {\n return;\n }\n\n // LocalStorage cross tabs update is not synced in IE, set a 1s timer by default to read latest value\n // https://stackoverflow.com/questions/24077117/localstorage-in-win8-1-ie11-does-not-synchronize\n this.syncTimeout = setTimeout(() => handleCrossTabsStorageChange(), opts._storageEventDelay);\n }\n\n requiresLeadership() {\n return false;\n }\n\n isStarted() {\n return this.started;\n }\n\n canStart() {\n return !!this.options.syncStorage && isBrowser();\n }\n\n start() {\n if (this.canStart()) {\n this.stop();\n window.addEventListener('storage', this.storageListener);\n this.started = true;\n }\n }\n\n stop() {\n if (this.started) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n window.removeEventListener('storage', this.storageListener!);\n clearTimeout(this.syncTimeout as any);\n this.started = false;\n }\n }\n} "],"file":"SyncStorageService.js"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
|
4
|
+
|
|
5
|
+
var _AutoRenewService = require("./AutoRenewService");
|
|
6
|
+
|
|
7
|
+
_Object$keys(_AutoRenewService).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _AutoRenewService[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _AutoRenewService[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
var _SyncStorageService = require("./SyncStorageService");
|
|
19
|
+
|
|
20
|
+
_Object$keys(_SyncStorageService).forEach(function (key) {
|
|
21
|
+
if (key === "default" || key === "__esModule") return;
|
|
22
|
+
if (key in exports && exports[key] === _SyncStorageService[key]) return;
|
|
23
|
+
Object.defineProperty(exports, key, {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () {
|
|
26
|
+
return _SyncStorageService[key];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../lib/services/index.ts"],"names":[],"mappings":";;;;AAaA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * \n * See the License for the specific language governing permissions and limitations under the License.\n */\n\n\nexport * from './AutoRenewService';\nexport * from './SyncStorageService';\n"],"file":"index.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"Service.js"}
|
package/cjs/types/index.js
CHANGED
|
@@ -171,6 +171,19 @@ _Object$keys(_TokenManager).forEach(function (key) {
|
|
|
171
171
|
});
|
|
172
172
|
});
|
|
173
173
|
|
|
174
|
+
var _Service = require("./Service");
|
|
175
|
+
|
|
176
|
+
_Object$keys(_Service).forEach(function (key) {
|
|
177
|
+
if (key === "default" || key === "__esModule") return;
|
|
178
|
+
if (key in exports && exports[key] === _Service[key]) return;
|
|
179
|
+
Object.defineProperty(exports, key, {
|
|
180
|
+
enumerable: true,
|
|
181
|
+
get: function () {
|
|
182
|
+
return _Service[key];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
174
187
|
var _UserClaims = require("./UserClaims");
|
|
175
188
|
|
|
176
189
|
_Object$keys(_UserClaims).forEach(function (key) {
|
package/cjs/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../lib/types/index.ts"],"names":[],"mappings":";;;;AAYA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport * from './api';\nexport * from './AuthState';\nexport * from './EventEmitter';\nexport * from './Transaction';\nexport * from './Cookies';\nexport * from './http';\nexport * from '../idx/types';\nexport * from './JWT';\nexport * from './OAuth';\nexport * from './OktaAuthOptions';\nexport * from './Storage';\nexport * from './Token';\nexport * from './TokenManager';\nexport * from './UserClaims';\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../../lib/types/index.ts"],"names":[],"mappings":";;;;AAYA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["/*!\n * Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nexport * from './api';\nexport * from './AuthState';\nexport * from './EventEmitter';\nexport * from './Transaction';\nexport * from './Cookies';\nexport * from './http';\nexport * from '../idx/types';\nexport * from './JWT';\nexport * from './OAuth';\nexport * from './OktaAuthOptions';\nexport * from './Storage';\nexport * from './Token';\nexport * from './TokenManager';\nexport * from './Service';\nexport * from './UserClaims';\n"],"file":"index.js"}
|