44 getLoggerFor ,
55 KeyValueStorage ,
66 MethodNotAllowedHttpError ,
7- UnauthorizedHttpError ,
8- UnsupportedMediaTypeHttpError
7+ UnauthorizedHttpError
98} from '@solid/community-server' ;
109import { randomUUID } from 'node:crypto' ;
1110import {
@@ -14,9 +13,9 @@ import {
1413 HttpHandlerRequest ,
1514 HttpHandlerResponse
1615} from '../util/http/models/HttpHandler' ;
17- import { ResourceDescription } from '../views/ResourceDescription' ;
18- import { reType } from '../util/ReType' ;
1916import { extractRequestSigner , verifyRequest } from '../util/HttpMessageSignatures' ;
17+ import { reType } from '../util/ReType' ;
18+ import { ResourceDescription } from '../views/ResourceDescription' ;
2019
2120/**
2221 * A ResourceRegistrationRequestHandler is tasked with implementing
@@ -27,20 +26,12 @@ import { extractRequestSigner, verifyRequest } from '../util/HttpMessageSignatur
2726export class ResourceRegistrationRequestHandler extends HttpHandler {
2827 protected readonly logger = getLoggerFor ( this ) ;
2928
30- /**
31- * @param {RequestingPartyRegistration[] } resourceServers - Pod Servers to be registered with the UMA AS
32- */
3329 constructor (
3430 private readonly resourceStore : KeyValueStorage < string , ResourceDescription > ,
3531 ) {
3632 super ( ) ;
3733 }
3834
39- /**
40- * Handle incoming requests for resource registration
41- * @param {HttpHandlerContext } param0
42- * @return {Observable<HttpHandlerResponse<PermissionRegistrationResponse>> }
43- */
4435 async handle ( { request } : HttpHandlerContext ) : Promise < HttpHandlerResponse < any > > {
4536 const signer = await extractRequestSigner ( request ) ;
4637
@@ -58,11 +49,7 @@ export class ResourceRegistrationRequestHandler extends HttpHandler {
5849 }
5950
6051 private async handlePost ( request : HttpHandlerRequest ) : Promise < HttpHandlerResponse < any > > {
61- const { headers, body } = request ;
62-
63- if ( headers [ 'content-type' ] !== 'application/json' ) {
64- throw new UnsupportedMediaTypeHttpError ( 'Only Media Type "application/json" is supported for this route.' ) ;
65- }
52+ const { body } = request ;
6653
6754 try {
6855 reType ( body , ResourceDescription ) ;
@@ -72,19 +59,16 @@ export class ResourceRegistrationRequestHandler extends HttpHandler {
7259 }
7360
7461 const resource = randomUUID ( ) ;
75- this . resourceStore . set ( resource , body ) ;
62+ await this . resourceStore . set ( resource , body ) ;
7663
7764 this . logger . info ( `Registered resource ${ resource } .` ) ;
7865
7966 return ( {
8067 status : 201 ,
81- headers : {
82- 'content-type' : 'application/json'
83- } ,
84- body : JSON . stringify ( {
68+ body : {
8569 _id : resource ,
8670 user_access_policy_uri : 'TODO: implement policy UI' ,
87- } ) ,
71+ } ,
8872 } )
8973 }
9074
@@ -97,9 +81,6 @@ export class ResourceRegistrationRequestHandler extends HttpHandler {
9781
9882 this . logger . info ( `Deleted resource ${ parameters . id } .` ) ;
9983
100- return ( {
101- status : 204 ,
102- headers : { } ,
103- } ) ;
84+ return { status : 204 } ;
10485 }
10586}
0 commit comments