File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
tools/diagnostics-app/src/components/widgets Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @powersync/diagnostics-app ' : patch
3+ ---
4+
5+ Improve extracting endpoint from token audience.
Original file line number Diff line number Diff line change @@ -155,10 +155,23 @@ function getTokenEndpoint(token: string) {
155155 try {
156156 const [ head , body , signature ] = token . split ( '.' ) ;
157157 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+ }
161173 }
174+
162175 return null ;
163176 } catch ( e ) {
164177 return null ;
You can’t perform that action at this time.
0 commit comments