Skip to content

feat(auth): add builder-api-key management (create/fetch/revoke)#124

Open
naruto11eth wants to merge 5 commits into
mainfrom
feature/dev-153-builder-api-key
Open

feat(auth): add builder-api-key management (create/fetch/revoke)#124
naruto11eth wants to merge 5 commits into
mainfrom
feature/dev-153-builder-api-key

Conversation

@naruto11eth

@naruto11eth naruto11eth commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Ports the ts-sdk /auth/builder-api-key surface to the secure clients (DEV-153 / #51).

  • create_builder_api_key() / fetch_builder_api_keys() — authenticate as the account (L2 via secure_clob). create returns the BuilderApiKey credential; fetch returns BuilderApiKeyInfo records (key, created_at, revoked_at).
  • revoke_builder_api_key() — authenticated by the builder key's own HMAC (POLY_BUILDER_*), per ts-sdk#68 (working-as-intended), not account L2. Raises UserInputError unless the client holds the builder key to revoke.
  • Extracts a shared build_builder_key_headers so builder-key HMAC header construction has a single source of truth (the relayer resolvers now reuse it).

Sync + async parity. Unit tests cover the parsers and client methods, including a guardrail that revoke carries POLY_BUILDER_* and not account L2.

Naming: adds BuilderApiKeyInfo for the list record (additive — no breaking change); BuilderApiKey stays the credential. A pre-1.0 rename to mirror ts-sdk's BuilderApiKeyCreds/BuilderApiKey split is deferred.

Follow-up: a live @metered create→fetch→revoke round-trip (needs real builder credentials) is intentionally not included here — it's the only check that confirms the server's exact signed inputs.

Refs DEV-153, #51


Note

Medium Risk
Touches credential lifecycle and HMAC auth paths; revoke’s builder-key-only signing is security-sensitive but aligned with ts-sdk and covered by tests.

Overview
Adds /auth/builder-api-key support on sync and async secure clients: create and list use account L2 (secure_clob); revoke uses the builder key’s own POLY_BUILDER_* HMAC on clob, not L2, and raises UserInputError unless the client was created with that BuilderApiKey.

Introduces BuilderApiKeyInfo for list rows (key, created_at, revoked_at) and centralizes builder-key signing in build_builder_key_headers, reused by relayer resolvers and revoke. Response parsers and unit tests cover auth shapes and the revoke header guardrail.

Reviewed by Cursor Bugbot for commit 47dd173. Bugbot is set up for automated code reviews on this repo. Configure here.

Add `BuilderApiKeyInfo` (`key`, `created_at`, `revoked_at`) for the builder-api-key list endpoint and export it. The existing `BuilderApiKey` credential type is unchanged.
Lift the `POLY_BUILDER_*` header construction out of the two relayer resolvers into a single `build_builder_key_headers` so the builder-api-key revoke path can reuse it and the HMAC signing has one source of truth. No behavior change.
Add `create_builder_api_key` / `fetch_builder_api_keys` / `revoke_builder_api_key` (plus sync twins). create and fetch authenticate as the account via `secure_clob`; revoke is signed by the builder key's own HMAC, not account L2.
Expose create/fetch/revoke builder-api-key on the sync and async secure clients. `revoke_builder_api_key` raises `UserInputError` unless the client was created with the builder key to revoke.
Cover the builder-api-key parsers and client methods, including that revoke carries `POLY_BUILDER_*` (builder-key HMAC) and not account L2.
@naruto11eth naruto11eth requested a review from cesarenaldi June 26, 2026 23:28
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