@okta/okta-auth-js 6.1.0 → 6.3.1

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.
Files changed (170) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +53 -23
  3. package/cjs/AuthStateManager.js +14 -7
  4. package/cjs/AuthStateManager.js.map +1 -1
  5. package/cjs/OktaAuth.js +30 -14
  6. package/cjs/OktaAuth.js.map +1 -1
  7. package/cjs/OktaUserAgent.js +2 -2
  8. package/cjs/PromiseQueue.js +9 -2
  9. package/cjs/PromiseQueue.js.map +1 -1
  10. package/cjs/ServiceManager.js +195 -0
  11. package/cjs/ServiceManager.js.map +1 -0
  12. package/cjs/TokenManager.js +6 -14
  13. package/cjs/TokenManager.js.map +1 -1
  14. package/cjs/TransactionManager.js +11 -5
  15. package/cjs/TransactionManager.js.map +1 -1
  16. package/cjs/browser/browserStorage.js +31 -25
  17. package/cjs/browser/browserStorage.js.map +1 -1
  18. package/cjs/crypto/node.js +19 -13
  19. package/cjs/crypto/node.js.map +1 -1
  20. package/cjs/idx/authenticator/Authenticator.js.map +1 -1
  21. package/cjs/idx/authenticator/OktaPassword.js +12 -3
  22. package/cjs/idx/authenticator/OktaPassword.js.map +1 -1
  23. package/cjs/idx/authenticator/OktaVerifyTotp.js +9 -1
  24. package/cjs/idx/authenticator/OktaVerifyTotp.js.map +1 -1
  25. package/cjs/idx/authenticator/SecurityQuestionEnrollment.js +14 -1
  26. package/cjs/idx/authenticator/SecurityQuestionEnrollment.js.map +1 -1
  27. package/cjs/idx/authenticator/SecurityQuestionVerification.js +9 -1
  28. package/cjs/idx/authenticator/SecurityQuestionVerification.js.map +1 -1
  29. package/cjs/idx/authenticator/VerificationCodeAuthenticator.js +13 -3
  30. package/cjs/idx/authenticator/VerificationCodeAuthenticator.js.map +1 -1
  31. package/cjs/idx/authenticator/WebauthnEnrollment.js +5 -0
  32. package/cjs/idx/authenticator/WebauthnEnrollment.js.map +1 -1
  33. package/cjs/idx/authenticator/WebauthnVerification.js +5 -0
  34. package/cjs/idx/authenticator/WebauthnVerification.js.map +1 -1
  35. package/cjs/idx/authenticator/util.js +64 -0
  36. package/cjs/idx/authenticator/util.js.map +1 -0
  37. package/cjs/idx/idx-js/index.js +0 -122
  38. package/cjs/idx/idx-js/index.js.map +1 -1
  39. package/cjs/idx/idx-js/introspect.js +10 -6
  40. package/cjs/idx/idx-js/introspect.js.map +1 -1
  41. package/cjs/idx/idx-js/v1/generateIdxAction.js +17 -23
  42. package/cjs/idx/idx-js/v1/generateIdxAction.js.map +1 -1
  43. package/cjs/idx/idx-js/v1/makeIdxState.js +5 -4
  44. package/cjs/idx/idx-js/v1/makeIdxState.js.map +1 -1
  45. package/cjs/idx/introspect.js +13 -3
  46. package/cjs/idx/introspect.js.map +1 -1
  47. package/cjs/idx/proceed.js +14 -11
  48. package/cjs/idx/proceed.js.map +1 -1
  49. package/cjs/idx/remediate.js +68 -77
  50. package/cjs/idx/remediate.js.map +1 -1
  51. package/cjs/idx/remediators/AuthenticatorEnrollmentData.js +6 -2
  52. package/cjs/idx/remediators/AuthenticatorEnrollmentData.js.map +1 -1
  53. package/cjs/idx/remediators/AuthenticatorVerificationData.js +56 -15
  54. package/cjs/idx/remediators/AuthenticatorVerificationData.js.map +1 -1
  55. package/cjs/idx/remediators/Base/AuthenticatorData.js +22 -14
  56. package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
  57. package/cjs/idx/remediators/Base/Remediator.js +85 -85
  58. package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
  59. package/cjs/idx/remediators/Base/SelectAuthenticator.js +24 -15
  60. package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
  61. package/cjs/idx/remediators/Base/VerifyAuthenticator.js +15 -4
  62. package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
  63. package/cjs/idx/remediators/ChallengePoll.js +8 -1
  64. package/cjs/idx/remediators/ChallengePoll.js.map +1 -1
  65. package/cjs/idx/remediators/EnrollPoll.js +1 -1
  66. package/cjs/idx/remediators/EnrollPoll.js.map +1 -1
  67. package/cjs/idx/remediators/EnrollProfile.js +15 -9
  68. package/cjs/idx/remediators/EnrollProfile.js.map +1 -1
  69. package/cjs/idx/remediators/EnrollmentChannelData.js +0 -8
  70. package/cjs/idx/remediators/EnrollmentChannelData.js.map +1 -1
  71. package/cjs/idx/remediators/Identify.js +12 -5
  72. package/cjs/idx/remediators/Identify.js.map +1 -1
  73. package/cjs/idx/remediators/ReEnrollAuthenticator.js +9 -8
  74. package/cjs/idx/remediators/ReEnrollAuthenticator.js.map +1 -1
  75. package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js +4 -3
  76. package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
  77. package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js +0 -1
  78. package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js.map +1 -1
  79. package/cjs/idx/remediators/Skip.js +1 -8
  80. package/cjs/idx/remediators/Skip.js.map +1 -1
  81. package/cjs/idx/remediators/util.js.map +1 -1
  82. package/cjs/idx/run.js +270 -195
  83. package/cjs/idx/run.js.map +1 -1
  84. package/cjs/idx/types/idx-js.js.map +1 -1
  85. package/cjs/idx/types/index.js +37 -0
  86. package/cjs/idx/types/index.js.map +1 -1
  87. package/cjs/idx/util.js +198 -0
  88. package/cjs/idx/util.js.map +1 -0
  89. package/cjs/options/browser.js +86 -0
  90. package/cjs/options/browser.js.map +1 -0
  91. package/cjs/options/index.js +94 -0
  92. package/cjs/options/index.js.map +1 -0
  93. package/cjs/options/node.js +45 -0
  94. package/cjs/options/node.js.map +1 -0
  95. package/cjs/options.js +11 -1
  96. package/cjs/options.js.map +1 -1
  97. package/cjs/server/serverStorage.js +7 -4
  98. package/cjs/server/serverStorage.js.map +1 -1
  99. package/cjs/services/AutoRenewService.js +94 -0
  100. package/cjs/services/AutoRenewService.js.map +1 -0
  101. package/cjs/services/SyncStorageService.js +93 -0
  102. package/cjs/services/SyncStorageService.js.map +1 -0
  103. package/cjs/services/index.js +30 -0
  104. package/cjs/services/index.js.map +1 -0
  105. package/cjs/types/Service.js +2 -0
  106. package/cjs/types/Service.js.map +1 -0
  107. package/cjs/types/index.js +13 -0
  108. package/cjs/types/index.js.map +1 -1
  109. package/dist/okta-auth-js.min.js +1 -1
  110. package/dist/okta-auth-js.min.js.LICENSE.txt +0 -8
  111. package/dist/okta-auth-js.min.js.map +1 -1
  112. package/dist/okta-auth-js.umd.js +1 -1
  113. package/dist/okta-auth-js.umd.js.LICENSE.txt +1 -7
  114. package/dist/okta-auth-js.umd.js.map +1 -1
  115. package/esm/{index.js → esm.browser.js} +2144 -2975
  116. package/esm/esm.browser.js.map +1 -0
  117. package/esm/esm.node.mjs +9595 -0
  118. package/esm/esm.node.mjs.map +1 -0
  119. package/lib/AuthStateManager.d.ts +3 -3
  120. package/lib/OktaAuth.d.ts +5 -4
  121. package/lib/PromiseQueue.d.ts +6 -2
  122. package/lib/ServiceManager.d.ts +38 -0
  123. package/lib/TokenManager.d.ts +0 -1
  124. package/lib/TransactionManager.d.ts +3 -4
  125. package/lib/idx/authenticator/Authenticator.d.ts +1 -1
  126. package/lib/idx/authenticator/OktaPassword.d.ts +2 -1
  127. package/lib/idx/authenticator/OktaVerifyTotp.d.ts +1 -1
  128. package/lib/idx/authenticator/SecurityQuestionEnrollment.d.ts +3 -5
  129. package/lib/idx/authenticator/SecurityQuestionVerification.d.ts +1 -1
  130. package/lib/idx/authenticator/VerificationCodeAuthenticator.d.ts +2 -1
  131. package/lib/idx/authenticator/WebauthnEnrollment.d.ts +1 -1
  132. package/lib/idx/authenticator/WebauthnVerification.d.ts +1 -1
  133. package/lib/idx/authenticator/util.d.ts +4 -0
  134. package/lib/idx/idx-js/index.d.ts +1 -17
  135. package/lib/idx/idx-js/introspect.d.ts +2 -1
  136. package/lib/idx/idx-js/v1/generateIdxAction.d.ts +1 -1
  137. package/lib/idx/idx-js/v1/makeIdxState.d.ts +2 -2
  138. package/lib/idx/proceed.d.ts +1 -3
  139. package/lib/idx/remediate.d.ts +2 -2
  140. package/lib/idx/remediators/AuthenticatorVerificationData.d.ts +6 -5
  141. package/lib/idx/remediators/Base/AuthenticatorData.d.ts +5 -9
  142. package/lib/idx/remediators/Base/Remediator.d.ts +5 -4
  143. package/lib/idx/remediators/Base/SelectAuthenticator.d.ts +7 -9
  144. package/lib/idx/remediators/Base/VerifyAuthenticator.d.ts +2 -4
  145. package/lib/idx/remediators/ChallengePoll.d.ts +1 -0
  146. package/lib/idx/remediators/EnrollProfile.d.ts +0 -3
  147. package/lib/idx/remediators/EnrollmentChannelData.d.ts +0 -4
  148. package/lib/idx/remediators/Identify.d.ts +3 -5
  149. package/lib/idx/remediators/ReEnrollAuthenticator.d.ts +2 -5
  150. package/lib/idx/remediators/SelectAuthenticatorAuthenticate.d.ts +2 -1
  151. package/lib/idx/remediators/SelectAuthenticatorUnlockAccount.d.ts +1 -2
  152. package/lib/idx/remediators/Skip.d.ts +0 -3
  153. package/lib/idx/types/idx-js.d.ts +5 -1
  154. package/lib/idx/types/index.d.ts +7 -3
  155. package/lib/idx/util.d.ts +11 -0
  156. package/lib/options/browser.d.ts +16 -0
  157. package/lib/options/index.d.ts +14 -0
  158. package/lib/options/node.d.ts +16 -0
  159. package/lib/services/AutoRenewService.d.ts +27 -0
  160. package/lib/services/{TokenService.d.ts → SyncStorageService.d.ts} +8 -5
  161. package/lib/services/index.d.ts +13 -0
  162. package/lib/types/OktaAuthOptions.d.ts +5 -0
  163. package/lib/types/Service.d.ts +23 -0
  164. package/lib/types/Storage.d.ts +7 -5
  165. package/lib/types/api.d.ts +6 -5
  166. package/lib/types/index.d.ts +1 -0
  167. package/package.json +26 -11
  168. package/cjs/services/TokenService.js +0 -111
  169. package/cjs/services/TokenService.js.map +0 -1
  170. package/esm/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../lib/options.ts"],"names":["BROWSER_STORAGE","token","storageTypes","cache","transaction","SERVER_STORAGE","getCookieSettings","args","isHTTPS","cookieSettings","cookies","secure","sameSite","getDefaultOptions","storageUtil","browserStorage","serverStorage","storageManager","enableSharedStorage","devMode","httpRequestClient","fetchRequest","transactionManager","mergeOptions","options","buildOptions","issuer","tokenUrl","authorizeUrl","userinfoUrl","revokeUrl","logoutUrl","clientId","redirectUri","state","scopes","postLogoutRedirectUri","responseMode","responseType","pkce","useInteractionCodeFlow","transformErrorXHR","transformAuthState","restoreOriginalUri","headers","flow","codeChallenge","codeChallengeMethod","recoveryToken","activationToken","ignoreSignature","clientSecret"],"mappings":";;;;;;;;;AAcA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AArBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AAUA,MAAMA,eAAsC,GAAG;AAC7CC,EAAAA,KAAK,EAAE;AACLC,IAAAA,YAAY,EAAE,CACZ,cADY,EAEZ,gBAFY,EAGZ,QAHY;AADT,GADsC;AAQ7CC,EAAAA,KAAK,EAAE;AACLD,IAAAA,YAAY,EAAE,CACZ,cADY,EAEZ,gBAFY,EAGZ,QAHY;AADT,GARsC;AAe7CE,EAAAA,WAAW,EAAE;AACXF,IAAAA,YAAY,EAAE,CACZ,gBADY,EAEZ,cAFY,EAGZ,QAHY;AADH,GAfgC;AAsB7C,wBAAsB;AACpBA,IAAAA,YAAY,EAAE,CACZ,cADY;AADM,GAtBuB;AA2B7C,kBAAgB;AACdA,IAAAA,YAAY,EAAE,CACZ,cADY;AADA;AA3B6B,CAA/C;AAkCA,MAAMG,cAAqC,GAAG;AAC5CJ,EAAAA,KAAK,EAAE;AACLC,IAAAA,YAAY,EAAE,CACZ,QADY;AADT,GADqC;AAM5CC,EAAAA,KAAK,EAAE;AACLD,IAAAA,YAAY,EAAE,CACZ,QADY;AADT,GANqC;AAW5CE,EAAAA,WAAW,EAAE;AACXF,IAAAA,YAAY,EAAE,CACZ,QADY;AADH;AAX+B,CAA9C;;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AAEhC,IAAI,CAACgC,IAAL,KAAc,KAAd,GAAsB,KAAtB,GAA8B,IAfpB;AAe0B;AAC1CC,IAAAA,sBAAsB,EAAEjC,IAAI,CAACiC,sBAhBb;AAkBhB;AACApB,IAAAA,iBAAiB,EAAEb,IAAI,CAACa,iBAnBR;AAoBhBqB,IAAAA,iBAAiB,EAAElC,IAAI,CAACkC,iBApBR;AAqBhBC,IAAAA,kBAAkB,EAAEnC,IAAI,CAACmC,kBArBT;AAsBhBC,IAAAA,kBAAkB,EAAEpC,IAAI,CAACoC,kBAtBT;AAuBhB7B,IAAAA,WAAW,EAAEP,IAAI,CAACO,WAvBF;AAwBhB8B,IAAAA,OAAO,EAAErC,IAAI,CAACqC,OAxBE;AAyBhBzB,IAAAA,OAAO,EAAE,CAAC,CAACZ,IAAI,CAACY,OAzBA;AA0BhBF,IAAAA,cAAc,EAAEV,IAAI,CAACU,cA1BL;AA2BhBK,IAAAA,kBAAkB,EAAEf,IAAI,CAACe,kBA3BT;AA4BhBZ,IAAAA,OAAO,EAAE,6BAAcJ,iBAAiB,CAACC,IAAD,EAAO,wBAAP,CAA/B,GAAmDA,IAAI,CAACG,OA5BjD;AA6BhBmC,IAAAA,IAAI,EAAEtC,IAAI,CAACsC,IA7BK;AA8BhBC,IAAAA,aAAa,EAAEvC,IAAI,CAACuC,aA9BJ;AA+BhBC,IAAAA,mBAAmB,EAAExC,IAAI,CAACwC,mBA/BV;AAgChBC,IAAAA,aAAa,EAAEzC,IAAI,CAACyC,aAhCJ;AAiChBC,IAAAA,eAAe,EAAE1C,IAAI,CAAC0C,eAjCN;AAmChB;AACAC,IAAAA,eAAe,EAAE,CAAC,CAAC3C,IAAI,CAAC2C,eApCR;AAsChB;AACAC,IAAAA,YAAY,EAAE5C,IAAI,CAAC4C;AAvCH,GAAX,CAAP;AAyCD","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/* eslint-disable complexity */\nimport { removeTrailingSlash, warn, removeNils } from './util';\nimport { assertValidConfig } from './builderUtil';\nimport { OktaAuthOptions, StorageManagerOptions } from './types';\n\nimport fetchRequest from './fetch/fetchRequest';\nimport browserStorage from './browser/browserStorage';\nimport serverStorage from './server/serverStorage';\nimport { isBrowser, isHTTPS } from './features';\n\nconst BROWSER_STORAGE: StorageManagerOptions = {\n token: {\n storageTypes: [\n 'localStorage',\n 'sessionStorage',\n 'cookie'\n ]\n },\n cache: {\n storageTypes: [\n 'localStorage',\n 'sessionStorage',\n 'cookie'\n ]\n },\n transaction: {\n storageTypes: [\n 'sessionStorage',\n 'localStorage',\n 'cookie'\n ]\n },\n 'shared-transaction': {\n storageTypes: [\n 'localStorage'\n ]\n },\n 'original-uri': {\n storageTypes: [\n 'localStorage'\n ]\n }\n};\n\nconst SERVER_STORAGE: StorageManagerOptions = {\n token: {\n storageTypes: [\n 'memory'\n ]\n },\n cache: {\n storageTypes: [\n 'memory'\n ]\n },\n transaction: {\n storageTypes: [\n 'memory'\n ]\n }\n};\n\nfunction getCookieSettings(args: OktaAuthOptions = {}, isHTTPS: boolean) {\n // Secure cookies will be automatically used on a HTTPS connection\n // Non-secure cookies will be automatically used on a HTTP connection\n // secure option can override the automatic behavior\n var cookieSettings = args.cookies || {};\n if (typeof cookieSettings.secure === 'undefined') {\n cookieSettings.secure = isHTTPS;\n }\n if (typeof cookieSettings.sameSite === 'undefined') {\n cookieSettings.sameSite = cookieSettings.secure ? 'none' : 'lax';\n }\n\n // If secure=true, but the connection is not HTTPS, set secure=false.\n if (cookieSettings.secure && !isHTTPS) {\n // eslint-disable-next-line no-console\n warn(\n 'The current page is not being served with the HTTPS protocol.\\n' +\n 'For security reasons, we strongly recommend using HTTPS.\\n' +\n 'If you cannot use HTTPS, set \"cookies.secure\" option to false.'\n );\n cookieSettings.secure = false;\n }\n\n // Chrome >= 80 will block cookies with SameSite=None unless they are also Secure\n // If sameSite=none, but the connection is not HTTPS, set sameSite=lax.\n if (cookieSettings.sameSite === 'none' && !cookieSettings.secure) {\n cookieSettings.sameSite = 'lax';\n }\n\n return cookieSettings;\n}\n\n\nexport function getDefaultOptions(): OktaAuthOptions {\n const storageUtil = isBrowser() ? browserStorage : serverStorage;\n const storageManager = isBrowser() ? BROWSER_STORAGE : SERVER_STORAGE;\n const enableSharedStorage = isBrowser() ? true : false; // localStorage for multi-tab flows (browser only)\n return {\n devMode: false,\n httpRequestClient: fetchRequest,\n storageUtil,\n storageManager,\n transactionManager: {\n enableSharedStorage\n }\n };\n}\n\nfunction mergeOptions(options, args): OktaAuthOptions {\n return Object.assign({}, options, removeNils(args), {\n storageManager: Object.assign({}, options.storageManager, args.storageManager),\n transactionManager: Object.assign({}, options.transactionManager, args.transactionManager),\n });\n}\n\nexport function buildOptions(args: OktaAuthOptions = {}): OktaAuthOptions {\n assertValidConfig(args);\n args = mergeOptions(getDefaultOptions(), args);\n return removeNils({\n // OIDC configuration\n issuer: removeTrailingSlash(args.issuer),\n tokenUrl: removeTrailingSlash(args.tokenUrl),\n authorizeUrl: removeTrailingSlash(args.authorizeUrl),\n userinfoUrl: removeTrailingSlash(args.userinfoUrl),\n revokeUrl: removeTrailingSlash(args.revokeUrl),\n logoutUrl: removeTrailingSlash(args.logoutUrl),\n clientId: args.clientId,\n redirectUri: args.redirectUri,\n state: args.state,\n scopes: args.scopes,\n postLogoutRedirectUri: args.postLogoutRedirectUri,\n responseMode: args.responseMode,\n responseType: args.responseType,\n pkce: args.pkce === false ? false : true, // PKCE defaults to true\n useInteractionCodeFlow: args.useInteractionCodeFlow,\n\n // Internal options\n httpRequestClient: args.httpRequestClient,\n transformErrorXHR: args.transformErrorXHR,\n transformAuthState: args.transformAuthState,\n restoreOriginalUri: args.restoreOriginalUri,\n storageUtil: args.storageUtil,\n headers: args.headers,\n devMode: !!args.devMode,\n storageManager: args.storageManager,\n transactionManager: args.transactionManager,\n cookies: isBrowser() ? getCookieSettings(args, isHTTPS()) : args.cookies,\n flow: args.flow,\n codeChallenge: args.codeChallenge,\n codeChallengeMethod: args.codeChallengeMethod,\n recoveryToken: args.recoveryToken,\n activationToken: args.activationToken,\n \n // Give the developer the ability to disable token signature validation.\n ignoreSignature: !!args.ignoreSignature,\n\n // Server-side web applications\n clientSecret: args.clientSecret\n });\n}\n"],"file":"options.js"}
1
+ {"version":3,"sources":["../../lib/options.ts"],"names":["BROWSER_STORAGE","token","storageTypes","cache","transaction","SERVER_STORAGE","getCookieSettings","args","isHTTPS","cookieSettings","cookies","secure","sameSite","getDefaultOptions","storageUtil","browserStorage","inMemoryStore","serverStorage","storageManager","enableSharedStorage","devMode","httpRequestClient","fetchRequest","transactionManager","mergeOptions","options","buildOptions","issuer","tokenUrl","authorizeUrl","userinfoUrl","revokeUrl","logoutUrl","clientId","redirectUri","state","scopes","postLogoutRedirectUri","responseMode","responseType","pkce","useInteractionCodeFlow","transformErrorXHR","transformAuthState","restoreOriginalUri","headers","flow","codeChallenge","codeChallengeMethod","recoveryToken","activationToken","ignoreSignature","clientSecret"],"mappings":";;;;;;;;;AAcA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AArBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AAUA,MAAMA,eAAsC,GAAG;AAC7CC,EAAAA,KAAK,EAAE;AACLC,IAAAA,YAAY,EAAE,CACZ,cADY,EAEZ,gBAFY,EAGZ,QAHY;AADT,GADsC;AAQ7CC,EAAAA,KAAK,EAAE;AACLD,IAAAA,YAAY,EAAE,CACZ,cADY,EAEZ,gBAFY,EAGZ,QAHY;AADT,GARsC;AAe7CE,EAAAA,WAAW,EA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AAA,kBAAkB,EAAEhB,IAAI,CAACgB,kBA3BT;AA4BhBb,IAAAA,OAAO,EAAE,6BAAcJ,iBAAiB,CAACC,IAAD,EAAO,wBAAP,CAA/B,GAAmDA,IAAI,CAACG,OA5BjD;AA6BhBoC,IAAAA,IAAI,EAAEvC,IAAI,CAACuC,IA7BK;AA8BhBC,IAAAA,aAAa,EAAExC,IAAI,CAACwC,aA9BJ;AA+BhBC,IAAAA,mBAAmB,EAAEzC,IAAI,CAACyC,mBA/BV;AAgChBC,IAAAA,aAAa,EAAE1C,IAAI,CAAC0C,aAhCJ;AAiChBC,IAAAA,eAAe,EAAE3C,IAAI,CAAC2C,eAjCN;AAmChB;AACAC,IAAAA,eAAe,EAAE,CAAC,CAAC5C,IAAI,CAAC4C,eApCR;AAsChB;AACAC,IAAAA,YAAY,EAAE7C,IAAI,CAAC6C;AAvCH,GAAX,CAAP;AAyCD","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/* eslint-disable complexity */\nimport { removeTrailingSlash, warn, removeNils } from './util';\nimport { assertValidConfig } from './builderUtil';\nimport { OktaAuthOptions, StorageManagerOptions } from './types';\n\nimport fetchRequest from './fetch/fetchRequest';\nimport browserStorage from './browser/browserStorage';\nimport serverStorage from './server/serverStorage';\nimport { isBrowser, isHTTPS } from './features';\n\nconst BROWSER_STORAGE: StorageManagerOptions = {\n token: {\n storageTypes: [\n 'localStorage',\n 'sessionStorage',\n 'cookie'\n ]\n },\n cache: {\n storageTypes: [\n 'localStorage',\n 'sessionStorage',\n 'cookie'\n ]\n },\n transaction: {\n storageTypes: [\n 'sessionStorage',\n 'localStorage',\n 'cookie'\n ]\n },\n 'shared-transaction': {\n storageTypes: [\n 'localStorage'\n ]\n },\n 'original-uri': {\n storageTypes: [\n 'localStorage'\n ]\n }\n};\n\nconst SERVER_STORAGE: StorageManagerOptions = {\n token: {\n storageTypes: [\n 'memory'\n ]\n },\n cache: {\n storageTypes: [\n 'memory'\n ]\n },\n transaction: {\n storageTypes: [\n 'memory'\n ]\n }\n};\n\nfunction getCookieSettings(args: OktaAuthOptions = {}, isHTTPS: boolean) {\n // Secure cookies will be automatically used on a HTTPS connection\n // Non-secure cookies will be automatically used on a HTTP connection\n // secure option can override the automatic behavior\n var cookieSettings = args.cookies || {};\n if (typeof cookieSettings.secure === 'undefined') {\n cookieSettings.secure = isHTTPS;\n }\n if (typeof cookieSettings.sameSite === 'undefined') {\n cookieSettings.sameSite = cookieSettings.secure ? 'none' : 'lax';\n }\n\n // If secure=true, but the connection is not HTTPS, set secure=false.\n if (cookieSettings.secure && !isHTTPS) {\n // eslint-disable-next-line no-console\n warn(\n 'The current page is not being served with the HTTPS protocol.\\n' +\n 'For security reasons, we strongly recommend using HTTPS.\\n' +\n 'If you cannot use HTTPS, set \"cookies.secure\" option to false.'\n );\n cookieSettings.secure = false;\n }\n\n // Chrome >= 80 will block cookies with SameSite=None unless they are also Secure\n // If sameSite=none, but the connection is not HTTPS, set sameSite=lax.\n if (cookieSettings.sameSite === 'none' && !cookieSettings.secure) {\n cookieSettings.sameSite = 'lax';\n }\n\n return cookieSettings;\n}\n\n\nexport function getDefaultOptions(): OktaAuthOptions {\n let storageUtil;\n if (isBrowser()) {\n storageUtil = Object.assign({}, browserStorage, {\n inMemoryStore: {} // create unique storage for this instance\n });\n } else {\n storageUtil = serverStorage;\n }\n const storageManager = isBrowser() ? BROWSER_STORAGE : SERVER_STORAGE;\n const enableSharedStorage = isBrowser() ? true : false; // localStorage for multi-tab flows (browser only)\n return {\n devMode: false,\n httpRequestClient: fetchRequest,\n storageUtil,\n storageManager,\n transactionManager: {\n enableSharedStorage\n }\n };\n}\n\nfunction mergeOptions(options, args): OktaAuthOptions {\n return Object.assign({}, options, removeNils(args), {\n storageManager: Object.assign({}, options.storageManager, args.storageManager),\n transactionManager: Object.assign({}, options.transactionManager, args.transactionManager),\n });\n}\n\nexport function buildOptions(args: OktaAuthOptions = {}): OktaAuthOptions {\n assertValidConfig(args);\n args = mergeOptions(getDefaultOptions(), args);\n return removeNils({\n // OIDC configuration\n issuer: removeTrailingSlash(args.issuer),\n tokenUrl: removeTrailingSlash(args.tokenUrl),\n authorizeUrl: removeTrailingSlash(args.authorizeUrl),\n userinfoUrl: removeTrailingSlash(args.userinfoUrl),\n revokeUrl: removeTrailingSlash(args.revokeUrl),\n logoutUrl: removeTrailingSlash(args.logoutUrl),\n clientId: args.clientId,\n redirectUri: args.redirectUri,\n state: args.state,\n scopes: args.scopes,\n postLogoutRedirectUri: args.postLogoutRedirectUri,\n responseMode: args.responseMode,\n responseType: args.responseType,\n pkce: args.pkce === false ? false : true, // PKCE defaults to true\n useInteractionCodeFlow: args.useInteractionCodeFlow,\n\n // Internal options\n httpRequestClient: args.httpRequestClient,\n transformErrorXHR: args.transformErrorXHR,\n transformAuthState: args.transformAuthState,\n restoreOriginalUri: args.restoreOriginalUri,\n storageUtil: args.storageUtil,\n headers: args.headers,\n devMode: !!args.devMode,\n storageManager: args.storageManager,\n transactionManager: args.transactionManager,\n cookies: isBrowser() ? getCookieSettings(args, isHTTPS()) : args.cookies,\n flow: args.flow,\n codeChallenge: args.codeChallenge,\n codeChallengeMethod: args.codeChallengeMethod,\n recoveryToken: args.recoveryToken,\n activationToken: args.activationToken,\n \n // Give the developer the ability to disable token signature validation.\n ignoreSignature: !!args.ignoreSignature,\n\n // Server-side web applications\n clientSecret: args.clientSecret\n });\n}\n"],"file":"options.js"}
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
+
3
5
  exports.default = void 0;
4
6
 
7
+ var _nodeCache = _interopRequireDefault(require("node-cache"));
8
+
5
9
  var _errors = require("../errors");
6
10
 
7
11
  /*!
@@ -16,12 +20,11 @@ var _errors = require("../errors");
16
20
  * See the License for the specific language governing permissions and limitations under the License.
17
21
  *
18
22
  */
23
+ // @ts-ignore
24
+ // Do not use this type in code, so it won't be emitted in the declaration output
19
25
  // eslint-disable-next-line import/no-commonjs
20
- const NodeCache = require('node-cache'); // commonJS module cannot be imported without esModuleInterop
21
26
  // this is a SHARED memory storage to support a stateless http server
22
-
23
-
24
- const sharedStorage = typeof NodeCache === 'function' ? new NodeCache() : null;
27
+ const sharedStorage = typeof _nodeCache.default === 'function' ? new _nodeCache.default() : null;
25
28
 
26
29
  class ServerCookies {
27
30
  // NodeCache
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../lib/server/serverStorage.ts"],"names":["NodeCache","require","sharedStorage","ServerCookies","constructor","nodeCache","set","name","value","expiresAt","Date","parse","ttl","now","get","delete","del","ServerStorage","storage","testStorageType","storageType","supported","getStorageByType","storageProvider","getStorage","AuthSdkError","findStorageType","getHttpCache","getItem","setItem","key"],"mappings":";;;;AAcA;;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA,MAAMA,SAAS,GAAGC,OAAO,CAAC,YAAD,CAAzB,C,CAAyC;AAEzC;;;AACA,MAAMC,aAAa,GAAG,OAAOF,SAAP,KAAqB,UAArB,GAAkC,IAAIA,SAAJ,EAAlC,GAAoD,IAA1E;;AAEA,MAAMG,aAAN,CAAuC;AACrB;AAEhBC,EAAAA,WAAW,CAACC,SAAD,EAAY;AACrB,SAAKA,SAAL,GAAiBA,SAAjB;AACD;;AAEDC,EAAAA,GAAG,CAACC,IAAD,EAAeC,KAAf,EAA8BC,SAA9B,EAAyD;AAC1D;AACA,QAAI,CAAC,CAAEC,IAAI,CAACC,KAAL,CAAWF,SAAX,CAA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AACD,GAnCwC,CAqCzC;;;AACAC,EAAAA,YAAY,GAAG;AACb,WAAO,IAAP,CADa,CACA;AACd,GAxCwC,CA0CzC;;;AACAH,EAAAA,UAAU,GAAkB;AAC1B,WAAO;AACLI,MAAAA,OAAO,EAAE,KAAKvB,SAAL,CAAeS,GADnB;AAELe,MAAAA,OAAO,EAAE,CAACC,GAAD,EAAMtB,KAAN,KAAgB;AACvB,aAAKH,SAAL,CAAeC,GAAf,CAAmBwB,GAAnB,EAAwBtB,KAAxB,EAA+B,0BAA/B;AACD;AAJI,KAAP;AAMD;;AAlDwC;;eAqD5B,IAAIS,aAAJ,CAAkBf,aAAlB,C","sourcesContent":["/*!\n * Copyright (c) 2018-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 { SimpleStorage, StorageType, StorageUtil, Cookies } from '../types';\nimport { AuthSdkError } from '../errors';\n// eslint-disable-next-line import/no-commonjs\nconst NodeCache = require('node-cache'); // commonJS module cannot be imported without esModuleInterop\n\n// this is a SHARED memory storage to support a stateless http server\nconst sharedStorage = typeof NodeCache === 'function' ? new NodeCache() : null;\n\nclass ServerCookies implements Cookies {\n nodeCache: any; // NodeCache\n \n constructor(nodeCache) {\n this.nodeCache = nodeCache;\n }\n\n set(name: string, value: string, expiresAt: string): string {\n // eslint-disable-next-line no-extra-boolean-cast\n if (!!(Date.parse(expiresAt))) {\n // Time to expiration in seconds\n var ttl = (Date.parse(expiresAt) - Date.now()) / 1000;\n this.nodeCache.set(name, value, ttl);\n } else {\n this.nodeCache.set(name, value);\n }\n\n return this.get(name);\n }\n\n get(name): string {\n return this.nodeCache.get(name);\n }\n\n delete(name) {\n return this.nodeCache.del(name);\n }\n}\n// Building this as an object allows us to mock the functions in our tests\nclass ServerStorage implements StorageUtil {\n nodeCache: any; // NodeCache\n storage: Cookies;\n constructor(nodeCache) {\n this.nodeCache = nodeCache;\n this.storage = new ServerCookies(nodeCache);\n }\n\n testStorageType(storageType: StorageType): boolean {\n var supported = false;\n switch (storageType) {\n case 'memory':\n supported = true;\n break;\n default:\n break;\n }\n return supported;\n }\n\n getStorageByType(storageType: StorageType): SimpleStorage {\n let storageProvider;\n switch (storageType) {\n case 'memory':\n storageProvider = this.getStorage();\n break;\n default:\n throw new AuthSdkError(`Unrecognized storage option: ${storageType}`);\n break;\n }\n return storageProvider;\n }\n\n findStorageType(): StorageType {\n return 'memory';\n }\n\n // will be removed in next version. OKTA-362589\n getHttpCache() {\n return null; // stubbed in server.js\n }\n\n // shared in-memory using node cache\n getStorage(): SimpleStorage {\n return {\n getItem: this.nodeCache.get,\n setItem: (key, value) => {\n this.nodeCache.set(key, value, '2200-01-01T00:00:00.000Z');\n }\n };\n }\n}\n\nexport default new ServerStorage(sharedStorage);\n"],"file":"serverStorage.js"}
1
+ {"version":3,"sources":["../../../lib/server/serverStorage.ts"],"names":["sharedStorage","NodeCache","ServerCookies","constructor","nodeCache","set","name","value","expiresAt","Date","parse","ttl","now","get","delete","del","ServerStorage","storage","testStorageType","storageType","supported","getStorageByType","storageProvider","getStorage","AuthSdkError","findStorageType","getHttpCache","getItem","setItem","key"],"mappings":";;;;;;AAeA;;AAEA;;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAIA;AAEA;AACA,MAAMA,aAAa,GAAG,OAAOC,kBAAP,KAAqB,UAArB,GAAkC,IAAIA,kBAAJ,EAAlC,GAAoD,IAA1E;;AAEA,MAAMC,aAAN,CAAuC;AACrB;AAEhBC,EAAAA,WAAW,CAACC,SAAD,EAAY;AACrB,SAAKA,SAAL,G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A;;AACF;AACE,cAAM,IAAIC,oBAAJ,CAAkB,gCAA+BL,WAAY,EAA7D,CAAN;AACA;AANJ;;AAQA,WAAOG,eAAP;AACD;;AAEDG,EAAAA,eAAe,GAAgB;AAC7B,WAAO,QAAP;AACD,GAnCwC,CAqCzC;;;AACAC,EAAAA,YAAY,GAAG;AACb,WAAO,IAAP,CADa,CACA;AACd,GAxCwC,CA0CzC;;;AACAH,EAAAA,UAAU,GAAkB;AAC1B,WAAO;AACLI,MAAAA,OAAO,EAAE,KAAKvB,SAAL,CAAeS,GADnB;AAELe,MAAAA,OAAO,EAAE,CAACC,GAAD,EAAMtB,KAAN,KAAgB;AACvB,aAAKH,SAAL,CAAeC,GAAf,CAAmBwB,GAAnB,EAAwBtB,KAAxB,EAA+B,0BAA/B;AACD;AAJI,KAAP;AAMD;;AAlDwC;;eAqD5B,IAAIS,aAAJ,CAAkBhB,aAAlB,C","sourcesContent":["/*!\n * Copyright (c) 2018-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// @ts-ignore \n// Do not use this type in code, so it won't be emitted in the declaration output\nimport NodeCache from 'node-cache';\nimport { SimpleStorage, StorageType, StorageUtil, Cookies } from '../types';\nimport { AuthSdkError } from '../errors';\n// eslint-disable-next-line import/no-commonjs\n\n// this is a SHARED memory storage to support a stateless http server\nconst sharedStorage = typeof NodeCache === 'function' ? new NodeCache() : null;\n\nclass ServerCookies implements Cookies {\n nodeCache: any; // NodeCache\n \n constructor(nodeCache) {\n this.nodeCache = nodeCache;\n }\n\n set(name: string, value: string, expiresAt: string): string {\n // eslint-disable-next-line no-extra-boolean-cast\n if (!!(Date.parse(expiresAt))) {\n // Time to expiration in seconds\n var ttl = (Date.parse(expiresAt) - Date.now()) / 1000;\n this.nodeCache.set(name, value, ttl);\n } else {\n this.nodeCache.set(name, value);\n }\n\n return this.get(name);\n }\n\n get(name): string {\n return this.nodeCache.get(name);\n }\n\n delete(name) {\n return this.nodeCache.del(name);\n }\n}\n// Building this as an object allows us to mock the functions in our tests\nclass ServerStorage implements StorageUtil {\n nodeCache: any; // NodeCache\n storage: Cookies;\n constructor(nodeCache) {\n this.nodeCache = nodeCache;\n this.storage = new ServerCookies(nodeCache);\n }\n\n testStorageType(storageType: StorageType): boolean {\n var supported = false;\n switch (storageType) {\n case 'memory':\n supported = true;\n break;\n default:\n break;\n }\n return supported;\n }\n\n getStorageByType(storageType: StorageType): SimpleStorage {\n let storageProvider;\n switch (storageType) {\n case 'memory':\n storageProvider = this.getStorage();\n break;\n default:\n throw new AuthSdkError(`Unrecognized storage option: ${storageType}`);\n break;\n }\n return storageProvider;\n }\n\n findStorageType(): StorageType {\n return 'memory';\n }\n\n // will be removed in next version. OKTA-362589\n getHttpCache() {\n return null; // stubbed in server.js\n }\n\n // shared in-memory using node cache\n getStorage(): SimpleStorage {\n return {\n getItem: this.nodeCache.get,\n setItem: (key, value) => {\n this.nodeCache.set(key, value, '2200-01-01T00:00:00.000Z');\n }\n };\n }\n}\n\nexport default new ServerStorage(sharedStorage);\n"],"file":"serverStorage.js"}
@@ -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,cA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1C;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","add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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,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=Service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"Service.js"}
@@ -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) {
@@ -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"}