Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(anoncreds): include prover_did for legacy indy #1342

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEVREADME.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions packages/anoncreds-rs/tests/indy-flow.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { AnonCredsCredentialRequest } from '@aries-framework/anoncreds'
import type { Wallet } from '@aries-framework/core'

import {
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]'
const INDY_CRED_REQUEST = 'hlindy/[email protected]'
Expand Down Expand Up @@ -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<AnonCredsCredentialRequestMetadata>(
AnonCredsCredentialRequestMetadataKey,
credentialRequestMetadata
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { AnonCredsCredentialRequest } from '../../models'

import {
CredentialState,
CredentialExchangeRecord,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/anoncreds/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down