Open
Conversation
Contributor
|
@cwheikki is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
Add @emulators/auth0 package with:
- OAuth token endpoint (client_credentials, password-realm, refresh_token)
- Management API v2 (user CRUD, email verification tickets)
- OIDC discovery and JWKS (RS256)
- Log event streaming (ss, fs, sv, scp) via webhooks
- Deterministic signing key support for static JWT validation
- Tabbed inspector UI (Users, Log Events, OAuth Clients, Connections)
- 42 unit tests
Error responses match Auth0's actual API formats: OAuth2 format for the
Authentication API and Auth0's { statusCode, error, message, errorCode }
for the Management API.
Also passes webhooks through to seedFromConfig across all emulators
(optional parameter, backward-compatible) to enable log stream subscriber
registration from seed config.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1ee4138 to
371b166
Compare
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.
I had attempted this a few years ago but with this project and modern tooling its much more effective now. This PR adds an emulator for the Auth0 APIs required to register, validate, and login as real user. This is now a working replacement for a live integration we have and it was as much of a drop-in replacement as you can get.
Summary
Add
@emulators/auth0package with Auth0 Authentication API, Management API v2, and OIDC emulation. Covers the OAuth token endpoint (client_credentials, password-realm, refresh_token), user CRUD, email verification tickets, and log event streaming via webhooks. Includes a tabbed inspector UI.Why this matters
Testing Auth0 registration, login, and token flows currently requires hitting real Auth0 tenants (rate-limited, costs money, unreliable in CI) or mocking at the HTTP level. No existing emulator covers Auth0's Management API or its
password-realmgrant type (an Auth0 extension to OAuth2 that routes login to a named database connection).With this emulator, the full identity flow can run locally: user registration (Management API) -> login (password-realm grant) -> token refresh -> email verification -> log event webhooks. All without network access.
Changes
New package:
@emulators/auth0Authentication API (
/oauth/token):grant_type=client_credentialsfor Management API tokensgrant_type=http://auth0.com/oauth/grant-type/password-realmfor user login (returns access_token, refresh_token, id_token JWT)grant_type=refresh_tokenfor token renewal/oauth/revoketo revoke refresh tokens/userinfofor authenticated user profileManagement API v2:
/api/v2/usersto create users with email, password, connection, app_metadata/api/v2/users/:idto fetch a user/api/v2/users-by-emailto search by email/api/v2/users/:idto update user fields (including password, app_metadata merge)/api/v2/tickets/email-verificationto create verification tickets/tickets/email-verificationto consume a ticket (marks email as verified)OIDC Discovery:
/.well-known/openid-configuration/.well-known/jwks.json(RS256 key pair)/_emulate/public-key.pem(RSA public key in PEM format)Deterministic Signing Key:
signing_keyin seed config to provide a known RSA key pair for static JWT validationkidsupported, defaults toemulate-auth0-1Log Event Streaming:
ss,fs,sv,scp) via webhook on user creation, signup failure, email verification, and password changelog_id,date,type,user_id,user_name,client_id,client_name,connection,strategy,strategy_type,description)log_streamsin seed configInspector UI (
/):renderInspectorPageError responses:
{ error, error_description }){ statusCode, error, message, errorCode })Seed config
Changes outside
@emulators/auth0Registry and CLI wiring (standard for any new service):
packages/emulate/src/registry.ts: addedauth0toSERVICE_NAME_LISTandSERVICE_REGISTRYpackages/emulate/package.json: added@emulators/auth0workspace dependencyseedFromConfigwebhooks passthrough (needed for log stream subscriber registration):packages/emulate/src/registry.ts: widenedLoadedService.seedFromConfigsignature to accept an optional 4thwebhooksparameterpackages/emulate/src/commands/start.tsandapi.ts: destructurewebhooksfromcreateServer()(already returned, previously unused) and pass it through toseedFromConfigThe
webhooksparameter is optional, so all 12 existing emulators are unaffected — theirseedFromConfigfunctions ignore the extra argument. Verified by running the full monorepopnpm buildandpnpm lintwith no failures.Root
README.md: updated port listing (all 13 services), added Auth0 endpoint section, Auth section, and architecture tree entry. Also updated the service name list in the programmatic API options table. The port listing was previously stale (only 7 of 13 services listed) — this PR brings it current.Testing
42 unit tests covering all endpoints, error response formats, log event dispatch, signing key configuration (deterministic and auto-generated), and edge cases (invalid PEM, half-configured keys, missing
offline_accessscope, blocked users). All pass againstpnpm test,pnpm type-check,pnpm format:check, andpnpm lint.Every endpoint was also manually tested against the running emulator via curl and an interactive browser-based test harness that exercises all API flows with inline assertions and a live log event stream.
Demo
auth0-emulator-demo.mp4