@symbo.ls/sdk 2.31.34 → 2.31.36

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.
Files changed (34) hide show
  1. package/dist/cjs/config/environment.js +13 -17
  2. package/dist/cjs/index.js +6 -6
  3. package/dist/cjs/services/AuthService.js +1 -128
  4. package/dist/cjs/services/BaseService.js +0 -15
  5. package/dist/cjs/services/CollabService.js +6 -5
  6. package/dist/esm/config/environment.js +13 -17
  7. package/dist/esm/index.js +26 -159
  8. package/dist/esm/services/AdminService.js +13 -32
  9. package/dist/esm/services/AuthService.js +14 -148
  10. package/dist/esm/services/BaseService.js +13 -32
  11. package/dist/esm/services/BranchService.js +13 -32
  12. package/dist/esm/services/CollabService.js +19 -37
  13. package/dist/esm/services/CoreService.js +13 -32
  14. package/dist/esm/services/DnsService.js +13 -32
  15. package/dist/esm/services/FileService.js +13 -32
  16. package/dist/esm/services/PaymentService.js +13 -32
  17. package/dist/esm/services/PlanService.js +13 -32
  18. package/dist/esm/services/ProjectService.js +13 -32
  19. package/dist/esm/services/PullRequestService.js +13 -32
  20. package/dist/esm/services/ScreenshotService.js +13 -32
  21. package/dist/esm/services/SubscriptionService.js +13 -32
  22. package/dist/esm/services/index.js +20 -153
  23. package/dist/esm/utils/CollabClient.js +13 -17
  24. package/dist/node/config/environment.js +13 -17
  25. package/dist/node/index.js +6 -6
  26. package/dist/node/services/AuthService.js +1 -118
  27. package/dist/node/services/BaseService.js +0 -15
  28. package/dist/node/services/CollabService.js +6 -5
  29. package/package.json +6 -6
  30. package/src/config/environment.js +13 -18
  31. package/src/index.js +27 -23
  32. package/src/services/AuthService.js +1 -154
  33. package/src/services/BaseService.js +1 -21
  34. package/src/services/CollabService.js +8 -6
@@ -14104,8 +14104,8 @@ var CONFIG = {
14104
14104
  apiUrl: "https://dev.api.symbols.app",
14105
14105
  githubClientId: "Ov23liHxyWFBxS8f1gnF",
14106
14106
  typesenseCollectionName: "docs",
14107
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
14108
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
14107
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
14108
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
14109
14109
  typesensePort: "443",
14110
14110
  typesenseProtocol: "https"
14111
14111
  },
@@ -14117,22 +14117,18 @@ var CONFIG = {
14117
14117
  basedOrg: "symbols",
14118
14118
  githubClientId: "Ov23liHxyWFBxS8f1gnF",
14119
14119
  typesenseCollectionName: "docs",
14120
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
14121
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
14120
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
14121
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
14122
14122
  typesensePort: "443",
14123
14123
  typesenseProtocol: "https"
14124
14124
  },
14125
14125
  upcoming: {
14126
- // socketUrl: 'https://upcoming.api.symbols.app',
14127
- // apiUrl: 'https://upcoming.api.symbols.app',
14128
- // githubClientId: 'Ov23liWF7NvdZ056RV5J'
14129
- // cloning from dev
14130
- socketUrl: "https://dev.api.symbols.app",
14131
- apiUrl: "https://dev.api.symbols.app",
14132
- githubClientId: "Ov23liHxyWFBxS8f1gnF",
14126
+ socketUrl: "https://upcoming.api.symbols.app",
14127
+ apiUrl: "https://upcoming.api.symbols.app",
14128
+ githubClientId: "Ov23liWF7NvdZ056RV5J",
14133
14129
  typesenseCollectionName: "docs",
14134
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
14135
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
14130
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
14131
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
14136
14132
  typesensePort: "443",
14137
14133
  typesenseProtocol: "https"
14138
14134
  },
@@ -14144,8 +14140,8 @@ var CONFIG = {
14144
14140
  basedOrg: "symbols",
14145
14141
  githubClientId: "Ov23ligwZDQVD0VfuWNa",
14146
14142
  typesenseCollectionName: "docs",
14147
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
14148
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
14143
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
14144
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
14149
14145
  typesensePort: "443",
14150
14146
  typesenseProtocol: "https"
14151
14147
  },
@@ -14157,8 +14153,8 @@ var CONFIG = {
14157
14153
  basedOrg: "symbols",
14158
14154
  githubClientId: "Ov23liFAlOEIXtX3dBtR",
14159
14155
  typesenseCollectionName: "docs",
14160
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
14161
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
14156
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
14157
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
14162
14158
  typesensePort: "443",
14163
14159
  typesenseProtocol: "https"
14164
14160
  }
@@ -14643,20 +14639,10 @@ var BaseService = class {
14643
14639
  }
14644
14640
  this._tokenManager = getTokenManager({
14645
14641
  apiUrl: this._apiUrl,
14646
- onTokenRefresh: (tokens) => {
14647
- this.updateContext({ authToken: tokens.accessToken });
14648
- },
14649
- onTokenExpired: () => {
14650
- this.updateContext({ authToken: null });
14651
- },
14652
14642
  onTokenError: (error) => {
14653
14643
  console.error("Token management error:", error);
14654
14644
  }
14655
14645
  });
14656
- const { authToken } = this._context;
14657
- if (authToken && !this._tokenManager.hasTokens()) {
14658
- this._tokenManager.setTokens({ access_token: authToken });
14659
- }
14660
14646
  this._setReady();
14661
14647
  } catch (error) {
14662
14648
  this._setError(error);
@@ -14722,11 +14708,6 @@ var BaseService = class {
14722
14708
  error
14723
14709
  );
14724
14710
  }
14725
- } else if (this._requiresInit(options.methodName)) {
14726
- const { authToken } = this._context;
14727
- if (authToken) {
14728
- defaultHeaders.Authorization = `Bearer ${authToken}`;
14729
- }
14730
14711
  }
14731
14712
  try {
14732
14713
  const response = await fetch(url2, {
@@ -14929,118 +14910,10 @@ var AuthService = class extends BaseService {
14929
14910
  "pro2",
14930
14911
  "enterprise"
14931
14912
  ]);
14932
- this._initialized = false;
14933
- this._apiUrl = null;
14934
- this._tokenManager = null;
14935
14913
  this._projectRoleCache = /* @__PURE__ */ new Map();
14936
14914
  this._roleCacheExpiry = 5 * 60 * 1e3;
14937
14915
  }
14938
- init({ context }) {
14939
- try {
14940
- const { appKey, authToken } = context || this._context;
14941
- this._apiUrl = environment_default.apiUrl;
14942
- if (!this._apiUrl) {
14943
- throw new Error("Auth service base URL not configured");
14944
- }
14945
- this._tokenManager = getTokenManager({
14946
- apiUrl: this._apiUrl,
14947
- onTokenRefresh: (tokens) => {
14948
- this.updateContext({ authToken: tokens.accessToken });
14949
- },
14950
- onTokenExpired: () => {
14951
- this.updateContext({ authToken: null });
14952
- },
14953
- onTokenError: (error) => {
14954
- console.error("Token management error:", error);
14955
- }
14956
- });
14957
- if (authToken && !this._tokenManager.hasTokens()) {
14958
- this._tokenManager.setTokens({ access_token: authToken });
14959
- }
14960
- this._info = {
14961
- config: {
14962
- apiUrl: this._apiUrl,
14963
- appKey: appKey ? `${appKey.substr(0, 4)}...${appKey.substr(-4)}` : null,
14964
- hasToken: Boolean(authToken)
14965
- }
14966
- };
14967
- this._initialized = true;
14968
- this._setReady();
14969
- } catch (error) {
14970
- this._setError(error);
14971
- throw error;
14972
- }
14973
- }
14974
- // Helper method to make HTTP requests
14975
- async _request(endpoint, options = {}) {
14976
- const url2 = `${this._apiUrl}/core${endpoint}`;
14977
- const defaultHeaders = {};
14978
- if (!(options.body instanceof FormData)) {
14979
- defaultHeaders["Content-Type"] = "application/json";
14980
- }
14981
- if (this._requiresInit(options.methodName) && this._tokenManager) {
14982
- try {
14983
- const validToken = await this._tokenManager.ensureValidToken();
14984
- if (validToken) {
14985
- const authHeader = this._tokenManager.getAuthHeader();
14986
- if (authHeader) {
14987
- defaultHeaders.Authorization = authHeader;
14988
- }
14989
- }
14990
- } catch (error) {
14991
- console.warn(
14992
- "Token management failed, proceeding without authentication:",
14993
- error
14994
- );
14995
- }
14996
- } else if (this._requiresInit(options.methodName)) {
14997
- const { authToken } = this._context;
14998
- if (authToken) {
14999
- defaultHeaders.Authorization = `Bearer ${authToken}`;
15000
- }
15001
- }
15002
- try {
15003
- const response = await fetch(url2, {
15004
- ...options,
15005
- headers: {
15006
- ...defaultHeaders,
15007
- ...options.headers
15008
- }
15009
- });
15010
- if (!response.ok) {
15011
- let error = {
15012
- message: `HTTP ${response.status}: ${response.statusText}`
15013
- };
15014
- try {
15015
- error = await response.json();
15016
- } catch {
15017
- }
15018
- throw new Error(error.message || error.error || "Request failed", { cause: error });
15019
- }
15020
- return response.status === 204 ? null : response.json();
15021
- } catch (error) {
15022
- throw new Error(`Request failed: ${error.message}`, { cause: error });
15023
- }
15024
- }
15025
- _requiresInit(methodName) {
15026
- const noInitMethods = /* @__PURE__ */ new Set([
15027
- "register",
15028
- "login",
15029
- "googleAuth",
15030
- "googleAuthCallback",
15031
- "githubAuth",
15032
- "requestPasswordReset",
15033
- "confirmPasswordReset",
15034
- "confirmRegistration",
15035
- "verifyEmail"
15036
- ]);
15037
- return !noInitMethods.has(methodName);
15038
- }
15039
- _requireReady(methodName) {
15040
- if (this._requiresInit(methodName) && !this._initialized) {
15041
- throw new Error("Auth service not initialized");
15042
- }
15043
- }
14916
+ // Use BaseService.init/_request/_requireReady implementations
15044
14917
  // ==================== AUTH METHODS ====================
15045
14918
  async register(userData) {
15046
14919
  try {
@@ -15076,7 +14949,6 @@ var AuthService = class extends BaseService {
15076
14949
  if (this._tokenManager) {
15077
14950
  this._tokenManager.setTokens(tokenData);
15078
14951
  }
15079
- this.updateContext({ authToken: tokens.accessToken });
15080
14952
  }
15081
14953
  if (response.success) {
15082
14954
  return response.data;
@@ -15096,12 +14968,10 @@ var AuthService = class extends BaseService {
15096
14968
  if (this._tokenManager) {
15097
14969
  this._tokenManager.clearTokens();
15098
14970
  }
15099
- this.updateContext({ authToken: null });
15100
14971
  } catch (error) {
15101
14972
  if (this._tokenManager) {
15102
14973
  this._tokenManager.clearTokens();
15103
14974
  }
15104
- this.updateContext({ authToken: null });
15105
14975
  throw new Error(`Logout failed: ${error.message}`, { cause: error });
15106
14976
  }
15107
14977
  }
@@ -15143,7 +15013,6 @@ var AuthService = class extends BaseService {
15143
15013
  if (this._tokenManager) {
15144
15014
  this._tokenManager.setTokens(tokenData);
15145
15015
  }
15146
- this.updateContext({ authToken: tokens.accessToken });
15147
15016
  }
15148
15017
  if (response.success) {
15149
15018
  return response.data;
@@ -15176,7 +15045,6 @@ var AuthService = class extends BaseService {
15176
15045
  if (this._tokenManager) {
15177
15046
  this._tokenManager.setTokens(tokenData);
15178
15047
  }
15179
- this.updateContext({ authToken: tokens.accessToken });
15180
15048
  }
15181
15049
  if (response.success) {
15182
15050
  return response.data;
@@ -15209,7 +15077,6 @@ var AuthService = class extends BaseService {
15209
15077
  if (this._tokenManager) {
15210
15078
  this._tokenManager.setTokens(tokenData);
15211
15079
  }
15212
- this.updateContext({ authToken: tokens.accessToken });
15213
15080
  }
15214
15081
  if (response.success) {
15215
15082
  return response.data;
@@ -15821,7 +15688,6 @@ var AuthService = class extends BaseService {
15821
15688
  this._tokenManager = null;
15822
15689
  }
15823
15690
  this._projectRoleCache.clear();
15824
- this._initialized = false;
15825
15691
  this._setReady(false);
15826
15692
  }
15827
15693
  };
@@ -28493,7 +28359,6 @@ var CollabService = class extends BaseService {
28493
28359
  (_b2 = this._client.socket) == null ? void 0 : _b2.once("connect", resolve);
28494
28360
  }
28495
28361
  });
28496
- console.log("[CollabService] socket connected");
28497
28362
  (_b = this._client.socket) == null ? void 0 : _b.on("ops", ({ changes }) => {
28498
28363
  console.log(`ops event`);
28499
28364
  this._stateManager.applyChanges(changes, { fromSocket: true });
@@ -28523,9 +28388,7 @@ var CollabService = class extends BaseService {
28523
28388
  this._pendingOps.length = 0;
28524
28389
  }
28525
28390
  this._connected = true;
28526
- console.log("[CollabService] Connected to project:", projectId);
28527
28391
  } catch (err) {
28528
- console.error("[CollabService] Connection failed:", err);
28529
28392
  throw err;
28530
28393
  }
28531
28394
  }
@@ -28774,7 +28637,9 @@ var CollabService = class extends BaseService {
28774
28637
  title: "Failed to update item",
28775
28638
  message: error.message
28776
28639
  });
28777
- throw new Error(`Failed to update item: ${error.message}`, { cause: error });
28640
+ throw new Error(`Failed to update item: ${error.message}`, {
28641
+ cause: error
28642
+ });
28778
28643
  }
28779
28644
  }
28780
28645
  deleteItem(type, key, opts = {}) {
@@ -28799,7 +28664,9 @@ var CollabService = class extends BaseService {
28799
28664
  title: "Failed to delete item",
28800
28665
  message: error.message
28801
28666
  });
28802
- throw new Error(`Failed to delete item: ${error.message}`, { cause: error });
28667
+ throw new Error(`Failed to delete item: ${error.message}`, {
28668
+ cause: error
28669
+ });
28803
28670
  }
28804
28671
  }
28805
28672
  /* ---------- socket event helpers ---------- */
@@ -17481,8 +17481,8 @@ var CONFIG = {
17481
17481
  apiUrl: "https://dev.api.symbols.app",
17482
17482
  githubClientId: "Ov23liHxyWFBxS8f1gnF",
17483
17483
  typesenseCollectionName: "docs",
17484
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
17485
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
17484
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
17485
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
17486
17486
  typesensePort: "443",
17487
17487
  typesenseProtocol: "https"
17488
17488
  },
@@ -17494,22 +17494,18 @@ var CONFIG = {
17494
17494
  basedOrg: "symbols",
17495
17495
  githubClientId: "Ov23liHxyWFBxS8f1gnF",
17496
17496
  typesenseCollectionName: "docs",
17497
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
17498
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
17497
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
17498
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
17499
17499
  typesensePort: "443",
17500
17500
  typesenseProtocol: "https"
17501
17501
  },
17502
17502
  upcoming: {
17503
- // socketUrl: 'https://upcoming.api.symbols.app',
17504
- // apiUrl: 'https://upcoming.api.symbols.app',
17505
- // githubClientId: 'Ov23liWF7NvdZ056RV5J'
17506
- // cloning from dev
17507
- socketUrl: "https://dev.api.symbols.app",
17508
- apiUrl: "https://dev.api.symbols.app",
17509
- githubClientId: "Ov23liHxyWFBxS8f1gnF",
17503
+ socketUrl: "https://upcoming.api.symbols.app",
17504
+ apiUrl: "https://upcoming.api.symbols.app",
17505
+ githubClientId: "Ov23liWF7NvdZ056RV5J",
17510
17506
  typesenseCollectionName: "docs",
17511
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
17512
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
17507
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
17508
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
17513
17509
  typesensePort: "443",
17514
17510
  typesenseProtocol: "https"
17515
17511
  },
@@ -17521,8 +17517,8 @@ var CONFIG = {
17521
17517
  basedOrg: "symbols",
17522
17518
  githubClientId: "Ov23ligwZDQVD0VfuWNa",
17523
17519
  typesenseCollectionName: "docs",
17524
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
17525
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
17520
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
17521
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
17526
17522
  typesensePort: "443",
17527
17523
  typesenseProtocol: "https"
17528
17524
  },
@@ -17534,8 +17530,8 @@ var CONFIG = {
17534
17530
  basedOrg: "symbols",
17535
17531
  githubClientId: "Ov23liFAlOEIXtX3dBtR",
17536
17532
  typesenseCollectionName: "docs",
17537
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
17538
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
17533
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
17534
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
17539
17535
  typesensePort: "443",
17540
17536
  typesenseProtocol: "https"
17541
17537
  }
@@ -41,8 +41,8 @@ const CONFIG = {
41
41
  apiUrl: "https://dev.api.symbols.app",
42
42
  githubClientId: "Ov23liHxyWFBxS8f1gnF",
43
43
  typesenseCollectionName: "docs",
44
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
45
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
44
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
45
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
46
46
  typesensePort: "443",
47
47
  typesenseProtocol: "https"
48
48
  },
@@ -54,22 +54,18 @@ const CONFIG = {
54
54
  basedOrg: "symbols",
55
55
  githubClientId: "Ov23liHxyWFBxS8f1gnF",
56
56
  typesenseCollectionName: "docs",
57
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
58
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
57
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
58
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
59
59
  typesensePort: "443",
60
60
  typesenseProtocol: "https"
61
61
  },
62
62
  upcoming: {
63
- // socketUrl: 'https://upcoming.api.symbols.app',
64
- // apiUrl: 'https://upcoming.api.symbols.app',
65
- // githubClientId: 'Ov23liWF7NvdZ056RV5J'
66
- // cloning from dev
67
- socketUrl: "https://dev.api.symbols.app",
68
- apiUrl: "https://dev.api.symbols.app",
69
- githubClientId: "Ov23liHxyWFBxS8f1gnF",
63
+ socketUrl: "https://upcoming.api.symbols.app",
64
+ apiUrl: "https://upcoming.api.symbols.app",
65
+ githubClientId: "Ov23liWF7NvdZ056RV5J",
70
66
  typesenseCollectionName: "docs",
71
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
72
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
67
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
68
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
73
69
  typesensePort: "443",
74
70
  typesenseProtocol: "https"
75
71
  },
@@ -81,8 +77,8 @@ const CONFIG = {
81
77
  basedOrg: "symbols",
82
78
  githubClientId: "Ov23ligwZDQVD0VfuWNa",
83
79
  typesenseCollectionName: "docs",
84
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
85
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
80
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
81
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
86
82
  typesensePort: "443",
87
83
  typesenseProtocol: "https"
88
84
  },
@@ -94,8 +90,8 @@ const CONFIG = {
94
90
  basedOrg: "symbols",
95
91
  githubClientId: "Ov23liFAlOEIXtX3dBtR",
96
92
  typesenseCollectionName: "docs",
97
- typesenseApiKey: "uvxRxi1FHfoxqv29CcyMGVEUtdsow4Ix",
98
- typesenseHost: "wy4zjlqe0h5v2g1np-1.a1.typesense.net",
93
+ typesenseApiKey: "awmcVpbWqZi9IUgmvslp1C5LKDU8tMjA",
94
+ typesenseHost: "tl2qpnwxev4cjm36p-1.a1.typesense.net",
99
95
  typesensePort: "443",
100
96
  typesenseProtocol: "https"
101
97
  }
@@ -159,9 +159,11 @@ class SDK {
159
159
  }
160
160
  // Update context
161
161
  updateContext(newContext) {
162
- if (newContext && typeof newContext === "object") {
163
- Object.assign(this._context, newContext);
164
- }
162
+ const { authToken, ...sanitized } = newContext || {};
163
+ this._context = {
164
+ ...this._context,
165
+ ...sanitized
166
+ };
165
167
  for (const service of this._services.values()) {
166
168
  service.updateContext(this._context);
167
169
  }
@@ -169,9 +171,7 @@ class SDK {
169
171
  // Check if SDK is ready
170
172
  isReady() {
171
173
  const sdkServices = Array.from(this._services.values());
172
- return sdkServices.length > 0 && sdkServices.every(
173
- (service) => service.isReady()
174
- );
174
+ return sdkServices.length > 0 && sdkServices.every((service) => service.isReady());
175
175
  }
176
176
  // Get SDK status
177
177
  getStatus() {
@@ -1,6 +1,4 @@
1
1
  import { BaseService } from "./BaseService.js";
2
- import environment from "../config/environment.js";
3
- import { getTokenManager } from "../utils/TokenManager.js";
4
2
  import {
5
3
  ROLE_PERMISSIONS,
6
4
  TIER_FEATURES,
@@ -17,118 +15,10 @@ class AuthService extends BaseService {
17
15
  "pro2",
18
16
  "enterprise"
19
17
  ]);
20
- this._initialized = false;
21
- this._apiUrl = null;
22
- this._tokenManager = null;
23
18
  this._projectRoleCache = /* @__PURE__ */ new Map();
24
19
  this._roleCacheExpiry = 5 * 60 * 1e3;
25
20
  }
26
- init({ context }) {
27
- try {
28
- const { appKey, authToken } = context || this._context;
29
- this._apiUrl = environment.apiUrl;
30
- if (!this._apiUrl) {
31
- throw new Error("Auth service base URL not configured");
32
- }
33
- this._tokenManager = getTokenManager({
34
- apiUrl: this._apiUrl,
35
- onTokenRefresh: (tokens) => {
36
- this.updateContext({ authToken: tokens.accessToken });
37
- },
38
- onTokenExpired: () => {
39
- this.updateContext({ authToken: null });
40
- },
41
- onTokenError: (error) => {
42
- console.error("Token management error:", error);
43
- }
44
- });
45
- if (authToken && !this._tokenManager.hasTokens()) {
46
- this._tokenManager.setTokens({ access_token: authToken });
47
- }
48
- this._info = {
49
- config: {
50
- apiUrl: this._apiUrl,
51
- appKey: appKey ? `${appKey.substr(0, 4)}...${appKey.substr(-4)}` : null,
52
- hasToken: Boolean(authToken)
53
- }
54
- };
55
- this._initialized = true;
56
- this._setReady();
57
- } catch (error) {
58
- this._setError(error);
59
- throw error;
60
- }
61
- }
62
- // Helper method to make HTTP requests
63
- async _request(endpoint, options = {}) {
64
- const url = `${this._apiUrl}/core${endpoint}`;
65
- const defaultHeaders = {};
66
- if (!(options.body instanceof FormData)) {
67
- defaultHeaders["Content-Type"] = "application/json";
68
- }
69
- if (this._requiresInit(options.methodName) && this._tokenManager) {
70
- try {
71
- const validToken = await this._tokenManager.ensureValidToken();
72
- if (validToken) {
73
- const authHeader = this._tokenManager.getAuthHeader();
74
- if (authHeader) {
75
- defaultHeaders.Authorization = authHeader;
76
- }
77
- }
78
- } catch (error) {
79
- console.warn(
80
- "Token management failed, proceeding without authentication:",
81
- error
82
- );
83
- }
84
- } else if (this._requiresInit(options.methodName)) {
85
- const { authToken } = this._context;
86
- if (authToken) {
87
- defaultHeaders.Authorization = `Bearer ${authToken}`;
88
- }
89
- }
90
- try {
91
- const response = await fetch(url, {
92
- ...options,
93
- headers: {
94
- ...defaultHeaders,
95
- ...options.headers
96
- }
97
- });
98
- if (!response.ok) {
99
- let error = {
100
- message: `HTTP ${response.status}: ${response.statusText}`
101
- };
102
- try {
103
- error = await response.json();
104
- } catch {
105
- }
106
- throw new Error(error.message || error.error || "Request failed", { cause: error });
107
- }
108
- return response.status === 204 ? null : response.json();
109
- } catch (error) {
110
- throw new Error(`Request failed: ${error.message}`, { cause: error });
111
- }
112
- }
113
- _requiresInit(methodName) {
114
- const noInitMethods = /* @__PURE__ */ new Set([
115
- "register",
116
- "login",
117
- "googleAuth",
118
- "googleAuthCallback",
119
- "githubAuth",
120
- "requestPasswordReset",
121
- "confirmPasswordReset",
122
- "confirmRegistration",
123
- "verifyEmail"
124
- ]);
125
- return !noInitMethods.has(methodName);
126
- }
127
- _requireReady(methodName) {
128
- if (this._requiresInit(methodName) && !this._initialized) {
129
- throw new Error("Auth service not initialized");
130
- }
131
- }
21
+ // Use BaseService.init/_request/_requireReady implementations
132
22
  // ==================== AUTH METHODS ====================
133
23
  async register(userData) {
134
24
  try {
@@ -164,7 +54,6 @@ class AuthService extends BaseService {
164
54
  if (this._tokenManager) {
165
55
  this._tokenManager.setTokens(tokenData);
166
56
  }
167
- this.updateContext({ authToken: tokens.accessToken });
168
57
  }
169
58
  if (response.success) {
170
59
  return response.data;
@@ -184,12 +73,10 @@ class AuthService extends BaseService {
184
73
  if (this._tokenManager) {
185
74
  this._tokenManager.clearTokens();
186
75
  }
187
- this.updateContext({ authToken: null });
188
76
  } catch (error) {
189
77
  if (this._tokenManager) {
190
78
  this._tokenManager.clearTokens();
191
79
  }
192
- this.updateContext({ authToken: null });
193
80
  throw new Error(`Logout failed: ${error.message}`, { cause: error });
194
81
  }
195
82
  }
@@ -231,7 +118,6 @@ class AuthService extends BaseService {
231
118
  if (this._tokenManager) {
232
119
  this._tokenManager.setTokens(tokenData);
233
120
  }
234
- this.updateContext({ authToken: tokens.accessToken });
235
121
  }
236
122
  if (response.success) {
237
123
  return response.data;
@@ -264,7 +150,6 @@ class AuthService extends BaseService {
264
150
  if (this._tokenManager) {
265
151
  this._tokenManager.setTokens(tokenData);
266
152
  }
267
- this.updateContext({ authToken: tokens.accessToken });
268
153
  }
269
154
  if (response.success) {
270
155
  return response.data;
@@ -297,7 +182,6 @@ class AuthService extends BaseService {
297
182
  if (this._tokenManager) {
298
183
  this._tokenManager.setTokens(tokenData);
299
184
  }
300
- this.updateContext({ authToken: tokens.accessToken });
301
185
  }
302
186
  if (response.success) {
303
187
  return response.data;
@@ -909,7 +793,6 @@ class AuthService extends BaseService {
909
793
  this._tokenManager = null;
910
794
  }
911
795
  this._projectRoleCache.clear();
912
- this._initialized = false;
913
796
  this._setReady(false);
914
797
  }
915
798
  }
@@ -19,20 +19,10 @@ class BaseService {
19
19
  }
20
20
  this._tokenManager = getTokenManager({
21
21
  apiUrl: this._apiUrl,
22
- onTokenRefresh: (tokens) => {
23
- this.updateContext({ authToken: tokens.accessToken });
24
- },
25
- onTokenExpired: () => {
26
- this.updateContext({ authToken: null });
27
- },
28
22
  onTokenError: (error) => {
29
23
  console.error("Token management error:", error);
30
24
  }
31
25
  });
32
- const { authToken } = this._context;
33
- if (authToken && !this._tokenManager.hasTokens()) {
34
- this._tokenManager.setTokens({ access_token: authToken });
35
- }
36
26
  this._setReady();
37
27
  } catch (error) {
38
28
  this._setError(error);
@@ -98,11 +88,6 @@ class BaseService {
98
88
  error
99
89
  );
100
90
  }
101
- } else if (this._requiresInit(options.methodName)) {
102
- const { authToken } = this._context;
103
- if (authToken) {
104
- defaultHeaders.Authorization = `Bearer ${authToken}`;
105
- }
106
91
  }
107
92
  try {
108
93
  const response = await fetch(url, {