From 039948d9849f0082bb057eb1885b35595b098233 Mon Sep 17 00:00:00 2001 From: Matthew Dean Date: Wed, 23 Aug 2023 08:56:06 +0100 Subject: [PATCH] Changes from review 1. refactored module instantiation to a helper function 2. configured correct types to support v1 and v2 credential and proof protocols and correct formats 3. proof controller updated to take parameters like agent 4. re-enabled oob proof api as create-request Signed-off-by: Matthew Dean --- packages/rest/src/cli.ts | 1 - packages/rest/src/cliAgent.ts | 54 +- .../src/controllers/proofs/ProofController.ts | 207 ++-- packages/rest/src/controllers/types.ts | 176 +-- packages/rest/src/routes/routes.ts | 339 +++++- packages/rest/src/routes/swagger.json | 1026 ++++++++++++----- packages/rest/src/utils/agent.ts | 152 ++- packages/rest/src/utils/helpers.ts | 13 + packages/rest/tests/credential.test.ts | 12 +- packages/rest/tests/proof.test.ts | 217 ++-- 10 files changed, 1440 insertions(+), 757 deletions(-) diff --git a/packages/rest/src/cli.ts b/packages/rest/src/cli.ts index 01472703..ec0e66a9 100644 --- a/packages/rest/src/cli.ts +++ b/packages/rest/src/cli.ts @@ -21,7 +21,6 @@ const parsed = yargs }) .option('indy-ledger', { array: true, - // TODO: this default is invalid, fixme default: [], coerce: (items: unknown[]) => items.map((i) => (typeof i === 'string' ? JSON.parse(i) : i)), }) diff --git a/packages/rest/src/cliAgent.ts b/packages/rest/src/cliAgent.ts index bba51299..3dad5f47 100644 --- a/packages/rest/src/cliAgent.ts +++ b/packages/rest/src/cliAgent.ts @@ -1,30 +1,19 @@ -import type { InitConfig } from '@aries-framework/core' -import type { WalletConfig } from '@aries-framework/core/build/types' +import type { InitConfig, WalletConfig } from '@aries-framework/core' import type { IndyVdrPoolConfig } from '@aries-framework/indy-vdr' -import { AnonCredsModule } from '@aries-framework/anoncreds' -import { AnonCredsRsModule } from '@aries-framework/anoncreds-rs' -import { AskarModule } from '@aries-framework/askar' import { HttpOutboundTransport, WsOutboundTransport, LogLevel, Agent, - ConnectionsModule, - ProofsModule, - CredentialsModule, AutoAcceptCredential, AutoAcceptProof, - MediatorModule, } from '@aries-framework/core' -import { IndyVdrAnonCredsRegistry, IndyVdrModule } from '@aries-framework/indy-vdr' import { agentDependencies, HttpInboundTransport, WsInboundTransport } from '@aries-framework/node' -import { anoncreds } from '@hyperledger/anoncreds-nodejs' -import { ariesAskar } from '@hyperledger/aries-askar-nodejs' -import { indyVdr } from '@hyperledger/indy-vdr-nodejs' import { readFile } from 'fs/promises' import { setupServer } from './server' +import { getAgentModules } from './utils/agent' import { TsLogger } from './utils/logger' export type Transports = 'ws' | 'http' @@ -46,7 +35,7 @@ const outboundTransportMapping = { export interface AriesRestConfig { label: string walletConfig: WalletConfig - indyLedgers: [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]] + indyLedgers: IndyVdrPoolConfig[] endpoints?: string[] autoAcceptConnections?: boolean autoAcceptCredentials?: AutoAcceptCredential @@ -93,36 +82,19 @@ export async function runRestAgent(restConfig: AriesRestConfig) { logger, } + const maybeLedgers = indyLedgers.length > 0 ? (indyLedgers as [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]]) : undefined + const modules = getAgentModules({ + autoAcceptConnections, + autoAcceptProofs, + autoAcceptCredentials, + autoAcceptMediationRequests, + indyLedgers: maybeLedgers, + }) + const agent = new Agent({ config: agentConfig, dependencies: agentDependencies, - modules: { - connections: new ConnectionsModule({ - autoAcceptConnections, - }), - proofs: new ProofsModule({ - autoAcceptProofs, - }), - credentials: new CredentialsModule({ - autoAcceptCredentials, - }), - indyVdr: new IndyVdrModule({ - indyVdr, - networks: indyLedgers, - }), - anoncreds: new AnonCredsModule({ - registries: [new IndyVdrAnonCredsRegistry()], - }), - anoncredsRs: new AnonCredsRsModule({ - anoncreds, - }), - askar: new AskarModule({ - ariesAskar, - }), - mediator: new MediatorModule({ - autoAcceptMediationRequests, - }), - }, + modules, }) // Register outbound transports diff --git a/packages/rest/src/controllers/proofs/ProofController.ts b/packages/rest/src/controllers/proofs/ProofController.ts index 2d482468..0ff5c3ed 100644 --- a/packages/rest/src/controllers/proofs/ProofController.ts +++ b/packages/rest/src/controllers/proofs/ProofController.ts @@ -1,43 +1,37 @@ import type { RestAgent } from '../../utils/agent' -import type { RequestProofOptionsProofRequestRestriction } from '../types' -import type { AnonCredsProofRequestRestriction } from '@aries-framework/anoncreds' +import type { AnonCredsRequestProofFormatOptions, AnonCredsProofRequestRestrictionOptions } from '../types' +import type { AnonCredsProofRequestRestriction, AnonCredsRequestProofFormat } from '@aries-framework/anoncreds' import type { ProofExchangeRecordProps } from '@aries-framework/core' import { Agent, RecordNotFoundError } from '@aries-framework/core' import { Body, Controller, Delete, Example, Get, Path, Post, Query, Res, Route, Tags, TsoaResponse } from 'tsoa' import { injectable } from 'tsyringe' +import { maybeMapValues } from '../../utils/helpers' import { ProofRecordExample, RecordId } from '../examples' -import { RequestProofOptions, RequestProofProposalOptions } from '../types' - -const maybeMapValues = ( - transform: (input: V) => U, - obj?: { - [key: string]: V - } -) => { - if (!obj) { - return obj - } - - return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, transform(value)])) -} - -const transformRequiredAttributes = (attributes?: string[]) => { +import { + RequestProofOptions, + AcceptProofProposalOptions, + AcceptProofRequestOptions, + ProposeProofOptions, + CreateProofRequestOptions, +} from '../types' + +const transformAttributeMarkers = (attributes?: { [key: string]: boolean }) => { if (!attributes) { return undefined } - return attributes.reduce<{ [key in `attr::${string}::marker`]: '1' }>( - (acc, attr) => ({ - [`attr::${attr}::marker`]: '1', + return Object.entries(attributes).reduce<{ [key in `attr::${string}::marker`]: '1' | '0' }>( + (acc, [attr, val]) => ({ + [`attr::${attr}::marker`]: val ? '1' : '0', ...acc, }), {} ) } -const transformRequiredAttributeValues = (attributeValues?: { [key in string]: string }) => { +const transformAttributeValues = (attributeValues?: { [key in string]: string }) => { if (!attributeValues) { return undefined } @@ -51,22 +45,44 @@ const transformRequiredAttributeValues = (attributeValues?: { [key in string]: s ) } -const transformRestriction = ( - restriction: RequestProofOptionsProofRequestRestriction -): AnonCredsProofRequestRestriction => ({ - schema_id: restriction.schemaId, - schema_issuer_id: restriction.schemaIssuerId, - schema_name: restriction.schemaName, - schema_version: restriction.schemaVersion, - issuer_id: restriction.issuerId, - cred_def_id: restriction.credDefId, - rev_reg_id: restriction.revRegId, - schema_issuer_did: restriction.schemaIssuerDid, - issuer_did: restriction.issuerDid, - ...transformRequiredAttributes(restriction.requiredAttributes), - ...transformRequiredAttributeValues(restriction.requiredAttributeValues), +const transformRestriction = ({ + attributeValues, + attributeMarkers, + ...others +}: AnonCredsProofRequestRestrictionOptions): AnonCredsProofRequestRestriction => ({ + ...transformAttributeMarkers(attributeMarkers), + ...transformAttributeValues(attributeValues), + ...others, }) +const transformProofFormat = ( + proofFormat?: AnonCredsRequestProofFormatOptions +): AnonCredsRequestProofFormat | undefined => { + if (!proofFormat) { + return undefined + } + + const { requested_attributes, requested_predicates, ...rest } = proofFormat + + return { + ...rest, + requested_attributes: maybeMapValues( + ({ restrictions, ...other }) => ({ + restrictions: restrictions?.map(transformRestriction), + ...other, + }), + requested_attributes + ), + requested_predicates: maybeMapValues( + ({ restrictions, ...other }) => ({ + restrictions: restrictions?.map(transformRestriction), + ...other, + }), + requested_predicates + ), + } +} + @Tags('Proofs') @Route('/proofs') @injectable() @@ -155,30 +171,18 @@ export class ProofController extends Controller { @Post('/propose-proof') @Example(ProofRecordExample) public async proposeProof( - @Body() proposal: RequestProofProposalOptions, + @Body() proposal: ProposeProofOptions, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { - const { attributes, predicates, connectionId, comment } = proposal - try { - const proof = await this.agent.proofs.proposeProof({ - connectionId, - protocolVersion: 'v2', - proofFormats: { - anoncreds: { - attributes, - predicates, - }, - }, - comment, - }) + const proof = await this.agent.proofs.proposeProof(proposal) return proof.toJSON() } catch (error) { if (error instanceof RecordNotFoundError) { return notFoundError(404, { - reason: `connection with connectionId "${connectionId}" not found.`, + reason: `connection with connectionId "${proposal.connectionId}" not found.`, }) } return internalServerError(500, { message: `something went wrong: ${error}` }) @@ -198,23 +202,14 @@ export class ProofController extends Controller { public async acceptProposal( @Path('proofRecordId') proofRecordId: string, @Body() - proposal: { - request: { name?: string; version?: string } - comment?: string - }, + proposal: AcceptProofProposalOptions, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { const proof = await this.agent.proofs.acceptProposal({ proofRecordId, - proofFormats: { - anoncreds: { - name: proposal.request.name, - version: proposal.request.version, - }, - }, - comment: proposal.comment, + ...proposal, }) return proof.toJSON() @@ -228,30 +223,32 @@ export class ProofController extends Controller { } } - // TODO: Represent out-of-band proof - // /** - // * Creates a presentation request not bound to any proposal or existing connection - // * - // * @param request - // * @returns ProofRequestMessageResponse - // */ - // @Post('/request-outofband-proof') - // @Example<{ proofUrl: string; proofRecord: ProofRecordProps }>({ - // proofUrl: 'https://example.com/proof-url', - // proofRecord: ProofRecordExample, - // }) - // public async requestProofOutOfBand(@Body() request: Omit) { - // const { proofRequestOptions, ...requestOptions } = request - - // const proof = await this.agent.proofs.createOutOfBandRequest(proofRequestOptions, requestOptions) - - // return { - // proofUrl: `${this.agent.config.endpoints[0]}/?d_m=${JsonEncoder.toBase64URL( - // proof.requestMessage.toJSON({ useLegacyDidSovPrefix: this.agent.config.useLegacyDidSovPrefix }) - // )}`, - // proofRecord: proof.proofRecord, - // } - // } + /** + * Creates a presentation request not bound to any proposal or existing connection + * + * @param request + * @returns ProofRequestMessageResponse + */ + @Post('/create-request') + @Example<{ message: object; proofRecord: ProofExchangeRecordProps }>({ + message: {}, + proofRecord: ProofRecordExample, + }) + public async createRequest(@Body() request: CreateProofRequestOptions) { + const { proofFormats, ...rest } = request + const { message, proofRecord } = await this.agent.proofs.createRequest({ + proofFormats: { + anoncreds: transformProofFormat(proofFormats.anoncreds), + indy: transformProofFormat(proofFormats.indy), + }, + ...rest, + }) + + return { + message, + proofRecord: proofRecord, + } + } /** * Creates a presentation request bound to existing connection @@ -266,37 +263,15 @@ export class ProofController extends Controller { @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { - const { connectionId, proofRequestOptions } = request - + const { connectionId, proofFormats, ...rest } = request try { const proof = await this.agent.proofs.requestProof({ connectionId, - protocolVersion: 'v2', proofFormats: { - anoncreds: { - name: proofRequestOptions.name, - version: proofRequestOptions.version, - requested_attributes: maybeMapValues( - (attribute) => ({ - name: attribute.name, - names: attribute.names, - non_revoked: attribute.nonRevoked, - restrictions: attribute.restrictions?.map(transformRestriction), - }), - proofRequestOptions.requestedAttributes - ), - requested_predicates: maybeMapValues( - (predicate) => ({ - name: predicate.name, - p_type: predicate.pType, - p_value: predicate.pValue, - non_revoked: predicate.nonRevoked, - restrictions: predicate.restrictions?.map(transformRestriction), - }), - proofRequestOptions.requestedPredicates - ), - }, + anoncreds: transformProofFormat(proofFormats.anoncreds), + indy: transformProofFormat(proofFormats.indy), }, + ...rest, }) return proof.toJSON() @@ -323,15 +298,11 @@ export class ProofController extends Controller { public async acceptRequest( @Path('proofRecordId') proofRecordId: string, @Body() - request: { - comment?: string - }, + request: AcceptProofRequestOptions, @Res() notFoundError: TsoaResponse<404, { reason: string }>, @Res() internalServerError: TsoaResponse<500, { message: string }> ) { try { - const { comment } = request - const retrievedCredentials = await this.agent.proofs.selectCredentialsForRequest({ proofRecordId, }) @@ -339,7 +310,7 @@ export class ProofController extends Controller { const proof = await this.agent.proofs.acceptRequest({ proofRecordId, proofFormats: retrievedCredentials.proofFormats, - comment, + ...request, }) return proof.toJSON() diff --git a/packages/rest/src/controllers/types.ts b/packages/rest/src/controllers/types.ts index cae58432..42acc1e7 100644 --- a/packages/rest/src/controllers/types.ts +++ b/packages/rest/src/controllers/types.ts @@ -1,16 +1,23 @@ import type { AnonCredsSchema, AnonCredsCredentialDefinition, - AnonCredsPresentationPreviewAttribute, - AnonCredsPresentationPreviewPredicate, AnonCredsNonRevokedInterval, AnonCredsPredicateType, + V1CredentialProtocol, + AnonCredsCredentialFormat, + LegacyIndyCredentialFormat, + AnonCredsCredentialFormatService, + LegacyIndyCredentialFormatService, + V1ProofProtocol, + LegacyIndyProofFormatService, + AnonCredsProofFormatService, + LegacyIndyProofFormat, + AnonCredsProofFormat, } from '@aries-framework/anoncreds' import type { AutoAcceptCredential, CredentialFormatPayload, HandshakeProtocol, - CredentialFormat, CredentialProtocolVersionType, ReceiveOutOfBandInvitationConfig, OutOfBandDidCommService, @@ -18,6 +25,10 @@ import type { DidDocumentMetadata, ProofExchangeRecord, V2CredentialProtocol, + V2ProofProtocol, + AutoAcceptProof, + ProofFormatPayload, + ProofsProtocolVersionType, } from '@aries-framework/core' import type { DIDDocument } from 'did-resolver' @@ -44,24 +55,19 @@ export interface ProofRequestMessageResponse { proofRecord: ProofExchangeRecord } -type CredentialProtocols = [V2CredentialProtocol] -type CredentialFormats = [CredentialFormat] +type CredentialProtocols = [ + V1CredentialProtocol, + V2CredentialProtocol<[LegacyIndyCredentialFormatService, AnonCredsCredentialFormatService]> +] +type CredentialFormats = [LegacyIndyCredentialFormat, AnonCredsCredentialFormat] + +type ProofProtocols = [V1ProofProtocol, V2ProofProtocol<[LegacyIndyProofFormatService, AnonCredsProofFormatService]>] +type ProofFormats = [LegacyIndyProofFormat, AnonCredsProofFormat] export interface ProposeCredentialOptions { protocolVersion: CredentialProtocolVersionType credentialFormats: { - indy: { - schemaIssuerDid: string - schemaId: string - schemaName: string - schemaVersion: string - credentialDefinitionId: string - issuerDid: string - attributes: { - name: string - value: string - }[] - } + [key in CredentialFormats[number] as key['formatKey']]?: CredentialFormats[number]['credentialFormats']['createProposal'] } autoAcceptCredential?: AutoAcceptCredential comment?: string @@ -70,18 +76,7 @@ export interface ProposeCredentialOptions { export interface AcceptCredentialProposalOptions { credentialFormats?: { - indy: { - schemaIssuerDid: string - schemaId: string - schemaName: string - schemaVersion: string - credentialDefinitionId: string - issuerDid: string - attributes: { - name: string - value: string - }[] - } + [key in CredentialFormats[number] as key['formatKey']]?: CredentialFormats[number]['credentialFormats']['acceptProposal'] } autoAcceptCredential?: AutoAcceptCredential comment?: string @@ -89,30 +84,14 @@ export interface AcceptCredentialProposalOptions { export interface CreateOfferOptions { protocolVersion: CredentialProtocolVersionType - credentialFormats: { - indy: { - credentialDefinitionId: string - attributes: { - name: string - value: string - }[] - } - } + credentialFormats: CredentialFormatPayload autoAcceptCredential?: AutoAcceptCredential comment?: string } export interface OfferCredentialOptions { protocolVersion: CredentialProtocolVersionType - credentialFormats: { - indy: { - credentialDefinitionId: string - attributes: { - name: string - value: string - }[] - } - } + credentialFormats: CredentialFormatPayload autoAcceptCredential?: AutoAcceptCredential comment?: string connectionId: string @@ -172,51 +151,92 @@ export interface ConnectionInvitationSchema { imageUrl?: string } -export interface RequestProofOptionsProofRequestRestriction { - schemaId?: string - schemaIssuerId?: string - schemaName?: string - schemaVersion?: string - issuerId?: string - credDefId?: string - revRegId?: string - schemaIssuerDid?: string - issuerDid?: string - requiredAttributes?: string[] - requiredAttributeValues?: { [key: string]: string } +export interface ProposeProofOptions { + connectionId: string + protocolVersion: ProofsProtocolVersionType + proofFormats: ProofFormatPayload + goalCode?: string + parentThreadId?: string + autoAcceptProof?: AutoAcceptProof + comment?: string } -export interface RequestProofOptionsRequestedAttribute { +export interface AcceptProofProposalOptions { + proofFormats?: ProofFormatPayload + goalCode?: string + willConfirm?: boolean + autoAcceptProof?: AutoAcceptProof + comment?: string +} + +export interface AcceptProofRequestOptions { + useReturnRoute?: boolean + goalCode?: string + willConfirm?: boolean + autoAcceptProof?: AutoAcceptProof + comment?: string +} + +export interface AnonCredsProofRequestRestrictionOptions { + schema_id?: string + schema_issuer_id?: string + schema_name?: string + schema_version?: string + issuer_id?: string + cred_def_id?: string + rev_reg_id?: string + schema_issuer_did?: string + issuer_did?: string + attributeValues?: { + [key: string]: string + } + attributeMarkers?: { + [key: string]: boolean + } +} + +export interface AnonCredsRequestedAttributeOptions { name?: string names?: string[] - restrictions?: RequestProofOptionsProofRequestRestriction[] - nonRevoked?: AnonCredsNonRevokedInterval + restrictions?: AnonCredsProofRequestRestrictionOptions[] + non_revoked?: AnonCredsNonRevokedInterval } -export interface RequestProofOptionsRequestedPredicate { +export interface AnonCredsRequestedPredicateOptions { name: string - pType: AnonCredsPredicateType - pValue: number - restrictions?: RequestProofOptionsProofRequestRestriction[] - nonRevoked?: AnonCredsNonRevokedInterval + p_type: AnonCredsPredicateType + p_value: number + restrictions?: AnonCredsProofRequestRestrictionOptions[] + non_revoked?: AnonCredsNonRevokedInterval } -export interface RequestProofOptions { - connectionId: string - proofRequestOptions: { - name: string - version: string - requestedAttributes?: { [key: string]: RequestProofOptionsRequestedAttribute } - requestedPredicates?: { [key: string]: RequestProofOptionsRequestedPredicate } +export interface AnonCredsRequestProofFormatOptions { + name: string + version: string + non_revoked?: AnonCredsNonRevokedInterval + requested_attributes?: { + [key: string]: AnonCredsRequestedAttributeOptions + } + requested_predicates?: { + [key: string]: AnonCredsRequestedPredicateOptions } } -export interface RequestProofProposalOptions { - connectionId: string - attributes: AnonCredsPresentationPreviewAttribute[] - predicates: AnonCredsPresentationPreviewPredicate[] +export interface CreateProofRequestOptions { + protocolVersion: ProofsProtocolVersionType + proofFormats: { + [key in ProofFormats[number] as key['formatKey']]?: AnonCredsRequestProofFormatOptions + } + goalCode?: string + parentThreadId?: string + willConfirm?: boolean + autoAcceptProof?: AutoAcceptProof comment?: string } +export interface RequestProofOptions extends CreateProofRequestOptions { + connectionId: string +} + export interface AnonCredsSchemaResponse extends AnonCredsSchema { id: string } diff --git a/packages/rest/src/routes/routes.ts b/packages/rest/src/routes/routes.ts index c7412d4f..afd8a983 100644 --- a/packages/rest/src/routes/routes.ts +++ b/packages/rest/src/routes/routes.ts @@ -78,6 +78,106 @@ const models: TsoaRoute.Models = { "type": {"dataType":"string","validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "CredentialPreviewAttributeOptions": { + "dataType": "refObject", + "properties": { + "name": {"dataType":"string","required":true}, + "mimeType": {"dataType":"string"}, + "value": {"dataType":"string","required":true}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "Pick_JwsGeneralFormat.Exclude_keyofJwsGeneralFormat.payload__": { + "dataType": "refAlias", + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"header":{"ref":"Record_string.unknown_","required":true},"signature":{"dataType":"string","required":true},"protected":{"dataType":"string","required":true}},"validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "Omit_JwsGeneralFormat.payload_": { + "dataType": "refAlias", + "type": {"ref":"Pick_JwsGeneralFormat.Exclude_keyofJwsGeneralFormat.payload__","validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "JwsDetachedFormat": { + "dataType": "refAlias", + "type": {"ref":"Omit_JwsGeneralFormat.payload_","validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "JwsFlattenedDetachedFormat": { + "dataType": "refObject", + "properties": { + "signatures": {"dataType":"array","array":{"dataType":"refAlias","ref":"JwsDetachedFormat"},"required":true}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AttachmentData": { + "dataType": "refObject", + "properties": { + "base64": {"dataType":"string"}, + "json": {"ref":"Record_string.unknown_"}, + "links": {"dataType":"array","array":{"dataType":"string"}}, + "jws": {"dataType":"union","subSchemas":[{"ref":"JwsDetachedFormat"},{"ref":"JwsFlattenedDetachedFormat"}]}, + "sha256": {"dataType":"string"}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "Attachment": { + "dataType": "refObject", + "properties": { + "id": {"dataType":"string","required":true}, + "description": {"dataType":"string"}, + "filename": {"dataType":"string"}, + "mimeType": {"dataType":"string"}, + "lastmodTime": {"dataType":"datetime"}, + "byteCount": {"dataType":"double"}, + "data": {"ref":"AttachmentData","required":true}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "LinkedAttachment": { + "dataType": "refObject", + "properties": { + "attributeName": {"dataType":"string","required":true}, + "attachment": {"ref":"Attachment","required":true}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AnonCredsProposeCredentialFormat": { + "dataType": "refObject", + "properties": { + "schemaIssuerId": {"dataType":"string"}, + "schemaId": {"dataType":"string"}, + "schemaName": {"dataType":"string"}, + "schemaVersion": {"dataType":"string"}, + "credentialDefinitionId": {"dataType":"string"}, + "issuerId": {"dataType":"string"}, + "attributes": {"dataType":"array","array":{"dataType":"refObject","ref":"CredentialPreviewAttributeOptions"}}, + "linkedAttachments": {"dataType":"array","array":{"dataType":"refObject","ref":"LinkedAttachment"}}, + "schemaIssuerDid": {"dataType":"string"}, + "issuerDid": {"dataType":"string"}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "Pick_AnonCredsProposeCredentialFormat.Exclude_keyofAnonCredsProposeCredentialFormat.schemaIssuerId-or-issuerId__": { + "dataType": "refAlias", + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{},"validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "Omit_AnonCredsProposeCredentialFormat.schemaIssuerId-or-issuerId_": { + "dataType": "refAlias", + "type": {"ref":"Pick_AnonCredsProposeCredentialFormat.Exclude_keyofAnonCredsProposeCredentialFormat.schemaIssuerId-or-issuerId__","validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "LegacyIndyProposeCredentialFormat": { + "dataType": "refAlias", + "type": {"ref":"Omit_AnonCredsProposeCredentialFormat.schemaIssuerId-or-issuerId_","validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "AutoAcceptCredential": { "dataType": "refEnum", "enums": ["always","contentApproved","never"], @@ -87,7 +187,7 @@ const models: TsoaRoute.Models = { "dataType": "refObject", "properties": { "protocolVersion": {"ref":"CredentialProtocolVersionType_CredentialProtocols_","required":true}, - "credentialFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"dataType":"nestedObjectLiteral","nestedProperties":{"attributes":{"dataType":"array","array":{"dataType":"nestedObjectLiteral","nestedProperties":{"value":{"dataType":"string","required":true},"name":{"dataType":"string","required":true}}},"required":true},"issuerDid":{"dataType":"string","required":true},"credentialDefinitionId":{"dataType":"string","required":true},"schemaVersion":{"dataType":"string","required":true},"schemaName":{"dataType":"string","required":true},"schemaId":{"dataType":"string","required":true},"schemaIssuerDid":{"dataType":"string","required":true}},"required":true}},"required":true}, + "credentialFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"dataType":"union","subSchemas":[{"ref":"AnonCredsProposeCredentialFormat"},{"ref":"LegacyIndyProposeCredentialFormat"}]},"anoncreds":{"dataType":"union","subSchemas":[{"ref":"AnonCredsProposeCredentialFormat"},{"ref":"LegacyIndyProposeCredentialFormat"}]}},"required":true}, "autoAcceptCredential": {"ref":"AutoAcceptCredential"}, "comment": {"dataType":"string"}, "connectionId": {"dataType":"string","required":true}, @@ -95,21 +195,46 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AnonCredsAcceptProposalFormat": { + "dataType": "refObject", + "properties": { + "credentialDefinitionId": {"dataType":"string"}, + "attributes": {"dataType":"array","array":{"dataType":"refObject","ref":"CredentialPreviewAttributeOptions"}}, + "linkedAttachments": {"dataType":"array","array":{"dataType":"refObject","ref":"LinkedAttachment"}}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "AcceptCredentialProposalOptions": { "dataType": "refObject", "properties": { - "credentialFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"dataType":"nestedObjectLiteral","nestedProperties":{"attributes":{"dataType":"array","array":{"dataType":"nestedObjectLiteral","nestedProperties":{"value":{"dataType":"string","required":true},"name":{"dataType":"string","required":true}}},"required":true},"issuerDid":{"dataType":"string","required":true},"credentialDefinitionId":{"dataType":"string","required":true},"schemaVersion":{"dataType":"string","required":true},"schemaName":{"dataType":"string","required":true},"schemaId":{"dataType":"string","required":true},"schemaIssuerDid":{"dataType":"string","required":true}},"required":true}}}, + "credentialFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"ref":"AnonCredsAcceptProposalFormat"},"anoncreds":{"ref":"AnonCredsAcceptProposalFormat"}}}, "autoAcceptCredential": {"ref":"AutoAcceptCredential"}, "comment": {"dataType":"string"}, }, "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AnonCredsOfferCredentialFormat": { + "dataType": "refObject", + "properties": { + "credentialDefinitionId": {"dataType":"string","required":true}, + "attributes": {"dataType":"array","array":{"dataType":"refObject","ref":"CredentialPreviewAttributeOptions"},"required":true}, + "linkedAttachments": {"dataType":"array","array":{"dataType":"refObject","ref":"LinkedAttachment"}}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "CredentialFormatPayload_CredentialFormats.createOffer_": { + "dataType": "refAlias", + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"ref":"AnonCredsOfferCredentialFormat"},"anoncreds":{"ref":"AnonCredsOfferCredentialFormat"}},"validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "CreateOfferOptions": { "dataType": "refObject", "properties": { "protocolVersion": {"ref":"CredentialProtocolVersionType_CredentialProtocols_","required":true}, - "credentialFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"dataType":"nestedObjectLiteral","nestedProperties":{"attributes":{"dataType":"array","array":{"dataType":"nestedObjectLiteral","nestedProperties":{"value":{"dataType":"string","required":true},"name":{"dataType":"string","required":true}}},"required":true},"credentialDefinitionId":{"dataType":"string","required":true}},"required":true}},"required":true}, + "credentialFormats": {"ref":"CredentialFormatPayload_CredentialFormats.createOffer_","required":true}, "autoAcceptCredential": {"ref":"AutoAcceptCredential"}, "comment": {"dataType":"string"}, }, @@ -120,7 +245,7 @@ const models: TsoaRoute.Models = { "dataType": "refObject", "properties": { "protocolVersion": {"ref":"CredentialProtocolVersionType_CredentialProtocols_","required":true}, - "credentialFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"dataType":"nestedObjectLiteral","nestedProperties":{"attributes":{"dataType":"array","array":{"dataType":"nestedObjectLiteral","nestedProperties":{"value":{"dataType":"string","required":true},"name":{"dataType":"string","required":true}}},"required":true},"credentialDefinitionId":{"dataType":"string","required":true}},"required":true}},"required":true}, + "credentialFormats": {"ref":"CredentialFormatPayload_CredentialFormats.createOffer_","required":true}, "autoAcceptCredential": {"ref":"AutoAcceptCredential"}, "comment": {"dataType":"string"}, "connectionId": {"dataType":"string","required":true}, @@ -128,9 +253,17 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AnonCredsAcceptOfferFormat": { + "dataType": "refObject", + "properties": { + "linkSecretId": {"dataType":"string"}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "CredentialFormatPayload_CredentialFormats.acceptOffer_": { "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{},"validators":{}}, + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"ref":"AnonCredsAcceptOfferFormat"},"anoncreds":{"ref":"AnonCredsAcceptOfferFormat"}},"validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "AcceptCredentialOfferOptions": { @@ -143,9 +276,19 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AnonCredsAcceptRequestFormat": { + "dataType": "refAlias", + "type": {"ref":"Record_string.never_","validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "Record_string.never_": { + "dataType": "refAlias", + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"ref":"AnonCredsAcceptRequestFormat"},"anoncreds":{"ref":"AnonCredsAcceptRequestFormat"}},"validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "CredentialFormatPayload_CredentialFormats.acceptRequest_": { "dataType": "refAlias", - "type": {"dataType":"nestedObjectLiteral","nestedProperties":{},"validators":{}}, + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"ref":"AnonCredsAcceptRequestFormat"},"anoncreds":{"ref":"AnonCredsAcceptRequestFormat"}},"validators":{}}, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "AcceptCredentialRequestOptions": { @@ -346,6 +489,11 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "ProofsProtocolVersionType_ProofProtocols_": { + "dataType": "refAlias", + "type": {"dataType":"string","validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "AnonCredsPresentationPreviewAttribute": { "dataType": "refObject", "properties": { @@ -374,35 +522,68 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "RequestProofProposalOptions": { + "AnonCredsProposeProofFormat": { + "dataType": "refObject", + "properties": { + "name": {"dataType":"string"}, + "version": {"dataType":"string"}, + "attributes": {"dataType":"array","array":{"dataType":"refObject","ref":"AnonCredsPresentationPreviewAttribute"}}, + "predicates": {"dataType":"array","array":{"dataType":"refObject","ref":"AnonCredsPresentationPreviewPredicate"}}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "ProofFormatPayload_ProofFormats.createProposal_": { + "dataType": "refAlias", + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"ref":"AnonCredsProposeProofFormat"},"anoncreds":{"ref":"AnonCredsProposeProofFormat"}},"validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AutoAcceptProof": { + "dataType": "refEnum", + "enums": ["always","contentApproved","never"], + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "ProposeProofOptions": { "dataType": "refObject", "properties": { "connectionId": {"dataType":"string","required":true}, - "attributes": {"dataType":"array","array":{"dataType":"refObject","ref":"AnonCredsPresentationPreviewAttribute"},"required":true}, - "predicates": {"dataType":"array","array":{"dataType":"refObject","ref":"AnonCredsPresentationPreviewPredicate"},"required":true}, + "protocolVersion": {"ref":"ProofsProtocolVersionType_ProofProtocols_","required":true}, + "proofFormats": {"ref":"ProofFormatPayload_ProofFormats.createProposal_","required":true}, + "goalCode": {"dataType":"string"}, + "parentThreadId": {"dataType":"string"}, + "autoAcceptProof": {"ref":"AutoAcceptProof"}, "comment": {"dataType":"string"}, }, "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "RequestProofOptionsProofRequestRestriction": { + "ProofFormatPayload_ProofFormats.acceptProposal_": { + "dataType": "refAlias", + "type": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"dataType":"nestedObjectLiteral","nestedProperties":{"version":{"dataType":"string"},"name":{"dataType":"string"}}},"anoncreds":{"dataType":"nestedObjectLiteral","nestedProperties":{"version":{"dataType":"string"},"name":{"dataType":"string"}}}},"validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AcceptProofProposalOptions": { "dataType": "refObject", "properties": { - "schemaId": {"dataType":"string"}, - "schemaIssuerId": {"dataType":"string"}, - "schemaName": {"dataType":"string"}, - "schemaVersion": {"dataType":"string"}, - "issuerId": {"dataType":"string"}, - "credDefId": {"dataType":"string"}, - "revRegId": {"dataType":"string"}, - "schemaIssuerDid": {"dataType":"string"}, - "issuerDid": {"dataType":"string"}, - "requiredAttributes": {"dataType":"array","array":{"dataType":"string"}}, - "requiredAttributeValues": {"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"dataType":"string"}}, + "proofFormats": {"ref":"ProofFormatPayload_ProofFormats.acceptProposal_"}, + "goalCode": {"dataType":"string"}, + "willConfirm": {"dataType":"boolean"}, + "autoAcceptProof": {"ref":"AutoAcceptProof"}, + "comment": {"dataType":"string"}, }, "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AgentMessage": { + "dataType": "refAlias", + "type": {"ref":"Record_string.unknown_","validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "ProofExchangeRecord": { + "dataType": "refAlias", + "type": {"ref":"Record_string.unknown_","validators":{}}, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa "AnonCredsNonRevokedInterval": { "dataType": "refObject", "properties": { @@ -412,25 +593,69 @@ const models: TsoaRoute.Models = { "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "RequestProofOptionsRequestedAttribute": { + "AnonCredsProofRequestRestrictionOptions": { + "dataType": "refObject", + "properties": { + "schema_id": {"dataType":"string"}, + "schema_issuer_id": {"dataType":"string"}, + "schema_name": {"dataType":"string"}, + "schema_version": {"dataType":"string"}, + "issuer_id": {"dataType":"string"}, + "cred_def_id": {"dataType":"string"}, + "rev_reg_id": {"dataType":"string"}, + "schema_issuer_did": {"dataType":"string"}, + "issuer_did": {"dataType":"string"}, + "attributeValues": {"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"dataType":"string"}}, + "attributeMarkers": {"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"dataType":"boolean"}}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AnonCredsRequestedAttributeOptions": { "dataType": "refObject", "properties": { "name": {"dataType":"string"}, "names": {"dataType":"array","array":{"dataType":"string"}}, - "restrictions": {"dataType":"array","array":{"dataType":"refObject","ref":"RequestProofOptionsProofRequestRestriction"}}, - "nonRevoked": {"ref":"AnonCredsNonRevokedInterval"}, + "restrictions": {"dataType":"array","array":{"dataType":"refObject","ref":"AnonCredsProofRequestRestrictionOptions"}}, + "non_revoked": {"ref":"AnonCredsNonRevokedInterval"}, }, "additionalProperties": false, }, // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa - "RequestProofOptionsRequestedPredicate": { + "AnonCredsRequestedPredicateOptions": { "dataType": "refObject", "properties": { "name": {"dataType":"string","required":true}, - "pType": {"ref":"AnonCredsPredicateType","required":true}, - "pValue": {"dataType":"double","required":true}, - "restrictions": {"dataType":"array","array":{"dataType":"refObject","ref":"RequestProofOptionsProofRequestRestriction"}}, - "nonRevoked": {"ref":"AnonCredsNonRevokedInterval"}, + "p_type": {"ref":"AnonCredsPredicateType","required":true}, + "p_value": {"dataType":"double","required":true}, + "restrictions": {"dataType":"array","array":{"dataType":"refObject","ref":"AnonCredsProofRequestRestrictionOptions"}}, + "non_revoked": {"ref":"AnonCredsNonRevokedInterval"}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AnonCredsRequestProofFormatOptions": { + "dataType": "refObject", + "properties": { + "name": {"dataType":"string","required":true}, + "version": {"dataType":"string","required":true}, + "non_revoked": {"ref":"AnonCredsNonRevokedInterval"}, + "requested_attributes": {"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"ref":"AnonCredsRequestedAttributeOptions"}}, + "requested_predicates": {"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"ref":"AnonCredsRequestedPredicateOptions"}}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "CreateProofRequestOptions": { + "dataType": "refObject", + "properties": { + "protocolVersion": {"ref":"ProofsProtocolVersionType_ProofProtocols_","required":true}, + "proofFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"ref":"AnonCredsRequestProofFormatOptions"},"anoncreds":{"ref":"AnonCredsRequestProofFormatOptions"}},"required":true}, + "goalCode": {"dataType":"string"}, + "parentThreadId": {"dataType":"string"}, + "willConfirm": {"dataType":"boolean"}, + "autoAcceptProof": {"ref":"AutoAcceptProof"}, + "comment": {"dataType":"string"}, }, "additionalProperties": false, }, @@ -438,8 +663,26 @@ const models: TsoaRoute.Models = { "RequestProofOptions": { "dataType": "refObject", "properties": { + "protocolVersion": {"ref":"ProofsProtocolVersionType_ProofProtocols_","required":true}, + "proofFormats": {"dataType":"nestedObjectLiteral","nestedProperties":{"indy":{"ref":"AnonCredsRequestProofFormatOptions"},"anoncreds":{"ref":"AnonCredsRequestProofFormatOptions"}},"required":true}, + "goalCode": {"dataType":"string"}, + "parentThreadId": {"dataType":"string"}, + "willConfirm": {"dataType":"boolean"}, + "autoAcceptProof": {"ref":"AutoAcceptProof"}, + "comment": {"dataType":"string"}, "connectionId": {"dataType":"string","required":true}, - "proofRequestOptions": {"dataType":"nestedObjectLiteral","nestedProperties":{"requestedPredicates":{"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"ref":"RequestProofOptionsRequestedPredicate"}},"requestedAttributes":{"dataType":"nestedObjectLiteral","nestedProperties":{},"additionalProperties":{"ref":"RequestProofOptionsRequestedAttribute"}},"version":{"dataType":"string","required":true},"name":{"dataType":"string","required":true}},"required":true}, + }, + "additionalProperties": false, + }, + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + "AcceptProofRequestOptions": { + "dataType": "refObject", + "properties": { + "useReturnRoute": {"dataType":"boolean"}, + "goalCode": {"dataType":"string"}, + "willConfirm": {"dataType":"boolean"}, + "autoAcceptProof": {"ref":"AutoAcceptProof"}, + "comment": {"dataType":"string"}, }, "additionalProperties": false, }, @@ -1571,7 +1814,7 @@ export function RegisterRoutes(app: express.Router) { async function ProofController_proposeProof(request: any, response: any, next: any) { const args = { - proposal: {"in":"body","name":"proposal","required":true,"ref":"RequestProofProposalOptions"}, + proposal: {"in":"body","name":"proposal","required":true,"ref":"ProposeProofOptions"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -1604,7 +1847,7 @@ export function RegisterRoutes(app: express.Router) { async function ProofController_acceptProposal(request: any, response: any, next: any) { const args = { proofRecordId: {"in":"path","name":"proofRecordId","required":true,"dataType":"string"}, - proposal: {"in":"body","name":"proposal","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"comment":{"dataType":"string"},"request":{"dataType":"nestedObjectLiteral","nestedProperties":{"version":{"dataType":"string"},"name":{"dataType":"string"}},"required":true}}}, + proposal: {"in":"body","name":"proposal","required":true,"ref":"AcceptProofProposalOptions"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; @@ -1630,6 +1873,36 @@ export function RegisterRoutes(app: express.Router) { } }); // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + app.post('/proofs/create-request', + ...(fetchMiddlewares(ProofController)), + ...(fetchMiddlewares(ProofController.prototype.createRequest)), + + async function ProofController_createRequest(request: any, response: any, next: any) { + const args = { + request: {"in":"body","name":"request","required":true,"ref":"CreateProofRequestOptions"}, + }; + + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa + + let validatedArgs: any[] = []; + try { + validatedArgs = getValidatedArgs(args, request, response); + + const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer; + + const controller: any = await container.get(ProofController); + if (typeof controller['setStatus'] === 'function') { + controller.setStatus(undefined); + } + + + const promise = controller.createRequest.apply(controller, validatedArgs as any); + promiseHandler(controller, promise, response, undefined, next); + } catch (err) { + return next(err); + } + }); + // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa app.post('/proofs/request-proof', ...(fetchMiddlewares(ProofController)), ...(fetchMiddlewares(ProofController.prototype.requestProof)), @@ -1669,7 +1942,7 @@ export function RegisterRoutes(app: express.Router) { async function ProofController_acceptRequest(request: any, response: any, next: any) { const args = { proofRecordId: {"in":"path","name":"proofRecordId","required":true,"dataType":"string"}, - request: {"in":"body","name":"request","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"comment":{"dataType":"string"}}}, + request: {"in":"body","name":"request","required":true,"ref":"AcceptProofRequestOptions"}, notFoundError: {"in":"res","name":"404","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"reason":{"dataType":"string","required":true}}}, internalServerError: {"in":"res","name":"500","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"message":{"dataType":"string","required":true}}}, }; diff --git a/packages/rest/src/routes/swagger.json b/packages/rest/src/routes/swagger.json index 3d969c4a..fcf91ffa 100644 --- a/packages/rest/src/routes/swagger.json +++ b/packages/rest/src/routes/swagger.json @@ -91,6 +91,220 @@ "type": "string", "description": "Get the supported protocol versions based on the provided credential protocols." }, + "CredentialPreviewAttributeOptions": { + "properties": { + "name": { + "type": "string" + }, + "mimeType": { + "type": "string" + }, + "value": { + "type": "string" + } + }, + "required": [ + "name", + "value" + ], + "type": "object", + "additionalProperties": false + }, + "Pick_JwsGeneralFormat.Exclude_keyofJwsGeneralFormat.payload__": { + "properties": { + "header": { + "$ref": "#/components/schemas/Record_string.unknown_", + "description": "unprotected header" + }, + "signature": { + "type": "string", + "description": "Base64url encoded signature" + }, + "protected": { + "type": "string", + "description": "Base64url encoded protected header" + } + }, + "required": [ + "header", + "signature", + "protected" + ], + "type": "object", + "description": "From T, pick a set of properties whose keys are in the union K" + }, + "Omit_JwsGeneralFormat.payload_": { + "$ref": "#/components/schemas/Pick_JwsGeneralFormat.Exclude_keyofJwsGeneralFormat.payload__", + "description": "Construct a type with the properties of T except for those in type K." + }, + "JwsDetachedFormat": { + "$ref": "#/components/schemas/Omit_JwsGeneralFormat.payload_" + }, + "JwsFlattenedDetachedFormat": { + "properties": { + "signatures": { + "items": { + "$ref": "#/components/schemas/JwsDetachedFormat" + }, + "type": "array" + } + }, + "required": [ + "signatures" + ], + "type": "object", + "additionalProperties": false + }, + "AttachmentData": { + "description": "A JSON object that gives access to the actual content of the attachment", + "properties": { + "base64": { + "type": "string", + "description": "Base64-encoded data, when representing arbitrary content inline instead of via links. Optional." + }, + "json": { + "$ref": "#/components/schemas/Record_string.unknown_", + "description": "Directly embedded JSON data, when representing content inline instead of via links, and when the content is natively conveyable as JSON. Optional." + }, + "links": { + "items": { + "type": "string" + }, + "type": "array", + "description": "A list of zero or more locations at which the content may be fetched. Optional." + }, + "jws": { + "anyOf": [ + { + "$ref": "#/components/schemas/JwsDetachedFormat" + }, + { + "$ref": "#/components/schemas/JwsFlattenedDetachedFormat" + } + ], + "description": "A JSON Web Signature over the content of the attachment. Optional." + }, + "sha256": { + "type": "string", + "description": "The hash of the content. Optional." + } + }, + "type": "object", + "additionalProperties": false + }, + "Attachment": { + "description": "Represents DIDComm attachment\nhttps://github.com/hyperledger/aries-rfcs/blob/master/concepts/0017-attachments/README.md", + "properties": { + "id": { + "type": "string" + }, + "description": { + "type": "string", + "description": "An optional human-readable description of the content." + }, + "filename": { + "type": "string", + "description": "A hint about the name that might be used if this attachment is persisted as a file. It is not required, and need not be unique. If this field is present and mime-type is not, the extension on the filename may be used to infer a MIME type." + }, + "mimeType": { + "type": "string", + "description": "Describes the MIME type of the attached content. Optional but recommended." + }, + "lastmodTime": { + "type": "string", + "format": "date-time", + "description": "A hint about when the content in this attachment was last modified." + }, + "byteCount": { + "type": "number", + "format": "double", + "description": "Optional, and mostly relevant when content is included by reference instead of by value. Lets the receiver guess how expensive it will be, in time, bandwidth, and storage, to fully fetch the attachment." + }, + "data": { + "$ref": "#/components/schemas/AttachmentData" + } + }, + "required": [ + "id", + "data" + ], + "type": "object", + "additionalProperties": false + }, + "LinkedAttachment": { + "properties": { + "attributeName": { + "type": "string", + "description": "The name that will be used to generate the linked credential" + }, + "attachment": { + "$ref": "#/components/schemas/Attachment", + "description": "The attachment that needs to be linked to the credential" + } + }, + "required": [ + "attributeName", + "attachment" + ], + "type": "object", + "additionalProperties": false + }, + "AnonCredsProposeCredentialFormat": { + "description": "This defines the module payload for calling CredentialsApi.createProposal\nor CredentialsApi.negotiateOffer", + "properties": { + "schemaIssuerId": { + "type": "string" + }, + "schemaId": { + "type": "string" + }, + "schemaName": { + "type": "string" + }, + "schemaVersion": { + "type": "string" + }, + "credentialDefinitionId": { + "type": "string" + }, + "issuerId": { + "type": "string" + }, + "attributes": { + "items": { + "$ref": "#/components/schemas/CredentialPreviewAttributeOptions" + }, + "type": "array" + }, + "linkedAttachments": { + "items": { + "$ref": "#/components/schemas/LinkedAttachment" + }, + "type": "array" + }, + "schemaIssuerDid": { + "type": "string" + }, + "issuerDid": { + "type": "string" + } + }, + "type": "object", + "additionalProperties": false + }, + "Pick_AnonCredsProposeCredentialFormat.Exclude_keyofAnonCredsProposeCredentialFormat.schemaIssuerId-or-issuerId__": { + "properties": {}, + "type": "object", + "description": "From T, pick a set of properties whose keys are in the union K" + }, + "Omit_AnonCredsProposeCredentialFormat.schemaIssuerId-or-issuerId_": { + "$ref": "#/components/schemas/Pick_AnonCredsProposeCredentialFormat.Exclude_keyofAnonCredsProposeCredentialFormat.schemaIssuerId-or-issuerId__", + "description": "Construct a type with the properties of T except for those in type K." + }, + "LegacyIndyProposeCredentialFormat": { + "$ref": "#/components/schemas/Omit_AnonCredsProposeCredentialFormat.schemaIssuerId-or-issuerId_", + "description": "This defines the module payload for calling CredentialsApi.createProposal\nor CredentialsApi.negotiateOffer\n\nNOTE: This doesn't include the `issuerId` and `schemaIssuerId` properties that are present in the newer format." + }, "AutoAcceptCredential": { "description": "Typing of the state for auto acceptance", "enum": [ @@ -108,59 +322,26 @@ "credentialFormats": { "properties": { "indy": { - "properties": { - "attributes": { - "items": { - "properties": { - "value": { - "type": "string" - }, - "name": { - "type": "string" - } - }, - "required": [ - "value", - "name" - ], - "type": "object" - }, - "type": "array" + "anyOf": [ + { + "$ref": "#/components/schemas/AnonCredsProposeCredentialFormat" }, - "issuerDid": { - "type": "string" - }, - "credentialDefinitionId": { - "type": "string" - }, - "schemaVersion": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "schemaId": { - "type": "string" + { + "$ref": "#/components/schemas/LegacyIndyProposeCredentialFormat" + } + ] + }, + "anoncreds": { + "anyOf": [ + { + "$ref": "#/components/schemas/AnonCredsProposeCredentialFormat" }, - "schemaIssuerDid": { - "type": "string" + { + "$ref": "#/components/schemas/LegacyIndyProposeCredentialFormat" } - }, - "required": [ - "attributes", - "issuerDid", - "credentialDefinitionId", - "schemaVersion", - "schemaName", - "schemaId", - "schemaIssuerDid" - ], - "type": "object" + ] } }, - "required": [ - "indy" - ], "type": "object" }, "autoAcceptCredential": { @@ -181,64 +362,39 @@ "type": "object", "additionalProperties": false }, + "AnonCredsAcceptProposalFormat": { + "description": "This defines the module payload for calling CredentialsApi.acceptProposal", + "properties": { + "credentialDefinitionId": { + "type": "string" + }, + "attributes": { + "items": { + "$ref": "#/components/schemas/CredentialPreviewAttributeOptions" + }, + "type": "array" + }, + "linkedAttachments": { + "items": { + "$ref": "#/components/schemas/LinkedAttachment" + }, + "type": "array" + } + }, + "type": "object", + "additionalProperties": false + }, "AcceptCredentialProposalOptions": { "properties": { "credentialFormats": { "properties": { "indy": { - "properties": { - "attributes": { - "items": { - "properties": { - "value": { - "type": "string" - }, - "name": { - "type": "string" - } - }, - "required": [ - "value", - "name" - ], - "type": "object" - }, - "type": "array" - }, - "issuerDid": { - "type": "string" - }, - "credentialDefinitionId": { - "type": "string" - }, - "schemaVersion": { - "type": "string" - }, - "schemaName": { - "type": "string" - }, - "schemaId": { - "type": "string" - }, - "schemaIssuerDid": { - "type": "string" - } - }, - "required": [ - "attributes", - "issuerDid", - "credentialDefinitionId", - "schemaVersion", - "schemaName", - "schemaId", - "schemaIssuerDid" - ], - "type": "object" + "$ref": "#/components/schemas/AnonCredsAcceptProposalFormat" + }, + "anoncreds": { + "$ref": "#/components/schemas/AnonCredsAcceptProposalFormat" } }, - "required": [ - "indy" - ], "type": "object" }, "autoAcceptCredential": { @@ -251,48 +407,51 @@ "type": "object", "additionalProperties": false }, + "AnonCredsOfferCredentialFormat": { + "description": "This defines the module payload for calling CredentialsApi.offerCredential\nor CredentialsApi.negotiateProposal", + "properties": { + "credentialDefinitionId": { + "type": "string" + }, + "attributes": { + "items": { + "$ref": "#/components/schemas/CredentialPreviewAttributeOptions" + }, + "type": "array" + }, + "linkedAttachments": { + "items": { + "$ref": "#/components/schemas/LinkedAttachment" + }, + "type": "array" + } + }, + "required": [ + "credentialDefinitionId", + "attributes" + ], + "type": "object", + "additionalProperties": false + }, + "CredentialFormatPayload_CredentialFormats.createOffer_": { + "properties": { + "indy": { + "$ref": "#/components/schemas/AnonCredsOfferCredentialFormat" + }, + "anoncreds": { + "$ref": "#/components/schemas/AnonCredsOfferCredentialFormat" + } + }, + "type": "object", + "description": "Get the payload for a specific method from a list of CredentialFormat interfaces and a method" + }, "CreateOfferOptions": { "properties": { "protocolVersion": { "$ref": "#/components/schemas/CredentialProtocolVersionType_CredentialProtocols_" }, "credentialFormats": { - "properties": { - "indy": { - "properties": { - "attributes": { - "items": { - "properties": { - "value": { - "type": "string" - }, - "name": { - "type": "string" - } - }, - "required": [ - "value", - "name" - ], - "type": "object" - }, - "type": "array" - }, - "credentialDefinitionId": { - "type": "string" - } - }, - "required": [ - "attributes", - "credentialDefinitionId" - ], - "type": "object" - } - }, - "required": [ - "indy" - ], - "type": "object" + "$ref": "#/components/schemas/CredentialFormatPayload_CredentialFormats.createOffer_" }, "autoAcceptCredential": { "$ref": "#/components/schemas/AutoAcceptCredential" @@ -314,42 +473,7 @@ "$ref": "#/components/schemas/CredentialProtocolVersionType_CredentialProtocols_" }, "credentialFormats": { - "properties": { - "indy": { - "properties": { - "attributes": { - "items": { - "properties": { - "value": { - "type": "string" - }, - "name": { - "type": "string" - } - }, - "required": [ - "value", - "name" - ], - "type": "object" - }, - "type": "array" - }, - "credentialDefinitionId": { - "type": "string" - } - }, - "required": [ - "attributes", - "credentialDefinitionId" - ], - "type": "object" - } - }, - "required": [ - "indy" - ], - "type": "object" + "$ref": "#/components/schemas/CredentialFormatPayload_CredentialFormats.createOffer_" }, "autoAcceptCredential": { "$ref": "#/components/schemas/AutoAcceptCredential" @@ -369,8 +493,25 @@ "type": "object", "additionalProperties": false }, + "AnonCredsAcceptOfferFormat": { + "description": "This defines the module payload for calling CredentialsApi.acceptOffer. No options are available for this\nmethod, so it's an empty object", + "properties": { + "linkSecretId": { + "type": "string" + } + }, + "type": "object", + "additionalProperties": false + }, "CredentialFormatPayload_CredentialFormats.acceptOffer_": { - "properties": {}, + "properties": { + "indy": { + "$ref": "#/components/schemas/AnonCredsAcceptOfferFormat" + }, + "anoncreds": { + "$ref": "#/components/schemas/AnonCredsAcceptOfferFormat" + } + }, "type": "object", "description": "Get the payload for a specific method from a list of CredentialFormat interfaces and a method" }, @@ -389,8 +530,31 @@ "type": "object", "additionalProperties": false }, + "AnonCredsAcceptRequestFormat": { + "$ref": "#/components/schemas/Record_string.never_", + "description": "This defines the module payload for calling CredentialsApi.acceptRequest. No options are available for this\nmethod, so it's an empty object" + }, + "Record_string.never_": { + "properties": { + "indy": { + "$ref": "#/components/schemas/AnonCredsAcceptRequestFormat" + }, + "anoncreds": { + "$ref": "#/components/schemas/AnonCredsAcceptRequestFormat" + } + }, + "type": "object", + "description": "Construct a type with a set of properties K of type T" + }, "CredentialFormatPayload_CredentialFormats.acceptRequest_": { - "properties": {}, + "properties": { + "indy": { + "$ref": "#/components/schemas/AnonCredsAcceptRequestFormat" + }, + "anoncreds": { + "$ref": "#/components/schemas/AnonCredsAcceptRequestFormat" + } + }, "type": "object", "description": "Get the payload for a specific method from a list of CredentialFormat interfaces and a method" }, @@ -869,6 +1033,10 @@ "type": "object", "additionalProperties": false }, + "ProofsProtocolVersionType_ProofProtocols_": { + "type": "string", + "description": "Get the supported protocol versions based on the provided proof protocols." + }, "AnonCredsPresentationPreviewAttribute": { "properties": { "name": { @@ -887,114 +1055,233 @@ "type": "string" } }, - "required": [ - "name" - ], + "required": [ + "name" + ], + "type": "object", + "additionalProperties": false + }, + "AnonCredsPredicateType": { + "type": "string", + "enum": [ + ">=", + ">", + "<=", + "<" + ] + }, + "AnonCredsPresentationPreviewPredicate": { + "properties": { + "name": { + "type": "string" + }, + "credentialDefinitionId": { + "type": "string" + }, + "predicate": { + "$ref": "#/components/schemas/AnonCredsPredicateType" + }, + "threshold": { + "type": "number", + "format": "double" + } + }, + "required": [ + "name", + "credentialDefinitionId", + "predicate", + "threshold" + ], + "type": "object", + "additionalProperties": false + }, + "AnonCredsProposeProofFormat": { + "description": "Interface for creating an anoncreds proof proposal.", + "properties": { + "name": { + "type": "string" + }, + "version": { + "type": "string" + }, + "attributes": { + "items": { + "$ref": "#/components/schemas/AnonCredsPresentationPreviewAttribute" + }, + "type": "array" + }, + "predicates": { + "items": { + "$ref": "#/components/schemas/AnonCredsPresentationPreviewPredicate" + }, + "type": "array" + } + }, + "type": "object", + "additionalProperties": false + }, + "ProofFormatPayload_ProofFormats.createProposal_": { + "properties": { + "indy": { + "$ref": "#/components/schemas/AnonCredsProposeProofFormat" + }, + "anoncreds": { + "$ref": "#/components/schemas/AnonCredsProposeProofFormat" + } + }, + "type": "object", + "description": "Get the payload for a specific method from a list of ProofFormat interfaces and a method" + }, + "AutoAcceptProof": { + "description": "Typing of the state for auto acceptance", + "enum": [ + "always", + "contentApproved", + "never" + ], + "type": "string" + }, + "ProposeProofOptions": { + "properties": { + "connectionId": { + "type": "string" + }, + "protocolVersion": { + "$ref": "#/components/schemas/ProofsProtocolVersionType_ProofProtocols_" + }, + "proofFormats": { + "$ref": "#/components/schemas/ProofFormatPayload_ProofFormats.createProposal_" + }, + "goalCode": { + "type": "string" + }, + "parentThreadId": { + "type": "string" + }, + "autoAcceptProof": { + "$ref": "#/components/schemas/AutoAcceptProof" + }, + "comment": { + "type": "string" + } + }, + "required": [ + "connectionId", + "protocolVersion", + "proofFormats" + ], + "type": "object", + "additionalProperties": false + }, + "ProofFormatPayload_ProofFormats.acceptProposal_": { + "properties": { + "indy": { + "properties": { + "version": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "type": "object" + }, + "anoncreds": { + "properties": { + "version": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "type": "object" + } + }, "type": "object", - "additionalProperties": false - }, - "AnonCredsPredicateType": { - "type": "string", - "enum": [ - ">=", - ">", - "<=", - "<" - ] + "description": "Get the payload for a specific method from a list of ProofFormat interfaces and a method" }, - "AnonCredsPresentationPreviewPredicate": { + "AcceptProofProposalOptions": { "properties": { - "name": { - "type": "string" + "proofFormats": { + "$ref": "#/components/schemas/ProofFormatPayload_ProofFormats.acceptProposal_" }, - "credentialDefinitionId": { + "goalCode": { "type": "string" }, - "predicate": { - "$ref": "#/components/schemas/AnonCredsPredicateType" + "willConfirm": { + "type": "boolean" }, - "threshold": { - "type": "number", - "format": "double" + "autoAcceptProof": { + "$ref": "#/components/schemas/AutoAcceptProof" + }, + "comment": { + "type": "string" } }, - "required": [ - "name", - "credentialDefinitionId", - "predicate", - "threshold" - ], "type": "object", "additionalProperties": false }, - "RequestProofProposalOptions": { + "AgentMessage": { + "$ref": "#/components/schemas/Record_string.unknown_" + }, + "ProofExchangeRecord": { + "$ref": "#/components/schemas/Record_string.unknown_" + }, + "AnonCredsNonRevokedInterval": { "properties": { - "connectionId": { - "type": "string" - }, - "attributes": { - "items": { - "$ref": "#/components/schemas/AnonCredsPresentationPreviewAttribute" - }, - "type": "array" - }, - "predicates": { - "items": { - "$ref": "#/components/schemas/AnonCredsPresentationPreviewPredicate" - }, - "type": "array" + "from": { + "type": "number", + "format": "double" }, - "comment": { - "type": "string" + "to": { + "type": "number", + "format": "double" } }, - "required": [ - "connectionId", - "attributes", - "predicates" - ], "type": "object", "additionalProperties": false }, - "RequestProofOptionsProofRequestRestriction": { + "AnonCredsProofRequestRestrictionOptions": { "properties": { - "schemaId": { + "schema_id": { "type": "string" }, - "schemaIssuerId": { + "schema_issuer_id": { "type": "string" }, - "schemaName": { + "schema_name": { "type": "string" }, - "schemaVersion": { + "schema_version": { "type": "string" }, - "issuerId": { + "issuer_id": { "type": "string" }, - "credDefId": { + "cred_def_id": { "type": "string" }, - "revRegId": { + "rev_reg_id": { "type": "string" }, - "schemaIssuerDid": { + "schema_issuer_did": { "type": "string" }, - "issuerDid": { + "issuer_did": { "type": "string" }, - "requiredAttributes": { - "items": { + "attributeValues": { + "properties": {}, + "additionalProperties": { "type": "string" }, - "type": "array" + "type": "object" }, - "requiredAttributeValues": { + "attributeMarkers": { "properties": {}, "additionalProperties": { - "type": "string" + "type": "boolean" }, "type": "object" } @@ -1002,21 +1289,7 @@ "type": "object", "additionalProperties": false }, - "AnonCredsNonRevokedInterval": { - "properties": { - "from": { - "type": "number", - "format": "double" - }, - "to": { - "type": "number", - "format": "double" - } - }, - "type": "object", - "additionalProperties": false - }, - "RequestProofOptionsRequestedAttribute": { + "AnonCredsRequestedAttributeOptions": { "properties": { "name": { "type": "string" @@ -1029,88 +1302,182 @@ }, "restrictions": { "items": { - "$ref": "#/components/schemas/RequestProofOptionsProofRequestRestriction" + "$ref": "#/components/schemas/AnonCredsProofRequestRestrictionOptions" }, "type": "array" }, - "nonRevoked": { + "non_revoked": { "$ref": "#/components/schemas/AnonCredsNonRevokedInterval" } }, "type": "object", "additionalProperties": false }, - "RequestProofOptionsRequestedPredicate": { + "AnonCredsRequestedPredicateOptions": { "properties": { "name": { "type": "string" }, - "pType": { + "p_type": { "$ref": "#/components/schemas/AnonCredsPredicateType" }, - "pValue": { + "p_value": { "type": "number", "format": "double" }, "restrictions": { "items": { - "$ref": "#/components/schemas/RequestProofOptionsProofRequestRestriction" + "$ref": "#/components/schemas/AnonCredsProofRequestRestrictionOptions" }, "type": "array" }, - "nonRevoked": { + "non_revoked": { "$ref": "#/components/schemas/AnonCredsNonRevokedInterval" } }, "required": [ "name", - "pType", - "pValue" + "p_type", + "p_value" ], "type": "object", "additionalProperties": false }, - "RequestProofOptions": { + "AnonCredsRequestProofFormatOptions": { "properties": { - "connectionId": { + "name": { + "type": "string" + }, + "version": { "type": "string" }, - "proofRequestOptions": { + "non_revoked": { + "$ref": "#/components/schemas/AnonCredsNonRevokedInterval" + }, + "requested_attributes": { + "properties": {}, + "additionalProperties": { + "$ref": "#/components/schemas/AnonCredsRequestedAttributeOptions" + }, + "type": "object" + }, + "requested_predicates": { + "properties": {}, + "additionalProperties": { + "$ref": "#/components/schemas/AnonCredsRequestedPredicateOptions" + }, + "type": "object" + } + }, + "required": [ + "name", + "version" + ], + "type": "object", + "additionalProperties": false + }, + "CreateProofRequestOptions": { + "properties": { + "protocolVersion": { + "$ref": "#/components/schemas/ProofsProtocolVersionType_ProofProtocols_" + }, + "proofFormats": { "properties": { - "requestedPredicates": { - "properties": {}, - "additionalProperties": { - "$ref": "#/components/schemas/RequestProofOptionsRequestedPredicate" - }, - "type": "object" - }, - "requestedAttributes": { - "properties": {}, - "additionalProperties": { - "$ref": "#/components/schemas/RequestProofOptionsRequestedAttribute" - }, - "type": "object" + "indy": { + "$ref": "#/components/schemas/AnonCredsRequestProofFormatOptions" }, - "version": { - "type": "string" + "anoncreds": { + "$ref": "#/components/schemas/AnonCredsRequestProofFormatOptions" + } + }, + "type": "object" + }, + "goalCode": { + "type": "string" + }, + "parentThreadId": { + "type": "string" + }, + "willConfirm": { + "type": "boolean" + }, + "autoAcceptProof": { + "$ref": "#/components/schemas/AutoAcceptProof" + }, + "comment": { + "type": "string" + } + }, + "required": [ + "protocolVersion", + "proofFormats" + ], + "type": "object", + "additionalProperties": false + }, + "RequestProofOptions": { + "properties": { + "protocolVersion": { + "$ref": "#/components/schemas/ProofsProtocolVersionType_ProofProtocols_" + }, + "proofFormats": { + "properties": { + "indy": { + "$ref": "#/components/schemas/AnonCredsRequestProofFormatOptions" }, - "name": { - "type": "string" + "anoncreds": { + "$ref": "#/components/schemas/AnonCredsRequestProofFormatOptions" } }, - "required": [ - "version", - "name" - ], "type": "object" + }, + "goalCode": { + "type": "string" + }, + "parentThreadId": { + "type": "string" + }, + "willConfirm": { + "type": "boolean" + }, + "autoAcceptProof": { + "$ref": "#/components/schemas/AutoAcceptProof" + }, + "comment": { + "type": "string" + }, + "connectionId": { + "type": "string" } }, "required": [ - "connectionId", - "proofRequestOptions" + "protocolVersion", + "proofFormats", + "connectionId" ], "type": "object", "additionalProperties": false + }, + "AcceptProofRequestOptions": { + "properties": { + "useReturnRoute": { + "type": "boolean" + }, + "goalCode": { + "type": "string" + }, + "willConfirm": { + "type": "boolean" + }, + "autoAcceptProof": { + "$ref": "#/components/schemas/AutoAcceptProof" + }, + "comment": { + "type": "string" + } + }, + "type": "object", + "additionalProperties": false } }, "securitySchemes": {} @@ -4275,7 +4642,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RequestProofProposalOptions" + "$ref": "#/components/schemas/ProposeProofOptions" } } } @@ -4362,26 +4729,66 @@ "content": { "application/json": { "schema": { - "properties": { - "comment": { - "type": "string" + "$ref": "#/components/schemas/AcceptProofProposalOptions" + } + } + } + } + } + }, + "/proofs/create-request": { + "post": { + "operationId": "CreateRequest", + "responses": { + "200": { + "description": "ProofRequestMessageResponse", + "content": { + "application/json": { + "schema": { + "properties": { + "proofRecord": { + "$ref": "#/components/schemas/ProofExchangeRecord" + }, + "message": { + "$ref": "#/components/schemas/AgentMessage" + } }, - "request": { - "properties": { - "version": { - "type": "string" - }, - "name": { - "type": "string" + "required": [ + "proofRecord", + "message" + ], + "type": "object" + }, + "examples": { + "Example 1": { + "value": { + "message": {}, + "proofRecord": { + "id": "821f9b26-ad04-4f56-89b6-e2ef9c72b36e", + "protocolVersion": "v2", + "threadId": "0019d466-5eea-4269-8c40-031b4896c5b7", + "connectionId": "2aecf74c-3073-4f98-9acb-92415d096834", + "createdAt": "2022-01-01T00:00:00.000Z" } - }, - "type": "object" + } } - }, - "required": [ - "request" - ], - "type": "object" + } + } + } + } + }, + "description": "Creates a presentation request not bound to any proposal or existing connection", + "tags": [ + "Proofs" + ], + "security": [], + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CreateProofRequestOptions" } } } @@ -4546,12 +4953,7 @@ "content": { "application/json": { "schema": { - "properties": { - "comment": { - "type": "string" - } - }, - "type": "object" + "$ref": "#/components/schemas/AcceptProofRequestOptions" } } } diff --git a/packages/rest/src/utils/agent.ts b/packages/rest/src/utils/agent.ts index 8039aee0..69f0cd83 100644 --- a/packages/rest/src/utils/agent.ts +++ b/packages/rest/src/utils/agent.ts @@ -1,10 +1,20 @@ -import type { AnonCredsProofFormatService } from '@aries-framework/anoncreds' -import type { V2CredentialProtocol, V2ProofProtocol } from '@aries-framework/core' +import type { ModulesMap } from '@aries-framework/core' +import type { IndyVdrPoolConfig } from '@aries-framework/indy-vdr' -import { AnonCredsModule } from '@aries-framework/anoncreds' +import { + AnonCredsCredentialFormatService, + AnonCredsProofFormatService, + V1CredentialProtocol, + AnonCredsModule, + LegacyIndyCredentialFormatService, + LegacyIndyProofFormatService, + V1ProofProtocol, +} from '@aries-framework/anoncreds' import { AnonCredsRsModule } from '@aries-framework/anoncreds-rs' import { AskarModule } from '@aries-framework/askar' import { + V2CredentialProtocol, + V2ProofProtocol, Agent, AutoAcceptCredential, AutoAcceptProof, @@ -25,24 +35,109 @@ import path from 'path' import { TsLogger } from './logger' import { BCOVRIN_TEST_GENESIS } from './util' -export type RestAgent = Agent<{ +export interface RestAgentModules extends ModulesMap { connections: ConnectionsModule - proofs: ProofsModule<[V2ProofProtocol<[AnonCredsProofFormatService]>]> - credentials: CredentialsModule<[V2CredentialProtocol]> - indyVdr: IndyVdrModule - anoncredsRs: AnonCredsRsModule + proofs: ProofsModule<[V1ProofProtocol, V2ProofProtocol<[LegacyIndyProofFormatService, AnonCredsProofFormatService]>]> + credentials: CredentialsModule<[V1CredentialProtocol, V2CredentialProtocol]> anoncreds: AnonCredsModule - askar: AskarModule - mediator: MediatorModule -}> +} + +export type RestAgent< + modules extends RestAgentModules = { + connections: ConnectionsModule + proofs: ProofsModule< + [V1ProofProtocol, V2ProofProtocol<[LegacyIndyProofFormatService, AnonCredsProofFormatService]>] + > + credentials: CredentialsModule<[V1CredentialProtocol, V2CredentialProtocol]> + anoncreds: AnonCredsModule + } +> = Agent export const genesisPath = process.env.GENESIS_TXN_PATH ? path.resolve(process.env.GENESIS_TXN_PATH) : path.join(__dirname, '../../../../network/genesis/local-genesis.txn') +export const getAgentModules = (options: { + autoAcceptConnections: boolean + autoAcceptProofs: AutoAcceptProof + autoAcceptCredentials: AutoAcceptCredential + autoAcceptMediationRequests: boolean + indyLedgers?: [IndyVdrPoolConfig, ...IndyVdrPoolConfig[]] +}): RestAgentModules => { + const legacyIndyCredentialFormatService = new LegacyIndyCredentialFormatService() + const legacyIndyProofFormatService = new LegacyIndyProofFormatService() + + const modules: RestAgentModules = { + connections: new ConnectionsModule({ + autoAcceptConnections: options.autoAcceptConnections, + }), + proofs: new ProofsModule({ + autoAcceptProofs: options.autoAcceptProofs, + proofProtocols: [ + new V1ProofProtocol({ + indyProofFormat: legacyIndyProofFormatService, + }), + new V2ProofProtocol({ + proofFormats: [legacyIndyProofFormatService, new AnonCredsProofFormatService()], + }), + ], + }), + credentials: new CredentialsModule({ + autoAcceptCredentials: options.autoAcceptCredentials, + credentialProtocols: [ + new V1CredentialProtocol({ + indyCredentialFormat: legacyIndyCredentialFormatService, + }), + new V2CredentialProtocol({ + credentialFormats: [legacyIndyCredentialFormatService, new AnonCredsCredentialFormatService()], + }), + ], + }), + anoncreds: new AnonCredsModule({ + registries: [new IndyVdrAnonCredsRegistry()], + }), + anoncredsRs: new AnonCredsRsModule({ + anoncreds, + }), + askar: new AskarModule({ + ariesAskar, + }), + mediator: new MediatorModule({ + autoAcceptMediationRequests: options.autoAcceptMediationRequests, + }), + } + + if (!options.indyLedgers) { + return modules + } + + return { + ...modules, + indyVdr: new IndyVdrModule({ + indyVdr, + networks: options.indyLedgers, + }), + } +} + export const setupAgent = async ({ name, endpoints, port }: { name: string; endpoints: string[]; port: number }) => { const logger = new TsLogger(LogLevel.debug) + const modules = getAgentModules({ + autoAcceptConnections: true, + autoAcceptProofs: AutoAcceptProof.ContentApproved, + autoAcceptCredentials: AutoAcceptCredential.ContentApproved, + autoAcceptMediationRequests: true, + indyLedgers: [ + { + isProduction: false, + indyNamespace: 'bcovrin:test', + genesisTransactions: BCOVRIN_TEST_GENESIS, + connectOnStartup: true, + }, + ], + }) + const agent = new Agent({ config: { label: name, @@ -53,40 +148,7 @@ export const setupAgent = async ({ name, endpoints, port }: { name: string; endp autoUpdateStorageOnStartup: true, }, dependencies: agentDependencies, - modules: { - connections: new ConnectionsModule({ - autoAcceptConnections: true, - }), - proofs: new ProofsModule({ - autoAcceptProofs: AutoAcceptProof.ContentApproved, - }), - credentials: new CredentialsModule({ - autoAcceptCredentials: AutoAcceptCredential.ContentApproved, - }), - indyVdr: new IndyVdrModule({ - indyVdr, - networks: [ - { - isProduction: false, - indyNamespace: 'bcovrin:test', - genesisTransactions: BCOVRIN_TEST_GENESIS, - connectOnStartup: true, - }, - ], - }), - anoncredsRs: new AnonCredsRsModule({ - anoncreds, - }), - anoncreds: new AnonCredsModule({ - registries: [new IndyVdrAnonCredsRegistry()], - }), - askar: new AskarModule({ - ariesAskar, - }), - mediator: new MediatorModule({ - autoAcceptMediationRequests: true, - }), - }, + modules, }) const httpInbound = new HttpInboundTransport({ diff --git a/packages/rest/src/utils/helpers.ts b/packages/rest/src/utils/helpers.ts index a66b4a69..620f053c 100644 --- a/packages/rest/src/utils/helpers.ts +++ b/packages/rest/src/utils/helpers.ts @@ -1,6 +1,19 @@ import { JsonTransformer } from '@aries-framework/core' import { JsonEncoder } from '@aries-framework/core/build/utils/JsonEncoder' +export function maybeMapValues( + transform: (input: V) => U, + obj?: { + [key: string]: V + } +) { + if (!obj) { + return obj + } + + return Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, transform(value)])) +} + export function objectToJson(result: T) { const serialized = JsonTransformer.serialize(result) return JsonEncoder.fromString(serialized) diff --git a/packages/rest/tests/credential.test.ts b/packages/rest/tests/credential.test.ts index 0e9cd4b1..0a9e4af5 100644 --- a/packages/rest/tests/credential.test.ts +++ b/packages/rest/tests/credential.test.ts @@ -1,3 +1,4 @@ +import type { AcceptCredentialProposalOptions, ProposeCredentialOptions } from '../src/controllers/types' import type { Agent, CredentialStateChangedEvent, OutOfBandRecord } from '@aries-framework/core' import type { Server } from 'net' @@ -137,7 +138,7 @@ describe('CredentialController', () => { const spy = jest.spyOn(bobAgent.credentials, 'proposeCredential').mockResolvedValueOnce(testCredential) const getResult = (): Promise => spy.mock.results[0].value - const proposalRequest = { + const proposalRequest: ProposeCredentialOptions = { connectionId: '000000aa-aa00-00a0-aa00-000a0aa00000', protocolVersion: 'v1', credentialFormats: { @@ -177,15 +178,10 @@ describe('CredentialController', () => { const spy = jest.spyOn(bobAgent.credentials, 'acceptProposal').mockResolvedValueOnce(testCredential) const getResult = (): Promise => spy.mock.results[0].value - const proposalRequest = { + const proposalRequest: AcceptCredentialProposalOptions = { credentialFormats: { indy: { credentialDefinitionId: 'WghBqNdoFjaYh6F5N9eBF:3:CL:3210:test', - issuerDid: 'WghBqNdoFjaYh6F5N9eBF', - schemaId: 'WgWxqztrNooG92RXvxSTWv:2:test:1.0', - schemaIssuerDid: 'WghBqNdoFjaYh6F5N9eBF', - schemaName: 'test', - schemaVersion: '1.0', attributes: [ { name: 'name', @@ -194,7 +190,7 @@ describe('CredentialController', () => { ], }, }, - autoAcceptCredential: 'always', + autoAcceptCredential: 'always' as AutoAcceptCredential, comment: 'test', } diff --git a/packages/rest/tests/proof.test.ts b/packages/rest/tests/proof.test.ts index 89b02460..8c538649 100644 --- a/packages/rest/tests/proof.test.ts +++ b/packages/rest/tests/proof.test.ts @@ -1,8 +1,13 @@ -import type { RequestProofProposalOptions } from '../src/controllers/types' +import type { + AcceptProofProposalOptions, + CreateProofRequestOptions, + ProposeProofOptions, + RequestProofOptions, +} from '../src/controllers/types' import type { Agent, ProofStateChangedEvent } from '@aries-framework/core' import type { Server } from 'net' -import { ProofEventTypes, ProofExchangeRecord, ProofState } from '@aries-framework/core' +import { AgentMessage, ProofEventTypes, ProofExchangeRecord, ProofState } from '@aries-framework/core' import request from 'supertest' import WebSocket from 'ws' @@ -14,6 +19,7 @@ describe('ProofController', () => { let app: Server let aliceAgent: Agent let bobAgent: Agent + let testMessage: AgentMessage let testProof: ProofExchangeRecord beforeAll(async () => { @@ -22,6 +28,7 @@ describe('ProofController', () => { app = await startServer(bobAgent, { port: 3033 }) testProof = getTestProof() + testMessage = new AgentMessage() }) afterEach(() => { @@ -89,15 +96,20 @@ describe('ProofController', () => { }) describe('Propose proof', () => { - const proposalRequest: RequestProofProposalOptions = { + const proposalRequest: ProposeProofOptions = { connectionId: '123456aa-aa78-90a1-aa23-456a7da89010', - attributes: [ - { - name: 'test', - credentialDefinitionId: 'WghBqNdoFjaYh6F5N9eBF:3:CL:3210:test', + protocolVersion: 'v2', + proofFormats: { + indy: { + attributes: [ + { + name: 'test', + credentialDefinitionId: 'WghBqNdoFjaYh6F5N9eBF:3:CL:3210:test', + }, + ], + predicates: [], }, - ], - predicates: [], + }, comment: 'test', } test('should return proof record', async () => { @@ -106,17 +118,7 @@ describe('ProofController', () => { const response = await request(app).post('/proofs/propose-proof').send(proposalRequest) - expect(spy).toHaveBeenCalledWith({ - connectionId: proposalRequest.connectionId, - protocolVersion: 'v2', - proofFormats: { - anoncreds: { - attributes: proposalRequest.attributes, - predicates: proposalRequest.predicates, - }, - }, - comment: proposalRequest.comment, - }) + expect(spy).toHaveBeenCalledWith(proposalRequest) expect(response.statusCode).toBe(200) expect(response.body).toEqual(objectToJson(await getResult())) }) @@ -129,10 +131,12 @@ describe('ProofController', () => { }) describe('Accept proof proposal', () => { - const acceptRequest = { - request: { - name: 'string', - version: 'string', + const acceptRequest: AcceptProofProposalOptions = { + proofFormats: { + anoncreds: { + name: 'string', + version: 'string', + }, }, comment: 'string', } @@ -145,13 +149,7 @@ describe('ProofController', () => { expect(spy).toHaveBeenCalledWith({ proofRecordId: testProof.id, - proofFormats: { - anoncreds: { - name: acceptRequest.request.name, - version: acceptRequest.request.version, - }, - }, - comment: acceptRequest.comment, + ...acceptRequest, }) expect(response.statusCode).toBe(200) expect(response.body).toEqual(objectToJson(await getResult())) @@ -164,49 +162,80 @@ describe('ProofController', () => { }) }) - // TODO: how to do out-of-band proof - describe.skip('Request out of band proof', () => { - test('should return proof record', async () => { - const response = await request(app) - .post(`/proofs/request-outofband-proof`) - .send({ - proofRequestOptions: { - name: 'string', - version: '1.0', - requestedAttributes: { - additionalProp1: { - name: 'string', - }, + describe('Request out of band proof', () => { + const proofRequest: CreateProofRequestOptions = { + protocolVersion: 'v1', + proofFormats: { + indy: { + name: 'string', + version: '1.0', + requested_attributes: { + additionalProp1: { + name: 'string', }, }, - }) + }, + }, + } + + test('should return proof record', async () => { + const mockValue = { message: testMessage, proofRecord: testProof } + const spy = jest.spyOn(bobAgent.proofs, 'createRequest').mockResolvedValueOnce(mockValue) + const getResult = (): Promise => spy.mock.results[0].value + + const response = await request(app).post(`/proofs/create-request`).send(proofRequest) expect(response.statusCode).toBe(200) - expect(response.body.proofUrl).toBeDefined() - expect(response.body.proofRecord).toBeDefined() + + const result = await getResult() + expect(response.body.message).toEqual(objectToJson(result.message)) + expect(response.body.proofRecord).toEqual(objectToJson(result.proofRecord)) }) }) describe('Request proof', () => { + const requestProofRequest: RequestProofOptions = { + connectionId: 'string', + protocolVersion: 'v1', + proofFormats: { + indy: { + name: 'string', + version: '1.0', + requested_attributes: { + additionalProp1: { + name: 'string', + }, + }, + }, + }, + } + const requestProofRequestWithAttr: RequestProofOptions = { + connectionId: 'string', + protocolVersion: 'v1', + proofFormats: { + indy: { + name: 'string', + version: '1.0', + requested_attributes: { + additionalProp1: { + name: 'string', + restrictions: [ + { + attributeMarkers: { a: true, b: false }, + attributeValues: { c: 'd', e: 'f' }, + }, + ], + }, + }, + }, + }, + } + test('should return proof record', async () => { const spy = jest.spyOn(bobAgent.proofs, 'requestProof').mockResolvedValueOnce(testProof) const getResult = (): Promise => spy.mock.results[0].value - const response = await request(app) - .post(`/proofs/request-proof`) - .send({ - connectionId: 'string', - proofRequestOptions: { - name: 'string', - version: '1.0', - requestedAttributes: { - additionalProp1: { - name: 'string', - }, - }, - requestedPredicates: {}, - }, - }) + const response = await request(app).post(`/proofs/request-proof`).send(requestProofRequest) expect(response.statusCode).toBe(200) expect(response.body).toEqual(objectToJson(await getResult())) @@ -215,43 +244,14 @@ describe('ProofController', () => { test('should transform proof request attribute restrictions', async () => { const spy = jest.spyOn(bobAgent.proofs, 'requestProof').mockResolvedValueOnce(testProof) - const response = await request(app) - .post(`/proofs/request-proof`) - .send({ - connectionId: 'string', - proofRequestOptions: { - name: 'string', - version: '1.0', - requestedAttributes: { - additionalProp1: { - name: 'string', - restrictions: [ - { - schemaId: 'schemaId', - schemaIssuerId: 'schemaIssuerId', - schemaName: 'schemaName', - schemaVersion: 'schemaVersion', - issuerId: 'issuerId', - credDefId: 'credDefId', - revRegId: 'revRegId', - schemaIssuerDid: 'schemaIssuerDid', - issuerDid: 'issuerDid', - requiredAttributes: ['a', 'b'], - requiredAttributeValues: { c: 'd', e: 'f' }, - }, - ], - }, - }, - requestedPredicates: {}, - }, - }) + const response = await request(app).post(`/proofs/request-proof`).send(requestProofRequestWithAttr) expect(response.statusCode).toBe(200) expect(spy).toHaveBeenCalledWith({ connectionId: 'string', - protocolVersion: 'v2', + protocolVersion: 'v1', proofFormats: { - anoncreds: { + indy: { name: 'string', version: '1.0', requested_attributes: { @@ -259,46 +259,21 @@ describe('ProofController', () => { name: 'string', restrictions: [ { - schema_id: 'schemaId', - schema_issuer_id: 'schemaIssuerId', - schema_name: 'schemaName', - schema_version: 'schemaVersion', - issuer_id: 'issuerId', - cred_def_id: 'credDefId', - rev_reg_id: 'revRegId', - schema_issuer_did: 'schemaIssuerDid', - issuer_did: 'issuerDid', 'attr::a::marker': '1', - 'attr::b::marker': '1', + 'attr::b::marker': '0', 'attr::c::value': 'd', 'attr::e::value': 'f', }, ], }, }, - requested_predicates: {}, }, }, }) }) test('should give 404 not found when connection is not found', async () => { - const response = await request(app) - .post(`/proofs/request-proof`) - .send({ - connectionId: 'string', - proofRequestOptions: { - name: 'string', - version: '1.0', - requestedAttributes: { - additionalProp1: { - name: 'string', - }, - }, - requestedPredicates: {}, - }, - }) - + const response = await request(app).post(`/proofs/request-proof`).send(requestProofRequest) expect(response.statusCode).toBe(404) }) })