V-1488abed / src /proxy /proxy-keys.ts
krazyxki's picture
Duplicate from neurokun/V-1488
29ce54a
raw
history blame contribute delete
385 Bytes
import crypto from 'crypto';
const keys = new Set<string>();
const generate = () => {
let key = crypto.randomUUID();
keys.add(key);
return key;
};
const revoke = (key: string | undefined) =>
key && keys.delete(key);
const check = (key: string | undefined) =>
Boolean(key && keys.has(key));
export const proxyKeys = {
revoke,
generate,
check,
};