Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
wallet = { ...encryptedWallet, privateKey, address: walletAddress };
} else {
// nothing provided, invalid login
throw new Error();
}
const network = findEthereumNetwork(ethereumNetwork);
dispatch(setEthereumNetwork(network));
let { user = {} } = await storage.get('user');
const userState = user.walletId ? REGISTERED : PENDING;
if (userState === REGISTERED) {
const fcmToken = await firebase.messaging().getToken().catch(() => null);
dispatch({ type: UPDATE_SESSION, payload: { fcmToken } });
await Intercom.sendTokenToIntercom(fcmToken).catch(() => null);
const signalCredentials = {
userId: user.id,
username: user.username,
walletId: user.walletId,
ethAddress: wallet.address,
fcmToken,
};
const updateOAuth = updateOAuthTokensCB(dispatch, signalCredentials);
const onOAuthTokensFailed = onOAuthTokensFailedCB(dispatch);
api.init(updateOAuth, oAuthTokens, onOAuthTokensFailed, network);
if (onLoginSuccess && wallet.privateKey) {
let { privateKey: privateKeyParam } = wallet;
privateKeyParam = privateKeyParam.indexOf('0x') === 0 ? privateKeyParam.slice(2) : privateKeyParam;
await onLoginSuccess(privateKeyParam);
}
const getTokenWalletAndRegister = async (
privateKey: string,
api: Object, // FIXME: this should be api: SDKWrapper
user: Object,
dispatch: Dispatch,
) => {
await firebase.messaging().requestPermission().catch(() => { });
const fcmToken = await firebase.messaging().getToken().catch(() => { });
await Intercom.sendTokenToIntercom(fcmToken).catch(() => null);
const sdkWallet = await api.registerOnAuthServer(privateKey, fcmToken, user.username);
const registrationSucceed = !sdkWallet.error;
const userInfo = await api.userInfo(sdkWallet.walletId);
const userState = Object.keys(userInfo).length ? REGISTERED : PENDING;
if (Object.keys(userInfo).length) {
dispatch(saveDbAction('user', { user: userInfo }, true));
}
const oAuthTokens = {
refreshToken: sdkWallet.refreshToken,
accessToken: sdkWallet.accessToken,
};
const updateOAuth = updateOAuthTokensCB(dispatch);
await updateOAuth(oAuthTokens);
componentWillMount() {
Intercom.setInAppMessageVisibility('GONE'); // prevent messanger launcher to appear
}
onNextPress={() => Intercom.displayMessenger()}
/>
onPress: () => Intercom.displayMessenger(),
withBackground: true,
onSendFeedback: () => () => Intercom.displayMessenger(),
})(ComponentToWrap);
onPress={() => Intercom.displayMessenger()}
/>
const rightItems = [{ label: 'Support', onPress: () => Intercom.displayMessenger(), key: 'getHelp' }];
if ((!isEmpty(exchangeAllowances) || !isEmpty(connectedProviders))
rightItems: [{ link: 'Support', onPress: () => Intercom.displayMessenger() }],
sideFlex: 2,
rightItems: [{ link: 'Support', onPress: () => Intercom.displayMessenger() }],
sideFlex: 2,