squarecommonblhelper 9.1.0 → 9.2.1

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,16 @@ helper for common bl for my projects.
15
15
 
16
16
  ## changelog
17
17
 
18
+ ### v9.2.1
19
+
20
+ - AuthenticationCommonBL:
21
+ - update type of GetUserDetailsV0ResponseZ and GetUserRecoveryMethodsV0ResponseZ to include RecoveryMethodEnumZ as key instead of random string.
22
+
23
+ ### v9.2.0
24
+
25
+ - AuthenticationCommonBL:
26
+ - add getUserRecoveryMethodsV0.
27
+
18
28
  ### v9.1.0
19
29
 
20
30
  - AuthenticationCommonBL:
@@ -38,7 +38,7 @@ declare class AuthenticationCommonBL {
38
38
  app_name: string;
39
39
  active_sessions: number;
40
40
  }[];
41
- recovery_methods: Record<string, boolean>;
41
+ recovery_methods: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
42
42
  email_verification_details: {
43
43
  expires_at: string;
44
44
  cooldown_reset_at: string;
@@ -121,5 +121,12 @@ declare class AuthenticationCommonBL {
121
121
  } | null;
122
122
  log?: any;
123
123
  }>;
124
+ getUserRecoveryMethodsV0(username: string): Promise<{
125
+ message: string | null;
126
+ data: {
127
+ main: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
128
+ };
129
+ log?: any;
130
+ }>;
124
131
  }
125
132
  export { AuthenticationCommonBL };
@@ -1,5 +1,5 @@
1
1
  import { fetchFileData, fetchJSONData } from "squarecommons";
2
- import { DeleteUserV0ResponseZ, GenerateAccountBackupCodeV0ResponseZ, GetUserDetailsV0ResponseZ, LogoutAllV0ResponseZ, LogoutAppsV0ResponseZ, sendResetPasswordEmailV0ResponseZ, sendVerificationEmailV0ResponseZ, updateProfileDetailsV0ResponseZ, UpdateUsernameV0ResponseZ, updateUserRecoveryMethodsV0ResponseZ, validateEmailVerificationCodeV0ResponseZ, } from "./types/AuthenticationResponses.js";
2
+ import { DeleteUserV0ResponseZ, GenerateAccountBackupCodeV0ResponseZ, GetUserDetailsV0ResponseZ, GetUserRecoveryMethodsV0ResponseZ, LogoutAllV0ResponseZ, LogoutAppsV0ResponseZ, sendResetPasswordEmailV0ResponseZ, sendVerificationEmailV0ResponseZ, updateProfileDetailsV0ResponseZ, UpdateUsernameV0ResponseZ, updateUserRecoveryMethodsV0ResponseZ, validateEmailVerificationCodeV0ResponseZ, } from "./types/AuthenticationResponses.js";
3
3
  class AuthenticationCommonBL {
4
4
  commonBLBaseURL;
5
5
  constructor(commonBLBaseURL = "http://localhost:10110") {
@@ -313,5 +313,26 @@ class AuthenticationCommonBL {
313
313
  throw error;
314
314
  }
315
315
  }
316
+ async getUserRecoveryMethodsV0(username) {
317
+ try {
318
+ const data = await fetchJSONData(
319
+ // base url
320
+ this.commonBLBaseURL,
321
+ // endpoint
322
+ "get_user_recovery_methods/v0",
323
+ // method
324
+ "GET",
325
+ // headers
326
+ undefined,
327
+ // body
328
+ undefined,
329
+ // query params
330
+ { username: username });
331
+ return GetUserRecoveryMethodsV0ResponseZ.parse(data);
332
+ }
333
+ catch (error) {
334
+ throw error;
335
+ }
336
+ }
316
337
  }
317
338
  export { AuthenticationCommonBL };
@@ -1,4 +1,6 @@
1
1
  import { z } from "zod";
2
+ declare const RecoveryMethodEnumZ: z.ZodEnum<["EMAIL", "BACKUP_CODE"]>;
3
+ type RecoveryMethodEnum = z.infer<typeof RecoveryMethodEnumZ>;
2
4
  declare const UpdateUsernameV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
3
5
  data: z.ZodAny;
4
6
  message: z.ZodNullable<z.ZodString>;
@@ -94,7 +96,7 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
94
96
  app_name: string;
95
97
  active_sessions: number;
96
98
  }>, "many">;
97
- recovery_methods: z.ZodRecord<z.ZodString, z.ZodBoolean>;
99
+ recovery_methods: z.ZodRecord<z.ZodEnum<["EMAIL", "BACKUP_CODE"]>, z.ZodBoolean>;
98
100
  email_verification_details: z.ZodNullable<z.ZodObject<{
99
101
  expires_at: z.ZodString;
100
102
  cooldown_reset_at: z.ZodString;
@@ -123,7 +125,7 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
123
125
  app_name: string;
124
126
  active_sessions: number;
125
127
  }[];
126
- recovery_methods: Record<string, boolean>;
128
+ recovery_methods: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
127
129
  email_verification_details: {
128
130
  expires_at: string;
129
131
  cooldown_reset_at: string;
@@ -146,7 +148,7 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
146
148
  app_name: string;
147
149
  active_sessions: number;
148
150
  }[];
149
- recovery_methods: Record<string, boolean>;
151
+ recovery_methods: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
150
152
  email_verification_details: {
151
153
  expires_at: string;
152
154
  cooldown_reset_at: string;
@@ -171,7 +173,7 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
171
173
  app_name: string;
172
174
  active_sessions: number;
173
175
  }[];
174
- recovery_methods: Record<string, boolean>;
176
+ recovery_methods: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
175
177
  email_verification_details: {
176
178
  expires_at: string;
177
179
  cooldown_reset_at: string;
@@ -196,7 +198,7 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
196
198
  app_name: string;
197
199
  active_sessions: number;
198
200
  }[];
199
- recovery_methods: Record<string, boolean>;
201
+ recovery_methods: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
200
202
  email_verification_details: {
201
203
  expires_at: string;
202
204
  cooldown_reset_at: string;
@@ -224,7 +226,7 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
224
226
  app_name: string;
225
227
  active_sessions: number;
226
228
  }[];
227
- recovery_methods: Record<string, boolean>;
229
+ recovery_methods: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
228
230
  email_verification_details: {
229
231
  expires_at: string;
230
232
  cooldown_reset_at: string;
@@ -253,7 +255,7 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
253
255
  app_name: string;
254
256
  active_sessions: number;
255
257
  }[];
256
- recovery_methods: Record<string, boolean>;
258
+ recovery_methods: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
257
259
  email_verification_details: {
258
260
  expires_at: string;
259
261
  cooldown_reset_at: string;
@@ -490,8 +492,6 @@ declare const sendResetPasswordEmailV0ResponseZ: z.ZodObject<z.objectUtil.extend
490
492
  log?: any;
491
493
  }>;
492
494
  type sendResetPasswordEmailV0Response = z.infer<typeof sendResetPasswordEmailV0ResponseZ>;
493
- declare const RecoveryMethodEnumZ: z.ZodEnum<["EMAIL", "BACKUP_CODE"]>;
494
- type RecoveryMethodEnum = z.infer<typeof RecoveryMethodEnumZ>;
495
495
  declare const updateUserRecoveryMethodsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
496
496
  data: z.ZodAny;
497
497
  message: z.ZodNullable<z.ZodString>;
@@ -575,4 +575,30 @@ declare const validateEmailVerificationCodeV0ResponseZ: z.ZodObject<z.objectUtil
575
575
  log?: any;
576
576
  }>;
577
577
  type validateEmailVerificationCodeV0Response = z.infer<typeof validateEmailVerificationCodeV0ResponseZ>;
578
- export { UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, DeleteUserV0Response, DeleteUserV0ResponseZ, LogoutAllV0Response, LogoutAllV0ResponseZ, LogoutAppsV0Response, LogoutAppsV0ResponseZ, GenerateAccountBackupCodeV0Response, GenerateAccountBackupCodeV0ResponseZ, updateProfileDetailsV0ResponseZ, updateProfileDetailsV0Response, sendResetPasswordEmailV0ResponseZ, sendResetPasswordEmailV0Response, RecoveryMethodEnumZ, RecoveryMethodEnum, updateUserRecoveryMethodsV0ResponseZ, updateUserRecoveryMethodsV0Response, sendVerificationEmailV0ResponseZ, sendVerificationEmailV0Response, validateEmailVerificationCodeV0ResponseZ, validateEmailVerificationCodeV0Response, };
578
+ declare const GetUserRecoveryMethodsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
579
+ data: z.ZodAny;
580
+ message: z.ZodNullable<z.ZodString>;
581
+ log: z.ZodAny;
582
+ }, {
583
+ data: z.ZodObject<{
584
+ main: z.ZodRecord<z.ZodEnum<["EMAIL", "BACKUP_CODE"]>, z.ZodBoolean>;
585
+ }, "strict", z.ZodTypeAny, {
586
+ main: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
587
+ }, {
588
+ main: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
589
+ }>;
590
+ }>, "strict", z.ZodTypeAny, {
591
+ message: string | null;
592
+ data: {
593
+ main: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
594
+ };
595
+ log?: any;
596
+ }, {
597
+ message: string | null;
598
+ data: {
599
+ main: Partial<Record<"EMAIL" | "BACKUP_CODE", boolean>>;
600
+ };
601
+ log?: any;
602
+ }>;
603
+ type GetUserRecoveryMethodsV0Response = z.infer<typeof GetUserRecoveryMethodsV0ResponseZ>;
604
+ export { UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, DeleteUserV0Response, DeleteUserV0ResponseZ, LogoutAllV0Response, LogoutAllV0ResponseZ, LogoutAppsV0Response, LogoutAppsV0ResponseZ, GenerateAccountBackupCodeV0Response, GenerateAccountBackupCodeV0ResponseZ, updateProfileDetailsV0ResponseZ, updateProfileDetailsV0Response, sendResetPasswordEmailV0ResponseZ, sendResetPasswordEmailV0Response, RecoveryMethodEnumZ, RecoveryMethodEnum, updateUserRecoveryMethodsV0ResponseZ, updateUserRecoveryMethodsV0Response, sendVerificationEmailV0ResponseZ, sendVerificationEmailV0Response, validateEmailVerificationCodeV0ResponseZ, validateEmailVerificationCodeV0Response, GetUserRecoveryMethodsV0ResponseZ, GetUserRecoveryMethodsV0Response, };
@@ -1,5 +1,6 @@
1
1
  import { APIOutputZ } from "squarecommons";
2
2
  import { z } from "zod";
3
+ const RecoveryMethodEnumZ = z.enum(["EMAIL", "BACKUP_CODE"]);
3
4
  const UpdateUsernameV0ResponseZ = APIOutputZ.extend({
4
5
  data: z.strictObject({
5
6
  main: z.strictObject({
@@ -28,7 +29,7 @@ const GetUserDetailsV0ResponseZ = APIOutputZ.extend({
28
29
  app_name: z.string(),
29
30
  active_sessions: z.number(),
30
31
  })),
31
- recovery_methods: z.record(z.string(), z.boolean()),
32
+ recovery_methods: z.record(RecoveryMethodEnumZ, z.boolean()),
32
33
  email_verification_details: z
33
34
  .strictObject({ expires_at: z.string(), cooldown_reset_at: z.string() })
34
35
  .nullable(),
@@ -76,7 +77,6 @@ const sendResetPasswordEmailV0ResponseZ = APIOutputZ.extend({
76
77
  cooldown_reset_at: z.string(),
77
78
  }),
78
79
  });
79
- const RecoveryMethodEnumZ = z.enum(["EMAIL", "BACKUP_CODE"]);
80
80
  const updateUserRecoveryMethodsV0ResponseZ = APIOutputZ.extend({
81
81
  data: z.strictObject({
82
82
  main: z.array(RecoveryMethodEnumZ),
@@ -93,4 +93,9 @@ const validateEmailVerificationCodeV0ResponseZ = APIOutputZ.extend({
93
93
  user_profile_email_verified: z.string(),
94
94
  })),
95
95
  });
96
- export { UpdateUsernameV0ResponseZ, GetUserDetailsV0ResponseZ, DeleteUserV0ResponseZ, LogoutAllV0ResponseZ, LogoutAppsV0ResponseZ, GenerateAccountBackupCodeV0ResponseZ, updateProfileDetailsV0ResponseZ, sendResetPasswordEmailV0ResponseZ, RecoveryMethodEnumZ, updateUserRecoveryMethodsV0ResponseZ, sendVerificationEmailV0ResponseZ, validateEmailVerificationCodeV0ResponseZ, };
96
+ const GetUserRecoveryMethodsV0ResponseZ = APIOutputZ.extend({
97
+ data: z.strictObject({
98
+ main: z.record(RecoveryMethodEnumZ, z.boolean()),
99
+ }),
100
+ });
101
+ export { UpdateUsernameV0ResponseZ, GetUserDetailsV0ResponseZ, DeleteUserV0ResponseZ, LogoutAllV0ResponseZ, LogoutAppsV0ResponseZ, GenerateAccountBackupCodeV0ResponseZ, updateProfileDetailsV0ResponseZ, sendResetPasswordEmailV0ResponseZ, RecoveryMethodEnumZ, updateUserRecoveryMethodsV0ResponseZ, sendVerificationEmailV0ResponseZ, validateEmailVerificationCodeV0ResponseZ, GetUserRecoveryMethodsV0ResponseZ, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarecommonblhelper",
3
- "version": "9.1.0",
3
+ "version": "9.2.1",
4
4
  "description": "helper for common bl for my projects.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",