@@ -22,6 +22,8 @@ import {Capability, KnownWidgetActions, WidgetApi} from 'matrix-react-sdk/src/wi
2222import { KJUR } from 'jsrsasign' ;
2323import { objectClone } from 'matrix-react-sdk/src/utils/objects' ;
2424
25+ const JITSI_OPENIDTOKEN_JWT_AUTH = 'openidtoken-jwt' ;
26+
2527// Dev note: we use raw JS without many dependencies to reduce bundle size.
2628// We do not need all of React to render a Jitsi conference.
2729
@@ -82,7 +84,7 @@ let widgetApi: WidgetApi;
8284 await widgetApi . setAlwaysOnScreen ( false ) ; // start off as detachable from the screen
8385
8486 // See https://github.com/matrix-org/prosody-mod-auth-matrix-user-verification
85- if ( jitsiAuth === 'openidtoken-jwt' ) {
87+ if ( jitsiAuth === JITSI_OPENIDTOKEN_JWT_AUTH ) {
8688 window . addEventListener ( 'message' , onWidgetMessage ) ;
8789 widgetApi . callAction (
8890 KnownWidgetActions . GetOpenIDCredentials ,
@@ -103,14 +105,14 @@ let widgetApi: WidgetApi;
103105} ) ( ) ;
104106
105107function processOpenIDMessage ( msg ) {
106- const data = ( msg . action === 'get_openid' ) ? msg . response : msg . data ;
108+ const data = ( msg . action === KnownWidgetActions . GetOpenIDCredentials ) ? msg . response : msg . data ;
107109
108110 switch ( data . state ) {
109111 case 'allowed' :
110112 console . info ( 'Successfully got OpenID credentials.' ) ;
111113 openIDToken = data . access_token ;
112- // Send a response if this was not a response
113- if ( msg . action === 'openid_credentials' ) {
114+ // Send a response if this was not a response to GetOpenIDCredentials
115+ if ( msg . action === KnownWidgetActions . ReceiveOpenIDCredentials ) {
114116 const request = objectClone ( msg ) ;
115117 request . response = { } ;
116118 window . parent . postMessage ( request , '*' ) ;
@@ -135,8 +137,8 @@ function onWidgetMessage(msg) {
135137 return ;
136138 }
137139 switch ( data . action ) {
138- case 'get_openid' :
139- case 'openid_credentials' :
140+ case KnownWidgetActions . GetOpenIDCredentials :
141+ case KnownWidgetActions . ReceiveOpenIDCredentials :
140142 processOpenIDMessage ( data ) ;
141143 break ;
142144 default :
@@ -217,7 +219,7 @@ function joinConference() { // event handler bound in HTML
217219 } ,
218220 jwt : undefined ,
219221 } ;
220- if ( jitsiAuth === 'openidtoken-jwt' ) {
222+ if ( jitsiAuth === JITSI_OPENIDTOKEN_JWT_AUTH ) {
221223 options . jwt = createJWTToken ( ) ;
222224 }
223225 const meetApi = new JitsiMeetExternalAPI ( jitsiDomain , options ) ;
0 commit comments