curtain-web-api 1.0.1 → 1.0.3
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.
|
@@ -14,7 +14,7 @@ export declare class CurtainWebAPI {
|
|
|
14
14
|
constructor(baseURL?: string);
|
|
15
15
|
login(username: string, password: string): Promise<User>;
|
|
16
16
|
getUserInfo(): Promise<User>;
|
|
17
|
-
logout(): Promise<
|
|
17
|
+
logout(): Promise<void>;
|
|
18
18
|
refresh(): Promise<import("axios").AxiosResponse<any, any>>;
|
|
19
19
|
ORCIDLogin(authorizationCode: string, redirectURI: string): Promise<User>;
|
|
20
20
|
checkIfRefreshTokenExpired(): boolean;
|
|
@@ -67,7 +67,12 @@ class CurtainWebAPI {
|
|
|
67
67
|
this.userInfoURL = baseURL + "user/";
|
|
68
68
|
this.axiosInstance.interceptors.request.use((config) => {
|
|
69
69
|
if (config.url) {
|
|
70
|
-
if (
|
|
70
|
+
if (
|
|
71
|
+
//config.url === this.refereshURL ||
|
|
72
|
+
config.url === this.logoutURL ||
|
|
73
|
+
config.url === this.userInfoURL ||
|
|
74
|
+
config.url.startsWith(this.baseURL + "curtain/") ||
|
|
75
|
+
config.url.startsWith(this.baseURL + "data_filter_list/")) {
|
|
71
76
|
if (this.user.loginStatus) {
|
|
72
77
|
config.headers["Authorization"] = "Bearer " + this.user.access_token;
|
|
73
78
|
}
|
|
@@ -87,6 +92,7 @@ class CurtainWebAPI {
|
|
|
87
92
|
if (!this.checkIfRefreshTokenExpired() && this.user.loginStatus) {
|
|
88
93
|
if (!this.isRefreshing) {
|
|
89
94
|
return this.refresh().then((response) => {
|
|
95
|
+
this.isRefreshing = false;
|
|
90
96
|
return this.axiosInstance.request(error.config);
|
|
91
97
|
}).catch((error) => {
|
|
92
98
|
this.isRefreshing = false;
|
|
@@ -134,8 +140,7 @@ class CurtainWebAPI {
|
|
|
134
140
|
headers["Accept"] = "application/json";
|
|
135
141
|
headers["Content-Type"] = "application/json";
|
|
136
142
|
return this.axiosInstance.post(this.logoutURL, { refresh_token: this.user.refresh_token }, { headers: headers, responseType: "json" }).then((response) => {
|
|
137
|
-
this.user.clearDB();
|
|
138
|
-
return response;
|
|
143
|
+
return this.user.clearDB();
|
|
139
144
|
});
|
|
140
145
|
}
|
|
141
146
|
refresh() {
|
|
@@ -190,7 +195,7 @@ class CurtainWebAPI {
|
|
|
190
195
|
let headers = new axios_1.AxiosHeaders();
|
|
191
196
|
headers["Accept"] = "application/json";
|
|
192
197
|
headers["Content-Type"] = "multipart/form-data";
|
|
193
|
-
return this.axiosInstance.put(this.baseURL + "curtain/"
|
|
198
|
+
return this.axiosInstance.put(this.baseURL + "curtain/", form, { headers: headers, responseType: "json" }).then((response) => {
|
|
194
199
|
return response;
|
|
195
200
|
});
|
|
196
201
|
}
|
package/curtainuser/000003.log
CHANGED
|
Binary file
|
package/curtainuser/LOG
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2023/04/15-17:
|
|
1
|
+
2023/04/15-17:56:07.976 99c Delete type=3 #1
|
package/package.json
CHANGED
|
@@ -43,7 +43,12 @@ export class CurtainWebAPI {
|
|
|
43
43
|
this.userInfoURL = baseURL + "user/";
|
|
44
44
|
this.axiosInstance.interceptors.request.use((config) => {
|
|
45
45
|
if (config.url) {
|
|
46
|
-
if (
|
|
46
|
+
if (
|
|
47
|
+
//config.url === this.refereshURL ||
|
|
48
|
+
config.url === this.logoutURL ||
|
|
49
|
+
config.url === this.userInfoURL ||
|
|
50
|
+
config.url.startsWith(this.baseURL + "curtain/") ||
|
|
51
|
+
config.url.startsWith(this.baseURL + "data_filter_list/")) {
|
|
47
52
|
if (this.user.loginStatus) {
|
|
48
53
|
config.headers["Authorization"] = "Bearer " + this.user.access_token;
|
|
49
54
|
}
|
|
@@ -64,6 +69,7 @@ export class CurtainWebAPI {
|
|
|
64
69
|
if (!this.checkIfRefreshTokenExpired() && this.user.loginStatus) {
|
|
65
70
|
if (!this.isRefreshing) {
|
|
66
71
|
return this.refresh().then((response) => {
|
|
72
|
+
this.isRefreshing = false;
|
|
67
73
|
return this.axiosInstance.request(error.config);
|
|
68
74
|
}).catch((error) => {
|
|
69
75
|
this.isRefreshing = false;
|
|
@@ -116,8 +122,7 @@ export class CurtainWebAPI {
|
|
|
116
122
|
headers["Accept"] = "application/json";
|
|
117
123
|
headers["Content-Type"] = "application/json";
|
|
118
124
|
return this.axiosInstance.post(this.logoutURL, {refresh_token: this.user.refresh_token}, {headers: headers, responseType:"json"}).then((response) => {
|
|
119
|
-
this.user.clearDB();
|
|
120
|
-
return response;
|
|
125
|
+
return this.user.clearDB();
|
|
121
126
|
});
|
|
122
127
|
}
|
|
123
128
|
|
|
@@ -177,7 +182,7 @@ export class CurtainWebAPI {
|
|
|
177
182
|
let headers = new AxiosHeaders();
|
|
178
183
|
headers["Accept"] = "application/json";
|
|
179
184
|
headers["Content-Type"] = "multipart/form-data";
|
|
180
|
-
return this.axiosInstance.put(this.baseURL + "curtain/"
|
|
185
|
+
return this.axiosInstance.put(this.baseURL + "curtain/", form, {headers: headers, responseType:"json"}).then((response) => {
|
|
181
186
|
return response;
|
|
182
187
|
});
|
|
183
188
|
}
|
|
@@ -98,7 +98,14 @@ describe("Session data", () => {
|
|
|
98
98
|
const curtainLogin = new CurtainWebAPI();
|
|
99
99
|
const result = await curtainLogin.postSettings("546c9ed7-30a6-4a0f-aedb-880815eb7051", "")
|
|
100
100
|
})
|
|
101
|
-
|
|
101
|
+
it('should login and then retrieve session data', async () => {
|
|
102
|
+
const curtainLogin = new CurtainWebAPI();
|
|
103
|
+
await curtainLogin.login("testroot", "testpassword")
|
|
104
|
+
const previousAccess = curtainLogin.user.access_token.slice()
|
|
105
|
+
await curtainLogin.refresh()
|
|
106
|
+
expect(previousAccess).to.not.equal(curtainLogin.user.access_token)
|
|
107
|
+
const result = await curtainLogin.postSettings("546c9ed7-30a6-4a0f-aedb-880815eb7051", "")
|
|
108
|
+
})
|
|
102
109
|
});
|
|
103
110
|
|
|
104
111
|
|