From b6f73ddf1f82c36c447f4d79b55f708c0ffb3167 Mon Sep 17 00:00:00 2001 From: DaevMithran Date: Mon, 12 Jun 2023 15:36:06 +0530 Subject: [PATCH] feat: Update swagger schemas --- package-lock.json | 4 +- src/controllers/revocation.ts | 17 ++++++++- src/services/identity/agent.ts | 1 + src/types/types.ts | 15 ++++++++ swagger.json | 67 +++++++++++++++++++++++++++++++++- 5 files changed, 98 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6d0befc16..9b1d5efbb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cheqd/credential-service", - "version": "2.1.0-develop.18", + "version": "2.1.0-develop.20", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cheqd/credential-service", - "version": "2.1.0-develop.18", + "version": "2.1.0-develop.20", "license": "Apache-2.0", "dependencies": { "@cheqd/did-provider-cheqd": "^3.3.0", diff --git a/src/controllers/revocation.ts b/src/controllers/revocation.ts index c7049f558..4d7ce4362 100644 --- a/src/controllers/revocation.ts +++ b/src/controllers/revocation.ts @@ -4,6 +4,7 @@ import { fromString } from 'uint8arrays' import { Identity } from '../services/identity/index.js' import { Veramo } from '../services/identity/agent.js' +import { ResourceMetadata } from '../types/types.js' export class RevocationController { @@ -50,8 +51,20 @@ export class RevocationController { } try { - const result = await Veramo.instance.resolve(`${request.query.did}?resourceType=StatusList2021&resourceMetadata=true`) - return response.status(200).json(result.contentStream?.linkedResourceMetadata || []) + let result = await Veramo.instance.resolve(`${request.query.did}?resourceType=StatusList2021&resourceMetadata=true`) + result = result.contentStream?.linkedResourceMetadata || [] + const statusList = result + .filter((resource: ResourceMetadata)=>resource.mediaType=='application/octet-stream' || resource.mediaType=='application/gzip') + .map((resource: ResourceMetadata)=>{ + return { + statusListName: resource.resourceName, + statusListVersion: resource.resourceVersion, + mediaType: resource.mediaType, + statusListId: resource.resourceId, + statusListNextVersion: resource.nextVersionId + } + }) + return response.status(200).json(statusList) } catch (error) { return response.status(500).json({ error: `Internal error: ${error}` diff --git a/src/services/identity/agent.ts b/src/services/identity/agent.ts index b40f77881..e59c30ddb 100644 --- a/src/services/identity/agent.ts +++ b/src/services/identity/agent.ts @@ -204,6 +204,7 @@ export class Veramo { : await agent.cheqdVerifyCredential({ credential: credential as VerifiableCredential, + fetchList: true, ...statusOptions } as ICheqdVerifyCredentialWithStatusList2021Args) } diff --git a/src/types/types.ts b/src/types/types.ts index 290cfd8f5..dcfb78625 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -220,3 +220,18 @@ export type VerifyStatusOptions = { } bootstrapOptions: {} } + +export interface ResourceMetadata { + collectionId: string + resourceId: string + resourceName: string + resourceVersion: string + resourceType: string + mediaType: string + created: + | Date + | undefined; + checksum: string; + previousVersionId: string; + nextVersionId: string; +} \ No newline at end of file diff --git a/swagger.json b/swagger.json index a22ab49e9..3b4923a5f 100644 --- a/swagger.json +++ b/swagger.json @@ -833,7 +833,35 @@ ], "responses": { "200": { - "description": "StatusList is fetched successfully" + "description": "StatusList is fetched successfully", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "object", + "properties": { + "statusListName": { + "type": "string" + }, + "statusListVersion": { + "type": "string" + }, + "mediaType": { + "type": "string", + "enum": ["application/gzip", "application/octet-stream"] + }, + "statusListId": { + "type": "string" + }, + "statusListNextVersion": { + "type": "string" + } + } + } + } + } + } }, "400": { "description": "A problem with the input fields has occurred. Additional state information plus metadata may be available in the response body.", @@ -1091,6 +1119,36 @@ "jwt", "lds" ] + }, + "credentialStatus": { + "type": "object", + "properties": { + "statusPurpose": { + "type": "string", + "enum": [ + "revocation", + "suspension" + ] + }, + "statusListName": { + "type": "string" + }, + "statusListIndex": { + "type": "number" + }, + "statusListVersipon": { + "type": "string" + }, + "statusListRangeStart": { + "type": "number" + }, + "statusListRangeEnd": { + "type": "number" + }, + "indexNotIn": { + "type": "number" + } + } } }, "required": [ @@ -1111,7 +1169,12 @@ "type": [ "Person" ], - "format": "jwt" + "format": "jwt", + "credentialStatus": { + "statusPurpose": "revocation", + "statusListName": "employee-credentials", + "statusListIndex": 10 + } } }, "Credential": {