Skip to content

🔒️ server: restrict bridge access by country - #1066

Merged
cruzdanilo merged 1 commit into
mainfrom
denylist
Jun 2, 2026
Merged

🔒️ server: restrict bridge access by country#1066
cruzdanilo merged 1 commit into
mainfrom
denylist

Conversation

@mainqueg

@mainqueg mainqueg commented Jun 1, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Bridge provider onboarding now enforces geographic restrictions. Users attempting to onboard from denylisted countries will receive a clear error response.
  • Tests

    • Added test coverage for country-based access restrictions, including error handling and provider unavailability scenarios.

@changeset-bot

changeset-bot Bot commented Jun 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1a88c70

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@exactly/server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 1, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR restricts bridge provider access for denylisted countries. It adds an ErrorCodes.DENYLISTED_COUNTRY error code, defines a denylist containing "ID", modifies bridge.getProvider to return unavailable status for denylisted countries, updates bridge.onboarding to reject them with warning logs, wires the error into the API response handler, and adds full test coverage for the new behavior.

Changes

Bridge country denylisting

Layer / File(s) Summary
Error code and denylist contract
server/utils/ramps/bridge.ts
ErrorCodes.DENYLISTED_COUNTRY constant and a Denylist set containing the country code "ID" are defined as module exports and constants.
Bridge provider denylisting logic
server/utils/ramps/bridge.ts
getProvider checks the persona countryCode against the denylist and returns NOT_AVAILABLE status with empty currencies if matched; onboarding logs a Sentry warning with credential and country context, then throws DENYLISTED_COUNTRY instead of proceeding.
API error handling
server/api/ramp.ts
The bridge onboarding error switch adds a DENYLISTED_COUNTRY case that returns HTTP 400 with code: error.message.
Test coverage
server/test/utils/bridge.test.ts, server/test/api/ramp.test.ts
Unit tests assert getProvider returns NOT_AVAILABLE without side effects and onboarding throws with Sentry logging; integration test asserts the API responds with HTTP 400 and { code: "denylisted country" }.
Release notes
.changeset/wary-falcon-guard.md
Changeset entry marks @exactly/server for patch release with description "restrict bridge access by country".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • exactly/exa#1058: Main changes implement a country denylist for the Bridge provider (adding Denylist, new ErrorCodes.DENYLISTED_COUNTRY, and related handling/tests), which directly addresses the "server: denylist bridge countries" requirement.

Possibly related PRs

  • exactly/exa#940: Both PRs modify server/utils/ramps/bridge.ts getProvider to change how availability/status is determined based on user or country conditions.
  • exactly/exa#897: Both PRs modify server/utils/ramps/bridge.ts onboarding behavior based on the persona countryCode.
  • exactly/exa#951: Both PRs modify getProvider flow in the same file, intersecting at onboarding/provider availability logic.

Suggested reviewers

  • nfmelendez
  • cruzdanilo
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: restricting bridge access by country through a denylist mechanism.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch denylist
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch denylist

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism to restrict bridge access by country, specifically denylisting Indonesia ("ID"). It updates the ramp API to return a 400 status code when a country is denylisted, handles this in the onboarding process, and adds corresponding unit tests. The review feedback suggests defensively normalizing the country code to uppercase before checking the denylist in both getProvider and onboarding functions to prevent potential case-sensitivity bypasses.

Comment thread server/utils/ramps/bridge.ts
Comment thread server/utils/ramps/bridge.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f16b75c3-5d35-4e0e-87fa-75b62e268d12

📥 Commits

Reviewing files that changed from the base of the PR and between 2096113 and 1a88c70.

📒 Files selected for processing (5)
  • .changeset/wary-falcon-guard.md
  • server/api/ramp.ts
  • server/test/api/ramp.test.ts
  • server/test/utils/bridge.test.ts
  • server/utils/ramps/bridge.ts

Comment thread server/utils/ramps/bridge.ts
@cruzdanilo
cruzdanilo marked this pull request as ready for review June 1, 2026 20:07

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a88c70669

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread server/utils/ramps/bridge.ts
@cruzdanilo
cruzdanilo merged commit 1a88c70 into main Jun 2, 2026
12 checks passed
@cruzdanilo
cruzdanilo deleted the denylist branch June 2, 2026 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants