@truly-you/trulyyou-web-sdk 0.1.20 → 0.1.21
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.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/sdk/TrulyYouSDK.ts +20 -7
package/package.json
CHANGED
package/src/sdk/TrulyYouSDK.ts
CHANGED
|
@@ -8,7 +8,7 @@ export class TrulyYouSDK {
|
|
|
8
8
|
private authAppId: string | undefined
|
|
9
9
|
private invisible: boolean
|
|
10
10
|
private targetElement: string | HTMLElement | undefined
|
|
11
|
-
private brandingCache: { primary?: string; background?: string; secondary?: string; textColor?: string; icon?: string; name?: string; authFlowId?: string } | null = null
|
|
11
|
+
private brandingCache: { primary?: string; background?: string; secondary?: string; textColor?: string; icon?: string; name?: string; authFlowId?: string; pusher?: { realtimeUrl?: string; appKey?: string } } | null = null
|
|
12
12
|
private realtimeUrl: string
|
|
13
13
|
private mockMobileDevice: boolean
|
|
14
14
|
|
|
@@ -89,7 +89,13 @@ export class TrulyYouSDK {
|
|
|
89
89
|
textColor: app.colors?.textColor,
|
|
90
90
|
icon: app.icon,
|
|
91
91
|
name: app.name,
|
|
92
|
-
authFlowId: app.authFlowId
|
|
92
|
+
authFlowId: app.authFlowId,
|
|
93
|
+
...(app.pusher && {
|
|
94
|
+
pusher: {
|
|
95
|
+
realtimeUrl: app.pusher.realtimeUrl,
|
|
96
|
+
appKey: app.pusher.appKey
|
|
97
|
+
}
|
|
98
|
+
})
|
|
93
99
|
}
|
|
94
100
|
console.log('[SDK]: Branding and authFlowId fetched and cached:', this.brandingCache)
|
|
95
101
|
return !!app.authFlowId
|
|
@@ -1016,6 +1022,11 @@ export class TrulyYouSDK {
|
|
|
1016
1022
|
apiCallStructure: apiCallStructure
|
|
1017
1023
|
}
|
|
1018
1024
|
|
|
1025
|
+
// Get Pusher config from branding cache (from API) or fall back to config/constructor values
|
|
1026
|
+
const pusherConfigFromBranding = this.brandingCache?.pusher
|
|
1027
|
+
const realtimeUrlToUse = pusherConfigFromBranding?.realtimeUrl || this.realtimeUrl
|
|
1028
|
+
const pusherAppKeyToUse = pusherConfigFromBranding?.appKey || this.config.pusherAppKey || 'app-key'
|
|
1029
|
+
|
|
1019
1030
|
// Parse realtimeUrl to extract host/port for Pusher
|
|
1020
1031
|
let pusherHost: string | undefined
|
|
1021
1032
|
let pusherPort: number | undefined
|
|
@@ -1023,9 +1034,9 @@ export class TrulyYouSDK {
|
|
|
1023
1034
|
let encrypted = true
|
|
1024
1035
|
|
|
1025
1036
|
try {
|
|
1026
|
-
const realtimeUrlObj = new URL(
|
|
1027
|
-
?
|
|
1028
|
-
:
|
|
1037
|
+
const realtimeUrlObj = new URL(realtimeUrlToUse.startsWith('ws://') || realtimeUrlToUse.startsWith('wss://')
|
|
1038
|
+
? realtimeUrlToUse
|
|
1039
|
+
: realtimeUrlToUse.replace(/^http:/, 'ws:').replace(/^https:/, 'wss:'))
|
|
1029
1040
|
|
|
1030
1041
|
pusherHost = realtimeUrlObj.hostname
|
|
1031
1042
|
pusherPort = realtimeUrlObj.port ? parseInt(realtimeUrlObj.port, 10) : (realtimeUrlObj.protocol === 'wss:' ? 443 : 80)
|
|
@@ -1037,8 +1048,8 @@ export class TrulyYouSDK {
|
|
|
1037
1048
|
pusherPort = 6001
|
|
1038
1049
|
}
|
|
1039
1050
|
|
|
1040
|
-
// Get Pusher app key from config or
|
|
1041
|
-
const pusherAppKey =
|
|
1051
|
+
// Get Pusher app key from branding cache, config, or default
|
|
1052
|
+
const pusherAppKey = pusherAppKeyToUse
|
|
1042
1053
|
|
|
1043
1054
|
// Merge custom Pusher config with parsed values
|
|
1044
1055
|
// When using custom wsHost/wsPort, we need to set cluster to empty string to disable default cluster behavior
|
|
@@ -1053,6 +1064,8 @@ export class TrulyYouSDK {
|
|
|
1053
1064
|
}
|
|
1054
1065
|
|
|
1055
1066
|
console.log('[SDK]: Initializing Pusher with config:', pusherOptions)
|
|
1067
|
+
console.log('[SDK]: Pusher app key:', pusherAppKey ? `${pusherAppKey.substring(0, 10)}...` : 'not set')
|
|
1068
|
+
console.log('[SDK]: Pusher config source:', pusherConfigFromBranding ? 'branding API' : (this.config.pusherAppKey ? 'constructor config' : 'default'))
|
|
1056
1069
|
const pusher = new Pusher(pusherAppKey, pusherOptions)
|
|
1057
1070
|
|
|
1058
1071
|
// Use signatureId as the channel name (Soketi doesn't need 'public-' prefix)
|