ggez-banking-sdk 0.4.29 → 0.4.30

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,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 pictureResult = await getBase64(data.picture);
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 (pictureResult) {
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: ext,
119
- content: pictureResult.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.result = createDefaultBaseResult({
19
- result: defaultResult,
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
  }
@@ -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 mimeType = blob.type || "image/jpeg";
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
- let binary = "";
14
- for (let i = 0; i < binaryData.byteLength; i++) {
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 { content, mimeType };
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.29",
3
+ "version": "0.4.30",
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",