Skip to content

Commit

Permalink
feat: Change from did/:did to did/search/:didUrl endpoint and sup…
Browse files Browse the repository at this point in the history
…port query parameters for DID endpoint in Credential Service [DEV-3097] (#331)

* Move commits from DEV-3097.

* Move constructor implementation to base class.

* Update swagger OpenAPI.

* Refactor code.

* Add resolve, resource/list, resource/dereferencing
to skip endpoints.

* Rename endpoint from `/did/resolve/{didUrl}` to
`/did/search/{didUrl}`.

* Use same configured unordered list symbol.

* Set correct route in registerRoute.

* Fix review comments.

* Add query parameters for /did/search/{did}.

* Update swagger.json.

* bump deps

* Update package-lock.json

* Remove `/resource/list/:did` endpoint.

* Remove unused methods/functions.

* Remove unused imports.

* Update swagger OpenAPI.

* Revert /did/search/{did} response type.

* Update package-lock.json

* Update swagger-types.ts

* Update issuer.ts

* Update swagger.json

* Update swagger-types.ts

* Update issuer.ts

* Update customer.ts

* Update customer.ts

* Merge branch 'develop' into DEV-3097-2

* Re-generate swagger OpenAPI.

* Remove an unreachable line of code.

* Remove removed endpoint from resourceAuthHandler.

* Format code.

* Rename endpoint from `/resource/dereferencing` to
`/resource/search`.

* Fix cycle import.

* Made CredentialRequest examplification

* Set correct response type for /did/search endpoint

* Set correct response type for /resource/search.

* Move resource query params to resource/search API.

* Remove resourceId path param from /resource/search

* Set an empty object for /resource/search API's
response type.

* Update swagger.json.

* Remove resourceId parameter from resource/search.

* Correct searchStatusList implementation.

* Refactor code.

* Add Content-Type: `*/*` header for resolve method.

* Fix linter mistake.

* Make status codes similar like DID Resolver.

* Fix OpenAPI linter mistakes.

* bump

* Rename IIdentity

* npm run format

* Update issuer.ts

* Fix DID Document example and schema

* Fix DID Document metadata

* Update swagger.json

* Fix resource metadata

* Build Swagger

* Update src/services/identity/identity.ts

Co-authored-by: Tasos Derisiotis <[email protected]>

* Update src/services/identity/identity.ts

Co-authored-by: Tasos Derisiotis <[email protected]>

* Update src/services/identity/identity.ts

Co-authored-by: Tasos Derisiotis <[email protected]>

* Restructure classes architecture.

* Add postfix to DefaultIdentityService subclasses.

* Rename class name from Identity to
IdentityStrategySetup.

---------

Co-authored-by: Ankur Banerjee <[email protected]>
Co-authored-by: Andrew Nikitin <[email protected]>
Co-authored-by: Tasos Derisiotis <[email protected]>
  • Loading branch information
4 people authored Aug 18, 2023
1 parent e556036 commit 4e34b76
Show file tree
Hide file tree
Showing 21 changed files with 1,501 additions and 711 deletions.
306 changes: 153 additions & 153 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"json-stringify-safe": "^5.0.1",
"jsonwebtoken": "^9.0.1",
"node-cache": "^5.1.2",
"pg": "^8.11.2",
"pg": "^8.11.3",
"pg-connection-string": "^2.6.2",
"secp256k1": "^5.0.0",
"sqlite3": "^5.1.6",
Expand Down
5 changes: 3 additions & 2 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class App {
app.get(
'/credential-status/search',
RevocationController.commonValidator,
new RevocationController().fetchStatusList
new RevocationController().searchStatusList
);

// Keys API
Expand All @@ -152,10 +152,11 @@ class App {
app.post('/did/update', IssuerController.updateValidator, new IssuerController().updateDid);
app.post('/did/deactivate/:did', IssuerController.deactivateValidator, new IssuerController().deactivateDid);
app.get('/did/list', new IssuerController().getDids);
app.get('/did/:did', new IssuerController().getDid);
app.get('/did/search/:did', new IssuerController().resolveDidUrl);

// Resource API
app.post('/resource/create/:did', IssuerController.resourceValidator, new IssuerController().createResource);
app.get('/resource/search/:did', new IssuerController().getResource);

// Account API
app.post('/account', new AccountController().create);
Expand Down
12 changes: 6 additions & 6 deletions src/controllers/credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { StatusCodes } from 'http-status-codes';
import { check, query, validationResult } from 'express-validator';

import { Credentials } from '../services/credentials.js';
import { Identity } from '../services/identity/index.js';
import { IdentityStrategySetup } from '../services/identity/index.js';

export class CredentialController {
public static issueValidator = [
Expand Down Expand Up @@ -167,7 +167,7 @@ export class CredentialController {
const { credential, policies } = request.body;
const verifyStatus = request.query.verifyStatus === 'true' ? true : false;
try {
const result = await new Identity(response.locals.customerId).agent.verifyCredential(
const result = await new IdentityStrategySetup(response.locals.customerId).agent.verifyCredential(
credential,
{
verifyStatus,
Expand Down Expand Up @@ -239,7 +239,7 @@ export class CredentialController {
return response
.status(StatusCodes.OK)
.json(
await new Identity(response.locals.customerId).agent.revokeCredentials(
await new IdentityStrategySetup(response.locals.customerId).agent.revokeCredentials(
request.body.credential,
publish,
response.locals.customerId
Expand Down Expand Up @@ -299,7 +299,7 @@ export class CredentialController {
return response
.status(StatusCodes.OK)
.json(
await new Identity(response.locals.customerId).agent.suspendCredentials(
await new IdentityStrategySetup(response.locals.customerId).agent.suspendCredentials(
request.body.credential,
request.body.publish,
response.locals.customerId
Expand Down Expand Up @@ -359,7 +359,7 @@ export class CredentialController {
return response
.status(StatusCodes.OK)
.json(
await new Identity(response.locals.customerId).agent.reinstateCredentials(
await new IdentityStrategySetup(response.locals.customerId).agent.reinstateCredentials(
request.body.credential,
request.body.publish,
response.locals.customerId
Expand Down Expand Up @@ -425,7 +425,7 @@ export class CredentialController {
const { presentation, verifierDid, policies } = request.body;
const verifyStatus = request.query.verifyStatus === 'true' ? true : false;
try {
const result = await new Identity(response.locals.customerId).agent.verifyPresentation(
const result = await new IdentityStrategySetup(response.locals.customerId).agent.verifyPresentation(
presentation,
{
verifyStatus,
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/customer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export class AccountController {
try {
const customer = await CustomerService.instance.create(response.locals.customerId);
if (!customer) {
return response.status(StatusCodes.BAD_REQUEST).json({
error: `Error creating customer. Please try again`,
return response.status(StatusCodes.INTERNAL_SERVER_ERROR).json({
error: `Internal server error. Please try again later.`,
});
}
// Send some tokens for testnet
Expand All @@ -53,7 +53,7 @@ export class AccountController {
});
} catch (error) {
return response.status(StatusCodes.INTERNAL_SERVER_ERROR).json({
error: `Error creating customer ${error}`,
error: `${error}`,
});
}
}
Expand Down
Loading

0 comments on commit 4e34b76

Please sign in to comment.