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 preAuth () {
if (!await checkInternetConnection()) {
// return early if not connected
return false
}
if (preAuthorizing) {
try {
// allow 5 seconds for active preauthorization to complete (after which
// whatever is waiting will be able to continue)
await pTimeout(waitForPreauthorization(), 5000)
console.log('alternate preAuthorization succeeded')
return true
} catch (err) {
console.log('alternative preAuthorization timed out or failed', err)
(isConnected) => {
if (isConnected) {
//check if there is internet connection
checkInternetConnection().then((hasInternet) => {
if (hasInternet)
onConnect && onConnect()
else
onDisconnect && onDisconnect()
})
}
else {
onDisconnect && onDisconnect()
}
}
)