@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.
- package/CHANGELOG.md +55 -0
- package/README.md +53 -23
- package/cjs/AuthStateManager.js +14 -7
- package/cjs/AuthStateManager.js.map +1 -1
- package/cjs/OktaAuth.js +30 -14
- package/cjs/OktaAuth.js.map +1 -1
- package/cjs/OktaUserAgent.js +2 -2
- package/cjs/PromiseQueue.js +9 -2
- package/cjs/PromiseQueue.js.map +1 -1
- package/cjs/ServiceManager.js +195 -0
- package/cjs/ServiceManager.js.map +1 -0
- package/cjs/TokenManager.js +6 -14
- package/cjs/TokenManager.js.map +1 -1
- package/cjs/TransactionManager.js +11 -5
- package/cjs/TransactionManager.js.map +1 -1
- package/cjs/browser/browserStorage.js +31 -25
- package/cjs/browser/browserStorage.js.map +1 -1
- package/cjs/crypto/node.js +19 -13
- package/cjs/crypto/node.js.map +1 -1
- package/cjs/idx/authenticator/Authenticator.js.map +1 -1
- package/cjs/idx/authenticator/OktaPassword.js +12 -3
- package/cjs/idx/authenticator/OktaPassword.js.map +1 -1
- package/cjs/idx/authenticator/OktaVerifyTotp.js +9 -1
- package/cjs/idx/authenticator/OktaVerifyTotp.js.map +1 -1
- package/cjs/idx/authenticator/SecurityQuestionEnrollment.js +14 -1
- package/cjs/idx/authenticator/SecurityQuestionEnrollment.js.map +1 -1
- package/cjs/idx/authenticator/SecurityQuestionVerification.js +9 -1
- package/cjs/idx/authenticator/SecurityQuestionVerification.js.map +1 -1
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js +13 -3
- package/cjs/idx/authenticator/VerificationCodeAuthenticator.js.map +1 -1
- package/cjs/idx/authenticator/WebauthnEnrollment.js +5 -0
- package/cjs/idx/authenticator/WebauthnEnrollment.js.map +1 -1
- package/cjs/idx/authenticator/WebauthnVerification.js +5 -0
- package/cjs/idx/authenticator/WebauthnVerification.js.map +1 -1
- package/cjs/idx/authenticator/util.js +64 -0
- package/cjs/idx/authenticator/util.js.map +1 -0
- package/cjs/idx/idx-js/index.js +0 -122
- package/cjs/idx/idx-js/index.js.map +1 -1
- package/cjs/idx/idx-js/introspect.js +10 -6
- package/cjs/idx/idx-js/introspect.js.map +1 -1
- package/cjs/idx/idx-js/v1/generateIdxAction.js +17 -23
- package/cjs/idx/idx-js/v1/generateIdxAction.js.map +1 -1
- package/cjs/idx/idx-js/v1/makeIdxState.js +5 -4
- package/cjs/idx/idx-js/v1/makeIdxState.js.map +1 -1
- package/cjs/idx/introspect.js +13 -3
- package/cjs/idx/introspect.js.map +1 -1
- package/cjs/idx/proceed.js +14 -11
- package/cjs/idx/proceed.js.map +1 -1
- package/cjs/idx/remediate.js +68 -77
- package/cjs/idx/remediate.js.map +1 -1
- package/cjs/idx/remediators/AuthenticatorEnrollmentData.js +6 -2
- package/cjs/idx/remediators/AuthenticatorEnrollmentData.js.map +1 -1
- package/cjs/idx/remediators/AuthenticatorVerificationData.js +56 -15
- package/cjs/idx/remediators/AuthenticatorVerificationData.js.map +1 -1
- package/cjs/idx/remediators/Base/AuthenticatorData.js +22 -14
- package/cjs/idx/remediators/Base/AuthenticatorData.js.map +1 -1
- package/cjs/idx/remediators/Base/Remediator.js +85 -85
- package/cjs/idx/remediators/Base/Remediator.js.map +1 -1
- package/cjs/idx/remediators/Base/SelectAuthenticator.js +24 -15
- package/cjs/idx/remediators/Base/SelectAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js +15 -4
- package/cjs/idx/remediators/Base/VerifyAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/ChallengePoll.js +8 -1
- package/cjs/idx/remediators/ChallengePoll.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/EnrollProfile.js +15 -9
- package/cjs/idx/remediators/EnrollProfile.js.map +1 -1
- package/cjs/idx/remediators/EnrollmentChannelData.js +0 -8
- package/cjs/idx/remediators/EnrollmentChannelData.js.map +1 -1
- package/cjs/idx/remediators/Identify.js +12 -5
- package/cjs/idx/remediators/Identify.js.map +1 -1
- package/cjs/idx/remediators/ReEnrollAuthenticator.js +9 -8
- package/cjs/idx/remediators/ReEnrollAuthenticator.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js +4 -3
- package/cjs/idx/remediators/SelectAuthenticatorAuthenticate.js.map +1 -1
- package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js +0 -1
- package/cjs/idx/remediators/SelectAuthenticatorUnlockAccount.js.map +1 -1
- package/cjs/idx/remediators/Skip.js +1 -8
- package/cjs/idx/remediators/Skip.js.map +1 -1
- package/cjs/idx/remediators/util.js.map +1 -1
- package/cjs/idx/run.js +270 -195
- package/cjs/idx/run.js.map +1 -1
- package/cjs/idx/types/idx-js.js.map +1 -1
- package/cjs/idx/types/index.js +37 -0
- package/cjs/idx/types/index.js.map +1 -1
- package/cjs/idx/util.js +198 -0
- package/cjs/idx/util.js.map +1 -0
- package/cjs/options/browser.js +86 -0
- package/cjs/options/browser.js.map +1 -0
- package/cjs/options/index.js +94 -0
- package/cjs/options/index.js.map +1 -0
- package/cjs/options/node.js +45 -0
- package/cjs/options/node.js.map +1 -0
- package/cjs/options.js +11 -1
- package/cjs/options.js.map +1 -1
- package/cjs/server/serverStorage.js +7 -4
- package/cjs/server/serverStorage.js.map +1 -1
- package/cjs/services/AutoRenewService.js +94 -0
- package/cjs/services/AutoRenewService.js.map +1 -0
- package/cjs/services/SyncStorageService.js +93 -0
- package/cjs/services/SyncStorageService.js.map +1 -0
- package/cjs/services/index.js +30 -0
- package/cjs/services/index.js.map +1 -0
- package/cjs/types/Service.js +2 -0
- package/cjs/types/Service.js.map +1 -0
- package/cjs/types/index.js +13 -0
- package/cjs/types/index.js.map +1 -1
- package/dist/okta-auth-js.min.js +1 -1
- package/dist/okta-auth-js.min.js.LICENSE.txt +0 -8
- package/dist/okta-auth-js.min.js.map +1 -1
- package/dist/okta-auth-js.umd.js +1 -1
- package/dist/okta-auth-js.umd.js.LICENSE.txt +1 -7
- package/dist/okta-auth-js.umd.js.map +1 -1
- package/esm/{index.js → esm.browser.js} +2144 -2975
- package/esm/esm.browser.js.map +1 -0
- package/esm/esm.node.mjs +9595 -0
- package/esm/esm.node.mjs.map +1 -0
- package/lib/AuthStateManager.d.ts +3 -3
- package/lib/OktaAuth.d.ts +5 -4
- package/lib/PromiseQueue.d.ts +6 -2
- package/lib/ServiceManager.d.ts +38 -0
- package/lib/TokenManager.d.ts +0 -1
- package/lib/TransactionManager.d.ts +3 -4
- package/lib/idx/authenticator/Authenticator.d.ts +1 -1
- package/lib/idx/authenticator/OktaPassword.d.ts +2 -1
- package/lib/idx/authenticator/OktaVerifyTotp.d.ts +1 -1
- package/lib/idx/authenticator/SecurityQuestionEnrollment.d.ts +3 -5
- package/lib/idx/authenticator/SecurityQuestionVerification.d.ts +1 -1
- package/lib/idx/authenticator/VerificationCodeAuthenticator.d.ts +2 -1
- package/lib/idx/authenticator/WebauthnEnrollment.d.ts +1 -1
- package/lib/idx/authenticator/WebauthnVerification.d.ts +1 -1
- package/lib/idx/authenticator/util.d.ts +4 -0
- package/lib/idx/idx-js/index.d.ts +1 -17
- package/lib/idx/idx-js/introspect.d.ts +2 -1
- package/lib/idx/idx-js/v1/generateIdxAction.d.ts +1 -1
- package/lib/idx/idx-js/v1/makeIdxState.d.ts +2 -2
- package/lib/idx/proceed.d.ts +1 -3
- package/lib/idx/remediate.d.ts +2 -2
- package/lib/idx/remediators/AuthenticatorVerificationData.d.ts +6 -5
- package/lib/idx/remediators/Base/AuthenticatorData.d.ts +5 -9
- package/lib/idx/remediators/Base/Remediator.d.ts +5 -4
- package/lib/idx/remediators/Base/SelectAuthenticator.d.ts +7 -9
- package/lib/idx/remediators/Base/VerifyAuthenticator.d.ts +2 -4
- package/lib/idx/remediators/ChallengePoll.d.ts +1 -0
- package/lib/idx/remediators/EnrollProfile.d.ts +0 -3
- package/lib/idx/remediators/EnrollmentChannelData.d.ts +0 -4
- package/lib/idx/remediators/Identify.d.ts +3 -5
- package/lib/idx/remediators/ReEnrollAuthenticator.d.ts +2 -5
- package/lib/idx/remediators/SelectAuthenticatorAuthenticate.d.ts +2 -1
- package/lib/idx/remediators/SelectAuthenticatorUnlockAccount.d.ts +1 -2
- package/lib/idx/remediators/Skip.d.ts +0 -3
- package/lib/idx/types/idx-js.d.ts +5 -1
- package/lib/idx/types/index.d.ts +7 -3
- package/lib/idx/util.d.ts +11 -0
- package/lib/options/browser.d.ts +16 -0
- package/lib/options/index.d.ts +14 -0
- package/lib/options/node.d.ts +16 -0
- package/lib/services/AutoRenewService.d.ts +27 -0
- package/lib/services/{TokenService.d.ts → SyncStorageService.d.ts} +8 -5
- package/lib/services/index.d.ts +13 -0
- package/lib/types/OktaAuthOptions.d.ts +5 -0
- package/lib/types/Service.d.ts +23 -0
- package/lib/types/Storage.d.ts +7 -5
- package/lib/types/api.d.ts +6 -5
- package/lib/types/index.d.ts +1 -0
- package/package.json +26 -11
- package/cjs/services/TokenService.js +0 -111
- package/cjs/services/TokenService.js.map +0 -1
- package/esm/index.js.map +0 -1
package/cjs/idx/types/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
exports.isAuthenticator = isAuthenticator;
|
|
3
4
|
Object.defineProperty(exports, "IdxAuthenticator", {
|
|
4
5
|
enumerable: true,
|
|
5
6
|
get: function () {
|
|
@@ -12,6 +13,12 @@ Object.defineProperty(exports, "IdxMessage", {
|
|
|
12
13
|
return _idxJs.IdxMessage;
|
|
13
14
|
}
|
|
14
15
|
});
|
|
16
|
+
Object.defineProperty(exports, "IdxMessages", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _idxJs.IdxMessages;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
15
22
|
Object.defineProperty(exports, "ChallengeData", {
|
|
16
23
|
enumerable: true,
|
|
17
24
|
get: function () {
|
|
@@ -24,6 +31,24 @@ Object.defineProperty(exports, "ActivationData", {
|
|
|
24
31
|
return _idxJs.ActivationData;
|
|
25
32
|
}
|
|
26
33
|
});
|
|
34
|
+
Object.defineProperty(exports, "IdxResponse", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function () {
|
|
37
|
+
return _idxJs.IdxResponse;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, "IdxContext", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () {
|
|
43
|
+
return _idxJs.IdxContext;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, "RawIdxResponse", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function () {
|
|
49
|
+
return _idxJs.RawIdxResponse;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
27
52
|
Object.defineProperty(exports, "FlowIdentifier", {
|
|
28
53
|
enumerable: true,
|
|
29
54
|
get: function () {
|
|
@@ -66,6 +91,12 @@ Object.defineProperty(exports, "CancelOptions", {
|
|
|
66
91
|
return _cancel.CancelOptions;
|
|
67
92
|
}
|
|
68
93
|
});
|
|
94
|
+
Object.defineProperty(exports, "RemediateOptions", {
|
|
95
|
+
enumerable: true,
|
|
96
|
+
get: function () {
|
|
97
|
+
return _remediate.RemediateOptions;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
69
100
|
Object.defineProperty(exports, "EmailVerifyCallbackResponse", {
|
|
70
101
|
enumerable: true,
|
|
71
102
|
get: function () {
|
|
@@ -102,6 +133,8 @@ var _proceed = require("../proceed");
|
|
|
102
133
|
|
|
103
134
|
var _cancel = require("../cancel");
|
|
104
135
|
|
|
136
|
+
var _remediate = require("../remediate");
|
|
137
|
+
|
|
105
138
|
var _emailVerify = require("../emailVerify");
|
|
106
139
|
|
|
107
140
|
var _WebauthnEnrollment = require("../authenticator/WebauthnEnrollment");
|
|
@@ -152,4 +185,8 @@ exports.IdxFeature = IdxFeature;
|
|
|
152
185
|
IdxFeature["SOCIAL_IDP"] = "redirect-idp";
|
|
153
186
|
IdxFeature["ACCOUNT_UNLOCK"] = "unlock-account";
|
|
154
187
|
})(IdxFeature || (exports.IdxFeature = IdxFeature = {}));
|
|
188
|
+
|
|
189
|
+
function isAuthenticator(obj) {
|
|
190
|
+
return obj && (obj.key || obj.id);
|
|
191
|
+
}
|
|
155
192
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../lib/idx/types/index.ts"],"names":["IdxStatus","AuthenticatorKey","IdxFeature"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../lib/idx/types/index.ts"],"names":["IdxStatus","AuthenticatorKey","IdxFeature","isAuthenticator","obj","key","id"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA;;AAWA;;AAWA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AAlDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IA0CYA,S;;;WAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;AAAAA,EAAAA,S;GAAAA,S,yBAAAA,S;;IAQAC,gB;;;WAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;AAAAA,EAAAA,gB;GAAAA,gB,gCAAAA,gB;;IAgCAC,U;;;WAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;AAAAA,EAAAA,U;GAAAA,U,0BAAAA,U;;AAsDL,SAASC,eAAT,CAAyBC,GAAzB,EAAyD;AAC9D,SAAOA,GAAG,KAAKA,GAAG,CAACC,GAAJ,IAAWD,GAAG,CAACE,EAApB,CAAV;AACD","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 { InteractOptions } from '../interact';\nimport { IntrospectOptions } from '../introspect';\nimport { APIError, Tokens } from '../../types';\nimport { PKCETransactionMeta } from '../../types/Transaction';\nimport { \n IdxActions, \n IdxAuthenticator, \n IdxContext,\n IdxForm,\n IdxMessage, \n IdxOption, \n IdxRemediation, \n IdxResponse, \n RawIdxResponse \n} from './idx-js';\nimport { FlowIdentifier } from './FlowIdentifier';\n\nexport {\n IdxMessage,\n IdxMessages,\n ChallengeData,\n ActivationData,\n IdxResponse,\n IdxContext,\n RawIdxResponse\n} from './idx-js';\nexport { AuthenticationOptions } from '../authenticate';\nexport { RegistrationOptions } from '../register';\nexport { PasswordRecoveryOptions } from '../recoverPassword';\nexport { AccountUnlockOptions } from '../unlockAccount';\nexport { ProceedOptions } from '../proceed';\nexport { CancelOptions } from '../cancel';\nexport { RemediateOptions } from '../remediate';\nexport { FlowIdentifier };\nexport { IdxAuthenticator };\nexport { EmailVerifyCallbackResponse } from '../emailVerify';\nexport { WebauthnEnrollValues } from '../authenticator/WebauthnEnrollment';\nexport { WebauthnVerificationValues } from '../authenticator/WebauthnVerification';\n\nexport enum IdxStatus {\n SUCCESS = 'SUCCESS',\n PENDING = 'PENDING',\n FAILURE = 'FAILURE',\n TERMINAL = 'TERMINAL',\n CANCELED = 'CANCELED',\n}\n\nexport enum AuthenticatorKey {\n OKTA_PASSWORD = 'okta_password',\n OKTA_EMAIL = 'okta_email',\n PHONE_NUMBER = 'phone_number',\n GOOGLE_AUTHENTICATOR = 'google_otp',\n SECURITY_QUESTION = 'security_question',\n OKTA_VERIFY = 'okta_verify',\n WEBAUTHN = 'webauthn',\n}\n\nexport type Input = {\n name: string;\n type?: string;\n label?: string;\n value?: string | {form: IdxForm};\n minLength?: number;\n maxLength?: number;\n secret?: boolean;\n required?: boolean;\n}\n\nexport type NextStep = {\n name: string;\n authenticator?: IdxAuthenticator;\n canSkip?: boolean;\n canResend?: boolean;\n inputs?: Input[];\n options?: IdxOption[];\n poll?: IdxPollOptions;\n authenticatorEnrollments?: IdxAuthenticator[];\n}\n\nexport enum IdxFeature {\n PASSWORD_RECOVERY = 'recover-password',\n REGISTRATION = 'enroll-profile',\n SOCIAL_IDP = 'redirect-idp',\n ACCOUNT_UNLOCK = 'unlock-account',\n}\n\nexport interface IdxTransactionMeta extends PKCETransactionMeta {\n interactionHandle?: string;\n remediations?: string[];\n flow?: FlowIdentifier;\n withCredentials?: boolean;\n activationToken?: string;\n recoveryToken?: string;\n}\n\nexport interface IdxTransaction {\n status: IdxStatus;\n tokens?: Tokens;\n nextStep?: NextStep;\n messages?: IdxMessage[];\n error?: APIError | IdxResponse;\n meta?: IdxTransactionMeta;\n enabledFeatures?: IdxFeature[];\n availableSteps?: NextStep[];\n\n // from idx-js, used by signin widget\n proceed: (remediationName: string, params: unknown) => Promise<IdxResponse>;\n neededToProceed: IdxRemediation[];\n rawIdxState: RawIdxResponse;\n interactionCode?: string;\n actions: IdxActions;\n context: IdxContext;\n}\n\nexport type IdxOptions = InteractOptions & IntrospectOptions & {\n flow?: FlowIdentifier;\n exchangeCodeForTokens?: boolean;\n autoRemediate?: boolean;\n step?: string;\n};\n\nexport interface IdxPollOptions {\n required?: boolean;\n refresh?: number;\n}\n\nexport type Authenticator = {\n id?: string;\n key?: string;\n methodType?: string;\n phoneNumber?: string;\n};\n\nexport function isAuthenticator(obj: any): obj is Authenticator {\n return obj && (obj.key || obj.id);\n}\n"],"file":"index.js"}
|
package/cjs/idx/util.js
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
|
4
|
+
|
|
5
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
6
|
+
|
|
7
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
8
|
+
|
|
9
|
+
exports.isTerminalResponse = isTerminalResponse;
|
|
10
|
+
exports.canSkipFn = canSkipFn;
|
|
11
|
+
exports.canResendFn = canResendFn;
|
|
12
|
+
exports.getMessagesFromIdxRemediationValue = getMessagesFromIdxRemediationValue;
|
|
13
|
+
exports.getMessagesFromResponse = getMessagesFromResponse;
|
|
14
|
+
exports.getEnabledFeatures = getEnabledFeatures;
|
|
15
|
+
exports.getAvailableSteps = getAvailableSteps;
|
|
16
|
+
exports.filterValuesForRemediation = filterValuesForRemediation;
|
|
17
|
+
|
|
18
|
+
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
19
|
+
|
|
20
|
+
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
21
|
+
|
|
22
|
+
var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
|
|
23
|
+
|
|
24
|
+
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
25
|
+
|
|
26
|
+
var _values = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/values"));
|
|
27
|
+
|
|
28
|
+
var remediators = _interopRequireWildcard(require("./remediators"));
|
|
29
|
+
|
|
30
|
+
var _types = require("./types");
|
|
31
|
+
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
+
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
|
+
|
|
36
|
+
function isTerminalResponse(idxResponse) {
|
|
37
|
+
const {
|
|
38
|
+
neededToProceed,
|
|
39
|
+
interactionCode
|
|
40
|
+
} = idxResponse;
|
|
41
|
+
return !neededToProceed.length && !interactionCode;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function canSkipFn(idxResponse) {
|
|
45
|
+
return idxResponse.neededToProceed.some(({
|
|
46
|
+
name
|
|
47
|
+
}) => name === 'skip');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function canResendFn(idxResponse) {
|
|
51
|
+
return (0, _keys.default)(idxResponse.actions).some(actionName => (0, _includes.default)(actionName).call(actionName, 'resend'));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getMessagesFromIdxRemediationValue(value) {
|
|
55
|
+
if (!value || !Array.isArray(value)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (0, _reduce.default)(value).call(value, (messages, value) => {
|
|
60
|
+
if (value.messages) {
|
|
61
|
+
messages = [...messages, ...value.messages.value];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (value.form) {
|
|
65
|
+
const messagesFromForm = getMessagesFromIdxRemediationValue(value.form.value) || [];
|
|
66
|
+
messages = [...messages, ...messagesFromForm];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (value.options) {
|
|
70
|
+
let optionValues = [];
|
|
71
|
+
value.options.forEach(option => {
|
|
72
|
+
if (!option.value || typeof option.value === 'string') {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
optionValues = [...optionValues, option.value];
|
|
77
|
+
});
|
|
78
|
+
const messagesFromOptions = getMessagesFromIdxRemediationValue(optionValues) || [];
|
|
79
|
+
messages = [...messages, ...messagesFromOptions];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return messages;
|
|
83
|
+
}, []);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function getMessagesFromResponse(idxResponse) {
|
|
87
|
+
var _rawIdxState$messages, _context;
|
|
88
|
+
|
|
89
|
+
let messages = [];
|
|
90
|
+
const {
|
|
91
|
+
rawIdxState,
|
|
92
|
+
neededToProceed
|
|
93
|
+
} = idxResponse; // Handle global messages
|
|
94
|
+
|
|
95
|
+
const globalMessages = (_rawIdxState$messages = rawIdxState.messages) === null || _rawIdxState$messages === void 0 ? void 0 : (0, _map.default)(_context = _rawIdxState$messages.value).call(_context, message => message);
|
|
96
|
+
|
|
97
|
+
if (globalMessages) {
|
|
98
|
+
messages = [...messages, ...globalMessages];
|
|
99
|
+
} // Handle field messages for current flow
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
for (let remediation of neededToProceed) {
|
|
103
|
+
const fieldMessages = getMessagesFromIdxRemediationValue(remediation.value);
|
|
104
|
+
|
|
105
|
+
if (fieldMessages) {
|
|
106
|
+
messages = [...messages, ...fieldMessages];
|
|
107
|
+
}
|
|
108
|
+
} // API may return identical error on same field, filter by i18n key
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
const seen = {};
|
|
112
|
+
messages = (0, _reduce.default)(messages).call(messages, (filtered, message) => {
|
|
113
|
+
var _message$i18n;
|
|
114
|
+
|
|
115
|
+
const key = (_message$i18n = message.i18n) === null || _message$i18n === void 0 ? void 0 : _message$i18n.key;
|
|
116
|
+
|
|
117
|
+
if (key && seen[key]) {
|
|
118
|
+
return filtered;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
seen[key] = message;
|
|
122
|
+
filtered = [...filtered, message];
|
|
123
|
+
return filtered;
|
|
124
|
+
}, []);
|
|
125
|
+
return messages;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function getEnabledFeatures(idxResponse) {
|
|
129
|
+
const res = [];
|
|
130
|
+
const {
|
|
131
|
+
actions,
|
|
132
|
+
neededToProceed
|
|
133
|
+
} = idxResponse;
|
|
134
|
+
|
|
135
|
+
if (actions['currentAuthenticator-recover']) {
|
|
136
|
+
res.push(_types.IdxFeature.PASSWORD_RECOVERY);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (neededToProceed.some(({
|
|
140
|
+
name
|
|
141
|
+
}) => name === 'select-enroll-profile')) {
|
|
142
|
+
res.push(_types.IdxFeature.REGISTRATION);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (neededToProceed.some(({
|
|
146
|
+
name
|
|
147
|
+
}) => name === 'redirect-idp')) {
|
|
148
|
+
res.push(_types.IdxFeature.SOCIAL_IDP);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (neededToProceed.some(({
|
|
152
|
+
name
|
|
153
|
+
}) => name === 'unlock-account')) {
|
|
154
|
+
res.push(_types.IdxFeature.ACCOUNT_UNLOCK);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return res;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function getAvailableSteps(idxResponse) {
|
|
161
|
+
var _context2;
|
|
162
|
+
|
|
163
|
+
const res = [];
|
|
164
|
+
const remediatorMap = (0, _reduce.default)(_context2 = (0, _values.default)(remediators)).call(_context2, (map, remediatorClass) => {
|
|
165
|
+
// Only add concrete subclasses to the map
|
|
166
|
+
if (remediatorClass.remediationName) {
|
|
167
|
+
map[remediatorClass.remediationName] = remediatorClass;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return map;
|
|
171
|
+
}, {});
|
|
172
|
+
|
|
173
|
+
for (let remediation of idxResponse.neededToProceed) {
|
|
174
|
+
const T = remediatorMap[remediation.name];
|
|
175
|
+
|
|
176
|
+
if (T) {
|
|
177
|
+
const remediator = new T(remediation);
|
|
178
|
+
res.push(remediator.getNextStep(idxResponse.context));
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return res;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function filterValuesForRemediation(idxResponse, values) {
|
|
186
|
+
var _context3;
|
|
187
|
+
|
|
188
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
189
|
+
const valuesForRemediation = (0, _reduce.default)(_context3 = idxResponse.neededToProceed[0].value).call(_context3, (res, entry) => {
|
|
190
|
+
const {
|
|
191
|
+
name
|
|
192
|
+
} = entry;
|
|
193
|
+
res[name] = values[name];
|
|
194
|
+
return res;
|
|
195
|
+
}, {});
|
|
196
|
+
return valuesForRemediation;
|
|
197
|
+
}
|
|
198
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../lib/idx/util.ts"],"names":["isTerminalResponse","idxResponse","neededToProceed","interactionCode","length","canSkipFn","some","name","canResendFn","actions","actionName","getMessagesFromIdxRemediationValue","value","Array","isArray","messages","form","messagesFromForm","options","optionValues","forEach","option","messagesFromOptions","getMessagesFromResponse","rawIdxState","globalMessages","message","remediation","fieldMessages","seen","filtered","key","i18n","getEnabledFeatures","res","push","IdxFeature","PASSWORD_RECOVERY","REGISTRATION","SOCIAL_IDP","ACCOUNT_UNLOCK","getAvailableSteps","remediatorMap","remediators","map","remediatorClass","remediationName","T","remediator","getNextStep","context","filterValuesForRemediation","values","valuesForRemediation","entry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA;;;;;;AAGO,SAASA,kBAAT,CAA4BC,WAA5B,EAAsD;AAC3D,QAAM;AAAEC,IAAAA,eAAF;AAAmBC,IAAAA;AAAnB,MAAuCF,WAA7C;AACA,SAAO,CAACC,eAAe,CAACE,MAAjB,IAA2B,CAACD,eAAnC;AACD;;AAEM,SAASE,SAAT,CAAmBJ,WAAnB,EAA6C;AAClD,SAAOA,WAAW,CAACC,eAAZ,CAA4BI,IAA5B,CAAiC,CAAC;AAAEC,IAAAA;AAAF,GAAD,KAAcA,IAAI,KAAK,MAAxD,CAAP;AACD;;AAEM,SAASC,WAAT,CAAqBP,WAArB,EAA+C;AACpD,SAAO,mBAAYA,WAAW,CAACQ,OAAxB,EAAiCH,IAAjC,CAAsCI,UAAU,IAAI,uBAAAA,UAAU,MAAV,CAAAA,UAAU,EAAU,QAAV,CAA9D,CAAP;AACD;;AAEM,SAASC,kCAAT,CACLC,KADK,EAEqB;AAC1B,MAAI,CAACA,KAAD,IAAU,CAACC,KAAK,CAACC,OAAN,CAAcF,KAAd,CAAf,EAAqC;AACnC;AACD;;AACD,SAAO,qBAAAA,KAAK,MAAL,CAAAA,KAAK,EAAQ,CAACG,QAAD,EAAWH,KAAX,KAAqB;AACvC,QAAIA,KAAK,CAACG,QAAV,EAAoB;AAClBA,MAAAA,QAAQ,GAAG,CAAC,GAAGA,QAAJ,EAAc,GAAGH,KAAK,CAACG,QAAN,CAAeH,KAAhC,CAAX;AACD;;AACD,QAAIA,KAAK,CAACI,IAAV,EAAgB;AACd,YAAMC,gBAAgB,GAAGN,kCAAkC,CAACC,KAAK,CAACI,IAAN,CAAWJ,KAAZ,CAAlC,IAAwD,EAAjF;AACAG,MAAAA,QAAQ,GAAG,CAAC,GAAGA,QAAJ,EAAc,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BAAWI,cAApB;AACD;;AAED,SAAON,GAAP;AACD;;AAEM,SAASO,iBAAT,CAA2BxC,WAA3B,EAAiE;AAAA;;AACtE,QAAMiC,GAAG,GAAG,EAAZ;AAEA,QAAMQ,aAAa,GAAG,sDAAcC,WAAd,mBAAkC,CAACC,GAAD,EAAMC,eAAN,KAA0B;AAChF;AACA,QAAIA,eAAe,CAACC,eAApB,EAAqC;AACnCF,MAAAA,GAAG,CAACC,eAAe,CAACC,eAAjB,CAAH,GAAuCD,eAAvC;AACD;;AACD,WAAOD,GAAP;AACD,GANqB,EAMnB,EANmB,CAAtB;;AAQA,OAAK,IAAIjB,WAAT,IAAwB1B,WAAW,CAACC,eAApC,EAAqD;AACnD,UAAM6C,CAAC,GAAGL,aAAa,CAACf,WAAW,CAACpB,IAAb,CAAvB;;AACA,QAAIwC,CAAJ,EAAO;AACL,YAAMC,UAAU,GAAG,IAAID,CAAJ,CAAMpB,WAAN,CAAnB;AACAO,MAAAA,GAAG,CAACC,IAAJ,CAAUa,UAAU,CAACC,WAAX,CAAuBhD,WAAW,CAACiD,OAAnC,CAAV;AACD;AACF;;AAED,SAAOhB,GAAP;AACD;;AAEM,SAASiB,0BAAT,CAAoClD,WAApC,EAA8DmD,MAA9D,EAA4G;AAAA;;AACjH;AACA,QAAMC,oBAAoB,GAAG,iCAAApD,WAAW,CAACC,eAAZ,CAA6B,CAA7B,EAAiCU,KAAjC,kBAA+C,CAACsB,GAAD,EAAMoB,KAAN,KAAgB;AAC1F,UAAM;AAAE/C,MAAAA;AAAF,QAAW+C,KAAjB;AACApB,IAAAA,GAAG,CAAC3B,IAAD,CAAH,GAAY6C,MAAM,CAAC7C,IAAD,CAAlB;AACA,WAAO2B,GAAP;AACD,GAJ4B,EAI1B,EAJ0B,CAA7B;AAKA,SAAOmB,oBAAP;AACD","sourcesContent":["import * as remediators from './remediators';\nimport { RemediationValues } from './remediators';\nimport { IdxFeature, NextStep } from './types';\nimport { IdxMessage, IdxRemediationValue, IdxResponse } from './types/idx-js';\n\nexport function isTerminalResponse(idxResponse: IdxResponse) {\n const { neededToProceed, interactionCode } = idxResponse;\n return !neededToProceed.length && !interactionCode;\n}\n\nexport function canSkipFn(idxResponse: IdxResponse) {\n return idxResponse.neededToProceed.some(({ name }) => name === 'skip');\n}\n\nexport function canResendFn(idxResponse: IdxResponse) {\n return Object.keys(idxResponse.actions).some(actionName => actionName.includes('resend'));\n}\n\nexport function getMessagesFromIdxRemediationValue(\n value?: IdxRemediationValue[]\n): IdxMessage[] | undefined {\n if (!value || !Array.isArray(value)) {\n return;\n }\n return value.reduce((messages, value) => {\n if (value.messages) {\n messages = [...messages, ...value.messages.value] as never;\n }\n if (value.form) {\n const messagesFromForm = getMessagesFromIdxRemediationValue(value.form.value) || [];\n messages = [...messages, ...messagesFromForm] as never;\n } \n if (value.options) {\n let optionValues = [];\n value.options.forEach(option => {\n if (!option.value || typeof option.value === 'string') {\n return;\n }\n optionValues = [...optionValues, option.value] as never;\n });\n const messagesFromOptions = getMessagesFromIdxRemediationValue(optionValues) || [];\n messages = [...messages, ...messagesFromOptions] as never;\n }\n return messages;\n }, []);\n}\n\nexport function getMessagesFromResponse(idxResponse: IdxResponse): IdxMessage[] {\n let messages: IdxMessage[] = [];\n const { rawIdxState, neededToProceed } = idxResponse;\n\n // Handle global messages\n const globalMessages = rawIdxState.messages?.value.map(message => message);\n if (globalMessages) {\n messages = [...messages, ...globalMessages] as never;\n }\n\n // Handle field messages for current flow\n for (let remediation of neededToProceed) {\n const fieldMessages = getMessagesFromIdxRemediationValue(remediation.value);\n if (fieldMessages) {\n messages = [...messages, ...fieldMessages] as never;\n }\n }\n\n // API may return identical error on same field, filter by i18n key\n const seen = {};\n messages = messages.reduce((filtered, message) => {\n const key = message.i18n?.key;\n if (key && seen[key]) {\n return filtered;\n }\n seen[key] = message;\n filtered = [...filtered, message] as never;\n return filtered;\n }, []);\n return messages;\n}\n\n\nexport function getEnabledFeatures(idxResponse: IdxResponse): IdxFeature[] {\n const res = [];\n const { actions, neededToProceed } = idxResponse;\n\n if (actions['currentAuthenticator-recover']) {\n res.push(IdxFeature.PASSWORD_RECOVERY as never);\n }\n\n if (neededToProceed.some(({ name }) => name === 'select-enroll-profile')) {\n res.push(IdxFeature.REGISTRATION as never);\n }\n\n if (neededToProceed.some(({ name }) => name === 'redirect-idp')) {\n res.push(IdxFeature.SOCIAL_IDP as never);\n }\n\n if (neededToProceed.some(({ name }) => name === 'unlock-account')) {\n res.push(IdxFeature.ACCOUNT_UNLOCK as never);\n }\n\n return res;\n}\n\nexport function getAvailableSteps(idxResponse: IdxResponse): NextStep[] {\n const res = [];\n\n const remediatorMap = Object.values(remediators).reduce((map, remediatorClass) => {\n // Only add concrete subclasses to the map\n if (remediatorClass.remediationName) {\n map[remediatorClass.remediationName] = remediatorClass;\n }\n return map;\n }, {});\n\n for (let remediation of idxResponse.neededToProceed) {\n const T = remediatorMap[remediation.name];\n if (T) {\n const remediator = new T(remediation);\n res.push (remediator.getNextStep(idxResponse.context) as never);\n }\n }\n\n return res;\n}\n\nexport function filterValuesForRemediation(idxResponse: IdxResponse, values: RemediationValues): RemediationValues {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const valuesForRemediation = idxResponse.neededToProceed![0]!.value!.reduce((res, entry) => {\n const { name } = entry;\n res[name] = values[name];\n return res;\n }, {});\n return valuesForRemediation;\n}\n"],"file":"util.js"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.getStorage = getStorage;
|
|
6
|
+
exports.getCookieSettings = getCookieSettings;
|
|
7
|
+
exports.enableSharedStorage = exports.STORAGE_MANAGER_OPTIONS = void 0;
|
|
8
|
+
|
|
9
|
+
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
10
|
+
|
|
11
|
+
var _util = require("../util");
|
|
12
|
+
|
|
13
|
+
var _browserStorage = _interopRequireDefault(require("../browser/browserStorage"));
|
|
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
|
+
|
|
27
|
+
/* eslint-disable complexity */
|
|
28
|
+
function getStorage() {
|
|
29
|
+
const storageUtil = (0, _assign.default)({}, _browserStorage.default, {
|
|
30
|
+
inMemoryStore: {} // create unique storage for this instance
|
|
31
|
+
|
|
32
|
+
});
|
|
33
|
+
return storageUtil;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const STORAGE_MANAGER_OPTIONS = {
|
|
37
|
+
token: {
|
|
38
|
+
storageTypes: ['localStorage', 'sessionStorage', 'cookie']
|
|
39
|
+
},
|
|
40
|
+
cache: {
|
|
41
|
+
storageTypes: ['localStorage', 'sessionStorage', 'cookie']
|
|
42
|
+
},
|
|
43
|
+
transaction: {
|
|
44
|
+
storageTypes: ['sessionStorage', 'localStorage', 'cookie']
|
|
45
|
+
},
|
|
46
|
+
'shared-transaction': {
|
|
47
|
+
storageTypes: ['localStorage']
|
|
48
|
+
},
|
|
49
|
+
'original-uri': {
|
|
50
|
+
storageTypes: ['localStorage']
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
exports.STORAGE_MANAGER_OPTIONS = STORAGE_MANAGER_OPTIONS;
|
|
54
|
+
const enableSharedStorage = true;
|
|
55
|
+
exports.enableSharedStorage = enableSharedStorage;
|
|
56
|
+
|
|
57
|
+
function getCookieSettings(args = {}, isHTTPS) {
|
|
58
|
+
// Secure cookies will be automatically used on a HTTPS connection
|
|
59
|
+
// Non-secure cookies will be automatically used on a HTTP connection
|
|
60
|
+
// secure option can override the automatic behavior
|
|
61
|
+
var cookieSettings = args.cookies || {};
|
|
62
|
+
|
|
63
|
+
if (typeof cookieSettings.secure === 'undefined') {
|
|
64
|
+
cookieSettings.secure = isHTTPS;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (typeof cookieSettings.sameSite === 'undefined') {
|
|
68
|
+
cookieSettings.sameSite = cookieSettings.secure ? 'none' : 'lax';
|
|
69
|
+
} // If secure=true, but the connection is not HTTPS, set secure=false.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
if (cookieSettings.secure && !isHTTPS) {
|
|
73
|
+
// eslint-disable-next-line no-console
|
|
74
|
+
(0, _util.warn)('The current page is not being served with the HTTPS protocol.\n' + 'For security reasons, we strongly recommend using HTTPS.\n' + 'If you cannot use HTTPS, set "cookies.secure" option to false.');
|
|
75
|
+
cookieSettings.secure = false;
|
|
76
|
+
} // Chrome >= 80 will block cookies with SameSite=None unless they are also Secure
|
|
77
|
+
// If sameSite=none, but the connection is not HTTPS, set sameSite=lax.
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
if (cookieSettings.sameSite === 'none' && !cookieSettings.secure) {
|
|
81
|
+
cookieSettings.sameSite = 'lax';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return cookieSettings;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../lib/options/browser.ts"],"names":["getStorage","storageUtil","browserStorage","inMemoryStore","STORAGE_MANAGER_OPTIONS","token","storageTypes","cache","transaction","enableSharedStorage","getCookieSettings","args","isHTTPS","cookieSettings","cookies","secure","sameSite"],"mappings":";;;;;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yB,CAACH,OAA9B,EAAuC;AACrC;AACA,oBACE,oEACA,4DADA,GAEA,gEAHF;AAKAC,IAAAA,cAAc,CAACE,MAAf,GAAwB,KAAxB;AACD,GArB6E,CAuB9E;AACA;;;AACA,MAAIF,cAAc,CAACG,QAAf,KAA4B,MAA5B,IAAsC,CAACH,cAAc,CAACE,MAA1D,EAAkE;AAChEF,IAAAA,cAAc,CAACG,QAAf,GAA0B,KAA1B;AACD;;AAED,SAAOH,cAAP;AACD","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/* eslint-disable complexity */\nimport { StorageManagerOptions, OktaAuthOptions, StorageUtil } from '../types';\nimport { warn } from '../util';\n\nimport { default as browserStorage } from '../browser/browserStorage';\n\nexport function getStorage(): StorageUtil {\n const storageUtil = Object.assign({}, browserStorage, {\n inMemoryStore: {} // create unique storage for this instance\n });\n return storageUtil;\n}\n\nexport const STORAGE_MANAGER_OPTIONS: 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\nexport const enableSharedStorage = true;\n\nexport function 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"],"file":"browser.js"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.getDefaultOptions = getDefaultOptions;
|
|
6
|
+
exports.buildOptions = buildOptions;
|
|
7
|
+
|
|
8
|
+
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
|
|
9
|
+
|
|
10
|
+
var _util = require("../util");
|
|
11
|
+
|
|
12
|
+
var _builderUtil = require("../builderUtil");
|
|
13
|
+
|
|
14
|
+
var _fetchRequest = _interopRequireDefault(require("../fetch/fetchRequest"));
|
|
15
|
+
|
|
16
|
+
var _node = require("./node");
|
|
17
|
+
|
|
18
|
+
var _features = require("../features");
|
|
19
|
+
|
|
20
|
+
/*!
|
|
21
|
+
* Copyright (c) 2015-present, Okta, Inc. and/or its affiliates. All rights reserved.
|
|
22
|
+
* The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the "License.")
|
|
23
|
+
*
|
|
24
|
+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
27
|
+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
*
|
|
29
|
+
* See the License for the specific language governing permissions and limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
function getDefaultOptions() {
|
|
32
|
+
const options = {
|
|
33
|
+
devMode: false,
|
|
34
|
+
httpRequestClient: _fetchRequest.default,
|
|
35
|
+
storageUtil: (0, _node.getStorage)(),
|
|
36
|
+
storageManager: _node.STORAGE_MANAGER_OPTIONS,
|
|
37
|
+
transactionManager: {
|
|
38
|
+
enableSharedStorage: _node.enableSharedStorage
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
return options;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function mergeOptions(options, args) {
|
|
45
|
+
return (0, _assign.default)({}, options, (0, _util.removeNils)(args), {
|
|
46
|
+
storageManager: (0, _assign.default)({}, options.storageManager, args.storageManager),
|
|
47
|
+
transactionManager: (0, _assign.default)({}, options.transactionManager, args.transactionManager)
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function buildOptions(args = {}) {
|
|
52
|
+
(0, _builderUtil.assertValidConfig)(args);
|
|
53
|
+
args = mergeOptions(getDefaultOptions(), args);
|
|
54
|
+
return (0, _util.removeNils)({
|
|
55
|
+
// OIDC configuration
|
|
56
|
+
issuer: (0, _util.removeTrailingSlash)(args.issuer),
|
|
57
|
+
tokenUrl: (0, _util.removeTrailingSlash)(args.tokenUrl),
|
|
58
|
+
authorizeUrl: (0, _util.removeTrailingSlash)(args.authorizeUrl),
|
|
59
|
+
userinfoUrl: (0, _util.removeTrailingSlash)(args.userinfoUrl),
|
|
60
|
+
revokeUrl: (0, _util.removeTrailingSlash)(args.revokeUrl),
|
|
61
|
+
logoutUrl: (0, _util.removeTrailingSlash)(args.logoutUrl),
|
|
62
|
+
clientId: args.clientId,
|
|
63
|
+
redirectUri: args.redirectUri,
|
|
64
|
+
state: args.state,
|
|
65
|
+
scopes: args.scopes,
|
|
66
|
+
postLogoutRedirectUri: args.postLogoutRedirectUri,
|
|
67
|
+
responseMode: args.responseMode,
|
|
68
|
+
responseType: args.responseType,
|
|
69
|
+
pkce: args.pkce === false ? false : true,
|
|
70
|
+
// PKCE defaults to true
|
|
71
|
+
useInteractionCodeFlow: args.useInteractionCodeFlow,
|
|
72
|
+
// Internal options
|
|
73
|
+
httpRequestClient: args.httpRequestClient,
|
|
74
|
+
transformErrorXHR: args.transformErrorXHR,
|
|
75
|
+
transformAuthState: args.transformAuthState,
|
|
76
|
+
restoreOriginalUri: args.restoreOriginalUri,
|
|
77
|
+
storageUtil: args.storageUtil,
|
|
78
|
+
headers: args.headers,
|
|
79
|
+
devMode: !!args.devMode,
|
|
80
|
+
storageManager: args.storageManager,
|
|
81
|
+
transactionManager: args.transactionManager,
|
|
82
|
+
cookies: (0, _node.getCookieSettings)(args, (0, _features.isHTTPS)()),
|
|
83
|
+
flow: args.flow,
|
|
84
|
+
codeChallenge: args.codeChallenge,
|
|
85
|
+
codeChallengeMethod: args.codeChallengeMethod,
|
|
86
|
+
recoveryToken: args.recoveryToken,
|
|
87
|
+
activationToken: args.activationToken,
|
|
88
|
+
// Give the developer the ability to disable token signature validation.
|
|
89
|
+
ignoreSignature: !!args.ignoreSignature,
|
|
90
|
+
// Server-side web applications
|
|
91
|
+
clientSecret: args.clientSecret
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../lib/options/index.ts"],"names":["getDefaultOptions","options","devMode","httpRequestClient","fetchRequest","storageUtil","storageManager","STORAGE_MANAGER_OPTIONS","transactionManager","enableSharedStorage","mergeOptions","args","buildOptions","issuer","tokenUrl","authorizeUrl","userinfoUrl","revokeUrl","logoutUrl","clientId","redirectUri","state","scopes","postLogoutRedirectUri","responseMode","responseType","pkce","useInteractionCodeFlow","transformErrorXHR","transformAuthState","restoreOriginalUri","headers","cookies","flow","codeChallenge","codeChallengeMethod","recoveryToken","activationToken","ignoreSignature","clientSecret"],"mappings":";;;;;;;;;AAYA;;AACA;;AAGA;;AACA;;AACA;;AAlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAUO,SAASA,iBAAT,GAA8C;AAGnD,QAAMC,OAAO,GAAG;AACdC,IAAAA,OAAO,EAAE,KADK;AAEdC,IAAAA,iBAAiB,EAAEC,qBAFL;AAGdC,IAAAA,WAAW,EAAE,uBAHC;AAIdC,IAAAA,cAAc,EAAEC,6BAJF;AAKdC,IAAAA,kBAAkB,EAAE;AAClBC,MAAAA,mBAAmB,EAAnBA;AADkB;AALN,GAAhB;AASA,SAAOR,OAAP;AACD;;AAED,SAASS,YAAT,CAAsBT,OAAtB,EAA+BU,IAA/B,EAAsD;AACpD,SAAO,qBAAc,EAAd,EAAkBV,OAAlB,EAA2B,sBAAWU,IAAX,CAA3B,EAA6C;AAClDL,IAAAA,cAAc,EAAE,qBAAc,EAAd,EAAkBL,OAAO,CAACK,cAA1B,EAA0CK,IAAI,CAACL,cAA/C,CADkC;AAElDE,IAAAA,kBAAkB,EAAE,qBAAc,EAAd,EAAkBP,OAAO,CAACO,kBAA1B,EAA8CG,IAAI,CAACH,kBAAnD;AAF8B,GAA7C,CAAP;AAID;;AAEM,SAASI,YAAT,CAAsBD,IAAqB,GAAG,EAA9C,EAAmE;AACxE,sCAAkBA,IAAlB;AACAA,EAAAA,IAAI,GAAGD,YAAY,CAACV,iBAAiB,EAAlB,EAAsBW,IAAtB,CAAnB;AACA,SAAO,sBAAW;AAChB;AACAE,IAAAA,MAAM,EAAE,+BAAoBF,IAAI,CAACE,MAAzB,CAFQ;AA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,IAAAA,kBAAkB,EAAEG,IAAI,CAACH,kBA3BT;AA4BhBwB,IAAAA,OAAO,EAAE,6BAAkBrB,IAAlB,EAAwB,wBAAxB,CA5BO;AA6BhBsB,IAAAA,IAAI,EAAEtB,IAAI,CAACsB,IA7BK;AA8BhBC,IAAAA,aAAa,EAAEvB,IAAI,CAACuB,aA9BJ;AA+BhBC,IAAAA,mBAAmB,EAAExB,IAAI,CAACwB,mBA/BV;AAgChBC,IAAAA,aAAa,EAAEzB,IAAI,CAACyB,aAhCJ;AAiChBC,IAAAA,eAAe,EAAE1B,IAAI,CAAC0B,eAjCN;AAmChB;AACAC,IAAAA,eAAe,EAAE,CAAC,CAAC3B,IAAI,CAAC2B,eApCR;AAsChB;AACAC,IAAAA,YAAY,EAAE5B,IAAI,CAAC4B;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\nimport { removeTrailingSlash, removeNils } from '../util';\nimport { assertValidConfig } from '../builderUtil';\nimport { OktaAuthOptions } from '../types';\n\nimport fetchRequest from '../fetch/fetchRequest';\nimport { getStorage, STORAGE_MANAGER_OPTIONS, enableSharedStorage, getCookieSettings } from './node';\nimport { isHTTPS } from '../features';\n\nexport function getDefaultOptions(): OktaAuthOptions {\n\n \n const options = {\n devMode: false,\n httpRequestClient: fetchRequest,\n storageUtil: getStorage(),\n storageManager: STORAGE_MANAGER_OPTIONS,\n transactionManager: {\n enableSharedStorage\n }\n };\n return options;\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: getCookieSettings(args, isHTTPS()),\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":"index.js"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
exports.getStorage = getStorage;
|
|
6
|
+
exports.getCookieSettings = getCookieSettings;
|
|
7
|
+
exports.enableSharedStorage = exports.STORAGE_MANAGER_OPTIONS = void 0;
|
|
8
|
+
|
|
9
|
+
var _serverStorage = _interopRequireDefault(require("../server/serverStorage"));
|
|
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
|
+
function getStorage() {
|
|
23
|
+
return _serverStorage.default;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const STORAGE_MANAGER_OPTIONS = {
|
|
27
|
+
token: {
|
|
28
|
+
storageTypes: ['memory']
|
|
29
|
+
},
|
|
30
|
+
cache: {
|
|
31
|
+
storageTypes: ['memory']
|
|
32
|
+
},
|
|
33
|
+
transaction: {
|
|
34
|
+
storageTypes: ['memory']
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.STORAGE_MANAGER_OPTIONS = STORAGE_MANAGER_OPTIONS;
|
|
38
|
+
const enableSharedStorage = false; // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
|
|
39
|
+
|
|
40
|
+
exports.enableSharedStorage = enableSharedStorage;
|
|
41
|
+
|
|
42
|
+
function getCookieSettings(args = {}, isHTTPS) {
|
|
43
|
+
return args.cookies;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../lib/options/node.ts"],"names":["getStorage","storage","STORAGE_MANAGER_OPTIONS","token","storageTypes","cache","transaction","enableSharedStorage","getCookieSettings","args","isHTTPS","cookies"],"mappings":";;;;;;;;AAcA;;AAdA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMO,SAASA,UAAT,GAAmC;AACxC,SAAOC,sBAAP;AACD;;AAEM,MAAMC,uBAA8C,GAAG;AAC5DC,EAAAA,KAAK,EAAE;AACLC,IAAAA,YAAY,EAAE,CACZ,QADY;AADT,GADqD;AAM5DC,EAAAA,KAAK,EAAE;AACLD,IAAAA,YAAY,EAAE,CACZ,QADY;AADT,GANqD;AAW5DE,EAAAA,WAAW,EAAE;AACXF,IAAAA,YAAY,EAAE,CACZ,QADY;AADH;AAX+C,CAAvD;;AAkBA,MAAMG,mBAAmB,GAAG,KAA5B,C,CAEP;;;;AACO,SAASC,iBAAT,CAA2BC,IAAqB,GAAG,EAAnD,EAAuDC,OAAvD,EAA0E;AAC/E,SAAOD,IAAI,CAACE,OAAZ;AACD","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\nimport { StorageManagerOptions, OktaAuthOptions, StorageUtil } from '../types';\n\nimport { default as storage } from '../server/serverStorage';\n\nexport function getStorage(): StorageUtil {\n return storage;\n}\n\nexport const STORAGE_MANAGER_OPTIONS: 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\nexport const enableSharedStorage = false;\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars\nexport function getCookieSettings(args: OktaAuthOptions = {}, isHTTPS?: boolean) {\n return args.cookies;\n}\n"],"file":"node.js"}
|
package/cjs/options.js
CHANGED
|
@@ -92,7 +92,17 @@ function getCookieSettings(args = {}, isHTTPS) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
function getDefaultOptions() {
|
|
95
|
-
|
|
95
|
+
let storageUtil;
|
|
96
|
+
|
|
97
|
+
if ((0, _features.isBrowser)()) {
|
|
98
|
+
storageUtil = (0, _assign.default)({}, _browserStorage.default, {
|
|
99
|
+
inMemoryStore: {} // create unique storage for this instance
|
|
100
|
+
|
|
101
|
+
});
|
|
102
|
+
} else {
|
|
103
|
+
storageUtil = _serverStorage.default;
|
|
104
|
+
}
|
|
105
|
+
|
|
96
106
|
const storageManager = (0, _features.isBrowser)() ? BROWSER_STORAGE : SERVER_STORAGE;
|
|
97
107
|
const enableSharedStorage = (0, _features.isBrowser)() ? true : false; // localStorage for multi-tab flows (browser only)
|
|
98
108
|
|