@giaeulate/baas-sdk 1.0.6 → 1.0.7

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.cjs CHANGED
@@ -910,12 +910,12 @@ var RealtimeService = class {
910
910
  if (this.socket?.readyState === WebSocket.OPEN) return Promise.resolve();
911
911
  return new Promise((resolve, reject) => {
912
912
  const token = this.tokenProvider();
913
- if (!this.apiKey || !token) {
914
- reject(new Error("Missing API key or authentication token for Realtime connection"));
913
+ if (!token) {
914
+ reject(new Error("Missing authentication token for Realtime connection"));
915
915
  return;
916
916
  }
917
917
  const wsUrl = this.url.replace(/^http/, "ws") + "/ws";
918
- const fullUrl = `${wsUrl}?apikey=${this.apiKey}&token=${token}`;
918
+ const fullUrl = this.apiKey ? `${wsUrl}?apikey=${this.apiKey}&token=${token}` : `${wsUrl}?token=${token}`;
919
919
  if (!this.wsConstructor) {
920
920
  reject(new Error("WebSocket constructor not provided or available in this environment"));
921
921
  return;
@@ -1049,6 +1049,12 @@ function createApiKeysModule(client) {
1049
1049
  },
1050
1050
  async delete(keyId) {
1051
1051
  return del(`/api/api-keys/${keyId}`);
1052
+ },
1053
+ async getInstanceToken() {
1054
+ return get("/api/api-keys/instance");
1055
+ },
1056
+ async regenerateInstanceToken() {
1057
+ return post("/api/api-keys/instance/regenerate", {});
1052
1058
  }
1053
1059
  };
1054
1060
  }
@@ -1278,6 +1284,12 @@ var BaasClient = class extends HttpClient {
1278
1284
  async deleteApiKey(keyId) {
1279
1285
  return this.apiKeys.delete(keyId);
1280
1286
  }
1287
+ async getInstanceToken() {
1288
+ return this.apiKeys.getInstanceToken();
1289
+ }
1290
+ async regenerateInstanceToken() {
1291
+ return this.apiKeys.regenerateInstanceToken();
1292
+ }
1281
1293
  // Backups shortcuts
1282
1294
  async createBackup(options) {
1283
1295
  return this.backups.create(options);
package/dist/index.d.cts CHANGED
@@ -589,6 +589,8 @@ interface ApiKeysModule {
589
589
  list(): Promise<any>;
590
590
  revoke(keyId: string): Promise<any>;
591
591
  delete(keyId: string): Promise<any>;
592
+ getInstanceToken(): Promise<any>;
593
+ regenerateInstanceToken(): Promise<any>;
592
594
  }
593
595
 
594
596
  /**
@@ -684,6 +686,8 @@ declare class BaasClient extends HttpClient {
684
686
  listApiKeys(): Promise<any>;
685
687
  revokeApiKey(keyId: string): Promise<any>;
686
688
  deleteApiKey(keyId: string): Promise<any>;
689
+ getInstanceToken(): Promise<any>;
690
+ regenerateInstanceToken(): Promise<any>;
687
691
  createBackup(options?: any): Promise<any>;
688
692
  listBackups(): Promise<any>;
689
693
  getBackup(backupId: string): Promise<any>;
package/dist/index.d.ts CHANGED
@@ -589,6 +589,8 @@ interface ApiKeysModule {
589
589
  list(): Promise<any>;
590
590
  revoke(keyId: string): Promise<any>;
591
591
  delete(keyId: string): Promise<any>;
592
+ getInstanceToken(): Promise<any>;
593
+ regenerateInstanceToken(): Promise<any>;
592
594
  }
593
595
 
594
596
  /**
@@ -684,6 +686,8 @@ declare class BaasClient extends HttpClient {
684
686
  listApiKeys(): Promise<any>;
685
687
  revokeApiKey(keyId: string): Promise<any>;
686
688
  deleteApiKey(keyId: string): Promise<any>;
689
+ getInstanceToken(): Promise<any>;
690
+ regenerateInstanceToken(): Promise<any>;
687
691
  createBackup(options?: any): Promise<any>;
688
692
  listBackups(): Promise<any>;
689
693
  getBackup(backupId: string): Promise<any>;
package/dist/index.js CHANGED
@@ -882,12 +882,12 @@ var RealtimeService = class {
882
882
  if (this.socket?.readyState === WebSocket.OPEN) return Promise.resolve();
883
883
  return new Promise((resolve, reject) => {
884
884
  const token = this.tokenProvider();
885
- if (!this.apiKey || !token) {
886
- reject(new Error("Missing API key or authentication token for Realtime connection"));
885
+ if (!token) {
886
+ reject(new Error("Missing authentication token for Realtime connection"));
887
887
  return;
888
888
  }
889
889
  const wsUrl = this.url.replace(/^http/, "ws") + "/ws";
890
- const fullUrl = `${wsUrl}?apikey=${this.apiKey}&token=${token}`;
890
+ const fullUrl = this.apiKey ? `${wsUrl}?apikey=${this.apiKey}&token=${token}` : `${wsUrl}?token=${token}`;
891
891
  if (!this.wsConstructor) {
892
892
  reject(new Error("WebSocket constructor not provided or available in this environment"));
893
893
  return;
@@ -1021,6 +1021,12 @@ function createApiKeysModule(client) {
1021
1021
  },
1022
1022
  async delete(keyId) {
1023
1023
  return del(`/api/api-keys/${keyId}`);
1024
+ },
1025
+ async getInstanceToken() {
1026
+ return get("/api/api-keys/instance");
1027
+ },
1028
+ async regenerateInstanceToken() {
1029
+ return post("/api/api-keys/instance/regenerate", {});
1024
1030
  }
1025
1031
  };
1026
1032
  }
@@ -1250,6 +1256,12 @@ var BaasClient = class extends HttpClient {
1250
1256
  async deleteApiKey(keyId) {
1251
1257
  return this.apiKeys.delete(keyId);
1252
1258
  }
1259
+ async getInstanceToken() {
1260
+ return this.apiKeys.getInstanceToken();
1261
+ }
1262
+ async regenerateInstanceToken() {
1263
+ return this.apiKeys.regenerateInstanceToken();
1264
+ }
1253
1265
  // Backups shortcuts
1254
1266
  async createBackup(options) {
1255
1267
  return this.backups.create(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@giaeulate/baas-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Standalone SDK for BaaS Golang",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",