whio-api-sdk 1.0.151 → 1.0.153
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/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/src/sdk/sdk.js +9 -3
- package/index.ts +1 -1
- package/package.json +1 -1
- package/src/sdk/sdk.ts +11 -3
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/src/sdk/sdk.js
CHANGED
|
@@ -38,14 +38,20 @@ export class ApiSDK {
|
|
|
38
38
|
this.user = userString ? JSON.parse(userString) : null;
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
request(endpoint, method = 'GET', body, headers = {}) {
|
|
41
|
+
request(endpoint, method = 'GET', body, headers = {}, noToken = false) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
const url = `${this.baseUrl}${endpoint}`;
|
|
44
44
|
const defaultHeaders = {
|
|
45
45
|
'Content-Type': 'application/json',
|
|
46
46
|
'ngrok-skip-browser-warning': 'true'
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
if (noToken) {
|
|
49
|
+
defaultHeaders['Authorization'] = '';
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// If no token is available, try to get it
|
|
53
|
+
yield this.getToken();
|
|
54
|
+
}
|
|
49
55
|
console.log(this.accessToken);
|
|
50
56
|
if (this.accessToken) {
|
|
51
57
|
defaultHeaders['Authorization'] = `Bearer ${this.accessToken}`;
|
|
@@ -87,7 +93,7 @@ export class ApiSDK {
|
|
|
87
93
|
login(credentials) {
|
|
88
94
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
95
|
try {
|
|
90
|
-
const response = yield this.request('/auth/login', 'POST', credentials);
|
|
96
|
+
const response = yield this.request('/auth/login', 'POST', credentials, {}, true);
|
|
91
97
|
this.accessToken = response.access_token;
|
|
92
98
|
this.refreshToken = response.referesh_token;
|
|
93
99
|
this.user = response.user;
|
package/index.ts
CHANGED
package/package.json
CHANGED
package/src/sdk/sdk.ts
CHANGED
|
@@ -63,7 +63,8 @@ export class ApiSDK {
|
|
|
63
63
|
endpoint: string,
|
|
64
64
|
method: string = 'GET',
|
|
65
65
|
body?: any,
|
|
66
|
-
headers: Record<string, string> = {}
|
|
66
|
+
headers: Record<string, string> = {},
|
|
67
|
+
noToken: boolean = false,
|
|
67
68
|
): Promise<T> {
|
|
68
69
|
const url = `${this.baseUrl}${endpoint}`;
|
|
69
70
|
const defaultHeaders: Record<string, string> = {
|
|
@@ -71,7 +72,12 @@ export class ApiSDK {
|
|
|
71
72
|
'ngrok-skip-browser-warning': 'true'
|
|
72
73
|
};
|
|
73
74
|
|
|
74
|
-
|
|
75
|
+
if (noToken) {
|
|
76
|
+
defaultHeaders['Authorization'] = '';
|
|
77
|
+
} else {
|
|
78
|
+
// If no token is available, try to get it
|
|
79
|
+
await this.getToken();
|
|
80
|
+
}
|
|
75
81
|
|
|
76
82
|
console.log(this.accessToken);
|
|
77
83
|
|
|
@@ -131,7 +137,9 @@ export class ApiSDK {
|
|
|
131
137
|
const response = await this.request<LoginResponse>(
|
|
132
138
|
'/auth/login',
|
|
133
139
|
'POST',
|
|
134
|
-
credentials
|
|
140
|
+
credentials,
|
|
141
|
+
{},
|
|
142
|
+
true
|
|
135
143
|
);
|
|
136
144
|
this.accessToken = response.access_token;
|
|
137
145
|
this.refreshToken = response.referesh_token;
|