@@ -22,6 +22,8 @@ import {Capability, KnownWidgetActions, WidgetApi} from 'matrix-react-sdk/src/wi
22
22
import { KJUR } from 'jsrsasign' ;
23
23
import { objectClone } from 'matrix-react-sdk/src/utils/objects' ;
24
24
25
+ const JITSI_OPENIDTOKEN_JWT_AUTH = 'openidtoken-jwt' ;
26
+
25
27
// Dev note: we use raw JS without many dependencies to reduce bundle size.
26
28
// We do not need all of React to render a Jitsi conference.
27
29
@@ -82,7 +84,7 @@ let widgetApi: WidgetApi;
82
84
await widgetApi . setAlwaysOnScreen ( false ) ; // start off as detachable from the screen
83
85
84
86
// See https://github.com/matrix-org/prosody-mod-auth-matrix-user-verification
85
- if ( jitsiAuth === 'openidtoken-jwt' ) {
87
+ if ( jitsiAuth === JITSI_OPENIDTOKEN_JWT_AUTH ) {
86
88
window . addEventListener ( 'message' , onWidgetMessage ) ;
87
89
widgetApi . callAction (
88
90
KnownWidgetActions . GetOpenIDCredentials ,
@@ -103,14 +105,14 @@ let widgetApi: WidgetApi;
103
105
} ) ( ) ;
104
106
105
107
function processOpenIDMessage ( msg ) {
106
- const data = ( msg . action === 'get_openid' ) ? msg . response : msg . data ;
108
+ const data = ( msg . action === KnownWidgetActions . GetOpenIDCredentials ) ? msg . response : msg . data ;
107
109
108
110
switch ( data . state ) {
109
111
case 'allowed' :
110
112
console . info ( 'Successfully got OpenID credentials.' ) ;
111
113
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 ) {
114
116
const request = objectClone ( msg ) ;
115
117
request . response = { } ;
116
118
window . parent . postMessage ( request , '*' ) ;
@@ -135,8 +137,8 @@ function onWidgetMessage(msg) {
135
137
return ;
136
138
}
137
139
switch ( data . action ) {
138
- case 'get_openid' :
139
- case 'openid_credentials' :
140
+ case KnownWidgetActions . GetOpenIDCredentials :
141
+ case KnownWidgetActions . ReceiveOpenIDCredentials :
140
142
processOpenIDMessage ( data ) ;
141
143
break ;
142
144
default :
@@ -217,7 +219,7 @@ function joinConference() { // event handler bound in HTML
217
219
} ,
218
220
jwt : undefined ,
219
221
} ;
220
- if ( jitsiAuth === 'openidtoken-jwt' ) {
222
+ if ( jitsiAuth === JITSI_OPENIDTOKEN_JWT_AUTH ) {
221
223
options . jwt = createJWTToken ( ) ;
222
224
}
223
225
const meetApi = new JitsiMeetExternalAPI ( jitsiDomain , options ) ;
0 commit comments