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

31 lines
1.0 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvalidBackupFlags = void 0;
exports.parseBackupFlags = parseBackupFlags;
/**
* Make sense of Bits 3 and 4 in authenticator indicating:
*
* - Whether the credential can be used on multiple devices
* - Whether the credential is backed up or not
*
* Invalid configurations will raise an `Error`
*/
function parseBackupFlags({ be, bs }) {
const credentialBackedUp = bs;
let credentialDeviceType = 'singleDevice';
if (be) {
credentialDeviceType = 'multiDevice';
}
if (credentialDeviceType === 'singleDevice' && credentialBackedUp) {
throw new InvalidBackupFlags('Single-device credential indicated that it was backed up, which should be impossible.');
}
return { credentialDeviceType, credentialBackedUp };
}
class InvalidBackupFlags extends Error {
constructor(message) {
super(message);
this.name = 'InvalidBackupFlags';
}
}
exports.InvalidBackupFlags = InvalidBackupFlags;