@helpdice/sdk 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/README.md +1 -0
- package/dist/account/endpoint.d.ts +6 -0
- package/dist/account/endpoint.js +7 -0
- package/dist/account/endpoint.js.map +1 -0
- package/dist/account/index.d.ts +4 -0
- package/dist/account/index.js +7 -0
- package/dist/account/index.js.map +1 -0
- package/dist/accounting/endpoint.d.ts +7 -0
- package/dist/accounting/endpoint.js +9 -0
- package/dist/accounting/endpoint.js.map +1 -0
- package/dist/accounting/index.d.ts +5 -0
- package/dist/accounting/index.js +12 -0
- package/dist/accounting/index.js.map +1 -0
- package/dist/auth/endpoint.d.ts +8 -0
- package/dist/auth/endpoint.js +9 -0
- package/dist/auth/endpoint.js.map +1 -0
- package/dist/auth/index.d.ts +41 -0
- package/dist/auth/index.js +41 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/logout.d.ts +12 -0
- package/dist/auth/logout.js +18 -0
- package/dist/auth/logout.js.map +1 -0
- package/dist/auth/signInWithGoogle.d.ts +8 -0
- package/dist/auth/signInWithGoogle.js +47 -0
- package/dist/auth/signInWithGoogle.js.map +1 -0
- package/dist/auth/signin.d.ts +11 -0
- package/dist/auth/signin.js +13 -0
- package/dist/auth/signin.js.map +1 -0
- package/dist/auth/signup.d.ts +11 -0
- package/dist/auth/signup.js +13 -0
- package/dist/auth/signup.js.map +1 -0
- package/dist/auth/types.d.ts +15 -0
- package/dist/auth/types.js +2 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/config/Env.d.ts +38 -0
- package/dist/config/Env.js +50 -0
- package/dist/config/Env.js.map +1 -0
- package/dist/config/axios.d.ts +11 -0
- package/dist/config/axios.js +85 -0
- package/dist/config/axios.js.map +1 -0
- package/dist/config/constants.d.ts +12 -0
- package/dist/config/constants.js +19 -0
- package/dist/config/constants.js.map +1 -0
- package/dist/config/fetch.d.ts +7 -0
- package/dist/config/fetch.js +36 -0
- package/dist/config/fetch.js.map +1 -0
- package/dist/config/firebase.d.ts +3 -0
- package/dist/config/firebase.js +15 -0
- package/dist/config/firebase.js.map +1 -0
- package/dist/config/handler.d.ts +13 -0
- package/dist/config/handler.js +31 -0
- package/dist/config/handler.js.map +1 -0
- package/dist/config/local-storage.d.ts +1 -0
- package/dist/config/local-storage.js +30 -0
- package/dist/config/local-storage.js.map +1 -0
- package/dist/config/route.d.ts +1 -0
- package/dist/config/route.js +25 -0
- package/dist/config/route.js.map +1 -0
- package/dist/content/endpoint.d.ts +14 -0
- package/dist/content/endpoint.js +15 -0
- package/dist/content/endpoint.js.map +1 -0
- package/dist/content/index.d.ts +12 -0
- package/dist/content/index.js +27 -0
- package/dist/content/index.js.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +4 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useAuth.d.ts +1 -0
- package/dist/hooks/useAuth.js +24 -0
- package/dist/hooks/useAuth.js.map +1 -0
- package/dist/hooks/usePrivate.d.ts +1 -0
- package/dist/hooks/usePrivate.js +16 -0
- package/dist/hooks/usePrivate.js.map +1 -0
- package/dist/hooks/useUser.d.ts +8 -0
- package/dist/hooks/useUser.js +11 -0
- package/dist/hooks/useUser.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/order/create.d.ts +9 -0
- package/dist/order/create.js +13 -0
- package/dist/order/create.js.map +1 -0
- package/dist/order/endpoint.d.ts +6 -0
- package/dist/order/endpoint.js +7 -0
- package/dist/order/endpoint.js.map +1 -0
- package/dist/order/index.d.ts +10 -0
- package/dist/order/index.js +6 -0
- package/dist/order/index.js.map +1 -0
- package/dist/order/types.d.ts +10 -0
- package/dist/order/types.js +2 -0
- package/dist/order/types.js.map +1 -0
- package/dist/payment/endpoint.d.ts +7 -0
- package/dist/payment/endpoint.js +8 -0
- package/dist/payment/endpoint.js.map +1 -0
- package/dist/payment/index.d.ts +17 -0
- package/dist/payment/index.js +8 -0
- package/dist/payment/index.js.map +1 -0
- package/dist/payment/start.d.ts +21 -0
- package/dist/payment/start.js +59 -0
- package/dist/payment/start.js.map +1 -0
- package/dist/payment/types.d.ts +17 -0
- package/dist/payment/types.js +2 -0
- package/dist/payment/types.js.map +1 -0
- package/dist/payment/verify.d.ts +10 -0
- package/dist/payment/verify.js +13 -0
- package/dist/payment/verify.js.map +1 -0
- package/dist/support/endpoint.d.ts +8 -0
- package/dist/support/endpoint.js +9 -0
- package/dist/support/endpoint.js.map +1 -0
- package/dist/support/index.d.ts +22 -0
- package/dist/support/index.js +11 -0
- package/dist/support/index.js.map +1 -0
- package/dist/support/newsletter.d.ts +10 -0
- package/dist/support/newsletter.js +13 -0
- package/dist/support/newsletter.js.map +1 -0
- package/dist/support/ticket.d.ts +10 -0
- package/dist/support/ticket.js +13 -0
- package/dist/support/ticket.js.map +1 -0
- package/dist/utils/auth.d.ts +4 -0
- package/dist/utils/auth.js +11 -0
- package/dist/utils/auth.js.map +1 -0
- package/dist/utils/localStorage.d.ts +34 -0
- package/dist/utils/localStorage.js +127 -0
- package/dist/utils/localStorage.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { post } from "../config/axios.js";
|
|
2
|
+
import handler from "../config/handler.js";
|
|
3
|
+
import { getUrl } from "../config/route.js";
|
|
4
|
+
import verify from "./verify.js";
|
|
5
|
+
const start = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
6
|
+
return handler(post(getUrl("payment", "v1", "create"), data, config), {
|
|
7
|
+
onFetching: () => onFetching?.(),
|
|
8
|
+
onError: (error) => onError?.(error),
|
|
9
|
+
onSuccess: (res) => {
|
|
10
|
+
const data = res.data;
|
|
11
|
+
if (data?.method === "RazorPay") {
|
|
12
|
+
const options = data.options;
|
|
13
|
+
options.handler = async (response) => {
|
|
14
|
+
// toast.dismiss();
|
|
15
|
+
const body = {
|
|
16
|
+
id: data._id,
|
|
17
|
+
payment: response,
|
|
18
|
+
};
|
|
19
|
+
verify(body, {
|
|
20
|
+
onSuccess(data) {
|
|
21
|
+
onSuccess?.(data);
|
|
22
|
+
},
|
|
23
|
+
onError(error) {
|
|
24
|
+
onError?.(error);
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
// const validateRes = await fetch('http://localhost:5000/order/validate', {
|
|
28
|
+
// method: 'POST',
|
|
29
|
+
// body: JSON.stringify(body),
|
|
30
|
+
// headers: {
|
|
31
|
+
// 'Content-Type': 'application/json'
|
|
32
|
+
// }
|
|
33
|
+
// });
|
|
34
|
+
// const jsonRes = await validateRes.json();
|
|
35
|
+
// console.log(jsonRes);
|
|
36
|
+
};
|
|
37
|
+
// eslint-disable-next-line
|
|
38
|
+
// window['RazorPay'] = null;
|
|
39
|
+
// var rzp1 = new window.Razorpay(data.options);
|
|
40
|
+
// rzp1.on('payment.failed', function (response: any) {
|
|
41
|
+
// // toast.dismiss();
|
|
42
|
+
// onError && onError(response.error);
|
|
43
|
+
// // toast.error('Payment Failed, Please Try Again Later');
|
|
44
|
+
// // alert(response.error.code);
|
|
45
|
+
// // alert(response.error.description);
|
|
46
|
+
// // alert(response.error.source);
|
|
47
|
+
// // alert(response.error.step);
|
|
48
|
+
// // alert(response.error.reason);
|
|
49
|
+
// // alert(response.error.metadata.order_id);
|
|
50
|
+
// // alert(response.error.metadata.payment_id);
|
|
51
|
+
// });
|
|
52
|
+
// rzp1.open();
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
onSettled: () => onSettled?.(),
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
export default start;
|
|
59
|
+
//# sourceMappingURL=start.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/payment/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,OAAO,MAAM,sBAAsB,CAAC;AA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gBAC7B,gDAAgD;gBAChD,uDAAuD;gBACvD,0BAA0B;gBAC1B,0CAA0C;gBAC1C,gEAAgE;gBAEhE,qCAAqC;gBACrC,4CAA4C;gBAC5C,uCAAuC;gBACvC,qCAAqC;gBACrC,uCAAuC;gBACvC,kDAAkD;gBAClD,oDAAoD;gBACpD,MAAM;gBACN,eAAe;YAChB,CAAC;QACF,CAAC;QACD,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE;KAC9B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
type Method = {
|
|
2
|
+
label: string;
|
|
3
|
+
currency: number | string;
|
|
4
|
+
};
|
|
5
|
+
type Payment = {
|
|
6
|
+
data: never;
|
|
7
|
+
token: string;
|
|
8
|
+
method: Method;
|
|
9
|
+
amount: string | number;
|
|
10
|
+
entity: never;
|
|
11
|
+
term: number;
|
|
12
|
+
};
|
|
13
|
+
type VerifyPayment = {
|
|
14
|
+
id: string;
|
|
15
|
+
payment: never;
|
|
16
|
+
};
|
|
17
|
+
export type { Payment, Method, VerifyPayment };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/payment/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SuccessProps } from "./start.js";
|
|
2
|
+
import type { VerifyPayment } from "./types.js";
|
|
3
|
+
declare const verify: (data: VerifyPayment, { config, onFetching, onSuccess, onError, onSettled, }: {
|
|
4
|
+
onFetching?: () => void;
|
|
5
|
+
onSuccess?: (data: SuccessProps) => void;
|
|
6
|
+
onError?: (error: string) => void;
|
|
7
|
+
onSettled?: () => void;
|
|
8
|
+
config?: never;
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
export default verify;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { post } from "../config/axios.js";
|
|
2
|
+
import handler from "../config/handler.js";
|
|
3
|
+
import { getUrl } from "../config/route.js";
|
|
4
|
+
const verify = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
5
|
+
return handler(post(getUrl("payment", "v1", "verify"), data, config), {
|
|
6
|
+
onFetching: () => onFetching?.(),
|
|
7
|
+
onError: (error) => onError?.(error),
|
|
8
|
+
onSuccess: (data) => onSuccess?.(data),
|
|
9
|
+
onSettled: () => onSettled?.(),
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export default verify;
|
|
13
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../src/payment/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAI5C,MAAM,MAAM,GAAG,CACd,IAAmB,EACnB,EACC,MAAM,EACN,UAAU,EACV,SAAS,EACT,OAAO,EACP,SAAS,GAOT,EACA,EAAE;IACH,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE;QACrE,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,EAAE;QAChC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC;QACpC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC;QACtC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE;KAC9B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpoint.js","sourceRoot":"","sources":["../../src/support/endpoint.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG;IACf,EAAE,EAAE;QACH,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,SAAS;QAClB,UAAU,EAAE,YAAY;KACxB;CACD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare const Support: {
|
|
2
|
+
ticket: (data: never, { config, onFetching, onSuccess, onError, onSettled, }: {
|
|
3
|
+
onFetching?: () => void;
|
|
4
|
+
onSuccess?: (data: object) => void;
|
|
5
|
+
onError?: (error: string) => void;
|
|
6
|
+
onSettled?: () => void;
|
|
7
|
+
config?: {
|
|
8
|
+
params: never;
|
|
9
|
+
};
|
|
10
|
+
}) => Promise<void>;
|
|
11
|
+
newsletter: (data: never, { config, onFetching, onSuccess, onError, onSettled, }: {
|
|
12
|
+
onFetching?: () => void;
|
|
13
|
+
onSuccess?: (data: object) => void;
|
|
14
|
+
onError?: (error: string) => void;
|
|
15
|
+
onSettled?: () => void;
|
|
16
|
+
config?: {
|
|
17
|
+
params: never;
|
|
18
|
+
};
|
|
19
|
+
}) => Promise<void>;
|
|
20
|
+
tickets: (config?: object | undefined) => Promise<import("axios").AxiosResponse<any, any>>;
|
|
21
|
+
};
|
|
22
|
+
export default Support;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { get } from "../config/axios.js";
|
|
2
|
+
import { getUrl } from "../config/route.js";
|
|
3
|
+
import newsletter from "./newsletter.js";
|
|
4
|
+
import ticket from "./ticket.js";
|
|
5
|
+
const Support = {
|
|
6
|
+
ticket,
|
|
7
|
+
newsletter,
|
|
8
|
+
tickets: (config) => get(getUrl("support", "v1", "tickets"), config),
|
|
9
|
+
};
|
|
10
|
+
export default Support;
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/support/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,MAAM,OAAO,GAAG;IACf,MAAM;IACN,UAAU;IACV,OAAO,EAAE,CAAC,MAA2B,EAAE,EAAE,CACxC,GAAG,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,MAAM,CAAC;CAChD,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const newsletter: (data: never, { config, onFetching, onSuccess, onError, onSettled, }: {
|
|
2
|
+
onFetching?: () => void;
|
|
3
|
+
onSuccess?: (data: object) => void;
|
|
4
|
+
onError?: (error: string) => void;
|
|
5
|
+
onSettled?: () => void;
|
|
6
|
+
config?: {
|
|
7
|
+
params: never;
|
|
8
|
+
};
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
export default newsletter;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { post } from "../config/axios.js";
|
|
2
|
+
import handler from "../config/handler.js";
|
|
3
|
+
import { getUrl } from "../config/route.js";
|
|
4
|
+
const newsletter = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
5
|
+
return handler(post(getUrl("support", "v1", "newsletter"), data, config), {
|
|
6
|
+
onFetching: () => onFetching?.(),
|
|
7
|
+
onError: (error) => onError?.(error),
|
|
8
|
+
onSuccess: (data) => onSuccess?.(data),
|
|
9
|
+
onSettled: () => onSettled?.(),
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export default newsletter;
|
|
13
|
+
//# sourceMappingURL=newsletter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"newsletter.js","sourceRoot":"","sources":["../../src/support/newsletter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,UAAU,GAAG,CAClB,IAAW,EACX,EACC,MAAM,EACN,UAAU,EACV,SAAS,EACT,OAAO,EACP,SAAS,GAOT,EACA,EAAE;IACH,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE;QACzE,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,EAAE;QAChC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC;QACpC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC;QACtC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE;KAC9B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const ticket: (data: never, { config, onFetching, onSuccess, onError, onSettled, }: {
|
|
2
|
+
onFetching?: () => void;
|
|
3
|
+
onSuccess?: (data: object) => void;
|
|
4
|
+
onError?: (error: string) => void;
|
|
5
|
+
onSettled?: () => void;
|
|
6
|
+
config?: {
|
|
7
|
+
params: never;
|
|
8
|
+
};
|
|
9
|
+
}) => Promise<void>;
|
|
10
|
+
export default ticket;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { post } from "../config/axios.js";
|
|
2
|
+
import handler from "../config/handler.js";
|
|
3
|
+
import { getUrl } from "../config/route.js";
|
|
4
|
+
const ticket = (data, { config, onFetching, onSuccess, onError, onSettled, }) => {
|
|
5
|
+
return handler(post(getUrl("support", "v1", "ticket"), data, config), {
|
|
6
|
+
onFetching: () => onFetching?.(),
|
|
7
|
+
onError: (error) => onError?.(error),
|
|
8
|
+
onSuccess: (data) => onSuccess?.(data),
|
|
9
|
+
onSettled: () => onSettled?.(),
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export default ticket;
|
|
13
|
+
//# sourceMappingURL=ticket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ticket.js","sourceRoot":"","sources":["../../src/support/ticket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,OAAO,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,MAAM,GAAG,CACd,IAAW,EACX,EACC,MAAM,EACN,UAAU,EACV,SAAS,EACT,OAAO,EACP,SAAS,GAOT,EACA,EAAE;IACH,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE;QACrE,UAAU,EAAE,GAAG,EAAE,CAAC,UAAU,EAAE,EAAE;QAChC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC;QACpC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC;QACtC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE;KAC9B,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Cookies from "js-cookie";
|
|
2
|
+
import { parseCookies } from "nookies";
|
|
3
|
+
export const getCookie = (key = "ACID") => {
|
|
4
|
+
return Cookies.get(key);
|
|
5
|
+
};
|
|
6
|
+
export const isAuth = () => !!getCookie();
|
|
7
|
+
export const getServerSideToken = (ctx) => {
|
|
8
|
+
const { token } = parseCookies(ctx);
|
|
9
|
+
return token;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/utils/auth.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,GAAG,GAAG,MAAM,EAAsB,EAAE;IAC7D,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;AAE1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAoB,EAAE,EAAE;IAC1D,MAAM,EAAE,KAAK,EAAE,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;IACpC,OAAO,KAAK,CAAC;AACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to set encryption key
|
|
3
|
+
* @param {string} key - encryption key name
|
|
4
|
+
* @param {string} value string value to be set as encryption key
|
|
5
|
+
*/
|
|
6
|
+
export declare function setEncryptionKey(key: string, value: string): void;
|
|
7
|
+
/**
|
|
8
|
+
* function to get the encryption key
|
|
9
|
+
* @param {string} - name of the key to get encryption key for
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
export declare function getEncryptionKey(key: string): string | null | undefined;
|
|
13
|
+
export declare function daysCountInMonth(month: number, year: number): number;
|
|
14
|
+
/**
|
|
15
|
+
* Funtion to store data in local storage
|
|
16
|
+
* Pass second argument as true if setting data for employee side
|
|
17
|
+
* @param {string} key key for the value to be stored
|
|
18
|
+
* @param {*} data actual data to be stored with the provided key
|
|
19
|
+
* @param {boolean} [useEmployeeKey] - flag to decide which encyption key to use, (employee's or admin's)
|
|
20
|
+
*/
|
|
21
|
+
export declare function setDataInStorage(key: string, data: string | object): void;
|
|
22
|
+
/**
|
|
23
|
+
* Function to get data from local storage
|
|
24
|
+
* Pass second argument as true if getting data for employee side
|
|
25
|
+
* @param {string} key - key of the item to fetch from local storage
|
|
26
|
+
* @param {boolean} [useEmployeeKey] - flag to decide which encyption key to use, (employee's or admin's)
|
|
27
|
+
* @returns {*} value associated with the key
|
|
28
|
+
*/
|
|
29
|
+
export declare function getDataFromStorage(key: string): any;
|
|
30
|
+
/**
|
|
31
|
+
* Function to clear items from local storage
|
|
32
|
+
* @param {(string|string[])} keys - key to remove or array of keys
|
|
33
|
+
*/
|
|
34
|
+
export declare function clearStorage(keys: string[]): void;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import CryptoJS from "crypto-js";
|
|
2
|
+
/**
|
|
3
|
+
* Function to set encryption key
|
|
4
|
+
* @param {string} key - encryption key name
|
|
5
|
+
* @param {string} value string value to be set as encryption key
|
|
6
|
+
*/
|
|
7
|
+
export function setEncryptionKey(key, value) {
|
|
8
|
+
if (key && value) {
|
|
9
|
+
const sha256Key = CryptoJS.SHA256(key).toString();
|
|
10
|
+
// console.log('setting key: ', key, value);
|
|
11
|
+
const sha256Data = CryptoJS.SHA256(value).toString();
|
|
12
|
+
localStorage.setItem(sha256Key, JSON.stringify(sha256Data));
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
console.error("No data provided");
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* function to get the encryption key
|
|
20
|
+
* @param {string} - name of the key to get encryption key for
|
|
21
|
+
* @returns {string}
|
|
22
|
+
*/
|
|
23
|
+
// eslint-disable-next-line consistent-return
|
|
24
|
+
export function getEncryptionKey(key) {
|
|
25
|
+
try {
|
|
26
|
+
const shaKey = CryptoJS.SHA256(key).toString();
|
|
27
|
+
// console.log('getting key: ', key, localStorage.getItem(shaKey));
|
|
28
|
+
return localStorage.getItem(shaKey);
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
console.error("something went wrong man hoho");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function daysCountInMonth(month, year) {
|
|
35
|
+
return new Date(year, month, 0).getDate();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Funtion to store data in local storage
|
|
39
|
+
* Pass second argument as true if setting data for employee side
|
|
40
|
+
* @param {string} key key for the value to be stored
|
|
41
|
+
* @param {*} data actual data to be stored with the provided key
|
|
42
|
+
* @param {boolean} [useEmployeeKey] - flag to decide which encyption key to use, (employee's or admin's)
|
|
43
|
+
*/
|
|
44
|
+
export function setDataInStorage(key, data) {
|
|
45
|
+
// Encrypt key
|
|
46
|
+
const shaKey = CryptoJS.SHA256(key).toString();
|
|
47
|
+
const encKeyName = "account_key";
|
|
48
|
+
const encryptionKey = getEncryptionKey(encKeyName);
|
|
49
|
+
// console.log('setting data: ', encryption_key, key, shaKey, data);
|
|
50
|
+
if (encryptionKey) {
|
|
51
|
+
// Encrypt data
|
|
52
|
+
const dataCipher = CryptoJS.AES.encrypt(JSON.stringify(data), encryptionKey).toString();
|
|
53
|
+
localStorage.setItem(shaKey, JSON.stringify(dataCipher));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Function to get data from local storage
|
|
58
|
+
* Pass second argument as true if getting data for employee side
|
|
59
|
+
* @param {string} key - key of the item to fetch from local storage
|
|
60
|
+
* @param {boolean} [useEmployeeKey] - flag to decide which encyption key to use, (employee's or admin's)
|
|
61
|
+
* @returns {*} value associated with the key
|
|
62
|
+
*/
|
|
63
|
+
// eslint-disable-next-line consistent-return
|
|
64
|
+
export function getDataFromStorage(key) {
|
|
65
|
+
try {
|
|
66
|
+
const shaKey = CryptoJS.SHA256(key).toString();
|
|
67
|
+
const encKeyName = "account_key";
|
|
68
|
+
const encryptionKey = getEncryptionKey(encKeyName);
|
|
69
|
+
// console.log(
|
|
70
|
+
// 'from getting data: ',
|
|
71
|
+
// key,
|
|
72
|
+
// 'encryption-key',
|
|
73
|
+
// typeof encryption_key,
|
|
74
|
+
// encryption_key
|
|
75
|
+
// );
|
|
76
|
+
if (encryptionKey && shaKey) {
|
|
77
|
+
const ciphertext = JSON.parse(String(localStorage.getItem(shaKey)));
|
|
78
|
+
if (ciphertext) {
|
|
79
|
+
// Decrypt
|
|
80
|
+
const bytes = CryptoJS.AES.decrypt(ciphertext, encryptionKey);
|
|
81
|
+
const originalData = bytes.toString(CryptoJS.enc.Utf8);
|
|
82
|
+
// console.log('getting data: ', key, shaKey, originalData);
|
|
83
|
+
return JSON.parse(originalData);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
// console.error('Error getting data from storage boi boi');
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Function to clear items from local storage
|
|
93
|
+
* @param {(string|string[])} keys - key to remove or array of keys
|
|
94
|
+
*/
|
|
95
|
+
// export function clearStorage(keys: string[]) {
|
|
96
|
+
// try {
|
|
97
|
+
// if (Array.isArray(keys)) {
|
|
98
|
+
// keys.forEach((key) => {
|
|
99
|
+
// const shaKey = CryptoJS.SHA256(key).toString();
|
|
100
|
+
// localStorage.removeItem(shaKey);
|
|
101
|
+
// });
|
|
102
|
+
// } else if (typeof keys === "string") {
|
|
103
|
+
// const shaKey = CryptoJS.SHA256(keys).toString();
|
|
104
|
+
// localStorage.removeItem(shaKey);
|
|
105
|
+
// }
|
|
106
|
+
// } catch (err) {
|
|
107
|
+
// console.error("Error clearing storage", err);
|
|
108
|
+
// }
|
|
109
|
+
// }
|
|
110
|
+
export function clearStorage(keys) {
|
|
111
|
+
try {
|
|
112
|
+
if (Array.isArray(keys)) {
|
|
113
|
+
for (const key of keys) {
|
|
114
|
+
const shaKey = CryptoJS.SHA256(key).toString();
|
|
115
|
+
localStorage.removeItem(shaKey);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else if (typeof keys === "string") {
|
|
119
|
+
const shaKey = CryptoJS.SHA256(keys).toString();
|
|
120
|
+
localStorage.removeItem(shaKey);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
console.error("Error clearing storage", err);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=localStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localStorage.js","sourceRoot":"","sources":["../../src/utils/localStorage.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,KAAa;IAC1D,IAAI,GAAG,IAAI,KAAK,EAAE,CAAC;QAClB,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QAClD,4CAA4C;QAC5C,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;QAErD,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IAC7D,CAAC;SAAM,CAAC;QACP,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACnC,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,6CAA6C;AAC7C,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC3C,IAAI,CAAC;QACJ,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC/C,mEAAmE;QACnE,OAAO,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACrC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACd,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;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AC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAC;IAC9C,CAAC;AACF,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@helpdice/sdk",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "A backend API-based SDK (Software Development Kit) provides developers with pre-built tools and libraries to interact seamlessly with a backend server or service. It simplifies the process of integrating external functionality, such as authentication, data storage, or third-party services, into applications. The SDK typically includes API endpoints, functions, and documentation, allowing developers to make requests, handle responses, and manage errors efficiently. By abstracting complex backend logic, it speeds up development, reduces coding errors, and ensures consistent interactions with the backend, making it easier to build scalable, secure, and feature-rich applications.",
|
|
5
|
+
"version": "0.0.1",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/helpdice/sdk.git"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://sdk.helpdice.com",
|
|
13
|
+
"files": [
|
|
14
|
+
"dist/**/*"
|
|
15
|
+
],
|
|
16
|
+
"author": "Helpdice Team",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@biomejs/biome": "1.8.3",
|
|
20
|
+
"@changesets/cli": "^2.27.7",
|
|
21
|
+
"@total-typescript/tsconfig": "^1.0.4",
|
|
22
|
+
"@types/crypto-js": "^4.2.2",
|
|
23
|
+
"@types/js-cookie": "^3.0.6",
|
|
24
|
+
"@types/react": "^19.0.8",
|
|
25
|
+
"typescript": "^5.5.3"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/helpdice/sdk/issues"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"axios": "^1.7.9",
|
|
32
|
+
"crypto-js": "^4.2.0",
|
|
33
|
+
"firebase": "^11.2.0",
|
|
34
|
+
"fs": "^0.0.1-security",
|
|
35
|
+
"fs-extra": "^11.3.0",
|
|
36
|
+
"js-cookie": "^3.0.5",
|
|
37
|
+
"jwt-decode": "^4.0.0",
|
|
38
|
+
"next": "^15.1.6",
|
|
39
|
+
"nookies": "^2.5.2",
|
|
40
|
+
"swr": "^2.3.0",
|
|
41
|
+
"zod": "^3.24.1"
|
|
42
|
+
},
|
|
43
|
+
"packageManager": "pnpm@9.6.0+sha512.38dc6fba8dba35b39340b9700112c2fe1e12f10b17134715a4aa98ccf7bb035e76fd981cf0bb384dfa98f8d6af5481c2bef2f4266a24bfa20c34eb7147ce0b5e",
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc",
|
|
46
|
+
"check": "biome check --write ./src",
|
|
47
|
+
"workflow:check": "biome check ./src",
|
|
48
|
+
"release": "pnpm run build && changeset publish"
|
|
49
|
+
}
|
|
50
|
+
}
|