1- import { getLoggerFor , PermissionReader , PermissionReaderInput ,
1+ import { getLoggerFor , PermissionReader , PermissionReaderInput ,
22PermissionMap , PermissionSet , IdentifierMap } from '@solid/community-server' ;
33import { UmaClaims } from '../uma/UmaClient' ;
44
@@ -20,25 +20,25 @@ export class UmaPermissionReader extends PermissionReader {
2020 const { permissions, iat : t_iat , exp : t_exp , nbf : t_nbf } = rpt ;
2121
2222 this . logger . info ( `Reading UMA permissions at ${ now } ` ) ;
23-
23+
2424 try {
2525 if ( t_iat && t_iat >= now ) throw new Error ( `Token seems to be issued in the future at ${ t_iat } .` ) ;
2626 if ( t_exp && t_exp <= now ) throw new Error ( `Token is expired since ${ t_exp } .` ) ;
2727 if ( t_nbf && t_nbf > now ) throw new Error ( `Token is not valid before ${ t_nbf } .` ) ;
28- } catch ( error ) {
28+ } catch ( error ) {
2929 this . logger . warn ( `Invalid UMA token: ${ error instanceof Error ? error . message : '' } ` ) ;
3030 return result ;
3131 }
32-
32+
3333 for ( const { resource_id, resource_scopes, iat : p_iat , exp : p_exp , nbf : p_nbf } of permissions ?? [ ] ) {
3434 const permissionSet = Object . fromEntries ( resource_scopes . map ( scope => {
3535 try {
3636 if ( p_iat && p_iat >= now ) throw new Error ( `UMA permission seems to be issued in the future at ${ p_iat } .` ) ;
3737 if ( p_exp && p_exp <= now ) throw new Error ( `UMA permission is expired since ${ p_exp } .` ) ;
3838 if ( p_nbf && p_nbf > now ) throw new Error ( `UMA permission is not valid before ${ p_nbf } .` ) ;
39- } catch ( error ) {
39+ } catch ( error ) {
4040 this . logger . warn ( `Invalid UMA permission: ${ error instanceof Error ? error . message : '' } ` ) ;
41- return [ scope , false ] ;
41+ return [ scope . replace ( 'urn:example:css:modes:' , '' ) , false ] ;
4242 }
4343 return [ scope . replace ( 'urn:example:css:modes:' , '' ) , true ] ;
4444 } ) ) ;
0 commit comments