@procivis/one-react-native-components 0.3.102 → 0.3.112
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/backup/preview-credentials.js.map +1 -1
- package/lib/commonjs/components/credential/credential.js.map +1 -1
- package/lib/commonjs/components/entity/EntityButtons.js.map +1 -1
- package/lib/commonjs/components/entity/entity-attributes.js.map +1 -1
- package/lib/commonjs/components/entity/entity-details-with-buttons.js +2 -2
- package/lib/commonjs/components/entity/entity-details-with-buttons.js.map +1 -1
- package/lib/commonjs/components/entity/entity-details.js +3 -3
- package/lib/commonjs/components/entity/entity-details.js.map +1 -1
- package/lib/commonjs/components/history/history-details-screen.js +10 -10
- package/lib/commonjs/components/history/history-details-screen.js.map +1 -1
- package/lib/commonjs/components/history/history-list-item-icon.js +15 -8
- package/lib/commonjs/components/history/history-list-item-icon.js.map +1 -1
- package/lib/commonjs/components/history/history-list-item.js.map +1 -1
- package/lib/commonjs/components/history/history-list-screen.js.map +1 -1
- package/lib/commonjs/components/history/history-list-section-header.js +1 -1
- package/lib/commonjs/components/history/history-list-section-header.js.map +1 -1
- package/lib/commonjs/components/history/history-list.js.map +1 -1
- package/lib/commonjs/components/proof-request/v1/select-credential.js.map +1 -1
- package/lib/commonjs/components/proof-request/v1/share-credential.js +3 -15
- package/lib/commonjs/components/proof-request/v1/share-credential.js.map +1 -1
- package/lib/commonjs/components/proof-request/v2/select-credential-v2.js.map +1 -1
- package/lib/commonjs/components/proof-request/v2/share-credential-v2-group.js.map +1 -1
- package/lib/commonjs/components/proof-request/v2/share-credential-v2.js.map +1 -1
- package/lib/commonjs/ui-components/control/checkbox.js +1 -1
- package/lib/commonjs/ui-components/control/checkbox.js.map +1 -1
- package/lib/commonjs/ui-components/control/switch.js +2 -2
- package/lib/commonjs/ui-components/control/switch.js.map +1 -1
- package/lib/commonjs/ui-components/header/foldable-header.js +26 -16
- package/lib/commonjs/ui-components/header/foldable-header.js.map +1 -1
- package/lib/commonjs/ui-components/history/history-section-header.js +1 -1
- package/lib/commonjs/ui-components/history/history-section-header.js.map +1 -1
- package/lib/commonjs/ui-components/history/history-section-list-item.js +1 -1
- package/lib/commonjs/ui-components/history/history-section-list-item.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/notice/index.js +14 -0
- package/lib/commonjs/ui-components/notice/index.js.map +1 -0
- package/lib/commonjs/ui-components/notice/wallet-notice.js +80 -0
- package/lib/commonjs/ui-components/notice/wallet-notice.js.map +1 -0
- package/lib/commonjs/ui-components/screens/nerd-mode-screen.js.map +1 -1
- package/lib/commonjs/utils/history.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/backup.js +2 -2
- package/lib/commonjs/utils/hooks/core/backup.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/cache.js +10 -10
- package/lib/commonjs/utils/hooks/core/cache.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/core-config.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/credential-schemas.js +1 -1
- package/lib/commonjs/utils/hooks/core/credential-schemas.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/credentials.js +4 -4
- package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/dids.js +2 -2
- package/lib/commonjs/utils/hooks/core/dids.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/history.js +1 -1
- package/lib/commonjs/utils/hooks/core/history.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/identifiers.js +2 -2
- 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/proof-schemas.js +1 -1
- package/lib/commonjs/utils/hooks/core/proof-schemas.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/proofs.js +23 -13
- package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/trust-entity.js +1 -1
- package/lib/commonjs/utils/hooks/core/trust-entity.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/trust-list.js +32 -0
- package/lib/commonjs/utils/hooks/core/trust-list.js.map +1 -0
- package/lib/commonjs/utils/hooks/core/wallet-unit.js +30 -2
- package/lib/commonjs/utils/hooks/core/wallet-unit.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/parsers/credential-images.js +4 -4
- package/lib/commonjs/utils/parsers/credential-images.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing-v2.js +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing-v2.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing.js +4 -10
- package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential.js +9 -9
- package/lib/commonjs/utils/parsers/credential.js.map +1 -1
- package/lib/commonjs/utils/parsers/query.js.map +1 -1
- package/lib/module/components/backup/preview-credentials.js.map +1 -1
- package/lib/module/components/credential/credential.js.map +1 -1
- package/lib/module/components/entity/EntityButtons.js.map +1 -1
- package/lib/module/components/entity/entity-attributes.js.map +1 -1
- package/lib/module/components/entity/entity-details-with-buttons.js +3 -3
- package/lib/module/components/entity/entity-details-with-buttons.js.map +1 -1
- package/lib/module/components/entity/entity-details.js +4 -4
- package/lib/module/components/entity/entity-details.js.map +1 -1
- package/lib/module/components/history/history-details-screen.js +11 -11
- package/lib/module/components/history/history-details-screen.js.map +1 -1
- package/lib/module/components/history/history-list-item-icon.js +16 -9
- package/lib/module/components/history/history-list-item-icon.js.map +1 -1
- package/lib/module/components/history/history-list-item.js.map +1 -1
- package/lib/module/components/history/history-list-screen.js.map +1 -1
- package/lib/module/components/history/history-list-section-header.js +1 -1
- package/lib/module/components/history/history-list-section-header.js.map +1 -1
- package/lib/module/components/history/history-list.js.map +1 -1
- package/lib/module/components/proof-request/v1/select-credential.js.map +1 -1
- package/lib/module/components/proof-request/v1/share-credential.js +4 -16
- package/lib/module/components/proof-request/v1/share-credential.js.map +1 -1
- package/lib/module/components/proof-request/v2/select-credential-v2.js.map +1 -1
- package/lib/module/components/proof-request/v2/share-credential-v2-group.js.map +1 -1
- package/lib/module/components/proof-request/v2/share-credential-v2.js.map +1 -1
- package/lib/module/ui-components/control/checkbox.js +1 -1
- package/lib/module/ui-components/control/checkbox.js.map +1 -1
- package/lib/module/ui-components/control/switch.js +3 -3
- package/lib/module/ui-components/control/switch.js.map +1 -1
- package/lib/module/ui-components/header/foldable-header.js +26 -16
- package/lib/module/ui-components/header/foldable-header.js.map +1 -1
- package/lib/module/ui-components/history/history-section-header.js +1 -1
- package/lib/module/ui-components/history/history-section-header.js.map +1 -1
- package/lib/module/ui-components/history/history-section-list-item.js +1 -1
- package/lib/module/ui-components/history/history-section-list-item.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/notice/index.js +3 -0
- package/lib/module/ui-components/notice/index.js.map +1 -0
- package/lib/module/ui-components/notice/wallet-notice.js +72 -0
- package/lib/module/ui-components/notice/wallet-notice.js.map +1 -0
- package/lib/module/ui-components/screens/nerd-mode-screen.js.map +1 -1
- package/lib/module/utils/history.js.map +1 -1
- package/lib/module/utils/hooks/core/backup.js +3 -3
- package/lib/module/utils/hooks/core/backup.js.map +1 -1
- package/lib/module/utils/hooks/core/cache.js +11 -11
- package/lib/module/utils/hooks/core/cache.js.map +1 -1
- package/lib/module/utils/hooks/core/core-config.js.map +1 -1
- package/lib/module/utils/hooks/core/credential-schemas.js +1 -1
- package/lib/module/utils/hooks/core/credential-schemas.js.map +1 -1
- package/lib/module/utils/hooks/core/credentials.js +5 -5
- package/lib/module/utils/hooks/core/credentials.js.map +1 -1
- package/lib/module/utils/hooks/core/dids.js +3 -3
- package/lib/module/utils/hooks/core/dids.js.map +1 -1
- package/lib/module/utils/hooks/core/history.js +1 -1
- package/lib/module/utils/hooks/core/history.js.map +1 -1
- package/lib/module/utils/hooks/core/identifiers.js +3 -3
- 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/proof-schemas.js +1 -1
- package/lib/module/utils/hooks/core/proof-schemas.js.map +1 -1
- package/lib/module/utils/hooks/core/proofs.js +24 -14
- package/lib/module/utils/hooks/core/proofs.js.map +1 -1
- package/lib/module/utils/hooks/core/trust-entity.js +2 -2
- package/lib/module/utils/hooks/core/trust-entity.js.map +1 -1
- package/lib/module/utils/hooks/core/trust-list.js +24 -0
- package/lib/module/utils/hooks/core/trust-list.js.map +1 -0
- package/lib/module/utils/hooks/core/wallet-unit.js +28 -2
- package/lib/module/utils/hooks/core/wallet-unit.js.map +1 -1
- package/lib/module/utils/hooks/revocation/credential-status.js +2 -2
- package/lib/module/utils/hooks/revocation/credential-status.js.map +1 -1
- package/lib/module/utils/parsers/credential-images.js +5 -5
- package/lib/module/utils/parsers/credential-images.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing-v2.js +1 -1
- package/lib/module/utils/parsers/credential-sharing-v2.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing.js +4 -10
- package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/module/utils/parsers/credential.js +10 -10
- package/lib/module/utils/parsers/credential.js.map +1 -1
- package/lib/module/utils/parsers/query.js.map +1 -1
- package/lib/typescript/components/backup/preview-credentials.d.ts +2 -2
- package/lib/typescript/components/credential/credential.d.ts +2 -2
- package/lib/typescript/components/entity/EntityButtons.d.ts +2 -2
- package/lib/typescript/components/entity/entity-attributes.d.ts +2 -2
- package/lib/typescript/components/entity/entity-details-with-buttons.d.ts +3 -3
- package/lib/typescript/components/entity/entity-details.d.ts +5 -5
- package/lib/typescript/components/history/history-details-screen.d.ts +2 -2
- package/lib/typescript/components/history/history-list-item-icon.d.ts +3 -3
- package/lib/typescript/components/history/history-list-item.d.ts +5 -5
- package/lib/typescript/components/history/history-list-screen.d.ts +4 -4
- package/lib/typescript/components/history/history-list.d.ts +5 -5
- package/lib/typescript/components/proof-request/v1/select-credential.d.ts +2 -2
- package/lib/typescript/components/proof-request/v1/share-credential.d.ts +6 -6
- package/lib/typescript/components/proof-request/v2/select-credential-v2.d.ts +3 -3
- package/lib/typescript/components/proof-request/v2/share-credential-v2-group.d.ts +4 -4
- package/lib/typescript/components/proof-request/v2/share-credential-v2.d.ts +5 -5
- package/lib/typescript/ui-components/control/checkbox.d.ts +1 -1
- package/lib/typescript/ui-components/index.d.ts +1 -0
- package/lib/typescript/ui-components/notice/index.d.ts +2 -0
- package/lib/typescript/ui-components/notice/wallet-notice.d.ts +11 -0
- package/lib/typescript/ui-components/screens/nerd-mode-screen.d.ts +2 -2
- package/lib/typescript/utils/history.d.ts +3 -3
- package/lib/typescript/utils/hooks/core/backup.d.ts +3 -3
- package/lib/typescript/utils/hooks/core/cache.d.ts +2 -2
- package/lib/typescript/utils/hooks/core/core-config.d.ts +4 -4
- package/lib/typescript/utils/hooks/core/credential-schemas.d.ts +6 -6
- package/lib/typescript/utils/hooks/core/credentials.d.ts +8 -8
- package/lib/typescript/utils/hooks/core/dids.d.ts +2 -2
- package/lib/typescript/utils/hooks/core/history.d.ts +2 -2
- package/lib/typescript/utils/hooks/core/identifiers.d.ts +3 -3
- package/lib/typescript/utils/hooks/core/index.d.ts +1 -0
- package/lib/typescript/utils/hooks/core/proof-schemas.d.ts +7 -7
- package/lib/typescript/utils/hooks/core/proofs.d.ts +14 -12
- package/lib/typescript/utils/hooks/core/trust-entity.d.ts +5 -5
- package/lib/typescript/utils/hooks/core/trust-list.d.ts +5 -0
- package/lib/typescript/utils/hooks/core/wallet-unit.d.ts +11 -5
- package/lib/typescript/utils/parsers/credential-images.d.ts +2 -2
- package/lib/typescript/utils/parsers/credential-sharing-v2.d.ts +7 -7
- package/lib/typescript/utils/parsers/credential-sharing.d.ts +8 -8
- package/lib/typescript/utils/parsers/credential.d.ts +11 -11
- package/lib/typescript/utils/parsers/query.d.ts +8 -8
- package/package.json +3 -3
- package/src/components/backup/preview-credentials.tsx +2 -2
- package/src/components/credential/credential.tsx +2 -2
- package/src/components/entity/EntityButtons.tsx +2 -2
- package/src/components/entity/entity-attributes.tsx +2 -2
- package/src/components/entity/entity-details-with-buttons.tsx +6 -11
- package/src/components/entity/entity-details.tsx +16 -17
- package/src/components/history/history-details-screen.tsx +13 -13
- package/src/components/history/history-list-item-icon.tsx +18 -15
- package/src/components/history/history-list-item.tsx +5 -9
- package/src/components/history/history-list-screen.tsx +4 -4
- package/src/components/history/history-list-section-header.tsx +1 -1
- package/src/components/history/history-list.tsx +6 -6
- package/src/components/proof-request/v1/select-credential.tsx +2 -2
- package/src/components/proof-request/v1/share-credential.tsx +12 -31
- package/src/components/proof-request/v2/select-credential-v2.tsx +3 -6
- package/src/components/proof-request/v2/share-credential-v2-group.tsx +10 -10
- package/src/components/proof-request/v2/share-credential-v2.tsx +9 -9
- package/src/ui-components/control/checkbox.tsx +12 -10
- package/src/ui-components/control/switch.tsx +23 -21
- package/src/ui-components/detail/detail.stories.tsx +1 -1
- package/src/ui-components/header/foldable-header.tsx +27 -20
- package/src/ui-components/history/history-section-header.tsx +1 -1
- package/src/ui-components/history/history-section-list-item.tsx +1 -1
- package/src/ui-components/index.ts +1 -0
- package/src/ui-components/notice/index.ts +3 -0
- package/src/ui-components/notice/wallet-notice.tsx +82 -0
- package/src/ui-components/screens/nerd-mode-screen.tsx +2 -2
- package/src/utils/history.ts +4 -4
- package/src/utils/hooks/core/backup.ts +3 -3
- package/src/utils/hooks/core/cache.ts +13 -13
- package/src/utils/hooks/core/core-config.ts +3 -3
- package/src/utils/hooks/core/credential-schemas.ts +5 -8
- package/src/utils/hooks/core/credentials.ts +14 -22
- package/src/utils/hooks/core/dids.ts +4 -4
- package/src/utils/hooks/core/history.ts +3 -3
- package/src/utils/hooks/core/identifiers.ts +4 -8
- package/src/utils/hooks/core/index.ts +1 -0
- package/src/utils/hooks/core/proof-schemas.ts +16 -22
- package/src/utils/hooks/core/proofs.ts +43 -36
- package/src/utils/hooks/core/trust-entity.ts +8 -10
- package/src/utils/hooks/core/trust-list.ts +29 -0
- package/src/utils/hooks/core/wallet-unit.ts +38 -12
- package/src/utils/hooks/revocation/credential-status.ts +2 -2
- package/src/utils/parsers/credential-images.tsx +7 -11
- package/src/utils/parsers/credential-sharing-v2.tsx +20 -23
- package/src/utils/parsers/credential-sharing.tsx +29 -38
- package/src/utils/parsers/credential.ts +43 -43
- package/src/utils/parsers/query.ts +14 -16
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
HolderWalletUnit,
|
|
3
|
+
HolderWalletUnitUpdateRequest,
|
|
4
|
+
WalletProvider,
|
|
5
|
+
WalletUnitStatus,
|
|
5
6
|
} from '@procivis/react-native-one-core';
|
|
6
7
|
import { useEffect } from 'react';
|
|
7
8
|
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
|
@@ -10,11 +11,9 @@ import { reportException } from '../../reporting';
|
|
|
10
11
|
import { useONECore } from './core-context';
|
|
11
12
|
|
|
12
13
|
export const WALLET_UNIT_QUERY_KEY = 'wallet-unit';
|
|
14
|
+
export const WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY = 'wallet-unit-trust-collections';
|
|
13
15
|
|
|
14
|
-
export const useWalletUnitDetail = (
|
|
15
|
-
walletUnitId: HolderWalletUnitResponseBindingDto['id'] | undefined,
|
|
16
|
-
active = true,
|
|
17
|
-
) => {
|
|
16
|
+
export const useWalletUnitDetail = (walletUnitId: HolderWalletUnit['id'] | undefined, active = true) => {
|
|
18
17
|
const { core } = useONECore();
|
|
19
18
|
|
|
20
19
|
return useQuery(
|
|
@@ -27,12 +26,25 @@ export const useWalletUnitDetail = (
|
|
|
27
26
|
);
|
|
28
27
|
};
|
|
29
28
|
|
|
29
|
+
export const useWalletUnitTrustCollections = (walletUnitId: HolderWalletUnit['id'] | undefined, active = true) => {
|
|
30
|
+
const { core } = useONECore();
|
|
31
|
+
|
|
32
|
+
return useQuery(
|
|
33
|
+
[WALLET_UNIT_TRUST_COLLECTIONS_QUERY_KEY, walletUnitId],
|
|
34
|
+
() => (walletUnitId ? core.holderGetWalletUnitTrustCollections(walletUnitId) : undefined),
|
|
35
|
+
{
|
|
36
|
+
enabled: active && Boolean(walletUnitId),
|
|
37
|
+
keepPreviousData: true,
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
30
42
|
export const useRegisterWalletUnit = () => {
|
|
31
43
|
const queryClient = useQueryClient();
|
|
32
44
|
const { core, organisationId } = useONECore();
|
|
33
45
|
|
|
34
46
|
return useMutation(
|
|
35
|
-
async (walletProvider:
|
|
47
|
+
async (walletProvider: WalletProvider) =>
|
|
36
48
|
core.holderRegisterWalletUnit({
|
|
37
49
|
keyType: 'ECDSA',
|
|
38
50
|
organisationId,
|
|
@@ -49,11 +61,25 @@ export const useWalletUnitStatus = () => {
|
|
|
49
61
|
const queryClient = useQueryClient();
|
|
50
62
|
const { core } = useONECore();
|
|
51
63
|
|
|
64
|
+
return useMutation(async (walletUnitId: HolderWalletUnit['id']) => core.holderWalletUnitStatus(walletUnitId), {
|
|
65
|
+
onError: async (err) => {
|
|
66
|
+
reportException(err, 'Refresh wallet unit failure');
|
|
67
|
+
await queryClient.invalidateQueries(WALLET_UNIT_QUERY_KEY);
|
|
68
|
+
},
|
|
69
|
+
onSuccess: () => queryClient.invalidateQueries(WALLET_UNIT_QUERY_KEY),
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const useWalletUnitUpdate = () => {
|
|
74
|
+
const queryClient = useQueryClient();
|
|
75
|
+
const { core } = useONECore();
|
|
76
|
+
|
|
52
77
|
return useMutation(
|
|
53
|
-
async (walletUnitId:
|
|
78
|
+
async ({ walletUnitId, update }: { walletUnitId: HolderWalletUnit['id']; update: HolderWalletUnitUpdateRequest }) =>
|
|
79
|
+
core.holderWalletUnitUpdate(walletUnitId, update),
|
|
54
80
|
{
|
|
55
81
|
onError: async (err) => {
|
|
56
|
-
reportException(err, '
|
|
82
|
+
reportException(err, 'Update wallet unit failure');
|
|
57
83
|
await queryClient.invalidateQueries(WALLET_UNIT_QUERY_KEY);
|
|
58
84
|
},
|
|
59
85
|
onSuccess: () => queryClient.invalidateQueries(WALLET_UNIT_QUERY_KEY),
|
|
@@ -61,7 +87,7 @@ export const useWalletUnitStatus = () => {
|
|
|
61
87
|
);
|
|
62
88
|
};
|
|
63
89
|
|
|
64
|
-
export const useWalletUnitCheck = (walletUnitId:
|
|
90
|
+
export const useWalletUnitCheck = (walletUnitId: HolderWalletUnit['id'] | undefined) => {
|
|
65
91
|
const { data: walletUnitDetail, isLoading } = useWalletUnitDetail(walletUnitId);
|
|
66
92
|
const { mutateAsync: refreshWalletUnit, isLoading: isRefreshing, status: refreshStatus } = useWalletUnitStatus();
|
|
67
93
|
|
|
@@ -69,7 +95,7 @@ export const useWalletUnitCheck = (walletUnitId: HolderWalletUnitResponseBinding
|
|
|
69
95
|
if (isLoading || refreshStatus !== 'idle') {
|
|
70
96
|
return;
|
|
71
97
|
}
|
|
72
|
-
if (walletUnitId && walletUnitDetail?.status ===
|
|
98
|
+
if (walletUnitId && walletUnitDetail?.status === WalletUnitStatus.ACTIVE) {
|
|
73
99
|
void refreshWalletUnit(walletUnitId);
|
|
74
100
|
}
|
|
75
101
|
}, [isLoading, refreshStatus, walletUnitDetail, refreshWalletUnit, walletUnitId]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CredentialState } from '@procivis/react-native-one-core';
|
|
2
2
|
import { useIsFocused } from '@react-navigation/native';
|
|
3
3
|
import { useCallback, useRef } from 'react';
|
|
4
4
|
|
|
@@ -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
|
-
states: [
|
|
21
|
+
states: [CredentialState.ACCEPTED, CredentialState.SUSPENDED],
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
const checkCredentialsStatus = useCallback(async () => {
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ClaimBindingDto,
|
|
3
|
-
CredentialSchemaCodeTypeBindingDto,
|
|
4
|
-
CredentialSchemaLayoutPropertiesBindingDto,
|
|
5
|
-
} from '@procivis/react-native-one-core';
|
|
1
|
+
import { Claim, CredentialSchemaCodeType, CredentialSchemaLayoutProperties } from '@procivis/react-native-one-core';
|
|
6
2
|
import React from 'react';
|
|
7
3
|
import { StyleSheet } from 'react-native';
|
|
8
4
|
|
|
@@ -21,8 +17,8 @@ const styles = StyleSheet.create({
|
|
|
21
17
|
});
|
|
22
18
|
|
|
23
19
|
export const getCarouselImagesFromClaims = (
|
|
24
|
-
claims:
|
|
25
|
-
layoutProperties?:
|
|
20
|
+
claims: Claim[],
|
|
21
|
+
layoutProperties?: CredentialSchemaLayoutProperties,
|
|
26
22
|
testID?: string,
|
|
27
23
|
): CarouselImage[] => {
|
|
28
24
|
const result: CarouselImage[] = [];
|
|
@@ -54,7 +50,7 @@ export const getCarouselImagesFromClaims = (
|
|
|
54
50
|
|
|
55
51
|
let claimValue = '';
|
|
56
52
|
|
|
57
|
-
if (claim && (claim.value.type_ === 'FLOAT' || claim.value.type_ === 'INTEGER')) {
|
|
53
|
+
if (claim && (claim.value.type_ === 'FLOAT' || claim.value.type_ === 'INTEGER' || claim.value.type_ === 'STRING')) {
|
|
58
54
|
claimValue = String(claim.value.value);
|
|
59
55
|
}
|
|
60
56
|
|
|
@@ -62,17 +58,17 @@ export const getCarouselImagesFromClaims = (
|
|
|
62
58
|
return result;
|
|
63
59
|
}
|
|
64
60
|
|
|
65
|
-
if (code.type ===
|
|
61
|
+
if (code.type === CredentialSchemaCodeType.QR_CODE) {
|
|
66
62
|
result.push({
|
|
67
63
|
element: <QrCode content={claimValue} testID={concatTestID(testID, CarouselImageType.QrCode)} />,
|
|
68
64
|
type: CarouselImageType.QrCode,
|
|
69
65
|
});
|
|
70
|
-
} else if (code.type ===
|
|
66
|
+
} else if (code.type === CredentialSchemaCodeType.BARCODE && isASCII(claimValue)) {
|
|
71
67
|
result.push({
|
|
72
68
|
element: <Barcode content={claimValue} testID={concatTestID(testID, CarouselImageType.Barcode)} />,
|
|
73
69
|
type: CarouselImageType.Barcode,
|
|
74
70
|
});
|
|
75
|
-
} else if (code.type ===
|
|
71
|
+
} else if (code.type === CredentialSchemaCodeType.MRZ) {
|
|
76
72
|
result.push({
|
|
77
73
|
element: <Mrz content={claimValue} testID={concatTestID(testID, CarouselImageType.MRZ)} />,
|
|
78
74
|
type: CarouselImageType.MRZ,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
Claim,
|
|
3
|
+
ClaimValue,
|
|
4
|
+
CoreConfig,
|
|
5
|
+
CredentialQueryFailureHint,
|
|
6
|
+
PresentationDefinitionV2Claim,
|
|
7
|
+
PresentationDefinitionV2ClaimValue,
|
|
8
|
+
PresentationDefinitionV2Credential,
|
|
9
9
|
} from '@procivis/react-native-one-core';
|
|
10
10
|
import React from 'react';
|
|
11
11
|
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from '.';
|
|
28
28
|
import { ShareCredentialCardLabels, validityCheckedCardFromCredential } from './credential-sharing';
|
|
29
29
|
|
|
30
|
-
const v2ClaimValueToClaimValue = (value:
|
|
30
|
+
const v2ClaimValueToClaimValue = (value: PresentationDefinitionV2ClaimValue): ClaimValue => {
|
|
31
31
|
if (value.type_ !== 'NESTED') {
|
|
32
32
|
return value;
|
|
33
33
|
}
|
|
@@ -37,7 +37,7 @@ const v2ClaimValueToClaimValue = (value: PresentationDefinitionV2ClaimValueBindi
|
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const v2PresentationClaimToClaim = (claim:
|
|
40
|
+
const v2PresentationClaimToClaim = (claim: PresentationDefinitionV2Claim): Claim => {
|
|
41
41
|
return {
|
|
42
42
|
schema: claim.schema,
|
|
43
43
|
path: claim.path,
|
|
@@ -46,7 +46,7 @@ const v2PresentationClaimToClaim = (claim: PresentationDefinitionV2ClaimBindingD
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
const getAttributeSelectorStatus = (
|
|
49
|
-
claim:
|
|
49
|
+
claim: PresentationDefinitionV2Claim,
|
|
50
50
|
selected: boolean,
|
|
51
51
|
force: boolean,
|
|
52
52
|
): SelectorStatus | undefined => {
|
|
@@ -66,11 +66,11 @@ const getAttributeSelectorStatus = (
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
export const shareCredentialCardAttributeFromV2Claim = (
|
|
69
|
-
claim:
|
|
69
|
+
claim: PresentationDefinitionV2Claim,
|
|
70
70
|
selection: string[] | undefined,
|
|
71
71
|
parentShared: boolean,
|
|
72
72
|
parentUserSelected: boolean,
|
|
73
|
-
config:
|
|
73
|
+
config: CoreConfig,
|
|
74
74
|
testID: string,
|
|
75
75
|
nested?: boolean,
|
|
76
76
|
listValue?: boolean,
|
|
@@ -133,7 +133,7 @@ export const shareCredentialCardAttributeFromV2Claim = (
|
|
|
133
133
|
};
|
|
134
134
|
|
|
135
135
|
export const missingCredentialCardFromFailureHint = (
|
|
136
|
-
failureHint:
|
|
136
|
+
failureHint: CredentialQueryFailureHint | undefined,
|
|
137
137
|
notice: CredentialCardNotice | undefined,
|
|
138
138
|
testID: string,
|
|
139
139
|
labels: ShareCredentialCardLabels,
|
|
@@ -154,12 +154,12 @@ export const missingCredentialCardFromFailureHint = (
|
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
export const shareCredentialCardFromV2PresentationCredential = (
|
|
157
|
-
credential:
|
|
158
|
-
failureHint:
|
|
157
|
+
credential: PresentationDefinitionV2Credential | undefined,
|
|
158
|
+
failureHint: CredentialQueryFailureHint | undefined,
|
|
159
159
|
expanded: boolean,
|
|
160
160
|
multipleCredentialsAvailable: boolean,
|
|
161
161
|
selectedFields: string[] | undefined,
|
|
162
|
-
config:
|
|
162
|
+
config: CoreConfig,
|
|
163
163
|
testID: string,
|
|
164
164
|
labels: ShareCredentialCardLabels,
|
|
165
165
|
): CredentialDetailsCardPropsWithoutWidth => {
|
|
@@ -181,7 +181,6 @@ export const shareCredentialCardFromV2PresentationCredential = (
|
|
|
181
181
|
...credential,
|
|
182
182
|
claims: [],
|
|
183
183
|
},
|
|
184
|
-
false,
|
|
185
184
|
expanded,
|
|
186
185
|
multipleCredentialsAvailable,
|
|
187
186
|
config,
|
|
@@ -201,10 +200,10 @@ export const shareCredentialCardFromV2PresentationCredential = (
|
|
|
201
200
|
};
|
|
202
201
|
|
|
203
202
|
export const selectCredentialCardFromV2Credential = (
|
|
204
|
-
credential:
|
|
203
|
+
credential: PresentationDefinitionV2Credential,
|
|
205
204
|
selected: boolean,
|
|
206
205
|
multiple: boolean,
|
|
207
|
-
config:
|
|
206
|
+
config: CoreConfig,
|
|
208
207
|
testID: string,
|
|
209
208
|
labels: ShareCredentialCardLabels,
|
|
210
209
|
): CredentialDetailsCardPropsWithoutWidth => {
|
|
@@ -248,15 +247,13 @@ export const selectCredentialCardFromV2Credential = (
|
|
|
248
247
|
};
|
|
249
248
|
};
|
|
250
249
|
|
|
251
|
-
export const getV2CredentialClaimAllSubpaths = (claim:
|
|
250
|
+
export const getV2CredentialClaimAllSubpaths = (claim: PresentationDefinitionV2Claim): string[] => {
|
|
252
251
|
if (claim.value.type_ !== 'NESTED') {
|
|
253
252
|
return [claim.path];
|
|
254
253
|
}
|
|
255
254
|
return [claim.path, ...claim.value.value.flatMap(getV2CredentialClaimAllSubpaths)];
|
|
256
255
|
};
|
|
257
256
|
|
|
258
|
-
export const getV2CredentialAvailablePaths = (
|
|
259
|
-
credential: PresentationDefinitionV2CredentialDetailBindingDto,
|
|
260
|
-
): string[] => {
|
|
257
|
+
export const getV2CredentialAvailablePaths = (credential: PresentationDefinitionV2Credential): string[] => {
|
|
261
258
|
return credential.claims.flatMap(getV2CredentialClaimAllSubpaths);
|
|
262
259
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Claim,
|
|
3
|
+
CoreConfig,
|
|
4
|
+
CredentialDetail,
|
|
5
|
+
PresentationDefinitionField,
|
|
6
|
+
PresentationDefinitionRequestedCredential,
|
|
7
7
|
} from '@procivis/react-native-one-core';
|
|
8
8
|
import React from 'react';
|
|
9
9
|
|
|
@@ -29,11 +29,10 @@ import {
|
|
|
29
29
|
} from './credential';
|
|
30
30
|
|
|
31
31
|
export const validityCheckedCardFromCredential = (
|
|
32
|
-
credential:
|
|
33
|
-
invalidLVVC: boolean,
|
|
32
|
+
credential: CredentialDetail,
|
|
34
33
|
expanded: boolean,
|
|
35
34
|
multipleCredentialsAvailable: boolean,
|
|
36
|
-
config:
|
|
35
|
+
config: CoreConfig,
|
|
37
36
|
notice: CredentialCardNotice | undefined,
|
|
38
37
|
testID: string,
|
|
39
38
|
labels: ShareCredentialCardLabels,
|
|
@@ -48,13 +47,7 @@ export const validityCheckedCardFromCredential = (
|
|
|
48
47
|
| 'statusIcon'
|
|
49
48
|
>
|
|
50
49
|
| undefined;
|
|
51
|
-
if (
|
|
52
|
-
credentialHeaderDetail = {
|
|
53
|
-
credentialDetailErrorColor: true,
|
|
54
|
-
credentialDetailPrimary: labels.revoked,
|
|
55
|
-
credentialDetailTestID: concatTestID(testID, 'header.invalid'),
|
|
56
|
-
};
|
|
57
|
-
} else if (!expanded && multipleCredentialsAvailable) {
|
|
50
|
+
if (!expanded && multipleCredentialsAvailable) {
|
|
58
51
|
credentialHeaderDetail = {
|
|
59
52
|
credentialDetailPrimary: labels.multipleCredentials,
|
|
60
53
|
credentialDetailTestID: concatTestID(testID, 'header.multiple'),
|
|
@@ -73,7 +66,7 @@ export const validityCheckedCardFromCredential = (
|
|
|
73
66
|
};
|
|
74
67
|
|
|
75
68
|
export const missingCredentialCardFromRequest = (
|
|
76
|
-
request:
|
|
69
|
+
request: PresentationDefinitionRequestedCredential,
|
|
77
70
|
notice: CredentialCardNotice | undefined,
|
|
78
71
|
testID: string,
|
|
79
72
|
labels: ShareCredentialCardLabels,
|
|
@@ -95,17 +88,17 @@ export const missingCredentialCardFromRequest = (
|
|
|
95
88
|
|
|
96
89
|
interface DisplayedAttribute {
|
|
97
90
|
claim?: FlatClaim;
|
|
98
|
-
field?:
|
|
91
|
+
field?: PresentationDefinitionField;
|
|
99
92
|
id: string;
|
|
100
93
|
selected?: boolean;
|
|
101
94
|
status: SelectorStatus;
|
|
102
95
|
}
|
|
103
96
|
|
|
104
97
|
const getAttributeSelectorStatus = (
|
|
105
|
-
field:
|
|
98
|
+
field: PresentationDefinitionField,
|
|
106
99
|
validityState: ValidityState,
|
|
107
|
-
credential?:
|
|
108
|
-
claim?:
|
|
100
|
+
credential?: CredentialDetail,
|
|
101
|
+
claim?: Claim,
|
|
109
102
|
selected?: boolean,
|
|
110
103
|
): SelectorStatus => {
|
|
111
104
|
if (!credential || validityState !== ValidityState.Valid) {
|
|
@@ -124,12 +117,12 @@ const getAttributeSelectorStatus = (
|
|
|
124
117
|
return selected ? SelectorStatus.SelectedCheckmark : SelectorStatus.Empty;
|
|
125
118
|
};
|
|
126
119
|
|
|
127
|
-
type FlatClaim =
|
|
120
|
+
type FlatClaim = Claim & {
|
|
128
121
|
isArrayElement?: boolean;
|
|
129
122
|
};
|
|
130
123
|
|
|
131
124
|
// Returns a spread list of all claims with their full JSON path as key, including all intermediate objects
|
|
132
|
-
const spreadClaims = (claims:
|
|
125
|
+
const spreadClaims = (claims: Claim[]): FlatClaim[] => {
|
|
133
126
|
return claims.reduce((acc, claim) => {
|
|
134
127
|
const result = [claim];
|
|
135
128
|
if (claim.value.type_ === 'NESTED') {
|
|
@@ -144,9 +137,9 @@ const spreadClaims = (claims: ClaimBindingDto[]): FlatClaim[] => {
|
|
|
144
137
|
};
|
|
145
138
|
|
|
146
139
|
const getDisplayedAttributes = (
|
|
147
|
-
request:
|
|
140
|
+
request: PresentationDefinitionRequestedCredential,
|
|
148
141
|
validityState: ValidityState,
|
|
149
|
-
credential?:
|
|
142
|
+
credential?: CredentialDetail,
|
|
150
143
|
selectiveDisclosureSupported?: boolean,
|
|
151
144
|
selectedFields?: string[],
|
|
152
145
|
): DisplayedAttribute[] => {
|
|
@@ -179,8 +172,8 @@ const getDisplayedAttributes = (
|
|
|
179
172
|
};
|
|
180
173
|
|
|
181
174
|
const getFullyNestedFields = (
|
|
182
|
-
fields:
|
|
183
|
-
credentialId:
|
|
175
|
+
fields: PresentationDefinitionRequestedCredential['fields'],
|
|
176
|
+
credentialId: CredentialDetail['id'],
|
|
184
177
|
) => {
|
|
185
178
|
const allKeys = fields.filter((field) => credentialId in field.keyMap).map((field) => field.keyMap[credentialId]);
|
|
186
179
|
|
|
@@ -192,11 +185,11 @@ const getFullyNestedFields = (
|
|
|
192
185
|
|
|
193
186
|
export const shareCredentialCardAttributeFromClaim = (
|
|
194
187
|
id: string,
|
|
195
|
-
config:
|
|
188
|
+
config: CoreConfig,
|
|
196
189
|
testID: string,
|
|
197
190
|
labels: ShareCredentialCardLabels,
|
|
198
191
|
claim?: FlatClaim,
|
|
199
|
-
field?:
|
|
192
|
+
field?: PresentationDefinitionField,
|
|
200
193
|
): CredentialAttribute => {
|
|
201
194
|
if (claim) {
|
|
202
195
|
return {
|
|
@@ -257,13 +250,12 @@ export type ShareCredentialCardLabels = CardLabels & {
|
|
|
257
250
|
};
|
|
258
251
|
|
|
259
252
|
export const shareCredentialCardFromCredential = (
|
|
260
|
-
credential:
|
|
261
|
-
invalidLVVC: boolean,
|
|
253
|
+
credential: CredentialDetail | undefined,
|
|
262
254
|
expanded: boolean,
|
|
263
255
|
multipleCredentialsAvailable: boolean,
|
|
264
|
-
request:
|
|
256
|
+
request: PresentationDefinitionRequestedCredential,
|
|
265
257
|
selectedFields: string[] | undefined,
|
|
266
|
-
config:
|
|
258
|
+
config: CoreConfig,
|
|
267
259
|
testID: string,
|
|
268
260
|
labels: ShareCredentialCardLabels,
|
|
269
261
|
): CredentialDetailsCardPropsWithoutWidth => {
|
|
@@ -282,7 +274,6 @@ export const shareCredentialCardFromCredential = (
|
|
|
282
274
|
const card = credential
|
|
283
275
|
? validityCheckedCardFromCredential(
|
|
284
276
|
credential,
|
|
285
|
-
invalidLVVC,
|
|
286
277
|
expanded,
|
|
287
278
|
multipleCredentialsAvailable,
|
|
288
279
|
config,
|
|
@@ -325,11 +316,11 @@ export const shareCredentialCardFromCredential = (
|
|
|
325
316
|
|
|
326
317
|
export const selectCredentialCardAttributeFromClaim = (
|
|
327
318
|
id: string,
|
|
328
|
-
config:
|
|
319
|
+
config: CoreConfig,
|
|
329
320
|
testID: string,
|
|
330
321
|
labels: ShareCredentialCardLabels,
|
|
331
322
|
claim?: FlatClaim,
|
|
332
|
-
field?:
|
|
323
|
+
field?: PresentationDefinitionField,
|
|
333
324
|
): CredentialAttribute => {
|
|
334
325
|
const attribute = shareCredentialCardAttributeFromClaim(id, config, testID, labels, claim, field);
|
|
335
326
|
if (!claim) {
|
|
@@ -342,10 +333,10 @@ export const selectCredentialCardAttributeFromClaim = (
|
|
|
342
333
|
};
|
|
343
334
|
|
|
344
335
|
export const selectCredentialCardFromCredential = (
|
|
345
|
-
credential:
|
|
336
|
+
credential: CredentialDetail,
|
|
346
337
|
selected: boolean,
|
|
347
|
-
request:
|
|
348
|
-
config:
|
|
338
|
+
request: PresentationDefinitionRequestedCredential,
|
|
339
|
+
config: CoreConfig,
|
|
349
340
|
testID: string,
|
|
350
341
|
labels: ShareCredentialCardLabels,
|
|
351
342
|
): CredentialDetailsCardPropsWithoutWidth => {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
Claim,
|
|
3
|
+
CoreConfig,
|
|
4
|
+
CredentialDetail,
|
|
5
|
+
CredentialListItem,
|
|
6
|
+
CredentialSchemaListItem,
|
|
7
|
+
CredentialState,
|
|
8
|
+
DataType,
|
|
9
|
+
FormatFeature,
|
|
10
10
|
} from '@procivis/react-native-one-core';
|
|
11
11
|
import { FC } from 'react';
|
|
12
12
|
import { SvgProps } from 'react-native-svg';
|
|
@@ -30,27 +30,27 @@ export enum ValidityState {
|
|
|
30
30
|
Valid = 'valid',
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export const getValidityState = (credential:
|
|
34
|
-
if (credential?.state ===
|
|
33
|
+
export const getValidityState = (credential: CredentialListItem | undefined) => {
|
|
34
|
+
if (credential?.state === CredentialState.REVOKED) {
|
|
35
35
|
return ValidityState.Revoked;
|
|
36
36
|
}
|
|
37
|
-
if (credential?.state ===
|
|
37
|
+
if (credential?.state === CredentialState.SUSPENDED) {
|
|
38
38
|
return ValidityState.Suspended;
|
|
39
39
|
}
|
|
40
40
|
return ValidityState.Valid;
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
export const supportsSelectiveDisclosure = (
|
|
44
|
-
credential:
|
|
45
|
-
config:
|
|
44
|
+
credential: CredentialListItem | undefined,
|
|
45
|
+
config: CoreConfig | undefined,
|
|
46
46
|
) => {
|
|
47
47
|
const formatConfig = credential && config?.format[credential.schema.format];
|
|
48
48
|
return formatConfig
|
|
49
|
-
? Boolean(formatConfig.capabilities?.features?.includes(
|
|
49
|
+
? Boolean(formatConfig.capabilities?.features?.includes(FormatFeature.SelectiveDisclosure))
|
|
50
50
|
: undefined;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
export const findClaimByPath = (path: string | undefined, claims:
|
|
53
|
+
export const findClaimByPath = (path: string | undefined, claims: Claim[]): Claim | undefined => {
|
|
54
54
|
if (!path) {
|
|
55
55
|
return undefined;
|
|
56
56
|
}
|
|
@@ -68,12 +68,12 @@ export const findClaimByPath = (path: string | undefined, claims: ClaimBindingDt
|
|
|
68
68
|
return undefined;
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
const formatCredentialDetail = (claim:
|
|
71
|
+
const formatCredentialDetail = (claim: Claim, config: CoreConfig, testID: string): string => {
|
|
72
72
|
const attributeValue = detailsCardAttributeValueFromClaim(claim, config, testID);
|
|
73
73
|
return attributeValue.value ?? '';
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
export const hasMsoValidityIssues = (credential:
|
|
76
|
+
export const hasMsoValidityIssues = (credential: CredentialDetail): boolean => {
|
|
77
77
|
const mdocMsoValidityIssue = Boolean(
|
|
78
78
|
credential.mdocMsoValidity?.nextUpdate && new Date(credential.mdocMsoValidity.nextUpdate) < new Date(),
|
|
79
79
|
);
|
|
@@ -89,9 +89,9 @@ export type CardHeaderLabels = {
|
|
|
89
89
|
};
|
|
90
90
|
|
|
91
91
|
const credentialDetailFromCredential = (
|
|
92
|
-
credential:
|
|
93
|
-
claims:
|
|
94
|
-
config:
|
|
92
|
+
credential: CredentialDetail,
|
|
93
|
+
claims: Claim[] = [],
|
|
94
|
+
config: CoreConfig,
|
|
95
95
|
testID: string,
|
|
96
96
|
labels: CardHeaderLabels,
|
|
97
97
|
): {
|
|
@@ -104,7 +104,7 @@ const credentialDetailFromCredential = (
|
|
|
104
104
|
const { layoutProperties } = credential.schema;
|
|
105
105
|
|
|
106
106
|
switch (credential.state) {
|
|
107
|
-
case
|
|
107
|
+
case CredentialState.SUSPENDED:
|
|
108
108
|
return {
|
|
109
109
|
credentialDetailPrimary: credential.suspendEndDate
|
|
110
110
|
? labels.suspendedUntil(formatDateTimeLocalized(new Date(credential.suspendEndDate))!)
|
|
@@ -112,7 +112,7 @@ const credentialDetailFromCredential = (
|
|
|
112
112
|
credentialDetailTestID: concatTestID(testID, 'suspended'),
|
|
113
113
|
statusIcon: CredentialWarningIcon,
|
|
114
114
|
};
|
|
115
|
-
case
|
|
115
|
+
case CredentialState.REVOKED:
|
|
116
116
|
return {
|
|
117
117
|
credentialDetailPrimary: labels.revoked,
|
|
118
118
|
credentialDetailErrorColor: true,
|
|
@@ -153,9 +153,9 @@ const credentialDetailFromCredential = (
|
|
|
153
153
|
};
|
|
154
154
|
|
|
155
155
|
export const cardHeaderFromCredential = (
|
|
156
|
-
credential:
|
|
157
|
-
claims:
|
|
158
|
-
config:
|
|
156
|
+
credential: CredentialDetail,
|
|
157
|
+
claims: Claim[] = [],
|
|
158
|
+
config: CoreConfig,
|
|
159
159
|
testID: string,
|
|
160
160
|
labels: CardHeaderLabels,
|
|
161
161
|
): Omit<CredentialHeaderProps, 'style'> => {
|
|
@@ -193,9 +193,9 @@ export type CardLabels = CardHeaderLabels & {
|
|
|
193
193
|
};
|
|
194
194
|
|
|
195
195
|
export const getCredentialCardPropsFromCredential = (
|
|
196
|
-
credential:
|
|
197
|
-
claims:
|
|
198
|
-
config:
|
|
196
|
+
credential: CredentialDetail,
|
|
197
|
+
claims: Claim[] = [],
|
|
198
|
+
config: CoreConfig,
|
|
199
199
|
notice: CredentialCardNotice | undefined,
|
|
200
200
|
testID: string,
|
|
201
201
|
labels: CardLabels,
|
|
@@ -224,8 +224,8 @@ export const getCredentialCardPropsFromCredential = (
|
|
|
224
224
|
};
|
|
225
225
|
|
|
226
226
|
export const detailsCardAttributeFromClaim = (
|
|
227
|
-
claim:
|
|
228
|
-
config:
|
|
227
|
+
claim: Claim,
|
|
228
|
+
config: CoreConfig,
|
|
229
229
|
testID: string,
|
|
230
230
|
): CredentialAttribute => {
|
|
231
231
|
const value = detailsCardAttributeValueFromClaim(claim, config, testID);
|
|
@@ -238,21 +238,21 @@ export const detailsCardAttributeFromClaim = (
|
|
|
238
238
|
};
|
|
239
239
|
|
|
240
240
|
const detailsCardAttributeValueFromClaim = (
|
|
241
|
-
claim:
|
|
242
|
-
config:
|
|
241
|
+
claim: Claim,
|
|
242
|
+
config: CoreConfig,
|
|
243
243
|
testID: string,
|
|
244
244
|
): CredentialAttributeValue => {
|
|
245
245
|
const typeConfig = config?.datatype[claim.schema.datatype];
|
|
246
246
|
|
|
247
247
|
if (claim.schema.array) {
|
|
248
248
|
return {
|
|
249
|
-
values: ((claim.value.value as
|
|
249
|
+
values: ((claim.value.value as Claim[]) || []).map((arrayValue, index) => {
|
|
250
250
|
return detailsCardAttributeFromClaim(arrayValue, config, concatTestID(testID, index.toString()));
|
|
251
251
|
}),
|
|
252
252
|
};
|
|
253
253
|
} else {
|
|
254
254
|
switch (typeConfig?.type) {
|
|
255
|
-
case
|
|
255
|
+
case DataType.Object: {
|
|
256
256
|
if (claim.value.type_ !== 'NESTED') {
|
|
257
257
|
return { attributes: [] };
|
|
258
258
|
}
|
|
@@ -262,7 +262,7 @@ const detailsCardAttributeValueFromClaim = (
|
|
|
262
262
|
),
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
|
-
case
|
|
265
|
+
case DataType.Date: {
|
|
266
266
|
if (!claim.value.value) {
|
|
267
267
|
// Don't try to parse empty values (which will return "Invalid Date")
|
|
268
268
|
return { testID: testID, value: String(claim.value.value) };
|
|
@@ -273,8 +273,8 @@ const detailsCardAttributeValueFromClaim = (
|
|
|
273
273
|
value: formatDateLocalized(new Date(date)) ?? date,
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
|
-
case
|
|
277
|
-
case
|
|
276
|
+
case DataType.Picture: // fallback
|
|
277
|
+
case DataType.SwiyuPicture: {
|
|
278
278
|
if (typeConfig.params?.showAs === 'IMAGE') {
|
|
279
279
|
return { image: { uri: claim.value.value as string }, testID: testID };
|
|
280
280
|
} else {
|
|
@@ -292,8 +292,8 @@ export type CredentialDetailsCardPropsWithoutWidth = Omit<CredentialDetailsCardP
|
|
|
292
292
|
};
|
|
293
293
|
|
|
294
294
|
export const detailsCardFromCredential = (
|
|
295
|
-
credential:
|
|
296
|
-
config:
|
|
295
|
+
credential: CredentialDetail,
|
|
296
|
+
config: CoreConfig,
|
|
297
297
|
testID: string,
|
|
298
298
|
labels: CardLabels,
|
|
299
299
|
): CredentialDetailsCardPropsWithoutWidth => {
|
|
@@ -301,9 +301,9 @@ export const detailsCardFromCredential = (
|
|
|
301
301
|
};
|
|
302
302
|
|
|
303
303
|
export const detailsCardFromCredentialWithClaims = (
|
|
304
|
-
credential:
|
|
305
|
-
claims:
|
|
306
|
-
config:
|
|
304
|
+
credential: CredentialDetail,
|
|
305
|
+
claims: Claim[],
|
|
306
|
+
config: CoreConfig,
|
|
307
307
|
testID: string,
|
|
308
308
|
labels: CardLabels,
|
|
309
309
|
): CredentialDetailsCardPropsWithoutWidth => {
|
|
@@ -402,7 +402,7 @@ function parseBase64Image(image: string | undefined) {
|
|
|
402
402
|
return image ? '__BASE64IMAGE__' : '';
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
-
export function getCredentialSchemaWithoutImages<T extends
|
|
405
|
+
export function getCredentialSchemaWithoutImages<T extends CredentialSchemaListItem>(credentialSchema: T): T {
|
|
406
406
|
return {
|
|
407
407
|
...credentialSchema,
|
|
408
408
|
layoutProperties: {
|