@oxyhq/services 0.0.47 → 0.0.49
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 +2 -0
- package/package.json +4 -10
- package/dist/AuthProvider.d.ts +0 -12
- package/dist/AuthProvider.d.ts.map +0 -1
- package/dist/AuthProvider.js +0 -41
- package/dist/assets/css/styles.css +0 -17
- package/dist/assets/dot-icon.d.ts +0 -3
- package/dist/assets/dot-icon.d.ts.map +0 -1
- package/dist/assets/dot-icon.js +0 -6
- package/dist/assets/verified-icon.d.ts +0 -3
- package/dist/assets/verified-icon.d.ts.map +0 -1
- package/dist/assets/verified-icon.js +0 -10
- package/dist/components/assets/oxy-logo.d.ts +0 -3
- package/dist/components/assets/oxy-logo.d.ts.map +0 -1
- package/dist/components/assets/oxy-logo.js +0 -30
- package/dist/components/auth/AccountSwitcher.d.ts +0 -7
- package/dist/components/auth/AccountSwitcher.d.ts.map +0 -1
- package/dist/components/auth/AccountSwitcher.js +0 -28
- package/dist/components/auth/AccountSwitcherModal.d.ts +0 -5
- package/dist/components/auth/AccountSwitcherModal.d.ts.map +0 -1
- package/dist/components/auth/AccountSwitcherModal.js +0 -53
- package/dist/components/auth/OAvatar.d.ts +0 -8
- package/dist/components/auth/OAvatar.d.ts.map +0 -1
- package/dist/components/auth/OAvatar.js +0 -18
- package/dist/components/auth/SessionOwnerButton.d.ts +0 -3
- package/dist/components/auth/SessionOwnerButton.d.ts.map +0 -1
- package/dist/components/auth/SessionOwnerButton.js +0 -30
- package/dist/components/auth/SignInButton.d.ts +0 -8
- package/dist/components/auth/SignInButton.d.ts.map +0 -1
- package/dist/components/auth/SignInButton.js +0 -15
- package/dist/components/auth/index.d.ts +0 -3
- package/dist/components/auth/index.d.ts.map +0 -1
- package/dist/components/auth/index.js +0 -2
- package/dist/components/auth/sign-in-button.module.css +0 -33
- package/dist/components/auth/sign-in-button.module.css.map +0 -1
- package/dist/components/auth/styles/oavatar.module.css +0 -34
- package/dist/components/auth/styles/oavatar.module.css.map +0 -1
- package/dist/components/auth/styles/session-owner-modal.module.css +0 -35
- package/dist/components/auth/styles/session-owner-modal.module.css.map +0 -1
- package/dist/components/auth/styles/sign-in-button.module.css +0 -30
- package/dist/components/auth/styles/sign-in-button.module.css.map +0 -1
- package/dist/components/elements/button/components/button.d.ts +0 -7
- package/dist/components/elements/button/components/button.d.ts.map +0 -1
- package/dist/components/elements/button/components/button.js +0 -6
- package/dist/components/elements/button/components/styles/button.module.css +0 -25
- package/dist/components/elements/button/components/styles/button.module.css.map +0 -1
- package/dist/components/elements/button/index.d.ts +0 -2
- package/dist/components/elements/button/index.d.ts.map +0 -1
- package/dist/components/elements/button/index.js +0 -1
- package/dist/components/elements/ellipsis-wrapper/components/ellipsis-wrapper.d.ts +0 -5
- package/dist/components/elements/ellipsis-wrapper/components/ellipsis-wrapper.d.ts.map +0 -1
- package/dist/components/elements/ellipsis-wrapper/components/ellipsis-wrapper.js +0 -4
- package/dist/components/elements/ellipsis-wrapper/components/styles/ellipses-wrapper.module.css +0 -11
- package/dist/components/elements/ellipsis-wrapper/components/styles/ellipses-wrapper.module.css.map +0 -1
- package/dist/components/elements/ellipsis-wrapper/index.d.ts +0 -2
- package/dist/components/elements/ellipsis-wrapper/index.d.ts.map +0 -1
- package/dist/components/elements/ellipsis-wrapper/index.js +0 -1
- package/dist/components/elements/modal/components/confirmation-modal.d.ts +0 -12
- package/dist/components/elements/modal/components/confirmation-modal.d.ts.map +0 -1
- package/dist/components/elements/modal/components/confirmation-modal.js +0 -21
- package/dist/components/elements/modal/components/modal.d.ts +0 -13
- package/dist/components/elements/modal/components/modal.d.ts.map +0 -1
- package/dist/components/elements/modal/components/modal.js +0 -111
- package/dist/components/elements/modal/components/styles/confirmation-modal.module.css +0 -105
- package/dist/components/elements/modal/components/styles/confirmation-modal.module.css.map +0 -1
- package/dist/components/elements/modal/components/styles/modal.module.css +0 -10
- package/dist/components/elements/modal/components/styles/modal.module.css.map +0 -1
- package/dist/components/elements/modal/hooks/use-track-position.d.ts +0 -5
- package/dist/components/elements/modal/hooks/use-track-position.d.ts.map +0 -1
- package/dist/components/elements/modal/hooks/use-track-position.js +0 -35
- package/dist/components/elements/modal/index.d.ts +0 -4
- package/dist/components/elements/modal/index.d.ts.map +0 -1
- package/dist/components/elements/modal/index.js +0 -3
- package/dist/config/index.d.ts +0 -21
- package/dist/config/index.d.ts.map +0 -1
- package/dist/config/index.js +0 -7
- package/dist/features/profile/components/avatar.d.ts +0 -10
- package/dist/features/profile/components/avatar.d.ts.map +0 -1
- package/dist/features/profile/components/avatar.js +0 -7
- package/dist/features/profile/components/styles/avatar.module.css +0 -15
- package/dist/features/profile/components/styles/avatar.module.css.map +0 -1
- package/dist/features/profile/components/styles/user-name.module.css +0 -18
- package/dist/features/profile/components/styles/user-name.module.css.map +0 -1
- package/dist/features/profile/components/styles/user-username.module.css +0 -6
- package/dist/features/profile/components/styles/user-username.module.css.map +0 -1
- package/dist/features/profile/components/user-name.d.ts +0 -7
- package/dist/features/profile/components/user-name.d.ts.map +0 -1
- package/dist/features/profile/components/user-name.js +0 -8
- package/dist/features/profile/components/user-username.d.ts +0 -5
- package/dist/features/profile/components/user-username.d.ts.map +0 -1
- package/dist/features/profile/components/user-username.js +0 -7
- package/dist/features/profile/index.d.ts +0 -4
- package/dist/features/profile/index.d.ts.map +0 -1
- package/dist/features/profile/index.js +0 -3
- package/dist/hooks/AuthService.d.ts +0 -14
- package/dist/hooks/AuthService.d.ts.map +0 -1
- package/dist/hooks/AuthService.js +0 -43
- package/dist/hooks/get-user.d.ts +0 -2
- package/dist/hooks/get-user.d.ts.map +0 -1
- package/dist/hooks/get-user.js +0 -28
- package/dist/hooks/getUserById.d.ts +0 -11
- package/dist/hooks/getUserById.d.ts.map +0 -1
- package/dist/hooks/getUserById.js +0 -20
- package/dist/hooks/use-user.d.ts +0 -14
- package/dist/hooks/use-user.d.ts.map +0 -1
- package/dist/hooks/use-user.js +0 -8
- package/dist/hooks/useOxySession.d.ts +0 -26
- package/dist/hooks/useOxySession.d.ts.map +0 -1
- package/dist/hooks/useOxySession.js +0 -45
- package/dist/hooks/usePeableSession.d.ts +0 -26
- package/dist/hooks/usePeableSession.d.ts.map +0 -1
- package/dist/hooks/usePeableSession.js +0 -45
- package/dist/index.css +0 -5
- package/dist/index.css.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -6
- package/dist/interfaces/index.d.ts +0 -10
- package/dist/interfaces/index.d.ts.map +0 -1
- package/dist/interfaces/index.js +0 -1
- package/dist/utils/cn.d.ts +0 -3
- package/dist/utils/cn.d.ts.map +0 -1
- package/dist/utils/cn.js +0 -5
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ReactNode } from "react";
|
|
3
|
-
interface AuthContextProps {
|
|
4
|
-
user: any;
|
|
5
|
-
login: () => void;
|
|
6
|
-
logout: () => void;
|
|
7
|
-
isAuthenticated: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare const AuthProvider: ({ children }: {
|
|
10
|
-
children: ReactNode;
|
|
11
|
-
}) => React.JSX.Element;
|
|
12
|
-
export declare const useAuth: () => AuthContextProps;
|
|
13
|
-
export {};
|
|
14
|
-
//# sourceMappingURL=AuthService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AuthService.d.ts","sourceRoot":"","sources":["../../src/hooks/AuthService.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAIL,SAAS,EAEV,MAAM,OAAO,CAAC;AAGf,UAAU,gBAAgB;IACxB,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAID,eAAO,MAAM,YAAY;cAA8B,SAAS;uBA0C/D,CAAC;AAEF,eAAO,MAAM,OAAO,wBAMnB,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { createContext, useContext, useState, useEffect, } from "react";
|
|
3
|
-
import axios from "axios";
|
|
4
|
-
const AuthContext = createContext(undefined);
|
|
5
|
-
export const AuthProvider = ({ children }) => {
|
|
6
|
-
const [user, setUser] = useState(null);
|
|
7
|
-
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
// Check if user session exists on mount
|
|
10
|
-
const token = localStorage.getItem("authToken");
|
|
11
|
-
if (token) {
|
|
12
|
-
authenticateToken(token);
|
|
13
|
-
}
|
|
14
|
-
}, []);
|
|
15
|
-
const authenticateToken = async (token) => {
|
|
16
|
-
try {
|
|
17
|
-
const response = await axios.post("https://auth.oxy.so/api/auth/validate", { token });
|
|
18
|
-
setUser(response.data.user);
|
|
19
|
-
setIsAuthenticated(true);
|
|
20
|
-
}
|
|
21
|
-
catch (error) {
|
|
22
|
-
setIsAuthenticated(false);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const login = () => {
|
|
26
|
-
const redirectUrl = `${window.location.origin}/auth/callback`;
|
|
27
|
-
window.location.href = `https://auth.oxy.so/api/auth/login?redirectUrl=${redirectUrl}`;
|
|
28
|
-
};
|
|
29
|
-
const logout = () => {
|
|
30
|
-
localStorage.removeItem("authToken");
|
|
31
|
-
setUser(null);
|
|
32
|
-
setIsAuthenticated(false);
|
|
33
|
-
window.location.href = `https://auth.oxy.so/api/auth/logout?redirectUrl=${window.location.origin}`;
|
|
34
|
-
};
|
|
35
|
-
return (React.createElement(AuthContext.Provider, { value: { user, login, logout, isAuthenticated } }, children));
|
|
36
|
-
};
|
|
37
|
-
export const useAuth = () => {
|
|
38
|
-
const context = useContext(AuthContext);
|
|
39
|
-
if (context === undefined) {
|
|
40
|
-
throw new Error("useAuth must be used within an AuthProvider");
|
|
41
|
-
}
|
|
42
|
-
return context;
|
|
43
|
-
};
|
package/dist/hooks/get-user.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-user.d.ts","sourceRoot":"","sources":["../../src/hooks/get-user.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,OAAc,MAAM,GAAG,SAAS,iBAsBnD,CAAC"}
|
package/dist/hooks/get-user.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { OXY_AUTH_URL } from "../config";
|
|
3
|
-
export const getUser = async (id) => {
|
|
4
|
-
try {
|
|
5
|
-
const response = await axios.get(OXY_AUTH_URL + `/api/users/${id}`);
|
|
6
|
-
return response.data;
|
|
7
|
-
}
|
|
8
|
-
catch (error) {
|
|
9
|
-
if (error.response) {
|
|
10
|
-
// The request was made and the server responded with a status code
|
|
11
|
-
// that falls out of the range of 2xx
|
|
12
|
-
console.log(error.response.data);
|
|
13
|
-
console.log(error.response.status);
|
|
14
|
-
console.log(error.response.headers);
|
|
15
|
-
}
|
|
16
|
-
else if (error.request) {
|
|
17
|
-
// The request was made but no response was received
|
|
18
|
-
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
|
|
19
|
-
// http.ClientRequest in node.js
|
|
20
|
-
console.log(error.request);
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
// Something happened in setting up the request that triggered an Error
|
|
24
|
-
console.log("Error", error.message);
|
|
25
|
-
}
|
|
26
|
-
console.log(error.config);
|
|
27
|
-
}
|
|
28
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
interface User {
|
|
2
|
-
id: string;
|
|
3
|
-
username: string;
|
|
4
|
-
name: string;
|
|
5
|
-
email: string;
|
|
6
|
-
role: string;
|
|
7
|
-
avatar: string;
|
|
8
|
-
}
|
|
9
|
-
declare const getUserById: (id?: string | string[], fields?: (keyof User)[]) => Promise<User>;
|
|
10
|
-
export default getUserById;
|
|
11
|
-
//# sourceMappingURL=getUserById.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getUserById.d.ts","sourceRoot":"","sources":["../../src/hooks/getUserById.ts"],"names":[],"mappings":"AAGA,UAAU,IAAI;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,QAAA,MAAM,WAAW,QAAe,MAAM,GAAG,MAAM,EAAE,WAAW,CAAC,MAAM,IAAI,CAAC,EAAE,kBAiBzE,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import axios from "axios";
|
|
2
|
-
import { OXY_AUTH_URL } from "../config";
|
|
3
|
-
const getUserById = async (id, fields) => {
|
|
4
|
-
try {
|
|
5
|
-
const response = await axios.get(OXY_AUTH_URL + `/api/users/${id}`);
|
|
6
|
-
const user = fields
|
|
7
|
-
? fields.reduce((obj, key) => ({ ...obj, [key]: response.data[key] }), {})
|
|
8
|
-
: response.data;
|
|
9
|
-
return user;
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
if (axios.isAxiosError(error)) {
|
|
13
|
-
throw new Error(error.message);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
throw new Error("An unknown error occurred while loading the user data.");
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
export default getUserById;
|
package/dist/hooks/use-user.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface IUser {
|
|
2
|
-
id: string;
|
|
3
|
-
username: string;
|
|
4
|
-
name: string;
|
|
5
|
-
email: string;
|
|
6
|
-
role: string;
|
|
7
|
-
avatar: string;
|
|
8
|
-
color: string;
|
|
9
|
-
}
|
|
10
|
-
export declare const useUser: ({ id, initialData: IUser, }: {
|
|
11
|
-
id: string | undefined;
|
|
12
|
-
initialData?: IUser;
|
|
13
|
-
}) => Promise<any>;
|
|
14
|
-
//# sourceMappingURL=use-user.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-user.d.ts","sourceRoot":"","sources":["../../src/hooks/use-user.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,OAAO,gCAGjB;IACD,EAAE,EAAE,MAAM,GAAG,SAAS,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC;CACrB,iBAMA,CAAC"}
|
package/dist/hooks/use-user.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
interface SessionModel {
|
|
2
|
-
user: {
|
|
3
|
-
id: string;
|
|
4
|
-
username: string;
|
|
5
|
-
name: string;
|
|
6
|
-
lastname: string;
|
|
7
|
-
email: string;
|
|
8
|
-
verified: boolean;
|
|
9
|
-
avatar: string;
|
|
10
|
-
created_at: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
type SessionState = {
|
|
14
|
-
session: SessionModel | null;
|
|
15
|
-
status: string;
|
|
16
|
-
error: any;
|
|
17
|
-
fetchSessionData: () => void;
|
|
18
|
-
};
|
|
19
|
-
export declare const useSessionStore: import("zustand").UseBoundStore<import("zustand").StoreApi<SessionState>>;
|
|
20
|
-
declare function useOxySession(): {
|
|
21
|
-
session: SessionModel | null;
|
|
22
|
-
status: string;
|
|
23
|
-
error: any;
|
|
24
|
-
};
|
|
25
|
-
export default useOxySession;
|
|
26
|
-
//# sourceMappingURL=useOxySession.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useOxySession.d.ts","sourceRoot":"","sources":["../../src/hooks/useOxySession.ts"],"names":[],"mappings":"AAOA,UAAU,YAAY;IACpB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,OAAO,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,GAAG,CAAC;IACX,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,eAAe,2EAmC1B,CAAC;AAEH,iBAAS,aAAa;;;;EAQrB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import { create } from "zustand";
|
|
4
|
-
import localforage from "localforage";
|
|
5
|
-
import { OXY_AUTH_URL } from "../config";
|
|
6
|
-
export const useSessionStore = create((set) => {
|
|
7
|
-
let isFirstFetch = true;
|
|
8
|
-
return {
|
|
9
|
-
session: null,
|
|
10
|
-
status: "loading",
|
|
11
|
-
error: null,
|
|
12
|
-
fetchSessionData: async () => {
|
|
13
|
-
try {
|
|
14
|
-
if (isFirstFetch) {
|
|
15
|
-
set({ status: "loading" });
|
|
16
|
-
isFirstFetch = false;
|
|
17
|
-
}
|
|
18
|
-
// Get the session ID from the URL parameters if it exists
|
|
19
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
20
|
-
let clientKey = urlParams.get("clientKey");
|
|
21
|
-
// If the session ID was not found in the URL parameters, get it from local storage
|
|
22
|
-
if (!clientKey) {
|
|
23
|
-
clientKey = await localforage.getItem("clientKey");
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
// If the session ID was found in the URL parameters, set it in local storage
|
|
27
|
-
await localforage.setItem("clientKey", clientKey);
|
|
28
|
-
}
|
|
29
|
-
const response = await axios.get(OXY_AUTH_URL + "/api/session/" + clientKey);
|
|
30
|
-
set({ session: response.data, status: "success" });
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
set({ error, status: "error" });
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
function useOxySession() {
|
|
39
|
-
const { session, status, error, fetchSessionData } = useSessionStore();
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
fetchSessionData();
|
|
42
|
-
}, []);
|
|
43
|
-
return { session, status, error };
|
|
44
|
-
}
|
|
45
|
-
export default useOxySession;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
interface SessionModel {
|
|
2
|
-
user: {
|
|
3
|
-
id: string;
|
|
4
|
-
username: string;
|
|
5
|
-
name: string;
|
|
6
|
-
lastname: string;
|
|
7
|
-
email: string;
|
|
8
|
-
verified: boolean;
|
|
9
|
-
profile_image_url: string;
|
|
10
|
-
created_at: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
type SessionState = {
|
|
14
|
-
session: SessionModel | null;
|
|
15
|
-
status: string;
|
|
16
|
-
error: any;
|
|
17
|
-
fetchSessionData: () => void;
|
|
18
|
-
};
|
|
19
|
-
export declare const useSessionStore: import("zustand").UseBoundStore<import("zustand").StoreApi<SessionState>>;
|
|
20
|
-
declare function useOxySession(): {
|
|
21
|
-
session: SessionModel | null;
|
|
22
|
-
status: string;
|
|
23
|
-
error: any;
|
|
24
|
-
};
|
|
25
|
-
export default useOxySession;
|
|
26
|
-
//# sourceMappingURL=usePeableSession.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"usePeableSession.d.ts","sourceRoot":"","sources":["../../src/hooks/usePeableSession.ts"],"names":[],"mappings":"AAOA,UAAU,YAAY;IACpB,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,OAAO,CAAC;QAClB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;CACH;AAED,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,GAAG,CAAC;IACX,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,eAAe,2EAmC1B,CAAC;AAEH,iBAAS,aAAa;;;;EAQrB;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import { create } from "zustand";
|
|
4
|
-
import localforage from "localforage";
|
|
5
|
-
import { OXY_AUTH_URL } from "../config";
|
|
6
|
-
export const useSessionStore = create((set) => {
|
|
7
|
-
let isFirstFetch = true;
|
|
8
|
-
return {
|
|
9
|
-
session: null,
|
|
10
|
-
status: "loading",
|
|
11
|
-
error: null,
|
|
12
|
-
fetchSessionData: async () => {
|
|
13
|
-
try {
|
|
14
|
-
if (isFirstFetch) {
|
|
15
|
-
set({ status: "loading" });
|
|
16
|
-
isFirstFetch = false;
|
|
17
|
-
}
|
|
18
|
-
// Get the session ID from the URL parameters if it exists
|
|
19
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
20
|
-
let clientKey = urlParams.get("clientKey");
|
|
21
|
-
// If the session ID was not found in the URL parameters, get it from local storage
|
|
22
|
-
if (!clientKey) {
|
|
23
|
-
clientKey = await localforage.getItem("clientKey");
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
// If the session ID was found in the URL parameters, set it in local storage
|
|
27
|
-
await localforage.setItem("clientKey", clientKey);
|
|
28
|
-
}
|
|
29
|
-
const response = await axios.get(OXY_AUTH_URL + "/api/session/" + clientKey);
|
|
30
|
-
set({ session: response.data, status: "success" });
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
set({ error, status: "error" });
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
});
|
|
38
|
-
function useOxySession() {
|
|
39
|
-
const { session, status, error, fetchSessionData } = useSessionStore();
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
fetchSessionData();
|
|
42
|
-
}, []);
|
|
43
|
-
return { session, status, error };
|
|
44
|
-
}
|
|
45
|
-
export default useOxySession;
|
package/dist/index.css
DELETED
package/dist/index.css.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../src/index.css"],"names":[],"mappings":"AAAA;AACA;AACA","file":"index.css"}
|
package/dist/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import useOxySession from "./hooks/useOxySession";
|
|
2
|
-
import getUserById from "./hooks/getUserById";
|
|
3
|
-
import SignInButton from "./components/auth/SignInButton";
|
|
4
|
-
import { AccountSwitcherModal } from "./components/auth/AccountSwitcherModal";
|
|
5
|
-
import { SessionOwnerButton } from "./components/auth/SessionOwnerButton";
|
|
6
|
-
export { useOxySession, getUserById, SignInButton, AccountSwitcherModal, SessionOwnerButton, };
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,uBAAuB,CAAC;AAClD,OAAO,WAAW,MAAM,qBAAqB,CAAC;AAC9C,OAAO,YAAY,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE1E,OAAO,EACL,aAAa,EACb,WAAW,EACX,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,GACnB,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import useOxySession from "./hooks/useOxySession";
|
|
2
|
-
import getUserById from "./hooks/getUserById";
|
|
3
|
-
import SignInButton from "./components/auth/SignInButton";
|
|
4
|
-
import { AccountSwitcherModal } from "./components/auth/AccountSwitcherModal";
|
|
5
|
-
import { SessionOwnerButton } from "./components/auth/SessionOwnerButton";
|
|
6
|
-
export { useOxySession, getUserById, SignInButton, AccountSwitcherModal, SessionOwnerButton, };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.tsx"],"names":[],"mappings":"AAaA,MAAM,WAAW,KAAK;IACpB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf"}
|
package/dist/interfaces/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/utils/cn.d.ts
DELETED
package/dist/utils/cn.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cn.d.ts","sourceRoot":"","sources":["../../src/utils/cn.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,UAAU,EAAE,MAAM,MAAM,CAAC;AAG7C,eAAO,MAAM,EAAE,cAAe,UAAU,EAAE,WAEzC,CAAC"}
|