Skip to content

Commit

Permalink
feat: Update swagger schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
DaevMithran committed Jun 12, 2023
1 parent 6f22bad commit b6f73dd
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions src/controllers/revocation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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}`
Expand Down
1 change: 1 addition & 0 deletions src/services/identity/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ export class Veramo {
:
await agent.cheqdVerifyCredential({
credential: credential as VerifiableCredential,
fetchList: true,
...statusOptions
} as ICheqdVerifyCredentialWithStatusList2021Args)
}
Expand Down
15 changes: 15 additions & 0 deletions src/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
67 changes: 65 additions & 2 deletions swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down Expand Up @@ -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": [
Expand All @@ -1111,7 +1169,12 @@
"type": [
"Person"
],
"format": "jwt"
"format": "jwt",
"credentialStatus": {
"statusPurpose": "revocation",
"statusListName": "employee-credentials",
"statusListIndex": 10
}
}
},
"Credential": {
Expand Down

0 comments on commit b6f73dd

Please sign in to comment.