@procivis/one-react-native-components 0.3.71 → 0.3.91

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 (262) hide show
  1. package/lib/commonjs/components/entity/entity-attributes.js +3 -1
  2. package/lib/commonjs/components/entity/entity-attributes.js.map +1 -1
  3. package/lib/commonjs/components/entity/entity-details-with-buttons.js +2 -1
  4. package/lib/commonjs/components/entity/entity-details-with-buttons.js.map +1 -1
  5. package/lib/commonjs/components/proof-request/index.js +23 -12
  6. package/lib/commonjs/components/proof-request/index.js.map +1 -1
  7. package/lib/commonjs/components/proof-request/select-share-credential-card-notice.js +37 -0
  8. package/lib/commonjs/components/proof-request/select-share-credential-card-notice.js.map +1 -0
  9. package/lib/commonjs/components/proof-request/share-credential-card-notice.js +36 -0
  10. package/lib/commonjs/components/proof-request/share-credential-card-notice.js.map +1 -0
  11. package/lib/commonjs/components/proof-request/{group.js → v1/group.js} +1 -1
  12. package/lib/commonjs/components/proof-request/v1/group.js.map +1 -0
  13. package/lib/commonjs/components/proof-request/v1/index.js +39 -0
  14. package/lib/commonjs/components/proof-request/v1/index.js.map +1 -0
  15. package/lib/commonjs/components/proof-request/{select-credential.js → v1/select-credential.js} +4 -4
  16. package/lib/commonjs/components/proof-request/v1/select-credential.js.map +1 -0
  17. package/lib/commonjs/components/proof-request/{share-credential.js → v1/share-credential.js} +25 -60
  18. package/lib/commonjs/components/proof-request/v1/share-credential.js.map +1 -0
  19. package/lib/commonjs/components/proof-request/v2/index.js +39 -0
  20. package/lib/commonjs/components/proof-request/v2/index.js.map +1 -0
  21. package/lib/commonjs/components/proof-request/v2/select-credential-v2.js +51 -0
  22. package/lib/commonjs/components/proof-request/v2/select-credential-v2.js.map +1 -0
  23. package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js +164 -0
  24. package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js.map +1 -0
  25. package/lib/commonjs/components/proof-request/v2/share-credential-v2.js +131 -0
  26. package/lib/commonjs/components/proof-request/v2/share-credential-v2.js.map +1 -0
  27. package/lib/commonjs/ui-components/buttons/share-button.js +1 -1
  28. package/lib/commonjs/ui-components/buttons/share-button.js.map +1 -1
  29. package/lib/commonjs/ui-components/camera/qr-code-scanner.js +5 -1
  30. package/lib/commonjs/ui-components/camera/qr-code-scanner.js.map +1 -1
  31. package/lib/commonjs/ui-components/credential/card/credential-details-list-item.js +16 -42
  32. package/lib/commonjs/ui-components/credential/card/credential-details-list-item.js.map +1 -1
  33. package/lib/commonjs/ui-components/credential/credential-attribute-item.js +3 -1
  34. package/lib/commonjs/ui-components/credential/credential-attribute-item.js.map +1 -1
  35. package/lib/commonjs/ui-components/credential/group/credential-group-header.js +72 -0
  36. package/lib/commonjs/ui-components/credential/group/credential-group-header.js.map +1 -0
  37. package/lib/commonjs/ui-components/credential/group/index.js +14 -0
  38. package/lib/commonjs/ui-components/credential/group/index.js.map +1 -0
  39. package/lib/commonjs/ui-components/credential/index.js +12 -0
  40. package/lib/commonjs/ui-components/credential/index.js.map +1 -1
  41. package/lib/commonjs/ui-components/header/foldable-header.js +29 -17
  42. package/lib/commonjs/ui-components/header/foldable-header.js.map +1 -1
  43. package/lib/commonjs/ui-components/index.js +11 -0
  44. package/lib/commonjs/ui-components/index.js.map +1 -1
  45. package/lib/commonjs/ui-components/loader/loading-result.js +1 -1
  46. package/lib/commonjs/ui-components/loader/loading-result.js.map +1 -1
  47. package/lib/commonjs/ui-components/pin/pin-lock-animation.js +477 -475
  48. package/lib/commonjs/ui-components/pin/pin-lock-animation.js.map +1 -1
  49. package/lib/commonjs/ui-components/proof-request/index.js +13 -0
  50. package/lib/commonjs/ui-components/proof-request/index.js.map +1 -0
  51. package/lib/commonjs/ui-components/proof-request/proof-request-set.js +47 -0
  52. package/lib/commonjs/ui-components/proof-request/proof-request-set.js.map +1 -0
  53. package/lib/commonjs/ui-components/screens/section-list-screen.js +17 -3
  54. package/lib/commonjs/ui-components/screens/section-list-screen.js.map +1 -1
  55. package/lib/commonjs/utils/array.js.map +1 -1
  56. package/lib/commonjs/utils/hooks/app-state.js +33 -0
  57. package/lib/commonjs/utils/hooks/app-state.js.map +1 -0
  58. package/lib/commonjs/utils/hooks/core/backup.js +1 -1
  59. package/lib/commonjs/utils/hooks/core/backup.js.map +1 -1
  60. package/lib/commonjs/utils/hooks/core/cache.js +4 -1
  61. package/lib/commonjs/utils/hooks/core/cache.js.map +1 -1
  62. package/lib/commonjs/utils/hooks/core/credentials.js +11 -10
  63. package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
  64. package/lib/commonjs/utils/hooks/core/identifiers.js +1 -1
  65. package/lib/commonjs/utils/hooks/core/identifiers.js.map +1 -1
  66. package/lib/commonjs/utils/hooks/core/index.js +11 -0
  67. package/lib/commonjs/utils/hooks/core/index.js.map +1 -1
  68. package/lib/commonjs/utils/hooks/core/proofs.js +41 -15
  69. package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
  70. package/lib/commonjs/utils/hooks/core/wallet-unit.js +76 -0
  71. package/lib/commonjs/utils/hooks/core/wallet-unit.js.map +1 -0
  72. package/lib/commonjs/utils/hooks/index.js +11 -0
  73. package/lib/commonjs/utils/hooks/index.js.map +1 -1
  74. package/lib/commonjs/utils/hooks/revocation/credential-status.js +1 -1
  75. package/lib/commonjs/utils/hooks/revocation/credential-status.js.map +1 -1
  76. package/lib/commonjs/utils/index.js +12 -12
  77. package/lib/commonjs/utils/index.js.map +1 -1
  78. package/lib/commonjs/utils/parsers/credential-sharing-v2.js +190 -0
  79. package/lib/commonjs/utils/parsers/credential-sharing-v2.js.map +1 -0
  80. package/lib/commonjs/utils/parsers/credential-sharing.js +25 -12
  81. package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
  82. package/lib/commonjs/utils/parsers/credential.js +89 -57
  83. package/lib/commonjs/utils/parsers/credential.js.map +1 -1
  84. package/lib/commonjs/utils/parsers/index.js +11 -0
  85. package/lib/commonjs/utils/parsers/index.js.map +1 -1
  86. package/lib/commonjs/utils/parsers/query.js +4 -4
  87. package/lib/commonjs/utils/parsers/query.js.map +1 -1
  88. package/lib/module/components/entity/entity-attributes.js +3 -1
  89. package/lib/module/components/entity/entity-attributes.js.map +1 -1
  90. package/lib/module/components/entity/entity-details-with-buttons.js +2 -1
  91. package/lib/module/components/entity/entity-details-with-buttons.js.map +1 -1
  92. package/lib/module/components/proof-request/index.js +4 -3
  93. package/lib/module/components/proof-request/index.js.map +1 -1
  94. package/lib/module/components/proof-request/select-share-credential-card-notice.js +29 -0
  95. package/lib/module/components/proof-request/select-share-credential-card-notice.js.map +1 -0
  96. package/lib/module/components/proof-request/share-credential-card-notice.js +28 -0
  97. package/lib/module/components/proof-request/share-credential-card-notice.js.map +1 -0
  98. package/lib/module/components/proof-request/{group.js → v1/group.js} +1 -1
  99. package/lib/module/components/proof-request/v1/group.js.map +1 -0
  100. package/lib/module/components/proof-request/v1/index.js +4 -0
  101. package/lib/module/components/proof-request/v1/index.js.map +1 -0
  102. package/lib/module/components/proof-request/{select-credential.js → v1/select-credential.js} +4 -4
  103. package/lib/module/components/proof-request/v1/select-credential.js.map +1 -0
  104. package/lib/module/components/proof-request/{share-credential.js → v1/share-credential.js} +26 -61
  105. package/lib/module/components/proof-request/v1/share-credential.js.map +1 -0
  106. package/lib/module/components/proof-request/v2/index.js +4 -0
  107. package/lib/module/components/proof-request/v2/index.js.map +1 -0
  108. package/lib/module/components/proof-request/v2/select-credential-v2.js +42 -0
  109. package/lib/module/components/proof-request/v2/select-credential-v2.js.map +1 -0
  110. package/lib/module/components/proof-request/v2/share-credential-v2-group.js +154 -0
  111. package/lib/module/components/proof-request/v2/share-credential-v2-group.js.map +1 -0
  112. package/lib/module/components/proof-request/v2/share-credential-v2.js +122 -0
  113. package/lib/module/components/proof-request/v2/share-credential-v2.js.map +1 -0
  114. package/lib/module/ui-components/buttons/share-button.js +1 -1
  115. package/lib/module/ui-components/buttons/share-button.js.map +1 -1
  116. package/lib/module/ui-components/camera/qr-code-scanner.js +5 -1
  117. package/lib/module/ui-components/camera/qr-code-scanner.js.map +1 -1
  118. package/lib/module/ui-components/credential/card/credential-details-list-item.js +19 -45
  119. package/lib/module/ui-components/credential/card/credential-details-list-item.js.map +1 -1
  120. package/lib/module/ui-components/credential/credential-attribute-item.js +3 -1
  121. package/lib/module/ui-components/credential/credential-attribute-item.js.map +1 -1
  122. package/lib/module/ui-components/credential/group/credential-group-header.js +64 -0
  123. package/lib/module/ui-components/credential/group/credential-group-header.js.map +1 -0
  124. package/lib/module/ui-components/credential/group/index.js +3 -0
  125. package/lib/module/ui-components/credential/group/index.js.map +1 -0
  126. package/lib/module/ui-components/credential/index.js +1 -0
  127. package/lib/module/ui-components/credential/index.js.map +1 -1
  128. package/lib/module/ui-components/header/foldable-header.js +29 -17
  129. package/lib/module/ui-components/header/foldable-header.js.map +1 -1
  130. package/lib/module/ui-components/index.js +1 -0
  131. package/lib/module/ui-components/index.js.map +1 -1
  132. package/lib/module/ui-components/loader/loading-result.js +1 -1
  133. package/lib/module/ui-components/loader/loading-result.js.map +1 -1
  134. package/lib/module/ui-components/pin/pin-lock-animation.js +477 -475
  135. package/lib/module/ui-components/pin/pin-lock-animation.js.map +1 -1
  136. package/lib/module/ui-components/proof-request/index.js +3 -0
  137. package/lib/module/ui-components/proof-request/index.js.map +1 -0
  138. package/lib/module/ui-components/proof-request/proof-request-set.js +39 -0
  139. package/lib/module/ui-components/proof-request/proof-request-set.js.map +1 -0
  140. package/lib/module/ui-components/screens/section-list-screen.js +15 -3
  141. package/lib/module/ui-components/screens/section-list-screen.js.map +1 -1
  142. package/lib/module/utils/array.js.map +1 -1
  143. package/lib/module/utils/hooks/app-state.js +27 -0
  144. package/lib/module/utils/hooks/app-state.js.map +1 -0
  145. package/lib/module/utils/hooks/core/backup.js +1 -1
  146. package/lib/module/utils/hooks/core/backup.js.map +1 -1
  147. package/lib/module/utils/hooks/core/cache.js +4 -1
  148. package/lib/module/utils/hooks/core/cache.js.map +1 -1
  149. package/lib/module/utils/hooks/core/credentials.js +12 -11
  150. package/lib/module/utils/hooks/core/credentials.js.map +1 -1
  151. package/lib/module/utils/hooks/core/identifiers.js +5 -5
  152. package/lib/module/utils/hooks/core/identifiers.js.map +1 -1
  153. package/lib/module/utils/hooks/core/index.js +1 -0
  154. package/lib/module/utils/hooks/core/index.js.map +1 -1
  155. package/lib/module/utils/hooks/core/proofs.js +42 -16
  156. package/lib/module/utils/hooks/core/proofs.js.map +1 -1
  157. package/lib/module/utils/hooks/core/wallet-unit.js +66 -0
  158. package/lib/module/utils/hooks/core/wallet-unit.js.map +1 -0
  159. package/lib/module/utils/hooks/index.js +1 -0
  160. package/lib/module/utils/hooks/index.js.map +1 -1
  161. package/lib/module/utils/hooks/revocation/credential-status.js +1 -1
  162. package/lib/module/utils/hooks/revocation/credential-status.js.map +1 -1
  163. package/lib/module/utils/index.js +1 -1
  164. package/lib/module/utils/index.js.map +1 -1
  165. package/lib/module/utils/parsers/credential-sharing-v2.js +177 -0
  166. package/lib/module/utils/parsers/credential-sharing-v2.js.map +1 -0
  167. package/lib/module/utils/parsers/credential-sharing.js +25 -12
  168. package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
  169. package/lib/module/utils/parsers/credential.js +89 -57
  170. package/lib/module/utils/parsers/credential.js.map +1 -1
  171. package/lib/module/utils/parsers/index.js +1 -0
  172. package/lib/module/utils/parsers/index.js.map +1 -1
  173. package/lib/module/utils/parsers/query.js +4 -4
  174. package/lib/module/utils/parsers/query.js.map +1 -1
  175. package/lib/typescript/components/entity/entity-attributes.d.ts +1 -0
  176. package/lib/typescript/components/proof-request/index.d.ts +4 -3
  177. package/lib/typescript/components/proof-request/select-share-credential-card-notice.d.ts +7 -0
  178. package/lib/typescript/components/proof-request/share-credential-card-notice.d.ts +6 -0
  179. package/lib/typescript/components/proof-request/v1/index.d.ts +3 -0
  180. package/lib/typescript/components/proof-request/{select-credential.d.ts → v1/select-credential.d.ts} +1 -1
  181. package/lib/typescript/components/proof-request/{share-credential.d.ts → v1/share-credential.d.ts} +1 -1
  182. package/lib/typescript/components/proof-request/v2/index.d.ts +3 -0
  183. package/lib/typescript/components/proof-request/v2/select-credential-v2.d.ts +14 -0
  184. package/lib/typescript/components/proof-request/v2/share-credential-v2-group.d.ts +24 -0
  185. package/lib/typescript/components/proof-request/v2/share-credential-v2.d.ts +23 -0
  186. package/lib/typescript/ui-components/credential/group/credential-group-header.d.ts +10 -0
  187. package/lib/typescript/ui-components/credential/group/index.d.ts +3 -0
  188. package/lib/typescript/ui-components/credential/index.d.ts +1 -0
  189. package/lib/typescript/ui-components/header/foldable-header.d.ts +1 -0
  190. package/lib/typescript/ui-components/index.d.ts +1 -0
  191. package/lib/typescript/ui-components/loader/loading-result.d.ts +1 -1
  192. package/lib/typescript/ui-components/pin/pin-lock-animation.d.ts +311 -311
  193. package/lib/typescript/ui-components/proof-request/index.d.ts +3 -0
  194. package/lib/typescript/ui-components/proof-request/proof-request-set.d.ts +7 -0
  195. package/lib/typescript/ui-components/screens/section-list-screen.d.ts +4 -2
  196. package/lib/typescript/utils/array.d.ts +1 -0
  197. package/lib/typescript/utils/hooks/app-state.d.ts +5 -0
  198. package/lib/typescript/utils/hooks/core/backup.d.ts +1 -1
  199. package/lib/typescript/utils/hooks/core/credentials.d.ts +2 -1
  200. package/lib/typescript/utils/hooks/core/identifiers.d.ts +1 -1
  201. package/lib/typescript/utils/hooks/core/index.d.ts +1 -0
  202. package/lib/typescript/utils/hooks/core/proofs.d.ts +6 -10
  203. package/lib/typescript/utils/hooks/core/wallet-unit.d.ts +9 -0
  204. package/lib/typescript/utils/hooks/index.d.ts +1 -0
  205. package/lib/typescript/utils/index.d.ts +1 -1
  206. package/lib/typescript/utils/parsers/credential-sharing-v2.d.ts +10 -0
  207. package/lib/typescript/utils/parsers/credential-sharing.d.ts +7 -2
  208. package/lib/typescript/utils/parsers/credential.d.ts +1 -2
  209. package/lib/typescript/utils/parsers/index.d.ts +1 -0
  210. package/lib/typescript/utils/parsers/query.d.ts +2 -2
  211. package/package.json +13 -7
  212. package/src/components/entity/entity-attributes.tsx +3 -0
  213. package/src/components/entity/entity-details-with-buttons.tsx +1 -0
  214. package/src/components/proof-request/index.ts +4 -3
  215. package/src/components/proof-request/select-share-credential-card-notice.tsx +37 -0
  216. package/src/components/proof-request/share-credential-card-notice.tsx +33 -0
  217. package/src/components/proof-request/{group.tsx → v1/group.tsx} +1 -1
  218. package/src/components/proof-request/v1/index.ts +3 -0
  219. package/src/components/proof-request/{select-credential.tsx → v1/select-credential.tsx} +7 -4
  220. package/src/components/proof-request/{share-credential.tsx → v1/share-credential.tsx} +30 -51
  221. package/src/components/proof-request/v2/index.ts +3 -0
  222. package/src/components/proof-request/v2/select-credential-v2.tsx +52 -0
  223. package/src/components/proof-request/v2/share-credential-v2-group.tsx +258 -0
  224. package/src/components/proof-request/v2/share-credential-v2.tsx +202 -0
  225. package/src/ui-components/buttons/share-button.tsx +1 -1
  226. package/src/ui-components/camera/qr-code-scanner.tsx +11 -2
  227. package/src/ui-components/credential/card/credential-details-list-item.tsx +27 -49
  228. package/src/ui-components/credential/credential-attribute-item.tsx +2 -0
  229. package/src/ui-components/credential/group/credential-group-header.tsx +70 -0
  230. package/src/ui-components/credential/group/index.ts +4 -0
  231. package/src/ui-components/credential/index.ts +1 -0
  232. package/src/ui-components/header/foldable-header.tsx +31 -16
  233. package/src/ui-components/index.ts +1 -0
  234. package/src/ui-components/loader/loading-result.tsx +1 -1
  235. package/src/ui-components/pin/pin-lock-animation.tsx +240 -278
  236. package/src/ui-components/proof-request/index.ts +4 -0
  237. package/src/ui-components/proof-request/proof-request-set.tsx +46 -0
  238. package/src/ui-components/screens/section-list-screen.tsx +18 -4
  239. package/src/utils/array.ts +4 -0
  240. package/src/utils/hooks/app-state.ts +29 -0
  241. package/src/utils/hooks/core/backup.ts +2 -5
  242. package/src/utils/hooks/core/cache.ts +3 -0
  243. package/src/utils/hooks/core/credentials.ts +14 -6
  244. package/src/utils/hooks/core/identifiers.ts +15 -14
  245. package/src/utils/hooks/core/index.ts +2 -1
  246. package/src/utils/hooks/core/proofs.ts +40 -22
  247. package/src/utils/hooks/core/wallet-unit.ts +71 -0
  248. package/src/utils/hooks/index.ts +1 -0
  249. package/src/utils/hooks/revocation/credential-status.ts +1 -1
  250. package/src/utils/index.ts +1 -1
  251. package/src/utils/parsers/credential-sharing-v2.tsx +278 -0
  252. package/src/utils/parsers/credential-sharing.tsx +63 -40
  253. package/src/utils/parsers/credential.ts +100 -57
  254. package/src/utils/parsers/index.ts +1 -0
  255. package/src/utils/parsers/query.ts +6 -5
  256. package/lib/commonjs/components/proof-request/group.js.map +0 -1
  257. package/lib/commonjs/components/proof-request/select-credential.js.map +0 -1
  258. package/lib/commonjs/components/proof-request/share-credential.js.map +0 -1
  259. package/lib/module/components/proof-request/group.js.map +0 -1
  260. package/lib/module/components/proof-request/select-credential.js.map +0 -1
  261. package/lib/module/components/proof-request/share-credential.js.map +0 -1
  262. /package/lib/typescript/components/proof-request/{group.d.ts → v1/group.d.ts} +0 -0
@@ -0,0 +1,278 @@
1
+ import {
2
+ Claim,
3
+ Config,
4
+ DataTypeEnum,
5
+ FailureHint,
6
+ PresentationDefinitionV2ClaimValue,
7
+ PresentationDefinitionV2CredentialClaim,
8
+ PresentationDefinitionV2CredentialDetail,
9
+ } from '@procivis/react-native-one-core';
10
+ import React from 'react';
11
+
12
+ import {
13
+ CredentialAttribute,
14
+ CredentialCardNotice,
15
+ CredentialCardProps,
16
+ CredentialNoticeWarningIcon,
17
+ CredentialWarningIcon,
18
+ Selector,
19
+ SelectorStatus,
20
+ } from '../../ui-components';
21
+ import { concatTestID } from '../testID';
22
+ import {
23
+ CredentialDetailsCardPropsWithoutWidth,
24
+ detailsCardAttributeFromClaim,
25
+ getCredentialCardPropsFromCredential,
26
+ supportsSelectiveDisclosure,
27
+ } from '.';
28
+ import { ShareCredentialCardLabels, validityCheckedCardFromCredential } from './credential-sharing';
29
+
30
+ const v2ClaimValueToClaimValue = (value: PresentationDefinitionV2ClaimValue): string | number | boolean | Claim[] => {
31
+ if (!Array.isArray(value)) {
32
+ return value;
33
+ }
34
+ return value.map((c) => v2PresentationClaimToClaim(c));
35
+ };
36
+
37
+ const v2PresentationClaimToClaim = (claim: PresentationDefinitionV2CredentialClaim): Claim => {
38
+ if (Array.isArray(claim.value)) {
39
+ if (claim.schema.array) {
40
+ return {
41
+ array: claim.schema.array,
42
+ dataType: claim.schema.datatype,
43
+ id: claim.path,
44
+ key: claim.path,
45
+ value: v2ClaimValueToClaimValue(claim.value) as Claim[],
46
+ };
47
+ } else {
48
+ return {
49
+ array: claim.schema.array,
50
+ dataType: DataTypeEnum.Object,
51
+ id: claim.path,
52
+ key: claim.path,
53
+ value: v2ClaimValueToClaimValue(claim.value) as Claim[],
54
+ };
55
+ }
56
+ }
57
+ return {
58
+ array: false,
59
+ dataType: claim.schema.datatype,
60
+ id: claim.path,
61
+ key: claim.path,
62
+ value: claim.value,
63
+ };
64
+ };
65
+
66
+ const getAttributeSelectorStatus = (
67
+ claim: PresentationDefinitionV2CredentialClaim,
68
+ selected: boolean,
69
+ force: boolean,
70
+ ): SelectorStatus | undefined => {
71
+ if (claim.required && selected) {
72
+ return SelectorStatus.Required;
73
+ }
74
+ if (force && claim.value) {
75
+ return SelectorStatus.Required;
76
+ }
77
+ if (claim.userSelection) {
78
+ if (selected) {
79
+ return SelectorStatus.SelectedCheckmark;
80
+ } else {
81
+ return SelectorStatus.Empty;
82
+ }
83
+ }
84
+ };
85
+
86
+ export const shareCredentialCardAttributeFromV2Claim = (
87
+ claim: PresentationDefinitionV2CredentialClaim,
88
+ selection: string[] | undefined,
89
+ parentShared: boolean,
90
+ parentUserSelected: boolean,
91
+ config: Config,
92
+ testID: string,
93
+ nested?: boolean,
94
+ listValue?: boolean,
95
+ ): CredentialAttribute => {
96
+ const attributeShared =
97
+ Boolean(selection?.some((path) => path.startsWith(claim.path))) || (parentShared && claim.required);
98
+ const userSelected = parentUserSelected || Boolean(selection?.includes(claim.path));
99
+ const selected = !claim.required && attributeShared;
100
+ const status = selection
101
+ ? getAttributeSelectorStatus(claim, attributeShared, parentUserSelected || (attributeShared && !userSelected))
102
+ : undefined;
103
+ const attribute = detailsCardAttributeFromClaim(v2PresentationClaimToClaim(claim), config, testID);
104
+ const disabledStatus = [SelectorStatus.Disabled, SelectorStatus.Rejected, SelectorStatus.Required];
105
+ const disabled = attribute.disabled || !status || disabledStatus.includes(status);
106
+ const credentialAttribute: CredentialAttribute = {
107
+ ...attribute,
108
+ disabled,
109
+ id: claim.path,
110
+ listValue,
111
+ nested,
112
+ path: claim.path,
113
+ rightAccessory: status && <Selector status={status} />,
114
+ selected,
115
+ testID,
116
+ };
117
+ if (Array.isArray(claim.value)) {
118
+ if (claim.schema.array) {
119
+ return {
120
+ ...credentialAttribute,
121
+ attributes: undefined,
122
+ image: undefined,
123
+ value: undefined,
124
+ values: claim.value.map((v) =>
125
+ shareCredentialCardAttributeFromV2Claim(
126
+ v,
127
+ selection,
128
+ attributeShared,
129
+ userSelected,
130
+ config,
131
+ testID,
132
+ true,
133
+ false,
134
+ ),
135
+ ),
136
+ };
137
+ } else if (claim.schema.datatype === 'OBJECT') {
138
+ return {
139
+ ...credentialAttribute,
140
+ attributes: claim.value.map((v) =>
141
+ shareCredentialCardAttributeFromV2Claim(v, selection, attributeShared, userSelected, config, testID, true),
142
+ ),
143
+ image: undefined,
144
+ value: undefined,
145
+ valueErrorColor: undefined,
146
+ values: undefined,
147
+ };
148
+ }
149
+ }
150
+ return credentialAttribute;
151
+ };
152
+
153
+ export const missingCredentialCardFromFailureHint = (
154
+ failureHint: FailureHint['failureHint'] | undefined,
155
+ notice: CredentialCardNotice | undefined,
156
+ testID: string,
157
+ labels: ShareCredentialCardLabels,
158
+ ): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'width'> => {
159
+ return {
160
+ cardImage: undefined,
161
+ color: undefined,
162
+ header: {
163
+ credentialDetailErrorColor: true,
164
+ credentialDetailPrimary: labels.missingCredential,
165
+ credentialDetailTestID: concatTestID(testID, 'header.missing'),
166
+ credentialName: failureHint?.credentialSchema?.name ?? '',
167
+ statusIcon: CredentialWarningIcon,
168
+ },
169
+ testID,
170
+ ...notice,
171
+ };
172
+ };
173
+
174
+ export const shareCredentialCardFromV2PresentationCredential = (
175
+ credential: PresentationDefinitionV2CredentialDetail | undefined,
176
+ failureHint: FailureHint['failureHint'] | undefined,
177
+ expanded: boolean,
178
+ multipleCredentialsAvailable: boolean,
179
+ selectedFields: string[] | undefined,
180
+ config: Config,
181
+ testID: string,
182
+ labels: ShareCredentialCardLabels,
183
+ ): CredentialDetailsCardPropsWithoutWidth => {
184
+ const selectiveDisclosureSupported = supportsSelectiveDisclosure(
185
+ credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
186
+ config,
187
+ );
188
+ const notice: CredentialCardNotice | undefined =
189
+ selectiveDisclosureSupported === false
190
+ ? {
191
+ noticeIcon: CredentialNoticeWarningIcon,
192
+ text: labels.selectiveDisclosureNotice,
193
+ }
194
+ : undefined;
195
+ const cardTestId = concatTestID(testID, 'card');
196
+ const card = credential
197
+ ? validityCheckedCardFromCredential(
198
+ {
199
+ ...credential,
200
+ claims: [],
201
+ },
202
+ false,
203
+ expanded,
204
+ multipleCredentialsAvailable,
205
+ config,
206
+ notice,
207
+ cardTestId,
208
+ labels,
209
+ )
210
+ : missingCredentialCardFromFailureHint(failureHint, notice, cardTestId, labels);
211
+
212
+ return {
213
+ attributes:
214
+ credential?.claims.map((v) =>
215
+ shareCredentialCardAttributeFromV2Claim(v, selectedFields ?? [], true, false, config, testID),
216
+ ) ?? [],
217
+ card,
218
+ };
219
+ };
220
+
221
+ export const selectCredentialCardFromV2Credential = (
222
+ credential: PresentationDefinitionV2CredentialDetail,
223
+ selected: boolean,
224
+ multiple: boolean,
225
+ config: Config,
226
+ testID: string,
227
+ labels: ShareCredentialCardLabels,
228
+ ): CredentialDetailsCardPropsWithoutWidth => {
229
+ const selectiveDisclosureSupported = supportsSelectiveDisclosure(
230
+ credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
231
+ config,
232
+ );
233
+ const selectedStatus = multiple ? SelectorStatus.SelectedCheckmark : SelectorStatus.SelectedRadio;
234
+ const rightAccessory = <Selector status={selected ? selectedStatus : SelectorStatus.Empty} />;
235
+ const notice: CredentialCardNotice | undefined =
236
+ selectiveDisclosureSupported === false
237
+ ? {
238
+ noticeIcon: CredentialNoticeWarningIcon,
239
+ text: labels.selectiveDisclosureNotice,
240
+ }
241
+ : undefined;
242
+ const { header, ...cardProps } = getCredentialCardPropsFromCredential(
243
+ {
244
+ ...credential,
245
+ claims: credential.claims.map(v2PresentationClaimToClaim),
246
+ },
247
+ credential.claims.map(v2PresentationClaimToClaim),
248
+ config,
249
+ notice,
250
+ testID,
251
+ labels,
252
+ );
253
+ const card = {
254
+ header: {
255
+ ...header,
256
+ accessory: rightAccessory,
257
+ },
258
+ ...cardProps,
259
+ };
260
+ return {
261
+ attributes:
262
+ credential?.claims.map((v) =>
263
+ shareCredentialCardAttributeFromV2Claim(v, undefined, false, false, config, testID),
264
+ ) ?? [],
265
+ card,
266
+ };
267
+ };
268
+
269
+ export const getV2CredentialClaimAllSubpaths = (claim: PresentationDefinitionV2CredentialClaim): string[] => {
270
+ if (!Array.isArray(claim.value)) {
271
+ return [claim.path];
272
+ }
273
+ return [claim.path, ...claim.value.flatMap(getV2CredentialClaimAllSubpaths)];
274
+ };
275
+
276
+ export const getV2CredentialAvailablePaths = (credential: PresentationDefinitionV2CredentialDetail): string[] => {
277
+ return credential.claims.flatMap(getV2CredentialClaimAllSubpaths);
278
+ };
@@ -40,13 +40,13 @@ export const validityCheckedCardFromCredential = (
40
40
  ): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'testID' | 'width'> => {
41
41
  let credentialHeaderDetail:
42
42
  | Pick<
43
- CredentialHeaderProps,
44
- | 'credentialDetailPrimary'
45
- | 'credentialDetailSecondary'
46
- | 'credentialDetailErrorColor'
47
- | 'credentialDetailTestID'
48
- | 'statusIcon'
49
- >
43
+ CredentialHeaderProps,
44
+ | 'credentialDetailPrimary'
45
+ | 'credentialDetailSecondary'
46
+ | 'credentialDetailErrorColor'
47
+ | 'credentialDetailTestID'
48
+ | 'statusIcon'
49
+ >
50
50
  | undefined;
51
51
  if (invalidLVVC) {
52
52
  credentialHeaderDetail = {
@@ -94,7 +94,7 @@ export const missingCredentialCardFromRequest = (
94
94
  };
95
95
 
96
96
  interface DisplayedAttribute {
97
- claim?: Claim;
97
+ claim?: FlatClaim;
98
98
  field?: PresentationDefinitionField;
99
99
  id: string;
100
100
  selected?: boolean;
@@ -124,16 +124,33 @@ const getAttributeSelectorStatus = (
124
124
  return selected ? SelectorStatus.SelectedCheckmark : SelectorStatus.Empty;
125
125
  };
126
126
 
127
+ type ClaimWithOptionalPath = Claim & {
128
+ path?: string;
129
+ };
130
+
131
+ type FlatClaim = Claim & {
132
+ path: string;
133
+ isArrayElement?: boolean;
134
+ };
135
+
127
136
  // Returns a spread list of all claims with their full JSON path as key, including all intermediate objects
128
- const spreadClaims = (claims: Claim[], parentClaimPath = ''): Claim[] => {
129
- return claims.reduce((acc, claim) => {
137
+ const spreadClaims = (claims: ClaimWithOptionalPath[]): FlatClaim[] => {
138
+ const claimsWithPath: FlatClaim[] = claims.map((c) => ({
139
+ ...c,
140
+ path: c.path ?? c.key,
141
+ }));
142
+ return claimsWithPath.reduce((acc, claim) => {
130
143
  const result = [claim];
131
144
  if (Array.isArray(claim.value)) {
132
- const claimPath = parentClaimPath ? `${parentClaimPath}/${claim.key}` : claim.key;
133
- result.push(...spreadClaims(claim.value, claimPath));
145
+ const nestedClaimsWithPath: FlatClaim[] = claim.value.map((c, i) => ({
146
+ ...c,
147
+ path: claim.array ? `${c.key}/${i}` : c.key,
148
+ isArrayElement: claim.array,
149
+ }));
150
+ result.push(...spreadClaims(nestedClaimsWithPath));
134
151
  }
135
152
  return [...acc, ...result];
136
- }, [] as Claim[]);
153
+ }, [] as FlatClaim[]);
137
154
  };
138
155
 
139
156
  const getDisplayedAttributes = (
@@ -144,10 +161,13 @@ const getDisplayedAttributes = (
144
161
  selectedFields?: string[],
145
162
  ): DisplayedAttribute[] => {
146
163
  const claims = credential ? spreadClaims(credential.claims) : undefined;
164
+ const isApplicable = credential ? request.applicableCredentials.includes(credential.id) : false;
147
165
 
148
166
  let fields = request.fields;
149
167
  if (credential) {
150
- const fieldsWithNoKeyMapping = request.fields.filter((field) => !(credential.id in field.keyMap));
168
+ const fieldsWithNoKeyMapping = request.fields
169
+ .filter((field) => !(credential.id in field.keyMap))
170
+ .filter((field) => !isApplicable || !field.required);
151
171
  const fullyNestedFields = getFullyNestedFields(request.fields, credential.id);
152
172
 
153
173
  fields = [...fieldsWithNoKeyMapping, ...fullyNestedFields];
@@ -156,8 +176,8 @@ const getDisplayedAttributes = (
156
176
  return fields.map((field) => {
157
177
  const selected = !field.required && selectedFields?.includes(field.id);
158
178
  const claim = credential
159
- ? claims?.find(({ key }) => {
160
- return key === field.keyMap[credential.id];
179
+ ? claims?.find(({ path }) => {
180
+ return path === field.keyMap[credential.id];
161
181
  })
162
182
  : undefined;
163
183
  const status =
@@ -185,11 +205,16 @@ export const shareCredentialCardAttributeFromClaim = (
185
205
  config: Config,
186
206
  testID: string,
187
207
  labels: ShareCredentialCardLabels,
188
- claim?: Claim,
208
+ claim?: FlatClaim,
189
209
  field?: PresentationDefinitionField,
190
210
  ): CredentialAttribute => {
191
211
  if (claim) {
192
- return { ...detailsCardAttributeFromClaim(claim, config, testID), id };
212
+ return {
213
+ ...detailsCardAttributeFromClaim(claim, config, testID),
214
+ id,
215
+ path: claim.path,
216
+ listValue: claim.isArrayElement,
217
+ };
193
218
  }
194
219
  return {
195
220
  id,
@@ -259,26 +284,24 @@ export const shareCredentialCardFromCredential = (
259
284
  const notice: CredentialCardNotice | undefined =
260
285
  selectiveDisclosureSupported === false
261
286
  ? {
262
- text: labels.selectiveDisclosureNotice,
263
- noticeIcon: CredentialNoticeWarningIcon,
264
- }
287
+ text: labels.selectiveDisclosureNotice,
288
+ noticeIcon: CredentialNoticeWarningIcon,
289
+ }
265
290
  : undefined;
266
291
  const cardTestId = concatTestID(testID, 'card');
267
292
  const card = credential
268
293
  ? validityCheckedCardFromCredential(
269
- credential,
270
- invalidLVVC,
271
- expanded,
272
- multipleCredentialsAvailable,
273
- config,
274
- notice,
275
- cardTestId,
276
- labels,
277
- )
294
+ credential,
295
+ invalidLVVC,
296
+ expanded,
297
+ multipleCredentialsAvailable,
298
+ config,
299
+ notice,
300
+ cardTestId,
301
+ labels,
302
+ )
278
303
  : missingCredentialCardFromRequest(request, notice, cardTestId, labels);
279
- const validityState = getValidityState(
280
- credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
281
- );
304
+ const validityState = getValidityState(credential ? { ...credential, issuer: credential.issuer?.id } : undefined);
282
305
  const displayedAttributes = getDisplayedAttributes(
283
306
  request,
284
307
  validityState,
@@ -315,7 +338,7 @@ export const selectCredentialCardAttributeFromClaim = (
315
338
  config: Config,
316
339
  testID: string,
317
340
  labels: ShareCredentialCardLabels,
318
- claim?: Claim,
341
+ claim?: FlatClaim,
319
342
  field?: PresentationDefinitionField,
320
343
  ): CredentialAttribute => {
321
344
  const attribute = shareCredentialCardAttributeFromClaim(id, config, testID, labels, claim, field);
@@ -344,9 +367,9 @@ export const selectCredentialCardFromCredential = (
344
367
  const notice: CredentialCardNotice | undefined =
345
368
  selectiveDisclosureSupported === false
346
369
  ? {
347
- text: labels.selectiveDisclosureNotice,
348
- noticeIcon: CredentialNoticeWarningIcon,
349
- }
370
+ text: labels.selectiveDisclosureNotice,
371
+ noticeIcon: CredentialNoticeWarningIcon,
372
+ }
350
373
  : undefined;
351
374
  const { header, ...cardProps } = getCredentialCardPropsFromCredential(
352
375
  credential,
@@ -363,9 +386,9 @@ export const selectCredentialCardFromCredential = (
363
386
  },
364
387
  ...cardProps,
365
388
  };
366
- const attributes: CredentialAttribute[] = request.fields.map((field) => {
367
- const claim = spreadClaims(credential.claims).find(({ key }) => {
368
- return key === field.keyMap[credential.id];
389
+ const attributes: CredentialAttribute[] = getFullyNestedFields(request.fields, credential.id).map((field) => {
390
+ const claim = spreadClaims(credential.claims).find(({ path }) => {
391
+ return path === field.keyMap[credential.id];
369
392
  });
370
393
 
371
394
  const attribute = selectCredentialCardAttributeFromClaim(field.id, config, testID, labels, claim, field);
@@ -8,6 +8,8 @@ import {
8
8
  DataTypeEnum,
9
9
  FormatFeatureEnum,
10
10
  } from '@procivis/react-native-one-core';
11
+ import { FC } from 'react';
12
+ import { SvgProps } from 'react-native-svg';
11
13
 
12
14
  import {
13
15
  CredentialAttribute,
@@ -84,60 +86,86 @@ export type CardHeaderLabels = {
84
86
  suspendedUntil: (date: string) => string;
85
87
  };
86
88
 
87
- export const cardHeaderFromCredential = (
89
+ const credentialDetailFromCredential = (
88
90
  credential: CredentialDetail,
89
91
  claims: Claim[] = [],
90
92
  config: Config,
91
93
  testID: string,
92
94
  labels: CardHeaderLabels,
93
- ): Omit<CredentialHeaderProps, 'style'> => {
94
- let credentialDetailPrimary =
95
- formatDateTimeLocalized(new Date(credential.issuanceDate ?? credential.createdDate)) ?? '';
96
-
97
- let credentialDetailSecondary: string | undefined;
98
- let credentialDetailErrorColor: boolean | undefined;
99
- let credentialDetailTestID: string | undefined;
100
- let statusIcon;
101
-
95
+ ): {
96
+ credentialDetailPrimary?: string;
97
+ credentialDetailSecondary?: string;
98
+ credentialDetailErrorColor?: boolean;
99
+ credentialDetailTestID?: string;
100
+ statusIcon?: FC<SvgProps>;
101
+ } => {
102
102
  const { layoutProperties } = credential.schema;
103
103
 
104
104
  switch (credential.state) {
105
105
  case CredentialStateEnum.SUSPENDED:
106
- credentialDetailPrimary = credential.suspendEndDate
107
- ? labels.suspendedUntil(formatDateTimeLocalized(new Date(credential.suspendEndDate))!)
108
- : labels.suspended;
109
- credentialDetailTestID = concatTestID(testID, 'suspended');
110
- statusIcon = CredentialWarningIcon;
111
- break;
106
+ return {
107
+ credentialDetailPrimary: credential.suspendEndDate
108
+ ? labels.suspendedUntil(formatDateTimeLocalized(new Date(credential.suspendEndDate))!)
109
+ : labels.suspended,
110
+ credentialDetailTestID: concatTestID(testID, 'suspended'),
111
+ statusIcon: CredentialWarningIcon,
112
+ };
112
113
  case CredentialStateEnum.REVOKED:
113
- credentialDetailPrimary = labels.revoked;
114
- credentialDetailErrorColor = true;
115
- credentialDetailTestID = concatTestID(testID, 'revoked');
116
- statusIcon = CredentialErrorIcon;
117
- break;
118
- default: {
119
- if (hasMsoValidityIssues(credential)) {
120
- credentialDetailPrimary = labels.validityIssues;
121
- credentialDetailTestID = concatTestID(testID, 'validity-issue');
122
- statusIcon = CredentialWarningIcon;
123
- } else {
124
- const primary = findClaimByPath(layoutProperties?.primaryAttribute, claims);
114
+ return {
115
+ credentialDetailPrimary: labels.revoked,
116
+ credentialDetailErrorColor: true,
117
+ credentialDetailTestID: concatTestID(testID, 'revoked'),
118
+ statusIcon: CredentialErrorIcon,
119
+ };
120
+ }
125
121
 
126
- if (primary) {
127
- credentialDetailPrimary = formatCredentialDetail(primary, config, concatTestID(testID, 'primary'));
128
- }
122
+ if (hasMsoValidityIssues(credential)) {
123
+ return {
124
+ credentialDetailPrimary: labels.validityIssues,
125
+ credentialDetailTestID: concatTestID(testID, 'validity-issue'),
126
+ statusIcon: CredentialWarningIcon,
127
+ };
128
+ }
129
129
 
130
- const secondary = findClaimByPath(layoutProperties?.secondaryAttribute, claims);
130
+ let credentialDetailPrimary =
131
+ formatDateTimeLocalized(new Date(credential.issuanceDate ?? credential.createdDate)) ?? '';
132
+ let credentialDetailSecondary: string | undefined;
131
133
 
132
- if (secondary) {
133
- credentialDetailSecondary = formatCredentialDetail(secondary, config, concatTestID(testID, 'secondary'));
134
- }
134
+ const primary = findClaimByPath(layoutProperties?.primaryAttribute, claims);
135
135
 
136
- credentialDetailTestID = concatTestID(testID, 'detail');
137
- }
138
- break;
139
- }
136
+ if (primary) {
137
+ credentialDetailPrimary = formatCredentialDetail(primary, config, concatTestID(testID, 'primary'));
138
+ }
139
+
140
+ const secondary = findClaimByPath(layoutProperties?.secondaryAttribute, claims);
141
+
142
+ if (secondary) {
143
+ credentialDetailSecondary = formatCredentialDetail(secondary, config, concatTestID(testID, 'secondary'));
140
144
  }
145
+
146
+ return {
147
+ credentialDetailPrimary,
148
+ credentialDetailSecondary,
149
+ credentialDetailTestID: concatTestID(testID, 'detail'),
150
+ };
151
+ };
152
+
153
+ export const cardHeaderFromCredential = (
154
+ credential: CredentialDetail,
155
+ claims: Claim[] = [],
156
+ config: Config,
157
+ testID: string,
158
+ labels: CardHeaderLabels,
159
+ ): Omit<CredentialHeaderProps, 'style'> => {
160
+ const {
161
+ credentialDetailPrimary,
162
+ credentialDetailSecondary,
163
+ credentialDetailErrorColor,
164
+ credentialDetailTestID,
165
+ statusIcon,
166
+ } = credentialDetailFromCredential(credential, claims, config, testID, labels);
167
+ const { layoutProperties } = credential.schema;
168
+
141
169
  return {
142
170
  color: layoutProperties?.logo?.backgroundColor,
143
171
  credentialDetailErrorColor,
@@ -242,7 +270,8 @@ const detailsCardAttributeValueFromClaim = (claim: Claim, config: Config, testID
242
270
  value: formatDateLocalized(new Date(date)) ?? date,
243
271
  };
244
272
  }
245
- case DataTypeEnum.File: {
273
+ case DataTypeEnum.Picture: // fallback
274
+ case DataTypeEnum.SwiyuPicture: {
246
275
  if (typeConfig.params?.showAs === 'IMAGE') {
247
276
  return { image: { uri: claim.value as string }, testID: testID };
248
277
  } else {
@@ -257,7 +286,7 @@ const detailsCardAttributeValueFromClaim = (claim: Claim, config: Config, testID
257
286
 
258
287
  export type CredentialDetailsCardPropsWithoutWidth = Omit<CredentialDetailsCardProps, 'expanded' | 'card'> & {
259
288
  card: Omit<CredentialCardProps, 'width'>;
260
- }
289
+ };
261
290
 
262
291
  export const detailsCardFromCredential = (
263
292
  credential: CredentialDetail,
@@ -307,9 +336,9 @@ export const nestAttributes = (attributes: CredentialAttribute[]): CredentialAtt
307
336
  const [first, ...rest] = attributePath;
308
337
  const parent = result.find((a) => a.name === first);
309
338
  if (parent) {
310
- insertAttributeInObject({ ...attribute, path: rest.join('/') }, parent);
339
+ insertAttributeInParent({ ...attribute, path: rest.join('/') }, parent);
311
340
  } else {
312
- result.push(nestAttributeInDummyObject(attribute));
341
+ result.push(nestAttributeInDummyParent(attribute));
313
342
  }
314
343
  }
315
344
  }
@@ -319,7 +348,7 @@ export const nestAttributes = (attributes: CredentialAttribute[]): CredentialAtt
319
348
 
320
349
  // We nest the leaf node in a (one or more) nested object(s)
321
350
  // to make sure the tree structure is correctly rendered in proof request screens.
322
- const nestAttributeInDummyObject = (attribute: CredentialAttribute): CredentialAttribute => {
351
+ const nestAttributeInDummyParent = (attribute: CredentialAttribute): CredentialAttribute => {
323
352
  const pathParts = attribute.path.split('/');
324
353
  const [first, ...rest] = pathParts;
325
354
  if (!rest.length) {
@@ -328,27 +357,41 @@ const nestAttributeInDummyObject = (attribute: CredentialAttribute): CredentialA
328
357
 
329
358
  // The dummy object is not selectable, and contains a placeholder ID
330
359
  // the user can't interact with it.
331
- return {
332
- attributes: [nestAttributeInDummyObject({ ...attribute, path: rest.join('/') })],
333
- disabled: true,
334
- id: `${attribute.id}/${first}`,
335
- name: first,
336
- path: attribute.path,
337
- };
360
+ if (attribute.listValue) {
361
+ return {
362
+ values: [nestAttributeInDummyParent({ ...attribute, path: rest.join('/') })],
363
+ disabled: true,
364
+ id: `${attribute.id}/${first}`,
365
+ name: first,
366
+ path: first,
367
+ };
368
+ } else {
369
+ return {
370
+ attributes: [nestAttributeInDummyParent({ ...attribute, path: rest.join('/') })],
371
+ disabled: true,
372
+ id: `${attribute.id}/${first}`,
373
+ name: first,
374
+ path: first,
375
+ };
376
+ }
338
377
  };
339
378
 
340
- // Recursively insert an attribute into an object
341
- // Will create nested objects if necessary
342
- const insertAttributeInObject = (attribute: CredentialAttribute, object: CredentialAttribute) => {
379
+ // Recursively insert an attribute into an parent
380
+ // Will create nested parents if necessary
381
+ const insertAttributeInParent = (attribute: CredentialAttribute, parent: CredentialAttribute) => {
343
382
  const pathParts = attribute.path.split('/');
344
383
  const [first, ...rest] = pathParts;
345
384
 
346
- const nextParent = object.attributes?.find((a) => a.name === first);
385
+ const nextParent = parent.attributes?.find((a) => a.name === first);
347
386
 
348
387
  if (!nextParent) {
349
- object.attributes?.push(nestAttributeInDummyObject(attribute));
388
+ if (attribute.listValue) {
389
+ parent.values?.push(nestAttributeInDummyParent(attribute));
390
+ } else {
391
+ parent.attributes?.push(nestAttributeInDummyParent(attribute));
392
+ }
350
393
  } else {
351
- insertAttributeInObject({ ...attribute, path: rest.join('/') }, nextParent);
394
+ insertAttributeInParent({ ...attribute, path: rest.join('/') }, nextParent);
352
395
  }
353
396
  };
354
397