Created
February 9, 2023 20:23
-
-
Save rvaidun/11e4ba2d61dd187586daf6c9b8172c65 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const functions = require("firebase-functions"); | |
const fetch = require("node-fetch"); | |
exports.login = functions.https.onRequest(async (req, res) => { | |
res.set("Access-Control-Allow-Origin", "*"); | |
const body = JSON.parse(req.body); | |
await fetch("https://auth.bereal.team/api/vonage/request-code", { | |
method: "POST", | |
headers: { | |
accept: "*/*", | |
"content-type": "application/json", | |
"user-agent": "BeReal/8586 CFNetwork/1240.0.4 Darwin/20.6.0", | |
"accept-language": "en-us", | |
}, | |
body: JSON.stringify({ | |
phoneNumber: body.phoneNumber, | |
deviceId: "DEVICEID", | |
}), | |
}); | |
fetch( | |
"https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyClient?key=AIzaSyDwjfEeparokD7sXPVQli9NsTuhT6fJ6iA", | |
{ | |
method: "POST", | |
headers: { | |
"content-type": "application/json", | |
accept: "*/*", | |
"x-client-version": "iOS/FirebaseSDK/9.6.0/FirebaseCore-iOS", | |
"x-ios-bundle-identifier": "AlexisBarreyat.BeReal", | |
"accept-language": "en", | |
"user-agent": | |
"FirebaseAuth.iOS/9.6.0 AlexisBarreyat.BeReal/0.31.0 iPhone/14.7.1 hw/iPhone9_1", | |
"x-firebase-locale": "en", | |
}, | |
body: JSON.stringify({ | |
appToken: | |
"appTOKEN", | |
}), | |
} | |
) | |
.then((response) => response.json()) | |
.then((data) => { | |
console.log(data.receipt); | |
fetch( | |
"https://www.googleapis.com/identitytoolkit/v3/relyingparty/sendVerificationCode?key=AIzaSyDwjfEeparokD7sXPVQli9NsTuhT6fJ6iA", | |
{ | |
method: "POST", | |
headers: { | |
"content-type": "application/json", | |
accept: "*/*", | |
"x-client-version": "iOS/FirebaseSDK/9.6.0/FirebaseCore-iOS", | |
"x-ios-bundle-identifier": "AlexisBarreyat.BeReal", | |
"accept-language": "en", | |
"user-agent": | |
"FirebaseAuth.iOS/9.6.0 AlexisBarreyat.BeReal/0.28.2 iPhone/14.7.1 hw/iPhone9_1", | |
"x-firebase-locale": "en", | |
}, | |
body: JSON.stringify({ | |
iosReceipt: data.receipt, | |
phoneNumber: body.phoneNumber, | |
}), | |
} | |
) | |
.then((response) => response.json()) | |
.then((data) => { | |
res.send(data); | |
if (data.error) { | |
functions.logger.error(data.error.message, data.error); | |
} else { | |
functions.logger.log(data); | |
functions.logger.log("Verification code sent to", body.phoneNumber); | |
} | |
}) | |
.catch((error) => { | |
res.send(error); | |
functions.logger.error(error); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is des the latest version?