mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-08 11:23:40 +01:00
Reviewed and verified at d1e3afa4af.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
13 lines
417 B
TypeScript
13 lines
417 B
TypeScript
/** Authenticated API use is real activity; rejecting an unknown key is not. */
|
|
export class IdleApiActivity {
|
|
private until = 0;
|
|
constructor(private readonly now: () => number = () => performance.now()) {}
|
|
record(): void {
|
|
this.until = Math.max(this.until, this.now() + 10 * 60_000);
|
|
}
|
|
active(): boolean {
|
|
return this.now() < this.until;
|
|
}
|
|
}
|
|
export const idleApiActivity = new IdleApiActivity();
|