feat: add deterministic Stellar address validation module - #363
Merged
Lakes41 merged 2 commits intoAug 26, 2026
Merged
Conversation
Adds @guildpass/stellar-utils, a framework-free module that validates Stellar StrKey addresses via native RFC4648 base32 decoding and CRC16/XMODEM checksum verification (no Stellar SDK, database, or Fastify dependency). Only ed25519 public account addresses (G...) are treated as valid; other well-formed StrKey types (M, S, T, X, P, C, L, B) are rejected explicitly as UNSUPPORTED_ADDRESS_TYPE instead of silently accepted. validateStellarAddress never throws; isStellarAddress and assertStellarAddress are provided as convenience wrappers. Closes Adamantine-guild#344 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Resolves the pnpm-lock.yaml conflict from main's permission-expression and webhook-verification packages by regenerating the lockfile via pnpm install.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
@guildpass/stellar-utils, a reusable, deterministic Stellar StrKey address validation module. It has no dependency on a Stellar SDK, Prisma, Redis, or Fastify, so it can be safely consumed at any boundary (wallet linking, membership operations, contract integrations) without duplicating validation logic across route handlers or services.Validation is implemented from first principles: RFC4648 base32 decoding (with canonical-encoding checks — invalid alphabet, non-zero padding bits, non-minimal length) and CRC16/XMODEM checksum verification, per the Stellar StrKey spec (https://developers.stellar.org/docs/encyclopedia/base32).
Linked Issue
Closes #344
Type of Change
Changes Made
packages/stellar-utils/src/index.ts—validateStellarAddress,isStellarAddress,assertStellarAddress,InvalidStellarAddressError, and theStellarAddressValidationResulttyped union.packages/stellar-utils/src/index.test.ts— 14 unit tests covering valid/invalid checksum, truncated/padded input, random strings, casing, unsupported StrKey types, empty/whitespace input, whitespace trimming, non-string input of many types, determinism, and the assertion API.packages/stellar-utils/package.json,tsconfig.json— package scaffolding, matching the conventions ofpackages/rate-limit.Design notes
G...ed25519 public account addresses are accepted. Other well-formed StrKey types (Mmuxed account,Sseed,Tpre-auth tx,Xsha256 hash,Psigned payload,Ccontract,Lliquidity pool,Bclaimable balance) are recognised by their version byte and rejected explicitly viaUNSUPPORTED_ADDRESS_TYPE, rather than falling through as generically malformed or being silently accepted.validateStellarAddress); casing and internal content are never normalised — a lowercase or mixed-case address is rejected rather than silently coerced, since StrKey is case-sensitive by spec.validateStellarAddressnever throws for ordinary invalid input (verified againstnull,undefined, numbers, booleans, objects, arrays, symbols, functions, andDateinstances).assertStellarAddressis provided separately for call sites that want throw-based control flow.Test Evidence
Repo-wide, from a clean install:
General Checklist
pnpm typecheckpassespnpm testpasses — all tests green.env.exampleupdated if new env variables were added — N/A, no new env variablesAdditional Notes
apps/api'stsctypecheck requirespnpm --filter @guildpass/api prisma:generateto have been run first (to generate the Prisma client types) — this is a pre-existing local-setup step unrelated to this change, confirmed present onmainbefore this branch's changes.