caprover-api 0.0.3 → 0.0.4
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 +2 -0
- package/package.json +1 -1
- package/src/api/ApiManager.ts +9 -4
- package/src/api/HttpClient.ts +5 -3
package/README.md
CHANGED
package/package.json
CHANGED
package/src/api/ApiManager.ts
CHANGED
|
@@ -43,13 +43,18 @@ export default class ApiManager {
|
|
|
43
43
|
|
|
44
44
|
constructor(
|
|
45
45
|
baseDomain: string,
|
|
46
|
-
private authCallback: AuthRequiredCallback
|
|
46
|
+
private authCallback: AuthRequiredCallback,
|
|
47
|
+
private authToken?: string
|
|
47
48
|
) {
|
|
48
49
|
const self = this
|
|
49
50
|
const URL = baseDomain + '/api/v2'
|
|
50
|
-
this.http = new HttpClient(
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
this.http = new HttpClient(
|
|
52
|
+
URL,
|
|
53
|
+
function () {
|
|
54
|
+
return self.getAuthToken()
|
|
55
|
+
},
|
|
56
|
+
authToken
|
|
57
|
+
)
|
|
53
58
|
}
|
|
54
59
|
|
|
55
60
|
destroy() {
|
package/src/api/HttpClient.ts
CHANGED
|
@@ -9,13 +9,15 @@ export default class HttpClient {
|
|
|
9
9
|
public readonly GET = 'GET'
|
|
10
10
|
public readonly POST = 'POST'
|
|
11
11
|
public isDestroyed = false
|
|
12
|
-
private authToken: string = ''
|
|
13
12
|
|
|
14
13
|
constructor(
|
|
15
14
|
private baseUrl: string,
|
|
16
|
-
private onAuthFailure: () => Promise<string
|
|
15
|
+
private onAuthFailure: () => Promise<string>,
|
|
16
|
+
private authToken?: string
|
|
17
17
|
) {
|
|
18
|
-
|
|
18
|
+
if (!authToken) {
|
|
19
|
+
this.authToken = ''
|
|
20
|
+
}
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
createHeaders() {
|