Repository navigation
feat(provider-ids): stable canonical-id resolver (closes #2256) - #2316
Merged
github-actions[bot] merged 1 commit intoNov 24, 2026
Merged
Conversation
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.
Closes #2256
Summary
Adds a stable, provider-agnostic canonical-id resolver behind the two requested paths, with no unrelated churn.
backend/src/lib/providerId.ts(zero-dependency, pure, side-effect-free):canonicalizeProviderId()/resolveProviderId()fold any provider identifier into<provider>:<normalized-id>-<8-hex FNV-1a>(wire-format version1).normalizeExternalId()trims, Unicode NFKD-folds, lower-cases, strips configured provider prefixes (cus_,PAY-,ch_, ...) and collapses separators to a single-. Non-ASCII becomes a separator; length is bounded (128 normalized / 512 raw).fnv1a32(provider + "\0" + normalizedId), so case/separator/prefix/Unicode equivalents collapse to one id while different providers and different ids stay distinct.parseProviderIdentifier(),areSameProviderId(),validateCanonicalIdConfig(),fnv1a32(),ProviderIdErrorwith stable codes, config-driven known-provider allow-list with custom-provider support, idempotent passthrough of already-canonical strings, and acreateCanonicalIdResolver()factory with metrics/logger hooks (rejections emitrecordRejected+warnand rethrow the typed error).packages/billing-types/(new@subtrackr/billing-typespackage):CANONICAL_ID_VERSION,CANONICAL_ID_PATTERN,CANONICAL_ID_PATTERN_SOURCE,KNOWN_PROVIDERS,ProviderKind,CanonicalProviderId,PROVIDER_PREFIXES,PROVIDER_ID_ERROR_CODES,MAX_NORMALIZED_ID_LENGTH,DEFAULT_ALLOW_CUSTOM_PROVIDERS. The backend imports these instead of duplicating them.Tests
backend/src/lib/__tests__/providerId.test.ts— 30 tests: constants/error surface, config validation, parsing, normalisation (case, separators, prefixes, Unicode), determinism and canonical well-formedness, cross-provider distinctness, Unicode folding, already-canonical passthrough, every failure code, resolution records, equality, and metrics/logger hooks.packages/billing-types/src/__tests__/index.test.ts— 5 tests: version/limits, provider set, canonical pattern positives/negatives, shared prefixes, shared error codes.Verification evidence
Run with no
node_modulesusing Node 26 native TypeScript type-stripping against the real.tssources (explicit.tsimport extensions):node verify_2256.mjs→ 52 passed, 0 failed (exit 0)python tools/check_secrets.py→[OK], SECRETS_EXIT=0Payouts
Base Mainnet (USDC/ETH): 0xC5dD2Ea54FF138bb3f71D3466092eA31eF115868
Solana (USDC/SOL): DN3pfYEvdkoTBP4oaEVvemsr98fZPhDSAbfVfmewRGQ5
PayPal: ivanzenteno3@gmail.com