backups/src/client.ts

24 lines
458 B
TypeScript

import crypto from 'node:crypto';
export type Client = {
name: string;
keySha256Sum: string;
/**
* In megabytes
*/
quota?: number;
};
export type NoKeyClient = {
name: string;
quota?: number;
};
export function checkKey(key: string, client: Client): boolean {
const sha = crypto.createHash('sha256');
sha.update(key);
const hashed = sha.digest().toString('hex');
return client.keySha256Sum === hashed;
}