Skip to content

Commit

Permalink
feat(credential-status): rename plugin interfaces and methods
Browse files Browse the repository at this point in the history
fixes #981
  • Loading branch information
mirceanis committed Aug 9, 2022
1 parent 6fbd22f commit a5adaba
Show file tree
Hide file tree
Showing 18 changed files with 878 additions and 573 deletions.
4 changes: 3 additions & 1 deletion docsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"documentPackages": [
"core",
"credential-ld",
"credential-status",
"credential-w3c",
"data-store",
"data-store-json",
Expand All @@ -15,11 +16,12 @@
"did-resolver",
"key-manager",
"kms-local",
"kms-web3",
"message-handler",
"remote-client",
"remote-server",
"selective-disclosure",
"url-handler",
"utils"
]
}
}
5 changes: 4 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"IDIDManager": "./src/types/IDIDManager.ts",
"IDataStore": "./src/types/IDataStore.ts",
"IDataStoreORM": "./src/types/IDataStoreORM.ts",
"IMessageHandler": "./src/types/IMessageHandler.ts"
"IMessageHandler": "./src/types/IMessageHandler.ts",
"ICredentialStatus": "./src/types/ICredentialStatus.ts",
"ICredentialStatusVerifier": "./src/types/ICredentialStatusVerifier.ts",
"ICredentialStatusManager": "./src/types/ICredentialStatusManager.ts"
}
},
"dependencies": {
Expand Down
615 changes: 600 additions & 15 deletions packages/core/plugin.schema.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ export { Agent, createAgent, IAgentOptions } from './agent'
export { ValidationError } from './validator'
export { CoreEvents } from './coreEvents'
export * from './types/IAgent'
export * from './types/ICredentialStatus'
export * from './types/ICredentialStatusManager'
export * from './types/ICredentialStatusVerifier'
export * from './types/IDataStore'
export * from './types/IDataStoreORM'
export * from './types/IIdentifier'
Expand Down
79 changes: 7 additions & 72 deletions packages/core/src/types/ICredentialStatus.ts
Original file line number Diff line number Diff line change
@@ -1,78 +1,13 @@
export { DIDDocument, DIDResolutionOptions, DIDResolutionResult } from 'did-resolver'
import { IPluginMethodMap } from './IAgent'
import { CredentialStatus, VerifiableCredential } from './vc-data-model'
import { ICredentialStatusVerifier } from './ICredentialStatusVerifier'
import { ICredentialStatusManager } from './ICredentialStatusManager'

/**
* The arguments expected by a plugin that implements a credential status type/method
* in order to change the status of an issued verifiable credential.
*
* Each credential status type has its own specific parameters according to their spec.
*
* @see https://w3c-ccg.github.io/vc-status-list-2021/ | StatusList2021Entry
* @see https://w3c-ccg.github.io/vc-csl2017/ | CredentialStatusList2017
* Veramo plugin interface for plugins implementing both the {@link ICredentialStatusManager | manager} and the
* {@link ICredentialStatusVerifier | verifier} aspects of Credential Status flow.
*
* @beta
*/
interface CredentialStatusUpdateOptions { [x: string]: any }

/**
* Input arguments for {@link ICredentialStatus.credentialStatusUpdate | credentialStatusUpdate}
* @beta
*/
export interface CredentialStatusUpdateArgs {
/**
* The verifiable credential whose status will be updated.
*/
vc: VerifiableCredential

/**
* Credential status strategy options that will be passed to the method specific manager.
*
* @see: https://www.w3.org/TR/vc-data-model/#status
*/
options?: CredentialStatusUpdateOptions
}

/**
* Arguments for generating a `credentialStatus` property for a {@link VerifiableCredential}.
* @see {@link ICredentialStatus.credentialStatusGenerate}
* @see {@link https://www.w3.org/TR/vc-data-model/#status | credentialStatus} data model
* @see {@link @veramo/credential-status#CredentialStatusPlugin | CredentialStatusPlugin}
*
* @beta
*/
export interface CredentialStatusGenerateArgs {
/**
* The credential status type (aka credential status method) to be used in the `credentialStatus` generation.
*/
type: string
}

/**
* Credential status manager interface
* @beta
*/
export interface ICredentialStatus extends IPluginMethodMap {
/**
* Changes the status of an existing verifiable credential.
* Commonly used to revoke an existent credential.
*
* @param args - Input arguments for updating the status or revoking a credential
* @beta
*/
credentialStatusUpdate(args: CredentialStatusUpdateArgs): Promise<any>

/**
* Generates a `credentialStatus` property for a future credential, not yet signed.
*
* This method is used during the creation of a VC in order to make the VC capable of
* having its status updated later, allowing it to be revoked later by instance.
*
* @param args - Input arguments for generating the `credentialStatus` field of a new credential
* @beta
*/
credentialStatusGenerate(args: CredentialStatusGenerateArgs): Promise<CredentialStatus>

/**
* List all the credential status types (methods) available in the current agent instance.
*/
credentialStatusTypes(): Promise<string[]>
}
export type ICredentialStatus = ICredentialStatusVerifier & ICredentialStatusManager
86 changes: 86 additions & 0 deletions packages/core/src/types/ICredentialStatusManager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
export { DIDDocument, DIDResolutionOptions, DIDResolutionResult } from 'did-resolver'
import { IPluginMethodMap } from './IAgent'
import { CredentialStatusReference, VerifiableCredential } from './vc-data-model'

/**
* The arguments expected by a plugin that implements a credential status type/method
* in order to change the status of an issued verifiable credential.
*
* Each credential status type has its own specific parameters according to their spec.
*
* @see {@link https://w3c-ccg.github.io/vc-status-list-2021/ | StatusList2021Entry }
* @see {@link https://w3c-ccg.github.io/vc-csl2017/ | CredentialStatusList2017 }
* @see {@link https://www.w3.org/TR/vc-data-model/#status | credential status data model }
*
* @beta
*/
interface CredentialStatusUpdateOptions {
[x: string]: any
}

/**
* Input arguments for {@link ICredentialStatusManager.credentialStatusUpdate | credentialStatusUpdate}
* @beta
*/
export interface CredentialStatusUpdateArgs {
/**
* The verifiable credential whose status will be updated.
*/
vc: VerifiableCredential

/**
* Options that will be forwarded to the credentialStatus method specific manager.
*
* @see {@link https://www.w3.org/TR/vc-data-model/#status}
*/
options?: CredentialStatusUpdateOptions
}

/**
* Arguments for generating a `credentialStatus` property for a {@link VerifiableCredential}.
* @see {@link ICredentialStatusManager.credentialStatusGenerate | credentialStatusGenerate}
*
* @beta
*/
export interface CredentialStatusGenerateArgs {
/**
* The credential status type (aka credential status method) to be used in the `credentialStatus` generation.
*/
type: string

/**
* Any other options will be forwarded to the credentialStatus method driver
*/
[x: string]: any
}

/**
* Credential status manager interface
* @beta
*/
export interface ICredentialStatusManager extends IPluginMethodMap {
/**
* Changes the status of an existing {@link VerifiableCredential}.
* Commonly used to revoke an existing credential.
*
* @param args - Input arguments for updating the status(revoking) a credential
* @beta
*/
credentialStatusUpdate(args: CredentialStatusUpdateArgs): Promise<any>

/**
* Generates a `credentialStatus` property for a future credential, not yet signed.
*
* This method is used during the creation of a {@link VerifiableCredential} in order to make it capable of
* having its status updated later (to be revoked).
*
* @param args - Input arguments for generating the `credentialStatus` field of a new credential
* @beta
*/
credentialStatusGenerate(args: CredentialStatusGenerateArgs): Promise<CredentialStatusReference>

/**
* List all the credential status types (methods) available in the current agent instance.
*/
credentialStatusTypes(): Promise<Array<string>>
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { IAgentContext, IPluginMethodMap, VerifiableCredential } from '@veramo/core'
import { CredentialStatus as CredentialStatusVerification } from 'credential-status'
import { DIDDocument } from 'did-resolver'
import { IAgentContext, IPluginMethodMap } from './IAgent'
import { VerifiableCredential, CredentialStatus } from './vc-data-model'
import { IResolver } from "./IResolver";

/**
* Arguments for calling {@link ICheckCredentialStatus.checkCredentialStatus | checkCredentialStatus}.
* Arguments for calling {@link ICredentialStatusVerifier.checkCredentialStatus | checkCredentialStatus}.
*
* The credential whose status should be checked and the DID document of the credential issuer.
*
Expand All @@ -12,8 +13,16 @@ import { DIDDocument } from 'did-resolver'
* @beta This API may change without a BREAKING CHANGE notice.
*/
export interface ICheckCredentialStatusArgs {
/**
* The credential whose status needs to be checked
*/
credential: VerifiableCredential
didDoc: DIDDocument

/**
* The DID document of the issuer. This can be used in case the DID Document is already resolver, to avoid a
* potentially expensive DID resolution operation.
*/
didDocumentOverride?: DIDDocument
}

/**
Expand All @@ -33,8 +42,7 @@ export interface ICheckCredentialStatusArgs {
*
* @beta This API may change without a BREAKING CHANGE notice.
*/
export interface ICheckCredentialStatus extends IPluginMethodMap {

export interface ICredentialStatusVerifier extends IPluginMethodMap {
/**
* Checks the status of a {@link @veramo/core#VerifiableCredential | Verifiable Credential}.
*
Expand All @@ -43,6 +51,6 @@ export interface ICheckCredentialStatus extends IPluginMethodMap {
*/
checkCredentialStatus(
args: ICheckCredentialStatusArgs,
context: IAgentContext<any>,
): Promise<CredentialStatusVerification>
context: IAgentContext<IResolver>,
): Promise<CredentialStatus>
}
35 changes: 28 additions & 7 deletions packages/core/src/types/IDIDManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ export interface IDIDManagerGetOrCreateArgs {
options?: object
}

/**
* The arguments necessary to perform a full DID document update for a DID.
*
* @see {@link IDIDManager.didManagerUpdate | didManagerUpdate}
*
* @beta
*/
export interface IDIDManagerUpdateArgs {
/**
* Required. DID
Expand All @@ -137,8 +144,10 @@ export interface IDIDManagerUpdateArgs {
document: Partial<DIDDocument>

/**
* Identifier provider specific options
*/
* Identifier provider specific options.
*
* @see {@link @veramo/did-manager#AbstractIdentifierProvider | AbstractIdentifierProvider}
*/
options?: {
[x: string]: any
}
Expand Down Expand Up @@ -242,7 +251,6 @@ export interface IDIDManager extends IPluginMethodMap {
* Returns a list of managed identifiers
*
* @param args - Required. Arguments to get the list of identifiers
* @param context - <a href="/docs/agent/plugins#executing-plugin-methods">Execution context</a>. Requires `agent` that has {@link @veramo/core#IKeyManager} methods
*
* @example
* ```typescript
Expand All @@ -266,7 +274,6 @@ export interface IDIDManager extends IPluginMethodMap {
* Returns a specific identifier by alias
*
* @param args - Required. Arguments to get the identifier
* @param context - <a href="/docs/agent/plugins#executing-plugin-methods">Execution context</a>. Requires `agent` that has {@link @veramo/core#IKeyManager} methods
*
* @example
* ```typescript
Expand All @@ -282,7 +289,9 @@ export interface IDIDManager extends IPluginMethodMap {
* Creates and returns a new identifier
*
* @param args - Required. Arguments to create the identifier
* @param context - <a href="/docs/agent/plugins#executing-plugin-methods">Execution context</a>. Requires `agent` that has {@link @veramo/core#IKeyManager} methods
* @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.
*
* @example
* ```typescript
Expand All @@ -299,7 +308,8 @@ export interface IDIDManager extends IPluginMethodMap {
* Sets identifier alias
*
* @param args - Required. Arguments to set identifier alias
* @param context - <a href="/docs/agent/plugins#executing-plugin-methods">Execution context</a>. Requires `agent` that has {@link @veramo/core#IKeyManager} methods
* @param context - <a href="/docs/agent/plugins#executing-plugin-methods">Execution context</a>. Requires `agent`
* that has {@link @veramo/core#IKeyManager} methods
*
* @example
* ```typescript
Expand All @@ -314,13 +324,24 @@ export interface IDIDManager extends IPluginMethodMap {

/**
* Returns an existing identifier or creates a new one for a specific alias
* @param args - The alias used for the search and the provider/kms/options used to create the DID when none is found.
* @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.
*/
didManagerGetOrCreate(
args: IDIDManagerGetOrCreateArgs,
context: IAgentContext<IKeyManager>,
): Promise<IIdentifier>

didManagerUpdate(args: IDIDManagerUpdateArgs, context: IAgentContext<IKeyManager>): Promise<IIdentifier>
/**
* Updates the DID document of a managed {@link 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>

/**
* Imports identifier
Expand Down
Loading

0 comments on commit a5adaba

Please sign in to comment.