@flashbacktech/flashbackclient 0.0.29 → 0.0.30

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.
@@ -1,6 +1,7 @@
1
1
  import { CreateUnitRequest, CreateUnitResponse } from './types';
2
2
  export declare class ApiClient {
3
- private apiClient;
3
+ private baseURL;
4
+ private headers;
4
5
  constructor(baseURL?: string);
5
6
  setAuthToken: (token: string | null) => void;
6
7
  authenticateGoogle: (token: string) => Promise<any>;
@@ -1,38 +1,55 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.ApiClient = void 0;
7
- const axios_1 = __importDefault(require("axios"));
8
4
  class ApiClient {
9
5
  constructor(baseURL = 'https://api.flashback.tech') {
10
6
  this.setAuthToken = (token) => {
11
7
  if (token) {
12
- this.apiClient.defaults.headers.common['Authorization'] = `Bearer ${token}`;
8
+ this.headers = {
9
+ ...this.headers,
10
+ Authorization: `Bearer ${token}`,
11
+ };
13
12
  }
14
13
  else {
15
- delete this.apiClient.defaults.headers.common['Authorization'];
14
+ this.headers = {
15
+ 'Content-Type': 'application/json',
16
+ };
16
17
  }
17
18
  };
18
19
  this.authenticateGoogle = async (token) => {
19
- const response = await this.apiClient.post('/auth/google', { token });
20
- return response.data;
20
+ const response = await fetch(`${this.baseURL}/auth/google`, {
21
+ method: 'POST',
22
+ headers: this.headers,
23
+ body: JSON.stringify({ token }),
24
+ });
25
+ if (!response.ok)
26
+ throw new Error(`HTTP error! status: ${response.status}`);
27
+ return response.json();
21
28
  };
22
29
  this.authenticateGithub = async (code) => {
23
- const response = await this.apiClient.post('/auth/github', { code });
24
- return response.data;
30
+ const response = await fetch(`${this.baseURL}/auth/github`, {
31
+ method: 'POST',
32
+ headers: this.headers,
33
+ body: JSON.stringify({ code }),
34
+ });
35
+ if (!response.ok)
36
+ throw new Error(`HTTP error! status: ${response.status}`);
37
+ return response.json();
25
38
  };
26
39
  this.createStorageUnit = async (data) => {
27
- const response = await this.apiClient.post('/unit', data);
28
- return response.data;
40
+ const response = await fetch(`${this.baseURL}/unit`, {
41
+ method: 'POST',
42
+ headers: this.headers,
43
+ body: JSON.stringify(data),
44
+ });
45
+ if (!response.ok)
46
+ throw new Error(`HTTP error! status: ${response.status}`);
47
+ return response.json();
48
+ };
49
+ this.baseURL = baseURL;
50
+ this.headers = {
51
+ 'Content-Type': 'application/json',
29
52
  };
30
- this.apiClient = axios_1.default.create({
31
- baseURL: baseURL,
32
- headers: {
33
- 'Content-Type': 'application/json',
34
- },
35
- });
36
53
  }
37
54
  }
38
55
  exports.ApiClient = ApiClient;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flashbacktech/flashbackclient",
3
- "version": "0.0.29",
3
+ "version": "0.0.30",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -24,7 +24,6 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@stellar/stellar-sdk": "^13.0.0",
27
- "axios": "^1.7.9",
28
27
  "formdata-node": "^6.0.3"
29
28
  },
30
29
  "bin": {
@@ -51,6 +50,7 @@
51
50
  "@google-cloud/storage": "^7.15.0",
52
51
  "@types/jest": "^29.5.14",
53
52
  "@types/node": "^22.10.1",
53
+ "@types/node-fetch": "^2.6.12",
54
54
  "@typescript-eslint/eslint-plugin": "^8.17.0",
55
55
  "@typescript-eslint/parser": "^8.17.0",
56
56
  "dotenv": "^16.4.7",