@gonzih/cc-tg 0.9.13 → 0.9.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tokens.js DELETED
@@ -1,56 +0,0 @@
1
- /**
2
- * OAuth token pool management.
3
- *
4
- * Supports CLAUDE_CODE_OAUTH_TOKENS (comma-separated list of tokens).
5
- * Falls back to CLAUDE_CODE_OAUTH_TOKEN for single-token / backwards compat.
6
- */
7
- let tokens = [];
8
- let currentIndex = 0;
9
- let initialized = false;
10
- /**
11
- * Load tokens from env vars. Called on startup; also re-callable in tests.
12
- * Priority: CLAUDE_CODE_OAUTH_TOKENS > CLAUDE_CODE_OAUTH_TOKEN > (empty)
13
- */
14
- export function loadTokens() {
15
- const multi = process.env.CLAUDE_CODE_OAUTH_TOKENS;
16
- if (multi) {
17
- tokens = multi.split(",").map((t) => t.trim()).filter(Boolean);
18
- }
19
- else {
20
- const single = process.env.CLAUDE_CODE_OAUTH_TOKEN;
21
- tokens = single ? [single] : [];
22
- }
23
- currentIndex = 0;
24
- initialized = true;
25
- return tokens;
26
- }
27
- function ensureInitialized() {
28
- if (!initialized)
29
- loadTokens();
30
- }
31
- /** Returns the current active token, or empty string if none configured. */
32
- export function getCurrentToken() {
33
- ensureInitialized();
34
- return tokens[currentIndex] ?? "";
35
- }
36
- /**
37
- * Advance to the next token (wraps around).
38
- * Returns the new current token.
39
- */
40
- export function rotateToken() {
41
- ensureInitialized();
42
- if (tokens.length === 0)
43
- return "";
44
- currentIndex = (currentIndex + 1) % tokens.length;
45
- return tokens[currentIndex];
46
- }
47
- /** Zero-based index of the current token. */
48
- export function getTokenIndex() {
49
- ensureInitialized();
50
- return currentIndex;
51
- }
52
- /** Total number of tokens in the pool. */
53
- export function getTokenCount() {
54
- ensureInitialized();
55
- return tokens.length;
56
- }