@todoist/mcp 19.2.0 → 19.3.0

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.
@@ -1,82 +0,0 @@
1
- import { validateBearerToken as A, getValidationRateLimit as v, createTokenVerdictCache as k, buildBearerChallenge as f } from "@todoist/mcp-core/host";
2
- import { a5 as p, a6 as g } from "./mcp-server-DYBahuLO.js";
3
- const m = "https://api.todoist.com", E = (e, t) => A({
4
- // Resolved the way the SDK resolves its own requests against a custom base URL. An empty
5
- // base (`TODOIST_BASE_URL=`) means the default, as it does for the SDK client.
6
- url: new URL("/api/v1/user", t || m),
7
- token: e,
8
- headers: g({ label: "auth:validate-token" }),
9
- fetch: p
10
- }), L = 3e5, S = 12e4, U = 1e4, y = 60, u = /* @__PURE__ */ new Map();
11
- function b(e) {
12
- let t = u.get(e);
13
- return t || (t = k({
14
- ttlMs: e,
15
- maxEntries: U,
16
- now: () => Date.now()
17
- }), u.set(e, t)), t;
18
- }
19
- function h(e, { tokenSent: t, resourceMetadataUrl: r }) {
20
- e.status(401).set(
21
- "WWW-Authenticate",
22
- f({
23
- error: t ? "invalid_token" : void 0,
24
- resourceMetadataUrl: r
25
- })
26
- ).json(
27
- t ? {
28
- error: "invalid_token",
29
- error_description: "Todoist API token is invalid or expired"
30
- } : { error_description: "Todoist API token is missing" }
31
- );
32
- }
33
- function w(e, t) {
34
- e.status(403).set(
35
- "WWW-Authenticate",
36
- f({ error: "insufficient_scope", resourceMetadataUrl: t })
37
- ).json({
38
- error: "insufficient_scope",
39
- error_description: "Todoist API token does not have the required scopes"
40
- });
41
- }
42
- function I(e, t) {
43
- e.status(429).set("Retry-After", String(t)).json({ error_description: "Todoist API rate limit reached, retry later" });
44
- }
45
- function T(e, t, r, i) {
46
- e === "valid" ? r() : e === "forbidden" ? w(t, i) : h(t, { tokenSent: !0, resourceMetadataUrl: i });
47
- }
48
- function D(e) {
49
- const t = e.type === "static" ? L : S, r = b(e.cacheTtlMs ?? t), { resourceMetadataUrl: i } = e;
50
- return async (_, n, a) => {
51
- const o = e.type === "static" ? e.apiKey : e.getApiKey(_);
52
- if (!o) {
53
- h(n, { tokenSent: !1, resourceMetadataUrl: i });
54
- return;
55
- }
56
- const d = r.get(o, e.baseUrl);
57
- if (d !== void 0) {
58
- T(d, n, a, i);
59
- return;
60
- }
61
- let s;
62
- try {
63
- s = await E(o, e.baseUrl);
64
- } catch (c) {
65
- const l = v(c);
66
- if (l) {
67
- console.warn(
68
- "[Token validation] Todoist API rate limit reached, answering 429:",
69
- c
70
- ), I(n, l.retryAfterSeconds ?? y);
71
- return;
72
- }
73
- console.warn("[Token validation] Validation failed, proceeding:", c), a();
74
- return;
75
- }
76
- r.set(o, e.baseUrl, s), T(s, n, a, i);
77
- };
78
- }
79
- export {
80
- D as r,
81
- E as v
82
- };