@gbozee/ultimate 0.0.2-112 → 0.0.2-113

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
@@ -59851,7 +59851,10 @@ function getExchangeKlass(exchange) {
59851
59851
  const func = exchange === "binance" ? BinanceExchange : BybitExchange;
59852
59852
  const clientFunc = exchange === "binance" ? initClient : initClient2;
59853
59853
  return async (payload) => {
59854
- const credentials = payload.getCredentials(payload.account, exchange);
59854
+ const credentials = await payload.getCredentials({
59855
+ account: payload.account,
59856
+ exchange
59857
+ });
59855
59858
  const client = await clientFunc(credentials, {
59856
59859
  type: "future",
59857
59860
  proxyAgent: payload.proxyAgent
@@ -59882,7 +59885,9 @@ async function getExchangeAccount(payload) {
59882
59885
  const proxyAgent = proxyOptions?.ignore_proxy ? null : proxyOptions?.proxy || _proxyAgent;
59883
59886
  const exchange_instance = await getExchangeKlass(account.exchange)({
59884
59887
  account: account.owner,
59885
- getCredentials: payload.getCredentials,
59888
+ getCredentials: async (_payload) => {
59889
+ return await payload.getCredentials({ ..._payload, app_db });
59890
+ },
59886
59891
  proxyAgent,
59887
59892
  canWithdraw
59888
59893
  });
@@ -59906,7 +59911,7 @@ class App {
59906
59911
  return await getExchangeAccount({
59907
59912
  account,
59908
59913
  app_db: this.app_db,
59909
- getCredentials: this.getCredentials,
59914
+ getCredentials: (p) => this.getCredentials({ ...p, app_db: this.app_db }),
59910
59915
  proxyOptions: this.proxyOptions,
59911
59916
  canWithdraw: this.proxyOptions?.canWithdraw
59912
59917
  });
@@ -60224,7 +60229,8 @@ async function initApp(payload) {
60224
60229
  password: payload.password
60225
60230
  });
60226
60231
  if (credentials) {
60227
- _getCredentials = (account, exchange) => {
60232
+ _getCredentials = async (payload2) => {
60233
+ const { account, exchange } = payload2;
60228
60234
  const credential = credentials.find((c) => c.name === account && c.exchange === exchange);
60229
60235
  if (!credential) {
60230
60236
  throw new Error(`Missing API Key or Secret for account '${account}' in .env file. Please check your environment variables.`);
@@ -60252,41 +60258,16 @@ async function initApp(payload) {
60252
60258
  });
60253
60259
  return app;
60254
60260
  }
60255
- function getCredentials(account, exchange) {
60261
+ async function getCredentials(payload) {
60262
+ const { account, exchange, app_db } = payload;
60256
60263
  console.log(`Fetching credentials for account: ${account}, exchange: ${exchange}`);
60257
- let apiKey;
60258
- let apiSecret;
60259
- switch (account) {
60260
- case "sub_account":
60261
- apiKey = process.env.SUB_ACCOUNT_API_KEY;
60262
- apiSecret = process.env.SUB_ACCOUNT_API_SECRET;
60263
- break;
60264
- case "tola_sub_account":
60265
- apiKey = process.env.TOLA_SUB_ACCOUNT_API_KEY;
60266
- apiSecret = process.env.TOLA_SUB_ACCOUNT_API_SECRET;
60267
- break;
60268
- case "gbozee1_sub_account":
60269
- apiKey = process.env.GBOZEE1_SUB_ACCOUNT_API_KEY;
60270
- apiSecret = process.env.GBOZEE1_SUB_ACCOUNT_API_SECRET;
60271
- break;
60272
- case "tomi_account":
60273
- apiKey = process.env.TOMI_ACCOUNT_API_KEY;
60274
- apiSecret = process.env.TOMI_ACCOUNT_API_SECRET;
60275
- break;
60276
- case "main_account":
60277
- default:
60278
- apiKey = process.env.MAIN_ACCOUNT_API_KEY;
60279
- apiSecret = process.env.MAIN_ACCOUNT_API_SECRET;
60280
- break;
60281
- }
60282
- if (!apiKey || !apiSecret) {
60264
+ const password = process.env.POCKETBASE_PASSWORD;
60265
+ const credentials = await app_db.getCredentials({ password });
60266
+ const result = credentials.find((c) => c.name === account && c.exchange === exchange);
60267
+ if (!result.api_key || !result.api_secret) {
60283
60268
  throw new Error(`Missing API Key or Secret for account '${account}' in .env file. Please check your environment variables.`);
60284
60269
  }
60285
- return {
60286
- api_key: apiKey,
60287
- api_secret: apiSecret,
60288
- email: process.env.POCKETBASE_EMAIL
60289
- };
60270
+ return result;
60290
60271
  }
60291
60272
  async function initialize(payload) {
60292
60273
  const { password, proxy, ignore_proxy, canWithdraw } = payload;
package/dist/index.d.ts CHANGED
@@ -2251,11 +2251,15 @@ declare class ExchangeAccount$1 {
2251
2251
  declare function getExchangeAccount(payload: {
2252
2252
  account: ExchangeType;
2253
2253
  app_db: AppDatabase;
2254
- getCredentials: (account: string, exchange: string) => {
2254
+ getCredentials: (payload: {
2255
+ account: string;
2256
+ exchange: string;
2257
+ app_db: AppDatabase;
2258
+ }) => Promise<{
2255
2259
  api_key: string;
2256
2260
  api_secret: string;
2257
2261
  email: string;
2258
- };
2262
+ }>;
2259
2263
  proxyOptions?: {
2260
2264
  proxy?: any;
2261
2265
  ignore_proxy?: boolean;
@@ -2270,11 +2274,14 @@ declare class App {
2270
2274
  canWithdraw?: boolean;
2271
2275
  };
2272
2276
  private getCredentials;
2273
- constructor(app_db: AppDatabase, getCredentials: (account: string, exchange: string) => {
2277
+ constructor(app_db: AppDatabase, getCredentials: (payload: {
2278
+ account: string;
2279
+ exchange: string;
2280
+ }) => Promise<{
2274
2281
  api_key: string;
2275
2282
  api_secret: string;
2276
2283
  email: string;
2277
- }, proxyOptions?: {
2284
+ }>, proxyOptions?: {
2278
2285
  proxy?: any;
2279
2286
  ignore_proxy?: boolean;
2280
2287
  canWithdraw?: boolean;
@@ -2491,21 +2498,25 @@ export declare function initApp(payload: {
2491
2498
  password?: string;
2492
2499
  salt?: string;
2493
2500
  email?: string;
2494
- getCredentials: (account: string, exchange: string) => {
2501
+ getCredentials: (payload: {
2502
+ account: string;
2503
+ exchange: string;
2504
+ app_db: AppDatabase;
2505
+ }) => Promise<{
2495
2506
  api_key: string;
2496
2507
  api_secret: string;
2497
2508
  email: string;
2498
- };
2509
+ }>;
2499
2510
  proxy?: any;
2500
2511
  ignore_proxy?: boolean;
2501
2512
  canWithdraw?: boolean;
2502
2513
  triggerToken?: string;
2503
2514
  }): Promise<App>;
2504
- declare function getCredentials(account: string, exchange: string): {
2505
- api_key: string;
2506
- api_secret: string;
2507
- email: string;
2508
- };
2515
+ declare function getCredentials(payload: {
2516
+ account: string;
2517
+ exchange: string;
2518
+ app_db: AppDatabase;
2519
+ }): Promise<any>;
2509
2520
  export declare function initialize(payload: {
2510
2521
  password?: string;
2511
2522
  proxy?: any;
package/dist/index.js CHANGED
@@ -59801,7 +59801,10 @@ function getExchangeKlass(exchange) {
59801
59801
  const func = exchange === "binance" ? BinanceExchange : BybitExchange;
59802
59802
  const clientFunc = exchange === "binance" ? initClient : initClient2;
59803
59803
  return async (payload) => {
59804
- const credentials = payload.getCredentials(payload.account, exchange);
59804
+ const credentials = await payload.getCredentials({
59805
+ account: payload.account,
59806
+ exchange
59807
+ });
59805
59808
  const client = await clientFunc(credentials, {
59806
59809
  type: "future",
59807
59810
  proxyAgent: payload.proxyAgent
@@ -59832,7 +59835,9 @@ async function getExchangeAccount(payload) {
59832
59835
  const proxyAgent = proxyOptions?.ignore_proxy ? null : proxyOptions?.proxy || _proxyAgent;
59833
59836
  const exchange_instance = await getExchangeKlass(account.exchange)({
59834
59837
  account: account.owner,
59835
- getCredentials: payload.getCredentials,
59838
+ getCredentials: async (_payload) => {
59839
+ return await payload.getCredentials({ ..._payload, app_db });
59840
+ },
59836
59841
  proxyAgent,
59837
59842
  canWithdraw
59838
59843
  });
@@ -59856,7 +59861,7 @@ class App {
59856
59861
  return await getExchangeAccount({
59857
59862
  account,
59858
59863
  app_db: this.app_db,
59859
- getCredentials: this.getCredentials,
59864
+ getCredentials: (p) => this.getCredentials({ ...p, app_db: this.app_db }),
59860
59865
  proxyOptions: this.proxyOptions,
59861
59866
  canWithdraw: this.proxyOptions?.canWithdraw
59862
59867
  });
@@ -60174,7 +60179,8 @@ async function initApp(payload) {
60174
60179
  password: payload.password
60175
60180
  });
60176
60181
  if (credentials) {
60177
- _getCredentials = (account, exchange) => {
60182
+ _getCredentials = async (payload2) => {
60183
+ const { account, exchange } = payload2;
60178
60184
  const credential = credentials.find((c) => c.name === account && c.exchange === exchange);
60179
60185
  if (!credential) {
60180
60186
  throw new Error(`Missing API Key or Secret for account '${account}' in .env file. Please check your environment variables.`);
@@ -60202,41 +60208,16 @@ async function initApp(payload) {
60202
60208
  });
60203
60209
  return app;
60204
60210
  }
60205
- function getCredentials(account, exchange) {
60211
+ async function getCredentials(payload) {
60212
+ const { account, exchange, app_db } = payload;
60206
60213
  console.log(`Fetching credentials for account: ${account}, exchange: ${exchange}`);
60207
- let apiKey;
60208
- let apiSecret;
60209
- switch (account) {
60210
- case "sub_account":
60211
- apiKey = process.env.SUB_ACCOUNT_API_KEY;
60212
- apiSecret = process.env.SUB_ACCOUNT_API_SECRET;
60213
- break;
60214
- case "tola_sub_account":
60215
- apiKey = process.env.TOLA_SUB_ACCOUNT_API_KEY;
60216
- apiSecret = process.env.TOLA_SUB_ACCOUNT_API_SECRET;
60217
- break;
60218
- case "gbozee1_sub_account":
60219
- apiKey = process.env.GBOZEE1_SUB_ACCOUNT_API_KEY;
60220
- apiSecret = process.env.GBOZEE1_SUB_ACCOUNT_API_SECRET;
60221
- break;
60222
- case "tomi_account":
60223
- apiKey = process.env.TOMI_ACCOUNT_API_KEY;
60224
- apiSecret = process.env.TOMI_ACCOUNT_API_SECRET;
60225
- break;
60226
- case "main_account":
60227
- default:
60228
- apiKey = process.env.MAIN_ACCOUNT_API_KEY;
60229
- apiSecret = process.env.MAIN_ACCOUNT_API_SECRET;
60230
- break;
60231
- }
60232
- if (!apiKey || !apiSecret) {
60214
+ const password = process.env.POCKETBASE_PASSWORD;
60215
+ const credentials = await app_db.getCredentials({ password });
60216
+ const result = credentials.find((c) => c.name === account && c.exchange === exchange);
60217
+ if (!result.api_key || !result.api_secret) {
60233
60218
  throw new Error(`Missing API Key or Secret for account '${account}' in .env file. Please check your environment variables.`);
60234
60219
  }
60235
- return {
60236
- api_key: apiKey,
60237
- api_secret: apiSecret,
60238
- email: process.env.POCKETBASE_EMAIL
60239
- };
60220
+ return result;
60240
60221
  }
60241
60222
  async function initialize(payload) {
60242
60223
  const { password, proxy, ignore_proxy, canWithdraw } = payload;
@@ -66531,7 +66531,10 @@ function getExchangeKlass(exchange) {
66531
66531
  const func = exchange === "binance" ? BinanceExchange : BybitExchange;
66532
66532
  const clientFunc = exchange === "binance" ? initClient : initClient2;
66533
66533
  return async (payload) => {
66534
- const credentials = payload.getCredentials(payload.account, exchange);
66534
+ const credentials = await payload.getCredentials({
66535
+ account: payload.account,
66536
+ exchange
66537
+ });
66535
66538
  const client = await clientFunc(credentials, {
66536
66539
  type: "future",
66537
66540
  proxyAgent: payload.proxyAgent
@@ -66562,7 +66565,9 @@ async function getExchangeAccount(payload) {
66562
66565
  const proxyAgent = proxyOptions?.ignore_proxy ? null : proxyOptions?.proxy || _proxyAgent;
66563
66566
  const exchange_instance = await getExchangeKlass(account.exchange)({
66564
66567
  account: account.owner,
66565
- getCredentials: payload.getCredentials,
66568
+ getCredentials: async (_payload) => {
66569
+ return await payload.getCredentials({ ..._payload, app_db });
66570
+ },
66566
66571
  proxyAgent,
66567
66572
  canWithdraw
66568
66573
  });
@@ -66586,7 +66591,7 @@ class App {
66586
66591
  return await getExchangeAccount({
66587
66592
  account,
66588
66593
  app_db: this.app_db,
66589
- getCredentials: this.getCredentials,
66594
+ getCredentials: (p) => this.getCredentials({ ...p, app_db: this.app_db }),
66590
66595
  proxyOptions: this.proxyOptions,
66591
66596
  canWithdraw: this.proxyOptions?.canWithdraw
66592
66597
  });
@@ -66904,7 +66909,8 @@ async function initApp(payload) {
66904
66909
  password: payload.password
66905
66910
  });
66906
66911
  if (credentials) {
66907
- _getCredentials = (account, exchange) => {
66912
+ _getCredentials = async (payload2) => {
66913
+ const { account, exchange } = payload2;
66908
66914
  const credential = credentials.find((c) => c.name === account && c.exchange === exchange);
66909
66915
  if (!credential) {
66910
66916
  throw new Error(`Missing API Key or Secret for account '${account}' in .env file. Please check your environment variables.`);
@@ -66942,11 +66948,19 @@ async function getApp() {
66942
66948
  password: process.env.POCKETBASE_PASSWORD
66943
66949
  },
66944
66950
  password: process.env.POCKETBASE_PASSWORD,
66945
- getCredentials: (account, exchange) => {
66951
+ getCredentials: async (payload) => {
66952
+ const { account, exchange, app_db } = payload;
66953
+ const credentials = await app_db.getCredentials({
66954
+ password: process.env.POCKETBASE_PASSWORD
66955
+ });
66956
+ const credential = credentials.find((c) => c.name === account && c.exchange === exchange);
66957
+ if (!credential) {
66958
+ throw new Error(`Missing API Key or Secret for account '${account}' in .env file. Please check your environment variables.`);
66959
+ }
66946
66960
  return {
66947
- api_key: "",
66948
- api_secret: "",
66949
- email: ""
66961
+ api_key: credential.api_key,
66962
+ api_secret: credential.api_secret,
66963
+ email: credential.email
66950
66964
  };
66951
66965
  }
66952
66966
  });
@@ -66508,7 +66508,10 @@ function getExchangeKlass(exchange) {
66508
66508
  const func = exchange === "binance" ? BinanceExchange : BybitExchange;
66509
66509
  const clientFunc = exchange === "binance" ? initClient : initClient2;
66510
66510
  return async (payload) => {
66511
- const credentials = payload.getCredentials(payload.account, exchange);
66511
+ const credentials = await payload.getCredentials({
66512
+ account: payload.account,
66513
+ exchange
66514
+ });
66512
66515
  const client = await clientFunc(credentials, {
66513
66516
  type: "future",
66514
66517
  proxyAgent: payload.proxyAgent
@@ -66539,7 +66542,9 @@ async function getExchangeAccount(payload) {
66539
66542
  const proxyAgent = proxyOptions?.ignore_proxy ? null : proxyOptions?.proxy || _proxyAgent;
66540
66543
  const exchange_instance = await getExchangeKlass(account.exchange)({
66541
66544
  account: account.owner,
66542
- getCredentials: payload.getCredentials,
66545
+ getCredentials: async (_payload) => {
66546
+ return await payload.getCredentials({ ..._payload, app_db });
66547
+ },
66543
66548
  proxyAgent,
66544
66549
  canWithdraw
66545
66550
  });
@@ -66563,7 +66568,7 @@ class App {
66563
66568
  return await getExchangeAccount({
66564
66569
  account,
66565
66570
  app_db: this.app_db,
66566
- getCredentials: this.getCredentials,
66571
+ getCredentials: (p) => this.getCredentials({ ...p, app_db: this.app_db }),
66567
66572
  proxyOptions: this.proxyOptions,
66568
66573
  canWithdraw: this.proxyOptions?.canWithdraw
66569
66574
  });
@@ -66881,7 +66886,8 @@ async function initApp(payload) {
66881
66886
  password: payload.password
66882
66887
  });
66883
66888
  if (credentials) {
66884
- _getCredentials = (account, exchange) => {
66889
+ _getCredentials = async (payload2) => {
66890
+ const { account, exchange } = payload2;
66885
66891
  const credential = credentials.find((c) => c.name === account && c.exchange === exchange);
66886
66892
  if (!credential) {
66887
66893
  throw new Error(`Missing API Key or Secret for account '${account}' in .env file. Please check your environment variables.`);
@@ -66919,11 +66925,19 @@ async function getApp() {
66919
66925
  password: process.env.POCKETBASE_PASSWORD
66920
66926
  },
66921
66927
  password: process.env.POCKETBASE_PASSWORD,
66922
- getCredentials: (account, exchange) => {
66928
+ getCredentials: async (payload) => {
66929
+ const { account, exchange, app_db } = payload;
66930
+ const credentials = await app_db.getCredentials({
66931
+ password: process.env.POCKETBASE_PASSWORD
66932
+ });
66933
+ const credential = credentials.find((c) => c.name === account && c.exchange === exchange);
66934
+ if (!credential) {
66935
+ throw new Error(`Missing API Key or Secret for account '${account}' in .env file. Please check your environment variables.`);
66936
+ }
66923
66937
  return {
66924
- api_key: "",
66925
- api_secret: "",
66926
- email: ""
66938
+ api_key: credential.api_key,
66939
+ api_secret: credential.api_secret,
66940
+ email: credential.email
66927
66941
  };
66928
66942
  }
66929
66943
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gbozee/ultimate",
3
3
  "type": "module",
4
- "version": "0.0.2-112",
4
+ "version": "0.0.2-113",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",