feat(stellar): publish SEP-1 stellar.toml metadata endpoint. - #75
Conversation
…-known/stellar.toml
WalkthroughAdds a configurable SEP-1 ChangesSEP-1 metadata endpoint
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant ExpressApp
participant wellKnownRoutes
participant stellarTomlService
Client->>ExpressApp: GET /.well-known/stellar.toml
ExpressApp->>wellKnownRoutes: Route request
wellKnownRoutes->>stellarTomlService: buildStellarToml()
stellarTomlService-->>wellKnownRoutes: TOML document
wellKnownRoutes-->>Client: 200 TOML response
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (1)
test/stellarToml.test.js (1)
24-38: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winMake the network-specific expectations deterministic.
These assertions hard-code testnet values, so a mainnet-configured run fails even when the network-aware implementation is correct. Pin
STELLAR_NETWORK=testnetbefore importingapp.js, or parameterize expectations for both networks.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/stellarToml.test.js` around lines 24 - 38, Make the tests in the NETWORK_PASSPHRASE and USDC CURRENCIES cases deterministic by setting STELLAR_NETWORK to testnet before app.js is imported, or derive expectations from the configured network. Preserve the existing testnet assertions when running in testnet mode and ensure app.js reads the intended network configuration.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@QUICK_START.md`:
- Line 73: Update the optional TOML environment-variable list in QUICK_START.md
to remove SIGNING_KEY or clearly mark it as a blank placeholder that must remain
unset until SEP-10 (`#25`). Ensure the documentation does not suggest storing or
publishing a private signing key through this endpoint.
In `@src/services/stellar/stellarTomlService.js`:
- Around line 63-64: Update the TOML generation loop in stellarTomlService
around setDocFields so every interpolated value is serialized or escaped as a
TOML string before being appended to lines. Handle quotes, backslashes, and
newlines for all environment-derived ORG_* values while preserving the generated
key/value structure and ensuring valid machine-readable TOML.
- Around line 39-43: Update the SIGNING_KEY handling in the stellar.toml
generation flow to never emit process.env.SIGNING_KEY verbatim. Validate that
the value is a public Stellar account key beginning with G and emit it only when
valid; otherwise keep the existing commented placeholder, ensuring secret seeds
or other invalid values are not published.
- Around line 4-5: Update the stellar.toml generation logic in
stellarTomlService to use only STELLAR_PLATFORM_PUBLIC_KEY for the published
account, removing the PLATFORM_WALLET_PUBLIC_KEY fallback; when
STELLAR_PLATFORM_PUBLIC_KEY is blank or unset, omit ACCOUNTS entirely.
In `@test/stellarToml.test.js`:
- Around line 40-47: Update the environment-mutating tests around the ORG_* and
STELLAR_PLATFORM_PUBLIC_KEY overrides to save each variable’s exact prior value
and restore it in a finally block, ensuring cleanup runs after failed
assertions. Restore empty-string values as empty strings, and delete a variable
only when its saved value was originally undefined.
- Around line 83-90: Update the test case “omits ACCOUNTS gracefully when no
platform key is available” to parse res.text as a Stellar TOML document and
assert doc.ACCOUNTS is undefined, not just that the response is successful. Also
disable or override the service’s PLATFORM_WALLET_PUBLIC_KEY fallback during the
test so the omission is genuinely exercised, while preserving environment
restoration afterward.
---
Nitpick comments:
In `@test/stellarToml.test.js`:
- Around line 24-38: Make the tests in the NETWORK_PASSPHRASE and USDC
CURRENCIES cases deterministic by setting STELLAR_NETWORK to testnet before
app.js is imported, or derive expectations from the configured network. Preserve
the existing testnet assertions when running in testnet mode and ensure app.js
reads the intended network configuration.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: ac51c7d1-8b45-401e-a80e-04e6d48cf9cf
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (9)
.env.exampleQUICK_START.mdREADME.mdapp.jspackage.jsonsrc/config/validateEnv.jssrc/routes/wellKnownRoutes.jssrc/services/stellar/stellarTomlService.jstest/stellarToml.test.js
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
test/stellarToml.test.js (1)
147-154: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winExercise the limiter threshold in this test
Ten requests never hit the currentapiLimitercap (100), so this doesn’t prove the/.well-knownroute stays exempt under load. Send at least 101 requests, or swap in a deliberately low test limiter, so a future global limiter regression fails here.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@test/stellarToml.test.js` around lines 147 - 154, Update the “is not affected by /api rate limiter” test to issue at least 101 concurrent requests, exceeding the current apiLimiter threshold while continuing to request /.well-known/stellar.toml and assert every response remains successful.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@test/stellarToml.test.js`:
- Around line 147-154: Update the “is not affected by /api rate limiter” test to
issue at least 101 concurrent requests, exceeding the current apiLimiter
threshold while continuing to request /.well-known/stellar.toml and assert every
response remains successful.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 0ef91c15-5bb6-45aa-bba3-e2bd86598b68
📒 Files selected for processing (3)
QUICK_START.mdsrc/services/stellar/stellarTomlService.jstest/stellarToml.test.js
🚧 Files skipped from review as they are similar to previous changes (2)
- QUICK_START.md
- src/services/stellar/stellarTomlService.js
Summary
Closes #58
Hosts a SEP-1
stellar.tomlfile at/.well-known/stellar.tomlso DeenBridge platform organization metadata, declared accounts, and supported assets (USDC) are discoverable and verifiable across the Stellar ecosystem.What Was Done
Config-Driven TOML Builder (
src/services/stellar/stellarTomlService.js):stellarService.js.ORG_NAME,ORG_URL,ORG_DESCRIPTION,ORG_LOGO,ORG_TWITTER,ORG_GITHUB,STELLAR_PLATFORM_PUBLIC_KEY,SIGNING_KEY).Public Well-Known Endpoint (
src/routes/wellKnownRoutes.js&app.js):GET /.well-known/stellar.toml.Content-Type: text/toml; charset=utf-8andAccess-Control-Allow-Origin: *per SEP-1 requirement./apirate limiter so ecosystem crawlers and wallets can fetch it unthrottled and unauthenticated.Validation & Docs:
src/config/validateEnv.jsand.env.example.QUICK_START.mdandREADME.md.Automated Testing (
test/stellarToml.test.js):@iarna/toml(devDependency) to parse and validate TOML response structure.How to Test