@procivis/one-react-native-components 0.3.71 → 0.3.91
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/entity/entity-attributes.js +3 -1
- package/lib/commonjs/components/entity/entity-attributes.js.map +1 -1
- package/lib/commonjs/components/entity/entity-details-with-buttons.js +2 -1
- package/lib/commonjs/components/entity/entity-details-with-buttons.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} +4 -4
- 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} +25 -60
- 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 +51 -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 +131 -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/cache.js +4 -1
- package/lib/commonjs/utils/hooks/core/cache.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/credentials.js +11 -10
- 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 +41 -15
- package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/wallet-unit.js +76 -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 +12 -12
- 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 +25 -12
- package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential.js +89 -57
- 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/module/components/entity/entity-attributes.js +3 -1
- package/lib/module/components/entity/entity-attributes.js.map +1 -1
- package/lib/module/components/entity/entity-details-with-buttons.js +2 -1
- package/lib/module/components/entity/entity-details-with-buttons.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} +4 -4
- package/lib/module/components/proof-request/v1/select-credential.js.map +1 -0
- package/lib/module/components/proof-request/{share-credential.js → v1/share-credential.js} +26 -61
- 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 +42 -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 +122 -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/cache.js +4 -1
- package/lib/module/utils/hooks/core/cache.js.map +1 -1
- package/lib/module/utils/hooks/core/credentials.js +12 -11
- 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 +42 -16
- package/lib/module/utils/hooks/core/proofs.js.map +1 -1
- package/lib/module/utils/hooks/core/wallet-unit.js +66 -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 +1 -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 +25 -12
- package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/module/utils/parsers/credential.js +89 -57
- 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/typescript/components/entity/entity-attributes.d.ts +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 +2 -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 -10
- 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 +1 -1
- package/lib/typescript/utils/parsers/credential-sharing-v2.d.ts +10 -0
- package/lib/typescript/utils/parsers/credential-sharing.d.ts +7 -2
- package/lib/typescript/utils/parsers/credential.d.ts +1 -2
- package/lib/typescript/utils/parsers/index.d.ts +1 -0
- package/lib/typescript/utils/parsers/query.d.ts +2 -2
- package/package.json +13 -7
- package/src/components/entity/entity-attributes.tsx +3 -0
- package/src/components/entity/entity-details-with-buttons.tsx +1 -0
- 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} +7 -4
- package/src/components/proof-request/{share-credential.tsx → v1/share-credential.tsx} +30 -51
- package/src/components/proof-request/v2/index.ts +3 -0
- package/src/components/proof-request/v2/select-credential-v2.tsx +52 -0
- package/src/components/proof-request/v2/share-credential-v2-group.tsx +258 -0
- package/src/components/proof-request/v2/share-credential-v2.tsx +202 -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/cache.ts +3 -0
- package/src/utils/hooks/core/credentials.ts +14 -6
- 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 +40 -22
- package/src/utils/hooks/core/wallet-unit.ts +71 -0
- package/src/utils/hooks/index.ts +1 -0
- package/src/utils/hooks/revocation/credential-status.ts +1 -1
- package/src/utils/index.ts +1 -1
- package/src/utils/parsers/credential-sharing-v2.tsx +278 -0
- package/src/utils/parsers/credential-sharing.tsx +63 -40
- package/src/utils/parsers/credential.ts +100 -57
- package/src/utils/parsers/index.ts +1 -0
- package/src/utils/parsers/query.ts +6 -5
- 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.map +0 -1
- /package/lib/typescript/components/proof-request/{group.d.ts → v1/group.d.ts} +0 -0
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Claim,
|
|
3
|
+
Config,
|
|
4
|
+
DataTypeEnum,
|
|
5
|
+
FailureHint,
|
|
6
|
+
PresentationDefinitionV2ClaimValue,
|
|
7
|
+
PresentationDefinitionV2CredentialClaim,
|
|
8
|
+
PresentationDefinitionV2CredentialDetail,
|
|
9
|
+
} from '@procivis/react-native-one-core';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
CredentialAttribute,
|
|
14
|
+
CredentialCardNotice,
|
|
15
|
+
CredentialCardProps,
|
|
16
|
+
CredentialNoticeWarningIcon,
|
|
17
|
+
CredentialWarningIcon,
|
|
18
|
+
Selector,
|
|
19
|
+
SelectorStatus,
|
|
20
|
+
} from '../../ui-components';
|
|
21
|
+
import { concatTestID } from '../testID';
|
|
22
|
+
import {
|
|
23
|
+
CredentialDetailsCardPropsWithoutWidth,
|
|
24
|
+
detailsCardAttributeFromClaim,
|
|
25
|
+
getCredentialCardPropsFromCredential,
|
|
26
|
+
supportsSelectiveDisclosure,
|
|
27
|
+
} from '.';
|
|
28
|
+
import { ShareCredentialCardLabels, validityCheckedCardFromCredential } from './credential-sharing';
|
|
29
|
+
|
|
30
|
+
const v2ClaimValueToClaimValue = (value: PresentationDefinitionV2ClaimValue): string | number | boolean | Claim[] => {
|
|
31
|
+
if (!Array.isArray(value)) {
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
return value.map((c) => v2PresentationClaimToClaim(c));
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const v2PresentationClaimToClaim = (claim: PresentationDefinitionV2CredentialClaim): Claim => {
|
|
38
|
+
if (Array.isArray(claim.value)) {
|
|
39
|
+
if (claim.schema.array) {
|
|
40
|
+
return {
|
|
41
|
+
array: claim.schema.array,
|
|
42
|
+
dataType: claim.schema.datatype,
|
|
43
|
+
id: claim.path,
|
|
44
|
+
key: claim.path,
|
|
45
|
+
value: v2ClaimValueToClaimValue(claim.value) as Claim[],
|
|
46
|
+
};
|
|
47
|
+
} else {
|
|
48
|
+
return {
|
|
49
|
+
array: claim.schema.array,
|
|
50
|
+
dataType: DataTypeEnum.Object,
|
|
51
|
+
id: claim.path,
|
|
52
|
+
key: claim.path,
|
|
53
|
+
value: v2ClaimValueToClaimValue(claim.value) as Claim[],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
array: false,
|
|
59
|
+
dataType: claim.schema.datatype,
|
|
60
|
+
id: claim.path,
|
|
61
|
+
key: claim.path,
|
|
62
|
+
value: claim.value,
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const getAttributeSelectorStatus = (
|
|
67
|
+
claim: PresentationDefinitionV2CredentialClaim,
|
|
68
|
+
selected: boolean,
|
|
69
|
+
force: boolean,
|
|
70
|
+
): SelectorStatus | undefined => {
|
|
71
|
+
if (claim.required && selected) {
|
|
72
|
+
return SelectorStatus.Required;
|
|
73
|
+
}
|
|
74
|
+
if (force && claim.value) {
|
|
75
|
+
return SelectorStatus.Required;
|
|
76
|
+
}
|
|
77
|
+
if (claim.userSelection) {
|
|
78
|
+
if (selected) {
|
|
79
|
+
return SelectorStatus.SelectedCheckmark;
|
|
80
|
+
} else {
|
|
81
|
+
return SelectorStatus.Empty;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export const shareCredentialCardAttributeFromV2Claim = (
|
|
87
|
+
claim: PresentationDefinitionV2CredentialClaim,
|
|
88
|
+
selection: string[] | undefined,
|
|
89
|
+
parentShared: boolean,
|
|
90
|
+
parentUserSelected: boolean,
|
|
91
|
+
config: Config,
|
|
92
|
+
testID: string,
|
|
93
|
+
nested?: boolean,
|
|
94
|
+
listValue?: boolean,
|
|
95
|
+
): CredentialAttribute => {
|
|
96
|
+
const attributeShared =
|
|
97
|
+
Boolean(selection?.some((path) => path.startsWith(claim.path))) || (parentShared && claim.required);
|
|
98
|
+
const userSelected = parentUserSelected || Boolean(selection?.includes(claim.path));
|
|
99
|
+
const selected = !claim.required && attributeShared;
|
|
100
|
+
const status = selection
|
|
101
|
+
? getAttributeSelectorStatus(claim, attributeShared, parentUserSelected || (attributeShared && !userSelected))
|
|
102
|
+
: undefined;
|
|
103
|
+
const attribute = detailsCardAttributeFromClaim(v2PresentationClaimToClaim(claim), config, testID);
|
|
104
|
+
const disabledStatus = [SelectorStatus.Disabled, SelectorStatus.Rejected, SelectorStatus.Required];
|
|
105
|
+
const disabled = attribute.disabled || !status || disabledStatus.includes(status);
|
|
106
|
+
const credentialAttribute: CredentialAttribute = {
|
|
107
|
+
...attribute,
|
|
108
|
+
disabled,
|
|
109
|
+
id: claim.path,
|
|
110
|
+
listValue,
|
|
111
|
+
nested,
|
|
112
|
+
path: claim.path,
|
|
113
|
+
rightAccessory: status && <Selector status={status} />,
|
|
114
|
+
selected,
|
|
115
|
+
testID,
|
|
116
|
+
};
|
|
117
|
+
if (Array.isArray(claim.value)) {
|
|
118
|
+
if (claim.schema.array) {
|
|
119
|
+
return {
|
|
120
|
+
...credentialAttribute,
|
|
121
|
+
attributes: undefined,
|
|
122
|
+
image: undefined,
|
|
123
|
+
value: undefined,
|
|
124
|
+
values: claim.value.map((v) =>
|
|
125
|
+
shareCredentialCardAttributeFromV2Claim(
|
|
126
|
+
v,
|
|
127
|
+
selection,
|
|
128
|
+
attributeShared,
|
|
129
|
+
userSelected,
|
|
130
|
+
config,
|
|
131
|
+
testID,
|
|
132
|
+
true,
|
|
133
|
+
false,
|
|
134
|
+
),
|
|
135
|
+
),
|
|
136
|
+
};
|
|
137
|
+
} else if (claim.schema.datatype === 'OBJECT') {
|
|
138
|
+
return {
|
|
139
|
+
...credentialAttribute,
|
|
140
|
+
attributes: claim.value.map((v) =>
|
|
141
|
+
shareCredentialCardAttributeFromV2Claim(v, selection, attributeShared, userSelected, config, testID, true),
|
|
142
|
+
),
|
|
143
|
+
image: undefined,
|
|
144
|
+
value: undefined,
|
|
145
|
+
valueErrorColor: undefined,
|
|
146
|
+
values: undefined,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return credentialAttribute;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const missingCredentialCardFromFailureHint = (
|
|
154
|
+
failureHint: FailureHint['failureHint'] | undefined,
|
|
155
|
+
notice: CredentialCardNotice | undefined,
|
|
156
|
+
testID: string,
|
|
157
|
+
labels: ShareCredentialCardLabels,
|
|
158
|
+
): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'width'> => {
|
|
159
|
+
return {
|
|
160
|
+
cardImage: undefined,
|
|
161
|
+
color: undefined,
|
|
162
|
+
header: {
|
|
163
|
+
credentialDetailErrorColor: true,
|
|
164
|
+
credentialDetailPrimary: labels.missingCredential,
|
|
165
|
+
credentialDetailTestID: concatTestID(testID, 'header.missing'),
|
|
166
|
+
credentialName: failureHint?.credentialSchema?.name ?? '',
|
|
167
|
+
statusIcon: CredentialWarningIcon,
|
|
168
|
+
},
|
|
169
|
+
testID,
|
|
170
|
+
...notice,
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export const shareCredentialCardFromV2PresentationCredential = (
|
|
175
|
+
credential: PresentationDefinitionV2CredentialDetail | undefined,
|
|
176
|
+
failureHint: FailureHint['failureHint'] | undefined,
|
|
177
|
+
expanded: boolean,
|
|
178
|
+
multipleCredentialsAvailable: boolean,
|
|
179
|
+
selectedFields: string[] | undefined,
|
|
180
|
+
config: Config,
|
|
181
|
+
testID: string,
|
|
182
|
+
labels: ShareCredentialCardLabels,
|
|
183
|
+
): CredentialDetailsCardPropsWithoutWidth => {
|
|
184
|
+
const selectiveDisclosureSupported = supportsSelectiveDisclosure(
|
|
185
|
+
credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
|
|
186
|
+
config,
|
|
187
|
+
);
|
|
188
|
+
const notice: CredentialCardNotice | undefined =
|
|
189
|
+
selectiveDisclosureSupported === false
|
|
190
|
+
? {
|
|
191
|
+
noticeIcon: CredentialNoticeWarningIcon,
|
|
192
|
+
text: labels.selectiveDisclosureNotice,
|
|
193
|
+
}
|
|
194
|
+
: undefined;
|
|
195
|
+
const cardTestId = concatTestID(testID, 'card');
|
|
196
|
+
const card = credential
|
|
197
|
+
? validityCheckedCardFromCredential(
|
|
198
|
+
{
|
|
199
|
+
...credential,
|
|
200
|
+
claims: [],
|
|
201
|
+
},
|
|
202
|
+
false,
|
|
203
|
+
expanded,
|
|
204
|
+
multipleCredentialsAvailable,
|
|
205
|
+
config,
|
|
206
|
+
notice,
|
|
207
|
+
cardTestId,
|
|
208
|
+
labels,
|
|
209
|
+
)
|
|
210
|
+
: missingCredentialCardFromFailureHint(failureHint, notice, cardTestId, labels);
|
|
211
|
+
|
|
212
|
+
return {
|
|
213
|
+
attributes:
|
|
214
|
+
credential?.claims.map((v) =>
|
|
215
|
+
shareCredentialCardAttributeFromV2Claim(v, selectedFields ?? [], true, false, config, testID),
|
|
216
|
+
) ?? [],
|
|
217
|
+
card,
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export const selectCredentialCardFromV2Credential = (
|
|
222
|
+
credential: PresentationDefinitionV2CredentialDetail,
|
|
223
|
+
selected: boolean,
|
|
224
|
+
multiple: boolean,
|
|
225
|
+
config: Config,
|
|
226
|
+
testID: string,
|
|
227
|
+
labels: ShareCredentialCardLabels,
|
|
228
|
+
): CredentialDetailsCardPropsWithoutWidth => {
|
|
229
|
+
const selectiveDisclosureSupported = supportsSelectiveDisclosure(
|
|
230
|
+
credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
|
|
231
|
+
config,
|
|
232
|
+
);
|
|
233
|
+
const selectedStatus = multiple ? SelectorStatus.SelectedCheckmark : SelectorStatus.SelectedRadio;
|
|
234
|
+
const rightAccessory = <Selector status={selected ? selectedStatus : SelectorStatus.Empty} />;
|
|
235
|
+
const notice: CredentialCardNotice | undefined =
|
|
236
|
+
selectiveDisclosureSupported === false
|
|
237
|
+
? {
|
|
238
|
+
noticeIcon: CredentialNoticeWarningIcon,
|
|
239
|
+
text: labels.selectiveDisclosureNotice,
|
|
240
|
+
}
|
|
241
|
+
: undefined;
|
|
242
|
+
const { header, ...cardProps } = getCredentialCardPropsFromCredential(
|
|
243
|
+
{
|
|
244
|
+
...credential,
|
|
245
|
+
claims: credential.claims.map(v2PresentationClaimToClaim),
|
|
246
|
+
},
|
|
247
|
+
credential.claims.map(v2PresentationClaimToClaim),
|
|
248
|
+
config,
|
|
249
|
+
notice,
|
|
250
|
+
testID,
|
|
251
|
+
labels,
|
|
252
|
+
);
|
|
253
|
+
const card = {
|
|
254
|
+
header: {
|
|
255
|
+
...header,
|
|
256
|
+
accessory: rightAccessory,
|
|
257
|
+
},
|
|
258
|
+
...cardProps,
|
|
259
|
+
};
|
|
260
|
+
return {
|
|
261
|
+
attributes:
|
|
262
|
+
credential?.claims.map((v) =>
|
|
263
|
+
shareCredentialCardAttributeFromV2Claim(v, undefined, false, false, config, testID),
|
|
264
|
+
) ?? [],
|
|
265
|
+
card,
|
|
266
|
+
};
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
export const getV2CredentialClaimAllSubpaths = (claim: PresentationDefinitionV2CredentialClaim): string[] => {
|
|
270
|
+
if (!Array.isArray(claim.value)) {
|
|
271
|
+
return [claim.path];
|
|
272
|
+
}
|
|
273
|
+
return [claim.path, ...claim.value.flatMap(getV2CredentialClaimAllSubpaths)];
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
export const getV2CredentialAvailablePaths = (credential: PresentationDefinitionV2CredentialDetail): string[] => {
|
|
277
|
+
return credential.claims.flatMap(getV2CredentialClaimAllSubpaths);
|
|
278
|
+
};
|
|
@@ -40,13 +40,13 @@ export const validityCheckedCardFromCredential = (
|
|
|
40
40
|
): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'testID' | 'width'> => {
|
|
41
41
|
let credentialHeaderDetail:
|
|
42
42
|
| Pick<
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
CredentialHeaderProps,
|
|
44
|
+
| 'credentialDetailPrimary'
|
|
45
|
+
| 'credentialDetailSecondary'
|
|
46
|
+
| 'credentialDetailErrorColor'
|
|
47
|
+
| 'credentialDetailTestID'
|
|
48
|
+
| 'statusIcon'
|
|
49
|
+
>
|
|
50
50
|
| undefined;
|
|
51
51
|
if (invalidLVVC) {
|
|
52
52
|
credentialHeaderDetail = {
|
|
@@ -94,7 +94,7 @@ export const missingCredentialCardFromRequest = (
|
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
interface DisplayedAttribute {
|
|
97
|
-
claim?:
|
|
97
|
+
claim?: FlatClaim;
|
|
98
98
|
field?: PresentationDefinitionField;
|
|
99
99
|
id: string;
|
|
100
100
|
selected?: boolean;
|
|
@@ -124,16 +124,33 @@ const getAttributeSelectorStatus = (
|
|
|
124
124
|
return selected ? SelectorStatus.SelectedCheckmark : SelectorStatus.Empty;
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
+
type ClaimWithOptionalPath = Claim & {
|
|
128
|
+
path?: string;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
type FlatClaim = Claim & {
|
|
132
|
+
path: string;
|
|
133
|
+
isArrayElement?: boolean;
|
|
134
|
+
};
|
|
135
|
+
|
|
127
136
|
// Returns a spread list of all claims with their full JSON path as key, including all intermediate objects
|
|
128
|
-
const spreadClaims = (claims:
|
|
129
|
-
|
|
137
|
+
const spreadClaims = (claims: ClaimWithOptionalPath[]): FlatClaim[] => {
|
|
138
|
+
const claimsWithPath: FlatClaim[] = claims.map((c) => ({
|
|
139
|
+
...c,
|
|
140
|
+
path: c.path ?? c.key,
|
|
141
|
+
}));
|
|
142
|
+
return claimsWithPath.reduce((acc, claim) => {
|
|
130
143
|
const result = [claim];
|
|
131
144
|
if (Array.isArray(claim.value)) {
|
|
132
|
-
const
|
|
133
|
-
|
|
145
|
+
const nestedClaimsWithPath: FlatClaim[] = claim.value.map((c, i) => ({
|
|
146
|
+
...c,
|
|
147
|
+
path: claim.array ? `${c.key}/${i}` : c.key,
|
|
148
|
+
isArrayElement: claim.array,
|
|
149
|
+
}));
|
|
150
|
+
result.push(...spreadClaims(nestedClaimsWithPath));
|
|
134
151
|
}
|
|
135
152
|
return [...acc, ...result];
|
|
136
|
-
}, [] as
|
|
153
|
+
}, [] as FlatClaim[]);
|
|
137
154
|
};
|
|
138
155
|
|
|
139
156
|
const getDisplayedAttributes = (
|
|
@@ -144,10 +161,13 @@ const getDisplayedAttributes = (
|
|
|
144
161
|
selectedFields?: string[],
|
|
145
162
|
): DisplayedAttribute[] => {
|
|
146
163
|
const claims = credential ? spreadClaims(credential.claims) : undefined;
|
|
164
|
+
const isApplicable = credential ? request.applicableCredentials.includes(credential.id) : false;
|
|
147
165
|
|
|
148
166
|
let fields = request.fields;
|
|
149
167
|
if (credential) {
|
|
150
|
-
const fieldsWithNoKeyMapping = request.fields
|
|
168
|
+
const fieldsWithNoKeyMapping = request.fields
|
|
169
|
+
.filter((field) => !(credential.id in field.keyMap))
|
|
170
|
+
.filter((field) => !isApplicable || !field.required);
|
|
151
171
|
const fullyNestedFields = getFullyNestedFields(request.fields, credential.id);
|
|
152
172
|
|
|
153
173
|
fields = [...fieldsWithNoKeyMapping, ...fullyNestedFields];
|
|
@@ -156,8 +176,8 @@ const getDisplayedAttributes = (
|
|
|
156
176
|
return fields.map((field) => {
|
|
157
177
|
const selected = !field.required && selectedFields?.includes(field.id);
|
|
158
178
|
const claim = credential
|
|
159
|
-
? claims?.find(({
|
|
160
|
-
|
|
179
|
+
? claims?.find(({ path }) => {
|
|
180
|
+
return path === field.keyMap[credential.id];
|
|
161
181
|
})
|
|
162
182
|
: undefined;
|
|
163
183
|
const status =
|
|
@@ -185,11 +205,16 @@ export const shareCredentialCardAttributeFromClaim = (
|
|
|
185
205
|
config: Config,
|
|
186
206
|
testID: string,
|
|
187
207
|
labels: ShareCredentialCardLabels,
|
|
188
|
-
claim?:
|
|
208
|
+
claim?: FlatClaim,
|
|
189
209
|
field?: PresentationDefinitionField,
|
|
190
210
|
): CredentialAttribute => {
|
|
191
211
|
if (claim) {
|
|
192
|
-
return {
|
|
212
|
+
return {
|
|
213
|
+
...detailsCardAttributeFromClaim(claim, config, testID),
|
|
214
|
+
id,
|
|
215
|
+
path: claim.path,
|
|
216
|
+
listValue: claim.isArrayElement,
|
|
217
|
+
};
|
|
193
218
|
}
|
|
194
219
|
return {
|
|
195
220
|
id,
|
|
@@ -259,26 +284,24 @@ export const shareCredentialCardFromCredential = (
|
|
|
259
284
|
const notice: CredentialCardNotice | undefined =
|
|
260
285
|
selectiveDisclosureSupported === false
|
|
261
286
|
? {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
287
|
+
text: labels.selectiveDisclosureNotice,
|
|
288
|
+
noticeIcon: CredentialNoticeWarningIcon,
|
|
289
|
+
}
|
|
265
290
|
: undefined;
|
|
266
291
|
const cardTestId = concatTestID(testID, 'card');
|
|
267
292
|
const card = credential
|
|
268
293
|
? validityCheckedCardFromCredential(
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
294
|
+
credential,
|
|
295
|
+
invalidLVVC,
|
|
296
|
+
expanded,
|
|
297
|
+
multipleCredentialsAvailable,
|
|
298
|
+
config,
|
|
299
|
+
notice,
|
|
300
|
+
cardTestId,
|
|
301
|
+
labels,
|
|
302
|
+
)
|
|
278
303
|
: missingCredentialCardFromRequest(request, notice, cardTestId, labels);
|
|
279
|
-
const validityState = getValidityState(
|
|
280
|
-
credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
|
|
281
|
-
);
|
|
304
|
+
const validityState = getValidityState(credential ? { ...credential, issuer: credential.issuer?.id } : undefined);
|
|
282
305
|
const displayedAttributes = getDisplayedAttributes(
|
|
283
306
|
request,
|
|
284
307
|
validityState,
|
|
@@ -315,7 +338,7 @@ export const selectCredentialCardAttributeFromClaim = (
|
|
|
315
338
|
config: Config,
|
|
316
339
|
testID: string,
|
|
317
340
|
labels: ShareCredentialCardLabels,
|
|
318
|
-
claim?:
|
|
341
|
+
claim?: FlatClaim,
|
|
319
342
|
field?: PresentationDefinitionField,
|
|
320
343
|
): CredentialAttribute => {
|
|
321
344
|
const attribute = shareCredentialCardAttributeFromClaim(id, config, testID, labels, claim, field);
|
|
@@ -344,9 +367,9 @@ export const selectCredentialCardFromCredential = (
|
|
|
344
367
|
const notice: CredentialCardNotice | undefined =
|
|
345
368
|
selectiveDisclosureSupported === false
|
|
346
369
|
? {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
370
|
+
text: labels.selectiveDisclosureNotice,
|
|
371
|
+
noticeIcon: CredentialNoticeWarningIcon,
|
|
372
|
+
}
|
|
350
373
|
: undefined;
|
|
351
374
|
const { header, ...cardProps } = getCredentialCardPropsFromCredential(
|
|
352
375
|
credential,
|
|
@@ -363,9 +386,9 @@ export const selectCredentialCardFromCredential = (
|
|
|
363
386
|
},
|
|
364
387
|
...cardProps,
|
|
365
388
|
};
|
|
366
|
-
const attributes: CredentialAttribute[] = request.fields.map((field) => {
|
|
367
|
-
const claim = spreadClaims(credential.claims).find(({
|
|
368
|
-
return
|
|
389
|
+
const attributes: CredentialAttribute[] = getFullyNestedFields(request.fields, credential.id).map((field) => {
|
|
390
|
+
const claim = spreadClaims(credential.claims).find(({ path }) => {
|
|
391
|
+
return path === field.keyMap[credential.id];
|
|
369
392
|
});
|
|
370
393
|
|
|
371
394
|
const attribute = selectCredentialCardAttributeFromClaim(field.id, config, testID, labels, claim, field);
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
DataTypeEnum,
|
|
9
9
|
FormatFeatureEnum,
|
|
10
10
|
} from '@procivis/react-native-one-core';
|
|
11
|
+
import { FC } from 'react';
|
|
12
|
+
import { SvgProps } from 'react-native-svg';
|
|
11
13
|
|
|
12
14
|
import {
|
|
13
15
|
CredentialAttribute,
|
|
@@ -84,60 +86,86 @@ export type CardHeaderLabels = {
|
|
|
84
86
|
suspendedUntil: (date: string) => string;
|
|
85
87
|
};
|
|
86
88
|
|
|
87
|
-
|
|
89
|
+
const credentialDetailFromCredential = (
|
|
88
90
|
credential: CredentialDetail,
|
|
89
91
|
claims: Claim[] = [],
|
|
90
92
|
config: Config,
|
|
91
93
|
testID: string,
|
|
92
94
|
labels: CardHeaderLabels,
|
|
93
|
-
):
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
let statusIcon;
|
|
101
|
-
|
|
95
|
+
): {
|
|
96
|
+
credentialDetailPrimary?: string;
|
|
97
|
+
credentialDetailSecondary?: string;
|
|
98
|
+
credentialDetailErrorColor?: boolean;
|
|
99
|
+
credentialDetailTestID?: string;
|
|
100
|
+
statusIcon?: FC<SvgProps>;
|
|
101
|
+
} => {
|
|
102
102
|
const { layoutProperties } = credential.schema;
|
|
103
103
|
|
|
104
104
|
switch (credential.state) {
|
|
105
105
|
case CredentialStateEnum.SUSPENDED:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
106
|
+
return {
|
|
107
|
+
credentialDetailPrimary: credential.suspendEndDate
|
|
108
|
+
? labels.suspendedUntil(formatDateTimeLocalized(new Date(credential.suspendEndDate))!)
|
|
109
|
+
: labels.suspended,
|
|
110
|
+
credentialDetailTestID: concatTestID(testID, 'suspended'),
|
|
111
|
+
statusIcon: CredentialWarningIcon,
|
|
112
|
+
};
|
|
112
113
|
case CredentialStateEnum.REVOKED:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
credentialDetailPrimary = labels.validityIssues;
|
|
121
|
-
credentialDetailTestID = concatTestID(testID, 'validity-issue');
|
|
122
|
-
statusIcon = CredentialWarningIcon;
|
|
123
|
-
} else {
|
|
124
|
-
const primary = findClaimByPath(layoutProperties?.primaryAttribute, claims);
|
|
114
|
+
return {
|
|
115
|
+
credentialDetailPrimary: labels.revoked,
|
|
116
|
+
credentialDetailErrorColor: true,
|
|
117
|
+
credentialDetailTestID: concatTestID(testID, 'revoked'),
|
|
118
|
+
statusIcon: CredentialErrorIcon,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
125
121
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
122
|
+
if (hasMsoValidityIssues(credential)) {
|
|
123
|
+
return {
|
|
124
|
+
credentialDetailPrimary: labels.validityIssues,
|
|
125
|
+
credentialDetailTestID: concatTestID(testID, 'validity-issue'),
|
|
126
|
+
statusIcon: CredentialWarningIcon,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
let credentialDetailPrimary =
|
|
131
|
+
formatDateTimeLocalized(new Date(credential.issuanceDate ?? credential.createdDate)) ?? '';
|
|
132
|
+
let credentialDetailSecondary: string | undefined;
|
|
131
133
|
|
|
132
|
-
|
|
133
|
-
credentialDetailSecondary = formatCredentialDetail(secondary, config, concatTestID(testID, 'secondary'));
|
|
134
|
-
}
|
|
134
|
+
const primary = findClaimByPath(layoutProperties?.primaryAttribute, claims);
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
if (primary) {
|
|
137
|
+
credentialDetailPrimary = formatCredentialDetail(primary, config, concatTestID(testID, 'primary'));
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const secondary = findClaimByPath(layoutProperties?.secondaryAttribute, claims);
|
|
141
|
+
|
|
142
|
+
if (secondary) {
|
|
143
|
+
credentialDetailSecondary = formatCredentialDetail(secondary, config, concatTestID(testID, 'secondary'));
|
|
140
144
|
}
|
|
145
|
+
|
|
146
|
+
return {
|
|
147
|
+
credentialDetailPrimary,
|
|
148
|
+
credentialDetailSecondary,
|
|
149
|
+
credentialDetailTestID: concatTestID(testID, 'detail'),
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const cardHeaderFromCredential = (
|
|
154
|
+
credential: CredentialDetail,
|
|
155
|
+
claims: Claim[] = [],
|
|
156
|
+
config: Config,
|
|
157
|
+
testID: string,
|
|
158
|
+
labels: CardHeaderLabels,
|
|
159
|
+
): Omit<CredentialHeaderProps, 'style'> => {
|
|
160
|
+
const {
|
|
161
|
+
credentialDetailPrimary,
|
|
162
|
+
credentialDetailSecondary,
|
|
163
|
+
credentialDetailErrorColor,
|
|
164
|
+
credentialDetailTestID,
|
|
165
|
+
statusIcon,
|
|
166
|
+
} = credentialDetailFromCredential(credential, claims, config, testID, labels);
|
|
167
|
+
const { layoutProperties } = credential.schema;
|
|
168
|
+
|
|
141
169
|
return {
|
|
142
170
|
color: layoutProperties?.logo?.backgroundColor,
|
|
143
171
|
credentialDetailErrorColor,
|
|
@@ -242,7 +270,8 @@ const detailsCardAttributeValueFromClaim = (claim: Claim, config: Config, testID
|
|
|
242
270
|
value: formatDateLocalized(new Date(date)) ?? date,
|
|
243
271
|
};
|
|
244
272
|
}
|
|
245
|
-
case DataTypeEnum.
|
|
273
|
+
case DataTypeEnum.Picture: // fallback
|
|
274
|
+
case DataTypeEnum.SwiyuPicture: {
|
|
246
275
|
if (typeConfig.params?.showAs === 'IMAGE') {
|
|
247
276
|
return { image: { uri: claim.value as string }, testID: testID };
|
|
248
277
|
} else {
|
|
@@ -257,7 +286,7 @@ const detailsCardAttributeValueFromClaim = (claim: Claim, config: Config, testID
|
|
|
257
286
|
|
|
258
287
|
export type CredentialDetailsCardPropsWithoutWidth = Omit<CredentialDetailsCardProps, 'expanded' | 'card'> & {
|
|
259
288
|
card: Omit<CredentialCardProps, 'width'>;
|
|
260
|
-
}
|
|
289
|
+
};
|
|
261
290
|
|
|
262
291
|
export const detailsCardFromCredential = (
|
|
263
292
|
credential: CredentialDetail,
|
|
@@ -307,9 +336,9 @@ export const nestAttributes = (attributes: CredentialAttribute[]): CredentialAtt
|
|
|
307
336
|
const [first, ...rest] = attributePath;
|
|
308
337
|
const parent = result.find((a) => a.name === first);
|
|
309
338
|
if (parent) {
|
|
310
|
-
|
|
339
|
+
insertAttributeInParent({ ...attribute, path: rest.join('/') }, parent);
|
|
311
340
|
} else {
|
|
312
|
-
result.push(
|
|
341
|
+
result.push(nestAttributeInDummyParent(attribute));
|
|
313
342
|
}
|
|
314
343
|
}
|
|
315
344
|
}
|
|
@@ -319,7 +348,7 @@ export const nestAttributes = (attributes: CredentialAttribute[]): CredentialAtt
|
|
|
319
348
|
|
|
320
349
|
// We nest the leaf node in a (one or more) nested object(s)
|
|
321
350
|
// to make sure the tree structure is correctly rendered in proof request screens.
|
|
322
|
-
const
|
|
351
|
+
const nestAttributeInDummyParent = (attribute: CredentialAttribute): CredentialAttribute => {
|
|
323
352
|
const pathParts = attribute.path.split('/');
|
|
324
353
|
const [first, ...rest] = pathParts;
|
|
325
354
|
if (!rest.length) {
|
|
@@ -328,27 +357,41 @@ const nestAttributeInDummyObject = (attribute: CredentialAttribute): CredentialA
|
|
|
328
357
|
|
|
329
358
|
// The dummy object is not selectable, and contains a placeholder ID
|
|
330
359
|
// the user can't interact with it.
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
360
|
+
if (attribute.listValue) {
|
|
361
|
+
return {
|
|
362
|
+
values: [nestAttributeInDummyParent({ ...attribute, path: rest.join('/') })],
|
|
363
|
+
disabled: true,
|
|
364
|
+
id: `${attribute.id}/${first}`,
|
|
365
|
+
name: first,
|
|
366
|
+
path: first,
|
|
367
|
+
};
|
|
368
|
+
} else {
|
|
369
|
+
return {
|
|
370
|
+
attributes: [nestAttributeInDummyParent({ ...attribute, path: rest.join('/') })],
|
|
371
|
+
disabled: true,
|
|
372
|
+
id: `${attribute.id}/${first}`,
|
|
373
|
+
name: first,
|
|
374
|
+
path: first,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
338
377
|
};
|
|
339
378
|
|
|
340
|
-
// Recursively insert an attribute into an
|
|
341
|
-
// Will create nested
|
|
342
|
-
const
|
|
379
|
+
// Recursively insert an attribute into an parent
|
|
380
|
+
// Will create nested parents if necessary
|
|
381
|
+
const insertAttributeInParent = (attribute: CredentialAttribute, parent: CredentialAttribute) => {
|
|
343
382
|
const pathParts = attribute.path.split('/');
|
|
344
383
|
const [first, ...rest] = pathParts;
|
|
345
384
|
|
|
346
|
-
const nextParent =
|
|
385
|
+
const nextParent = parent.attributes?.find((a) => a.name === first);
|
|
347
386
|
|
|
348
387
|
if (!nextParent) {
|
|
349
|
-
|
|
388
|
+
if (attribute.listValue) {
|
|
389
|
+
parent.values?.push(nestAttributeInDummyParent(attribute));
|
|
390
|
+
} else {
|
|
391
|
+
parent.attributes?.push(nestAttributeInDummyParent(attribute));
|
|
392
|
+
}
|
|
350
393
|
} else {
|
|
351
|
-
|
|
394
|
+
insertAttributeInParent({ ...attribute, path: rest.join('/') }, nextParent);
|
|
352
395
|
}
|
|
353
396
|
};
|
|
354
397
|
|