verify() 通过先尝试调用 createPublicKey() 来解析字符串密钥,在 HS* 路径上耗时 4x-52x
作者: Katha-Sikdar创建于 2026年9月17日更新于 2026年9月17日
if (secretOrPublicKey != null && !(secretOrPublicKey instanceof KeyObject)) {
try {
secretOrPublicKey = createPublicKey(secretOrPublicKey); // cannot succeed for an HMAC secret
} catch (_) {
try {
secretOrPublicKey = createSecretKey(/* ... */);Confirmed independently with node --cpu-prof over 200k iterations, which attributes self-time per frame with no differencing involved:
内容来源: auth0/node-jsonwebtoken