caprover-api 0.0.4 → 0.0.5

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.
@@ -31,8 +31,9 @@ export type AuthenticationContent = {
31
31
  export type AuthRequiredCallback = () => Promise<AuthenticationContent>;
32
32
  export default class ApiManager {
33
33
  private authCallback;
34
+ private authToken?;
34
35
  private http;
35
- constructor(baseDomain: string, authCallback: AuthRequiredCallback);
36
+ constructor(baseDomain: string, authCallback: AuthRequiredCallback, authToken?: string | undefined);
36
37
  destroy(): void;
37
38
  getAuthToken(): Promise<string>;
38
39
  getAllThemes(): Promise<{
@@ -5,13 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const HttpClient_1 = __importDefault(require("./HttpClient"));
7
7
  class ApiManager {
8
- constructor(baseDomain, authCallback) {
8
+ constructor(baseDomain, authCallback, authToken) {
9
9
  this.authCallback = authCallback;
10
+ this.authToken = authToken;
10
11
  const self = this;
11
12
  const URL = baseDomain + '/api/v2';
12
13
  this.http = new HttpClient_1.default(URL, function () {
13
14
  return self.getAuthToken();
14
- });
15
+ }, authToken);
15
16
  }
16
17
  destroy() {
17
18
  this.http.destroy();
@@ -1,11 +1,11 @@
1
1
  export default class HttpClient {
2
2
  private baseUrl;
3
3
  private onAuthFailure;
4
+ private authToken?;
4
5
  readonly GET = "GET";
5
6
  readonly POST = "POST";
6
7
  isDestroyed: boolean;
7
- private authToken;
8
- constructor(baseUrl: string, onAuthFailure: () => Promise<string>);
8
+ constructor(baseUrl: string, onAuthFailure: () => Promise<string>, authToken?: string | undefined);
9
9
  createHeaders(): any;
10
10
  setAuthToken(authToken: string): void;
11
11
  destroy(): void;
@@ -9,14 +9,16 @@ let TOKEN_HEADER = 'x-captain-auth';
9
9
  let NAMESPACE = 'x-namespace';
10
10
  let CAPTAIN = 'captain';
11
11
  class HttpClient {
12
- constructor(baseUrl, onAuthFailure) {
12
+ constructor(baseUrl, onAuthFailure, authToken) {
13
13
  this.baseUrl = baseUrl;
14
14
  this.onAuthFailure = onAuthFailure;
15
+ this.authToken = authToken;
15
16
  this.GET = 'GET';
16
17
  this.POST = 'POST';
17
18
  this.isDestroyed = false;
18
- this.authToken = '';
19
- //
19
+ if (!authToken) {
20
+ this.authToken = '';
21
+ }
20
22
  }
21
23
  createHeaders() {
22
24
  let headers = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caprover-api",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "API client for CapRover",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",