squarecommonblhelper 2.0.1 → 4.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 +10 -0
- package/dist/authentication.d.ts +2 -16
- package/dist/authentication.js +1 -43
- package/dist/types/AuthenticationResponses.d.ts +17 -73
- package/dist/types/AuthenticationResponses.js +3 -13
- package/example.js +1 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,6 +15,16 @@ helper for common bl for my projects.
|
|
|
15
15
|
|
|
16
16
|
## changelog
|
|
17
17
|
|
|
18
|
+
### v4.0.0
|
|
19
|
+
|
|
20
|
+
- AuthenticationCommonBL:
|
|
21
|
+
- change type for GetUserDetailsV0ResponseZ to make it compatible with latest changes.
|
|
22
|
+
|
|
23
|
+
### v3.0.0
|
|
24
|
+
|
|
25
|
+
- AuthenticationCommonBL:
|
|
26
|
+
- remove generateAccessTokenV0, logoutV0.
|
|
27
|
+
|
|
18
28
|
### v2.0.1
|
|
19
29
|
|
|
20
30
|
- use strictObject in zod.
|
package/dist/authentication.d.ts
CHANGED
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
declare class AuthenticationCommonBL {
|
|
2
2
|
private commonBLBaseURL;
|
|
3
3
|
constructor(commonBLBaseURL?: string);
|
|
4
|
-
logoutV0(refreshToken: string): Promise<{
|
|
5
|
-
message: string | null;
|
|
6
|
-
data: null;
|
|
7
|
-
log?: any;
|
|
8
|
-
}>;
|
|
9
|
-
generateAccessTokenV0(refreshToken: string): Promise<{
|
|
10
|
-
message: string | null;
|
|
11
|
-
data: {
|
|
12
|
-
main: {
|
|
13
|
-
access_token: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
log?: any;
|
|
17
|
-
}>;
|
|
18
4
|
deleteUserV0(accessToken: string, password: string): Promise<{
|
|
19
5
|
message: string | null;
|
|
20
6
|
data: null;
|
|
@@ -43,9 +29,9 @@ declare class AuthenticationCommonBL {
|
|
|
43
29
|
credentials: {
|
|
44
30
|
username: string;
|
|
45
31
|
};
|
|
46
|
-
apps:
|
|
32
|
+
apps: string[];
|
|
47
33
|
sessions: {
|
|
48
|
-
|
|
34
|
+
app_name: string;
|
|
49
35
|
active_sessions: number;
|
|
50
36
|
}[];
|
|
51
37
|
};
|
package/dist/authentication.js
CHANGED
|
@@ -1,52 +1,10 @@
|
|
|
1
1
|
import { fetchJSONData } from "squarecommons";
|
|
2
|
-
import { DeleteUserV0Z,
|
|
2
|
+
import { DeleteUserV0Z, GetUserDetailsV0ResponseZ, UpdatePasswordV0ResponseZ, UpdateUsernameV0ResponseZ } from "./types/AuthenticationResponses.js";
|
|
3
3
|
class AuthenticationCommonBL {
|
|
4
4
|
commonBLBaseURL;
|
|
5
5
|
constructor(commonBLBaseURL = "http://localhost:10110") {
|
|
6
6
|
this.commonBLBaseURL = commonBLBaseURL;
|
|
7
7
|
}
|
|
8
|
-
async logoutV0(refreshToken) {
|
|
9
|
-
try {
|
|
10
|
-
const data = await fetchJSONData(
|
|
11
|
-
// base url
|
|
12
|
-
this.commonBLBaseURL,
|
|
13
|
-
// endpoint
|
|
14
|
-
"logout/v0",
|
|
15
|
-
// method
|
|
16
|
-
"DELETE",
|
|
17
|
-
// headers
|
|
18
|
-
{ refresh_token: refreshToken },
|
|
19
|
-
// body
|
|
20
|
-
undefined,
|
|
21
|
-
// query params
|
|
22
|
-
undefined);
|
|
23
|
-
return LogoutV0Z.parse(data);
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
throw error;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
async generateAccessTokenV0(refreshToken) {
|
|
30
|
-
try {
|
|
31
|
-
const data = await fetchJSONData(
|
|
32
|
-
// base url
|
|
33
|
-
this.commonBLBaseURL,
|
|
34
|
-
// endpoint
|
|
35
|
-
"generate_access_token/v0",
|
|
36
|
-
// method
|
|
37
|
-
"GET",
|
|
38
|
-
// headers
|
|
39
|
-
{ refresh_token: refreshToken },
|
|
40
|
-
// body
|
|
41
|
-
undefined,
|
|
42
|
-
// query params
|
|
43
|
-
undefined);
|
|
44
|
-
return GenerateAccessTokenV0ResponseZ.parse(data);
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
8
|
async deleteUserV0(accessToken, password) {
|
|
51
9
|
try {
|
|
52
10
|
const data = await fetchJSONData(
|
|
@@ -1,44 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
declare const GenerateAccessTokenV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
3
|
-
data: z.ZodAny;
|
|
4
|
-
message: z.ZodNullable<z.ZodString>;
|
|
5
|
-
log: z.ZodAny;
|
|
6
|
-
}, {
|
|
7
|
-
data: z.ZodObject<{
|
|
8
|
-
main: z.ZodObject<{
|
|
9
|
-
access_token: z.ZodString;
|
|
10
|
-
}, "strict", z.ZodTypeAny, {
|
|
11
|
-
access_token: string;
|
|
12
|
-
}, {
|
|
13
|
-
access_token: string;
|
|
14
|
-
}>;
|
|
15
|
-
}, "strict", z.ZodTypeAny, {
|
|
16
|
-
main: {
|
|
17
|
-
access_token: string;
|
|
18
|
-
};
|
|
19
|
-
}, {
|
|
20
|
-
main: {
|
|
21
|
-
access_token: string;
|
|
22
|
-
};
|
|
23
|
-
}>;
|
|
24
|
-
}>, "strip", z.ZodTypeAny, {
|
|
25
|
-
message: string | null;
|
|
26
|
-
data: {
|
|
27
|
-
main: {
|
|
28
|
-
access_token: string;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
log?: any;
|
|
32
|
-
}, {
|
|
33
|
-
message: string | null;
|
|
34
|
-
data: {
|
|
35
|
-
main: {
|
|
36
|
-
access_token: string;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
log?: any;
|
|
40
|
-
}>;
|
|
41
|
-
type GenerateAccessTokenV0Response = z.infer<typeof GenerateAccessTokenV0ResponseZ>;
|
|
42
2
|
declare const UpdateUsernameV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
43
3
|
data: z.ZodAny;
|
|
44
4
|
message: z.ZodNullable<z.ZodString>;
|
|
@@ -117,15 +77,15 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
117
77
|
}, {
|
|
118
78
|
username: string;
|
|
119
79
|
}>;
|
|
120
|
-
apps: z.ZodArray<z.
|
|
80
|
+
apps: z.ZodArray<z.ZodString, "many">;
|
|
121
81
|
sessions: z.ZodArray<z.ZodObject<{
|
|
122
|
-
|
|
82
|
+
app_name: z.ZodString;
|
|
123
83
|
active_sessions: z.ZodNumber;
|
|
124
84
|
}, "strict", z.ZodTypeAny, {
|
|
125
|
-
|
|
85
|
+
app_name: string;
|
|
126
86
|
active_sessions: number;
|
|
127
87
|
}, {
|
|
128
|
-
|
|
88
|
+
app_name: string;
|
|
129
89
|
active_sessions: number;
|
|
130
90
|
}>, "many">;
|
|
131
91
|
}, "strict", z.ZodTypeAny, {
|
|
@@ -133,9 +93,9 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
133
93
|
credentials: {
|
|
134
94
|
username: string;
|
|
135
95
|
};
|
|
136
|
-
apps:
|
|
96
|
+
apps: string[];
|
|
137
97
|
sessions: {
|
|
138
|
-
|
|
98
|
+
app_name: string;
|
|
139
99
|
active_sessions: number;
|
|
140
100
|
}[];
|
|
141
101
|
}, {
|
|
@@ -143,9 +103,9 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
143
103
|
credentials: {
|
|
144
104
|
username: string;
|
|
145
105
|
};
|
|
146
|
-
apps:
|
|
106
|
+
apps: string[];
|
|
147
107
|
sessions: {
|
|
148
|
-
|
|
108
|
+
app_name: string;
|
|
149
109
|
active_sessions: number;
|
|
150
110
|
}[];
|
|
151
111
|
}>;
|
|
@@ -155,9 +115,9 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
155
115
|
credentials: {
|
|
156
116
|
username: string;
|
|
157
117
|
};
|
|
158
|
-
apps:
|
|
118
|
+
apps: string[];
|
|
159
119
|
sessions: {
|
|
160
|
-
|
|
120
|
+
app_name: string;
|
|
161
121
|
active_sessions: number;
|
|
162
122
|
}[];
|
|
163
123
|
};
|
|
@@ -167,9 +127,9 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
167
127
|
credentials: {
|
|
168
128
|
username: string;
|
|
169
129
|
};
|
|
170
|
-
apps:
|
|
130
|
+
apps: string[];
|
|
171
131
|
sessions: {
|
|
172
|
-
|
|
132
|
+
app_name: string;
|
|
173
133
|
active_sessions: number;
|
|
174
134
|
}[];
|
|
175
135
|
};
|
|
@@ -182,9 +142,9 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
182
142
|
credentials: {
|
|
183
143
|
username: string;
|
|
184
144
|
};
|
|
185
|
-
apps:
|
|
145
|
+
apps: string[];
|
|
186
146
|
sessions: {
|
|
187
|
-
|
|
147
|
+
app_name: string;
|
|
188
148
|
active_sessions: number;
|
|
189
149
|
}[];
|
|
190
150
|
};
|
|
@@ -198,9 +158,9 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
198
158
|
credentials: {
|
|
199
159
|
username: string;
|
|
200
160
|
};
|
|
201
|
-
apps:
|
|
161
|
+
apps: string[];
|
|
202
162
|
sessions: {
|
|
203
|
-
|
|
163
|
+
app_name: string;
|
|
204
164
|
active_sessions: number;
|
|
205
165
|
}[];
|
|
206
166
|
};
|
|
@@ -208,22 +168,6 @@ declare const GetUserDetailsV0ResponseZ: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
208
168
|
log?: any;
|
|
209
169
|
}>;
|
|
210
170
|
type GetUserDetailsV0Response = z.infer<typeof GetUserDetailsV0ResponseZ>;
|
|
211
|
-
declare const LogoutV0Z: z.ZodObject<z.objectUtil.extendShape<{
|
|
212
|
-
data: z.ZodAny;
|
|
213
|
-
message: z.ZodNullable<z.ZodString>;
|
|
214
|
-
log: z.ZodAny;
|
|
215
|
-
}, {
|
|
216
|
-
data: z.ZodNull;
|
|
217
|
-
}>, "strip", z.ZodTypeAny, {
|
|
218
|
-
message: string | null;
|
|
219
|
-
data: null;
|
|
220
|
-
log?: any;
|
|
221
|
-
}, {
|
|
222
|
-
message: string | null;
|
|
223
|
-
data: null;
|
|
224
|
-
log?: any;
|
|
225
|
-
}>;
|
|
226
|
-
type LogoutV0 = z.infer<typeof LogoutV0Z>;
|
|
227
171
|
declare const DeleteUserV0Z: z.ZodObject<z.objectUtil.extendShape<{
|
|
228
172
|
data: z.ZodAny;
|
|
229
173
|
message: z.ZodNullable<z.ZodString>;
|
|
@@ -240,4 +184,4 @@ declare const DeleteUserV0Z: z.ZodObject<z.objectUtil.extendShape<{
|
|
|
240
184
|
log?: any;
|
|
241
185
|
}>;
|
|
242
186
|
type DeleteUserV0 = z.infer<typeof DeleteUserV0Z>;
|
|
243
|
-
export {
|
|
187
|
+
export { UpdateUsernameV0ResponseZ, UpdateUsernameV0Response, UpdatePasswordV0ResponseZ, UpdatePasswordV0Response, GetUserDetailsV0ResponseZ, GetUserDetailsV0Response, DeleteUserV0, DeleteUserV0Z, };
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { APIOutputZ } from "squarecommons";
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
const GenerateAccessTokenV0ResponseZ = APIOutputZ.extend({
|
|
4
|
-
data: z.strictObject({
|
|
5
|
-
main: z.strictObject({
|
|
6
|
-
access_token: z.string(),
|
|
7
|
-
}),
|
|
8
|
-
}),
|
|
9
|
-
});
|
|
10
3
|
const UpdateUsernameV0ResponseZ = APIOutputZ.extend({
|
|
11
4
|
data: z.strictObject({
|
|
12
5
|
main: z.strictObject({
|
|
@@ -25,18 +18,15 @@ const GetUserDetailsV0ResponseZ = APIOutputZ.extend({
|
|
|
25
18
|
credentials: z.strictObject({
|
|
26
19
|
username: z.string(),
|
|
27
20
|
}),
|
|
28
|
-
apps: z.array(z.
|
|
21
|
+
apps: z.array(z.string()),
|
|
29
22
|
sessions: z.array(z.strictObject({
|
|
30
|
-
|
|
23
|
+
app_name: z.string(),
|
|
31
24
|
active_sessions: z.number(),
|
|
32
25
|
})),
|
|
33
26
|
}),
|
|
34
27
|
}),
|
|
35
28
|
});
|
|
36
|
-
const LogoutV0Z = APIOutputZ.extend({
|
|
37
|
-
data: z.null(),
|
|
38
|
-
});
|
|
39
29
|
const DeleteUserV0Z = APIOutputZ.extend({
|
|
40
30
|
data: z.null(),
|
|
41
31
|
});
|
|
42
|
-
export {
|
|
32
|
+
export { UpdateUsernameV0ResponseZ, UpdatePasswordV0ResponseZ, GetUserDetailsV0ResponseZ, DeleteUserV0Z, };
|
package/example.js
CHANGED
|
@@ -4,9 +4,7 @@ let greetingCommonBL = new GreetingCommonBL();
|
|
|
4
4
|
console.log(await greetingCommonBL.createGreetingV0(true));
|
|
5
5
|
|
|
6
6
|
let authenticationCommonBL = new AuthenticationCommonBL();
|
|
7
|
-
|
|
8
|
-
await authenticationCommonBL.generateAccessTokenV0("dummy_refresh_token")
|
|
9
|
-
);
|
|
7
|
+
|
|
10
8
|
console.log(
|
|
11
9
|
await authenticationCommonBL.updateUsernameV0(
|
|
12
10
|
"dummy_access_token",
|
|
@@ -23,8 +21,6 @@ console.log(
|
|
|
23
21
|
console.log(
|
|
24
22
|
await authenticationCommonBL.getUserDetailsV0("dummy_access_token")
|
|
25
23
|
);
|
|
26
|
-
console.log(await authenticationCommonBL.logoutV0("dummy_refresh_token"));
|
|
27
|
-
|
|
28
24
|
console.log(
|
|
29
25
|
await authenticationCommonBL.deleteUserV0("dummy_access_token", "password")
|
|
30
26
|
);
|