squarecommonblhelper 1.0.2 → 1.1.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 +14 -0
- package/dist/authentication.d.ts +11 -0
- package/dist/authentication.js +134 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/example.js +14 -0
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -15,6 +15,20 @@ helper for common bl for my projects.
|
|
|
15
15
|
|
|
16
16
|
## changelog
|
|
17
17
|
|
|
18
|
+
### v1.1.0
|
|
19
|
+
|
|
20
|
+
- add AuthenticationCommonBL class with the following methods:
|
|
21
|
+
- logoutV0
|
|
22
|
+
- generateAccessTokenV0
|
|
23
|
+
- deleteUserV0
|
|
24
|
+
- updateUsernameV0
|
|
25
|
+
- updatePasswordV0
|
|
26
|
+
- getUserDetailsV0
|
|
27
|
+
|
|
28
|
+
### v1.0.3
|
|
29
|
+
|
|
30
|
+
- experimental release.
|
|
31
|
+
|
|
18
32
|
### v1.0.2
|
|
19
33
|
|
|
20
34
|
- replace user_id with accessToken from greeting -> createGreetingV0.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare class AuthenticationCommonBL {
|
|
2
|
+
private commonBLBaseURL;
|
|
3
|
+
constructor(commonBLBaseURL?: string);
|
|
4
|
+
logoutV0(refreshToken: string): Promise<import("squarecommons").APIOutput>;
|
|
5
|
+
generateAccessTokenV0(refreshToken: string): Promise<import("squarecommons").APIOutput>;
|
|
6
|
+
deleteUserV0(accessToken: string, password: string): Promise<import("squarecommons").APIOutput>;
|
|
7
|
+
updateUsernameV0(accessToken: string, newUsername: string): Promise<import("squarecommons").APIOutput>;
|
|
8
|
+
updatePasswordV0(accessToken: string, oldPassword: string, newPassword: string): Promise<import("squarecommons").APIOutput>;
|
|
9
|
+
getUserDetailsV0(accessToken: string): Promise<import("squarecommons").APIOutput>;
|
|
10
|
+
}
|
|
11
|
+
export { AuthenticationCommonBL };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { fetchJSONData } from "squarecommons";
|
|
2
|
+
class AuthenticationCommonBL {
|
|
3
|
+
commonBLBaseURL;
|
|
4
|
+
constructor(commonBLBaseURL = "http://localhost:10110") {
|
|
5
|
+
this.commonBLBaseURL = commonBLBaseURL;
|
|
6
|
+
}
|
|
7
|
+
async logoutV0(refreshToken) {
|
|
8
|
+
try {
|
|
9
|
+
const data = await fetchJSONData(
|
|
10
|
+
// base url
|
|
11
|
+
this.commonBLBaseURL,
|
|
12
|
+
// endpoint
|
|
13
|
+
"logout/v0",
|
|
14
|
+
// method
|
|
15
|
+
"DELETE",
|
|
16
|
+
// headers
|
|
17
|
+
{ refresh_token: refreshToken },
|
|
18
|
+
// body
|
|
19
|
+
undefined,
|
|
20
|
+
// query params
|
|
21
|
+
undefined);
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async generateAccessTokenV0(refreshToken) {
|
|
29
|
+
try {
|
|
30
|
+
const data = await fetchJSONData(
|
|
31
|
+
// base url
|
|
32
|
+
this.commonBLBaseURL,
|
|
33
|
+
// endpoint
|
|
34
|
+
"generate_access_token/v0",
|
|
35
|
+
// method
|
|
36
|
+
"GET",
|
|
37
|
+
// headers
|
|
38
|
+
{ refresh_token: refreshToken },
|
|
39
|
+
// body
|
|
40
|
+
undefined,
|
|
41
|
+
// query params
|
|
42
|
+
undefined);
|
|
43
|
+
return data;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async deleteUserV0(accessToken, password) {
|
|
50
|
+
try {
|
|
51
|
+
const data = await fetchJSONData(
|
|
52
|
+
// base url
|
|
53
|
+
this.commonBLBaseURL,
|
|
54
|
+
// endpoint
|
|
55
|
+
"delete_user/v0",
|
|
56
|
+
// method
|
|
57
|
+
"DELETE",
|
|
58
|
+
// headers
|
|
59
|
+
{ access_token: accessToken },
|
|
60
|
+
// body
|
|
61
|
+
{ password: password },
|
|
62
|
+
// query params
|
|
63
|
+
undefined);
|
|
64
|
+
return data;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async updateUsernameV0(accessToken, newUsername) {
|
|
71
|
+
try {
|
|
72
|
+
const data = await fetchJSONData(
|
|
73
|
+
// base url
|
|
74
|
+
this.commonBLBaseURL,
|
|
75
|
+
// endpoint
|
|
76
|
+
"update_username/v0",
|
|
77
|
+
// method
|
|
78
|
+
"PATCH",
|
|
79
|
+
// headers
|
|
80
|
+
{ access_token: accessToken },
|
|
81
|
+
// body
|
|
82
|
+
{ new_username: newUsername },
|
|
83
|
+
// query params
|
|
84
|
+
undefined);
|
|
85
|
+
return data;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async updatePasswordV0(accessToken, oldPassword, newPassword) {
|
|
92
|
+
try {
|
|
93
|
+
const data = await fetchJSONData(
|
|
94
|
+
// base url
|
|
95
|
+
this.commonBLBaseURL,
|
|
96
|
+
// endpoint
|
|
97
|
+
"update_password/v0",
|
|
98
|
+
// method
|
|
99
|
+
"PATCH",
|
|
100
|
+
// headers
|
|
101
|
+
{ access_token: accessToken },
|
|
102
|
+
// body
|
|
103
|
+
{ old_password: oldPassword, new_password: newPassword },
|
|
104
|
+
// query params
|
|
105
|
+
undefined);
|
|
106
|
+
return data;
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
throw error;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async getUserDetailsV0(accessToken) {
|
|
113
|
+
try {
|
|
114
|
+
const data = await fetchJSONData(
|
|
115
|
+
// base url
|
|
116
|
+
this.commonBLBaseURL,
|
|
117
|
+
// endpoint
|
|
118
|
+
"get_user_details/v0",
|
|
119
|
+
// method
|
|
120
|
+
"GET",
|
|
121
|
+
// headers
|
|
122
|
+
{ access_token: accessToken },
|
|
123
|
+
// body
|
|
124
|
+
undefined,
|
|
125
|
+
// query params
|
|
126
|
+
undefined);
|
|
127
|
+
return data;
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
export { AuthenticationCommonBL };
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/example.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GreetingCommonBL,
|
|
3
|
+
UtilsCommonBL,
|
|
4
|
+
AuthenticationCommonBL,
|
|
5
|
+
} from "./dist/index.js";
|
|
6
|
+
|
|
7
|
+
let greetingCommonBL = new GreetingCommonBL();
|
|
8
|
+
console.log(await greetingCommonBL.createGreetingV0(true));
|
|
9
|
+
|
|
10
|
+
let utilsCommonBL = new UtilsCommonBL();
|
|
11
|
+
console.log(await utilsCommonBL.getAppIdV0("test"));
|
|
12
|
+
|
|
13
|
+
let authenticationCommonBL = new AuthenticationCommonBL();
|
|
14
|
+
console.log(await authenticationCommonBL.generateAccessTokenV0(""));
|
package/package.json
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "squarecommonblhelper",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "helper for common bl for my projects.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"test": "",
|
|
10
|
-
"
|
|
10
|
+
"prepare": "npm run build",
|
|
11
|
+
"build": "rimraf /dist && tsc",
|
|
11
12
|
"dev": "tsc && node dist/index.js"
|
|
12
13
|
},
|
|
13
14
|
"files": [
|
|
14
15
|
"dist",
|
|
15
|
-
"README.md"
|
|
16
|
+
"README.md",
|
|
17
|
+
"example.js"
|
|
16
18
|
],
|
|
17
19
|
"repository": {
|
|
18
20
|
"type": "git",
|
|
@@ -25,12 +27,13 @@
|
|
|
25
27
|
},
|
|
26
28
|
"homepage": "https://github.com/thepmsquare/squareCommonBLHelper#readme",
|
|
27
29
|
"devDependencies": {
|
|
30
|
+
"rimraf": "^6.0.1",
|
|
28
31
|
"typescript": "^5.3.3"
|
|
29
32
|
},
|
|
30
33
|
"engines": {
|
|
31
34
|
"node": ">=18.0.0"
|
|
32
35
|
},
|
|
33
36
|
"dependencies": {
|
|
34
|
-
"squarecommons": "^1.0.
|
|
37
|
+
"squarecommons": "^1.0.13"
|
|
35
38
|
}
|
|
36
39
|
}
|