@ludo.ninja/components 2.2.54 → 2.2.56
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/build/layouts/AppLayout.d.ts +2 -2
- package/build/layouts/AppLayout.js +6 -4
- package/build/modules/user/auth/HOCAuthSearchParamsLocalhostInterceptor.d.ts +3 -0
- package/build/modules/user/auth/HOCAuthSearchParamsLocalhostInterceptor.js +36 -0
- package/build/utils/auth/index.js +3 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ReactNode } from "react";
|
|
2
1
|
import { AppProps } from "next/app";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
3
|
export declare const AppLayout: ({ children, pageProps }: {
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
pageProps: AppProps["pageProps"];
|
|
6
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
}) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<import("react").AwaitedReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AppLayout = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const styled_components_1 = require("styled-components");
|
|
6
|
-
const ui_1 = require("../store/ui");
|
|
7
|
-
const client_1 = require("@apollo/client");
|
|
8
5
|
const apollo_1 = require("../hooks/apollo");
|
|
9
6
|
const GlobalLayout_1 = require("./GlobalLayout");
|
|
7
|
+
const HOCAuthSearchParamsLocalhostInterceptor_1 = require("../modules/user/auth/HOCAuthSearchParamsLocalhostInterceptor");
|
|
10
8
|
const store_1 = require("../modules/user/store");
|
|
11
9
|
const index_1 = require("../store/index");
|
|
12
|
-
const
|
|
10
|
+
const ui_1 = require("../store/ui");
|
|
11
|
+
const client_1 = require("@apollo/client");
|
|
12
|
+
const styled_components_1 = require("styled-components");
|
|
13
|
+
const AppLayoutProviders = ({ children, pageProps }) => {
|
|
13
14
|
const apolloClient = (0, apollo_1.useApollo)(pageProps);
|
|
14
15
|
const theme = (0, ui_1.useUiStore)((state) => state.theme);
|
|
15
16
|
return ((0, jsx_runtime_1.jsx)(index_1.SSRProvider, { initialState: {
|
|
@@ -19,4 +20,5 @@ const AppLayout = ({ children, pageProps }) => {
|
|
|
19
20
|
isSignedIn: !!pageProps.userData,
|
|
20
21
|
}, children: (0, jsx_runtime_1.jsx)(GlobalLayout_1.GlobalLayout, { children: children }) }) }) }) }));
|
|
21
22
|
};
|
|
23
|
+
const AppLayout = ({ children, pageProps }) => (0, HOCAuthSearchParamsLocalhostInterceptor_1.HOCAuthSearchParamsLocalhostInterceptor)((0, jsx_runtime_1.jsx)(AppLayoutProviders, { pageProps: pageProps, children: children }), pageProps);
|
|
22
24
|
exports.AppLayout = AppLayout;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { AppProps } from "next/app";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
export declare const HOCAuthSearchParamsLocalhostInterceptor: (Component: ReactNode, pageProps: AppProps["pageProps"]) => string | number | bigint | boolean | Iterable<ReactNode> | Promise<import("react").AwaitedReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HOCAuthSearchParamsLocalhostInterceptor = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const env_1 = require("../../../store/env");
|
|
6
|
+
const api_1 = require("@ludo.ninja/api");
|
|
7
|
+
const router_1 = require("next/router");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const AuthLoginLocalhost = () => {
|
|
10
|
+
(0, react_1.useEffect)(() => {
|
|
11
|
+
const currentUrl = new URL(window.location.href);
|
|
12
|
+
const userId = currentUrl.searchParams.get("userId");
|
|
13
|
+
const wallets = currentUrl.searchParams.get("wallets");
|
|
14
|
+
const newUser = currentUrl.searchParams.get("newUser");
|
|
15
|
+
const inviteCode = currentUrl.searchParams.get("inviteCode");
|
|
16
|
+
const role = currentUrl.searchParams.get("role");
|
|
17
|
+
const authToken = currentUrl.searchParams.get("authToken");
|
|
18
|
+
const refreshToken = currentUrl.searchParams.get("refreshToken");
|
|
19
|
+
if (userId && wallets && authToken && refreshToken) {
|
|
20
|
+
api_1.authCookies.assignCookies(userId, JSON.parse(wallets), authToken, refreshToken, String(newUser), inviteCode?.toString() || "null", String(role), "localhost");
|
|
21
|
+
const paramsToRemove = ["userId", "wallets", "newUser", "inviteCode", "role", "authToken", "refreshToken"];
|
|
22
|
+
paramsToRemove.forEach((param) => currentUrl.searchParams.delete(param));
|
|
23
|
+
window.location.href = currentUrl.toString();
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
const HOCAuthSearchParamsLocalhostInterceptor = (Component, pageProps) => {
|
|
29
|
+
const router = (0, router_1.useRouter)();
|
|
30
|
+
const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_VALUE);
|
|
31
|
+
if (!pageProps.userData && router.query?.authToken && NEXT_PUBLIC_ENV_VALUE === "development") {
|
|
32
|
+
return (0, jsx_runtime_1.jsx)(AuthLoginLocalhost, {});
|
|
33
|
+
}
|
|
34
|
+
return Component;
|
|
35
|
+
};
|
|
36
|
+
exports.HOCAuthSearchParamsLocalhostInterceptor = HOCAuthSearchParamsLocalhostInterceptor;
|
|
@@ -5,6 +5,8 @@ const env_1 = require("../../store/env");
|
|
|
5
5
|
const ludoDomains_1 = require("@ludo.ninja/core/build/ludoDomains");
|
|
6
6
|
const useRedirectToLoginWindow = () => {
|
|
7
7
|
const NEXT_PUBLIC_ENV_VALUE = (0, env_1.useEnvStore)((state) => state.NEXT_PUBLIC_ENV_VALUE);
|
|
8
|
-
|
|
8
|
+
const isFromLocalhost = NEXT_PUBLIC_ENV_VALUE === "development";
|
|
9
|
+
const domainType = isFromLocalhost ? "stage" : NEXT_PUBLIC_ENV_VALUE;
|
|
10
|
+
return () => window.open(`${ludoDomains_1.ludoDomains[domainType]["auth"]}/login${isFromLocalhost ? "?isFromLocalhost=true&" : "?"}fallback_url=${window.location.href.replace(/\s/g, "")}`, "_self");
|
|
9
11
|
};
|
|
10
12
|
exports.useRedirectToLoginWindow = useRedirectToLoginWindow;
|