diff --git a/apps/vc-api/test/vc-api/workflows/resident-card/resident-card-issuance.exchange.ts b/apps/vc-api/test/vc-api/workflows/resident-card/resident-card-issuance.exchange.ts index 3544e3d..465bf2f 100644 --- a/apps/vc-api/test/vc-api/workflows/resident-card/resident-card-issuance.exchange.ts +++ b/apps/vc-api/test/vc-api/workflows/resident-card/resident-card-issuance.exchange.ts @@ -8,13 +8,13 @@ import { WalletClient } from '../../../wallet-client'; import { VerifiablePresentationDto } from '../../../../src/vc-api/credentials/dtos/verifiable-presentation.dto'; import { CredentialDto } from '../../../../src/vc-api/credentials/dtos/credential.dto'; import { Presentation } from '../../../../src/vc-api/exchanges/types/presentation'; -import { ExchangeDefinitionDto } from '../../../../src/vc-api/exchanges/dtos/exchange-definition.dto'; import { VpRequestInteractServiceType } from '../../../../src/vc-api/exchanges/types/vp-request-interact-service-type'; import { VpRequestQueryType } from '../../../../src/vc-api/exchanges/types/vp-request-query-type'; import { ProvePresentationOptionsDto } from '../../../../src/vc-api/credentials/dtos/prove-presentation-options.dto'; +import { WorkflowConfigDto } from 'src/vc-api/workflows/dtos/create-workflow-request.dto'; export class ResidentCardIssuance { - #exchangeId = 'permanent-resident-card-issuance'; + #workflowId = 'permanent-resident-card-issuance'; #callbackUrl: string; queryType = VpRequestQueryType.didAuth; @@ -22,32 +22,36 @@ export class ResidentCardIssuance { this.#callbackUrl = callbackUrl; } - getExchangeId(): string { - return this.#exchangeId; + getWorkflowId(): string { + return this.#workflowId; } - getExchangeDefinition(): ExchangeDefinitionDto { - const exchangeDefinition: ExchangeDefinitionDto = { - exchangeId: this.#exchangeId, - query: [ - { - type: this.queryType, - credentialQuery: [] + getWorkflowDefinition(): WorkflowConfigDto { + const exchangeDefinition: WorkflowConfigDto = { + id: this.#workflowId, + steps: { + intialStep: { + query: [ + { + type: this.queryType, + credentialQuery: [] + } + ], + interactServices: [ + { + type: VpRequestInteractServiceType.mediatedPresentation + } + ], + callback: [ + { + url: this.#callbackUrl + } + ] } - ], - interactServices: [ - { - type: VpRequestInteractServiceType.mediatedPresentation - } - ], - isOneTime: false, - callback: [ - { - url: this.#callbackUrl - } - ] + }, + initialStep: 'initialStep' }; - return plainToClass(ExchangeDefinitionDto, exchangeDefinition); + return plainToClass(WorkflowConfigDto, exchangeDefinition); } /** diff --git a/apps/vc-api/test/vc-api/workflows/resident-card/resident-card-presentation.exchange.ts b/apps/vc-api/test/vc-api/workflows/resident-card/resident-card-presentation.exchange.ts index 9d085ef..21a0b08 100644 --- a/apps/vc-api/test/vc-api/workflows/resident-card/resident-card-presentation.exchange.ts +++ b/apps/vc-api/test/vc-api/workflows/resident-card/resident-card-presentation.exchange.ts @@ -23,7 +23,7 @@ export class ResidentCardPresentation { getExchangeDefinition(): ExchangeDefinitionDto { const exchangeDefinition: ExchangeDefinitionDto = { - exchangeId: this.#exchangeId, + id: this.#exchangeId, query: [ { type: this.queryType, diff --git a/apps/vc-api/test/vc-api/workflows/resident-card/resident-card.e2e-suite.ts b/apps/vc-api/test/vc-api/workflows/resident-card/resident-card.e2e-suite.ts index 86f8d68..9765a2a 100644 --- a/apps/vc-api/test/vc-api/workflows/resident-card/resident-card.e2e-suite.ts +++ b/apps/vc-api/test/vc-api/workflows/resident-card/resident-card.e2e-suite.ts @@ -20,10 +20,10 @@ const callbackUrlBase = 'http://example.com'; const callbackUrlPath = '/endpoint'; const callbackUrl = `${callbackUrlBase}${callbackUrlPath}`; -export const residentCardExchangeSuite = () => { +export const residentCardWorkflowSuite = () => { it('should support Resident Card issuance and presentation', async () => { - // As issuer, configure credential issuance exchange - // POST /exchanges + // As issuer, configure credential issuance workflow + // POST /workflows const exchange = new ResidentCardIssuance(callbackUrl); const numHolderQueriesPriorToIssuance = 2; const issuanceCallbackScope = nock(callbackUrlBase) @@ -31,13 +31,20 @@ export const residentCardExchangeSuite = () => { .times(numHolderQueriesPriorToIssuance) .reply(201); await request(app.getHttpServer()) - .post(`${vcApiBaseUrl}/exchanges`) - .send(exchange.getExchangeDefinition()) + .post(`${vcApiBaseUrl}/workflows`) + .send(exchange.getWorkflowDefinition()) + .expect(201); + + // As issuer, configure credential issuance exchange + // POST /workflows/{localWorkflowId}/exchanges + await request(app.getHttpServer()) + .post(`${vcApiBaseUrl}/workflows/${exchange.getWorkflowId()}/exchanges/`) + .send(exchange.getWorkflowDefinition()) .expect(201); // As holder, start issuance exchange // POST /exchanges/{exchangeId} - const issuanceExchangeEndpoint = `${vcApiBaseUrl}/exchanges/${exchange.getExchangeId()}`; + const issuanceExchangeEndpoint = `${vcApiBaseUrl}/exchanges/${exchange.getWorkflowId()}`; const issuanceVpRequest = await walletClient.startExchange(issuanceExchangeEndpoint, exchange.queryType); const issuanceExchangeContinuationEndpoint = getContinuationEndpoint(issuanceVpRequest); expect(issuanceExchangeContinuationEndpoint).toContain(issuanceExchangeEndpoint); @@ -67,7 +74,7 @@ export const residentCardExchangeSuite = () => { // TODO TODO TODO!!! How does the issuer know the transactionId? -> Maybe can rely on notification const urlComponents = issuanceExchangeContinuationEndpoint.split('/'); const transactionId = urlComponents.pop(); - const transaction = await walletClient.getExchangeTransaction(exchange.getExchangeId(), transactionId); + const transaction = await walletClient.getExchangeTransaction(exchange.getWorkflowId(), transactionId); // As the issuer, check the result of the transaction verification expect(transaction.presentationSubmission.verificationResult.verified).toBeTruthy(); @@ -80,7 +87,7 @@ export const residentCardExchangeSuite = () => { result: ReviewResult.approved, vp: issuedVP }; - await walletClient.addSubmissionReview(exchange.getExchangeId(), transactionId, submissionReview); + await walletClient.addSubmissionReview(exchange.getWorkflowId(), transactionId, submissionReview); // As the holder, check for a reviewed submission const secondContinuationResponse = await walletClient.continueExchange(