@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.
- package/lib/commonjs/components/credential/credential.js +8 -2
- package/lib/commonjs/components/credential/credential.js.map +1 -1
- package/lib/commonjs/components/proof-request/index.js +23 -12
- package/lib/commonjs/components/proof-request/index.js.map +1 -1
- package/lib/commonjs/components/proof-request/select-share-credential-card-notice.js +37 -0
- package/lib/commonjs/components/proof-request/select-share-credential-card-notice.js.map +1 -0
- package/lib/commonjs/components/proof-request/share-credential-card-notice.js +36 -0
- package/lib/commonjs/components/proof-request/share-credential-card-notice.js.map +1 -0
- package/lib/commonjs/components/proof-request/{group.js → v1/group.js} +1 -1
- package/lib/commonjs/components/proof-request/v1/group.js.map +1 -0
- package/lib/commonjs/components/proof-request/v1/index.js +39 -0
- package/lib/commonjs/components/proof-request/v1/index.js.map +1 -0
- package/lib/commonjs/components/proof-request/{select-credential.js → v1/select-credential.js} +12 -6
- package/lib/commonjs/components/proof-request/v1/select-credential.js.map +1 -0
- package/lib/commonjs/components/proof-request/{share-credential.js → v1/share-credential.js} +33 -62
- package/lib/commonjs/components/proof-request/v1/share-credential.js.map +1 -0
- package/lib/commonjs/components/proof-request/v2/index.js +39 -0
- package/lib/commonjs/components/proof-request/v2/index.js.map +1 -0
- package/lib/commonjs/components/proof-request/v2/select-credential-v2.js +55 -0
- package/lib/commonjs/components/proof-request/v2/select-credential-v2.js.map +1 -0
- package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js +164 -0
- package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js.map +1 -0
- package/lib/commonjs/components/proof-request/v2/share-credential-v2.js +135 -0
- package/lib/commonjs/components/proof-request/v2/share-credential-v2.js.map +1 -0
- package/lib/commonjs/ui-components/buttons/share-button.js +1 -1
- package/lib/commonjs/ui-components/buttons/share-button.js.map +1 -1
- package/lib/commonjs/ui-components/camera/qr-code-scanner.js +5 -1
- package/lib/commonjs/ui-components/camera/qr-code-scanner.js.map +1 -1
- package/lib/commonjs/ui-components/credential/card/credential-details-list-item.js +16 -42
- package/lib/commonjs/ui-components/credential/card/credential-details-list-item.js.map +1 -1
- package/lib/commonjs/ui-components/credential/credential-attribute-item.js +3 -1
- package/lib/commonjs/ui-components/credential/credential-attribute-item.js.map +1 -1
- package/lib/commonjs/ui-components/credential/group/credential-group-header.js +72 -0
- package/lib/commonjs/ui-components/credential/group/credential-group-header.js.map +1 -0
- package/lib/commonjs/ui-components/credential/group/index.js +14 -0
- package/lib/commonjs/ui-components/credential/group/index.js.map +1 -0
- package/lib/commonjs/ui-components/credential/index.js +12 -0
- package/lib/commonjs/ui-components/credential/index.js.map +1 -1
- package/lib/commonjs/ui-components/header/foldable-header.js +29 -17
- package/lib/commonjs/ui-components/header/foldable-header.js.map +1 -1
- package/lib/commonjs/ui-components/index.js +11 -0
- package/lib/commonjs/ui-components/index.js.map +1 -1
- package/lib/commonjs/ui-components/loader/loading-result.js +1 -1
- package/lib/commonjs/ui-components/loader/loading-result.js.map +1 -1
- package/lib/commonjs/ui-components/pin/pin-lock-animation.js +477 -475
- package/lib/commonjs/ui-components/pin/pin-lock-animation.js.map +1 -1
- package/lib/commonjs/ui-components/proof-request/index.js +13 -0
- package/lib/commonjs/ui-components/proof-request/index.js.map +1 -0
- package/lib/commonjs/ui-components/proof-request/proof-request-set.js +47 -0
- package/lib/commonjs/ui-components/proof-request/proof-request-set.js.map +1 -0
- package/lib/commonjs/ui-components/screens/section-list-screen.js +17 -3
- package/lib/commonjs/ui-components/screens/section-list-screen.js.map +1 -1
- package/lib/commonjs/utils/array.js.map +1 -1
- package/lib/commonjs/utils/hooks/app-state.js +33 -0
- package/lib/commonjs/utils/hooks/app-state.js.map +1 -0
- package/lib/commonjs/utils/hooks/core/backup.js +1 -1
- package/lib/commonjs/utils/hooks/core/backup.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/credentials.js +10 -3
- package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/identifiers.js +1 -1
- package/lib/commonjs/utils/hooks/core/identifiers.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/index.js +11 -0
- package/lib/commonjs/utils/hooks/core/index.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/proofs.js +39 -10
- package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/wallet-unit.js +85 -0
- package/lib/commonjs/utils/hooks/core/wallet-unit.js.map +1 -0
- package/lib/commonjs/utils/hooks/index.js +11 -0
- package/lib/commonjs/utils/hooks/index.js.map +1 -1
- package/lib/commonjs/utils/hooks/revocation/credential-status.js +1 -1
- package/lib/commonjs/utils/hooks/revocation/credential-status.js.map +1 -1
- package/lib/commonjs/utils/index.js +16 -4
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing-v2.js +190 -0
- package/lib/commonjs/utils/parsers/credential-sharing-v2.js.map +1 -0
- package/lib/commonjs/utils/parsers/credential-sharing.js +31 -18
- package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential.js +111 -63
- package/lib/commonjs/utils/parsers/credential.js.map +1 -1
- package/lib/commonjs/utils/parsers/index.js +11 -0
- package/lib/commonjs/utils/parsers/index.js.map +1 -1
- package/lib/commonjs/utils/parsers/query.js +4 -4
- package/lib/commonjs/utils/parsers/query.js.map +1 -1
- package/lib/commonjs/utils/wallet-unit.js +30 -0
- package/lib/commonjs/utils/wallet-unit.js.map +1 -0
- package/lib/module/components/credential/credential.js +8 -2
- package/lib/module/components/credential/credential.js.map +1 -1
- package/lib/module/components/proof-request/index.js +4 -3
- package/lib/module/components/proof-request/index.js.map +1 -1
- package/lib/module/components/proof-request/select-share-credential-card-notice.js +29 -0
- package/lib/module/components/proof-request/select-share-credential-card-notice.js.map +1 -0
- package/lib/module/components/proof-request/share-credential-card-notice.js +28 -0
- package/lib/module/components/proof-request/share-credential-card-notice.js.map +1 -0
- package/lib/module/components/proof-request/{group.js → v1/group.js} +1 -1
- package/lib/module/components/proof-request/v1/group.js.map +1 -0
- package/lib/module/components/proof-request/v1/index.js +4 -0
- package/lib/module/components/proof-request/v1/index.js.map +1 -0
- package/lib/module/components/proof-request/{select-credential.js → v1/select-credential.js} +12 -6
- package/lib/module/components/proof-request/v1/select-credential.js.map +1 -0
- package/lib/module/components/proof-request/v1/share-credential.js +118 -0
- package/lib/module/components/proof-request/v1/share-credential.js.map +1 -0
- package/lib/module/components/proof-request/v2/index.js +4 -0
- package/lib/module/components/proof-request/v2/index.js.map +1 -0
- package/lib/module/components/proof-request/v2/select-credential-v2.js +46 -0
- package/lib/module/components/proof-request/v2/select-credential-v2.js.map +1 -0
- package/lib/module/components/proof-request/v2/share-credential-v2-group.js +154 -0
- package/lib/module/components/proof-request/v2/share-credential-v2-group.js.map +1 -0
- package/lib/module/components/proof-request/v2/share-credential-v2.js +126 -0
- package/lib/module/components/proof-request/v2/share-credential-v2.js.map +1 -0
- package/lib/module/ui-components/buttons/share-button.js +1 -1
- package/lib/module/ui-components/buttons/share-button.js.map +1 -1
- package/lib/module/ui-components/camera/qr-code-scanner.js +5 -1
- package/lib/module/ui-components/camera/qr-code-scanner.js.map +1 -1
- package/lib/module/ui-components/credential/card/credential-details-list-item.js +19 -45
- package/lib/module/ui-components/credential/card/credential-details-list-item.js.map +1 -1
- package/lib/module/ui-components/credential/credential-attribute-item.js +3 -1
- package/lib/module/ui-components/credential/credential-attribute-item.js.map +1 -1
- package/lib/module/ui-components/credential/group/credential-group-header.js +64 -0
- package/lib/module/ui-components/credential/group/credential-group-header.js.map +1 -0
- package/lib/module/ui-components/credential/group/index.js +3 -0
- package/lib/module/ui-components/credential/group/index.js.map +1 -0
- package/lib/module/ui-components/credential/index.js +1 -0
- package/lib/module/ui-components/credential/index.js.map +1 -1
- package/lib/module/ui-components/header/foldable-header.js +29 -17
- package/lib/module/ui-components/header/foldable-header.js.map +1 -1
- package/lib/module/ui-components/index.js +1 -0
- package/lib/module/ui-components/index.js.map +1 -1
- package/lib/module/ui-components/loader/loading-result.js +1 -1
- package/lib/module/ui-components/loader/loading-result.js.map +1 -1
- package/lib/module/ui-components/pin/pin-lock-animation.js +477 -475
- package/lib/module/ui-components/pin/pin-lock-animation.js.map +1 -1
- package/lib/module/ui-components/proof-request/index.js +3 -0
- package/lib/module/ui-components/proof-request/index.js.map +1 -0
- package/lib/module/ui-components/proof-request/proof-request-set.js +39 -0
- package/lib/module/ui-components/proof-request/proof-request-set.js.map +1 -0
- package/lib/module/ui-components/screens/section-list-screen.js +15 -3
- package/lib/module/ui-components/screens/section-list-screen.js.map +1 -1
- package/lib/module/utils/array.js.map +1 -1
- package/lib/module/utils/hooks/app-state.js +27 -0
- package/lib/module/utils/hooks/app-state.js.map +1 -0
- package/lib/module/utils/hooks/core/backup.js +1 -1
- package/lib/module/utils/hooks/core/backup.js.map +1 -1
- package/lib/module/utils/hooks/core/credentials.js +11 -4
- package/lib/module/utils/hooks/core/credentials.js.map +1 -1
- package/lib/module/utils/hooks/core/identifiers.js +5 -5
- package/lib/module/utils/hooks/core/identifiers.js.map +1 -1
- package/lib/module/utils/hooks/core/index.js +1 -0
- package/lib/module/utils/hooks/core/index.js.map +1 -1
- package/lib/module/utils/hooks/core/proofs.js +40 -11
- package/lib/module/utils/hooks/core/proofs.js.map +1 -1
- package/lib/module/utils/hooks/core/wallet-unit.js +75 -0
- package/lib/module/utils/hooks/core/wallet-unit.js.map +1 -0
- package/lib/module/utils/hooks/index.js +1 -0
- package/lib/module/utils/hooks/index.js.map +1 -1
- package/lib/module/utils/hooks/revocation/credential-status.js +1 -1
- package/lib/module/utils/hooks/revocation/credential-status.js.map +1 -1
- package/lib/module/utils/index.js +2 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing-v2.js +177 -0
- package/lib/module/utils/parsers/credential-sharing-v2.js.map +1 -0
- package/lib/module/utils/parsers/credential-sharing.js +31 -18
- package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/module/utils/parsers/credential.js +112 -64
- package/lib/module/utils/parsers/credential.js.map +1 -1
- package/lib/module/utils/parsers/index.js +1 -0
- package/lib/module/utils/parsers/index.js.map +1 -1
- package/lib/module/utils/parsers/query.js +4 -4
- package/lib/module/utils/parsers/query.js.map +1 -1
- package/lib/module/utils/wallet-unit.js +22 -0
- package/lib/module/utils/wallet-unit.js.map +1 -0
- package/lib/typescript/components/proof-request/index.d.ts +4 -3
- package/lib/typescript/components/proof-request/select-share-credential-card-notice.d.ts +7 -0
- package/lib/typescript/components/proof-request/share-credential-card-notice.d.ts +6 -0
- package/lib/typescript/components/proof-request/v1/index.d.ts +3 -0
- package/lib/typescript/components/proof-request/{select-credential.d.ts → v1/select-credential.d.ts} +1 -1
- package/lib/typescript/components/proof-request/{share-credential.d.ts → v1/share-credential.d.ts} +1 -1
- package/lib/typescript/components/proof-request/v2/index.d.ts +3 -0
- package/lib/typescript/components/proof-request/v2/select-credential-v2.d.ts +14 -0
- package/lib/typescript/components/proof-request/v2/share-credential-v2-group.d.ts +24 -0
- package/lib/typescript/components/proof-request/v2/share-credential-v2.d.ts +23 -0
- package/lib/typescript/ui-components/credential/group/credential-group-header.d.ts +10 -0
- package/lib/typescript/ui-components/credential/group/index.d.ts +3 -0
- package/lib/typescript/ui-components/credential/index.d.ts +1 -0
- package/lib/typescript/ui-components/header/foldable-header.d.ts +1 -0
- package/lib/typescript/ui-components/index.d.ts +1 -0
- package/lib/typescript/ui-components/loader/loading-result.d.ts +1 -1
- package/lib/typescript/ui-components/pin/pin-lock-animation.d.ts +311 -311
- package/lib/typescript/ui-components/proof-request/index.d.ts +3 -0
- package/lib/typescript/ui-components/proof-request/proof-request-set.d.ts +7 -0
- package/lib/typescript/ui-components/screens/section-list-screen.d.ts +4 -2
- package/lib/typescript/utils/array.d.ts +1 -0
- package/lib/typescript/utils/hooks/app-state.d.ts +5 -0
- package/lib/typescript/utils/hooks/core/backup.d.ts +1 -1
- package/lib/typescript/utils/hooks/core/credentials.d.ts +1 -1
- package/lib/typescript/utils/hooks/core/identifiers.d.ts +1 -1
- package/lib/typescript/utils/hooks/core/index.d.ts +1 -0
- package/lib/typescript/utils/hooks/core/proofs.d.ts +6 -7
- package/lib/typescript/utils/hooks/core/wallet-unit.d.ts +9 -0
- package/lib/typescript/utils/hooks/index.d.ts +1 -0
- package/lib/typescript/utils/index.d.ts +2 -1
- package/lib/typescript/utils/parsers/credential-sharing-v2.d.ts +11 -0
- package/lib/typescript/utils/parsers/credential-sharing.d.ts +11 -5
- package/lib/typescript/utils/parsers/credential.d.ts +9 -6
- package/lib/typescript/utils/parsers/index.d.ts +1 -0
- package/lib/typescript/utils/parsers/query.d.ts +2 -2
- package/lib/typescript/utils/wallet-unit.d.ts +8 -0
- package/package.json +12 -6
- package/src/components/credential/credential.tsx +5 -1
- package/src/components/proof-request/index.ts +4 -3
- package/src/components/proof-request/select-share-credential-card-notice.tsx +37 -0
- package/src/components/proof-request/share-credential-card-notice.tsx +33 -0
- package/src/components/proof-request/{group.tsx → v1/group.tsx} +1 -1
- package/src/components/proof-request/v1/index.ts +3 -0
- package/src/components/proof-request/{select-credential.tsx → v1/select-credential.tsx} +12 -5
- package/src/components/proof-request/{share-credential.tsx → v1/share-credential.tsx} +35 -52
- package/src/components/proof-request/v2/index.ts +3 -0
- package/src/components/proof-request/v2/select-credential-v2.tsx +59 -0
- package/src/components/proof-request/v2/share-credential-v2-group.tsx +258 -0
- package/src/components/proof-request/v2/share-credential-v2.tsx +211 -0
- package/src/ui-components/buttons/share-button.tsx +1 -1
- package/src/ui-components/camera/qr-code-scanner.tsx +11 -2
- package/src/ui-components/credential/card/credential-details-list-item.tsx +27 -49
- package/src/ui-components/credential/credential-attribute-item.tsx +2 -0
- package/src/ui-components/credential/group/credential-group-header.tsx +70 -0
- package/src/ui-components/credential/group/index.ts +4 -0
- package/src/ui-components/credential/index.ts +1 -0
- package/src/ui-components/header/foldable-header.tsx +31 -16
- package/src/ui-components/index.ts +1 -0
- package/src/ui-components/loader/loading-result.tsx +1 -1
- package/src/ui-components/pin/pin-lock-animation.tsx +240 -278
- package/src/ui-components/proof-request/index.ts +4 -0
- package/src/ui-components/proof-request/proof-request-set.tsx +46 -0
- package/src/ui-components/screens/section-list-screen.tsx +18 -4
- package/src/utils/array.ts +4 -0
- package/src/utils/hooks/app-state.ts +29 -0
- package/src/utils/hooks/core/backup.ts +2 -5
- package/src/utils/hooks/core/credentials.ts +11 -4
- package/src/utils/hooks/core/identifiers.ts +15 -14
- package/src/utils/hooks/core/index.ts +2 -1
- package/src/utils/hooks/core/proofs.ts +36 -12
- package/src/utils/hooks/core/wallet-unit.ts +77 -0
- package/src/utils/hooks/index.ts +1 -0
- package/src/utils/hooks/revocation/credential-status.ts +1 -1
- package/src/utils/index.ts +2 -1
- package/src/utils/parsers/credential-sharing-v2.tsx +283 -0
- package/src/utils/parsers/credential-sharing.tsx +40 -16
- package/src/utils/parsers/credential.ts +129 -59
- package/src/utils/parsers/index.ts +1 -0
- package/src/utils/parsers/query.ts +6 -5
- package/src/utils/wallet-unit.ts +30 -0
- package/lib/commonjs/components/proof-request/group.js.map +0 -1
- package/lib/commonjs/components/proof-request/select-credential.js.map +0 -1
- package/lib/commonjs/components/proof-request/share-credential.js.map +0 -1
- package/lib/module/components/proof-request/group.js.map +0 -1
- package/lib/module/components/proof-request/select-credential.js.map +0 -1
- package/lib/module/components/proof-request/share-credential.js +0 -147
- package/lib/module/components/proof-request/share-credential.js.map +0 -1
- /package/lib/typescript/components/proof-request/{group.d.ts → v1/group.d.ts} +0 -0
|
@@ -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} /> :
|
|
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}
|
package/src/utils/array.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 ('
|
|
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
|
|
2
|
-
import { useQuery } from
|
|
1
|
+
import { IdentifierListQuery, IdentifierStateEnum, IdentifierTypeEnum } from '@procivis/react-native-one-core';
|
|
2
|
+
import { useQuery } from 'react-query';
|
|
3
3
|
|
|
4
|
-
import { getQueryKeyFromIdentifierListQueryParams } from
|
|
5
|
-
import { useONECore } from
|
|
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 }) =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
};
|
|
@@ -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
|
-
|
|
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 (
|
|
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(
|
|
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
|
+
};
|
package/src/utils/hooks/index.ts
CHANGED
|
@@ -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
|
-
|
|
21
|
+
states: [CredentialStateEnum.ACCEPTED, CredentialStateEnum.SUSPENDED],
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const checkCredentialsStatus = useCallback(async () => {
|
package/src/utils/index.ts
CHANGED
|
@@ -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 './
|
|
21
|
+
export * from './wallet-unit';
|