@procivis/one-react-native-components 0.3.115 → 0.3.130

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/credential/credential.js +2 -1
  2. package/lib/commonjs/components/credential/credential.js.map +1 -1
  3. package/lib/commonjs/components/history/history-list-item-icon.js +3 -3
  4. package/lib/commonjs/components/history/history-list-item-icon.js.map +1 -1
  5. package/lib/commonjs/components/history/history-list-item.js +2 -8
  6. package/lib/commonjs/components/history/history-list-item.js.map +1 -1
  7. package/lib/commonjs/components/history/history-list-screen.js +1 -1
  8. package/lib/commonjs/components/history/history-list-screen.js.map +1 -1
  9. package/lib/commonjs/components/index.js +11 -11
  10. package/lib/commonjs/components/index.js.map +1 -1
  11. package/lib/commonjs/components/proof-request/v1/select-credential.js +2 -1
  12. package/lib/commonjs/components/proof-request/v1/select-credential.js.map +1 -1
  13. package/lib/commonjs/components/proof-request/v1/share-credential.js +2 -1
  14. package/lib/commonjs/components/proof-request/v1/share-credential.js.map +1 -1
  15. package/lib/commonjs/components/proof-request/v2/select-credential-v2.js +2 -1
  16. package/lib/commonjs/components/proof-request/v2/select-credential-v2.js.map +1 -1
  17. package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js +3 -1
  18. package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js.map +1 -1
  19. package/lib/commonjs/components/proof-request/v2/share-credential-v2.js +4 -2
  20. package/lib/commonjs/components/proof-request/v2/share-credential-v2.js.map +1 -1
  21. package/lib/commonjs/components/trust-info/index.js +29 -0
  22. package/lib/commonjs/components/trust-info/index.js.map +1 -0
  23. package/lib/commonjs/components/trust-info/trust-info.js +79 -0
  24. package/lib/commonjs/components/trust-info/trust-info.js.map +1 -0
  25. package/lib/commonjs/ui-components/credential/card/credential-details-card.js +3 -1
  26. package/lib/commonjs/ui-components/credential/card/credential-details-card.js.map +1 -1
  27. package/lib/commonjs/ui-components/header/foldable-header.js.map +1 -1
  28. package/lib/commonjs/ui-components/header/header.js +2 -0
  29. package/lib/commonjs/ui-components/header/header.js.map +1 -1
  30. package/lib/commonjs/ui-components/history/history-details.js +2 -2
  31. package/lib/commonjs/ui-components/history/history-details.js.map +1 -1
  32. package/lib/commonjs/ui-components/icons/contact.js +45 -0
  33. package/lib/commonjs/ui-components/icons/contact.js.map +1 -0
  34. package/lib/commonjs/ui-components/icons/credential.js +3 -3
  35. package/lib/commonjs/ui-components/icons/credential.js.map +1 -1
  36. package/lib/commonjs/ui-components/icons/icons.js +20 -1
  37. package/lib/commonjs/ui-components/icons/icons.js.map +1 -1
  38. package/lib/commonjs/ui-components/icons/index.js +11 -0
  39. package/lib/commonjs/ui-components/icons/index.js.map +1 -1
  40. package/lib/commonjs/ui-components/loader/loading-result.js +2 -0
  41. package/lib/commonjs/ui-components/loader/loading-result.js.map +1 -1
  42. package/lib/commonjs/ui-components/screens/index.js +7 -0
  43. package/lib/commonjs/ui-components/screens/index.js.map +1 -1
  44. package/lib/commonjs/ui-components/screens/nerd-mode-screen.js +28 -24
  45. package/lib/commonjs/ui-components/screens/nerd-mode-screen.js.map +1 -1
  46. package/lib/commonjs/ui-components/screens/trust-info-details-screen.js +384 -0
  47. package/lib/commonjs/ui-components/screens/trust-info-details-screen.js.map +1 -0
  48. package/lib/commonjs/utils/date.js +4 -5
  49. package/lib/commonjs/utils/date.js.map +1 -1
  50. package/lib/commonjs/utils/hooks/core/cache.js +8 -4
  51. package/lib/commonjs/utils/hooks/core/cache.js.map +1 -1
  52. package/lib/commonjs/utils/hooks/core/core-config.js +1 -6
  53. package/lib/commonjs/utils/hooks/core/core-config.js.map +1 -1
  54. package/lib/commonjs/utils/hooks/core/core-context.js +0 -15
  55. package/lib/commonjs/utils/hooks/core/core-context.js.map +1 -1
  56. package/lib/commonjs/utils/hooks/core/credentials.js +40 -1
  57. package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
  58. package/lib/commonjs/utils/hooks/core/index.js +0 -11
  59. package/lib/commonjs/utils/hooks/core/index.js.map +1 -1
  60. package/lib/commonjs/utils/hooks/core/proofs.js +12 -1
  61. package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
  62. package/lib/commonjs/utils/hooks/core/trust-list.js +19 -3
  63. package/lib/commonjs/utils/hooks/core/trust-list.js.map +1 -1
  64. package/lib/commonjs/utils/hooks/core/verifier-instance.js +22 -3
  65. package/lib/commonjs/utils/hooks/core/verifier-instance.js.map +1 -1
  66. package/lib/commonjs/utils/hooks/core/wallet-unit.js +2 -2
  67. package/lib/commonjs/utils/hooks/core/wallet-unit.js.map +1 -1
  68. package/lib/commonjs/utils/parsers/credential-sharing-v2.js +14 -14
  69. package/lib/commonjs/utils/parsers/credential-sharing-v2.js.map +1 -1
  70. package/lib/commonjs/utils/parsers/credential-sharing.js +20 -18
  71. package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
  72. package/lib/commonjs/utils/parsers/credential.js +36 -22
  73. package/lib/commonjs/utils/parsers/credential.js.map +1 -1
  74. package/lib/commonjs/utils/parsers/query.js +1 -1
  75. package/lib/commonjs/utils/parsers/query.js.map +1 -1
  76. package/lib/commonjs/utils/translations.js +15 -0
  77. package/lib/commonjs/utils/translations.js.map +1 -0
  78. package/lib/module/components/credential/credential.js +2 -1
  79. package/lib/module/components/credential/credential.js.map +1 -1
  80. package/lib/module/components/history/history-list-item-icon.js +3 -3
  81. package/lib/module/components/history/history-list-item-icon.js.map +1 -1
  82. package/lib/module/components/history/history-list-item.js +3 -9
  83. package/lib/module/components/history/history-list-item.js.map +1 -1
  84. package/lib/module/components/history/history-list-screen.js +1 -1
  85. package/lib/module/components/history/history-list-screen.js.map +1 -1
  86. package/lib/module/components/index.js +1 -1
  87. package/lib/module/components/index.js.map +1 -1
  88. package/lib/module/components/proof-request/v1/select-credential.js +2 -1
  89. package/lib/module/components/proof-request/v1/select-credential.js.map +1 -1
  90. package/lib/module/components/proof-request/v1/share-credential.js +2 -1
  91. package/lib/module/components/proof-request/v1/share-credential.js.map +1 -1
  92. package/lib/module/components/proof-request/v2/select-credential-v2.js +2 -1
  93. package/lib/module/components/proof-request/v2/select-credential-v2.js.map +1 -1
  94. package/lib/module/components/proof-request/v2/share-credential-v2-group.js +3 -1
  95. package/lib/module/components/proof-request/v2/share-credential-v2-group.js.map +1 -1
  96. package/lib/module/components/proof-request/v2/share-credential-v2.js +4 -2
  97. package/lib/module/components/proof-request/v2/share-credential-v2.js.map +1 -1
  98. package/lib/module/components/trust-info/index.js +4 -0
  99. package/lib/module/components/trust-info/index.js.map +1 -0
  100. package/lib/module/components/trust-info/trust-info.js +70 -0
  101. package/lib/module/components/trust-info/trust-info.js.map +1 -0
  102. package/lib/module/ui-components/credential/card/credential-details-card.js +3 -1
  103. package/lib/module/ui-components/credential/card/credential-details-card.js.map +1 -1
  104. package/lib/module/ui-components/header/foldable-header.js.map +1 -1
  105. package/lib/module/ui-components/header/header.js +2 -0
  106. package/lib/module/ui-components/header/header.js.map +1 -1
  107. package/lib/module/ui-components/history/history-details.js +3 -3
  108. package/lib/module/ui-components/history/history-details.js.map +1 -1
  109. package/lib/module/ui-components/icons/contact.js +34 -0
  110. package/lib/module/ui-components/icons/contact.js.map +1 -0
  111. package/lib/module/ui-components/icons/credential.js +1 -1
  112. package/lib/module/ui-components/icons/credential.js.map +1 -1
  113. package/lib/module/ui-components/icons/icons.js +18 -0
  114. package/lib/module/ui-components/icons/icons.js.map +1 -1
  115. package/lib/module/ui-components/icons/index.js +1 -0
  116. package/lib/module/ui-components/icons/index.js.map +1 -1
  117. package/lib/module/ui-components/loader/loading-result.js +2 -0
  118. package/lib/module/ui-components/loader/loading-result.js.map +1 -1
  119. package/lib/module/ui-components/screens/index.js +2 -0
  120. package/lib/module/ui-components/screens/index.js.map +1 -1
  121. package/lib/module/ui-components/screens/nerd-mode-screen.js +29 -25
  122. package/lib/module/ui-components/screens/nerd-mode-screen.js.map +1 -1
  123. package/lib/module/ui-components/screens/trust-info-details-screen.js +375 -0
  124. package/lib/module/ui-components/screens/trust-info-details-screen.js.map +1 -0
  125. package/lib/module/utils/date.js +4 -5
  126. package/lib/module/utils/date.js.map +1 -1
  127. package/lib/module/utils/hooks/core/cache.js +8 -4
  128. package/lib/module/utils/hooks/core/cache.js.map +1 -1
  129. package/lib/module/utils/hooks/core/core-config.js +0 -4
  130. package/lib/module/utils/hooks/core/core-config.js.map +1 -1
  131. package/lib/module/utils/hooks/core/core-context.js +0 -15
  132. package/lib/module/utils/hooks/core/core-context.js.map +1 -1
  133. package/lib/module/utils/hooks/core/credentials.js +37 -1
  134. package/lib/module/utils/hooks/core/credentials.js.map +1 -1
  135. package/lib/module/utils/hooks/core/index.js +0 -1
  136. package/lib/module/utils/hooks/core/index.js.map +1 -1
  137. package/lib/module/utils/hooks/core/proofs.js +10 -0
  138. package/lib/module/utils/hooks/core/proofs.js.map +1 -1
  139. package/lib/module/utils/hooks/core/trust-list.js +20 -4
  140. package/lib/module/utils/hooks/core/trust-list.js.map +1 -1
  141. package/lib/module/utils/hooks/core/verifier-instance.js +20 -2
  142. package/lib/module/utils/hooks/core/verifier-instance.js.map +1 -1
  143. package/lib/module/utils/hooks/core/wallet-unit.js +2 -2
  144. package/lib/module/utils/hooks/core/wallet-unit.js.map +1 -1
  145. package/lib/module/utils/parsers/credential-sharing-v2.js +15 -15
  146. package/lib/module/utils/parsers/credential-sharing-v2.js.map +1 -1
  147. package/lib/module/utils/parsers/credential-sharing.js +20 -18
  148. package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
  149. package/lib/module/utils/parsers/credential.js +37 -23
  150. package/lib/module/utils/parsers/credential.js.map +1 -1
  151. package/lib/module/utils/parsers/query.js +1 -1
  152. package/lib/module/utils/parsers/query.js.map +1 -1
  153. package/lib/module/utils/translations.js +8 -0
  154. package/lib/module/utils/translations.js.map +1 -0
  155. package/lib/typescript/components/credential/credential.d.ts +1 -0
  156. package/lib/typescript/components/history/history-list-item.d.ts +1 -1
  157. package/lib/typescript/components/index.d.ts +1 -1
  158. package/lib/typescript/components/proof-request/v1/select-credential.d.ts +1 -0
  159. package/lib/typescript/components/proof-request/v1/share-credential.d.ts +1 -0
  160. package/lib/typescript/components/proof-request/v2/select-credential-v2.d.ts +1 -0
  161. package/lib/typescript/components/proof-request/v2/share-credential-v2-group.d.ts +1 -0
  162. package/lib/typescript/components/proof-request/v2/share-credential-v2.d.ts +1 -0
  163. package/lib/typescript/components/trust-info/index.d.ts +3 -0
  164. package/lib/typescript/components/trust-info/trust-info.d.ts +19 -0
  165. package/lib/typescript/ui-components/header/header.d.ts +2 -0
  166. package/lib/typescript/ui-components/history/history-details.d.ts +2 -2
  167. package/lib/typescript/ui-components/icons/contact.d.ts +4 -0
  168. package/lib/typescript/ui-components/icons/credential.d.ts +1 -1
  169. package/lib/typescript/ui-components/icons/icons.d.ts +1 -0
  170. package/lib/typescript/ui-components/icons/index.d.ts +1 -0
  171. package/lib/typescript/ui-components/screens/index.d.ts +3 -0
  172. package/lib/typescript/ui-components/screens/nerd-mode-screen.d.ts +5 -12
  173. package/lib/typescript/ui-components/screens/trust-info-details-screen.d.ts +32 -0
  174. package/lib/typescript/utils/hooks/core/core-config.d.ts +0 -1
  175. package/lib/typescript/utils/hooks/core/core-context.d.ts +0 -1
  176. package/lib/typescript/utils/hooks/core/credentials.d.ts +5 -1
  177. package/lib/typescript/utils/hooks/core/index.d.ts +0 -1
  178. package/lib/typescript/utils/hooks/core/proofs.d.ts +2 -0
  179. package/lib/typescript/utils/hooks/core/trust-list.d.ts +1 -4
  180. package/lib/typescript/utils/hooks/core/verifier-instance.d.ts +2 -0
  181. package/lib/typescript/utils/hooks/core/wallet-unit.d.ts +2 -2
  182. package/lib/typescript/utils/parsers/credential-sharing-v2.d.ts +3 -3
  183. package/lib/typescript/utils/parsers/credential-sharing.d.ts +6 -6
  184. package/lib/typescript/utils/parsers/credential.d.ts +5 -5
  185. package/lib/typescript/utils/parsers/query.d.ts +1 -1
  186. package/lib/typescript/utils/translations.d.ts +1 -0
  187. package/package.json +8 -8
  188. package/src/components/credential/credential.tsx +3 -0
  189. package/src/components/history/history-list-item-icon.tsx +2 -2
  190. package/src/components/history/history-list-item.tsx +4 -9
  191. package/src/components/history/history-list-screen.tsx +1 -1
  192. package/src/components/index.ts +1 -1
  193. package/src/components/proof-request/v1/select-credential.tsx +3 -1
  194. package/src/components/proof-request/v1/share-credential.tsx +3 -0
  195. package/src/components/proof-request/v2/select-credential-v2.tsx +3 -1
  196. package/src/components/proof-request/v2/share-credential-v2-group.tsx +4 -0
  197. package/src/components/proof-request/v2/share-credential-v2.tsx +5 -0
  198. package/src/components/trust-info/index.ts +4 -0
  199. package/src/components/trust-info/trust-info.tsx +90 -0
  200. package/src/ui-components/credential/card/credential-details-card.tsx +3 -2
  201. package/src/ui-components/header/foldable-header.tsx +10 -9
  202. package/src/ui-components/header/header.tsx +18 -3
  203. package/src/ui-components/history/history-details.tsx +4 -4
  204. package/src/ui-components/icons/contact.tsx +26 -0
  205. package/src/ui-components/icons/credential.tsx +1 -1
  206. package/src/ui-components/icons/icons.tsx +18 -0
  207. package/src/ui-components/icons/index.ts +1 -0
  208. package/src/ui-components/loader/loading-result.tsx +7 -1
  209. package/src/ui-components/screens/index.ts +3 -0
  210. package/src/ui-components/screens/nerd-mode-screen.tsx +49 -41
  211. package/src/ui-components/screens/trust-info-details-screen.tsx +472 -0
  212. package/src/utils/date.ts +7 -14
  213. package/src/utils/hooks/core/cache.ts +12 -4
  214. package/src/utils/hooks/core/core-config.ts +1 -6
  215. package/src/utils/hooks/core/core-context.tsx +0 -24
  216. package/src/utils/hooks/core/credentials.ts +43 -1
  217. package/src/utils/hooks/core/index.ts +0 -1
  218. package/src/utils/hooks/core/proofs.ts +14 -0
  219. package/src/utils/hooks/core/trust-list.ts +22 -11
  220. package/src/utils/hooks/core/verifier-instance.ts +23 -2
  221. package/src/utils/hooks/core/wallet-unit.ts +3 -3
  222. package/src/utils/parsers/credential-sharing-v2.tsx +29 -12
  223. package/src/utils/parsers/credential-sharing.tsx +33 -16
  224. package/src/utils/parsers/credential.ts +45 -14
  225. package/src/utils/parsers/query.ts +3 -0
  226. package/src/utils/translations.ts +10 -0
  227. package/lib/commonjs/components/entity/EntityButtons.js +0 -64
  228. package/lib/commonjs/components/entity/EntityButtons.js.map +0 -1
  229. package/lib/commonjs/components/entity/entity-attributes.js +0 -65
  230. package/lib/commonjs/components/entity/entity-attributes.js.map +0 -1
  231. package/lib/commonjs/components/entity/entity-details-with-buttons.js +0 -67
  232. package/lib/commonjs/components/entity/entity-details-with-buttons.js.map +0 -1
  233. package/lib/commonjs/components/entity/entity-details.js +0 -101
  234. package/lib/commonjs/components/entity/entity-details.js.map +0 -1
  235. package/lib/commonjs/components/entity/index.js +0 -14
  236. package/lib/commonjs/components/entity/index.js.map +0 -1
  237. package/lib/commonjs/utils/hooks/core/trust-entity.js +0 -147
  238. package/lib/commonjs/utils/hooks/core/trust-entity.js.map +0 -1
  239. package/lib/module/components/entity/EntityButtons.js +0 -56
  240. package/lib/module/components/entity/EntityButtons.js.map +0 -1
  241. package/lib/module/components/entity/entity-attributes.js +0 -57
  242. package/lib/module/components/entity/entity-attributes.js.map +0 -1
  243. package/lib/module/components/entity/entity-details-with-buttons.js +0 -58
  244. package/lib/module/components/entity/entity-details-with-buttons.js.map +0 -1
  245. package/lib/module/components/entity/entity-details.js +0 -92
  246. package/lib/module/components/entity/entity-details.js.map +0 -1
  247. package/lib/module/components/entity/index.js +0 -3
  248. package/lib/module/components/entity/index.js.map +0 -1
  249. package/lib/module/utils/hooks/core/trust-entity.js +0 -136
  250. package/lib/module/utils/hooks/core/trust-entity.js.map +0 -1
  251. package/lib/typescript/components/entity/EntityButtons.d.ts +0 -14
  252. package/lib/typescript/components/entity/entity-attributes.d.ts +0 -15
  253. package/lib/typescript/components/entity/entity-details-with-buttons.d.ts +0 -18
  254. package/lib/typescript/components/entity/entity-details.d.ts +0 -21
  255. package/lib/typescript/components/entity/index.d.ts +0 -3
  256. package/lib/typescript/utils/hooks/core/trust-entity.d.ts +0 -17
  257. package/src/components/entity/EntityButtons.tsx +0 -79
  258. package/src/components/entity/entity-attributes.tsx +0 -80
  259. package/src/components/entity/entity-details-with-buttons.tsx +0 -75
  260. package/src/components/entity/entity-details.tsx +0 -145
  261. package/src/components/entity/index.ts +0 -4
  262. package/src/utils/hooks/core/trust-entity.ts +0 -172
@@ -1,136 +0,0 @@
1
- import { IdentifierType, OneError } from '@procivis/react-native-one-core';
2
- import { useCallback } from 'react';
3
- import { useMutation, useQuery, useQueryClient } from 'react-query';
4
- import { reportException } from '../../reporting';
5
- import { useHTTPClient } from '../http/client';
6
- import { useONECore } from './core-context';
7
- import { OneErrorCode } from './error-code';
8
- import { HISTORY_LIST_QUERY_KEY } from './history';
9
- import { useIdentifierDetails } from './identifiers';
10
- export const TRUST_ENTITY_DETAIL_QUERY_KEY = 'trust-entity-detail';
11
- export const REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY = 'remote-trust-entity-detail';
12
- export const useCreateTrustAnchor = () => {
13
- const httpClient = useHTTPClient();
14
- return useCallback(async (core, publisherReference) => {
15
- const trustAnchors = await core.listTrustAnchors({
16
- page: 0,
17
- pageSize: 1
18
- });
19
- if (trustAnchors.values.length > 0) {
20
- return;
21
- }
22
- const response = await httpClient.get(publisherReference);
23
- if (!response.ok || !response.data) {
24
- return;
25
- }
26
- const trustAnchor = response.data;
27
- await core.createTrustAnchor({
28
- isPublisher: false,
29
- name: trustAnchor.name,
30
- publisherReference,
31
- type: TrustManagementEnum.SimpleTrustList
32
- }).catch(err => {
33
- reportException(err, 'Failed to create trust anchor');
34
- throw err;
35
- });
36
- }, [httpClient]);
37
- };
38
- export const useTrustEntity = identifierId => {
39
- const {
40
- core
41
- } = useONECore();
42
- const {
43
- data: identifierDetail
44
- } = useIdentifierDetails(identifierId);
45
- return useQuery([TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId], () => {
46
- var _identifierDetail$cer;
47
- return identifierId && identifierDetail ? core.resolveTrustEntityByIdentifier({
48
- identifiers: [{
49
- certificateId: (identifierDetail === null || identifierDetail === void 0 ? void 0 : identifierDetail.type) === IdentifierType.CERTIFICATE ? (_identifierDetail$cer = identifierDetail.certificates) === null || _identifierDetail$cer === void 0 || (_identifierDetail$cer = _identifierDetail$cer[0]) === null || _identifierDetail$cer === void 0 ? void 0 : _identifierDetail$cer.id : undefined,
50
- id: identifierId
51
- }]
52
- }).then(result => {
53
- var _result$identifierId$, _result$identifierId;
54
- return (_result$identifierId$ = (_result$identifierId = result[identifierId]) === null || _result$identifierId === void 0 || (_result$identifierId = _result$identifierId[0]) === null || _result$identifierId === void 0 ? void 0 : _result$identifierId.trustEntity) !== null && _result$identifierId$ !== void 0 ? _result$identifierId$ : null;
55
- }).catch(e => {
56
- if (e instanceof OneError && e.code === OneErrorCode.NoTrustEntityFound) {
57
- return null;
58
- }
59
- throw e;
60
- }) : undefined;
61
- }, {
62
- enabled: Boolean(identifierDetail),
63
- keepPreviousData: true
64
- });
65
- };
66
- export const useRemoteTrustEntity = identifierId => {
67
- const {
68
- core
69
- } = useONECore();
70
- const {
71
- data: identifierDetail
72
- } = useIdentifierDetails(identifierId);
73
- return useQuery([REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId], () => identifierDetail !== null && identifierDetail !== void 0 && identifierDetail.did ? core.getRemoteTrustEntity(identifierDetail.did.id) : undefined, {
74
- enabled: Boolean(identifierDetail === null || identifierDetail === void 0 ? void 0 : identifierDetail.did),
75
- keepPreviousData: true
76
- });
77
- };
78
- export const useCreateRemoteTrustEntity = () => {
79
- const queryClient = useQueryClient();
80
- const {
81
- core
82
- } = useONECore();
83
- return useMutation(async request => {
84
- const {
85
- identifierId,
86
- didId
87
- } = request;
88
- let entityDidId = didId;
89
- if (identifierId) {
90
- var _identifierDetail$did;
91
- const identifierDetail = await core.getIdentifier(identifierId);
92
- entityDidId = identifierDetail === null || identifierDetail === void 0 || (_identifierDetail$did = identifierDetail.did) === null || _identifierDetail$did === void 0 ? void 0 : _identifierDetail$did.id;
93
- }
94
- return core.createRemoteTrustEntity({
95
- ...request,
96
- didId: entityDidId
97
- });
98
- }, {
99
- onSuccess: async () => {
100
- await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);
101
- await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
102
- }
103
- });
104
- };
105
- export const useUpdateRemoteTrustEntity = () => {
106
- const queryClient = useQueryClient();
107
- const {
108
- core
109
- } = useONECore();
110
- return useMutation(async request => {
111
- const {
112
- identifierId,
113
- didId
114
- } = request;
115
- let entityDidId = didId;
116
- if (identifierId) {
117
- var _identifierDetail$did2;
118
- const identifierDetail = await core.getIdentifier(identifierId);
119
- entityDidId = identifierDetail === null || identifierDetail === void 0 || (_identifierDetail$did2 = identifierDetail.did) === null || _identifierDetail$did2 === void 0 ? void 0 : _identifierDetail$did2.id;
120
- }
121
- return core.updateRemoteTrustEntity({
122
- ...request,
123
- didId: entityDidId
124
- });
125
- }, {
126
- onSuccess: async () => {
127
- await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);
128
- await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
129
- }
130
- });
131
- };
132
- export let TrustManagementEnum = /*#__PURE__*/function (TrustManagementEnum) {
133
- TrustManagementEnum["SimpleTrustList"] = "SIMPLE_TRUST_LIST";
134
- return TrustManagementEnum;
135
- }({});
136
- //# sourceMappingURL=trust-entity.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["IdentifierType","OneError","useCallback","useMutation","useQuery","useQueryClient","reportException","useHTTPClient","useONECore","OneErrorCode","HISTORY_LIST_QUERY_KEY","useIdentifierDetails","TRUST_ENTITY_DETAIL_QUERY_KEY","REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY","useCreateTrustAnchor","httpClient","core","publisherReference","trustAnchors","listTrustAnchors","page","pageSize","values","length","response","get","ok","data","trustAnchor","createTrustAnchor","isPublisher","name","type","TrustManagementEnum","SimpleTrustList","catch","err","useTrustEntity","identifierId","identifierDetail","_identifierDetail$cer","resolveTrustEntityByIdentifier","identifiers","certificateId","CERTIFICATE","certificates","id","undefined","then","result","_result$identifierId$","_result$identifierId","trustEntity","e","code","NoTrustEntityFound","enabled","Boolean","keepPreviousData","useRemoteTrustEntity","did","getRemoteTrustEntity","useCreateRemoteTrustEntity","queryClient","request","didId","entityDidId","_identifierDetail$did","getIdentifier","createRemoteTrustEntity","onSuccess","invalidateQueries","useUpdateRemoteTrustEntity","_identifierDetail$did2","updateRemoteTrustEntity"],"sources":["trust-entity.ts"],"sourcesContent":["import {\n CreateRemoteTrustEntityRequest,\n IdentifierType,\n ONECore,\n OneError,\n TrustAnchorDetail,\n UpdateRemoteTrustEntityRequest,\n} from '@procivis/react-native-one-core';\nimport { useCallback } from 'react';\nimport { useMutation, useQuery, useQueryClient } from 'react-query';\n\nimport { reportException } from '../../reporting';\nimport { useHTTPClient } from '../http/client';\nimport { useONECore } from './core-context';\nimport { OneErrorCode } from './error-code';\nimport { HISTORY_LIST_QUERY_KEY } from './history';\nimport { useIdentifierDetails } from './identifiers';\n\nexport const TRUST_ENTITY_DETAIL_QUERY_KEY = 'trust-entity-detail';\nexport const REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY = 'remote-trust-entity-detail';\n\nexport const useCreateTrustAnchor = () => {\n const httpClient = useHTTPClient();\n\n return useCallback(\n async (core: ONECore, publisherReference: string) => {\n const trustAnchors = await core.listTrustAnchors({\n page: 0,\n pageSize: 1,\n });\n if (trustAnchors.values.length > 0) {\n return;\n }\n const response = await httpClient.get<TrustAnchorDetail>(publisherReference);\n if (!response.ok || !response.data) {\n return;\n }\n const trustAnchor = response.data;\n await core\n .createTrustAnchor({\n isPublisher: false,\n name: trustAnchor.name,\n publisherReference,\n type: TrustManagementEnum.SimpleTrustList,\n })\n .catch((err) => {\n reportException(err, 'Failed to create trust anchor');\n throw err;\n });\n },\n [httpClient],\n );\n};\n\nexport const useTrustEntity = (identifierId: string | undefined) => {\n const { core } = useONECore();\n\n const { data: identifierDetail } = useIdentifierDetails(identifierId);\n\n return useQuery(\n [TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],\n () =>\n identifierId && identifierDetail\n ? core\n .resolveTrustEntityByIdentifier({\n identifiers: [\n {\n certificateId:\n identifierDetail?.type === IdentifierType.CERTIFICATE\n ? identifierDetail.certificates?.[0]?.id\n : undefined,\n id: identifierId,\n },\n ],\n })\n .then((result) => {\n return result[identifierId]?.[0]?.trustEntity ?? null;\n })\n .catch((e) => {\n if (e instanceof OneError && e.code === OneErrorCode.NoTrustEntityFound) {\n return null;\n }\n throw e;\n })\n : undefined,\n {\n enabled: Boolean(identifierDetail),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useRemoteTrustEntity = (identifierId: string | undefined) => {\n const { core } = useONECore();\n\n const { data: identifierDetail } = useIdentifierDetails(identifierId);\n\n return useQuery(\n [REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],\n () => (identifierDetail?.did ? core.getRemoteTrustEntity(identifierDetail.did.id) : undefined),\n {\n enabled: Boolean(identifierDetail?.did),\n keepPreviousData: true,\n },\n );\n};\n\nexport const useCreateRemoteTrustEntity = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(\n async (request: Omit<CreateRemoteTrustEntityRequest, 'didId'> & { identifierId?: string; didId?: string }) => {\n const { identifierId, didId } = request;\n\n let entityDidId = didId;\n\n if (identifierId) {\n const identifierDetail = await core.getIdentifier(identifierId);\n entityDidId = identifierDetail?.did?.id;\n }\n\n return core.createRemoteTrustEntity({\n ...request,\n didId: entityDidId!,\n });\n },\n {\n onSuccess: async () => {\n await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n },\n );\n};\n\nexport const useUpdateRemoteTrustEntity = () => {\n const queryClient = useQueryClient();\n const { core } = useONECore();\n\n return useMutation(\n async (\n request: Omit<UpdateRemoteTrustEntityRequest, 'didId'> & {\n identifierId?: string;\n didId?: string;\n },\n ) => {\n const { identifierId, didId } = request;\n\n let entityDidId = didId;\n if (identifierId) {\n const identifierDetail = await core.getIdentifier(identifierId);\n entityDidId = identifierDetail?.did?.id;\n }\n\n return core.updateRemoteTrustEntity({\n ...request,\n didId: entityDidId!,\n });\n },\n {\n onSuccess: async () => {\n await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);\n await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);\n },\n },\n );\n};\n\nexport enum TrustManagementEnum {\n SimpleTrustList = 'SIMPLE_TRUST_LIST',\n}\n"],"mappings":"AAAA,SAEEA,cAAc,EAEdC,QAAQ,QAGH,iCAAiC;AACxC,SAASC,WAAW,QAAQ,OAAO;AACnC,SAASC,WAAW,EAAEC,QAAQ,EAAEC,cAAc,QAAQ,aAAa;AAEnE,SAASC,eAAe,QAAQ,iBAAiB;AACjD,SAASC,aAAa,QAAQ,gBAAgB;AAC9C,SAASC,UAAU,QAAQ,gBAAgB;AAC3C,SAASC,YAAY,QAAQ,cAAc;AAC3C,SAASC,sBAAsB,QAAQ,WAAW;AAClD,SAASC,oBAAoB,QAAQ,eAAe;AAEpD,OAAO,MAAMC,6BAA6B,GAAG,qBAAqB;AAClE,OAAO,MAAMC,oCAAoC,GAAG,4BAA4B;AAEhF,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAM;EACxC,MAAMC,UAAU,GAAGR,aAAa,CAAC,CAAC;EAElC,OAAOL,WAAW,CAChB,OAAOc,IAAa,EAAEC,kBAA0B,KAAK;IACnD,MAAMC,YAAY,GAAG,MAAMF,IAAI,CAACG,gBAAgB,CAAC;MAC/CC,IAAI,EAAE,CAAC;MACPC,QAAQ,EAAE;IACZ,CAAC,CAAC;IACF,IAAIH,YAAY,CAACI,MAAM,CAACC,MAAM,GAAG,CAAC,EAAE;MAClC;IACF;IACA,MAAMC,QAAQ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WAAW,GAAG3B,gBAAgB,aAAhBA,gBAAgB,gBAAAkC,sBAAA,GAAhBlC,gBAAgB,CAAEqB,GAAG,cAAAa,sBAAA,uBAArBA,sBAAA,CAAuB3B,EAAE;IACzC;IAEA,OAAO9B,IAAI,CAAC0D,uBAAuB,CAAC;MAClC,GAAGV,OAAO;MACVC,KAAK,EAAEC;IACT,CAAC,CAAC;EACJ,CAAC,EACD;IACEI,SAAS,EAAE,MAAAA,CAAA,KAAY;MACrB,MAAMP,WAAW,CAACQ,iBAAiB,CAAC1D,oCAAoC,CAAC;MACzE,MAAMkD,WAAW,CAACQ,iBAAiB,CAAC7D,sBAAsB,CAAC;IAC7D;EACF,CACF,CAAC;AACH,CAAC;AAED,WAAYuB,mBAAmB,0BAAnBA,mBAAmB;EAAnBA,mBAAmB;EAAA,OAAnBA,mBAAmB;AAAA","ignoreList":[]}
@@ -1,14 +0,0 @@
1
- import { TrustEntityDetail } from '@procivis/react-native-one-core';
2
- import React from 'react';
3
- import { EntityLabels } from '../../ui-components/screens/nerd-mode-screen';
4
- export interface EntityButton {
5
- url: string;
6
- label: string;
7
- }
8
- interface EntityButtonsProps {
9
- entity?: TrustEntityDetail;
10
- labels: EntityLabels;
11
- testID?: string;
12
- }
13
- declare const _default: React.NamedExoticComponent<EntityButtonsProps>;
14
- export default _default;
@@ -1,15 +0,0 @@
1
- import { TrustEntityDetail, TrustEntityListItem } from '@procivis/react-native-one-core';
2
- import React from 'react';
3
- import { AttributesLabels, EntityType } from '../../ui-components/screens/nerd-mode-screen';
4
- interface EntityAttributesProps {
5
- certificate?: string;
6
- did?: string;
7
- trustEntity?: TrustEntityDetail | TrustEntityListItem;
8
- trusted: boolean;
9
- labels: AttributesLabels;
10
- onCopyToClipboard: (value: string) => void;
11
- entityType: EntityType;
12
- testID?: string;
13
- }
14
- declare const _default: React.NamedExoticComponent<EntityAttributesProps>;
15
- export default _default;
@@ -1,18 +0,0 @@
1
- import { IdentifierListItem, TrustEntityRole } from '@procivis/react-native-one-core';
2
- import React from 'react';
3
- import { StyleProp, ViewStyle } from 'react-native';
4
- import { AttributesLabels, EntityLabels, EntityType } from '../../ui-components/screens/nerd-mode-screen';
5
- export type ContextRole = Exclude<TrustEntityRole, TrustEntityRole.BOTH>;
6
- interface EntityDetailsWithButtonsProps {
7
- identifier?: IdentifierListItem;
8
- entityLabels: EntityLabels;
9
- attributesLabels: AttributesLabels;
10
- style?: StyleProp<ViewStyle>;
11
- textColor?: string;
12
- testID?: string;
13
- role: ContextRole;
14
- onCopyToClipboard: (value: string) => void;
15
- entityType: EntityType;
16
- }
17
- declare const _default: React.NamedExoticComponent<EntityDetailsWithButtonsProps>;
18
- export default _default;
@@ -1,21 +0,0 @@
1
- import { IdentifierListItem, TrustEntityDetail, TrustEntityRole } from '@procivis/react-native-one-core';
2
- import { FC, ReactNode } from 'react';
3
- import { StyleProp, ViewStyle } from 'react-native';
4
- export type EntityDetailsLabels = {
5
- unknown: string;
6
- };
7
- export type EntityDetailsProps = {
8
- labels: EntityDetailsLabels;
9
- renderMore?: (trustEntity: TrustEntityDetail) => ReactNode;
10
- role: Exclude<TrustEntityRole, TrustEntityRole.BOTH>;
11
- style?: StyleProp<ViewStyle>;
12
- sublineColor?: string;
13
- textColor?: string;
14
- testID?: string;
15
- } & ({
16
- identifier?: IdentifierListItem;
17
- } | {
18
- entity: TrustEntityDetail;
19
- });
20
- declare const EntityDetails: FC<EntityDetailsProps>;
21
- export default EntityDetails;
@@ -1,3 +0,0 @@
1
- import type { EntityDetailsLabels, EntityDetailsProps } from './entity-details';
2
- import EntityDetails from './entity-details';
3
- export { EntityDetails, EntityDetailsLabels, EntityDetailsProps };
@@ -1,17 +0,0 @@
1
- import { CreateRemoteTrustEntityRequest, ONECore, UpdateRemoteTrustEntityRequest } from '@procivis/react-native-one-core';
2
- export declare const TRUST_ENTITY_DETAIL_QUERY_KEY = "trust-entity-detail";
3
- export declare const REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY = "remote-trust-entity-detail";
4
- export declare const useCreateTrustAnchor: () => (core: ONECore, publisherReference: string) => Promise<void>;
5
- export declare const useTrustEntity: (identifierId: string | undefined) => import("react-query").UseQueryResult<import("@procivis/react-native-one-core").TrustEntityDetail | null | undefined, unknown>;
6
- export declare const useRemoteTrustEntity: (identifierId: string | undefined) => import("react-query").UseQueryResult<import("@procivis/react-native-one-core").RemoteTrustEntityDetail | undefined, unknown>;
7
- export declare const useCreateRemoteTrustEntity: () => import("react-query").UseMutationResult<string, unknown, Omit<CreateRemoteTrustEntityRequest, "didId"> & {
8
- identifierId?: string | undefined;
9
- didId?: string | undefined;
10
- }, unknown>;
11
- export declare const useUpdateRemoteTrustEntity: () => import("react-query").UseMutationResult<void, unknown, Omit<UpdateRemoteTrustEntityRequest, "didId"> & {
12
- identifierId?: string | undefined;
13
- didId?: string | undefined;
14
- }, unknown>;
15
- export declare enum TrustManagementEnum {
16
- SimpleTrustList = "SIMPLE_TRUST_LIST"
17
- }
@@ -1,79 +0,0 @@
1
- import { TrustEntityDetail } from '@procivis/react-native-one-core';
2
- import React, { FC, memo, useCallback, useMemo } from 'react';
3
- import { Linking, StyleSheet, View } from 'react-native';
4
-
5
- import { Button, ButtonType } from '../../ui-components/buttons';
6
- import { EntityLabels } from '../../ui-components/screens/nerd-mode-screen';
7
- import { concatTestID, reportException } from '../../utils';
8
-
9
- export interface EntityButton {
10
- url: string;
11
- label: string;
12
- }
13
-
14
- interface EntityButtonsProps {
15
- entity?: TrustEntityDetail;
16
- labels: EntityLabels;
17
- testID?: string;
18
- }
19
-
20
- const EntityButtons: FC<EntityButtonsProps> = ({ entity, labels, testID }) => {
21
- const buttons = useMemo(
22
- () =>
23
- [
24
- {
25
- label: labels.visitWebsite,
26
- url: entity?.website || '',
27
- testID: 'website',
28
- },
29
- {
30
- label: labels.termsAndServices,
31
- url: entity?.termsUrl || '',
32
- testID: 'termsOfService',
33
- },
34
- {
35
- label: labels.privacyPolicy,
36
- url: entity?.privacyUrl || '',
37
- testID: 'privacyPolicy',
38
- },
39
- ].filter((btn) => Boolean(btn.url)),
40
- [entity, labels],
41
- );
42
-
43
- const openURL = useCallback(
44
- (url: string) => () => {
45
- Linking.openURL(url).catch((e) => {
46
- reportException(e, 'Error opening entity link');
47
- });
48
- },
49
- [],
50
- );
51
- return (
52
- <View style={[styles.buttons]} testID={testID}>
53
- {buttons.map(({ label, url, testID: testIdSuffix }) => (
54
- <Button
55
- key={label}
56
- title={label}
57
- onPress={openURL(url)}
58
- style={styles.urlButton}
59
- testID={concatTestID(testID, testIdSuffix)}
60
- type={ButtonType.SmallTech}
61
- />
62
- ))}
63
- </View>
64
- );
65
- };
66
-
67
- const styles = StyleSheet.create({
68
- buttons: {
69
- paddingBottom: 10,
70
- paddingHorizontal: 12,
71
- },
72
- urlButton: {
73
- borderRadius: 4,
74
- borderWidth: 0,
75
- marginTop: 4,
76
- },
77
- });
78
-
79
- export default memo(EntityButtons);
@@ -1,80 +0,0 @@
1
- import { TrustEntityDetail, TrustEntityListItem } from '@procivis/react-native-one-core';
2
- import React, { FC, memo } from 'react';
3
- import { StyleSheet, View } from 'react-native';
4
-
5
- import { NerdModeItem } from '../../ui-components/nerd-view';
6
- import { AttributesLabels, EntityType } from '../../ui-components/screens/nerd-mode-screen';
7
- import { addElementIf } from '../../utils/array';
8
-
9
- interface EntityAttributesProps {
10
- certificate?: string;
11
- did?: string;
12
- trustEntity?: TrustEntityDetail | TrustEntityListItem;
13
- trusted: boolean;
14
- labels: AttributesLabels;
15
- onCopyToClipboard: (value: string) => void;
16
- entityType: EntityType;
17
- testID?: string;
18
- }
19
-
20
- const EntityAttributes: FC<EntityAttributesProps> = ({
21
- certificate,
22
- did,
23
- trustEntity,
24
- trusted,
25
- labels,
26
- entityType,
27
- testID,
28
- onCopyToClipboard,
29
- }) => {
30
- const didSections = did?.split(':') ?? [];
31
- const identifier = didSections.pop();
32
- const didMethod = didSections.length ? didSections.join(':') + ':' : '';
33
-
34
- const attributes = [
35
- ...addElementIf(trusted, {
36
- attributeKey: labels.trustRegistry,
37
- highlightedText: trustEntity?.trustAnchor.name,
38
- testID: 'trustRegistry',
39
- }),
40
- ...addElementIf(Boolean(did), {
41
- attributeKey: entityType === EntityType.CredentialEntity ? labels.issuerIdentifier : labels.entityIdentifier,
42
- attributeText: identifier,
43
- canBeCopied: true,
44
- highlightedText: didMethod,
45
- testID: 'issuerDID',
46
- }),
47
- ...addElementIf(Boolean(certificate), {
48
- attributeKey: entityType === EntityType.CredentialEntity ? labels.issuerIdentifier : labels.entityIdentifier,
49
- attributeText: certificate,
50
- canBeCopied: true,
51
- testID: 'issuerCertificate',
52
- }),
53
- ...addElementIf(trusted && Boolean(trustEntity?.role), {
54
- attributeKey: labels.role,
55
- highlightedText: trustEntity?.role,
56
- testID: 'role',
57
- }),
58
- ];
59
- return (
60
- <View style={styles.wrapper}>
61
- {attributes.map((attribute) => (
62
- <NerdModeItem
63
- key={attribute.attributeKey}
64
- {...attribute}
65
- labels={labels}
66
- onCopyToClipboard={onCopyToClipboard}
67
- testID={testID}
68
- />
69
- ))}
70
- </View>
71
- );
72
- };
73
-
74
- const styles = StyleSheet.create({
75
- wrapper: {
76
- marginBottom: 20,
77
- },
78
- });
79
-
80
- export default memo(EntityAttributes);
@@ -1,75 +0,0 @@
1
- import { IdentifierListItem, TrustEntityRole, TrustEntityState } from '@procivis/react-native-one-core';
2
- import React, { FC, memo } from 'react';
3
- import { StyleProp, View, ViewStyle } from 'react-native';
4
-
5
- import { AttributesLabels, EntityLabels, EntityType } from '../../ui-components/screens/nerd-mode-screen';
6
- import { useAppColorScheme } from '../../ui-components/theme/color-scheme-context';
7
- import { concatTestID, useIdentifierDetails } from '../../utils';
8
- import { useTrustEntity } from '../../utils/hooks/core/trust-entity';
9
- import EntityAttributes from './entity-attributes';
10
- import EntityDetails from './entity-details';
11
- import EntityButtons from './EntityButtons';
12
-
13
- export type ContextRole = Exclude<TrustEntityRole, TrustEntityRole.BOTH>;
14
-
15
- interface EntityDetailsWithButtonsProps {
16
- identifier?: IdentifierListItem;
17
- entityLabels: EntityLabels;
18
- attributesLabels: AttributesLabels;
19
- style?: StyleProp<ViewStyle>;
20
- textColor?: string;
21
- testID?: string;
22
- role: ContextRole;
23
- onCopyToClipboard: (value: string) => void;
24
- entityType: EntityType;
25
- }
26
-
27
- const EntityDetailsWithButtons: FC<EntityDetailsWithButtonsProps> = ({
28
- identifier,
29
- entityLabels,
30
- attributesLabels,
31
- onCopyToClipboard,
32
- role,
33
- entityType,
34
- testID,
35
- ...props
36
- }) => {
37
- let { data } = useTrustEntity(identifier?.id);
38
- let { data: identifierDetail } = useIdentifierDetails(identifier?.id);
39
- const trustEntity = data ?? undefined;
40
-
41
- const colorScheme = useAppColorScheme();
42
-
43
- const trusted = Boolean(
44
- trustEntity &&
45
- trustEntity.state === TrustEntityState.ACTIVE &&
46
- (trustEntity.role === TrustEntityRole.BOTH || trustEntity.role === role),
47
- );
48
-
49
- return (
50
- <View style={{ backgroundColor: colorScheme.nerdView.background }}>
51
- <EntityDetails
52
- identifier={identifier}
53
- labels={{
54
- unknown: role === TrustEntityRole.ISSUER ? entityLabels.unknownIssuer : entityLabels.unknownVerifier,
55
- }}
56
- role={role}
57
- testID={testID}
58
- {...props}
59
- />
60
- {trusted && <EntityButtons entity={trustEntity} labels={entityLabels} testID={concatTestID(testID, 'links')} />}
61
- <EntityAttributes
62
- certificate={identifierDetail?.certificates?.[0]?.chain}
63
- did={identifierDetail?.did?.did}
64
- trustEntity={trustEntity}
65
- trusted={trusted}
66
- labels={attributesLabels}
67
- onCopyToClipboard={onCopyToClipboard}
68
- entityType={entityType}
69
- testID={testID}
70
- />
71
- </View>
72
- );
73
- };
74
-
75
- export default memo(EntityDetailsWithButtons);
@@ -1,145 +0,0 @@
1
- import {
2
- CertificateDetail,
3
- IdentifierListItem,
4
- IdentifierType,
5
- TrustEntityDetail,
6
- TrustEntityRole,
7
- TrustEntityState,
8
- } from '@procivis/react-native-one-core';
9
- import React, { FC, ReactNode, useMemo } from 'react';
10
- import { StyleProp, ViewStyle } from 'react-native';
11
-
12
- import { AvatarProps } from '../../ui-components';
13
- import EntityCluster from '../../ui-components/entity/entity-cluster';
14
- import { EntityNotTrustedIcon, EntityTrustedIcon } from '../../ui-components/icons';
15
- import { concatTestID, replaceBreakingHyphens, useIdentifierDetails } from '../../utils';
16
- import { useTrustEntity } from '../../utils/hooks/core/trust-entity';
17
-
18
- export type EntityDetailsLabels = {
19
- unknown: string;
20
- };
21
-
22
- export type EntityDetailsProps = {
23
- labels: EntityDetailsLabels;
24
- renderMore?: (trustEntity: TrustEntityDetail) => ReactNode;
25
- role: Exclude<TrustEntityRole, TrustEntityRole.BOTH>;
26
- style?: StyleProp<ViewStyle>;
27
- sublineColor?: string;
28
- textColor?: string;
29
- testID?: string;
30
- } & (
31
- | {
32
- identifier?: IdentifierListItem;
33
- }
34
- | {
35
- entity: TrustEntityDetail;
36
- }
37
- );
38
-
39
- const getCertificateCommonName = (certificate: CertificateDetail): string | undefined => {
40
- return certificate.x509Attributes.subject
41
- .split(', ')
42
- .find((s) => s.startsWith('CN'))
43
- ?.split('=')
44
- ?.pop();
45
- };
46
-
47
- const EntityDetails: FC<EntityDetailsProps> = ({
48
- labels,
49
- renderMore,
50
- role,
51
- style,
52
- testID,
53
- sublineColor,
54
- textColor,
55
- ...props
56
- }) => {
57
- const { data, isLoading: isLoadingTrustEntity } = useTrustEntity(
58
- 'identifier' in props ? props.identifier?.id : undefined,
59
- );
60
- const trustEntity = 'entity' in props ? props.entity : data ?? undefined;
61
- const { data: identifierDetail, isLoading: isLoadingIdentifier } = useIdentifierDetails(
62
- 'identifier' in props ? props.identifier?.id : undefined,
63
- );
64
-
65
- const trusted =
66
- trustEntity &&
67
- trustEntity.state === TrustEntityState.ACTIVE &&
68
- (trustEntity.role === TrustEntityRole.BOTH || trustEntity.role === role);
69
-
70
- const isLoading = isLoadingIdentifier || isLoadingTrustEntity;
71
-
72
- const avatarProps: AvatarProps | undefined = useMemo(() => {
73
- if (isLoading) {
74
- return undefined;
75
- }
76
-
77
- const avatar =
78
- trusted && identifierDetail?.type === 'DID' && trustEntity.logo
79
- ? { imageSource: { uri: trustEntity.logo } }
80
- : undefined;
81
-
82
- const placeholderText =
83
- identifierDetail?.type === IdentifierType.CERTIFICATE && identifierDetail.certificates?.[0]
84
- ? getCertificateCommonName(identifierDetail.certificates[0])?.substring(0, 1)
85
- : 'D';
86
-
87
- const statusIcon = trusted ? (
88
- <EntityTrustedIcon testID={concatTestID(testID, 'statusIcon', 'trusted')} />
89
- ) : (
90
- <EntityNotTrustedIcon testID={concatTestID(testID, 'statusIcon', 'notTrusted')} />
91
- );
92
-
93
- if (trustEntity) {
94
- return {
95
- avatar,
96
- placeholderText:
97
- trusted && identifierDetail?.type === 'DID' ? trustEntity.name.substring(0, 1) : placeholderText,
98
- statusIcon,
99
- testID: concatTestID(testID, 'avatar'),
100
- };
101
- }
102
-
103
- return {
104
- placeholderText,
105
- statusIcon,
106
- };
107
- }, [trustEntity, trusted, identifierDetail, isLoading, testID]);
108
-
109
- const trustEntityName = useMemo(() => {
110
- if (isLoading) {
111
- return '';
112
- }
113
- if (identifierDetail?.type === IdentifierType.CERTIFICATE && identifierDetail.certificates?.[0]) {
114
- const commonName = getCertificateCommonName(identifierDetail.certificates[0]);
115
- if (commonName) {
116
- return commonName;
117
- }
118
- }
119
- if (trustEntity) {
120
- return trustEntity.name;
121
- }
122
- if (identifierDetail?.did?.did) {
123
- return replaceBreakingHyphens(identifierDetail.did.did);
124
- }
125
-
126
- return labels.unknown;
127
- }, [labels.unknown, trustEntity, identifierDetail, isLoading]);
128
-
129
- return (
130
- <>
131
- <EntityCluster
132
- avatar={avatarProps}
133
- entityName={trustEntityName}
134
- style={style}
135
- testID={testID}
136
- textColor={textColor}
137
- sublineColor={sublineColor}
138
- isLoading={isLoading}
139
- />
140
- {trustEntity && renderMore && renderMore(trustEntity)}
141
- </>
142
- );
143
- };
144
-
145
- export default EntityDetails;
@@ -1,4 +0,0 @@
1
- import type { EntityDetailsLabels, EntityDetailsProps } from './entity-details';
2
- import EntityDetails from './entity-details';
3
-
4
- export { EntityDetails, EntityDetailsLabels, EntityDetailsProps };