How to authenticate the GKLocalPlayer on my Node.js server

那年仲夏 提交于 2020-01-05 08:08:41

问题


In Apple's Doc, generateIdentityVerificationSignatureWithCompletionHandler, you are to concatenate into a data buffer 4 parameters, one of which being "The timestamp parameter in Big-Endian UInt-64 format", and then generate a SHA-1 hash value for verification.

Has anyone accomplished this successfully in Node.js/Javascript? The main issue I am having is that Javascript/Node.js does not seem to have any support 64-bit unsigned big endian integers; it seems to max out at 32-bit, unsigned.

PS: I know there the following related questions, but they do not tackle this particular javascript issue.

  1. How to authenticate the GKLocalPlayer on my 'third party server'?: the solutions are for ruby, python, and obj-c; all having native support for producing the 64-bit BE hex for the timestamp.
  2. How to authenticate Game Center User from 3rd party node.js server: the code relies on the client sending the server a timestamp already in the form of a hex string (see json.hexTimestamp, around ln 22)

Is it even possible to reliably create the hex representation of a 64-bit unsigned big endian ... in javascript? I'm considering executing ruby/python via Node.js as a possible workaround.


回答1:


The easier way is to use ref

var ref = require('ref');

var buf = ref.alloc('uint64');
ref.writeUInt64BE(buf, 0, '1401893400733');

after that you could use the buffer to update the verifier.



来源:https://stackoverflow.com/questions/23223266/how-to-authenticate-the-gklocalplayer-on-my-node-js-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!