Added apple gamekit auth
Untested rn
This commit is contained in:
22615
package-lock.json
generated
22615
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -23,11 +23,13 @@
|
||||
"@parse/push-adapter": "3.0.0-alpha2",
|
||||
"@parse/s3-files-adapter": "1.2.1",
|
||||
"@parse/simple-mailgun-adapter": "1.0.2",
|
||||
"bcrypt": "3.0.0",
|
||||
"bcryptjs": "2.4.3",
|
||||
"body-parser": "1.18.3",
|
||||
"commander": "2.16.0",
|
||||
"deepcopy": "1.0.0",
|
||||
"express": "4.16.2",
|
||||
"gamecenter-identity-verifier": "^0.1.1",
|
||||
"intersect": "1.0.1",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"jwks-rsa": "^1.12.3",
|
||||
@@ -43,6 +45,7 @@
|
||||
"steam-appticket": "1.0.1",
|
||||
"tv4": "1.3.0",
|
||||
"uuid": "^3.1.0",
|
||||
"uws": "10.148.1",
|
||||
"winston": "2.4.1",
|
||||
"winston-daily-rotate-file": "1.7.2",
|
||||
"ws": "6.0.0"
|
||||
|
||||
52
src/Adapters/Auth/apple.js
Normal file
52
src/Adapters/Auth/apple.js
Normal file
@@ -0,0 +1,52 @@
|
||||
var Parse = require('parse/node').Parse;
|
||||
const { URL } = require('url');
|
||||
var jwt = require('jsonwebtoken');
|
||||
var jwksClient = require('jwks-rsa');
|
||||
var verifier = require('gamecenter-identity-verifier');
|
||||
|
||||
// Returns a promise that fulfills iff this nsa id token is valid
|
||||
function validateAuthData(authData, authOptions) {
|
||||
console.log("going to validate for apple");
|
||||
console.log(authData);
|
||||
var necessaries = ["timestamp", "salt", "id", "bundleId", "signature", "publicKeyUrl"];
|
||||
for (var necessary in necessaries) {
|
||||
if (!(necessary in authData)) {
|
||||
error("Auth data does not have property " + necessary);
|
||||
}
|
||||
}
|
||||
|
||||
var identity = {
|
||||
publicKeyUrl: authData["publicKeyUrl"],
|
||||
timestamp: authData["timestamp"],
|
||||
signature: authData["signature"],
|
||||
salt: authData["salt"],
|
||||
playerId: authData["id"],
|
||||
bundleId: authData["bundleId"]
|
||||
};
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
verifier.verify(identity, function (err, token) {
|
||||
if (!err) {
|
||||
resolve(token);
|
||||
}
|
||||
else {
|
||||
reject("Error authenticating with gamekit: " + err.message);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// we're validating the bundleId in the in the user auth method
|
||||
function validateAppId() {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
function error(message) {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, message);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
validateAppId,
|
||||
validateAuthData
|
||||
};
|
||||
@@ -18,6 +18,7 @@ const wechat = require("./wechat");
|
||||
const weibo = require("./weibo");
|
||||
const steam = require("./steam");
|
||||
const nintendo = require("./nintendo");
|
||||
const apple = require("./apple");
|
||||
|
||||
const anonymous = {
|
||||
validateAuthData: () => {
|
||||
@@ -47,7 +48,8 @@ const providers = {
|
||||
wechat,
|
||||
weibo,
|
||||
steam,
|
||||
nintendo
|
||||
nintendo,
|
||||
apple
|
||||
}
|
||||
function authDataValidator(adapter, appIds, options) {
|
||||
return function(authData) {
|
||||
|
||||
Reference in New Issue
Block a user