@auth0/auth0-spa-js 2.12.0 → 2.13.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/README.md +4 -2
- package/dist/auth0-spa-js.development.js +286 -20
- package/dist/auth0-spa-js.development.js.map +1 -1
- package/dist/auth0-spa-js.production.esm.js +1 -1
- package/dist/auth0-spa-js.production.esm.js.map +1 -1
- package/dist/auth0-spa-js.production.js +1 -1
- package/dist/auth0-spa-js.production.js.map +1 -1
- package/dist/auth0-spa-js.worker.development.js.map +1 -1
- package/dist/auth0-spa-js.worker.production.js.map +1 -1
- package/dist/lib/auth0-spa-js.cjs.js +306 -20
- package/dist/lib/auth0-spa-js.cjs.js.map +1 -1
- package/dist/typings/Auth0Client.d.ts +32 -0
- package/dist/typings/errors.d.ts +15 -1
- package/dist/typings/global.d.ts +2 -2
- package/dist/typings/index.d.ts +3 -0
- package/dist/typings/mfa/MfaApiClient.d.ts +225 -0
- package/dist/typings/mfa/MfaContextManager.d.ts +79 -0
- package/dist/typings/mfa/constants.d.ts +23 -0
- package/dist/typings/mfa/errors.d.ts +117 -0
- package/dist/typings/mfa/index.d.ts +4 -0
- package/dist/typings/mfa/types.d.ts +181 -0
- package/dist/typings/mfa/utils.d.ts +23 -0
- package/dist/typings/utils.d.ts +2 -1
- package/dist/typings/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/Auth0Client.ts +54 -3
- package/src/dpop/utils.ts +4 -1
- package/src/errors.ts +12 -1
- package/src/global.ts +24 -1
- package/src/http.ts +1 -1
- package/src/index.ts +22 -0
- package/src/mfa/MfaApiClient.ts +425 -0
- package/src/mfa/MfaContextManager.ts +128 -0
- package/src/mfa/constants.ts +48 -0
- package/src/mfa/errors.ts +154 -0
- package/src/mfa/index.ts +24 -0
- package/src/mfa/types.ts +209 -0
- package/src/mfa/utils.ts +41 -0
- package/src/utils.ts +7 -1
- package/src/version.ts +1 -1
|
@@ -551,7 +551,7 @@ var SuperTokensLock = function() {
|
|
|
551
551
|
|
|
552
552
|
var _default = browserTabsLock.default = SuperTokensLock;
|
|
553
553
|
|
|
554
|
-
var version = "2.
|
|
554
|
+
var version = "2.13.0";
|
|
555
555
|
|
|
556
556
|
const DEFAULT_AUTHORIZE_TIMEOUT_IN_SECONDS = 60;
|
|
557
557
|
|
|
@@ -649,9 +649,10 @@ class PopupOpenError extends GenericError {
|
|
|
649
649
|
}
|
|
650
650
|
|
|
651
651
|
class MfaRequiredError extends GenericError {
|
|
652
|
-
constructor(error, error_description, mfa_token) {
|
|
652
|
+
constructor(error, error_description, mfa_token, mfa_requirements) {
|
|
653
653
|
super(error, error_description);
|
|
654
654
|
this.mfa_token = mfa_token;
|
|
655
|
+
this.mfa_requirements = mfa_requirements;
|
|
655
656
|
Object.setPrototypeOf(this, MfaRequiredError.prototype);
|
|
656
657
|
}
|
|
657
658
|
}
|
|
@@ -805,13 +806,19 @@ const ALLOWED_AUTH0CLIENT_PROPERTIES = [ {
|
|
|
805
806
|
type: [ "object" ]
|
|
806
807
|
} ];
|
|
807
808
|
|
|
808
|
-
const stripAuth0Client =
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
809
|
+
const stripAuth0Client = function stripAuth0Client(auth0Client) {
|
|
810
|
+
let excludeEnv = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
811
|
+
return Object.keys(auth0Client).reduce(((acc, key) => {
|
|
812
|
+
if (excludeEnv && key === "env") {
|
|
813
|
+
return acc;
|
|
814
|
+
}
|
|
815
|
+
const allowedProperty = ALLOWED_AUTH0CLIENT_PROPERTIES.find((p => p.key === key));
|
|
816
|
+
if (allowedProperty && allowedProperty.type.includes(typeof auth0Client[key])) {
|
|
817
|
+
acc[key] = auth0Client[key];
|
|
818
|
+
}
|
|
819
|
+
return acc;
|
|
820
|
+
}), {});
|
|
821
|
+
};
|
|
815
822
|
|
|
816
823
|
const createQueryParams = _a => {
|
|
817
824
|
var {clientId: client_id} = _a, params = __rest(_a, [ "clientId" ]);
|
|
@@ -1193,7 +1200,7 @@ const DPOP_NONCE_HEADER = "dpop-nonce";
|
|
|
1193
1200
|
|
|
1194
1201
|
const KEY_PAIR_ALGORITHM = "ES256";
|
|
1195
1202
|
|
|
1196
|
-
const SUPPORTED_GRANT_TYPES = [ "authorization_code", "refresh_token", "urn:ietf:params:oauth:grant-type:token-exchange" ];
|
|
1203
|
+
const SUPPORTED_GRANT_TYPES = [ "authorization_code", "refresh_token", "urn:ietf:params:oauth:grant-type:token-exchange", "http://auth0.com/oauth/grant-type/mfa-oob", "http://auth0.com/oauth/grant-type/mfa-otp", "http://auth0.com/oauth/grant-type/mfa-recovery-code" ];
|
|
1197
1204
|
|
|
1198
1205
|
function generateKeyPair() {
|
|
1199
1206
|
return generateKeyPair$1(KEY_PAIR_ALGORITHM, {
|
|
@@ -1318,7 +1325,7 @@ async function getJSON(url, timeout, audience, scope, options, worker, useFormDa
|
|
|
1318
1325
|
if (!ok) {
|
|
1319
1326
|
const errorMessage = error_description || "HTTP error. Unable to fetch ".concat(url);
|
|
1320
1327
|
if (error === "mfa_required") {
|
|
1321
|
-
throw new MfaRequiredError(error, errorMessage, data.mfa_token);
|
|
1328
|
+
throw new MfaRequiredError(error, errorMessage, data.mfa_token, data.mfa_requirements);
|
|
1322
1329
|
}
|
|
1323
1330
|
if (error === "missing_refresh_token") {
|
|
1324
1331
|
throw new MissingRefreshTokenError(audience, scope);
|
|
@@ -2454,6 +2461,61 @@ class MyAccountApiError extends Error {
|
|
|
2454
2461
|
}
|
|
2455
2462
|
}
|
|
2456
2463
|
|
|
2464
|
+
const FACTOR_MAPPING = {
|
|
2465
|
+
otp: {
|
|
2466
|
+
authenticatorTypes: [ "otp" ]
|
|
2467
|
+
},
|
|
2468
|
+
sms: {
|
|
2469
|
+
authenticatorTypes: [ "oob" ],
|
|
2470
|
+
oobChannels: [ "sms" ]
|
|
2471
|
+
},
|
|
2472
|
+
email: {
|
|
2473
|
+
authenticatorTypes: [ "oob" ],
|
|
2474
|
+
oobChannels: [ "email" ]
|
|
2475
|
+
},
|
|
2476
|
+
push: {
|
|
2477
|
+
authenticatorTypes: [ "oob" ],
|
|
2478
|
+
oobChannels: [ "auth0" ]
|
|
2479
|
+
},
|
|
2480
|
+
voice: {
|
|
2481
|
+
authenticatorTypes: [ "oob" ],
|
|
2482
|
+
oobChannels: [ "voice" ]
|
|
2483
|
+
}
|
|
2484
|
+
};
|
|
2485
|
+
|
|
2486
|
+
const MfaGrantTypes = {
|
|
2487
|
+
OTP: "http://auth0.com/oauth/grant-type/mfa-otp",
|
|
2488
|
+
OOB: "http://auth0.com/oauth/grant-type/mfa-oob",
|
|
2489
|
+
RECOVERY_CODE: "http://auth0.com/oauth/grant-type/mfa-recovery-code"
|
|
2490
|
+
};
|
|
2491
|
+
|
|
2492
|
+
function getAuthJsEnrollParams(params) {
|
|
2493
|
+
const mapping = FACTOR_MAPPING[params.factorType];
|
|
2494
|
+
return Object.assign(Object.assign(Object.assign({
|
|
2495
|
+
mfaToken: params.mfaToken,
|
|
2496
|
+
authenticatorTypes: mapping.authenticatorTypes
|
|
2497
|
+
}, mapping.oobChannels && {
|
|
2498
|
+
oobChannels: mapping.oobChannels
|
|
2499
|
+
}), "phoneNumber" in params && {
|
|
2500
|
+
phoneNumber: params.phoneNumber
|
|
2501
|
+
}), "email" in params && {
|
|
2502
|
+
email: params.email
|
|
2503
|
+
});
|
|
2504
|
+
}
|
|
2505
|
+
|
|
2506
|
+
function getGrantType(params) {
|
|
2507
|
+
if ("otp" in params && params.otp) {
|
|
2508
|
+
return MfaGrantTypes.OTP;
|
|
2509
|
+
}
|
|
2510
|
+
if ("oobCode" in params && params.oobCode) {
|
|
2511
|
+
return MfaGrantTypes.OOB;
|
|
2512
|
+
}
|
|
2513
|
+
if ("recoveryCode" in params && params.recoveryCode) {
|
|
2514
|
+
return MfaGrantTypes.RECOVERY_CODE;
|
|
2515
|
+
}
|
|
2516
|
+
return undefined;
|
|
2517
|
+
}
|
|
2518
|
+
|
|
2457
2519
|
function _OverloadYield(e, d) {
|
|
2458
2520
|
this.v = e, this.k = d;
|
|
2459
2521
|
}
|
|
@@ -7036,7 +7098,7 @@ function stripUndefinedProperties(value) {
|
|
|
7036
7098
|
})), {});
|
|
7037
7099
|
}
|
|
7038
7100
|
|
|
7039
|
-
var MfaError = class MfaError extends Error {
|
|
7101
|
+
var MfaError$1 = class MfaError extends Error {
|
|
7040
7102
|
constructor(code, message, cause) {
|
|
7041
7103
|
super(message);
|
|
7042
7104
|
_defineProperty(this, "cause", void 0);
|
|
@@ -7050,28 +7112,28 @@ var MfaError = class MfaError extends Error {
|
|
|
7050
7112
|
}
|
|
7051
7113
|
};
|
|
7052
7114
|
|
|
7053
|
-
var MfaListAuthenticatorsError = class extends MfaError {
|
|
7115
|
+
var MfaListAuthenticatorsError$1 = class extends MfaError$1 {
|
|
7054
7116
|
constructor(message, cause) {
|
|
7055
7117
|
super("mfa_list_authenticators_error", message, cause);
|
|
7056
7118
|
this.name = "MfaListAuthenticatorsError";
|
|
7057
7119
|
}
|
|
7058
7120
|
};
|
|
7059
7121
|
|
|
7060
|
-
var MfaEnrollmentError = class extends MfaError {
|
|
7122
|
+
var MfaEnrollmentError$1 = class extends MfaError$1 {
|
|
7061
7123
|
constructor(message, cause) {
|
|
7062
7124
|
super("mfa_enrollment_error", message, cause);
|
|
7063
7125
|
this.name = "MfaEnrollmentError";
|
|
7064
7126
|
}
|
|
7065
7127
|
};
|
|
7066
7128
|
|
|
7067
|
-
var MfaDeleteAuthenticatorError = class extends MfaError {
|
|
7129
|
+
var MfaDeleteAuthenticatorError = class extends MfaError$1 {
|
|
7068
7130
|
constructor(message, cause) {
|
|
7069
7131
|
super("mfa_delete_authenticator_error", message, cause);
|
|
7070
7132
|
this.name = "MfaDeleteAuthenticatorError";
|
|
7071
7133
|
}
|
|
7072
7134
|
};
|
|
7073
7135
|
|
|
7074
|
-
var MfaChallengeError = class extends MfaError {
|
|
7136
|
+
var MfaChallengeError$1 = class extends MfaError$1 {
|
|
7075
7137
|
constructor(message, cause) {
|
|
7076
7138
|
super("mfa_challenge_error", message, cause);
|
|
7077
7139
|
this.name = "MfaChallengeError";
|
|
@@ -7149,7 +7211,7 @@ class MfaClient {
|
|
|
7149
7211
|
});
|
|
7150
7212
|
if (!response.ok) {
|
|
7151
7213
|
const error = await response.json();
|
|
7152
|
-
throw new MfaListAuthenticatorsError(error.error_description || "Failed to list authenticators", error);
|
|
7214
|
+
throw new MfaListAuthenticatorsError$1(error.error_description || "Failed to list authenticators", error);
|
|
7153
7215
|
}
|
|
7154
7216
|
const apiResponse = await response.json();
|
|
7155
7217
|
return apiResponse.map(transformAuthenticatorResponse);
|
|
@@ -7179,7 +7241,7 @@ class MfaClient {
|
|
|
7179
7241
|
});
|
|
7180
7242
|
if (!response.ok) {
|
|
7181
7243
|
const error = await response.json();
|
|
7182
|
-
throw new MfaEnrollmentError(error.error_description || "Failed to enroll authenticator", error);
|
|
7244
|
+
throw new MfaEnrollmentError$1(error.error_description || "Failed to enroll authenticator", error);
|
|
7183
7245
|
}
|
|
7184
7246
|
const apiResponse = await response.json();
|
|
7185
7247
|
return transformEnrollmentResponse(apiResponse);
|
|
@@ -7219,7 +7281,7 @@ class MfaClient {
|
|
|
7219
7281
|
});
|
|
7220
7282
|
if (!response.ok) {
|
|
7221
7283
|
const error = await response.json();
|
|
7222
|
-
throw new MfaChallengeError(error.error_description || "Failed to challenge authenticator", error);
|
|
7284
|
+
throw new MfaChallengeError$1(error.error_description || "Failed to challenge authenticator", error);
|
|
7223
7285
|
}
|
|
7224
7286
|
const apiResponse = await response.json();
|
|
7225
7287
|
return transformChallengeResponse(apiResponse);
|
|
@@ -7668,6 +7730,203 @@ async function _buildAuthorizationUrl(options) {
|
|
|
7668
7730
|
};
|
|
7669
7731
|
}
|
|
7670
7732
|
|
|
7733
|
+
class MfaError extends GenericError {
|
|
7734
|
+
constructor(error, error_description) {
|
|
7735
|
+
super(error, error_description);
|
|
7736
|
+
Object.setPrototypeOf(this, MfaError.prototype);
|
|
7737
|
+
}
|
|
7738
|
+
static fromPayload(_ref) {
|
|
7739
|
+
let {error: error, error_description: error_description} = _ref;
|
|
7740
|
+
return new MfaError(error, error_description);
|
|
7741
|
+
}
|
|
7742
|
+
}
|
|
7743
|
+
|
|
7744
|
+
class MfaListAuthenticatorsError extends MfaError {
|
|
7745
|
+
constructor(error, error_description) {
|
|
7746
|
+
super(error, error_description);
|
|
7747
|
+
Object.setPrototypeOf(this, MfaListAuthenticatorsError.prototype);
|
|
7748
|
+
}
|
|
7749
|
+
}
|
|
7750
|
+
|
|
7751
|
+
class MfaEnrollmentError extends MfaError {
|
|
7752
|
+
constructor(error, error_description) {
|
|
7753
|
+
super(error, error_description);
|
|
7754
|
+
Object.setPrototypeOf(this, MfaEnrollmentError.prototype);
|
|
7755
|
+
}
|
|
7756
|
+
}
|
|
7757
|
+
|
|
7758
|
+
class MfaChallengeError extends MfaError {
|
|
7759
|
+
constructor(error, error_description) {
|
|
7760
|
+
super(error, error_description);
|
|
7761
|
+
Object.setPrototypeOf(this, MfaChallengeError.prototype);
|
|
7762
|
+
}
|
|
7763
|
+
}
|
|
7764
|
+
|
|
7765
|
+
class MfaVerifyError extends MfaError {
|
|
7766
|
+
constructor(error, error_description) {
|
|
7767
|
+
super(error, error_description);
|
|
7768
|
+
Object.setPrototypeOf(this, MfaVerifyError.prototype);
|
|
7769
|
+
}
|
|
7770
|
+
}
|
|
7771
|
+
|
|
7772
|
+
class MfaEnrollmentFactorsError extends MfaError {
|
|
7773
|
+
constructor(error, error_description) {
|
|
7774
|
+
super(error, error_description);
|
|
7775
|
+
Object.setPrototypeOf(this, MfaEnrollmentFactorsError.prototype);
|
|
7776
|
+
}
|
|
7777
|
+
}
|
|
7778
|
+
|
|
7779
|
+
const DEFAULT_TTL_MS = 10 * 60 * 1e3;
|
|
7780
|
+
|
|
7781
|
+
class MfaContextManager {
|
|
7782
|
+
constructor() {
|
|
7783
|
+
let ttlMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_TTL_MS;
|
|
7784
|
+
this.contexts = new Map;
|
|
7785
|
+
this.ttlMs = ttlMs;
|
|
7786
|
+
}
|
|
7787
|
+
set(mfaToken, context) {
|
|
7788
|
+
this.cleanup();
|
|
7789
|
+
this.contexts.set(mfaToken, Object.assign(Object.assign({}, context), {
|
|
7790
|
+
createdAt: Date.now()
|
|
7791
|
+
}));
|
|
7792
|
+
}
|
|
7793
|
+
get(mfaToken) {
|
|
7794
|
+
const context = this.contexts.get(mfaToken);
|
|
7795
|
+
if (!context) {
|
|
7796
|
+
return undefined;
|
|
7797
|
+
}
|
|
7798
|
+
if (Date.now() - context.createdAt > this.ttlMs) {
|
|
7799
|
+
this.contexts.delete(mfaToken);
|
|
7800
|
+
return undefined;
|
|
7801
|
+
}
|
|
7802
|
+
return context;
|
|
7803
|
+
}
|
|
7804
|
+
remove(mfaToken) {
|
|
7805
|
+
this.contexts.delete(mfaToken);
|
|
7806
|
+
}
|
|
7807
|
+
cleanup() {
|
|
7808
|
+
const now = Date.now();
|
|
7809
|
+
for (const [key, value] of this.contexts) {
|
|
7810
|
+
if (now - value.createdAt > this.ttlMs) {
|
|
7811
|
+
this.contexts.delete(key);
|
|
7812
|
+
}
|
|
7813
|
+
}
|
|
7814
|
+
}
|
|
7815
|
+
get size() {
|
|
7816
|
+
return this.contexts.size;
|
|
7817
|
+
}
|
|
7818
|
+
}
|
|
7819
|
+
|
|
7820
|
+
class MfaApiClient {
|
|
7821
|
+
constructor(authJsMfaClient, auth0Client) {
|
|
7822
|
+
this.authJsMfaClient = authJsMfaClient;
|
|
7823
|
+
this.auth0Client = auth0Client;
|
|
7824
|
+
this.contextManager = new MfaContextManager;
|
|
7825
|
+
}
|
|
7826
|
+
setMFAAuthDetails(mfaToken, scope, audience, mfaRequirements) {
|
|
7827
|
+
this.contextManager.set(mfaToken, {
|
|
7828
|
+
scope: scope,
|
|
7829
|
+
audience: audience,
|
|
7830
|
+
mfaRequirements: mfaRequirements
|
|
7831
|
+
});
|
|
7832
|
+
}
|
|
7833
|
+
async getAuthenticators(mfaToken) {
|
|
7834
|
+
var _a, _b;
|
|
7835
|
+
const context = this.contextManager.get(mfaToken);
|
|
7836
|
+
if (!((_a = context === null || context === void 0 ? void 0 : context.mfaRequirements) === null || _a === void 0 ? void 0 : _a.challenge) || context.mfaRequirements.challenge.length === 0) {
|
|
7837
|
+
throw new MfaListAuthenticatorsError("invalid_request", "challengeType is required and must contain at least one challenge type, please check mfa_required error payload");
|
|
7838
|
+
}
|
|
7839
|
+
const challengeTypes = context.mfaRequirements.challenge.map((c => c.type));
|
|
7840
|
+
try {
|
|
7841
|
+
const allAuthenticators = await this.authJsMfaClient.listAuthenticators({
|
|
7842
|
+
mfaToken: mfaToken
|
|
7843
|
+
});
|
|
7844
|
+
return allAuthenticators.filter((auth => {
|
|
7845
|
+
if (!auth.type) return false;
|
|
7846
|
+
return challengeTypes.includes(auth.type);
|
|
7847
|
+
}));
|
|
7848
|
+
} catch (error) {
|
|
7849
|
+
if (error instanceof MfaListAuthenticatorsError$1) {
|
|
7850
|
+
throw new MfaListAuthenticatorsError((_b = error.cause) === null || _b === void 0 ? void 0 : _b.error, error.message);
|
|
7851
|
+
}
|
|
7852
|
+
throw error;
|
|
7853
|
+
}
|
|
7854
|
+
}
|
|
7855
|
+
async enroll(params) {
|
|
7856
|
+
var _a;
|
|
7857
|
+
const authJsParams = getAuthJsEnrollParams(params);
|
|
7858
|
+
try {
|
|
7859
|
+
return await this.authJsMfaClient.enrollAuthenticator(authJsParams);
|
|
7860
|
+
} catch (error) {
|
|
7861
|
+
if (error instanceof MfaEnrollmentError$1) {
|
|
7862
|
+
throw new MfaEnrollmentError((_a = error.cause) === null || _a === void 0 ? void 0 : _a.error, error.message);
|
|
7863
|
+
}
|
|
7864
|
+
throw error;
|
|
7865
|
+
}
|
|
7866
|
+
}
|
|
7867
|
+
async challenge(params) {
|
|
7868
|
+
var _a;
|
|
7869
|
+
try {
|
|
7870
|
+
const authJsParams = {
|
|
7871
|
+
challengeType: params.challengeType,
|
|
7872
|
+
mfaToken: params.mfaToken
|
|
7873
|
+
};
|
|
7874
|
+
if (params.authenticatorId) {
|
|
7875
|
+
authJsParams.authenticatorId = params.authenticatorId;
|
|
7876
|
+
}
|
|
7877
|
+
return await this.authJsMfaClient.challengeAuthenticator(authJsParams);
|
|
7878
|
+
} catch (error) {
|
|
7879
|
+
if (error instanceof MfaChallengeError$1) {
|
|
7880
|
+
throw new MfaChallengeError((_a = error.cause) === null || _a === void 0 ? void 0 : _a.error, error.message);
|
|
7881
|
+
}
|
|
7882
|
+
throw error;
|
|
7883
|
+
}
|
|
7884
|
+
}
|
|
7885
|
+
async getEnrollmentFactors(mfaToken) {
|
|
7886
|
+
const context = this.contextManager.get(mfaToken);
|
|
7887
|
+
if (!context || !context.mfaRequirements) {
|
|
7888
|
+
throw new MfaEnrollmentFactorsError("mfa_context_not_found", "MFA context not found for this MFA token. Please retry the original request to get a new MFA token.");
|
|
7889
|
+
}
|
|
7890
|
+
if (!context.mfaRequirements.enroll || context.mfaRequirements.enroll.length === 0) {
|
|
7891
|
+
return [];
|
|
7892
|
+
}
|
|
7893
|
+
return context.mfaRequirements.enroll;
|
|
7894
|
+
}
|
|
7895
|
+
async verify(params) {
|
|
7896
|
+
const context = this.contextManager.get(params.mfaToken);
|
|
7897
|
+
if (!context) {
|
|
7898
|
+
throw new MfaVerifyError("mfa_context_not_found", "MFA context not found for this MFA token. Please retry the original request to get a new MFA token.");
|
|
7899
|
+
}
|
|
7900
|
+
const grantType = getGrantType(params);
|
|
7901
|
+
if (!grantType) {
|
|
7902
|
+
throw new MfaVerifyError("invalid_request", "Unable to determine grant type. Provide one of: otp, oobCode, or recoveryCode.");
|
|
7903
|
+
}
|
|
7904
|
+
const scope = context.scope;
|
|
7905
|
+
const audience = context.audience;
|
|
7906
|
+
try {
|
|
7907
|
+
const result = await this.auth0Client._requestTokenForMfa({
|
|
7908
|
+
grant_type: grantType,
|
|
7909
|
+
mfaToken: params.mfaToken,
|
|
7910
|
+
scope: scope,
|
|
7911
|
+
audience: audience,
|
|
7912
|
+
otp: params.otp,
|
|
7913
|
+
oob_code: params.oobCode,
|
|
7914
|
+
binding_code: params.bindingCode,
|
|
7915
|
+
recovery_code: params.recoveryCode
|
|
7916
|
+
});
|
|
7917
|
+
this.contextManager.remove(params.mfaToken);
|
|
7918
|
+
return result;
|
|
7919
|
+
} catch (error) {
|
|
7920
|
+
if (error instanceof MfaRequiredError) {
|
|
7921
|
+
this.setMFAAuthDetails(error.mfa_token, scope, audience, error.mfa_requirements);
|
|
7922
|
+
} else if (error instanceof MfaVerifyError) {
|
|
7923
|
+
throw new MfaVerifyError(error.error, error.error_description);
|
|
7924
|
+
}
|
|
7925
|
+
throw error;
|
|
7926
|
+
}
|
|
7927
|
+
}
|
|
7928
|
+
}
|
|
7929
|
+
|
|
7671
7930
|
const lock = new _default;
|
|
7672
7931
|
|
|
7673
7932
|
class Auth0Client {
|
|
@@ -7737,6 +7996,7 @@ class Auth0Client {
|
|
|
7737
7996
|
domain: this.options.domain,
|
|
7738
7997
|
clientId: this.options.clientId
|
|
7739
7998
|
});
|
|
7999
|
+
this.mfa = new MfaApiClient(this.authJsClient.mfa, this);
|
|
7740
8000
|
if (typeof window !== "undefined" && window.Worker && this.options.useRefreshTokens && cacheLocation === CACHE_LOCATION_MEMORY) {
|
|
7741
8001
|
if (this.options.workerUrl) {
|
|
7742
8002
|
this.worker = new Worker(this.options.workerUrl);
|
|
@@ -7752,7 +8012,9 @@ class Auth0Client {
|
|
|
7752
8012
|
});
|
|
7753
8013
|
}
|
|
7754
8014
|
_url(path) {
|
|
7755
|
-
const
|
|
8015
|
+
const auth0ClientObj = this.options.auth0Client || DEFAULT_AUTH0_CLIENT;
|
|
8016
|
+
const strippedAuth0Client = stripAuth0Client(auth0ClientObj, true);
|
|
8017
|
+
const auth0Client = encodeURIComponent(btoa(JSON.stringify(strippedAuth0Client)));
|
|
7756
8018
|
return "".concat(this.domainUrl).concat(path, "&auth0Client=").concat(auth0Client);
|
|
7757
8019
|
}
|
|
7758
8020
|
_authorizeUrl(authorizeOptions) {
|
|
@@ -8133,6 +8395,7 @@ class Auth0Client {
|
|
|
8133
8395
|
}
|
|
8134
8396
|
}
|
|
8135
8397
|
async _getTokenUsingRefreshToken(options) {
|
|
8398
|
+
var _a, _b;
|
|
8136
8399
|
const cache = await this.cacheManager.get(new CacheKey({
|
|
8137
8400
|
scope: options.authorizationParams.scope,
|
|
8138
8401
|
audience: options.authorizationParams.audience || DEFAULT_AUDIENCE,
|
|
@@ -8183,6 +8446,9 @@ class Auth0Client {
|
|
|
8183
8446
|
if ((e.message.indexOf(MISSING_REFRESH_TOKEN_ERROR_MESSAGE) > -1 || e.message && e.message.indexOf(INVALID_REFRESH_TOKEN_ERROR_MESSAGE) > -1) && this.options.useRefreshTokensFallback) {
|
|
8184
8447
|
return await this._getTokenFromIFrame(options);
|
|
8185
8448
|
}
|
|
8449
|
+
if (e instanceof MfaRequiredError) {
|
|
8450
|
+
this.mfa.setMFAAuthDetails(e.mfa_token, (_a = options.authorizationParams) === null || _a === void 0 ? void 0 : _a.scope, (_b = options.authorizationParams) === null || _b === void 0 ? void 0 : _b.audience, e.mfa_requirements);
|
|
8451
|
+
}
|
|
8186
8452
|
throw e;
|
|
8187
8453
|
}
|
|
8188
8454
|
}
|
|
@@ -8352,6 +8618,12 @@ class Auth0Client {
|
|
|
8352
8618
|
window.location.assign(url);
|
|
8353
8619
|
}
|
|
8354
8620
|
}
|
|
8621
|
+
async _requestTokenForMfa(options, additionalParameters) {
|
|
8622
|
+
const {mfaToken: mfaToken} = options, restOptions = __rest(options, [ "mfaToken" ]);
|
|
8623
|
+
return this._requestToken(Object.assign(Object.assign({}, restOptions), {
|
|
8624
|
+
mfa_token: mfaToken
|
|
8625
|
+
}), additionalParameters);
|
|
8626
|
+
}
|
|
8355
8627
|
}
|
|
8356
8628
|
|
|
8357
8629
|
async function createAuth0Client(options) {
|
|
@@ -8374,8 +8646,22 @@ exports.InMemoryCache = InMemoryCache;
|
|
|
8374
8646
|
|
|
8375
8647
|
exports.LocalStorageCache = LocalStorageCache;
|
|
8376
8648
|
|
|
8649
|
+
exports.MfaApiClient = MfaApiClient;
|
|
8650
|
+
|
|
8651
|
+
exports.MfaChallengeError = MfaChallengeError;
|
|
8652
|
+
|
|
8653
|
+
exports.MfaEnrollmentError = MfaEnrollmentError;
|
|
8654
|
+
|
|
8655
|
+
exports.MfaEnrollmentFactorsError = MfaEnrollmentFactorsError;
|
|
8656
|
+
|
|
8657
|
+
exports.MfaError = MfaError;
|
|
8658
|
+
|
|
8659
|
+
exports.MfaListAuthenticatorsError = MfaListAuthenticatorsError;
|
|
8660
|
+
|
|
8377
8661
|
exports.MfaRequiredError = MfaRequiredError;
|
|
8378
8662
|
|
|
8663
|
+
exports.MfaVerifyError = MfaVerifyError;
|
|
8664
|
+
|
|
8379
8665
|
exports.MissingRefreshTokenError = MissingRefreshTokenError;
|
|
8380
8666
|
|
|
8381
8667
|
exports.MyAccountApiError = MyAccountApiError;
|