saasufy-components 3.27.3 → 3.28.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 CHANGED
@@ -222,8 +222,8 @@ So for example, if your `index.html` file is served up from the URL `http://mywe
222
222
  - `route-path`: The path of the page. Supports custom URL parameters in the format `/org/:orgId/user/:userId`.
223
223
  - `partial-route`: An optional attribute which, if specified, will allow the `route-path` to be matched partially from the start. This can be used to ignore the ending of a path which is not relevant to the page in order to avoid unnecessary re-renders.
224
224
  - `redirect`: An optional path/route which this page should redirect to. Note that the content of this page will not be shown so it should always be empty.
225
- - `no-auth-redirect`: An optional alternative path/route to redirect to if the user lands on this page but they are not authenticated. If the user is authenticated, then the content of the template will be displayed as normal.
226
- - `auth-redirect`: An optional alternative path/route to redirect to if the user lands on this page but they are already authenticated. If the user is not authenticated, then the content of the template will be displayed as normal.
225
+ - `no-auth-redirect`: An optional alternative path/route to redirect to if the user is on this page but they are not authenticated. If the user is authenticated, then the content of the template will be displayed as normal.
226
+ - `auth-redirect`: An optional alternative path/route to redirect to if the user is on this page but they are already authenticated. If the user is not authenticated, then the content of the template will be displayed as normal.
227
227
  - `hard-redirect`: An optional, additional attribute which can be specified alongside a `redirect`, `no-auth-redirect` or `auth-redirect` attribute to ensure that any redirect will change the URL in the address bar. Redirects are `soft` redirects by default; this means that they redirect the user to the target page but keep the current URL path unchanged.
228
228
 
229
229
  ### socket-provider
@@ -792,7 +792,8 @@ A link to initiate an OAuth flow to authenticate a user as part of log in. Can s
792
792
  - `provider` (required): The name of the provider. It must match the provider name specified on the `Authentication` page of your Saasufy control panel and also the value provided to the `oauth-handler` component at the end of the OAuth flow.
793
793
  - `client-id` (required): This is the client ID from the third-party OAuth provider.
794
794
  - `state-size`: This allows you to control the size (in bytes) of the random state string which is passed to the OAuth provider as part of the OAuth flow. Defaults to 20.
795
- - `state-session-storage-key`: The state string is stored in the browser's `sessionStorage` under this key. Defaults to `oauth.state`. It must match the value provided to the `oauth-handler` component at the end of the OAuth flow.
795
+ - `state-storage-key`: The state string is stored in the browser's `sessionStorage` under this key. Defaults to `oauth.state`. It must match the value provided to the `oauth-handler` component at the end of the OAuth flow.
796
+ - `use-local-storage`: By default, the state is stored inside sessionStorage. If this property is set, then the state will be stored inside localStorage instead. This is useful for sharing the state across different tabs. If set, this attribute should also be set on the related `oauth-handler` component.
796
797
 
797
798
  ### oauth-handler
798
799
 
@@ -818,10 +819,11 @@ When using an OAuth provider, the callback URL which you register with the provi
818
819
  - `success-url`: If authentication is successful, the browser's `location.href` will be set to this value. It can be used to redirect the user to their dashboard, for example.
819
820
  - `extra-data`: This attribute can be used to pass additional data to the OAuth `getAccessTokenURL` endpoint. For Google OAuth, for example, an additional `redirect_uri` field is required, so it should be set using `extra-data="redirect_uri=http://localhost.com:8000/"` (substitute the URI with your own).
820
821
  - `navigate-event-path`: If authentication is successful and a path is set via this attribute, the component will emit a `navigate` event which will bubble up the component hierarchy and can be used by a parent component to perform the success redirection. This approach can be used as an alternative to `success-location-hash` or `success-url` for doing the final redirect.
821
- - `state-session-storage-key`: The state string is stored in the browser's `sessionStorage` under this key. Defaults to `oauth.state`. It must match the value provided to the `oauth-link` component at the start of the OAuth flow.
822
+ - `state-storage-key`: The state string is stored in the browser's `sessionStorage` under this key. Defaults to `oauth.state`. It must match the value provided to the `oauth-link` component at the start of the OAuth flow.
822
823
  - `code-param-name`: The name of the query parameter which holds the `code` as provided by the OAuth provider within the OAuth callback URL. Defaults to `code`.
823
824
  - `state-param-name`: The name of the query parameter which holds the `state` as provided by the OAuth provider within the OAuth callback URL. Defaults to `state`.
824
825
  - `auth-timeout`: The number of milliseconds to wait for authentication to complete before timing out. Defaults to 10000 (10 seconds).
826
+ - `use-local-storage`: By default, the state is retrieved from sessionStorage. If this property is set, then the state will be retrieved from localStorage instead. This is useful for sharing the state across different tabs. If set, this attribute should also be set on the related `oauth-link` component.
825
827
 
826
828
  ### render-group
827
829
 
package/app-router.js CHANGED
@@ -149,6 +149,7 @@ export class AppRouter extends SocketConsumer {
149
149
  let defaultPage = this.getAttribute('default-page');
150
150
  if (!defaultPage) {
151
151
  routerViewport.innerHTML = '';
152
+ this.lastPageState = null;
152
153
  return;
153
154
  }
154
155
  routeArgs = this.computeRouteArgs(pagePath, regExp, params);
package/oauth-handler.js CHANGED
@@ -33,8 +33,9 @@ class OAuthHandler extends SocketConsumer {
33
33
  throw new Error('The provider attribute of oauth-handler was not specified');
34
34
  }
35
35
 
36
- let sessionStorageKey = this.getAttribute('state-session-storage-key') || 'oauth.state';
37
- let expectedOAuthState = sessionStorage.getItem(sessionStorageKey);
36
+ let useLocalStorage = this.hasAttribute('use-local-storage');
37
+ let storageKey = this.getAttribute('state-storage-key') || 'oauth.state';
38
+ let expectedOAuthState = (useLocalStorage ? localStorage : sessionStorage).getItem(storageKey);
38
39
  if (!expectedOAuthState) {
39
40
  this.innerHTML = `
40
41
  <div class="error">OAuth authentication failed because the state was missing.</div>
package/oauth-link.js CHANGED
@@ -16,7 +16,8 @@ class OAuthLink extends HTMLElement {
16
16
  'provider',
17
17
  'client-id',
18
18
  'state-size',
19
- 'state-session-storage-key'
19
+ 'state-storage-key',
20
+ 'use-local-storage'
20
21
  ];
21
22
  }
22
23
 
@@ -71,10 +72,11 @@ class OAuthLink extends HTMLElement {
71
72
  if (!provider) {
72
73
  throw new Error('The provider attribute of oauth-link was not specified');
73
74
  }
75
+ let useLocalStorage = this.hasAttribute('use-local-storage');
74
76
  let stateSize = Number(this.getAttribute('state-size') || 20);
75
- let sessionStorageKey = this.getAttribute('state-session-storage-key') || 'oauth.state';
77
+ let storageKey = this.getAttribute('state-storage-key') || 'oauth.state';
76
78
  this.state = `${provider}-${generateRandomHexString(stateSize)}`;
77
- sessionStorage.setItem(sessionStorageKey, this.state);
79
+ (useLocalStorage ? localStorage : sessionStorage).setItem(storageKey, this.state);
78
80
 
79
81
  this.shadowRoot.innerHTML = `
80
82
  <slot name="item"></slot>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saasufy-components",
3
- "version": "3.27.3",
3
+ "version": "3.28.0",
4
4
  "description": "Components for Saasufy.",
5
5
  "main": "index.js",
6
6
  "scripts": {