@proof-holdings/mcp-server 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/LICENSE +1 -1
- package/README.md +220 -217
- package/dist/authBoundary.d.ts +193 -0
- package/dist/authBoundary.d.ts.map +1 -0
- package/dist/authBoundary.js +341 -0
- package/dist/authBoundary.js.map +1 -0
- package/dist/factory.d.ts +35 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/factory.js +130 -0
- package/dist/factory.js.map +1 -0
- package/dist/http.d.ts +78 -3
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +251 -6
- package/dist/http.js.map +1 -1
- package/dist/remote.d.ts +111 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +789 -0
- package/dist/remote.js.map +1 -0
- package/dist/server.js +11 -57
- package/dist/server.js.map +1 -1
- package/dist/toolAnnotations.d.ts +27 -0
- package/dist/toolAnnotations.d.ts.map +1 -0
- package/dist/toolAnnotations.js +158 -0
- package/dist/toolAnnotations.js.map +1 -0
- package/dist/tools/{projects.d.ts → accounts.d.ts} +1 -1
- package/dist/tools/accounts.d.ts.map +1 -0
- package/dist/tools/accounts.js +70 -0
- package/dist/tools/accounts.js.map +1 -0
- package/dist/tools/api-keys.d.ts.map +1 -1
- package/dist/tools/api-keys.js +14 -5
- package/dist/tools/api-keys.js.map +1 -1
- package/dist/tools/auth-flows.d.ts +4 -0
- package/dist/tools/auth-flows.d.ts.map +1 -0
- package/dist/tools/auth-flows.js +34 -0
- package/dist/tools/auth-flows.js.map +1 -0
- package/dist/tools/auth.js +1 -1
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/authorizations.d.ts +4 -0
- package/dist/tools/authorizations.d.ts.map +1 -0
- package/dist/tools/authorizations.js +111 -0
- package/dist/tools/authorizations.js.map +1 -0
- package/dist/tools/circles.d.ts +4 -0
- package/dist/tools/circles.d.ts.map +1 -0
- package/dist/tools/circles.js +215 -0
- package/dist/tools/circles.js.map +1 -0
- package/dist/tools/confirmations.d.ts +4 -0
- package/dist/tools/confirmations.d.ts.map +1 -0
- package/dist/tools/confirmations.js +86 -0
- package/dist/tools/confirmations.js.map +1 -0
- package/dist/tools/delegation-verify-outcomes.d.ts +23 -0
- package/dist/tools/delegation-verify-outcomes.d.ts.map +1 -0
- package/dist/tools/delegation-verify-outcomes.js +51 -0
- package/dist/tools/delegation-verify-outcomes.js.map +1 -0
- package/dist/tools/delegation-verify.d.ts +24 -0
- package/dist/tools/delegation-verify.d.ts.map +1 -0
- package/dist/tools/delegation-verify.js +192 -0
- package/dist/tools/delegation-verify.js.map +1 -0
- package/dist/tools/delegations.d.ts +4 -0
- package/dist/tools/delegations.d.ts.map +1 -0
- package/dist/tools/delegations.js +84 -0
- package/dist/tools/delegations.js.map +1 -0
- package/dist/tools/domains.d.ts.map +1 -1
- package/dist/tools/domains.js +1 -2
- package/dist/tools/domains.js.map +1 -1
- package/dist/tools/hitl-keys.d.ts +4 -0
- package/dist/tools/hitl-keys.d.ts.map +1 -0
- package/dist/tools/hitl-keys.js +52 -0
- package/dist/tools/hitl-keys.js.map +1 -0
- package/dist/tools/hitl.d.ts +4 -0
- package/dist/tools/hitl.d.ts.map +1 -0
- package/dist/tools/hitl.js +151 -0
- package/dist/tools/hitl.js.map +1 -0
- package/dist/tools/phones.js +1 -1
- package/dist/tools/phones.js.map +1 -1
- package/dist/tools/profiles.d.ts.map +1 -1
- package/dist/tools/profiles.js +73 -0
- package/dist/tools/profiles.js.map +1 -1
- package/dist/tools/proof-me.d.ts +4 -0
- package/dist/tools/proof-me.d.ts.map +1 -0
- package/dist/tools/proof-me.js +36 -0
- package/dist/tools/proof-me.js.map +1 -0
- package/dist/tools/proofs.d.ts.map +1 -1
- package/dist/tools/proofs.js +9 -6
- package/dist/tools/proofs.js.map +1 -1
- package/dist/tools/render-auth-link.d.ts +3 -0
- package/dist/tools/render-auth-link.d.ts.map +1 -0
- package/dist/tools/render-auth-link.js +30 -0
- package/dist/tools/render-auth-link.js.map +1 -0
- package/dist/tools/sessions.js +5 -5
- package/dist/tools/sessions.js.map +1 -1
- package/dist/tools/settings.d.ts.map +1 -1
- package/dist/tools/settings.js +77 -2
- package/dist/tools/settings.js.map +1 -1
- package/dist/tools/twofa.d.ts.map +1 -1
- package/dist/tools/twofa.js +16 -3
- package/dist/tools/twofa.js.map +1 -1
- package/dist/tools/user-requests.d.ts.map +1 -1
- package/dist/tools/user-requests.js +1 -2
- package/dist/tools/user-requests.js.map +1 -1
- package/dist/tools/verification-requests.d.ts.map +1 -1
- package/dist/tools/verification-requests.js +40 -13
- package/dist/tools/verification-requests.js.map +1 -1
- package/dist/tools/verifications.d.ts.map +1 -1
- package/dist/tools/verifications.js +59 -12
- package/dist/tools/verifications.js.map +1 -1
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +114 -5
- package/dist/types.js.map +1 -1
- package/package.json +11 -5
- package/dist/tools/projects.d.ts.map +0 -1
- package/dist/tools/projects.js +0 -159
- package/dist/tools/projects.js.map +0 -1
package/dist/factory.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { HttpClient } from './http.js';
|
|
3
|
+
import { accessNoticeFor, serverInstructions } from './authBoundary.js';
|
|
4
|
+
import { annotationsFor } from './toolAnnotations.js';
|
|
5
|
+
import { registerTools as registerVerifications } from './tools/verifications.js';
|
|
6
|
+
import { registerTools as registerVerificationRequests } from './tools/verification-requests.js';
|
|
7
|
+
import { registerTools as registerProofs } from './tools/proofs.js';
|
|
8
|
+
import { registerTools as registerSessions } from './tools/sessions.js';
|
|
9
|
+
import { registerTools as registerAssets } from './tools/assets.js';
|
|
10
|
+
import { registerTools as registerAuth } from './tools/auth.js';
|
|
11
|
+
import { registerTools as registerSettings } from './tools/settings.js';
|
|
12
|
+
import { registerTools as registerTemplates } from './tools/templates.js';
|
|
13
|
+
import { registerTools as registerWebhookDeliveries } from './tools/webhook-deliveries.js';
|
|
14
|
+
import { registerTools as registerBilling } from './tools/billing.js';
|
|
15
|
+
import { registerTools as registerProfiles } from './tools/profiles.js';
|
|
16
|
+
import { registerTools as registerEmails } from './tools/emails.js';
|
|
17
|
+
import { registerTools as registerPhones } from './tools/phones.js';
|
|
18
|
+
import { registerTools as registerApiKeys } from './tools/api-keys.js';
|
|
19
|
+
import { registerTools as registerTwofa } from './tools/twofa.js';
|
|
20
|
+
import { registerTools as registerDomains } from './tools/domains.js';
|
|
21
|
+
import { registerTools as registerDnsCredentials } from './tools/dns-credentials.js';
|
|
22
|
+
import { registerTools as registerUserRequests } from './tools/user-requests.js';
|
|
23
|
+
import { registerTools as registerUserDomainVerify } from './tools/user-domain-verify.js';
|
|
24
|
+
import { registerTools as registerPublicProfiles } from './tools/public-profiles.js';
|
|
25
|
+
import { registerTools as registerAuthorizations } from './tools/authorizations.js';
|
|
26
|
+
import { registerTools as registerConfirmations } from './tools/confirmations.js';
|
|
27
|
+
import { registerTools as registerHitl } from './tools/hitl.js';
|
|
28
|
+
import { registerTools as registerHitlKeys } from './tools/hitl-keys.js';
|
|
29
|
+
import { registerTools as registerProofMe } from './tools/proof-me.js';
|
|
30
|
+
import { registerTools as registerCircles } from './tools/circles.js';
|
|
31
|
+
import { registerTools as registerDelegations } from './tools/delegations.js';
|
|
32
|
+
import { registerTools as registerDelegationVerify } from './tools/delegation-verify.js';
|
|
33
|
+
import { registerTools as registerAuthFlows } from './tools/auth-flows.js';
|
|
34
|
+
import { registerTools as registerAccounts } from './tools/accounts.js';
|
|
35
|
+
import { registerTools as registerRenderAuthLink } from './tools/render-auth-link.js';
|
|
36
|
+
/**
|
|
37
|
+
* Builds one MCP server with its own HTTP client.
|
|
38
|
+
*
|
|
39
|
+
* Why a factory at all (`h-mcp-remote`, SC-4): the stdio entrypoint serves exactly one user, so one
|
|
40
|
+
* `HttpClient` per process is correct there. The remote server serves many, and `HttpClient` keeps
|
|
41
|
+
* `sessionToken` / `refreshToken` as INSTANCE fields written by `captureSetCookie` — sharing one
|
|
42
|
+
* across connections would hand the next user the previous user's logged-in session. So the unit of
|
|
43
|
+
* isolation is the connection, and this function is that unit.
|
|
44
|
+
*
|
|
45
|
+
* The registration list below is the ONLY copy in the package: `server.ts` calls this rather than
|
|
46
|
+
* repeating it. A second copy would work on the day it was written and drift one module at a time
|
|
47
|
+
* afterwards, with both paths green — `__tests__/factory.test.ts` pins both the list's completeness
|
|
48
|
+
* against `src/tools` and the absence of a second copy in `server.ts`.
|
|
49
|
+
*/
|
|
50
|
+
export function createProofServer(options) {
|
|
51
|
+
const http = new HttpClient({
|
|
52
|
+
apiKey: options.apiKey,
|
|
53
|
+
baseUrl: options.baseUrl,
|
|
54
|
+
remote: options.remote,
|
|
55
|
+
});
|
|
56
|
+
const access = { remote: options.remote, hasCredential: Boolean(options.apiKey) };
|
|
57
|
+
const server = new McpServer({
|
|
58
|
+
name: 'proof-holdings',
|
|
59
|
+
// The version every client reads back from `initialize`, and the one a user quotes in a bug
|
|
60
|
+
// report. A LITERAL rather than a read of `mcp/package.json` — a CHOICE, not a constraint;
|
|
61
|
+
// the manifest is reachable from here. What makes the literal safe is the pin below, never
|
|
62
|
+
// that choice. Held equal to the manifest by
|
|
63
|
+
// `src/__tests__/drift/delegation-publication.test.ts` (h-npm-registry-release). If this is
|
|
64
|
+
// ever replaced by a real read, delete the pin in the same change: a pin over a derived
|
|
65
|
+
// value guards nothing.
|
|
66
|
+
version: '1.2.0',
|
|
67
|
+
}, { instructions: serverInstructions(access) });
|
|
68
|
+
const bound = server.tool.bind(server);
|
|
69
|
+
const toolNames = new Set();
|
|
70
|
+
/**
|
|
71
|
+
* The registrar every module below is handed, wrapping `server.tool` so the access notice is
|
|
72
|
+
* appended in ONE place (`h-fix-mcp-agent-facing-text`, SC-1).
|
|
73
|
+
*
|
|
74
|
+
* Editing 176 descriptions by hand would have put the same sentence in 176 places, drifting one
|
|
75
|
+
* tool at a time, and each copy would have had to know the transport it was registered on —
|
|
76
|
+
* which a description literal cannot. Here the classification in `authBoundary.ts` is read once,
|
|
77
|
+
* beside the connection that determines it. The signature is `server.tool`'s own, and only the
|
|
78
|
+
* description argument is touched: a registration whose second argument is not a string is passed
|
|
79
|
+
* through untouched rather than being coerced, because the SDK accepts several call shapes and a
|
|
80
|
+
* wrapper that assumes one would corrupt the others.
|
|
81
|
+
*/
|
|
82
|
+
const tool = ((...args) => {
|
|
83
|
+
const [name, description] = args;
|
|
84
|
+
const registered = (typeof name === 'string' && typeof description === 'string'
|
|
85
|
+
? bound(name, description + accessNoticeFor(name, access), ...args.slice(2))
|
|
86
|
+
: bound(...args));
|
|
87
|
+
// Stamped after registration rather than passed as an argument, so the modules' call shape —
|
|
88
|
+
// which the tool counters and the tests' capture mock both read — stays exactly as it is.
|
|
89
|
+
if (typeof name === 'string') {
|
|
90
|
+
registered.update({ annotations: annotationsFor(name) });
|
|
91
|
+
toolNames.add(name);
|
|
92
|
+
}
|
|
93
|
+
return registered;
|
|
94
|
+
});
|
|
95
|
+
registerVerifications(tool, http);
|
|
96
|
+
registerVerificationRequests(tool, http);
|
|
97
|
+
registerProofs(tool, http);
|
|
98
|
+
registerSessions(tool, http);
|
|
99
|
+
registerAssets(tool, http);
|
|
100
|
+
registerAuth(tool, http);
|
|
101
|
+
registerSettings(tool, http);
|
|
102
|
+
registerTemplates(tool, http);
|
|
103
|
+
registerWebhookDeliveries(tool, http);
|
|
104
|
+
registerBilling(tool, http);
|
|
105
|
+
registerProfiles(tool, http);
|
|
106
|
+
registerEmails(tool, http);
|
|
107
|
+
registerPhones(tool, http);
|
|
108
|
+
registerApiKeys(tool, http);
|
|
109
|
+
registerTwofa(tool, http);
|
|
110
|
+
registerDomains(tool, http);
|
|
111
|
+
registerDnsCredentials(tool, http);
|
|
112
|
+
registerUserRequests(tool, http);
|
|
113
|
+
registerUserDomainVerify(tool, http);
|
|
114
|
+
registerPublicProfiles(tool, http);
|
|
115
|
+
registerAuthorizations(tool, http);
|
|
116
|
+
registerConfirmations(tool, http);
|
|
117
|
+
registerHitl(tool, http);
|
|
118
|
+
registerHitlKeys(tool, http);
|
|
119
|
+
registerProofMe(tool, http);
|
|
120
|
+
registerCircles(tool, http);
|
|
121
|
+
registerDelegations(tool, http);
|
|
122
|
+
// Takes the base URL rather than the HTTP client: verifying a third party's delegation runs
|
|
123
|
+
// against PUBLIC surfaces only and carries no API key.
|
|
124
|
+
registerDelegationVerify(tool, { baseUrl: options.baseUrl });
|
|
125
|
+
registerAuthFlows(tool, http);
|
|
126
|
+
registerAccounts(tool, http);
|
|
127
|
+
registerRenderAuthLink(tool);
|
|
128
|
+
return { server, http, toolNames };
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAuB,MAAM,yCAAyC,CAAC;AAEzF,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAsB,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,aAAa,IAAI,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAE,aAAa,IAAI,4BAA4B,EAAE,MAAM,kCAAkC,CAAC;AACjG,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,aAAa,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAAE,aAAa,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,aAAa,IAAI,gBAAgB,EAAE,MAAM,qBA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C3B,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC1B,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACjC,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACrC,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnC,qBAAqB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACzB,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,eAAe,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,mBAAmB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAChC,4FAA4F;IAC5F,uDAAuD;IACvD,wBAAwB,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7D,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9B,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC7B,sBAAsB,CAAC,IAAI,CAAC,CAAC;IAE7B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;AACrC,CAAC"}
|
package/dist/http.d.ts
CHANGED
|
@@ -1,26 +1,101 @@
|
|
|
1
1
|
export interface HttpClientConfig {
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* API key (Bearer). OPTIONAL — the server also runs in public mode, where the bootstrap
|
|
4
|
+
* and verification surfaces work with no credential at all and every other tool answers
|
|
5
|
+
* `api_key_required` instead of the process exiting at startup.
|
|
6
|
+
*/
|
|
7
|
+
apiKey?: string;
|
|
3
8
|
baseUrl: string;
|
|
4
9
|
timeout?: number;
|
|
5
10
|
maxRetries?: number;
|
|
11
|
+
/**
|
|
12
|
+
* True when this client serves the REMOTE transport (`src/remote.ts`) rather than a local stdio
|
|
13
|
+
* process. It changes exactly one thing — what the "you need a key" refusal tells the user to do
|
|
14
|
+
* — because the stdio instruction (set `PROOF_API_KEY`, restart the server) is impossible on a
|
|
15
|
+
* server somebody else runs.
|
|
16
|
+
*/
|
|
17
|
+
remote?: boolean;
|
|
6
18
|
}
|
|
7
19
|
type QueryValue = string | number | boolean | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Routes that sit UNDER a `SESSION_AUTH_PREFIXES` prefix but are not session-only on the backend,
|
|
22
|
+
* so a keyed client without a login session may still send them with the key. Everything else on
|
|
23
|
+
* the session surface is refused before the network when no session is held
|
|
24
|
+
* (`user_session_required`): the backend's answer there would be `invalid_token`, which an agent
|
|
25
|
+
* reads as "the key is bad" rather than "sign in first".
|
|
26
|
+
*
|
|
27
|
+
* `src/__tests__/drift/api-parity.test.ts` holds this list against `docs/api-map.yaml` in both
|
|
28
|
+
* directions: every endpoint under the session prefixes whose `auth` is not `jwt` must match an
|
|
29
|
+
* entry, and every entry must match such an endpoint.
|
|
30
|
+
*/
|
|
31
|
+
export declare const SESSION_EXEMPT_PATHS: ReadonlyArray<{
|
|
32
|
+
method: string;
|
|
33
|
+
pattern: RegExp;
|
|
34
|
+
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Endpoints the client may call with NO credential — the public mode surface.
|
|
37
|
+
*
|
|
38
|
+
* Stored as (method, prefix) PAIRS, not bare prefixes, and the reason is load-bearing:
|
|
39
|
+
* `/api/v1/auth/sessions` is the prefix of two public routes (create a login session, poll one)
|
|
40
|
+
* AND of two `jwt+api_key` ones (`GET /auth/sessions` lists sessions, `DELETE /auth/sessions/:id`
|
|
41
|
+
* revokes one). A prefix-only list would mark those two public, so a keyless call would travel to
|
|
42
|
+
* the network and come back `invalid_token` instead of getting the structured hint here.
|
|
43
|
+
*
|
|
44
|
+
* The drift rule `validateMcpPublicPathCoverage` (scripts/validate-api-map.ts) requires every
|
|
45
|
+
* `auth: public` + `mcp: available` endpoint in docs/api-map.yaml to appear below. That rule is a
|
|
46
|
+
* LOWER BOUND, not the definition: the two poll routes are carried here but not required by it,
|
|
47
|
+
* because the map holds them `planned` (they are reached through `wait_for_login` /
|
|
48
|
+
* `wait_for_account_creation` rather than by a tool of their own). Removing them would leave both
|
|
49
|
+
* wait tools broken in public mode while every check stayed green.
|
|
50
|
+
*/
|
|
51
|
+
export declare const PUBLIC_PATHS: ReadonlyArray<{
|
|
52
|
+
method: string;
|
|
53
|
+
prefix: string;
|
|
54
|
+
}>;
|
|
8
55
|
export declare class HttpClient {
|
|
9
56
|
readonly baseUrl: string;
|
|
10
|
-
private readonly apiKey
|
|
57
|
+
private readonly apiKey?;
|
|
11
58
|
private readonly timeout;
|
|
12
59
|
private readonly maxRetries;
|
|
60
|
+
private readonly remote;
|
|
61
|
+
private sessionToken?;
|
|
62
|
+
private refreshToken?;
|
|
63
|
+
private refreshing?;
|
|
13
64
|
constructor(config: HttpClientConfig);
|
|
14
65
|
request<T>(method: string, path: string, options?: {
|
|
15
66
|
body?: unknown;
|
|
16
67
|
query?: Record<string, QueryValue>;
|
|
68
|
+
headers?: Record<string, string>;
|
|
69
|
+
/** Internal: set on the post-refresh retry to prevent an infinite refresh loop. */
|
|
70
|
+
_refreshed?: boolean;
|
|
17
71
|
}): Promise<T>;
|
|
72
|
+
/**
|
|
73
|
+
* True once a login flow has put a session on this client (`captureSetCookie`).
|
|
74
|
+
*
|
|
75
|
+
* Boolean only, never the token: the remote server needs to know whether this CONNECTION has
|
|
76
|
+
* been signed in — the bootstrap road `start_login` opens — and nothing else. Without it a caller
|
|
77
|
+
* with no API key looks identical before and after signing in, and the tools behind
|
|
78
|
+
* `SESSION_AUTH_PREFIXES` are refused to a user who just logged in.
|
|
79
|
+
*/
|
|
80
|
+
hasSessionToken(): boolean;
|
|
18
81
|
get<T>(path: string, query?: Record<string, QueryValue>): Promise<T>;
|
|
19
82
|
post<T>(path: string, body?: unknown): Promise<T>;
|
|
20
83
|
put<T>(path: string, body?: unknown): Promise<T>;
|
|
21
84
|
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
22
|
-
del<T>(path: string): Promise<T>;
|
|
85
|
+
del<T>(path: string, body?: unknown): Promise<T>;
|
|
23
86
|
private buildUrl;
|
|
87
|
+
/** True for endpoints behind `jwtAuth` — the user JWT session surface. */
|
|
88
|
+
private usesSessionAuth;
|
|
89
|
+
/** Capture the `token` / `refresh_token` cookies the login + refresh flows set via Set-Cookie. */
|
|
90
|
+
private captureSetCookie;
|
|
91
|
+
/**
|
|
92
|
+
* Exchange the refresh token for a rotated access token. Returns true on success.
|
|
93
|
+
* Concurrent callers share one in-flight refresh so a single-use refresh token is
|
|
94
|
+
* only spent once (otherwise the loser would post a consumed token and wipe the
|
|
95
|
+
* freshly-rotated session).
|
|
96
|
+
*/
|
|
97
|
+
private refreshSession;
|
|
98
|
+
private doRefresh;
|
|
24
99
|
private backoff;
|
|
25
100
|
private sleep;
|
|
26
101
|
}
|
package/dist/http.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,KAAK,UA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AAG,OAAO,CAAC,CAAC,CAAC;IAIpE,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIjD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhD,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIlD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhD,OAAO,CAAC,QAAQ;IAYhB,0EAA0E;IAC1E,OAAO,CAAC,eAAe;IAIvB,kGAAkG;IAClG,OAAO,CAAC,gBAAgB;IAexB;;;;;OAKG;IACH,OAAO,CAAC,cAAc;YASR,SAAS;IA6BvB,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,KAAK;CAGd;AAED,qBAAa,QAAS,SAAQ,KAAK;aAGf,IAAI,EAAE,MAAM;aACZ,UAAU,EAAE,MAAM;aAClB,OAAO,CAAC,EAAE,OAAO;gBAHjC,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,OAAO,YAAA;CAMpC"}
|
package/dist/http.js
CHANGED
|
@@ -1,16 +1,159 @@
|
|
|
1
|
-
|
|
1
|
+
// The version this client sends in its own `User-Agent` (`proof-mcp/<version>`), i.e. what the
|
|
2
|
+
// issuer's logs attribute a request to. A LITERAL for the same reason `factory.ts`'s `serverInfo`
|
|
3
|
+
// one is, and safe for the same reason: the pin, not the choice. Held equal to `mcp/package.json`
|
|
4
|
+
// by `src/__tests__/drift/delegation-publication.test.ts` (h-npm-registry-release).
|
|
5
|
+
//
|
|
6
|
+
// Of the carriers a version bump has to move, this is the one it misses: a bare constant at the
|
|
7
|
+
// top of a module about HTTP, where nothing about editing the manifest leads a reader.
|
|
8
|
+
const VERSION = '1.2.0';
|
|
9
|
+
/**
|
|
10
|
+
* 5xx error codes that must NOT be retried, because they are refusals rather than outages.
|
|
11
|
+
*
|
|
12
|
+
* The distinction is not academic on this client: it retries EVERY method, so a POST refusal is
|
|
13
|
+
* re-sent as a fresh act. `challenge_delivery_failed` (`POST /api/v1/auth/sessions`, email
|
|
14
|
+
* channel) is the case that forced the list — the server deletes the session whose mail it could
|
|
15
|
+
* not send, so a retry mails again and drops again.
|
|
16
|
+
*
|
|
17
|
+
* Deliberately narrow. That route answers FOUR other 5xx and none of them belongs here.
|
|
18
|
+
* `identity_check_unavailable`, `email_service_unavailable` (both 503) and
|
|
19
|
+
* `session_creation_failed` (500) each refuse BEFORE anything is stored, so a second attempt is a
|
|
20
|
+
* second chance rather than a second act. The fourth is the uncomfortable one: a generic 500
|
|
21
|
+
* `internal_error` from the controller's own `catch` can be raised AFTER `storeAuthSession`, so
|
|
22
|
+
* retrying it CAN repeat an act — and it stays retryable regardless, because `internal_error` is
|
|
23
|
+
* what the error handler answers for every unhandled throw in the whole API, so listing it would
|
|
24
|
+
* stop retrying genuine outages everywhere. Narrowing that one needs a code of its own, which is a
|
|
25
|
+
* backend change rather than a client one.
|
|
26
|
+
*
|
|
27
|
+
* SCOPE. This list is keyed on the CODE, not the path, so the second emitter of
|
|
28
|
+
* `challenge_delivery_failed` — `POST /api/v1/verifications`, via
|
|
29
|
+
* `abortUndeliverableEmailChallenge` — is covered here too. What is NOT covered is the four SDKs:
|
|
30
|
+
* their HTTP clients each retry any 5xx on any method, so the same defect stands on that surface.
|
|
31
|
+
*
|
|
32
|
+
* Held to the issuer's own spelling by `src/__tests__/drift/login-delivery-refusal.test.ts`, which
|
|
33
|
+
* extracts the code from the controller that emits it.
|
|
34
|
+
*/
|
|
35
|
+
const TERMINAL_5XX_CODES = new Set(['challenge_delivery_failed']);
|
|
36
|
+
// Path prefixes protected by `jwtAuth` ONLY (pure JWT surface — these 401 with an API key).
|
|
37
|
+
// Deliberately excludes the dual-auth (`jwtOrApiKeyAuth`) endpoints that already work with the
|
|
38
|
+
// API key and enforce its scopes — `/me/{profiles,settings,usage,export,assets}`,
|
|
39
|
+
// `/profiles/me`, `/profiles/me/assets`, `/profiles/profiles/:id/proofs`, and `/auth/sessions`
|
|
40
|
+
// (list/revoke). Sending the JWT there would silently switch the principal from the API-key
|
|
41
|
+
// tenant to the logged-in user and bypass scope checks. The two `/profiles/me/*` entries
|
|
42
|
+
// below are the jwt-only exceptions inside that otherwise dual-auth family.
|
|
43
|
+
const SESSION_AUTH_PREFIXES = [
|
|
44
|
+
'/api/v1/me/emails',
|
|
45
|
+
'/api/v1/me/phones',
|
|
46
|
+
'/api/v1/me/api-keys',
|
|
47
|
+
'/api/v1/me/2fa',
|
|
48
|
+
'/api/v1/me/domains',
|
|
49
|
+
'/api/v1/me/dns-credentials',
|
|
50
|
+
'/api/v1/me/dns-providers',
|
|
51
|
+
'/api/v1/me/verification-requests',
|
|
52
|
+
'/api/v1/me/verify/',
|
|
53
|
+
'/api/v1/me/account',
|
|
54
|
+
'/api/v1/profiles/me/username',
|
|
55
|
+
'/api/v1/profiles/me/proofs',
|
|
56
|
+
];
|
|
57
|
+
/**
|
|
58
|
+
* Routes that sit UNDER a `SESSION_AUTH_PREFIXES` prefix but are not session-only on the backend,
|
|
59
|
+
* so a keyed client without a login session may still send them with the key. Everything else on
|
|
60
|
+
* the session surface is refused before the network when no session is held
|
|
61
|
+
* (`user_session_required`): the backend's answer there would be `invalid_token`, which an agent
|
|
62
|
+
* reads as "the key is bad" rather than "sign in first".
|
|
63
|
+
*
|
|
64
|
+
* `src/__tests__/drift/api-parity.test.ts` holds this list against `docs/api-map.yaml` in both
|
|
65
|
+
* directions: every endpoint under the session prefixes whose `auth` is not `jwt` must match an
|
|
66
|
+
* entry, and every entry must match such an endpoint.
|
|
67
|
+
*/
|
|
68
|
+
export const SESSION_EXEMPT_PATHS = [
|
|
69
|
+
{ method: 'GET', pattern: /^\/api\/v1\/me\/api-keys\/[^/]+\/usage$/ },
|
|
70
|
+
{ method: 'GET', pattern: /^\/api\/v1\/me\/verification-requests$/ },
|
|
71
|
+
{ method: 'GET', pattern: /^\/api\/v1\/me\/emails\/verify\/[^/]+$/ },
|
|
72
|
+
];
|
|
73
|
+
function isSessionExempt(method, path) {
|
|
74
|
+
const verb = method.toUpperCase();
|
|
75
|
+
return SESSION_EXEMPT_PATHS.some((p) => p.method === verb && p.pattern.test(path));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Endpoints the client may call with NO credential — the public mode surface.
|
|
79
|
+
*
|
|
80
|
+
* Stored as (method, prefix) PAIRS, not bare prefixes, and the reason is load-bearing:
|
|
81
|
+
* `/api/v1/auth/sessions` is the prefix of two public routes (create a login session, poll one)
|
|
82
|
+
* AND of two `jwt+api_key` ones (`GET /auth/sessions` lists sessions, `DELETE /auth/sessions/:id`
|
|
83
|
+
* revokes one). A prefix-only list would mark those two public, so a keyless call would travel to
|
|
84
|
+
* the network and come back `invalid_token` instead of getting the structured hint here.
|
|
85
|
+
*
|
|
86
|
+
* The drift rule `validateMcpPublicPathCoverage` (scripts/validate-api-map.ts) requires every
|
|
87
|
+
* `auth: public` + `mcp: available` endpoint in docs/api-map.yaml to appear below. That rule is a
|
|
88
|
+
* LOWER BOUND, not the definition: the two poll routes are carried here but not required by it,
|
|
89
|
+
* because the map holds them `planned` (they are reached through `wait_for_login` /
|
|
90
|
+
* `wait_for_account_creation` rather than by a tool of their own). Removing them would leave both
|
|
91
|
+
* wait tools broken in public mode while every check stayed green.
|
|
92
|
+
*/
|
|
93
|
+
export const PUBLIC_PATHS = [
|
|
94
|
+
{ method: 'POST', prefix: '/api/v1/proofs/validate' },
|
|
95
|
+
{ method: 'GET', prefix: '/api/v1/proofs/revoked' },
|
|
96
|
+
{ method: 'POST', prefix: '/api/v1/auth/sessions' },
|
|
97
|
+
{ method: 'GET', prefix: '/api/v1/auth/sessions/' },
|
|
98
|
+
{ method: 'POST', prefix: '/api/v1/accounts' },
|
|
99
|
+
{ method: 'GET', prefix: '/api/v1/accounts/' },
|
|
100
|
+
];
|
|
101
|
+
/** True when (method, path) is on the public surface above. Method is compared case-insensitively. */
|
|
102
|
+
function isPublicPath(method, path) {
|
|
103
|
+
const verb = method.toUpperCase();
|
|
104
|
+
return PUBLIC_PATHS.some((p) => p.method === verb && path.startsWith(p.prefix));
|
|
105
|
+
}
|
|
2
106
|
export class HttpClient {
|
|
3
107
|
baseUrl;
|
|
4
108
|
apiKey;
|
|
5
109
|
timeout;
|
|
6
110
|
maxRetries;
|
|
111
|
+
remote;
|
|
112
|
+
sessionToken;
|
|
113
|
+
refreshToken;
|
|
114
|
+
refreshing;
|
|
7
115
|
constructor(config) {
|
|
8
116
|
this.apiKey = config.apiKey;
|
|
9
117
|
this.baseUrl = config.baseUrl.replace(/\/$/, '');
|
|
10
118
|
this.timeout = config.timeout ?? 30_000;
|
|
11
119
|
this.maxRetries = config.maxRetries ?? 2;
|
|
120
|
+
this.remote = config.remote ?? false;
|
|
12
121
|
}
|
|
13
122
|
async request(method, path, options) {
|
|
123
|
+
const sessionPath = this.usesSessionAuth(path);
|
|
124
|
+
const useSession = sessionPath && !!this.sessionToken;
|
|
125
|
+
const bearer = useSession ? this.sessionToken : this.apiKey;
|
|
126
|
+
// A key is held but this route answers only to a signed-in user. Sending the key would come
|
|
127
|
+
// back `invalid_token` — "your key is bad" — when the key is fine and a login is what's missing.
|
|
128
|
+
if (sessionPath && !this.sessionToken && this.apiKey && !isSessionExempt(method, path)) {
|
|
129
|
+
throw new ApiError('This operation needs a signed-in Proof session, and an API key cannot open it: it covers your own ' +
|
|
130
|
+
'account records (emails, phones, domains, API keys, 2FA, DNS credentials, verification requests, ' +
|
|
131
|
+
'your public profile\'s username and proof list). Call start_login, finish the sign-in it describes, ' +
|
|
132
|
+
'call wait_for_login until it reports success, then call this tool again.', 'user_session_required', 401);
|
|
133
|
+
}
|
|
134
|
+
// Public mode: answer before the network rather than after it. A credential-less call to a
|
|
135
|
+
// keyed route would otherwise spend a round trip to return `invalid_token`, which reads to an
|
|
136
|
+
// agent as "the key is wrong" rather than "there is no key yet".
|
|
137
|
+
if (!bearer && !isPublicPath(method, path)) {
|
|
138
|
+
// The wording matters as much as the code, and it has to be true for the transport the caller
|
|
139
|
+
// is actually on. It once said "run create_account to get a key from inside this session",
|
|
140
|
+
// which an agent can follow forever without succeeding on stdio: the key is read from the
|
|
141
|
+
// environment and has no runtime setter. But the fix was written for stdio alone, and on the
|
|
142
|
+
// REMOTE server the resulting instruction is not merely unhelpful — it is impossible, since
|
|
143
|
+
// nobody can set an env var on somebody else's pod or restart it. A signed-in remote user
|
|
144
|
+
// calling a tool outside the session surface is exactly who reads this.
|
|
145
|
+
throw new ApiError(this.remote
|
|
146
|
+
? 'This operation needs a Proof account with an API key. Connect this server to your account ' +
|
|
147
|
+
'(your client\'s sign-in / "Authenticate" step), then call the tool again. Signing in with ' +
|
|
148
|
+
'start_login alone covers your own contact and account records — emails, phones, domains, ' +
|
|
149
|
+
'API keys, 2FA, DNS credentials, verification requests, your public profile\'s username ' +
|
|
150
|
+
'and proof list; account-wide reads such as the platform summary, settings and usage ' +
|
|
151
|
+
'need the key that connecting grants.'
|
|
152
|
+
: 'This operation needs a Proof API key, which must be present in PROOF_API_KEY when the server starts. ' +
|
|
153
|
+
'Without one you can still create an account or sign in (create_account, start_login) and check ' +
|
|
154
|
+
'proofs and delegations. If you are signed in, create_api_key works over that session — but the new ' +
|
|
155
|
+
'key takes effect only after it is put in PROOF_API_KEY and this MCP server is restarted.', 'api_key_required', 401);
|
|
156
|
+
}
|
|
14
157
|
const url = this.buildUrl(path, options?.query);
|
|
15
158
|
let lastError;
|
|
16
159
|
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
@@ -20,14 +163,17 @@ export class HttpClient {
|
|
|
20
163
|
const response = await fetch(url, {
|
|
21
164
|
method,
|
|
22
165
|
headers: {
|
|
166
|
+
...options?.headers,
|
|
23
167
|
'Content-Type': 'application/json',
|
|
24
|
-
'Authorization': `Bearer ${
|
|
168
|
+
...(bearer ? { 'Authorization': `Bearer ${bearer}` } : {}),
|
|
25
169
|
'User-Agent': `proof-mcp/${VERSION}`,
|
|
26
170
|
},
|
|
27
171
|
body: options?.body ? JSON.stringify(options.body) : undefined,
|
|
28
172
|
signal: controller.signal,
|
|
29
173
|
});
|
|
30
174
|
clearTimeout(timeoutId);
|
|
175
|
+
// Capture the JWT session cookie set by the login / account-creation flows
|
|
176
|
+
this.captureSetCookie(response);
|
|
31
177
|
if (response.status === 429 && attempt < this.maxRetries) {
|
|
32
178
|
const retryAfter = response.headers.get('Retry-After');
|
|
33
179
|
const parsed = retryAfter ? parseInt(retryAfter, 10) : NaN;
|
|
@@ -36,14 +182,33 @@ export class HttpClient {
|
|
|
36
182
|
continue;
|
|
37
183
|
}
|
|
38
184
|
if (response.status >= 500 && attempt < this.maxRetries) {
|
|
39
|
-
|
|
40
|
-
|
|
185
|
+
// A 5xx is retried as transient — EXCEPT where the body names itself a terminal REFUSAL.
|
|
186
|
+
// This client retries every method, POST included, so a retried refusal is not a second
|
|
187
|
+
// chance at the same act: `POST /api/v1/auth/sessions` deletes the session it could not
|
|
188
|
+
// mail before answering, so each attempt composes a NEW one, and a provider that fails
|
|
189
|
+
// after accepting can leave a person holding several codes, none of which belongs to a
|
|
190
|
+
// live session. `response.clone()` keeps the body readable for the error path below.
|
|
191
|
+
const peeked = (await response.clone().json().catch(() => ({})));
|
|
192
|
+
const peekedCode = peeked.error?.code;
|
|
193
|
+
if (!peekedCode || !TERMINAL_5XX_CODES.has(peekedCode)) {
|
|
194
|
+
await this.sleep(this.backoff(attempt));
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
41
197
|
}
|
|
42
198
|
const body = (await response.json().catch(() => ({})));
|
|
43
199
|
if (!response.ok) {
|
|
44
200
|
const apiError = body.error;
|
|
45
201
|
const code = apiError?.code ?? `http_${response.status}`;
|
|
46
202
|
const message = apiError?.message ?? `Request failed with status ${response.status}`;
|
|
203
|
+
// Expired session JWT: refresh once and retry the original request.
|
|
204
|
+
if (response.status === 401 &&
|
|
205
|
+
code === 'token_expired' &&
|
|
206
|
+
useSession &&
|
|
207
|
+
!options?._refreshed &&
|
|
208
|
+
this.refreshToken &&
|
|
209
|
+
(await this.refreshSession())) {
|
|
210
|
+
return this.request(method, path, { ...options, _refreshed: true });
|
|
211
|
+
}
|
|
47
212
|
throw new ApiError(message, code, response.status, apiError?.details);
|
|
48
213
|
}
|
|
49
214
|
return body;
|
|
@@ -68,6 +233,17 @@ export class HttpClient {
|
|
|
68
233
|
}
|
|
69
234
|
throw new ApiError(lastError?.message ?? 'Network request failed', 'network_error', 0);
|
|
70
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* True once a login flow has put a session on this client (`captureSetCookie`).
|
|
238
|
+
*
|
|
239
|
+
* Boolean only, never the token: the remote server needs to know whether this CONNECTION has
|
|
240
|
+
* been signed in — the bootstrap road `start_login` opens — and nothing else. Without it a caller
|
|
241
|
+
* with no API key looks identical before and after signing in, and the tools behind
|
|
242
|
+
* `SESSION_AUTH_PREFIXES` are refused to a user who just logged in.
|
|
243
|
+
*/
|
|
244
|
+
hasSessionToken() {
|
|
245
|
+
return !!this.sessionToken;
|
|
246
|
+
}
|
|
71
247
|
get(path, query) {
|
|
72
248
|
return this.request('GET', path, { query });
|
|
73
249
|
}
|
|
@@ -80,8 +256,8 @@ export class HttpClient {
|
|
|
80
256
|
patch(path, body) {
|
|
81
257
|
return this.request('PATCH', path, { body });
|
|
82
258
|
}
|
|
83
|
-
del(path) {
|
|
84
|
-
return this.request('DELETE', path);
|
|
259
|
+
del(path, body) {
|
|
260
|
+
return this.request('DELETE', path, body ? { body } : undefined);
|
|
85
261
|
}
|
|
86
262
|
buildUrl(path, query) {
|
|
87
263
|
const url = new URL(path, this.baseUrl);
|
|
@@ -94,6 +270,75 @@ export class HttpClient {
|
|
|
94
270
|
}
|
|
95
271
|
return url.toString();
|
|
96
272
|
}
|
|
273
|
+
/** True for endpoints behind `jwtAuth` — the user JWT session surface. */
|
|
274
|
+
usesSessionAuth(path) {
|
|
275
|
+
return SESSION_AUTH_PREFIXES.some((prefix) => path.startsWith(prefix)) || path === '/api/v1/auth/me';
|
|
276
|
+
}
|
|
277
|
+
/** Capture the `token` / `refresh_token` cookies the login + refresh flows set via Set-Cookie. */
|
|
278
|
+
captureSetCookie(response) {
|
|
279
|
+
// getSetCookie() requires Node >= 18.14 / undici; guard so older runtimes don't throw.
|
|
280
|
+
if (typeof response.headers.getSetCookie !== 'function')
|
|
281
|
+
return;
|
|
282
|
+
const cookies = response.headers.getSetCookie();
|
|
283
|
+
for (const cookie of cookies) {
|
|
284
|
+
const pair = cookie.split(';', 1)[0];
|
|
285
|
+
const eq = pair.indexOf('=');
|
|
286
|
+
if (eq === -1)
|
|
287
|
+
continue;
|
|
288
|
+
const name = pair.slice(0, eq).trim();
|
|
289
|
+
const value = pair.slice(eq + 1).trim();
|
|
290
|
+
if (name === 'token')
|
|
291
|
+
this.sessionToken = value;
|
|
292
|
+
else if (name === 'refresh_token')
|
|
293
|
+
this.refreshToken = value;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Exchange the refresh token for a rotated access token. Returns true on success.
|
|
298
|
+
* Concurrent callers share one in-flight refresh so a single-use refresh token is
|
|
299
|
+
* only spent once (otherwise the loser would post a consumed token and wipe the
|
|
300
|
+
* freshly-rotated session).
|
|
301
|
+
*/
|
|
302
|
+
refreshSession() {
|
|
303
|
+
if (!this.refreshToken)
|
|
304
|
+
return Promise.resolve(false);
|
|
305
|
+
if (this.refreshing)
|
|
306
|
+
return this.refreshing;
|
|
307
|
+
this.refreshing = this.doRefresh().finally(() => {
|
|
308
|
+
this.refreshing = undefined;
|
|
309
|
+
});
|
|
310
|
+
return this.refreshing;
|
|
311
|
+
}
|
|
312
|
+
async doRefresh() {
|
|
313
|
+
const controller = new AbortController();
|
|
314
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeout);
|
|
315
|
+
try {
|
|
316
|
+
const response = await fetch(this.buildUrl('/api/v1/auth/refresh'), {
|
|
317
|
+
method: 'POST',
|
|
318
|
+
headers: {
|
|
319
|
+
'Content-Type': 'application/json',
|
|
320
|
+
'Cookie': `refresh_token=${this.refreshToken}`,
|
|
321
|
+
'User-Agent': `proof-mcp/${VERSION}`,
|
|
322
|
+
},
|
|
323
|
+
signal: controller.signal,
|
|
324
|
+
});
|
|
325
|
+
if (!response.ok) {
|
|
326
|
+
this.sessionToken = undefined;
|
|
327
|
+
this.refreshToken = undefined;
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
this.captureSetCookie(response);
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
catch {
|
|
334
|
+
this.sessionToken = undefined;
|
|
335
|
+
this.refreshToken = undefined;
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
finally {
|
|
339
|
+
clearTimeout(timeoutId);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
97
342
|
backoff(attempt) {
|
|
98
343
|
return Math.min(1000 * Math.pow(2, attempt), 10000);
|
|
99
344
|
}
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,GAAG,OAAO,CAAC;AAWxB,MAAM,OAAO,UAAU;IACL,OAAO,CAAS;IACf,MAAM,CAAS;IACf,OAAO,CAAS;IAChB,UAAU,CAAS;IAEpC,YAAY,MAAwB;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACjD,IA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