Skip to content

Commit

Permalink
fix: update credo-ts (fixes bug related to processing creds with lega…
Browse files Browse the repository at this point in the history
…cy ids)
  • Loading branch information
auer-martin committed Apr 18, 2024
1 parent c8d3935 commit cbcb497
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 124 deletions.
14 changes: 7 additions & 7 deletions packages/legacy/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
"test": "echo 'nothing to do'"
},
"dependencies": {
"@credo-ts/anoncreds": "^0.5.1",
"@credo-ts/askar": "^0.5.1",
"@credo-ts/core": "^0.5.1",
"@credo-ts/indy-sdk-to-askar-migration": "^0.5.1",
"@credo-ts/indy-vdr": "^0.5.1",
"@credo-ts/anoncreds": "0.5.1-alpha.19",
"@credo-ts/askar": "0.5.1-alpha.19",
"@credo-ts/core": "0.5.1-alpha.19",
"@credo-ts/indy-sdk-to-askar-migration": "0.5.1-alpha.19",
"@credo-ts/indy-vdr": "0.5.1-alpha.19",
"@credo-ts/push-notifications": "^0.7.0",
"@credo-ts/question-answer": "^0.5.1",
"@credo-ts/question-answer": "0.5.1-alpha.19",
"@credo-ts/react-hooks": "^0.6.0",
"@credo-ts/react-native": "^0.5.1",
"@credo-ts/react-native": "0.5.1-alpha.19",
"@formatjs/intl-datetimeformat": "4.2.4",
"@formatjs/intl-displaynames": "5.2.4",
"@formatjs/intl-getcanonicallocales": "1.7.3",
Expand Down
9 changes: 7 additions & 2 deletions packages/legacy/core/App/utils/anonCredsProofRequestMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
getAnonCredsTagsFromRecord,
} from '@credo-ts/anoncreds'
import {
ClaimFormat,
DifPexCredentialsForRequest,
DifPresentationExchangeDefinition,
DifPresentationExchangeDefinitionV2,
Expand Down Expand Up @@ -150,10 +151,14 @@ export const getDescriptorMetadata = (credentialsForRequest: DifPexCredentialsFo
for (const entry of requestedAttribute.submissionEntry) {
const inputDescriptorId = entry.inputDescriptorId

const recordsWithMetadata = entry.verifiableCredentials.map((record) => {
const recordsWithMetadata = entry.verifiableCredentials.map((submissionEntryCredential) => {
if (submissionEntryCredential.type !== ClaimFormat.LdpVc) {
throw new Error(`Unsupported credential type. ${submissionEntryCredential.type}`)
}
const record = submissionEntryCredential.credentialRecord
const anonCredsTags = getAnonCredsTagsFromRecord(record as W3cCredentialRecord)
if (!anonCredsTags) throw new Error('Missing AnonCreds tags from credential record')
return { record: record as W3cCredentialRecord, anonCredsTags }
return { record, anonCredsTags }
})

if (!descriptorMetadata[inputDescriptorId]) descriptorMetadata[inputDescriptorId] = []
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { getCredentialsForAnonCredsProofRequest } from '@credo-ts/anoncreds'
import {
ClaimFormat,
CredentialExchangeRecord,
CredentialRole,
CredentialState,
Expand Down Expand Up @@ -446,7 +447,7 @@ describe('displays a proof request screen', () => {
inputDescriptorId: 'email',
name: undefined,
purpose: undefined,
verifiableCredentials: [testW3cCredentialRecord],
verifiableCredentials: [{ type: ClaimFormat.LdpVc, credentialRecord: testW3cCredentialRecord }],
},
],
isRequirementSatisfied: true,
Expand All @@ -459,7 +460,7 @@ describe('displays a proof request screen', () => {
inputDescriptorId: 'time',
name: undefined,
purpose: undefined,
verifiableCredentials: [testW3cCredentialRecord],
verifiableCredentials: [{ type: ClaimFormat.LdpVc, credentialRecord: testW3cCredentialRecord }],
},
],
isRequirementSatisfied: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AnonCredsCredentialsForProofRequest } from '@credo-ts/anoncreds'
import { DifPexCredentialsForRequest, JsonTransformer, W3cCredentialRecord } from '@credo-ts/core'
import { ClaimFormat, DifPexCredentialsForRequest, JsonTransformer, W3cCredentialRecord } from '@credo-ts/core'
import { DifPexAnonCredsProofRequest } from '../../../App/utils/anonCredsProofRequestMapper'

export const testW3cCredentialRecord = JsonTransformer.fromJSON(
Expand Down Expand Up @@ -254,7 +254,7 @@ export const difPexCredentialsForRequest: DifPexCredentialsForRequest = {
inputDescriptorId: 'age',
name: undefined,
purpose: undefined,
verifiableCredentials: [testW3cCredentialRecord],
verifiableCredentials: [{ type: ClaimFormat.LdpVc, credentialRecord: testW3cCredentialRecord }],
},
],
isRequirementSatisfied: true,
Expand All @@ -267,7 +267,7 @@ export const difPexCredentialsForRequest: DifPexCredentialsForRequest = {
inputDescriptorId: 'email',
name: undefined,
purpose: undefined,
verifiableCredentials: [testW3cCredentialRecord],
verifiableCredentials: [{ type: ClaimFormat.LdpVc, credentialRecord: testW3cCredentialRecord }],
},
],
isRequirementSatisfied: true,
Expand All @@ -280,7 +280,7 @@ export const difPexCredentialsForRequest: DifPexCredentialsForRequest = {
inputDescriptorId: 'time',
name: undefined,
purpose: undefined,
verifiableCredentials: [testW3cCredentialRecord],
verifiableCredentials: [{ type: ClaimFormat.LdpVc, credentialRecord: testW3cCredentialRecord }],
},
],
isRequirementSatisfied: true,
Expand All @@ -301,7 +301,10 @@ export const difPexCredentialsForRequest2: DifPexCredentialsForRequest = {
inputDescriptorId: 'age',
name: undefined,
purpose: undefined,
verifiableCredentials: [testW3cCredentialRecord, testW3cCredentialRecord2],
verifiableCredentials: [
{ type: ClaimFormat.LdpVc, credentialRecord: testW3cCredentialRecord },
{ type: ClaimFormat.LdpVc, credentialRecord: testW3cCredentialRecord2 },
],
},
],
isRequirementSatisfied: true,
Expand All @@ -314,7 +317,10 @@ export const difPexCredentialsForRequest2: DifPexCredentialsForRequest = {
inputDescriptorId: 'email',
name: undefined,
purpose: undefined,
verifiableCredentials: [testW3cCredentialRecord, testW3cCredentialRecord2],
verifiableCredentials: [
{ type: ClaimFormat.LdpVc, credentialRecord: testW3cCredentialRecord },
{ type: ClaimFormat.LdpVc, credentialRecord: testW3cCredentialRecord2 },
],
},
],
isRequirementSatisfied: true,
Expand All @@ -327,7 +333,10 @@ export const difPexCredentialsForRequest2: DifPexCredentialsForRequest = {
inputDescriptorId: 'time',
name: undefined,
purpose: undefined,
verifiableCredentials: [testW3cCredentialRecord, testW3cCredentialRecord2],
verifiableCredentials: [
{ type: ClaimFormat.LdpVc, credentialRecord: testW3cCredentialRecord },
{ type: ClaimFormat.LdpVc, credentialRecord: testW3cCredentialRecord2 },
],
},
],
isRequirementSatisfied: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
testW3cCredentialRecord,
testW3cCredentialRecord2,
} from '../screens/fixtures/w3c-proof-request'
import { ClaimFormat } from '@credo-ts/core'

describe('getDescriptorMetadata', () => {
test('Returns Correct DescriptorMetadata', async () => {
Expand All @@ -28,19 +29,31 @@ describe('getDescriptorMetadata', () => {
isRequirementSatisfied: true,
needsCount: 1,
rule: 'all',
submissionEntry: [{ inputDescriptorId: '0', verifiableCredentials: [record1] }],
submissionEntry: [
{ inputDescriptorId: '0', verifiableCredentials: [{ credentialRecord: record1, type: ClaimFormat.LdpVc }] },
],
},
{
isRequirementSatisfied: true,
needsCount: 1,
rule: 'all',
submissionEntry: [{ inputDescriptorId: '1', verifiableCredentials: [record2] }],
submissionEntry: [
{ inputDescriptorId: '1', verifiableCredentials: [{ credentialRecord: record2, type: ClaimFormat.LdpVc }] },
],
},
{
isRequirementSatisfied: true,
needsCount: 1,
rule: 'all',
submissionEntry: [{ inputDescriptorId: '2', verifiableCredentials: [record1, record2] }],
submissionEntry: [
{
inputDescriptorId: '2',
verifiableCredentials: [
{ credentialRecord: record1, type: ClaimFormat.LdpVc },
{ credentialRecord: record2, type: ClaimFormat.LdpVc },
],
},
],
},
],
})
Expand Down
28 changes: 14 additions & 14 deletions packages/legacy/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
"@babel/core": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@commitlint/cli": "^11.0.0",
"@credo-ts/anoncreds": "^0.5.1",
"@credo-ts/askar": "^0.5.1",
"@credo-ts/core": "^0.5.1",
"@credo-ts/indy-sdk-to-askar-migration": "^0.5.1",
"@credo-ts/indy-vdr": "^0.5.1",
"@credo-ts/anoncreds": "0.5.1-alpha.19",
"@credo-ts/askar": "0.5.1-alpha.19",
"@credo-ts/core": "0.5.1-alpha.19",
"@credo-ts/indy-sdk-to-askar-migration": "0.5.1-alpha.19",
"@credo-ts/indy-vdr": "0.5.1-alpha.19",
"@credo-ts/push-notifications": "^0.7.0",
"@credo-ts/question-answer": "^0.5.1",
"@credo-ts/question-answer": "0.5.1-alpha.19",
"@credo-ts/react-hooks": "^0.6.0",
"@credo-ts/react-native": "^0.5.1",
"@credo-ts/react-native": "0.5.1-alpha.19",
"@formatjs/intl-datetimeformat": "4.2.4",
"@formatjs/intl-displaynames": "5.2.4",
"@formatjs/intl-getcanonicallocales": "1.7.3",
Expand Down Expand Up @@ -145,15 +145,15 @@
"uuid": "^9.0.0"
},
"peerDependencies": {
"@credo-ts/anoncreds": "^0.5.1",
"@credo-ts/askar": "^0.5.1",
"@credo-ts/core": "^0.5.1",
"@credo-ts/indy-sdk-to-askar-migration": "^0.5.1",
"@credo-ts/indy-vdr": "^0.5.1",
"@credo-ts/anoncreds": "0.5.1-alpha.19",
"@credo-ts/askar": "0.5.1-alpha.19",
"@credo-ts/core": "0.5.1-alpha.19",
"@credo-ts/indy-sdk-to-askar-migration": "0.5.1-alpha.19",
"@credo-ts/indy-vdr": "0.5.1-alpha.19",
"@credo-ts/push-notifications": "^0.7.0",
"@credo-ts/question-answer": "^0.5.1",
"@credo-ts/question-answer": "0.5.1-alpha.19",
"@credo-ts/react-hooks": "^0.6.0",
"@credo-ts/react-native": "^0.5.1",
"@credo-ts/react-native": "0.5.1-alpha.19",
"@formatjs/intl-datetimeformat": "4.2.4",
"@formatjs/intl-displaynames": "5.2.4",
"@formatjs/intl-getcanonicallocales": "1.7.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/oca/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
"typescript": "^5.0.4"
},
"dependencies": {
"@credo-ts/anoncreds": "^0.5.1",
"@credo-ts/core": "^0.5.1",
"@credo-ts/anoncreds": "0.5.1-alpha.19",
"@credo-ts/core": "0.5.1-alpha.19",
"axios": "^1.4.0",
"lodash.startcase": "^4.4.0"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/remote-logs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"homepage": "https://github.com/hyperledger/aries-mobile-agent-react-native#readme",
"devDependencies": {
"@babel/runtime": "^7.20.0",
"@credo-ts/core": "^0.5.1",
"@credo-ts/core": "0.5.1-alpha.19",
"@typescript-eslint/parser": "^6.6.0",
"axios": "^1.4.0",
"buffer": "^6.0.3",
Expand All @@ -45,7 +45,7 @@
"typescript": "^5.0.4"
},
"peerDependencies": {
"@credo-ts/core": "^0.5.1",
"@credo-ts/core": "0.5.1-alpha.19",
"axios": "^1.4.0",
"buffer": "^6.0.3",
"react": "^18.2.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/verifier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@credo-ts/anoncreds": "^0.5.1",
"@credo-ts/core": "^0.5.1",
"@credo-ts/anoncreds": "0.5.1-alpha.19",
"@credo-ts/core": "0.5.1-alpha.19",
"@credo-ts/react-hooks": "^0.6.0",
"@hyperledger/anoncreds-shared": "^0.2.1",
"@types/jest": "^29.5.5",
Expand All @@ -36,8 +36,8 @@
"typescript": "^5.0.4"
},
"peerDependencies": {
"@credo-ts/anoncreds": "^0.5.1",
"@credo-ts/core": "^0.5.1",
"@credo-ts/anoncreds": "0.5.1-alpha.19",
"@credo-ts/core": "0.5.1-alpha.19",
"@credo-ts/react-hooks": "^0.6.0",
"@hyperledger/anoncreds-shared": "^0.2.1",
"react": "^18.2.0"
Expand Down
Loading

0 comments on commit cbcb497

Please sign in to comment.