@ovh-ux/manager-core-sso 0.2.0 → 0.2.1

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 CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.2.1](https://github.com/ovh/manager/compare/@ovh-ux/manager-core-sso@0.2.0...@ovh-ux/manager-core-sso@0.2.1) (2024-10-24)
7
+
8
+ **Note:** Version bump only for package @ovh-ux/manager-core-sso
9
+
10
+
11
+
12
+
13
+
6
14
  # [0.2.0](https://github.com/ovh/manager/compare/@ovh-ux/manager-core-sso@0.1.0...@ovh-ux/manager-core-sso@0.2.0) (2024-08-08)
7
15
 
8
16
 
@@ -0,0 +1,9 @@
1
+ export const DEFAULT_SSO_AUTH_URL = {
2
+ loginUrl: '/auth/',
3
+ logoutUrl: '/auth/?action=disconnect',
4
+ euLoginUrl: 'https://www.ovh.com/auth/',
5
+ euLogoutUrl: 'https://www.ovh.com/auth/?action=disconnect',
6
+ };
7
+ export default {
8
+ DEFAULT_SSO_AUTH_URL,
9
+ };
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ import { DEFAULT_SSO_AUTH_URL } from './constants';
2
+ const { loginUrl, logoutUrl, euLoginUrl, euLogoutUrl } = DEFAULT_SSO_AUTH_URL;
3
+ const buildRedirectUrl = (url, params) => {
4
+ return `${url}${url.indexOf('?') > -1 ? '&' : '?'}${params.join('&')}`;
5
+ };
6
+ const redirectTo = (url) => {
7
+ return window.location.assign(url);
8
+ };
9
+ const isOvhTelecom = () => window.location.host === 'www.ovhtelecom.fr';
10
+ export const redirectToLoginPage = (onsuccessUrl = '') => {
11
+ const params = [];
12
+ if (loginUrl.indexOf('onsuccess') === -1) {
13
+ params.push(`onsuccess=${encodeURIComponent(onsuccessUrl || window.location.href)}`);
14
+ }
15
+ // redirect to login url
16
+ redirectTo(buildRedirectUrl(isOvhTelecom() ? euLoginUrl : loginUrl, params));
17
+ };
18
+ export const redirectToLogoutPage = (onsuccessUrl = '') => {
19
+ const params = [];
20
+ if (logoutUrl.indexOf('onsuccess') === -1) {
21
+ params.push(`onsuccess=${encodeURIComponent(onsuccessUrl || window.location.href)}`);
22
+ }
23
+ if (logoutUrl.indexOf('from') === -1 && document.referrer) {
24
+ params.push(`from=${encodeURIComponent(document.referrer)}`);
25
+ }
26
+ // redirect to login url
27
+ redirectTo(buildRedirectUrl(isOvhTelecom() ? euLogoutUrl : logoutUrl, params));
28
+ };
29
+ export * from './constants';
30
+ export default {
31
+ DEFAULT_SSO_AUTH_URL,
32
+ redirectToLoginPage,
33
+ redirectToLogoutPage,
34
+ };
@@ -0,0 +1,15 @@
1
+ export declare const DEFAULT_SSO_AUTH_URL: {
2
+ loginUrl: string;
3
+ logoutUrl: string;
4
+ euLoginUrl: string;
5
+ euLogoutUrl: string;
6
+ };
7
+ declare const _default: {
8
+ DEFAULT_SSO_AUTH_URL: {
9
+ loginUrl: string;
10
+ logoutUrl: string;
11
+ euLoginUrl: string;
12
+ euLogoutUrl: string;
13
+ };
14
+ };
15
+ export default _default;
@@ -0,0 +1,14 @@
1
+ export declare const redirectToLoginPage: (onsuccessUrl?: string) => void;
2
+ export declare const redirectToLogoutPage: (onsuccessUrl?: string) => void;
3
+ export * from './constants';
4
+ declare const _default: {
5
+ DEFAULT_SSO_AUTH_URL: {
6
+ loginUrl: string;
7
+ logoutUrl: string;
8
+ euLoginUrl: string;
9
+ euLogoutUrl: string;
10
+ };
11
+ redirectToLoginPage: (onsuccessUrl?: string) => void;
12
+ redirectToLogoutPage: (onsuccessUrl?: string) => void;
13
+ };
14
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ovh-ux/manager-core-sso",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "",
5
5
  "license": "BSD-3-Clause",
6
6
  "author": "OVH SAS",
@@ -14,6 +14,7 @@
14
14
  "scripts": {
15
15
  "build": "tsc",
16
16
  "dev": "tsc",
17
+ "prepare": "tsc",
17
18
  "start:watch": "tsc -w"
18
19
  },
19
20
  "devDependencies": {