thefrontside / simulacrum

A simulation platform for use during testing, during development and for high-fidelity application previews
88 stars 14 forks source link

Add Cosmiconfig and zod to @simulacrum/auth0-config #190

Closed dagda1 closed 2 years ago

dagda1 commented 2 years ago

Motivation

This is the next step in the evolution of getting the auth0-simulator to start from 1 command.

This PR makes it possible to start the simulator and also supply a username and password for a user who can authenticate:

npx @simulacrum/auth0-simulator --standalone --username=admin@org.com --password=Passw0rd

We still have the ssl problem and mkcert but this makes it easier.

Approach

You can add config to any of the things cosmiconfig supports like the package.json file:

,
  "auth0Simulator": {
    "domain": "localhost:4400",
    "clientID": "00000000000000000000000000000000",
    "audience": "https://thefrontside.auth0.com/api/v1/",
    "scope": "openid profile email offline_access",
    "rulesDirectory": "__mocks__/rules"
  }

I've also added some basic validation using zod in the auth0 types.

I've added --standalone, '--username' and '--password` switches to the auth0-simulator bin script. I'll update the README when the approach is agreed.

Screenshots

https://user-images.githubusercontent.com/118328/160128199-08efd3e8-4159-4ee0-a1b2-8594f77e2106.mp4

netlify[bot] commented 2 years ago

Deploy Preview for simulacrum canceled.

Name Link
Latest commit 21b18feb0dee4fa91fa0a6251fcaa6ea00d98890
Latest deploy log https://app.netlify.com/sites/simulacrum/deploys/623dc52ecaba7d00087e4a82