File tree 1 file changed +16
-3
lines changed
tools/diagnostics-app/src/components/widgets
1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -155,10 +155,23 @@ function getTokenEndpoint(token: string) {
155
155
try {
156
156
const [ head , body , signature ] = token . split ( '.' ) ;
157
157
const payload = JSON . parse ( atob ( body ) ) ;
158
- const aud = payload . aud as string | undefined ;
159
- if ( aud ?. endsWith ( '.journeyapps.com' ) ) {
160
- return aud ;
158
+ const aud = payload . aud as string | string [ ] | undefined ;
159
+ const audiences = Array . isArray ( aud ) ? aud : [ aud ] ;
160
+
161
+ // Prioritize public powersync URL
162
+ for ( let aud of audiences ) {
163
+ if ( aud ?. match ( / ^ h t t p s ? : .* .j o u r n e y a p p s .c o m / ) ) {
164
+ return aud ;
165
+ }
166
+ }
167
+
168
+ // Fallback to any URL
169
+ for ( let aud of audiences ) {
170
+ if ( aud ?. match ( / ^ h t t p s ? : / ) ) {
171
+ return aud ;
172
+ }
161
173
}
174
+
162
175
return null ;
163
176
} catch ( e ) {
164
177
return null ;
You can’t perform that action at this time.
0 commit comments