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

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 (258) hide show
  1. package/lib/commonjs/components/credential/credential.js +8 -2
  2. package/lib/commonjs/components/credential/credential.js.map +1 -1
  3. package/lib/commonjs/components/proof-request/index.js +23 -12
  4. package/lib/commonjs/components/proof-request/index.js.map +1 -1
  5. package/lib/commonjs/components/proof-request/select-share-credential-card-notice.js +37 -0
  6. package/lib/commonjs/components/proof-request/select-share-credential-card-notice.js.map +1 -0
  7. package/lib/commonjs/components/proof-request/share-credential-card-notice.js +36 -0
  8. package/lib/commonjs/components/proof-request/share-credential-card-notice.js.map +1 -0
  9. package/lib/commonjs/components/proof-request/{group.js → v1/group.js} +1 -1
  10. package/lib/commonjs/components/proof-request/v1/group.js.map +1 -0
  11. package/lib/commonjs/components/proof-request/v1/index.js +39 -0
  12. package/lib/commonjs/components/proof-request/v1/index.js.map +1 -0
  13. package/lib/commonjs/components/proof-request/{select-credential.js → v1/select-credential.js} +12 -6
  14. package/lib/commonjs/components/proof-request/v1/select-credential.js.map +1 -0
  15. package/lib/commonjs/components/proof-request/{share-credential.js → v1/share-credential.js} +33 -62
  16. package/lib/commonjs/components/proof-request/v1/share-credential.js.map +1 -0
  17. package/lib/commonjs/components/proof-request/v2/index.js +39 -0
  18. package/lib/commonjs/components/proof-request/v2/index.js.map +1 -0
  19. package/lib/commonjs/components/proof-request/v2/select-credential-v2.js +55 -0
  20. package/lib/commonjs/components/proof-request/v2/select-credential-v2.js.map +1 -0
  21. package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js +164 -0
  22. package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js.map +1 -0
  23. package/lib/commonjs/components/proof-request/v2/share-credential-v2.js +135 -0
  24. package/lib/commonjs/components/proof-request/v2/share-credential-v2.js.map +1 -0
  25. package/lib/commonjs/ui-components/buttons/share-button.js +1 -1
  26. package/lib/commonjs/ui-components/buttons/share-button.js.map +1 -1
  27. package/lib/commonjs/ui-components/camera/qr-code-scanner.js +5 -1
  28. package/lib/commonjs/ui-components/camera/qr-code-scanner.js.map +1 -1
  29. package/lib/commonjs/ui-components/credential/card/credential-details-list-item.js +16 -42
  30. package/lib/commonjs/ui-components/credential/card/credential-details-list-item.js.map +1 -1
  31. package/lib/commonjs/ui-components/credential/credential-attribute-item.js +3 -1
  32. package/lib/commonjs/ui-components/credential/credential-attribute-item.js.map +1 -1
  33. package/lib/commonjs/ui-components/credential/group/credential-group-header.js +72 -0
  34. package/lib/commonjs/ui-components/credential/group/credential-group-header.js.map +1 -0
  35. package/lib/commonjs/ui-components/credential/group/index.js +14 -0
  36. package/lib/commonjs/ui-components/credential/group/index.js.map +1 -0
  37. package/lib/commonjs/ui-components/credential/index.js +12 -0
  38. package/lib/commonjs/ui-components/credential/index.js.map +1 -1
  39. package/lib/commonjs/ui-components/header/foldable-header.js +29 -17
  40. package/lib/commonjs/ui-components/header/foldable-header.js.map +1 -1
  41. package/lib/commonjs/ui-components/index.js +11 -0
  42. package/lib/commonjs/ui-components/index.js.map +1 -1
  43. package/lib/commonjs/ui-components/loader/loading-result.js +1 -1
  44. package/lib/commonjs/ui-components/loader/loading-result.js.map +1 -1
  45. package/lib/commonjs/ui-components/pin/pin-lock-animation.js +477 -475
  46. package/lib/commonjs/ui-components/pin/pin-lock-animation.js.map +1 -1
  47. package/lib/commonjs/ui-components/proof-request/index.js +13 -0
  48. package/lib/commonjs/ui-components/proof-request/index.js.map +1 -0
  49. package/lib/commonjs/ui-components/proof-request/proof-request-set.js +47 -0
  50. package/lib/commonjs/ui-components/proof-request/proof-request-set.js.map +1 -0
  51. package/lib/commonjs/ui-components/screens/section-list-screen.js +17 -3
  52. package/lib/commonjs/ui-components/screens/section-list-screen.js.map +1 -1
  53. package/lib/commonjs/utils/array.js.map +1 -1
  54. package/lib/commonjs/utils/hooks/app-state.js +33 -0
  55. package/lib/commonjs/utils/hooks/app-state.js.map +1 -0
  56. package/lib/commonjs/utils/hooks/core/backup.js +1 -1
  57. package/lib/commonjs/utils/hooks/core/backup.js.map +1 -1
  58. package/lib/commonjs/utils/hooks/core/credentials.js +10 -3
  59. package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
  60. package/lib/commonjs/utils/hooks/core/identifiers.js +1 -1
  61. package/lib/commonjs/utils/hooks/core/identifiers.js.map +1 -1
  62. package/lib/commonjs/utils/hooks/core/index.js +11 -0
  63. package/lib/commonjs/utils/hooks/core/index.js.map +1 -1
  64. package/lib/commonjs/utils/hooks/core/proofs.js +39 -10
  65. package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
  66. package/lib/commonjs/utils/hooks/core/wallet-unit.js +85 -0
  67. package/lib/commonjs/utils/hooks/core/wallet-unit.js.map +1 -0
  68. package/lib/commonjs/utils/hooks/index.js +11 -0
  69. package/lib/commonjs/utils/hooks/index.js.map +1 -1
  70. package/lib/commonjs/utils/hooks/revocation/credential-status.js +1 -1
  71. package/lib/commonjs/utils/hooks/revocation/credential-status.js.map +1 -1
  72. package/lib/commonjs/utils/index.js +16 -4
  73. package/lib/commonjs/utils/index.js.map +1 -1
  74. package/lib/commonjs/utils/parsers/credential-sharing-v2.js +190 -0
  75. package/lib/commonjs/utils/parsers/credential-sharing-v2.js.map +1 -0
  76. package/lib/commonjs/utils/parsers/credential-sharing.js +31 -18
  77. package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
  78. package/lib/commonjs/utils/parsers/credential.js +111 -63
  79. package/lib/commonjs/utils/parsers/credential.js.map +1 -1
  80. package/lib/commonjs/utils/parsers/index.js +11 -0
  81. package/lib/commonjs/utils/parsers/index.js.map +1 -1
  82. package/lib/commonjs/utils/parsers/query.js +4 -4
  83. package/lib/commonjs/utils/parsers/query.js.map +1 -1
  84. package/lib/commonjs/utils/wallet-unit.js +30 -0
  85. package/lib/commonjs/utils/wallet-unit.js.map +1 -0
  86. package/lib/module/components/credential/credential.js +8 -2
  87. package/lib/module/components/credential/credential.js.map +1 -1
  88. package/lib/module/components/proof-request/index.js +4 -3
  89. package/lib/module/components/proof-request/index.js.map +1 -1
  90. package/lib/module/components/proof-request/select-share-credential-card-notice.js +29 -0
  91. package/lib/module/components/proof-request/select-share-credential-card-notice.js.map +1 -0
  92. package/lib/module/components/proof-request/share-credential-card-notice.js +28 -0
  93. package/lib/module/components/proof-request/share-credential-card-notice.js.map +1 -0
  94. package/lib/module/components/proof-request/{group.js → v1/group.js} +1 -1
  95. package/lib/module/components/proof-request/v1/group.js.map +1 -0
  96. package/lib/module/components/proof-request/v1/index.js +4 -0
  97. package/lib/module/components/proof-request/v1/index.js.map +1 -0
  98. package/lib/module/components/proof-request/{select-credential.js → v1/select-credential.js} +12 -6
  99. package/lib/module/components/proof-request/v1/select-credential.js.map +1 -0
  100. package/lib/module/components/proof-request/v1/share-credential.js +118 -0
  101. package/lib/module/components/proof-request/v1/share-credential.js.map +1 -0
  102. package/lib/module/components/proof-request/v2/index.js +4 -0
  103. package/lib/module/components/proof-request/v2/index.js.map +1 -0
  104. package/lib/module/components/proof-request/v2/select-credential-v2.js +46 -0
  105. package/lib/module/components/proof-request/v2/select-credential-v2.js.map +1 -0
  106. package/lib/module/components/proof-request/v2/share-credential-v2-group.js +154 -0
  107. package/lib/module/components/proof-request/v2/share-credential-v2-group.js.map +1 -0
  108. package/lib/module/components/proof-request/v2/share-credential-v2.js +126 -0
  109. package/lib/module/components/proof-request/v2/share-credential-v2.js.map +1 -0
  110. package/lib/module/ui-components/buttons/share-button.js +1 -1
  111. package/lib/module/ui-components/buttons/share-button.js.map +1 -1
  112. package/lib/module/ui-components/camera/qr-code-scanner.js +5 -1
  113. package/lib/module/ui-components/camera/qr-code-scanner.js.map +1 -1
  114. package/lib/module/ui-components/credential/card/credential-details-list-item.js +19 -45
  115. package/lib/module/ui-components/credential/card/credential-details-list-item.js.map +1 -1
  116. package/lib/module/ui-components/credential/credential-attribute-item.js +3 -1
  117. package/lib/module/ui-components/credential/credential-attribute-item.js.map +1 -1
  118. package/lib/module/ui-components/credential/group/credential-group-header.js +64 -0
  119. package/lib/module/ui-components/credential/group/credential-group-header.js.map +1 -0
  120. package/lib/module/ui-components/credential/group/index.js +3 -0
  121. package/lib/module/ui-components/credential/group/index.js.map +1 -0
  122. package/lib/module/ui-components/credential/index.js +1 -0
  123. package/lib/module/ui-components/credential/index.js.map +1 -1
  124. package/lib/module/ui-components/header/foldable-header.js +29 -17
  125. package/lib/module/ui-components/header/foldable-header.js.map +1 -1
  126. package/lib/module/ui-components/index.js +1 -0
  127. package/lib/module/ui-components/index.js.map +1 -1
  128. package/lib/module/ui-components/loader/loading-result.js +1 -1
  129. package/lib/module/ui-components/loader/loading-result.js.map +1 -1
  130. package/lib/module/ui-components/pin/pin-lock-animation.js +477 -475
  131. package/lib/module/ui-components/pin/pin-lock-animation.js.map +1 -1
  132. package/lib/module/ui-components/proof-request/index.js +3 -0
  133. package/lib/module/ui-components/proof-request/index.js.map +1 -0
  134. package/lib/module/ui-components/proof-request/proof-request-set.js +39 -0
  135. package/lib/module/ui-components/proof-request/proof-request-set.js.map +1 -0
  136. package/lib/module/ui-components/screens/section-list-screen.js +15 -3
  137. package/lib/module/ui-components/screens/section-list-screen.js.map +1 -1
  138. package/lib/module/utils/array.js.map +1 -1
  139. package/lib/module/utils/hooks/app-state.js +27 -0
  140. package/lib/module/utils/hooks/app-state.js.map +1 -0
  141. package/lib/module/utils/hooks/core/backup.js +1 -1
  142. package/lib/module/utils/hooks/core/backup.js.map +1 -1
  143. package/lib/module/utils/hooks/core/credentials.js +11 -4
  144. package/lib/module/utils/hooks/core/credentials.js.map +1 -1
  145. package/lib/module/utils/hooks/core/identifiers.js +5 -5
  146. package/lib/module/utils/hooks/core/identifiers.js.map +1 -1
  147. package/lib/module/utils/hooks/core/index.js +1 -0
  148. package/lib/module/utils/hooks/core/index.js.map +1 -1
  149. package/lib/module/utils/hooks/core/proofs.js +40 -11
  150. package/lib/module/utils/hooks/core/proofs.js.map +1 -1
  151. package/lib/module/utils/hooks/core/wallet-unit.js +75 -0
  152. package/lib/module/utils/hooks/core/wallet-unit.js.map +1 -0
  153. package/lib/module/utils/hooks/index.js +1 -0
  154. package/lib/module/utils/hooks/index.js.map +1 -1
  155. package/lib/module/utils/hooks/revocation/credential-status.js +1 -1
  156. package/lib/module/utils/hooks/revocation/credential-status.js.map +1 -1
  157. package/lib/module/utils/index.js +2 -1
  158. package/lib/module/utils/index.js.map +1 -1
  159. package/lib/module/utils/parsers/credential-sharing-v2.js +177 -0
  160. package/lib/module/utils/parsers/credential-sharing-v2.js.map +1 -0
  161. package/lib/module/utils/parsers/credential-sharing.js +31 -18
  162. package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
  163. package/lib/module/utils/parsers/credential.js +112 -64
  164. package/lib/module/utils/parsers/credential.js.map +1 -1
  165. package/lib/module/utils/parsers/index.js +1 -0
  166. package/lib/module/utils/parsers/index.js.map +1 -1
  167. package/lib/module/utils/parsers/query.js +4 -4
  168. package/lib/module/utils/parsers/query.js.map +1 -1
  169. package/lib/module/utils/wallet-unit.js +22 -0
  170. package/lib/module/utils/wallet-unit.js.map +1 -0
  171. package/lib/typescript/components/proof-request/index.d.ts +4 -3
  172. package/lib/typescript/components/proof-request/select-share-credential-card-notice.d.ts +7 -0
  173. package/lib/typescript/components/proof-request/share-credential-card-notice.d.ts +6 -0
  174. package/lib/typescript/components/proof-request/v1/index.d.ts +3 -0
  175. package/lib/typescript/components/proof-request/{select-credential.d.ts → v1/select-credential.d.ts} +1 -1
  176. package/lib/typescript/components/proof-request/{share-credential.d.ts → v1/share-credential.d.ts} +1 -1
  177. package/lib/typescript/components/proof-request/v2/index.d.ts +3 -0
  178. package/lib/typescript/components/proof-request/v2/select-credential-v2.d.ts +14 -0
  179. package/lib/typescript/components/proof-request/v2/share-credential-v2-group.d.ts +24 -0
  180. package/lib/typescript/components/proof-request/v2/share-credential-v2.d.ts +23 -0
  181. package/lib/typescript/ui-components/credential/group/credential-group-header.d.ts +10 -0
  182. package/lib/typescript/ui-components/credential/group/index.d.ts +3 -0
  183. package/lib/typescript/ui-components/credential/index.d.ts +1 -0
  184. package/lib/typescript/ui-components/header/foldable-header.d.ts +1 -0
  185. package/lib/typescript/ui-components/index.d.ts +1 -0
  186. package/lib/typescript/ui-components/loader/loading-result.d.ts +1 -1
  187. package/lib/typescript/ui-components/pin/pin-lock-animation.d.ts +311 -311
  188. package/lib/typescript/ui-components/proof-request/index.d.ts +3 -0
  189. package/lib/typescript/ui-components/proof-request/proof-request-set.d.ts +7 -0
  190. package/lib/typescript/ui-components/screens/section-list-screen.d.ts +4 -2
  191. package/lib/typescript/utils/array.d.ts +1 -0
  192. package/lib/typescript/utils/hooks/app-state.d.ts +5 -0
  193. package/lib/typescript/utils/hooks/core/backup.d.ts +1 -1
  194. package/lib/typescript/utils/hooks/core/credentials.d.ts +1 -1
  195. package/lib/typescript/utils/hooks/core/identifiers.d.ts +1 -1
  196. package/lib/typescript/utils/hooks/core/index.d.ts +1 -0
  197. package/lib/typescript/utils/hooks/core/proofs.d.ts +6 -7
  198. package/lib/typescript/utils/hooks/core/wallet-unit.d.ts +9 -0
  199. package/lib/typescript/utils/hooks/index.d.ts +1 -0
  200. package/lib/typescript/utils/index.d.ts +2 -1
  201. package/lib/typescript/utils/parsers/credential-sharing-v2.d.ts +11 -0
  202. package/lib/typescript/utils/parsers/credential-sharing.d.ts +11 -5
  203. package/lib/typescript/utils/parsers/credential.d.ts +9 -6
  204. package/lib/typescript/utils/parsers/index.d.ts +1 -0
  205. package/lib/typescript/utils/parsers/query.d.ts +2 -2
  206. package/lib/typescript/utils/wallet-unit.d.ts +8 -0
  207. package/package.json +12 -6
  208. package/src/components/credential/credential.tsx +5 -1
  209. package/src/components/proof-request/index.ts +4 -3
  210. package/src/components/proof-request/select-share-credential-card-notice.tsx +37 -0
  211. package/src/components/proof-request/share-credential-card-notice.tsx +33 -0
  212. package/src/components/proof-request/{group.tsx → v1/group.tsx} +1 -1
  213. package/src/components/proof-request/v1/index.ts +3 -0
  214. package/src/components/proof-request/{select-credential.tsx → v1/select-credential.tsx} +12 -5
  215. package/src/components/proof-request/{share-credential.tsx → v1/share-credential.tsx} +35 -52
  216. package/src/components/proof-request/v2/index.ts +3 -0
  217. package/src/components/proof-request/v2/select-credential-v2.tsx +59 -0
  218. package/src/components/proof-request/v2/share-credential-v2-group.tsx +258 -0
  219. package/src/components/proof-request/v2/share-credential-v2.tsx +211 -0
  220. package/src/ui-components/buttons/share-button.tsx +1 -1
  221. package/src/ui-components/camera/qr-code-scanner.tsx +11 -2
  222. package/src/ui-components/credential/card/credential-details-list-item.tsx +27 -49
  223. package/src/ui-components/credential/credential-attribute-item.tsx +2 -0
  224. package/src/ui-components/credential/group/credential-group-header.tsx +70 -0
  225. package/src/ui-components/credential/group/index.ts +4 -0
  226. package/src/ui-components/credential/index.ts +1 -0
  227. package/src/ui-components/header/foldable-header.tsx +31 -16
  228. package/src/ui-components/index.ts +1 -0
  229. package/src/ui-components/loader/loading-result.tsx +1 -1
  230. package/src/ui-components/pin/pin-lock-animation.tsx +240 -278
  231. package/src/ui-components/proof-request/index.ts +4 -0
  232. package/src/ui-components/proof-request/proof-request-set.tsx +46 -0
  233. package/src/ui-components/screens/section-list-screen.tsx +18 -4
  234. package/src/utils/array.ts +4 -0
  235. package/src/utils/hooks/app-state.ts +29 -0
  236. package/src/utils/hooks/core/backup.ts +2 -5
  237. package/src/utils/hooks/core/credentials.ts +11 -4
  238. package/src/utils/hooks/core/identifiers.ts +15 -14
  239. package/src/utils/hooks/core/index.ts +2 -1
  240. package/src/utils/hooks/core/proofs.ts +36 -12
  241. package/src/utils/hooks/core/wallet-unit.ts +77 -0
  242. package/src/utils/hooks/index.ts +1 -0
  243. package/src/utils/hooks/revocation/credential-status.ts +1 -1
  244. package/src/utils/index.ts +2 -1
  245. package/src/utils/parsers/credential-sharing-v2.tsx +283 -0
  246. package/src/utils/parsers/credential-sharing.tsx +40 -16
  247. package/src/utils/parsers/credential.ts +129 -59
  248. package/src/utils/parsers/index.ts +1 -0
  249. package/src/utils/parsers/query.ts +6 -5
  250. package/src/utils/wallet-unit.ts +30 -0
  251. package/lib/commonjs/components/proof-request/group.js.map +0 -1
  252. package/lib/commonjs/components/proof-request/select-credential.js.map +0 -1
  253. package/lib/commonjs/components/proof-request/share-credential.js.map +0 -1
  254. package/lib/module/components/proof-request/group.js.map +0 -1
  255. package/lib/module/components/proof-request/select-credential.js.map +0 -1
  256. package/lib/module/components/proof-request/share-credential.js +0 -147
  257. package/lib/module/components/proof-request/share-credential.js.map +0 -1
  258. /package/lib/typescript/components/proof-request/{group.d.ts → v1/group.d.ts} +0 -0
@@ -0,0 +1,4 @@
1
+ import type { ProofRequestSetProps } from './proof-request-set';
2
+ import { ProofRequestSet } from './proof-request-set';
3
+
4
+ export { ProofRequestSet, ProofRequestSetProps };
@@ -0,0 +1,46 @@
1
+ import React, { FunctionComponent, PropsWithChildren } from 'react';
2
+ import { StyleSheet, View } from 'react-native';
3
+
4
+ import { Typography } from '../text';
5
+ import { useAppColorScheme } from '../theme';
6
+
7
+ export type ProofRequestSetProps = {
8
+ headerLabel?: string;
9
+ showHeader?: boolean;
10
+ showSeparator?: boolean;
11
+ };
12
+
13
+ export const ProofRequestSet: FunctionComponent<PropsWithChildren<ProofRequestSetProps>> = ({
14
+ children,
15
+ headerLabel,
16
+ showHeader = false,
17
+ showSeparator = true,
18
+ }) => {
19
+ const colorScheme = useAppColorScheme();
20
+ return (
21
+ <View style={styles.set}>
22
+ {showSeparator && <View style={[styles.separator, { backgroundColor: colorScheme.grayDark }]} />}
23
+ {showHeader && headerLabel && (
24
+ <Typography align="left" color={colorScheme.text} preset="m" style={styles.header}>
25
+ {headerLabel}
26
+ </Typography>
27
+ )}
28
+ {children}
29
+ </View>
30
+ );
31
+ };
32
+
33
+ const styles = StyleSheet.create({
34
+ header: {
35
+ marginBottom: 16,
36
+ },
37
+ separator: {
38
+ height: 1,
39
+ marginBottom: 16,
40
+ marginHorizontal: 4,
41
+ opacity: 0.5,
42
+ },
43
+ set: {
44
+ marginTop: 16,
45
+ },
46
+ });
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useMemo } from 'react';
2
2
  import { Platform, SectionList, SectionListProps, StyleSheet, View, ViewProps, ViewStyle } from 'react-native';
3
3
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
4
4
 
@@ -13,13 +13,15 @@ export type SectionListScreenProps<ItemT, SectionT> = ViewProps & {
13
13
  static?: boolean;
14
14
  title: string;
15
15
  };
16
- list: Omit<SectionListProps<ItemT, SectionT>, 'ListHeaderComponent' | 'onScroll'>;
16
+ list: Omit<SectionListProps<ItemT, SectionT>, 'ListHeaderComponent' | 'onScroll'> & {
17
+ header?: React.ComponentType<any> | React.ReactElement;
18
+ };
17
19
  modalPresentation?: boolean;
18
20
  };
19
21
 
20
22
  const SectionListScreen = <ItemT, SectionT>({
21
23
  header,
22
- list: { contentContainerStyle, stickySectionHeadersEnabled, ...listProps },
24
+ list: { contentContainerStyle, header: listHeader, stickySectionHeadersEnabled, ...listProps },
23
25
  modalPresentation,
24
26
  style,
25
27
  ...viewProps
@@ -41,10 +43,22 @@ const SectionListScreen = <ItemT, SectionT>({
41
43
  headerPaddingStyle = styles.modalHeaderWithoutHandle;
42
44
  }
43
45
 
46
+ const headerView: React.ReactElement | undefined = useMemo(() => {
47
+ if (!listHeader) {
48
+ return undefined;
49
+ }
50
+ if (React.isValidElement(listHeader)) {
51
+ return listHeader;
52
+ } else {
53
+ const HeaderComponent = listHeader as React.ComponentType<any>;
54
+ return <HeaderComponent />;
55
+ }
56
+ }, [listHeader]);
57
+
44
58
  return (
45
59
  <View style={[styles.container, { backgroundColor: colorScheme.background }, style]} {...viewProps}>
46
60
  <SectionList<ItemT, SectionT>
47
- ListHeaderComponent={!header.static ? <ListTitleHeader title={header.title} /> : undefined}
61
+ ListHeaderComponent={!header.static ? <View><ListTitleHeader title={header.title} />{headerView}</View> : headerView}
48
62
  contentContainerStyle={[contentInsetsStyle, contentContainerStyle]}
49
63
  onScroll={onScroll}
50
64
  scrollEventThrottle={100}
@@ -1,3 +1,7 @@
1
1
  export function addElementIf<T>(condition: boolean, obj: T) {
2
2
  return condition ? Array(obj) : [];
3
3
  }
4
+
5
+ export type ArrayElement<ArrayType extends readonly unknown[]> = ArrayType extends readonly (infer ElementType)[]
6
+ ? ElementType
7
+ : never;
@@ -0,0 +1,29 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { AppState } from 'react-native';
3
+
4
+ /**
5
+ * Returns current app state
6
+ */
7
+ export function useAppState() {
8
+ const [appState, setAppState] = useState(AppState.currentState);
9
+
10
+ useEffect(() => {
11
+ const subscription = AppState.addEventListener('change', setAppState);
12
+ return () => subscription.remove();
13
+ }, []);
14
+
15
+ return appState;
16
+ }
17
+
18
+ export function useIsAppActive(): boolean | undefined {
19
+ switch (useAppState()) {
20
+ case 'active':
21
+ case 'extension':
22
+ return true;
23
+ case 'inactive':
24
+ case 'background':
25
+ return false;
26
+ default:
27
+ return undefined;
28
+ }
29
+ }
@@ -70,10 +70,7 @@ export const useRollbackImport = () => {
70
70
  * @param {IdentifiersInitializationConfig} config Select desired keys/dids to be restored/created
71
71
  * @returns [hwIdentifierId, swIdentifierId]
72
72
  */
73
- export const useBackupFinalizeImportProcedure = ({
74
- generateHwKey,
75
- generateSwKey,
76
- }: IdentifiersInitializationConfig) => {
73
+ export const useBackupFinalizeImportProcedure = ({ generateHwKey, generateSwKey }: IdentifiersInitializationConfig) => {
77
74
  const { mutateAsync: finalizeImport } = useFinalizeImport();
78
75
  const { core, organisationId } = useONECore();
79
76
 
@@ -84,7 +81,7 @@ export const useBackupFinalizeImportProcedure = ({
84
81
  let swIdentifierId: string | undefined;
85
82
  if (generateSwKey) {
86
83
  const identifiers = await core.getIdentifiers({
87
- state: IdentifierStateEnum.ACTIVE,
84
+ states: [IdentifierStateEnum.ACTIVE],
88
85
  organisationId,
89
86
  page: 0,
90
87
  pageSize: 1,
@@ -10,9 +10,10 @@ import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from 'react-q
10
10
 
11
11
  import { getQueryKeyFromCredentialListQueryParams } from '../../parsers/query';
12
12
  import { useONECore } from './core-context';
13
- import { CREDENTIAL_SCHEMA_LIST_QUERY_KEY } from './credential-schemas';
13
+ import { CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY, CREDENTIAL_SCHEMA_LIST_QUERY_KEY } from './credential-schemas';
14
14
  import { OneErrorCode } from './error-code';
15
15
  import { HISTORY_LIST_QUERY_KEY } from './history';
16
+ import { PROOF_LIST_QUERY_KEY } from './proofs';
16
17
 
17
18
  const PAGE_SIZE = 20;
18
19
  export const CREDENTIAL_LIST_QUERY_KEY = 'credential-list';
@@ -30,7 +31,7 @@ export const useCredentials = (queryParams?: Partial<CredentialListQuery>) => {
30
31
  page: 0,
31
32
  // TODO: workaround pagination for now, until it's supported by UI
32
33
  pageSize: 10000,
33
- status: [CredentialStateEnum.ACCEPTED, CredentialStateEnum.SUSPENDED, CredentialStateEnum.REVOKED],
34
+ states: [CredentialStateEnum.ACCEPTED, CredentialStateEnum.SUSPENDED, CredentialStateEnum.REVOKED],
34
35
  ...queryParams,
35
36
  });
36
37
  return values;
@@ -55,7 +56,7 @@ export const usePagedCredentials = (queryParams?: Partial<CredentialListQuery>)
55
56
  organisationId,
56
57
  page: pageParam,
57
58
  pageSize: PAGE_SIZE,
58
- status: [CredentialStateEnum.ACCEPTED, CredentialStateEnum.SUSPENDED, CredentialStateEnum.REVOKED],
59
+ states: [CredentialStateEnum.ACCEPTED, CredentialStateEnum.SUSPENDED, CredentialStateEnum.REVOKED],
59
60
  ...queryParams,
60
61
  }),
61
62
  {
@@ -87,9 +88,12 @@ export const useInvitationHandler = () => {
87
88
  core.handleInvitation({ organisationId, ...request }),
88
89
  {
89
90
  onSuccess: async (result: InvitationResult) => {
90
- if ('credentialIds' in result) {
91
+ if ('proofId' in result) {
92
+ await queryClient.invalidateQueries(PROOF_LIST_QUERY_KEY);
93
+ } else {
91
94
  await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);
92
95
  await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_LIST_QUERY_KEY);
96
+ await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY);
93
97
  }
94
98
  await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
95
99
  },
@@ -115,6 +119,8 @@ export const useCredentialAccept = () => {
115
119
  {
116
120
  onSuccess: async () => {
117
121
  await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);
122
+ await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_LIST_QUERY_KEY);
123
+ await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY);
118
124
  await queryClient.invalidateQueries(CREDENTIAL_DETAIL_QUERY_KEY);
119
125
  await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
120
126
  },
@@ -200,6 +206,7 @@ export const useContinueIssuance = () => {
200
206
  onSuccess: async () => {
201
207
  await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);
202
208
  await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_LIST_QUERY_KEY);
209
+ await queryClient.invalidateQueries(CREDENTIAL_SCHEMA_DETAIL_QUERY_KEY);
203
210
  await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
204
211
  },
205
212
  });
@@ -1,8 +1,8 @@
1
- import { IdentifierListQuery, IdentifierStateEnum, IdentifierTypeEnum } from "@procivis/react-native-one-core";
2
- import { useQuery } from "react-query";
1
+ import { IdentifierListQuery, IdentifierStateEnum, IdentifierTypeEnum } from '@procivis/react-native-one-core';
2
+ import { useQuery } from 'react-query';
3
3
 
4
- import { getQueryKeyFromIdentifierListQueryParams } from "../../parsers";
5
- import { useONECore } from "./core-context";
4
+ import { getQueryKeyFromIdentifierListQueryParams } from '../../parsers';
5
+ import { useONECore } from './core-context';
6
6
 
7
7
  export const IDENTIFIER_DETAIL_QUERY_KEY = 'identifier-detail';
8
8
  export const IDENTIFIER_LIST_QUERY_KEY = 'identifier-list';
@@ -19,21 +19,22 @@ export const useIdentifierDetails = (identifierId: string | undefined) => {
19
19
  keepPreviousData: true,
20
20
  },
21
21
  );
22
- }
22
+ };
23
23
 
24
24
  export const useIdentifiers = (identifierFilter?: Partial<IdentifierListQuery>) => {
25
25
  const { core, organisationId } = useONECore();
26
26
 
27
27
  return useQuery(
28
28
  [IDENTIFIER_LIST_QUERY_KEY, ...getQueryKeyFromIdentifierListQueryParams(identifierFilter)],
29
- ({ pageParam = 0 }) => (core.getIdentifiers({
30
- types: [IdentifierTypeEnum.DID],
31
- isRemote: false,
32
- page: pageParam,
33
- state: IdentifierStateEnum.ACTIVE,
34
- organisationId: organisationId,
35
- pageSize: PAGE_SIZE,
36
- ...identifierFilter,
37
- })),
29
+ ({ pageParam = 0 }) =>
30
+ core.getIdentifiers({
31
+ types: [IdentifierTypeEnum.DID],
32
+ isRemote: false,
33
+ page: pageParam,
34
+ states: [IdentifierStateEnum.ACTIVE],
35
+ organisationId: organisationId,
36
+ pageSize: PAGE_SIZE,
37
+ ...identifierFilter,
38
+ }),
38
39
  );
39
40
  };
@@ -11,4 +11,5 @@ export * from './identifiers';
11
11
  export * from './proof-schemas';
12
12
  export * from './proofs';
13
13
  export * from './query';
14
- export * from './trust-entity';
14
+ export * from './trust-entity';
15
+ export * from './wallet-unit';
@@ -1,12 +1,16 @@
1
1
  import {
2
2
  Config,
3
3
  CreateProofRequest,
4
+ HistoryActionEnum,
5
+ HistoryEntityTypeEnum,
6
+ HistoryErrorMetadata,
4
7
  IdentifierListQuery,
5
8
  OneError,
6
9
  PresentationSubmitCredentialRequest,
7
10
  ProofListQuery,
8
11
  ProofSchema,
9
12
  ProofStateEnum,
13
+ ProposeProofRequest,
10
14
  ShareProofRequest,
11
15
  } from '@procivis/react-native-one-core';
12
16
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
@@ -37,11 +41,31 @@ export const useProofDetail = (proofId: string | undefined) => {
37
41
  };
38
42
 
39
43
  export const useProofState = (proofId: string | undefined, isPolling: boolean) => {
40
- const { core } = useONECore();
44
+ const { core, organisationId } = useONECore();
41
45
 
42
46
  return useQuery(
43
47
  [PROOF_STATE_QUERY_KEY, proofId],
44
- () => (proofId ? core.getProof(proofId).then((proof) => proof.state) : undefined),
48
+ async () => {
49
+ if (!proofId) {
50
+ return undefined;
51
+ }
52
+
53
+ const state = await core.getProof(proofId).then((proof) => proof.state);
54
+ let metadata: HistoryErrorMetadata | undefined;
55
+ if (state === ProofStateEnum.ERROR) {
56
+ metadata = await core
57
+ .getHistory({
58
+ organisationId,
59
+ page: 0,
60
+ pageSize: 1,
61
+ entityId: proofId,
62
+ entityTypes: [HistoryEntityTypeEnum.PROOF],
63
+ actions: [HistoryActionEnum.ERRORED],
64
+ })
65
+ .then((result) => result.values[0]?.metadata as HistoryErrorMetadata);
66
+ }
67
+ return { state, metadata };
68
+ },
45
69
  {
46
70
  enabled: Boolean(proofId),
47
71
  refetchInterval: isPolling ? 1000 : false,
@@ -60,6 +84,7 @@ export const useProofUrl = () => {
60
84
  core.shareProof(proofId, request ?? {}).then((proof) => proof.url),
61
85
  {
62
86
  onSuccess: async () => {
87
+ await queryClient.invalidateQueries(PROOF_LIST_QUERY_KEY);
63
88
  await queryClient.invalidateQueries(PROOF_DETAIL_QUERY_KEY);
64
89
  await queryClient.invalidateQueries(PROOF_STATE_QUERY_KEY);
65
90
  },
@@ -88,9 +113,12 @@ export const useProofAccept = () => {
88
113
  {
89
114
  onError: async (err) => {
90
115
  reportException(err, 'Proof submission failure');
116
+ await queryClient.invalidateQueries(PROOF_LIST_QUERY_KEY);
91
117
  await queryClient.invalidateQueries(PROOF_DETAIL_QUERY_KEY);
118
+ await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
92
119
  },
93
120
  onSuccess: async () => {
121
+ await queryClient.invalidateQueries(PROOF_LIST_QUERY_KEY);
94
122
  await queryClient.invalidateQueries(PROOF_DETAIL_QUERY_KEY);
95
123
  await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
96
124
  },
@@ -112,6 +140,7 @@ export const useProofReject = () => {
112
140
  }),
113
141
  {
114
142
  onSuccess: async () => {
143
+ await queryClient.invalidateQueries(PROOF_LIST_QUERY_KEY);
115
144
  await queryClient.invalidateQueries(PROOF_DETAIL_QUERY_KEY);
116
145
  await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
117
146
  },
@@ -136,19 +165,15 @@ export enum VerificationEngagement {
136
165
  NFC = 'NFC',
137
166
  }
138
167
 
139
- export interface ProposeProofRequest {
140
- exchange: VerificationProtocol;
141
- engagement: VerificationEngagement[];
142
- }
143
-
144
168
  export const useProposeProof = () => {
145
169
  const queryClient = useQueryClient();
146
170
  const { core, organisationId } = useONECore();
147
171
 
148
172
  return useMutation(
149
- async ({ exchange, engagement }: ProposeProofRequest) => core.proposeProof(exchange, organisationId, engagement),
173
+ async (request: Omit<ProposeProofRequest, 'organisationId'>) => core.proposeProof({ organisationId, ...request }),
150
174
  {
151
175
  onSuccess: async () => {
176
+ await queryClient.invalidateQueries(PROOF_LIST_QUERY_KEY);
152
177
  await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
153
178
  },
154
179
  },
@@ -207,8 +232,7 @@ export const useProofCreate = () => {
207
232
  return useMutation(async (data: CreateProofRequest) => core.createProof(data), {
208
233
  onSuccess: async () => {
209
234
  await queryClient.invalidateQueries(PROOF_LIST_QUERY_KEY);
210
- await queryClient.invalidateQueries(PROOF_STATE_QUERY_KEY);
211
- await queryClient.invalidateQueries(PROOF_DETAIL_QUERY_KEY);
235
+ await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
212
236
  },
213
237
  });
214
238
  };
@@ -280,7 +304,7 @@ export const useProofForSchemaIdWithTransport = (
280
304
  return;
281
305
  }
282
306
 
283
- if (proofState !== ProofStateEnum.CREATED && proofState !== ProofStateEnum.PENDING) {
307
+ if (proofState?.state !== ProofStateEnum.CREATED && proofState?.state !== ProofStateEnum.PENDING) {
284
308
  setProofId(undefined);
285
309
  } else {
286
310
  setDeleting(true);
@@ -352,7 +376,7 @@ export const useShareProof = (proofUrlProps: ProofUrlHookParams | undefined, ena
352
376
 
353
377
  // reset when proofId changes or the proof was retracted
354
378
  useEffect(() => {
355
- if (!proofUrlProps?.proofId || proofState === ProofStateEnum.CREATED) {
379
+ if (!proofUrlProps?.proofId || proofState?.state === ProofStateEnum.CREATED) {
356
380
  setSharedProof(undefined);
357
381
  }
358
382
  }, [proofUrlProps?.proofId, proofState]);
@@ -0,0 +1,77 @@
1
+ import { WalletProvider, WalletUnitStatusEnum } from '@procivis/react-native-one-core';
2
+ import { useEffect } from 'react';
3
+ import { useMutation, useQuery, useQueryClient } from 'react-query';
4
+
5
+ import { reportException } from '../../reporting';
6
+ import { useONECore } from './core-context';
7
+
8
+ export const ATTESTATION_QUERY_KEY = 'wallet-unit-attestation';
9
+
10
+ export const useWalletUnitAttestation = (active = true) => {
11
+ const { core, organisationId } = useONECore();
12
+
13
+ return useQuery([ATTESTATION_QUERY_KEY, organisationId], () => core.holderGetWalletUnitAttestation(organisationId), {
14
+ enabled: active,
15
+ keepPreviousData: true,
16
+ retry: false,
17
+ });
18
+ };
19
+
20
+ export const useRegisterWalletUnit = () => {
21
+ const queryClient = useQueryClient();
22
+ const { core, organisationId } = useONECore();
23
+
24
+ return useMutation(
25
+ async (walletProvider: WalletProvider) => {
26
+ const result = await core.holderRegisterWalletUnit({
27
+ keyType: 'ECDSA',
28
+ organisationId,
29
+ walletProvider,
30
+ });
31
+
32
+ return result;
33
+ },
34
+ {
35
+ onSuccess: () => queryClient.invalidateQueries([ATTESTATION_QUERY_KEY, organisationId]),
36
+ },
37
+ );
38
+ };
39
+
40
+ export const useRefreshWalletUnit = () => {
41
+ const queryClient = useQueryClient();
42
+ const { core, organisationId } = useONECore();
43
+
44
+ return useMutation(
45
+ async (appIntegrityCheckRequired: boolean) =>
46
+ core.holderRefreshWalletUnit({
47
+ appIntegrityCheckRequired,
48
+ organisationId,
49
+ }),
50
+ {
51
+ onError: async (err) => {
52
+ reportException(err, 'Refresh wallet unit failure');
53
+ await queryClient.invalidateQueries([ATTESTATION_QUERY_KEY, organisationId]);
54
+ },
55
+ onSuccess: () => queryClient.invalidateQueries([ATTESTATION_QUERY_KEY, organisationId]),
56
+ },
57
+ );
58
+ };
59
+
60
+ export const useWalletUnitCheck = (appIntegrityCheckRequired: boolean) => {
61
+ const { data: walletUnitAttestation, isLoading } = useWalletUnitAttestation();
62
+ const { mutateAsync: refreshWalletUnit, isLoading: isRefreshing, status: refreshStatus } = useRefreshWalletUnit();
63
+
64
+ useEffect(() => {
65
+ if (isLoading || refreshStatus !== 'idle') {
66
+ return;
67
+ }
68
+ if (walletUnitAttestation?.status === WalletUnitStatusEnum.ACTIVE) {
69
+ void refreshWalletUnit(appIntegrityCheckRequired);
70
+ }
71
+ }, [isLoading, refreshStatus, walletUnitAttestation, refreshWalletUnit, appIntegrityCheckRequired]);
72
+
73
+ return {
74
+ isLoading: isLoading || isRefreshing,
75
+ walletUnitAttestation: isLoading || isRefreshing ? undefined : walletUnitAttestation,
76
+ };
77
+ };
@@ -1,3 +1,4 @@
1
+ export * from './app-state';
1
2
  export * from './connectivity/connectivity';
2
3
  export * from './core';
3
4
  export * from './credential-card/credential-card-expanding';
@@ -18,7 +18,7 @@ export const useCredentialStatusCheck = (credentialIds?: string[], forceRefresh
18
18
  const { mutateAsync: check } = useCredentialRevocationCheck(forceRefresh);
19
19
  const { data: credentials } = useCredentials({
20
20
  ids: credentialIds,
21
- status: [CredentialStateEnum.ACCEPTED, CredentialStateEnum.SUSPENDED],
21
+ states: [CredentialStateEnum.ACCEPTED, CredentialStateEnum.SUSPENDED],
22
22
  });
23
23
 
24
24
  const checkCredentialsStatus = useCallback(async () => {
@@ -15,6 +15,7 @@ export * from './parsers';
15
15
  export * from './ref';
16
16
  export * from './reporting';
17
17
  export * from './string';
18
+ export * from './url';
18
19
  export * from './useMemoAsync';
19
20
  export * from './uuid';
20
- export * from './url';
21
+ export * from './wallet-unit';