@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.
- package/lib/commonjs/ui-components/buttons/index.js +7 -0
- package/lib/commonjs/ui-components/buttons/index.js.map +1 -1
- package/lib/commonjs/ui-components/buttons/share-button.js +54 -0
- package/lib/commonjs/ui-components/buttons/share-button.js.map +1 -0
- package/lib/commonjs/ui-components/icons/icons.js +24 -1
- package/lib/commonjs/ui-components/icons/icons.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 +8 -1
- package/lib/commonjs/ui-components/loader/loading-result.js.map +1 -1
- package/lib/commonjs/ui-components/nfc/index.js +14 -0
- package/lib/commonjs/ui-components/nfc/index.js.map +1 -0
- package/lib/commonjs/ui-components/nfc/nfc-process.js +77 -0
- package/lib/commonjs/ui-components/nfc/nfc-process.js.map +1 -0
- package/lib/commonjs/ui-components/screens/section-list-screen.js +20 -5
- package/lib/commonjs/ui-components/screens/section-list-screen.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/backup.js +3 -4
- package/lib/commonjs/utils/hooks/core/backup.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/core-init.js +4 -22
- package/lib/commonjs/utils/hooks/core/core-init.js.map +1 -1
- package/lib/commonjs/utils/hooks/core/proofs.js +10 -2
- package/lib/commonjs/utils/hooks/core/proofs.js.map +1 -1
- package/lib/commonjs/utils/hooks/index.js +11 -0
- package/lib/commonjs/utils/hooks/index.js.map +1 -1
- package/lib/commonjs/utils/hooks/nfc/nfc-status.js +40 -0
- package/lib/commonjs/utils/hooks/nfc/nfc-status.js.map +1 -0
- package/lib/commonjs/utils/index.js +12 -0
- package/lib/commonjs/utils/index.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/url.js +80 -0
- package/lib/commonjs/utils/url.js.map +1 -0
- package/lib/module/ui-components/buttons/index.js +2 -1
- package/lib/module/ui-components/buttons/index.js.map +1 -1
- package/lib/module/ui-components/buttons/share-button.js +47 -0
- package/lib/module/ui-components/buttons/share-button.js.map +1 -0
- package/lib/module/ui-components/icons/icons.js +22 -0
- package/lib/module/ui-components/icons/icons.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 +8 -1
- package/lib/module/ui-components/loader/loading-result.js.map +1 -1
- package/lib/module/ui-components/nfc/index.js +3 -0
- package/lib/module/ui-components/nfc/index.js.map +1 -0
- package/lib/module/ui-components/nfc/nfc-process.js +69 -0
- package/lib/module/ui-components/nfc/nfc-process.js.map +1 -0
- package/lib/module/ui-components/screens/section-list-screen.js +21 -6
- package/lib/module/ui-components/screens/section-list-screen.js.map +1 -1
- package/lib/module/utils/hooks/core/backup.js +4 -5
- package/lib/module/utils/hooks/core/backup.js.map +1 -1
- package/lib/module/utils/hooks/core/core-init.js +3 -20
- package/lib/module/utils/hooks/core/core-init.js.map +1 -1
- package/lib/module/utils/hooks/core/proofs.js +9 -1
- package/lib/module/utils/hooks/core/proofs.js.map +1 -1
- package/lib/module/utils/hooks/index.js +1 -0
- package/lib/module/utils/hooks/index.js.map +1 -1
- package/lib/module/utils/hooks/nfc/nfc-status.js +32 -0
- package/lib/module/utils/hooks/nfc/nfc-status.js.map +1 -0
- package/lib/module/utils/index.js +1 -0
- package/lib/module/utils/index.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/url.js +71 -0
- package/lib/module/utils/url.js.map +1 -0
- package/lib/typescript/ui-components/buttons/index.d.ts +3 -1
- package/lib/typescript/ui-components/buttons/share-button.d.ts +10 -0
- package/lib/typescript/ui-components/icons/icons.d.ts +1 -0
- package/lib/typescript/ui-components/index.d.ts +1 -0
- package/lib/typescript/ui-components/loader/loading-result.d.ts +2 -0
- package/lib/typescript/ui-components/nfc/index.d.ts +2 -0
- package/lib/typescript/ui-components/nfc/nfc-process.d.ts +17 -0
- package/lib/typescript/ui-components/screens/section-list-screen.d.ts +2 -1
- package/lib/typescript/utils/hooks/core/backup.d.ts +1 -1
- package/lib/typescript/utils/hooks/core/core-init.d.ts +1 -3
- package/lib/typescript/utils/hooks/core/proofs.d.ts +9 -1
- package/lib/typescript/utils/hooks/index.d.ts +1 -0
- package/lib/typescript/utils/hooks/nfc/nfc-status.d.ts +6 -0
- package/lib/typescript/utils/index.d.ts +1 -0
- package/lib/typescript/utils/url.d.ts +19 -0
- package/package.json +7 -3
- package/src/ui-components/buttons/index.ts +4 -0
- package/src/ui-components/buttons/share-button.stories.tsx +25 -0
- package/src/ui-components/buttons/share-button.tsx +55 -0
- package/src/ui-components/icons/icons.tsx +22 -0
- package/src/ui-components/index.ts +1 -0
- package/src/ui-components/loader/loading-result.stories.tsx +4 -1
- package/src/ui-components/loader/loading-result.tsx +7 -0
- package/src/ui-components/nfc/index.ts +3 -0
- package/src/ui-components/nfc/nfc-process.tsx +80 -0
- package/src/ui-components/screens/section-list-screen.tsx +21 -4
- package/src/utils/hooks/core/backup.ts +1 -4
- package/src/utils/hooks/core/core-init.ts +1 -23
- package/src/utils/hooks/core/proofs.ts +17 -4
- package/src/utils/hooks/index.ts +1 -0
- package/src/utils/hooks/nfc/nfc-status.ts +31 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/parsers/query.ts +1 -0
- 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
|
|
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,
|
|
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
|
|
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
|
|
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(
|
|
139
|
-
|
|
140
|
-
|
|
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 = () => {
|
package/src/utils/hooks/index.ts
CHANGED
|
@@ -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
|
+
};
|
package/src/utils/index.ts
CHANGED
package/src/utils/url.ts
ADDED
|
@@ -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
|
+
};
|