@plasmicapp/react-web 0.2.165 → 0.2.166

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/dist/all.d.ts CHANGED
@@ -318,6 +318,7 @@ declare function Trans({ transKey, children }: TransProps): React__default.React
318
318
  interface PlasmicDataSourceContextValue {
319
319
  userAuthToken?: string;
320
320
  isUserLoading?: boolean;
321
+ authRedirectUri?: string;
321
322
  user?: {
322
323
  email: string;
323
324
  properties: Record<string, unknown> | null;
@@ -785,11 +785,11 @@ function uuidv4() {
785
785
  return (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16);
786
786
  });
787
787
  }
788
- function triggerLogin(_x, _x2) {
788
+ function triggerLogin(_x, _x2, _x3) {
789
789
  return _triggerLogin.apply(this, arguments);
790
790
  }
791
791
  function _triggerLogin() {
792
- _triggerLogin = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(appId, authorizeEndpoint) {
792
+ _triggerLogin = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(appId, authorizeEndpoint, redirectUri) {
793
793
  var sha256, _sha, continueTo, state, code_verifier, code_challenge, params, url;
794
794
  return runtime_1.wrap(function _callee2$(_context2) {
795
795
  while (1) {
@@ -822,7 +822,7 @@ function _triggerLogin() {
822
822
  }));
823
823
  return _sha.apply(this, arguments);
824
824
  };
825
- sha256 = function _sha2(_x3) {
825
+ sha256 = function _sha2(_x4) {
826
826
  return _sha.apply(this, arguments);
827
827
  };
828
828
  continueTo = window.location.href;
@@ -841,9 +841,12 @@ function _triggerLogin() {
841
841
  params.set("response_type", "code");
842
842
  params.set("code_challenge", code_challenge);
843
843
  params.set("code_challenge_method", "S256");
844
+ if (redirectUri) {
845
+ params.set("redirect_uri", redirectUri);
846
+ }
844
847
  url = authorizeEndpoint + "?" + params.toString();
845
848
  window.location.href = url;
846
- case 17:
849
+ case 18:
847
850
  case "end":
848
851
  return _context2.stop();
849
852
  }
@@ -862,7 +865,7 @@ function PlasmicPageGuard(props) {
862
865
  React__default.useEffect(function () {
863
866
  if (canTriggerLogin) {
864
867
  if (minRole && dataSourceCtxValue && "isUserLoading" in dataSourceCtxValue && !dataSourceCtxValue.isUserLoading && !dataSourceCtxValue.user) {
865
- triggerLogin(appId, authorizeEndpoint);
868
+ triggerLogin(appId, authorizeEndpoint, dataSourceCtxValue.authRedirectUri);
866
869
  }
867
870
  }
868
871
  }, [dataSourceCtxValue, appId, authorizeEndpoint, canTriggerLogin, minRole]);
@@ -884,7 +887,7 @@ function PlasmicPageGuard(props) {
884
887
  }
885
888
  return dataSourceCtxValue.user.roleIds.includes(minRole);
886
889
  }
887
- if (!dataSourceCtxValue || dataSourceCtxValue.isUserLoading || !dataSourceCtxValue.user && canTriggerLogin) {
890
+ if (!dataSourceCtxValue || dataSourceCtxValue.isUserLoading || !dataSourceCtxValue.user && minRole && canTriggerLogin) {
888
891
  return null;
889
892
  }
890
893
  if (!canUserViewPage()) {
@@ -2175,6 +2178,7 @@ function PlasmicRootProvider(props) {
2175
2178
  children = props.children,
2176
2179
  userAuthToken = props.userAuthToken,
2177
2180
  isUserLoading = props.isUserLoading,
2181
+ authRedirectUri = props.authRedirectUri,
2178
2182
  user = props.user;
2179
2183
  var context = React.useMemo(function () {
2180
2184
  return {
@@ -2185,9 +2189,10 @@ function PlasmicRootProvider(props) {
2185
2189
  return {
2186
2190
  userAuthToken: userAuthToken,
2187
2191
  user: user,
2188
- isUserLoading: isUserLoading
2192
+ isUserLoading: isUserLoading,
2193
+ authRedirectUri: authRedirectUri
2189
2194
  };
2190
- }, [userAuthToken, isUserLoading, user]);
2195
+ }, [userAuthToken, isUserLoading, user, authRedirectUri]);
2191
2196
  return React.createElement(PlasmicRootContext.Provider, {
2192
2197
  value: context
2193
2198
  }, React.createElement(ssr.SSRProvider, null, React.createElement(dataSourcesContext.PlasmicDataSourceContextProvider, {