@reclaimprotocol/agent 0.1.1-dev.1 → 0.1.2
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 +1 -1
- package/lib/cdp/capture-engine.d.ts +66 -0
- package/lib/cdp/capture-engine.js +153 -0
- package/lib/cdp/capture.d.ts +9 -20
- package/lib/cdp/capture.js +14 -138
- package/lib/cdp/index.d.ts +3 -0
- package/lib/cdp/index.js +6 -0
- package/lib/cdp/launcher.js +4 -3
- package/lib/config/store.d.ts +7 -6
- package/lib/config/store.js +2 -2
- package/lib/consts.d.ts +68 -0
- package/lib/consts.js +134 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.js +1 -1
- package/lib/logger.js +2 -1
- package/lib/mcp/api/operations.gen.d.ts +100 -48
- package/lib/mcp/api/operations.gen.js +1129 -194
- package/lib/mcp/api/to-zod.d.ts +24 -0
- package/lib/mcp/api/to-zod.js +94 -0
- package/lib/mcp/api/tools.js +1 -1
- package/lib/mcp/credentials/authenticate.d.ts +3 -0
- package/lib/mcp/{tools/credentials → credentials}/authenticate.js +3 -3
- package/lib/mcp/credentials/build.d.ts +5 -0
- package/lib/mcp/credentials/build.js +18 -0
- package/lib/mcp/{tools/credentials → credentials}/cache.d.ts +9 -9
- package/lib/mcp/{tools/credentials → credentials}/cache.js +36 -19
- package/lib/mcp/credentials/import.d.ts +2 -0
- package/lib/mcp/{tools/credentials → credentials}/import.js +2 -2
- package/lib/mcp/credentials/issue.d.ts +2 -0
- package/lib/mcp/{tools/credentials → credentials}/issue.js +4 -4
- package/lib/mcp/credentials/keypair.d.ts +17 -0
- package/lib/mcp/credentials/keypair.js +48 -0
- package/lib/mcp/credentials/link.d.ts +3 -0
- package/lib/mcp/credentials/link.js +107 -0
- package/lib/mcp/{tools/credentials → credentials}/list-cached.d.ts +1 -1
- package/lib/mcp/{tools/credentials → credentials}/list-cached.js +5 -5
- package/lib/mcp/credentials/owner-key.d.ts +23 -0
- package/lib/mcp/credentials/owner-key.js +58 -0
- package/lib/mcp/credentials/paths.d.ts +12 -0
- package/lib/mcp/credentials/paths.js +35 -0
- package/lib/mcp/credentials/poll.d.ts +27 -0
- package/lib/mcp/credentials/poll.js +61 -0
- package/lib/mcp/{tools/credentials → credentials}/resolve-owner-key.d.ts +1 -1
- package/lib/mcp/{tools/credentials → credentials}/resolve-owner-key.js +2 -2
- package/lib/mcp/credentials/session-cache.d.ts +14 -0
- package/lib/mcp/credentials/session-cache.js +42 -0
- package/lib/mcp/{tools/credentials → credentials}/status.d.ts +1 -1
- package/lib/mcp/credentials/status.js +76 -0
- package/lib/mcp/instructions.d.ts +1 -0
- package/lib/mcp/instructions.js +11 -0
- package/lib/mcp/register.d.ts +38 -0
- package/lib/mcp/register.js +80 -0
- package/lib/mcp/server.d.ts +2 -8
- package/lib/mcp/server.js +3 -33
- package/lib/mcp/start.js +17 -11
- package/lib/mcp/tools/agent/build.d.ts +5 -9
- package/lib/mcp/tools/agent/build.js +7 -24
- package/lib/mcp/tools/agent/index.d.ts +2 -0
- package/lib/mcp/tools/agent/index.js +3 -0
- package/lib/mcp/tools/agent/proof.js +3 -7
- package/lib/mcp/tools/agent/propose.js +13 -2
- package/lib/mcp/tools/agent/publish.js +172 -75
- package/lib/mcp/tools/agent/replay.js +0 -5
- package/lib/mcp/tools/analyze.d.ts +3 -0
- package/lib/mcp/tools/analyze.js +26 -0
- package/lib/mcp/tools/attach.d.ts +11 -0
- package/lib/mcp/tools/attach.js +72 -0
- package/lib/mcp/tools/authenticate/authenticate.js +107 -0
- package/lib/mcp/tools/authenticate/build.d.ts +15 -0
- package/lib/mcp/tools/authenticate/build.js +28 -0
- package/lib/mcp/tools/authenticate/decrypt-key.d.ts +19 -0
- package/lib/mcp/tools/authenticate/decrypt-key.js +46 -0
- package/lib/mcp/tools/authenticate/eth-key.d.ts +31 -0
- package/lib/mcp/tools/authenticate/eth-key.js +116 -0
- package/lib/mcp/tools/authenticate/import.js +57 -0
- package/lib/mcp/tools/authenticate/index.d.ts +2 -0
- package/lib/mcp/tools/authenticate/index.js +4 -0
- package/lib/mcp/tools/authenticate/issue.js +42 -0
- package/lib/mcp/tools/authenticate/resolve-owner-key.d.ts +13 -0
- package/lib/mcp/tools/authenticate/resolve-owner-key.js +53 -0
- package/lib/mcp/tools/capture.d.ts +10 -0
- package/lib/mcp/tools/capture.js +142 -0
- package/lib/mcp/tools/eval.d.ts +5 -0
- package/lib/mcp/tools/eval.js +127 -0
- package/lib/mcp/tools/find.d.ts +3 -0
- package/lib/mcp/tools/find.js +60 -0
- package/lib/mcp/tools/index.d.ts +3 -0
- package/lib/mcp/tools/index.js +6 -0
- package/lib/mcp/tools/owner-key.d.ts +2 -0
- package/lib/mcp/tools/owner-key.js +63 -0
- package/lib/mcp/tools/proof.d.ts +3 -0
- package/lib/mcp/tools/proof.js +214 -0
- package/lib/mcp/tools/propose.d.ts +9 -0
- package/lib/mcp/tools/propose.js +75 -0
- package/lib/mcp/tools/publish.d.ts +3 -0
- package/lib/mcp/tools/publish.js +59 -0
- package/lib/mcp/tools/replay.d.ts +3 -0
- package/lib/mcp/tools/replay.js +46 -0
- package/lib/mcp/tools/session.d.ts +10 -0
- package/lib/mcp/tools/session.js +29 -0
- package/lib/mcp/tools/verification/build.d.ts +12 -0
- package/lib/mcp/tools/verification/build.js +14 -0
- package/lib/mcp/tools/verification/diagnose.d.ts +11 -0
- package/lib/mcp/tools/verification/diagnose.js +132 -0
- package/lib/mcp/tools/verification/index.d.ts +1 -0
- package/lib/mcp/tools/verification/index.js +2 -0
- package/lib/mcp/tools/verification/result.d.ts +11 -0
- package/lib/mcp/tools/verification/result.js +126 -0
- package/lib/mcp/verifications/build.d.ts +5 -0
- package/lib/mcp/verifications/build.js +14 -0
- package/lib/mcp/verifications/create.d.ts +3 -0
- package/lib/mcp/verifications/create.js +57 -0
- package/lib/mcp/verifications/find.d.ts +3 -0
- package/lib/mcp/verifications/find.js +37 -0
- package/lib/mcp/verifications/get.d.ts +3 -0
- package/lib/mcp/verifications/get.js +26 -0
- package/lib/mcp/verifications/update.d.ts +3 -0
- package/lib/mcp/verifications/update.js +78 -0
- package/lib/old/client.d.ts +3 -0
- package/lib/old/flag.d.ts +4 -1
- package/lib/old/flag.js +4 -3
- package/lib/old/identity.d.ts +0 -10
- package/lib/old/identity.js +8 -7
- package/lib/old/instructions.d.ts +0 -6
- package/lib/old/instructions.js +6 -24
- package/lib/old/login-cdp.d.ts +0 -3
- package/lib/old/login-cdp.js +2 -4
- package/lib/old/to-register.d.ts +3 -0
- package/lib/old/to-register.js +32 -7
- package/lib/old/tools/authenticate.js +2 -1
- package/lib/old/tools/publish.js +71 -10
- package/lib/paths.js +2 -2
- package/lib/proof/attestor.d.ts +33 -1
- package/lib/proof/attestor.js +67 -64
- package/lib/proof/index.d.ts +5 -0
- package/lib/proof/index.js +6 -0
- package/lib/proof/proof-core.d.ts +35 -0
- package/lib/proof/proof-core.js +84 -0
- package/lib/provider/index.d.ts +5 -0
- package/lib/provider/index.js +9 -0
- package/lib/provider/injection-doc.d.ts +1 -0
- package/lib/provider/injection-doc.js +17 -0
- package/lib/provider/match-redaction-warning.d.ts +25 -0
- package/lib/provider/match-redaction-warning.js +35 -0
- package/lib/provider/schema.d.ts +16 -0
- package/lib/provider/schema.js +11 -1
- package/lib/provider/to-version.d.ts +61 -12
- package/lib/provider/to-version.js +109 -24
- package/lib/provider/verification-checks.d.ts +12 -0
- package/lib/provider/verification-checks.js +30 -0
- package/lib/routes.gen.d.ts +271 -0
- package/lib/routes.gen.js +73 -0
- package/lib/types/openapi.gen.d.ts +3967 -0
- package/lib/types/openapi.gen.js +5 -0
- package/package.json +16 -7
- package/skill/SKILL.md +35 -14
- package/skill/builder-mode.md +13 -0
- package/skill/injection-api.md +42 -0
- package/skill/old-mode.md +15 -0
- package/src/cdp/capture-engine.ts +256 -0
- package/src/cdp/capture.ts +25 -185
- package/src/cdp/index.ts +6 -0
- package/src/cdp/launcher.ts +5 -4
- package/src/config/store.ts +7 -6
- package/src/consts.ts +164 -0
- package/src/index.ts +2 -4
- package/src/logger.ts +2 -1
- package/src/mcp/api/operations.gen.ts +1155 -194
- package/src/mcp/api/to-zod.ts +115 -0
- package/src/mcp/api/tools.ts +9 -3
- package/src/mcp/instructions.ts +15 -0
- package/src/mcp/server.ts +5 -50
- package/src/mcp/start.ts +27 -11
- package/src/mcp/tools/agent/build.ts +7 -27
- package/src/mcp/tools/agent/index.ts +4 -0
- package/src/mcp/tools/agent/proof.ts +3 -8
- package/src/mcp/tools/agent/propose.ts +13 -2
- package/src/mcp/tools/agent/publish.ts +218 -92
- package/src/mcp/tools/agent/replay.ts +0 -5
- package/src/mcp/tools/{credentials → authenticate}/authenticate.ts +9 -8
- package/src/mcp/tools/authenticate/build.ts +32 -0
- package/src/mcp/tools/authenticate/decrypt-key.ts +59 -0
- package/src/mcp/tools/authenticate/eth-key.ts +162 -0
- package/src/mcp/tools/authenticate/import.ts +73 -0
- package/src/mcp/tools/authenticate/index.ts +4 -0
- package/src/mcp/tools/authenticate/issue.ts +50 -0
- package/src/mcp/tools/authenticate/resolve-owner-key.ts +60 -0
- package/src/mcp/tools/index.ts +6 -0
- package/src/mcp/tools/verification/build.ts +16 -0
- package/src/mcp/tools/verification/index.ts +2 -0
- package/src/mcp/tools/verification/result.ts +154 -0
- package/src/old/client.ts +3 -0
- package/src/old/flag.ts +4 -3
- package/src/old/identity.ts +8 -7
- package/src/old/instructions.ts +10 -25
- package/src/old/login-cdp.ts +2 -5
- package/src/old/to-register.ts +58 -26
- package/src/old/tools/authenticate.ts +2 -1
- package/src/old/tools/publish.ts +92 -16
- package/src/paths.ts +2 -2
- package/src/proof/attestor.ts +114 -72
- package/src/proof/index.ts +21 -0
- package/src/proof/proof-core.ts +119 -0
- package/src/provider/index.ts +20 -0
- package/src/provider/injection-doc.ts +21 -0
- package/src/provider/match-redaction-warning.ts +53 -0
- package/src/provider/schema.ts +23 -0
- package/src/provider/to-version.ts +180 -33
- package/src/provider/verification-checks.ts +36 -0
- package/lib/mcp/tools/credentials/build.d.ts +0 -16
- package/lib/mcp/tools/credentials/build.js +0 -33
- package/lib/mcp/tools/credentials/status.js +0 -62
- package/src/mcp/tools/credentials/build.ts +0 -37
- package/src/mcp/tools/credentials/cache.ts +0 -161
- package/src/mcp/tools/credentials/env-file.ts +0 -101
- package/src/mcp/tools/credentials/import.ts +0 -72
- package/src/mcp/tools/credentials/issue.ts +0 -107
- package/src/mcp/tools/credentials/list-cached.ts +0 -66
- package/src/mcp/tools/credentials/register.ts +0 -49
- package/src/mcp/tools/credentials/resolve-owner-key.ts +0 -78
- package/src/mcp/tools/credentials/status.ts +0 -82
- package/src/types/openapi.ts +0 -7
- /package/lib/mcp/{tools/credentials → credentials}/env-file.d.ts +0 -0
- /package/lib/mcp/{tools/credentials → credentials}/env-file.js +0 -0
- /package/lib/mcp/{tools/credentials → credentials}/register.d.ts +0 -0
- /package/lib/mcp/{tools/credentials → credentials}/register.js +0 -0
- /package/lib/mcp/tools/{credentials → authenticate}/authenticate.d.ts +0 -0
- /package/lib/mcp/tools/{credentials → authenticate}/import.d.ts +0 -0
- /package/lib/mcp/tools/{credentials → authenticate}/issue.d.ts +0 -0
- /package/lib/mcp/tools/{credentials → authenticate}/session-cache.d.ts +0 -0
- /package/lib/mcp/tools/{credentials → authenticate}/session-cache.js +0 -0
- /package/src/mcp/tools/{credentials → authenticate}/session-cache.ts +0 -0
package/lib/old/client.d.ts
CHANGED
|
@@ -24,6 +24,9 @@ export interface RegisterProviderBody {
|
|
|
24
24
|
description?: string;
|
|
25
25
|
loginUrl: string;
|
|
26
26
|
geoLocation?: string;
|
|
27
|
+
/** Provider-level flag on the old backend (defaults false there; the
|
|
28
|
+
* translator sends `true` to match the builder default). */
|
|
29
|
+
useProxy?: boolean;
|
|
27
30
|
providerType?: 'PRIVATE' | 'PUBLIC';
|
|
28
31
|
requestData: unknown[];
|
|
29
32
|
}
|
package/lib/old/flag.d.ts
CHANGED
|
@@ -7,5 +7,8 @@
|
|
|
7
7
|
* EXPLICITLY by setting `USE_OLD_DEVTOOLS=false`. Anything else — unset,
|
|
8
8
|
* empty, `true`, `1`, a typo — keeps old mode on, so a forgotten env var
|
|
9
9
|
* can never silently route a developer at the half-built builder backend.
|
|
10
|
+
*
|
|
11
|
+
* The actual env read lives in `../consts.ts` (the single env-access module);
|
|
12
|
+
* this widely-imported path re-exports it for back-compat.
|
|
10
13
|
*/
|
|
11
|
-
export
|
|
14
|
+
export { useOldDevtools } from '../consts.ts';
|
package/lib/old/flag.js
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* EXPLICITLY by setting `USE_OLD_DEVTOOLS=false`. Anything else — unset,
|
|
8
8
|
* empty, `true`, `1`, a typo — keeps old mode on, so a forgotten env var
|
|
9
9
|
* can never silently route a developer at the half-built builder backend.
|
|
10
|
+
*
|
|
11
|
+
* The actual env read lives in `../consts.ts` (the single env-access module);
|
|
12
|
+
* this widely-imported path re-exports it for back-compat.
|
|
10
13
|
*/
|
|
11
|
-
export
|
|
12
|
-
return (process.env.USE_OLD_DEVTOOLS ?? '').trim().toLowerCase() !== 'false';
|
|
13
|
-
}
|
|
14
|
+
export { useOldDevtools } from "../consts.js";
|
package/lib/old/identity.d.ts
CHANGED
|
@@ -2,16 +2,6 @@ import type { OldIdentity } from './client.ts';
|
|
|
2
2
|
/** Normalize an eth uid input to `eth:<lowercase-address>`. Accepts a bare
|
|
3
3
|
* `0x…` address or an already-prefixed `eth:0x…`. */
|
|
4
4
|
export declare function toEthUid(addressOrUid: string): OldIdentity;
|
|
5
|
-
/**
|
|
6
|
-
* Resolve a caller identity from the environment, in priority order:
|
|
7
|
-
* 1. `RECLAIM_OLD_API_TOKEN` — a dashboard Firebase bearer token.
|
|
8
|
-
* 2. `RECLAIM_OLD_ETH_UID` — an `eth:<addr>` (or bare `0x…`) uid.
|
|
9
|
-
* 3. `RECLAIM_PRIVATE_KEY` — derive the eth uid from the local app key.
|
|
10
|
-
* Returns undefined when none is set.
|
|
11
|
-
*/
|
|
12
|
-
export declare function resolveIdentityFromEnv(): OldIdentity | undefined;
|
|
13
|
-
/** Read the identity persisted by a prior `reclaim_authenticate` call. */
|
|
14
|
-
export declare function loadPersistedIdentity(): OldIdentity | undefined;
|
|
15
5
|
/** Persist the identity so it survives an MCP-server restart. */
|
|
16
6
|
export declare function persistIdentity(identity: OldIdentity): void;
|
|
17
7
|
/**
|
package/lib/old/identity.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { deriveFromPrivateKey } from '@reclaimprotocol/client';
|
|
2
2
|
import { ConfigStore } from "../config/store.js";
|
|
3
|
+
import { oldApiToken, oldEthUid, privateKey } from "../consts.js";
|
|
3
4
|
/** Normalize an eth uid input to `eth:<lowercase-address>`. Accepts a bare
|
|
4
5
|
* `0x…` address or an already-prefixed `eth:0x…`. */
|
|
5
6
|
export function toEthUid(addressOrUid) {
|
|
@@ -14,23 +15,23 @@ export function toEthUid(addressOrUid) {
|
|
|
14
15
|
* 3. `RECLAIM_PRIVATE_KEY` — derive the eth uid from the local app key.
|
|
15
16
|
* Returns undefined when none is set.
|
|
16
17
|
*/
|
|
17
|
-
|
|
18
|
-
const token =
|
|
18
|
+
function resolveIdentityFromEnv() {
|
|
19
|
+
const token = oldApiToken()?.trim();
|
|
19
20
|
if (token) {
|
|
20
21
|
return { kind: 'bearer', token };
|
|
21
22
|
}
|
|
22
|
-
const ethUid =
|
|
23
|
+
const ethUid = oldEthUid()?.trim();
|
|
23
24
|
if (ethUid) {
|
|
24
25
|
return toEthUid(ethUid);
|
|
25
26
|
}
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
28
|
-
return toEthUid(deriveFromPrivateKey(
|
|
27
|
+
const key = privateKey()?.trim();
|
|
28
|
+
if (key) {
|
|
29
|
+
return toEthUid(deriveFromPrivateKey(key).address);
|
|
29
30
|
}
|
|
30
31
|
return undefined;
|
|
31
32
|
}
|
|
32
33
|
/** Read the identity persisted by a prior `reclaim_authenticate` call. */
|
|
33
|
-
|
|
34
|
+
function loadPersistedIdentity() {
|
|
34
35
|
return new ConfigStore().read()?.old_devtools;
|
|
35
36
|
}
|
|
36
37
|
/** Persist the identity so it survives an MCP-server restart. */
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP server instructions shown to the LLM when running in OLD-devtools mode
|
|
3
|
-
* (`USE_OLD_DEVTOOLS` unset or not `false`). Describes the REDUCED tool
|
|
4
|
-
* surface — there are no org/credential-link/review flows and no generated
|
|
5
|
-
* API tools here. Must not mention disabled tools.
|
|
6
|
-
*/
|
|
7
1
|
export declare const OLD_MODE_INSTRUCTIONS: string;
|
package/lib/old/instructions.js
CHANGED
|
@@ -2,28 +2,10 @@
|
|
|
2
2
|
* MCP server instructions shown to the LLM when running in OLD-devtools mode
|
|
3
3
|
* (`USE_OLD_DEVTOOLS` unset or not `false`). Describes the REDUCED tool
|
|
4
4
|
* surface — there are no org/credential-link/review flows and no generated
|
|
5
|
-
* API tools here.
|
|
5
|
+
* API tools here. The prose lives in `skill/old-mode.md` (published via the
|
|
6
|
+
* `files` array); the path resolves identically from `src/old` (dev) and
|
|
7
|
+
* `lib/old` (published).
|
|
6
8
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
'Provider-authoring flow:\n' +
|
|
11
|
-
'1. `reclaim_authenticate` — by default opens the dashboard in Chrome, ' +
|
|
12
|
-
'waits for you to sign in, captures the token automatically, and closes ' +
|
|
13
|
-
'the tab (or paste a `token` / pass an eth `ethAddress` to skip the ' +
|
|
14
|
-
'browser). Do this once before publishing or listing.\n' +
|
|
15
|
-
'2. `attach_chrome` → `start_capture` → drive the page (`navigate`, ' +
|
|
16
|
-
'`wait_for_page`) → inspect (`list_requests`, `get_request`, ' +
|
|
17
|
-
'`find_requests_containing`).\n' +
|
|
18
|
-
'3. `propose_provider` to draft a provider, `replay_request` to ' +
|
|
19
|
-
'pre-flight, `run_proof` to verify with the attestor. OPRF/`hash` ' +
|
|
20
|
-
'redactions are optional and supported.\n' +
|
|
21
|
-
'4. `create_provider_version_from_capture` to publish. With NO ' +
|
|
22
|
-
'`providerId` it REGISTERS A NEW provider (re-running creates a ' +
|
|
23
|
-
'duplicate); pass a ' +
|
|
24
|
-
'`providerId` from `get_me_providers` to add a new version to an existing ' +
|
|
25
|
-
'provider instead.\n' +
|
|
26
|
-
'5. `get_me_providers` lists the providers you own (the only ' +
|
|
27
|
-
'provider-listing tool available in this mode).\n\n' +
|
|
28
|
-
'Only GET/POST endpoints can be captured into providers here. There is no ' +
|
|
29
|
-
'organization, credential-linking, or public-review workflow in this mode.';
|
|
9
|
+
import { readFileSync } from 'node:fs';
|
|
10
|
+
import { fileURLToPath } from 'node:url';
|
|
11
|
+
export const OLD_MODE_INSTRUCTIONS = readFileSync(fileURLToPath(new URL('../../skill/old-mode.md', import.meta.url)), 'utf8').trim();
|
package/lib/old/login-cdp.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/** The devtools dashboard login page. Override per-call or via
|
|
2
|
-
* `RECLAIM_OLD_LOGIN_URL`. */
|
|
3
|
-
export declare const DEFAULT_LOGIN_URL = "https://dev.reclaimprotocol.org";
|
|
4
1
|
export interface CdpLoginResult {
|
|
5
2
|
token: string;
|
|
6
3
|
/** True when we launched (and then closed) a dedicated Chrome just for
|
package/lib/old/login-cdp.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { connectCdp } from "../cdp/client.js";
|
|
2
2
|
import { defaultProfileDir, launchChrome, waitForCdpReady, } from "../cdp/launcher.js";
|
|
3
3
|
import { ConfigStore } from "../config/store.js";
|
|
4
|
-
|
|
5
|
-
* `RECLAIM_OLD_LOGIN_URL`. */
|
|
6
|
-
export const DEFAULT_LOGIN_URL = 'https://dev.reclaimprotocol.org';
|
|
4
|
+
import { DEFAULT_LOGIN_URL, oldLoginUrl } from "../consts.js";
|
|
7
5
|
/**
|
|
8
6
|
* Read the Firebase ID token the dashboard persisted after login.
|
|
9
7
|
*
|
|
@@ -64,7 +62,7 @@ const EXTRACT_TOKEN_JS = `(async () => {
|
|
|
64
62
|
* disrupt it.
|
|
65
63
|
*/
|
|
66
64
|
export async function captureFirebaseTokenViaCdp(opts) {
|
|
67
|
-
const loginUrl = opts.loginUrl ||
|
|
65
|
+
const loginUrl = opts.loginUrl || oldLoginUrl() || DEFAULT_LOGIN_URL;
|
|
68
66
|
const timeoutMs = opts.timeoutMs ?? 180_000;
|
|
69
67
|
const pollMs = opts.pollMs ?? 1000;
|
|
70
68
|
const cfg = new ConfigStore().read()?.browser_agent;
|
package/lib/old/to-register.d.ts
CHANGED
|
@@ -17,7 +17,10 @@ import type { RegisterProviderBody, UpdateProviderConfigBody } from './client.ts
|
|
|
17
17
|
export interface OldProviderOpts {
|
|
18
18
|
initialUrl: string;
|
|
19
19
|
description?: string;
|
|
20
|
+
/** Defaults to `{{DYNAMIC_GEO}}` when omitted. */
|
|
20
21
|
geoLocation?: string;
|
|
22
|
+
/** Defaults to `true` when omitted. Register only (Provider-level flag). */
|
|
23
|
+
useProxy?: boolean;
|
|
21
24
|
providerType?: 'PRIVATE' | 'PUBLIC';
|
|
22
25
|
}
|
|
23
26
|
/** Body for `POST /api/providers/register` — new provider + v1.0.0. */
|
package/lib/old/to-register.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/** Default web settings, mirroring the builder openapi defaults
|
|
2
|
+
* (`ProviderWebSettings.geoLocation`, `PortalClientOptions.useProxy`). The old
|
|
3
|
+
* backend accepts both: `geoLocation` lives on the providerConfig, `useProxy`
|
|
4
|
+
* is a Provider-level flag (register only). */
|
|
5
|
+
const DEFAULT_GEO_LOCATION = '{{DYNAMIC_GEO}}';
|
|
6
|
+
const DEFAULT_USE_PROXY = true;
|
|
1
7
|
/** Build the single `requestData` entry shared by register + update. */
|
|
2
8
|
function requestDataFromProvider(provider) {
|
|
3
9
|
const method = String(provider.method).toUpperCase();
|
|
@@ -5,13 +11,31 @@ function requestDataFromProvider(provider) {
|
|
|
5
11
|
throw new Error('Old devtools supports only GET/POST requests; got ' +
|
|
6
12
|
`"${provider.method}". Re-capture against a GET/POST endpoint.`);
|
|
7
13
|
}
|
|
14
|
+
// The old backend has no dotted interpolation: consumer-supplied params
|
|
15
|
+
// must use the `{{context_<name>}}` form here, not the builder's
|
|
16
|
+
// `{{context.<name>}}`. Catch the mix-up at publish with a clear error
|
|
17
|
+
// instead of a template that silently never resolves.
|
|
18
|
+
const dotted = `${provider.url}\n${provider.body ?? ''}`
|
|
19
|
+
.match(/\{\{context\.[A-Za-z_][A-Za-z0-9_]*\}\}/);
|
|
20
|
+
if (dotted) {
|
|
21
|
+
throw new Error(`Old devtools does not support ${dotted[0]} — rename ` +
|
|
22
|
+
'consumer-supplied params to the {{context_<name>}} form ' +
|
|
23
|
+
'for this backend.');
|
|
24
|
+
}
|
|
8
25
|
const responseMatches = provider.responseMatches.map((m, i) => ({
|
|
9
26
|
value: m.value,
|
|
10
27
|
type: m.type ?? 'contains',
|
|
11
28
|
isOptional: false,
|
|
12
29
|
order: i,
|
|
13
30
|
}));
|
|
14
|
-
|
|
31
|
+
// Old devtools wants `responseMatches` and `responseRedactions` as PARALLEL
|
|
32
|
+
// arrays — same shape the builder uses, so pass them through directly. We do
|
|
33
|
+
// NOT enforce any match/redaction count relationship here (and never pad —
|
|
34
|
+
// empty placeholder matches break proof generation): the author keeps full
|
|
35
|
+
// control. The publish tool surfaces a non-blocking warning when matches <
|
|
36
|
+
// redactions (see `matchRedactionWarnings`), and the dev decides.
|
|
37
|
+
const sourceRedactions = provider.responseRedactions ?? [];
|
|
38
|
+
const responseRedactions = sourceRedactions.map((r, i) => {
|
|
15
39
|
const out = { order: i };
|
|
16
40
|
if (r.xPath !== undefined) {
|
|
17
41
|
out.xPath = r.xPath;
|
|
@@ -54,27 +78,28 @@ export function providerToRegisterBody(provider, opts) {
|
|
|
54
78
|
name: provider.name,
|
|
55
79
|
loginUrl: opts.initialUrl,
|
|
56
80
|
providerType: opts.providerType ?? 'PRIVATE',
|
|
81
|
+
// Web-settings defaults mirror the builder openapi defaults.
|
|
82
|
+
geoLocation: opts.geoLocation ?? DEFAULT_GEO_LOCATION,
|
|
83
|
+
useProxy: opts.useProxy ?? DEFAULT_USE_PROXY,
|
|
57
84
|
requestData: [requestDataFromProvider(provider)],
|
|
58
85
|
};
|
|
59
86
|
if (opts.description !== undefined) {
|
|
60
87
|
body.description = opts.description;
|
|
61
88
|
}
|
|
62
|
-
if (opts.geoLocation !== undefined) {
|
|
63
|
-
body.geoLocation = opts.geoLocation;
|
|
64
|
-
}
|
|
65
89
|
return body;
|
|
66
90
|
}
|
|
67
91
|
/** Body for `POST /api/providers/:providerId/config` — adds a new version to
|
|
68
92
|
* an EXISTING provider. `version` must not already exist; `versionInfo` is
|
|
69
93
|
* required and must be ≥10 chars (enforced by the backend). */
|
|
70
94
|
export function providerToConfigBody(provider, opts, version, versionInfo) {
|
|
95
|
+
// `useProxy` is a Provider-level flag on the old backend, not part of a
|
|
96
|
+
// version's providerConfig — so the config (new-version) path only carries
|
|
97
|
+
// `geoLocation`. It defaults the same way as register.
|
|
71
98
|
const providerConfig = {
|
|
72
99
|
loginUrl: opts.initialUrl,
|
|
100
|
+
geoLocation: opts.geoLocation ?? DEFAULT_GEO_LOCATION,
|
|
73
101
|
requestData: [requestDataFromProvider(provider)],
|
|
74
102
|
};
|
|
75
|
-
if (opts.geoLocation !== undefined) {
|
|
76
|
-
providerConfig.geoLocation = opts.geoLocation;
|
|
77
|
-
}
|
|
78
103
|
return { providerConfig, version, versionInfo };
|
|
79
104
|
}
|
|
80
105
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { agentDisabled } from "../../consts.js";
|
|
1
2
|
import { defineTool } from "../../mcp/server.js";
|
|
2
3
|
import { persistIdentity, toEthUid } from "../identity.js";
|
|
3
4
|
import { captureFirebaseTokenViaCdp } from "../login-cdp.js";
|
|
@@ -108,7 +109,7 @@ export function authenticateTool(client) {
|
|
|
108
109
|
}
|
|
109
110
|
}
|
|
110
111
|
// CDP browser login (the default headline flow).
|
|
111
|
-
if (
|
|
112
|
+
if (agentDisabled()) {
|
|
112
113
|
throw new Error('Browser login is unavailable (RECLAIM_AGENT_DISABLED=1). Pass a ' +
|
|
113
114
|
'`token` (Firebase ID token) or `ethAddress` instead.');
|
|
114
115
|
}
|
package/lib/old/tools/publish.js
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
|
+
import { Boom, isBoom } from '@hapi/boom';
|
|
1
2
|
import { defineTool } from "../../mcp/server.js";
|
|
3
|
+
import { countsFor, matchRedactionWarnings, } from "../../provider/match-redaction-warning.js";
|
|
2
4
|
import { bumpPatchString, extractVersions, providerToConfigBody, providerToRegisterBody, } from "../to-register.js";
|
|
3
5
|
const DEFAULT_VERSION_INFO = 'Updated from MCP browser capture';
|
|
6
|
+
/**
|
|
7
|
+
* The old backend lets you add a version only to a provider YOU own. A
|
|
8
|
+
* `providerId` for a public provider (or anyone else's) comes back as
|
|
9
|
+
* 401/403/404 — the dev's likely intent is to publish their OWN version of that
|
|
10
|
+
* site, which on this backend means registering a separate copy. Rethrow those
|
|
11
|
+
* failures with that actionable suggestion; leave other errors (e.g. a 400
|
|
12
|
+
* version collision) untouched so their real detail surfaces.
|
|
13
|
+
*/
|
|
14
|
+
function rethrowOwnershipError(err, providerId) {
|
|
15
|
+
const status = isBoom(err) ? err.output.statusCode : undefined;
|
|
16
|
+
if (status !== 401 && status !== 403 && status !== 404) {
|
|
17
|
+
throw err;
|
|
18
|
+
}
|
|
19
|
+
const base = isBoom(err) ? err.message : String(err);
|
|
20
|
+
throw new Boom(`${base} — could not add a version to provider ${providerId}. You can ` +
|
|
21
|
+
'only publish new versions on providers you own. If this is a public ' +
|
|
22
|
+
"provider (or one you don't own), re-run " +
|
|
23
|
+
'create_provider_version_from_capture WITHOUT `providerId` to register ' +
|
|
24
|
+
"your own copy. If it IS yours, confirm you're authenticated " +
|
|
25
|
+
'(reclaim_authenticate) as the account that created it.', {
|
|
26
|
+
statusCode: status,
|
|
27
|
+
data: isBoom(err) ? err.data : { status, detail: base },
|
|
28
|
+
});
|
|
29
|
+
}
|
|
4
30
|
/**
|
|
5
31
|
* Publish a drafted provider to the OLD devtools backend. Keeps the builder
|
|
6
32
|
* tool NAME (`create_provider_version_from_capture`) so the skill flow is
|
|
@@ -25,6 +51,10 @@ export function createVersionFromCaptureTool(client) {
|
|
|
25
51
|
'1.0.0; re-running creates a duplicate). Pass `providerId` (from ' +
|
|
26
52
|
'get_me_providers) to add a NEW VERSION to that existing provider ' +
|
|
27
53
|
'(the patch is auto-bumped). \n\n' +
|
|
54
|
+
'You can only add versions to a provider YOU own — the `providerId` ' +
|
|
55
|
+
'must come from get_me_providers. To publish your own version of a ' +
|
|
56
|
+
"PUBLIC provider you don't own, omit `providerId` to register your " +
|
|
57
|
+
'own copy (you cannot edit someone else\'s provider here). \n\n' +
|
|
28
58
|
'Captured requests must be GET/POST. OPRF redactions are supported.',
|
|
29
59
|
inputSchema: {
|
|
30
60
|
type: 'object',
|
|
@@ -58,7 +88,16 @@ export function createVersionFromCaptureTool(client) {
|
|
|
58
88
|
type: 'string',
|
|
59
89
|
description: 'Provider description (new-provider register only).',
|
|
60
90
|
},
|
|
61
|
-
geoLocation: {
|
|
91
|
+
geoLocation: {
|
|
92
|
+
type: 'string',
|
|
93
|
+
description: 'Geo the verification appears to originate from. Defaults to ' +
|
|
94
|
+
"'{{DYNAMIC_GEO}}' (the user's geo) when omitted.",
|
|
95
|
+
},
|
|
96
|
+
useProxy: {
|
|
97
|
+
type: 'boolean',
|
|
98
|
+
description: 'Route portal/attestation traffic through a proxy. Defaults to ' +
|
|
99
|
+
'true when omitted. Applied on register only.',
|
|
100
|
+
},
|
|
62
101
|
providerType: { type: 'string', enum: ['PRIVATE', 'PUBLIC'] },
|
|
63
102
|
notes: {
|
|
64
103
|
type: 'string',
|
|
@@ -76,22 +115,44 @@ export function createVersionFromCaptureTool(client) {
|
|
|
76
115
|
if (args.geoLocation !== undefined) {
|
|
77
116
|
opts.geoLocation = args.geoLocation;
|
|
78
117
|
}
|
|
118
|
+
if (args.useProxy !== undefined) {
|
|
119
|
+
opts.useProxy = args.useProxy;
|
|
120
|
+
}
|
|
79
121
|
if (args.providerType !== undefined) {
|
|
80
122
|
opts.providerType = args.providerType;
|
|
81
123
|
}
|
|
124
|
+
// Non-blocking advisory — never alters or blocks the publish; the
|
|
125
|
+
// author keeps full control. Attaches under `_notes` when relevant.
|
|
126
|
+
const notes = matchRedactionWarnings([
|
|
127
|
+
countsFor('Request', args.provider),
|
|
128
|
+
]);
|
|
129
|
+
const withNotes = (result) => {
|
|
130
|
+
if (notes.length && result && typeof result === 'object') {
|
|
131
|
+
return { ...result, _notes: notes };
|
|
132
|
+
}
|
|
133
|
+
return result;
|
|
134
|
+
};
|
|
82
135
|
// New provider.
|
|
83
136
|
if (!args.providerId) {
|
|
84
137
|
const body = providerToRegisterBody(args.provider, opts);
|
|
85
|
-
return client.registerProvider(body);
|
|
138
|
+
return withNotes(await client.registerProvider(body));
|
|
86
139
|
}
|
|
87
140
|
// New version of an existing provider — pick the next patch above
|
|
88
|
-
// the highest existing version.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
141
|
+
// the highest existing version. A provider you don't own (e.g. a
|
|
142
|
+
// public one) fails here with 401/403/404; surface the register-a-copy
|
|
143
|
+
// workaround instead of a bare permission error.
|
|
144
|
+
const providerId = args.providerId;
|
|
145
|
+
try {
|
|
146
|
+
const versionsResp = await client.listVersions(providerId);
|
|
147
|
+
const version = bumpPatchString(extractVersions(versionsResp));
|
|
148
|
+
const versionInfo = args.notes && args.notes.trim().length >= 10
|
|
149
|
+
? args.notes.trim()
|
|
150
|
+
: DEFAULT_VERSION_INFO;
|
|
151
|
+
const body = providerToConfigBody(args.provider, opts, version, versionInfo);
|
|
152
|
+
return withNotes(await client.updateProviderConfig(providerId, body));
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
rethrowOwnershipError(err, providerId);
|
|
156
|
+
}
|
|
96
157
|
});
|
|
97
158
|
}
|
package/lib/paths.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs';
|
|
2
|
-
import { homedir } from 'node:os';
|
|
3
2
|
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
import { reclaimHome } from "./consts.js";
|
|
4
4
|
/**
|
|
5
5
|
* Resolve the Reclaim cache directory (`~/.reclaim`). Honours the
|
|
6
6
|
* `RECLAIM_HOME` env var as an override so tests can sandbox writes.
|
|
7
7
|
*/
|
|
8
8
|
export function reclaimHomeDirPath() {
|
|
9
|
-
return
|
|
9
|
+
return reclaimHome();
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Walk up from `start` until we find a directory containing one of
|
package/lib/proof/attestor.d.ts
CHANGED
|
@@ -4,6 +4,35 @@ export interface AttestorLogEntry {
|
|
|
4
4
|
msg: string;
|
|
5
5
|
ctx?: Record<string, unknown>;
|
|
6
6
|
}
|
|
7
|
+
/** The attestor's signed claim data + signature, for building the nested proof
|
|
8
|
+
* JWS a Consumer verifies against the attestor's key. Populated when
|
|
9
|
+
* `includeAttestorClaim` is set (the app's verification runner needs it; the
|
|
10
|
+
* MCP `run_proof` tool ignores it). */
|
|
11
|
+
export interface AttestorClaim {
|
|
12
|
+
/** ProviderClaimData: provider, parameters, context (JSON string), owner,
|
|
13
|
+
* timestampS, epoch, identifier. */
|
|
14
|
+
claim: Record<string, unknown>;
|
|
15
|
+
/** Hex (0x) attestor ETH address that signed the claim (the nested `kid`). */
|
|
16
|
+
attestorAddress: string;
|
|
17
|
+
/** Hex (0x) attestor claim signature (EIP-191 over the claim sign-data). */
|
|
18
|
+
claimSignature: string;
|
|
19
|
+
}
|
|
20
|
+
/** Options for {@link runAttestorProof}. */
|
|
21
|
+
export interface RunAttestorProofOptions {
|
|
22
|
+
attestorUrl?: string;
|
|
23
|
+
/** When resolving the key from env/.env/file, the address the caller expects
|
|
24
|
+
* to sign with (sanity check). Ignored when `ownerPrivateKey` is given. */
|
|
25
|
+
ownerAddress?: string;
|
|
26
|
+
/** Sign with this key directly (e.g. the app/VC's ephemeral per-session key)
|
|
27
|
+
* instead of resolving from env/.env/file. */
|
|
28
|
+
ownerPrivateKey?: string;
|
|
29
|
+
/** ZK engine for `createClaimOnAttestor`. Defaults to `'gnark'`; the app's
|
|
30
|
+
* server-side verification runner uses `'snarkjs'`. */
|
|
31
|
+
zkEngine?: 'gnark' | 'snarkjs';
|
|
32
|
+
/** Extract the structured {@link AttestorClaim} (claim + attestor signature)
|
|
33
|
+
* onto the result for nested-proof construction. */
|
|
34
|
+
includeAttestorClaim?: boolean;
|
|
35
|
+
}
|
|
7
36
|
export interface ProofResult {
|
|
8
37
|
proof: unknown;
|
|
9
38
|
extractedValue: string;
|
|
@@ -12,6 +41,9 @@ export interface ProofResult {
|
|
|
12
41
|
owner?: string;
|
|
13
42
|
verified: boolean;
|
|
14
43
|
error?: string;
|
|
44
|
+
/** Structured claim + signature for nested-proof verification. Set only when
|
|
45
|
+
* `includeAttestorClaim` was requested and the claim carries signatures. */
|
|
46
|
+
attestorClaim?: AttestorClaim;
|
|
15
47
|
/** Set to `'missing-owner-key'` when no credential was available to
|
|
16
48
|
* sign with — distinguishes this recoverable case from other proof
|
|
17
49
|
* errors so the skill can point the dev at `issue_credentials` /
|
|
@@ -36,4 +68,4 @@ export declare function tailLogs(entries: AttestorLogEntry[], n?: number): Attes
|
|
|
36
68
|
/** Filter to just warn/error/fatal — for the LLM-visible response on
|
|
37
69
|
* successful proofs, where chatty trace/info would just waste context. */
|
|
38
70
|
export declare function warnsAndErrors(entries: AttestorLogEntry[]): AttestorLogEntry[];
|
|
39
|
-
export declare function runAttestorProof(provider: ReclaimProvider, secrets: Record<string, string>,
|
|
71
|
+
export declare function runAttestorProof(provider: ReclaimProvider, secrets: Record<string, string>, opts?: RunAttestorProofOptions): Promise<ProofResult>;
|
package/lib/proof/attestor.js
CHANGED
|
@@ -5,8 +5,11 @@
|
|
|
5
5
|
// responseMatches are the regex/contains checks the attestor runs on the
|
|
6
6
|
// revealed slice; jsonPath/xPath live on responseRedactions (what the prover
|
|
7
7
|
// reveals), never on responseMatches.
|
|
8
|
+
import { bytesToHex } from '@noble/hashes/utils.js';
|
|
8
9
|
import { createClaimOnAttestor, } from '@reclaimprotocol/attestor-core';
|
|
9
|
-
import {
|
|
10
|
+
import { agentTraceEnabled } from "../consts.js";
|
|
11
|
+
import { resolveEthKey } from "../mcp/tools/authenticate/eth-key.js";
|
|
12
|
+
import { buildHttpParams, ensureAttestorCrypto, parseClaim, resolveAttestorUrl, } from "./proof-core.js";
|
|
10
13
|
import { ensureZkFiles } from "./zk-files.js";
|
|
11
14
|
/** Trim a captured log stream to the last N entries — for shrinking the
|
|
12
15
|
* LLM-visible response while the full stream stays in the on-disk dump. */
|
|
@@ -80,56 +83,61 @@ function makeCaptureLogger() {
|
|
|
80
83
|
};
|
|
81
84
|
return { logger: make({}), entries };
|
|
82
85
|
}
|
|
83
|
-
/** Default public attestor websocket URL. Resolved per-call so an env-var
|
|
84
|
-
* change or per-request override takes effect without restarting the
|
|
85
|
-
* MCP server. */
|
|
86
|
-
const FALLBACK_ATTESTOR_URL = 'wss://attestor.reclaimprotocol.org:444/ws';
|
|
87
|
-
function resolveAttestorUrl(override) {
|
|
88
|
-
return (override ?? process.env['RECLAIM_ATTESTOR_URL'] ?? FALLBACK_ATTESTOR_URL);
|
|
89
|
-
}
|
|
90
86
|
// ---------------------------------------------------------------------------
|
|
91
87
|
// Main entry point
|
|
92
88
|
// ---------------------------------------------------------------------------
|
|
93
|
-
export async function runAttestorProof(provider, secrets,
|
|
94
|
-
//
|
|
95
|
-
//
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
89
|
+
export async function runAttestorProof(provider, secrets, opts = {}) {
|
|
90
|
+
// Sign with the caller-supplied key (the app/VC's ephemeral per-session
|
|
91
|
+
// key) when given; otherwise resolve env/.env/file. `ownerAddress` is a
|
|
92
|
+
// sanity check on the resolved key (ignored when a key is supplied).
|
|
93
|
+
let ownerPrivateKey;
|
|
94
|
+
if (opts.ownerPrivateKey) {
|
|
95
|
+
ownerPrivateKey = opts.ownerPrivateKey;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
const resolved = resolveEthKey();
|
|
99
|
+
if (!resolved) {
|
|
100
|
+
return {
|
|
101
|
+
proof: undefined,
|
|
102
|
+
extractedValue: '',
|
|
103
|
+
extractedParameters: {},
|
|
104
|
+
verified: false,
|
|
105
|
+
error: 'No eth proof-owner key available (no RECLAIM_PRIVATE_KEY in env, ' +
|
|
106
|
+
'.env, or RECLAIM_PRIVATE_KEY_FILE). Call resolve_owner_key, then ' +
|
|
107
|
+
'issue_credentials (generate) or import_credentials (provide one), ' +
|
|
108
|
+
'and retry run_proof.',
|
|
109
|
+
errorKind: 'missing-owner-key',
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
if (opts.ownerAddress
|
|
113
|
+
&& opts.ownerAddress.toLowerCase() !== resolved.address) {
|
|
114
|
+
return {
|
|
115
|
+
proof: undefined,
|
|
116
|
+
extractedValue: '',
|
|
117
|
+
extractedParameters: {},
|
|
118
|
+
verified: false,
|
|
119
|
+
error: `Requested ownerAddress "${opts.ownerAddress}" does not match ` +
|
|
120
|
+
`the resolved eth key (${resolved.address}, source: ` +
|
|
121
|
+
`${resolved.source}). ` +
|
|
122
|
+
'Call resolve_owner_key to get the current address, or update the ' +
|
|
123
|
+
'configured key.',
|
|
124
|
+
errorKind: 'missing-owner-key',
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
ownerPrivateKey = resolved.privateKey;
|
|
111
128
|
}
|
|
112
129
|
try {
|
|
113
|
-
//
|
|
114
|
-
//
|
|
130
|
+
// Init the TLS crypto backend (idempotent), then fetch ZK circuits
|
|
131
|
+
// lazily on the first proof (not at install time).
|
|
132
|
+
ensureAttestorCrypto();
|
|
115
133
|
await ensureZkFiles();
|
|
116
|
-
const params =
|
|
117
|
-
url: provider.url,
|
|
118
|
-
method: provider.method,
|
|
119
|
-
...(provider.headers !== undefined && { headers: provider.headers }),
|
|
120
|
-
...(provider.body !== undefined && { body: provider.body }),
|
|
121
|
-
responseMatches: provider.responseMatches,
|
|
122
|
-
responseRedactions: provider.responseRedactions ?? [],
|
|
123
|
-
...(provider.paramValues !== undefined && {
|
|
124
|
-
paramValues: provider.paramValues,
|
|
125
|
-
}),
|
|
126
|
-
};
|
|
134
|
+
const params = buildHttpParams(provider);
|
|
127
135
|
// Diagnostic logger capture is gated behind RECLAIM_AGENT_TRACE so the
|
|
128
136
|
// happy path doesn't pay the cost (the attestor SDK emits a *lot* of
|
|
129
137
|
// trace/debug entries during ZK setup). Flip RECLAIM_AGENT_TRACE=1 to
|
|
130
138
|
// turn it back on when something's broken; logs flow into the proof
|
|
131
139
|
// response and into the on-disk proof-runs dump.
|
|
132
|
-
const traceEnabled =
|
|
140
|
+
const traceEnabled = agentTraceEnabled();
|
|
133
141
|
const capture = traceEnabled ? makeCaptureLogger() : undefined;
|
|
134
142
|
const attestorLogs = capture?.entries;
|
|
135
143
|
let claim;
|
|
@@ -141,8 +149,8 @@ export async function runAttestorProof(provider, secrets, attestorUrl, ownerAddr
|
|
|
141
149
|
headers: secrets,
|
|
142
150
|
},
|
|
143
151
|
ownerPrivateKey,
|
|
144
|
-
client: { url: resolveAttestorUrl(attestorUrl) },
|
|
145
|
-
zkEngine: '
|
|
152
|
+
client: { url: resolveAttestorUrl(opts.attestorUrl) },
|
|
153
|
+
zkEngine: opts.zkEngine ?? 'gnark',
|
|
146
154
|
...(capture !== undefined && { logger: capture.logger }),
|
|
147
155
|
});
|
|
148
156
|
}
|
|
@@ -160,38 +168,33 @@ export async function runAttestorProof(provider, secrets, attestorUrl, ownerAddr
|
|
|
160
168
|
}
|
|
161
169
|
return errorResult;
|
|
162
170
|
}
|
|
163
|
-
|
|
164
|
-
const claimRecord = claim;
|
|
165
|
-
const claimData = claimRecord['claim'];
|
|
166
|
-
// claimData.context is a JSON-encoded string carrying
|
|
167
|
-
// { extractedParameters: {...}, providerHash, ... }.
|
|
168
|
-
let context = {};
|
|
169
|
-
const rawContext = claimData?.['context'];
|
|
170
|
-
if (typeof rawContext === 'string') {
|
|
171
|
-
try {
|
|
172
|
-
context = JSON.parse(rawContext);
|
|
173
|
-
}
|
|
174
|
-
catch {
|
|
175
|
-
// Leave context empty if it isn't valid JSON.
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
const extractedParameters = context['extractedParameters'] ??
|
|
179
|
-
{};
|
|
180
|
-
const extractedValue = Object.values(extractedParameters)[0] ?? '';
|
|
171
|
+
const { extractedValue, extractedParameters, identifier, owner, claimData } = parseClaim(claim);
|
|
181
172
|
const result = {
|
|
182
173
|
proof: claim,
|
|
183
174
|
extractedValue,
|
|
184
175
|
extractedParameters,
|
|
185
176
|
verified: true,
|
|
186
177
|
};
|
|
187
|
-
|
|
188
|
-
if (typeof identifier === 'string') {
|
|
178
|
+
if (identifier !== undefined) {
|
|
189
179
|
result.identifier = identifier;
|
|
190
180
|
}
|
|
191
|
-
|
|
192
|
-
if (typeof owner === 'string') {
|
|
181
|
+
if (owner !== undefined) {
|
|
193
182
|
result.owner = owner;
|
|
194
183
|
}
|
|
184
|
+
// Structured claim + signature so the result JWS can carry a nested,
|
|
185
|
+
// attestor-signed proof the Consumer verifies independently.
|
|
186
|
+
if (opts.includeAttestorClaim) {
|
|
187
|
+
const sigs = claim.signatures;
|
|
188
|
+
if (claimData
|
|
189
|
+
&& typeof sigs?.attestorAddress === 'string'
|
|
190
|
+
&& sigs.claimSignature instanceof Uint8Array) {
|
|
191
|
+
result.attestorClaim = {
|
|
192
|
+
claim: claimData,
|
|
193
|
+
attestorAddress: sigs.attestorAddress,
|
|
194
|
+
claimSignature: '0x' + bytesToHex(sigs.claimSignature),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
}
|
|
195
198
|
// Only set when RECLAIM_AGENT_TRACE=1. Full stream — the MCP layer
|
|
196
199
|
// trims for the LLM-visible response; the on-disk dump gets it all.
|
|
197
200
|
if (attestorLogs !== undefined && attestorLogs.length > 0) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { AttestorClaim, AttestorLogEntry, ProofResult, RunAttestorProofOptions, } from './attestor.ts';
|
|
2
|
+
export { runAttestorProof, tailLogs, warnsAndErrors } from './attestor.ts';
|
|
3
|
+
export { buildHttpParams, ensureAttestorCrypto, type ParsedClaim, parseClaim, resolveAttestorUrl, } from './proof-core.ts';
|
|
4
|
+
export { ensureZkFiles } from './zk-files.ts';
|
|
5
|
+
export { createClaimOnAttestor } from '@reclaimprotocol/attestor-core';
|