@helpdice/sdk 0.5.1 → 0.5.2
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/index.js +10 -12
- package/dist/index.js.map +1 -1
- package/dist/types/config/index.d.ts +2 -28
- package/dist/types/config/state.d.ts +31 -0
- package/package.json +9 -9
- package/dist/cjs/account/endpoint.js +0 -8
- package/dist/cjs/account/index.js +0 -17
- package/dist/cjs/account/types.js +0 -2
- package/dist/cjs/account/update_profile.js +0 -17
- package/dist/cjs/accounting/createInvoice.js +0 -17
- package/dist/cjs/accounting/endpoint.js +0 -14
- package/dist/cjs/accounting/index.js +0 -25
- package/dist/cjs/accounting/submitInvoice.js +0 -17
- package/dist/cjs/accounting/types.js +0 -2
- package/dist/cjs/accounting/updateInvoice.js +0 -17
- package/dist/cjs/apis/cities.js +0 -17
- package/dist/cjs/apis/countries.js +0 -17
- package/dist/cjs/apis/index.js +0 -14
- package/dist/cjs/apis/states.js +0 -17
- package/dist/cjs/assets/endpoint.js +0 -9
- package/dist/cjs/assets/index.js +0 -11
- package/dist/cjs/auth/authWithKey.js +0 -17
- package/dist/cjs/auth/authWithToken.js +0 -17
- package/dist/cjs/auth/endpoint.js +0 -15
- package/dist/cjs/auth/index.js +0 -94
- package/dist/cjs/auth/logout.js +0 -22
- package/dist/cjs/auth/register.js +0 -17
- package/dist/cjs/auth/resetPassword.js +0 -17
- package/dist/cjs/auth/signInWithGoogle.js +0 -56
- package/dist/cjs/auth/signin.js +0 -17
- package/dist/cjs/auth/signup.js +0 -17
- package/dist/cjs/auth/types.js +0 -2
- package/dist/cjs/config/axios.js +0 -120
- package/dist/cjs/config/constants.js +0 -12
- package/dist/cjs/config/fetch.js +0 -37
- package/dist/cjs/config/handler.js +0 -32
- package/dist/cjs/config/index.js +0 -37
- package/dist/cjs/config/local-storage.js +0 -29
- package/dist/cjs/config/route.js +0 -47
- package/dist/cjs/config/validate.js +0 -15
- package/dist/cjs/content/endpoint.js +0 -17
- package/dist/cjs/content/index.js +0 -29
- package/dist/cjs/hooks/index.js +0 -10
- package/dist/cjs/hooks/useAuth.js +0 -23
- package/dist/cjs/hooks/usePrivate.js +0 -15
- package/dist/cjs/hooks/useUser.js +0 -15
- package/dist/cjs/index.js +0 -59
- package/dist/cjs/inventory/endpoint.js +0 -9
- package/dist/cjs/inventory/index.js +0 -26
- package/dist/cjs/linkie/endpoint.js +0 -8
- package/dist/cjs/linkie/index.js +0 -20
- package/dist/cjs/linkie/shortUrl.js +0 -17
- package/dist/cjs/linkie/types.js +0 -2
- package/dist/cjs/order/create.js +0 -17
- package/dist/cjs/order/endpoint.js +0 -8
- package/dist/cjs/order/index.js +0 -10
- package/dist/cjs/order/types.js +0 -2
- package/dist/cjs/payment/components/ProcessPayment.js +0 -266
- package/dist/cjs/payment/endpoint.js +0 -9
- package/dist/cjs/payment/index.js +0 -12
- package/dist/cjs/payment/start.js +0 -38
- package/dist/cjs/payment/types.js +0 -2
- package/dist/cjs/payment/verify.js +0 -17
- package/dist/cjs/sales/endpoint.js +0 -8
- package/dist/cjs/sales/index.js +0 -7
- package/dist/cjs/sales/lead.js +0 -22
- package/dist/cjs/sales/types.js +0 -17
- package/dist/cjs/support/endpoint.js +0 -10
- package/dist/cjs/support/index.js +0 -15
- package/dist/cjs/support/newsletter.js +0 -17
- package/dist/cjs/support/ticket.js +0 -17
- package/dist/cjs/tools/endpoint.js +0 -8
- package/dist/cjs/tools/exchangeRates.js +0 -30
- package/dist/cjs/tools/index.js +0 -10
- package/dist/cjs/types.js +0 -9
- package/dist/cjs/utils/auth.js +0 -23
- package/dist/cjs/utils/handler.js +0 -35
- package/dist/cjs/utils/localStorage.js +0 -137
- package/dist/cjs/utils/share.js +0 -25
- package/dist/types/config/local-storage.d.ts +0 -0
- package/dist/types/config/validate.d.ts +0 -4
- package/dist/types/hooks/index.d.ts +0 -1
- package/dist/types/hooks/useAuth.d.ts +0 -0
- package/dist/types/hooks/usePrivate.d.ts +0 -0
- package/dist/types/hooks/useUser.d.ts +0 -8
- package/dist/types/payment/components/ProcessPayment.d.ts +0 -0
|
@@ -1,137 +0,0 @@
|
|
|
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.setEncryptionKey = setEncryptionKey;
|
|
7
|
-
exports.getEncryptionKey = getEncryptionKey;
|
|
8
|
-
exports.daysCountInMonth = daysCountInMonth;
|
|
9
|
-
exports.setDataInStorage = setDataInStorage;
|
|
10
|
-
exports.getDataFromStorage = getDataFromStorage;
|
|
11
|
-
exports.clearStorage = clearStorage;
|
|
12
|
-
const crypto_js_1 = __importDefault(require("crypto-js"));
|
|
13
|
-
/**
|
|
14
|
-
* Function to set encryption key
|
|
15
|
-
* @param {string} key - encryption key name
|
|
16
|
-
* @param {string} value string value to be set as encryption key
|
|
17
|
-
*/
|
|
18
|
-
function setEncryptionKey(key, value) {
|
|
19
|
-
if (key && value) {
|
|
20
|
-
const sha256Key = crypto_js_1.default.SHA256(key).toString();
|
|
21
|
-
// console.log('setting key: ', key, value);
|
|
22
|
-
const sha256Data = crypto_js_1.default.SHA256(value).toString();
|
|
23
|
-
localStorage.setItem(sha256Key, JSON.stringify(sha256Data));
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
console.error("No data provided");
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* function to get the encryption key
|
|
31
|
-
* @param {string} - name of the key to get encryption key for
|
|
32
|
-
* @returns {string}
|
|
33
|
-
*/
|
|
34
|
-
// eslint-disable-next-line consistent-return
|
|
35
|
-
function getEncryptionKey(key) {
|
|
36
|
-
try {
|
|
37
|
-
const shaKey = crypto_js_1.default.SHA256(key).toString();
|
|
38
|
-
// console.log('getting key: ', key, localStorage.getItem(shaKey));
|
|
39
|
-
return localStorage.getItem(shaKey);
|
|
40
|
-
}
|
|
41
|
-
catch (err) {
|
|
42
|
-
console.error("something went wrong man hoho");
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function daysCountInMonth(month, year) {
|
|
46
|
-
return new Date(year, month, 0).getDate();
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Funtion to store data in local storage
|
|
50
|
-
* Pass second argument as true if setting data for employee side
|
|
51
|
-
* @param {string} key key for the value to be stored
|
|
52
|
-
* @param {*} data actual data to be stored with the provided key
|
|
53
|
-
* @param {boolean} [useEmployeeKey] - flag to decide which encyption key to use, (employee's or admin's)
|
|
54
|
-
*/
|
|
55
|
-
function setDataInStorage(key, data) {
|
|
56
|
-
// Encrypt key
|
|
57
|
-
const shaKey = crypto_js_1.default.SHA256(key).toString();
|
|
58
|
-
const encKeyName = "account_key";
|
|
59
|
-
const encryptionKey = getEncryptionKey(encKeyName);
|
|
60
|
-
// console.log('setting data: ', encryption_key, key, shaKey, data);
|
|
61
|
-
if (encryptionKey) {
|
|
62
|
-
// Encrypt data
|
|
63
|
-
const dataCipher = crypto_js_1.default.AES.encrypt(JSON.stringify(data), encryptionKey).toString();
|
|
64
|
-
localStorage.setItem(shaKey, JSON.stringify(dataCipher));
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Function to get data from local storage
|
|
69
|
-
* Pass second argument as true if getting data for employee side
|
|
70
|
-
* @param {string} key - key of the item to fetch from local storage
|
|
71
|
-
* @param {boolean} [useEmployeeKey] - flag to decide which encyption key to use, (employee's or admin's)
|
|
72
|
-
* @returns {*} value associated with the key
|
|
73
|
-
*/
|
|
74
|
-
// eslint-disable-next-line consistent-return
|
|
75
|
-
function getDataFromStorage(key) {
|
|
76
|
-
try {
|
|
77
|
-
const shaKey = crypto_js_1.default.SHA256(key).toString();
|
|
78
|
-
const encKeyName = "account_key";
|
|
79
|
-
const encryptionKey = getEncryptionKey(encKeyName);
|
|
80
|
-
// console.log(
|
|
81
|
-
// 'from getting data: ',
|
|
82
|
-
// key,
|
|
83
|
-
// 'encryption-key',
|
|
84
|
-
// typeof encryption_key,
|
|
85
|
-
// encryption_key
|
|
86
|
-
// );
|
|
87
|
-
if (encryptionKey && shaKey) {
|
|
88
|
-
const ciphertext = JSON.parse(String(localStorage.getItem(shaKey)));
|
|
89
|
-
if (ciphertext) {
|
|
90
|
-
// Decrypt
|
|
91
|
-
const bytes = crypto_js_1.default.AES.decrypt(ciphertext, encryptionKey);
|
|
92
|
-
const originalData = bytes.toString(crypto_js_1.default.enc.Utf8);
|
|
93
|
-
// console.log('getting data: ', key, shaKey, originalData);
|
|
94
|
-
return JSON.parse(originalData);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch (err) {
|
|
99
|
-
// console.error('Error getting data from storage boi boi');
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Function to clear items from local storage
|
|
104
|
-
* @param {(string|string[])} keys - key to remove or array of keys
|
|
105
|
-
*/
|
|
106
|
-
// export function clearStorage(keys: string[]) {
|
|
107
|
-
// try {
|
|
108
|
-
// if (Array.isArray(keys)) {
|
|
109
|
-
// keys.forEach((key) => {
|
|
110
|
-
// const shaKey = CryptoJS.SHA256(key).toString();
|
|
111
|
-
// localStorage.removeItem(shaKey);
|
|
112
|
-
// });
|
|
113
|
-
// } else if (typeof keys === "string") {
|
|
114
|
-
// const shaKey = CryptoJS.SHA256(keys).toString();
|
|
115
|
-
// localStorage.removeItem(shaKey);
|
|
116
|
-
// }
|
|
117
|
-
// } catch (err) {
|
|
118
|
-
// console.error("Error clearing storage", err);
|
|
119
|
-
// }
|
|
120
|
-
// }
|
|
121
|
-
function clearStorage(keys) {
|
|
122
|
-
try {
|
|
123
|
-
if (Array.isArray(keys)) {
|
|
124
|
-
for (const key of keys) {
|
|
125
|
-
const shaKey = crypto_js_1.default.SHA256(key).toString();
|
|
126
|
-
localStorage.removeItem(shaKey);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else if (typeof keys === "string") {
|
|
130
|
-
const shaKey = crypto_js_1.default.SHA256(keys).toString();
|
|
131
|
-
localStorage.removeItem(shaKey);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
catch (err) {
|
|
135
|
-
console.error("Error clearing storage", err);
|
|
136
|
-
}
|
|
137
|
-
}
|
package/dist/cjs/utils/share.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = shareUrl;
|
|
4
|
-
function shareUrl(title, url) {
|
|
5
|
-
// URL encoding to ensure special characters are handled properly
|
|
6
|
-
const encodedTitle = encodeURIComponent(title);
|
|
7
|
-
const encodedUrl = encodeURIComponent(url);
|
|
8
|
-
const target = "_blank";
|
|
9
|
-
const dimension = "width=600,height=400";
|
|
10
|
-
// Social media share URLs
|
|
11
|
-
const shareLinks = {
|
|
12
|
-
facebook: `https://www.facebook.com/sharer/sharer.php?u=${encodedUrl}`,
|
|
13
|
-
twitter: `https://twitter.com/intent/tweet?text=${encodedTitle}&url=${encodedUrl}`,
|
|
14
|
-
linkedin: `https://www.linkedin.com/sharing/share-offsite/?url=${encodedUrl}`,
|
|
15
|
-
whatsapp: `https://api.whatsapp.com/send?text=${encodedTitle} ${encodedUrl}`,
|
|
16
|
-
pinterest: `https://www.pinterest.com/pin/create/button/?url=${encodedUrl}&description=${encodedTitle}`,
|
|
17
|
-
};
|
|
18
|
-
return {
|
|
19
|
-
facebook: () => window.open(shareLinks.facebook, target, dimension),
|
|
20
|
-
twitter: () => window.open(shareLinks.twitter, target, dimension),
|
|
21
|
-
linkedin: () => window.open(shareLinks.linkedin, target, dimension),
|
|
22
|
-
whatsapp: () => window.open(shareLinks.whatsapp, target, dimension),
|
|
23
|
-
pinterest: () => window.open(shareLinks.pinterest, target, dimension),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as useUser } from "./useUser";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|