@procivis/one-react-native-components 0.3.121 → 0.3.130
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 +2 -1
- package/lib/commonjs/components/credential/credential.js.map +1 -1
- package/lib/commonjs/components/history/history-list-item-icon.js +2 -3
- package/lib/commonjs/components/history/history-list-item-icon.js.map +1 -1
- package/lib/commonjs/components/history/history-list-item.js +2 -8
- package/lib/commonjs/components/history/history-list-item.js.map +1 -1
- package/lib/commonjs/components/history/history-list-screen.js +1 -1
- package/lib/commonjs/components/history/history-list-screen.js.map +1 -1
- package/lib/commonjs/components/index.js +0 -11
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/proof-request/v1/select-credential.js +2 -1
- package/lib/commonjs/components/proof-request/v1/select-credential.js.map +1 -1
- package/lib/commonjs/components/proof-request/v1/share-credential.js +2 -1
- package/lib/commonjs/components/proof-request/v1/share-credential.js.map +1 -1
- package/lib/commonjs/components/proof-request/v2/select-credential-v2.js +2 -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 +3 -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 +4 -2
- package/lib/commonjs/components/proof-request/v2/share-credential-v2.js.map +1 -1
- package/lib/commonjs/ui-components/credential/card/credential-details-card.js +3 -1
- package/lib/commonjs/ui-components/credential/card/credential-details-card.js.map +1 -1
- package/lib/commonjs/ui-components/header/foldable-header.js.map +1 -1
- package/lib/commonjs/ui-components/header/header.js.map +1 -1
- package/lib/commonjs/ui-components/history/history-details.js +2 -2
- package/lib/commonjs/ui-components/history/history-details.js.map +1 -1
- package/lib/commonjs/ui-components/icons/contact.js.map +1 -1
- package/lib/commonjs/ui-components/icons/credential.js +3 -3
- package/lib/commonjs/ui-components/icons/credential.js.map +1 -1
- package/lib/commonjs/ui-components/icons/icons.js +20 -1
- package/lib/commonjs/ui-components/icons/icons.js.map +1 -1
- package/lib/commonjs/ui-components/loader/loading-result.js +2 -0
- package/lib/commonjs/ui-components/loader/loading-result.js.map +1 -1
- package/lib/commonjs/ui-components/screens/nerd-mode-screen.js +7 -33
- package/lib/commonjs/ui-components/screens/nerd-mode-screen.js.map +1 -1
- package/lib/commonjs/utils/date.js +4 -5
- package/lib/commonjs/utils/date.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/cache.js +7 -4
- package/lib/commonjs/utils/hooks/core/cache.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/core-config.js +1 -6
- package/lib/commonjs/utils/hooks/core/core-config.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/core-context.js +0 -15
- package/lib/commonjs/utils/hooks/core/core-context.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/credentials.js +15 -1
- package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/index.js +0 -11
- package/lib/commonjs/utils/hooks/core/index.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/trust-list.js +19 -3
- package/lib/commonjs/utils/hooks/core/trust-list.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/verifier-instance.js +22 -3
- package/lib/commonjs/utils/hooks/core/verifier-instance.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/wallet-unit.js +2 -2
- package/lib/commonjs/utils/hooks/core/wallet-unit.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing-v2.js +14 -14
- package/lib/commonjs/utils/parsers/credential-sharing-v2.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential-sharing.js +20 -18
- package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/commonjs/utils/parsers/credential.js +36 -22
- package/lib/commonjs/utils/parsers/credential.js.map +1 -1
- package/lib/commonjs/utils/parsers/query.js +1 -1
- package/lib/commonjs/utils/parsers/query.js.map +1 -1
- package/lib/commonjs/utils/translations.js +15 -0
- package/lib/commonjs/utils/translations.js.map +1 -0
- package/lib/module/components/credential/credential.js +2 -1
- package/lib/module/components/credential/credential.js.map +1 -1
- package/lib/module/components/history/history-list-item-icon.js +2 -3
- package/lib/module/components/history/history-list-item-icon.js.map +1 -1
- package/lib/module/components/history/history-list-item.js +3 -9
- package/lib/module/components/history/history-list-item.js.map +1 -1
- package/lib/module/components/history/history-list-screen.js +1 -1
- package/lib/module/components/history/history-list-screen.js.map +1 -1
- package/lib/module/components/index.js +0 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/proof-request/v1/select-credential.js +2 -1
- package/lib/module/components/proof-request/v1/select-credential.js.map +1 -1
- package/lib/module/components/proof-request/v1/share-credential.js +2 -1
- package/lib/module/components/proof-request/v1/share-credential.js.map +1 -1
- package/lib/module/components/proof-request/v2/select-credential-v2.js +2 -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 +3 -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 +4 -2
- package/lib/module/components/proof-request/v2/share-credential-v2.js.map +1 -1
- package/lib/module/ui-components/credential/card/credential-details-card.js +3 -1
- package/lib/module/ui-components/credential/card/credential-details-card.js.map +1 -1
- package/lib/module/ui-components/header/foldable-header.js.map +1 -1
- package/lib/module/ui-components/header/header.js.map +1 -1
- package/lib/module/ui-components/history/history-details.js +3 -3
- package/lib/module/ui-components/history/history-details.js.map +1 -1
- package/lib/module/ui-components/icons/contact.js.map +1 -1
- package/lib/module/ui-components/icons/credential.js +1 -1
- package/lib/module/ui-components/icons/credential.js.map +1 -1
- package/lib/module/ui-components/icons/icons.js +18 -0
- package/lib/module/ui-components/icons/icons.js.map +1 -1
- package/lib/module/ui-components/loader/loading-result.js +2 -0
- package/lib/module/ui-components/loader/loading-result.js.map +1 -1
- package/lib/module/ui-components/screens/nerd-mode-screen.js +7 -33
- package/lib/module/ui-components/screens/nerd-mode-screen.js.map +1 -1
- package/lib/module/utils/date.js +4 -5
- package/lib/module/utils/date.js.map +1 -1
- package/lib/module/utils/hooks/core/cache.js +7 -4
- package/lib/module/utils/hooks/core/cache.js.map +1 -1
- package/lib/module/utils/hooks/core/core-config.js +0 -4
- package/lib/module/utils/hooks/core/core-config.js.map +1 -1
- package/lib/module/utils/hooks/core/core-context.js +0 -15
- package/lib/module/utils/hooks/core/core-context.js.map +1 -1
- package/lib/module/utils/hooks/core/credentials.js +13 -0
- package/lib/module/utils/hooks/core/credentials.js.map +1 -1
- package/lib/module/utils/hooks/core/index.js +0 -1
- package/lib/module/utils/hooks/core/index.js.map +1 -1
- package/lib/module/utils/hooks/core/trust-list.js +20 -4
- package/lib/module/utils/hooks/core/trust-list.js.map +1 -1
- package/lib/module/utils/hooks/core/verifier-instance.js +20 -2
- package/lib/module/utils/hooks/core/verifier-instance.js.map +1 -1
- package/lib/module/utils/hooks/core/wallet-unit.js +2 -2
- package/lib/module/utils/hooks/core/wallet-unit.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing-v2.js +15 -15
- package/lib/module/utils/parsers/credential-sharing-v2.js.map +1 -1
- package/lib/module/utils/parsers/credential-sharing.js +20 -18
- package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
- package/lib/module/utils/parsers/credential.js +37 -23
- package/lib/module/utils/parsers/credential.js.map +1 -1
- package/lib/module/utils/parsers/query.js +1 -1
- package/lib/module/utils/parsers/query.js.map +1 -1
- package/lib/module/utils/translations.js +8 -0
- package/lib/module/utils/translations.js.map +1 -0
- package/lib/typescript/components/credential/credential.d.ts +1 -0
- package/lib/typescript/components/history/history-list-item.d.ts +1 -1
- package/lib/typescript/components/index.d.ts +0 -1
- package/lib/typescript/components/proof-request/v1/select-credential.d.ts +1 -0
- package/lib/typescript/components/proof-request/v1/share-credential.d.ts +1 -0
- package/lib/typescript/components/proof-request/v2/select-credential-v2.d.ts +1 -0
- package/lib/typescript/components/proof-request/v2/share-credential-v2-group.d.ts +1 -0
- package/lib/typescript/components/proof-request/v2/share-credential-v2.d.ts +1 -0
- package/lib/typescript/ui-components/history/history-details.d.ts +2 -2
- package/lib/typescript/ui-components/icons/credential.d.ts +1 -1
- package/lib/typescript/ui-components/icons/icons.d.ts +1 -0
- package/lib/typescript/ui-components/screens/nerd-mode-screen.d.ts +0 -12
- package/lib/typescript/utils/hooks/core/core-config.d.ts +0 -1
- package/lib/typescript/utils/hooks/core/core-context.d.ts +0 -1
- package/lib/typescript/utils/hooks/core/credentials.d.ts +2 -1
- package/lib/typescript/utils/hooks/core/index.d.ts +0 -1
- package/lib/typescript/utils/hooks/core/trust-list.d.ts +1 -4
- package/lib/typescript/utils/hooks/core/verifier-instance.d.ts +2 -0
- package/lib/typescript/utils/hooks/core/wallet-unit.d.ts +2 -2
- package/lib/typescript/utils/parsers/credential-sharing-v2.d.ts +3 -3
- package/lib/typescript/utils/parsers/credential-sharing.d.ts +6 -6
- package/lib/typescript/utils/parsers/credential.d.ts +5 -5
- package/lib/typescript/utils/parsers/query.d.ts +1 -1
- package/lib/typescript/utils/translations.d.ts +1 -0
- package/package.json +3 -3
- package/src/components/credential/credential.tsx +3 -0
- package/src/components/history/history-list-item-icon.tsx +1 -2
- package/src/components/history/history-list-item.tsx +4 -9
- package/src/components/history/history-list-screen.tsx +1 -1
- package/src/components/index.ts +0 -1
- package/src/components/proof-request/v1/select-credential.tsx +3 -1
- package/src/components/proof-request/v1/share-credential.tsx +3 -0
- package/src/components/proof-request/v2/select-credential-v2.tsx +3 -1
- package/src/components/proof-request/v2/share-credential-v2-group.tsx +4 -0
- package/src/components/proof-request/v2/share-credential-v2.tsx +5 -0
- package/src/ui-components/credential/card/credential-details-card.tsx +3 -2
- package/src/ui-components/header/foldable-header.tsx +10 -9
- package/src/ui-components/header/header.tsx +10 -1
- package/src/ui-components/history/history-details.tsx +4 -4
- package/src/ui-components/icons/contact.tsx +1 -1
- package/src/ui-components/icons/credential.tsx +1 -1
- package/src/ui-components/icons/icons.tsx +18 -0
- package/src/ui-components/loader/loading-result.tsx +7 -1
- package/src/ui-components/screens/nerd-mode-screen.tsx +2 -52
- package/src/utils/date.ts +7 -14
- package/src/utils/hooks/core/cache.ts +10 -3
- package/src/utils/hooks/core/core-config.ts +1 -6
- package/src/utils/hooks/core/core-context.tsx +0 -24
- package/src/utils/hooks/core/credentials.ts +13 -0
- package/src/utils/hooks/core/index.ts +0 -1
- package/src/utils/hooks/core/trust-list.ts +22 -11
- package/src/utils/hooks/core/verifier-instance.ts +23 -2
- package/src/utils/hooks/core/wallet-unit.ts +3 -3
- package/src/utils/parsers/credential-sharing-v2.tsx +29 -12
- package/src/utils/parsers/credential-sharing.tsx +33 -16
- package/src/utils/parsers/credential.ts +45 -14
- package/src/utils/parsers/query.ts +3 -0
- package/src/utils/translations.ts +10 -0
- package/lib/commonjs/components/entity/EntityButtons.js +0 -64
- package/lib/commonjs/components/entity/EntityButtons.js.map +0 -1
- package/lib/commonjs/components/entity/entity-attributes.js +0 -65
- package/lib/commonjs/components/entity/entity-attributes.js.map +0 -1
- package/lib/commonjs/components/entity/entity-details-with-buttons.js +0 -67
- package/lib/commonjs/components/entity/entity-details-with-buttons.js.map +0 -1
- package/lib/commonjs/components/entity/entity-details.js +0 -101
- package/lib/commonjs/components/entity/entity-details.js.map +0 -1
- package/lib/commonjs/components/entity/index.js +0 -14
- package/lib/commonjs/components/entity/index.js.map +0 -1
- package/lib/commonjs/utils/hooks/core/trust-entity.js +0 -147
- package/lib/commonjs/utils/hooks/core/trust-entity.js.map +0 -1
- package/lib/module/components/entity/EntityButtons.js +0 -56
- package/lib/module/components/entity/EntityButtons.js.map +0 -1
- package/lib/module/components/entity/entity-attributes.js +0 -57
- package/lib/module/components/entity/entity-attributes.js.map +0 -1
- package/lib/module/components/entity/entity-details-with-buttons.js +0 -58
- package/lib/module/components/entity/entity-details-with-buttons.js.map +0 -1
- package/lib/module/components/entity/entity-details.js +0 -92
- package/lib/module/components/entity/entity-details.js.map +0 -1
- package/lib/module/components/entity/index.js +0 -3
- package/lib/module/components/entity/index.js.map +0 -1
- package/lib/module/utils/hooks/core/trust-entity.js +0 -136
- package/lib/module/utils/hooks/core/trust-entity.js.map +0 -1
- package/lib/typescript/components/entity/EntityButtons.d.ts +0 -14
- package/lib/typescript/components/entity/entity-attributes.d.ts +0 -15
- package/lib/typescript/components/entity/entity-details-with-buttons.d.ts +0 -18
- package/lib/typescript/components/entity/entity-details.d.ts +0 -21
- package/lib/typescript/components/entity/index.d.ts +0 -3
- package/lib/typescript/utils/hooks/core/trust-entity.d.ts +0 -17
- package/src/components/entity/EntityButtons.tsx +0 -79
- package/src/components/entity/entity-attributes.tsx +0 -80
- package/src/components/entity/entity-details-with-buttons.tsx +0 -75
- package/src/components/entity/entity-details.tsx +0 -145
- package/src/components/entity/index.ts +0 -4
- package/src/utils/hooks/core/trust-entity.ts +0 -172
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { TrustEntityDetail, TrustEntityListItem } from '@procivis/react-native-one-core';
|
|
2
|
-
import React, { FC, memo } from 'react';
|
|
3
|
-
import { StyleSheet, View } from 'react-native';
|
|
4
|
-
|
|
5
|
-
import { NerdModeItem } from '../../ui-components/nerd-view';
|
|
6
|
-
import { AttributesLabels, EntityType } from '../../ui-components/screens/nerd-mode-screen';
|
|
7
|
-
import { addElementIf } from '../../utils/array';
|
|
8
|
-
|
|
9
|
-
interface EntityAttributesProps {
|
|
10
|
-
certificate?: string;
|
|
11
|
-
did?: string;
|
|
12
|
-
trustEntity?: TrustEntityDetail | TrustEntityListItem;
|
|
13
|
-
trusted: boolean;
|
|
14
|
-
labels: AttributesLabels;
|
|
15
|
-
onCopyToClipboard: (value: string) => void;
|
|
16
|
-
entityType: EntityType;
|
|
17
|
-
testID?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const EntityAttributes: FC<EntityAttributesProps> = ({
|
|
21
|
-
certificate,
|
|
22
|
-
did,
|
|
23
|
-
trustEntity,
|
|
24
|
-
trusted,
|
|
25
|
-
labels,
|
|
26
|
-
entityType,
|
|
27
|
-
testID,
|
|
28
|
-
onCopyToClipboard,
|
|
29
|
-
}) => {
|
|
30
|
-
const didSections = did?.split(':') ?? [];
|
|
31
|
-
const identifier = didSections.pop();
|
|
32
|
-
const didMethod = didSections.length ? didSections.join(':') + ':' : '';
|
|
33
|
-
|
|
34
|
-
const attributes = [
|
|
35
|
-
...addElementIf(trusted, {
|
|
36
|
-
attributeKey: labels.trustRegistry,
|
|
37
|
-
highlightedText: trustEntity?.trustAnchor.name,
|
|
38
|
-
testID: 'trustRegistry',
|
|
39
|
-
}),
|
|
40
|
-
...addElementIf(Boolean(did), {
|
|
41
|
-
attributeKey: entityType === EntityType.CredentialEntity ? labels.issuerIdentifier : labels.entityIdentifier,
|
|
42
|
-
attributeText: identifier,
|
|
43
|
-
canBeCopied: true,
|
|
44
|
-
highlightedText: didMethod,
|
|
45
|
-
testID: 'issuerDID',
|
|
46
|
-
}),
|
|
47
|
-
...addElementIf(Boolean(certificate), {
|
|
48
|
-
attributeKey: entityType === EntityType.CredentialEntity ? labels.issuerIdentifier : labels.entityIdentifier,
|
|
49
|
-
attributeText: certificate,
|
|
50
|
-
canBeCopied: true,
|
|
51
|
-
testID: 'issuerCertificate',
|
|
52
|
-
}),
|
|
53
|
-
...addElementIf(trusted && Boolean(trustEntity?.role), {
|
|
54
|
-
attributeKey: labels.role,
|
|
55
|
-
highlightedText: trustEntity?.role,
|
|
56
|
-
testID: 'role',
|
|
57
|
-
}),
|
|
58
|
-
];
|
|
59
|
-
return (
|
|
60
|
-
<View style={styles.wrapper}>
|
|
61
|
-
{attributes.map((attribute) => (
|
|
62
|
-
<NerdModeItem
|
|
63
|
-
key={attribute.attributeKey}
|
|
64
|
-
{...attribute}
|
|
65
|
-
labels={labels}
|
|
66
|
-
onCopyToClipboard={onCopyToClipboard}
|
|
67
|
-
testID={testID}
|
|
68
|
-
/>
|
|
69
|
-
))}
|
|
70
|
-
</View>
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const styles = StyleSheet.create({
|
|
75
|
-
wrapper: {
|
|
76
|
-
marginBottom: 20,
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
export default memo(EntityAttributes);
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { IdentifierListItem, TrustEntityRole, TrustEntityState } from '@procivis/react-native-one-core';
|
|
2
|
-
import React, { FC, memo } from 'react';
|
|
3
|
-
import { StyleProp, View, ViewStyle } from 'react-native';
|
|
4
|
-
|
|
5
|
-
import { AttributesLabels, EntityLabels, EntityType } from '../../ui-components/screens/nerd-mode-screen';
|
|
6
|
-
import { useAppColorScheme } from '../../ui-components/theme/color-scheme-context';
|
|
7
|
-
import { concatTestID, useIdentifierDetails } from '../../utils';
|
|
8
|
-
import { useTrustEntity } from '../../utils/hooks/core/trust-entity';
|
|
9
|
-
import EntityAttributes from './entity-attributes';
|
|
10
|
-
import EntityDetails from './entity-details';
|
|
11
|
-
import EntityButtons from './EntityButtons';
|
|
12
|
-
|
|
13
|
-
export type ContextRole = Exclude<TrustEntityRole, TrustEntityRole.BOTH>;
|
|
14
|
-
|
|
15
|
-
interface EntityDetailsWithButtonsProps {
|
|
16
|
-
identifier?: IdentifierListItem;
|
|
17
|
-
entityLabels: EntityLabels;
|
|
18
|
-
attributesLabels: AttributesLabels;
|
|
19
|
-
style?: StyleProp<ViewStyle>;
|
|
20
|
-
textColor?: string;
|
|
21
|
-
testID?: string;
|
|
22
|
-
role: ContextRole;
|
|
23
|
-
onCopyToClipboard: (value: string) => void;
|
|
24
|
-
entityType: EntityType;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const EntityDetailsWithButtons: FC<EntityDetailsWithButtonsProps> = ({
|
|
28
|
-
identifier,
|
|
29
|
-
entityLabels,
|
|
30
|
-
attributesLabels,
|
|
31
|
-
onCopyToClipboard,
|
|
32
|
-
role,
|
|
33
|
-
entityType,
|
|
34
|
-
testID,
|
|
35
|
-
...props
|
|
36
|
-
}) => {
|
|
37
|
-
let { data } = useTrustEntity(identifier?.id);
|
|
38
|
-
let { data: identifierDetail } = useIdentifierDetails(identifier?.id);
|
|
39
|
-
const trustEntity = data ?? undefined;
|
|
40
|
-
|
|
41
|
-
const colorScheme = useAppColorScheme();
|
|
42
|
-
|
|
43
|
-
const trusted = Boolean(
|
|
44
|
-
trustEntity &&
|
|
45
|
-
trustEntity.state === TrustEntityState.ACTIVE &&
|
|
46
|
-
(trustEntity.role === TrustEntityRole.BOTH || trustEntity.role === role),
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<View style={{ backgroundColor: colorScheme.nerdView.background }}>
|
|
51
|
-
<EntityDetails
|
|
52
|
-
identifier={identifier}
|
|
53
|
-
labels={{
|
|
54
|
-
unknown: role === TrustEntityRole.ISSUER ? entityLabels.unknownIssuer : entityLabels.unknownVerifier,
|
|
55
|
-
}}
|
|
56
|
-
role={role}
|
|
57
|
-
testID={testID}
|
|
58
|
-
{...props}
|
|
59
|
-
/>
|
|
60
|
-
{trusted && <EntityButtons entity={trustEntity} labels={entityLabels} testID={concatTestID(testID, 'links')} />}
|
|
61
|
-
<EntityAttributes
|
|
62
|
-
certificate={identifierDetail?.certificates?.[0]?.chain}
|
|
63
|
-
did={identifierDetail?.did?.did}
|
|
64
|
-
trustEntity={trustEntity}
|
|
65
|
-
trusted={trusted}
|
|
66
|
-
labels={attributesLabels}
|
|
67
|
-
onCopyToClipboard={onCopyToClipboard}
|
|
68
|
-
entityType={entityType}
|
|
69
|
-
testID={testID}
|
|
70
|
-
/>
|
|
71
|
-
</View>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export default memo(EntityDetailsWithButtons);
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CertificateDetail,
|
|
3
|
-
IdentifierListItem,
|
|
4
|
-
IdentifierType,
|
|
5
|
-
TrustEntityDetail,
|
|
6
|
-
TrustEntityRole,
|
|
7
|
-
TrustEntityState,
|
|
8
|
-
} from '@procivis/react-native-one-core';
|
|
9
|
-
import React, { FC, ReactNode, useMemo } from 'react';
|
|
10
|
-
import { StyleProp, ViewStyle } from 'react-native';
|
|
11
|
-
|
|
12
|
-
import { AvatarProps } from '../../ui-components';
|
|
13
|
-
import EntityCluster from '../../ui-components/entity/entity-cluster';
|
|
14
|
-
import { EntityNotTrustedIcon, EntityTrustedIcon } from '../../ui-components/icons';
|
|
15
|
-
import { concatTestID, replaceBreakingHyphens, useIdentifierDetails } from '../../utils';
|
|
16
|
-
import { useTrustEntity } from '../../utils/hooks/core/trust-entity';
|
|
17
|
-
|
|
18
|
-
export type EntityDetailsLabels = {
|
|
19
|
-
unknown: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type EntityDetailsProps = {
|
|
23
|
-
labels: EntityDetailsLabels;
|
|
24
|
-
renderMore?: (trustEntity: TrustEntityDetail) => ReactNode;
|
|
25
|
-
role: Exclude<TrustEntityRole, TrustEntityRole.BOTH>;
|
|
26
|
-
style?: StyleProp<ViewStyle>;
|
|
27
|
-
sublineColor?: string;
|
|
28
|
-
textColor?: string;
|
|
29
|
-
testID?: string;
|
|
30
|
-
} & (
|
|
31
|
-
| {
|
|
32
|
-
identifier?: IdentifierListItem;
|
|
33
|
-
}
|
|
34
|
-
| {
|
|
35
|
-
entity: TrustEntityDetail;
|
|
36
|
-
}
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
const getCertificateCommonName = (certificate: CertificateDetail): string | undefined => {
|
|
40
|
-
return certificate.x509Attributes.subject
|
|
41
|
-
.split(', ')
|
|
42
|
-
.find((s) => s.startsWith('CN'))
|
|
43
|
-
?.split('=')
|
|
44
|
-
?.pop();
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const EntityDetails: FC<EntityDetailsProps> = ({
|
|
48
|
-
labels,
|
|
49
|
-
renderMore,
|
|
50
|
-
role,
|
|
51
|
-
style,
|
|
52
|
-
testID,
|
|
53
|
-
sublineColor,
|
|
54
|
-
textColor,
|
|
55
|
-
...props
|
|
56
|
-
}) => {
|
|
57
|
-
const { data, isLoading: isLoadingTrustEntity } = useTrustEntity(
|
|
58
|
-
'identifier' in props ? props.identifier?.id : undefined,
|
|
59
|
-
);
|
|
60
|
-
const trustEntity = 'entity' in props ? props.entity : data ?? undefined;
|
|
61
|
-
const { data: identifierDetail, isLoading: isLoadingIdentifier } = useIdentifierDetails(
|
|
62
|
-
'identifier' in props ? props.identifier?.id : undefined,
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const trusted =
|
|
66
|
-
trustEntity &&
|
|
67
|
-
trustEntity.state === TrustEntityState.ACTIVE &&
|
|
68
|
-
(trustEntity.role === TrustEntityRole.BOTH || trustEntity.role === role);
|
|
69
|
-
|
|
70
|
-
const isLoading = isLoadingIdentifier || isLoadingTrustEntity;
|
|
71
|
-
|
|
72
|
-
const avatarProps: AvatarProps | undefined = useMemo(() => {
|
|
73
|
-
if (isLoading) {
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const avatar =
|
|
78
|
-
trusted && identifierDetail?.type === 'DID' && trustEntity.logo
|
|
79
|
-
? { imageSource: { uri: trustEntity.logo } }
|
|
80
|
-
: undefined;
|
|
81
|
-
|
|
82
|
-
const placeholderText =
|
|
83
|
-
identifierDetail?.type === IdentifierType.CERTIFICATE && identifierDetail.certificates?.[0]
|
|
84
|
-
? getCertificateCommonName(identifierDetail.certificates[0])?.substring(0, 1)
|
|
85
|
-
: 'D';
|
|
86
|
-
|
|
87
|
-
const statusIcon = trusted ? (
|
|
88
|
-
<EntityTrustedIcon testID={concatTestID(testID, 'statusIcon', 'trusted')} />
|
|
89
|
-
) : (
|
|
90
|
-
<EntityNotTrustedIcon testID={concatTestID(testID, 'statusIcon', 'notTrusted')} />
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
if (trustEntity) {
|
|
94
|
-
return {
|
|
95
|
-
avatar,
|
|
96
|
-
placeholderText:
|
|
97
|
-
trusted && identifierDetail?.type === 'DID' ? trustEntity.name.substring(0, 1) : placeholderText,
|
|
98
|
-
statusIcon,
|
|
99
|
-
testID: concatTestID(testID, 'avatar'),
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return {
|
|
104
|
-
placeholderText,
|
|
105
|
-
statusIcon,
|
|
106
|
-
};
|
|
107
|
-
}, [trustEntity, trusted, identifierDetail, isLoading, testID]);
|
|
108
|
-
|
|
109
|
-
const trustEntityName = useMemo(() => {
|
|
110
|
-
if (isLoading) {
|
|
111
|
-
return '';
|
|
112
|
-
}
|
|
113
|
-
if (identifierDetail?.type === IdentifierType.CERTIFICATE && identifierDetail.certificates?.[0]) {
|
|
114
|
-
const commonName = getCertificateCommonName(identifierDetail.certificates[0]);
|
|
115
|
-
if (commonName) {
|
|
116
|
-
return commonName;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (trustEntity) {
|
|
120
|
-
return trustEntity.name;
|
|
121
|
-
}
|
|
122
|
-
if (identifierDetail?.did?.did) {
|
|
123
|
-
return replaceBreakingHyphens(identifierDetail.did.did);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return labels.unknown;
|
|
127
|
-
}, [labels.unknown, trustEntity, identifierDetail, isLoading]);
|
|
128
|
-
|
|
129
|
-
return (
|
|
130
|
-
<>
|
|
131
|
-
<EntityCluster
|
|
132
|
-
avatar={avatarProps}
|
|
133
|
-
entityName={trustEntityName}
|
|
134
|
-
style={style}
|
|
135
|
-
testID={testID}
|
|
136
|
-
textColor={textColor}
|
|
137
|
-
sublineColor={sublineColor}
|
|
138
|
-
isLoading={isLoading}
|
|
139
|
-
/>
|
|
140
|
-
{trustEntity && renderMore && renderMore(trustEntity)}
|
|
141
|
-
</>
|
|
142
|
-
);
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
export default EntityDetails;
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CreateRemoteTrustEntityRequest,
|
|
3
|
-
IdentifierType,
|
|
4
|
-
ONECore,
|
|
5
|
-
OneError,
|
|
6
|
-
TrustAnchorDetail,
|
|
7
|
-
UpdateRemoteTrustEntityRequest,
|
|
8
|
-
} from '@procivis/react-native-one-core';
|
|
9
|
-
import { useCallback } from 'react';
|
|
10
|
-
import { useMutation, useQuery, useQueryClient } from 'react-query';
|
|
11
|
-
|
|
12
|
-
import { reportException } from '../../reporting';
|
|
13
|
-
import { useHTTPClient } from '../http/client';
|
|
14
|
-
import { useONECore } from './core-context';
|
|
15
|
-
import { OneErrorCode } from './error-code';
|
|
16
|
-
import { HISTORY_LIST_QUERY_KEY } from './history';
|
|
17
|
-
import { useIdentifierDetails } from './identifiers';
|
|
18
|
-
|
|
19
|
-
export const TRUST_ENTITY_DETAIL_QUERY_KEY = 'trust-entity-detail';
|
|
20
|
-
export const REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY = 'remote-trust-entity-detail';
|
|
21
|
-
|
|
22
|
-
export const useCreateTrustAnchor = () => {
|
|
23
|
-
const httpClient = useHTTPClient();
|
|
24
|
-
|
|
25
|
-
return useCallback(
|
|
26
|
-
async (core: ONECore, publisherReference: string) => {
|
|
27
|
-
const trustAnchors = await core.listTrustAnchors({
|
|
28
|
-
page: 0,
|
|
29
|
-
pageSize: 1,
|
|
30
|
-
});
|
|
31
|
-
if (trustAnchors.values.length > 0) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const response = await httpClient.get<TrustAnchorDetail>(publisherReference);
|
|
35
|
-
if (!response.ok || !response.data) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const trustAnchor = response.data;
|
|
39
|
-
await core
|
|
40
|
-
.createTrustAnchor({
|
|
41
|
-
isPublisher: false,
|
|
42
|
-
name: trustAnchor.name,
|
|
43
|
-
publisherReference,
|
|
44
|
-
type: TrustManagementEnum.SimpleTrustList,
|
|
45
|
-
})
|
|
46
|
-
.catch((err) => {
|
|
47
|
-
reportException(err, 'Failed to create trust anchor');
|
|
48
|
-
throw err;
|
|
49
|
-
});
|
|
50
|
-
},
|
|
51
|
-
[httpClient],
|
|
52
|
-
);
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const useTrustEntity = (identifierId: string | undefined) => {
|
|
56
|
-
const { core } = useONECore();
|
|
57
|
-
|
|
58
|
-
const { data: identifierDetail } = useIdentifierDetails(identifierId);
|
|
59
|
-
|
|
60
|
-
return useQuery(
|
|
61
|
-
[TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],
|
|
62
|
-
() =>
|
|
63
|
-
identifierId && identifierDetail
|
|
64
|
-
? core
|
|
65
|
-
.resolveTrustEntityByIdentifier({
|
|
66
|
-
identifiers: [
|
|
67
|
-
{
|
|
68
|
-
certificateId:
|
|
69
|
-
identifierDetail?.type === IdentifierType.CERTIFICATE
|
|
70
|
-
? identifierDetail.certificates?.[0]?.id
|
|
71
|
-
: undefined,
|
|
72
|
-
id: identifierId,
|
|
73
|
-
},
|
|
74
|
-
],
|
|
75
|
-
})
|
|
76
|
-
.then((result) => {
|
|
77
|
-
return result[identifierId]?.[0]?.trustEntity ?? null;
|
|
78
|
-
})
|
|
79
|
-
.catch((e) => {
|
|
80
|
-
if (e instanceof OneError && e.code === OneErrorCode.NoTrustEntityFound) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
throw e;
|
|
84
|
-
})
|
|
85
|
-
: undefined,
|
|
86
|
-
{
|
|
87
|
-
enabled: Boolean(identifierDetail),
|
|
88
|
-
keepPreviousData: true,
|
|
89
|
-
},
|
|
90
|
-
);
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
export const useRemoteTrustEntity = (identifierId: string | undefined) => {
|
|
94
|
-
const { core } = useONECore();
|
|
95
|
-
|
|
96
|
-
const { data: identifierDetail } = useIdentifierDetails(identifierId);
|
|
97
|
-
|
|
98
|
-
return useQuery(
|
|
99
|
-
[REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],
|
|
100
|
-
() => (identifierDetail?.did ? core.getRemoteTrustEntity(identifierDetail.did.id) : undefined),
|
|
101
|
-
{
|
|
102
|
-
enabled: Boolean(identifierDetail?.did),
|
|
103
|
-
keepPreviousData: true,
|
|
104
|
-
},
|
|
105
|
-
);
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const useCreateRemoteTrustEntity = () => {
|
|
109
|
-
const queryClient = useQueryClient();
|
|
110
|
-
const { core } = useONECore();
|
|
111
|
-
|
|
112
|
-
return useMutation(
|
|
113
|
-
async (request: Omit<CreateRemoteTrustEntityRequest, 'didId'> & { identifierId?: string; didId?: string }) => {
|
|
114
|
-
const { identifierId, didId } = request;
|
|
115
|
-
|
|
116
|
-
let entityDidId = didId;
|
|
117
|
-
|
|
118
|
-
if (identifierId) {
|
|
119
|
-
const identifierDetail = await core.getIdentifier(identifierId);
|
|
120
|
-
entityDidId = identifierDetail?.did?.id;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
return core.createRemoteTrustEntity({
|
|
124
|
-
...request,
|
|
125
|
-
didId: entityDidId!,
|
|
126
|
-
});
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
onSuccess: async () => {
|
|
130
|
-
await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);
|
|
131
|
-
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
);
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export const useUpdateRemoteTrustEntity = () => {
|
|
138
|
-
const queryClient = useQueryClient();
|
|
139
|
-
const { core } = useONECore();
|
|
140
|
-
|
|
141
|
-
return useMutation(
|
|
142
|
-
async (
|
|
143
|
-
request: Omit<UpdateRemoteTrustEntityRequest, 'didId'> & {
|
|
144
|
-
identifierId?: string;
|
|
145
|
-
didId?: string;
|
|
146
|
-
},
|
|
147
|
-
) => {
|
|
148
|
-
const { identifierId, didId } = request;
|
|
149
|
-
|
|
150
|
-
let entityDidId = didId;
|
|
151
|
-
if (identifierId) {
|
|
152
|
-
const identifierDetail = await core.getIdentifier(identifierId);
|
|
153
|
-
entityDidId = identifierDetail?.did?.id;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
return core.updateRemoteTrustEntity({
|
|
157
|
-
...request,
|
|
158
|
-
didId: entityDidId!,
|
|
159
|
-
});
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
onSuccess: async () => {
|
|
163
|
-
await queryClient.invalidateQueries(REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY);
|
|
164
|
-
await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
export enum TrustManagementEnum {
|
|
171
|
-
SimpleTrustList = 'SIMPLE_TRUST_LIST',
|
|
172
|
-
}
|