Skip to content

Commit

Permalink
Address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
thehenrytsai committed Jun 28, 2024
1 parent 662b234 commit c60648d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/http-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class HttpApi {
dwn: Dwn;

constructor(config: DwnServerConfig, dwn: Dwn, registrationManager?: RegistrationManager) {
console.log(config);
log.info(config);

this.#packageInfo = {
server: config.serverName,
Expand Down Expand Up @@ -351,7 +351,7 @@ export class HttpApi {
if (this.#config.registrationStoreUrl !== undefined) {
this.#api.post('/registration', async (req: Request, res: Response) => {
const requestBody = req.body;
console.log('Registration request:', requestBody);
log.info('Registration request:', requestBody);

try {
await this.registrationManager.handleRegistrationRequest(requestBody);
Expand All @@ -362,7 +362,7 @@ export class HttpApi {
if (dwnServerError.code !== undefined) {
res.status(400).json(dwnServerError);
} else {
console.log('Error handling registration request:', error);
log.info('Error handling registration request:', error);
res.status(500).json({ success: false });
}
}
Expand All @@ -375,7 +375,7 @@ export class HttpApi {
* Endpoint that the connecting App pushes the Pushed Authorization Request Object to start the Web5 Connect flow.
*/
this.#api.post('/connect/par', async (req, res) => {
console.log('Storing Pushed Authorization Request (PAR) request...');
log.info('Storing Pushed Authorization Request (PAR) request...');

const result = await this.web5ConnectServer.setWeb5ConnectRequest(req.body.request);
res.status(201).json(result);
Expand All @@ -385,7 +385,7 @@ export class HttpApi {
* Endpoint that the Identity Provider (wallet) calls to retrieve the Pushed Authorization Request.
*/
this.#api.get('/connect/:requestId.jwt', async (req, res) => {
console.log(`Retrieving Web5 Connect Request object of ID: ${req.params.requestId}...`);
log.info(`Retrieving Web5 Connect Request object of ID: ${req.params.requestId}...`);

// Look up the request object based on the requestId.
const requestObjectJwt = await this.web5ConnectServer.getWeb5ConnectRequest(req.params.requestId);
Expand All @@ -405,7 +405,7 @@ export class HttpApi {
* Endpoint that the Identity Provider (wallet) pushes the Authorization Response ID token to.
*/
this.#api.post('/connect/sessions', async (req, res) => {
console.log('Storing Identity Provider (wallet) pushed response with ID token...');
log.info('Storing Identity Provider (wallet) pushed response with ID token...');

// Store the ID token.
const idToken = req.body.id_token;
Expand Down Expand Up @@ -433,7 +433,7 @@ export class HttpApi {
* The Web5 Connect Response is also an ID token.
*/
this.#api.get('/connect/sessions/:state.jwt', async (req, res) => {
console.log(`Retrieving ID token for state: ${req.params.state}...`);
log.info(`Retrieving ID token for state: ${req.params.state}...`);

// Look up the ID token.
const idToken = await this.web5ConnectServer.getWeb5ConnectResponse(req.params.state);
Expand Down
4 changes: 0 additions & 4 deletions src/web5-connect/web5-connect-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ export class Web5ConnectServer {
* This is the initial call to the connect server to start the Web5 Connect flow.
*/
public async setWeb5ConnectRequest(request: Web5ConnectRequest): Promise<SetWeb5ConnectRequestResult> {
console.log('Received Pushed Authorization Request (PAR) request.');

// Generate a request URI
const requestId = randomUuid();
const request_uri = `${this.baseUrl}/connect/${requestId}.jwt`;
Expand Down Expand Up @@ -79,8 +77,6 @@ export class Web5ConnectServer {
* Sets the Web5 Connect Response object, which is also an OIDC ID token.
*/
public async setWeb5ConnectResponse(state: string, response: Web5ConnectResponse): Promise<any> {
console.log('Identity Provider pushed response with ID token.');

this.dataStore.set(`response:${state}`, response);
}

Expand Down

0 comments on commit c60648d

Please sign in to comment.