@airsoko/auth 0.0.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/dist/__generated__/globalTypes.d.ts +590 -0
- package/dist/__generated__/globalTypes.d.ts.map +1 -0
- package/dist/__generated__/globalTypes.js +607 -0
- package/dist/src/constants/endpoints.d.ts +5 -0
- package/dist/src/constants/endpoints.d.ts.map +1 -0
- package/dist/src/constants/endpoints.js +7 -0
- package/dist/src/constants/index.d.ts +6 -0
- package/dist/src/constants/index.d.ts.map +1 -0
- package/dist/src/constants/index.js +8 -0
- package/dist/src/core/AuthContext.d.ts +5 -0
- package/dist/src/core/AuthContext.d.ts.map +1 -0
- package/dist/src/core/AuthContext.js +10 -0
- package/dist/src/core/client.d.ts +108 -0
- package/dist/src/core/client.d.ts.map +1 -0
- package/dist/src/core/client.js +256 -0
- package/dist/src/core/old/SampleAuthProvider.d.ts +37 -0
- package/dist/src/core/old/SampleAuthProvider.d.ts.map +1 -0
- package/dist/src/core/old/SampleAuthProvider.js +123 -0
- package/dist/src/core/user/context.d.ts +56 -0
- package/dist/src/core/user/context.d.ts.map +1 -0
- package/dist/src/core/user/context.js +46 -0
- package/dist/src/core/user/hooks.d.ts +2 -0
- package/dist/src/core/user/hooks.d.ts.map +1 -0
- package/dist/src/core/user/hooks.js +5 -0
- package/dist/src/core/user/index.d.ts +4 -0
- package/dist/src/core/user/index.d.ts.map +1 -0
- package/dist/src/core/user/index.js +9 -0
- package/dist/src/core/user/provider.d.ts +19 -0
- package/dist/src/core/user/provider.d.ts.map +1 -0
- package/dist/src/core/user/provider.js +71 -0
- package/dist/src/data/checkDeviceSatus.d.ts +5 -0
- package/dist/src/data/checkDeviceSatus.d.ts.map +1 -0
- package/dist/src/data/checkDeviceSatus.js +58 -0
- package/dist/src/data/getMerchantUser.d.ts +3 -0
- package/dist/src/data/getMerchantUser.d.ts.map +1 -0
- package/dist/src/data/getMerchantUser.js +20 -0
- package/dist/src/data/getRegularUser.d.ts +3 -0
- package/dist/src/data/getRegularUser.d.ts.map +1 -0
- package/dist/src/data/getRegularUser.js +20 -0
- package/dist/src/graphql/__generated__/Logout.d.ts +4 -0
- package/dist/src/graphql/__generated__/Logout.d.ts.map +1 -0
- package/dist/src/graphql/__generated__/Logout.js +6 -0
- package/dist/src/graphql/__generated__/onboarding.d.ts +29 -0
- package/dist/src/graphql/__generated__/onboarding.d.ts.map +1 -0
- package/dist/src/graphql/__generated__/onboarding.js +6 -0
- package/dist/src/graphql/__generated__/onboardingShop.d.ts +66 -0
- package/dist/src/graphql/__generated__/onboardingShop.d.ts.map +1 -0
- package/dist/src/graphql/__generated__/onboardingShop.js +6 -0
- package/dist/src/graphql/queries.d.ts +10 -0
- package/dist/src/graphql/queries.d.ts.map +1 -0
- package/dist/src/graphql/queries.js +68 -0
- package/dist/src/graphql/typings.d.ts +66 -0
- package/dist/src/graphql/typings.d.ts.map +1 -0
- package/dist/src/graphql/typings.js +2 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +25 -0
- package/dist/src/utils/currentPageHasParam.d.ts +13 -0
- package/dist/src/utils/currentPageHasParam.d.ts.map +1 -0
- package/dist/src/utils/currentPageHasParam.js +23 -0
- package/dist/src/utils/getCookie.d.ts +7 -0
- package/dist/src/utils/getCookie.d.ts.map +1 -0
- package/dist/src/utils/getCookie.js +19 -0
- package/dist/src/utils/getMainDomain.d.ts +45 -0
- package/dist/src/utils/getMainDomain.d.ts.map +1 -0
- package/dist/src/utils/getMainDomain.js +73 -0
- package/dist/src/utils/getProtocol.d.ts +8 -0
- package/dist/src/utils/getProtocol.d.ts.map +1 -0
- package/dist/src/utils/getProtocol.js +13 -0
- package/dist/src/utils/getURL.d.ts +26 -0
- package/dist/src/utils/getURL.d.ts.map +1 -0
- package/dist/src/utils/getURL.js +56 -0
- package/dist/src/utils/index.d.ts +8 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +17 -0
- package/dist/src/utils/jwt/decode.d.ts +3 -0
- package/dist/src/utils/jwt/decode.d.ts.map +1 -0
- package/dist/src/utils/jwt/decode.js +32 -0
- package/dist/src/utils/jwt/encode.d.ts +3 -0
- package/dist/src/utils/jwt/encode.d.ts.map +1 -0
- package/dist/src/utils/jwt/encode.js +25 -0
- package/dist/src/utils/jwt/index.d.ts +3 -0
- package/dist/src/utils/jwt/index.d.ts.map +1 -0
- package/dist/src/utils/jwt/index.js +7 -0
- package/dist/src/utils/redirectToPathWithParams.d.ts +9 -0
- package/dist/src/utils/redirectToPathWithParams.d.ts.map +1 -0
- package/dist/src/utils/redirectToPathWithParams.js +22 -0
- package/dist/src/utils/setSharedCookie.d.ts +8 -0
- package/dist/src/utils/setSharedCookie.d.ts.map +1 -0
- package/dist/src/utils/setSharedCookie.js +21 -0
- package/package.json +35 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/user/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserAuthProvider = exports.useAuth = exports.UserAuthContext = void 0;
|
|
4
|
+
var context_1 = require("./context");
|
|
5
|
+
Object.defineProperty(exports, "UserAuthContext", { enumerable: true, get: function () { return context_1.UserAuthContext; } });
|
|
6
|
+
var hooks_1 = require("./hooks");
|
|
7
|
+
Object.defineProperty(exports, "useAuth", { enumerable: true, get: function () { return hooks_1.useAuth; } });
|
|
8
|
+
var provider_1 = require("./provider");
|
|
9
|
+
Object.defineProperty(exports, "UserAuthProvider", { enumerable: true, get: function () { return provider_1.UserAuthProvider; } });
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { AuthAudience } from "../../graphql/typings";
|
|
3
|
+
/**
|
|
4
|
+
* Represents the properties describing the device type context.
|
|
5
|
+
*/
|
|
6
|
+
export interface UserAuthProviderProps {
|
|
7
|
+
/** The child components. */
|
|
8
|
+
children: React.ReactNode;
|
|
9
|
+
/** The authentication service domain. */
|
|
10
|
+
domain: string;
|
|
11
|
+
/** The client ID used to authenticate the app. */
|
|
12
|
+
clientId: string;
|
|
13
|
+
/** The URI to which the authentication service redirects after successful authentication. */
|
|
14
|
+
redirectUri: string;
|
|
15
|
+
/** The target audience for the authentication service. */
|
|
16
|
+
audience: AuthAudience;
|
|
17
|
+
}
|
|
18
|
+
export declare function UserAuthProvider({ children, domain, clientId, redirectUri, audience, }: UserAuthProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/core/user/provider.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAIrD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,4BAA4B;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,6FAA6F;IAC7F,WAAW,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,QAAQ,EAAE,YAAY,CAAC;CACxB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,WAAW,EACX,QAAQ,GACT,EAAE,qBAAqB,2CAyFvB"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserAuthProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const client_1 = require("../client");
|
|
7
|
+
const context_1 = require("./context");
|
|
8
|
+
function UserAuthProvider({ children, domain, clientId, redirectUri, audience, }) {
|
|
9
|
+
/** Initializes the authentication client. */
|
|
10
|
+
const initialAuthClient = (domain, clientId, redirectUri, audience) => {
|
|
11
|
+
return new client_1.AuthClient(domain, clientId, redirectUri, audience);
|
|
12
|
+
};
|
|
13
|
+
const authClient = initialAuthClient(domain, clientId, redirectUri, audience);
|
|
14
|
+
const [authState, dispatch] = (0, react_1.useReducer)(context_1.AuthReducer, context_1.AuthState);
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
async function init() {
|
|
17
|
+
const isAuthenticated = await authClient.isAuthenticated();
|
|
18
|
+
if (isAuthenticated) {
|
|
19
|
+
const authUserProperties = await authClient.getUser();
|
|
20
|
+
dispatch({ type: "SET_USER", payload: Object.assign({}, authUserProperties) });
|
|
21
|
+
}
|
|
22
|
+
dispatch({ type: "RESOLVE", payload: { sessionLoading: false } });
|
|
23
|
+
}
|
|
24
|
+
init();
|
|
25
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
+
}, []);
|
|
27
|
+
/**
|
|
28
|
+
* Handles the authentication callback when the user is redirected back to the application
|
|
29
|
+
* after authenticating with Auth0.
|
|
30
|
+
*/
|
|
31
|
+
const handleAuthCallback = (0, react_1.useCallback)(async () => {
|
|
32
|
+
dispatch({ type: "SET_SESSION_LOADING", payload: true });
|
|
33
|
+
const authUserProperties = await authClient.getUser();
|
|
34
|
+
dispatch({ type: "SET_USER", payload: Object.assign({}, authUserProperties) });
|
|
35
|
+
dispatch({ type: "SET_SESSION_LOADING", payload: false });
|
|
36
|
+
}, [authClient, dispatch]);
|
|
37
|
+
const login = (0, react_1.useCallback)(async (token) => {
|
|
38
|
+
// try {
|
|
39
|
+
dispatch({ type: "SET_SESSION_LOADING", payload: true });
|
|
40
|
+
await authClient.setAuthToken(token);
|
|
41
|
+
const authUserProperties = await authClient.getUser();
|
|
42
|
+
dispatch({ type: "SET_USER", payload: Object.assign({}, authUserProperties) });
|
|
43
|
+
dispatch({ type: "SET_SESSION_LOADING", payload: false });
|
|
44
|
+
await authClient.storeUserIdentifiers(authUserProperties);
|
|
45
|
+
await authClient.redirectToStoredUrl();
|
|
46
|
+
}, [authClient, dispatch]);
|
|
47
|
+
const logout = (0, react_1.useCallback)(async () => {
|
|
48
|
+
try {
|
|
49
|
+
dispatch({ type: "SET_SESSION_LOADING", payload: true });
|
|
50
|
+
dispatch({ type: "LOGOUT", payload: null });
|
|
51
|
+
await authClient.logout();
|
|
52
|
+
await authClient.setAuthToken("");
|
|
53
|
+
dispatch({ type: "SET_SESSION_LOADING", payload: false });
|
|
54
|
+
await authClient.redirectToStoredUrl();
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new Error("invalid credentials");
|
|
58
|
+
}
|
|
59
|
+
}, [authClient, dispatch]);
|
|
60
|
+
(0, react_1.useEffect)(() => {
|
|
61
|
+
const init = async () => {
|
|
62
|
+
if (window.location.search.includes("code=")) {
|
|
63
|
+
await handleAuthCallback();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
init();
|
|
67
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
68
|
+
}, []);
|
|
69
|
+
return ((0, jsx_runtime_1.jsx)(context_1.UserAuthContext.Provider, { value: Object.assign(Object.assign({}, authState), { logout, goLogin: authClient.redirectToLogin.bind(authClient), signIn: login }), children: children }));
|
|
70
|
+
}
|
|
71
|
+
exports.UserAuthProvider = UserAuthProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkDeviceSatus.d.ts","sourceRoot":"","sources":["../../../src/data/checkDeviceSatus.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,gBAAgB,qBAQ5B,CAAA;AAID,eAAO,MAAM,mBAAmB;;CAiD/B,CAAA"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCheckDeviceSatus = exports.checkDeviceSatus = void 0;
|
|
4
|
+
const endpoints_1 = require("../constants/endpoints");
|
|
5
|
+
const checkDeviceSatus = async () => {
|
|
6
|
+
fetch(endpoints_1.BROWSER_AUTH_ENDPOINTS.DEVICE_STATUS_ENQUIRY, {
|
|
7
|
+
method: 'POST',
|
|
8
|
+
headers: {
|
|
9
|
+
'Content-Type': 'application/json',
|
|
10
|
+
},
|
|
11
|
+
// credentials: 'include',
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
exports.checkDeviceSatus = checkDeviceSatus;
|
|
15
|
+
const react_1 = require("react");
|
|
16
|
+
const useCheckDeviceSatus = () => {
|
|
17
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
18
|
+
(0, react_1.useEffect)(() => {
|
|
19
|
+
const abortController = new AbortController();
|
|
20
|
+
const abortSignal = abortController.signal;
|
|
21
|
+
const fetchData = async () => {
|
|
22
|
+
setIsLoading(true);
|
|
23
|
+
try {
|
|
24
|
+
const response = await fetch(endpoints_1.BROWSER_AUTH_ENDPOINTS.DEVICE_STATUS_ENQUIRY, {
|
|
25
|
+
method: 'GET',
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
},
|
|
29
|
+
credentials: 'include',
|
|
30
|
+
signal: abortSignal,
|
|
31
|
+
});
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
throw new Error('Network response was not ok');
|
|
34
|
+
}
|
|
35
|
+
// Process the response here
|
|
36
|
+
setIsLoading(false);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (error.name === 'AbortError') {
|
|
40
|
+
// eslint-disable-next-line no-console
|
|
41
|
+
console.log('Request was canceled');
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// eslint-disable-next-line no-console
|
|
45
|
+
console.error('Error:', error);
|
|
46
|
+
}
|
|
47
|
+
setIsLoading(false);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
fetchData();
|
|
51
|
+
// Cleanup function to abort the request if the component unmounts
|
|
52
|
+
return () => {
|
|
53
|
+
abortController.abort();
|
|
54
|
+
};
|
|
55
|
+
}, []);
|
|
56
|
+
return { isLoading };
|
|
57
|
+
};
|
|
58
|
+
exports.useCheckDeviceSatus = useCheckDeviceSatus;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMerchantUser.d.ts","sourceRoot":"","sources":["../../../src/data/getMerchantUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGxD,wBAAsB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAelG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMerchantUser = void 0;
|
|
4
|
+
const queries_1 = require("../graphql/queries");
|
|
5
|
+
async function getMerchantUser(authToken) {
|
|
6
|
+
var _a, _b, _c, _d;
|
|
7
|
+
const response = await (0, queries_1.OnboardingUser)();
|
|
8
|
+
const data = response.data;
|
|
9
|
+
if (!(data === null || data === void 0 ? void 0 : data.onboarding)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
user: data.onboarding,
|
|
14
|
+
shop: null,
|
|
15
|
+
currencyCode: (_b = (_a = data.onboarding) === null || _a === void 0 ? void 0 : _a.profile) === null || _b === void 0 ? void 0 : _b.currencyCode,
|
|
16
|
+
countryCode: (_d = (_c = data.onboarding) === null || _c === void 0 ? void 0 : _c.profile) === null || _d === void 0 ? void 0 : _d.countryCode,
|
|
17
|
+
staffMember: null,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.getMerchantUser = getMerchantUser;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getRegularUser.d.ts","sourceRoot":"","sources":["../../../src/data/getRegularUser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAGvD,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAejG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRegularUser = void 0;
|
|
4
|
+
const queries_1 = require("../graphql/queries");
|
|
5
|
+
async function getRegularUser(authToken) {
|
|
6
|
+
var _a, _b, _c, _d;
|
|
7
|
+
const response = await (0, queries_1.OnboardingUser)();
|
|
8
|
+
const data = response.data;
|
|
9
|
+
if (!(data === null || data === void 0 ? void 0 : data.onboarding)) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
user: data.onboarding,
|
|
14
|
+
shop: null,
|
|
15
|
+
currencyCode: (_b = (_a = data.onboarding) === null || _a === void 0 ? void 0 : _a.profile) === null || _b === void 0 ? void 0 : _b.currencyCode,
|
|
16
|
+
countryCode: (_d = (_c = data.onboarding) === null || _c === void 0 ? void 0 : _c.profile) === null || _d === void 0 ? void 0 : _d.countryCode,
|
|
17
|
+
staffMember: null,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.getRegularUser = getRegularUser;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Logout.d.ts","sourceRoot":"","sources":["../../../../src/graphql/__generated__/Logout.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,MAAM;IACrB,UAAU,EAAE,OAAO,GAAG,IAAI,CAAC;CAC5B"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { CurrencyCode, CountryCode } from "./../../../__generated__/globalTypes";
|
|
2
|
+
export interface onboarding_onboarding_avatar {
|
|
3
|
+
__typename: "Attachment";
|
|
4
|
+
src: string | null;
|
|
5
|
+
id: string;
|
|
6
|
+
type: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface onboarding_onboarding_profile {
|
|
9
|
+
__typename: "Profile";
|
|
10
|
+
currencyCode: CurrencyCode | null;
|
|
11
|
+
countryCode: CountryCode | null;
|
|
12
|
+
}
|
|
13
|
+
export interface onboarding_onboarding {
|
|
14
|
+
__typename: "Customer";
|
|
15
|
+
id: string | null;
|
|
16
|
+
name: string | null;
|
|
17
|
+
phone: string | null;
|
|
18
|
+
email: string | null;
|
|
19
|
+
initials: string | null;
|
|
20
|
+
username: string | null;
|
|
21
|
+
firstName: string | null;
|
|
22
|
+
lastName: string | null;
|
|
23
|
+
avatar: onboarding_onboarding_avatar | null;
|
|
24
|
+
profile: onboarding_onboarding_profile | null;
|
|
25
|
+
}
|
|
26
|
+
export interface onboarding {
|
|
27
|
+
onboarding: onboarding_onboarding | null;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=onboarding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding.d.ts","sourceRoot":"","sources":["../../../../src/graphql/__generated__/onboarding.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAMjF,MAAM,WAAW,4BAA4B;IAC3C,UAAU,EAAE,YAAY,CAAC;IACzB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,6BAA6B;IAC5C,UAAU,EAAE,SAAS,CAAC;IACtB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,WAAW,EAAE,WAAW,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,UAAU,CAAC;IACvB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,4BAA4B,GAAG,IAAI,CAAC;IAC5C,OAAO,EAAE,6BAA6B,GAAG,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,qBAAqB,GAAG,IAAI,CAAC;CAC1C"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { StaffPermissionLevel, PermissionType, CurrencyCode, ShopStatus, CountryCode } from "./../../../__generated__/globalTypes";
|
|
2
|
+
export interface onboardingShop_staffMember_user_avatar {
|
|
3
|
+
__typename: "Attachment";
|
|
4
|
+
src: string | null;
|
|
5
|
+
id: string;
|
|
6
|
+
type: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface onboardingShop_staffMember_user {
|
|
9
|
+
__typename: "Customer";
|
|
10
|
+
id: string | null;
|
|
11
|
+
name: string | null;
|
|
12
|
+
phone: string | null;
|
|
13
|
+
email: string | null;
|
|
14
|
+
initials: string | null;
|
|
15
|
+
username: string | null;
|
|
16
|
+
firstName: string | null;
|
|
17
|
+
lastName: string | null;
|
|
18
|
+
avatar: onboardingShop_staffMember_user_avatar | null;
|
|
19
|
+
}
|
|
20
|
+
export interface onboardingShop_staffMember {
|
|
21
|
+
__typename: "StaffMember";
|
|
22
|
+
id: string;
|
|
23
|
+
active: boolean;
|
|
24
|
+
permissionLevel: StaffPermissionLevel;
|
|
25
|
+
userPermissions: (PermissionType | null)[] | null;
|
|
26
|
+
user: onboardingShop_staffMember_user | null;
|
|
27
|
+
}
|
|
28
|
+
export interface onboardingShop_shop_logo {
|
|
29
|
+
__typename: "Attachment";
|
|
30
|
+
src: string | null;
|
|
31
|
+
}
|
|
32
|
+
export interface onboardingShop_shop_coverImage {
|
|
33
|
+
__typename: "Attachment";
|
|
34
|
+
src: string | null;
|
|
35
|
+
}
|
|
36
|
+
export interface onboardingShop_shop_settings {
|
|
37
|
+
__typename: "ShopSettings";
|
|
38
|
+
shopId: string;
|
|
39
|
+
currencyCode: CurrencyCode;
|
|
40
|
+
countryCode: CountryCode;
|
|
41
|
+
website: string | null;
|
|
42
|
+
domain: string | null;
|
|
43
|
+
primaryLocale: string | null;
|
|
44
|
+
}
|
|
45
|
+
export interface onboardingShop_shop {
|
|
46
|
+
__typename: "Shop";
|
|
47
|
+
id: string;
|
|
48
|
+
userId: string;
|
|
49
|
+
storeNo: string | null;
|
|
50
|
+
companyId: number | null;
|
|
51
|
+
name: string | null;
|
|
52
|
+
handle: string | null;
|
|
53
|
+
logo: onboardingShop_shop_logo | null;
|
|
54
|
+
coverImage: onboardingShop_shop_coverImage | null;
|
|
55
|
+
currencyCode: CurrencyCode | null;
|
|
56
|
+
phone: string | null;
|
|
57
|
+
isActive: number;
|
|
58
|
+
status: ShopStatus | null;
|
|
59
|
+
createdAt: any;
|
|
60
|
+
settings: onboardingShop_shop_settings | null;
|
|
61
|
+
}
|
|
62
|
+
export interface onboardingShop {
|
|
63
|
+
staffMember: onboardingShop_staffMember | null;
|
|
64
|
+
shop: onboardingShop_shop | null;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=onboardingShop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboardingShop.d.ts","sourceRoot":"","sources":["../../../../src/graphql/__generated__/onboardingShop.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAMnI,MAAM,WAAW,sCAAsC;IACrD,UAAU,EAAE,YAAY,CAAC;IACzB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,+BAA+B;IAC9C,UAAU,EAAE,UAAU,CAAC;IACvB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,EAAE,sCAAsC,GAAG,IAAI,CAAC;CACvD;AAED,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,aAAa,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,oBAAoB,CAAC;IACtC,eAAe,EAAE,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;IAClD,IAAI,EAAE,+BAA+B,GAAG,IAAI,CAAC;CAC9C;AAED,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,YAAY,CAAC;IACzB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,8BAA8B;IAC7C,UAAU,EAAE,YAAY,CAAC;IACzB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,4BAA4B;IAC3C,UAAU,EAAE,cAAc,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,EAAE,WAAW,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,IAAI,EAAE,wBAAwB,GAAG,IAAI,CAAC;IACtC,UAAU,EAAE,8BAA8B,GAAG,IAAI,CAAC;IAClD,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,GAAG,CAAC;IACf,QAAQ,EAAE,4BAA4B,GAAG,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,0BAA0B,GAAG,IAAI,CAAC;IAC/C,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAClC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logs the user out by removing the authentication token.
|
|
3
|
+
*/
|
|
4
|
+
export declare const LogoutUser: () => Promise<import("@apollo/client").FetchResult<any, Record<string, any>, Record<string, any>>>;
|
|
5
|
+
export declare const LogoutCustomer: () => Promise<import("@apollo/client").FetchResult<any, Record<string, any>, Record<string, any>>>;
|
|
6
|
+
/**
|
|
7
|
+
* Logs the user out by removing the authentication token.
|
|
8
|
+
*/
|
|
9
|
+
export declare const OnboardingUser: () => Promise<import("@apollo/client").ApolloQueryResult<any>>;
|
|
10
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/graphql/queries.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,eAAO,MAAM,UAAU,oGAStB,CAAC;AAEF,eAAO,MAAM,cAAc,oGAS1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,gEA8B1B,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OnboardingUser = exports.LogoutCustomer = exports.LogoutUser = void 0;
|
|
7
|
+
const client_1 = __importDefault(require("@airsoko/graphql/client"));
|
|
8
|
+
const client_2 = require("@apollo/client");
|
|
9
|
+
/**
|
|
10
|
+
* Logs the user out by removing the authentication token.
|
|
11
|
+
*/
|
|
12
|
+
const LogoutUser = async () => {
|
|
13
|
+
return await client_1.default.auth.mutate({
|
|
14
|
+
mutation: (0, client_2.gql) `
|
|
15
|
+
mutation Logout {
|
|
16
|
+
customerLogout
|
|
17
|
+
}
|
|
18
|
+
`,
|
|
19
|
+
fetchPolicy: "network-only",
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
exports.LogoutUser = LogoutUser;
|
|
23
|
+
const LogoutCustomer = async () => {
|
|
24
|
+
return await client_1.default.auth.mutate({
|
|
25
|
+
mutation: (0, client_2.gql) `
|
|
26
|
+
mutation Logout {
|
|
27
|
+
customerLogout
|
|
28
|
+
}
|
|
29
|
+
`,
|
|
30
|
+
fetchPolicy: "network-only",
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.LogoutCustomer = LogoutCustomer;
|
|
34
|
+
/**
|
|
35
|
+
* Logs the user out by removing the authentication token.
|
|
36
|
+
*/
|
|
37
|
+
const OnboardingUser = async () => {
|
|
38
|
+
return await client_1.default.auth.query({
|
|
39
|
+
query: (0, client_2.gql) `
|
|
40
|
+
query onboarding {
|
|
41
|
+
onboarding {
|
|
42
|
+
id
|
|
43
|
+
name
|
|
44
|
+
phone
|
|
45
|
+
email
|
|
46
|
+
phone
|
|
47
|
+
initials
|
|
48
|
+
username
|
|
49
|
+
firstName
|
|
50
|
+
lastName
|
|
51
|
+
avatar {
|
|
52
|
+
src
|
|
53
|
+
id
|
|
54
|
+
type
|
|
55
|
+
}
|
|
56
|
+
avatarOriginal
|
|
57
|
+
profile {
|
|
58
|
+
currencyCode
|
|
59
|
+
countryCode
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
`,
|
|
64
|
+
fetchPolicy: "network-only",
|
|
65
|
+
notifyOnNetworkStatusChange: true,
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
exports.OnboardingUser = OnboardingUser;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CountryCode, CurrencyCode } from "../../__generated__/globalTypes";
|
|
2
|
+
import { onboardingShop_shop, onboardingShop_staffMember, onboardingShop_staffMember_user } from "./__generated__/onboardingShop";
|
|
3
|
+
export interface LoginResult {
|
|
4
|
+
isAuthenticated: boolean;
|
|
5
|
+
user?: Record<string, unknown>;
|
|
6
|
+
error?: Error;
|
|
7
|
+
}
|
|
8
|
+
export type AuthUser = {
|
|
9
|
+
email: string;
|
|
10
|
+
initials: string;
|
|
11
|
+
phone: string;
|
|
12
|
+
firstName: string;
|
|
13
|
+
id: string;
|
|
14
|
+
lastName: string;
|
|
15
|
+
name: string;
|
|
16
|
+
avatar: AuthUserAvatar;
|
|
17
|
+
};
|
|
18
|
+
type AuthUserAvatar = {
|
|
19
|
+
src: string;
|
|
20
|
+
id: string;
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
export type ShopAuthResponseData = {
|
|
24
|
+
token: string;
|
|
25
|
+
shop: any;
|
|
26
|
+
accessToken: ShopAccessTokenData;
|
|
27
|
+
};
|
|
28
|
+
export type ShopAccessTokenData = {
|
|
29
|
+
expiresAt: string;
|
|
30
|
+
};
|
|
31
|
+
export interface AuthUserProperties {
|
|
32
|
+
user: onboardingShop_staffMember_user | null;
|
|
33
|
+
shop: onboardingShop_shop | null;
|
|
34
|
+
currencyCode: CurrencyCode | undefined;
|
|
35
|
+
countryCode: CountryCode | undefined;
|
|
36
|
+
staffMember: onboardingShop_staffMember;
|
|
37
|
+
}
|
|
38
|
+
export type AuthAudience = "CUSTOMER" | "MERCHANT" | "ADMIN";
|
|
39
|
+
/**
|
|
40
|
+
* Props for handling a successful shop login.
|
|
41
|
+
*/
|
|
42
|
+
export interface ShopLoginSuccessProps {
|
|
43
|
+
/**
|
|
44
|
+
* Data containing the shop authentication response.
|
|
45
|
+
*/
|
|
46
|
+
data: ShopAuthResponseData;
|
|
47
|
+
/**
|
|
48
|
+
* Options for customizing the login behavior.
|
|
49
|
+
*/
|
|
50
|
+
options?: {
|
|
51
|
+
/**
|
|
52
|
+
* The URL to redirect to after a successful login.
|
|
53
|
+
*/
|
|
54
|
+
redirectUrl?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Whether to clear the previous session cookies.
|
|
57
|
+
*/
|
|
58
|
+
clearPreviousSession?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Next action after login
|
|
61
|
+
*/
|
|
62
|
+
nextAction?: () => void;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=typings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typings.d.ts","sourceRoot":"","sources":["../../../src/graphql/typings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,+BAA+B,EAChC,MAAM,gCAAgC,CAAC;AACxC,MAAM,WAAW,WAAW;IAC1B,eAAe,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IAEd,QAAQ,EAAE,MAAM,CAAC;IAEjB,KAAK,EAAE,MAAM,CAAC;IAEd,SAAS,EAAE,MAAM,CAAC;IAElB,EAAE,EAAE,MAAM,CAAC;IAEX,QAAQ,EAAE,MAAM,CAAC;IAEjB,IAAI,EAAE,MAAM,CAAC;IAEb,MAAM,EAAE,cAAc,CAAC;CACxB,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,GAAG,CAAC;IACV,WAAW,EAAE,mBAAmB,CAAC;CAClC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,+BAA+B,GAAG,IAAI,CAAC;IAC7C,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACjC,YAAY,EAAE,YAAY,GAAG,SAAS,CAAC;IACvC,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,WAAW,EAAE,0BAA0B,CAAC;CACzC;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,IAAI,EAAE,oBAAoB,CAAC;IAE3B;;OAEG;IACH,OAAO,CAAC,EAAE;QACR;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QAErB;;WAEG;QACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;QAE/B;;WAEG;QACH,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;KACzB,CAAC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAChF,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.useCheckDeviceSatus = exports.checkDeviceSatus = exports.useAuth = exports.AuthProvider = void 0;
|
|
18
|
+
var AuthContext_1 = require("./core/AuthContext");
|
|
19
|
+
Object.defineProperty(exports, "AuthProvider", { enumerable: true, get: function () { return AuthContext_1.AuthProvider; } });
|
|
20
|
+
var user_1 = require("./core/user");
|
|
21
|
+
Object.defineProperty(exports, "useAuth", { enumerable: true, get: function () { return user_1.useAuth; } });
|
|
22
|
+
var checkDeviceSatus_1 = require("./data/checkDeviceSatus");
|
|
23
|
+
Object.defineProperty(exports, "checkDeviceSatus", { enumerable: true, get: function () { return checkDeviceSatus_1.checkDeviceSatus; } });
|
|
24
|
+
Object.defineProperty(exports, "useCheckDeviceSatus", { enumerable: true, get: function () { return checkDeviceSatus_1.useCheckDeviceSatus; } });
|
|
25
|
+
__exportStar(require("./graphql/typings"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the current page URL contains the specified query parameter.
|
|
3
|
+
* @param key - The query parameter key to check.
|
|
4
|
+
* @returns A boolean indicating whether the query parameter exists in the current page URL.
|
|
5
|
+
* @example
|
|
6
|
+
* // Check if the "redirectId" parameter exists in the current page URL
|
|
7
|
+
* const hasRedirectId = currentPageHasParam('redirectId');
|
|
8
|
+
* if (hasRedirectId) {
|
|
9
|
+
* // Do something
|
|
10
|
+
* }
|
|
11
|
+
*/
|
|
12
|
+
export declare function currentPageHasParam(key: string): boolean;
|
|
13
|
+
//# sourceMappingURL=currentPageHasParam.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currentPageHasParam.d.ts","sourceRoot":"","sources":["../../../src/utils/currentPageHasParam.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CASxD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.currentPageHasParam = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the current page URL contains the specified query parameter.
|
|
6
|
+
* @param key - The query parameter key to check.
|
|
7
|
+
* @returns A boolean indicating whether the query parameter exists in the current page URL.
|
|
8
|
+
* @example
|
|
9
|
+
* // Check if the "redirectId" parameter exists in the current page URL
|
|
10
|
+
* const hasRedirectId = currentPageHasParam('redirectId');
|
|
11
|
+
* if (hasRedirectId) {
|
|
12
|
+
* // Do something
|
|
13
|
+
* }
|
|
14
|
+
*/
|
|
15
|
+
function currentPageHasParam(key) {
|
|
16
|
+
if (typeof window === 'undefined') {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const currentURL = new URL(window.location.href);
|
|
20
|
+
const searchParams = currentURL.searchParams;
|
|
21
|
+
return searchParams.has(key);
|
|
22
|
+
}
|
|
23
|
+
exports.currentPageHasParam = currentPageHasParam;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility function to get the value of a cookie by name
|
|
3
|
+
* @param name The name of the cookie
|
|
4
|
+
* @returns The value of the cookie, or undefined if the cookie does not exist
|
|
5
|
+
*/
|
|
6
|
+
export declare function getCookie(name: string): string | undefined;
|
|
7
|
+
//# sourceMappingURL=getCookie.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getCookie.d.ts","sourceRoot":"","sources":["../../../src/utils/getCookie.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAS1D"}
|