@procivis/one-react-native-components 0.3.62 → 0.3.71

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 (98) hide show
  1. package/lib/commonjs/ui-components/buttons/index.js +7 -0
  2. package/lib/commonjs/ui-components/buttons/index.js.map +1 -1
  3. package/lib/commonjs/ui-components/buttons/share-button.js +54 -0
  4. package/lib/commonjs/ui-components/buttons/share-button.js.map +1 -0
  5. package/lib/commonjs/ui-components/icons/icons.js +24 -1
  6. package/lib/commonjs/ui-components/icons/icons.js.map +1 -1
  7. package/lib/commonjs/ui-components/index.js +11 -0
  8. package/lib/commonjs/ui-components/index.js.map +1 -1
  9. package/lib/commonjs/ui-components/loader/loading-result.js +8 -1
  10. package/lib/commonjs/ui-components/loader/loading-result.js.map +1 -1
  11. package/lib/commonjs/ui-components/nfc/index.js +14 -0
  12. package/lib/commonjs/ui-components/nfc/index.js.map +1 -0
  13. package/lib/commonjs/ui-components/nfc/nfc-process.js +77 -0
  14. package/lib/commonjs/ui-components/nfc/nfc-process.js.map +1 -0
  15. package/lib/commonjs/ui-components/screens/section-list-screen.js +20 -5
  16. package/lib/commonjs/ui-components/screens/section-list-screen.js.map +1 -1
  17. package/lib/commonjs/utils/hooks/core/backup.js +3 -4
  18. package/lib/commonjs/utils/hooks/core/backup.js.map +1 -1
  19. package/lib/commonjs/utils/hooks/core/core-init.js +4 -22
  20. package/lib/commonjs/utils/hooks/core/core-init.js.map +1 -1
  21. package/lib/commonjs/utils/hooks/core/proofs.js +10 -2
  22. package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
  23. package/lib/commonjs/utils/hooks/index.js +11 -0
  24. package/lib/commonjs/utils/hooks/index.js.map +1 -1
  25. package/lib/commonjs/utils/hooks/nfc/nfc-status.js +40 -0
  26. package/lib/commonjs/utils/hooks/nfc/nfc-status.js.map +1 -0
  27. package/lib/commonjs/utils/index.js +12 -0
  28. package/lib/commonjs/utils/index.js.map +1 -1
  29. package/lib/commonjs/utils/parsers/query.js +1 -1
  30. package/lib/commonjs/utils/parsers/query.js.map +1 -1
  31. package/lib/commonjs/utils/url.js +80 -0
  32. package/lib/commonjs/utils/url.js.map +1 -0
  33. package/lib/module/ui-components/buttons/index.js +2 -1
  34. package/lib/module/ui-components/buttons/index.js.map +1 -1
  35. package/lib/module/ui-components/buttons/share-button.js +47 -0
  36. package/lib/module/ui-components/buttons/share-button.js.map +1 -0
  37. package/lib/module/ui-components/icons/icons.js +22 -0
  38. package/lib/module/ui-components/icons/icons.js.map +1 -1
  39. package/lib/module/ui-components/index.js +1 -0
  40. package/lib/module/ui-components/index.js.map +1 -1
  41. package/lib/module/ui-components/loader/loading-result.js +8 -1
  42. package/lib/module/ui-components/loader/loading-result.js.map +1 -1
  43. package/lib/module/ui-components/nfc/index.js +3 -0
  44. package/lib/module/ui-components/nfc/index.js.map +1 -0
  45. package/lib/module/ui-components/nfc/nfc-process.js +69 -0
  46. package/lib/module/ui-components/nfc/nfc-process.js.map +1 -0
  47. package/lib/module/ui-components/screens/section-list-screen.js +21 -6
  48. package/lib/module/ui-components/screens/section-list-screen.js.map +1 -1
  49. package/lib/module/utils/hooks/core/backup.js +4 -5
  50. package/lib/module/utils/hooks/core/backup.js.map +1 -1
  51. package/lib/module/utils/hooks/core/core-init.js +3 -20
  52. package/lib/module/utils/hooks/core/core-init.js.map +1 -1
  53. package/lib/module/utils/hooks/core/proofs.js +9 -1
  54. package/lib/module/utils/hooks/core/proofs.js.map +1 -1
  55. package/lib/module/utils/hooks/index.js +1 -0
  56. package/lib/module/utils/hooks/index.js.map +1 -1
  57. package/lib/module/utils/hooks/nfc/nfc-status.js +32 -0
  58. package/lib/module/utils/hooks/nfc/nfc-status.js.map +1 -0
  59. package/lib/module/utils/index.js +1 -0
  60. package/lib/module/utils/index.js.map +1 -1
  61. package/lib/module/utils/parsers/query.js +1 -1
  62. package/lib/module/utils/parsers/query.js.map +1 -1
  63. package/lib/module/utils/url.js +71 -0
  64. package/lib/module/utils/url.js.map +1 -0
  65. package/lib/typescript/ui-components/buttons/index.d.ts +3 -1
  66. package/lib/typescript/ui-components/buttons/share-button.d.ts +10 -0
  67. package/lib/typescript/ui-components/icons/icons.d.ts +1 -0
  68. package/lib/typescript/ui-components/index.d.ts +1 -0
  69. package/lib/typescript/ui-components/loader/loading-result.d.ts +2 -0
  70. package/lib/typescript/ui-components/nfc/index.d.ts +2 -0
  71. package/lib/typescript/ui-components/nfc/nfc-process.d.ts +17 -0
  72. package/lib/typescript/ui-components/screens/section-list-screen.d.ts +2 -1
  73. package/lib/typescript/utils/hooks/core/backup.d.ts +1 -1
  74. package/lib/typescript/utils/hooks/core/core-init.d.ts +1 -3
  75. package/lib/typescript/utils/hooks/core/proofs.d.ts +9 -1
  76. package/lib/typescript/utils/hooks/index.d.ts +1 -0
  77. package/lib/typescript/utils/hooks/nfc/nfc-status.d.ts +6 -0
  78. package/lib/typescript/utils/index.d.ts +1 -0
  79. package/lib/typescript/utils/url.d.ts +19 -0
  80. package/package.json +7 -3
  81. package/src/ui-components/buttons/index.ts +4 -0
  82. package/src/ui-components/buttons/share-button.stories.tsx +25 -0
  83. package/src/ui-components/buttons/share-button.tsx +55 -0
  84. package/src/ui-components/icons/icons.tsx +22 -0
  85. package/src/ui-components/index.ts +1 -0
  86. package/src/ui-components/loader/loading-result.stories.tsx +4 -1
  87. package/src/ui-components/loader/loading-result.tsx +7 -0
  88. package/src/ui-components/nfc/index.ts +3 -0
  89. package/src/ui-components/nfc/nfc-process.tsx +80 -0
  90. package/src/ui-components/screens/section-list-screen.tsx +21 -4
  91. package/src/utils/hooks/core/backup.ts +1 -4
  92. package/src/utils/hooks/core/core-init.ts +1 -23
  93. package/src/utils/hooks/core/proofs.ts +17 -4
  94. package/src/utils/hooks/index.ts +1 -0
  95. package/src/utils/hooks/nfc/nfc-status.ts +31 -0
  96. package/src/utils/index.ts +1 -0
  97. package/src/utils/parsers/query.ts +1 -0
  98. package/src/utils/url.ts +61 -0
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { SectionList, SectionListProps, StyleSheet, View, ViewProps } from 'react-native';
2
+ import { Platform, SectionList, SectionListProps, StyleSheet, View, ViewProps, ViewStyle } from 'react-native';
3
3
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
4
4
 
5
5
  import { useOnScrollHeaderState } from '../../utils/hooks/header/on-scroll-header-state';
@@ -14,19 +14,33 @@ export type SectionListScreenProps<ItemT, SectionT> = ViewProps & {
14
14
  title: string;
15
15
  };
16
16
  list: Omit<SectionListProps<ItemT, SectionT>, 'ListHeaderComponent' | 'onScroll'>;
17
+ modalPresentation?: boolean;
17
18
  };
18
19
 
19
20
  const SectionListScreen = <ItemT, SectionT>({
20
21
  header,
21
22
  list: { contentContainerStyle, stickySectionHeadersEnabled, ...listProps },
23
+ modalPresentation,
22
24
  style,
23
25
  ...viewProps
24
26
  }: SectionListScreenProps<ItemT, SectionT>) => {
25
27
  const colorScheme = useAppColorScheme();
26
- const safeAreaInsets = useSafeAreaInsets();
27
- const contentInsetsStyle = useListContentInset();
28
+ const { top } = useSafeAreaInsets();
29
+ const contentInsetsStyle = useListContentInset({
30
+ headerHeight: modalPresentation && Platform.OS === 'ios' ? 63 : 48,
31
+ modalPresentation,
32
+ });
28
33
  const { titleVisible, onScroll } = useOnScrollHeaderState();
29
34
 
35
+ let headerPaddingStyle: ViewStyle | undefined;
36
+ if (!modalPresentation || Platform.OS === 'android') {
37
+ headerPaddingStyle = {
38
+ paddingTop: top,
39
+ };
40
+ } else if (modalPresentation && !header.modalHandleVisible && Platform.OS === 'ios') {
41
+ headerPaddingStyle = styles.modalHeaderWithoutHandle;
42
+ }
43
+
30
44
  return (
31
45
  <View style={[styles.container, { backgroundColor: colorScheme.background }, style]} {...viewProps}>
32
46
  <SectionList<ItemT, SectionT>
@@ -40,7 +54,7 @@ const SectionListScreen = <ItemT, SectionT>({
40
54
  <NavigationHeader
41
55
  animate
42
56
  blurred
43
- style={[styles.header, { paddingTop: safeAreaInsets.top }]}
57
+ style={[styles.header, headerPaddingStyle]}
44
58
  titleVisible={header.static || titleVisible}
45
59
  {...header}
46
60
  />
@@ -56,6 +70,9 @@ const styles = StyleSheet.create({
56
70
  position: 'absolute',
57
71
  width: '100%',
58
72
  },
73
+ modalHeaderWithoutHandle: {
74
+ paddingTop: 15,
75
+ },
59
76
  });
60
77
 
61
78
  export default SectionListScreen;
@@ -5,7 +5,6 @@ import { useMutation, useQuery, useQueryClient } from 'react-query';
5
5
  import { reportException } from '../../reporting';
6
6
  import { useONECore } from './core-context';
7
7
  import {
8
- generateAttestationKey,
9
8
  generateHwIdentifier,
10
9
  generateSwIdentifier,
11
10
  IdentifiersInitializationConfig,
@@ -74,7 +73,6 @@ export const useRollbackImport = () => {
74
73
  export const useBackupFinalizeImportProcedure = ({
75
74
  generateHwKey,
76
75
  generateSwKey,
77
- generateAttestationKey: shouldGenerateAttestationKey,
78
76
  }: IdentifiersInitializationConfig) => {
79
77
  const { mutateAsync: finalizeImport } = useFinalizeImport();
80
78
  const { core, organisationId } = useONECore();
@@ -99,10 +97,9 @@ export const useBackupFinalizeImportProcedure = ({
99
97
  return Promise.all([
100
98
  generateHwKey ? generateHwIdentifier(core, organisationId) : null,
101
99
  !swIdentifierId && generateSwKey ? generateSwIdentifier(core, organisationId) : swIdentifierId,
102
- shouldGenerateAttestationKey ? generateAttestationKey(core, organisationId) : null,
103
100
  ]).catch((err) => {
104
101
  reportException(err, 'Failed to create base identifiers');
105
102
  throw err;
106
103
  });
107
- }, [finalizeImport, generateSwKey, generateHwKey, core, organisationId, shouldGenerateAttestationKey]);
104
+ }, [finalizeImport, generateSwKey, generateHwKey, core, organisationId]);
108
105
  };
@@ -77,29 +77,9 @@ export const generateSwIdentifier = async (core: ONECore, organisationId: string
77
77
  });
78
78
  };
79
79
 
80
- export const generateAttestationKey = async (core: ONECore, organisationId: string) => {
81
- return await core
82
- .generateKey({
83
- keyParams: {},
84
- keyType: 'ECDSA',
85
- name: 'holder-key-attestation',
86
- organisationId,
87
- storageParams: {},
88
- storageType: 'SECURE_ELEMENT',
89
- })
90
- .catch((e) => {
91
- // ignore if Attestation keys not supported by device
92
- if (e instanceof OneError && e.code === OneErrorCode.KeyStorageNotSupported) {
93
- return null;
94
- }
95
- throw e;
96
- });
97
- };
98
-
99
80
  export interface IdentifiersInitializationConfig {
100
81
  generateHwKey: boolean;
101
82
  generateSwKey: boolean;
102
- generateAttestationKey: boolean;
103
83
  }
104
84
 
105
85
  /**
@@ -110,7 +90,6 @@ export interface IdentifiersInitializationConfig {
110
90
  export const useInitializeONECoreIdentifiers = ({
111
91
  generateHwKey,
112
92
  generateSwKey,
113
- generateAttestationKey: shouldGenerateAttestationKey,
114
93
  }: IdentifiersInitializationConfig) => {
115
94
  const { core, organisationId } = useONECore();
116
95
 
@@ -127,12 +106,11 @@ export const useInitializeONECoreIdentifiers = ({
127
106
  Promise.all([
128
107
  generateHwKey ? generateHwIdentifier(core, organisationId) : null,
129
108
  generateSwKey ? generateSwIdentifier(core, organisationId) : null,
130
- shouldGenerateAttestationKey ? generateAttestationKey(core, organisationId) : null,
131
109
  ]),
132
110
  )
133
111
  .catch((err) => {
134
112
  reportException(err, 'Failed to create base identifiers');
135
113
  throw err;
136
114
  });
137
- }, [core, organisationId, generateHwKey, generateSwKey, shouldGenerateAttestationKey]);
115
+ }, [core, organisationId, generateHwKey, generateSwKey]);
138
116
  };
@@ -131,15 +131,28 @@ export enum VerificationProtocol {
131
131
  SCAN_TO_VERIFY = 'SCAN_TO_VERIFY',
132
132
  }
133
133
 
134
+ export enum VerificationEngagement {
135
+ QR_CODE = 'QR_CODE',
136
+ NFC = 'NFC',
137
+ }
138
+
139
+ export interface ProposeProofRequest {
140
+ exchange: VerificationProtocol;
141
+ engagement: VerificationEngagement[];
142
+ }
143
+
134
144
  export const useProposeProof = () => {
135
145
  const queryClient = useQueryClient();
136
146
  const { core, organisationId } = useONECore();
137
147
 
138
- return useMutation(async (exchange: VerificationProtocol) => core.proposeProof(exchange, organisationId), {
139
- onSuccess: async () => {
140
- await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
148
+ return useMutation(
149
+ async ({ exchange, engagement }: ProposeProofRequest) => core.proposeProof(exchange, organisationId, engagement),
150
+ {
151
+ onSuccess: async () => {
152
+ await queryClient.invalidateQueries(HISTORY_LIST_QUERY_KEY);
153
+ },
141
154
  },
142
- });
155
+ );
143
156
  };
144
157
 
145
158
  export const useProofDelete = () => {
@@ -4,5 +4,6 @@ export * from './credential-card/credential-card-expanding';
4
4
  export * from './header/on-scroll-header-state';
5
5
  export * from './list/list-content-inset';
6
6
  export * from './navigation';
7
+ export * from './nfc/nfc-status';
7
8
  export * from './pin-security/pin-security';
8
9
  export * from './revocation/credential-status';
@@ -0,0 +1,31 @@
1
+ import { useCallback, useEffect, useState } from 'react';
2
+ import NfcManager from 'react-native-nfc-manager';
3
+
4
+ export const useNFCStatus = () => {
5
+ const [isNFCEnabled, setIsNFCEnabled] = useState<boolean>();
6
+ const [isLoading, setIsLoading] = useState<boolean>();
7
+ const [error, setError] = useState<unknown>();
8
+
9
+ const checkNFCStatus = useCallback(async () => {
10
+ try {
11
+ setIsLoading(true);
12
+ const isEnabled = await NfcManager.isEnabled();
13
+ setIsNFCEnabled(isEnabled);
14
+ setIsLoading(false);
15
+ } catch (e) {
16
+ setError(e);
17
+ }
18
+ }, []);
19
+
20
+ useEffect(() => {
21
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
22
+ checkNFCStatus();
23
+ }, [checkNFCStatus]);
24
+
25
+ const recheck = useCallback(() => {
26
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
27
+ checkNFCStatus();
28
+ }, [checkNFCStatus]);
29
+
30
+ return { error, isLoading, isNFCEnabled, recheck };
31
+ };
@@ -17,3 +17,4 @@ export * from './reporting';
17
17
  export * from './string';
18
18
  export * from './useMemoAsync';
19
19
  export * from './uuid';
20
+ export * from './url';
@@ -38,6 +38,7 @@ export const getQueryKeyFromCredentialListQueryParams = (queryParams: Partial<Cr
38
38
  'status',
39
39
  'include',
40
40
  'profile',
41
+ 'credentialSchemaIds',
41
42
  'createdDateAfter',
42
43
  'createdDateBefore',
43
44
  'lastModifiedAfter',
@@ -0,0 +1,61 @@
1
+ import { Platform } from 'react-native';
2
+ import Share from 'react-native-share';
3
+
4
+ /**
5
+ * Check URL validity
6
+ * @param {string} urlString URL to validate.
7
+ * @returns {boolean}
8
+ */
9
+ export const isUrlValid = (urlString: string): boolean => {
10
+ try {
11
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+ const url = new URL(urlString);
13
+ return true;
14
+ } catch {
15
+ return false;
16
+ }
17
+ };
18
+
19
+ /**
20
+ * Check URL http(s) validity
21
+ * @param {string} urlString URL to validate.
22
+ * @returns {boolean}
23
+ */
24
+ export const isValidHttpUrl = (urlString: string): boolean => {
25
+ try {
26
+ const url = new URL(urlString);
27
+ return url?.protocol === 'http:' || url?.protocol === 'https:';
28
+ } catch {
29
+ return false;
30
+ }
31
+ };
32
+
33
+ /**
34
+ * Share URL via share sheet
35
+ * @param {string} url URL to share.
36
+ * @param {string} title _(optional)_ title for iOS share sheet.
37
+ * @returns {boolean}
38
+ */
39
+ export const shareUrl = async (url: string, title?: string) => {
40
+ if (Platform.OS === 'ios') {
41
+ await Share.open({
42
+ activityItemSources: [
43
+ {
44
+ placeholderItem: { type: 'url', content: url },
45
+ item: {
46
+ default: { type: 'url', content: url },
47
+ },
48
+ subject: title
49
+ ? {
50
+ default: title,
51
+ }
52
+ : undefined,
53
+ linkMetadata: { originalUrl: url, url, title },
54
+ },
55
+ ],
56
+ failOnCancel: false,
57
+ });
58
+ } else {
59
+ await Share.open({ url, failOnCancel: false });
60
+ }
61
+ };