tiny-http-mcp-server 0.1.62 → 0.1.64
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/composition.json +1 -1
- package/node_modules/auth-store/README.md +3 -1
- package/node_modules/auth-store/dist/encrypted-file-store.js +1 -0
- package/node_modules/auth-store/dist/transaction-lock.js +1 -0
- package/node_modules/mcp-oauth/README.md +12 -3
- package/node_modules/mcp-oauth/dist/client/auth-store-session-store.js +4 -2
- package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +10 -5
- package/node_modules/mcp-oauth/dist/client/resource-bound-store.js +2 -0
- package/node_modules/mcp-oauth/dist/client/token-endpoint.js +6 -0
- package/node_modules/tiny-mcp-client/dist/index.js +21 -7
- package/package.json +1 -1
package/dist/composition.json
CHANGED
|
@@ -34,7 +34,9 @@ for transactions spanning a read, external operation and write. Independent
|
|
|
34
34
|
instances and processes serialize the same encrypted file or Keychain
|
|
35
35
|
service/account; unrelated identities proceed independently. The default
|
|
36
36
|
acquisition timeout is 30 seconds. Cancellation during acquisition does not
|
|
37
|
-
release the active owner's lock.
|
|
37
|
+
release the active owner's lock. Each acquisition retains its original signal
|
|
38
|
+
and timeout before path checks wait; replacing the caller's option handles cannot
|
|
39
|
+
bypass original cancellation or introduce another signal's cancellation. Individual `get`, `set` and `delete` calls do
|
|
38
40
|
not implicitly acquire it.
|
|
39
41
|
|
|
40
42
|
Locks use private filesystem claim directories, containing PID/random names
|
|
@@ -81,6 +81,7 @@ export class EncryptedFileStore {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
async withLock(operation, options = {}) {
|
|
84
|
+
options = { ...options };
|
|
84
85
|
await this.assertCredentialPathHasNoSymbolicLinks(`${this.filePath}.lock`);
|
|
85
86
|
if (this.fs.readdir === undefined)
|
|
86
87
|
throw new Error("Secret-store transaction locks require filesystem readdir support");
|
|
@@ -3,6 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { hasOwnErrorCode } from "./error-codes.js";
|
|
4
4
|
/** Filesystem bakery lock: unique claims allow dead-owner cleanup without deleting a replacement owner's lock. */
|
|
5
5
|
export async function withSecretStoreFileLock(fs, lockDirectory, operation, options = {}) {
|
|
6
|
+
options = { ...options };
|
|
6
7
|
const timeoutMs = options.timeoutMs ?? 30_000;
|
|
7
8
|
if (!Number.isFinite(timeoutMs) || timeoutMs < 0 || timeoutMs > 2_147_483_647)
|
|
8
9
|
throw new Error("Invalid secret-store transaction lock timeout");
|
|
@@ -64,7 +64,8 @@ aborting the original signal still cancels authorization.
|
|
|
64
64
|
Native session and client persistence factories also capture file paths, salts,
|
|
65
65
|
Keychain identities, lock locations and selected filesystem/command handles.
|
|
66
66
|
Mutating these settings cannot redirect a later read or write.
|
|
67
|
-
The factories
|
|
67
|
+
The factories copy these settings before reading the selected backend environment
|
|
68
|
+
variable, so its getter cannot replace them. They resolve that variable once at creation;
|
|
68
69
|
later environment changes cannot move a transaction between file and Keychain.
|
|
69
70
|
|
|
70
71
|
`createJwksTokenVerifier(options)` accepts:
|
|
@@ -125,7 +126,11 @@ timeoutMs })`. Reset acquires the raw identity backend lock, so it can recover
|
|
|
125
126
|
corrupt or undecryptable records without reading their old contents. It atomically
|
|
126
127
|
retires the identity's grant and registrations and writes a marker that suppresses
|
|
127
128
|
stale initial grants. The default lock wait is 30 seconds. Other names/profiles
|
|
128
|
-
are untouched, and symlink paths are still refused.
|
|
129
|
+
are untouched, and symlink paths are still refused. Native reset, import and
|
|
130
|
+
transaction callbacks retain their original signal while locks or reconciliation
|
|
131
|
+
wait; replacing a caller handle cannot change subsequent cancellation checks.
|
|
132
|
+
Cancellation after a completed identity write prevents the transaction callback
|
|
133
|
+
from running and retains that already persisted identity.
|
|
129
134
|
|
|
130
135
|
Configure `client.metadata.scope` to request a precise scope set; broader
|
|
131
136
|
discovery metadata does not override it. Explicit scopes must match the cached
|
|
@@ -255,7 +260,11 @@ transient retry or restoration of the original grant. Gateway error pages do not
|
|
|
255
260
|
Native persisted OAuth reads always reject corrupt encrypted documents and
|
|
256
261
|
invalid stored JSON, with diagnostics that omit decrypted contents. They retain
|
|
257
262
|
the existing record for explicit reset rather than interpreting corruption as
|
|
258
|
-
an absent session and reviving an initial grant.
|
|
263
|
+
an absent session and reviving an initial grant. Persisted access tokens that
|
|
264
|
+
cannot be sent as HTTP headers fail with diagnostics that omit token contents;
|
|
265
|
+
the original record remains available for explicit recovery. Token responses are
|
|
266
|
+
checked before activation or persistence. An unusable rotated access token keeps
|
|
267
|
+
refresh intent pending, preventing rotating-token replay. Caller file-backend settings
|
|
259
268
|
cannot disable this policy.
|
|
260
269
|
|
|
261
270
|
## Environment Variables
|
|
@@ -82,12 +82,14 @@ export function createAuthStoreClientStore(options, namespace) {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
function snapshotPersistenceOptions(options) {
|
|
85
|
-
|
|
86
|
-
...options,
|
|
85
|
+
const snapshot = {
|
|
86
|
+
...options,
|
|
87
87
|
...(options.fileStore === undefined ? {} : { fileStore: { ...options.fileStore } }),
|
|
88
88
|
...(options.keychainStore === undefined ? {} : { keychainStore: { ...options.keychainStore,
|
|
89
89
|
...(options.keychainStore.lock === undefined ? {} : { lock: { ...options.keychainStore.lock } }) } })
|
|
90
90
|
};
|
|
91
|
+
snapshot.backend = resolveSecretStoreBackend(snapshot);
|
|
92
|
+
return snapshot;
|
|
91
93
|
}
|
|
92
94
|
export function createNamedSecretStore(key, options, defaults, namespace) {
|
|
93
95
|
const hash = crypto.createHash("sha256").update(namespace === undefined ? key : JSON.stringify([namespace, key])).digest("hex");
|
|
@@ -591,11 +591,16 @@ function normalizeLoadedSession(session) {
|
|
|
591
591
|
if (client === null) {
|
|
592
592
|
return { ...session, client: { clientId: "" }, tokens: undefined };
|
|
593
593
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
594
|
+
const tokens = normalizeStoredTokens(getOwnEntry(session, "tokens"));
|
|
595
|
+
if (tokens !== undefined) {
|
|
596
|
+
try {
|
|
597
|
+
new Headers({ Authorization: `Bearer ${tokens.accessToken}` });
|
|
598
|
+
}
|
|
599
|
+
catch {
|
|
600
|
+
throw new Error("Stored OAuth access token is not a valid HTTP header value");
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return { ...session, client, tokens };
|
|
599
604
|
}
|
|
600
605
|
function normalizeImportedTokens(value, now) {
|
|
601
606
|
if (!isObjectRecord(value))
|
|
@@ -51,6 +51,7 @@ export function createResourceBoundOAuthStores(options, namespace, identity) {
|
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
53
|
async function replace(record, options) {
|
|
54
|
+
options = { ...options };
|
|
54
55
|
options.signal?.throwIfAborted();
|
|
55
56
|
const timeoutMs = options.timeoutMs ?? 30_000;
|
|
56
57
|
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 2_147_483_647)
|
|
@@ -124,6 +125,7 @@ export function createResourceBoundOAuthStores(options, namespace, identity) {
|
|
|
124
125
|
}
|
|
125
126
|
result.sessionStore = {
|
|
126
127
|
async withLock(resource, operation, options) {
|
|
128
|
+
options = { ...options };
|
|
127
129
|
if (store.withLock === undefined)
|
|
128
130
|
throw new Error("OAuth resource identity backend must support transaction locks");
|
|
129
131
|
return store.withLock(async () => {
|
|
@@ -105,6 +105,12 @@ async function requestTokens(input) {
|
|
|
105
105
|
throw new Error("OAuth token response missing access_token");
|
|
106
106
|
}
|
|
107
107
|
const normalizedAccessToken = accessToken.trim();
|
|
108
|
+
try {
|
|
109
|
+
new Headers({ Authorization: `Bearer ${normalizedAccessToken}` });
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
throw new Error("OAuth token response access_token is not a valid HTTP header value");
|
|
113
|
+
}
|
|
108
114
|
const tokenType = normalizeBearerTokenType(getOwnEntry(payload, "token_type"));
|
|
109
115
|
if (tokenType === null) {
|
|
110
116
|
throw new Error("OAuth token response missing token_type=Bearer");
|
|
@@ -3907,6 +3907,7 @@ function hasOwnErrorCode(error, code) {
|
|
|
3907
3907
|
import { randomUUID } from "node:crypto";
|
|
3908
3908
|
import path from "node:path";
|
|
3909
3909
|
async function withSecretStoreFileLock(fs2, lockDirectory, operation, options = {}) {
|
|
3910
|
+
options = { ...options };
|
|
3910
3911
|
const timeoutMs = options.timeoutMs ?? 3e4;
|
|
3911
3912
|
if (!Number.isFinite(timeoutMs) || timeoutMs < 0 || timeoutMs > 2147483647)
|
|
3912
3913
|
throw new Error("Invalid secret-store transaction lock timeout");
|
|
@@ -4126,6 +4127,7 @@ var EncryptedFileStore = class {
|
|
|
4126
4127
|
}
|
|
4127
4128
|
}
|
|
4128
4129
|
async withLock(operation, options = {}) {
|
|
4130
|
+
options = { ...options };
|
|
4129
4131
|
await this.assertCredentialPathHasNoSymbolicLinks(`${this.filePath}.lock`);
|
|
4130
4132
|
if (this.fs.readdir === void 0)
|
|
4131
4133
|
throw new Error("Secret-store transaction locks require filesystem readdir support");
|
|
@@ -4638,15 +4640,16 @@ function createAuthStoreClientStore(options, namespace) {
|
|
|
4638
4640
|
};
|
|
4639
4641
|
}
|
|
4640
4642
|
function snapshotPersistenceOptions(options) {
|
|
4641
|
-
|
|
4643
|
+
const snapshot = {
|
|
4642
4644
|
...options,
|
|
4643
|
-
backend: resolveSecretStoreBackend(options),
|
|
4644
4645
|
...options.fileStore === void 0 ? {} : { fileStore: { ...options.fileStore } },
|
|
4645
4646
|
...options.keychainStore === void 0 ? {} : { keychainStore: {
|
|
4646
4647
|
...options.keychainStore,
|
|
4647
4648
|
...options.keychainStore.lock === void 0 ? {} : { lock: { ...options.keychainStore.lock } }
|
|
4648
4649
|
} }
|
|
4649
4650
|
};
|
|
4651
|
+
snapshot.backend = resolveSecretStoreBackend(snapshot);
|
|
4652
|
+
return snapshot;
|
|
4650
4653
|
}
|
|
4651
4654
|
function createNamedSecretStore(key2, options, defaults, namespace) {
|
|
4652
4655
|
const hash = crypto2.createHash("sha256").update(namespace === void 0 ? key2 : JSON.stringify([namespace, key2])).digest("hex");
|
|
@@ -4790,6 +4793,7 @@ function createResourceBoundOAuthStores(options, namespace, identity) {
|
|
|
4790
4793
|
}
|
|
4791
4794
|
};
|
|
4792
4795
|
async function replace(record2, options2) {
|
|
4796
|
+
options2 = { ...options2 };
|
|
4793
4797
|
options2.signal?.throwIfAborted();
|
|
4794
4798
|
const timeoutMs = options2.timeoutMs ?? 3e4;
|
|
4795
4799
|
if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 2147483647)
|
|
@@ -4855,6 +4859,7 @@ function createResourceBoundOAuthStores(options, namespace, identity) {
|
|
|
4855
4859
|
}
|
|
4856
4860
|
result.sessionStore = {
|
|
4857
4861
|
async withLock(resource, operation, options2) {
|
|
4862
|
+
options2 = { ...options2 };
|
|
4858
4863
|
if (store.withLock === void 0)
|
|
4859
4864
|
throw new Error("OAuth resource identity backend must support transaction locks");
|
|
4860
4865
|
return store.withLock(async () => {
|
|
@@ -5111,6 +5116,11 @@ async function requestTokens(input) {
|
|
|
5111
5116
|
throw new Error("OAuth token response missing access_token");
|
|
5112
5117
|
}
|
|
5113
5118
|
const normalizedAccessToken = accessToken.trim();
|
|
5119
|
+
try {
|
|
5120
|
+
new Headers({ Authorization: `Bearer ${normalizedAccessToken}` });
|
|
5121
|
+
} catch {
|
|
5122
|
+
throw new Error("OAuth token response access_token is not a valid HTTP header value");
|
|
5123
|
+
}
|
|
5114
5124
|
const tokenType = normalizeBearerTokenType(getOwnEntry5(payload, "token_type"));
|
|
5115
5125
|
if (tokenType === null) {
|
|
5116
5126
|
throw new Error("OAuth token response missing token_type=Bearer");
|
|
@@ -5822,11 +5832,15 @@ function normalizeLoadedSession(session) {
|
|
|
5822
5832
|
if (client === null) {
|
|
5823
5833
|
return { ...session, client: { clientId: "" }, tokens: void 0 };
|
|
5824
5834
|
}
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5835
|
+
const tokens = normalizeStoredTokens(getOwnEntry6(session, "tokens"));
|
|
5836
|
+
if (tokens !== void 0) {
|
|
5837
|
+
try {
|
|
5838
|
+
new Headers({ Authorization: `Bearer ${tokens.accessToken}` });
|
|
5839
|
+
} catch {
|
|
5840
|
+
throw new Error("Stored OAuth access token is not a valid HTTP header value");
|
|
5841
|
+
}
|
|
5842
|
+
}
|
|
5843
|
+
return { ...session, client, tokens };
|
|
5830
5844
|
}
|
|
5831
5845
|
function normalizeImportedTokens(value, now) {
|
|
5832
5846
|
if (!isObjectRecord3(value))
|