Skip to content

Fix critical auth: send access-token header instead of Authorization: Bearer#9

Merged
pimfeltkamp merged 2 commits intomainfrom
fix-auth-header-access-token
Apr 28, 2026
Merged

Fix critical auth: send access-token header instead of Authorization: Bearer#9
pimfeltkamp merged 2 commits intomainfrom
fix-auth-header-access-token

Conversation

@pimfeltkamp
Copy link
Copy Markdown
Contributor

Summary

Critical bug: every authenticated request currently fails. The transport sends Authorization: Bearer <token>, which the AWS API Gateway in front of api.cryptohopper.com/v1/* rejects (it routes Authorization to a SigV4 parser and returns 405 Missing Authentication Token).

Cryptohopper's Public API v1 uses access-token: <token>. Switching the SDK to send that header instead.

Why this slipped through

  • Local docs in cryptohopper-resources/docs/api/authentication.md and getting-started.md say "Authorization: Bearer" — they're wrong; the live docs at https://www.cryptohopper.com/api-documentation/how-the-api-works are authoritative ("access-token - Your access token received with the Oauth2 authentication").
  • Tests use mocks (createMockFetch), so the wrong header never hit a real gateway.
  • No e2e smoke test in CI.

Confirmation from prior art

Source Header used
cryptohopper.com Public API docs access-token
cryptohopper-ios-sdk HopperAPIRequest.swift:248 access-token (for v1 calls; Bearer only for the V2 admin API)
cryptohopper-android-sdk HopperAPIRequest.kt:331 access-token (same v1/v2 split)
code-samples/curl/README.md -H "access-token: [ACCESS TOKEN]"

Changes

  • src/client.ts:160 — single line: Authorization: Bearer ${this.apiKey}"access-token": this.apiKey. Comment explains why.
  • test/client.test.ts:20 — assertion updated to check access-token header is set and authorization is unset.
  • CHANGELOG.md0.4.0-alpha.2 entry under "Fixed" with full root-cause writeup.
  • src/version.ts + package.json bumped to 0.4.0-alpha.2.

Compatibility

No public-API change. The fix is purely in the request-builder. Every consumer call (client.user.get(), client.hoppers.list(), etc.) keeps its existing signature and behaviour. Only the wire-level header changes.

Test plan

  • npm test — 67/67 pass (was 67/67 before).
  • npm run typecheck — clean.
  • npm run build — clean.
  • (manual, for reviewer) CRYPTOHOPPER_TOKEN=<real-token> npx tsx examples/whoami.ts should now succeed where it would have 405'd before.

Cross-reference

  • Tracking issue: cryptohopper-resources#9. Sister PRs landing for Python/Go/Ruby/Rust/PHP/Dart/Swift in this same iter. Resources docs + wiki sweep follow.

Critical: every authenticated request was being rejected by the
AWS API Gateway in front of api.cryptohopper.com/v1/*. The gateway
routes the `Authorization` header into a SigV4 parser and returns
`405 Missing Authentication Token` — there's no Bearer-token authz
on these routes.

Cryptohopper's Public API v1 uses `access-token: <token>` instead.
Confirmed by:
  - https://www.cryptohopper.com/api-documentation/how-the-api-works
    explicitly says: 'access-token - Your access token received with
    the Oauth2 authentication'
  - cryptohopper-ios-sdk/Cryptohopper-iOS-SDK/SharedModels/ConfigModels/
    HopperAPIRequest.swift:248 sends `access-token` for v1 calls
    (and `Authorization: Bearer` only for the V2 admin API)
  - cryptohopper-android-sdk/sdk/src/.../HopperAPIRequest.kt:331 same
  - cryptohopper/code-samples/curl/README.md uses
    `-H "access-token: [ACCESS TOKEN]"`

Bump to 0.4.0-alpha.2. No public-API change — `client.user.get()`,
`client.hoppers.list()`, etc. keep their signatures. Only the
wire-level header sent on each request changes. Test suite updated
to assert the new header; 67/67 pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The Exchange and Marketplace sections claimed those endpoints
accepted anonymous calls. The auth-header fix in this PR establishes
that EVERY endpoint on api.cryptohopper.com/v1/* requires a real
token (the AWS API Gateway has no anonymous routes), so the README
labels were misleading. Replaces them with comments that match
reality.
@pimfeltkamp
Copy link
Copy Markdown
Contributor Author

Pushed a small follow-up commit (Drop ... README claim ...) that strikes the matching (public, no auth) / (public — no auth required) claim from the README. Same bug surface as this PR — the auth fix establishes that every endpoint requires a real token, so the README label was misleading. No re-review needed beyond skimming the +1/-1 (or +2/-2) README diff.

@pimfeltkamp pimfeltkamp merged commit 3d628cf into main Apr 28, 2026
1 check passed
pimfeltkamp added a commit to cryptohopper/cryptohopper-cli that referenced this pull request Apr 28, 2026
* Bump @cryptohopper/sdk to ^0.4.0-alpha.2 (auth header fix)

The CLI's underlying SDK sent Authorization: Bearer <token>
which the AWS API Gateway rejects on api.cryptohopper.com/v1/*
(returns 405 Missing Authentication Token). The fix in
@cryptohopper/sdk@0.4.0-alpha.2 switches to access-token: <token>.

This PR picks up that fix and bumps the CLI to 0.6.0-alpha.2.
No CLI surface change.

Blocked on: cryptohopper/cryptohopper-node-sdk#9 (must merge and
publish to npm before this CLI release can install the new SDK).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Drop 'public ticker (no auth)' README claim (matches the dep bump)

The Quickstart claimed 'cryptohopper ticker' worked without
authentication. The auth-header fix in the underlying SDK
(@cryptohopper/sdk@0.4.0-alpha.2, picked up by this PR's dep
bump) establishes that EVERY endpoint requires a real token.
The CLI inherits that — every subcommand including 'ticker'
needs you to have run 'cryptohopper login' first.

* Regenerate package-lock.json for @cryptohopper/sdk@0.4.0-alpha.2

The original PR bumped package.json's caret to ^0.4.0-alpha.2 but
left the lockfile pinning the older 0.4.0-alpha.1, causing `npm ci`
in CI to fail with EUSAGE (manifest/lockfile mismatch).

Now that 0.4.0-alpha.2 is published to npm (it landed earlier today),
`npm install` resolves the new version cleanly. Lockfile entry now
records:

  node_modules/@cryptohopper/sdk: 0.4.0-alpha.2

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-authored-by: Pim Feltkamp <pimfeltkamp@gmail.com>
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.

1 participant