ggez-banking-sdk 0.4.29 → 0.4.31
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/api/data/user/user.js +4 -11
- package/dist/helper/api/responseHelper.js +6 -3
- package/dist/helper/storage/localStorageHelper.d.ts +4 -0
- package/dist/helper/storage/localStorageHelper.js +20 -0
- package/dist/utils/data/manipulation.d.ts +1 -4
- package/dist/utils/data/manipulation.js +5 -9
- package/package.json +1 -1
|
@@ -87,14 +87,8 @@ const fillCreateUserData = (data) => {
|
|
|
87
87
|
}
|
|
88
88
|
return userData;
|
|
89
89
|
};
|
|
90
|
-
const mimeToExtension = {
|
|
91
|
-
"image/jpeg": ".jpg",
|
|
92
|
-
"image/png": ".png",
|
|
93
|
-
"image/webp": ".webp",
|
|
94
|
-
"image/gif": ".gif",
|
|
95
|
-
};
|
|
96
90
|
const fillCreateUserWithGoogleData = async (data) => {
|
|
97
|
-
const
|
|
91
|
+
const base64 = await getBase64(data.picture);
|
|
98
92
|
const userData = fillCreateUserData(data);
|
|
99
93
|
const externalAuth = {
|
|
100
94
|
id: 0,
|
|
@@ -105,8 +99,7 @@ const fillCreateUserWithGoogleData = async (data) => {
|
|
|
105
99
|
verification_status: EntityVerificationStatus.Verified,
|
|
106
100
|
};
|
|
107
101
|
userData.external_auth = [externalAuth];
|
|
108
|
-
if (
|
|
109
|
-
const ext = mimeToExtension[pictureResult.mimeType] ?? ".jpg";
|
|
102
|
+
if (base64) {
|
|
110
103
|
const documentData = {
|
|
111
104
|
info: {
|
|
112
105
|
type: DocumentType.Profile_Picture,
|
|
@@ -115,8 +108,8 @@ const fillCreateUserWithGoogleData = async (data) => {
|
|
|
115
108
|
attachment: [
|
|
116
109
|
{
|
|
117
110
|
file_name: data.loginId,
|
|
118
|
-
file_extension:
|
|
119
|
-
content:
|
|
111
|
+
file_extension: ".jpg",
|
|
112
|
+
content: base64,
|
|
120
113
|
},
|
|
121
114
|
],
|
|
122
115
|
};
|
|
@@ -15,9 +15,12 @@ class ResponseHelper {
|
|
|
15
15
|
description: "Operation completed successfully",
|
|
16
16
|
};
|
|
17
17
|
if (!res.data.result) {
|
|
18
|
-
res.data
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
res.data = {
|
|
19
|
+
...createDefaultBaseResult({
|
|
20
|
+
result: defaultResult,
|
|
21
|
+
}),
|
|
22
|
+
...res.data,
|
|
23
|
+
};
|
|
21
24
|
if (isStringData) {
|
|
22
25
|
res.data = JSON.stringify(res.data);
|
|
23
26
|
}
|
|
@@ -13,5 +13,9 @@ declare class LocalStorageHelper {
|
|
|
13
13
|
set(key: string, value: string): null | undefined;
|
|
14
14
|
remove(key: string): null | undefined;
|
|
15
15
|
clear(): void;
|
|
16
|
+
setLocalStorageByUserData(data: UserData): void;
|
|
17
|
+
removeLocalStorageOnSignup(): void;
|
|
18
|
+
removeLocalStorageOnLogout(): void;
|
|
19
|
+
clearLocalStorage(): void;
|
|
16
20
|
}
|
|
17
21
|
export { LocalStorageHelper };
|
|
@@ -84,5 +84,25 @@ class LocalStorageHelper {
|
|
|
84
84
|
clear() {
|
|
85
85
|
localStorage.clear();
|
|
86
86
|
}
|
|
87
|
+
// #endregion
|
|
88
|
+
// #region "Utils"
|
|
89
|
+
setLocalStorageByUserData(data) {
|
|
90
|
+
if (data.preferences?.preferred_language_code) {
|
|
91
|
+
this.set("lang", data.preferences.preferred_language_code);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
removeLocalStorageOnSignup() {
|
|
95
|
+
this.remove("promoCode");
|
|
96
|
+
this.remove("promotionData");
|
|
97
|
+
this.remove("referralCode");
|
|
98
|
+
}
|
|
99
|
+
removeLocalStorageOnLogout() {
|
|
100
|
+
this.remove("CUD");
|
|
101
|
+
}
|
|
102
|
+
clearLocalStorage() {
|
|
103
|
+
this.remove("CUD");
|
|
104
|
+
this.remove("currency");
|
|
105
|
+
this.remove("prefixCurrency");
|
|
106
|
+
}
|
|
87
107
|
}
|
|
88
108
|
export { LocalStorageHelper };
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
declare const pad: (number: number) => string;
|
|
2
2
|
declare const padMilliseconds: (number: number) => string;
|
|
3
|
-
declare const getBase64: (url: string) => Promise<
|
|
4
|
-
content: string;
|
|
5
|
-
mimeType: string;
|
|
6
|
-
} | null>;
|
|
3
|
+
declare const getBase64: (url: string) => Promise<string | null>;
|
|
7
4
|
export { pad, padMilliseconds, getBase64 };
|
|
@@ -4,17 +4,13 @@ const getBase64 = async (url) => {
|
|
|
4
4
|
try {
|
|
5
5
|
const response = await fetch(url);
|
|
6
6
|
const blob = await response.blob();
|
|
7
|
-
const
|
|
8
|
-
const content = await new Promise((resolve, reject) => {
|
|
7
|
+
const base64 = new Promise((resolve, reject) => {
|
|
9
8
|
const reader = new FileReader();
|
|
10
9
|
reader.onload = () => {
|
|
11
10
|
if (reader.result instanceof ArrayBuffer) {
|
|
12
11
|
const binaryData = new Uint8Array(reader.result);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
binary += String.fromCharCode(binaryData[i]);
|
|
16
|
-
}
|
|
17
|
-
resolve(btoa(binary));
|
|
12
|
+
const base64Data = btoa(String.fromCharCode(...binaryData));
|
|
13
|
+
resolve(base64Data);
|
|
18
14
|
}
|
|
19
15
|
else {
|
|
20
16
|
reject(new Error("Failed to read as ArrayBuffer"));
|
|
@@ -22,9 +18,9 @@ const getBase64 = async (url) => {
|
|
|
22
18
|
};
|
|
23
19
|
reader.readAsArrayBuffer(blob);
|
|
24
20
|
});
|
|
25
|
-
return
|
|
21
|
+
return await base64;
|
|
26
22
|
}
|
|
27
|
-
catch {
|
|
23
|
+
catch (error) {
|
|
28
24
|
return null;
|
|
29
25
|
}
|
|
30
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ggez-banking-sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.31",
|
|
4
4
|
"description": "A Node.js package to handle GGEZ Banking API endpoints, Simplify the process of managing CRUD operations with this efficient and easy-to-use package.",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|