Lines 1-41javascript
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.loadTokens = loadTokens;
4exports.saveTokens = saveTokens;
5exports.clearTokens = clearTokens;
6exports.exchangeCodeForTokens = exchangeCodeForTokens;
7exports.refreshAccessToken = refreshAccessToken;
8exports.getValidAccessToken = getValidAccessToken;
9exports.generateCodeVerifier = generateCodeVerifier;
10exports.generateCodeChallenge = generateCodeChallenge;
11exports.generateState = generateState;
12exports.startCallbackServer = startCallbackServer;
13exports.openBrowser = openBrowser;
14exports.authorize = authorize;
15const node_https_1 = require("node:https");
16const node_http_1 = require("node:http");
17const node_fs_1 = require("node:fs");
18const node_path_1 = require("node:path");
19const node_os_1 = require("node:os");
20const node_http_2 = require("node:http");
21const node_crypto_1 = require("node:crypto");
22const node_child_process_1 = require("node:child_process");
23// ── Token Storage ────────────────────────────────────────────
24const SCOREHUB_DIR = (0, node_path_1.join)((0, node_os_1.homedir)(), ".scorehub");
25const TOKEN_FILE = (host) => (0, node_path_1.join)(SCOREHUB_DIR, host, "oauth.json");
26function ensureDir(filePath) {
27 const dir = (0, node_path_1.dirname)(filePath);
28 if (!(0, node_fs_1.existsSync)(dir)) {
29 (0, node_fs_1.mkdirSync)(dir, { recursive: true });
32function loadTokens(host) {
33 const file = TOKEN_FILE(host);
34 if (!(0, node_fs_1.existsSync)(file))
37 return JSON.parse((0, node_fs_1.readFileSync)(file, "utf-8"));