squarecommonblhelper 5.0.0 → 5.2.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,17 @@ helper for common bl for my projects.
|
|
|
15
15
|
|
|
16
16
|
## changelog
|
|
17
17
|
|
|
18
|
+
### v5.2.0
|
|
19
|
+
|
|
20
|
+
- AuthenticationCommonBL:
|
|
21
|
+
- add updateUserProfilePhotoV0.
|
|
22
|
+
- rename getUserProfilePhoto to getUserProfilePhotoV0.
|
|
23
|
+
|
|
24
|
+
### v5.1.0
|
|
25
|
+
|
|
26
|
+
- AuthenticationCommonBL:
|
|
27
|
+
- add getUserProfilePhoto.
|
|
28
|
+
|
|
18
29
|
### v5.0.0
|
|
19
30
|
|
|
20
31
|
- AuthenticationCommonBL:
|
package/dist/authentication.d.ts
CHANGED
|
@@ -54,5 +54,11 @@ declare class AuthenticationCommonBL {
|
|
|
54
54
|
data: null;
|
|
55
55
|
log?: any;
|
|
56
56
|
}>;
|
|
57
|
+
getUserProfilePhotoV0(accessToken: string): Promise<Blob>;
|
|
58
|
+
updateUserProfilePhotoV0(accessToken: string, profilePhoto?: File): Promise<{
|
|
59
|
+
message: string | null;
|
|
60
|
+
data?: any;
|
|
61
|
+
log?: any;
|
|
62
|
+
}>;
|
|
57
63
|
}
|
|
58
64
|
export { AuthenticationCommonBL };
|
package/dist/authentication.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { fetchJSONData } from "squarecommons";
|
|
1
|
+
import { fetchFileData, fetchJSONData } from "squarecommons";
|
|
2
2
|
import { DeleteUserV0Z, GetUserDetailsV0ResponseZ, LogoutAllV0Z, LogoutAppsV0Z, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ, } from "./types/AuthenticationResponses.js";
|
|
3
3
|
class AuthenticationCommonBL {
|
|
4
4
|
commonBLBaseURL;
|
|
@@ -131,5 +131,61 @@ class AuthenticationCommonBL {
|
|
|
131
131
|
throw error;
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
+
async getUserProfilePhotoV0(accessToken) {
|
|
135
|
+
try {
|
|
136
|
+
const data = await fetchFileData(
|
|
137
|
+
// base url
|
|
138
|
+
this.commonBLBaseURL,
|
|
139
|
+
// endpoint
|
|
140
|
+
"get_user_profile_photo/v0",
|
|
141
|
+
// method
|
|
142
|
+
"GET",
|
|
143
|
+
// headers
|
|
144
|
+
{ access_token: accessToken },
|
|
145
|
+
// body
|
|
146
|
+
undefined,
|
|
147
|
+
// query params
|
|
148
|
+
undefined);
|
|
149
|
+
return data;
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async updateUserProfilePhotoV0(accessToken, profilePhoto) {
|
|
156
|
+
try {
|
|
157
|
+
const MAX_SIZE = 5 * 1024 * 1024; // 5 MiB
|
|
158
|
+
const ALLOWED_TYPES = ['image/png', 'image/jpeg'];
|
|
159
|
+
if (profilePhoto) {
|
|
160
|
+
if (!ALLOWED_TYPES.includes(profilePhoto.type)) {
|
|
161
|
+
throw new Error('invalid file type: only png or jpeg allowed');
|
|
162
|
+
}
|
|
163
|
+
if (profilePhoto.size > MAX_SIZE) {
|
|
164
|
+
throw new Error('file too large: must be under 5 MiB');
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const formData = new FormData();
|
|
168
|
+
if (profilePhoto) {
|
|
169
|
+
formData.append("profile_photo", profilePhoto);
|
|
170
|
+
}
|
|
171
|
+
const data = await fetchJSONData(
|
|
172
|
+
// base url
|
|
173
|
+
this.commonBLBaseURL,
|
|
174
|
+
// endpoint
|
|
175
|
+
"update_user_profile_photo/v0",
|
|
176
|
+
// method
|
|
177
|
+
"PATCH",
|
|
178
|
+
// headers
|
|
179
|
+
{ access_token: accessToken },
|
|
180
|
+
// body
|
|
181
|
+
formData,
|
|
182
|
+
// query params
|
|
183
|
+
undefined);
|
|
184
|
+
return data;
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
134
190
|
}
|
|
135
191
|
export { AuthenticationCommonBL };
|
|
@@ -26,7 +26,7 @@ declare const UpdateUsernameV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
26
26
|
username: string;
|
|
27
27
|
};
|
|
28
28
|
}>;
|
|
29
|
-
}>, "
|
|
29
|
+
}>, "strict", z.ZodTypeAny, {
|
|
30
30
|
message: string | null;
|
|
31
31
|
data: {
|
|
32
32
|
main: {
|
|
@@ -52,7 +52,7 @@ declare const UpdatePasswordV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
52
52
|
log: z.ZodAny;
|
|
53
53
|
}, {
|
|
54
54
|
data: z.ZodNull;
|
|
55
|
-
}>, "
|
|
55
|
+
}>, "strict", z.ZodTypeAny, {
|
|
56
56
|
message: string | null;
|
|
57
57
|
data: null;
|
|
58
58
|
log?: any;
|
|
@@ -176,7 +176,7 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
176
176
|
}[];
|
|
177
177
|
};
|
|
178
178
|
}>;
|
|
179
|
-
}>, "
|
|
179
|
+
}>, "strict", z.ZodTypeAny, {
|
|
180
180
|
message: string | null;
|
|
181
181
|
data: {
|
|
182
182
|
main: {
|
|
@@ -228,7 +228,7 @@ declare const DeleteUserV0Z: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
228
228
|
log: z.ZodAny;
|
|
229
229
|
}, {
|
|
230
230
|
data: z.ZodNull;
|
|
231
|
-
}>, "
|
|
231
|
+
}>, "strict", z.ZodTypeAny, {
|
|
232
232
|
message: string | null;
|
|
233
233
|
data: null;
|
|
234
234
|
log?: any;
|
|
@@ -244,7 +244,7 @@ declare const LogoutAllV0Z: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
244
244
|
log: z.ZodAny;
|
|
245
245
|
}, {
|
|
246
246
|
data: z.ZodNull;
|
|
247
|
-
}>, "
|
|
247
|
+
}>, "strict", z.ZodTypeAny, {
|
|
248
248
|
message: string | null;
|
|
249
249
|
data: null;
|
|
250
250
|
log?: any;
|
|
@@ -260,7 +260,7 @@ declare const LogoutAppsV0Z: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
260
260
|
log: z.ZodAny;
|
|
261
261
|
}, {
|
|
262
262
|
data: z.ZodNull;
|
|
263
|
-
}>, "
|
|
263
|
+
}>, "strict", z.ZodTypeAny, {
|
|
264
264
|
message: string | null;
|
|
265
265
|
data: null;
|
|
266
266
|
log?: any;
|
package/example.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "squarecommonblhelper",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "helper for common bl for my projects.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"node": ">=18.0.0"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"squarecommons": "^2.
|
|
37
|
+
"squarecommons": "^2.3.0",
|
|
38
38
|
"zod": "^3.24.1"
|
|
39
39
|
}
|
|
40
40
|
}
|