@bifold/verifier 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +1 -0
  2. package/build/commonjs/README.md +4 -0
  3. package/build/commonjs/constants.js +9 -0
  4. package/build/commonjs/constants.js.map +1 -0
  5. package/build/commonjs/hooks/proofs.js +22 -0
  6. package/build/commonjs/hooks/proofs.js.map +1 -0
  7. package/build/commonjs/index.js +120 -0
  8. package/build/commonjs/index.js.map +1 -0
  9. package/build/commonjs/request-templates.js +59 -0
  10. package/build/commonjs/request-templates.js.map +1 -0
  11. package/build/commonjs/types/agent.js +9 -0
  12. package/build/commonjs/types/agent.js.map +1 -0
  13. package/build/commonjs/types/metadata.js +11 -0
  14. package/build/commonjs/types/metadata.js.map +1 -0
  15. package/build/commonjs/types/proof-reqeust-template.js +12 -0
  16. package/build/commonjs/types/proof-reqeust-template.js.map +1 -0
  17. package/build/commonjs/types/proof.js +26 -0
  18. package/build/commonjs/types/proof.js.map +1 -0
  19. package/build/commonjs/utils/proof-request.js +163 -0
  20. package/build/commonjs/utils/proof-request.js.map +1 -0
  21. package/build/commonjs/utils/proof.js +184 -0
  22. package/build/commonjs/utils/proof.js.map +1 -0
  23. package/build/module/README.md +4 -0
  24. package/build/module/constants.js +3 -0
  25. package/build/module/constants.js.map +1 -0
  26. package/build/module/hooks/proofs.js +15 -0
  27. package/build/module/hooks/proofs.js.map +1 -0
  28. package/build/module/index.js +7 -0
  29. package/build/module/index.js.map +1 -0
  30. package/build/module/request-templates.js +52 -0
  31. package/build/module/request-templates.js.map +1 -0
  32. package/build/module/types/agent.js +5 -0
  33. package/build/module/types/agent.js.map +1 -0
  34. package/build/module/types/metadata.js +5 -0
  35. package/build/module/types/metadata.js.map +1 -0
  36. package/build/module/types/proof-reqeust-template.js +8 -0
  37. package/build/module/types/proof-reqeust-template.js.map +1 -0
  38. package/build/module/types/proof.js +18 -0
  39. package/build/module/types/proof.js.map +1 -0
  40. package/build/module/utils/proof-request.js +151 -0
  41. package/build/module/utils/proof-request.js.map +1 -0
  42. package/build/module/utils/proof.js +171 -0
  43. package/build/module/utils/proof.js.map +1 -0
  44. package/build/typescript/__tests__/verifier/proof-request.test.d.ts +2 -0
  45. package/build/typescript/__tests__/verifier/proof-request.test.d.ts.map +1 -0
  46. package/build/typescript/__tests__/verifier/proof.test.d.ts +2 -0
  47. package/build/typescript/__tests__/verifier/proof.test.d.ts.map +1 -0
  48. package/build/typescript/constants.d.ts +3 -0
  49. package/build/typescript/constants.d.ts.map +1 -0
  50. package/build/typescript/hooks/proofs.d.ts +3 -0
  51. package/build/typescript/hooks/proofs.d.ts.map +1 -0
  52. package/build/typescript/index.d.ts +11 -0
  53. package/build/typescript/index.d.ts.map +1 -0
  54. package/build/typescript/request-templates.d.ts +3 -0
  55. package/build/typescript/request-templates.d.ts.map +1 -0
  56. package/build/typescript/types/agent.d.ts +12 -0
  57. package/build/typescript/types/agent.d.ts.map +1 -0
  58. package/build/typescript/types/metadata.d.ts +9 -0
  59. package/build/typescript/types/metadata.d.ts.map +1 -0
  60. package/build/typescript/types/proof-reqeust-template.d.ts +48 -0
  61. package/build/typescript/types/proof-reqeust-template.d.ts.map +1 -0
  62. package/build/typescript/types/proof.d.ts +51 -0
  63. package/build/typescript/types/proof.d.ts.map +1 -0
  64. package/build/typescript/utils/proof-request.d.ts +30 -0
  65. package/build/typescript/utils/proof-request.d.ts.map +1 -0
  66. package/build/typescript/utils/proof.d.ts +18 -0
  67. package/build/typescript/utils/proof.d.ts.map +1 -0
  68. package/package.json +59 -0
  69. package/src/README.md +4 -0
  70. package/src/__tests__/verifier/__snapshots__/proof-request.test.ts.snap +72 -0
  71. package/src/__tests__/verifier/__snapshots__/proof.test.ts.snap +135 -0
  72. package/src/__tests__/verifier/proof-request.test.ts +34 -0
  73. package/src/__tests__/verifier/proof.test.ts +99 -0
  74. package/src/constants.ts +2 -0
  75. package/src/hooks/proofs.ts +20 -0
  76. package/src/index.ts +45 -0
  77. package/src/request-templates.ts +62 -0
  78. package/src/types/agent.ts +53 -0
  79. package/src/types/metadata.ts +9 -0
  80. package/src/types/proof-reqeust-template.ts +59 -0
  81. package/src/types/proof.ts +68 -0
  82. package/src/utils/proof-request.ts +177 -0
  83. package/src/utils/proof.ts +173 -0
@@ -0,0 +1,135 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Helpers Get proof identifiers 1`] = `
4
+ Object {
5
+ "cred_def_id": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712167:latest",
6
+ "schema_id": "7KuDTpQh3GJ7Gp6kErpWvM:2:Faber College:1.0.0",
7
+ }
8
+ `;
9
+
10
+ exports[`Helpers Group shared proof data by credential 1`] = `
11
+ Map {
12
+ "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712167:latest" => Object {
13
+ "data": CredentialSharedProofData {
14
+ "resolvedPredicates": Array [
15
+ Object {
16
+ "identifiers": Object {
17
+ "cred_def_id": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712167:latest",
18
+ "schema_id": "7KuDTpQh3GJ7Gp6kErpWvM:2:Faber College:1.0.0",
19
+ },
20
+ "name": "age",
21
+ "predicateType": ">=",
22
+ "predicateValue": 1,
23
+ },
24
+ ],
25
+ "sharedAttributeGroups": Array [
26
+ Object {
27
+ "attributes": Array [
28
+ Object {
29
+ "name": "first_name",
30
+ "value": "Aries",
31
+ },
32
+ Object {
33
+ "name": "second_name",
34
+ "value": "Bifold",
35
+ },
36
+ ],
37
+ "identifiers": Object {
38
+ "cred_def_id": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712167:latest",
39
+ "schema_id": "7KuDTpQh3GJ7Gp6kErpWvM:2:Faber College:1.0.0",
40
+ },
41
+ },
42
+ ],
43
+ "sharedAttributes": Array [
44
+ Object {
45
+ "identifiers": Object {
46
+ "cred_def_id": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712167:latest",
47
+ "schema_id": "7KuDTpQh3GJ7Gp6kErpWvM:2:Faber College:1.0.0",
48
+ },
49
+ "name": "date",
50
+ "value": "1/1/1",
51
+ },
52
+ ],
53
+ },
54
+ "identifiers": Object {
55
+ "cred_def_id": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712167:latest",
56
+ "schema_id": "7KuDTpQh3GJ7Gp6kErpWvM:2:Faber College:1.0.0",
57
+ },
58
+ },
59
+ "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712168:latest" => Object {
60
+ "data": CredentialSharedProofData {
61
+ "resolvedPredicates": Array [],
62
+ "sharedAttributeGroups": Array [],
63
+ "sharedAttributes": Array [
64
+ Object {
65
+ "identifiers": Object {
66
+ "cred_def_id": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712168:latest",
67
+ "schema_id": "7KuDTpQh3GJ7Gp6kErpWvM:2:Passport:1.0.0",
68
+ },
69
+ "name": "passport_no",
70
+ "value": "123123",
71
+ },
72
+ ],
73
+ },
74
+ "identifiers": Object {
75
+ "cred_def_id": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712168:latest",
76
+ "schema_id": "7KuDTpQh3GJ7Gp6kErpWvM:2:Passport:1.0.0",
77
+ },
78
+ },
79
+ }
80
+ `;
81
+
82
+ exports[`Helpers Parse indy proof 1`] = `
83
+ ParsedAnonCredsProof {
84
+ "resolvedPredicates": Array [
85
+ Object {
86
+ "identifiers": Object {
87
+ "cred_def_id": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712167:latest",
88
+ "schema_id": "7KuDTpQh3GJ7Gp6kErpWvM:2:Faber College:1.0.0",
89
+ },
90
+ "name": "age",
91
+ "predicateType": ">=",
92
+ "predicateValue": 1,
93
+ },
94
+ ],
95
+ "sharedAttributeGroups": Array [
96
+ Object {
97
+ "attributes": Array [
98
+ Object {
99
+ "name": "first_name",
100
+ "value": "Aries",
101
+ },
102
+ Object {
103
+ "name": "second_name",
104
+ "value": "Bifold",
105
+ },
106
+ ],
107
+ "identifiers": Object {
108
+ "cred_def_id": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712167:latest",
109
+ "schema_id": "7KuDTpQh3GJ7Gp6kErpWvM:2:Faber College:1.0.0",
110
+ },
111
+ },
112
+ ],
113
+ "sharedAttributes": Array [
114
+ Object {
115
+ "identifiers": Object {
116
+ "cred_def_id": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712167:latest",
117
+ "schema_id": "7KuDTpQh3GJ7Gp6kErpWvM:2:Faber College:1.0.0",
118
+ },
119
+ "name": "date",
120
+ "value": "1/1/1",
121
+ },
122
+ Object {
123
+ "identifiers": Object {
124
+ "cred_def_id": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712168:latest",
125
+ "schema_id": "7KuDTpQh3GJ7Gp6kErpWvM:2:Passport:1.0.0",
126
+ },
127
+ "name": "passport_no",
128
+ "value": "123123",
129
+ },
130
+ ],
131
+ "unresolvedAttributeGroups": Array [],
132
+ "unresolvedAttributes": Array [],
133
+ "unresolvedPredicates": Array [],
134
+ }
135
+ `;
@@ -0,0 +1,34 @@
1
+ import { getProofRequestTemplates } from '../../request-templates'
2
+ import { buildProofRequestDataForTemplate, hasPredicates } from '../../utils/proof-request'
3
+
4
+ import SpyInstance = jest.SpyInstance
5
+
6
+ describe('Helpers', () => {
7
+ let spy: SpyInstance
8
+
9
+ beforeAll(() => {
10
+ spy = jest.spyOn(Date, 'now').mockImplementation(() => 1677766511505)
11
+ })
12
+ const templates = getProofRequestTemplates(false)
13
+
14
+ test('Build anoncreds proof request from template containing two requested attributes', async () => {
15
+ const template = templates[0]
16
+ const proofRequest = buildProofRequestDataForTemplate(template)
17
+ expect(proofRequest).toMatchSnapshot()
18
+ })
19
+
20
+ test('Build anoncreds proof request from template containing two requested attributes and predicate', async () => {
21
+ const template = templates[1]
22
+ const proofRequest = buildProofRequestDataForTemplate(template)
23
+ expect(proofRequest).toMatchSnapshot()
24
+ })
25
+
26
+ test('Check if proof has predicates', async () => {
27
+ expect(hasPredicates(templates[0])).toBeFalsy()
28
+ expect(hasPredicates(templates[1])).toBeTruthy()
29
+ })
30
+
31
+ afterAll(() => {
32
+ spy.mockRestore()
33
+ })
34
+ })
@@ -0,0 +1,99 @@
1
+ import { AnonCredsProof } from '@credo-ts/anoncreds'
2
+ import { getProofIdentifiers, groupSharedProofDataByCredential, parseAnonCredsProof } from '../../utils/proof'
3
+ const proof_request = {
4
+ name: 'proof-request',
5
+ version: '1.0',
6
+ nonce: '1298236324864',
7
+ requested_attributes: {
8
+ attribute_1: {
9
+ names: ['first_name', 'second_name'],
10
+ },
11
+ attribute_2: {
12
+ name: 'date',
13
+ },
14
+ attribute_3: {
15
+ name: 'passport_no',
16
+ },
17
+ },
18
+ requested_predicates: {
19
+ predicate_1: {
20
+ name: 'age',
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ p_type: '>=' as any,
23
+ p_value: 1,
24
+ },
25
+ },
26
+ }
27
+
28
+ const proof: AnonCredsProof = {
29
+ proof: {
30
+ proofs: [],
31
+ aggregated_proof: {
32
+ c_list: [],
33
+ },
34
+ },
35
+ requested_proof: {
36
+ revealed_attrs: {
37
+ attribute_2: {
38
+ sub_proof_index: 0,
39
+ raw: '1/1/1',
40
+ encoded: '',
41
+ },
42
+ attribute_3: {
43
+ sub_proof_index: 1,
44
+ raw: '123123',
45
+ encoded: '',
46
+ },
47
+ },
48
+ revealed_attr_groups: {
49
+ attribute_1: {
50
+ sub_proof_index: 0,
51
+ values: {
52
+ first_name: {
53
+ raw: 'Aries',
54
+ encoded: '',
55
+ },
56
+ second_name: {
57
+ raw: 'Bifold',
58
+ encoded: '',
59
+ },
60
+ },
61
+ },
62
+ },
63
+ self_attested_attrs: {},
64
+ unrevealed_attrs: {},
65
+ predicates: {
66
+ predicate_1: {
67
+ sub_proof_index: 0,
68
+ },
69
+ },
70
+ },
71
+ identifiers: [
72
+ {
73
+ schema_id: '7KuDTpQh3GJ7Gp6kErpWvM:2:Faber College:1.0.0',
74
+ cred_def_id: '7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712167:latest',
75
+ },
76
+ {
77
+ schema_id: '7KuDTpQh3GJ7Gp6kErpWvM:2:Passport:1.0.0',
78
+ cred_def_id: '7KuDTpQh3GJ7Gp6kErpWvM:3:CL:712168:latest',
79
+ },
80
+ ],
81
+ }
82
+
83
+ describe('Helpers', () => {
84
+ test('Parse indy proof', async () => {
85
+ const proofRequest = parseAnonCredsProof(proof_request, proof)
86
+ expect(proofRequest).toMatchSnapshot()
87
+ })
88
+
89
+ test('Group shared proof data by credential', async () => {
90
+ const data = parseAnonCredsProof(proof_request, proof)
91
+ const groupedData = groupSharedProofDataByCredential(data)
92
+ expect(groupedData).toMatchSnapshot()
93
+ })
94
+
95
+ test('Get proof identifiers', async () => {
96
+ const identifiers = getProofIdentifiers(proof, 0)
97
+ expect(identifiers).toMatchSnapshot()
98
+ })
99
+ })
@@ -0,0 +1,2 @@
1
+ export const protocolVersion = 'v2'
2
+ export const domain = 'didcomm://invite'
@@ -0,0 +1,20 @@
1
+ import { ProofExchangeRecord } from '@credo-ts/core'
2
+ import { useProofs } from '@credo-ts/react-hooks'
3
+ import { useMemo } from 'react'
4
+
5
+ import { ProofCustomMetadata, ProofMetadata } from '../types/metadata'
6
+
7
+ export const useProofsByTemplateId = (templateId: string): ProofExchangeRecord[] => {
8
+ const { records: proofs } = useProofs()
9
+
10
+ return useMemo(
11
+ () =>
12
+ proofs.filter((proof: ProofExchangeRecord) => {
13
+ const metadata = proof?.metadata.get(ProofMetadata.customMetadata) as ProofCustomMetadata
14
+ if (metadata?.proof_request_template_id === templateId) {
15
+ return proof
16
+ }
17
+ }),
18
+ [proofs, templateId]
19
+ )
20
+ }
package/src/index.ts ADDED
@@ -0,0 +1,45 @@
1
+ export { ProofRequestType } from './types/proof-reqeust-template'
2
+ export type {
3
+ ProofRequestTemplate,
4
+ DifProofRequestTemplatePayload,
5
+ DifProofRequestTemplatePayloadData,
6
+ AnonCredsProofRequestTemplatePayload,
7
+ AnonCredsProofRequestTemplatePayloadData,
8
+ AnonCredsRequestedAttribute,
9
+ AnonCredsRequestedPredicate,
10
+ } from './types/proof-reqeust-template'
11
+ export type {
12
+ GroupedSharedProofData,
13
+ GroupedSharedProofDataItem,
14
+ CredentialSharedProofData,
15
+ ParsedAnonCredsProof,
16
+ UnresolvedPredicate,
17
+ ResolvedPredicate,
18
+ SharedAttributesGroup,
19
+ SharedGroupedAttribute,
20
+ SharedAttribute,
21
+ MissingAttribute,
22
+ } from './types/proof'
23
+ export type { ProofCustomMetadata } from './types/metadata'
24
+ export { ProofMetadata } from './types/metadata'
25
+ export { useProofsByTemplateId } from './hooks/proofs'
26
+ export {
27
+ getProofIdentifiers,
28
+ parseAnonCredsProof,
29
+ groupSharedProofDataByCredential,
30
+ getProofData,
31
+ isPresentationReceived,
32
+ isPresentationFailed,
33
+ markProofAsViewed,
34
+ linkProofWithTemplate,
35
+ } from './utils/proof'
36
+ export type { CreateProofRequestInvitationResult, SendProofRequestResult } from './utils/proof-request'
37
+ export {
38
+ findProofRequestMessage,
39
+ buildProofRequestDataForTemplate,
40
+ createConnectionlessProofRequestInvitation,
41
+ sendProofRequest,
42
+ hasPredicates,
43
+ isParameterizable,
44
+ } from './utils/proof-request'
45
+ export { getProofRequestTemplates } from './request-templates'
@@ -0,0 +1,62 @@
1
+ import { ProofRequestTemplate, ProofRequestType } from './types/proof-reqeust-template'
2
+
3
+ export const getProofRequestTemplates = (useDevRestrictions: boolean) => {
4
+ const studentRestrictions = [{ cred_def_id: 'XUxBrVSALWHLeycAUhrNr9:3:CL:26293:student_card' }]
5
+ const studentDevRestrictions = [{ schema_name: 'student_card' }]
6
+ const restrictions = useDevRestrictions ? studentDevRestrictions : studentRestrictions
7
+ const defaultProofRequestTemplates: Array<ProofRequestTemplate> = [
8
+ {
9
+ id: 'Aries:5:StudentFullName:0.0.1:indy',
10
+ name: 'Student full name',
11
+ description: 'Verify the full name of a student',
12
+ version: '0.0.1',
13
+ payload: {
14
+ type: ProofRequestType.AnonCreds,
15
+ data: [
16
+ {
17
+ schema: 'XUxBrVSALWHLeycAUhrNr9:3:CL:26293:Student Card',
18
+ requestedAttributes: [
19
+ {
20
+ name: 'student_first_name',
21
+ restrictions,
22
+ },
23
+ {
24
+ name: 'student_last_name',
25
+ restrictions,
26
+ },
27
+ ],
28
+ },
29
+ ],
30
+ },
31
+ },
32
+ {
33
+ id: 'Aries:5:StudentFullNameAndExpirationDate:0.0.1:indy',
34
+ name: 'Student full name and expiration date',
35
+ description: 'Verify that full name of a student and that he/she has a not expired student card.',
36
+ version: '0.0.1',
37
+ payload: {
38
+ type: ProofRequestType.AnonCreds,
39
+ data: [
40
+ {
41
+ schema: 'XUxBrVSALWHLeycAUhrNr9:3:CL:26293:Student Card',
42
+ requestedAttributes: [
43
+ {
44
+ names: ['student_first_name', 'student_last_name'],
45
+ restrictions,
46
+ },
47
+ ],
48
+ requestedPredicates: [
49
+ {
50
+ name: 'expiry_date',
51
+ predicateType: '>=',
52
+ predicateValue: 20240101,
53
+ restrictions,
54
+ },
55
+ ],
56
+ },
57
+ ],
58
+ },
59
+ },
60
+ ]
61
+ return defaultProofRequestTemplates
62
+ }
@@ -0,0 +1,53 @@
1
+ import {
2
+ AnonCredsCredentialFormatService,
3
+ AnonCredsModule,
4
+ AnonCredsProofFormatService,
5
+ DataIntegrityCredentialFormatService,
6
+ LegacyIndyCredentialFormatService,
7
+ LegacyIndyProofFormatService,
8
+ V1CredentialProtocol,
9
+ V1ProofProtocol,
10
+ } from '@credo-ts/anoncreds'
11
+ import {
12
+ Agent,
13
+ ConnectionsModule,
14
+ CredentialsModule,
15
+ DifPresentationExchangeProofFormatService,
16
+ MediationRecipientModule,
17
+ ProofsModule,
18
+ V2CredentialProtocol,
19
+ V2ProofProtocol,
20
+ } from '@credo-ts/core'
21
+
22
+ function getAgentModules() {
23
+ return null as unknown as {
24
+ //askar: AskarModule
25
+ //anoncredsRs: AnonCredsRsModule
26
+ anoncreds: AnonCredsModule
27
+ //indyVdr: IndyVdrModule
28
+ connections: ConnectionsModule
29
+ credentials: CredentialsModule<
30
+ (
31
+ | V1CredentialProtocol
32
+ | V2CredentialProtocol<
33
+ (
34
+ | LegacyIndyCredentialFormatService
35
+ | AnonCredsCredentialFormatService
36
+ | DataIntegrityCredentialFormatService
37
+ )[]
38
+ >
39
+ )[]
40
+ >
41
+ proofs: ProofsModule<
42
+ (
43
+ | V1ProofProtocol
44
+ | V2ProofProtocol<
45
+ (LegacyIndyProofFormatService | AnonCredsProofFormatService | DifPresentationExchangeProofFormatService)[]
46
+ >
47
+ )[]
48
+ >
49
+ mediationRecipient: MediationRecipientModule
50
+ }
51
+ }
52
+
53
+ export type BifoldAgent = Agent<ReturnType<typeof getAgentModules>>
@@ -0,0 +1,9 @@
1
+ export enum ProofMetadata {
2
+ customMetadata = 'customMetadata',
3
+ }
4
+
5
+ export interface ProofCustomMetadata {
6
+ details_seen?: boolean
7
+ proof_request_template_id?: string
8
+ delete_conn_after_seen?: boolean
9
+ }
@@ -0,0 +1,59 @@
1
+ import {
2
+ AnonCredsNonRevokedInterval,
3
+ AnonCredsPredicateType,
4
+ AnonCredsProofRequestRestriction,
5
+ } from '@credo-ts/anoncreds'
6
+
7
+ export interface AnonCredsRequestedPredicate {
8
+ label?: string
9
+ name: string
10
+ predicateType: AnonCredsPredicateType
11
+ predicateValue: number
12
+ restrictions?: AnonCredsProofRequestRestriction[]
13
+ devRestrictions?: AnonCredsProofRequestRestriction[]
14
+ nonRevoked?: AnonCredsNonRevokedInterval
15
+ parameterizable?: boolean
16
+ }
17
+
18
+ export interface AnonCredsRequestedAttribute {
19
+ label?: string
20
+ name?: string
21
+ names?: Array<string>
22
+ restrictions?: AnonCredsProofRequestRestriction[]
23
+ devRestrictions?: AnonCredsProofRequestRestriction[]
24
+ revealed?: boolean
25
+ nonRevoked?: AnonCredsNonRevokedInterval
26
+ }
27
+
28
+ export interface AnonCredsProofRequestTemplatePayloadData {
29
+ schema: string
30
+ requestedAttributes?: Array<AnonCredsRequestedAttribute>
31
+ requestedPredicates?: Array<AnonCredsRequestedPredicate>
32
+ }
33
+
34
+ export enum ProofRequestType {
35
+ AnonCreds = 'anoncreds',
36
+ DIF = 'dif',
37
+ }
38
+
39
+ export interface AnonCredsProofRequestTemplatePayload {
40
+ type: ProofRequestType.AnonCreds
41
+ data: Array<AnonCredsProofRequestTemplatePayloadData>
42
+ }
43
+
44
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
45
+ export interface DifProofRequestTemplatePayloadData {}
46
+
47
+ export interface DifProofRequestTemplatePayload {
48
+ type: ProofRequestType.DIF
49
+ data: Array<DifProofRequestTemplatePayloadData>
50
+ }
51
+
52
+ export interface ProofRequestTemplate {
53
+ id: string
54
+ name: string
55
+ description: string
56
+ version: string
57
+ devOnly?: boolean
58
+ payload: AnonCredsProofRequestTemplatePayload | DifProofRequestTemplatePayload
59
+ }
@@ -0,0 +1,68 @@
1
+ import { AnonCredsProof } from '@credo-ts/anoncreds'
2
+ type AnonCredsProofIdentifier = AnonCredsProof['identifiers'][number]
3
+
4
+ export interface MissingAttribute {
5
+ name: string
6
+ }
7
+
8
+ export interface SharedAttribute {
9
+ name: string
10
+ value: string
11
+ identifiers: AnonCredsProofIdentifier
12
+ }
13
+
14
+ export interface SharedGroupedAttribute {
15
+ name: string
16
+ value: string
17
+ }
18
+
19
+ export interface SharedAttributesGroup {
20
+ attributes: Array<SharedGroupedAttribute>
21
+ identifiers: AnonCredsProofIdentifier
22
+ }
23
+
24
+ export interface ResolvedPredicate {
25
+ name: string
26
+ predicateType: string
27
+ predicateValue: number
28
+ identifiers: AnonCredsProofIdentifier
29
+ }
30
+
31
+ export interface UnresolvedPredicate {
32
+ name: string
33
+ predicateType: string
34
+ predicateValue: number
35
+ }
36
+
37
+ export class ParsedAnonCredsProof {
38
+ public sharedAttributes: Array<SharedAttribute>
39
+ public sharedAttributeGroups: Array<SharedAttributesGroup>
40
+ public resolvedPredicates: Array<ResolvedPredicate>
41
+ public unresolvedAttributes: Array<MissingAttribute>
42
+ public unresolvedAttributeGroups: Array<Array<MissingAttribute>>
43
+ public unresolvedPredicates: Array<UnresolvedPredicate>
44
+
45
+ public constructor() {
46
+ this.sharedAttributes = []
47
+ this.sharedAttributeGroups = []
48
+ this.resolvedPredicates = []
49
+ this.unresolvedAttributes = []
50
+ this.unresolvedAttributeGroups = []
51
+ this.unresolvedPredicates = []
52
+ }
53
+ }
54
+
55
+ export class CredentialSharedProofData {
56
+ public sharedAttributes: Array<SharedAttribute>
57
+ public sharedAttributeGroups: Array<SharedAttributesGroup>
58
+ public resolvedPredicates: Array<ResolvedPredicate>
59
+
60
+ public constructor() {
61
+ this.sharedAttributes = []
62
+ this.sharedAttributeGroups = []
63
+ this.resolvedPredicates = []
64
+ }
65
+ }
66
+
67
+ export type GroupedSharedProofDataItem = { data: CredentialSharedProofData; identifiers: AnonCredsProofIdentifier }
68
+ export type GroupedSharedProofData = Map<string, GroupedSharedProofDataItem>