squarecommonblhelper 5.2.0 → 6.0.0

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/README.md CHANGED
@@ -15,6 +15,23 @@ helper for common bl for my projects.
15
15
 
16
16
  ## changelog
17
17
 
18
+ ### v6.0.0
19
+
20
+ - AuthenticationCommonBL:
21
+ - **breaking change** remove updatePasswordV0.
22
+ - add generateAccountBackupCodesV0.
23
+ - method changed of deleteUserV0 from delete to post.
24
+ - add updateProfileDetailsV0.
25
+ - add sendResetPasswordEmailV0.
26
+ - add updateUserRecoveryMethodsV0.
27
+ - add sendVerificationEmailV0.
28
+ - add validateEmailVerificationCodeV0.
29
+
30
+ ### v5.2.1
31
+
32
+ - AuthenticationCommonBL:
33
+ - fix url in updateUserProfilePhotoV0.
34
+
18
35
  ### v5.2.0
19
36
 
20
37
  - AuthenticationCommonBL:
@@ -1,3 +1,4 @@
1
+ import { RecoveryMethodEnum } from "./types/AuthenticationResponses.js";
1
2
  declare class AuthenticationCommonBL {
2
3
  private commonBLBaseURL;
3
4
  constructor(commonBLBaseURL?: string);
@@ -16,11 +17,6 @@ declare class AuthenticationCommonBL {
16
17
  };
17
18
  log?: any;
18
19
  }>;
19
- updatePasswordV0(accessToken: string, oldPassword: string, newPassword: string): Promise<{
20
- message: string | null;
21
- data: null;
22
- log?: any;
23
- }>;
24
20
  getUserDetailsV0(accessToken: string): Promise<{
25
21
  message: string | null;
26
22
  data: {
@@ -60,5 +56,61 @@ declare class AuthenticationCommonBL {
60
56
  data?: any;
61
57
  log?: any;
62
58
  }>;
59
+ generateAccountBackupCodesV0(accessToken: string): Promise<{
60
+ message: string | null;
61
+ data: {
62
+ main: {
63
+ user_id: string;
64
+ backup_codes: string[];
65
+ };
66
+ };
67
+ log?: any;
68
+ }>;
69
+ updateProfileDetailsV0(accessToken: string, firstName?: string, lastName?: string, email?: string, phoneNumberCountryCode?: string, phoneNumber?: string): Promise<{
70
+ message: string | null;
71
+ data: {
72
+ main: {
73
+ user_id: string;
74
+ user_profile_id: number;
75
+ user_profile_photo_storage_token: string | null;
76
+ user_profile_email: string | null;
77
+ user_profile_phone_number: string | null;
78
+ user_profile_first_name: string | null;
79
+ user_profile_last_name: string | null;
80
+ user_profile_phone_number_country_code: string | null;
81
+ user_profile_email_verified: string | null;
82
+ }[];
83
+ affected_count: number;
84
+ };
85
+ log?: any;
86
+ }>;
87
+ sendResetPasswordEmailV0(username: string): Promise<{
88
+ message: string | null;
89
+ data: {
90
+ expires_at: string;
91
+ };
92
+ log?: any;
93
+ }>;
94
+ updateUserRecoveryMethodsV0(accessToken: string, recoveryMethodsToAdd?: RecoveryMethodEnum[], recoveryMethodsToRemove?: RecoveryMethodEnum[]): Promise<{
95
+ message: string | null;
96
+ data: {
97
+ main: ("EMAIL" | "BACKUP_CODE")[];
98
+ };
99
+ log?: any;
100
+ }>;
101
+ sendVerificationEmailV0(accessToken: string): Promise<{
102
+ message: string | null;
103
+ data: {
104
+ expires_at: string;
105
+ } | null;
106
+ log?: any;
107
+ }>;
108
+ validateEmailVerificationCodeV0(accessToken: string, verificationCode: string): Promise<{
109
+ message: string | null;
110
+ data: {
111
+ user_profile_email_verified: string;
112
+ } | null;
113
+ log?: any;
114
+ }>;
63
115
  }
64
116
  export { AuthenticationCommonBL };
@@ -1,5 +1,5 @@
1
1
  import { fetchFileData, fetchJSONData } from "squarecommons";
2
- import { DeleteUserV0Z, GetUserDetailsV0ResponseZ, LogoutAllV0Z, LogoutAppsV0Z, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
2
+ import { DeleteUserV0Z, GenerateAccountBackupCodeZ, GetUserDetailsV0ResponseZ, LogoutAllV0Z, LogoutAppsV0Z, sendResetPasswordEmailV0ResponseZ, sendVerificationEmailV0ResponseZ, updateProfileDetailsZ, UpdateUsernameV0ResponseZ, updateUserRecoveryMethodsV0ResponseZ, validateEmailVerificationCodeV0ResponseZ } from "./types/AuthenticationResponses.js";
3
3
  class AuthenticationCommonBL {
4
4
  commonBLBaseURL;
5
5
  constructor(commonBLBaseURL = "http://localhost:10110") {
@@ -13,7 +13,7 @@ class AuthenticationCommonBL {
13
13
  // endpoint
14
14
  "delete_user/v0",
15
15
  // method
16
- "DELETE",
16
+ "POST",
17
17
  // headers
18
18
  { access_token: accessToken },
19
19
  // body
@@ -47,27 +47,6 @@ class AuthenticationCommonBL {
47
47
  throw error;
48
48
  }
49
49
  }
50
- async updatePasswordV0(accessToken, oldPassword, newPassword) {
51
- try {
52
- const data = await fetchJSONData(
53
- // base url
54
- this.commonBLBaseURL,
55
- // endpoint
56
- "update_password/v0",
57
- // method
58
- "PATCH",
59
- // headers
60
- { access_token: accessToken },
61
- // body
62
- { old_password: oldPassword, new_password: newPassword },
63
- // query params
64
- undefined);
65
- return UpdatePasswordV0ResponseZ.parse(data);
66
- }
67
- catch (error) {
68
- throw error;
69
- }
70
- }
71
50
  async getUserDetailsV0(accessToken) {
72
51
  try {
73
52
  const data = await fetchJSONData(
@@ -155,13 +134,13 @@ class AuthenticationCommonBL {
155
134
  async updateUserProfilePhotoV0(accessToken, profilePhoto) {
156
135
  try {
157
136
  const MAX_SIZE = 5 * 1024 * 1024; // 5 MiB
158
- const ALLOWED_TYPES = ['image/png', 'image/jpeg'];
137
+ const ALLOWED_TYPES = ["image/png", "image/jpeg"];
159
138
  if (profilePhoto) {
160
139
  if (!ALLOWED_TYPES.includes(profilePhoto.type)) {
161
- throw new Error('invalid file type: only png or jpeg allowed');
140
+ throw new Error("invalid file type: only png or jpeg allowed");
162
141
  }
163
142
  if (profilePhoto.size > MAX_SIZE) {
164
- throw new Error('file too large: must be under 5 MiB');
143
+ throw new Error("file too large: must be under 5 MiB");
165
144
  }
166
145
  }
167
146
  const formData = new FormData();
@@ -172,7 +151,7 @@ class AuthenticationCommonBL {
172
151
  // base url
173
152
  this.commonBLBaseURL,
174
153
  // endpoint
175
- "update_user_profile_photo/v0",
154
+ "update_profile_photo/v0",
176
155
  // method
177
156
  "PATCH",
178
157
  // headers
@@ -187,5 +166,152 @@ class AuthenticationCommonBL {
187
166
  throw error;
188
167
  }
189
168
  }
169
+ async generateAccountBackupCodesV0(accessToken) {
170
+ try {
171
+ const data = await fetchJSONData(
172
+ // base url
173
+ this.commonBLBaseURL,
174
+ // endpoint
175
+ "generate_account_backup_codes/v0",
176
+ // method
177
+ "POST",
178
+ // headers
179
+ { access_token: accessToken },
180
+ // body
181
+ undefined,
182
+ // query params
183
+ undefined);
184
+ return GenerateAccountBackupCodeZ.parse(data);
185
+ }
186
+ catch (error) {
187
+ throw error;
188
+ }
189
+ }
190
+ async updateProfileDetailsV0(accessToken, firstName, lastName, email, phoneNumberCountryCode, phoneNumber) {
191
+ try {
192
+ const queryParams = {};
193
+ if (firstName)
194
+ queryParams["first_name"] = firstName;
195
+ if (lastName)
196
+ queryParams["last_name"] = lastName;
197
+ if (email)
198
+ queryParams["email"] = email;
199
+ if (phoneNumberCountryCode)
200
+ queryParams["phone_number_country_code"] = phoneNumberCountryCode;
201
+ if (phoneNumber)
202
+ queryParams["phone_number"] = phoneNumber;
203
+ // Call API
204
+ const data = await fetchJSONData(
205
+ // base url
206
+ this.commonBLBaseURL,
207
+ // endpoint
208
+ "update_profile_details/v0",
209
+ // method
210
+ "PATCH",
211
+ // headers
212
+ { access_token: accessToken },
213
+ // body
214
+ undefined,
215
+ // query params
216
+ queryParams);
217
+ return updateProfileDetailsZ.parse(data);
218
+ }
219
+ catch (error) {
220
+ throw error;
221
+ }
222
+ }
223
+ async sendResetPasswordEmailV0(username) {
224
+ try {
225
+ const data = await fetchJSONData(
226
+ // base url
227
+ this.commonBLBaseURL,
228
+ // endpoint
229
+ "send_reset_password_email/v0",
230
+ // method
231
+ "POST",
232
+ // headers
233
+ undefined,
234
+ // body
235
+ { username: username },
236
+ // query params
237
+ undefined);
238
+ return sendResetPasswordEmailV0ResponseZ.parse(data);
239
+ }
240
+ catch (error) {
241
+ throw error;
242
+ }
243
+ }
244
+ async updateUserRecoveryMethodsV0(accessToken, recoveryMethodsToAdd, recoveryMethodsToRemove) {
245
+ try {
246
+ if (!recoveryMethodsToAdd) {
247
+ recoveryMethodsToAdd = [];
248
+ }
249
+ if (!recoveryMethodsToRemove) {
250
+ recoveryMethodsToRemove = [];
251
+ }
252
+ const data = await fetchJSONData(
253
+ // base url
254
+ this.commonBLBaseURL,
255
+ // endpoint
256
+ "update_user_recovery_methods/v0",
257
+ // method
258
+ "PATCH",
259
+ // headers
260
+ { access_token: accessToken },
261
+ // body
262
+ undefined,
263
+ // query params
264
+ {
265
+ recovery_methods_to_add: recoveryMethodsToAdd.join(","),
266
+ recovery_methods_to_remove: recoveryMethodsToRemove.join(","),
267
+ });
268
+ return updateUserRecoveryMethodsV0ResponseZ.parse(data);
269
+ }
270
+ catch (error) {
271
+ throw error;
272
+ }
273
+ }
274
+ async sendVerificationEmailV0(accessToken) {
275
+ try {
276
+ const data = await fetchJSONData(
277
+ // base url
278
+ this.commonBLBaseURL,
279
+ // endpoint
280
+ "send_verification_email/v0",
281
+ // method
282
+ "POST",
283
+ // headers
284
+ { access_token: accessToken },
285
+ // body
286
+ undefined,
287
+ // query params
288
+ undefined);
289
+ return sendVerificationEmailV0ResponseZ.parse(data);
290
+ }
291
+ catch (error) {
292
+ throw error;
293
+ }
294
+ }
295
+ async validateEmailVerificationCodeV0(accessToken, verificationCode) {
296
+ try {
297
+ const data = await fetchJSONData(
298
+ // base url
299
+ this.commonBLBaseURL,
300
+ // endpoint
301
+ "validate_email_verification_code/v0",
302
+ // method
303
+ "POST",
304
+ // headers
305
+ { access_token: accessToken },
306
+ // body
307
+ { verification_code: verificationCode },
308
+ // query params
309
+ undefined);
310
+ return validateEmailVerificationCodeV0ResponseZ.parse(data);
311
+ }
312
+ catch (error) {
313
+ throw error;
314
+ }
315
+ }
190
316
  }
191
317
  export { AuthenticationCommonBL };
@@ -46,22 +46,6 @@ declare const UpdateUsernameV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
46
46
  log?: any;
47
47
  }>;
48
48
  type UpdateUsernameV0Response = z.infer<typeof UpdateUsernameV0ResponseZ>;
49
- declare const UpdatePasswordV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
50
- data: z.ZodAny;
51
- message: z.ZodNullable<z.ZodString>;
52
- log: z.ZodAny;
53
- }, {
54
- data: z.ZodNull;
55
- }>, "strict", z.ZodTypeAny, {
56
- message: string | null;
57
- data: null;
58
- log?: any;
59
- }, {
60
- message: string | null;
61
- data: null;
62
- log?: any;
63
- }>;
64
- type UpdatePasswordV0Response = z.infer<typeof UpdatePasswordV0ResponseZ>;
65
49
  declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
66
50
  data: z.ZodAny;
67
51
  message: z.ZodNullable<z.ZodString>;
@@ -270,4 +254,258 @@ declare const LogoutAppsV0Z: z.ZodObject<z.objectUtil.extendShape<{
270
254
  log?: any;
271
255
  }>;
272
256
  type LogoutAppsV0 = z.infer<typeof LogoutAppsV0Z>;
273
- export { UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, UpdatePasswordV0ResponseZ, UpdatePasswordV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, DeleteUserV0, DeleteUserV0Z, LogoutAllV0, LogoutAllV0Z, LogoutAppsV0, LogoutAppsV0Z, };
257
+ declare const GenerateAccountBackupCodeZ: z.ZodObject<z.objectUtil.extendShape<{
258
+ data: z.ZodAny;
259
+ message: z.ZodNullable<z.ZodString>;
260
+ log: z.ZodAny;
261
+ }, {
262
+ data: z.ZodObject<{
263
+ main: z.ZodObject<{
264
+ user_id: z.ZodString;
265
+ backup_codes: z.ZodArray<z.ZodString, "many">;
266
+ }, "strict", z.ZodTypeAny, {
267
+ user_id: string;
268
+ backup_codes: string[];
269
+ }, {
270
+ user_id: string;
271
+ backup_codes: string[];
272
+ }>;
273
+ }, "strict", z.ZodTypeAny, {
274
+ main: {
275
+ user_id: string;
276
+ backup_codes: string[];
277
+ };
278
+ }, {
279
+ main: {
280
+ user_id: string;
281
+ backup_codes: string[];
282
+ };
283
+ }>;
284
+ }>, "strict", z.ZodTypeAny, {
285
+ message: string | null;
286
+ data: {
287
+ main: {
288
+ user_id: string;
289
+ backup_codes: string[];
290
+ };
291
+ };
292
+ log?: any;
293
+ }, {
294
+ message: string | null;
295
+ data: {
296
+ main: {
297
+ user_id: string;
298
+ backup_codes: string[];
299
+ };
300
+ };
301
+ log?: any;
302
+ }>;
303
+ type GenerateAccountBackupCode = z.infer<typeof GenerateAccountBackupCodeZ>;
304
+ declare const updateProfileDetailsZ: z.ZodObject<z.objectUtil.extendShape<{
305
+ data: z.ZodAny;
306
+ message: z.ZodNullable<z.ZodString>;
307
+ log: z.ZodAny;
308
+ }, {
309
+ data: z.ZodObject<{
310
+ main: z.ZodArray<z.ZodObject<{
311
+ user_profile_photo_storage_token: z.ZodNullable<z.ZodString>;
312
+ user_profile_email: z.ZodNullable<z.ZodString>;
313
+ user_profile_phone_number_country_code: z.ZodNullable<z.ZodString>;
314
+ user_profile_first_name: z.ZodNullable<z.ZodString>;
315
+ user_profile_last_name: z.ZodNullable<z.ZodString>;
316
+ user_id: z.ZodString;
317
+ user_profile_id: z.ZodNumber;
318
+ user_profile_email_verified: z.ZodNullable<z.ZodString>;
319
+ user_profile_phone_number: z.ZodNullable<z.ZodString>;
320
+ }, "strict", z.ZodTypeAny, {
321
+ user_id: string;
322
+ user_profile_id: number;
323
+ user_profile_photo_storage_token: string | null;
324
+ user_profile_email: string | null;
325
+ user_profile_phone_number: string | null;
326
+ user_profile_first_name: string | null;
327
+ user_profile_last_name: string | null;
328
+ user_profile_phone_number_country_code: string | null;
329
+ user_profile_email_verified: string | null;
330
+ }, {
331
+ user_id: string;
332
+ user_profile_id: number;
333
+ user_profile_photo_storage_token: string | null;
334
+ user_profile_email: string | null;
335
+ user_profile_phone_number: string | null;
336
+ user_profile_first_name: string | null;
337
+ user_profile_last_name: string | null;
338
+ user_profile_phone_number_country_code: string | null;
339
+ user_profile_email_verified: string | null;
340
+ }>, "many">;
341
+ affected_count: z.ZodNumber;
342
+ }, "strict", z.ZodTypeAny, {
343
+ main: {
344
+ user_id: string;
345
+ user_profile_id: number;
346
+ user_profile_photo_storage_token: string | null;
347
+ user_profile_email: string | null;
348
+ user_profile_phone_number: string | null;
349
+ user_profile_first_name: string | null;
350
+ user_profile_last_name: string | null;
351
+ user_profile_phone_number_country_code: string | null;
352
+ user_profile_email_verified: string | null;
353
+ }[];
354
+ affected_count: number;
355
+ }, {
356
+ main: {
357
+ user_id: string;
358
+ user_profile_id: number;
359
+ user_profile_photo_storage_token: string | null;
360
+ user_profile_email: string | null;
361
+ user_profile_phone_number: string | null;
362
+ user_profile_first_name: string | null;
363
+ user_profile_last_name: string | null;
364
+ user_profile_phone_number_country_code: string | null;
365
+ user_profile_email_verified: string | null;
366
+ }[];
367
+ affected_count: number;
368
+ }>;
369
+ }>, "strict", z.ZodTypeAny, {
370
+ message: string | null;
371
+ data: {
372
+ main: {
373
+ user_id: string;
374
+ user_profile_id: number;
375
+ user_profile_photo_storage_token: string | null;
376
+ user_profile_email: string | null;
377
+ user_profile_phone_number: string | null;
378
+ user_profile_first_name: string | null;
379
+ user_profile_last_name: string | null;
380
+ user_profile_phone_number_country_code: string | null;
381
+ user_profile_email_verified: string | null;
382
+ }[];
383
+ affected_count: number;
384
+ };
385
+ log?: any;
386
+ }, {
387
+ message: string | null;
388
+ data: {
389
+ main: {
390
+ user_id: string;
391
+ user_profile_id: number;
392
+ user_profile_photo_storage_token: string | null;
393
+ user_profile_email: string | null;
394
+ user_profile_phone_number: string | null;
395
+ user_profile_first_name: string | null;
396
+ user_profile_last_name: string | null;
397
+ user_profile_phone_number_country_code: string | null;
398
+ user_profile_email_verified: string | null;
399
+ }[];
400
+ affected_count: number;
401
+ };
402
+ log?: any;
403
+ }>;
404
+ type updateProfileDetails = z.infer<typeof updateProfileDetailsZ>;
405
+ declare const sendResetPasswordEmailV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
406
+ data: z.ZodAny;
407
+ message: z.ZodNullable<z.ZodString>;
408
+ log: z.ZodAny;
409
+ }, {
410
+ data: z.ZodObject<{
411
+ expires_at: z.ZodString;
412
+ }, "strict", z.ZodTypeAny, {
413
+ expires_at: string;
414
+ }, {
415
+ expires_at: string;
416
+ }>;
417
+ }>, "strict", z.ZodTypeAny, {
418
+ message: string | null;
419
+ data: {
420
+ expires_at: string;
421
+ };
422
+ log?: any;
423
+ }, {
424
+ message: string | null;
425
+ data: {
426
+ expires_at: string;
427
+ };
428
+ log?: any;
429
+ }>;
430
+ type sendResetPasswordEmailV0Response = z.infer<typeof sendResetPasswordEmailV0ResponseZ>;
431
+ declare const RecoveryMethodEnumZ: z.ZodEnum<["EMAIL", "BACKUP_CODE"]>;
432
+ type RecoveryMethodEnum = z.infer<typeof RecoveryMethodEnumZ>;
433
+ declare const updateUserRecoveryMethodsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
434
+ data: z.ZodAny;
435
+ message: z.ZodNullable<z.ZodString>;
436
+ log: z.ZodAny;
437
+ }, {
438
+ data: z.ZodObject<{
439
+ main: z.ZodArray<z.ZodEnum<["EMAIL", "BACKUP_CODE"]>, "many">;
440
+ }, "strict", z.ZodTypeAny, {
441
+ main: ("EMAIL" | "BACKUP_CODE")[];
442
+ }, {
443
+ main: ("EMAIL" | "BACKUP_CODE")[];
444
+ }>;
445
+ }>, "strict", z.ZodTypeAny, {
446
+ message: string | null;
447
+ data: {
448
+ main: ("EMAIL" | "BACKUP_CODE")[];
449
+ };
450
+ log?: any;
451
+ }, {
452
+ message: string | null;
453
+ data: {
454
+ main: ("EMAIL" | "BACKUP_CODE")[];
455
+ };
456
+ log?: any;
457
+ }>;
458
+ type updateUserRecoveryMethodsV0Response = z.infer<typeof updateUserRecoveryMethodsV0ResponseZ>;
459
+ declare const sendVerificationEmailV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
460
+ data: z.ZodAny;
461
+ message: z.ZodNullable<z.ZodString>;
462
+ log: z.ZodAny;
463
+ }, {
464
+ data: z.ZodNullable<z.ZodObject<{
465
+ expires_at: z.ZodString;
466
+ }, "strict", z.ZodTypeAny, {
467
+ expires_at: string;
468
+ }, {
469
+ expires_at: string;
470
+ }>>;
471
+ }>, "strict", z.ZodTypeAny, {
472
+ message: string | null;
473
+ data: {
474
+ expires_at: string;
475
+ } | null;
476
+ log?: any;
477
+ }, {
478
+ message: string | null;
479
+ data: {
480
+ expires_at: string;
481
+ } | null;
482
+ log?: any;
483
+ }>;
484
+ type sendVerificationEmailV0Response = z.infer<typeof sendVerificationEmailV0ResponseZ>;
485
+ declare const validateEmailVerificationCodeV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
486
+ data: z.ZodAny;
487
+ message: z.ZodNullable<z.ZodString>;
488
+ log: z.ZodAny;
489
+ }, {
490
+ data: z.ZodNullable<z.ZodObject<{
491
+ user_profile_email_verified: z.ZodString;
492
+ }, "strict", z.ZodTypeAny, {
493
+ user_profile_email_verified: string;
494
+ }, {
495
+ user_profile_email_verified: string;
496
+ }>>;
497
+ }>, "strict", z.ZodTypeAny, {
498
+ message: string | null;
499
+ data: {
500
+ user_profile_email_verified: string;
501
+ } | null;
502
+ log?: any;
503
+ }, {
504
+ message: string | null;
505
+ data: {
506
+ user_profile_email_verified: string;
507
+ } | null;
508
+ log?: any;
509
+ }>;
510
+ type validateEmailVerificationCodeV0Response = z.infer<typeof validateEmailVerificationCodeV0ResponseZ>;
511
+ export { UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, DeleteUserV0, DeleteUserV0Z, LogoutAllV0, LogoutAllV0Z, LogoutAppsV0, LogoutAppsV0Z, GenerateAccountBackupCode, GenerateAccountBackupCodeZ, updateProfileDetailsZ, updateProfileDetails, sendResetPasswordEmailV0ResponseZ, sendResetPasswordEmailV0Response, RecoveryMethodEnumZ, RecoveryMethodEnum, updateUserRecoveryMethodsV0ResponseZ, updateUserRecoveryMethodsV0Response, sendVerificationEmailV0ResponseZ, sendVerificationEmailV0Response, validateEmailVerificationCodeV0ResponseZ, validateEmailVerificationCodeV0Response, };
@@ -8,9 +8,6 @@ const UpdateUsernameV0ResponseZ = APIOutputZ.extend({
8
8
  }),
9
9
  }),
10
10
  });
11
- const UpdatePasswordV0ResponseZ = APIOutputZ.extend({
12
- data: z.null(),
13
- });
14
11
  const GetUserDetailsV0ResponseZ = APIOutputZ.extend({
15
12
  data: z.strictObject({
16
13
  main: z.strictObject({
@@ -41,4 +38,51 @@ const LogoutAllV0Z = APIOutputZ.extend({
41
38
  const LogoutAppsV0Z = APIOutputZ.extend({
42
39
  data: z.null(),
43
40
  });
44
- export { UpdateUsernameV0ResponseZ, UpdatePasswordV0ResponseZ, GetUserDetailsV0ResponseZ, DeleteUserV0Z, LogoutAllV0Z, LogoutAppsV0Z, };
41
+ const GenerateAccountBackupCodeZ = APIOutputZ.extend({
42
+ data: z.strictObject({
43
+ main: z.strictObject({
44
+ user_id: z.string(),
45
+ backup_codes: z.array(z.string()),
46
+ }),
47
+ }),
48
+ });
49
+ const updateProfileDetailsZ = APIOutputZ.extend({
50
+ data: z.strictObject({
51
+ main: z
52
+ .array(z.strictObject({
53
+ user_profile_photo_storage_token: z.string().nullable(),
54
+ user_profile_email: z.string().nullable(),
55
+ user_profile_phone_number_country_code: z.string().nullable(),
56
+ user_profile_first_name: z.string().nullable(),
57
+ user_profile_last_name: z.string().nullable(),
58
+ user_id: z.string(),
59
+ user_profile_id: z.number(),
60
+ user_profile_email_verified: z.string().nullable(),
61
+ user_profile_phone_number: z.string().nullable(),
62
+ }))
63
+ .length(1),
64
+ affected_count: z.number(),
65
+ }),
66
+ });
67
+ const sendResetPasswordEmailV0ResponseZ = APIOutputZ.extend({
68
+ data: z.strictObject({
69
+ expires_at: z.string(),
70
+ }),
71
+ });
72
+ const RecoveryMethodEnumZ = z.enum(["EMAIL", "BACKUP_CODE"]);
73
+ const updateUserRecoveryMethodsV0ResponseZ = APIOutputZ.extend({
74
+ data: z.strictObject({
75
+ main: z.array(RecoveryMethodEnumZ),
76
+ }),
77
+ });
78
+ const sendVerificationEmailV0ResponseZ = APIOutputZ.extend({
79
+ data: z.nullable(z.strictObject({
80
+ expires_at: z.string(),
81
+ })),
82
+ });
83
+ const validateEmailVerificationCodeV0ResponseZ = APIOutputZ.extend({
84
+ data: z.nullable(z.strictObject({
85
+ user_profile_email_verified: z.string(),
86
+ })),
87
+ });
88
+ export { UpdateUsernameV0ResponseZ, GetUserDetailsV0ResponseZ, DeleteUserV0Z, LogoutAllV0Z, LogoutAppsV0Z, GenerateAccountBackupCodeZ, updateProfileDetailsZ, sendResetPasswordEmailV0ResponseZ, RecoveryMethodEnumZ, updateUserRecoveryMethodsV0ResponseZ, sendVerificationEmailV0ResponseZ, validateEmailVerificationCodeV0ResponseZ, };
package/example.js CHANGED
@@ -29,3 +29,21 @@ console.log(
29
29
  await authenticationCommonBL.logoutAppsV0("dummy_access_token", ["test"])
30
30
  );
31
31
  console.log(await authenticationCommonBL.getProfilePhoto("dummy_access_token"));
32
+ console.log(
33
+ await authenticationCommonBL.sendResetPasswordEmailV0("dummy_username")
34
+ );
35
+ console.log(
36
+ await authenticationCommonBL.updateProfileDetailsV0(
37
+ "dummy_access_token",
38
+ "first_name"
39
+ )
40
+ );
41
+ console.log(
42
+ await authenticationCommonBL.updateUserRecoveryMethodsV0(
43
+ "dummy_access_token",
44
+ ["BACKUP_CODE"]
45
+ )
46
+ );
47
+ console.log(
48
+ await authenticationCommonBL.sendVerificationEmailV0("dummy_access_token")
49
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarecommonblhelper",
3
- "version": "5.2.0",
3
+ "version": "6.0.0",
4
4
  "description": "helper for common bl for my projects.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",