Skip to content

Commit

Permalink
feat(credential-status): expect revoked boolean property from StatusM…
Browse files Browse the repository at this point in the history
…ethods

docs: fix inline docs broken references

docs(kms-web3): add docs to kms-web3
  • Loading branch information
mirceanis committed Aug 10, 2022
1 parent a5adaba commit e00daa4
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 50 deletions.
2 changes: 1 addition & 1 deletion __tests__/shared/credentialStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const checkStatus = async (credential: any): Promise<CredentialStatus> => {
throw new Error('Invalid state.')
}

return revoked ? { revoked } : {}
return { revoked }
}

export default (testContext: {
Expand Down
7 changes: 5 additions & 2 deletions packages/core/plugin.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3164,8 +3164,8 @@
},
"save": {
"type": "boolean",
"description": "Optional. If set to `true`, the message will be saved using\n {@link IDataStore.dataStoreSaveMessage | dataStoreSaveMessage } \n<p/><p/>",
"deprecated": "Please call {@link IDataStore.dataStoreSaveMessage | dataStoreSaveMessage()} after handling the\nmessage and determining that it must be saved."
"description": "Optional. If set to `true`, the message will be saved using\n {@link @veramo/core#IDataStore.dataStoreSaveMessage | dataStoreSaveMessage } \n<p/><p/>",
"deprecated": "Please call {@link @veramo/core#IDataStore.dataStoreSaveMessage | dataStoreSaveMessage()} after\nhandling the message and determining that it must be saved."
}
},
"required": [
Expand Down Expand Up @@ -3872,6 +3872,9 @@
"type": "boolean"
}
},
"required": [
"revoked"
],
"description": "Represents the result of a status check.\n\nImplementations MUST populate the `revoked` boolean property, but they can return additional metadata that is method specific."
}
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/types/IDIDManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,13 @@ export interface IDIDManager extends IPluginMethodMap {
): Promise<IIdentifier>

/**
* Updates the DID document of a managed {@link IIdentifier | DID}.
* Updates the DID document of a managed {@link @veramo/core#IIdentifier | DID}.
* @param args - the arguments necessary for the update. The options are specific for each DID provider.
* @param context - *RESERVED* This is filled by the framework when the method is called. This method's <a
* href="/docs/agent/plugins#executing-plugin-methods">execution context</a> requires an `agent` that has
* {@link @veramo/core#IKeyManager} methods.
*/
didManagerUpdate(args: IDIDManagerUpdateArgs, context: IAgentContext<IKeyManager>): Promise<IIdentifier>
didManagerUpdate(args: IDIDManagerUpdateArgs, context: IAgentContext<IKeyManager>): Promise<IIdentifier>

/**
* Imports identifier
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/types/IMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export interface IHandleMessageArgs {

/**
* Optional. If set to `true`, the message will be saved using
* {@link IDataStore.dataStoreSaveMessage | dataStoreSaveMessage}
* {@link @veramo/core#IDataStore.dataStoreSaveMessage | dataStoreSaveMessage}
* <p/><p/>
* @deprecated Please call {@link IDataStore.dataStoreSaveMessage | dataStoreSaveMessage()} after handling the
* message and determining that it must be saved.
* @deprecated Please call {@link @veramo/core#IDataStore.dataStoreSaveMessage | dataStoreSaveMessage()} after
* handling the message and determining that it must be saved.
*/
save?: boolean
}
Expand All @@ -36,7 +36,7 @@ export interface IMessageHandler extends IPluginMethodMap {
* Parses a raw message.
*
* After the message is parsed, you can decide if it should be saved, and pass the result to
* {@link IDataStore.dataStoreSaveMessage | dataStoreSaveMessage()} to save it.
* {@link @veramo/core#IDataStore.dataStoreSaveMessage | dataStoreSaveMessage()} to save it.
*
* @param args - The `raw` message to be handled along with optional `metadata` about the origin.
* @param context - Execution context. Requires agent with {@link @veramo/core#IDataStore} methods
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/types/vc-data-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export type CredentialStatusReference = {
* @beta This API may change without a BREAKING CHANGE notice.
*/
export type CredentialStatus = {
revoked?: boolean
revoked: boolean
[x: string]: any
}

Expand Down
10 changes: 5 additions & 5 deletions packages/credential-eip712/plugin.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"$ref": "#/components/schemas/DateType"
},
"credentialStatus": {
"$ref": "#/components/schemas/CredentialStatus"
"$ref": "#/components/schemas/CredentialStatusReference"
},
"id": {
"type": "string"
Expand Down Expand Up @@ -75,7 +75,7 @@
"type": "string"
}
],
"description": "The issuer of a Credential or the holder of a Presentation.\n\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }"
"description": "The issuer of a {@link VerifiableCredential } or the holder of a {@link VerifiablePresentation } .\n\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }"
},
"CredentialSubject": {
"type": "object",
Expand All @@ -90,7 +90,7 @@
"type": "string",
"description": "Represents an issuance or expiration date for Credentials / Presentations. This is used as input when creating them."
},
"CredentialStatus": {
"CredentialStatusReference": {
"type": "object",
"properties": {
"id": {
Expand Down Expand Up @@ -151,7 +151,7 @@
"type": "string"
},
"credentialStatus": {
"$ref": "#/components/schemas/CredentialStatus"
"$ref": "#/components/schemas/CredentialStatusReference"
},
"id": {
"type": "string"
Expand All @@ -173,7 +173,7 @@
"type": "string"
}
},
"description": "A proof property of a Verifiable Credential or Presentation"
"description": "A proof property of a {@link VerifiableCredential } or {@link VerifiablePresentation }"
},
"ICreateVerifiablePresentationEIP712Args": {
"type": "object",
Expand Down
10 changes: 5 additions & 5 deletions packages/credential-ld/plugin.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"$ref": "#/components/schemas/DateType"
},
"credentialStatus": {
"$ref": "#/components/schemas/CredentialStatus"
"$ref": "#/components/schemas/CredentialStatusReference"
},
"id": {
"type": "string"
Expand Down Expand Up @@ -75,7 +75,7 @@
"type": "string"
}
],
"description": "The issuer of a Credential or the holder of a Presentation.\n\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }"
"description": "The issuer of a {@link VerifiableCredential } or the holder of a {@link VerifiablePresentation } .\n\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }"
},
"CredentialSubject": {
"type": "object",
Expand All @@ -90,7 +90,7 @@
"type": "string",
"description": "Represents an issuance or expiration date for Credentials / Presentations. This is used as input when creating them."
},
"CredentialStatus": {
"CredentialStatusReference": {
"type": "object",
"properties": {
"id": {
Expand Down Expand Up @@ -151,7 +151,7 @@
"type": "string"
},
"credentialStatus": {
"$ref": "#/components/schemas/CredentialStatus"
"$ref": "#/components/schemas/CredentialStatusReference"
},
"id": {
"type": "string"
Expand All @@ -173,7 +173,7 @@
"type": "string"
}
},
"description": "A proof property of a Verifiable Credential or Presentation"
"description": "A proof property of a {@link VerifiableCredential } or {@link VerifiablePresentation }"
},
"ICreateVerifiablePresentationLDArgs": {
"type": "object",
Expand Down
5 changes: 0 additions & 5 deletions packages/credential-status/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
"build": "tsc",
"extract-api": "yarn veramo dev extract-api"
},
"veramo": {
"pluginInterfaces": {
"ICheckCredentialStatus": "./src/types.ts"
}
},
"dependencies": {
"@veramo/core": "^3.1.0",
"@veramo/utils": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('@veramo/credential-status', () => {

it('should check the credential status', async () => {
expect.assertions(3)
const expectedResult = {}
const expectedResult = { revoked: false }
const checkStatus = jest.fn(async () => expectedResult)
const agent = createAgent<ICredentialStatusVerifier>({
plugins: [
Expand All @@ -41,7 +41,7 @@ describe('@veramo/credential-status', () => {

it('should check the credential status using DID resolver to get the issuer doc', async () => {
expect.assertions(4)
const expectedResult = {}
const expectedResult = { revoked: false }
const checkStatus = jest.fn(async () => expectedResult)
const fakeResolver: Resolvable = {
resolve: jest.fn(
Expand Down
16 changes: 14 additions & 2 deletions packages/credential-status/src/credential-status.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {
CredentialStatus,
IAgentContext,
IAgentPlugin,
ICheckCredentialStatusArgs,
ICredentialStatusVerifier,
IResolver,
} from '@veramo/core'
import { extractIssuer, resolveDidOrThrow } from '@veramo/utils'
import { extractIssuer, isDefined, resolveDidOrThrow } from '@veramo/utils'
import { Status, StatusMethod } from 'credential-status'

/**
Expand Down Expand Up @@ -43,6 +44,17 @@ export class CredentialStatusPlugin implements IAgentPlugin {
const issuerDid = extractIssuer(args.credential)
didDoc = await resolveDidOrThrow(issuerDid, context)
}
return this.status.checkStatus(args.credential, didDoc)
const statusCheck: CredentialStatus = (await this.status.checkStatus(
args.credential,
didDoc,
)) as CredentialStatus
if (!isDefined(statusCheck.revoked)) {
throw new Error(
`invalid_result: 'revoked' property missing. The Credential Status verification resulted in an ambiguous result: ${JSON.stringify(
statusCheck,
)}`,
)
}
return statusCheck
}
}
14 changes: 7 additions & 7 deletions packages/credential-w3c/plugin.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"save": {
"type": "boolean",
"description": "If this parameter is true, the resulting VerifiablePresentation is sent to the\n {@link @veramo/core#IDataStore | storage plugin } to be saved.",
"deprecated": "Please call {@link IDataStore.dataStoreSaveVerifiableCredential | dataStoreSaveVerifiableCredential()}to save the credential after creating it."
"deprecated": "Please call\n{@link @veramo/core#IDataStore.dataStoreSaveVerifiableCredential | dataStoreSaveVerifiableCredential()} to save\nthe credential after creating it."
},
"proofFormat": {
"$ref": "#/components/schemas/ProofFormat",
Expand Down Expand Up @@ -61,7 +61,7 @@
"$ref": "#/components/schemas/DateType"
},
"credentialStatus": {
"$ref": "#/components/schemas/CredentialStatus"
"$ref": "#/components/schemas/CredentialStatusReference"
},
"id": {
"type": "string"
Expand Down Expand Up @@ -89,7 +89,7 @@
"type": "string"
}
],
"description": "The issuer of a Credential or the holder of a Presentation.\n\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }"
"description": "The issuer of a {@link VerifiableCredential } or the holder of a {@link VerifiablePresentation } .\n\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }"
},
"CredentialSubject": {
"type": "object",
Expand All @@ -104,7 +104,7 @@
"type": "string",
"description": "Represents an issuance or expiration date for Credentials / Presentations. This is used as input when creating them."
},
"CredentialStatus": {
"CredentialStatusReference": {
"type": "object",
"properties": {
"id": {
Expand Down Expand Up @@ -174,7 +174,7 @@
"type": "string"
},
"credentialStatus": {
"$ref": "#/components/schemas/CredentialStatus"
"$ref": "#/components/schemas/CredentialStatusReference"
},
"id": {
"type": "string"
Expand All @@ -196,7 +196,7 @@
"type": "string"
}
},
"description": "A proof property of a Verifiable Credential or Presentation"
"description": "A proof property of a {@link VerifiableCredential } or {@link VerifiablePresentation }"
},
"ICreateVerifiablePresentationArgs": {
"type": "object",
Expand All @@ -208,7 +208,7 @@
"save": {
"type": "boolean",
"description": "If this parameter is true, the resulting VerifiablePresentation is sent to the\n {@link @veramo/core#IDataStore | storage plugin } to be saved. <p/><p/>",
"deprecated": "Please call\n{@link IDataStore.dataStoreSaveVerifiablePresentation | dataStoreSaveVerifiablePresentation()} to save the\ncredential after creating it."
"deprecated": "Please call\n{@link @veramo/core#IDataStore.dataStoreSaveVerifiablePresentation | dataStoreSaveVerifiablePresentation()} to\nsave the credential after creating it."
},
"challenge": {
"type": "string",
Expand Down
9 changes: 5 additions & 4 deletions packages/credential-w3c/src/action-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ export interface ICreateVerifiablePresentationArgs {
* {@link @veramo/core#IDataStore | storage plugin} to be saved.
* <p/><p/>
* @deprecated Please call
* {@link IDataStore.dataStoreSaveVerifiablePresentation | dataStoreSaveVerifiablePresentation()} to save the
* credential after creating it.
* {@link @veramo/core#IDataStore.dataStoreSaveVerifiablePresentation | dataStoreSaveVerifiablePresentation()} to
* save the credential after creating it.
*/
save?: boolean

Expand Down Expand Up @@ -134,8 +134,9 @@ export interface ICreateVerifiableCredentialArgs {
* If this parameter is true, the resulting VerifiablePresentation is sent to the
* {@link @veramo/core#IDataStore | storage plugin} to be saved.
*
* @deprecated Please call {@link IDataStore.dataStoreSaveVerifiableCredential | dataStoreSaveVerifiableCredential()}
* to save the credential after creating it.
* @deprecated Please call
* {@link @veramo/core#IDataStore.dataStoreSaveVerifiableCredential | dataStoreSaveVerifiableCredential()} to save
* the credential after creating it.
*/
save?: boolean

Expand Down
8 changes: 4 additions & 4 deletions packages/did-comm/plugin.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@
"type": "string"
},
"credentialStatus": {
"$ref": "#/components/schemas/CredentialStatus"
"$ref": "#/components/schemas/CredentialStatusReference"
},
"id": {
"type": "string"
Expand All @@ -366,7 +366,7 @@
"type": "string"
}
},
"description": "A proof property of a Verifiable Credential or Presentation"
"description": "A proof property of a {@link VerifiableCredential } or {@link VerifiablePresentation }"
},
"IssuerType": {
"anyOf": [
Expand All @@ -385,7 +385,7 @@
"type": "string"
}
],
"description": "The issuer of a Credential or the holder of a Presentation.\n\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }"
"description": "The issuer of a {@link VerifiableCredential } or the holder of a {@link VerifiablePresentation } .\n\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }"
},
"CredentialSubject": {
"type": "object",
Expand All @@ -396,7 +396,7 @@
},
"description": "The value of the credentialSubject property is defined as a set of objects that contain one or more properties that are each related to a subject of the verifiable credential. Each object MAY contain an id.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#credential-subject | Credential Subject }"
},
"CredentialStatus": {
"CredentialStatusReference": {
"type": "object",
"properties": {
"id": {
Expand Down
18 changes: 18 additions & 0 deletions packages/kms-web3/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"apiReport": {
"enabled": true,
"reportFolder": "./api",
"reportTempFolder": "./api"
},

"docModel": {
"enabled": true,
"apiJsonFilePath": "./api/<unscopedPackageName>.api.json"
},

"dtsRollup": {
"enabled": false
},
"mainEntryPointFilePath": "<projectFolder>/build/index.d.ts"
}
3 changes: 2 additions & 1 deletion packages/kms-web3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"main": "build/index.js",
"types": "build/index.d.ts",
"scripts": {
"build": "tsc"
"build": "tsc",
"extract-api": "yarn veramo dev extract-api"
},
"dependencies": {
"@ethersproject/providers": "^5.6.8",
Expand Down
2 changes: 1 addition & 1 deletion packages/kms-web3/src/web3-key-management-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { AbstractKeyManagementSystem, Eip712Payload } from '@veramo/key-manager'
import { toUtf8String } from '@ethersproject/strings'

/**
* This is a {@link @veramo/keyManager#AbstractKeyManagementSystem | KMS} implementation that uses the addresses of a
* This is a {@link @veramo/key-manager#AbstractKeyManagementSystem | KMS} implementation that uses the addresses of a
* web3 wallet as key identifiers, and calls the respective wallet for signing operations.
* @beta
*/
Expand Down
Loading

0 comments on commit e00daa4

Please sign in to comment.