@todoist/mcp-core 1.0.0 → 1.2.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.
- package/README.md +11 -10
- package/dist/host/challenge.d.ts +13 -4
- package/dist/host/challenge.d.ts.map +1 -1
- package/dist/host/challenge.js +2 -1
- package/dist/host/challenge.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -129,14 +129,14 @@ export const validateNotesToken: ValidateToken = (token, baseUrl = 'https://note
|
|
|
129
129
|
validateBearerToken({ url: `${baseUrl}/api/v1/me`, token })
|
|
130
130
|
```
|
|
131
131
|
|
|
132
|
-
| The API answers | `validateBearerToken`
|
|
133
|
-
| ------------------------------------- |
|
|
134
|
-
| 2xx | `valid`
|
|
135
|
-
| 401 | `invalid`: the host sends a 401 challenge, and the client refreshes its token
|
|
136
|
-
| 403 | `forbidden`, or whatever `classifyForbidden(response)` returns
|
|
137
|
-
| any other status, a redirect included | throws `TokenValidationError`, whose `httpStatusCode` lets the host treat a 5xx as transient
|
|
138
|
-
| nothing within `timeoutMs` (5s) | rejects with the `TimeoutError`
|
|
139
|
-
| a network failure | rejects with the error unchanged
|
|
132
|
+
| The API answers | `validateBearerToken` |
|
|
133
|
+
| ------------------------------------- | --------------------------------------------------------------------------------------------- |
|
|
134
|
+
| 2xx | `valid` |
|
|
135
|
+
| 401 | `invalid`: the host sends a 401 `invalid_token` challenge, and the client refreshes its token |
|
|
136
|
+
| 403 | `forbidden`, or whatever `classifyForbidden(response)` returns |
|
|
137
|
+
| any other status, a redirect included | throws `TokenValidationError`, whose `httpStatusCode` lets the host treat a 5xx as transient |
|
|
138
|
+
| nothing within `timeoutMs` (5s) | rejects with the `TimeoutError` |
|
|
139
|
+
| a network failure | rejects with the error unchanged |
|
|
140
140
|
|
|
141
141
|
The body is drained unread, so a change to the response's shape can't misclassify a token and the connection goes back to the pool. Redirects aren't followed: a sign-in page that answers 200 would otherwise pass for an accepted token. Pass `classifyForbidden` when a 403 can also mean a refusal that consent can't lift, `headers` to tag the request, and `fetch` when the server's API client has its own transport (a proxy from `HTTPS_PROXY`, say), so validation goes the same way as every other call.
|
|
142
142
|
|
|
@@ -168,9 +168,10 @@ async function checkToken(token: string, baseUrl: string): Promise<Response | 'p
|
|
|
168
168
|
status: forbidden ? 403 : 401,
|
|
169
169
|
headers: {
|
|
170
170
|
'WWW-Authenticate': buildBearerChallenge({
|
|
171
|
-
error: forbidden ? 'insufficient_scope' :
|
|
171
|
+
error: forbidden ? 'insufficient_scope' : 'invalid_token',
|
|
172
172
|
resourceMetadataUrl:
|
|
173
173
|
'https://notes.example.com/.well-known/oauth-protected-resource/mcp',
|
|
174
|
+
scopes: ['notes:read', 'notes:write'],
|
|
174
175
|
}),
|
|
175
176
|
},
|
|
176
177
|
})
|
|
@@ -178,7 +179,7 @@ async function checkToken(token: string, baseUrl: string): Promise<Response | 'p
|
|
|
178
179
|
```
|
|
179
180
|
|
|
180
181
|
- `isTransientValidationError`: a timeout, a dropped or refused connection, or a 5xx, the rejections worth retrying. A redirect or a 404 is not.
|
|
181
|
-
- `buildBearerChallenge`: `Bearer`, with `error="
|
|
182
|
+
- `buildBearerChallenge`: `Bearer`, with `error="…"`, `resource_metadata="…"` and `scope="…"` (from `scopes`, space-separated) when given. Pass `error: 'invalid_token'` on a 401 for a token that was sent and refused, `'insufficient_scope'` on a 403, and no `error` when the request carried no token (RFC 6750 §3.1). MCP clients request the challenge's `scope` ahead of the metadata's `scopes_supported`, so pass the resource's scopes to help a client that never reads the metadata.
|
|
182
183
|
- `createTokenVerdictCache`: verdicts keyed by token and base URL, kept for `ttlMs`, the oldest dropped when full.
|
|
183
184
|
|
|
184
185
|
### Contract tests
|
package/dist/host/challenge.d.ts
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
export type BearerChallengeOptions = {
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* The RFC 6750 error code. `invalid_token` for a 401 on a token that was sent but is revoked,
|
|
4
|
+
* expired or otherwise refused, so the client knows to refresh it or authorise again.
|
|
5
|
+
* `insufficient_scope` for a 403 on a token that lacks a scope, so the client asks for consent
|
|
6
|
+
* again. Left out when the request carried no token at all (RFC 6750 §3.1): there is nothing
|
|
7
|
+
* wrong with a token that was never sent.
|
|
5
8
|
*/
|
|
6
|
-
error?: 'insufficient_scope';
|
|
9
|
+
error?: 'invalid_token' | 'insufficient_scope';
|
|
7
10
|
/** The resource's protected-resource metadata (RFC 9728), where the client finds how to authorise. */
|
|
8
11
|
resourceMetadataUrl?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The scopes a token needs for this resource, sent as RFC 6750's `scope` attribute. MCP clients
|
|
14
|
+
* request these first, ahead of the metadata's `scopes_supported`, so a client that can't find
|
|
15
|
+
* the resource's metadata still asks for the right ones. Left out when empty.
|
|
16
|
+
*/
|
|
17
|
+
scopes?: readonly string[];
|
|
9
18
|
};
|
|
10
19
|
/** The `WWW-Authenticate` value for a refused bearer token. */
|
|
11
|
-
export declare function buildBearerChallenge({ error, resourceMetadataUrl, }?: BearerChallengeOptions): string;
|
|
20
|
+
export declare function buildBearerChallenge({ error, resourceMetadataUrl, scopes, }?: BearerChallengeOptions): string;
|
|
12
21
|
//# sourceMappingURL=challenge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"challenge.d.ts","sourceRoot":"","sources":["../../src/host/challenge.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG;IACjC
|
|
1
|
+
{"version":3,"file":"challenge.d.ts","sourceRoot":"","sources":["../../src/host/challenge.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG;IACjC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,eAAe,GAAG,oBAAoB,CAAA;IAC9C,sGAAsG;IACtG,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAC5B;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC7B,CAAA;AAED,+DAA+D;AAC/D,wBAAgB,oBAAoB,CAAC,EACjC,KAAK,EACL,mBAAmB,EACnB,MAAM,GACT,GAAE,sBAA2B,GAAG,MAAM,CAOtC"}
|
package/dist/host/challenge.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/** The `WWW-Authenticate` value for a refused bearer token. */
|
|
2
|
-
export function buildBearerChallenge({ error, resourceMetadataUrl, } = {}) {
|
|
2
|
+
export function buildBearerChallenge({ error, resourceMetadataUrl, scopes, } = {}) {
|
|
3
3
|
const params = [
|
|
4
4
|
...(error ? [`error="${error}"`] : []),
|
|
5
5
|
...(resourceMetadataUrl ? [`resource_metadata="${resourceMetadataUrl}"`] : []),
|
|
6
|
+
...(scopes && scopes.length > 0 ? [`scope="${scopes.join(' ')}"`] : []),
|
|
6
7
|
];
|
|
7
8
|
return params.length > 0 ? `Bearer ${params.join(', ')}` : 'Bearer';
|
|
8
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"challenge.js","sourceRoot":"","sources":["../../src/host/challenge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"challenge.js","sourceRoot":"","sources":["../../src/host/challenge.ts"],"names":[],"mappings":"AAmBA,+DAA+D;AAC/D,MAAM,UAAU,oBAAoB,CAAC,EACjC,KAAK,EACL,mBAAmB,EACnB,MAAM,GACT,GAA2B,EAAE;IAC1B,MAAM,MAAM,GAAG;QACX,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,sBAAsB,mBAAmB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9E,GAAG,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1E,CAAA;IACD,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,UAAU,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAA;AACvE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@todoist/mcp-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Shared core for the Doist MCP servers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -64,11 +64,11 @@
|
|
|
64
64
|
"@types/node": "25.9.9",
|
|
65
65
|
"conventional-changelog-conventionalcommits": "9.3.1",
|
|
66
66
|
"lefthook": "2.2.2",
|
|
67
|
-
"oxfmt": "0.
|
|
68
|
-
"oxlint": "1.
|
|
67
|
+
"oxfmt": "0.79.0",
|
|
68
|
+
"oxlint": "1.94.0",
|
|
69
69
|
"semantic-release": "25.0.9",
|
|
70
70
|
"typescript": "7.0.2",
|
|
71
|
-
"vitest": "5.
|
|
71
|
+
"vitest": "5.1.1",
|
|
72
72
|
"zod": "4.6.7"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|