@finatic/client 0.0.137 → 0.0.139
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.d.ts +23 -1
- package/dist/index.js +228 -99
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +228 -99
- package/dist/index.mjs.map +1 -1
- package/dist/types/core/client/FinaticConnect.d.ts +20 -1
- package/dist/types/core/portal/PortalUI.d.ts +0 -3
- package/dist/types/themes/portalPresets.d.ts +1 -0
- package/dist/types/types/connect.d.ts +4 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -936,7 +936,10 @@ interface PortalMessage {
|
|
|
936
936
|
}
|
|
937
937
|
interface PortalOptions {
|
|
938
938
|
/** Callback when user successfully connects */
|
|
939
|
-
onSuccess?: (userId: string
|
|
939
|
+
onSuccess?: (userId: string, tokens?: {
|
|
940
|
+
access_token?: string;
|
|
941
|
+
refresh_token?: string;
|
|
942
|
+
}) => void;
|
|
940
943
|
/** Callback when an error occurs */
|
|
941
944
|
onError?: (error: Error) => void;
|
|
942
945
|
/** Callback when the portal is closed */
|
|
@@ -1383,6 +1386,25 @@ declare class FinaticConnect extends EventEmitter {
|
|
|
1383
1386
|
side?: 'Buy' | 'Sell';
|
|
1384
1387
|
order_id?: string;
|
|
1385
1388
|
}>, broker?: 'robinhood' | 'tasty_trade' | 'ninja_trader', connection_id?: string): Promise<OrderResponse>;
|
|
1389
|
+
/**
|
|
1390
|
+
* Set the broker context for trading
|
|
1391
|
+
* @param broker - The broker to use for trading
|
|
1392
|
+
*/
|
|
1393
|
+
setTradingContextBroker(broker: 'robinhood' | 'tasty_trade' | 'ninja_trader' | 'interactive_brokers' | 'tradestation'): void;
|
|
1394
|
+
/**
|
|
1395
|
+
* Set the account context for trading
|
|
1396
|
+
* @param accountNumber - The account number to use for trading
|
|
1397
|
+
* @param accountId - Optional account ID
|
|
1398
|
+
*/
|
|
1399
|
+
setTradingContextAccount(accountNumber: string, accountId?: string): void;
|
|
1400
|
+
/**
|
|
1401
|
+
* Get the current trading context
|
|
1402
|
+
*/
|
|
1403
|
+
getTradingContext(): TradingContext;
|
|
1404
|
+
/**
|
|
1405
|
+
* Clear the trading context
|
|
1406
|
+
*/
|
|
1407
|
+
clearTradingContext(): void;
|
|
1386
1408
|
/**
|
|
1387
1409
|
* Place a stock market order (convenience method)
|
|
1388
1410
|
*/
|
package/dist/index.js
CHANGED
|
@@ -666,7 +666,7 @@ class ApiClient {
|
|
|
666
666
|
return this.request('/brokers/data/orders', {
|
|
667
667
|
method: 'GET',
|
|
668
668
|
headers: {
|
|
669
|
-
|
|
669
|
+
Authorization: `Bearer ${accessToken}`,
|
|
670
670
|
},
|
|
671
671
|
});
|
|
672
672
|
}
|
|
@@ -747,8 +747,8 @@ class ApiClient {
|
|
|
747
747
|
order: {
|
|
748
748
|
order_id: orderId,
|
|
749
749
|
account_number: accountNumber,
|
|
750
|
-
...extras
|
|
751
|
-
}
|
|
750
|
+
...extras,
|
|
751
|
+
},
|
|
752
752
|
};
|
|
753
753
|
}
|
|
754
754
|
return this.request(`/brokers/orders/${orderId}`, {
|
|
@@ -1026,7 +1026,7 @@ class ApiClient {
|
|
|
1026
1026
|
return this.request(`/auth/session/${sessionId}/user`, {
|
|
1027
1027
|
method: 'GET',
|
|
1028
1028
|
headers: {
|
|
1029
|
-
|
|
1029
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1030
1030
|
},
|
|
1031
1031
|
});
|
|
1032
1032
|
}
|
|
@@ -1053,12 +1053,9 @@ class ApiClient {
|
|
|
1053
1053
|
}
|
|
1054
1054
|
// Broker Data Management
|
|
1055
1055
|
async getBrokerList() {
|
|
1056
|
-
|
|
1056
|
+
// Public endpoint - no auth required
|
|
1057
1057
|
return this.request('/brokers/', {
|
|
1058
1058
|
method: 'GET',
|
|
1059
|
-
headers: {
|
|
1060
|
-
'Authorization': `Bearer ${accessToken}`,
|
|
1061
|
-
},
|
|
1062
1059
|
});
|
|
1063
1060
|
}
|
|
1064
1061
|
async getBrokerAccounts(options) {
|
|
@@ -1076,7 +1073,7 @@ class ApiClient {
|
|
|
1076
1073
|
return this.request('/brokers/data/accounts', {
|
|
1077
1074
|
method: 'GET',
|
|
1078
1075
|
headers: {
|
|
1079
|
-
|
|
1076
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1080
1077
|
},
|
|
1081
1078
|
params,
|
|
1082
1079
|
});
|
|
@@ -1096,7 +1093,7 @@ class ApiClient {
|
|
|
1096
1093
|
return this.request('/brokers/data/orders', {
|
|
1097
1094
|
method: 'GET',
|
|
1098
1095
|
headers: {
|
|
1099
|
-
|
|
1096
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1100
1097
|
},
|
|
1101
1098
|
params,
|
|
1102
1099
|
});
|
|
@@ -1116,7 +1113,7 @@ class ApiClient {
|
|
|
1116
1113
|
return this.request('/brokers/data/positions', {
|
|
1117
1114
|
method: 'GET',
|
|
1118
1115
|
headers: {
|
|
1119
|
-
|
|
1116
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1120
1117
|
},
|
|
1121
1118
|
params,
|
|
1122
1119
|
});
|
|
@@ -1136,7 +1133,7 @@ class ApiClient {
|
|
|
1136
1133
|
return this.request('/brokers/data/balances', {
|
|
1137
1134
|
method: 'GET',
|
|
1138
1135
|
headers: {
|
|
1139
|
-
|
|
1136
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1140
1137
|
},
|
|
1141
1138
|
params,
|
|
1142
1139
|
});
|
|
@@ -1146,7 +1143,7 @@ class ApiClient {
|
|
|
1146
1143
|
return this.request('/brokers/connections', {
|
|
1147
1144
|
method: 'GET',
|
|
1148
1145
|
headers: {
|
|
1149
|
-
|
|
1146
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1150
1147
|
},
|
|
1151
1148
|
});
|
|
1152
1149
|
}
|
|
@@ -1165,7 +1162,7 @@ class ApiClient {
|
|
|
1165
1162
|
return this.request(url, {
|
|
1166
1163
|
method: 'GET',
|
|
1167
1164
|
headers: {
|
|
1168
|
-
|
|
1165
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1169
1166
|
},
|
|
1170
1167
|
});
|
|
1171
1168
|
}
|
|
@@ -1486,7 +1483,7 @@ class ApiClient {
|
|
|
1486
1483
|
return this.request(`/brokers/disconnect/${connectionId}`, {
|
|
1487
1484
|
method: 'DELETE',
|
|
1488
1485
|
headers: {
|
|
1489
|
-
|
|
1486
|
+
Authorization: `Bearer ${accessToken}`,
|
|
1490
1487
|
},
|
|
1491
1488
|
});
|
|
1492
1489
|
}
|
|
@@ -1549,7 +1546,6 @@ class PortalUI {
|
|
|
1549
1546
|
this.messageHandler = null;
|
|
1550
1547
|
this.sessionId = null;
|
|
1551
1548
|
this.portalOrigin = null;
|
|
1552
|
-
this.userToken = null;
|
|
1553
1549
|
this.originalBodyStyle = null;
|
|
1554
1550
|
this.createContainer();
|
|
1555
1551
|
}
|
|
@@ -1682,9 +1678,11 @@ class PortalUI {
|
|
|
1682
1678
|
case 'portal-success': {
|
|
1683
1679
|
// Handle both direct userId and data.userId formats
|
|
1684
1680
|
const successUserId = userId || (data && data.userId);
|
|
1685
|
-
const
|
|
1686
|
-
|
|
1687
|
-
|
|
1681
|
+
const tokens = {
|
|
1682
|
+
access_token: access_token || (data && data.access_token),
|
|
1683
|
+
refresh_token: refresh_token || (data && data.refresh_token)
|
|
1684
|
+
};
|
|
1685
|
+
this.handlePortalSuccess(successUserId, tokens);
|
|
1688
1686
|
break;
|
|
1689
1687
|
}
|
|
1690
1688
|
case 'portal-error': {
|
|
@@ -1704,7 +1702,7 @@ class PortalUI {
|
|
|
1704
1702
|
break;
|
|
1705
1703
|
// Legacy support for old message types
|
|
1706
1704
|
case 'success':
|
|
1707
|
-
this.handleSuccess(userId
|
|
1705
|
+
this.handleSuccess(userId);
|
|
1708
1706
|
break;
|
|
1709
1707
|
case 'error':
|
|
1710
1708
|
this.handleError(error);
|
|
@@ -1716,30 +1714,17 @@ class PortalUI {
|
|
|
1716
1714
|
console.warn('[PortalUI] Received unhandled message type:', type);
|
|
1717
1715
|
}
|
|
1718
1716
|
}
|
|
1719
|
-
handlePortalSuccess(userId,
|
|
1717
|
+
handlePortalSuccess(userId, tokens) {
|
|
1720
1718
|
if (!userId) {
|
|
1721
1719
|
console.error('[PortalUI] Missing userId in portal-success message');
|
|
1722
1720
|
return;
|
|
1723
1721
|
}
|
|
1724
1722
|
console.log('[PortalUI] Portal success - User connected:', userId);
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
const userToken = {
|
|
1728
|
-
accessToken: accessToken,
|
|
1729
|
-
refreshToken: refreshToken,
|
|
1730
|
-
expiresIn: 3600, // Default to 1 hour
|
|
1731
|
-
user_id: userId,
|
|
1732
|
-
tokenType: 'Bearer',
|
|
1733
|
-
scope: 'api:access',
|
|
1734
|
-
};
|
|
1735
|
-
this.userToken = userToken;
|
|
1736
|
-
console.log('[PortalUI] Portal authentication successful');
|
|
1737
|
-
}
|
|
1738
|
-
else {
|
|
1739
|
-
console.warn('[PortalUI] No tokens received from portal');
|
|
1723
|
+
if (tokens?.access_token && tokens?.refresh_token) {
|
|
1724
|
+
console.log('[PortalUI] Tokens received for user:', userId);
|
|
1740
1725
|
}
|
|
1741
1726
|
// Pass userId to parent (SDK will handle tokens internally)
|
|
1742
|
-
this.options?.onSuccess?.(userId);
|
|
1727
|
+
this.options?.onSuccess?.(userId, tokens);
|
|
1743
1728
|
}
|
|
1744
1729
|
handlePortalError(error) {
|
|
1745
1730
|
console.error('[PortalUI] Portal error:', error);
|
|
@@ -1762,22 +1747,11 @@ class PortalUI {
|
|
|
1762
1747
|
this.options.onEvent(data.type, data.data);
|
|
1763
1748
|
}
|
|
1764
1749
|
}
|
|
1765
|
-
handleSuccess(userId
|
|
1766
|
-
if (!userId
|
|
1750
|
+
handleSuccess(userId) {
|
|
1751
|
+
if (!userId) {
|
|
1767
1752
|
console.error('[PortalUI] Missing required fields in success message');
|
|
1768
1753
|
return;
|
|
1769
1754
|
}
|
|
1770
|
-
// Convert portal tokens to UserToken format
|
|
1771
|
-
const userToken = {
|
|
1772
|
-
accessToken: access_token,
|
|
1773
|
-
refreshToken: refresh_token,
|
|
1774
|
-
expiresIn: 3600, // Default to 1 hour
|
|
1775
|
-
user_id: userId,
|
|
1776
|
-
tokenType: 'Bearer',
|
|
1777
|
-
scope: 'api:access',
|
|
1778
|
-
};
|
|
1779
|
-
// Store tokens internally
|
|
1780
|
-
this.userToken = userToken;
|
|
1781
1755
|
// Pass userId to parent
|
|
1782
1756
|
this.options?.onSuccess?.(userId);
|
|
1783
1757
|
}
|
|
@@ -1796,9 +1770,6 @@ class PortalUI {
|
|
|
1796
1770
|
this.iframe.style.height = `${height}px`;
|
|
1797
1771
|
}
|
|
1798
1772
|
}
|
|
1799
|
-
getTokens() {
|
|
1800
|
-
return this.userToken;
|
|
1801
|
-
}
|
|
1802
1773
|
}
|
|
1803
1774
|
|
|
1804
1775
|
/**
|
|
@@ -2831,7 +2802,7 @@ class MockApiClient {
|
|
|
2831
2802
|
paramsBroker: params.broker,
|
|
2832
2803
|
contextBroker: this.tradingContext.broker,
|
|
2833
2804
|
paramsAccountNumber: params.accountNumber,
|
|
2834
|
-
contextAccountNumber: this.tradingContext.accountNumber
|
|
2805
|
+
contextAccountNumber: this.tradingContext.accountNumber,
|
|
2835
2806
|
});
|
|
2836
2807
|
const fullParams = {
|
|
2837
2808
|
broker: (params.broker || this.tradingContext.broker) ||
|
|
@@ -2894,7 +2865,7 @@ class MockApiClient {
|
|
|
2894
2865
|
console.log('MockApiClient.setAccount Debug:', {
|
|
2895
2866
|
accountNumber,
|
|
2896
2867
|
accountId,
|
|
2897
|
-
previousContext: { ...this.tradingContext }
|
|
2868
|
+
previousContext: { ...this.tradingContext },
|
|
2898
2869
|
});
|
|
2899
2870
|
this.tradingContext.accountNumber = accountNumber;
|
|
2900
2871
|
this.tradingContext.accountId = accountId;
|
|
@@ -3039,7 +3010,7 @@ class MockApiClient {
|
|
|
3039
3010
|
}
|
|
3040
3011
|
// Broker Data Management
|
|
3041
3012
|
async getBrokerList() {
|
|
3042
|
-
|
|
3013
|
+
// Public in mock mode as well - no auth required
|
|
3043
3014
|
return this.mockDataProvider.mockGetBrokerList();
|
|
3044
3015
|
}
|
|
3045
3016
|
async getBrokerAccounts(options) {
|
|
@@ -4483,6 +4454,196 @@ const orangeTheme = {
|
|
|
4483
4454
|
hoverEnd: 'rgba(249, 115, 22, 0.08)',
|
|
4484
4455
|
},
|
|
4485
4456
|
};
|
|
4457
|
+
// StockAlgos theme - Clean professional theme matching StockAlgos website
|
|
4458
|
+
const stockAlgosTheme = {
|
|
4459
|
+
mode: 'light', // Light mode like StockAlgos website
|
|
4460
|
+
colors: {
|
|
4461
|
+
background: {
|
|
4462
|
+
primary: '#FFFFFF', // Clean white background
|
|
4463
|
+
secondary: '#FFFFFF', // Also white for consistency
|
|
4464
|
+
tertiary: '#F8FAFC', // Very light gray for subtle elevation
|
|
4465
|
+
accent: 'rgba(79, 70, 229, 0.05)', // Very subtle blue accent
|
|
4466
|
+
glass: '#FFFFFF', // Pure white, no transparency
|
|
4467
|
+
},
|
|
4468
|
+
status: {
|
|
4469
|
+
connected: '#10B981', // Green for positive/connected
|
|
4470
|
+
disconnected: '#EF4444', // Red for negative/disconnected
|
|
4471
|
+
warning: '#F59E0B', // Amber for warnings
|
|
4472
|
+
pending: '#6366F1', // Indigo for pending states
|
|
4473
|
+
error: '#EF4444', // Red for errors
|
|
4474
|
+
success: '#10B981', // Green for success
|
|
4475
|
+
},
|
|
4476
|
+
text: {
|
|
4477
|
+
primary: '#111827', // Very dark text for maximum contrast
|
|
4478
|
+
secondary: '#374151', // Dark gray for secondary text
|
|
4479
|
+
muted: '#6B7280', // Medium gray for muted text
|
|
4480
|
+
inverse: '#FFFFFF', // White for text on dark backgrounds
|
|
4481
|
+
},
|
|
4482
|
+
border: {
|
|
4483
|
+
primary: '#E5E7EB', // Light gray border
|
|
4484
|
+
secondary: '#F3F4F6', // Very light gray border
|
|
4485
|
+
hover: '#D1D5DB', // Slightly darker on hover
|
|
4486
|
+
focus: '#4F46E5', // Blue focus border
|
|
4487
|
+
accent: '#4F46E5', // Blue accent border
|
|
4488
|
+
},
|
|
4489
|
+
input: {
|
|
4490
|
+
background: '#FFFFFF', // White input background
|
|
4491
|
+
border: '#D1D5DB', // Slightly more visible light gray border
|
|
4492
|
+
borderFocus: '#4F46E5', // Blue focus border
|
|
4493
|
+
text: '#111827', // Darker text for better contrast
|
|
4494
|
+
placeholder: '#6B7280', // Darker placeholder for visibility
|
|
4495
|
+
},
|
|
4496
|
+
button: {
|
|
4497
|
+
primary: {
|
|
4498
|
+
background: '#4F46E5', // Blue primary button
|
|
4499
|
+
text: '#FFFFFF', // White text
|
|
4500
|
+
hover: '#4338CA', // Darker blue on hover
|
|
4501
|
+
active: '#3730A3', // Even darker on active
|
|
4502
|
+
},
|
|
4503
|
+
secondary: {
|
|
4504
|
+
background: '#FFFFFF', // White background
|
|
4505
|
+
text: '#4F46E5', // Blue text
|
|
4506
|
+
border: '#E5E7EB', // Light gray border
|
|
4507
|
+
hover: '#F8FAFC', // Very light gray on hover
|
|
4508
|
+
active: '#F1F5F9', // Light gray on active
|
|
4509
|
+
},
|
|
4510
|
+
},
|
|
4511
|
+
},
|
|
4512
|
+
typography: {
|
|
4513
|
+
fontFamily: {
|
|
4514
|
+
primary: 'Inter, system-ui, -apple-system, sans-serif', // Clean, modern font like StockAlgos
|
|
4515
|
+
secondary: 'Inter, system-ui, -apple-system, sans-serif',
|
|
4516
|
+
},
|
|
4517
|
+
fontSize: {
|
|
4518
|
+
xs: '0.75rem', // 12px
|
|
4519
|
+
sm: '0.875rem', // 14px
|
|
4520
|
+
base: '1rem', // 16px
|
|
4521
|
+
lg: '1.125rem', // 18px
|
|
4522
|
+
xl: '1.25rem', // 20px
|
|
4523
|
+
'2xl': '1.5rem', // 24px
|
|
4524
|
+
'3xl': '1.875rem', // 30px
|
|
4525
|
+
'4xl': '2.25rem', // 36px
|
|
4526
|
+
},
|
|
4527
|
+
fontWeight: {
|
|
4528
|
+
normal: 400,
|
|
4529
|
+
medium: 500,
|
|
4530
|
+
semibold: 600,
|
|
4531
|
+
bold: 700,
|
|
4532
|
+
extrabold: 800,
|
|
4533
|
+
},
|
|
4534
|
+
lineHeight: {
|
|
4535
|
+
tight: '1.25',
|
|
4536
|
+
normal: '1.5',
|
|
4537
|
+
relaxed: '1.75',
|
|
4538
|
+
},
|
|
4539
|
+
},
|
|
4540
|
+
spacing: {
|
|
4541
|
+
xs: '0.25rem', // 4px
|
|
4542
|
+
sm: '0.5rem', // 8px
|
|
4543
|
+
md: '1rem', // 16px
|
|
4544
|
+
lg: '1.5rem', // 24px
|
|
4545
|
+
xl: '2rem', // 32px
|
|
4546
|
+
'2xl': '3rem', // 48px
|
|
4547
|
+
'3xl': '4rem', // 64px
|
|
4548
|
+
},
|
|
4549
|
+
layout: {
|
|
4550
|
+
containerMaxWidth: '1440px',
|
|
4551
|
+
gridGap: '1rem',
|
|
4552
|
+
cardPadding: '1.5rem',
|
|
4553
|
+
borderRadius: {
|
|
4554
|
+
sm: '0.25rem', // 4px
|
|
4555
|
+
md: '0.5rem', // 8px
|
|
4556
|
+
lg: '0.75rem', // 12px
|
|
4557
|
+
xl: '1rem', // 16px
|
|
4558
|
+
'2xl': '1.5rem', // 24px
|
|
4559
|
+
full: '9999px',
|
|
4560
|
+
},
|
|
4561
|
+
},
|
|
4562
|
+
components: {
|
|
4563
|
+
brokerCard: {
|
|
4564
|
+
width: '100%',
|
|
4565
|
+
height: '180px',
|
|
4566
|
+
logoSize: '64px',
|
|
4567
|
+
padding: '1.5rem',
|
|
4568
|
+
},
|
|
4569
|
+
statusIndicator: {
|
|
4570
|
+
size: '22px',
|
|
4571
|
+
glowIntensity: 0.1, // Minimal glow for clean look
|
|
4572
|
+
},
|
|
4573
|
+
modal: {
|
|
4574
|
+
background: '#FFFFFF', // Pure white modal background
|
|
4575
|
+
backdrop: 'rgba(0, 0, 0, 0.4)', // Lighter backdrop
|
|
4576
|
+
},
|
|
4577
|
+
brokerCardModern: {
|
|
4578
|
+
width: '150px',
|
|
4579
|
+
height: '150px',
|
|
4580
|
+
padding: '16px',
|
|
4581
|
+
logoSize: '48px',
|
|
4582
|
+
statusSize: '22px',
|
|
4583
|
+
},
|
|
4584
|
+
connectButton: {
|
|
4585
|
+
width: '120px',
|
|
4586
|
+
height: '120px',
|
|
4587
|
+
},
|
|
4588
|
+
themeSwitcher: {
|
|
4589
|
+
indicatorSize: '24px',
|
|
4590
|
+
},
|
|
4591
|
+
},
|
|
4592
|
+
effects: {
|
|
4593
|
+
glassmorphism: {
|
|
4594
|
+
enabled: false, // Disable glass effects for clean look
|
|
4595
|
+
blur: '0px',
|
|
4596
|
+
opacity: 0,
|
|
4597
|
+
border: 'rgba(0, 0, 0, 0.1)',
|
|
4598
|
+
},
|
|
4599
|
+
animations: {
|
|
4600
|
+
enabled: true,
|
|
4601
|
+
duration: {
|
|
4602
|
+
fast: '150ms',
|
|
4603
|
+
normal: '200ms', // Faster, more subtle animations
|
|
4604
|
+
slow: '300ms',
|
|
4605
|
+
},
|
|
4606
|
+
easing: {
|
|
4607
|
+
default: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
4608
|
+
smooth: 'cubic-bezier(0.25, 0.46, 0.45, 0.94)',
|
|
4609
|
+
bounce: 'cubic-bezier(0.68, -0.55, 0.265, 1.55)',
|
|
4610
|
+
},
|
|
4611
|
+
},
|
|
4612
|
+
shadows: {
|
|
4613
|
+
sm: '0 1px 2px rgba(0, 0, 0, 0.05)', // Very subtle shadows
|
|
4614
|
+
md: '0 4px 6px rgba(0, 0, 0, 0.07)',
|
|
4615
|
+
lg: '0 10px 15px rgba(0, 0, 0, 0.1)',
|
|
4616
|
+
xl: '0 20px 25px rgba(0, 0, 0, 0.1)',
|
|
4617
|
+
card: '0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06)', // Clean card shadow
|
|
4618
|
+
cardHover: '0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06)', // Subtle hover shadow
|
|
4619
|
+
glow: '0 0 0px transparent', // No glow effects
|
|
4620
|
+
focus: '0 0 0 3px rgba(79, 70, 229, 0.1)', // Subtle focus ring
|
|
4621
|
+
},
|
|
4622
|
+
},
|
|
4623
|
+
branding: {
|
|
4624
|
+
logo: '/stockalgos-logo.png', // Custom logo path
|
|
4625
|
+
companyName: 'StockAlgos', // Company name
|
|
4626
|
+
favicon: '/stockalgos-favicon.ico', // Custom favicon
|
|
4627
|
+
primaryColor: '#4F46E5', // Indigo brand color
|
|
4628
|
+
},
|
|
4629
|
+
// Minimal glow effects
|
|
4630
|
+
glow: {
|
|
4631
|
+
primary: 'transparent',
|
|
4632
|
+
secondary: 'transparent',
|
|
4633
|
+
card: 'transparent',
|
|
4634
|
+
cardHover: 'rgba(79, 70, 229, 0.05)', // Very subtle
|
|
4635
|
+
button: 'transparent',
|
|
4636
|
+
focus: 'rgba(79, 70, 229, 0.1)',
|
|
4637
|
+
scrollbar: 'transparent',
|
|
4638
|
+
},
|
|
4639
|
+
// Minimal gradients
|
|
4640
|
+
gradients: {
|
|
4641
|
+
start: 'rgba(79, 70, 229, 0.02)',
|
|
4642
|
+
end: 'rgba(79, 70, 229, 0.01)',
|
|
4643
|
+
hoverStart: 'rgba(79, 70, 229, 0.05)',
|
|
4644
|
+
hoverEnd: 'rgba(79, 70, 229, 0.02)',
|
|
4645
|
+
},
|
|
4646
|
+
};
|
|
4486
4647
|
// Theme preset mapping
|
|
4487
4648
|
const portalThemePresets = {
|
|
4488
4649
|
dark: darkTheme,
|
|
@@ -4491,6 +4652,7 @@ const portalThemePresets = {
|
|
|
4491
4652
|
purple: purpleTheme,
|
|
4492
4653
|
green: greenTheme,
|
|
4493
4654
|
orange: orangeTheme,
|
|
4655
|
+
stockAlgos: stockAlgosTheme,
|
|
4494
4656
|
};
|
|
4495
4657
|
|
|
4496
4658
|
/**
|
|
@@ -4942,7 +5104,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
4942
5104
|
expires_in: this.userToken.expiresIn,
|
|
4943
5105
|
token_type: this.userToken.tokenType,
|
|
4944
5106
|
scope: this.userToken.scope,
|
|
4945
|
-
company_id: this.companyId
|
|
5107
|
+
company_id: this.companyId,
|
|
4946
5108
|
};
|
|
4947
5109
|
}
|
|
4948
5110
|
async initializeWithUser(userId) {
|
|
@@ -5018,21 +5180,15 @@ class FinaticConnect extends EventEmitter {
|
|
|
5018
5180
|
}
|
|
5019
5181
|
// Show portal
|
|
5020
5182
|
this.portalUI.show(themedPortalUrl, this.sessionId || '', {
|
|
5021
|
-
onSuccess: async (userId) => {
|
|
5183
|
+
onSuccess: async (userId, tokens) => {
|
|
5022
5184
|
try {
|
|
5023
5185
|
if (!this.sessionId) {
|
|
5024
5186
|
throw new SessionError('Session not initialized');
|
|
5025
5187
|
}
|
|
5026
|
-
//
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
throw new Error('No tokens received from portal');
|
|
5188
|
+
// Handle tokens if provided
|
|
5189
|
+
if (tokens?.access_token && tokens?.refresh_token) {
|
|
5190
|
+
this.handleTokens(tokens);
|
|
5030
5191
|
}
|
|
5031
|
-
// Set the tokens internally
|
|
5032
|
-
this.userToken = userToken;
|
|
5033
|
-
// Set tokens in ApiClient for automatic token management
|
|
5034
|
-
const expiresAt = new Date(Date.now() + 3600 * 1000).toISOString(); // 1 hour from now
|
|
5035
|
-
this.apiClient.setTokens(userToken.accessToken, userToken.refreshToken, expiresAt, userId);
|
|
5036
5192
|
// Emit portal success event
|
|
5037
5193
|
this.emit('portal:success', userId);
|
|
5038
5194
|
// Emit legacy success event
|
|
@@ -5213,7 +5369,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
5213
5369
|
* Set the broker context for trading
|
|
5214
5370
|
* @param broker - The broker to use for trading
|
|
5215
5371
|
*/
|
|
5216
|
-
|
|
5372
|
+
setTradingContextBroker(broker) {
|
|
5217
5373
|
this.apiClient.setBroker(broker);
|
|
5218
5374
|
}
|
|
5219
5375
|
/**
|
|
@@ -5221,7 +5377,7 @@ class FinaticConnect extends EventEmitter {
|
|
|
5221
5377
|
* @param accountNumber - The account number to use for trading
|
|
5222
5378
|
* @param accountId - Optional account ID
|
|
5223
5379
|
*/
|
|
5224
|
-
|
|
5380
|
+
setTradingContextAccount(accountNumber, accountId) {
|
|
5225
5381
|
this.apiClient.setAccount(accountNumber, accountId);
|
|
5226
5382
|
}
|
|
5227
5383
|
/**
|
|
@@ -5371,33 +5527,6 @@ class FinaticConnect extends EventEmitter {
|
|
|
5371
5527
|
throw error;
|
|
5372
5528
|
}
|
|
5373
5529
|
}
|
|
5374
|
-
/**
|
|
5375
|
-
* Set the broker context for trading operations
|
|
5376
|
-
* @param broker - The broker to set as context
|
|
5377
|
-
*/
|
|
5378
|
-
setBroker(broker) {
|
|
5379
|
-
this.apiClient.setBroker(broker);
|
|
5380
|
-
}
|
|
5381
|
-
/**
|
|
5382
|
-
* Set the account context for trading operations
|
|
5383
|
-
* @param accountNumber - The account number to set as context
|
|
5384
|
-
*/
|
|
5385
|
-
setAccount(accountNumber) {
|
|
5386
|
-
this.apiClient.setAccount(accountNumber);
|
|
5387
|
-
}
|
|
5388
|
-
/**
|
|
5389
|
-
* Get the current trading context
|
|
5390
|
-
* @returns Object with current broker and account context
|
|
5391
|
-
*/
|
|
5392
|
-
getTradingContext() {
|
|
5393
|
-
return this.apiClient.getTradingContext();
|
|
5394
|
-
}
|
|
5395
|
-
/**
|
|
5396
|
-
* Clear the trading context
|
|
5397
|
-
*/
|
|
5398
|
-
clearTradingContext() {
|
|
5399
|
-
this.apiClient.clearTradingContext();
|
|
5400
|
-
}
|
|
5401
5530
|
/**
|
|
5402
5531
|
* Get the current user ID
|
|
5403
5532
|
* @returns The current user ID or undefined if not authenticated
|
|
@@ -5417,9 +5546,9 @@ class FinaticConnect extends EventEmitter {
|
|
|
5417
5546
|
* @returns Promise with array of broker information
|
|
5418
5547
|
*/
|
|
5419
5548
|
async getBrokerList() {
|
|
5420
|
-
if (!this.isAuthed()) {
|
|
5421
|
-
|
|
5422
|
-
}
|
|
5549
|
+
// if (!this.isAuthed()) {
|
|
5550
|
+
// throw new AuthenticationError('Not authenticated');
|
|
5551
|
+
// }
|
|
5423
5552
|
const response = await this.apiClient.getBrokerList();
|
|
5424
5553
|
const baseUrl = this.baseUrl.replace('/api/v1', ''); // Remove /api/v1 to get the base URL
|
|
5425
5554
|
// Transform the broker list to include full logo URLs
|