Is there a way to access the raw body of the request? Not that has been parsed into json?
@Injectable()
export class WooGuard implements CanActivate {
secret: string;
constructor(
private readonly reflector: Reflector,
private configService: ConfigService,
) {
this.secret = this.configService.get<string>("woocommerce.webhook.secret");
}
async canActivate(
context: ExecutionContext,
): Promise<boolean> {
const request = context.switchToHttp().getRequest<Request>();
request.body // this is parsed json
// I am calculating the sha256 hash of the body with a secret for a webhook.
// due to how the raw json is vs. the JSON.stringify(request.body), the signature is never the same.
}
}