diff --git a/DEVREADME.md b/DEVREADME.md index 73550b193e..98849e0997 100644 --- a/DEVREADME.md +++ b/DEVREADME.md @@ -85,7 +85,7 @@ GENESIS_TXN_PATH=network/genesis/local-genesis.txn TEST_AGENT_PUBLIC_DID_SEED=00 Locally, you might want to run the tests without postgres tests. You can do that by ignoring the tests: ```sh -yarn test --testPathIgnorePatterns ./packages/core/tests/postgres.e2e.test.ts -u +yarn test --testPathIgnorePatterns ./packages/indy-sdk/tests/postgres.e2e.test.ts -u ``` In case you run into trouble running the tests, e.g. complaining about snapshots not being up-to-date, you can try and remove the data stored for the indy-client. On a Unix system with default setup you achieve this by running: diff --git a/packages/anoncreds-rs/tests/indy-flow.test.ts b/packages/anoncreds-rs/tests/indy-flow.test.ts index b201b8c31e..d3b53ed6fe 100644 --- a/packages/anoncreds-rs/tests/indy-flow.test.ts +++ b/packages/anoncreds-rs/tests/indy-flow.test.ts @@ -1,3 +1,4 @@ +import type { AnonCredsCredentialRequest } from '@aries-framework/anoncreds' import type { Wallet } from '@aries-framework/core' import { @@ -225,6 +226,9 @@ describe('Legacy indy format services using anoncreds-rs', () => { }, }) + // Make sure the request contains a prover_did field + expect((requestAttachment.getDataAsJson() as AnonCredsCredentialRequest).prover_did).toBeDefined() + // Issuer processes and accepts request await legacyIndyCredentialFormatService.processRequest(agentContext, { credentialRecord: issuerCredentialRecord, diff --git a/packages/anoncreds/src/formats/LegacyIndyCredentialFormatService.ts b/packages/anoncreds/src/formats/LegacyIndyCredentialFormatService.ts index af8ee049c8..33aba1e7bc 100644 --- a/packages/anoncreds/src/formats/LegacyIndyCredentialFormatService.ts +++ b/packages/anoncreds/src/formats/LegacyIndyCredentialFormatService.ts @@ -53,6 +53,7 @@ import { createAndLinkAttachmentsToPreview, } from '../utils/credential' import { AnonCredsCredentialMetadataKey, AnonCredsCredentialRequestMetadataKey } from '../utils/metadata' +import { generateLegacyProverDidLikeString } from '../utils/proverDid' const INDY_CRED_ABSTRACT = 'hlindy/cred-abstract@v2.0' const INDY_CRED_REQUEST = 'hlindy/cred-req@v2.0' @@ -244,6 +245,12 @@ export class LegacyIndyCredentialFormatService implements CredentialFormatServic linkSecretId: credentialFormats?.indy?.linkSecretId, }) + if (!credentialRequest.prover_did) { + // We just generate a prover did like string, as it's not used for anything and we don't need + // to prove ownership of the did. It's deprecated in AnonCreds v1, but kept for backwards compatibility + credentialRequest.prover_did = generateLegacyProverDidLikeString() + } + credentialRecord.metadata.set( AnonCredsCredentialRequestMetadataKey, credentialRequestMetadata diff --git a/packages/anoncreds/src/formats/__tests__/legacy-indy-format-services.test.ts b/packages/anoncreds/src/formats/__tests__/legacy-indy-format-services.test.ts index 850e9c9a0f..2a8e628097 100644 --- a/packages/anoncreds/src/formats/__tests__/legacy-indy-format-services.test.ts +++ b/packages/anoncreds/src/formats/__tests__/legacy-indy-format-services.test.ts @@ -1,3 +1,5 @@ +import type { AnonCredsCredentialRequest } from '../../models' + import { CredentialState, CredentialExchangeRecord, @@ -187,6 +189,9 @@ describe('Legacy indy format services', () => { offerAttachment, }) + // Make sure the request contains a prover_did field + expect((requestAttachment.getDataAsJson() as AnonCredsCredentialRequest).prover_did).toBeDefined() + // Issuer processes and accepts request await indyCredentialFormatService.processRequest(agentContext, { credentialRecord: issuerCredentialRecord, diff --git a/packages/anoncreds/src/index.ts b/packages/anoncreds/src/index.ts index 11e113699c..eb942ec9ef 100644 --- a/packages/anoncreds/src/index.ts +++ b/packages/anoncreds/src/index.ts @@ -9,3 +9,4 @@ export { AnonCredsModule } from './AnonCredsModule' export { AnonCredsModuleConfig, AnonCredsModuleConfigOptions } from './AnonCredsModuleConfig' export { AnonCredsApi } from './AnonCredsApi' export * from './AnonCredsApiOptions' +export { generateLegacyProverDidLikeString } from './utils/proverDid' diff --git a/packages/indy-sdk/src/anoncreds/utils/proverDid.ts b/packages/anoncreds/src/utils/proverDid.ts similarity index 100% rename from packages/indy-sdk/src/anoncreds/utils/proverDid.ts rename to packages/anoncreds/src/utils/proverDid.ts diff --git a/packages/indy-sdk/src/anoncreds/services/IndySdkHolderService.ts b/packages/indy-sdk/src/anoncreds/services/IndySdkHolderService.ts index 394ed39198..e00718c62c 100644 --- a/packages/indy-sdk/src/anoncreds/services/IndySdkHolderService.ts +++ b/packages/indy-sdk/src/anoncreds/services/IndySdkHolderService.ts @@ -25,14 +25,13 @@ import type { IndyProofRequest, } from 'indy-sdk' -import { AnonCredsLinkSecretRepository } from '@aries-framework/anoncreds' +import { AnonCredsLinkSecretRepository, generateLegacyProverDidLikeString } from '@aries-framework/anoncreds' import { AriesFrameworkError, injectable, inject, utils } from '@aries-framework/core' import { IndySdkError, isIndyError } from '../../error' import { IndySdk, IndySdkSymbol } from '../../types' import { assertIndySdkWallet } from '../../utils/assertIndySdkWallet' import { getIndySeqNoFromUnqualifiedCredentialDefinitionId } from '../utils/identifiers' -import { generateLegacyProverDidLikeString } from '../utils/proverDid' import { indySdkCredentialDefinitionFromAnonCreds, indySdkRevocationRegistryDefinitionFromAnonCreds, diff --git a/packages/indy-sdk/src/anoncreds/services/IndySdkIssuerService.ts b/packages/indy-sdk/src/anoncreds/services/IndySdkIssuerService.ts index ba6c2a1780..d0d0a796d1 100644 --- a/packages/indy-sdk/src/anoncreds/services/IndySdkIssuerService.ts +++ b/packages/indy-sdk/src/anoncreds/services/IndySdkIssuerService.ts @@ -12,12 +12,12 @@ import type { } from '@aries-framework/anoncreds' import type { AgentContext } from '@aries-framework/core' +import { generateLegacyProverDidLikeString } from '@aries-framework/anoncreds' import { injectable, AriesFrameworkError, inject } from '@aries-framework/core' import { IndySdkError, isIndyError } from '../../error' import { IndySdk, IndySdkSymbol } from '../../types' import { assertIndySdkWallet } from '../../utils/assertIndySdkWallet' -import { generateLegacyProverDidLikeString } from '../utils/proverDid' import { createTailsReader } from '../utils/tails' import { indySdkSchemaFromAnonCreds } from '../utils/transform'