@finatic/client 0.0.138 → 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 +4 -1
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -5
- package/dist/index.mjs.map +1 -1
- 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 */
|
package/dist/index.js
CHANGED
|
@@ -1672,13 +1672,17 @@ class PortalUI {
|
|
|
1672
1672
|
console.warn('[PortalUI] Received message from unauthorized origin:', event.origin, 'Expected:', this.portalOrigin);
|
|
1673
1673
|
return;
|
|
1674
1674
|
}
|
|
1675
|
-
const { type, userId, error, height, data } = event.data;
|
|
1675
|
+
const { type, userId, access_token, refresh_token, error, height, data } = event.data;
|
|
1676
1676
|
console.log('[PortalUI] Received message:', event.data);
|
|
1677
1677
|
switch (type) {
|
|
1678
1678
|
case 'portal-success': {
|
|
1679
1679
|
// Handle both direct userId and data.userId formats
|
|
1680
1680
|
const successUserId = userId || (data && data.userId);
|
|
1681
|
-
|
|
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);
|
|
1682
1686
|
break;
|
|
1683
1687
|
}
|
|
1684
1688
|
case 'portal-error': {
|
|
@@ -1710,14 +1714,17 @@ class PortalUI {
|
|
|
1710
1714
|
console.warn('[PortalUI] Received unhandled message type:', type);
|
|
1711
1715
|
}
|
|
1712
1716
|
}
|
|
1713
|
-
handlePortalSuccess(userId) {
|
|
1717
|
+
handlePortalSuccess(userId, tokens) {
|
|
1714
1718
|
if (!userId) {
|
|
1715
1719
|
console.error('[PortalUI] Missing userId in portal-success message');
|
|
1716
1720
|
return;
|
|
1717
1721
|
}
|
|
1718
1722
|
console.log('[PortalUI] Portal success - User connected:', userId);
|
|
1723
|
+
if (tokens?.access_token && tokens?.refresh_token) {
|
|
1724
|
+
console.log('[PortalUI] Tokens received for user:', userId);
|
|
1725
|
+
}
|
|
1719
1726
|
// Pass userId to parent (SDK will handle tokens internally)
|
|
1720
|
-
this.options?.onSuccess?.(userId);
|
|
1727
|
+
this.options?.onSuccess?.(userId, tokens);
|
|
1721
1728
|
}
|
|
1722
1729
|
handlePortalError(error) {
|
|
1723
1730
|
console.error('[PortalUI] Portal error:', error);
|
|
@@ -5173,11 +5180,15 @@ class FinaticConnect extends EventEmitter {
|
|
|
5173
5180
|
}
|
|
5174
5181
|
// Show portal
|
|
5175
5182
|
this.portalUI.show(themedPortalUrl, this.sessionId || '', {
|
|
5176
|
-
onSuccess: async (userId) => {
|
|
5183
|
+
onSuccess: async (userId, tokens) => {
|
|
5177
5184
|
try {
|
|
5178
5185
|
if (!this.sessionId) {
|
|
5179
5186
|
throw new SessionError('Session not initialized');
|
|
5180
5187
|
}
|
|
5188
|
+
// Handle tokens if provided
|
|
5189
|
+
if (tokens?.access_token && tokens?.refresh_token) {
|
|
5190
|
+
this.handleTokens(tokens);
|
|
5191
|
+
}
|
|
5181
5192
|
// Emit portal success event
|
|
5182
5193
|
this.emit('portal:success', userId);
|
|
5183
5194
|
// Emit legacy success event
|