HI, please can anyone help confirm what’s missing in my configuration, I keep getting invalid signature error. Currently using API setup in Nestjs. Thanks.
data: { message: ‘invalid signature’, code: -1 }
janlev
December 18, 2023, 3:16pm
2
Hey @Pausonbigi , we have an official SDK for Javascript.
You are more than welcome to use that one.
If you’re still curios on how we generate the JWT using our SDK, you may use our logic in our official SDK:
import { IAuthProvider } from "./iauth-provider";
import * as jwt from "jsonwebtoken";
import * as crypto from "crypto";
import { v4 as uuid } from "uuid";
export class ApiTokenProvider implements IAuthProvider {
constructor(private privateKey: string, private apiKey: string) { }
signJwt(path: string, bodyJson?: any): string {
const token = jwt.sign({
uri: path,
nonce: uuid(),
iat: Math.floor(Date.now() / 1000),
exp: Math.floor(Date.now() / 1000) + 55,
sub: this.apiKey,
bodyHash: crypto.createHash("sha256").update(JSON.stringify(bodyJson || "")).digest().toString("hex")
} as any, this.privateKey, { algorithm: "RS256"});
return token;
This file has been truncated. show original