feat: OAuth bearer auth across all paths + removeBackground client (v1.2.0) - #9
Merged
Conversation
- add accessToken client configuration option - send Authorization: Bearer when accessToken is provided - keep existing x-api-key authentication unchanged - allow client initialization without an API key when using OAuth
…ints Add a top-level removeBackground client (c.removeBackground) that posts to /v1/remove-background and returns a transparent SVG, mirroring the convert/aiVectorize builder (configure/execute + stream). Complete OAuth bearer support for form-data endpoints: the earlier accessToken work only reached the JSON path (HttpClient.buildHeaders), so form-data requests (edit, convert, remove-background) still sent an empty x-api-key and no Authorization header over bearer. Add a shared BaseClient.buildAuthHeaders() (bearer when accessToken is set, else x-api-key) and use it in executeFormDataRequest and the streaming path, so all transports authenticate consistently. - add RemoveBackgroundClient + RemoveBackground types + core wiring/export - add BaseClient.buildAuthHeaders() and apply to form-data + stream paths - bump version to 1.2.0
The get() methods bypassed handleRequest() with a raw fetch that hardcoded x-api-key, so OAuth (Bearer) sessions sent no credential and got 401. Use buildAuthHeaders() to match the working list/download paths.
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.
Objective
Add OAuth Bearer access-token support to the SDK so it can authenticate via a JWT (
Authorization: Bearer) in addition tox-api-key. Also adds a newremoveBackgroundclient. Bumps to v1.2.0. Thex-api-keypath is unchanged.Changes
accessTokenconfig option; when set the SDK sendsAuthorization: Bearerinstead ofx-api-key. Completed it for form-data endpoints (edit,convert,remove-background) via a sharedBaseClient.buildAuthHeaders()— the initial work only covered the JSON path, so form-data requests failed over bearer.removeBackgroundclient.c.removeBackground.configure({ file, svgText, storage, stream }).execute()→ posts to/v1/remove-background, returns a transparent SVG. New types + core wiring + export.Verified end-to-end via the MCP server over both stdio (api-key) and HTTP (bearer). No breaking changes.