feat(auth0): switch from cosmiconfig to configliere (#362)#363
feat(auth0): switch from cosmiconfig to configliere (#362)#363a-kriya wants to merge 1 commit intothefrontside:mainfrom
Conversation
commit: |
Package Changes Through 08812b3There are 4 changes which include @simulacrum/auth0-simulator with minor, @simulacrum/server with noop, @simulacrum/foundation-simulator with minor, @simulacrum/github-api-simulator with minor Planned Package VersionsThe following package releases are the planned based on the context of changes in this pull request.
Add another change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
|
@jbolda Will you be able to help test this, and make improvements. I can't login with the default user due to SSL errors even when setting |
|
Hmm, how are you testing it out? If it uses the auth0 libs, those tend to throw errors if they aren't pointing at https. Is that the error you are getting? That is why we had the instructions to use |
|
As a bit of a separate question, do you have some requirements that prevent you from installing a local dev-only cert? I was considering automating that process more, a few libs can help some with it, but it the ramifications of trying to do it automatically were unclear. |
|
Not really, Regardless, if you want to drop the third commit of this PR, please feel free. |
| debug: boolean, | ||
| ): Record<Routes, RequestHandler> => { | ||
| let { audience, scope, clientID, rulesDirectory } = options; | ||
| let { audience, scope, clientId, rulesDirectory } = options; |
There was a problem hiding this comment.
I think clientID was explicitly used as that aligns with Auth0 docs. Could we confirm that and maybe link it to their docs for future reference?
There was a problem hiding this comment.
The WebAuth instantiation in views/login.ts still specifies clientID, but using it as our config option was creating --client-i-d and CLIENT_I_D as the parameters.
There was a problem hiding this comment.
Ahhh I see. @cowboyd do we have a good way to deal with this?
| const envs = [{ name: "env", value: process.env as Record<string, string> }]; | ||
| const values = [{ name: "options", value: options }]; | ||
| const result = auth0Program.parse({ args, envs, values }); | ||
|
|
||
| if (!result.ok) throw result.error; | ||
|
|
||
| return result.value.config; |
There was a problem hiding this comment.
It looks like you have some good progress here. We will need to parse with a file as well. The inject is the new part of the API to help in handling it. This example that uses the newer inject which we will need to load a config file. After we have our parser, the return of that is effectively an object. That object is what we can pass directly to the auth0 simulator.
|
|
||
| export const simulation: Auth0Simulator = (args = {}) => { | ||
| const config = getConfig(args.options); | ||
| const config = getConfig(args.options, args.args); |
There was a problem hiding this comment.
The slight adjustment here is that we don't do the config handling here. args.options should just be passed all of the data that we get from config. We won't parse in this function as that should be complete by the time we call this function. I don't think it will create a breaking change as before and after we only have an object. This distinction though means we can do more advanced parsing and pass in the result here.
There was a problem hiding this comment.
How would start.cjs look? Would index.ts export getConfig which start.cjs will call and pass to simulation()?
There was a problem hiding this comment.
Yep! Or at least the config parser. getConfig() could probably be removed as you would want to handle commands and then call simulation only in some cases (instead of the early return that you have).

Motivation
Migrates from cosmiconfig to in-house configliere for parsing configuration options.
Adds a
protocolconfig option to allow users to choose serving overhttporhttps.