Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function getKey(key: string) {
try {
Logger.debug(TAG, `Getting key ${key} from keystore`)
const value = await RNSecureKeyStore.get(key)
Logger.debug(TAG, `Key ${key} retrieved from keystore`)
return value
} catch (error) {
Logger.error(TAG, `Error getting key ${key} from keystore`, error)
// Capturing error in sentry for now as we debug backup key issue
Sentry.captureException(error)
throw error
}
}
export function captureExceptionWithoutState(err, logger) {
if (!Config.SentryEnabled) {
return;
}
if (err && logger) {
try {
Sentry.captureException(err, {logger});
} catch (error) {
// do nothing...
}
}
}
export async function setKey(key: string, value: string) {
try {
Logger.debug(TAG, `Setting key ${key} in keystore`)
// TODO(Rossy + Jean): Revisit this accessible setting
await RNSecureKeyStore.set(key, value, {
accessible: ACCESSIBLE.WHEN_UNLOCKED,
})
Logger.debug(TAG, `Key ${key} set in keystore`)
} catch (error) {
Logger.error(TAG, `Error setting key ${key} in keystore`, error)
// Capturing error in sentry for now as we debug backup key issue
Sentry.captureException(error)
throw error
}
}
const authClient = new AuthClient({
authServer:
this.props.config.authServer || 'https://auth.originprotocol.com',
disablePersistence: true
})
try {
const tokenData = await authClient.getTokenWithSignature(
wallet.activeAccount.address,
signature,
payload
)
return tokenData.authToken
} catch (error) {
Sentry.captureException(error)
console.warn('Failed to generate auth token', error)
}
return null
}
sendSentryException = () => {
Sentry.captureException(new Error('Debug Exception'))
this.showSentryAlert()
}
showSentryAlert = () => {
.catch(error => {
dispatch({
payload: fallbackGasPrices,
type: GAS_PRICES_FAILURE,
});
captureException(error);
fetchReject(error);
});
});
const customErrorHandler = (e, isFatal) => {
if (sentryEnabled) {
Sentry.captureException(e)
}
Logger.error('RootErrorHandler', `Unhandled error. isFatal: ${isFatal}`, e)
defaultErrorHandler(e, isFatal)
}
ErrorUtils.setGlobalHandler(customErrorHandler)
.catch(e => {
Sentry.captureException(e)
})
}
Sentry.withScope(scope => {
if (report.error instanceof AppError && report.error.origError) {
scope.setExtras({
AppError: report.error.message,
UserError: report.userError,
UserDescription: report.userDescription,
UserContact: report.userContact,
sendPrivateData: report.sendPrivateData,
})
report.error = report.error.origError
}
Sentry.captureException(report.error)
})
}
capture(() => {
Sentry.captureException(error, {logger});
}, store);
}