mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-19 22:27:20 +02:00
feat: add read-only GitHub App access alongside OAuth
This commit is contained in:
1 parent
e5c44845f0
commit
a60ad6a921
49 files changed
+1754
-139
No files matched your search
@@ -0,0 +1,12 @@
|
||||
import { createHash } from "crypto";
|
||||
|
||||
interface TokenContext { quotaKey: string; renew: (force?: boolean) => Promise<string>; }
|
||||
const contexts = new Map<string, TokenContext>();
|
||||
export function registerGitHubToken(token: string, context: TokenContext) {
|
||||
if (contexts.size >= 2000 && !contexts.has(token)) contexts.delete(contexts.keys().next().value!);
|
||||
contexts.set(token, context);
|
||||
}
|
||||
export function githubTokenContext(token: string) { return contexts.get(token); }
|
||||
export function githubQuotaKey(token: string) {
|
||||
return contexts.get(token)?.quotaKey || createHash("sha256").update(token).digest("hex").slice(0, 24);
|
||||
}
|
||||
Reference in new issue
Block a user