@flashbacktech/flashbackclient 0.0.51 → 0.0.53

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,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>;
@@ -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 = {
@@ -78,14 +81,20 @@ class ApiClient {
78
81
  this.authenticateWeb3Stellar = async (token) => {
79
82
  throw new Error('Not implemented');
80
83
  };
81
- this.makeRequest = async (method, path, data) => {
84
+ this.makeRequest = async (path, method, data) => {
82
85
  const options = {
83
86
  method,
84
87
  headers: this.headers,
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flashbacktech/flashbackclient",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },