@ferrlabs/mcp-core 6.5.4 → 7.0.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.
|
@@ -33,13 +33,13 @@ describe('apiRequest', () => {
|
|
|
33
33
|
});
|
|
34
34
|
it('includes x-api-token header when token is provided', async () => {
|
|
35
35
|
mockFetch.mockResolvedValue(makeResponse({ id: 'user-1' }));
|
|
36
|
-
await apiRequest('/
|
|
36
|
+
await apiRequest('/auth/me', { token: 'my-secret-token' });
|
|
37
37
|
const [, init] = mockFetch.mock.calls[0];
|
|
38
38
|
expect(init.headers['x-api-token']).toBe('my-secret-token');
|
|
39
39
|
});
|
|
40
40
|
it('returns undefined for 204 No Content responses', async () => {
|
|
41
41
|
mockFetch.mockResolvedValue({ ok: true, status: 204, json: vi.fn() });
|
|
42
|
-
const result = await apiRequest('/
|
|
42
|
+
const result = await apiRequest('/auth/tokens/123', { method: 'DELETE' });
|
|
43
43
|
expect(result).toBeUndefined();
|
|
44
44
|
});
|
|
45
45
|
it('throws an error when the response is not ok', async () => {
|
|
@@ -52,19 +52,19 @@ describe('apiRequest', () => {
|
|
|
52
52
|
});
|
|
53
53
|
it('sends a JSON body for POST requests', async () => {
|
|
54
54
|
mockFetch.mockResolvedValue(makeResponse({ id: 'tok-1' }));
|
|
55
|
-
await apiRequest('/
|
|
55
|
+
await apiRequest('/auth/tokens', { method: 'POST', body: { name: 'ci', scopes: ['*'] } });
|
|
56
56
|
const [, init] = mockFetch.mock.calls[0];
|
|
57
57
|
expect(init.body).toBe(JSON.stringify({ name: 'ci', scopes: ['*'] }));
|
|
58
58
|
});
|
|
59
59
|
it('clears persisted token and cache on 401 with a token', async () => {
|
|
60
60
|
mockFetch.mockResolvedValue(makeResponse({ error: 'unauthorized' }, 401));
|
|
61
|
-
await expect(apiRequest('/
|
|
61
|
+
await expect(apiRequest('/orgs', { token: 'stale' })).rejects.toBeInstanceOf(UnauthorizedError);
|
|
62
62
|
expect(clearPersistedTokenMock).toHaveBeenCalledOnce();
|
|
63
63
|
expect(clearTokenCacheMock).toHaveBeenCalledOnce();
|
|
64
64
|
});
|
|
65
65
|
it('does not clear persisted token on 401 without a token', async () => {
|
|
66
66
|
mockFetch.mockResolvedValue(makeResponse({ error: 'unauthorized' }, 401));
|
|
67
|
-
await expect(apiRequest('/
|
|
67
|
+
await expect(apiRequest('/orgs')).rejects.toThrow('unauthorized');
|
|
68
68
|
expect(clearPersistedTokenMock).not.toHaveBeenCalled();
|
|
69
69
|
expect(clearTokenCacheMock).not.toHaveBeenCalled();
|
|
70
70
|
});
|
package/dist/api-client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAMA,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,iBAAkB,SAAQ,KAAK;
|
|
1
|
+
{"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAMA,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED,wBAAsB,UAAU,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,CAAC,CAAC,CAmD1F"}
|
package/dist/auth/oauth.js
CHANGED
|
@@ -97,7 +97,7 @@ function bindCallbackListener(port, expectedState) {
|
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
99
|
async function exchangeCodeForToken(code, codeVerifier, redirectUri) {
|
|
100
|
-
const res = await fetchWithTimeout(`${API_BASE}/
|
|
100
|
+
const res = await fetchWithTimeout(`${API_BASE}/auth/exchange`, {
|
|
101
101
|
method: 'POST',
|
|
102
102
|
headers: { 'Content-Type': 'application/json', 'User-Agent': 'ferrlabs-mcp/oauth' },
|
|
103
103
|
body: JSON.stringify({
|
package/package.json
CHANGED