Repository navigation
adamant-api v3.2.0
SDK release coordinated with ADAMANT Node v0.11.0. This release includes critical security and correctness fixes: local Ed25519 + address-binding verification of recipient and delegate public keys before caching or encryption (#109 / #110), plain filter serialization for getKVS() and chat queries (#97), usable-node onReady readiness with capped startup backoff (#99), resilient HTTP 429 Too Many Requests failover and per-node cooldowns, POST /api/states/get support, OpenAPI DTO generation migrated to Adamant-im/adamant, and a 7-day npm dependency release-age quarantine with zero production audit vulnerabilities.
Important security & correctness upgrade notice: All
v3.0.0andv3.1.0consumers should upgrade tov3.2.0:
- Verifies recipient and delegate Ed25519 public keys and local address derivation before caching or encrypting messages (#109, #110).
- Fixes
getKVS(),getChatTransactions(),getChats(), andgetChatMessages()sendingand:-prefixed filters that pre-v0.11.0 nodes silently ignored while returningsuccess: truewith unfiltered network-wide records (#97).
Highlights
Recipient & delegate public-key verification (#109, #110)
- Enforces canonical 32-byte on-curve Ed25519 validation (rejecting non-canonical, off-curve, and small-order Curve25519 keys of orders 1, 2, 4, and 8) and local ADM address derivation checks before caching or encrypting messages.
getPublicKey()returns''without a network request for invalid ADM addresses and returns''without poisoning the cache when a node returns a mismatched or malformed key.sendMessage()locally re-verifies resolved recipient keys and rejects invalid/mismatched keys with{success: false, errorMessage};voteForDelegate()rejects delegate keys failing address binding.- Uses a
Map-backedpublicKeysCacheverified on both writes and reads, and isolates network-dependent delegate caches (byAddress,byUsername) perAdamantApiinstance.
Security & correctness fix for KVS and chat filters
getKVS(),getChatTransactions(),getChats(), andgetChatMessages()now emit plain filter names (flattening explicitand: { ... }wrappers), matching the documented node contract across every ADAMANT Node version.- Rejects unsupported
orwrappers and pre-prefixedand:/or:filter keys on AND-only endpoints client-side with{success: false, errorMessage}instead of sending prefixes that older nodes ignore and v0.11.0+ nodes reject. - Verified with a recorded mainnet
/api/states/getfixture test.
Usable-node readiness & loader filtering
- Excludes nodes reporting
loader.loaded: falseorloader.syncing: truefrom primary active node selection and WebSocket connection lists, while keeping legacy nodes without aloaderobject eligible. - Holds
onReady(and exposesapi.isReady) until a usable node is actually selected, retrying startup checks with capped backoff (5s,10s,30s,60s, continuing even if an earlier sweep throws) instead of waiting for the 5-minute periodic sweep. - When already initialized and all ready nodes fail or fall below
minVersion, falls back with a warning to aminVersion-compatible loaded-but-syncing node only when a recent synced height reference is available (within 10 minutes) and the candidate is within 25 blocks of that height (checkHealthAtStartup: falsewithout a prior synced sweep, lagging nodes, andloaded: falsenodes are never selected). - Prevents double-firing
onReadyif the callback throws and safely skips non-object responses (e.g., HTML200maintenance pages),null, or incomplete{success: true}status payloads.
ADAMANT Node v0.11.0 API, OpenAPI & KVS POST alignment
- Migrates deterministic API DTO generation (
scripts/sync-api-types.mjs) from the archivedAdamant-im/adamant-schemarepo toAdamant-im/adamant(openapi/specification/openapi.yamlat released v0.11.0mastercommit50568f37dc2b7da86f44991f96c40c8edde74d67), reading exact installed tool versions viacreateRequire. - Regenerates
src/api/generated.tswithRateLimitErrorResponseDto,GetKVSRequestBody, and updatedhttps://docs.adamant.im/links. - Aligns endpoint option types (
ChatroomsOptions, newChatTransactionsOptions, andKVSOptions) with ADAMANT Node v0.11.0 strict filter validation (toHeightenforced on/api/chats/getand/api/states/get; height/range filters excluded from/api/chatrooms/*). - Deprecates
ChatroomsOptions.userIdand strips it at runtime on/api/chatrooms/*with a dedicated one-time deprecation warning so legacy callers do not fail validation on v0.11.0+ nodes. - Adds
POST /api/states/getsupport viaapi.getKVS(options, {method: 'POST'})for largekeyIds/senderIdsqueries, with full idempotent read failover matchingGET.
Resilient HTTP 429 Too Many Requests & failover hardening
- Captures
targetNodebefore each request so concurrent failures never flipthis.nodeback to a failed node. - Switches immediately to another cached synced, non-rate-limited node on multi-node HTTP
429without extra/api/node/statusprobes; skips health sweeps on single-node429responses and handles429incheckNode()distinctly from offline nodes. - Deduplicates concurrent
updateNodes()sweeps via an in-flight promise (updateNodesPromise) and upgrades an in-flight planned sweep to forced failover when a request reports a failed node. - Rotates away from
failedNodeacross both 2-node and 3+-node synced sets and tracks per-node 429 cooldowns (rateLimitedUntil, capped at 60s) so forced and planned health sweeps avoid rate-limited nodes until cooldown expires. - Parses
Retry-After(seconds or HTTP-date),RateLimit-Reset, andRateLimit-Scopeheaders; fails over immediately for idempotent reads (GETandPOST /api/states/get) when another synced node exists, or honors bounded backoff with jitter (up to 10s) on a single node without tight-looping. - Exposes optional
status,retryAfterMs, andrateLimitScopemetadata on HTTP 429 failure results inAdamantApiResult, while keeping writePOSTrequests strictly non-replayed.
Dependency security refresh & 7-day release-age quarantine
- Enforces
minimumReleaseAge: 10080(7 days) and explicitallowBuilds('@parcel/watcher': false,esbuild: true,unrs-resolver: true) inpnpm-workspace.yamlwith zero release-age exclusions. - Refreshes direct and transitive dependencies past the 7-day cutoff (
axios@^1.21.1,bitcoinjs-lib@^7.0.5,tiny-secp256k1@^2.2.5,pbkdf2@^3.1.7,socket.io-client@^4.8.4,bip39@^3.1.2,ecpair@^3.0.2,semver@^7.8.6,@redocly/cli@2.78.0,eslint@10.15.0,jest@^30.5.2,prettier@3.10.1,swagger-typescript-api@13.14.0, and more), reducing production audit findings from 20 to 0. - Publishes via GitHub Actions npm Trusted Publishing with build provenance.
Compatibility and migration notes
- Strict Ed25519 key & address-binding verification (#109, #110):
encodeMessage()anddecodeMessage()now throwinvalid keyfor non-canonical, off-curve, and small-order (orders 1, 2, 4, 8) Ed25519 keys. Legitimate mainnet keys are unaffected.getPublicKey()returns''without a network request for invalid ADM addresses and also returns''when the node's key does not derive the address.sendMessage()rejects such recipients with{success: false, errorMessage}, andvoteForDelegate()rejects delegate keys failing address binding.
- TypeScript query option narrowing:
ChatroomsOptionsandKVSOptionsno longer inherit unsupportedTransactionQueryParametersfields that ADAMANT Node v0.11.0 rejects.getChatTransactions()now usesChatTransactionsOptions(a superset ofChatroomsOptionsretainingfromHeight,toHeight,inId, andisIn).TransactionQueryParametersremains exported unchanged. transformTransactionQuery()throw behavior: CallingtransformTransactionQuery(query, 'states' | 'chats' | 'chatrooms')directly with anorwrapper or pre-prefixedand:/or:filter keys now throws anErrorwith thebadParametermessage (whereasAdamantApiclient methods return{success: false, errorMessage}).toHeightongetKVS()/getChatTransactions(): Enforced only by ADAMANT Node v0.11.0+; older nodes silently ignoretoHeightand return newer records withsuccess: true, so callers relying on an upper height bound should setminVersion: '0.11.0'.userIdon/api/chatrooms/*: Deprecated onChatroomsOptionsand stripped at runtime with a dedicated warning; pass the account address only as the URL path argument ofgetChats(address)/getChatMessages(address1, address2).onReadybehavior: WithcheckHealthAtStartup: true,onReadynow waits (andapi.isReadystaysfalse) until a usable, loaded, non-syncing node is selected, retrying startup checks with5s → 10s → 30s → 60sbackoff.- HTTP 429 failure metadata: Optional
status,retryAfterMs, andrateLimitScopefields are added to thesuccess: falsevariant ofAdamantApiResultwhen a request fails with HTTP 429.
Transaction byte layout, hashes, IDs, signatures, encryption, wallet derivation, and root exports are unchanged.
Diff overview
- 20 commits (16 non-merge commits)
- 32 files changed, 6,490 insertions and 2,476 deletions
Validation
Verified on Node.js v24.19.0 and pnpm 11.13.1:
pnpm test— compile, typecheck, 20 suites and 333 tests (100% function coverage), andgts lintpassedpnpm run api-types:check— matchesAdamant-im/adamant@50568f37dc2b7da86f44991f96c40c8edde74d67pnpm run metadata:check— matchesAdamant-im/adamant-wallets@54a820b6dc5e0ec77c3a6fbac91d2f7809a2f5b7pnpm run docs:build— TypeDoc and VitePress build passed (vitepress devalso verified)pnpm run test:package— ESM, CommonJS, live consumers, package subpaths, and TypeScript declarations passedpnpm audit --prod --audit-level=moderate— 0 vulnerabilitiespnpm audit signatures— all 893 locked packages verified
Related
- Release PR: #107
- Release task: #106
- Plain chat & KVS filter fix: #101
onReady& syncing node fix: #102- Node v0.11.0 alignment & dependency refresh: #105
- Recipient & delegate public-key verification: #110
- ADAMANT Node v0.11.0 release PR: Adamant-im/adamant#303
- SDK documentation: https://js.docs.adamant.im
Full Changelog: v3.1.0...v3.2.0