< pre class="lang-none Prettyprint-override">POST /api/delete HTTP/1.1
Host: 26d5-45-8-19-76.ngrok-free.app
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)
Content-Length: 166
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/x-www-form-urlencoded
X-Forwarded-For: 2a03
X-Forwarded-Host: 26d5-45-8-19-76.ngrok-free.app
X-Forwarded-Proto: https
signed_request=NybldKYslIBJJfCjH9jIE6PI3ohOKimGpB293v1ojeI.eyJ1c2VyX2lk.......
Я не могу проверить содержимое с помощью заголовка, предоставленного на основе описания, приведенного в следующей ссылке. Обратный вызов запроса на удаление данных.
Я сделал следующее в Сервис платформы NestJS
import { Injectable } from '@nestjs/common';
import * as crypto from 'crypto';
@Injectable()
export class SignedRequestService {
private readonly secret = 'appsecret'; // Use your app secret here
parseSignedRequest(signedRequest: string): any | null {
const [encodedSig, payload] = signedRequest.split('.', 2);
// decode the data
const sig = this.base64UrlDecode(encodedSig);
const data = JSON.parse(this.base64UrlDecode(payload));
// confirm the signature
const expectedSig = crypto
.createHmac('sha256', this.secret)
.update(payload)
.digest();
if (Buffer.compare(Buffer.from(sig), expectedSig) !== 0) {
console.error('Bad Signed JSON signature!');
return null;
}
return data;
}
private base64UrlDecode(input: string): string {
const base64 = input.replace(/-/g, '+').replace(/_/g, '/');
return Buffer.from(base64, 'base64').toString('utf-8');
}
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... ned-reques
Мобильная версия