1- import {
2- Authorizer , createErrorMessage , ForbiddenHttpError , getLoggerFor , UnauthorizedHttpError
1+ import {
2+ Authorizer , createErrorMessage , ForbiddenHttpError , getLoggerFor , InternalServerError , UnauthorizedHttpError
33} from '@solid/community-server' ;
44import type { AccessMap , AuthorizerInput } from '@solid/community-server' ;
55import { OwnerUtil } from '../util/OwnerUtil' ;
@@ -30,25 +30,25 @@ export class UmaAuthorizer extends Authorizer {
3030 */
3131 public constructor (
3232 protected authorizer : Authorizer ,
33- protected ownerUtil : OwnerUtil ,
33+ protected ownerUtil : OwnerUtil ,
3434 protected umaClient : UmaClient ,
3535 ) {
3636 super ( ) ;
3737 }
3838
3939 public async handle ( input : AuthorizerInput ) : Promise < void > {
4040 try {
41-
41+
4242 // Try authorizer
4343 await this . authorizer . handleSafe ( input ) ;
4444 } catch ( error : unknown ) {
4545
4646 // Unless 403/403 throw original error
4747 if ( ! UnauthorizedHttpError . isInstance ( error ) && ! ForbiddenHttpError . isInstance ( error ) ) throw error ;
48-
48+
4949 // Request UMA ticket
5050 const authHeader = await this . requestTicket ( input . requestedModes ) ;
51-
51+
5252 // Add auth header to error metadata if private
5353 if ( authHeader ) {
5454 error . metadata . add ( WWW_AUTH , literal ( authHeader ) ) ;
@@ -65,14 +65,14 @@ export class UmaAuthorizer extends Authorizer {
6565 const owner = await this . ownerUtil . findCommonOwner ( requestedModes . keys ( ) ) ;
6666 const issuer = await this . ownerUtil . findIssuer ( owner ) ;
6767
68- if ( ! issuer ) throw new Error ( `No UMA authorization server found for ${ owner } .` ) ;
68+ if ( ! issuer ) throw new InternalServerError ( `No UMA authorization server found for ${ owner } .` ) ;
6969
7070 try {
7171 const ticket = await this . umaClient . fetchTicket ( requestedModes , issuer ) ;
7272 return ticket ? `UMA realm="solid", as_uri="${ issuer } ", ticket="${ ticket } "` : undefined ;
7373 } catch ( e ) {
7474 this . logger . error ( `Error while requesting UMA header: ${ ( e as Error ) . message } ` ) ;
75- throw new Error ( ' Error while requesting UMA header.' ) ;
75+ throw new InternalServerError ( ` Error while requesting UMA header: ${ ( e as Error ) . message } .` ) ;
7676 }
7777 }
7878}
0 commit comments