@flashbacktech/flashbackclient 0.0.51 → 0.0.52
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/api/client.d.ts +2 -0
- package/dist/api/client.js +10 -0
- package/package.json +1 -1
package/dist/api/client.d.ts
CHANGED
|
@@ -14,7 +14,9 @@ export declare class HttpError extends Error {
|
|
|
14
14
|
export declare class ApiClient implements IApiClient {
|
|
15
15
|
private baseURL;
|
|
16
16
|
private headers;
|
|
17
|
+
private debug;
|
|
17
18
|
constructor(baseURL?: string);
|
|
19
|
+
setDebug: (debug: boolean) => void;
|
|
18
20
|
setAuthToken: (token: string | null) => void;
|
|
19
21
|
authenticate: (token: string, provider: ProviderType) => Promise<any>;
|
|
20
22
|
exchangeCode: (code: string, provider: ProviderType) => Promise<OAuth2ResponseDTO>;
|
package/dist/api/client.js
CHANGED
|
@@ -14,6 +14,9 @@ class HttpError extends Error {
|
|
|
14
14
|
exports.HttpError = HttpError;
|
|
15
15
|
class ApiClient {
|
|
16
16
|
constructor(baseURL = 'https://api.flashback.tech') {
|
|
17
|
+
this.setDebug = (debug) => {
|
|
18
|
+
this.debug = debug;
|
|
19
|
+
};
|
|
17
20
|
this.setAuthToken = (token) => {
|
|
18
21
|
if (token) {
|
|
19
22
|
this.headers = {
|
|
@@ -85,7 +88,13 @@ class ApiClient {
|
|
|
85
88
|
body: data ? JSON.stringify(data) : null,
|
|
86
89
|
};
|
|
87
90
|
const cleanPath = path.startsWith('/') ? path.substring(1) : path;
|
|
91
|
+
if (this.debug) {
|
|
92
|
+
console.log(`DEBUG: ${method} ${cleanPath} ${JSON.stringify(data)}`);
|
|
93
|
+
}
|
|
88
94
|
const response = await fetch(`${this.baseURL}/${cleanPath}`, options);
|
|
95
|
+
if (this.debug) {
|
|
96
|
+
console.log(`DEBUG: ${response.status} ${response.statusText}`);
|
|
97
|
+
}
|
|
89
98
|
// If response is not ok, handle it before trying to parse JSON
|
|
90
99
|
if (!response.ok) {
|
|
91
100
|
let errorData = null;
|
|
@@ -170,6 +179,7 @@ class ApiClient {
|
|
|
170
179
|
this.headers = {
|
|
171
180
|
'Content-Type': 'application/json',
|
|
172
181
|
};
|
|
182
|
+
this.debug = false;
|
|
173
183
|
}
|
|
174
184
|
}
|
|
175
185
|
exports.ApiClient = ApiClient;
|