Skip to content

Commit

Permalink
feat: added routes for contract and vc endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Dexagod committed Apr 4, 2024
1 parent ab2b691 commit 39c304a
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/uma/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"sai-uma:config/routes/tickets.json",
"sai-uma:config/routes/tokens.json",
"sai-uma:config/routes/log.json",
"sai-uma:config/routes/vc.json",
"sai-uma:config/routes/contract.json",
"sai-uma:config/tickets/storage/default.json",
"sai-uma:config/tickets/strategy/claim-elimination.json",
"sai-uma:config/tokens/factory/default.json",
Expand Down Expand Up @@ -52,7 +54,9 @@
{ "@id": "urn:uma:default:ResourceRegistrationRoute" },
{ "@id": "urn:uma:default:ResourceRegistrationOpsRoute" },
{ "@id": "urn:uma:default:IntrospectionRoute" },
{ "@id": "urn:uma:default:LogRoute" }
{ "@id": "urn:uma:default:LogRoute" },
{ "@id": "urn:uma:default:VCRoute" },
{ "@id": "urn:uma:default:ContractRoute" }
]
}
],
Expand Down
23 changes: 23 additions & 0 deletions packages/uma/config/routes/contract.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"@context": [
"https://linkedsoftwaredependencies.org/bundles/npm/@solidlab/uma/^0.0.0/components/context.jsonld"
],
"@graph": [
{
"@id": "urn:uma:default:ContractRoute",
"@type": "HttpHandlerRoute",
"operations": [
{
"@type": "HttpHandlerOperation",
"method": "GET",
"publish": true
}
],
"handler": {
"@type": "ContractRequestHandler",
"baseUrl": { "@id": "urn:uma:variables:baseUrl" }
},
"path": "/uma/contract"
}
]
}
23 changes: 23 additions & 0 deletions packages/uma/config/routes/vc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"@context": [
"https://linkedsoftwaredependencies.org/bundles/npm/@solidlab/uma/^0.0.0/components/context.jsonld"
],
"@graph": [
{
"@id": "urn:uma:default:VCRoute",
"@type": "HttpHandlerRoute",
"operations": [
{
"@type": "HttpHandlerOperation",
"method": "GET",
"publish": true
}
],
"handler": {
"@type": "VCRequestHandler",
"baseUrl": { "@id": "urn:uma:variables:baseUrl" }
},
"path": "/uma/vc"
}
]
}
2 changes: 2 additions & 0 deletions packages/uma/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export * from './routes/ResourceRegistration';
export * from './routes/Token';
export * from './routes/Config';
export * from './routes/Log';
export * from './routes/VC';
export * from './routes/Contract';

// Tickets
export * from './ticketing/Ticket';
Expand Down
46 changes: 46 additions & 0 deletions packages/uma/src/routes/Contract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ASYMMETRIC_CRYPTOGRAPHIC_ALGORITHM }
from '@solid/access-token-verifier/dist/constant/ASYMMETRIC_CRYPTOGRAPHIC_ALGORITHM';
import { HttpHandler } from '../util/http/models/HttpHandler';
import { HttpHandlerContext } from '../util/http/models/HttpHandlerContext';
import { HttpHandlerResponse } from '../util/http/models/HttpHandlerResponse';
import { Logger } from '../util/logging/Logger';
import { getLoggerFor } from '../util/logging/LoggerUtils';
import { getOperationLogger } from '../logging/OperationLogger';

/**
* An HttpHandler used for returning the logs
* stored in the UMA Authorization Service.
*/
export class ContractRequestHandler extends HttpHandler {
protected readonly logger: Logger = getLoggerFor(this);

operationLogger = getOperationLogger()

/**
* An HttpHandler used for returning the configuration
* of the UMA Authorization Service.
* @param {string} baseUrl - Base URL of the AS
*/
constructor(protected readonly baseUrl: string) {
super();
}

/**
* Returns the endpoint's UMA configuration
*
* @param {HttpHandlerContext} context - an irrelevant incoming context
* @return {Observable<HttpHandlerResponse>} - the mock response
*/
async handle(context: HttpHandlerContext): Promise<HttpHandlerResponse> {
this.logger.info(`Received contract retrieval request at '${context.request.url}'`);

return {
body: '<this> <is> "the contract endpoint".',
headers: {'content-type': 'application/trig'},
status: 200,
};
}

}


49 changes: 49 additions & 0 deletions packages/uma/src/routes/VC.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { ASYMMETRIC_CRYPTOGRAPHIC_ALGORITHM }
from '@solid/access-token-verifier/dist/constant/ASYMMETRIC_CRYPTOGRAPHIC_ALGORITHM';
import { HttpHandler } from '../util/http/models/HttpHandler';
import { HttpHandlerContext } from '../util/http/models/HttpHandlerContext';
import { HttpHandlerResponse } from '../util/http/models/HttpHandlerResponse';
import { Logger } from '../util/logging/Logger';
import { getLoggerFor } from '../util/logging/LoggerUtils';
import { getOperationLogger } from '../logging/OperationLogger';
import { Quad } from 'n3';
import { serializeQuads } from '@solid/community-server';


/**
* An HttpHandler used for returning the logs
* stored in the UMA Authorization Service.
*/
export class VCRequestHandler extends HttpHandler {
protected readonly logger: Logger = getLoggerFor(this);

operationLogger = getOperationLogger()

/**
* An HttpHandler used for returning the configuration
* of the UMA Authorization Service.
* @param {string} baseUrl - Base URL of the AS
*/
constructor(protected readonly baseUrl: string) {
super();
}

/**
* Returns the endpoint's UMA configuration
*
* @param {HttpHandlerContext} context - an irrelevant incoming context
* @return {Observable<HttpHandlerResponse>} - the mock response
*/
async handle(context: HttpHandlerContext): Promise<HttpHandlerResponse> {
this.logger.info(`Received VC endpoint request at '${context.request.url}'`);

return {
body: '<this> <is> "the vc endpoint".',
headers: {'content-type': 'application/trig'},
status: 200,
};
}

}


0 comments on commit 39c304a

Please sign in to comment.