@bifold/core 2.4.3 → 2.4.4
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/App.js +6 -2
- package/lib/commonjs/App.js.map +1 -1
- package/lib/commonjs/components/misc/CredentialCard11ActionFooter.js +1 -1
- package/lib/commonjs/components/misc/CredentialCard11ActionFooter.js.map +1 -1
- package/lib/commonjs/components/misc/ErrorBoundary.js +210 -0
- package/lib/commonjs/components/misc/ErrorBoundary.js.map +1 -0
- package/lib/commonjs/container-impl.js +2 -2
- package/lib/commonjs/container-impl.js.map +1 -1
- package/lib/commonjs/index.js +16 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/services/bifoldLogger.js +9 -0
- package/lib/commonjs/services/bifoldLogger.js.map +1 -0
- package/lib/commonjs/theme.js +3 -2
- package/lib/commonjs/theme.js.map +1 -1
- package/lib/module/App.js +6 -2
- package/lib/module/App.js.map +1 -1
- package/lib/module/components/misc/CredentialCard11ActionFooter.js +1 -1
- package/lib/module/components/misc/CredentialCard11ActionFooter.js.map +1 -1
- package/lib/module/components/misc/ErrorBoundary.js +202 -0
- package/lib/module/components/misc/ErrorBoundary.js.map +1 -0
- package/lib/module/container-impl.js +2 -2
- package/lib/module/container-impl.js.map +1 -1
- package/lib/module/index.js +3 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/bifoldLogger.js +3 -0
- package/lib/module/services/bifoldLogger.js.map +1 -0
- package/lib/module/theme.js +3 -2
- package/lib/module/theme.js.map +1 -1
- package/lib/typescript/src/App.d.ts.map +1 -1
- package/lib/typescript/src/components/misc/ErrorBoundary.d.ts +9 -0
- package/lib/typescript/src/components/misc/ErrorBoundary.d.ts.map +1 -0
- package/lib/typescript/src/container-impl.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +5 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/services/bifoldLogger.d.ts +3 -0
- package/lib/typescript/src/services/bifoldLogger.d.ts.map +1 -0
- package/lib/typescript/src/theme.d.ts +1 -0
- package/lib/typescript/src/theme.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/App.tsx +29 -25
- package/src/components/misc/CredentialCard11ActionFooter.tsx +1 -1
- package/src/components/misc/ErrorBoundary.tsx +200 -0
- package/src/container-impl.ts +2 -1
- package/src/index.ts +6 -1
- package/src/services/bifoldLogger.ts +3 -0
- package/src/theme.ts +3 -2
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react'
|
|
2
|
+
import { StyleSheet, Text, useWindowDimensions, ScrollView, View, TouchableOpacity } from 'react-native'
|
|
3
|
+
import { SafeAreaView } from 'react-native-safe-area-context'
|
|
4
|
+
import { GenericFn } from 'types/fn'
|
|
5
|
+
import { useTranslation } from 'react-i18next'
|
|
6
|
+
import Button, { ButtonType } from '../buttons/Button'
|
|
7
|
+
import Icon from 'react-native-vector-icons/MaterialIcons'
|
|
8
|
+
import { getBuildNumber, getVersion } from 'react-native-device-info'
|
|
9
|
+
import { testIdWithKey } from '../../utils/testable'
|
|
10
|
+
import { BifoldError } from '../../types/error'
|
|
11
|
+
import { BifoldLogger } from '../../services/logger'
|
|
12
|
+
|
|
13
|
+
const iconSize = 30
|
|
14
|
+
|
|
15
|
+
interface ErrorBoundaryProps {
|
|
16
|
+
children: ReactNode
|
|
17
|
+
styles: ReturnType<typeof StyleSheet.create>
|
|
18
|
+
t: (key: string) => string
|
|
19
|
+
logger: BifoldLogger
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface ErrorBoundaryState {
|
|
23
|
+
hasError: boolean
|
|
24
|
+
error: Error | null
|
|
25
|
+
reported: boolean
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
29
|
+
state: ErrorBoundaryState = { hasError: false, error: null, reported: false }
|
|
30
|
+
|
|
31
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState {
|
|
32
|
+
return { hasError: true, error, reported: false }
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
onDismissModalTouched = () => {
|
|
36
|
+
this.setState({ hasError: false, error: null, reported: false })
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
componentDidCatch(error: Error) {
|
|
40
|
+
const { logger } = this.props
|
|
41
|
+
logger.error('ErrorBoundary caught an error:', error)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
reportError = (error: Error, logger: BifoldLogger) => {
|
|
45
|
+
if (error) {
|
|
46
|
+
this.setState({ reported: true })
|
|
47
|
+
logger.report(error as BifoldError)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
render() {
|
|
52
|
+
const { hasError, error, reported } = this.state
|
|
53
|
+
const { t, styles, logger } = this.props
|
|
54
|
+
|
|
55
|
+
if (hasError && error) {
|
|
56
|
+
return (
|
|
57
|
+
<SafeAreaView style={[styles.container, { justifyContent: 'center', alignItems: 'center' }]}>
|
|
58
|
+
<ErrorBoundaryInfoBox
|
|
59
|
+
title={error.name}
|
|
60
|
+
description={error.message}
|
|
61
|
+
secondaryCallToActionTitle={reported ? t('Error.Reported') : t('Error.ReportThisProblem')}
|
|
62
|
+
secondaryCallToActionPressed={() => this.reportError(error, logger)}
|
|
63
|
+
secondaryCallToActionDisabled={reported}
|
|
64
|
+
onCallToActionPressed={this.onDismissModalTouched}
|
|
65
|
+
onCallToActionLabel={t('Global.Okay')}
|
|
66
|
+
showVersionFooter
|
|
67
|
+
/>
|
|
68
|
+
</SafeAreaView>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return this.props.children
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
interface ErrorBoundaryInfoBoxProps {
|
|
77
|
+
title: string
|
|
78
|
+
description?: string
|
|
79
|
+
secondaryCallToActionTitle?: string
|
|
80
|
+
secondaryCallToActionPressed?: GenericFn
|
|
81
|
+
secondaryCallToActionDisabled?: boolean
|
|
82
|
+
onCallToActionPressed?: GenericFn
|
|
83
|
+
onCallToActionLabel?: string
|
|
84
|
+
showVersionFooter: boolean
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const ErrorBoundaryInfoBox: React.FC<ErrorBoundaryInfoBoxProps> = ({
|
|
88
|
+
title,
|
|
89
|
+
description,
|
|
90
|
+
secondaryCallToActionTitle,
|
|
91
|
+
secondaryCallToActionPressed,
|
|
92
|
+
secondaryCallToActionDisabled,
|
|
93
|
+
onCallToActionPressed,
|
|
94
|
+
onCallToActionLabel,
|
|
95
|
+
showVersionFooter,
|
|
96
|
+
}) => {
|
|
97
|
+
const { width } = useWindowDimensions()
|
|
98
|
+
const { t } = useTranslation()
|
|
99
|
+
|
|
100
|
+
const styles = StyleSheet.create({
|
|
101
|
+
container: {
|
|
102
|
+
backgroundColor: 'lightgrey',
|
|
103
|
+
borderColor: 'darkgrey',
|
|
104
|
+
borderRadius: 5,
|
|
105
|
+
borderWidth: 1,
|
|
106
|
+
padding: 10,
|
|
107
|
+
minWidth: width - 2 * 25,
|
|
108
|
+
height: 400,
|
|
109
|
+
},
|
|
110
|
+
headerContainer: {
|
|
111
|
+
flexDirection: 'row',
|
|
112
|
+
paddingHorizontal: 5,
|
|
113
|
+
paddingTop: 5,
|
|
114
|
+
},
|
|
115
|
+
bodyContainer: {
|
|
116
|
+
flexDirection: 'column',
|
|
117
|
+
marginLeft: 10,
|
|
118
|
+
paddingHorizontal: 5,
|
|
119
|
+
paddingBottom: 5,
|
|
120
|
+
flexGrow: 0,
|
|
121
|
+
},
|
|
122
|
+
headerText: {
|
|
123
|
+
marginLeft: 7,
|
|
124
|
+
flexShrink: 1,
|
|
125
|
+
alignSelf: 'center',
|
|
126
|
+
color: 'darkred',
|
|
127
|
+
},
|
|
128
|
+
bodyText: {
|
|
129
|
+
flexShrink: 1,
|
|
130
|
+
marginVertical: 16,
|
|
131
|
+
color: 'darkred',
|
|
132
|
+
},
|
|
133
|
+
showDetailsText: {
|
|
134
|
+
fontWeight: 'normal',
|
|
135
|
+
color: 'black',
|
|
136
|
+
},
|
|
137
|
+
})
|
|
138
|
+
return (
|
|
139
|
+
<View style={styles.container}>
|
|
140
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
141
|
+
<View style={styles.headerContainer}>
|
|
142
|
+
<Icon name={'error'} size={iconSize} color={'darkred'} />
|
|
143
|
+
<Text style={styles.headerText}>{title}</Text>
|
|
144
|
+
</View>
|
|
145
|
+
<TouchableOpacity accessibilityLabel={'dismiss'} accessibilityRole={'button'} onPress={onCallToActionPressed}>
|
|
146
|
+
<Icon name={'close'} size={iconSize} color={'black'} />
|
|
147
|
+
</TouchableOpacity>
|
|
148
|
+
</View>
|
|
149
|
+
<View style={{ maxHeight: 150, marginBottom: 8 }}>
|
|
150
|
+
<ScrollView>
|
|
151
|
+
<Text style={styles.bodyText}>{description}</Text>
|
|
152
|
+
</ScrollView>
|
|
153
|
+
</View>
|
|
154
|
+
{onCallToActionLabel && (
|
|
155
|
+
<View style={{ marginBottom: 8 }}>
|
|
156
|
+
<Button buttonType={ButtonType.Critical} title={onCallToActionLabel} onPress={onCallToActionPressed} />
|
|
157
|
+
</View>
|
|
158
|
+
)}
|
|
159
|
+
{secondaryCallToActionTitle && (
|
|
160
|
+
<Button
|
|
161
|
+
buttonType={ButtonType.Critical}
|
|
162
|
+
title={secondaryCallToActionTitle}
|
|
163
|
+
onPress={secondaryCallToActionPressed}
|
|
164
|
+
disabled={secondaryCallToActionDisabled}
|
|
165
|
+
/>
|
|
166
|
+
)}
|
|
167
|
+
{showVersionFooter ? (
|
|
168
|
+
<Text
|
|
169
|
+
style={{ flex: 1, marginTop: 8, textAlign: 'center', color: 'darkred' }}
|
|
170
|
+
testID={testIdWithKey('VersionNumber')}
|
|
171
|
+
>
|
|
172
|
+
{`${t('Settings.Version')} ${getVersion()} (${getBuildNumber()})`}
|
|
173
|
+
</Text>
|
|
174
|
+
) : null}
|
|
175
|
+
</View>
|
|
176
|
+
)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
interface ErrorBoundaryWrapperProps {
|
|
180
|
+
children: ReactNode
|
|
181
|
+
logger: BifoldLogger
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const ErrorBoundaryWrapper: React.FC<ErrorBoundaryWrapperProps> = ({ children, logger }) => {
|
|
185
|
+
const { t } = useTranslation()
|
|
186
|
+
const styles = StyleSheet.create({
|
|
187
|
+
container: {
|
|
188
|
+
flex: 1,
|
|
189
|
+
padding: 20,
|
|
190
|
+
},
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
return (
|
|
194
|
+
<ErrorBoundary t={t} styles={styles} logger={logger}>
|
|
195
|
+
{children}
|
|
196
|
+
</ErrorBoundary>
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export default ErrorBoundaryWrapper
|
package/src/container-impl.ts
CHANGED
|
@@ -44,6 +44,7 @@ import ToggleBiometry from './screens/ToggleBiometry'
|
|
|
44
44
|
import UpdateAvailable from './screens/UpdateAvailable'
|
|
45
45
|
import { loadLoginAttempt } from './services/keychain'
|
|
46
46
|
import { BifoldLogger } from './services/logger'
|
|
47
|
+
import { bifoldLoggerInstance } from './services/bifoldLogger'
|
|
47
48
|
import { PersistentStorage } from './services/storage'
|
|
48
49
|
import { Config, HistoryEventsLoggerConfig } from './types/config'
|
|
49
50
|
import { InlineErrorPosition } from './types/error'
|
|
@@ -139,7 +140,7 @@ export class MainContainer implements Container {
|
|
|
139
140
|
this._container.registerInstance(TOKENS.CRED_HELP_ACTION_OVERRIDES, [])
|
|
140
141
|
this._container.registerInstance(TOKENS.OBJECT_SCREEN_CONFIG, DefaultScreenOptionsDictionary)
|
|
141
142
|
this._container.registerInstance(TOKENS.OBJECT_LAYOUT_CONFIG, DefaultScreenLayoutOptions)
|
|
142
|
-
this._container.registerInstance(TOKENS.UTIL_LOGGER,
|
|
143
|
+
this._container.registerInstance(TOKENS.UTIL_LOGGER, bifoldLoggerInstance)
|
|
143
144
|
this._container.registerInstance(TOKENS.UTIL_OCA_RESOLVER, new DefaultOCABundleResolver(bundle))
|
|
144
145
|
this._container.registerInstance(TOKENS.UTIL_LEDGERS, defaultIndyLedgers)
|
|
145
146
|
this._container.registerInstance(TOKENS.UTIL_PROOF_TEMPLATE, getProofRequestTemplates)
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,7 @@ import BulletPoint from './components/inputs/BulletPoint'
|
|
|
12
12
|
import CheckBoxRow from './components/inputs/CheckBoxRow'
|
|
13
13
|
import ContentGradient from './components/misc/ContentGradient'
|
|
14
14
|
import CredentialCard from './components/misc/CredentialCard'
|
|
15
|
+
import ErrorBoundaryWrapper from './components/misc/ErrorBoundary'
|
|
15
16
|
import InfoBox, { InfoBoxType } from './components/misc/InfoBox'
|
|
16
17
|
import ErrorModal from './components/modals/ErrorModal'
|
|
17
18
|
import SafeAreaModal from './components/modals/SafeAreaModal'
|
|
@@ -64,6 +65,8 @@ import useBifoldAgentSetup from './hooks/useBifoldAgentSetup'
|
|
|
64
65
|
import usePreventScreenCapture from './hooks/screen-capture'
|
|
65
66
|
import { DefaultScreenLayoutOptions } from './navigators/defaultLayoutOptions'
|
|
66
67
|
import { DeepPartial, ThemeBuilder } from './theme-builder'
|
|
68
|
+
import { BannerMessage } from './components/views/Banner'
|
|
69
|
+
import { bifoldLoggerInstance } from './services/bifoldLogger'
|
|
67
70
|
|
|
68
71
|
export * from './navigators'
|
|
69
72
|
export * from './services/storage'
|
|
@@ -175,6 +178,8 @@ export {
|
|
|
175
178
|
ButtonLocation,
|
|
176
179
|
CheckBoxRow,
|
|
177
180
|
CredentialCard,
|
|
181
|
+
ErrorBoundaryWrapper,
|
|
182
|
+
bifoldLoggerInstance,
|
|
178
183
|
ContentGradient,
|
|
179
184
|
ErrorModal,
|
|
180
185
|
SafeAreaModal,
|
|
@@ -229,4 +234,4 @@ export {
|
|
|
229
234
|
DefaultScreenLayoutOptions,
|
|
230
235
|
ThemeBuilder,
|
|
231
236
|
}
|
|
232
|
-
export type { IButton, DeepPartial }
|
|
237
|
+
export type { IButton, DeepPartial, BannerMessage }
|
package/src/theme.ts
CHANGED
|
@@ -269,6 +269,7 @@ const BrandColors = {
|
|
|
269
269
|
unorderedList: GrayscaleColors.white,
|
|
270
270
|
unorderedListModal: GrayscaleColors.white,
|
|
271
271
|
link: '#42803E',
|
|
272
|
+
credentialLink: '#42803E',
|
|
272
273
|
text: GrayscaleColors.white,
|
|
273
274
|
icon: GrayscaleColors.white,
|
|
274
275
|
headerIcon: GrayscaleColors.white,
|
|
@@ -572,12 +573,12 @@ export function createButtonsTheme(theme: { ColorPalette: IColorPalette; TextThe
|
|
|
572
573
|
critical: {
|
|
573
574
|
padding: 16,
|
|
574
575
|
borderRadius: 4,
|
|
575
|
-
backgroundColor: theme.ColorPalette.
|
|
576
|
+
backgroundColor: theme.ColorPalette.semantic.error,
|
|
576
577
|
},
|
|
577
578
|
criticalDisabled: {
|
|
578
579
|
padding: 16,
|
|
579
580
|
borderRadius: 4,
|
|
580
|
-
backgroundColor:
|
|
581
|
+
backgroundColor: `rgba(216, 41, 47, ${lightOpacity})`,
|
|
581
582
|
},
|
|
582
583
|
primary: {
|
|
583
584
|
padding: 16,
|