@okta/okta-auth-js 7.5.0 → 7.6.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 +21 -0
- package/README.md +27 -5
- package/cjs/browser/fingerprint.js +1 -2
- package/cjs/browser/fingerprint.js.map +1 -1
- package/cjs/core/ServiceManager/browser.js +13 -6
- package/cjs/core/ServiceManager/browser.js.map +1 -1
- package/cjs/core/types/Service.js.map +1 -1
- package/cjs/core/types/api.js.map +1 -1
- package/cjs/fetch/fetchRequest.js +1 -2
- package/cjs/fetch/fetchRequest.js.map +1 -1
- package/cjs/http/OktaUserAgent.js +2 -2
- package/cjs/http/request.js +11 -5
- package/cjs/http/request.js.map +1 -1
- package/cjs/idx/IdxTransactionManager.js +1 -1
- package/cjs/idx/IdxTransactionManager.js.map +1 -1
- package/cjs/idx/authenticator/Authenticator.js.map +1 -1
- package/cjs/idx/authenticator/OktaPassword.js +17 -6
- package/cjs/idx/authenticator/OktaPassword.js.map +1 -1
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js +1 -2
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js.map +1 -1
- package/cjs/idx/authenticator/getAuthenticator.js +3 -4
- package/cjs/idx/authenticator/getAuthenticator.js.map +1 -1
- package/cjs/idx/idxState/index.js +1 -1
- package/cjs/idx/idxState/index.js.map +1 -1
- package/cjs/idx/idxState/v1/generateIdxAction.js +2 -2
- package/cjs/idx/idxState/v1/generateIdxAction.js.map +1 -1
- package/cjs/idx/idxState/v1/idxResponseParser.js +2 -4
- package/cjs/idx/idxState/v1/idxResponseParser.js.map +1 -1
- package/cjs/idx/idxState/v1/makeIdxState.js +1 -2
- package/cjs/idx/idxState/v1/makeIdxState.js.map +1 -1
- package/cjs/idx/interact.js +1 -2
- package/cjs/idx/interact.js.map +1 -1
- package/cjs/idx/poll.js +3 -5
- package/cjs/idx/poll.js.map +1 -1
- package/cjs/idx/proceed.js +1 -1
- package/cjs/idx/proceed.js.map +1 -1
- package/cjs/idx/remediators/Base/AuthenticatorData.js +1 -1
- package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
- package/cjs/idx/remediators/Base/Remediator.js +5 -7
- package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
- package/cjs/idx/remediators/Base/SelectAuthenticator.js +3 -4
- package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js +1 -2
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/EnrollPoll.js +1 -1
- package/cjs/idx/remediators/EnrollPoll.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js +2 -3
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js +2 -3
- package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js.map +1 -1
- package/cjs/idx/remediators/SelectEnrollmentChannel.js +1 -2
- package/cjs/idx/remediators/SelectEnrollmentChannel.js.map +1 -1
- package/cjs/idx/remediators/util.js +2 -4
- package/cjs/idx/remediators/util.js.map +1 -1
- package/cjs/idx/run.js +6 -10
- package/cjs/idx/run.js.map +1 -1
- package/cjs/idx/transactionMeta.js +1 -1
- package/cjs/idx/transactionMeta.js.map +1 -1
- package/cjs/idx/types/idx-js.js.map +1 -1
- package/cjs/idx/util.js +3 -6
- package/cjs/idx/util.js.map +1 -1
- package/cjs/myaccount/emailApi.js +1 -1
- package/cjs/myaccount/emailApi.js.map +1 -1
- package/cjs/myaccount/passwordApi.js +2 -2
- package/cjs/myaccount/passwordApi.js.map +1 -1
- package/cjs/myaccount/phoneApi.js +1 -1
- package/cjs/myaccount/phoneApi.js.map +1 -1
- package/cjs/myaccount/profileApi.js +2 -2
- package/cjs/myaccount/profileApi.js.map +1 -1
- package/cjs/myaccount/request.js +1 -1
- package/cjs/myaccount/request.js.map +1 -1
- package/cjs/oidc/TokenManager.js +18 -3
- package/cjs/oidc/TokenManager.js.map +1 -1
- package/cjs/oidc/TransactionManager.js +1 -1
- package/cjs/oidc/TransactionManager.js.map +1 -1
- package/cjs/oidc/getToken.js +1 -2
- package/cjs/oidc/getToken.js.map +1 -1
- package/cjs/oidc/introspect.js +3 -5
- package/cjs/oidc/introspect.js.map +1 -1
- package/cjs/oidc/mixin/index.js +18 -3
- package/cjs/oidc/mixin/index.js.map +1 -1
- package/cjs/oidc/options/OAuthOptionsConstructor.js +1 -1
- package/cjs/oidc/options/OAuthOptionsConstructor.js.map +1 -1
- package/cjs/oidc/renewTokens.js +1 -2
- package/cjs/oidc/renewTokens.js.map +1 -1
- package/cjs/oidc/types/api.js.map +1 -1
- package/cjs/oidc/util/errors.js +2 -2
- package/cjs/oidc/util/errors.js.map +1 -1
- package/cjs/oidc/util/validateClaims.js +1 -1
- package/cjs/oidc/util/validateClaims.js.map +1 -1
- package/cjs/oidc/verifyToken.js +1 -1
- package/cjs/oidc/verifyToken.js.map +1 -1
- package/cjs/services/LeaderElectionService.js +3 -6
- package/cjs/services/LeaderElectionService.js.map +1 -1
- package/cjs/services/RenewOnTabActivationService.js +64 -0
- package/cjs/services/RenewOnTabActivationService.js.map +1 -0
- package/cjs/services/SyncStorageService.js +6 -11
- package/cjs/services/SyncStorageService.js.map +1 -1
- package/cjs/services/index.js +11 -0
- package/cjs/services/index.js.map +1 -1
- package/dist/okta-auth-js.authn.min.analyzer.html +2 -2
- package/dist/okta-auth-js.authn.min.js +1 -1
- package/dist/okta-auth-js.authn.min.js.map +1 -1
- package/dist/okta-auth-js.core.min.analyzer.html +2 -2
- package/dist/okta-auth-js.core.min.js +1 -1
- package/dist/okta-auth-js.core.min.js.map +1 -1
- package/dist/okta-auth-js.idx.min.analyzer.html +2 -2
- package/dist/okta-auth-js.idx.min.js +1 -1
- package/dist/okta-auth-js.idx.min.js.map +1 -1
- package/dist/okta-auth-js.min.analyzer.html +2 -2
- package/dist/okta-auth-js.min.js +1 -1
- package/dist/okta-auth-js.min.js.map +1 -1
- package/dist/okta-auth-js.myaccount.min.analyzer.html +2 -2
- package/dist/okta-auth-js.myaccount.min.js +1 -1
- package/dist/okta-auth-js.myaccount.min.js.map +1 -1
- package/esm/browser/core/ServiceManager/browser.js +9 -2
- package/esm/browser/core/ServiceManager/browser.js.map +1 -1
- package/esm/browser/http/OktaUserAgent.js +2 -2
- package/esm/browser/http/request.js +7 -1
- package/esm/browser/http/request.js.map +1 -1
- package/esm/browser/idx/authenticator/Authenticator.js.map +1 -1
- package/esm/browser/idx/authenticator/OktaPassword.js +17 -4
- package/esm/browser/idx/authenticator/OktaPassword.js.map +1 -1
- package/esm/browser/idx/types/idx-js.js.map +1 -1
- package/esm/browser/oidc/TokenManager.js +12 -1
- package/esm/browser/oidc/TokenManager.js.map +1 -1
- package/esm/browser/oidc/introspect.js +1 -1
- package/esm/browser/oidc/introspect.js.map +1 -1
- package/esm/browser/oidc/mixin/index.js +16 -0
- package/esm/browser/oidc/mixin/index.js.map +1 -1
- package/esm/browser/oidc/options/OAuthOptionsConstructor.js +1 -1
- package/esm/browser/oidc/options/OAuthOptionsConstructor.js.map +1 -1
- package/esm/browser/oidc/util/validateClaims.js +2 -1
- package/esm/browser/oidc/util/validateClaims.js.map +1 -1
- package/esm/browser/package.json +1 -1
- package/esm/browser/services/RenewOnTabActivationService.js +67 -0
- package/esm/browser/services/RenewOnTabActivationService.js.map +1 -0
- package/esm/node/http/OktaUserAgent.js +2 -2
- package/esm/node/http/request.js +7 -1
- package/esm/node/http/request.js.map +1 -1
- package/esm/node/idx/authenticator/Authenticator.js.map +1 -1
- package/esm/node/idx/authenticator/OktaPassword.js +17 -4
- package/esm/node/idx/authenticator/OktaPassword.js.map +1 -1
- package/esm/node/idx/types/idx-js.js.map +1 -1
- package/esm/node/oidc/TokenManager.js +12 -1
- package/esm/node/oidc/TokenManager.js.map +1 -1
- package/esm/node/oidc/introspect.js +1 -1
- package/esm/node/oidc/introspect.js.map +1 -1
- package/esm/node/oidc/mixin/index.js +16 -0
- package/esm/node/oidc/mixin/index.js.map +1 -1
- package/esm/node/oidc/options/OAuthOptionsConstructor.js +1 -1
- package/esm/node/oidc/options/OAuthOptionsConstructor.js.map +1 -1
- package/esm/node/oidc/util/validateClaims.js +2 -1
- package/esm/node/oidc/util/validateClaims.js.map +1 -1
- package/esm/node/package.json +1 -1
- package/package.json +4 -6
- package/types/lib/core/types/Service.d.ts +7 -1
- package/types/lib/core/types/api.d.ts +1 -0
- package/types/lib/idx/authenticator/Authenticator.d.ts +1 -1
- package/types/lib/idx/authenticator/OktaPassword.d.ts +2 -1
- package/types/lib/idx/types/idx-js.d.ts +1 -0
- package/types/lib/oidc/types/api.d.ts +1 -0
- package/types/lib/services/RenewOnTabActivationService.d.ts +16 -0
- package/types/lib/services/index.d.ts +1 -0
- package/umd/authn.js +1 -1
- package/umd/authn.js.map +1 -1
- package/umd/core.js +1 -1
- package/umd/core.js.map +1 -1
- package/umd/default.js +1 -1
- package/umd/default.js.map +1 -1
- package/umd/idx.js +1 -1
- package/umd/idx.js.map +1 -1
- package/umd/myaccount.js +1 -1
- package/umd/myaccount.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 7.6.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#1507](https://github.com/okta/okta-auth-js/pull/1507) add: new method `getOrRenewAccessToken`
|
|
8
|
+
- [#1505](https://github.com/okta/okta-auth-js/pull/1505) add: support of `revokeSessions` param for `OktaPassword` authenticator (can be used in `reset-authenticator` remediation)
|
|
9
|
+
- [#1512](https://github.com/okta/okta-auth-js/pull/1512) add: new service `RenewOnTabActivation`
|
|
10
|
+
|
|
11
|
+
### Bug Fix
|
|
12
|
+
|
|
13
|
+
- [#1513](https://github.com/okta/okta-auth-js/pull/1513) fix: restricts `issuer` "-admin" validation to `.okta` domain
|
|
14
|
+
|
|
15
|
+
## 7.5.1
|
|
16
|
+
|
|
17
|
+
### Bug Fix
|
|
18
|
+
|
|
19
|
+
- [#1488](https://github.com/okta/okta-auth-js/pull/1488) fix: type `OktaAuthOptions` now requires `issuer`
|
|
20
|
+
- [#1482](https://github.com/okta/okta-auth-js/pull/1482) fix: idToken claim validation now accepts `aud` array
|
|
21
|
+
* Resolves [#1481](https://github.com/okta/okta-auth-js/pull/1481)
|
|
22
|
+
- [#1487](https://github.com/okta/okta-auth-js/pull/1487) fix: Handle fetch exceptions
|
|
23
|
+
|
|
3
24
|
## 7.5.0
|
|
4
25
|
|
|
5
26
|
### Bug Fix
|
package/README.md
CHANGED
|
@@ -36,14 +36,20 @@ You can learn more on the [Okta + JavaScript][lang-landing] page in our document
|
|
|
36
36
|
|
|
37
37
|
This library uses semantic versioning and follows Okta's [library version policy](https://developer.okta.com/code/library-versions/).
|
|
38
38
|
|
|
39
|
+
> :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning:<br>
|
|
40
|
+
#### :warning: Bulletin Board :warning:
|
|
41
|
+
* Review [Future of autoRenew](./docs/autoRenew-notice.md) <br>
|
|
42
|
+
* Review [End of Third-Party Cookies](https://developer.okta.com/blog/2024/02/29/third-party-cookies) <br>
|
|
43
|
+
> :warning: :warning: :warning: :warning: :warning: :warning: :warning: :warning::warning:<br>
|
|
44
|
+
|
|
39
45
|
## Release Status
|
|
40
46
|
|
|
41
|
-
:heavy_check_mark: The current stable major version series is: `
|
|
47
|
+
:heavy_check_mark: The current stable major version series is: `7.x`
|
|
42
48
|
|
|
43
49
|
| Version | Status |
|
|
44
50
|
| ------- | -------------------------------- |
|
|
45
51
|
| `7.x` | :heavy_check_mark: Stable |
|
|
46
|
-
| `6.x` | :
|
|
52
|
+
| `6.x` | :x: Retired |
|
|
47
53
|
| `5.x` | :x: Retired |
|
|
48
54
|
| `4.x` | :x: Retired |
|
|
49
55
|
| `3.x` | :x: Retired |
|
|
@@ -96,7 +102,7 @@ require('@okta/okta-auth-js/polyfill');
|
|
|
96
102
|
The built polyfill bundle is also available on our global CDN. Include the following script in your HTML file to load before any other scripts:
|
|
97
103
|
|
|
98
104
|
```html
|
|
99
|
-
<script src="https://global.oktacdn.com/okta-auth-js/7.
|
|
105
|
+
<script src="https://global.oktacdn.com/okta-auth-js/7.5.1/okta-auth-js.polyfill.js" type="text/javascript" integrity="sha384-EBFsuVdi4TGp/DwS7b+t+wA8zmWK10omkX05ZjJWQhzWuW31t7FWEGOnHQeIr8+L" crossorigin="anonymous"></script>
|
|
100
106
|
```
|
|
101
107
|
|
|
102
108
|
> :warning: The version shown in this sample may be older than the current version. We recommend using the highest version available
|
|
@@ -171,7 +177,7 @@ If you are using the JS on a web page from the browser, you can copy the `node_m
|
|
|
171
177
|
The built library bundle is also available on our global CDN. Include the following script in your HTML file to load before your application script:
|
|
172
178
|
|
|
173
179
|
```html
|
|
174
|
-
<script src="https://global.oktacdn.com/okta-auth-js/7.
|
|
180
|
+
<script src="https://global.oktacdn.com/okta-auth-js/7.5.1/okta-auth-js.min.js" type="text/javascript" integrity="sha384-6epSwnIDkI5zFNEVNjEYy3A7aSZ+C7ehmEyG8zDJZfP9Bmnxc51TK8du+2me4pjb" crossorigin="anonymous"></script>
|
|
175
181
|
```
|
|
176
182
|
|
|
177
183
|
> :warning: The version shown in this sample may be older than the current version. We recommend using the highest version available
|
|
@@ -342,7 +348,7 @@ Most applications will handle an OAuth callback using a special route/page, sepa
|
|
|
342
348
|
**It’s important that no other app logic runs until the async parseFromUrl / token manager logic is complete**
|
|
343
349
|
3. After this, continue normal app logic
|
|
344
350
|
|
|
345
|
-
```
|
|
351
|
+
```javascript
|
|
346
352
|
|
|
347
353
|
async function main() {
|
|
348
354
|
// create OktaAuth instance
|
|
@@ -843,6 +849,8 @@ services: {
|
|
|
843
849
|
autoRenew: true,
|
|
844
850
|
autoRemove: true,
|
|
845
851
|
syncStorage: true,
|
|
852
|
+
renewOnTabActivation: true,
|
|
853
|
+
tabInactivityDuration: 1800 // seconds
|
|
846
854
|
}
|
|
847
855
|
```
|
|
848
856
|
|
|
@@ -866,6 +874,15 @@ Automatically syncs tokens across browser tabs when it's supported in browser (b
|
|
|
866
874
|
|
|
867
875
|
This is accomplished by selecting a single tab to handle the network requests to refresh the tokens and broadcasting to the other tabs. This is done to avoid all tabs sending refresh requests simultaneously, which can cause rate limiting/throttling issues.
|
|
868
876
|
|
|
877
|
+
#### `renewOnTabActivation`
|
|
878
|
+
> NOTE: This service requires `autoRenew: true`
|
|
879
|
+
|
|
880
|
+
When enabled (`{ autoRenew: true, renewOnTabActivation: true }`), this service binds a handler to the [Page Visibility API](https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API) which attempts a token renew (if needed) when the tab becomes active after a (configurable) inactivity period
|
|
881
|
+
|
|
882
|
+
#### `tabInactivityDuration`
|
|
883
|
+
The amount of time, in seconds, a tab needs to be inactive for the `RenewOnTabActivation` service to attempt a token renew. Defaults to `1800` (30 mins)
|
|
884
|
+
|
|
885
|
+
|
|
869
886
|
## API Reference
|
|
870
887
|
<!-- no toc -->
|
|
871
888
|
* [start](#start)
|
|
@@ -886,6 +903,7 @@ This is accomplished by selecting a single tab to handle the network requests to
|
|
|
886
903
|
* [getUser](#getuser)
|
|
887
904
|
* [getIdToken](#getidtoken)
|
|
888
905
|
* [getAccessToken](#getaccesstoken)
|
|
906
|
+
* [getOrRenewAccessToken](#getorrenewaccesstoken)
|
|
889
907
|
* [storeTokensFromRedirect](#storetokensfromredirect)
|
|
890
908
|
* [setOriginalUri](#setoriginaluriuri)
|
|
891
909
|
* [getOriginalUri](#getoriginaluristate)
|
|
@@ -1154,6 +1172,10 @@ Returns the id token string retrieved from [authState](#authstatemanager) if it
|
|
|
1154
1172
|
|
|
1155
1173
|
Returns the access token string retrieved from [authState](#authstatemanager) if it exists.
|
|
1156
1174
|
|
|
1175
|
+
### `getOrRenewAccessToken()`
|
|
1176
|
+
|
|
1177
|
+
Returns the access token string if it exists. Returns `null` if the access token doesn't exist or a renewal cannot be completed
|
|
1178
|
+
|
|
1157
1179
|
### `storeTokensFromRedirect()`
|
|
1158
1180
|
|
|
1159
1181
|
> :hourglass: async
|
|
@@ -25,7 +25,6 @@ function fingerprint(sdk, options) {
|
|
|
25
25
|
var iframe;
|
|
26
26
|
var listener;
|
|
27
27
|
var promise = new Promise(function (resolve, reject) {
|
|
28
|
-
var _options;
|
|
29
28
|
iframe = document.createElement('iframe');
|
|
30
29
|
iframe.style.display = 'none';
|
|
31
30
|
|
|
@@ -59,7 +58,7 @@ function fingerprint(sdk, options) {
|
|
|
59
58
|
document.body.appendChild(iframe);
|
|
60
59
|
timeout = setTimeout(function () {
|
|
61
60
|
reject(new _errors.AuthSdkError('Fingerprinting timed out'));
|
|
62
|
-
},
|
|
61
|
+
}, options?.timeout || 15000);
|
|
63
62
|
});
|
|
64
63
|
return promise.finally(function () {
|
|
65
64
|
clearTimeout(timeout);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fingerprint.js","names":["fingerprint","sdk","options","isFingerprintSupported","Promise","reject","AuthSdkError","timeout","iframe","listener","promise","resolve","document","createElement","style","display","e","data","origin","getIssuerOrigin","msg","JSON","parse","err","type","source","postMessage","stringify","addListener","window","src","body","appendChild","setTimeout","finally","clearTimeout","removeListener","contains","parentElement","removeChild"],"sources":["../../../lib/browser/fingerprint.ts"],"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 { AuthSdkError } from '../errors';\nimport { isFingerprintSupported } from '../features';\nimport {\n addListener,\n removeListener\n} from '../oidc';\nimport { FingerprintOptions } from '../authn/types';\nimport { OktaAuthHttpInterface } from '../http/types';\n\nexport default function fingerprint(sdk: OktaAuthHttpInterface, options?: FingerprintOptions): Promise<string> {\n options = options || {};\n\n if (!isFingerprintSupported()) {\n return Promise.reject(new AuthSdkError('Fingerprinting is not supported on this device'));\n }\n\n var timeout;\n var iframe;\n var listener;\n var promise = new Promise(function (resolve, reject) {\n iframe = document.createElement('iframe');\n iframe.style.display = 'none';\n\n // eslint-disable-next-line complexity\n listener = function listener(e) {\n if (!e || !e.data || e.origin !== sdk.getIssuerOrigin()) {\n return;\n }\n\n try {\n var msg = JSON.parse(e.data);\n } catch (err) {\n // iframe messages should all be parsable\n // skip not parsable messages come from other sources in same origin (browser extensions)\n // TODO: add namespace flag in okta-core to distinguish messages that come from other sources\n return;\n }\n\n if (!msg) { return; }\n if (msg.type === 'FingerprintAvailable') {\n return resolve(msg.fingerprint as string);\n }\n if (msg.type === 'FingerprintServiceReady') {\n e.source.postMessage(JSON.stringify({\n type: 'GetFingerprint'\n }), e.origin);\n }\n };\n addListener(window, 'message', listener);\n\n iframe.src = sdk.getIssuerOrigin() + '/auth/services/devicefingerprint';\n document.body.appendChild(iframe);\n\n timeout = setTimeout(function() {\n reject(new AuthSdkError('Fingerprinting timed out'));\n }, options?.timeout || 15000);\n });\n\n return promise.finally(function() {\n clearTimeout(timeout);\n removeListener(window, 'message', listener);\n if (document.body.contains(iframe)) {\n iframe.parentElement.removeChild(iframe);\n }\n }) as Promise<string>;\n}\n"],"mappings":";;;AAaA;AACA;AACA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYe,SAASA,WAAW,CAACC,GAA0B,EAAEC,OAA4B,EAAmB;EAC7GA,OAAO,GAAGA,OAAO,IAAI,CAAC,CAAC;EAEvB,IAAI,CAAC,IAAAC,gCAAsB,GAAE,EAAE;IAC7B,OAAOC,OAAO,CAACC,MAAM,CAAC,IAAIC,oBAAY,CAAC,gDAAgD,CAAC,CAAC;EAC3F;EAEA,IAAIC,OAAO;EACX,IAAIC,MAAM;EACV,IAAIC,QAAQ;EACZ,IAAIC,OAAO,GAAG,IAAIN,OAAO,CAAC,UAAUO,OAAO,EAAEN,MAAM,EAAE;
|
|
1
|
+
{"version":3,"file":"fingerprint.js","names":["fingerprint","sdk","options","isFingerprintSupported","Promise","reject","AuthSdkError","timeout","iframe","listener","promise","resolve","document","createElement","style","display","e","data","origin","getIssuerOrigin","msg","JSON","parse","err","type","source","postMessage","stringify","addListener","window","src","body","appendChild","setTimeout","finally","clearTimeout","removeListener","contains","parentElement","removeChild"],"sources":["../../../lib/browser/fingerprint.ts"],"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 { AuthSdkError } from '../errors';\nimport { isFingerprintSupported } from '../features';\nimport {\n addListener,\n removeListener\n} from '../oidc';\nimport { FingerprintOptions } from '../authn/types';\nimport { OktaAuthHttpInterface } from '../http/types';\n\nexport default function fingerprint(sdk: OktaAuthHttpInterface, options?: FingerprintOptions): Promise<string> {\n options = options || {};\n\n if (!isFingerprintSupported()) {\n return Promise.reject(new AuthSdkError('Fingerprinting is not supported on this device'));\n }\n\n var timeout;\n var iframe;\n var listener;\n var promise = new Promise(function (resolve, reject) {\n iframe = document.createElement('iframe');\n iframe.style.display = 'none';\n\n // eslint-disable-next-line complexity\n listener = function listener(e) {\n if (!e || !e.data || e.origin !== sdk.getIssuerOrigin()) {\n return;\n }\n\n try {\n var msg = JSON.parse(e.data);\n } catch (err) {\n // iframe messages should all be parsable\n // skip not parsable messages come from other sources in same origin (browser extensions)\n // TODO: add namespace flag in okta-core to distinguish messages that come from other sources\n return;\n }\n\n if (!msg) { return; }\n if (msg.type === 'FingerprintAvailable') {\n return resolve(msg.fingerprint as string);\n }\n if (msg.type === 'FingerprintServiceReady') {\n e.source.postMessage(JSON.stringify({\n type: 'GetFingerprint'\n }), e.origin);\n }\n };\n addListener(window, 'message', listener);\n\n iframe.src = sdk.getIssuerOrigin() + '/auth/services/devicefingerprint';\n document.body.appendChild(iframe);\n\n timeout = setTimeout(function() {\n reject(new AuthSdkError('Fingerprinting timed out'));\n }, options?.timeout || 15000);\n });\n\n return promise.finally(function() {\n clearTimeout(timeout);\n removeListener(window, 'message', listener);\n if (document.body.contains(iframe)) {\n iframe.parentElement.removeChild(iframe);\n }\n }) as Promise<string>;\n}\n"],"mappings":";;;AAaA;AACA;AACA;AAfA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAYe,SAASA,WAAW,CAACC,GAA0B,EAAEC,OAA4B,EAAmB;EAC7GA,OAAO,GAAGA,OAAO,IAAI,CAAC,CAAC;EAEvB,IAAI,CAAC,IAAAC,gCAAsB,GAAE,EAAE;IAC7B,OAAOC,OAAO,CAACC,MAAM,CAAC,IAAIC,oBAAY,CAAC,gDAAgD,CAAC,CAAC;EAC3F;EAEA,IAAIC,OAAO;EACX,IAAIC,MAAM;EACV,IAAIC,QAAQ;EACZ,IAAIC,OAAO,GAAG,IAAIN,OAAO,CAAC,UAAUO,OAAO,EAAEN,MAAM,EAAE;IACnDG,MAAM,GAAGI,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;IACzCL,MAAM,CAACM,KAAK,CAACC,OAAO,GAAG,MAAM;;IAE7B;IACAN,QAAQ,GAAG,SAASA,QAAQ,CAACO,CAAC,EAAE;MAC9B,IAAI,CAACA,CAAC,IAAI,CAACA,CAAC,CAACC,IAAI,IAAID,CAAC,CAACE,MAAM,K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AAC;AACJ;AAAC"}
|
|
@@ -20,6 +20,7 @@ var _util = require("../../util");
|
|
|
20
20
|
const AUTO_RENEW = 'autoRenew';
|
|
21
21
|
const SYNC_STORAGE = 'syncStorage';
|
|
22
22
|
const LEADER_ELECTION = 'leaderElection';
|
|
23
|
+
const RENEW_ON_TAB_ACTIVATION = 'renewOnTabActivation';
|
|
23
24
|
class ServiceManager {
|
|
24
25
|
constructor(sdk, options = {}) {
|
|
25
26
|
this.sdk = sdk;
|
|
@@ -56,8 +57,7 @@ class ServiceManager {
|
|
|
56
57
|
}
|
|
57
58
|
}
|
|
58
59
|
isLeader() {
|
|
59
|
-
|
|
60
|
-
return (_this$getService = this.getService(LEADER_ELECTION)) === null || _this$getService === void 0 ? void 0 : _this$getService.isLeader();
|
|
60
|
+
return this.getService(LEADER_ELECTION)?.isLeader();
|
|
61
61
|
}
|
|
62
62
|
isLeaderRequired() {
|
|
63
63
|
return [...this.services.values()].some(srv => srv.canStart() && srv.requiresLeadership());
|
|
@@ -95,9 +95,9 @@ class ServiceManager {
|
|
|
95
95
|
let canStart = srv.canStart() && !srv.isStarted();
|
|
96
96
|
// only start election if a leader is required
|
|
97
97
|
if (name === LEADER_ELECTION) {
|
|
98
|
-
canStart
|
|
98
|
+
canStart &&= this.isLeaderRequired();
|
|
99
99
|
} else if (srv.requiresLeadership()) {
|
|
100
|
-
canStart
|
|
100
|
+
canStart &&= this.isLeader();
|
|
101
101
|
}
|
|
102
102
|
return canStart;
|
|
103
103
|
}
|
|
@@ -121,6 +121,11 @@ class ServiceManager {
|
|
|
121
121
|
...this.options
|
|
122
122
|
});
|
|
123
123
|
break;
|
|
124
|
+
case RENEW_ON_TAB_ACTIVATION:
|
|
125
|
+
service = new _services.RenewOnTabActivationService(tokenManager, {
|
|
126
|
+
...this.options
|
|
127
|
+
});
|
|
128
|
+
break;
|
|
124
129
|
default:
|
|
125
130
|
throw new Error(`Unknown service ${name}`);
|
|
126
131
|
}
|
|
@@ -128,10 +133,12 @@ class ServiceManager {
|
|
|
128
133
|
}
|
|
129
134
|
}
|
|
130
135
|
exports.ServiceManager = ServiceManager;
|
|
131
|
-
(0, _defineProperty2.default)(ServiceManager, "knownServices", [AUTO_RENEW, SYNC_STORAGE, LEADER_ELECTION]);
|
|
136
|
+
(0, _defineProperty2.default)(ServiceManager, "knownServices", [AUTO_RENEW, SYNC_STORAGE, LEADER_ELECTION, RENEW_ON_TAB_ACTIVATION]);
|
|
132
137
|
(0, _defineProperty2.default)(ServiceManager, "defaultOptions", {
|
|
133
138
|
autoRenew: true,
|
|
134
139
|
autoRemove: true,
|
|
135
|
-
syncStorage: true
|
|
140
|
+
syncStorage: true,
|
|
141
|
+
renewOnTabActivation: true,
|
|
142
|
+
tabInactivityDuration: 1800 // 30 mins in seconds
|
|
136
143
|
});
|
|
137
144
|
//# sourceMappingURL=browser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","names":["AUTO_RENEW","SYNC_STORAGE","LEADER_ELECTION","ServiceManager","constructor","sdk","options","onLeader","bind","autoRenew","autoRemove","syncStorage","tokenManager","getOptions","electionChannelName","broadcastChannelName","Object","assign","defaultOptions","clientId","syncChannelName","removeNils","started","services","Map","knownServices","forEach","name","svc","createService","set","startServices","isLeader","getService","isLeaderRequired","values","some","srv","canStart","requiresLeadership","start","stop","stopServices","get","entries","canStartService","isStarted","service","LeaderElectionService","AutoRenewService","SyncStorageService","Error"],"sources":["../../../../lib/core/ServiceManager/browser.ts"],"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 {\n OAuthTransactionMeta,\n OAuthStorageManagerInterface,\n} from '../../oidc';\n\nimport {\n ServiceManagerInterface,\n ServiceInterface,\n ServiceManagerOptions,\n OktaAuthCoreInterface,\n OktaAuthCoreOptions\n} from '../types';\nimport { AutoRenewService
|
|
1
|
+
{"version":3,"file":"browser.js","names":["AUTO_RENEW","SYNC_STORAGE","LEADER_ELECTION","RENEW_ON_TAB_ACTIVATION","ServiceManager","constructor","sdk","options","onLeader","bind","autoRenew","autoRemove","syncStorage","tokenManager","getOptions","electionChannelName","broadcastChannelName","Object","assign","defaultOptions","clientId","syncChannelName","removeNils","started","services","Map","knownServices","forEach","name","svc","createService","set","startServices","isLeader","getService","isLeaderRequired","values","some","srv","canStart","requiresLeadership","start","stop","stopServices","get","entries","canStartService","isStarted","service","LeaderElectionService","AutoRenewService","SyncStorageService","RenewOnTabActivationService","Error","renewOnTabActivation","tabInactivityDuration"],"sources":["../../../../lib/core/ServiceManager/browser.ts"],"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 {\n OAuthTransactionMeta,\n OAuthStorageManagerInterface,\n} from '../../oidc';\n\nimport {\n ServiceManagerInterface,\n ServiceInterface,\n ServiceManagerOptions,\n OktaAuthCoreInterface,\n OktaAuthCoreOptions\n} from '../types';\nimport { AutoRenewService,\n SyncStorageService,\n LeaderElectionService,\n RenewOnTabActivationService\n} from '../../services';\nimport { removeNils } from '../../util';\n\nconst AUTO_RENEW = 'autoRenew';\nconst SYNC_STORAGE = 'syncStorage';\nconst LEADER_ELECTION = 'leaderElection';\nconst RENEW_ON_TAB_ACTIVATION = 'renewOnTabActivation';\n\nexport class ServiceManager\n<\n M extends OAuthTransactionMeta,\n S extends OAuthStorageManagerInterface<M>,\n O extends OktaAuthCoreOptions\n>\nimplements ServiceManagerInterface \n{\n private sdk: OktaAuthCoreInterface<M, S, O>;\n private options: ServiceManagerOptions;\n private services: Map<string, ServiceInterface>;\n private started: boolean;\n\n private static knownServices = [AUTO_RENEW, SYNC_STORAGE, LEADER_ELECTION, RENEW_ON_TAB_ACTIVATION];\n\n private static defaultOptions: ServiceManagerOptions = {\n autoRenew: true,\n autoRemove: true,\n syncStorage: true,\n renewOnTabActivation: true,\n tabInactivityDuration: 1800, // 30 mins in seconds\n };\n\n constructor(sdk: OktaAuthCoreInterface<M, S, O>, options: ServiceManagerOptions = {}) {\n this.sdk = sdk;\n this.onLeader = this.onLeader.bind(this);\n\n // TODO: backwards compatibility, remove in next major version - OKTA-473815\n const { autoRenew, autoRemove, syncStorage } = sdk.tokenManager.getOptions();\n options.electionChannelName = options.electionChannelName || options.broadcastChannelName;\n this.options = Object.assign({}, \n ServiceManager.defaultOptions,\n { autoRenew, autoRemove, syncStorage }, \n {\n electionChannelName: `${sdk.options.clientId}-election`,\n syncChannelName: `${sdk.options.clientId}-sync`,\n },\n removeNils(options)\n );\n\n this.started = false;\n this.services = new Map();\n\n ServiceManager.knownServices.forEach(name => {\n const svc = this.createService(name);\n if (svc) {\n this.services.set(name, svc);\n }\n });\n }\n\n private async onLeader() {\n if (this.started) {\n // Start services that requires leadership\n await this.startServices();\n }\n }\n\n isLeader() {\n return (this.getService(LEADER_ELECTION) as LeaderElectionService)?.isLeader();\n }\n\n isLeaderRequired() {\n return [...this.services.values()].some(srv => srv.canStart() && srv.requiresLeadership());\n }\n\n async start() {\n if (this.started) {\n return; // noop if services have already started\n }\n await this.startServices();\n this.started = true;\n }\n \n async stop() {\n await this.stopServices();\n this.started = false;\n }\n\n getService(name: string): ServiceInterface | undefined {\n return this.services.get(name);\n }\n\n private async startServices() {\n for (const [name, srv] of this.services.entries()) {\n if (this.canStartService(name, srv)) {\n await srv.start();\n }\n }\n }\n\n private async stopServices() {\n for (const srv of this.services.values()) {\n await srv.stop();\n }\n }\n\n // eslint-disable-next-line complexity\n private canStartService(name: string, srv: ServiceInterface): boolean {\n let canStart = srv.canStart() && !srv.isStarted();\n // only start election if a leader is required\n if (name === LEADER_ELECTION) {\n canStart &&= this.isLeaderRequired();\n } else if (srv.requiresLeadership()) {\n canStart &&= this.isLeader();\n }\n return canStart;\n }\n\n private createService(name: string): ServiceInterface {\n const tokenManager = this.sdk.tokenManager;\n\n let service: ServiceInterface;\n switch (name) {\n case LEADER_ELECTION:\n service = new LeaderElectionService({...this.options, onLeader: this.onLeader});\n break;\n case AUTO_RENEW:\n service = new AutoRenewService(tokenManager, {...this.options});\n break;\n case SYNC_STORAGE:\n service = new SyncStorageService(tokenManager, {...this.options});\n break;\n case RENEW_ON_TAB_ACTIVATION:\n service = new RenewOnTabActivationService(tokenManager, {...this.options});\n break;\n default:\n throw new Error(`Unknown service ${name}`);\n }\n return service;\n }\n\n}\n"],"mappings":";;;;;AAyBA;AAKA;AA9BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsBA,MAAMA,UAAU,GAAG,WAAW;AAC9B,MAAMC,YAAY,GAAG,aAAa;AAClC,MAAMC,eAAe,GAAG,gBAAgB;AACxC,MAAMC,uBAAuB,GAAG,sBAAsB;AAE/C,MAAMC,cAAc,CAO3B;EAgBEC,WAAW,CAACC,GAAmC,EAAEC,OAA8B,GAAG,CAAC,CAAC,EAAE;IACpF,IAAI,CAACD,GAAG,GAAGA,GAAG;IACd,IAAI,CAACE,QAAQ,GAAG,IAAI,CAACA,QAAQ,CAACC,IAAI,CAAC,IAAI,CAAC;;IAExC;IACA,MAAM;MAAEC,SAAS;MAAEC,UAAU;MAAEC;IAAY,CAAC,GAAGN,GAAG,CAACO,YAAY,CAACC,UAAU,EA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AAG,IAAIC,+BAAqB,CAAC;UAAC,GAAG,IAAI,CAAC1C,OAAO;UAAEC,QAAQ,EAAE,IAAI,CAACA;QAAQ,CAAC,CAAC;QAC/E;MACF,KAAKR,UAAU;QACbgD,OAAO,GAAG,IAAIE,0BAAgB,CAACrC,YAAY,EAAE;UAAC,GAAG,IAAI,CAACN;QAAO,CAAC,CAAC;QAC/D;MACF,KAAKN,YAAY;QACf+C,OAAO,GAAG,IAAIG,4BAAkB,CAACtC,YAAY,EAAE;UAAC,GAAG,IAAI,CAACN;QAAO,CAAC,CAAC;QACjE;MACF,KAAKJ,uBAAuB;QAC1B6C,OAAO,GAAG,IAAII,qCAA2B,CAACvC,YAAY,EAAE;UAAC,GAAG,IAAI,CAACN;QAAO,CAAC,CAAC;QAC1E;MACF;QACE,MAAM,IAAI8C,KAAK,CAAE,mBAAkBzB,IAAK,EAAC,CAAC;IAAC;IAE/C,OAAOoB,OAAO;EAChB;AAEF;AAAC;AAAA,8BApIY5C,cAAc,mBAaM,CAACJ,UAAU,EAAEC,YAAY,EAAEC,eAAe,EAAEC,uBAAuB,CAAC;AAAA,8BAbxFC,cAAc,oBAe8B;EACrDM,SAAS,EAAE,IAAI;EACfC,UAAU,EAAE,IAAI;EAChBC,WAAW,EAAE,IAAI;EACjB0C,oBAAoB,EAAE,IAAI;EAC1BC,qBAAqB,EAAE,IAAI,CAAK;AAClC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Service.js","names":[],"sources":["../../../../lib/core/types/Service.ts"],"sourcesContent":["// only add methods needed internally\nexport interface ServiceInterface {\n start(): Promise<void>;\n stop(): Promise<void>;\n isStarted(): boolean;\n canStart(): boolean;\n requiresLeadership(): boolean;\n}\n\nexport interface ServiceManagerInterface {\n isLeaderRequired(): boolean;\n isLeader(): boolean;\n start(): Promise<void>;\n stop(): Promise<void>;\n getService(name: string): ServiceInterface | undefined;\n}\n\nexport interface AutoRenewServiceOptions {\n autoRenew?: boolean;\n autoRemove?: boolean;\n}\n\nexport interface SyncStorageServiceOptions {\n syncStorage?: boolean;\n syncChannelName?: string;\n}\n\nexport interface LeaderElectionServiceOptions {\n electionChannelName?: string;\n // TODO: remove in next major version - OKTA-473815\n broadcastChannelName?: string;\n}\n\nexport type ServiceManagerOptions
|
|
1
|
+
{"version":3,"file":"Service.js","names":[],"sources":["../../../../lib/core/types/Service.ts"],"sourcesContent":["// only add methods needed internally\nexport interface ServiceInterface {\n start(): Promise<void>;\n stop(): Promise<void>;\n isStarted(): boolean;\n canStart(): boolean;\n requiresLeadership(): boolean;\n}\n\nexport interface ServiceManagerInterface {\n isLeaderRequired(): boolean;\n isLeader(): boolean;\n start(): Promise<void>;\n stop(): Promise<void>;\n getService(name: string): ServiceInterface | undefined;\n}\n\nexport interface AutoRenewServiceOptions {\n autoRenew?: boolean;\n autoRemove?: boolean;\n}\n\nexport interface SyncStorageServiceOptions {\n syncStorage?: boolean;\n syncChannelName?: string;\n}\n\nexport interface LeaderElectionServiceOptions {\n electionChannelName?: string;\n // TODO: remove in next major version - OKTA-473815\n broadcastChannelName?: string;\n}\n\ntype seconds = number;\n\nexport interface RenewOnTabActivationServiceOptions {\n renewOnTabActivation?: boolean;\n tabInactivityDuration?: seconds;\n}\n\nexport type ServiceManagerOptions =\n AutoRenewServiceOptions &\n SyncStorageServiceOptions &\n LeaderElectionServiceOptions &\n RenewOnTabActivationServiceOptions;\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","names":[],"sources":["../../../../lib/core/types/api.ts"],"sourcesContent":["import {\n OAuthStorageManagerInterface,\n OktaAuthOAuthInterface,\n OktaAuthOAuthOptions,\n PKCETransactionMeta,\n Tokens,\n TransactionManagerInterface\n} from '../../oidc/types';\n\nimport { ServiceManagerInterface, ServiceManagerOptions } from './Service';\nimport { AuthState, AuthStateManagerInterface } from './AuthState';\n\n\n// options passed to AuthJS constructor\nexport interface OktaAuthCoreOptions extends OktaAuthOAuthOptions\n{\n services?: ServiceManagerOptions;\n // eslint-disable-next-line no-use-before-define\n transformAuthState?: (oktaAuth: OktaAuthCoreInterface, authState: AuthState) => Promise<AuthState>;\n}\n\nexport type CoreStorageManagerInterface<\n M extends PKCETransactionMeta = PKCETransactionMeta\n> = OAuthStorageManagerInterface<M>;\n\n// an instance of AuthJS with OAuth and Services\nexport interface OktaAuthCoreInterface<\n M extends PKCETransactionMeta = PKCETransactionMeta,\n S extends CoreStorageManagerInterface<M> = CoreStorageManagerInterface<M>,\n O extends OktaAuthCoreOptions = OktaAuthCoreOptions,\n TM extends TransactionManagerInterface = TransactionManagerInterface\n> \nextends OktaAuthOAuthInterface<M, S, O, TM>\n{\n serviceManager: ServiceManagerInterface;\n authStateManager: AuthStateManagerInterface;\n start(): Promise<void>;\n stop(): Promise<void>;\n handleLoginRedirect(tokens?: Tokens, originalUri?: string): Promise<void>;\n handleRedirect(originalUri?: string): Promise<void>;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"api.js","names":[],"sources":["../../../../lib/core/types/api.ts"],"sourcesContent":["import {\n OAuthStorageManagerInterface,\n OktaAuthOAuthInterface,\n OktaAuthOAuthOptions,\n PKCETransactionMeta,\n Tokens,\n TransactionManagerInterface\n} from '../../oidc/types';\n\nimport { ServiceManagerInterface, ServiceManagerOptions } from './Service';\nimport { AuthState, AuthStateManagerInterface } from './AuthState';\n\n\n// options passed to AuthJS constructor\nexport interface OktaAuthCoreOptions extends OktaAuthOAuthOptions\n{\n issuer: string;\n services?: ServiceManagerOptions;\n // eslint-disable-next-line no-use-before-define\n transformAuthState?: (oktaAuth: OktaAuthCoreInterface, authState: AuthState) => Promise<AuthState>;\n}\n\nexport type CoreStorageManagerInterface<\n M extends PKCETransactionMeta = PKCETransactionMeta\n> = OAuthStorageManagerInterface<M>;\n\n// an instance of AuthJS with OAuth and Services\nexport interface OktaAuthCoreInterface<\n M extends PKCETransactionMeta = PKCETransactionMeta,\n S extends CoreStorageManagerInterface<M> = CoreStorageManagerInterface<M>,\n O extends OktaAuthCoreOptions = OktaAuthCoreOptions,\n TM extends TransactionManagerInterface = TransactionManagerInterface\n> \nextends OktaAuthOAuthInterface<M, S, O, TM>\n{\n serviceManager: ServiceManagerInterface;\n authStateManager: AuthStateManagerInterface;\n start(): Promise<void>;\n stop(): Promise<void>;\n handleLoginRedirect(tokens?: Tokens, originalUri?: string): Promise<void>;\n handleRedirect(originalUri?: string): Promise<void>;\n}\n"],"mappings":""}
|
|
@@ -80,8 +80,7 @@ function fetchRequest(method, url, args) {
|
|
|
80
80
|
return readData(response).then(data => {
|
|
81
81
|
return formatResult(status, data, response);
|
|
82
82
|
}).then(result => {
|
|
83
|
-
|
|
84
|
-
if (error || (_result$responseJSON = result.responseJSON) !== null && _result$responseJSON !== void 0 && _result$responseJSON.error) {
|
|
83
|
+
if (error || result.responseJSON?.error) {
|
|
85
84
|
// Throwing result object since error handling is done in http.js
|
|
86
85
|
throw result;
|
|
87
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchRequest.js","names":["appJsonContentTypeRegex","readData","response","headers","get","toLowerCase","indexOf","json","catch","e","error","errorSummary","text","formatResult","status","data","isObject","pair","entries","result","responseText","JSON","stringify","responseType","responseJSON","fetchRequest","method","url","args","body","contentType","test","Object","map","param","value","encodeURIComponent","join","fetch","global","crossFetch","fetchPromise","credentials","withCredentials","finally","Promise","resolve","then","ok"],"sources":["../../../lib/fetch/fetchRequest.ts"],"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\nimport crossFetch from 'cross-fetch';\nimport { FetchOptions, HttpResponse } from '../http/types';\n\n// content-type = application/json OR application/ion+json\nconst appJsonContentTypeRegex = /application\\/\\w*\\+?json/;\n\nfunction readData(response: Response): Promise<object | string> {\n if (response.headers.get('Content-Type') &&\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n response.headers.get('Content-Type')!.toLowerCase().indexOf('application/json') >= 0) {\n return response.json()\n // JSON parse can fail if response is not a valid object\n .catch(e => {\n return {\n error: e,\n errorSummary: 'Could not parse server response'\n };\n });\n } else {\n return response.text();\n }\n}\n\nfunction formatResult(status: number, data: object | string, response: Response) {\n const isObject = typeof data === 'object';\n const headers = {};\n for (const pair of (response.headers as any).entries()) {\n headers[pair[0]] = pair[1];\n }\n const result: HttpResponse = {\n responseText: isObject ? JSON.stringify(data) : data as string,\n status: status,\n headers\n };\n if (isObject) {\n result.responseType = 'json';\n result.responseJSON = data as object;\n }\n return result;\n}\n\n/* eslint-disable complexity */\nfunction fetchRequest(method: string, url: string, args: FetchOptions) {\n var body = args.data;\n var headers = args.headers || {};\n var contentType = (headers['Content-Type'] || headers['content-type'] || '');\n\n if (body && typeof body !== 'string') {\n // JSON encode body (if appropriate)\n if (appJsonContentTypeRegex.test(contentType)) {\n body = JSON.stringify(body);\n }\n else if (contentType === 'application/x-www-form-urlencoded') {\n body = Object.entries(body)\n .map( ([param, value]) => `${param}=${encodeURIComponent(value)}` )\n .join('&');\n }\n }\n\n var fetch = global.fetch || crossFetch;\n var fetchPromise = fetch(url, {\n method: method,\n headers: args.headers,\n body: body as string,\n credentials: args.withCredentials ? 'include' : 'omit'\n });\n\n if (!fetchPromise.finally) {\n fetchPromise = Promise.resolve(fetchPromise);\n }\n\n return fetchPromise.then(function(response) {\n var error = !response.ok;\n var status = response.status;\n return readData(response)\n .then(data => {\n return formatResult(status, data, response);\n })\n .then(result => {\n if (error || result.responseJSON?.error) {\n // Throwing result object since error handling is done in http.js\n throw result;\n }\n return result;\n });\n });\n}\n\nexport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,CAACY,MAAM;IAC5B,OAAOb,QAAQ,CAACC,QAAQ,CAAC,CACtB6C,IAAI,CAAChC,IAAI,IAAI;MACZ,OAAOF,YAAY,CAACC,MAAM,EAAEC,IAAI,EAAEb,QAAQ,CAAC;IAC7C,CAAC,CAAC,CACD6C,IAAI,CAAC5B,MAAM,IAAI;
|
|
1
|
+
{"version":3,"file":"fetchRequest.js","names":["appJsonContentTypeRegex","readData","response","headers","get","toLowerCase","indexOf","json","catch","e","error","errorSummary","text","formatResult","status","data","isObject","pair","entries","result","responseText","JSON","stringify","responseType","responseJSON","fetchRequest","method","url","args","body","contentType","test","Object","map","param","value","encodeURIComponent","join","fetch","global","crossFetch","fetchPromise","credentials","withCredentials","finally","Promise","resolve","then","ok"],"sources":["../../../lib/fetch/fetchRequest.ts"],"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\nimport crossFetch from 'cross-fetch';\nimport { FetchOptions, HttpResponse } from '../http/types';\n\n// content-type = application/json OR application/ion+json\nconst appJsonContentTypeRegex = /application\\/\\w*\\+?json/;\n\nfunction readData(response: Response): Promise<object | string> {\n if (response.headers.get('Content-Type') &&\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n response.headers.get('Content-Type')!.toLowerCase().indexOf('application/json') >= 0) {\n return response.json()\n // JSON parse can fail if response is not a valid object\n .catch(e => {\n return {\n error: e,\n errorSummary: 'Could not parse server response'\n };\n });\n } else {\n return response.text();\n }\n}\n\nfunction formatResult(status: number, data: object | string, response: Response) {\n const isObject = typeof data === 'object';\n const headers = {};\n for (const pair of (response.headers as any).entries()) {\n headers[pair[0]] = pair[1];\n }\n const result: HttpResponse = {\n responseText: isObject ? JSON.stringify(data) : data as string,\n status: status,\n headers\n };\n if (isObject) {\n result.responseType = 'json';\n result.responseJSON = data as object;\n }\n return result;\n}\n\n/* eslint-disable complexity */\nfunction fetchRequest(method: string, url: string, args: FetchOptions) {\n var body = args.data;\n var headers = args.headers || {};\n var contentType = (headers['Content-Type'] || headers['content-type'] || '');\n\n if (body && typeof body !== 'string') {\n // JSON encode body (if appropriate)\n if (appJsonContentTypeRegex.test(contentType)) {\n body = JSON.stringify(body);\n }\n else if (contentType === 'application/x-www-form-urlencoded') {\n body = Object.entries(body)\n .map( ([param, value]) => `${param}=${encodeURIComponent(value)}` )\n .join('&');\n }\n }\n\n var fetch = global.fetch || crossFetch;\n var fetchPromise = fetch(url, {\n method: method,\n headers: args.headers,\n body: body as string,\n credentials: args.withCredentials ? 'include' : 'omit'\n });\n\n if (!fetchPromise.finally) {\n fetchPromise = Promise.resolve(fetchPromise);\n }\n\n return fetchPromise.then(function(response) {\n var error = !response.ok;\n var status = response.status;\n return readData(response)\n .then(data => {\n return formatResult(status, data, response);\n })\n .then(result => {\n if (error || result.responseJSON?.error) {\n // Throwing result object since error handling is done in http.js\n throw result;\n }\n return result;\n });\n });\n}\n\nexport default fetchRequest;\n"],"mappings":";;;;AAYA;AAZA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA,MAAMA,uBAAuB,GAAG,yBAAyB;AAEzD,SAASC,QAAQ,CAACC,QAAkB,EAA4B;EAC9D,IAAIA,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,cAAc,CAAC;EACtC;EACAF,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,cAAc,CAAC,CAAEC,WAAW,EAAE,CAACC,OAAO,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE;IACxF,OAAOJ,QAAQ,CAACK,IAAI;IAClB;IAAA,CACCC,KA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require("../features");
|
|
|
20
20
|
class OktaUserAgent {
|
|
21
21
|
constructor() {
|
|
22
22
|
// add base sdk env
|
|
23
|
-
this.environments = [`okta-auth-js/${"7.
|
|
23
|
+
this.environments = [`okta-auth-js/${"7.6.0"}`];
|
|
24
24
|
this.maybeAddNodeEnvironment();
|
|
25
25
|
}
|
|
26
26
|
addEnvironment(env) {
|
|
@@ -32,7 +32,7 @@ class OktaUserAgent {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
getVersion() {
|
|
35
|
-
return "7.
|
|
35
|
+
return "7.6.0";
|
|
36
36
|
}
|
|
37
37
|
maybeAddNodeEnvironment() {
|
|
38
38
|
if ((0, _features.isBrowser)() || !process || !process.versions) {
|
package/cjs/http/request.js
CHANGED
|
@@ -32,8 +32,15 @@ const parseInsufficientAuthenticationError = header => {
|
|
|
32
32
|
return acc;
|
|
33
33
|
}, {});
|
|
34
34
|
};
|
|
35
|
-
const formatError = (sdk,
|
|
36
|
-
|
|
35
|
+
const formatError = (sdk, error) => {
|
|
36
|
+
if (error instanceof Error) {
|
|
37
|
+
// fetch() can throw exceptions
|
|
38
|
+
// see https://developer.mozilla.org/en-US/docs/Web/API/fetch#exceptions
|
|
39
|
+
return new _errors.AuthApiError({
|
|
40
|
+
errorSummary: error.message
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
let resp = error;
|
|
37
44
|
let err;
|
|
38
45
|
let serverErr = {};
|
|
39
46
|
if (resp.responseText && (0, _util.isString)(resp.responseText)) {
|
|
@@ -56,8 +63,7 @@ const formatError = (sdk, resp) => {
|
|
|
56
63
|
} else {
|
|
57
64
|
err = new _errors.AuthApiError(serverErr, resp);
|
|
58
65
|
}
|
|
59
|
-
if (
|
|
60
|
-
var _resp3, _resp3$headers;
|
|
66
|
+
if (resp?.status === 403 && !!resp?.headers?.['www-authenticate']) {
|
|
61
67
|
const {
|
|
62
68
|
error,
|
|
63
69
|
// eslint-disable-next-line camelcase
|
|
@@ -66,7 +72,7 @@ const formatError = (sdk, resp) => {
|
|
|
66
72
|
max_age,
|
|
67
73
|
// eslint-disable-next-line camelcase
|
|
68
74
|
acr_values
|
|
69
|
-
} = parseInsufficientAuthenticationError(
|
|
75
|
+
} = parseInsufficientAuthenticationError(resp?.headers?.['www-authenticate']);
|
|
70
76
|
if (error === 'insufficient_authentication_context') {
|
|
71
77
|
err = new _errors.AuthApiError({
|
|
72
78
|
errorSummary: error,
|
package/cjs/http/request.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","names":["parseInsufficientAuthenticationError","header","AuthSdkError","split","map","part","trim","reduce","acc","curr","replace","formatError","sdk","resp","err","serverErr","responseText","isString","JSON","parse","e","errorSummary","status","options","transformErrorXHR","clone","error","error_description","OAuthError","AuthApiError","headers","max_age","acr_values","errorCauses","httpRequest","httpRequestInterceptors","interceptor","url","method","args","saveAuthnState","accessToken","withCredentials","storageUtil","storage","httpCache","storageManager","getHttpCache","cookies","cacheResponse","cacheContents","getStorage","cachedResponse","Date","now","expiresAt","Promise","resolve","response","oktaUserAgentHeader","_oktaUserAgent","getHttpHeader","Object","assign","removeNils","ajaxOptions","data","undefined","res","httpRequestClient","then","Array","isArray","forEach","item","stateToken","delete","STATE_TOKEN_KEY_NAME","set","updateStorage","Math","floor","DEFAULT_CACHE_DURATION","catch","errorCode","get","isAbsoluteUrl","getIssuerOrigin","getOptions","post","postOptions"],"sources":["../../../lib/http/request.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\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 { isString, clone, isAbsoluteUrl, removeNils } from '../util';\nimport { STATE_TOKEN_KEY_NAME, DEFAULT_CACHE_DURATION } from '../constants';\nimport {\n OktaAuthHttpInterface,\n RequestOptions,\n FetchOptions,\n RequestData,\n HttpResponse\n} from './types';\nimport { AuthApiError, OAuthError, AuthSdkError, APIError } from '../errors';\n\ntype InsufficientAuthenticationError = {\n error: string;\n // eslint-disable-next-line camelcase\n error_description: string;\n // eslint-disable-next-line camelcase\n max_age: string;\n // eslint-disable-next-line camelcase\n acr_values: string;\n};\n\nconst parseInsufficientAuthenticationError = (\n header: string\n): InsufficientAuthenticationError => {\n if (!header) {\n throw new AuthSdkError('Missing header string');\n }\n\n return header\n .split(',')\n .map(part => part.trim())\n .map(part => part.split('='))\n .reduce((acc, curr) => {\n // unwrap quotes from value\n acc[curr[0]] = curr[1].replace(/^\"(.*)\"$/, '$1');\n return acc;\n }, {}) as InsufficientAuthenticationError;\n};\n\nconst formatError = (sdk: OktaAuthHttpInterface, resp: HttpResponse): AuthApiError | OAuthError => {\n let err: AuthApiError | OAuthError;\n let serverErr: Record<string, any> = {};\n if (resp.responseText && isString(resp.responseText)) {\n try {\n serverErr = JSON.parse(resp.responseText);\n } catch (e) {\n serverErr = {\n errorSummary: 'Unknown error'\n };\n }\n }\n\n if (resp.status >= 500) {\n serverErr.errorSummary = 'Unknown error';\n }\n\n if (sdk.options.transformErrorXHR) {\n resp = sdk.options.transformErrorXHR(clone(resp));\n }\n\n if (serverErr.error && serverErr.error_description) {\n err = new OAuthError(serverErr.error, serverErr.error_description);\n } else {\n err = new AuthApiError(serverErr as APIError, resp);\n }\n\n if (resp?.status === 403 && !!resp?.headers?.['www-authenticate']) {\n const { \n error, \n // eslint-disable-next-line camelcase\n error_description,\n // eslint-disable-next-line camelcase\n max_age,\n // eslint-disable-next-line camelcase\n acr_values \n } = parseInsufficientAuthenticationError(resp?.headers?.['www-authenticate']);\n if (error === 'insufficient_authentication_context') {\n err = new AuthApiError(\n { \n errorSummary: error,\n // eslint-disable-next-line camelcase\n errorCauses: [{ errorSummary: error_description }]\n }, \n resp, \n {\n // eslint-disable-next-line camelcase\n max_age: +max_age,\n // eslint-disable-next-line camelcase\n ...(acr_values && { acr_values })\n }\n );\n }\n }\n\n return err;\n};\n\nexport function httpRequest(sdk: OktaAuthHttpInterface, options: RequestOptions): Promise<any> {\n options = options || {};\n\n if (sdk.options.httpRequestInterceptors) {\n for (const interceptor of sdk.options.httpRequestInterceptors) {\n interceptor(options);\n }\n }\n\n var url = options.url,\n method = options.method,\n args = options.args,\n saveAuthnState = options.saveAuthnState,\n accessToken = options.accessToken,\n withCredentials = options.withCredentials === true, // default value is false\n storageUtil = sdk.options.storageUtil,\n storage = storageUtil!.storage,\n httpCache = sdk.storageManager.getHttpCache(sdk.options.cookies);\n\n if (options.cacheResponse) {\n var cacheContents = httpCache.getStorage();\n var cachedResponse = cacheContents[url as string];\n if (cachedResponse && Date.now()/1000 < cachedResponse.expiresAt) {\n return Promise.resolve(cachedResponse.response);\n }\n }\n\n var oktaUserAgentHeader = sdk._oktaUserAgent.getHttpHeader();\n var headers: HeadersInit = {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json',\n ...oktaUserAgentHeader\n };\n Object.assign(headers, sdk.options.headers, options.headers);\n headers = removeNils(headers) as HeadersInit;\n\n if (accessToken && isString(accessToken)) {\n headers['Authorization'] = 'Bearer ' + accessToken;\n }\n\n var ajaxOptions: FetchOptions = {\n headers,\n data: args || undefined,\n withCredentials\n };\n\n var err, res;\n return sdk.options.httpRequestClient!(method!, url!, ajaxOptions)\n .then(function(resp) {\n res = resp.responseText;\n if (res && isString(res)) {\n res = JSON.parse(res);\n if (res && typeof res === 'object' && !res.headers) {\n if (Array.isArray(res)) {\n res.forEach(item => {\n item.headers = resp.headers;\n });\n } else {\n res.headers = resp.headers;\n }\n }\n }\n\n if (saveAuthnState) {\n if (!res.stateToken) {\n storage.delete(STATE_TOKEN_KEY_NAME);\n }\n }\n\n if (res && res.stateToken && res.expiresAt) {\n storage.set(STATE_TOKEN_KEY_NAME, res.stateToken, res.expiresAt, sdk.options.cookies!);\n }\n\n if (res && options.cacheResponse) {\n httpCache.updateStorage(url!, {\n expiresAt: Math.floor(Date.now()/1000) + DEFAULT_CACHE_DURATION,\n response: res\n });\n }\n \n return res;\n })\n .catch(function(resp) {\n err = formatError(sdk, resp);\n\n if (err.errorCode === 'E0000011') {\n storage.delete(STATE_TOKEN_KEY_NAME);\n }\n\n throw err;\n });\n}\n\nexport function get(sdk: OktaAuthHttpInterface, url: string, options?: RequestOptions) {\n url = isAbsoluteUrl(url) ? url : sdk.getIssuerOrigin() + url;\n var getOptions = {\n url: url,\n method: 'GET'\n };\n Object.assign(getOptions, options);\n return httpRequest(sdk, getOptions);\n}\n\nexport function post(sdk: OktaAuthHttpInterface, url: string, args?: RequestData, options?: RequestOptions) {\n url = isAbsoluteUrl(url) ? url : sdk.getIssuerOrigin() + url;\n var postOptions = {\n url: url,\n method: 'POST',\n args: args,\n saveAuthnState: true\n };\n Object.assign(postOptions, options);\n return httpRequest(sdk, postOptions);\n}\n"],"mappings":";;;;;AAeA;AACA;AAQA;AAxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAsBA,MAAMA,oCAAoC,GACxCC,MAAc,IACsB;EACpC,IAAI,CAACA,MAAM,EAAE;IACX,MAAM,IAAIC,oBAAY,CAAC,uBAAuB,CAAC;EACjD;EAEA,OAAOD,MAAM,CACVE,KAAK,CAAC,GAAG,CAAC,CACVC,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,IAAI,EAAE,CAAC,CACxBF,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACF,KAAK,CAAC,GAAG,CAAC,CAAC,CAC5BI,MAAM,CAAC,CAACC,GAAG,EAAEC,IAAI,KAAK;IACrB;IACAD,GAAG,CAACC,IAAI,CAAC,CAAC,CAA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GAAW,EAAEd,OAAwB,EAAE;EACrFc,GAAG,GAAG,IAAAiD,mBAAa,EAACjD,GAAG,CAAC,GAAGA,GAAG,GAAGzB,GAAG,CAAC2E,eAAe,EAAE,GAAGlD,GAAG;EAC5D,IAAImD,UAAU,GAAG;IACfnD,GAAG,EAAEA,GAAG;IACRC,MAAM,EAAE;EACV,CAAC;EACDwB,MAAM,CAACC,MAAM,CAACyB,UAAU,EAAEjE,OAAO,CAAC;EAClC,OAAOW,WAAW,CAACtB,GAAG,EAAE4E,UAAU,CAAC;AACrC;AAEO,SAASC,IAAI,CAAC7E,GAA0B,EAAEyB,GAAW,EAAEE,IAAkB,EAAEhB,OAAwB,EAAE;EAC1Gc,GAAG,GAAG,IAAAiD,mBAAa,EAACjD,GAAG,CAAC,GAAGA,GAAG,GAAGzB,GAAG,CAAC2E,eAAe,EAAE,GAAGlD,GAAG;EAC5D,IAAIqD,WAAW,GAAG;IAChBrD,GAAG,EAAEA,GAAG;IACRC,MAAM,EAAE,MAAM;IACdC,IAAI,EAAEA,IAAI;IACVC,cAAc,EAAE;EAClB,CAAC;EACDsB,MAAM,CAACC,MAAM,CAAC2B,WAAW,EAAEnE,OAAO,CAAC;EACnC,OAAOW,WAAW,CAACtB,GAAG,EAAE8E,WAAW,CAAC;AACtC"}
|
|
1
|
+
{"version":3,"file":"request.js","names":["parseInsufficientAuthenticationError","header","AuthSdkError","split","map","part","trim","reduce","acc","curr","replace","formatError","sdk","error","Error","AuthApiError","errorSummary","message","resp","err","serverErr","responseText","isString","JSON","parse","e","status","options","transformErrorXHR","clone","error_description","OAuthError","headers","max_age","acr_values","errorCauses","httpRequest","httpRequestInterceptors","interceptor","url","method","args","saveAuthnState","accessToken","withCredentials","storageUtil","storage","httpCache","storageManager","getHttpCache","cookies","cacheResponse","cacheContents","getStorage","cachedResponse","Date","now","expiresAt","Promise","resolve","response","oktaUserAgentHeader","_oktaUserAgent","getHttpHeader","Object","assign","removeNils","ajaxOptions","data","undefined","res","httpRequestClient","then","Array","isArray","forEach","item","stateToken","delete","STATE_TOKEN_KEY_NAME","set","updateStorage","Math","floor","DEFAULT_CACHE_DURATION","catch","errorCode","get","isAbsoluteUrl","getIssuerOrigin","getOptions","post","postOptions"],"sources":["../../../lib/http/request.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-non-null-assertion */\n/*!\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 { isString, clone, isAbsoluteUrl, removeNils } from '../util';\nimport { STATE_TOKEN_KEY_NAME, DEFAULT_CACHE_DURATION } from '../constants';\nimport {\n OktaAuthHttpInterface,\n RequestOptions,\n FetchOptions,\n RequestData,\n HttpResponse\n} from './types';\nimport { AuthApiError, OAuthError, AuthSdkError, APIError } from '../errors';\n\ntype InsufficientAuthenticationError = {\n error: string;\n // eslint-disable-next-line camelcase\n error_description: string;\n // eslint-disable-next-line camelcase\n max_age: string;\n // eslint-disable-next-line camelcase\n acr_values: string;\n};\n\nconst parseInsufficientAuthenticationError = (\n header: string\n): InsufficientAuthenticationError => {\n if (!header) {\n throw new AuthSdkError('Missing header string');\n }\n\n return header\n .split(',')\n .map(part => part.trim())\n .map(part => part.split('='))\n .reduce((acc, curr) => {\n // unwrap quotes from value\n acc[curr[0]] = curr[1].replace(/^\"(.*)\"$/, '$1');\n return acc;\n }, {}) as InsufficientAuthenticationError;\n};\n\nconst formatError = (sdk: OktaAuthHttpInterface, error: HttpResponse | Error): AuthApiError | OAuthError => {\n if (error instanceof Error) {\n // fetch() can throw exceptions\n // see https://developer.mozilla.org/en-US/docs/Web/API/fetch#exceptions\n return new AuthApiError({\n errorSummary: error.message,\n });\n }\n\n let resp: HttpResponse = error;\n let err: AuthApiError | OAuthError;\n let serverErr: Record<string, any> = {};\n if (resp.responseText && isString(resp.responseText)) {\n try {\n serverErr = JSON.parse(resp.responseText);\n } catch (e) {\n serverErr = {\n errorSummary: 'Unknown error'\n };\n }\n }\n\n if (resp.status >= 500) {\n serverErr.errorSummary = 'Unknown error';\n }\n\n if (sdk.options.transformErrorXHR) {\n resp = sdk.options.transformErrorXHR(clone(resp));\n }\n\n if (serverErr.error && serverErr.error_description) {\n err = new OAuthError(serverErr.error, serverErr.error_description);\n } else {\n err = new AuthApiError(serverErr as APIError, resp);\n }\n\n if (resp?.status === 403 && !!resp?.headers?.['www-authenticate']) {\n const { \n error, \n // eslint-disable-next-line camelcase\n error_description,\n // eslint-disable-next-line camelcase\n max_age,\n // eslint-disable-next-line camelcase\n acr_values \n } = parseInsufficientAuthenticationError(resp?.headers?.['www-authenticate']);\n if (error === 'insufficient_authentication_context') {\n err = new AuthApiError(\n { \n errorSummary: error,\n // eslint-disable-next-line camelcase\n errorCauses: [{ errorSummary: error_description }]\n }, \n resp, \n {\n // eslint-disable-next-line camelcase\n max_age: +max_age,\n // eslint-disable-next-line camelcase\n ...(acr_values && { acr_values })\n }\n );\n }\n }\n\n return err;\n};\n\nexport function httpRequest(sdk: OktaAuthHttpInterface, options: RequestOptions): Promise<any> {\n options = options || {};\n\n if (sdk.options.httpRequestInterceptors) {\n for (const interceptor of sdk.options.httpRequestInterceptors) {\n interceptor(options);\n }\n }\n\n var url = options.url,\n method = options.method,\n args = options.args,\n saveAuthnState = options.saveAuthnState,\n accessToken = options.accessToken,\n withCredentials = options.withCredentials === true, // default value is false\n storageUtil = sdk.options.storageUtil,\n storage = storageUtil!.storage,\n httpCache = sdk.storageManager.getHttpCache(sdk.options.cookies);\n\n if (options.cacheResponse) {\n var cacheContents = httpCache.getStorage();\n var cachedResponse = cacheContents[url as string];\n if (cachedResponse && Date.now()/1000 < cachedResponse.expiresAt) {\n return Promise.resolve(cachedResponse.response);\n }\n }\n\n var oktaUserAgentHeader = sdk._oktaUserAgent.getHttpHeader();\n var headers: HeadersInit = {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json',\n ...oktaUserAgentHeader\n };\n Object.assign(headers, sdk.options.headers, options.headers);\n headers = removeNils(headers) as HeadersInit;\n\n if (accessToken && isString(accessToken)) {\n headers['Authorization'] = 'Bearer ' + accessToken;\n }\n\n var ajaxOptions: FetchOptions = {\n headers,\n data: args || undefined,\n withCredentials\n };\n\n var err, res;\n return sdk.options.httpRequestClient!(method!, url!, ajaxOptions)\n .then(function(resp) {\n res = resp.responseText;\n if (res && isString(res)) {\n res = JSON.parse(res);\n if (res && typeof res === 'object' && !res.headers) {\n if (Array.isArray(res)) {\n res.forEach(item => {\n item.headers = resp.headers;\n });\n } else {\n res.headers = resp.headers;\n }\n }\n }\n\n if (saveAuthnState) {\n if (!res.stateToken) {\n storage.delete(STATE_TOKEN_KEY_NAME);\n }\n }\n\n if (res && res.stateToken && res.expiresAt) {\n storage.set(STATE_TOKEN_KEY_NAME, res.stateToken, res.expiresAt, sdk.options.cookies!);\n }\n\n if (res && options.cacheResponse) {\n httpCache.updateStorage(url!, {\n expiresAt: Math.floor(Date.now()/1000) + DEFAULT_CACHE_DURATION,\n response: res\n });\n }\n \n return res;\n })\n .catch(function(resp) {\n err = formatError(sdk, resp);\n\n if (err.errorCode === 'E0000011') {\n storage.delete(STATE_TOKEN_KEY_NAME);\n }\n\n throw err;\n });\n}\n\nexport function get(sdk: OktaAuthHttpInterface, url: string, options?: RequestOptions) {\n url = isAbsoluteUrl(url) ? url : sdk.getIssuerOrigin() + url;\n var getOptions = {\n url: url,\n method: 'GET'\n };\n Object.assign(getOptions, options);\n return httpRequest(sdk, getOptions);\n}\n\nexport function post(sdk: OktaAuthHttpInterface, url: string, args?: RequestData, options?: RequestOptions) {\n url = isAbsoluteUrl(url) ? url : sdk.getIssuerOrigin() + url;\n var postOptions = {\n url: url,\n method: 'POST',\n args: args,\n saveAuthnState: true\n };\n Object.assign(postOptions, options);\n return httpRequest(sdk, postOptions);\n}\n"],"mappings":";;;;;AAeA;AACA;AAQA;AAxBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAsBA,MAAMA,oCAAoC,GACxCC,MAAc,IACsB;EACpC,IAAI,CAACA,MAAM,EAAE;IACX,MAAM,IAAIC,oBAAY,CAAC,uBAAuB,CAAC;EACjD;EAEA,OAAOD,MAAM,CACVE,KAAK,CAAC,GAAG,CAAC,CACVC,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACC,IAAI,EAAE,CAAC,CACxBF,GAAG,CAACC,IAAI,IAAIA,IAAI,CAACF,KAAK,CAAC,GAAG,CAAC,CAAC,CAC5BI,MAAM,CAAC,CAACC,GAAG,EAAEC,IAAI,KAAK;IACrB;IACAD,GAAG,CAACC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAGA,IAAI,CAAC,CAAC,CAAC,CAACC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC;IAChD,OAAOF,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAC;AACV,CAAC;AAED,MAAMG,WAAW,GAAG,CAACC,GAA0B,EAAEC,KAA2B,KAAgC;EAC1G,IAAIA,KAAK,YAAYC,KAAK,EAAE;IAC1B;IACA;IACA,OAAO,IAAIC,oBAAY,CAAC;MACtBC,YAAY,EAAEH,KAAK,CAACI;IACtB,CAAC,CAAC;EACJ;EAEA,IAAIC,IAAkB,GAAGL,KAAK;EAC9B,IAAIM,GAA8B;EAClC,IAAIC,SAA8B,GAAG,CAAC,CAAC;EACvC,IAAIF,IAAI,CAACG,YAAY,IAAI,IAAAC,cAAQ,EAACJ,IAAI,CAACG,YAAY,CAAC,EAAE;IACpD,IAAI;MACFD,SAAS,GAAGG,IAAI,CAACC,KAAK,CAACN,IAAI,CAACG,YAAY,CA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G,GAAG3B,GAAG,CAAC6E,eAAe,EAAE,GAAGlD,GAAG;EAC5D,IAAIqD,WAAW,GAAG;IAChBrD,GAAG,EAAEA,GAAG;IACRC,MAAM,EAAE,MAAM;IACdC,IAAI,EAAEA,IAAI;IACVC,cAAc,EAAE;EAClB,CAAC;EACDsB,MAAM,CAACC,MAAM,CAAC2B,WAAW,EAAEjE,OAAO,CAAC;EACnC,OAAOS,WAAW,CAACxB,GAAG,EAAEgF,WAAW,CAAC;AACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IdxTransactionManager.js","names":["createIdxTransactionManager","TransactionManager","createTransactionManager","IdxTransactionManager","constructor","options","clear","clearIdxResponse","saveIdxResponse","data","saveLastResponse","storage","storageManager","getIdxResponseStorage","setStorage","loadIdxResponse","storedValue","getStorage","isRawIdxResponse","rawIdxResponse","interactionHandle","clearStorage"],"sources":["../../../lib/idx/IdxTransactionManager.ts"],"sourcesContent":["import { ClearTransactionMetaOptions, TransactionManagerOptions } from '../oidc/types';\nimport { createTransactionManager } from '../oidc/TransactionManager';\nimport { IdxTransactionMeta, IntrospectOptions } from './types';\nimport { isRawIdxResponse } from './types/idx-js';\nimport { IdxStorageManagerInterface, SavedIdxResponse } from './types/storage';\n\nexport function createIdxTransactionManager\n<\n M extends IdxTransactionMeta = IdxTransactionMeta,\n S extends IdxStorageManagerInterface<M> = IdxStorageManagerInterface<M>\n>\n()\n{\n const TransactionManager = createTransactionManager<M, S>();\n return class IdxTransactionManager extends TransactionManager\n {\n constructor(options: TransactionManagerOptions) {\n super(options);\n }\n\n clear(options: ClearTransactionMetaOptions = {}) {\n super.clear(options);\n\n if (options.clearIdxResponse !== false) {\n this.clearIdxResponse();\n }\n }\n \n saveIdxResponse(data: SavedIdxResponse): void {\n if (!this.saveLastResponse) {\n return;\n }\n const storage = this.storageManager.getIdxResponseStorage();\n if (!storage) {\n return;\n }\n storage.setStorage(data);\n }\n\n // eslint-disable-next-line complexity\n loadIdxResponse(options?: IntrospectOptions): SavedIdxResponse | null {\n if (!this.saveLastResponse) {\n return null;\n }\n const storage = this.storageManager.getIdxResponseStorage();\n if (!storage) {\n return null;\n }\n const storedValue = storage.getStorage();\n if (!storedValue || !isRawIdxResponse(storedValue.rawIdxResponse)) {\n return null;\n }\n\n if (options) {\n const { interactionHandle } = options;\n if (interactionHandle && storedValue.interactionHandle !== interactionHandle) {\n return null;\n }\n }\n\n return storedValue;\n }\n\n clearIdxResponse(): void {\n if (!this.saveLastResponse) {\n return;\n }\n const storage = this.storageManager.getIdxResponseStorage();\n storage?.clearStorage();\n }\n };\n}\n"],"mappings":";;;AACA;AAEA;AAGO,SAASA,2BAA2B,GAM3C;EACE,MAAMC,kBAAkB,GAAG,IAAAC,4CAAwB,GAAQ;EAC3D,OAAO,MAAMC,qBAAqB,SAASF,kBAAkB,CAC7D;IACEG,WAAW,CAACC,OAAkC,EAAE;MAC9C,KAAK,CAACA,OAAO,CAAC;IAChB;IAEAC,KAAK,CAACD,OAAoC,GAAG,CAAC,CAAC,EAAE;MAC/C,KAAK,CAACC,KAAK,CAACD,OAAO,CAAC;MAEpB,IAAIA,OAAO,CAACE,gBAAgB,KAAK,KAAK,EAAE;QACtC,IAAI,CAACA,gBAAgB,EAAE;MACzB;IACF;IAEAC,eAAe,CAACC,IAAsB,EAAQ;MAC5C,IAAI,CAAC,IAAI,CAACC,gBAAgB,EAAE;QAC1B;MACF;MACA,MAAMC,OAAO,GAAG,IAAI,CAACC,cAAc,CAACC,qBAAqB,EAAE;MAC3D,IAAI,CAACF,OAAO,EAAE;QACZ;MACF;MACAA,OAAO,CAACG,UAAU,CAACL,IAAI,CAAC;IAC1B;;IAEA;IACAM,eAAe,CAACV,OAA2B,EAA2B;MACpE,IAAI,CAAC,IAAI,CAACK,gBAAgB,EAAE;QAC1B,OAAO,IAAI;MACb;MACA,MAAMC,OAAO,GAAG,IAAI,CAACC,cAAc,CAACC,qBAAqB,EAAE;MAC3D,IAAI,CAACF,OAAO,EAAE;QACZ,OAAO,IAAI;MACb;MACA,MAAMK,WAAW,GAAGL,OAAO,CAACM,UAAU,EAAE;MACxC,IAAI,CAACD,WAAW,IAAI,CAAC,IAAAE,uBAAgB,EAACF,WAAW,CAACG,cAAc,CAAC,EAAE;QACjE,OAAO,IAAI;MACb;MAEA,IAAId,OAAO,EAAE;QACX,MAAM;UAAEe;QAAkB,CAAC,GAAGf,OAAO;QACrC,IAAIe,iBAAiB,IAAIJ,WAAW,CAACI,iBAAiB,KAAKA,iBAAiB,EAAE;UAC5E,OAAO,IAAI;QACb;MACF;MAEA,OAAOJ,WAAW;IACpB;IAEAT,gBAAgB,GAAS;MACvB,IAAI,CAAC,IAAI,CAACG,gBAAgB,EAAE;QAC1B;MACF;MACA,MAAMC,OAAO,GAAG,IAAI,CAACC,cAAc,CAACC,qBAAqB,EAAE;MAC3DF,OAAO,
|
|
1
|
+
{"version":3,"file":"IdxTransactionManager.js","names":["createIdxTransactionManager","TransactionManager","createTransactionManager","IdxTransactionManager","constructor","options","clear","clearIdxResponse","saveIdxResponse","data","saveLastResponse","storage","storageManager","getIdxResponseStorage","setStorage","loadIdxResponse","storedValue","getStorage","isRawIdxResponse","rawIdxResponse","interactionHandle","clearStorage"],"sources":["../../../lib/idx/IdxTransactionManager.ts"],"sourcesContent":["import { ClearTransactionMetaOptions, TransactionManagerOptions } from '../oidc/types';\nimport { createTransactionManager } from '../oidc/TransactionManager';\nimport { IdxTransactionMeta, IntrospectOptions } from './types';\nimport { isRawIdxResponse } from './types/idx-js';\nimport { IdxStorageManagerInterface, SavedIdxResponse } from './types/storage';\n\nexport function createIdxTransactionManager\n<\n M extends IdxTransactionMeta = IdxTransactionMeta,\n S extends IdxStorageManagerInterface<M> = IdxStorageManagerInterface<M>\n>\n()\n{\n const TransactionManager = createTransactionManager<M, S>();\n return class IdxTransactionManager extends TransactionManager\n {\n constructor(options: TransactionManagerOptions) {\n super(options);\n }\n\n clear(options: ClearTransactionMetaOptions = {}) {\n super.clear(options);\n\n if (options.clearIdxResponse !== false) {\n this.clearIdxResponse();\n }\n }\n \n saveIdxResponse(data: SavedIdxResponse): void {\n if (!this.saveLastResponse) {\n return;\n }\n const storage = this.storageManager.getIdxResponseStorage();\n if (!storage) {\n return;\n }\n storage.setStorage(data);\n }\n\n // eslint-disable-next-line complexity\n loadIdxResponse(options?: IntrospectOptions): SavedIdxResponse | null {\n if (!this.saveLastResponse) {\n return null;\n }\n const storage = this.storageManager.getIdxResponseStorage();\n if (!storage) {\n return null;\n }\n const storedValue = storage.getStorage();\n if (!storedValue || !isRawIdxResponse(storedValue.rawIdxResponse)) {\n return null;\n }\n\n if (options) {\n const { interactionHandle } = options;\n if (interactionHandle && storedValue.interactionHandle !== interactionHandle) {\n return null;\n }\n }\n\n return storedValue;\n }\n\n clearIdxResponse(): void {\n if (!this.saveLastResponse) {\n return;\n }\n const storage = this.storageManager.getIdxResponseStorage();\n storage?.clearStorage();\n }\n };\n}\n"],"mappings":";;;AACA;AAEA;AAGO,SAASA,2BAA2B,GAM3C;EACE,MAAMC,kBAAkB,GAAG,IAAAC,4CAAwB,GAAQ;EAC3D,OAAO,MAAMC,qBAAqB,SAASF,kBAAkB,CAC7D;IACEG,WAAW,CAACC,OAAkC,EAAE;MAC9C,KAAK,CAACA,OAAO,CAAC;IAChB;IAEAC,KAAK,CAACD,OAAoC,GAAG,CAAC,CAAC,EAAE;MAC/C,KAAK,CAACC,KAAK,CAACD,OAAO,CAAC;MAEpB,IAAIA,OAAO,CAACE,gBAAgB,KAAK,KAAK,EAAE;QACtC,IAAI,CAACA,gBAAgB,EAAE;MACzB;IACF;IAEAC,eAAe,CAACC,IAAsB,EAAQ;MAC5C,IAAI,CAAC,IAAI,CAACC,gBAAgB,EAAE;QAC1B;MACF;MACA,MAAMC,OAAO,GAAG,IAAI,CAACC,cAAc,CAACC,qBAAqB,EAAE;MAC3D,IAAI,CAACF,OAAO,EAAE;QACZ;MACF;MACAA,OAAO,CAACG,UAAU,CAACL,IAAI,CAAC;IAC1B;;IAEA;IACAM,eAAe,CAACV,OAA2B,EAA2B;MACpE,IAAI,CAAC,IAAI,CAACK,gBAAgB,EAAE;QAC1B,OAAO,IAAI;MACb;MACA,MAAMC,OAAO,GAAG,IAAI,CAACC,cAAc,CAACC,qBAAqB,EAAE;MAC3D,IAAI,CAACF,OAAO,EAAE;QACZ,OAAO,IAAI;MACb;MACA,MAAMK,WAAW,GAAGL,OAAO,CAACM,UAAU,EAAE;MACxC,IAAI,CAACD,WAAW,IAAI,CAAC,IAAAE,uBAAgB,EAACF,WAAW,CAACG,cAAc,CAAC,EAAE;QACjE,OAAO,IAAI;MACb;MAEA,IAAId,OAAO,EAAE;QACX,MAAM;UAAEe;QAAkB,CAAC,GAAGf,OAAO;QACrC,IAAIe,iBAAiB,IAAIJ,WAAW,CAACI,iBAAiB,KAAKA,iBAAiB,EAAE;UAC5E,OAAO,IAAI;QACb;MACF;MAEA,OAAOJ,WAAW;IACpB;IAEAT,gBAAgB,GAAS;MACvB,IAAI,CAAC,IAAI,CAACG,gBAAgB,EAAE;QAC1B;MACF;MACA,MAAMC,OAAO,GAAG,IAAI,CAACC,cAAc,CAACC,qBAAqB,EAAE;MAC3DF,OAAO,EAAEU,YAAY,EAAE;IACzB;EACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Authenticator.js","names":["Authenticator","constructor","authenticator","meta"],"sources":["../../../../lib/idx/authenticator/Authenticator.ts"],"sourcesContent":["import { IdxAuthenticator, IdxRemediationValue } from '../types/idx-js';\n\n\nexport interface Credentials {\n [key: string]: string | undefined;\n}\n\nexport abstract class Authenticator<Values> {\n meta: IdxAuthenticator;\n\n constructor(authenticator: IdxAuthenticator) {\n this.meta = authenticator;\n }\n\n abstract canVerify(values: Values): boolean;\n\n abstract mapCredentials(values: Values): Credentials | undefined;\n\n abstract getInputs(idxRemediationValue: IdxRemediationValue): any; // TODO: add type\n}\n"],"mappings":";;;AAOO,MAAeA,aAAa,CAAS;EAG1CC,WAAW,CAACC,aAA+B,EAAE;IAC3C,IAAI,CAACC,IAAI,GAAGD,aAAa;EAC3B;;EAMmE;AACrE;AAAC"}
|
|
1
|
+
{"version":3,"file":"Authenticator.js","names":["Authenticator","constructor","authenticator","meta"],"sources":["../../../../lib/idx/authenticator/Authenticator.ts"],"sourcesContent":["import { IdxAuthenticator, IdxRemediationValue } from '../types/idx-js';\n\n\nexport interface Credentials {\n [key: string]: string | boolean | number | undefined;\n}\n\nexport abstract class Authenticator<Values> {\n meta: IdxAuthenticator;\n\n constructor(authenticator: IdxAuthenticator) {\n this.meta = authenticator;\n }\n\n abstract canVerify(values: Values): boolean;\n\n abstract mapCredentials(values: Values): Credentials | undefined;\n\n abstract getInputs(idxRemediationValue: IdxRemediationValue): any; // TODO: add type\n}\n"],"mappings":";;;AAOO,MAAeA,aAAa,CAAS;EAG1CC,WAAW,CAACC,aAA+B,EAAE;IAC3C,IAAI,CAACC,IAAI,GAAGD,aAAa;EAC3B;;EAMmE;AACrE;AAAC"}
|
|
@@ -10,23 +10,34 @@ class OktaPassword extends _Authenticator.Authenticator {
|
|
|
10
10
|
const {
|
|
11
11
|
credentials,
|
|
12
12
|
password,
|
|
13
|
-
passcode
|
|
13
|
+
passcode,
|
|
14
|
+
revokeSessions
|
|
14
15
|
} = values;
|
|
15
16
|
if (!credentials && !password && !passcode) {
|
|
16
17
|
return;
|
|
17
18
|
}
|
|
18
19
|
return credentials || {
|
|
19
|
-
passcode: passcode || password
|
|
20
|
+
passcode: passcode || password,
|
|
21
|
+
revokeSessions
|
|
20
22
|
};
|
|
21
23
|
}
|
|
22
24
|
getInputs(idxRemediationValue) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
...((_idxRemediationValue$ = idxRemediationValue.form) === null || _idxRemediationValue$ === void 0 ? void 0 : _idxRemediationValue$.value[0]),
|
|
25
|
+
const inputs = [{
|
|
26
|
+
...idxRemediationValue.form?.value[0],
|
|
26
27
|
name: 'password',
|
|
27
28
|
type: 'string',
|
|
28
29
|
required: idxRemediationValue.required
|
|
29
|
-
};
|
|
30
|
+
}];
|
|
31
|
+
const revokeSessions = idxRemediationValue.form?.value.find(input => input.name === 'revokeSessions');
|
|
32
|
+
if (revokeSessions) {
|
|
33
|
+
inputs.push({
|
|
34
|
+
name: 'revokeSessions',
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
label: 'Sign me out of all other devices',
|
|
37
|
+
required: false
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return inputs;
|
|
30
41
|
}
|
|
31
42
|
}
|
|
32
43
|
exports.OktaPassword = OktaPassword;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OktaPassword.js","names":["OktaPassword","Authenticator","canVerify","values","credentials","password","passcode","mapCredentials","getInputs","idxRemediationValue","form","value","name","type","required"],"sources":["../../../../lib/idx/authenticator/OktaPassword.ts"],"sourcesContent":["import { Authenticator, Credentials } from './Authenticator';\n\nexport interface OktaPasswordInputValues {\n password?: string;\n passcode?: string;\n credentials?: Credentials;\n}\n\nexport class OktaPassword extends Authenticator<OktaPasswordInputValues> {\n canVerify(values: OktaPasswordInputValues) {\n return !!(values.credentials || values.password || values.passcode);\n }\n\n mapCredentials(values: OktaPasswordInputValues): Credentials | undefined {\n const { credentials, password, passcode } = values;\n if (!credentials && !password && !passcode) {\n return;\n }\n return credentials || {
|
|
1
|
+
{"version":3,"file":"OktaPassword.js","names":["OktaPassword","Authenticator","canVerify","values","credentials","password","passcode","mapCredentials","revokeSessions","getInputs","idxRemediationValue","inputs","form","value","name","type","required","find","input","push","label"],"sources":["../../../../lib/idx/authenticator/OktaPassword.ts"],"sourcesContent":["import { Authenticator, Credentials } from './Authenticator';\n\nexport interface OktaPasswordInputValues {\n password?: string;\n passcode?: string;\n credentials?: Credentials;\n // for ResetAuthenticator\n revokeSessions?: boolean;\n}\n\nexport class OktaPassword extends Authenticator<OktaPasswordInputValues> {\n canVerify(values: OktaPasswordInputValues) {\n return !!(values.credentials || values.password || values.passcode);\n }\n\n mapCredentials(values: OktaPasswordInputValues): Credentials | undefined {\n const { credentials, password, passcode, revokeSessions } = values;\n if (!credentials && !password && !passcode) {\n return;\n }\n return credentials || {\n passcode: passcode || password,\n revokeSessions,\n };\n }\n\n getInputs(idxRemediationValue) {\n const inputs = [{\n ...idxRemediationValue.form?.value[0],\n name: 'password',\n type: 'string',\n required: idxRemediationValue.required,\n }];\n const revokeSessions = idxRemediationValue.form?.value.find(\n input => input.name === 'revokeSessions'\n );\n if (revokeSessions) {\n inputs.push({\n name: 'revokeSessions',\n type: 'boolean',\n label: 'Sign me out of all other devices',\n required: false,\n });\n }\n return inputs;\n }\n}\n"],"mappings":";;;AAAA;AAUO,MAAMA,YAAY,SAASC,4BAAa,CAA0B;EACvEC,SAAS,CAACC,MAA+B,EAAE;IACzC,OAAO,CAAC,EAAEA,MAAM,CAACC,WAAW,IAAID,MAAM,CAACE,QAAQ,IAAIF,MAAM,CAACG,QAAQ,CAAC;EACrE;EAEAC,cAAc,CAACJ,MAA+B,EAA2B;IACvE,MAAM;MAAEC,WAAW;MAAEC,QAAQ;MAAEC,QAAQ;MAAEE;IAAe,CAAC,GAAGL,MAAM;IAClE,IAAI,CAACC,WAAW,IAAI,CAACC,QAAQ,IAAI,CAACC,QAAQ,EAAE;MAC1C;IACF;IACA,OAAOF,WAAW,IAAI;MACpBE,QAAQ,EAAEA,QAAQ,IAAID,QAAQ;MAC9BG;IACF,CAAC;EACH;EAEAC,SAAS,CAACC,mBAAmB,EAAE;IAC7B,MAAMC,MAAM,GAAG,CAAC;MACd,GAAGD,mBAAmB,CAACE,IAAI,EAAEC,KAAK,CAAC,CAAC,CAAC;MACrCC,IAAI,EAAE,UAAU;MAChBC,IAAI,EAAE,QAAQ;MACdC,QAAQ,EAAEN,mBAAmB,CAACM;IAChC,CAAC,CAAC;IACF,MAAMR,cAAc,GAAGE,mBAAmB,CAACE,IAAI,EAAEC,KAAK,CAACI,IAAI,CACzDC,KAAK,IAAIA,KAAK,CAACJ,IAAI,KAAK,gBAAgB,CACzC;IACD,IAAIN,cAAc,EAAE;MAClBG,MAAM,CAACQ,IAAI,CAAC;QACVL,IAAI,EAAE,gBAAgB;QACtBC,IAAI,EAAE,SAAS;QACfK,KAAK,EAAE,kCAAkC;QACzCJ,QAAQ,EAAE;MACZ,CAAC,CAAC;IACJ;IACA,OAAOL,MAAM;EACf;AACF;AAAC"}
|
|
@@ -23,9 +23,8 @@ class VerificationCodeAuthenticator extends _Authenticator.Authenticator {
|
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
getInputs(idxRemediationValue) {
|
|
26
|
-
var _idxRemediationValue$;
|
|
27
26
|
return {
|
|
28
|
-
...
|
|
27
|
+
...idxRemediationValue.form?.value[0],
|
|
29
28
|
name: 'verificationCode',
|
|
30
29
|
type: 'string',
|
|
31
30
|
required: idxRemediationValue.required
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VerificationCodeAuthenticator.js","names":["VerificationCodeAuthenticator","Authenticator","canVerify","values","credentials","verificationCode","otp","mapCredentials","passcode","getInputs","idxRemediationValue","form","value","name","type","required"],"sources":["../../../../lib/idx/authenticator/VerificationCodeAuthenticator.ts"],"sourcesContent":["import { Authenticator, Credentials } from './Authenticator';\n\nexport interface VerificationCodeValues {\n verificationCode?: string;\n otp?: string;\n credentials?: Credentials;\n}\n\ninterface VerificationCodeCredentials extends Credentials {\n passcode: string;\n}\n\n// general authenticator to handle \"verificationCode\" input\n// it can be used for \"email\", \"phone\", \"google authenticator\"\n// a new authenticator class should be created if special cases need to be handled\nexport class VerificationCodeAuthenticator extends Authenticator<VerificationCodeValues> {\n canVerify(values: VerificationCodeValues) {\n return !!(values.credentials ||values.verificationCode || values.otp);\n }\n\n mapCredentials(values): VerificationCodeCredentials | Credentials | undefined {\n const { credentials, verificationCode, otp } = values;\n if (!credentials && !verificationCode && !otp) {\n return;\n }\n return credentials || { passcode: verificationCode || otp };\n }\n\n getInputs(idxRemediationValue) {\n return {\n ...idxRemediationValue.form?.value[0],\n name: 'verificationCode',\n type: 'string',\n required: idxRemediationValue.required\n };\n }\n}\n"],"mappings":";;;AAAA;AAYA;AACA;AACA;AACO,MAAMA,6BAA6B,SAASC,4BAAa,CAAyB;EACvFC,SAAS,CAACC,MAA8B,EAAE;IACxC,OAAO,CAAC,EAAEA,MAAM,CAACC,WAAW,IAAGD,MAAM,CAACE,gBAAgB,IAAIF,MAAM,CAACG,GAAG,CAAC;EACvE;EAEAC,cAAc,CAACJ,MAAM,EAAyD;IAC5E,MAAM;MAAEC,WAAW;MAAEC,gBAAgB;MAAEC;IAAI,CAAC,GAAGH,MAAM;IACrD,IAAI,CAACC,WAAW,IAAI,CAACC,gBAAgB,IAAI,CAACC,GAAG,EAAE;MAC7C;IACF;IACA,OAAOF,WAAW,IAAI;MAAEI,QAAQ,EAAEH,gBAAgB,IAAIC;IAAI,CAAC;EAC7D;EAEAG,SAAS,CAACC,mBAAmB,EAAE;
|
|
1
|
+
{"version":3,"file":"VerificationCodeAuthenticator.js","names":["VerificationCodeAuthenticator","Authenticator","canVerify","values","credentials","verificationCode","otp","mapCredentials","passcode","getInputs","idxRemediationValue","form","value","name","type","required"],"sources":["../../../../lib/idx/authenticator/VerificationCodeAuthenticator.ts"],"sourcesContent":["import { Authenticator, Credentials } from './Authenticator';\n\nexport interface VerificationCodeValues {\n verificationCode?: string;\n otp?: string;\n credentials?: Credentials;\n}\n\ninterface VerificationCodeCredentials extends Credentials {\n passcode: string;\n}\n\n// general authenticator to handle \"verificationCode\" input\n// it can be used for \"email\", \"phone\", \"google authenticator\"\n// a new authenticator class should be created if special cases need to be handled\nexport class VerificationCodeAuthenticator extends Authenticator<VerificationCodeValues> {\n canVerify(values: VerificationCodeValues) {\n return !!(values.credentials ||values.verificationCode || values.otp);\n }\n\n mapCredentials(values): VerificationCodeCredentials | Credentials | undefined {\n const { credentials, verificationCode, otp } = values;\n if (!credentials && !verificationCode && !otp) {\n return;\n }\n return credentials || { passcode: verificationCode || otp };\n }\n\n getInputs(idxRemediationValue) {\n return {\n ...idxRemediationValue.form?.value[0],\n name: 'verificationCode',\n type: 'string',\n required: idxRemediationValue.required\n };\n }\n}\n"],"mappings":";;;AAAA;AAYA;AACA;AACA;AACO,MAAMA,6BAA6B,SAASC,4BAAa,CAAyB;EACvFC,SAAS,CAACC,MAA8B,EAAE;IACxC,OAAO,CAAC,EAAEA,MAAM,CAACC,WAAW,IAAGD,MAAM,CAACE,gBAAgB,IAAIF,MAAM,CAACG,GAAG,CAAC;EACvE;EAEAC,cAAc,CAACJ,MAAM,EAAyD;IAC5E,MAAM;MAAEC,WAAW;MAAEC,gBAAgB;MAAEC;IAAI,CAAC,GAAGH,MAAM;IACrD,IAAI,CAACC,WAAW,IAAI,CAACC,gBAAgB,IAAI,CAACC,GAAG,EAAE;MAC7C;IACF;IACA,OAAOF,WAAW,IAAI;MAAEI,QAAQ,EAAEH,gBAAgB,IAAIC;IAAI,CAAC;EAC7D;EAEAG,SAAS,CAACC,mBAAmB,EAAE;IAC7B,OAAO;MACL,GAAGA,mBAAmB,CAACC,IAAI,EAAEC,KAAK,CAAC,CAAC,CAAC;MACrCC,IAAI,EAAE,kBAAkB;MACxBC,IAAI,EAAE,QAAQ;MACdC,QAAQ,EAAEL,mBAAmB,CAACK;IAChC,CAAC;EACH;AACF;AAAC"}
|