Added apple gamekit auth

Untested rn
This commit is contained in:
Joe Bain
2026-01-26 15:36:05 +00:00
parent ccd90508dd
commit ac73dab494
4 changed files with 22655 additions and 19 deletions

22615
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -23,11 +23,13 @@
"@parse/push-adapter": "3.0.0-alpha2", "@parse/push-adapter": "3.0.0-alpha2",
"@parse/s3-files-adapter": "1.2.1", "@parse/s3-files-adapter": "1.2.1",
"@parse/simple-mailgun-adapter": "1.0.2", "@parse/simple-mailgun-adapter": "1.0.2",
"bcrypt": "3.0.0",
"bcryptjs": "2.4.3", "bcryptjs": "2.4.3",
"body-parser": "1.18.3", "body-parser": "1.18.3",
"commander": "2.16.0", "commander": "2.16.0",
"deepcopy": "1.0.0", "deepcopy": "1.0.0",
"express": "4.16.2", "express": "4.16.2",
"gamecenter-identity-verifier": "^0.1.1",
"intersect": "1.0.1", "intersect": "1.0.1",
"jsonwebtoken": "^8.5.1", "jsonwebtoken": "^8.5.1",
"jwks-rsa": "^1.12.3", "jwks-rsa": "^1.12.3",
@@ -43,6 +45,7 @@
"steam-appticket": "1.0.1", "steam-appticket": "1.0.1",
"tv4": "1.3.0", "tv4": "1.3.0",
"uuid": "^3.1.0", "uuid": "^3.1.0",
"uws": "10.148.1",
"winston": "2.4.1", "winston": "2.4.1",
"winston-daily-rotate-file": "1.7.2", "winston-daily-rotate-file": "1.7.2",
"ws": "6.0.0" "ws": "6.0.0"

View 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
};

View File

@@ -18,6 +18,7 @@ const wechat = require("./wechat");
const weibo = require("./weibo"); const weibo = require("./weibo");
const steam = require("./steam"); const steam = require("./steam");
const nintendo = require("./nintendo"); const nintendo = require("./nintendo");
const apple = require("./apple");
const anonymous = { const anonymous = {
validateAuthData: () => { validateAuthData: () => {
@@ -47,7 +48,8 @@ const providers = {
wechat, wechat,
weibo, weibo,
steam, steam,
nintendo nintendo,
apple
} }
function authDataValidator(adapter, appIds, options) { function authDataValidator(adapter, appIds, options) {
return function(authData) { return function(authData) {