dero-mcp-server 0.2.2 → 0.4.1
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/POSITIONING.md +94 -0
- package/README.md +125 -24
- package/SKILL.md +264 -0
- package/data/docs-index.json +264 -260
- package/dist/bn254.d.ts +74 -0
- package/dist/bn254.d.ts.map +1 -0
- package/dist/bn254.js +205 -0
- package/dist/bn254.js.map +1 -0
- package/dist/citations.d.ts +70 -0
- package/dist/citations.d.ts.map +1 -1
- package/dist/citations.js +161 -1
- package/dist/citations.js.map +1 -1
- package/dist/composites/_shared.d.ts +1 -1
- package/dist/composites/_shared.js +1 -1
- package/dist/composites/audit-chain-artifact-claim.d.ts +128 -0
- package/dist/composites/audit-chain-artifact-claim.d.ts.map +1 -0
- package/dist/composites/audit-chain-artifact-claim.js +305 -0
- package/dist/composites/audit-chain-artifact-claim.js.map +1 -0
- package/dist/composites/diagnose-chain-health.d.ts +1 -1
- package/dist/composites/diagnose-chain-health.js +1 -1
- package/dist/composites/estimate-deploy-cost.d.ts +1 -1
- package/dist/composites/estimate-deploy-cost.js +1 -1
- package/dist/composites/explain-smart-contract.d.ts +1 -1
- package/dist/composites/explain-smart-contract.js +1 -1
- package/dist/composites/forge-demo-proof.d.ts +81 -0
- package/dist/composites/forge-demo-proof.d.ts.map +1 -0
- package/dist/composites/forge-demo-proof.js +204 -0
- package/dist/composites/forge-demo-proof.js.map +1 -0
- package/dist/composites/recommend-docs-path.d.ts +1 -1
- package/dist/composites/recommend-docs-path.js +1 -1
- package/dist/composites/trace-transaction-with-context.d.ts +1 -1
- package/dist/composites/trace-transaction-with-context.js +1 -1
- package/dist/daemon-base.d.ts +28 -0
- package/dist/daemon-base.d.ts.map +1 -0
- package/dist/daemon-base.js +62 -0
- package/dist/daemon-base.js.map +1 -0
- package/dist/dero-curve.d.ts +79 -0
- package/dist/dero-curve.d.ts.map +1 -0
- package/dist/dero-curve.js +79 -0
- package/dist/dero-curve.js.map +1 -0
- package/dist/docs-parse.d.ts.map +1 -1
- package/dist/docs-parse.js +18 -2
- package/dist/docs-parse.js.map +1 -1
- package/dist/http-server.d.ts +37 -0
- package/dist/http-server.d.ts.map +1 -0
- package/dist/http-server.js +139 -0
- package/dist/http-server.js.map +1 -0
- package/dist/index.js +18 -11
- package/dist/index.js.map +1 -1
- package/dist/proof-decode.d.ts +125 -0
- package/dist/proof-decode.d.ts.map +1 -0
- package/dist/proof-decode.js +619 -0
- package/dist/proof-decode.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +89 -11
- package/dist/server.js.map +1 -1
- package/dist/tool-descriptions.d.ts +3 -0
- package/dist/tool-descriptions.d.ts.map +1 -1
- package/dist/tool-descriptions.js +39 -0
- package/dist/tool-descriptions.js.map +1 -1
- package/dist/tx-parse.d.ts +63 -0
- package/dist/tx-parse.d.ts.map +1 -0
- package/dist/tx-parse.js +183 -0
- package/dist/tx-parse.js.map +1 -0
- package/package.json +24 -3
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `dero_forge_demo_proof` — composite #7.
|
|
3
|
+
*
|
|
4
|
+
* Builds a `deroproof…` display object for a chosen transaction, ring slot,
|
|
5
|
+
* and amount. The string is constructed locally from public chain data — no
|
|
6
|
+
* wallet, no keys, no broadcast. On an unpatched explorer it shows
|
|
7
|
+
* **Verified ✓** for the chosen amount; on the chain, nothing changes.
|
|
8
|
+
*
|
|
9
|
+
* Purpose: defensive demonstration of the integrity-page Part 3 forge math
|
|
10
|
+
* (`docs/integrity/inflation-claim`, Part 3). When an AI agent is asked
|
|
11
|
+
* "does this deroproof string prove the chain minted coins?", the agent can
|
|
12
|
+
* forge an equivalent string here and show, on real chain inputs, that
|
|
13
|
+
* **Verified** is a display-layer fact about the pasted object — not a
|
|
14
|
+
* consensus statement about coins moving.
|
|
15
|
+
*
|
|
16
|
+
* Math (same equation `proof.Prove()` checks at `proof/proof.go:88-95`):
|
|
17
|
+
*
|
|
18
|
+
* blinder = C[slot] − amount × G
|
|
19
|
+
* forged_string = bech32("deroproof", version || blinder_compressed || CBOR({HH: 0…0, VU: amount}))
|
|
20
|
+
*
|
|
21
|
+
* Self-check: amount × G + blinder == C[slot]. If this fails, the encoded
|
|
22
|
+
* string would not verify and we never return it.
|
|
23
|
+
*
|
|
24
|
+
* Read-only invariant: this tool computes a string and returns it. It does
|
|
25
|
+
* NOT touch a wallet, broadcast a transaction, or mutate any chain state.
|
|
26
|
+
* Annotation `readOnlyHint: true` is preserved.
|
|
27
|
+
*/
|
|
28
|
+
import { z } from 'zod';
|
|
29
|
+
import { G, add, deroCompressHex, negate, pointsEqual, scalarMult, uint64ToSignedScalar, } from '../bn254.js';
|
|
30
|
+
import { enrichWithFlaggedArtifacts, relatedDocsFor, } from '../citations.js';
|
|
31
|
+
import { encodeForgeProofString } from '../proof-decode.js';
|
|
32
|
+
import { getRingCommitment, parseTransaction } from '../tx-parse.js';
|
|
33
|
+
import { runChain, stepLatencies, stepValue, } from './_shared.js';
|
|
34
|
+
const ATOMIC = 100000n;
|
|
35
|
+
const UINT64_MOD = 1n << 64n;
|
|
36
|
+
export const forgeDemoProofInputSchema = {
|
|
37
|
+
tx_hash: z
|
|
38
|
+
.string()
|
|
39
|
+
.regex(/^[0-9a-fA-F]{64}$/, 'tx_hash must be 64 hex characters')
|
|
40
|
+
.optional()
|
|
41
|
+
.describe('TX hash to forge against. Daemon fetches the TX hex + ring members. Mutually exclusive with tx_hex.'),
|
|
42
|
+
tx_hex: z
|
|
43
|
+
.string()
|
|
44
|
+
.min(2)
|
|
45
|
+
.optional()
|
|
46
|
+
.describe('Raw TX bytes as hex (skip the daemon round-trip). Mutually exclusive with tx_hash. When provided, ring_receiver_address is omitted from the response (the hex carries publickey pointers, not full addresses).'),
|
|
47
|
+
ring_slot: z
|
|
48
|
+
.number()
|
|
49
|
+
.int()
|
|
50
|
+
.nonnegative()
|
|
51
|
+
.default(0)
|
|
52
|
+
.describe('Which ring slot 0..ring_size-1 the forged proof should resolve to. Defaults to 0.'),
|
|
53
|
+
amount_dero: z
|
|
54
|
+
.string()
|
|
55
|
+
.regex(/^-?\d+(\.\d{1,5})?$/, 'amount_dero must be a signed decimal with at most 5 fractional digits (e.g. "-1", "1000000", "-2200000.00181")')
|
|
56
|
+
.default('-1')
|
|
57
|
+
.describe('Target display amount in signed DERO (5 fractional digits = atomic precision). Negative values demonstrate the uint64 wraparound. Default "-1".'),
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Parse a signed-decimal DERO string (e.g. "-2200000.00181") into:
|
|
61
|
+
* - signed atoms (bigint, may be negative)
|
|
62
|
+
* - uint64 (atoms mod 2^64)
|
|
63
|
+
*/
|
|
64
|
+
function parseAmount(amountDero) {
|
|
65
|
+
const negative = amountDero.startsWith('-');
|
|
66
|
+
const unsigned = negative ? amountDero.slice(1) : amountDero;
|
|
67
|
+
const dot = unsigned.indexOf('.');
|
|
68
|
+
const wholeStr = dot === -1 ? unsigned : unsigned.slice(0, dot);
|
|
69
|
+
const fracStr = dot === -1 ? '' : unsigned.slice(dot + 1);
|
|
70
|
+
const fracPadded = (fracStr + '00000').slice(0, 5);
|
|
71
|
+
const whole = BigInt(wholeStr.length === 0 ? '0' : wholeStr);
|
|
72
|
+
const frac = BigInt(fracPadded);
|
|
73
|
+
const absAtoms = whole * ATOMIC + frac;
|
|
74
|
+
const signedAtoms = negative ? -absAtoms : absAtoms;
|
|
75
|
+
const uint64 = ((signedAtoms % UINT64_MOD) + UINT64_MOD) % UINT64_MOD;
|
|
76
|
+
// Normalize the input echo so callers see the canonical form (5 fractional digits).
|
|
77
|
+
const normalized = `${negative && absAtoms > 0n ? '-' : ''}${whole.toString()}.${fracPadded}`;
|
|
78
|
+
return { signedAtoms, uint64, signedDeroNormalized: normalized };
|
|
79
|
+
}
|
|
80
|
+
/** Format a uint64 as the unpatched-explorer display amount (whole.fractional with 5 digits). */
|
|
81
|
+
function formatExplorerDisplay(uint64) {
|
|
82
|
+
const whole = uint64 / ATOMIC;
|
|
83
|
+
const frac = uint64 % ATOMIC;
|
|
84
|
+
// Group thousands in the whole-part for readability.
|
|
85
|
+
const wholeStr = whole.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
86
|
+
return `${wholeStr}.${frac.toString().padStart(5, '0')} DERO`;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Execute the forge. Composes:
|
|
90
|
+
* 1. (optional) daemon fetch of TX hex + ring members
|
|
91
|
+
* 2. parse TX → extract C[ring_slot]
|
|
92
|
+
* 3. compute blinder = C[slot] − amount × G
|
|
93
|
+
* 4. self-check: amount × G + blinder == C[slot]
|
|
94
|
+
* 5. encode forged proof string + assemble narrative + citations
|
|
95
|
+
*/
|
|
96
|
+
export async function forgeDemoProof(rpc, input) {
|
|
97
|
+
if (input.tx_hash && input.tx_hex) {
|
|
98
|
+
throw new Error('INVALID_INPUT: provide exactly one of tx_hash or tx_hex (not both)');
|
|
99
|
+
}
|
|
100
|
+
if (!input.tx_hash && !input.tx_hex) {
|
|
101
|
+
throw new Error('INVALID_INPUT: provide either tx_hash or tx_hex');
|
|
102
|
+
}
|
|
103
|
+
const ringSlot = input.ring_slot ?? 0;
|
|
104
|
+
const amountDero = input.amount_dero ?? '-1';
|
|
105
|
+
// ─── 1. Fetch TX (optional daemon round-trip) ─────────────────────────────
|
|
106
|
+
let txHex;
|
|
107
|
+
let receiverAddress = null;
|
|
108
|
+
const txSource = input.tx_hash ? 'tx_hash' : 'tx_hex';
|
|
109
|
+
const steps = [];
|
|
110
|
+
if (input.tx_hash) {
|
|
111
|
+
const hash = input.tx_hash;
|
|
112
|
+
steps.push({
|
|
113
|
+
name: 'get_transaction',
|
|
114
|
+
required: true,
|
|
115
|
+
fn: () => rpc('DERO.GetTransaction', {
|
|
116
|
+
txs_hashes: [hash],
|
|
117
|
+
decode_as_json: 1,
|
|
118
|
+
}),
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
const chain = await runChain(steps);
|
|
122
|
+
if (input.tx_hash) {
|
|
123
|
+
const txResult = stepValue(chain, 'get_transaction');
|
|
124
|
+
if (!txResult || !txResult.txs_as_hex || txResult.txs_as_hex.length === 0) {
|
|
125
|
+
throw new Error(`daemon did not return TX hex for ${input.tx_hash} (chain halted at ${chain.haltedAt ?? '?'})`);
|
|
126
|
+
}
|
|
127
|
+
txHex = txResult.txs_as_hex[0];
|
|
128
|
+
const ring = txResult.txs?.[0]?.ring?.[0];
|
|
129
|
+
if (ring && ringSlot >= 0 && ringSlot < ring.length) {
|
|
130
|
+
receiverAddress = ring[ringSlot];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
txHex = input.tx_hex;
|
|
135
|
+
}
|
|
136
|
+
// ─── 2. Parse TX → extract C[ring_slot] ──────────────────────────────────
|
|
137
|
+
let tx;
|
|
138
|
+
try {
|
|
139
|
+
tx = parseTransaction(txHex);
|
|
140
|
+
}
|
|
141
|
+
catch (err) {
|
|
142
|
+
throw new Error(`tx-parse failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
143
|
+
}
|
|
144
|
+
const stmt = tx.payloads[0].statement;
|
|
145
|
+
if (ringSlot >= stmt.ring_size) {
|
|
146
|
+
throw new Error(`INVALID_INPUT: ring_slot ${ringSlot} >= ring_size ${stmt.ring_size}`);
|
|
147
|
+
}
|
|
148
|
+
const Cslot = getRingCommitment(tx, ringSlot);
|
|
149
|
+
// ─── 3. Forge math ────────────────────────────────────────────────────────
|
|
150
|
+
const { signedAtoms, uint64, signedDeroNormalized } = parseAmount(amountDero);
|
|
151
|
+
const amountG = scalarMult(G, uint64ToSignedScalar(uint64));
|
|
152
|
+
const blinder = add(Cslot, negate(amountG));
|
|
153
|
+
// ─── 4. Self-check (mirror of proof.Prove() inner loop) ──────────────────
|
|
154
|
+
const reconstructed = add(amountG, blinder);
|
|
155
|
+
const verified = pointsEqual(reconstructed, Cslot);
|
|
156
|
+
if (!verified) {
|
|
157
|
+
// Should be impossible by construction — bail loud rather than emit a string
|
|
158
|
+
// that would fail an explorer check.
|
|
159
|
+
throw new Error('self-check FAILED: amount × G + blinder != C[slot] — bn254 math regression');
|
|
160
|
+
}
|
|
161
|
+
// ─── 5. Encode forged proof string ────────────────────────────────────────
|
|
162
|
+
const blinderHex = deroCompressHex(blinder);
|
|
163
|
+
const blinderBytes = new Uint8Array(33);
|
|
164
|
+
for (let i = 0; i < 33; i++)
|
|
165
|
+
blinderBytes[i] = parseInt(blinderHex.slice(i * 2, i * 2 + 2), 16);
|
|
166
|
+
const forgedString = encodeForgeProofString(blinderBytes, uint64);
|
|
167
|
+
// ─── 6. Citations + context_note enrichment ───────────────────────────────
|
|
168
|
+
const enrichment = enrichWithFlaggedArtifacts({
|
|
169
|
+
...(input.tx_hash ? { tx_hash: input.tx_hash } : {}),
|
|
170
|
+
}, relatedDocsFor('dero_forge_demo_proof'));
|
|
171
|
+
const related_docs = enrichment?.related_docs ?? relatedDocsFor('dero_forge_demo_proof') ?? [];
|
|
172
|
+
const context_note = enrichment?.context_note ??
|
|
173
|
+
'This is a forged display object built locally from public chain data — no wallet, no keys, no broadcast. On unpatched explorers it shows Verified ✓ for the chosen amount; on the chain, nothing changed. See related_docs for the technical rebuttal.';
|
|
174
|
+
return {
|
|
175
|
+
forged_proof_string: forgedString,
|
|
176
|
+
target_amount: {
|
|
177
|
+
dero: signedDeroNormalized,
|
|
178
|
+
atoms_signed: signedAtoms.toString(),
|
|
179
|
+
atoms_uint64: uint64.toString(),
|
|
180
|
+
},
|
|
181
|
+
ring_slot: ringSlot,
|
|
182
|
+
ring_size: stmt.ring_size,
|
|
183
|
+
ring_receiver_address: receiverAddress,
|
|
184
|
+
math: {
|
|
185
|
+
C_slot_hex: stmt.C_hex[ringSlot],
|
|
186
|
+
amount_x_G_hex: deroCompressHex(amountG),
|
|
187
|
+
blinder_hex: blinderHex,
|
|
188
|
+
},
|
|
189
|
+
self_check: {
|
|
190
|
+
verified: true,
|
|
191
|
+
method: 'Reconstructed amount × G + blinder and confirmed equal to C[slot] — same equation proof.Prove() uses (proof/proof.go:88-95).',
|
|
192
|
+
},
|
|
193
|
+
explorer_display_amount: formatExplorerDisplay(uint64),
|
|
194
|
+
context_note,
|
|
195
|
+
related_docs,
|
|
196
|
+
_diagnostics: {
|
|
197
|
+
step_latencies: stepLatencies(chain),
|
|
198
|
+
halted_at: chain.haltedAt,
|
|
199
|
+
total_ms: chain.totalMs,
|
|
200
|
+
tx_source: txSource,
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=forge-demo-proof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forge-demo-proof.js","sourceRoot":"","sources":["../../src/composites/forge-demo-proof.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EACL,CAAC,EACD,GAAG,EACH,eAAe,EAEf,MAAM,EACN,WAAW,EACX,UAAU,EACV,oBAAoB,GACrB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,0BAA0B,EAC1B,cAAc,GAEf,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC3D,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAA0B,MAAM,gBAAgB,CAAA;AAC5F,OAAO,EACL,QAAQ,EACR,aAAa,EACb,SAAS,GAGV,MAAM,cAAc,CAAA;AAErB,MAAM,MAAM,GAAG,OAAQ,CAAA;AACvB,MAAM,UAAU,GAAG,EAAE,IAAI,GAAG,CAAA;AAE5B,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACvC,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,KAAK,CAAC,mBAAmB,EAAE,mCAAmC,CAAC;SAC/D,QAAQ,EAAE;SACV,QAAQ,CACP,qGAAqG,CACt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AC,QAAQ,EAAE;YACpC,YAAY,EAAE,MAAM,CAAC,QAAQ,EAAE;SAChC;QACD,SAAS,EAAE,QAAQ;QACnB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,qBAAqB,EAAE,eAAe;QACtC,IAAI,EAAE;YACJ,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC;YAChC,cAAc,EAAE,eAAe,CAAC,OAAO,CAAC;YACxC,WAAW,EAAE,UAAU;SACxB;QACD,UAAU,EAAE;YACV,QAAQ,EAAE,IAAI;YACd,MAAM,EACJ,8HAA8H;SACjI;QACD,uBAAuB,EAAE,qBAAqB,CAAC,MAAM,CAAC;QACtD,YAAY;QACZ,YAAY;QACZ,YAAY,EAAE;YACZ,cAAc,EAAE,aAAa,CAAC,KAAK,CAAC;YACpC,SAAS,EAAE,KAAK,CAAC,QAAQ;YACzB,QAAQ,EAAE,KAAK,CAAC,OAAO;YACvB,SAAS,EAAE,QAAQ;SACpB;KACF,CAAA;AACH,CAAC"}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* that guess: one call, one ranked answer, with citations the agent
|
|
14
14
|
* can drop straight into a response.
|
|
15
15
|
*
|
|
16
|
-
* Design contract
|
|
16
|
+
* Design contract § 3. Sequencing rule: SHIP
|
|
17
17
|
* THIRD. Pure docs composition — no chain reads. Proves the
|
|
18
18
|
* "docs-only composite" pattern that future docs-heavy tools can
|
|
19
19
|
* reuse.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* that guess: one call, one ranked answer, with citations the agent
|
|
14
14
|
* can drop straight into a response.
|
|
15
15
|
*
|
|
16
|
-
* Design contract
|
|
16
|
+
* Design contract § 3. Sequencing rule: SHIP
|
|
17
17
|
* THIRD. Pure docs composition — no chain reads. Proves the
|
|
18
18
|
* "docs-only composite" pattern that future docs-heavy tools can
|
|
19
19
|
* reuse.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* any SC context. This composite combines all of that in one call
|
|
8
8
|
* and stitches the right docs page as a citation.
|
|
9
9
|
*
|
|
10
|
-
* Design contract
|
|
10
|
+
* Design contract § 5. Sequencing rule: SHIP
|
|
11
11
|
* LAST — highest fan-out + failure-mode count of all Phase C
|
|
12
12
|
* composites.
|
|
13
13
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* any SC context. This composite combines all of that in one call
|
|
8
8
|
* and stitches the right docs page as a citation.
|
|
9
9
|
*
|
|
10
|
-
* Design contract
|
|
10
|
+
* Design contract § 5. Sequencing rule: SHIP
|
|
11
11
|
* LAST — highest fan-out + failure-mode count of all Phase C
|
|
12
12
|
* composites.
|
|
13
13
|
*
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baked-in third-party public mainnet daemon. Last-resort fallback so the
|
|
3
|
+
* server works with zero setup, but it is someone else's node — prefer a
|
|
4
|
+
* local derod for privacy and trust.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PUBLIC_DAEMON_BASE = "http://82.65.143.182:10102";
|
|
7
|
+
/** A derod running locally on its default RPC bind — the preferred source. */
|
|
8
|
+
export declare const LOCAL_DAEMON_BASE = "http://127.0.0.1:10102";
|
|
9
|
+
export type DaemonSource = 'env' | 'local' | 'public';
|
|
10
|
+
export type DaemonResolution = {
|
|
11
|
+
base: string;
|
|
12
|
+
source: DaemonSource;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Resolve which DERO daemon the server should talk to, local-first:
|
|
16
|
+
*
|
|
17
|
+
* 1. DERO_DAEMON_URL set → honor it verbatim (hosted deploys, custom nodes).
|
|
18
|
+
* 2. else local node up → http://127.0.0.1:10102 (private, no third party).
|
|
19
|
+
* 3. else → baked-in public fallback (works with zero setup).
|
|
20
|
+
*
|
|
21
|
+
* Resolved once at startup. stdio hosts spawn a fresh process per session, so
|
|
22
|
+
* a node started later is picked up on the next launch; a long-running HTTP
|
|
23
|
+
* server re-resolves on restart.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveDaemonBase(): Promise<DaemonResolution>;
|
|
26
|
+
/** One-line, human-readable description of a resolution for startup logs. */
|
|
27
|
+
export declare function describeDaemonResolution({ base, source }: DaemonResolution): string;
|
|
28
|
+
//# sourceMappingURL=daemon-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon-base.d.ts","sourceRoot":"","sources":["../src/daemon-base.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,+BAA+B,CAAA;AAE9D,8EAA8E;AAC9E,eAAO,MAAM,iBAAiB,2BAA2B,CAAA;AAEzD,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAA;AAErD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,YAAY,CAAA;CACrB,CAAA;AA+BD;;;;;;;;;;GAUG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAQnE;AAED,6EAA6E;AAC7E,wBAAgB,wBAAwB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,gBAAgB,GAAG,MAAM,CASnF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { deroJsonRpc, jsonRpcEndpoint } from './rpc.js';
|
|
2
|
+
/**
|
|
3
|
+
* Baked-in third-party public mainnet daemon. Last-resort fallback so the
|
|
4
|
+
* server works with zero setup, but it is someone else's node — prefer a
|
|
5
|
+
* local derod for privacy and trust.
|
|
6
|
+
*/
|
|
7
|
+
export const PUBLIC_DAEMON_BASE = 'http://82.65.143.182:10102';
|
|
8
|
+
/** A derod running locally on its default RPC bind — the preferred source. */
|
|
9
|
+
export const LOCAL_DAEMON_BASE = 'http://127.0.0.1:10102';
|
|
10
|
+
function stripJsonRpc(url) {
|
|
11
|
+
return url.replace(/\/json_rpc\/?$/, '').replace(/\/+$/, '');
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Probe a base URL to confirm a real DERO daemon answers there. Calls
|
|
15
|
+
* DERO.GetInfo rather than a bare TCP connect, so an unrelated service
|
|
16
|
+
* squatting on the port is not mistaken for a daemon. A refused connection
|
|
17
|
+
* on localhost rejects almost immediately, so this adds no meaningful
|
|
18
|
+
* startup latency when no node is running.
|
|
19
|
+
*/
|
|
20
|
+
async function isDeroDaemon(base, timeoutMs = 1500) {
|
|
21
|
+
try {
|
|
22
|
+
const info = await deroJsonRpc(jsonRpcEndpoint(base), 'DERO.GetInfo', undefined, { timeoutMs });
|
|
23
|
+
return (!!info &&
|
|
24
|
+
typeof info === 'object' &&
|
|
25
|
+
(typeof info.height === 'number' || typeof info.topoheight === 'number'));
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolve which DERO daemon the server should talk to, local-first:
|
|
33
|
+
*
|
|
34
|
+
* 1. DERO_DAEMON_URL set → honor it verbatim (hosted deploys, custom nodes).
|
|
35
|
+
* 2. else local node up → http://127.0.0.1:10102 (private, no third party).
|
|
36
|
+
* 3. else → baked-in public fallback (works with zero setup).
|
|
37
|
+
*
|
|
38
|
+
* Resolved once at startup. stdio hosts spawn a fresh process per session, so
|
|
39
|
+
* a node started later is picked up on the next launch; a long-running HTTP
|
|
40
|
+
* server re-resolves on restart.
|
|
41
|
+
*/
|
|
42
|
+
export async function resolveDaemonBase() {
|
|
43
|
+
const fromEnv = process.env.DERO_DAEMON_URL?.trim();
|
|
44
|
+
if (fromEnv)
|
|
45
|
+
return { base: stripJsonRpc(fromEnv), source: 'env' };
|
|
46
|
+
if (await isDeroDaemon(LOCAL_DAEMON_BASE)) {
|
|
47
|
+
return { base: LOCAL_DAEMON_BASE, source: 'local' };
|
|
48
|
+
}
|
|
49
|
+
return { base: PUBLIC_DAEMON_BASE, source: 'public' };
|
|
50
|
+
}
|
|
51
|
+
/** One-line, human-readable description of a resolution for startup logs. */
|
|
52
|
+
export function describeDaemonResolution({ base, source }) {
|
|
53
|
+
switch (source) {
|
|
54
|
+
case 'env':
|
|
55
|
+
return `daemon: ${base} (from DERO_DAEMON_URL)`;
|
|
56
|
+
case 'local':
|
|
57
|
+
return `daemon: ${base} (local node detected)`;
|
|
58
|
+
case 'public':
|
|
59
|
+
return `daemon: ${base} (no local node found — public fallback; run your own derod for privacy)`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=daemon-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daemon-base.js","sourceRoot":"","sources":["../src/daemon-base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAEvD;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,4BAA4B,CAAA;AAE9D,8EAA8E;AAC9E,MAAM,CAAC,MAAM,iBAAiB,GAAG,wBAAwB,CAAA;AASzD,SAAS,YAAY,CAAC,GAAW;IAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;;GAMG;AACH,KAAK,UAAU,YAAY,CAAC,IAAY,EAAE,SAAS,GAAG,IAAI;IACxD,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,MAAM,WAAW,CAC5B,eAAe,CAAC,IAAI,CAAC,EACrB,cAAc,EACd,SAAS,EACT,EAAE,SAAS,EAAE,CACd,CAAA;QACD,OAAO,CACL,CAAC,CAAC,IAAI;YACN,OAAO,IAAI,KAAK,QAAQ;YACxB,CAAC,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,UAAU,KAAK,QAAQ,CAAC,CACzE,CAAA;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,EAAE,CAAA;IACnD,IAAI,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;IAElE,IAAI,MAAM,YAAY,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC1C,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;IACrD,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAA;AACvD,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,wBAAwB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAoB;IACzE,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,KAAK;YACR,OAAO,WAAW,IAAI,yBAAyB,CAAA;QACjD,KAAK,OAAO;YACV,OAAO,WAAW,IAAI,wBAAwB,CAAA;QAChD,KAAK,QAAQ;YACX,OAAO,WAAW,IAAI,0EAA0E,CAAA;IACpG,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DERO bn256 (alt_bn128 / bn254) constants and helpers.
|
|
3
|
+
*
|
|
4
|
+
* DERO uses the Pedersen base point `G = HashToPoint(HashtoNumber("DEROG"))`
|
|
5
|
+
* (`cryptography/crypto/algebra_pedersen.go:36`). It is NOT the standard bn254
|
|
6
|
+
* generator. Extracted once from a Go scratch program against the DEROHE
|
|
7
|
+
* Release 142 checkout — see `scripts/extract-g.go` (kept out-of-tree, regen
|
|
8
|
+
* instructions below) — and pinned here so this server does not need to
|
|
9
|
+
* reimplement HashToPoint.
|
|
10
|
+
*
|
|
11
|
+
* Wire format for compressed points (33 bytes, mirrors
|
|
12
|
+
* `cryptography/bn256/changes.go:19-35`):
|
|
13
|
+
*
|
|
14
|
+
* bytes[0..32] X coordinate, big-endian (32 bytes)
|
|
15
|
+
* bytes[32] sign byte:
|
|
16
|
+
* 0x00 if the original Y is the smaller of the two
|
|
17
|
+
* square roots of x^3 + 3 mod P (i.e. Y < P - Y)
|
|
18
|
+
* 0x01 if Y is the larger one
|
|
19
|
+
*
|
|
20
|
+
* To re-extract after a DEROHE update, drop this into
|
|
21
|
+
* `<derohe>/cmd/extract_g/main.go` and `go run ./cmd/extract_g/`:
|
|
22
|
+
*
|
|
23
|
+
* package main
|
|
24
|
+
* import (
|
|
25
|
+
* "fmt"; "math/big"
|
|
26
|
+
* "github.com/deroproject/derohe/cryptography/bn256"
|
|
27
|
+
* "github.com/deroproject/derohe/cryptography/crypto"
|
|
28
|
+
* )
|
|
29
|
+
* func main() {
|
|
30
|
+
* dump := func(l string, p *bn256.G1) { fmt.Printf("%s: %x\n", l, p.EncodeCompressed()) }
|
|
31
|
+
* dump("G", crypto.G)
|
|
32
|
+
* two := new(bn256.G1).Add(crypto.G, crypto.G); dump("2G", two)
|
|
33
|
+
* dump("-G", new(bn256.G1).Neg(crypto.G))
|
|
34
|
+
* dump("G*100000", new(bn256.G1).ScalarMult(crypto.G, new(big.Int).SetUint64(100_000)))
|
|
35
|
+
* }
|
|
36
|
+
*/
|
|
37
|
+
/** Pedersen base point G, 33-byte compressed hex (DERO format). */
|
|
38
|
+
export declare const DERO_G_COMPRESSED_HEX = "02eacfbf92b94015c9b0b3d901dae37ec68f74dea7e4484c76d505aade4ad7c001";
|
|
39
|
+
/** bn254 prime field modulus. */
|
|
40
|
+
export declare const BN254_P = 21888242871839275222246405745257275088696311157297823662689037894645226208583n;
|
|
41
|
+
/** bn254 curve order (subgroup order r). */
|
|
42
|
+
export declare const BN254_R = 21888242871839275222246405745257275088548364400416034343698204186575808495617n;
|
|
43
|
+
/** Curve equation constant: y^2 = x^3 + B. */
|
|
44
|
+
export declare const BN254_B = 3n;
|
|
45
|
+
/**
|
|
46
|
+
* Cross-implementation verification fixtures — produced by the Go scratch
|
|
47
|
+
* program above and used by the TS bn254 wrapper's self-tests. If the TS
|
|
48
|
+
* implementation cannot reproduce these compressed bytes from the underlying
|
|
49
|
+
* scalar operations, the noble-curves wiring or the DERO compression format
|
|
50
|
+
* is wrong — bail before forging anything.
|
|
51
|
+
*/
|
|
52
|
+
export declare const CURVE_FIXTURES: {
|
|
53
|
+
/** G itself. */
|
|
54
|
+
readonly G: "02eacfbf92b94015c9b0b3d901dae37ec68f74dea7e4484c76d505aade4ad7c001";
|
|
55
|
+
/** 2G = G + G. */
|
|
56
|
+
readonly twoG: "1723c9b5c0c573e9d202fea0243d5ffa5ca5e1adcfd50d0c0d53c48e1f190e0b00";
|
|
57
|
+
/** 3G = 2G + G. */
|
|
58
|
+
readonly threeG: "187768b7ba4478fd947490d31d6f10ce393c7429e1166f42a5bbc1d9a487a33600";
|
|
59
|
+
/** -G (negation). */
|
|
60
|
+
readonly negG: "02eacfbf92b94015c9b0b3d901dae37ec68f74dea7e4484c76d505aade4ad7c000";
|
|
61
|
+
/** G * 100_000 (= 1 DERO in atomic units — the smallest "real" forge scalar). */
|
|
62
|
+
readonly gMul1Dero: "1d03a5cf6ceb36e69d4e312d9f3d8413dd463f5f3498a31468bf9b46abbdd2e001";
|
|
63
|
+
/**
|
|
64
|
+
* G * int64(uint64(18446744073709451616)) = G * -100000 — the proof.go:89
|
|
65
|
+
* scalar for the docs-page demo's -1 DERO forge. Verifies the TS
|
|
66
|
+
* uint64→signed-scalar reduction matches Go's int64 cast.
|
|
67
|
+
*/
|
|
68
|
+
readonly gMulNeg1DeroAtoms: "1d03a5cf6ceb36e69d4e312d9f3d8413dd463f5f3498a31468bf9b46abbdd2e000";
|
|
69
|
+
/**
|
|
70
|
+
* G * int64(uint64(18446743853709551435)) = G * -220000000181 — the scalar
|
|
71
|
+
* proof.Prove() actually uses for the cited 2022 inflation-claim proof's V.
|
|
72
|
+
* Verifies the TS path reproduces the on-the-wire scalar for the
|
|
73
|
+
* real-world adversarial input.
|
|
74
|
+
*/
|
|
75
|
+
readonly gMulCited2022V: "0a5d16be695e5ca24f8f83e6a2f39a1bafe5251b69e182efbb90d41801782d1b00";
|
|
76
|
+
};
|
|
77
|
+
/** Atomic units per DERO. */
|
|
78
|
+
export declare const DERO_ATOMIC = 100000n;
|
|
79
|
+
//# sourceMappingURL=dero-curve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dero-curve.d.ts","sourceRoot":"","sources":["../src/dero-curve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,uEACoC,CAAA;AAEtE,iCAAiC;AACjC,eAAO,MAAM,OAAO,iFACiD,CAAA;AAErE,4CAA4C;AAC5C,eAAO,MAAM,OAAO,iFACiD,CAAA;AAErE,8CAA8C;AAC9C,eAAO,MAAM,OAAO,KAAK,CAAA;AAEzB;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;IACzB,gBAAgB;;IAEhB,kBAAkB;;IAElB,mBAAmB;;IAEnB,qBAAqB;;IAErB,iFAAiF;;IAEjF;;;;OAIG;;IAGH;;;;;OAKG;;CAEK,CAAA;AAEV,6BAA6B;AAC7B,eAAO,MAAM,WAAW,UAAW,CAAA"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DERO bn256 (alt_bn128 / bn254) constants and helpers.
|
|
3
|
+
*
|
|
4
|
+
* DERO uses the Pedersen base point `G = HashToPoint(HashtoNumber("DEROG"))`
|
|
5
|
+
* (`cryptography/crypto/algebra_pedersen.go:36`). It is NOT the standard bn254
|
|
6
|
+
* generator. Extracted once from a Go scratch program against the DEROHE
|
|
7
|
+
* Release 142 checkout — see `scripts/extract-g.go` (kept out-of-tree, regen
|
|
8
|
+
* instructions below) — and pinned here so this server does not need to
|
|
9
|
+
* reimplement HashToPoint.
|
|
10
|
+
*
|
|
11
|
+
* Wire format for compressed points (33 bytes, mirrors
|
|
12
|
+
* `cryptography/bn256/changes.go:19-35`):
|
|
13
|
+
*
|
|
14
|
+
* bytes[0..32] X coordinate, big-endian (32 bytes)
|
|
15
|
+
* bytes[32] sign byte:
|
|
16
|
+
* 0x00 if the original Y is the smaller of the two
|
|
17
|
+
* square roots of x^3 + 3 mod P (i.e. Y < P - Y)
|
|
18
|
+
* 0x01 if Y is the larger one
|
|
19
|
+
*
|
|
20
|
+
* To re-extract after a DEROHE update, drop this into
|
|
21
|
+
* `<derohe>/cmd/extract_g/main.go` and `go run ./cmd/extract_g/`:
|
|
22
|
+
*
|
|
23
|
+
* package main
|
|
24
|
+
* import (
|
|
25
|
+
* "fmt"; "math/big"
|
|
26
|
+
* "github.com/deroproject/derohe/cryptography/bn256"
|
|
27
|
+
* "github.com/deroproject/derohe/cryptography/crypto"
|
|
28
|
+
* )
|
|
29
|
+
* func main() {
|
|
30
|
+
* dump := func(l string, p *bn256.G1) { fmt.Printf("%s: %x\n", l, p.EncodeCompressed()) }
|
|
31
|
+
* dump("G", crypto.G)
|
|
32
|
+
* two := new(bn256.G1).Add(crypto.G, crypto.G); dump("2G", two)
|
|
33
|
+
* dump("-G", new(bn256.G1).Neg(crypto.G))
|
|
34
|
+
* dump("G*100000", new(bn256.G1).ScalarMult(crypto.G, new(big.Int).SetUint64(100_000)))
|
|
35
|
+
* }
|
|
36
|
+
*/
|
|
37
|
+
/** Pedersen base point G, 33-byte compressed hex (DERO format). */
|
|
38
|
+
export const DERO_G_COMPRESSED_HEX = '02eacfbf92b94015c9b0b3d901dae37ec68f74dea7e4484c76d505aade4ad7c001';
|
|
39
|
+
/** bn254 prime field modulus. */
|
|
40
|
+
export const BN254_P = 0x30644e72e131a029b85045b68181585d97816a916871ca8d3c208c16d87cfd47n;
|
|
41
|
+
/** bn254 curve order (subgroup order r). */
|
|
42
|
+
export const BN254_R = 0x30644e72e131a029b85045b68181585d2833e84879b9709143e1f593f0000001n;
|
|
43
|
+
/** Curve equation constant: y^2 = x^3 + B. */
|
|
44
|
+
export const BN254_B = 3n;
|
|
45
|
+
/**
|
|
46
|
+
* Cross-implementation verification fixtures — produced by the Go scratch
|
|
47
|
+
* program above and used by the TS bn254 wrapper's self-tests. If the TS
|
|
48
|
+
* implementation cannot reproduce these compressed bytes from the underlying
|
|
49
|
+
* scalar operations, the noble-curves wiring or the DERO compression format
|
|
50
|
+
* is wrong — bail before forging anything.
|
|
51
|
+
*/
|
|
52
|
+
export const CURVE_FIXTURES = {
|
|
53
|
+
/** G itself. */
|
|
54
|
+
G: '02eacfbf92b94015c9b0b3d901dae37ec68f74dea7e4484c76d505aade4ad7c001',
|
|
55
|
+
/** 2G = G + G. */
|
|
56
|
+
twoG: '1723c9b5c0c573e9d202fea0243d5ffa5ca5e1adcfd50d0c0d53c48e1f190e0b00',
|
|
57
|
+
/** 3G = 2G + G. */
|
|
58
|
+
threeG: '187768b7ba4478fd947490d31d6f10ce393c7429e1166f42a5bbc1d9a487a33600',
|
|
59
|
+
/** -G (negation). */
|
|
60
|
+
negG: '02eacfbf92b94015c9b0b3d901dae37ec68f74dea7e4484c76d505aade4ad7c000',
|
|
61
|
+
/** G * 100_000 (= 1 DERO in atomic units — the smallest "real" forge scalar). */
|
|
62
|
+
gMul1Dero: '1d03a5cf6ceb36e69d4e312d9f3d8413dd463f5f3498a31468bf9b46abbdd2e001',
|
|
63
|
+
/**
|
|
64
|
+
* G * int64(uint64(18446744073709451616)) = G * -100000 — the proof.go:89
|
|
65
|
+
* scalar for the docs-page demo's -1 DERO forge. Verifies the TS
|
|
66
|
+
* uint64→signed-scalar reduction matches Go's int64 cast.
|
|
67
|
+
*/
|
|
68
|
+
gMulNeg1DeroAtoms: '1d03a5cf6ceb36e69d4e312d9f3d8413dd463f5f3498a31468bf9b46abbdd2e000',
|
|
69
|
+
/**
|
|
70
|
+
* G * int64(uint64(18446743853709551435)) = G * -220000000181 — the scalar
|
|
71
|
+
* proof.Prove() actually uses for the cited 2022 inflation-claim proof's V.
|
|
72
|
+
* Verifies the TS path reproduces the on-the-wire scalar for the
|
|
73
|
+
* real-world adversarial input.
|
|
74
|
+
*/
|
|
75
|
+
gMulCited2022V: '0a5d16be695e5ca24f8f83e6a2f39a1bafe5251b69e182efbb90d41801782d1b00',
|
|
76
|
+
};
|
|
77
|
+
/** Atomic units per DERO. */
|
|
78
|
+
export const DERO_ATOMIC = 100000n;
|
|
79
|
+
//# sourceMappingURL=dero-curve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dero-curve.js","sourceRoot":"","sources":["../src/dero-curve.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,mEAAmE;AACnE,MAAM,CAAC,MAAM,qBAAqB,GAChC,oEAAoE,CAAA;AAEtE,iCAAiC;AACjC,MAAM,CAAC,MAAM,OAAO,GAClB,mEAAmE,CAAA;AAErE,4CAA4C;AAC5C,MAAM,CAAC,MAAM,OAAO,GAClB,mEAAmE,CAAA;AAErE,8CAA8C;AAC9C,MAAM,CAAC,MAAM,OAAO,GAAG,EAAE,CAAA;AAEzB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,gBAAgB;IAChB,CAAC,EAAE,oEAAoE;IACvE,kBAAkB;IAClB,IAAI,EAAE,oEAAoE;IAC1E,mBAAmB;IACnB,MAAM,EAAE,oEAAoE;IAC5E,qBAAqB;IACrB,IAAI,EAAE,oEAAoE;IAC1E,iFAAiF;IACjF,SAAS,EAAE,oEAAoE;IAC/E;;;;OAIG;IACH,iBAAiB,EACf,oEAAoE;IACtE;;;;;OAKG;IACH,cAAc,EAAE,oEAAoE;CAC5E,CAAA;AAEV,6BAA6B;AAC7B,MAAM,CAAC,MAAM,WAAW,GAAG,OAAQ,CAAA"}
|
package/dist/docs-parse.d.ts.map
CHANGED
|
@@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AG,MAAM,CAEpD;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ1D;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAWlD;AAyCD,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAqC7E;AAED,wBAAsB,mBAAmB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkBrF"}
|
package/dist/docs-parse.js
CHANGED
|
@@ -90,7 +90,23 @@ async function walkMdxFiles(dir) {
|
|
|
90
90
|
function buildCanonicalUrl(product, slug) {
|
|
91
91
|
if (!slug)
|
|
92
92
|
return `${DOC_BASE_URLS[product]}/`;
|
|
93
|
-
|
|
93
|
+
// .md mirror suffix points agents at the LLM-canonical Markdown surface.
|
|
94
|
+
// All four ecosystem sites (derod, tela, hologram, deropay) ship the App
|
|
95
|
+
// Router .md mirror route as of 0.2.4.
|
|
96
|
+
return `${DOC_BASE_URLS[product]}/${slug}.md`;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Normalize a frontmatter-supplied canonical URL so it carries the same
|
|
100
|
+
* `.md` suffix as builder-generated URLs. Without this, any MDX page that
|
|
101
|
+
* declared its own `canonicalUrl` in frontmatter would bypass the suffix
|
|
102
|
+
* and point agents at the HTML version.
|
|
103
|
+
*/
|
|
104
|
+
function applyMdSuffix(_product, url) {
|
|
105
|
+
// Don't double-suffix; preserve query/anchor if present.
|
|
106
|
+
const [base, rest = ''] = url.split(/(?=[?#])/);
|
|
107
|
+
if (/\.md$/.test(base) || /\.[a-z0-9]{2,5}$/i.test(base))
|
|
108
|
+
return url;
|
|
109
|
+
return `${base}.md${rest}`;
|
|
94
110
|
}
|
|
95
111
|
export async function indexDocsFromRoot(root) {
|
|
96
112
|
const pages = [];
|
|
@@ -112,7 +128,7 @@ export async function indexDocsFromRoot(root) {
|
|
|
112
128
|
slug,
|
|
113
129
|
title: frontmatter.title || safeTitleFromSlug(slug),
|
|
114
130
|
description: frontmatter.description || null,
|
|
115
|
-
canonicalUrl: frontmatter.canonicalUrl || buildCanonicalUrl(product, slug),
|
|
131
|
+
canonicalUrl: applyMdSuffix(product, frontmatter.canonicalUrl || buildCanonicalUrl(product, slug)),
|
|
116
132
|
sourcePath: path.relative(root, filePath).replace(/\\/g, '/'),
|
|
117
133
|
headings,
|
|
118
134
|
plainText: mdxToPlainText(content),
|
package/dist/docs-parse.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs-parse.js","sourceRoot":"","sources":["../src/docs-parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,CAAU,CAAA;AAGlF,MAAM,CAAC,MAAM,aAAa,GAAmC;IAC3D,KAAK,EAAE,YAAY;IACnB,IAAI,EAAE,WAAW;IACjB,QAAQ,EAAE,eAAe;IACzB,OAAO,EAAE,cAAc;CACxB,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAmC;IAC3D,KAAK,EAAE,mBAAmB;IAC1B,IAAI,EAAE,wBAAwB;IAC9B,QAAQ,EAAE,4BAA4B;IACtC,OAAO,EAAE,uBAAuB;CACjC,CAAA;AAqBD,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;AAC7D,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACrC,IAAI,CAAC,IAAI;QAAE,OAAO,MAAM,CAAA;IACxB,OAAO,IAA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D,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streamable HTTP transport entry for dero-mcp-server.
|
|
3
|
+
*
|
|
4
|
+
* Same factory (`createDeroMcpServer`) as the stdio entry — just a
|
|
5
|
+
* different transport on top. Enable via `dero-mcp-server --http`
|
|
6
|
+
* or `DERO_MCP_HTTP=1` (see index.ts dispatcher).
|
|
7
|
+
*
|
|
8
|
+
* Stateless by design: each request is independent. No session
|
|
9
|
+
* tracking, no in-memory state across requests, no logs of query
|
|
10
|
+
* payloads. Pairs cleanly with read-only semantics and the
|
|
11
|
+
* privacy-first brand.
|
|
12
|
+
*
|
|
13
|
+
* Environment:
|
|
14
|
+
* DERO_DAEMON_URL — JSON-RPC base. If unset, resolves local-first:
|
|
15
|
+
* a local derod (127.0.0.1:10102) if reachable,
|
|
16
|
+
* else the baked-in public fallback.
|
|
17
|
+
* DERO_MCP_HTTP_PORT — listen port (default: 8787)
|
|
18
|
+
* DERO_MCP_HTTP_HOST — listen address (default: 127.0.0.1)
|
|
19
|
+
* DERO_MCP_AUTH_TOKEN — if set, require `Authorization: Bearer <token>`
|
|
20
|
+
* on /mcp. Constant-time compared. Recommended
|
|
21
|
+
* when binding to a public address; required
|
|
22
|
+
* if behind a reverse proxy without its own auth.
|
|
23
|
+
*
|
|
24
|
+
* Routes:
|
|
25
|
+
* POST /mcp — MCP streamable HTTP endpoint
|
|
26
|
+
* GET /mcp — same (SSE compat for older clients)
|
|
27
|
+
* GET /health — health check {status, version, daemon_url, daemon_source}
|
|
28
|
+
* anything else → 404
|
|
29
|
+
*
|
|
30
|
+
* Reverse-proxy expectations:
|
|
31
|
+
* - TLS handled upstream (Caddy / Cloudflare / etc.) — this server is
|
|
32
|
+
* plain HTTP.
|
|
33
|
+
* - Original client IP can be passed via X-Forwarded-For for logging;
|
|
34
|
+
* we don't log IPs by default but the middleware reads it if present.
|
|
35
|
+
*/
|
|
36
|
+
export declare function startHttpServer(): Promise<void>;
|
|
37
|
+
//# sourceMappingURL=http-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-server.d.ts","sourceRoot":"","sources":["../src/http-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAsCH,wBAAsB,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,CAoFrD"}
|