const getEncodedData = function()

in server-examples/nodejs-backend/matches.js [215:242]


  const getEncodedData = function (signedRequest) {
    // You can set USE_SECURE_COMMUNICATION=false
    //  in the .env file to bypass validation
    // while doing local testing and using the FBInstant mock SDK.
    if (process.env.USE_SECURE_COMMUNICATION === false) {
      return signedRequest;
    }

    try {
      const json =
        crypto.enc.Base64.parse(signedRequest.split('.')[1])
        .toString(crypto.enc.Utf8);
      const encodedData = JSON.parse(json);

      /*
            Here's an example of encodedData can look like
            {
                algorithm: 'HMAC-SHA256',
                issued_at: 1520009634,
                player_id: '123456789',
                request_payload: 'backend_save'
            }
            */
      return encodedData.request_payload;
    } catch (e) {
      return null;
    }
  };