ggez-banking-sdk 0.4.27 → 0.4.29
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.
|
@@ -87,8 +87,14 @@ 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
|
+
};
|
|
90
96
|
const fillCreateUserWithGoogleData = async (data) => {
|
|
91
|
-
const
|
|
97
|
+
const pictureResult = await getBase64(data.picture);
|
|
92
98
|
const userData = fillCreateUserData(data);
|
|
93
99
|
const externalAuth = {
|
|
94
100
|
id: 0,
|
|
@@ -99,7 +105,8 @@ const fillCreateUserWithGoogleData = async (data) => {
|
|
|
99
105
|
verification_status: EntityVerificationStatus.Verified,
|
|
100
106
|
};
|
|
101
107
|
userData.external_auth = [externalAuth];
|
|
102
|
-
if (
|
|
108
|
+
if (pictureResult) {
|
|
109
|
+
const ext = mimeToExtension[pictureResult.mimeType] ?? ".jpg";
|
|
103
110
|
const documentData = {
|
|
104
111
|
info: {
|
|
105
112
|
type: DocumentType.Profile_Picture,
|
|
@@ -108,8 +115,8 @@ const fillCreateUserWithGoogleData = async (data) => {
|
|
|
108
115
|
attachment: [
|
|
109
116
|
{
|
|
110
117
|
file_name: data.loginId,
|
|
111
|
-
file_extension:
|
|
112
|
-
content:
|
|
118
|
+
file_extension: ext,
|
|
119
|
+
content: pictureResult.content,
|
|
113
120
|
},
|
|
114
121
|
],
|
|
115
122
|
};
|
|
@@ -51,8 +51,7 @@ class AxiosHelper {
|
|
|
51
51
|
if (token && !req.headers.has(HeaderKeys.Authorization)) {
|
|
52
52
|
req.headers.set(HeaderKeys.Authorization, AxiosHelper.bearer(token));
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
req.headers.set(HeaderKeys.SourceID, generateSourceID(userId));
|
|
54
|
+
req.headers.set(HeaderKeys.SourceID, generateSourceID(userId ?? 0));
|
|
56
55
|
if (lang)
|
|
57
56
|
req.headers.set(HeaderKeys.Language, lang);
|
|
58
57
|
if (iid)
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
declare const pad: (number: number) => string;
|
|
2
2
|
declare const padMilliseconds: (number: number) => string;
|
|
3
|
-
declare const getBase64: (url: string) => Promise<
|
|
3
|
+
declare const getBase64: (url: string) => Promise<{
|
|
4
|
+
content: string;
|
|
5
|
+
mimeType: string;
|
|
6
|
+
} | null>;
|
|
4
7
|
export { pad, padMilliseconds, getBase64 };
|
|
@@ -4,13 +4,17 @@ const getBase64 = async (url) => {
|
|
|
4
4
|
try {
|
|
5
5
|
const response = await fetch(url);
|
|
6
6
|
const blob = await response.blob();
|
|
7
|
-
const
|
|
7
|
+
const mimeType = blob.type || "image/jpeg";
|
|
8
|
+
const content = await new Promise((resolve, reject) => {
|
|
8
9
|
const reader = new FileReader();
|
|
9
10
|
reader.onload = () => {
|
|
10
11
|
if (reader.result instanceof ArrayBuffer) {
|
|
11
12
|
const binaryData = new Uint8Array(reader.result);
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
let binary = "";
|
|
14
|
+
for (let i = 0; i < binaryData.byteLength; i++) {
|
|
15
|
+
binary += String.fromCharCode(binaryData[i]);
|
|
16
|
+
}
|
|
17
|
+
resolve(btoa(binary));
|
|
14
18
|
}
|
|
15
19
|
else {
|
|
16
20
|
reject(new Error("Failed to read as ArrayBuffer"));
|
|
@@ -18,9 +22,9 @@ const getBase64 = async (url) => {
|
|
|
18
22
|
};
|
|
19
23
|
reader.readAsArrayBuffer(blob);
|
|
20
24
|
});
|
|
21
|
-
return
|
|
25
|
+
return { content, mimeType };
|
|
22
26
|
}
|
|
23
|
-
catch
|
|
27
|
+
catch {
|
|
24
28
|
return null;
|
|
25
29
|
}
|
|
26
30
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ggez-banking-sdk",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.29",
|
|
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",
|