chore(frontend): two buy buttons — unsigned vs signed OnRamper URL (demo, not for merge)#13138
Draft
sbpublic wants to merge 8 commits into
Draft
chore(frontend): two buy buttons — unsigned vs signed OnRamper URL (demo, not for merge)#13138sbpublic wants to merge 8 commits into
sbpublic wants to merge 8 commits into
Conversation
Demo branch (not for merge): drop the backend `signOnramperWidgetUrl` round-trip and the `&signature=` suffix so the widget URL can be composed entirely on the frontend, without provisioning the signing secret. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Demo branch (not for merge): build the iframe src synchronously now that `buildOnramperLink` no longer awaits the backend, and drop the now-dead signing-failure fallback path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Demo branch (not for merge): drop the runtime `onramper_enabled` backend check (which requires the signing secret) so the widget opens on staging from the build-time ONRAMPER_ENABLED flag alone, with no backend dependency. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…builder Demo branch (not for merge): restore the production signed `buildOnramperLink` (backend HMAC + `&signature=`) and add `buildUnsignedOnramperLink` for the frontend-only variant, sharing a private `composeOnramperUrl` helper. This lets the two buy buttons pick signed vs unsigned at call time. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Demo branch (not for merge): a `signed` prop chooses between the async backend-signed URL (with the signing-failure notice fallback) and the synchronous unsigned URL. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Demo branch (not for merge): render two buy buttons — the default "Buy" opens the widget with the unsigned URL, "Buy S" opens it with the production signed URL. The chosen mode is threaded through BuyModal and BuyModalContent into the widget. BuyButton gains optional label/testId overrides for the second button. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Demo branch (not for merge): the backend gate moved into the widget, so the content tests now assert unsigned mode renders the iframe without any backend call, signed mode renders it once signing succeeds, and signed mode falls back to the unavailable notice when signing fails. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Demo branch (not for merge): set ONRAMPER_ENABLED to always-true (was `LOCAL || STAGING`) so the buy widget is enabled on beta too and this demo can be deployed there. Kept as `true as boolean` so the flag stays mockable in tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Motivation
On staging the Buy button shows "Buying tokens is temporarily unavailable … while we further improve the security of this process by introducing URL signing." even though the build-time
ONRAMPER_ENABLEDflag is on. The widget is additionally gated by a runtime backend check (onramper_enabled), which only returnstrueonce a controller has provisioned theonramper_signing_secreton the backend canister. Until that secret exists, the widget stays hidden.This branch lets us exercise the OnRamper widget (on staging or beta) before the signing secret is provisioned, and to compare the two URL flows side by side.
Changes
Two buy buttons are rendered where there was one:
Implementation:
onramper.env.ts:ONRAMPER_ENABLEDis forced to always-true (wasLOCAL || STAGING) so the widget is enabled on beta and production too — required to deploy this demo to beta.onramper.utils.ts: keeps the production signedbuildOnramperLink(backend HMAC +&signature=<hex>) and addsbuildUnsignedOnramperLinkfor the frontend-only variant; both share a privatecomposeOnramperUrlhelper.OnramperWidget.svelte: asignedprop selects between the async backend-signed URL (with the signing-failure notice fallback) and the synchronous unsigned URL.BuyModalContent.svelte/BuyModal.svelte: forward thesignedflag from the button to the widget. The build-timeONRAMPER_ENABLEDflag still gates the modal; the runtimeonramper_enabledbackend pre-check is dropped (signed mode now surfaces signing failures inside the widget instead).Buy.svelte/BuyButton.svelte: render the two buttons;BuyButtongains optionalbuttonLabel/testIdoverrides so "Buy S" is distinct.Tests
npm run format,npm run lint -- --max-warnings 0andnpm run checkpass for the changed source files. (The unrelated pre-existingsvelte-checkerrors insol/btc/ic-pub-keymodules come from localnode_modulesversion skew and are not from this branch.)onramper.utils.spec.tspasses (the signed builder is unchanged from production).BuyModalContent.spec.tswas updated to the two-mode behavior: unsigned mode renders the iframe without calling the backend, signed mode renders it once signing succeeds, and signed mode falls back to the unavailable notice when signing fails. Affected suites: 37 tests green (onramper.utils,BuyModalContent,BuyButton, heroActions).Invalid Signature) since April 2025, so the "Buy" (unsigned) button may show an error inside the iframe. The point is that the widget opens with the full composed URL, not that OnRamper accepts it. On a backend without the signing secret, "Buy S" will show the unavailable notice (signing fails) — the same behavior as production today.https://buy.onramper.comwith the prod API key (VITE_ONRAMPER_API_KEY_PROD), not the dev endpoint used on staging.🤖 Generated with Claude Code — model: Claude Opus 4.8 (claude-opus-4-8)