@procivis/one-react-native-components 0.3.132 → 0.3.143

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 (139) hide show
  1. package/lib/commonjs/components/history/history-list-item-icon.js +2 -0
  2. package/lib/commonjs/components/history/history-list-item-icon.js.map +1 -1
  3. package/lib/commonjs/components/proof-request/index.js +1 -12
  4. package/lib/commonjs/components/proof-request/index.js.map +1 -1
  5. package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js.map +1 -1
  6. package/lib/commonjs/components/proof-request/v2/share-credential-v2.js.map +1 -1
  7. package/lib/commonjs/ui-components/buttons/scan-button.js +122 -27
  8. package/lib/commonjs/ui-components/buttons/scan-button.js.map +1 -1
  9. package/lib/commonjs/ui-components/credential/card/credential-details-card.js +37 -18
  10. package/lib/commonjs/ui-components/credential/card/credential-details-card.js.map +1 -1
  11. package/lib/commonjs/ui-components/credential/credential-attribute-item.js +13 -4
  12. package/lib/commonjs/ui-components/credential/credential-attribute-item.js.map +1 -1
  13. package/lib/commonjs/ui-components/icons/icons.js +36 -2
  14. package/lib/commonjs/ui-components/icons/icons.js.map +1 -1
  15. package/lib/commonjs/ui-components/list/wallet/empty-list.js +2 -1
  16. package/lib/commonjs/ui-components/list/wallet/empty-list.js.map +1 -1
  17. package/lib/commonjs/ui-components/notice/wallet-notice.js +4 -2
  18. package/lib/commonjs/ui-components/notice/wallet-notice.js.map +1 -1
  19. package/lib/commonjs/ui-components/text/expandableTypography.js +64 -0
  20. package/lib/commonjs/ui-components/text/expandableTypography.js.map +1 -0
  21. package/lib/commonjs/ui-components/text/index.js +15 -0
  22. package/lib/commonjs/ui-components/text/index.js.map +1 -1
  23. package/lib/commonjs/utils/hooks/core/credential-schemas.js +24 -1
  24. package/lib/commonjs/utils/hooks/core/credential-schemas.js.map +1 -1
  25. package/lib/commonjs/utils/hooks/core/proofs.js +1 -1
  26. package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
  27. package/lib/commonjs/utils/hooks/core/wallet-unit.js +20 -1
  28. package/lib/commonjs/utils/hooks/core/wallet-unit.js.map +1 -1
  29. package/lib/commonjs/utils/parsers/credential-sharing-v2.js +34 -7
  30. package/lib/commonjs/utils/parsers/credential-sharing-v2.js.map +1 -1
  31. package/lib/commonjs/utils/parsers/credential.js +12 -4
  32. package/lib/commonjs/utils/parsers/credential.js.map +1 -1
  33. package/lib/commonjs/utils/parsers/index.js +0 -11
  34. package/lib/commonjs/utils/parsers/index.js.map +1 -1
  35. package/lib/commonjs/utils/parsers/query.js +1 -1
  36. package/lib/commonjs/utils/parsers/query.js.map +1 -1
  37. package/lib/module/components/history/history-list-item-icon.js +2 -0
  38. package/lib/module/components/history/history-list-item-icon.js.map +1 -1
  39. package/lib/module/components/proof-request/index.js +0 -1
  40. package/lib/module/components/proof-request/index.js.map +1 -1
  41. package/lib/module/components/proof-request/v2/share-credential-v2-group.js.map +1 -1
  42. package/lib/module/components/proof-request/v2/share-credential-v2.js.map +1 -1
  43. package/lib/module/ui-components/buttons/scan-button.js +124 -29
  44. package/lib/module/ui-components/buttons/scan-button.js.map +1 -1
  45. package/lib/module/ui-components/credential/card/credential-details-card.js +37 -18
  46. package/lib/module/ui-components/credential/card/credential-details-card.js.map +1 -1
  47. package/lib/module/ui-components/credential/credential-attribute-item.js +13 -4
  48. package/lib/module/ui-components/credential/credential-attribute-item.js.map +1 -1
  49. package/lib/module/ui-components/icons/icons.js +32 -0
  50. package/lib/module/ui-components/icons/icons.js.map +1 -1
  51. package/lib/module/ui-components/list/wallet/empty-list.js +2 -1
  52. package/lib/module/ui-components/list/wallet/empty-list.js.map +1 -1
  53. package/lib/module/ui-components/notice/wallet-notice.js +4 -2
  54. package/lib/module/ui-components/notice/wallet-notice.js.map +1 -1
  55. package/lib/module/ui-components/text/expandableTypography.js +55 -0
  56. package/lib/module/ui-components/text/expandableTypography.js.map +1 -0
  57. package/lib/module/ui-components/text/index.js +2 -1
  58. package/lib/module/ui-components/text/index.js.map +1 -1
  59. package/lib/module/utils/hooks/core/credential-schemas.js +24 -1
  60. package/lib/module/utils/hooks/core/credential-schemas.js.map +1 -1
  61. package/lib/module/utils/hooks/core/proofs.js +1 -1
  62. package/lib/module/utils/hooks/core/proofs.js.map +1 -1
  63. package/lib/module/utils/hooks/core/wallet-unit.js +18 -0
  64. package/lib/module/utils/hooks/core/wallet-unit.js.map +1 -1
  65. package/lib/module/utils/parsers/credential-sharing-v2.js +32 -6
  66. package/lib/module/utils/parsers/credential-sharing-v2.js.map +1 -1
  67. package/lib/module/utils/parsers/credential.js +10 -4
  68. package/lib/module/utils/parsers/credential.js.map +1 -1
  69. package/lib/module/utils/parsers/index.js +0 -1
  70. package/lib/module/utils/parsers/index.js.map +1 -1
  71. package/lib/module/utils/parsers/query.js +1 -1
  72. package/lib/module/utils/parsers/query.js.map +1 -1
  73. package/lib/typescript/components/proof-request/index.d.ts +0 -1
  74. package/lib/typescript/components/proof-request/v2/share-credential-v2-group.d.ts +8 -1
  75. package/lib/typescript/components/proof-request/v2/share-credential-v2.d.ts +1 -1
  76. package/lib/typescript/ui-components/buttons/scan-button.d.ts +9 -3
  77. package/lib/typescript/ui-components/credential/card/credential-details-card.d.ts +3 -0
  78. package/lib/typescript/ui-components/credential/credential-attribute-item.d.ts +3 -0
  79. package/lib/typescript/ui-components/icons/icons.d.ts +2 -0
  80. package/lib/typescript/ui-components/list/wallet/empty-list.d.ts +2 -2
  81. package/lib/typescript/ui-components/text/expandableTypography.d.ts +10 -0
  82. package/lib/typescript/ui-components/text/index.d.ts +2 -1
  83. package/lib/typescript/ui-components/text/typography.d.ts +14 -14
  84. package/lib/typescript/utils/hooks/app-state.d.ts +1 -1
  85. package/lib/typescript/utils/hooks/core/proofs.d.ts +2 -2
  86. package/lib/typescript/utils/hooks/core/wallet-unit.d.ts +5 -1
  87. package/lib/typescript/utils/parsers/credential-sharing-v2.d.ts +10 -2
  88. package/lib/typescript/utils/parsers/credential.d.ts +2 -1
  89. package/lib/typescript/utils/parsers/index.d.ts +0 -1
  90. package/package.json +5 -4
  91. package/src/components/history/history-list-item-icon.tsx +2 -0
  92. package/src/components/proof-request/index.ts +0 -1
  93. package/src/components/proof-request/v2/share-credential-v2-group.tsx +9 -2
  94. package/src/components/proof-request/v2/share-credential-v2.tsx +1 -1
  95. package/src/ui-components/buttons/scan-button.tsx +130 -38
  96. package/src/ui-components/credential/card/credential-details-card.tsx +46 -19
  97. package/src/ui-components/credential/credential-attribute-item.tsx +15 -3
  98. package/src/ui-components/icons/icons.tsx +24 -0
  99. package/src/ui-components/list/wallet/empty-list.tsx +11 -8
  100. package/src/ui-components/notice/wallet-notice.tsx +4 -2
  101. package/src/ui-components/text/expandableTypography.tsx +71 -0
  102. package/src/ui-components/text/index.ts +2 -1
  103. package/src/utils/hooks/core/credential-schemas.ts +23 -1
  104. package/src/utils/hooks/core/proofs.ts +3 -3
  105. package/src/utils/hooks/core/wallet-unit.ts +21 -0
  106. package/src/utils/parsers/credential-sharing-v2.tsx +71 -6
  107. package/src/utils/parsers/credential.ts +14 -3
  108. package/src/utils/parsers/index.ts +0 -1
  109. package/src/utils/parsers/query.ts +0 -1
  110. package/lib/commonjs/components/proof-request/v1/group.js +0 -35
  111. package/lib/commonjs/components/proof-request/v1/group.js.map +0 -1
  112. package/lib/commonjs/components/proof-request/v1/index.js +0 -39
  113. package/lib/commonjs/components/proof-request/v1/index.js.map +0 -1
  114. package/lib/commonjs/components/proof-request/v1/select-credential.js +0 -53
  115. package/lib/commonjs/components/proof-request/v1/select-credential.js.map +0 -1
  116. package/lib/commonjs/components/proof-request/v1/share-credential.js +0 -110
  117. package/lib/commonjs/components/proof-request/v1/share-credential.js.map +0 -1
  118. package/lib/commonjs/utils/parsers/credential-sharing.js +0 -263
  119. package/lib/commonjs/utils/parsers/credential-sharing.js.map +0 -1
  120. package/lib/module/components/proof-request/v1/group.js +0 -27
  121. package/lib/module/components/proof-request/v1/group.js.map +0 -1
  122. package/lib/module/components/proof-request/v1/index.js +0 -4
  123. package/lib/module/components/proof-request/v1/index.js.map +0 -1
  124. package/lib/module/components/proof-request/v1/select-credential.js +0 -44
  125. package/lib/module/components/proof-request/v1/select-credential.js.map +0 -1
  126. package/lib/module/components/proof-request/v1/share-credential.js +0 -101
  127. package/lib/module/components/proof-request/v1/share-credential.js.map +0 -1
  128. package/lib/module/utils/parsers/credential-sharing.js +0 -250
  129. package/lib/module/utils/parsers/credential-sharing.js.map +0 -1
  130. package/lib/typescript/components/proof-request/v1/group.d.ts +0 -2
  131. package/lib/typescript/components/proof-request/v1/index.d.ts +0 -3
  132. package/lib/typescript/components/proof-request/v1/select-credential.d.ts +0 -15
  133. package/lib/typescript/components/proof-request/v1/share-credential.d.ts +0 -27
  134. package/lib/typescript/utils/parsers/credential-sharing.d.ts +0 -20
  135. package/src/components/proof-request/v1/group.tsx +0 -26
  136. package/src/components/proof-request/v1/index.ts +0 -3
  137. package/src/components/proof-request/v1/select-credential.tsx +0 -55
  138. package/src/components/proof-request/v1/share-credential.tsx +0 -159
  139. package/src/utils/parsers/credential-sharing.tsx +0 -404
@@ -1,250 +0,0 @@
1
- import React from 'react';
2
- import { Selector, SelectorStatus } from '../../ui-components/credential';
3
- import { CredentialNoticeWarningIcon, CredentialWarningIcon, RequiredAttributeIcon } from '../../ui-components/icons';
4
- import { concatTestID } from '../testID';
5
- import { detailsCardAttributeFromClaim, getCredentialCardPropsFromCredential, getValidityState, nestAttributes, supportsSelectiveDisclosure, ValidityState } from './credential';
6
- export const validityCheckedCardFromCredential = (credential, expanded, selectiveDisclosureSupported, multipleCredentialsAvailable, config, notice, testID, labels, language) => {
7
- let credentialHeaderDetail;
8
- if (selectiveDisclosureSupported === false) {
9
- credentialHeaderDetail = {
10
- credentialDetailPrimary: labels.selectiveDisclosure,
11
- credentialDetailTestID: concatTestID(testID, 'header.nonSelectiveDisclosure'),
12
- statusIcon: CredentialWarningIcon
13
- };
14
- } else if (!expanded && multipleCredentialsAvailable) {
15
- credentialHeaderDetail = {
16
- credentialDetailPrimary: labels.multipleCredentials,
17
- credentialDetailTestID: concatTestID(testID, 'header.multiple'),
18
- statusIcon: CredentialWarningIcon
19
- };
20
- }
21
- const card = getCredentialCardPropsFromCredential(credential, credential.claims, config, notice, testID, labels, language);
22
- return {
23
- ...card,
24
- header: {
25
- ...card.header,
26
- ...credentialHeaderDetail
27
- }
28
- };
29
- };
30
- export const missingCredentialCardFromRequest = (request, notice, testID, labels) => {
31
- var _request$name;
32
- return {
33
- cardImage: undefined,
34
- color: undefined,
35
- testID,
36
- header: {
37
- credentialDetailErrorColor: true,
38
- credentialDetailPrimary: labels.missingCredential,
39
- credentialDetailTestID: concatTestID(testID, 'header.missing'),
40
- credentialName: (_request$name = request.name) !== null && _request$name !== void 0 ? _request$name : request.id,
41
- statusIcon: CredentialWarningIcon
42
- },
43
- ...notice
44
- };
45
- };
46
- const getAttributeSelectorStatus = (field, validityState, credential, claim, selected) => {
47
- if (!credential || validityState !== ValidityState.Valid) {
48
- return SelectorStatus.Rejected;
49
- }
50
- if (field.required) {
51
- if (claim) {
52
- return SelectorStatus.Required;
53
- } else {
54
- return SelectorStatus.Rejected;
55
- }
56
- }
57
- if (!claim) {
58
- return SelectorStatus.Disabled;
59
- }
60
- return selected ? SelectorStatus.SelectedCheckmark : SelectorStatus.Empty;
61
- };
62
- // Returns a spread list of all claims with their full JSON path as key, including all intermediate objects
63
- const spreadClaims = claims => {
64
- return claims.reduce((acc, claim) => {
65
- const result = [claim];
66
- if (claim.value.type_ === 'NESTED') {
67
- const nestedClaimsWithPath = claim.value.value.map(c => ({
68
- ...c,
69
- isArrayElement: claim.schema.array && claim.path.split('/').pop() !== claim.schema.key
70
- }));
71
- result.push(...spreadClaims(nestedClaimsWithPath));
72
- }
73
- return [...acc, ...result];
74
- }, []);
75
- };
76
- const getDisplayedAttributes = (request, validityState, credential, selectiveDisclosureSupported, selectedFields) => {
77
- const claims = credential ? spreadClaims(credential.claims) : undefined;
78
- const isApplicable = credential ? request.applicableCredentials.includes(credential.id) : false;
79
- let fields = request.fields;
80
- if (credential) {
81
- const fieldsWithNoKeyMapping = request.fields.filter(field => !(credential.id in field.keyMap)).filter(field => !isApplicable || !field.required);
82
- const fullyNestedFields = getFullyNestedFields(request.fields, credential.id);
83
- fields = [...fieldsWithNoKeyMapping, ...fullyNestedFields];
84
- }
85
- return fields.map(field => {
86
- const selected = !field.required && (selectedFields === null || selectedFields === void 0 ? void 0 : selectedFields.includes(field.id));
87
- const claim = credential ? claims === null || claims === void 0 ? void 0 : claims.find(({
88
- path
89
- }) => {
90
- return path === field.keyMap[credential.id];
91
- }) : undefined;
92
- const status = selectiveDisclosureSupported === false ? SelectorStatus.Required : getAttributeSelectorStatus(field, validityState, credential, claim, selected);
93
- return {
94
- claim,
95
- field,
96
- id: field.id,
97
- selected,
98
- status
99
- };
100
- });
101
- };
102
- const getFullyNestedFields = (fields, credentialId) => {
103
- const allKeys = fields.filter(field => credentialId in field.keyMap).map(field => field.keyMap[credentialId]);
104
- return fields.map(field => ({
105
- field,
106
- key: field.keyMap[credentialId]
107
- })).filter(({
108
- key
109
- }) => key && allKeys.every(k => !k.startsWith(`${key}/`))).map(({
110
- field
111
- }) => field);
112
- };
113
- export const shareCredentialCardAttributeFromClaim = (id, config, testID, labels, language, claim, field) => {
114
- var _field$name$split$pop, _field$name, _field$name2;
115
- if (claim) {
116
- return {
117
- ...detailsCardAttributeFromClaim(claim, config, testID, language),
118
- id,
119
- path: claim.path,
120
- listValue: claim.isArrayElement
121
- };
122
- }
123
- return {
124
- id,
125
- name: (_field$name$split$pop = field === null || field === void 0 || (_field$name = field.name) === null || _field$name === void 0 ? void 0 : _field$name.split('/').pop()) !== null && _field$name$split$pop !== void 0 ? _field$name$split$pop : id,
126
- path: (_field$name2 = field === null || field === void 0 ? void 0 : field.name) !== null && _field$name2 !== void 0 ? _field$name2 : id,
127
- value: labels.missingAttribute,
128
- valueErrorColor: true
129
- };
130
- };
131
-
132
- // Will propagate the attribute status (right accessory + selected?) for all nested attributes
133
- // Note: This function MUTATES the input attribute
134
- const setStatusForNestedObjectOrArrayFields = (attribute, status, disabled) => {
135
- const accessory = status && /*#__PURE__*/React.createElement(Selector, {
136
- status: status
137
- });
138
- const isObject = attribute.attributes && attribute.attributes.length > 0;
139
- const isArray = attribute.values && attribute.values.length > 0;
140
-
141
- // If the attribute is not an object or array, we update the attribute and return
142
- if (!isObject && !isArray) {
143
- attribute.rightAccessory = accessory;
144
- attribute.disabled = disabled;
145
- return attribute;
146
- }
147
-
148
- // The object can be optional (tappable radio-checkmark), or required (checkmark)
149
- if (status === SelectorStatus.SelectedCheckmark || status === SelectorStatus.Empty) {
150
- // If it's a selectable object, the accessory is rendered next to the object title,
151
- // The nested attributes have no accessory, and can not be selected
152
- attribute.rightAccessory = accessory;
153
- setStatusForNestedObjectOrArrayFields(attribute, undefined, true);
154
- } else {
155
- var _attribute$attributes;
156
- const nested = (_attribute$attributes = attribute.attributes) !== null && _attribute$attributes !== void 0 ? _attribute$attributes : attribute.values;
157
- // If the object is required / rejected, the accessory is rendered next to each nested attribute (except other object titles)
158
- // all fields are disabled
159
- for (const nestedAttribute of nested) {
160
- setStatusForNestedObjectOrArrayFields(nestedAttribute, status, true);
161
- }
162
- }
163
- };
164
- export const shareCredentialCardFromCredential = (credential, expanded, multipleCredentialsAvailable, request, selectedFields, config, testID, labels, language) => {
165
- var _credential$issuer, _credential$issuer2;
166
- const selectiveDisclosureSupported = supportsSelectiveDisclosure(credential ? {
167
- ...credential,
168
- issuer: (_credential$issuer = credential.issuer) === null || _credential$issuer === void 0 ? void 0 : _credential$issuer.id
169
- } : undefined, config);
170
- const cardTestId = concatTestID(testID, 'card');
171
- const card = credential ? validityCheckedCardFromCredential(credential, expanded, selectiveDisclosureSupported, multipleCredentialsAvailable, config, undefined, cardTestId, labels, language) : missingCredentialCardFromRequest(request, undefined, cardTestId, labels);
172
- const validityState = getValidityState(credential ? {
173
- ...credential,
174
- issuer: (_credential$issuer2 = credential.issuer) === null || _credential$issuer2 === void 0 ? void 0 : _credential$issuer2.id
175
- } : undefined);
176
- const displayedAttributes = getDisplayedAttributes(request, validityState, credential, selectiveDisclosureSupported, selectedFields);
177
- const attributes = displayedAttributes.map(({
178
- claim,
179
- field,
180
- id,
181
- selected,
182
- status
183
- }, index) => {
184
- const disabled = !credential || !field || field.required || !claim;
185
- const attribute = {
186
- ...shareCredentialCardAttributeFromClaim(id, config, concatTestID(testID, 'attribute', `${index}`), labels, language, claim, field),
187
- selected
188
- };
189
- setStatusForNestedObjectOrArrayFields(attribute, status, disabled);
190
- return attribute;
191
- });
192
- return {
193
- attributes: nestAttributes(attributes),
194
- card
195
- };
196
- };
197
- export const selectCredentialCardAttributeFromClaim = (id, config, testID, labels, language, claim, field) => {
198
- const attribute = shareCredentialCardAttributeFromClaim(id, config, testID, labels, language, claim, field);
199
- if (!claim) {
200
- return attribute;
201
- }
202
- return {
203
- ...attribute,
204
- rightAccessory: RequiredAttributeIcon
205
- };
206
- };
207
- export const selectCredentialCardFromCredential = (credential, selected, request, config, testID, labels, language) => {
208
- var _credential$issuer3;
209
- const selectiveDisclosureSupported = supportsSelectiveDisclosure(credential ? {
210
- ...credential,
211
- issuer: (_credential$issuer3 = credential.issuer) === null || _credential$issuer3 === void 0 ? void 0 : _credential$issuer3.id
212
- } : undefined, config);
213
- const rightAccessory = /*#__PURE__*/React.createElement(Selector, {
214
- status: selected ? SelectorStatus.SelectedRadio : SelectorStatus.Empty
215
- });
216
- const notice = selectiveDisclosureSupported === false ? {
217
- text: labels.selectiveDisclosure,
218
- noticeIcon: CredentialNoticeWarningIcon
219
- } : undefined;
220
- const {
221
- header,
222
- ...cardProps
223
- } = getCredentialCardPropsFromCredential(credential, credential.claims, config, notice, testID, labels, language);
224
- const card = {
225
- header: {
226
- ...header,
227
- accessory: rightAccessory
228
- },
229
- ...cardProps
230
- };
231
- const attributes = getFullyNestedFields(request.fields, credential.id).map(field => {
232
- const claim = spreadClaims(credential.claims).find(({
233
- path
234
- }) => {
235
- return path === field.keyMap[credential.id];
236
- });
237
- const attribute = selectCredentialCardAttributeFromClaim(field.id, config, testID, labels, language, claim, field);
238
- return {
239
- ...attribute,
240
- rightAccessory: /*#__PURE__*/React.createElement(Selector, {
241
- status: field.required && !claim ? SelectorStatus.Rejected : SelectorStatus.Required
242
- })
243
- };
244
- });
245
- return {
246
- attributes: nestAttributes(attributes),
247
- card
248
- };
249
- };
250
- //# sourceMappingURL=credential-sharing.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","Selector","SelectorStatus","CredentialNoticeWarningIcon","CredentialWarningIcon","RequiredAttributeIcon","concatTestID","detailsCardAttributeFromClaim","getCredentialCardPropsFromCredential","getValidityState","nestAttributes","supportsSelectiveDisclosure","ValidityState","validityCheckedCardFromCredential","credential","expanded","selectiveDisclosureSupported","multipleCredentialsAvailable","config","notice","testID","labels","language","credentialHeaderDetail","credentialDetailPrimary","selectiveDisclosure","credentialDetailTestID","statusIcon","multipleCredentials","card","claims","header","missingCredentialCardFromRequest","request","_request$name","cardImage","undefined","color","credentialDetailErrorColor","missingCredential","credentialName","name","id","getAttributeSelectorStatus","field","validityState","claim","selected","Valid","Rejected","required","Required","Disabled","SelectedCheckmark","Empty","spreadClaims","reduce","acc","result","value","type_","nestedClaimsWithPath","map","c","isArrayElement","schema","array","path","split","pop","key","push","getDisplayedAttributes","selectedFields","isApplicable","applicableCredentials","includes","fields","fieldsWithNoKeyMapping","filter","keyMap","fullyNestedFields","getFullyNestedFields","find","status","credentialId","allKeys","every","k","startsWith","shareCredentialCardAttributeFromClaim","_field$name$split$pop","_field$name","_field$name2","listValue","missingAttribute","valueErrorColor","setStatusForNestedObjectOrArrayFields","attribute","disabled","accessory","createElement","isObject","attributes","length","isArray","values","rightAccessory","_attribute$attributes","nested","nestedAttribute","shareCredentialCardFromCredential","_credential$issuer","_credential$issuer2","issuer","cardTestId","displayedAttributes","index","selectCredentialCardAttributeFromClaim","selectCredentialCardFromCredential","_credential$issuer3","SelectedRadio","text","noticeIcon","cardProps"],"sources":["credential-sharing.tsx"],"sourcesContent":["import {\n Claim,\n CoreConfig,\n CredentialDetail,\n PresentationDefinitionField,\n PresentationDefinitionRequestedCredential,\n} from '@procivis/react-native-one-core';\nimport React from 'react';\n\nimport {\n CredentialAttribute,\n CredentialCardProps,\n CredentialHeaderProps,\n Selector,\n SelectorStatus,\n} from '../../ui-components/credential';\nimport { CredentialCardNotice } from '../../ui-components/credential/card/credential-card';\nimport { CredentialNoticeWarningIcon, CredentialWarningIcon, RequiredAttributeIcon } from '../../ui-components/icons';\nimport { concatTestID } from '../testID';\nimport {\n CardLabels,\n CredentialDetailsCardPropsWithoutWidth,\n detailsCardAttributeFromClaim,\n getCredentialCardPropsFromCredential,\n getValidityState,\n nestAttributes,\n supportsSelectiveDisclosure,\n ValidityState,\n} from './credential';\n\nexport const validityCheckedCardFromCredential = (\n credential: CredentialDetail,\n expanded: boolean,\n selectiveDisclosureSupported: boolean | undefined,\n multipleCredentialsAvailable: boolean,\n config: CoreConfig,\n notice: CredentialCardNotice | undefined,\n testID: string,\n labels: ShareCredentialCardLabels,\n language: string | undefined,\n): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'testID' | 'width'> => {\n let credentialHeaderDetail:\n | Pick<\n CredentialHeaderProps,\n | 'credentialDetailPrimary'\n | 'credentialDetailSecondary'\n | 'credentialDetailErrorColor'\n | 'credentialDetailTestID'\n | 'statusIcon'\n >\n | undefined;\n if (selectiveDisclosureSupported === false) {\n credentialHeaderDetail = {\n credentialDetailPrimary: labels.selectiveDisclosure,\n credentialDetailTestID: concatTestID(testID, 'header.nonSelectiveDisclosure'),\n statusIcon: CredentialWarningIcon,\n };\n } else if (!expanded && multipleCredentialsAvailable) {\n credentialHeaderDetail = {\n credentialDetailPrimary: labels.multipleCredentials,\n credentialDetailTestID: concatTestID(testID, 'header.multiple'),\n statusIcon: CredentialWarningIcon,\n };\n }\n\n const card = getCredentialCardPropsFromCredential(\n credential,\n credential.claims,\n config,\n notice,\n testID,\n labels,\n language,\n );\n return {\n ...card,\n header: {\n ...card.header,\n ...credentialHeaderDetail,\n },\n };\n};\n\nexport const missingCredentialCardFromRequest = (\n request: PresentationDefinitionRequestedCredential,\n notice: CredentialCardNotice | undefined,\n testID: string,\n labels: ShareCredentialCardLabels,\n): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'width'> => {\n return {\n cardImage: undefined,\n color: undefined,\n testID,\n header: {\n credentialDetailErrorColor: true,\n credentialDetailPrimary: labels.missingCredential,\n credentialDetailTestID: concatTestID(testID, 'header.missing'),\n credentialName: request.name ?? request.id,\n statusIcon: CredentialWarningIcon,\n },\n ...notice,\n };\n};\n\ninterface DisplayedAttribute {\n claim?: FlatClaim;\n field?: PresentationDefinitionField;\n id: string;\n selected?: boolean;\n status: SelectorStatus;\n}\n\nconst getAttributeSelectorStatus = (\n field: PresentationDefinitionField,\n validityState: ValidityState,\n credential?: CredentialDetail,\n claim?: Claim,\n selected?: boolean,\n): SelectorStatus => {\n if (!credential || validityState !== ValidityState.Valid) {\n return SelectorStatus.Rejected;\n }\n if (field.required) {\n if (claim) {\n return SelectorStatus.Required;\n } else {\n return SelectorStatus.Rejected;\n }\n }\n if (!claim) {\n return SelectorStatus.Disabled;\n }\n return selected ? SelectorStatus.SelectedCheckmark : SelectorStatus.Empty;\n};\n\ntype FlatClaim = Claim & {\n isArrayElement?: boolean;\n};\n\n// Returns a spread list of all claims with their full JSON path as key, including all intermediate objects\nconst spreadClaims = (claims: Claim[]): FlatClaim[] => {\n return claims.reduce((acc, claim) => {\n const result = [claim];\n if (claim.value.type_ === 'NESTED') {\n const nestedClaimsWithPath: FlatClaim[] = claim.value.value.map((c) => ({\n ...c,\n isArrayElement: claim.schema.array && claim.path.split('/').pop() !== claim.schema.key,\n }));\n result.push(...spreadClaims(nestedClaimsWithPath));\n }\n return [...acc, ...result];\n }, [] as FlatClaim[]);\n};\n\nconst getDisplayedAttributes = (\n request: PresentationDefinitionRequestedCredential,\n validityState: ValidityState,\n credential?: CredentialDetail,\n selectiveDisclosureSupported?: boolean,\n selectedFields?: string[],\n): DisplayedAttribute[] => {\n const claims = credential ? spreadClaims(credential.claims) : undefined;\n const isApplicable = credential ? request.applicableCredentials.includes(credential.id) : false;\n\n let fields = request.fields;\n if (credential) {\n const fieldsWithNoKeyMapping = request.fields\n .filter((field) => !(credential.id in field.keyMap))\n .filter((field) => !isApplicable || !field.required);\n const fullyNestedFields = getFullyNestedFields(request.fields, credential.id);\n\n fields = [...fieldsWithNoKeyMapping, ...fullyNestedFields];\n }\n\n return fields.map((field) => {\n const selected = !field.required && selectedFields?.includes(field.id);\n const claim = credential\n ? claims?.find(({ path }) => {\n return path === field.keyMap[credential.id];\n })\n : undefined;\n const status =\n selectiveDisclosureSupported === false\n ? SelectorStatus.Required\n : getAttributeSelectorStatus(field, validityState, credential, claim, selected);\n return { claim, field, id: field.id, selected, status };\n });\n};\n\nconst getFullyNestedFields = (\n fields: PresentationDefinitionRequestedCredential['fields'],\n credentialId: CredentialDetail['id'],\n) => {\n const allKeys = fields.filter((field) => credentialId in field.keyMap).map((field) => field.keyMap[credentialId]);\n\n return fields\n .map((field) => ({ field, key: field.keyMap[credentialId] }))\n .filter(({ key }) => key && allKeys.every((k) => !k.startsWith(`${key}/`)))\n .map(({ field }) => field);\n};\n\nexport const shareCredentialCardAttributeFromClaim = (\n id: string,\n config: CoreConfig,\n testID: string,\n labels: ShareCredentialCardLabels,\n language: string | undefined,\n claim?: FlatClaim,\n field?: PresentationDefinitionField,\n): CredentialAttribute => {\n if (claim) {\n return {\n ...detailsCardAttributeFromClaim(claim, config, testID, language),\n id,\n path: claim.path,\n listValue: claim.isArrayElement,\n };\n }\n return {\n id,\n name: field?.name?.split('/').pop() ?? id,\n path: field?.name ?? id,\n value: labels.missingAttribute,\n valueErrorColor: true,\n };\n};\n\n// Will propagate the attribute status (right accessory + selected?) for all nested attributes\n// Note: This function MUTATES the input attribute\nconst setStatusForNestedObjectOrArrayFields = (\n attribute: CredentialAttribute,\n status?: SelectorStatus,\n disabled?: boolean,\n) => {\n const accessory = status && <Selector status={status} />;\n const isObject = attribute.attributes && attribute.attributes.length > 0;\n const isArray = attribute.values && attribute.values.length > 0;\n\n // If the attribute is not an object or array, we update the attribute and return\n if (!isObject && !isArray) {\n attribute.rightAccessory = accessory;\n attribute.disabled = disabled;\n return attribute;\n }\n\n // The object can be optional (tappable radio-checkmark), or required (checkmark)\n if (status === SelectorStatus.SelectedCheckmark || status === SelectorStatus.Empty) {\n // If it's a selectable object, the accessory is rendered next to the object title,\n // The nested attributes have no accessory, and can not be selected\n attribute.rightAccessory = accessory;\n setStatusForNestedObjectOrArrayFields(attribute, undefined, true);\n } else {\n const nested = attribute.attributes ?? attribute.values;\n // If the object is required / rejected, the accessory is rendered next to each nested attribute (except other object titles)\n // all fields are disabled\n for (const nestedAttribute of nested) {\n setStatusForNestedObjectOrArrayFields(nestedAttribute, status, true);\n }\n }\n};\n\nexport type ShareCredentialCardLabels = CardLabels & {\n selectiveDisclosure: string;\n missingAttribute: string;\n missingCredential: string;\n multipleCredentials: string;\n};\n\nexport const shareCredentialCardFromCredential = (\n credential: CredentialDetail | undefined,\n expanded: boolean,\n multipleCredentialsAvailable: boolean,\n request: PresentationDefinitionRequestedCredential,\n selectedFields: string[] | undefined,\n config: CoreConfig,\n testID: string,\n labels: ShareCredentialCardLabels,\n language: string | undefined,\n): CredentialDetailsCardPropsWithoutWidth => {\n const selectiveDisclosureSupported = supportsSelectiveDisclosure(\n credential ? { ...credential, issuer: credential.issuer?.id } : undefined,\n config,\n );\n const cardTestId = concatTestID(testID, 'card');\n const card = credential\n ? validityCheckedCardFromCredential(\n credential,\n expanded,\n selectiveDisclosureSupported,\n multipleCredentialsAvailable,\n config,\n undefined,\n cardTestId,\n labels,\n language,\n )\n : missingCredentialCardFromRequest(request, undefined, cardTestId, labels);\n const validityState = getValidityState(credential ? { ...credential, issuer: credential.issuer?.id } : undefined);\n const displayedAttributes = getDisplayedAttributes(\n request,\n validityState,\n credential,\n selectiveDisclosureSupported,\n selectedFields,\n );\n\n const attributes: CredentialAttribute[] = displayedAttributes.map(({ claim, field, id, selected, status }, index) => {\n const disabled = !credential || !field || field.required || !claim;\n const attribute: CredentialAttribute = {\n ...shareCredentialCardAttributeFromClaim(\n id,\n config,\n concatTestID(testID, 'attribute', `${index}`),\n labels,\n language,\n claim,\n field,\n ),\n selected,\n };\n\n setStatusForNestedObjectOrArrayFields(attribute, status, disabled);\n return attribute;\n });\n return {\n attributes: nestAttributes(attributes),\n card,\n };\n};\n\nexport const selectCredentialCardAttributeFromClaim = (\n id: string,\n config: CoreConfig,\n testID: string,\n labels: ShareCredentialCardLabels,\n language: string | undefined,\n claim?: FlatClaim,\n field?: PresentationDefinitionField,\n): CredentialAttribute => {\n const attribute = shareCredentialCardAttributeFromClaim(id, config, testID, labels, language, claim, field);\n if (!claim) {\n return attribute;\n }\n return {\n ...attribute,\n rightAccessory: RequiredAttributeIcon,\n };\n};\n\nexport const selectCredentialCardFromCredential = (\n credential: CredentialDetail,\n selected: boolean,\n request: PresentationDefinitionRequestedCredential,\n config: CoreConfig,\n testID: string,\n labels: ShareCredentialCardLabels,\n language: string | undefined,\n): CredentialDetailsCardPropsWithoutWidth => {\n const selectiveDisclosureSupported = supportsSelectiveDisclosure(\n credential ? { ...credential, issuer: credential.issuer?.id } : undefined,\n config,\n );\n const rightAccessory = <Selector status={selected ? SelectorStatus.SelectedRadio : SelectorStatus.Empty} />;\n const notice: CredentialCardNotice | undefined =\n selectiveDisclosureSupported === false\n ? {\n text: labels.selectiveDisclosure,\n noticeIcon: CredentialNoticeWarningIcon,\n }\n : undefined;\n const { header, ...cardProps } = getCredentialCardPropsFromCredential(\n credential,\n credential.claims,\n config,\n notice,\n testID,\n labels,\n language,\n );\n const card = {\n header: {\n ...header,\n accessory: rightAccessory,\n },\n ...cardProps,\n };\n const attributes: CredentialAttribute[] = getFullyNestedFields(request.fields, credential.id).map((field) => {\n const claim = spreadClaims(credential.claims).find(({ path }) => {\n return path === field.keyMap[credential.id];\n });\n\n const attribute = selectCredentialCardAttributeFromClaim(field.id, config, testID, labels, language, claim, field);\n return {\n ...attribute,\n rightAccessory: (\n <Selector status={field.required && !claim ? SelectorStatus.Rejected : SelectorStatus.Required} />\n ),\n };\n });\n return {\n attributes: nestAttributes(attributes),\n card,\n };\n};\n"],"mappings":"AAOA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAIEC,QAAQ,EACRC,cAAc,QACT,gCAAgC;AAEvC,SAASC,2BAA2B,EAAEC,qBAAqB,EAAEC,qBAAqB,QAAQ,2BAA2B;AACrH,SAASC,YAAY,QAAQ,WAAW;AACxC,SAGEC,6BAA6B,EAC7BC,oCAAoC,EACpCC,gBAAgB,EAChBC,cAAc,EACdC,2BAA2B,EAC3BC,aAAa,QACR,cAAc;AAErB,OAAO,MAAMC,iCAAiC,GAAGA,CAC/CC,UAA4B,EAC5BC,QAAiB,EACjBC,4BAAiD,EACjDC,4BAAqC,EACrCC,MAAkB,EAClBC,MAAwC,EACxCC,MAAc,EACdC,MAAiC,EACjCC,QAA4B,KACkD;EAC9E,IAAIC,sBASS;EACb,IAAIP,4BAA4B,KAAK,KAAK,EAAE;IAC1CO,sBAAsB,GAAG;MACvBC,uBAAuB,EAAEH,MAAM,CAACI,mBAAmB;MACnDC,sBAAsB,EAAEpB,YAAY,CAACc,MAAM,EAAE,+BAA+B,CAAC;MAC7EO,UAAU,EAAEvB;IACd,CAAC;EACH,CAAC,MAAM,IAAI,CAACW,QAAQ,IAAIE,4BAA4B,EAAE;IACpDM,sBAAsB,GAAG;MACvBC,uBAAuB,EAAEH,MAAM,CAACO,mBAAmB;MACnDF,sBAAsB,EAAEpB,YAAY,CAACc,MAAM,EAAE,iBAAiB,CAAC;MAC/DO,UAAU,EAAEvB;IACd,CAAC;EACH;EAEA,MAAMyB,IAAI,GAAGrB,oCAAoC,CAC/CM,UAAU,EACVA,UAAU,CAACgB,MAAM,EACjBZ,MAAM,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AG5C,cAAc,CAAC+C,QAAQ,GAAG/C,cAAc,CAACiD;MAAS,CAAE;IAErG,CAAC;EACH,CAAC,CAAC;EACF,OAAO;IACLoD,UAAU,EAAE7F,cAAc,CAAC6F,UAAU,CAAC;IACtC1E;EACF,CAAC;AACH,CAAC","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- import { FunctionComponent, PropsWithChildren } from 'react';
2
- export declare const ProofRequestGroup: FunctionComponent<PropsWithChildren>;
@@ -1,3 +0,0 @@
1
- export * from './group';
2
- export * from './select-credential';
3
- export * from './share-credential';
@@ -1,15 +0,0 @@
1
- import { PresentationDefinitionRequestedCredential } from '@procivis/react-native-one-core';
2
- import { FC } from 'react';
3
- import { ImageSourcePropType } from 'react-native';
4
- import { ShareCredentialCardLabels } from '../../../utils/parsers/credential-sharing';
5
- export declare const SelectCredential: FC<{
6
- credentialId: string;
7
- labels: ShareCredentialCardLabels;
8
- language?: string;
9
- lastItem: boolean;
10
- onImagePreview: (title: string, image: ImageSourcePropType) => void;
11
- onPress?: () => void;
12
- request: PresentationDefinitionRequestedCredential;
13
- selected: boolean;
14
- testID: string;
15
- }>;
@@ -1,27 +0,0 @@
1
- import { CredentialDetail, CredentialListItem, PresentationDefinitionField, PresentationDefinitionRequestedCredential } from '@procivis/react-native-one-core';
2
- import { FunctionComponent } from 'react';
3
- import { ImageSourcePropType, StyleProp, ViewStyle } from 'react-native';
4
- import { ShareCredentialCardLabels } from '../../../utils/parsers/credential-sharing';
5
- export type ShareCredentialLabels = ShareCredentialCardLabels & {
6
- invalidCredentialNotice: string;
7
- multipleCredentialsNotice: string;
8
- multipleCredentialsSelect: string;
9
- revokedCredentialNotice: string;
10
- suspendedCredentialNotice: string;
11
- };
12
- export declare const ShareCredential: FunctionComponent<{
13
- allCredentials: CredentialDetail[];
14
- expanded?: boolean;
15
- labels: ShareCredentialLabels;
16
- language?: string;
17
- lastItem?: boolean;
18
- onHeaderPress?: (_credentialId?: string) => void;
19
- onImagePreview: (title: string, image: ImageSourcePropType) => void;
20
- onSelectCredential?: () => void;
21
- onSelectField: (_id: PresentationDefinitionField['id'], _selected: boolean) => void;
22
- request: PresentationDefinitionRequestedCredential;
23
- selectedCredentialId?: CredentialListItem['id'];
24
- selectedFields?: Array<PresentationDefinitionField['id']>;
25
- style?: StyleProp<ViewStyle>;
26
- testID: string;
27
- }>;
@@ -1,20 +0,0 @@
1
- import { Claim, CoreConfig, CredentialDetail, PresentationDefinitionField, PresentationDefinitionRequestedCredential } from '@procivis/react-native-one-core';
2
- import { CredentialAttribute, CredentialCardProps } from '../../ui-components/credential';
3
- import { CredentialCardNotice } from '../../ui-components/credential/card/credential-card';
4
- import { CardLabels, CredentialDetailsCardPropsWithoutWidth } from './credential';
5
- export declare const validityCheckedCardFromCredential: (credential: CredentialDetail, expanded: boolean, selectiveDisclosureSupported: boolean | undefined, multipleCredentialsAvailable: boolean, config: CoreConfig, notice: CredentialCardNotice | undefined, testID: string, labels: ShareCredentialCardLabels, language: string | undefined) => Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'testID' | 'width'>;
6
- export declare const missingCredentialCardFromRequest: (request: PresentationDefinitionRequestedCredential, notice: CredentialCardNotice | undefined, testID: string, labels: ShareCredentialCardLabels) => Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'width'>;
7
- type FlatClaim = Claim & {
8
- isArrayElement?: boolean;
9
- };
10
- export declare const shareCredentialCardAttributeFromClaim: (id: string, config: CoreConfig, testID: string, labels: ShareCredentialCardLabels, language: string | undefined, claim?: FlatClaim, field?: PresentationDefinitionField) => CredentialAttribute;
11
- export type ShareCredentialCardLabels = CardLabels & {
12
- selectiveDisclosure: string;
13
- missingAttribute: string;
14
- missingCredential: string;
15
- multipleCredentials: string;
16
- };
17
- export declare const shareCredentialCardFromCredential: (credential: CredentialDetail | undefined, expanded: boolean, multipleCredentialsAvailable: boolean, request: PresentationDefinitionRequestedCredential, selectedFields: string[] | undefined, config: CoreConfig, testID: string, labels: ShareCredentialCardLabels, language: string | undefined) => CredentialDetailsCardPropsWithoutWidth;
18
- export declare const selectCredentialCardAttributeFromClaim: (id: string, config: CoreConfig, testID: string, labels: ShareCredentialCardLabels, language: string | undefined, claim?: FlatClaim, field?: PresentationDefinitionField) => CredentialAttribute;
19
- export declare const selectCredentialCardFromCredential: (credential: CredentialDetail, selected: boolean, request: PresentationDefinitionRequestedCredential, config: CoreConfig, testID: string, labels: ShareCredentialCardLabels, language: string | undefined) => CredentialDetailsCardPropsWithoutWidth;
20
- export {};
@@ -1,26 +0,0 @@
1
- import React, { FunctionComponent, PropsWithChildren } from 'react';
2
- import { StyleSheet, View } from 'react-native';
3
-
4
- import { useAppColorScheme } from '../../../ui-components/theme';
5
-
6
- export const ProofRequestGroup: FunctionComponent<PropsWithChildren> = ({ children }) => {
7
- const colorScheme = useAppColorScheme();
8
- return (
9
- <View style={styles.group}>
10
- <View style={[styles.separator, { backgroundColor: colorScheme.grayDark }]} />
11
- {children}
12
- </View>
13
- );
14
- };
15
-
16
- const styles = StyleSheet.create({
17
- group: {
18
- marginTop: 16,
19
- },
20
- separator: {
21
- height: 1,
22
- marginBottom: 16,
23
- marginHorizontal: 4,
24
- opacity: 0.5,
25
- },
26
- });
@@ -1,3 +0,0 @@
1
- export * from './group';
2
- export * from './select-credential';
3
- export * from './share-credential';
@@ -1,55 +0,0 @@
1
- import { PresentationDefinitionRequestedCredential } from '@procivis/react-native-one-core';
2
- import React, { FC, useMemo } from 'react';
3
- import { Dimensions, ImageSourcePropType } from 'react-native';
4
-
5
- import { CredentialDetailsCardListItem } from '../../../ui-components';
6
- import { useCoreConfig } from '../../../utils/hooks/core/core-config';
7
- import { useCredentialDetail } from '../../../utils/hooks/core/credentials';
8
- import {
9
- selectCredentialCardFromCredential,
10
- ShareCredentialCardLabels,
11
- } from '../../../utils/parsers/credential-sharing';
12
-
13
- export const SelectCredential: FC<{
14
- credentialId: string;
15
- labels: ShareCredentialCardLabels;
16
- language?: string;
17
- lastItem: boolean;
18
- onImagePreview: (title: string, image: ImageSourcePropType) => void;
19
- onPress?: () => void;
20
- request: PresentationDefinitionRequestedCredential;
21
- selected: boolean;
22
- testID: string;
23
- }> = ({ credentialId, labels, language, lastItem, onImagePreview, onPress, request, selected, testID }) => {
24
- const { data: credential } = useCredentialDetail(credentialId);
25
- const { data: config } = useCoreConfig();
26
- const cardWidth = useMemo(() => Dimensions.get('window').width - 32, []);
27
-
28
- if (!credential || !config) {
29
- return null;
30
- }
31
-
32
- const { card, attributes } = selectCredentialCardFromCredential(
33
- credential,
34
- selected,
35
- request,
36
- config,
37
- testID,
38
- labels,
39
- language,
40
- );
41
-
42
- return (
43
- <CredentialDetailsCardListItem
44
- attributes={attributes}
45
- card={{
46
- ...card,
47
- onHeaderPress: onPress,
48
- width: cardWidth,
49
- }}
50
- expanded={selected}
51
- lastItem={lastItem}
52
- onImagePreview={onImagePreview}
53
- />
54
- );
55
- };
@@ -1,159 +0,0 @@
1
- import {
2
- CredentialDetail,
3
- CredentialListItem,
4
- CredentialState,
5
- PresentationDefinitionField,
6
- PresentationDefinitionRequestedCredential,
7
- } from '@procivis/react-native-one-core';
8
- import React, { FunctionComponent, useMemo } from 'react';
9
- import { Dimensions, ImageSourcePropType, StyleProp, StyleSheet, ViewStyle } from 'react-native';
10
-
11
- import { CredentialDetailsCardListItem, useAppColorScheme } from '../../../ui-components';
12
- import { concatTestID } from '../../../utils';
13
- import { useCoreConfig } from '../../../utils/hooks/core/core-config';
14
- import { getValidityState, ValidityState } from '../../../utils/parsers/credential';
15
- import {
16
- shareCredentialCardFromCredential,
17
- ShareCredentialCardLabels,
18
- } from '../../../utils/parsers/credential-sharing';
19
- import { SelectShareCredentialCardNotice } from '../select-share-credential-card-notice';
20
- import { ShareCredentialCardNotice } from '../share-credential-card-notice';
21
-
22
- export type ShareCredentialLabels = ShareCredentialCardLabels & {
23
- invalidCredentialNotice: string;
24
- multipleCredentialsNotice: string;
25
- multipleCredentialsSelect: string;
26
- revokedCredentialNotice: string;
27
- suspendedCredentialNotice: string;
28
- };
29
-
30
- export const ShareCredential: FunctionComponent<{
31
- allCredentials: CredentialDetail[];
32
- expanded?: boolean;
33
- labels: ShareCredentialLabels;
34
- language?: string;
35
- lastItem?: boolean;
36
- onHeaderPress?: (_credentialId?: string) => void;
37
- onImagePreview: (title: string, image: ImageSourcePropType) => void;
38
- onSelectCredential?: () => void;
39
- onSelectField: (_id: PresentationDefinitionField['id'], _selected: boolean) => void;
40
- request: PresentationDefinitionRequestedCredential;
41
- selectedCredentialId?: CredentialListItem['id'];
42
- selectedFields?: Array<PresentationDefinitionField['id']>;
43
- style?: StyleProp<ViewStyle>;
44
- testID: string;
45
- }> = ({
46
- allCredentials,
47
- expanded,
48
- labels,
49
- language,
50
- lastItem,
51
- onHeaderPress,
52
- onImagePreview,
53
- onSelectCredential,
54
- onSelectField,
55
- request,
56
- selectedCredentialId,
57
- selectedFields,
58
- style,
59
- testID,
60
- }) => {
61
- const colorScheme = useAppColorScheme();
62
- const credential = allCredentials.find((c) => c.id === selectedCredentialId);
63
- const { data: config } = useCoreConfig();
64
- const cardWidth = useMemo(() => Dimensions.get('window').width - 32, []);
65
-
66
- const selectionOptions = useMemo(
67
- () =>
68
- request.applicableCredentials.filter((applicableCredentialId) =>
69
- allCredentials.some(({ id, state }) => id === applicableCredentialId && state === CredentialState.ACCEPTED),
70
- ),
71
- [allCredentials, request],
72
- );
73
- const multipleCredentialsAvailable = selectionOptions.length > 1;
74
-
75
- const validityState = getValidityState(
76
- credential
77
- ? {
78
- ...credential,
79
- issuer: credential?.issuer?.id,
80
- }
81
- : undefined,
82
- );
83
-
84
- const footer = useMemo(() => {
85
- if (!expanded) {
86
- return;
87
- }
88
- if (validityState === ValidityState.Revoked) {
89
- return (
90
- <ShareCredentialCardNotice
91
- testID={concatTestID(testID, 'notice.revoked')}
92
- text={labels.revokedCredentialNotice}
93
- />
94
- );
95
- }
96
- if (validityState === ValidityState.Suspended) {
97
- return (
98
- <ShareCredentialCardNotice
99
- testID={concatTestID(testID, 'notice.suspended')}
100
- text={labels.suspendedCredentialNotice}
101
- />
102
- );
103
- }
104
-
105
- if (multipleCredentialsAvailable) {
106
- return (
107
- <SelectShareCredentialCardNotice
108
- buttonTitle={labels.multipleCredentialsSelect}
109
- onPress={onSelectCredential}
110
- testID={concatTestID(testID, 'notice.multiple')}
111
- text={labels.multipleCredentialsNotice}
112
- />
113
- );
114
- }
115
- }, [expanded, labels, multipleCredentialsAvailable, onSelectCredential, testID, validityState]);
116
-
117
- if (!config) {
118
- return null;
119
- }
120
-
121
- const { card, attributes } = shareCredentialCardFromCredential(
122
- credential,
123
- Boolean(expanded),
124
- multipleCredentialsAvailable,
125
- request,
126
- selectedFields,
127
- config,
128
- testID,
129
- labels,
130
- language,
131
- );
132
-
133
- return (
134
- <CredentialDetailsCardListItem
135
- attributes={attributes}
136
- card={{
137
- ...card,
138
- credentialId: request.id,
139
- onHeaderPress,
140
- width: cardWidth,
141
- }}
142
- expanded={expanded}
143
- footer={footer}
144
- lastItem={lastItem}
145
- onAttributeSelected={onSelectField}
146
- onImagePreview={onImagePreview}
147
- style={[styles.credential, { borderColor: colorScheme.background }, style]}
148
- testID={testID}
149
- />
150
- );
151
- };
152
-
153
- const styles = StyleSheet.create({
154
- credential: {
155
- borderRadius: 10,
156
- borderWidth: 1,
157
- marginBottom: 8,
158
- },
159
- });