toolcraft 0.0.91 → 0.0.93

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.
Files changed (62) hide show
  1. package/composition.json +60 -0
  2. package/dist/composition.d.ts +15 -0
  3. package/dist/composition.js +10 -0
  4. package/dist/composition.json +60 -0
  5. package/node_modules/@poe-code/agent-defs/package.json +9 -5
  6. package/node_modules/@poe-code/agent-human-in-loop/package.json +8 -4
  7. package/node_modules/@poe-code/agent-mcp-config/package.json +8 -4
  8. package/node_modules/@poe-code/config-mutations/package.json +8 -4
  9. package/node_modules/@poe-code/frontmatter/package.json +8 -4
  10. package/node_modules/@poe-code/process-runner/package.json +8 -4
  11. package/node_modules/@poe-code/task-list/package.json +8 -4
  12. package/node_modules/auth-store/package.json +3 -4
  13. package/node_modules/tiny-mcp-client/.turbo/turbo-build.log +1 -1
  14. package/node_modules/tiny-mcp-client/dist/index.d.ts +660 -2
  15. package/node_modules/tiny-mcp-client/dist/index.js +3870 -1
  16. package/node_modules/tiny-mcp-client/package.json +8 -4
  17. package/node_modules/tiny-mcp-client/scripts/build.mjs +63 -0
  18. package/node_modules/toolcraft-design/package.json +3 -7
  19. package/package.json +11 -7
  20. package/node_modules/mcp-oauth/LICENSE +0 -21
  21. package/node_modules/mcp-oauth/README.md +0 -31
  22. package/node_modules/mcp-oauth/dist/client/auth-store-session-store.d.ts +0 -14
  23. package/node_modules/mcp-oauth/dist/client/auth-store-session-store.js +0 -169
  24. package/node_modules/mcp-oauth/dist/client/authorization-state.d.ts +0 -8
  25. package/node_modules/mcp-oauth/dist/client/authorization-state.js +0 -47
  26. package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.d.ts +0 -3
  27. package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +0 -627
  28. package/node_modules/mcp-oauth/dist/client/loopback-authorization.d.ts +0 -20
  29. package/node_modules/mcp-oauth/dist/client/loopback-authorization.js +0 -207
  30. package/node_modules/mcp-oauth/dist/client/pkce.d.ts +0 -2
  31. package/node_modules/mcp-oauth/dist/client/pkce.js +0 -7
  32. package/node_modules/mcp-oauth/dist/client/token-endpoint.d.ts +0 -40
  33. package/node_modules/mcp-oauth/dist/client/token-endpoint.js +0 -164
  34. package/node_modules/mcp-oauth/dist/client/types.d.ts +0 -113
  35. package/node_modules/mcp-oauth/dist/client/types.js +0 -1
  36. package/node_modules/mcp-oauth/dist/index.d.ts +0 -10
  37. package/node_modules/mcp-oauth/dist/index.js +0 -7
  38. package/node_modules/mcp-oauth/dist/resource-indicator.d.ts +0 -1
  39. package/node_modules/mcp-oauth/dist/resource-indicator.js +0 -11
  40. package/node_modules/mcp-oauth/dist/server/jwks-token-verifier.d.ts +0 -28
  41. package/node_modules/mcp-oauth/dist/server/jwks-token-verifier.js +0 -304
  42. package/node_modules/mcp-oauth/dist/types.compile-check.d.ts +0 -1
  43. package/node_modules/mcp-oauth/dist/types.compile-check.js +0 -22
  44. package/node_modules/mcp-oauth/package.json +0 -32
  45. package/node_modules/tiny-mcp-client/dist/internal.d.ts +0 -556
  46. package/node_modules/tiny-mcp-client/dist/internal.js +0 -2688
  47. package/node_modules/tiny-mcp-client/dist/jsonrpc-types.compile-check.d.ts +0 -1
  48. package/node_modules/tiny-mcp-client/dist/jsonrpc-types.compile-check.js +0 -37
  49. package/node_modules/tiny-mcp-client/dist/mcp-lifecycle-types.compile-check.d.ts +0 -1
  50. package/node_modules/tiny-mcp-client/dist/mcp-lifecycle-types.compile-check.js +0 -50
  51. package/node_modules/tiny-mcp-client/dist/mcp-prompt-types.compile-check.d.ts +0 -1
  52. package/node_modules/tiny-mcp-client/dist/mcp-prompt-types.compile-check.js +0 -50
  53. package/node_modules/tiny-mcp-client/dist/mcp-resource-types.compile-check.d.ts +0 -1
  54. package/node_modules/tiny-mcp-client/dist/mcp-resource-types.compile-check.js +0 -51
  55. package/node_modules/tiny-mcp-client/dist/mcp-tool-types.compile-check.d.ts +0 -1
  56. package/node_modules/tiny-mcp-client/dist/mcp-tool-types.compile-check.js +0 -99
  57. package/node_modules/tiny-mcp-client/dist/mcp-transport-types.compile-check.d.ts +0 -1
  58. package/node_modules/tiny-mcp-client/dist/mcp-transport-types.compile-check.js +0 -56
  59. package/node_modules/tiny-mcp-client/dist/mcp-utility-types.compile-check.d.ts +0 -1
  60. package/node_modules/tiny-mcp-client/dist/mcp-utility-types.compile-check.js +0 -145
  61. package/node_modules/tiny-mcp-client/dist/oauth-discovery.d.ts +0 -24
  62. package/node_modules/tiny-mcp-client/dist/oauth-discovery.js +0 -382
@@ -1,304 +0,0 @@
1
- import { decodeProtectedHeader, errors, importJWK, jwtVerify, } from "jose";
2
- import { canonicalizeResourceIndicator } from "../resource-indicator.js";
3
- const DEFAULT_ALLOWED_ALGORITHMS = [
4
- "ES256",
5
- "ES384",
6
- "ES512",
7
- "RS256",
8
- "RS384",
9
- "RS512",
10
- "PS256",
11
- "PS384",
12
- "PS512",
13
- "EdDSA",
14
- ];
15
- function isTokenVerificationErrorShape(error) {
16
- if (!(error instanceof Error)) {
17
- return false;
18
- }
19
- const challengeError = error;
20
- return challengeError.error === "invalid_token"
21
- || challengeError.error === "insufficient_scope";
22
- }
23
- function isObjectRecord(value) {
24
- return typeof value === "object" && value !== null && !Array.isArray(value);
25
- }
26
- function isStringArray(value) {
27
- return Array.isArray(value) && value.every((item) => typeof item === "string");
28
- }
29
- function getOwnEntry(record, key) {
30
- return Object.prototype.hasOwnProperty.call(record, key)
31
- ? record[key]
32
- : undefined;
33
- }
34
- function getOwnString(record, key) {
35
- const value = getOwnEntry(record, key);
36
- return typeof value === "string" ? value : undefined;
37
- }
38
- function toUrl(value, label) {
39
- try {
40
- return new URL(String(value));
41
- }
42
- catch {
43
- throw new Error(`${label} must be an absolute URL`);
44
- }
45
- }
46
- function normalizeAudience(value) {
47
- if (typeof value === "string") {
48
- return [value];
49
- }
50
- return isStringArray(value) ? [...value] : [];
51
- }
52
- function normalizeVerifiedAudience(value, expectedResource) {
53
- const audiences = normalizeAudience(value);
54
- if (audiences.length !== 1) {
55
- throw createInvalidTokenError("audience mismatch");
56
- }
57
- let normalizedAudience;
58
- try {
59
- normalizedAudience = canonicalizeResourceIndicator(audiences[0] ?? "");
60
- }
61
- catch {
62
- throw createInvalidTokenError("audience mismatch");
63
- }
64
- if (normalizedAudience !== expectedResource) {
65
- throw createInvalidTokenError("audience mismatch");
66
- }
67
- return [normalizedAudience];
68
- }
69
- function parseScopes(payload) {
70
- const scope = getOwnString(payload, "scope");
71
- const scopes = getOwnEntry(payload, "scopes");
72
- const raw = scope !== undefined
73
- ? scope
74
- : typeof scopes === "string"
75
- ? scopes
76
- : null;
77
- if (raw !== null) {
78
- return raw
79
- .split(" ")
80
- .map((scope) => scope.trim())
81
- .filter((scope) => scope.length > 0);
82
- }
83
- return isStringArray(scopes) ? [...scopes] : [];
84
- }
85
- function toVerifiedAccessToken(token, payload, audience = normalizeAudience(getOwnEntry(payload, "aud"))) {
86
- const issuer = getOwnString(payload, "iss");
87
- const expiresAt = getOwnEntry(payload, "exp");
88
- const subject = getOwnString(payload, "sub");
89
- const clientId = getOwnString(payload, "client_id");
90
- return {
91
- token,
92
- issuer: issuer ?? "",
93
- audience,
94
- scopes: parseScopes(payload),
95
- expiresAt: typeof expiresAt === "number" ? expiresAt : 0,
96
- claims: { ...payload },
97
- ...(subject !== undefined
98
- ? {
99
- subject,
100
- }
101
- : {}),
102
- ...(clientId !== undefined
103
- ? {
104
- clientId,
105
- }
106
- : {}),
107
- };
108
- }
109
- function createTokenVerificationError(input) {
110
- return Object.assign(new Error(input.errorDescription ?? input.error), input);
111
- }
112
- function createInvalidTokenError(errorDescription) {
113
- return createTokenVerificationError({
114
- error: "invalid_token",
115
- errorDescription,
116
- });
117
- }
118
- function normalizeVerificationError(error) {
119
- if (isTokenVerificationErrorShape(error)) {
120
- return error;
121
- }
122
- if (error instanceof errors.JWTExpired) {
123
- return createInvalidTokenError("token expired");
124
- }
125
- if (error instanceof errors.JWTClaimValidationFailed) {
126
- if (error.claim === "aud") {
127
- return createInvalidTokenError("audience mismatch");
128
- }
129
- if (error.claim === "iss") {
130
- return createInvalidTokenError("issuer mismatch");
131
- }
132
- if (error.claim === "nbf") {
133
- return createInvalidTokenError("token not active yet");
134
- }
135
- if (error.claim === "exp") {
136
- return createInvalidTokenError("token expired");
137
- }
138
- }
139
- if (error instanceof errors.JOSEAlgNotAllowed
140
- || error instanceof errors.JOSENotSupported) {
141
- return createInvalidTokenError("unsupported token algorithm");
142
- }
143
- if (error instanceof errors.JWKSNoMatchingKey
144
- || error instanceof errors.JWKSMultipleMatchingKeys
145
- || error instanceof errors.JWSSignatureVerificationFailed) {
146
- return createInvalidTokenError("token signature invalid");
147
- }
148
- if (error instanceof errors.JWKSInvalid) {
149
- return createInvalidTokenError("invalid JWKS document");
150
- }
151
- if (error instanceof errors.JWKSTimeout) {
152
- return createInvalidTokenError("timed out loading JWKS");
153
- }
154
- if (error instanceof Error) {
155
- return createInvalidTokenError(error.message);
156
- }
157
- return createInvalidTokenError("token verification failed");
158
- }
159
- async function loadJwks(jwksUrl, fetchImplementation) {
160
- const response = await fetchImplementation(jwksUrl, {
161
- headers: {
162
- Accept: "application/json",
163
- },
164
- });
165
- if (!response.ok) {
166
- throw createInvalidTokenError(`unable to load JWKS (${response.status})`);
167
- }
168
- const payload = (await response.json());
169
- const keys = isObjectRecord(payload) ? getOwnEntry(payload, "keys") : undefined;
170
- if (!isObjectRecord(payload) || !Array.isArray(keys)) {
171
- throw createInvalidTokenError("invalid JWKS document");
172
- }
173
- return { ...payload, keys };
174
- }
175
- function resolveAlgorithm(token, allowedAlgorithms) {
176
- const header = decodeProtectedHeader(token);
177
- const alg = getOwnString(header, "alg");
178
- if (hasCriticalHeaderClaims(header)) {
179
- throw createInvalidTokenError("unsupported critical token claims");
180
- }
181
- if (typeof alg !== "string"
182
- || alg === "none"
183
- || alg.startsWith("HS")
184
- || !allowedAlgorithms.includes(alg)) {
185
- throw createInvalidTokenError("unsupported token algorithm");
186
- }
187
- return alg;
188
- }
189
- function hasCriticalHeaderClaims(header) {
190
- const criticalClaims = getOwnEntry(header, "crit");
191
- return Array.isArray(criticalClaims) && criticalClaims.length > 0;
192
- }
193
- function isVerificationCandidate(key, alg, kid) {
194
- const keyId = getOwnString(key, "kid");
195
- const keyAlgorithm = getOwnString(key, "alg");
196
- const keyUse = getOwnString(key, "use");
197
- const keyOps = getOwnEntry(key, "key_ops");
198
- if (kid !== undefined && keyId !== kid) {
199
- return false;
200
- }
201
- if (keyAlgorithm !== undefined && keyAlgorithm !== alg) {
202
- return false;
203
- }
204
- if (keyUse !== undefined && keyUse !== "sig") {
205
- return false;
206
- }
207
- if (Array.isArray(keyOps) && !keyOps.includes("verify")) {
208
- return false;
209
- }
210
- return true;
211
- }
212
- function shouldContinueWithNextKey(error) {
213
- return error instanceof errors.JWSSignatureVerificationFailed;
214
- }
215
- async function verifyJwtAgainstJwks(input) {
216
- const protectedHeader = decodeProtectedHeader(input.token);
217
- const kid = getOwnString(protectedHeader, "kid");
218
- const candidateKeys = input.jwks.keys.filter((key) => isVerificationCandidate(key, input.alg, kid));
219
- if (candidateKeys.length === 0) {
220
- throw createInvalidTokenError("token signature invalid");
221
- }
222
- let lastSignatureError;
223
- for (const candidate of candidateKeys) {
224
- try {
225
- const key = await importJWK(candidate, input.alg);
226
- return await jwtVerify(input.token, key, {
227
- algorithms: [input.alg],
228
- issuer: [...input.authorizationServers],
229
- clockTolerance: input.clockSkewSeconds,
230
- });
231
- }
232
- catch (error) {
233
- if (shouldContinueWithNextKey(error)) {
234
- lastSignatureError = error;
235
- continue;
236
- }
237
- throw error;
238
- }
239
- }
240
- throw lastSignatureError ?? createInvalidTokenError("token signature invalid");
241
- }
242
- export function createJwksTokenVerifier(options) {
243
- const jwksUrl = toUrl(options.jwksUrl, "jwksUrl");
244
- const clockSkewSeconds = options.clockSkewSeconds ?? 30;
245
- const allowedAlgorithms = options.allowedAlgorithms ?? DEFAULT_ALLOWED_ALGORITHMS;
246
- const jwksCacheTtlMs = options.jwksCacheTtlMs ?? 300_000;
247
- const fetchImplementation = options.fetch ?? globalThis.fetch;
248
- let cachedJwks;
249
- let pendingJwks;
250
- if (typeof fetchImplementation !== "function") {
251
- throw new Error("fetch is not available; pass options.fetch explicitly");
252
- }
253
- async function getJwks() {
254
- const now = Date.now();
255
- if (cachedJwks !== undefined && cachedJwks.expiresAt > now) {
256
- return cachedJwks.value;
257
- }
258
- if (pendingJwks !== undefined) {
259
- return pendingJwks;
260
- }
261
- pendingJwks = loadJwks(jwksUrl, fetchImplementation)
262
- .then((jwks) => {
263
- cachedJwks = {
264
- value: jwks,
265
- expiresAt: Date.now() + jwksCacheTtlMs,
266
- };
267
- return jwks;
268
- })
269
- .finally(() => {
270
- pendingJwks = undefined;
271
- });
272
- return pendingJwks;
273
- }
274
- return {
275
- async verify(input) {
276
- const expectedResource = canonicalizeResourceIndicator(input.resource);
277
- const algorithm = resolveAlgorithm(input.token, allowedAlgorithms);
278
- try {
279
- const jwks = await getJwks();
280
- const verified = await verifyJwtAgainstJwks({
281
- token: input.token,
282
- jwks,
283
- alg: algorithm,
284
- authorizationServers: input.authorizationServers,
285
- clockSkewSeconds,
286
- });
287
- const audience = normalizeVerifiedAudience(getOwnEntry(verified.payload, "aud"), expectedResource);
288
- const accessToken = toVerifiedAccessToken(input.token, verified.payload, audience);
289
- if (input.requiredScopes.length > 0
290
- && !input.requiredScopes.every((scope) => accessToken.scopes.includes(scope))) {
291
- throw createTokenVerificationError({
292
- error: "insufficient_scope",
293
- errorDescription: "insufficient scope",
294
- scope: [...input.requiredScopes],
295
- });
296
- }
297
- return accessToken;
298
- }
299
- catch (error) {
300
- throw normalizeVerificationError(error);
301
- }
302
- },
303
- };
304
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- const ignoredImplicitGrantOptions = {
2
- client: {
3
- mode: "static",
4
- clientId: "client-id",
5
- // @ts-expect-error implicit response types are not configurable via the public API
6
- responseType: "token",
7
- },
8
- browser: {
9
- openBrowser: async () => { },
10
- },
11
- };
12
- const ignoredPasswordGrantOptions = {
13
- client: {
14
- mode: "dynamic",
15
- // @ts-expect-error password grants are not configurable via the public API
16
- grantType: "password",
17
- },
18
- browser: {
19
- openBrowser: async () => { },
20
- },
21
- };
22
- export {};
@@ -1,32 +0,0 @@
1
- {
2
- "name": "mcp-oauth",
3
- "version": "0.0.1",
4
- "license": "MIT",
5
- "private": true,
6
- "type": "module",
7
- "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js"
13
- }
14
- },
15
- "scripts": {
16
- "build": "tsc"
17
- },
18
- "dependencies": {
19
- "jose": "^6.1.2"
20
- },
21
- "devDependencies": {
22
- "tiny-oauth-test-server": "*"
23
- },
24
- "files": [
25
- "dist"
26
- ],
27
- "repository": {
28
- "type": "git",
29
- "url": "git+https://github.com/poe-platform/poe-code.git",
30
- "directory": "packages/mcp-oauth"
31
- }
32
- }