@finatic/client 0.0.131 → 0.0.133
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/README.md +0 -4
- package/dist/index.d.ts +0 -5
- package/dist/index.js +17 -24
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -24
- package/dist/index.mjs.map +1 -1
- package/dist/types/client/FinaticConnect.d.ts +0 -5
- package/package.json +4 -1
package/dist/index.mjs
CHANGED
|
@@ -3684,7 +3684,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
3684
3684
|
this.BROKER_LIST_CACHE_DURATION = 1000 * 60 * 60 * 24; // 24 hours in milliseconds
|
|
3685
3685
|
this.currentSessionState = null;
|
|
3686
3686
|
this.options = options;
|
|
3687
|
-
this.baseUrl = options.baseUrl || '
|
|
3687
|
+
this.baseUrl = options.baseUrl || 'https://api.finatic.dev';
|
|
3688
3688
|
this.apiClient = MockFactory.createApiClient(this.baseUrl, deviceInfo);
|
|
3689
3689
|
this.portalUI = new PortalUI(this.baseUrl);
|
|
3690
3690
|
this.deviceInfo = deviceInfo;
|
|
@@ -3750,13 +3750,6 @@ class FinaticConnect extends EventEmitter {
|
|
|
3750
3750
|
const expiresAt = new Date(Date.now() + 3600 * 1000).toISOString(); // 1 hour from now
|
|
3751
3751
|
this.apiClient.setTokens(tokens.access_token, tokens.refresh_token, expiresAt, userId);
|
|
3752
3752
|
}
|
|
3753
|
-
/**
|
|
3754
|
-
* Check if the user is authenticated
|
|
3755
|
-
* @returns True if the user has a valid access token
|
|
3756
|
-
*/
|
|
3757
|
-
isAuthenticated() {
|
|
3758
|
-
return this.isAuthed();
|
|
3759
|
-
}
|
|
3760
3753
|
/**
|
|
3761
3754
|
* Check if the user is fully authenticated (has userId, access token, and refresh token)
|
|
3762
3755
|
* @returns True if the user is fully authenticated and ready for API calls
|
|
@@ -3772,7 +3765,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
3772
3765
|
* @returns Promise with paginated result that supports navigation
|
|
3773
3766
|
*/
|
|
3774
3767
|
async getOrders(params) {
|
|
3775
|
-
if (!this.
|
|
3768
|
+
if (!this.isAuthed()) {
|
|
3776
3769
|
throw new AuthenticationError('User is not authenticated');
|
|
3777
3770
|
}
|
|
3778
3771
|
const page = params?.page || 1;
|
|
@@ -3786,7 +3779,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
3786
3779
|
* @returns Promise with paginated result that supports navigation
|
|
3787
3780
|
*/
|
|
3788
3781
|
async getPositions(params) {
|
|
3789
|
-
if (!this.
|
|
3782
|
+
if (!this.isAuthed()) {
|
|
3790
3783
|
throw new AuthenticationError('User is not authenticated');
|
|
3791
3784
|
}
|
|
3792
3785
|
const page = params?.page || 1;
|
|
@@ -3800,7 +3793,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
3800
3793
|
* @returns Promise with paginated result that supports navigation
|
|
3801
3794
|
*/
|
|
3802
3795
|
async getAccounts(params) {
|
|
3803
|
-
if (!this.
|
|
3796
|
+
if (!this.isAuthed()) {
|
|
3804
3797
|
throw new AuthenticationError('User is not authenticated');
|
|
3805
3798
|
}
|
|
3806
3799
|
const page = params?.page || 1;
|
|
@@ -3835,7 +3828,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
3835
3828
|
if (!FinaticConnect.instance) {
|
|
3836
3829
|
const connectOptions = {
|
|
3837
3830
|
token,
|
|
3838
|
-
baseUrl: options?.baseUrl || '
|
|
3831
|
+
baseUrl: options?.baseUrl || 'https://api.finatic.dev',
|
|
3839
3832
|
onSuccess: undefined,
|
|
3840
3833
|
onError: undefined,
|
|
3841
3834
|
onClose: undefined,
|
|
@@ -4235,7 +4228,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4235
4228
|
* @throws AuthenticationError if user is not authenticated
|
|
4236
4229
|
*/
|
|
4237
4230
|
getUserId() {
|
|
4238
|
-
if (!this.
|
|
4231
|
+
if (!this.isAuthed()) {
|
|
4239
4232
|
return null;
|
|
4240
4233
|
}
|
|
4241
4234
|
if (!this.userToken?.user_id) {
|
|
@@ -4248,7 +4241,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4248
4241
|
* @returns Promise with array of broker information
|
|
4249
4242
|
*/
|
|
4250
4243
|
async getBrokerList() {
|
|
4251
|
-
if (!this.
|
|
4244
|
+
if (!this.isAuthed()) {
|
|
4252
4245
|
throw new AuthenticationError('Not authenticated');
|
|
4253
4246
|
}
|
|
4254
4247
|
const response = await this.apiClient.getBrokerListAuto();
|
|
@@ -4265,7 +4258,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4265
4258
|
* @throws AuthenticationError if user is not authenticated
|
|
4266
4259
|
*/
|
|
4267
4260
|
async getBrokerConnections() {
|
|
4268
|
-
if (!this.
|
|
4261
|
+
if (!this.isAuthed()) {
|
|
4269
4262
|
throw new AuthenticationError('User is not authenticated. Please connect a broker first.');
|
|
4270
4263
|
}
|
|
4271
4264
|
if (!this.userToken?.user_id) {
|
|
@@ -4347,7 +4340,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4347
4340
|
* @returns Promise with paginated orders result
|
|
4348
4341
|
*/
|
|
4349
4342
|
async getOrdersPage(page = 1, perPage = 100, filter) {
|
|
4350
|
-
if (!this.
|
|
4343
|
+
if (!this.isAuthed()) {
|
|
4351
4344
|
throw new AuthenticationError('User is not authenticated');
|
|
4352
4345
|
}
|
|
4353
4346
|
return this.apiClient.getBrokerOrdersPage(page, perPage, filter);
|
|
@@ -4360,7 +4353,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4360
4353
|
* @returns Promise with paginated positions result
|
|
4361
4354
|
*/
|
|
4362
4355
|
async getPositionsPage(page = 1, perPage = 100, filter) {
|
|
4363
|
-
if (!this.
|
|
4356
|
+
if (!this.isAuthed()) {
|
|
4364
4357
|
throw new AuthenticationError('User is not authenticated');
|
|
4365
4358
|
}
|
|
4366
4359
|
return this.apiClient.getBrokerPositionsPage(page, perPage, filter);
|
|
@@ -4373,7 +4366,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4373
4366
|
* @returns Promise with paginated accounts result
|
|
4374
4367
|
*/
|
|
4375
4368
|
async getAccountsPage(page = 1, perPage = 100, filter) {
|
|
4376
|
-
if (!this.
|
|
4369
|
+
if (!this.isAuthed()) {
|
|
4377
4370
|
throw new AuthenticationError('User is not authenticated');
|
|
4378
4371
|
}
|
|
4379
4372
|
return this.apiClient.getBrokerAccountsPage(page, perPage, filter);
|
|
@@ -4384,7 +4377,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4384
4377
|
* @returns Promise with next page of orders or null if no more pages
|
|
4385
4378
|
*/
|
|
4386
4379
|
async getNextOrdersPage(previousResult) {
|
|
4387
|
-
if (!this.
|
|
4380
|
+
if (!this.isAuthed()) {
|
|
4388
4381
|
throw new AuthenticationError('User is not authenticated');
|
|
4389
4382
|
}
|
|
4390
4383
|
return this.apiClient.getNextPage(previousResult, (offset, limit) => {
|
|
@@ -4398,7 +4391,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4398
4391
|
* @returns Promise with next page of positions or null if no more pages
|
|
4399
4392
|
*/
|
|
4400
4393
|
async getNextPositionsPage(previousResult) {
|
|
4401
|
-
if (!this.
|
|
4394
|
+
if (!this.isAuthed()) {
|
|
4402
4395
|
throw new AuthenticationError('User is not authenticated');
|
|
4403
4396
|
}
|
|
4404
4397
|
return this.apiClient.getNextPage(previousResult, (offset, limit) => {
|
|
@@ -4412,7 +4405,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4412
4405
|
* @returns Promise with next page of accounts or null if no more pages
|
|
4413
4406
|
*/
|
|
4414
4407
|
async getNextAccountsPage(previousResult) {
|
|
4415
|
-
if (!this.
|
|
4408
|
+
if (!this.isAuthed()) {
|
|
4416
4409
|
throw new AuthenticationError('User is not authenticated');
|
|
4417
4410
|
}
|
|
4418
4411
|
return this.apiClient.getNextPage(previousResult, (offset, limit) => {
|
|
@@ -4426,7 +4419,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4426
4419
|
* @returns Promise with all orders
|
|
4427
4420
|
*/
|
|
4428
4421
|
async getAllOrders(filter) {
|
|
4429
|
-
if (!this.
|
|
4422
|
+
if (!this.isAuthed()) {
|
|
4430
4423
|
throw new AuthenticationError('User is not authenticated');
|
|
4431
4424
|
}
|
|
4432
4425
|
const allData = [];
|
|
@@ -4448,7 +4441,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4448
4441
|
* @returns Promise with all positions
|
|
4449
4442
|
*/
|
|
4450
4443
|
async getAllPositions(filter) {
|
|
4451
|
-
if (!this.
|
|
4444
|
+
if (!this.isAuthed()) {
|
|
4452
4445
|
throw new AuthenticationError('User is not authenticated');
|
|
4453
4446
|
}
|
|
4454
4447
|
const allData = [];
|
|
@@ -4470,7 +4463,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4470
4463
|
* @returns Promise with all accounts
|
|
4471
4464
|
*/
|
|
4472
4465
|
async getAllAccounts(filter) {
|
|
4473
|
-
if (!this.
|
|
4466
|
+
if (!this.isAuthed()) {
|
|
4474
4467
|
throw new AuthenticationError('User is not authenticated');
|
|
4475
4468
|
}
|
|
4476
4469
|
const allData = [];
|