@finatic/client 0.0.132 → 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 +15 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -22
- package/dist/index.mjs.map +1 -1
- package/dist/types/client/FinaticConnect.d.ts +0 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -404,10 +404,6 @@ Modifies an existing order.
|
|
|
404
404
|
|
|
405
405
|
### Authentication
|
|
406
406
|
|
|
407
|
-
#### `isAuthenticated()`
|
|
408
|
-
|
|
409
|
-
Returns true if the user is authenticated.
|
|
410
|
-
|
|
411
407
|
#### `isAuthed()`
|
|
412
408
|
|
|
413
409
|
Returns true if the user is fully authenticated (has userId, access token, and refresh token).
|
package/dist/index.d.ts
CHANGED
|
@@ -1104,11 +1104,6 @@ declare class FinaticConnect extends EventEmitter {
|
|
|
1104
1104
|
private currentSessionState;
|
|
1105
1105
|
constructor(options: FinaticConnectOptions, deviceInfo?: DeviceInfo);
|
|
1106
1106
|
private handleTokens;
|
|
1107
|
-
/**
|
|
1108
|
-
* Check if the user is authenticated
|
|
1109
|
-
* @returns True if the user has a valid access token
|
|
1110
|
-
*/
|
|
1111
|
-
isAuthenticated(): boolean;
|
|
1112
1107
|
/**
|
|
1113
1108
|
* Check if the user is fully authenticated (has userId, access token, and refresh token)
|
|
1114
1109
|
* @returns True if the user is fully authenticated and ready for API calls
|
package/dist/index.js
CHANGED
|
@@ -3752,13 +3752,6 @@ class FinaticConnect extends EventEmitter {
|
|
|
3752
3752
|
const expiresAt = new Date(Date.now() + 3600 * 1000).toISOString(); // 1 hour from now
|
|
3753
3753
|
this.apiClient.setTokens(tokens.access_token, tokens.refresh_token, expiresAt, userId);
|
|
3754
3754
|
}
|
|
3755
|
-
/**
|
|
3756
|
-
* Check if the user is authenticated
|
|
3757
|
-
* @returns True if the user has a valid access token
|
|
3758
|
-
*/
|
|
3759
|
-
isAuthenticated() {
|
|
3760
|
-
return this.isAuthed();
|
|
3761
|
-
}
|
|
3762
3755
|
/**
|
|
3763
3756
|
* Check if the user is fully authenticated (has userId, access token, and refresh token)
|
|
3764
3757
|
* @returns True if the user is fully authenticated and ready for API calls
|
|
@@ -3774,7 +3767,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
3774
3767
|
* @returns Promise with paginated result that supports navigation
|
|
3775
3768
|
*/
|
|
3776
3769
|
async getOrders(params) {
|
|
3777
|
-
if (!this.
|
|
3770
|
+
if (!this.isAuthed()) {
|
|
3778
3771
|
throw new AuthenticationError('User is not authenticated');
|
|
3779
3772
|
}
|
|
3780
3773
|
const page = params?.page || 1;
|
|
@@ -3788,7 +3781,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
3788
3781
|
* @returns Promise with paginated result that supports navigation
|
|
3789
3782
|
*/
|
|
3790
3783
|
async getPositions(params) {
|
|
3791
|
-
if (!this.
|
|
3784
|
+
if (!this.isAuthed()) {
|
|
3792
3785
|
throw new AuthenticationError('User is not authenticated');
|
|
3793
3786
|
}
|
|
3794
3787
|
const page = params?.page || 1;
|
|
@@ -3802,7 +3795,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
3802
3795
|
* @returns Promise with paginated result that supports navigation
|
|
3803
3796
|
*/
|
|
3804
3797
|
async getAccounts(params) {
|
|
3805
|
-
if (!this.
|
|
3798
|
+
if (!this.isAuthed()) {
|
|
3806
3799
|
throw new AuthenticationError('User is not authenticated');
|
|
3807
3800
|
}
|
|
3808
3801
|
const page = params?.page || 1;
|
|
@@ -4237,7 +4230,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4237
4230
|
* @throws AuthenticationError if user is not authenticated
|
|
4238
4231
|
*/
|
|
4239
4232
|
getUserId() {
|
|
4240
|
-
if (!this.
|
|
4233
|
+
if (!this.isAuthed()) {
|
|
4241
4234
|
return null;
|
|
4242
4235
|
}
|
|
4243
4236
|
if (!this.userToken?.user_id) {
|
|
@@ -4250,7 +4243,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4250
4243
|
* @returns Promise with array of broker information
|
|
4251
4244
|
*/
|
|
4252
4245
|
async getBrokerList() {
|
|
4253
|
-
if (!this.
|
|
4246
|
+
if (!this.isAuthed()) {
|
|
4254
4247
|
throw new AuthenticationError('Not authenticated');
|
|
4255
4248
|
}
|
|
4256
4249
|
const response = await this.apiClient.getBrokerListAuto();
|
|
@@ -4267,7 +4260,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4267
4260
|
* @throws AuthenticationError if user is not authenticated
|
|
4268
4261
|
*/
|
|
4269
4262
|
async getBrokerConnections() {
|
|
4270
|
-
if (!this.
|
|
4263
|
+
if (!this.isAuthed()) {
|
|
4271
4264
|
throw new AuthenticationError('User is not authenticated. Please connect a broker first.');
|
|
4272
4265
|
}
|
|
4273
4266
|
if (!this.userToken?.user_id) {
|
|
@@ -4349,7 +4342,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4349
4342
|
* @returns Promise with paginated orders result
|
|
4350
4343
|
*/
|
|
4351
4344
|
async getOrdersPage(page = 1, perPage = 100, filter) {
|
|
4352
|
-
if (!this.
|
|
4345
|
+
if (!this.isAuthed()) {
|
|
4353
4346
|
throw new AuthenticationError('User is not authenticated');
|
|
4354
4347
|
}
|
|
4355
4348
|
return this.apiClient.getBrokerOrdersPage(page, perPage, filter);
|
|
@@ -4362,7 +4355,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4362
4355
|
* @returns Promise with paginated positions result
|
|
4363
4356
|
*/
|
|
4364
4357
|
async getPositionsPage(page = 1, perPage = 100, filter) {
|
|
4365
|
-
if (!this.
|
|
4358
|
+
if (!this.isAuthed()) {
|
|
4366
4359
|
throw new AuthenticationError('User is not authenticated');
|
|
4367
4360
|
}
|
|
4368
4361
|
return this.apiClient.getBrokerPositionsPage(page, perPage, filter);
|
|
@@ -4375,7 +4368,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4375
4368
|
* @returns Promise with paginated accounts result
|
|
4376
4369
|
*/
|
|
4377
4370
|
async getAccountsPage(page = 1, perPage = 100, filter) {
|
|
4378
|
-
if (!this.
|
|
4371
|
+
if (!this.isAuthed()) {
|
|
4379
4372
|
throw new AuthenticationError('User is not authenticated');
|
|
4380
4373
|
}
|
|
4381
4374
|
return this.apiClient.getBrokerAccountsPage(page, perPage, filter);
|
|
@@ -4386,7 +4379,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4386
4379
|
* @returns Promise with next page of orders or null if no more pages
|
|
4387
4380
|
*/
|
|
4388
4381
|
async getNextOrdersPage(previousResult) {
|
|
4389
|
-
if (!this.
|
|
4382
|
+
if (!this.isAuthed()) {
|
|
4390
4383
|
throw new AuthenticationError('User is not authenticated');
|
|
4391
4384
|
}
|
|
4392
4385
|
return this.apiClient.getNextPage(previousResult, (offset, limit) => {
|
|
@@ -4400,7 +4393,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4400
4393
|
* @returns Promise with next page of positions or null if no more pages
|
|
4401
4394
|
*/
|
|
4402
4395
|
async getNextPositionsPage(previousResult) {
|
|
4403
|
-
if (!this.
|
|
4396
|
+
if (!this.isAuthed()) {
|
|
4404
4397
|
throw new AuthenticationError('User is not authenticated');
|
|
4405
4398
|
}
|
|
4406
4399
|
return this.apiClient.getNextPage(previousResult, (offset, limit) => {
|
|
@@ -4414,7 +4407,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4414
4407
|
* @returns Promise with next page of accounts or null if no more pages
|
|
4415
4408
|
*/
|
|
4416
4409
|
async getNextAccountsPage(previousResult) {
|
|
4417
|
-
if (!this.
|
|
4410
|
+
if (!this.isAuthed()) {
|
|
4418
4411
|
throw new AuthenticationError('User is not authenticated');
|
|
4419
4412
|
}
|
|
4420
4413
|
return this.apiClient.getNextPage(previousResult, (offset, limit) => {
|
|
@@ -4428,7 +4421,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4428
4421
|
* @returns Promise with all orders
|
|
4429
4422
|
*/
|
|
4430
4423
|
async getAllOrders(filter) {
|
|
4431
|
-
if (!this.
|
|
4424
|
+
if (!this.isAuthed()) {
|
|
4432
4425
|
throw new AuthenticationError('User is not authenticated');
|
|
4433
4426
|
}
|
|
4434
4427
|
const allData = [];
|
|
@@ -4450,7 +4443,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4450
4443
|
* @returns Promise with all positions
|
|
4451
4444
|
*/
|
|
4452
4445
|
async getAllPositions(filter) {
|
|
4453
|
-
if (!this.
|
|
4446
|
+
if (!this.isAuthed()) {
|
|
4454
4447
|
throw new AuthenticationError('User is not authenticated');
|
|
4455
4448
|
}
|
|
4456
4449
|
const allData = [];
|
|
@@ -4472,7 +4465,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4472
4465
|
* @returns Promise with all accounts
|
|
4473
4466
|
*/
|
|
4474
4467
|
async getAllAccounts(filter) {
|
|
4475
|
-
if (!this.
|
|
4468
|
+
if (!this.isAuthed()) {
|
|
4476
4469
|
throw new AuthenticationError('User is not authenticated');
|
|
4477
4470
|
}
|
|
4478
4471
|
const allData = [];
|