ggez-banking-sdk 0.1.134 → 0.1.136

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.
@@ -255,7 +255,7 @@ class UserClient {
255
255
  };
256
256
  CreateUserWithGoogle = async (data) => {
257
257
  try {
258
- const userData = FillCreateUserWithGoogleData(data);
258
+ const userData = await FillCreateUserWithGoogleData(data);
259
259
  const { data: tokenData } = await this.authService.generateLimitedToken({
260
260
  installationId: data.installationID,
261
261
  });
@@ -3,4 +3,4 @@ import type { UserData } from "../../../types";
3
3
  export { FillUserData, FillCreateUserData, FillCreateUserWithGoogleData };
4
4
  declare const FillUserData: <K extends keyof UserData>(key: K, value: UserData[K]) => UserData;
5
5
  declare const FillCreateUserData: (data: ICreateUserData) => UserData;
6
- declare const FillCreateUserWithGoogleData: (data: ICreateUserWithGoogleData) => UserData;
6
+ declare const FillCreateUserWithGoogleData: (data: ICreateUserWithGoogleData) => Promise<UserData>;
@@ -1,5 +1,6 @@
1
- import { DeviceType, EntityStatus, EntityVerificationStatus, Gender, PhoneNumberTypes, SecurityAuthenticationTypes, SecurityLoginType, Titles, } from "../../../constants";
1
+ import { DeviceType, EntityStatus, EntityVerificationStatus, Gender, DocumentType, PhoneNumberTypes, SecurityAuthenticationTypes, SecurityLoginType, Titles, } from "../../../constants";
2
2
  import { ClientHelper, DateTimeHelper } from "../../../helper";
3
+ import { getBase64 } from "../../../utils";
3
4
  export { FillUserData, FillCreateUserData, FillCreateUserWithGoogleData };
4
5
  const FillUserData = (key, value) => {
5
6
  const userData = {
@@ -144,7 +145,8 @@ const FillCreateUserData = (data) => {
144
145
  };
145
146
  return userData;
146
147
  };
147
- const FillCreateUserWithGoogleData = (data) => {
148
+ const FillCreateUserWithGoogleData = async (data) => {
149
+ const base64 = await getBase64(data.picture);
148
150
  const userData = FillCreateUserData(data);
149
151
  const externalAuth = {
150
152
  id: 0,
@@ -154,6 +156,20 @@ const FillCreateUserWithGoogleData = (data) => {
154
156
  type: SecurityLoginType.Google,
155
157
  verification_status: EntityVerificationStatus.Verified,
156
158
  };
159
+ const documentData = {
160
+ info: {
161
+ type: DocumentType.Profile_Picture,
162
+ subject: "Profile Picture",
163
+ },
164
+ attachment: [
165
+ {
166
+ file_name: "",
167
+ file_extension: ".jpg",
168
+ content: base64,
169
+ },
170
+ ],
171
+ };
157
172
  userData.external_auth = [externalAuth];
173
+ userData.documents = [documentData];
158
174
  return userData;
159
175
  };
@@ -1,4 +1,7 @@
1
1
  import { CustomField } from "../../../banking";
2
+ type DeepPartial<T> = {
3
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
4
+ };
2
5
  interface ICreateUserData {
3
6
  firstName: string;
4
7
  lastName: string;
@@ -21,7 +24,7 @@ interface ICreateUserData {
21
24
  referralCodeType: string;
22
25
  mobileNumberCountry: string;
23
26
  preferredLanguageCode: string;
24
- customField: Partial<CustomField>;
27
+ customField: DeepPartial<CustomField>;
25
28
  }
26
29
  interface ICreateUserWithGoogleData extends ICreateUserData {
27
30
  loginId: string;
@@ -1,3 +1,4 @@
1
1
  declare const pad: (number: number) => string;
2
2
  declare const padMilliseconds: (number: number) => string;
3
- export { pad, padMilliseconds };
3
+ declare const getBase64: (url: string) => Promise<string>;
4
+ export { pad, padMilliseconds, getBase64 };
@@ -1,3 +1,22 @@
1
1
  const pad = (number) => String(number).padStart(2, "0");
2
2
  const padMilliseconds = (number) => String(number).padStart(3, "0");
3
- export { pad, padMilliseconds };
3
+ const getBase64 = async (url) => {
4
+ const response = await fetch(url);
5
+ const blob = await response.blob();
6
+ const base64 = new Promise((resolve, reject) => {
7
+ const reader = new FileReader();
8
+ reader.onload = () => {
9
+ if (reader.result instanceof ArrayBuffer) {
10
+ const binaryData = new Uint8Array(reader.result);
11
+ const base64Data = btoa(String.fromCharCode(...binaryData));
12
+ resolve(base64Data);
13
+ }
14
+ else {
15
+ reject(new Error("Failed to read as ArrayBuffer"));
16
+ }
17
+ };
18
+ reader.readAsArrayBuffer(blob);
19
+ });
20
+ return base64;
21
+ };
22
+ export { pad, padMilliseconds, getBase64 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ggez-banking-sdk",
3
- "version": "0.1.134",
3
+ "version": "0.1.136",
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",