@@ -519,8 +519,12 @@ export class AuthController {
519
519
console . error ( 'Error creating default user applications!' , e ) ;
520
520
}
521
521
522
- await this . _notifyConductorOfNewUser ( foundUser ) ;
523
- await this . _notifyADAPTOfNewUser ( foundUser ) ;
522
+ const webhookPromises = [
523
+ this . _notifyConductorOfNewUser ( foundUser ) ,
524
+ this . _notifyADAPTOfNewUser ( foundUser )
525
+ ] ;
526
+
527
+ await Promise . all ( webhookPromises ) ; // both return false and log if failed, so they shouldn't affect each other
524
528
525
529
let shouldCreateSSOSession = true ;
526
530
let redirectCASService = null ;
@@ -1155,11 +1159,14 @@ export class AuthController {
1155
1159
}
1156
1160
}
1157
1161
1158
- private _getADAPTWebhookHeaders ( ) {
1162
+ private async _getADAPTWebhookHeaders ( ) {
1163
+ const encoded = new TextEncoder ( ) . encode ( process . env . ADAPT_API_KEY ?? 'unknown' ) ;
1164
+ const jwtToSend = await new SignJWT ( { } ) . setProtectedHeader ( { alg : 'HS256' , typ : 'JWT' } ) . setIssuedAt ( ) . setExpirationTime ( '1h' ) . sign ( encoded ) ;
1165
+
1159
1166
return {
1160
1167
'Content-Type' : 'application/json' ,
1161
1168
'X-Requested-With' : 'XMLHttpRequest' ,
1162
- 'Authorization' : `Bearer ${ process . env . ADAPT_API_KEY } ` ,
1169
+ 'Authorization' : `Bearer ${ jwtToSend } ` ,
1163
1170
'Origin' : process . env . PRODUCTION_DOMAIN ?? process . env . DOMAIN ?? 'one.libretexts.org' ,
1164
1171
} ;
1165
1172
}
@@ -1183,7 +1190,7 @@ export class AuthController {
1183
1190
} ;
1184
1191
1185
1192
const res = await axios . post ( adaptWebhookURL , payload , {
1186
- headers : this . _getADAPTWebhookHeaders ( ) ,
1193
+ headers : await this . _getADAPTWebhookHeaders ( ) ,
1187
1194
} ) ;
1188
1195
1189
1196
if ( res . data . err ) {
@@ -1211,7 +1218,7 @@ export class AuthController {
1211
1218
} ;
1212
1219
1213
1220
const res = await axios . post ( adaptWebhookURL , payload , {
1214
- headers : this . _getADAPTWebhookHeaders ( ) ,
1221
+ headers : await this . _getADAPTWebhookHeaders ( ) ,
1215
1222
} ) ;
1216
1223
1217
1224
if ( res . data . err ) {
0 commit comments