Files
NapCatQQ/.pnpm-store/v3/files/7a/65a05dda2dacbc090727cd7ddbed8413f972572589cb0a065a2df4cabb72ff8e850414a6bd185ffcda082bad4b80ba568d7f138c064473297e8916de868387
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

40 lines
1.5 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._verifySignatureInternals = void 0;
exports.verifySignature = verifySignature;
const index_js_1 = require("./iso/index.js");
const decodeCredentialPublicKey_js_1 = require("./decodeCredentialPublicKey.js");
const convertX509PublicKeyToCOSE_js_1 = require("./convertX509PublicKeyToCOSE.js");
/**
* Verify an authenticator's signature
*/
function verifySignature(opts) {
const { signature, data, credentialPublicKey, x509Certificate, hashAlgorithm, } = opts;
if (!x509Certificate && !credentialPublicKey) {
throw new Error('Must declare either "leafCert" or "credentialPublicKey"');
}
if (x509Certificate && credentialPublicKey) {
throw new Error('Must not declare both "leafCert" and "credentialPublicKey"');
}
let cosePublicKey = new Map();
if (credentialPublicKey) {
cosePublicKey = (0, decodeCredentialPublicKey_js_1.decodeCredentialPublicKey)(credentialPublicKey);
}
else if (x509Certificate) {
cosePublicKey = (0, convertX509PublicKeyToCOSE_js_1.convertX509PublicKeyToCOSE)(x509Certificate);
}
return exports._verifySignatureInternals.stubThis(index_js_1.isoCrypto.verify({
cosePublicKey,
signature,
data,
shaHashOverride: hashAlgorithm,
}));
}
/**
* Make it possible to stub the return value during testing
* @ignore Don't include this in docs output
*/
exports._verifySignatureInternals = {
stubThis: (value) => value,
};