@plasmicapp/react-web 0.2.165 → 0.2.167

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.
@@ -780,11 +780,11 @@ function uuidv4() {
780
780
  return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
781
781
  });
782
782
  }
783
- function triggerLogin(_x, _x2) {
783
+ function triggerLogin(_x, _x2, _x3) {
784
784
  return _triggerLogin.apply(this, arguments);
785
785
  }
786
786
  function _triggerLogin() {
787
- _triggerLogin = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(appId, authorizeEndpoint) {
787
+ _triggerLogin = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(appId, authorizeEndpoint, redirectUri) {
788
788
  var sha256, _sha, continueTo, state, code_verifier, code_challenge, params, url;
789
789
  return runtime_1.wrap(function _callee2$(_context2) {
790
790
  while (1) {
@@ -817,7 +817,7 @@ function _triggerLogin() {
817
817
  }));
818
818
  return _sha.apply(this, arguments);
819
819
  };
820
- sha256 = function _sha2(_x3) {
820
+ sha256 = function _sha2(_x4) {
821
821
  return _sha.apply(this, arguments);
822
822
  };
823
823
  continueTo = window.location.href;
@@ -836,9 +836,12 @@ function _triggerLogin() {
836
836
  params.set("response_type", "code");
837
837
  params.set("code_challenge", code_challenge);
838
838
  params.set("code_challenge_method", "S256");
839
+ if (redirectUri) {
840
+ params.set("redirect_uri", redirectUri);
841
+ }
839
842
  url = authorizeEndpoint + "?" + params.toString();
840
843
  window.location.href = url;
841
- case 17:
844
+ case 18:
842
845
  case "end":
843
846
  return _context2.stop();
844
847
  }
@@ -857,7 +860,7 @@ function PlasmicPageGuard(props) {
857
860
  React__default.useEffect(function () {
858
861
  if (canTriggerLogin) {
859
862
  if (minRole && dataSourceCtxValue && "isUserLoading" in dataSourceCtxValue && !dataSourceCtxValue.isUserLoading && !dataSourceCtxValue.user) {
860
- triggerLogin(appId, authorizeEndpoint);
863
+ triggerLogin(appId, authorizeEndpoint, dataSourceCtxValue.authRedirectUri);
861
864
  }
862
865
  }
863
866
  }, [dataSourceCtxValue, appId, authorizeEndpoint, canTriggerLogin, minRole]);
@@ -879,7 +882,7 @@ function PlasmicPageGuard(props) {
879
882
  }
880
883
  return dataSourceCtxValue.user.roleIds.includes(minRole);
881
884
  }
882
- if (!dataSourceCtxValue || dataSourceCtxValue.isUserLoading || !dataSourceCtxValue.user && canTriggerLogin) {
885
+ if (!dataSourceCtxValue || dataSourceCtxValue.isUserLoading || !dataSourceCtxValue.user && minRole && canTriggerLogin) {
883
886
  return null;
884
887
  }
885
888
  if (!canUserViewPage()) {
@@ -2170,6 +2173,7 @@ function PlasmicRootProvider(props) {
2170
2173
  children = props.children,
2171
2174
  userAuthToken = props.userAuthToken,
2172
2175
  isUserLoading = props.isUserLoading,
2176
+ authRedirectUri = props.authRedirectUri,
2173
2177
  user = props.user;
2174
2178
  var context = useMemo(function () {
2175
2179
  return {
@@ -2180,9 +2184,10 @@ function PlasmicRootProvider(props) {
2180
2184
  return {
2181
2185
  userAuthToken: userAuthToken,
2182
2186
  user: user,
2183
- isUserLoading: isUserLoading
2187
+ isUserLoading: isUserLoading,
2188
+ authRedirectUri: authRedirectUri
2184
2189
  };
2185
- }, [userAuthToken, isUserLoading, user]);
2190
+ }, [userAuthToken, isUserLoading, user, authRedirectUri]);
2186
2191
  return createElement(PlasmicRootContext.Provider, {
2187
2192
  value: context
2188
2193
  }, createElement(SSRProvider, null, createElement(PlasmicDataSourceContextProvider, {