@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,283 @@
|
|
|
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 { WUAState } from '../wallet-unit';
|
|
23
|
+
import {
|
|
24
|
+
CredentialDetailsCardPropsWithoutWidth,
|
|
25
|
+
detailsCardAttributeFromClaim,
|
|
26
|
+
getCredentialCardPropsFromCredential,
|
|
27
|
+
supportsSelectiveDisclosure,
|
|
28
|
+
} from '.';
|
|
29
|
+
import { ShareCredentialCardLabels, validityCheckedCardFromCredential } from './credential-sharing';
|
|
30
|
+
|
|
31
|
+
const v2ClaimValueToClaimValue = (value: PresentationDefinitionV2ClaimValue): string | number | boolean | Claim[] => {
|
|
32
|
+
if (!Array.isArray(value)) {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
return value.map((c) => v2PresentationClaimToClaim(c));
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const v2PresentationClaimToClaim = (claim: PresentationDefinitionV2CredentialClaim): Claim => {
|
|
39
|
+
if (Array.isArray(claim.value)) {
|
|
40
|
+
if (claim.schema.array) {
|
|
41
|
+
return {
|
|
42
|
+
array: claim.schema.array,
|
|
43
|
+
dataType: claim.schema.datatype,
|
|
44
|
+
id: claim.path,
|
|
45
|
+
key: claim.path,
|
|
46
|
+
value: v2ClaimValueToClaimValue(claim.value) as Claim[],
|
|
47
|
+
};
|
|
48
|
+
} else {
|
|
49
|
+
return {
|
|
50
|
+
array: claim.schema.array,
|
|
51
|
+
dataType: DataTypeEnum.Object,
|
|
52
|
+
id: claim.path,
|
|
53
|
+
key: claim.path,
|
|
54
|
+
value: v2ClaimValueToClaimValue(claim.value) as Claim[],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
array: false,
|
|
60
|
+
dataType: claim.schema.datatype,
|
|
61
|
+
id: claim.path,
|
|
62
|
+
key: claim.path,
|
|
63
|
+
value: claim.value,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const getAttributeSelectorStatus = (
|
|
68
|
+
claim: PresentationDefinitionV2CredentialClaim,
|
|
69
|
+
selected: boolean,
|
|
70
|
+
force: boolean,
|
|
71
|
+
): SelectorStatus | undefined => {
|
|
72
|
+
if (claim.required && selected) {
|
|
73
|
+
return SelectorStatus.Required;
|
|
74
|
+
}
|
|
75
|
+
if (force && claim.value) {
|
|
76
|
+
return SelectorStatus.Required;
|
|
77
|
+
}
|
|
78
|
+
if (claim.userSelection) {
|
|
79
|
+
if (selected) {
|
|
80
|
+
return SelectorStatus.SelectedCheckmark;
|
|
81
|
+
} else {
|
|
82
|
+
return SelectorStatus.Empty;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const shareCredentialCardAttributeFromV2Claim = (
|
|
88
|
+
claim: PresentationDefinitionV2CredentialClaim,
|
|
89
|
+
selection: string[] | undefined,
|
|
90
|
+
parentShared: boolean,
|
|
91
|
+
parentUserSelected: boolean,
|
|
92
|
+
config: Config,
|
|
93
|
+
testID: string,
|
|
94
|
+
nested?: boolean,
|
|
95
|
+
listValue?: boolean,
|
|
96
|
+
): CredentialAttribute => {
|
|
97
|
+
const attributeShared =
|
|
98
|
+
Boolean(selection?.some((path) => path.startsWith(claim.path))) || (parentShared && claim.required);
|
|
99
|
+
const userSelected = parentUserSelected || Boolean(selection?.includes(claim.path));
|
|
100
|
+
const selected = !claim.required && attributeShared;
|
|
101
|
+
const status = selection
|
|
102
|
+
? getAttributeSelectorStatus(claim, attributeShared, parentUserSelected || (attributeShared && !userSelected))
|
|
103
|
+
: undefined;
|
|
104
|
+
const attribute = detailsCardAttributeFromClaim(v2PresentationClaimToClaim(claim), config, testID);
|
|
105
|
+
const disabledStatus = [SelectorStatus.Disabled, SelectorStatus.Rejected, SelectorStatus.Required];
|
|
106
|
+
const disabled = attribute.disabled || !status || disabledStatus.includes(status);
|
|
107
|
+
const credentialAttribute: CredentialAttribute = {
|
|
108
|
+
...attribute,
|
|
109
|
+
disabled,
|
|
110
|
+
id: claim.path,
|
|
111
|
+
listValue,
|
|
112
|
+
nested,
|
|
113
|
+
path: claim.path,
|
|
114
|
+
rightAccessory: status && <Selector status={status} />,
|
|
115
|
+
selected,
|
|
116
|
+
testID,
|
|
117
|
+
};
|
|
118
|
+
if (Array.isArray(claim.value)) {
|
|
119
|
+
if (claim.schema.array) {
|
|
120
|
+
return {
|
|
121
|
+
...credentialAttribute,
|
|
122
|
+
attributes: undefined,
|
|
123
|
+
image: undefined,
|
|
124
|
+
value: undefined,
|
|
125
|
+
values: claim.value.map((v) =>
|
|
126
|
+
shareCredentialCardAttributeFromV2Claim(
|
|
127
|
+
v,
|
|
128
|
+
selection,
|
|
129
|
+
attributeShared,
|
|
130
|
+
userSelected,
|
|
131
|
+
config,
|
|
132
|
+
testID,
|
|
133
|
+
true,
|
|
134
|
+
false,
|
|
135
|
+
),
|
|
136
|
+
),
|
|
137
|
+
};
|
|
138
|
+
} else if (claim.schema.datatype === 'OBJECT') {
|
|
139
|
+
return {
|
|
140
|
+
...credentialAttribute,
|
|
141
|
+
attributes: claim.value.map((v) =>
|
|
142
|
+
shareCredentialCardAttributeFromV2Claim(v, selection, attributeShared, userSelected, config, testID, true),
|
|
143
|
+
),
|
|
144
|
+
image: undefined,
|
|
145
|
+
value: undefined,
|
|
146
|
+
valueErrorColor: undefined,
|
|
147
|
+
values: undefined,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return credentialAttribute;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
export const missingCredentialCardFromFailureHint = (
|
|
155
|
+
failureHint: FailureHint['failureHint'] | undefined,
|
|
156
|
+
notice: CredentialCardNotice | undefined,
|
|
157
|
+
testID: string,
|
|
158
|
+
labels: ShareCredentialCardLabels,
|
|
159
|
+
): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'width'> => {
|
|
160
|
+
return {
|
|
161
|
+
cardImage: undefined,
|
|
162
|
+
color: undefined,
|
|
163
|
+
header: {
|
|
164
|
+
credentialDetailErrorColor: true,
|
|
165
|
+
credentialDetailPrimary: labels.missingCredential,
|
|
166
|
+
credentialDetailTestID: concatTestID(testID, 'header.missing'),
|
|
167
|
+
credentialName: failureHint?.credentialSchema?.name ?? '',
|
|
168
|
+
statusIcon: CredentialWarningIcon,
|
|
169
|
+
},
|
|
170
|
+
testID,
|
|
171
|
+
...notice,
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export const shareCredentialCardFromV2PresentationCredential = (
|
|
176
|
+
credential: PresentationDefinitionV2CredentialDetail | undefined,
|
|
177
|
+
failureHint: FailureHint['failureHint'] | undefined,
|
|
178
|
+
expanded: boolean,
|
|
179
|
+
multipleCredentialsAvailable: boolean,
|
|
180
|
+
selectedFields: string[] | undefined,
|
|
181
|
+
config: Config,
|
|
182
|
+
wuaState: WUAState | undefined,
|
|
183
|
+
testID: string,
|
|
184
|
+
labels: ShareCredentialCardLabels,
|
|
185
|
+
): CredentialDetailsCardPropsWithoutWidth => {
|
|
186
|
+
const selectiveDisclosureSupported = supportsSelectiveDisclosure(
|
|
187
|
+
credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
|
|
188
|
+
config,
|
|
189
|
+
);
|
|
190
|
+
const notice: CredentialCardNotice | undefined =
|
|
191
|
+
selectiveDisclosureSupported === false
|
|
192
|
+
? {
|
|
193
|
+
noticeIcon: CredentialNoticeWarningIcon,
|
|
194
|
+
text: labels.selectiveDisclosureNotice,
|
|
195
|
+
}
|
|
196
|
+
: undefined;
|
|
197
|
+
const cardTestId = concatTestID(testID, 'card');
|
|
198
|
+
const card = credential
|
|
199
|
+
? validityCheckedCardFromCredential(
|
|
200
|
+
{
|
|
201
|
+
...credential,
|
|
202
|
+
claims: [],
|
|
203
|
+
},
|
|
204
|
+
false,
|
|
205
|
+
expanded,
|
|
206
|
+
multipleCredentialsAvailable,
|
|
207
|
+
config,
|
|
208
|
+
wuaState,
|
|
209
|
+
notice,
|
|
210
|
+
cardTestId,
|
|
211
|
+
labels,
|
|
212
|
+
)
|
|
213
|
+
: missingCredentialCardFromFailureHint(failureHint, notice, cardTestId, labels);
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
attributes:
|
|
217
|
+
credential?.claims.map((v) =>
|
|
218
|
+
shareCredentialCardAttributeFromV2Claim(v, selectedFields ?? [], true, false, config, testID),
|
|
219
|
+
) ?? [],
|
|
220
|
+
card,
|
|
221
|
+
};
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export const selectCredentialCardFromV2Credential = (
|
|
225
|
+
credential: PresentationDefinitionV2CredentialDetail,
|
|
226
|
+
selected: boolean,
|
|
227
|
+
multiple: boolean,
|
|
228
|
+
config: Config,
|
|
229
|
+
wuaState: WUAState | undefined,
|
|
230
|
+
testID: string,
|
|
231
|
+
labels: ShareCredentialCardLabels,
|
|
232
|
+
): CredentialDetailsCardPropsWithoutWidth => {
|
|
233
|
+
const selectiveDisclosureSupported = supportsSelectiveDisclosure(
|
|
234
|
+
credential ? { ...credential, issuer: credential.issuer?.id } : undefined,
|
|
235
|
+
config,
|
|
236
|
+
);
|
|
237
|
+
const selectedStatus = multiple ? SelectorStatus.SelectedCheckmark : SelectorStatus.SelectedRadio;
|
|
238
|
+
const rightAccessory = <Selector status={selected ? selectedStatus : SelectorStatus.Empty} />;
|
|
239
|
+
const notice: CredentialCardNotice | undefined =
|
|
240
|
+
selectiveDisclosureSupported === false
|
|
241
|
+
? {
|
|
242
|
+
noticeIcon: CredentialNoticeWarningIcon,
|
|
243
|
+
text: labels.selectiveDisclosureNotice,
|
|
244
|
+
}
|
|
245
|
+
: undefined;
|
|
246
|
+
const { header, ...cardProps } = getCredentialCardPropsFromCredential(
|
|
247
|
+
{
|
|
248
|
+
...credential,
|
|
249
|
+
claims: credential.claims.map(v2PresentationClaimToClaim),
|
|
250
|
+
},
|
|
251
|
+
credential.claims.map(v2PresentationClaimToClaim),
|
|
252
|
+
config,
|
|
253
|
+
wuaState,
|
|
254
|
+
notice,
|
|
255
|
+
testID,
|
|
256
|
+
labels,
|
|
257
|
+
);
|
|
258
|
+
const card = {
|
|
259
|
+
header: {
|
|
260
|
+
...header,
|
|
261
|
+
accessory: rightAccessory,
|
|
262
|
+
},
|
|
263
|
+
...cardProps,
|
|
264
|
+
};
|
|
265
|
+
return {
|
|
266
|
+
attributes:
|
|
267
|
+
credential?.claims.map((v) =>
|
|
268
|
+
shareCredentialCardAttributeFromV2Claim(v, undefined, false, false, config, testID),
|
|
269
|
+
) ?? [],
|
|
270
|
+
card,
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export const getV2CredentialClaimAllSubpaths = (claim: PresentationDefinitionV2CredentialClaim): string[] => {
|
|
275
|
+
if (!Array.isArray(claim.value)) {
|
|
276
|
+
return [claim.path];
|
|
277
|
+
}
|
|
278
|
+
return [claim.path, ...claim.value.flatMap(getV2CredentialClaimAllSubpaths)];
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export const getV2CredentialAvailablePaths = (credential: PresentationDefinitionV2CredentialDetail): string[] => {
|
|
282
|
+
return credential.claims.flatMap(getV2CredentialClaimAllSubpaths);
|
|
283
|
+
};
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
import { CredentialCardNotice } from '../../ui-components/credential/card/credential-card';
|
|
18
18
|
import { CredentialNoticeWarningIcon, CredentialWarningIcon, RequiredAttributeIcon } from '../../ui-components/icons';
|
|
19
19
|
import { concatTestID } from '../testID';
|
|
20
|
+
import { WUAState } from '../wallet-unit';
|
|
20
21
|
import {
|
|
21
22
|
CardLabels,
|
|
22
23
|
CredentialDetailsCardPropsWithoutWidth,
|
|
@@ -34,6 +35,7 @@ export const validityCheckedCardFromCredential = (
|
|
|
34
35
|
expanded: boolean,
|
|
35
36
|
multipleCredentialsAvailable: boolean,
|
|
36
37
|
config: Config,
|
|
38
|
+
wuaState: WUAState | undefined,
|
|
37
39
|
notice: CredentialCardNotice | undefined,
|
|
38
40
|
testID: string,
|
|
39
41
|
labels: ShareCredentialCardLabels,
|
|
@@ -62,7 +64,7 @@ export const validityCheckedCardFromCredential = (
|
|
|
62
64
|
};
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
const card = getCredentialCardPropsFromCredential(credential, credential.claims, config, notice, testID, labels);
|
|
67
|
+
const card = getCredentialCardPropsFromCredential(credential, credential.claims, config, wuaState, notice, testID, labels);
|
|
66
68
|
return {
|
|
67
69
|
...card,
|
|
68
70
|
header: {
|
|
@@ -94,7 +96,7 @@ export const missingCredentialCardFromRequest = (
|
|
|
94
96
|
};
|
|
95
97
|
|
|
96
98
|
interface DisplayedAttribute {
|
|
97
|
-
claim?:
|
|
99
|
+
claim?: FlatClaim;
|
|
98
100
|
field?: PresentationDefinitionField;
|
|
99
101
|
id: string;
|
|
100
102
|
selected?: boolean;
|
|
@@ -124,16 +126,33 @@ const getAttributeSelectorStatus = (
|
|
|
124
126
|
return selected ? SelectorStatus.SelectedCheckmark : SelectorStatus.Empty;
|
|
125
127
|
};
|
|
126
128
|
|
|
129
|
+
type ClaimWithOptionalPath = Claim & {
|
|
130
|
+
path?: string;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
type FlatClaim = Claim & {
|
|
134
|
+
path: string;
|
|
135
|
+
isArrayElement?: boolean;
|
|
136
|
+
};
|
|
137
|
+
|
|
127
138
|
// Returns a spread list of all claims with their full JSON path as key, including all intermediate objects
|
|
128
|
-
const spreadClaims = (claims:
|
|
129
|
-
|
|
139
|
+
const spreadClaims = (claims: ClaimWithOptionalPath[]): FlatClaim[] => {
|
|
140
|
+
const claimsWithPath: FlatClaim[] = claims.map((c) => ({
|
|
141
|
+
...c,
|
|
142
|
+
path: c.path ?? c.key,
|
|
143
|
+
}));
|
|
144
|
+
return claimsWithPath.reduce((acc, claim) => {
|
|
130
145
|
const result = [claim];
|
|
131
146
|
if (Array.isArray(claim.value)) {
|
|
132
|
-
const
|
|
133
|
-
|
|
147
|
+
const nestedClaimsWithPath: FlatClaim[] = claim.value.map((c, i) => ({
|
|
148
|
+
...c,
|
|
149
|
+
path: claim.array ? `${c.key}/${i}` : c.key,
|
|
150
|
+
isArrayElement: claim.array,
|
|
151
|
+
}));
|
|
152
|
+
result.push(...spreadClaims(nestedClaimsWithPath));
|
|
134
153
|
}
|
|
135
154
|
return [...acc, ...result];
|
|
136
|
-
}, [] as
|
|
155
|
+
}, [] as FlatClaim[]);
|
|
137
156
|
};
|
|
138
157
|
|
|
139
158
|
const getDisplayedAttributes = (
|
|
@@ -144,10 +163,11 @@ const getDisplayedAttributes = (
|
|
|
144
163
|
selectedFields?: string[],
|
|
145
164
|
): DisplayedAttribute[] => {
|
|
146
165
|
const claims = credential ? spreadClaims(credential.claims) : undefined;
|
|
166
|
+
const isApplicable = credential ? request.applicableCredentials.includes(credential.id) : false;
|
|
147
167
|
|
|
148
168
|
let fields = request.fields;
|
|
149
169
|
if (credential) {
|
|
150
|
-
const fieldsWithNoKeyMapping = request.fields.filter((field) => !(credential.id in field.keyMap));
|
|
170
|
+
const fieldsWithNoKeyMapping = request.fields.filter((field) => !(credential.id in field.keyMap)).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
|
-
return
|
|
179
|
+
? claims?.find(({ path }) => {
|
|
180
|
+
return path === field.keyMap[credential.id];
|
|
161
181
|
})
|
|
162
182
|
: undefined;
|
|
163
183
|
const status =
|
|
@@ -185,11 +205,11 @@ 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 { ...detailsCardAttributeFromClaim(claim, config, testID), id };
|
|
212
|
+
return { ...detailsCardAttributeFromClaim(claim, config, testID), id, path: claim.path, listValue: claim.isArrayElement };
|
|
193
213
|
}
|
|
194
214
|
return {
|
|
195
215
|
id,
|
|
@@ -249,6 +269,7 @@ export const shareCredentialCardFromCredential = (
|
|
|
249
269
|
request: PresentationDefinitionRequestedCredential,
|
|
250
270
|
selectedFields: string[] | undefined,
|
|
251
271
|
config: Config,
|
|
272
|
+
wuaState: WUAState | undefined,
|
|
252
273
|
testID: string,
|
|
253
274
|
labels: ShareCredentialCardLabels,
|
|
254
275
|
): CredentialDetailsCardPropsWithoutWidth => {
|
|
@@ -271,6 +292,7 @@ export const shareCredentialCardFromCredential = (
|
|
|
271
292
|
expanded,
|
|
272
293
|
multipleCredentialsAvailable,
|
|
273
294
|
config,
|
|
295
|
+
wuaState,
|
|
274
296
|
notice,
|
|
275
297
|
cardTestId,
|
|
276
298
|
labels,
|
|
@@ -315,7 +337,7 @@ export const selectCredentialCardAttributeFromClaim = (
|
|
|
315
337
|
config: Config,
|
|
316
338
|
testID: string,
|
|
317
339
|
labels: ShareCredentialCardLabels,
|
|
318
|
-
claim?:
|
|
340
|
+
claim?: FlatClaim,
|
|
319
341
|
field?: PresentationDefinitionField,
|
|
320
342
|
): CredentialAttribute => {
|
|
321
343
|
const attribute = shareCredentialCardAttributeFromClaim(id, config, testID, labels, claim, field);
|
|
@@ -333,6 +355,7 @@ export const selectCredentialCardFromCredential = (
|
|
|
333
355
|
selected: boolean,
|
|
334
356
|
request: PresentationDefinitionRequestedCredential,
|
|
335
357
|
config: Config,
|
|
358
|
+
wuaState: WUAState | undefined,
|
|
336
359
|
testID: string,
|
|
337
360
|
labels: ShareCredentialCardLabels,
|
|
338
361
|
): CredentialDetailsCardPropsWithoutWidth => {
|
|
@@ -352,6 +375,7 @@ export const selectCredentialCardFromCredential = (
|
|
|
352
375
|
credential,
|
|
353
376
|
credential.claims,
|
|
354
377
|
config,
|
|
378
|
+
wuaState,
|
|
355
379
|
notice,
|
|
356
380
|
testID,
|
|
357
381
|
labels,
|
|
@@ -363,9 +387,9 @@ export const selectCredentialCardFromCredential = (
|
|
|
363
387
|
},
|
|
364
388
|
...cardProps,
|
|
365
389
|
};
|
|
366
|
-
const attributes: CredentialAttribute[] = request.fields.map((field) => {
|
|
367
|
-
const claim = spreadClaims(credential.claims).find(({
|
|
368
|
-
return
|
|
390
|
+
const attributes: CredentialAttribute[] = getFullyNestedFields(request.fields, credential.id).map((field) => {
|
|
391
|
+
const claim = spreadClaims(credential.claims).find(({ path }) => {
|
|
392
|
+
return path === field.keyMap[credential.id];
|
|
369
393
|
});
|
|
370
394
|
|
|
371
395
|
const attribute = selectCredentialCardAttributeFromClaim(field.id, config, testID, labels, claim, field);
|