@procivis/one-react-native-components 0.3.22 → 0.3.27

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.
Files changed (113) hide show
  1. package/lib/commonjs/components/entity/entity-attributes.js +1 -1
  2. package/lib/commonjs/components/entity/entity-attributes.js.map +1 -1
  3. package/lib/commonjs/components/entity/entity-details-with-buttons.js +15 -6
  4. package/lib/commonjs/components/entity/entity-details-with-buttons.js.map +1 -1
  5. package/lib/commonjs/components/entity/entity-details.js +18 -17
  6. package/lib/commonjs/components/entity/entity-details.js.map +1 -1
  7. package/lib/commonjs/components/history/history-list-item-icon.js +4 -1
  8. package/lib/commonjs/components/history/history-list-item-icon.js.map +1 -1
  9. package/lib/commonjs/components/history/history-list-item.js +12 -2
  10. package/lib/commonjs/components/history/history-list-item.js.map +1 -1
  11. package/lib/commonjs/components/history/history-list-screen.js +2 -0
  12. package/lib/commonjs/components/history/history-list-screen.js.map +1 -1
  13. package/lib/commonjs/components/proof-request/share-credential.js +3 -2
  14. package/lib/commonjs/components/proof-request/share-credential.js.map +1 -1
  15. package/lib/commonjs/ui-components/entity/entity-cluster.js +1 -1
  16. package/lib/commonjs/ui-components/entity/entity-cluster.js.map +1 -1
  17. package/lib/commonjs/ui-components/icons/entity.js +29 -1
  18. package/lib/commonjs/ui-components/icons/entity.js.map +1 -1
  19. package/lib/commonjs/ui-components/icons/history.js +3 -1
  20. package/lib/commonjs/ui-components/icons/history.js.map +1 -1
  21. package/lib/commonjs/ui-components/screens/nerd-mode-screen.js +1 -1
  22. package/lib/commonjs/ui-components/screens/nerd-mode-screen.js.map +1 -1
  23. package/lib/commonjs/utils/hooks/core/core-init.js +27 -23
  24. package/lib/commonjs/utils/hooks/core/core-init.js.map +1 -1
  25. package/lib/commonjs/utils/hooks/core/credentials.js +2 -1
  26. package/lib/commonjs/utils/hooks/core/credentials.js.map +1 -1
  27. package/lib/commonjs/utils/hooks/core/identifiers.js +20 -0
  28. package/lib/commonjs/utils/hooks/core/identifiers.js.map +1 -0
  29. package/lib/commonjs/utils/hooks/core/index.js +11 -0
  30. package/lib/commonjs/utils/hooks/core/index.js.map +1 -1
  31. package/lib/commonjs/utils/hooks/core/proofs.js +2 -1
  32. package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
  33. package/lib/commonjs/utils/hooks/core/trust-entity.js +9 -3
  34. package/lib/commonjs/utils/hooks/core/trust-entity.js.map +1 -1
  35. package/lib/commonjs/utils/parsers/credential-sharing.js +8 -5
  36. package/lib/commonjs/utils/parsers/credential-sharing.js.map +1 -1
  37. package/lib/commonjs/utils/parsers/credential.js +7 -0
  38. package/lib/commonjs/utils/parsers/credential.js.map +1 -1
  39. package/lib/commonjs/utils/parsers/query.js +2 -2
  40. package/lib/commonjs/utils/parsers/query.js.map +1 -1
  41. package/lib/module/components/entity/entity-attributes.js +1 -1
  42. package/lib/module/components/entity/entity-attributes.js.map +1 -1
  43. package/lib/module/components/entity/entity-details-with-buttons.js +17 -8
  44. package/lib/module/components/entity/entity-details-with-buttons.js.map +1 -1
  45. package/lib/module/components/entity/entity-details.js +20 -19
  46. package/lib/module/components/entity/entity-details.js.map +1 -1
  47. package/lib/module/components/history/history-list-item-icon.js +5 -2
  48. package/lib/module/components/history/history-list-item-icon.js.map +1 -1
  49. package/lib/module/components/history/history-list-item.js +12 -2
  50. package/lib/module/components/history/history-list-item.js.map +1 -1
  51. package/lib/module/components/history/history-list-screen.js +2 -0
  52. package/lib/module/components/history/history-list-screen.js.map +1 -1
  53. package/lib/module/components/proof-request/share-credential.js +3 -2
  54. package/lib/module/components/proof-request/share-credential.js.map +1 -1
  55. package/lib/module/ui-components/entity/entity-cluster.js +1 -1
  56. package/lib/module/ui-components/entity/entity-cluster.js.map +1 -1
  57. package/lib/module/ui-components/icons/entity.js +27 -0
  58. package/lib/module/ui-components/icons/entity.js.map +1 -1
  59. package/lib/module/ui-components/icons/history.js +2 -0
  60. package/lib/module/ui-components/icons/history.js.map +1 -1
  61. package/lib/module/ui-components/screens/nerd-mode-screen.js +1 -1
  62. package/lib/module/ui-components/screens/nerd-mode-screen.js.map +1 -1
  63. package/lib/module/utils/hooks/core/core-init.js +27 -23
  64. package/lib/module/utils/hooks/core/core-init.js.map +1 -1
  65. package/lib/module/utils/hooks/core/credentials.js +2 -1
  66. package/lib/module/utils/hooks/core/credentials.js.map +1 -1
  67. package/lib/module/utils/hooks/core/identifiers.js +13 -0
  68. package/lib/module/utils/hooks/core/identifiers.js.map +1 -0
  69. package/lib/module/utils/hooks/core/index.js +1 -0
  70. package/lib/module/utils/hooks/core/index.js.map +1 -1
  71. package/lib/module/utils/hooks/core/proofs.js +2 -1
  72. package/lib/module/utils/hooks/core/proofs.js.map +1 -1
  73. package/lib/module/utils/hooks/core/trust-entity.js +9 -3
  74. package/lib/module/utils/hooks/core/trust-entity.js.map +1 -1
  75. package/lib/module/utils/parsers/credential-sharing.js +8 -5
  76. package/lib/module/utils/parsers/credential-sharing.js.map +1 -1
  77. package/lib/module/utils/parsers/credential.js +7 -0
  78. package/lib/module/utils/parsers/credential.js.map +1 -1
  79. package/lib/module/utils/parsers/query.js +2 -2
  80. package/lib/module/utils/parsers/query.js.map +1 -1
  81. package/lib/typescript/components/entity/entity-details-with-buttons.d.ts +3 -2
  82. package/lib/typescript/components/entity/entity-details.d.ts +3 -2
  83. package/lib/typescript/components/history/history-list-item.d.ts +1 -0
  84. package/lib/typescript/components/history/history-list-screen.d.ts +2 -0
  85. package/lib/typescript/ui-components/icons/entity.d.ts +1 -0
  86. package/lib/typescript/ui-components/icons/history.d.ts +2 -0
  87. package/lib/typescript/ui-components/screens/nerd-mode-screen.d.ts +4 -4
  88. package/lib/typescript/utils/hooks/core/credentials.d.ts +2 -1
  89. package/lib/typescript/utils/hooks/core/identifiers.d.ts +2 -0
  90. package/lib/typescript/utils/hooks/core/index.d.ts +1 -0
  91. package/lib/typescript/utils/hooks/core/proofs.d.ts +2 -1
  92. package/lib/typescript/utils/hooks/core/trust-entity.d.ts +1 -1
  93. package/package.json +4 -4
  94. package/src/components/entity/entity-attributes.tsx +1 -1
  95. package/src/components/entity/entity-details-with-buttons.tsx +18 -12
  96. package/src/components/entity/entity-details.tsx +24 -27
  97. package/src/components/history/history-list-item-icon.tsx +5 -0
  98. package/src/components/history/history-list-item.tsx +13 -2
  99. package/src/components/history/history-list-screen.tsx +4 -1
  100. package/src/components/proof-request/share-credential.tsx +2 -1
  101. package/src/ui-components/entity/entity-cluster.tsx +1 -1
  102. package/src/ui-components/icons/entity.tsx +27 -0
  103. package/src/ui-components/icons/history.tsx +2 -0
  104. package/src/ui-components/screens/nerd-mode-screen.tsx +5 -5
  105. package/src/utils/hooks/core/core-init.ts +26 -22
  106. package/src/utils/hooks/core/credentials.ts +9 -3
  107. package/src/utils/hooks/core/identifiers.ts +18 -0
  108. package/src/utils/hooks/core/index.ts +2 -1
  109. package/src/utils/hooks/core/proofs.ts +4 -2
  110. package/src/utils/hooks/core/trust-entity.ts +14 -10
  111. package/src/utils/parsers/credential-sharing.tsx +25 -25
  112. package/src/utils/parsers/credential.ts +4 -0
  113. package/src/utils/parsers/query.tsx +2 -2
@@ -1,10 +1,11 @@
1
- import { DidListItem, TrustEntity, TrustEntityRoleEnum, TrustEntityStateEnum } from '@procivis/react-native-one-core';
1
+ import { TrustEntity, TrustEntityRoleEnum, TrustEntityStateEnum } from '@procivis/react-native-one-core';
2
+ import { IdentifierListItem } from '@procivis/react-native-one-core/dist/src/identifier';
2
3
  import React, { FC, ReactNode, useMemo } from 'react';
3
4
  import { StyleProp, ViewStyle } from 'react-native';
4
5
 
5
6
  import EntityCluster from '../../ui-components/entity/entity-cluster';
6
- import { EntityTrustedIcon } from '../../ui-components/icons';
7
- import { concatTestID, replaceBreakingHyphens } from '../../utils';
7
+ import { EntityNotTrustedIcon, EntityTrustedIcon } from '../../ui-components/icons';
8
+ import { concatTestID, replaceBreakingHyphens, useIdentifierDetails } from '../../utils';
8
9
  import { useTrustEntity } from '../../utils/hooks/core/trust-entity';
9
10
 
10
11
  export type EntityDetailsLabels = {
@@ -18,17 +19,18 @@ export type EntityDetailsProps = {
18
19
  style?: StyleProp<ViewStyle>;
19
20
  testID?: string;
20
21
  } & (
21
- | {
22
- did?: DidListItem;
22
+ | {
23
+ identifier?: IdentifierListItem;
23
24
  }
24
- | {
25
+ | {
25
26
  entity: TrustEntity;
26
27
  }
27
- );
28
+ );
28
29
 
29
30
  const EntityDetails: FC<EntityDetailsProps> = ({ labels, renderMore, role, style, testID, ...props }) => {
30
- const { data } = useTrustEntity('did' in props ? props.did?.id : undefined);
31
+ const { data } = useTrustEntity('identifier' in props ? props.identifier?.id : undefined);
31
32
  const trustEntity: TrustEntity | undefined = 'entity' in props ? props.entity : data ?? undefined;
33
+ const { data: identifierDetail } = useIdentifierDetails('identifier' in props ? props.identifier?.id : undefined);
32
34
 
33
35
  const trusted =
34
36
  trustEntity &&
@@ -37,24 +39,17 @@ const EntityDetails: FC<EntityDetailsProps> = ({ labels, renderMore, role, style
37
39
 
38
40
  const trustEntityName = useMemo(() => {
39
41
  if (!trusted) {
42
+ if (identifierDetail?.did?.did) {
43
+ return replaceBreakingHyphens(identifierDetail.did.did);
44
+ }
40
45
  return labels.unknown;
41
46
  }
42
47
  return trustEntity.name;
43
- }, [labels.unknown, trustEntity, trusted]);
44
-
45
- const trustEntitySubline = useMemo(() => {
46
- if (!trustEntity) {
47
- return 'did' in props ? (props.did?.did ? replaceBreakingHyphens(props.did.did) : undefined) : undefined;
48
- }
49
- if (!trusted) {
50
- return replaceBreakingHyphens(trustEntity.did.did);
51
- }
52
- return undefined;
53
- }, [props, trustEntity, trusted]);
48
+ }, [labels.unknown, trustEntity, trusted, identifierDetail]);
54
49
 
55
50
  const trustEntityStatusIcon = useMemo(() => {
56
51
  if (!trusted) {
57
- return undefined;
52
+ return <EntityNotTrustedIcon testID={concatTestID(testID, 'statusIcon', 'notTrusted')} />;
58
53
  }
59
54
  return <EntityTrustedIcon testID={concatTestID(testID, 'statusIcon', 'trusted')} />;
60
55
  }, [testID, trusted]);
@@ -65,16 +60,18 @@ const EntityDetails: FC<EntityDetailsProps> = ({ labels, renderMore, role, style
65
60
  avatar={
66
61
  trustEntity
67
62
  ? {
68
- avatar: trusted && trustEntity.logo ? { imageSource: { uri: trustEntity.logo } } : undefined,
69
- placeholderText: trustEntity.name.substring(0, 1),
70
- statusIcon: trustEntityStatusIcon,
71
- testID: concatTestID(testID, 'avatar'),
72
- }
73
- : undefined
63
+ avatar: trusted && trustEntity.logo ? { imageSource: { uri: trustEntity.logo } } : undefined,
64
+ placeholderText: trusted ? trustEntity.name.substring(0, 1) : "U",
65
+ statusIcon: trustEntityStatusIcon,
66
+ testID: concatTestID(testID, 'avatar'),
67
+ }
68
+ : {
69
+ statusIcon: trustEntityStatusIcon,
70
+ placeholderText: "U",
71
+ }
74
72
  }
75
73
  entityName={trustEntityName}
76
74
  style={style}
77
- subline={trustEntitySubline}
78
75
  testID={testID}
79
76
  />
80
77
  {trustEntity && renderMore && renderMore(trustEntity)}
@@ -5,8 +5,10 @@ import { SvgProps } from 'react-native-svg';
5
5
  import {
6
6
  HistoryBackupCreatedIcon,
7
7
  HistoryBackupRestoredIcon,
8
+ HistoryCertificateIcon,
8
9
  HistoryCredentialIcon,
9
10
  HistoryDidIcon,
11
+ HistoryIdentifierIcon,
10
12
  HistoryIssueIcon,
11
13
  HistoryItemIcon,
12
14
  HistoryKeyIcon,
@@ -51,12 +53,15 @@ const defaultIcons: {
51
53
  WITHDRAWN: HistoryStatusErrorIcon,
52
54
  REACTIVATED: HistoryStatusAcceptedIcon,
53
55
  CSR_GENERATED: HistoryStatusAcceptedIcon,
56
+ EXPIRED: HistoryStatusErrorIcon,
54
57
  },
55
58
  entityTypes: {
56
59
  BACKUP: HistoryRevokeIcon,
60
+ CERTIFICATE: HistoryCertificateIcon,
57
61
  CREDENTIAL: HistoryCredentialIcon,
58
62
  CREDENTIAL_SCHEMA: HistorySchemaIcon,
59
63
  DID: HistoryDidIcon,
64
+ IDENTIFIER: HistoryIdentifierIcon,
60
65
  KEY: HistoryKeyIcon,
61
66
  ORGANISATION: HistoryOrganisationIcon,
62
67
  PROOF: HistoryProofRequestIcon,
@@ -13,6 +13,7 @@ export type HistoryListItemLabels = {
13
13
  export interface HistoryListItemViewProps {
14
14
  dateFormatter?: (date: Date) => string;
15
15
  first?: boolean;
16
+ infoLabelMode?: 'entity' | 'associatedLabel' | 'none';
16
17
  item: HistoryListItem;
17
18
  labels: HistoryListItemLabels;
18
19
  last?: boolean;
@@ -23,15 +24,25 @@ export interface HistoryListItemViewProps {
23
24
  export const HistoryListItemView: FC<HistoryListItemViewProps> = ({
24
25
  dateFormatter = formatTime,
25
26
  first,
27
+ infoLabelMode = 'entity',
26
28
  item,
27
29
  labels,
28
30
  last,
29
31
  onPress,
30
32
  testID
31
33
  }) => {
32
- const { data: entity } = useTrustEntity(item.target);
34
+ const { data: entity } = useTrustEntity(infoLabelMode === 'entity' ? item.target : undefined);
33
35
 
34
36
  const label = `${labels.entityTypes[item.entityType]} ${labels.actions[item.action]}`;
37
+ let infoLabel;
38
+ switch (infoLabelMode) {
39
+ case 'entity':
40
+ infoLabel = entity?.name;
41
+ break;
42
+ case 'associatedLabel':
43
+ infoLabel = item.name;
44
+ break;
45
+ }
35
46
  const icon = <HistoryListItemIcon item={item} />;
36
47
 
37
48
  const pressHandler = useCallback(() => {
@@ -42,7 +53,7 @@ export const HistoryListItemView: FC<HistoryListItemViewProps> = ({
42
53
  <HistoryItemView
43
54
  first={first}
44
55
  icon={icon}
45
- info={entity?.name}
56
+ info={infoLabel}
46
57
  label={label}
47
58
  last={last}
48
59
  onPress={pressHandler}
@@ -13,6 +13,7 @@ import {
13
13
  } from '../../ui-components';
14
14
  import { concatTestID, groupEntriesByDay, HistoryGroupByDaySection, useListContentInset } from '../../utils';
15
15
  import { HistoryListLabels, HistoryListView } from './history-list';
16
+ import { HistoryListItemViewProps } from './history-list-item';
16
17
 
17
18
  export type HistoryListScreenLabels = {
18
19
  emptyTitle: string;
@@ -24,6 +25,7 @@ export type HistoryListScreenLabels = {
24
25
 
25
26
  export type HistoryListScreenProps = {
26
27
  groupItems?: (entries: HistoryListItem[]) => HistoryGroupByDaySection[];
28
+ itemInfoLabelMode?: HistoryListItemViewProps['infoLabelMode'];
27
29
  labels: HistoryListScreenLabels;
28
30
  onBackPressed: () => void;
29
31
  onHistoryItemPressed: (historyItem: HistoryListItem) => void;
@@ -36,6 +38,7 @@ export type HistoryListScreenProps = {
36
38
  export const HistoryListScreen: FC<PropsWithChildren<HistoryListScreenProps>> = ({
37
39
  children,
38
40
  groupItems = groupEntriesByDay,
41
+ itemInfoLabelMode = 'entity',
39
42
  labels,
40
43
  onBackPressed,
41
44
  onHistoryItemPressed,
@@ -92,7 +95,7 @@ export const HistoryListScreen: FC<PropsWithChildren<HistoryListScreenProps>> =
92
95
  <HistoryListView
93
96
  contentContainerStyle={insets}
94
97
  groupItems={groupItems}
95
- itemProps={{ onPress: onHistoryItemPressed }}
98
+ itemProps={{ infoLabelMode: itemInfoLabelMode, onPress: onHistoryItemPressed }}
96
99
  onEmpty={setEmpty}
97
100
  onScroll={Animated.event([{ nativeEvent: { contentOffset: { y: scrollOffset } } }], {
98
101
  useNativeDriver: true,
@@ -70,7 +70,8 @@ export const ShareCredential: FunctionComponent<{
70
70
  credential
71
71
  ? {
72
72
  ...credential,
73
- issuerDid: credential?.issuerDid?.did,
73
+ issuerDid: credential?.issuerDid?.id,
74
+ issuer: credential?.issuer?.id,
74
75
  }
75
76
  : undefined,
76
77
  );
@@ -44,7 +44,7 @@ const EntityCluster: FunctionComponent<EntityClusterProps> = ({
44
44
  <Typography
45
45
  testID={concatTestID(testID, 'entityName')}
46
46
  color={textColor ?? colorScheme.text}
47
- numberOfLines={2}
47
+ numberOfLines={1}
48
48
  preset="m"
49
49
  style={styles.entityName}>
50
50
  {entityName}
@@ -29,3 +29,30 @@ export const EntityTrustedIcon: FC<SvgProps> = ({ ...props }) => {
29
29
  </Svg>
30
30
  );
31
31
  };
32
+
33
+ // https://www.figma.com/design/52qDYWUMjXAGre1dcnz5bz/Procivis-One-Wallet?node-id=415-5402&t=prmu1s6PuABrPg0l-0
34
+ export const EntityNotTrustedIcon: FC<SvgProps> = ({ ...props }) => {
35
+ const colorScheme = useAppColorScheme();
36
+ return (
37
+ <Svg width={22} height={20} viewBox="0 0 22 20" fill="none" {...props}>
38
+ <Path
39
+ d="M4.35742 17.9673C3.87598 17.9673 3.45817 17.8621 3.104 17.6519C2.74984 17.4416 2.47591 17.1593 2.28223 16.8052C2.09408 16.451 2 16.0581 2 15.6265C2 15.2059 2.11068 14.8047 2.33203 14.4229L8.75684 3.2251C8.97266 2.83219 9.26318 2.53613 9.62842 2.33691C9.99365 2.1377 10.3755 2.03809 10.7739 2.03809C11.1724 2.03809 11.5514 2.1377 11.9111 2.33691C12.2708 2.5306 12.5641 2.82666 12.791 3.2251L19.2158 14.4229C19.3265 14.611 19.4095 14.8075 19.4648 15.0122C19.5202 15.217 19.5479 15.4217 19.5479 15.6265C19.5479 16.0581 19.451 16.451 19.2573 16.8052C19.0636 17.1593 18.7897 17.4416 18.4355 17.6519C18.0869 17.8621 17.6719 17.9673 17.1904 17.9673H4.35742Z"
40
+ fill={colorScheme.warning}
41
+ />
42
+ <Path
43
+ d="M10.7744 1.03809C11.3435 1.03817 11.884 1.18254 12.3838 1.45703L12.3848 1.45605C12.386 1.45672 12.3874 1.45831 12.3887 1.45898C12.3908 1.46017 12.3933 1.46072 12.3955 1.46191L12.3945 1.46289C12.9333 1.75557 13.3522 2.19115 13.6582 2.72754L20.0781 13.916L20.1865 14.1162C20.2888 14.3193 20.3712 14.5309 20.4307 14.751C20.5082 15.0377 20.5479 15.331 20.5479 15.627C20.5478 16.2141 20.4144 16.7738 20.1348 17.2852C19.8533 17.7998 19.4512 18.2119 18.9463 18.5117L18.9453 18.5107C18.4159 18.8284 17.818 18.9678 17.1904 18.9678H4.35742C3.72707 18.9678 3.12678 18.8281 2.59375 18.5117C2.08885 18.2119 1.68678 17.7998 1.40527 17.2852L1.39941 17.2744C1.1288 16.765 1.00007 16.2092 1 15.627C1 15.0214 1.16165 14.4473 1.4668 13.9209L7.88965 2.72754C8.1894 2.18833 8.60891 1.75383 9.14941 1.45898C9.65481 1.18331 10.2012 1.03809 10.7744 1.03809Z"
44
+ stroke={colorScheme.white}
45
+ strokeWidth={2}
46
+ strokeOpacity={0.2}
47
+ />
48
+ <Path
49
+ d="M11.5376 11.5093C11.5265 12.0239 11.2747 12.2812 10.7822 12.2812C10.2786 12.2812 10.0186 12.0267 10.002 11.5176L9.88574 7.33398C9.87467 7.08496 9.95215 6.88021 10.1182 6.71973C10.2842 6.55371 10.5028 6.4707 10.7739 6.4707C11.0396 6.4707 11.2581 6.55371 11.4297 6.71973C11.6012 6.88021 11.6815 7.08773 11.6704 7.34229L11.5376 11.5093Z"
50
+ fill={colorScheme.black}
51
+ />
52
+ <Path
53
+ d="M11.4961 14.8711C11.2969 15.0482 11.0589 15.1367 10.7822 15.1367C10.5055 15.1367 10.2648 15.0482 10.0601 14.8711C9.86084 14.694 9.76123 14.4671 9.76123 14.1904C9.76123 13.9193 9.86084 13.6924 10.0601 13.5098C10.2593 13.3271 10.5 13.2358 10.7822 13.2358C11.0589 13.2358 11.2969 13.3271 11.4961 13.5098C11.6953 13.6924 11.7949 13.9193 11.7949 14.1904C11.7949 14.4671 11.6953 14.694 11.4961 14.8711Z"
54
+ fill={colorScheme.black}
55
+ />
56
+ </Svg>
57
+ )
58
+ }
@@ -114,6 +114,8 @@ export const HistorySuspendIcon: FC<SvgProps> = (props) => {
114
114
 
115
115
  // TODO: replace HistoryDidIcon with icon of schema
116
116
  export const HistoryDidIcon = HistoryIssueIcon;
117
+ export const HistoryIdentifierIcon = HistoryIssueIcon;
118
+ export const HistoryCertificateIcon = HistoryIssueIcon;
117
119
 
118
120
  // TODO: replace HistoryKeyIcon with icon of schema
119
121
  export const HistoryKeyIcon = HistoryIssueIcon;
@@ -1,4 +1,4 @@
1
- import { DidListItem } from '@procivis/react-native-one-core';
1
+ import { IdentifierListItem } from '@procivis/react-native-one-core/dist/src/identifier';
2
2
  import React, { FunctionComponent, useState } from 'react';
3
3
  import { SectionList, StyleSheet, View } from 'react-native';
4
4
  import Animated, { useAnimatedScrollHandler, useSharedValue } from 'react-native-reanimated';
@@ -26,15 +26,15 @@ export interface EntityLabels {
26
26
 
27
27
  export interface AttributesLabels {
28
28
  trustRegistry: string;
29
- issuerDid: string;
30
- entityDid: string;
29
+ issuerIdentifier: string;
30
+ entityIdentifier: string;
31
31
  role: string;
32
32
  expand: string;
33
33
  collapse: string;
34
34
  }
35
35
 
36
36
  interface SectionEntityCluster {
37
- did?: DidListItem;
37
+ identifier?: IdentifierListItem;
38
38
  subline?: string;
39
39
  entityLabels: EntityLabels;
40
40
  role: ContextRole;
@@ -66,7 +66,7 @@ export enum EntityType {
66
66
  }
67
67
 
68
68
  function isSectionEntityCluster(item: NerdModeSectionItem): item is SectionEntityCluster {
69
- return (item as SectionEntityCluster).did !== undefined;
69
+ return (item as SectionEntityCluster).identifier !== undefined;
70
70
  }
71
71
 
72
72
  const AnimatedSectionList = Animated.createAnimatedComponent(SectionList<NerdModeSectionItem>);
@@ -8,7 +8,7 @@ import { OneErrorCode } from './error-code';
8
8
  export const SW_DID_NAME_PREFIX = 'holder-did-sw-key';
9
9
  export const HW_DID_NAME_PREFIX = 'holder-did-hw-key';
10
10
 
11
- const generateHwDid = async (core: ONECore, organisationId: string) => {
11
+ const generateHwIdentifier = async (core: ONECore, organisationId: string) => {
12
12
  const hwKeyId = await core
13
13
  .generateKey({
14
14
  keyParams: {},
@@ -27,25 +27,27 @@ const generateHwDid = async (core: ONECore, organisationId: string) => {
27
27
  });
28
28
 
29
29
  if (hwKeyId) {
30
- return core.createDid({
31
- didMethod: 'KEY',
32
- keys: {
33
- assertionMethod: [hwKeyId],
34
- authentication: [hwKeyId],
35
- capabilityDelegation: [hwKeyId],
36
- capabilityInvocation: [hwKeyId],
37
- keyAgreement: [hwKeyId],
30
+ return core.createIdentifier({
31
+ did: {
32
+ method: 'KEY',
33
+ keys: {
34
+ assertionMethod: [hwKeyId],
35
+ authentication: [hwKeyId],
36
+ capabilityDelegation: [hwKeyId],
37
+ capabilityInvocation: [hwKeyId],
38
+ keyAgreement: [hwKeyId],
39
+ },
40
+ params: {},
38
41
  },
39
42
  name: HW_DID_NAME_PREFIX,
40
43
  organisationId,
41
- params: {},
42
44
  });
43
45
  }
44
46
 
45
47
  return null;
46
48
  };
47
49
 
48
- const generateSwDid = async (core: ONECore, organisationId: string) => {
50
+ const generateSwIdentifier = async (core: ONECore, organisationId: string) => {
49
51
  const swKeyId = await core.generateKey({
50
52
  keyParams: {},
51
53
  keyType: 'ECDSA',
@@ -55,18 +57,20 @@ const generateSwDid = async (core: ONECore, organisationId: string) => {
55
57
  storageType: 'INTERNAL',
56
58
  });
57
59
 
58
- return core.createDid({
59
- didMethod: 'KEY',
60
- keys: {
61
- assertionMethod: [swKeyId],
62
- authentication: [swKeyId],
63
- capabilityDelegation: [swKeyId],
64
- capabilityInvocation: [swKeyId],
65
- keyAgreement: [swKeyId],
60
+ return core.createIdentifier({
61
+ did: {
62
+ method: 'KEY',
63
+ keys: {
64
+ assertionMethod: [swKeyId],
65
+ authentication: [swKeyId],
66
+ capabilityDelegation: [swKeyId],
67
+ capabilityInvocation: [swKeyId],
68
+ keyAgreement: [swKeyId],
69
+ },
70
+ params: {},
66
71
  },
67
72
  name: SW_DID_NAME_PREFIX,
68
73
  organisationId,
69
- params: {},
70
74
  });
71
75
  };
72
76
 
@@ -94,8 +98,8 @@ export const useInitializeONECoreIdentifiers = ({ generateHwKey, generateSwKey }
94
98
  })
95
99
  .then(() =>
96
100
  Promise.all([
97
- generateHwKey ? generateHwDid(core, organisationId) : null,
98
- generateSwKey ? generateSwDid(core, organisationId) : null,
101
+ generateHwKey ? generateHwIdentifier(core, organisationId) : null,
102
+ generateSwKey ? generateSwIdentifier(core, organisationId) : null,
99
103
  ]),
100
104
  )
101
105
  .catch((err) => {
@@ -95,11 +95,17 @@ export const useCredentialAccept = () => {
95
95
  const queryClient = useQueryClient();
96
96
  const { core } = useONECore();
97
97
 
98
- type CredentialAcceptHookParams = { didId: string; interactionId: string; keyId?: string; txCode?: string };
98
+ type CredentialAcceptHookParams = {
99
+ didId?: string;
100
+ identifierId?: string;
101
+ interactionId: string;
102
+ keyId?: string;
103
+ txCode?: string;
104
+ };
99
105
 
100
106
  return useMutation(
101
- async ({ interactionId, didId, keyId, txCode }: CredentialAcceptHookParams) =>
102
- core.holderAcceptCredential(interactionId, didId, keyId, txCode),
107
+ async ({ interactionId, didId, identifierId, keyId, txCode }: CredentialAcceptHookParams) =>
108
+ core.holderAcceptCredential(interactionId, didId, identifierId, keyId, txCode),
103
109
  {
104
110
  onSuccess: async () => {
105
111
  await queryClient.invalidateQueries(CREDENTIAL_LIST_QUERY_KEY);
@@ -0,0 +1,18 @@
1
+ import { useQuery } from "react-query";
2
+
3
+ import { useONECore } from "./core-context";
4
+
5
+ export const IDENTIFIER_DETAIL_QUERY_KEY = 'identifier-detail';
6
+
7
+ export const useIdentifierDetails = (identifierId: string | undefined) => {
8
+ const { core } = useONECore();
9
+
10
+ return useQuery(
11
+ [IDENTIFIER_DETAIL_QUERY_KEY, identifierId],
12
+ () => (identifierId ? core.getIdentifier(identifierId) : undefined),
13
+ {
14
+ enabled: Boolean(identifierId),
15
+ keepPreviousData: true,
16
+ },
17
+ );
18
+ }
@@ -7,7 +7,8 @@ export * from './credential-schemas';
7
7
  export * from './credentials';
8
8
  export * from './dids';
9
9
  export * from './history';
10
+ export * from './identifiers';
10
11
  export * from './proof-schemas';
11
12
  export * from './proofs';
12
13
  export * from './query';
13
- export * from './trust-entity';
14
+ export * from './trust-entity';
@@ -75,13 +75,15 @@ export const useProofAccept = () => {
75
75
  interactionId,
76
76
  credentials,
77
77
  didId,
78
+ identifierId,
78
79
  keyId,
79
80
  }: {
80
81
  credentials: Record<string, PresentationSubmitCredentialRequest>;
81
- didId: string;
82
+ didId?: string;
83
+ identifierId?: string;
82
84
  interactionId: string;
83
85
  keyId?: string;
84
- }) => core.holderSubmitProof(interactionId, credentials, didId, keyId),
86
+ }) => core.holderSubmitProof(interactionId, credentials, didId, identifierId, keyId),
85
87
  {
86
88
  onError: async () => {
87
89
  await queryClient.invalidateQueries(PROOF_DETAIL_QUERY_KEY);
@@ -13,6 +13,7 @@ import { useHTTPClient } from '../http/client';
13
13
  import { useONECore } from './core-context';
14
14
  import { OneErrorCode } from './error-code';
15
15
  import { HISTORY_LIST_QUERY_KEY } from './history';
16
+ import { useIdentifierDetails } from './identifiers';
16
17
 
17
18
  export const TRUST_ENTITY_DETAIL_QUERY_KEY = 'trust-entity-detail';
18
19
  export const REMOTE_TRUST_ENTITY_DETAIL_QUERY_KEY = 'remote-trust-entity-detail';
@@ -50,22 +51,25 @@ export const useCreateTrustAnchor = (publisherReference: string) => {
50
51
  );
51
52
  };
52
53
 
53
- export const useTrustEntity = (didId: string | undefined) => {
54
+ // NOTE: As per ONE-5672, only handles DID Identifier details
55
+ export const useTrustEntity = (identifierId: string | undefined) => {
54
56
  const { core } = useONECore();
55
57
 
58
+ const { data: identifierDetail } = useIdentifierDetails(identifierId);
59
+
56
60
  return useQuery(
57
- [TRUST_ENTITY_DETAIL_QUERY_KEY, didId],
61
+ [TRUST_ENTITY_DETAIL_QUERY_KEY, identifierId],
58
62
  () =>
59
- didId
60
- ? core.getTrustEntityByDid(didId).catch((e) => {
61
- if (e instanceof OneError && e.code === OneErrorCode.NoTrustEntityFound) {
62
- return null;
63
- }
64
- throw e;
65
- })
63
+ identifierDetail?.did
64
+ ? core.getTrustEntityByDid(identifierDetail.did.id).catch((e) => {
65
+ if (e instanceof OneError && e.code === OneErrorCode.NoTrustEntityFound) {
66
+ return null;
67
+ }
68
+ throw e;
69
+ })
66
70
  : undefined,
67
71
  {
68
- enabled: Boolean(didId),
72
+ enabled: Boolean(identifierDetail?.did),
69
73
  keepPreviousData: true,
70
74
  },
71
75
  );
@@ -40,13 +40,13 @@ export const validityCheckedCardFromCredential = (
40
40
  ): Omit<CredentialCardProps, 'onHeaderPress' | 'style' | 'testID'> => {
41
41
  let credentialHeaderDetail:
42
42
  | Pick<
43
- CredentialHeaderProps,
44
- | 'credentialDetailPrimary'
45
- | 'credentialDetailSecondary'
46
- | 'credentialDetailErrorColor'
47
- | 'credentialDetailTestID'
48
- | 'statusIcon'
49
- >
43
+ CredentialHeaderProps,
44
+ | 'credentialDetailPrimary'
45
+ | 'credentialDetailSecondary'
46
+ | 'credentialDetailErrorColor'
47
+ | 'credentialDetailTestID'
48
+ | 'statusIcon'
49
+ >
50
50
  | undefined;
51
51
  if (invalidLVVC) {
52
52
  credentialHeaderDetail = {
@@ -236,31 +236,31 @@ export const shareCredentialCardFromCredential = (
236
236
  labels: ShareCredentialCardLabels,
237
237
  ): Omit<CredentialDetailsCardProps, 'expanded'> => {
238
238
  const selectiveDisclosureSupported = supportsSelectiveDisclosure(
239
- credential ? { ...credential, issuerDid: credential.issuerDid?.did } : undefined,
239
+ credential ? { ...credential, issuerDid: credential.issuerDid?.id, issuer: credential.issuer?.id } : undefined,
240
240
  config,
241
241
  );
242
242
  const notice: CredentialCardNotice | undefined =
243
243
  selectiveDisclosureSupported === false
244
244
  ? {
245
- text: labels.selectiveDisclosureNotice,
246
- noticeIcon: CredentialNoticeWarningIcon,
247
- }
245
+ text: labels.selectiveDisclosureNotice,
246
+ noticeIcon: CredentialNoticeWarningIcon,
247
+ }
248
248
  : undefined;
249
249
  const cardTestId = concatTestID(testID, 'card');
250
250
  const card = credential
251
251
  ? validityCheckedCardFromCredential(
252
- credential,
253
- invalidLVVC,
254
- expanded,
255
- multipleCredentialsAvailable,
256
- config,
257
- notice,
258
- cardTestId,
259
- labels,
260
- )
252
+ credential,
253
+ invalidLVVC,
254
+ expanded,
255
+ multipleCredentialsAvailable,
256
+ config,
257
+ notice,
258
+ cardTestId,
259
+ labels,
260
+ )
261
261
  : missingCredentialCardFromRequest(request, notice, cardTestId, labels);
262
262
  const validityState = getValidityState(
263
- credential ? { ...credential, issuerDid: credential.issuerDid?.did } : undefined,
263
+ credential ? { ...credential, issuerDid: credential.issuerDid?.id, issuer: credential.issuer?.id } : undefined,
264
264
  );
265
265
  const displayedAttributes = getDisplayedAttributes(
266
266
  request,
@@ -320,16 +320,16 @@ export const selectCredentialCardFromCredential = (
320
320
  labels: ShareCredentialCardLabels,
321
321
  ): Omit<CredentialDetailsCardProps, 'expanded'> => {
322
322
  const selectiveDisclosureSupported = supportsSelectiveDisclosure(
323
- credential ? { ...credential, issuerDid: credential.issuerDid?.did } : undefined,
323
+ credential ? { ...credential, issuerDid: credential.issuerDid?.id, issuer: credential.issuer?.id } : undefined,
324
324
  config,
325
325
  );
326
326
  const rightAccessory = <Selector status={selected ? SelectorStatus.SelectedRadio : SelectorStatus.Empty} />;
327
327
  const notice: CredentialCardNotice | undefined =
328
328
  selectiveDisclosureSupported === false
329
329
  ? {
330
- text: labels.selectiveDisclosureNotice,
331
- noticeIcon: CredentialNoticeWarningIcon,
332
- }
330
+ text: labels.selectiveDisclosureNotice,
331
+ noticeIcon: CredentialNoticeWarningIcon,
332
+ }
333
333
  : undefined;
334
334
  const { header, ...cardProps } = getCredentialCardPropsFromCredential(
335
335
  credential,
@@ -231,6 +231,10 @@ const detailsCardAttributeValueFromClaim = (claim: Claim, config: Config, testID
231
231
  };
232
232
  }
233
233
  case DataTypeEnum.Date: {
234
+ if (!claim.value) {
235
+ // Don't try to parse empty values (which will return "Invalid Date")
236
+ return { testID: testID, value: String(claim.value) };
237
+ }
234
238
  const date = claim.value as string;
235
239
  return {
236
240
  testID: testID,
@@ -26,7 +26,7 @@ export const getQueryKeyFromHistoryListQueryParams = (queryParams?: Partial<Hist
26
26
  entityTypes,
27
27
  createdDateFrom,
28
28
  createdDateTo,
29
- didId,
29
+ identifierId,
30
30
  credentialId,
31
31
  credentialSchemaId,
32
32
  searchText,
@@ -39,7 +39,7 @@ export const getQueryKeyFromHistoryListQueryParams = (queryParams?: Partial<Hist
39
39
  entityTypes,
40
40
  createdDateFrom,
41
41
  createdDateTo,
42
- didId,
42
+ identifierId,
43
43
  credentialId,
44
44
  credentialSchemaId,
45
45
  searchText,