嗨,我想从 sign_vals 获取结果并将其用于 sign_request ,我的问题是,当我想在sign_vals中使用该值时,我一直变得不确定可能是一个小问题,但我希望有人可以提供帮助。谢谢
const vals = username + "|" + ikey;
const duo_sig = await this._sign_vals(
skey,
vals,
this.DUO_PREFIX,
this.DUO_EXPIRE
);
const app_sig = await this._sign_vals(
akey,
vals,
this.APP_PREFIX,
this.APP_EXPIRE
);
console.log(app_sig);
const sig_request = duo_sig + ":" + app_sig;
return sig_request;
}
_sign_vals(key, vals, prefix, expire: number) {
var exp = Math.round(new Date().getTime() / 1000) + expire;
var val = vals + "|" + exp;
var sig;
var b64 = Buffer.from(val).toString("base64");
const cookie = prefix + "|" + b64;
this.computehmac(key, cookie).then((data) => {
console.log(data);
const hexedstring = Buffer.from(data).toString("hex");
const output = cookie + "|" + hexedstring;
this.output = output;
return this.output;
});
//this.output = (await this.cookie) + "|" + this.sig;
}
computehmac(key: any, cookie: any) {
const computation = hmac.compute(key, cookie, "SHA-1");
return computation;
}```