@stytch/vanilla-js 5.19.0 → 5.20.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 +18 -0
- package/dist/b2b/index.esm.js +20 -13
- package/dist/b2b/index.headless.esm.js +1 -1
- package/dist/b2b/index.headless.js +1 -1
- package/dist/b2b/index.js +20 -13
- package/dist/index.esm.js +1 -1
- package/dist/index.headless.esm.js +1 -1
- package/dist/index.headless.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @stytch/vanilla-js
|
|
2
2
|
|
|
3
|
+
## 5.20.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4427412: Allow specifying an organization slug via configuration when using the organization-specific auth flow, rather than relying on the URL. Specify an organization slug using `config.organizationSlug`.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [4427412]
|
|
12
|
+
- @stytch/core@2.45.0
|
|
13
|
+
|
|
14
|
+
## 5.19.1
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- b04388e: Fix incorrect error message when re-sending a B2B email one-time passcode fails
|
|
19
|
+
- c98bfe2: Informative error for discovery logins that are disallowed due to claimed email domains
|
|
20
|
+
|
|
3
21
|
## 5.19.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/b2b/index.esm.js
CHANGED
|
@@ -57,6 +57,7 @@ var ErrorType;
|
|
|
57
57
|
ErrorType[ErrorType["Organization"] = 2] = "Organization";
|
|
58
58
|
ErrorType[ErrorType["CannotJoinOrgDueToAuthPolicy"] = 3] = "CannotJoinOrgDueToAuthPolicy";
|
|
59
59
|
ErrorType[ErrorType["AdBlockerDetected"] = 4] = "AdBlockerDetected";
|
|
60
|
+
ErrorType[ErrorType["OrganizationDiscoveryClaimedDomain"] = 5] = "OrganizationDiscoveryClaimedDomain";
|
|
60
61
|
})(ErrorType || (ErrorType = {}));
|
|
61
62
|
var AppScreens$1;
|
|
62
63
|
(function (AppScreens) {
|
|
@@ -967,7 +968,7 @@ var ErrorScreen = function ErrorScreen() {
|
|
|
967
968
|
_useGlobalReducer2 = _slicedToArray(_useGlobalReducer, 1),
|
|
968
969
|
state = _useGlobalReducer2[0];
|
|
969
970
|
var currentErrorType = state.errorType;
|
|
970
|
-
var ErrorTypeMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ErrorType.Default, 'Something went wrong. Try again later or contact your admin for help.'), ErrorType.EmailMagicLink, 'Something went wrong. Your login link may have expired, been revoked, or been used more than once. Request a new login link to try again, or contact your admin for help.'), ErrorType.Organization, 'The organization you are looking for could not be found. If you think this is a mistake, contact your admin.'), ErrorType.CannotJoinOrgDueToAuthPolicy, "Unable to join due to ".concat((_b = (_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.organization_name) !== null && _b !== void 0 ? _b : 'the organization', "'s authentication policy. Please contact your admin for more information.")), ErrorType.AdBlockerDetected, 'The request was blocked by an Ad Blocker. Please disable your ad blocker, refresh the page, and try again.');
|
|
971
|
+
var ErrorTypeMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ErrorType.Default, 'Something went wrong. Try again later or contact your admin for help.'), ErrorType.EmailMagicLink, 'Something went wrong. Your login link may have expired, been revoked, or been used more than once. Request a new login link to try again, or contact your admin for help.'), ErrorType.Organization, 'The organization you are looking for could not be found. If you think this is a mistake, contact your admin.'), ErrorType.CannotJoinOrgDueToAuthPolicy, "Unable to join due to ".concat((_b = (_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.organization_name) !== null && _b !== void 0 ? _b : 'the organization', "'s authentication policy. Please contact your admin for more information.")), ErrorType.AdBlockerDetected, 'The request was blocked by an Ad Blocker. Please disable your ad blocker, refresh the page, and try again.'), ErrorType.OrganizationDiscoveryClaimedDomain, 'Your email domain is associated with a particular organization, so you are unable to join or create other organizations. Please contact your admin for more information.');
|
|
971
972
|
return /*#__PURE__*/wn.createElement(ErrorDisplay, {
|
|
972
973
|
text: ErrorTypeMap[currentErrorType]
|
|
973
974
|
});
|
|
@@ -1450,6 +1451,7 @@ var useMutate = function useMutate(key, fetcher, options) {
|
|
|
1450
1451
|
}));
|
|
1451
1452
|
};
|
|
1452
1453
|
var useExtractSlug = function useExtractSlug() {
|
|
1454
|
+
var _a;
|
|
1453
1455
|
var _useGlobalReducer7 = useGlobalReducer(),
|
|
1454
1456
|
_useGlobalReducer8 = _slicedToArray(_useGlobalReducer7, 2),
|
|
1455
1457
|
state = _useGlobalReducer8[0],
|
|
@@ -1458,8 +1460,9 @@ var useExtractSlug = function useExtractSlug() {
|
|
|
1458
1460
|
_h$2 = _slicedToArray(_h$, 2),
|
|
1459
1461
|
pattern = _h$2[0],
|
|
1460
1462
|
setPattern = _h$2[1];
|
|
1463
|
+
var config = useConfig();
|
|
1461
1464
|
var stytchClient = useStytch();
|
|
1462
|
-
var slug = extractFromPattern(pattern || null, window.location.href);
|
|
1465
|
+
var slug = (_a = config.organizationSlug) !== null && _a !== void 0 ? _a : extractFromPattern(pattern || null, window.location.href);
|
|
1463
1466
|
var _useMutate = useMutate('stytch.organization.getBySlug', function (_, _ref41) {
|
|
1464
1467
|
var slug = _ref41.arg.slug;
|
|
1465
1468
|
return stytchClient.organization.getBySlug({
|
|
@@ -1496,10 +1499,10 @@ var useExtractSlug = function useExtractSlug() {
|
|
|
1496
1499
|
});
|
|
1497
1500
|
}
|
|
1498
1501
|
}, [slug, state.flowState, state.screen]);
|
|
1502
|
+
var resultPending = pattern === undefined || isSearching;
|
|
1499
1503
|
return {
|
|
1500
|
-
isSearching: isSearching,
|
|
1501
1504
|
slug: slug,
|
|
1502
|
-
|
|
1505
|
+
resultPending: resultPending
|
|
1503
1506
|
};
|
|
1504
1507
|
};
|
|
1505
1508
|
var useBootstrap = function useBootstrap() {
|
|
@@ -3592,6 +3595,12 @@ var Discovery = function Discovery() {
|
|
|
3592
3595
|
}, {
|
|
3593
3596
|
onSuccess: function onSuccess(data) {
|
|
3594
3597
|
onAuthenticateSuccess(data, dispatch, config);
|
|
3598
|
+
},
|
|
3599
|
+
onError: function onError(error) {
|
|
3600
|
+
dispatch({
|
|
3601
|
+
type: 'set_error_message_and_transition',
|
|
3602
|
+
errorType: error.error_type === 'action_not_allowed_email_domain_is_claimed' ? ErrorType.OrganizationDiscoveryClaimedDomain : ErrorType.Default
|
|
3603
|
+
});
|
|
3595
3604
|
}
|
|
3596
3605
|
}),
|
|
3597
3606
|
stytchDiscoveryExchange = _useMutate3.trigger,
|
|
@@ -3604,10 +3613,10 @@ var Discovery = function Discovery() {
|
|
|
3604
3613
|
onSuccess: function onSuccess(data) {
|
|
3605
3614
|
onAuthenticateSuccess(data, dispatch, config);
|
|
3606
3615
|
},
|
|
3607
|
-
onError: function onError() {
|
|
3616
|
+
onError: function onError(error) {
|
|
3608
3617
|
dispatch({
|
|
3609
|
-
type: '
|
|
3610
|
-
|
|
3618
|
+
type: 'set_error_message_and_transition',
|
|
3619
|
+
errorType: error.error_type === 'action_not_allowed_email_domain_is_claimed' ? ErrorType.OrganizationDiscoveryClaimedDomain : ErrorType.Default
|
|
3611
3620
|
});
|
|
3612
3621
|
}
|
|
3613
3622
|
}),
|
|
@@ -4240,8 +4249,7 @@ var EmailOTPEntryScreen = function EmailOTPEntryScreen() {
|
|
|
4240
4249
|
resetAuthenticate = _useMutate6.reset;
|
|
4241
4250
|
var isAuthenticatingAny = isDiscoveryAuthenticating || isAuthenticating;
|
|
4242
4251
|
var authenticateAnyError = discoveryAuthenticateError || authenticateError;
|
|
4243
|
-
var
|
|
4244
|
-
var errorMessage = errorAny ? 'Invalid passcode, please try again.' : undefined;
|
|
4252
|
+
var errorMessage = authenticateAnyError ? 'Invalid passcode, please try again.' : sendError ? extractErrorMessage(sendError) : undefined;
|
|
4245
4253
|
var resetAll = function resetAll() {
|
|
4246
4254
|
resetDiscoveryAuthenticate();
|
|
4247
4255
|
resetAuthenticate();
|
|
@@ -7979,9 +7987,8 @@ var AppContainer$1 = function AppContainer$1() {
|
|
|
7979
7987
|
isDiscoveryLoading = _useMutate19.isMutating;
|
|
7980
7988
|
var isTokenAuthLoading = isMagicLinkLoading || isSSOLoading || isDiscoveryLoading || isDiscoveryOAuthLoading || isOAuthLoading || isImpersonationLoading;
|
|
7981
7989
|
var _useExtractSlug = useExtractSlug(),
|
|
7982
|
-
isSearching = _useExtractSlug.isSearching,
|
|
7983
7990
|
slug = _useExtractSlug.slug,
|
|
7984
|
-
|
|
7991
|
+
resultPending = _useExtractSlug.resultPending;
|
|
7985
7992
|
p$1(function () {
|
|
7986
7993
|
if (isOnlyFloatingOneTap) {
|
|
7987
7994
|
return;
|
|
@@ -8046,13 +8053,13 @@ var AppContainer$1 = function AppContainer$1() {
|
|
|
8046
8053
|
if (token && isSupportedTokenType(tokenType)) {
|
|
8047
8054
|
return;
|
|
8048
8055
|
}
|
|
8049
|
-
if (!slug &&
|
|
8056
|
+
if (!slug && !resultPending && state.flowState.organization === null && state.screen === AppScreens$1.Main && state.flowState.type == AuthFlowType.Organization) {
|
|
8050
8057
|
dispatch({
|
|
8051
8058
|
type: 'set_error_message_and_transition',
|
|
8052
8059
|
errorType: ErrorType.Organization
|
|
8053
8060
|
});
|
|
8054
8061
|
}
|
|
8055
|
-
}, [dispatch, isOnlyFloatingOneTap,
|
|
8062
|
+
}, [dispatch, isOnlyFloatingOneTap, isTokenAuthLoading, resultPending, slug, state.flowState.organization, state.flowState.type, state.screen, triggerError]);
|
|
8056
8063
|
if (isOnlyFloatingOneTap) {
|
|
8057
8064
|
return /*#__PURE__*/wn.createElement(B2BGoogleOneTap, null);
|
|
8058
8065
|
}
|
|
@@ -214,7 +214,7 @@ var ClientsideServicesProvider = /*#__PURE__*/function () {
|
|
|
214
214
|
}
|
|
215
215
|
}]);
|
|
216
216
|
}();
|
|
217
|
-
var version = "5.
|
|
217
|
+
var version = "5.20.0";
|
|
218
218
|
var NetworkClient = /*#__PURE__*/function () {
|
|
219
219
|
function NetworkClient(_publicToken, _subscriptionDataLayer, _liveAPIURL, _testAPIURL, additionalTelemetryDataFn) {
|
|
220
220
|
_classCallCheck(this, NetworkClient);
|
|
@@ -215,7 +215,7 @@ var ClientsideServicesProvider = /*#__PURE__*/function () {
|
|
|
215
215
|
}
|
|
216
216
|
}]);
|
|
217
217
|
}();
|
|
218
|
-
var version = "5.
|
|
218
|
+
var version = "5.20.0";
|
|
219
219
|
var NetworkClient = /*#__PURE__*/function () {
|
|
220
220
|
function NetworkClient(_publicToken, _subscriptionDataLayer, _liveAPIURL, _testAPIURL, additionalTelemetryDataFn) {
|
|
221
221
|
_classCallCheck(this, NetworkClient);
|
package/dist/b2b/index.js
CHANGED
|
@@ -58,6 +58,7 @@ var ErrorType;
|
|
|
58
58
|
ErrorType[ErrorType["Organization"] = 2] = "Organization";
|
|
59
59
|
ErrorType[ErrorType["CannotJoinOrgDueToAuthPolicy"] = 3] = "CannotJoinOrgDueToAuthPolicy";
|
|
60
60
|
ErrorType[ErrorType["AdBlockerDetected"] = 4] = "AdBlockerDetected";
|
|
61
|
+
ErrorType[ErrorType["OrganizationDiscoveryClaimedDomain"] = 5] = "OrganizationDiscoveryClaimedDomain";
|
|
61
62
|
})(ErrorType || (ErrorType = {}));
|
|
62
63
|
var AppScreens$1;
|
|
63
64
|
(function (AppScreens) {
|
|
@@ -968,7 +969,7 @@ var ErrorScreen = function ErrorScreen() {
|
|
|
968
969
|
_useGlobalReducer2 = _slicedToArray(_useGlobalReducer, 1),
|
|
969
970
|
state = _useGlobalReducer2[0];
|
|
970
971
|
var currentErrorType = state.errorType;
|
|
971
|
-
var ErrorTypeMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ErrorType.Default, 'Something went wrong. Try again later or contact your admin for help.'), ErrorType.EmailMagicLink, 'Something went wrong. Your login link may have expired, been revoked, or been used more than once. Request a new login link to try again, or contact your admin for help.'), ErrorType.Organization, 'The organization you are looking for could not be found. If you think this is a mistake, contact your admin.'), ErrorType.CannotJoinOrgDueToAuthPolicy, "Unable to join due to ".concat((_b = (_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.organization_name) !== null && _b !== void 0 ? _b : 'the organization', "'s authentication policy. Please contact your admin for more information.")), ErrorType.AdBlockerDetected, 'The request was blocked by an Ad Blocker. Please disable your ad blocker, refresh the page, and try again.');
|
|
972
|
+
var ErrorTypeMap = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ErrorType.Default, 'Something went wrong. Try again later or contact your admin for help.'), ErrorType.EmailMagicLink, 'Something went wrong. Your login link may have expired, been revoked, or been used more than once. Request a new login link to try again, or contact your admin for help.'), ErrorType.Organization, 'The organization you are looking for could not be found. If you think this is a mistake, contact your admin.'), ErrorType.CannotJoinOrgDueToAuthPolicy, "Unable to join due to ".concat((_b = (_a = state.flowState.organization) === null || _a === void 0 ? void 0 : _a.organization_name) !== null && _b !== void 0 ? _b : 'the organization', "'s authentication policy. Please contact your admin for more information.")), ErrorType.AdBlockerDetected, 'The request was blocked by an Ad Blocker. Please disable your ad blocker, refresh the page, and try again.'), ErrorType.OrganizationDiscoveryClaimedDomain, 'Your email domain is associated with a particular organization, so you are unable to join or create other organizations. Please contact your admin for more information.');
|
|
972
973
|
return /*#__PURE__*/extractErrorMessage.wn.createElement(ErrorDisplay, {
|
|
973
974
|
text: ErrorTypeMap[currentErrorType]
|
|
974
975
|
});
|
|
@@ -1451,6 +1452,7 @@ var useMutate = function useMutate(key, fetcher, options) {
|
|
|
1451
1452
|
}));
|
|
1452
1453
|
};
|
|
1453
1454
|
var useExtractSlug = function useExtractSlug() {
|
|
1455
|
+
var _a;
|
|
1454
1456
|
var _useGlobalReducer7 = useGlobalReducer(),
|
|
1455
1457
|
_useGlobalReducer8 = _slicedToArray(_useGlobalReducer7, 2),
|
|
1456
1458
|
state = _useGlobalReducer8[0],
|
|
@@ -1459,8 +1461,9 @@ var useExtractSlug = function useExtractSlug() {
|
|
|
1459
1461
|
_extractErrorMessage$7 = _slicedToArray(_extractErrorMessage$6, 2),
|
|
1460
1462
|
pattern = _extractErrorMessage$7[0],
|
|
1461
1463
|
setPattern = _extractErrorMessage$7[1];
|
|
1464
|
+
var config = useConfig();
|
|
1462
1465
|
var stytchClient = useStytch();
|
|
1463
|
-
var slug = extractFromPattern(pattern || null, window.location.href);
|
|
1466
|
+
var slug = (_a = config.organizationSlug) !== null && _a !== void 0 ? _a : extractFromPattern(pattern || null, window.location.href);
|
|
1464
1467
|
var _useMutate = useMutate('stytch.organization.getBySlug', function (_, _ref41) {
|
|
1465
1468
|
var slug = _ref41.arg.slug;
|
|
1466
1469
|
return stytchClient.organization.getBySlug({
|
|
@@ -1497,10 +1500,10 @@ var useExtractSlug = function useExtractSlug() {
|
|
|
1497
1500
|
});
|
|
1498
1501
|
}
|
|
1499
1502
|
}, [slug, state.flowState, state.screen]);
|
|
1503
|
+
var resultPending = pattern === undefined || isSearching;
|
|
1500
1504
|
return {
|
|
1501
|
-
isSearching: isSearching,
|
|
1502
1505
|
slug: slug,
|
|
1503
|
-
|
|
1506
|
+
resultPending: resultPending
|
|
1504
1507
|
};
|
|
1505
1508
|
};
|
|
1506
1509
|
var useBootstrap = function useBootstrap() {
|
|
@@ -3593,6 +3596,12 @@ var Discovery = function Discovery() {
|
|
|
3593
3596
|
}, {
|
|
3594
3597
|
onSuccess: function onSuccess(data) {
|
|
3595
3598
|
onAuthenticateSuccess(data, dispatch, config);
|
|
3599
|
+
},
|
|
3600
|
+
onError: function onError(error) {
|
|
3601
|
+
dispatch({
|
|
3602
|
+
type: 'set_error_message_and_transition',
|
|
3603
|
+
errorType: error.error_type === 'action_not_allowed_email_domain_is_claimed' ? ErrorType.OrganizationDiscoveryClaimedDomain : ErrorType.Default
|
|
3604
|
+
});
|
|
3596
3605
|
}
|
|
3597
3606
|
}),
|
|
3598
3607
|
stytchDiscoveryExchange = _useMutate3.trigger,
|
|
@@ -3605,10 +3614,10 @@ var Discovery = function Discovery() {
|
|
|
3605
3614
|
onSuccess: function onSuccess(data) {
|
|
3606
3615
|
onAuthenticateSuccess(data, dispatch, config);
|
|
3607
3616
|
},
|
|
3608
|
-
onError: function onError() {
|
|
3617
|
+
onError: function onError(error) {
|
|
3609
3618
|
dispatch({
|
|
3610
|
-
type: '
|
|
3611
|
-
|
|
3619
|
+
type: 'set_error_message_and_transition',
|
|
3620
|
+
errorType: error.error_type === 'action_not_allowed_email_domain_is_claimed' ? ErrorType.OrganizationDiscoveryClaimedDomain : ErrorType.Default
|
|
3612
3621
|
});
|
|
3613
3622
|
}
|
|
3614
3623
|
}),
|
|
@@ -4241,8 +4250,7 @@ var EmailOTPEntryScreen = function EmailOTPEntryScreen() {
|
|
|
4241
4250
|
resetAuthenticate = _useMutate6.reset;
|
|
4242
4251
|
var isAuthenticatingAny = isDiscoveryAuthenticating || isAuthenticating;
|
|
4243
4252
|
var authenticateAnyError = discoveryAuthenticateError || authenticateError;
|
|
4244
|
-
var
|
|
4245
|
-
var errorMessage = errorAny ? 'Invalid passcode, please try again.' : undefined;
|
|
4253
|
+
var errorMessage = authenticateAnyError ? 'Invalid passcode, please try again.' : sendError ? extractErrorMessage.extractErrorMessage(sendError) : undefined;
|
|
4246
4254
|
var resetAll = function resetAll() {
|
|
4247
4255
|
resetDiscoveryAuthenticate();
|
|
4248
4256
|
resetAuthenticate();
|
|
@@ -7980,9 +7988,8 @@ var AppContainer$1 = function AppContainer$1() {
|
|
|
7980
7988
|
isDiscoveryLoading = _useMutate19.isMutating;
|
|
7981
7989
|
var isTokenAuthLoading = isMagicLinkLoading || isSSOLoading || isDiscoveryLoading || isDiscoveryOAuthLoading || isOAuthLoading || isImpersonationLoading;
|
|
7982
7990
|
var _useExtractSlug = useExtractSlug(),
|
|
7983
|
-
isSearching = _useExtractSlug.isSearching,
|
|
7984
7991
|
slug = _useExtractSlug.slug,
|
|
7985
|
-
|
|
7992
|
+
resultPending = _useExtractSlug.resultPending;
|
|
7986
7993
|
extractErrorMessage.p(function () {
|
|
7987
7994
|
if (isOnlyFloatingOneTap) {
|
|
7988
7995
|
return;
|
|
@@ -8047,13 +8054,13 @@ var AppContainer$1 = function AppContainer$1() {
|
|
|
8047
8054
|
if (token && isSupportedTokenType(tokenType)) {
|
|
8048
8055
|
return;
|
|
8049
8056
|
}
|
|
8050
|
-
if (!slug &&
|
|
8057
|
+
if (!slug && !resultPending && state.flowState.organization === null && state.screen === AppScreens$1.Main && state.flowState.type == internal.AuthFlowType.Organization) {
|
|
8051
8058
|
dispatch({
|
|
8052
8059
|
type: 'set_error_message_and_transition',
|
|
8053
8060
|
errorType: ErrorType.Organization
|
|
8054
8061
|
});
|
|
8055
8062
|
}
|
|
8056
|
-
}, [dispatch, isOnlyFloatingOneTap,
|
|
8063
|
+
}, [dispatch, isOnlyFloatingOneTap, isTokenAuthLoading, resultPending, slug, state.flowState.organization, state.flowState.type, state.screen, triggerError]);
|
|
8057
8064
|
if (isOnlyFloatingOneTap) {
|
|
8058
8065
|
return /*#__PURE__*/extractErrorMessage.wn.createElement(B2BGoogleOneTap, null);
|
|
8059
8066
|
}
|