Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 11e068b

Browse files
kushalshit27ramya18101
andauthoredFeb 6, 2025··
new experimental ea command flag (#1027)
* feat: add experimental early access feature command * update documentation for experimental features and add logging instruction * update test: should dump tenant.yaml without defaults as AUTH0_EXPERIMENTAL_EA=false * Include new screens to support ACUL (#1028) Co-authored-by: Kushal <[email protected]> --------- Co-authored-by: Ramya Anusri <[email protected]>
1 parent 9766cb7 commit 11e068b

File tree

13 files changed

+377
-134
lines changed

13 files changed

+377
-134
lines changed
 

‎docs/using-as-cli.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Boolean. Enables more verbose error logging; useful during troubleshooting. Defa
3434

3535
A url for proxying requests. Only set this if you are behind a proxy.
3636

37+
### `--experimental_ea`
38+
39+
Boolean. When enabled, gain early access Auth0 resources support and experimental features. Default: `false`.
40+
3741
### Examples
3842

3943
```shell
@@ -71,6 +75,10 @@ A url for proxying requests. Only set this if you are behind a proxy.
7175

7276
Boolean. Enables more verbose error logging; useful during troubleshooting. Default: `false`.
7377

78+
### `--experimental_ea`
79+
80+
Boolean. When enabled, gain early access Auth0 resources support and experimental features. Default: `false`.
81+
7482
### Examples
7583

7684
```shell

‎src/args.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type SharedParams = {
99
secret?: string;
1010
base_path?: string; // Necessary when package imported as Node module
1111
config?: Partial<Config>;
12+
experimental_ea?: boolean;
1213
};
1314

1415
type ImportSpecificParams = {
@@ -43,6 +44,11 @@ function getParams(): CliParams {
4344
describe: 'A url for proxying requests, only set this if you are behind a proxy.',
4445
type: 'string',
4546
})
47+
.option('experimental_ea', {
48+
describe: 'This will enable supoort experimental early access of features/resource types.',
49+
type: 'boolean',
50+
default: false,
51+
})
4652
.command(['import', 'deploy'], 'Deploy Configuration', {
4753
input_file: {
4854
alias: 'i',

‎src/commands/export.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default async function exportCMD(params: ExportParams) {
1717
export_ids: exportIds,
1818
secret: clientSecret,
1919
env: shouldInheritEnv = false,
20+
experimental_ea: experimentalEA,
2021
} = params;
2122

2223
if (shouldInheritEnv) {
@@ -44,6 +45,14 @@ export default async function exportCMD(params: ExportParams) {
4445
overrides.AUTH0_EXPORT_IDENTIFIERS = exportIds;
4546
}
4647

48+
// Overrides AUTH0_INCLUDE_EXPERIMENTAL_EA is experimental_ea passed in command line
49+
if (experimentalEA) {
50+
overrides.AUTH0_EXPERIMENTAL_EA = experimentalEA;
51+
52+
// nconf.overrides() sometimes doesn't work, so we need to set it manually to ensure it's set
53+
nconf.set('AUTH0_EXPERIMENTAL_EA', experimentalEA);
54+
}
55+
4756
// Check output folder
4857
if (!isDirectory(outputFolder)) {
4958
log.info(`Creating ${outputFolder}`);

‎src/commands/import.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export default async function importCMD(params: ImportParams) {
1313
config: configObj,
1414
env: shouldInheritEnv = false,
1515
secret: clientSecret,
16+
experimental_ea: experimentalEA,
1617
} = params;
1718

1819
if (shouldInheritEnv) {
@@ -39,6 +40,14 @@ export default async function importCMD(params: ImportParams) {
3940
overrides.AUTH0_CLIENT_SECRET = clientSecret;
4041
}
4142

43+
// Overrides AUTH0_INCLUDE_EXPERIMENTAL_EA is experimental_ea passed in command line
44+
if (experimentalEA) {
45+
overrides.AUTH0_EXPERIMENTAL_EA = experimentalEA;
46+
47+
// nconf.overrides() sometimes doesn't work, so we need to set it manually to ensure it's set
48+
nconf.set('AUTH0_EXPERIMENTAL_EA', experimentalEA);
49+
}
50+
4251
nconf.overrides(overrides);
4352

4453
// Setup context and load

‎src/context/index.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const nonPrimitiveProps: (keyof Config)[] = [
2626
'INCLUDED_PROPS',
2727
];
2828

29+
const EA_FEATURES = ['ACUL'];
30+
2931
export const setupContext = async (
3032
config: Config,
3133
command: 'import' | 'export'
@@ -132,6 +134,23 @@ export const setupContext = async (
132134
}
133135
})(config);
134136

137+
((config: Config) => {
138+
// Check if experimental early access features are enabled
139+
if (config.AUTH0_EXPERIMENTAL_EA) {
140+
log.warn(
141+
`Experimental early access ${
142+
EA_FEATURES.length === 1
143+
? 'feature [' + EA_FEATURES.join('') + '] is'
144+
: 'features [' + EA_FEATURES.join(',') + '] are'
145+
} enabled. These are in a pre-release state and may change in future release.`
146+
);
147+
} else {
148+
log.info(
149+
'To enable experimental early access features use --experimental_ea flag or set AUTH0_EXPERIMENTAL_EA=true in configuration JSON.'
150+
);
151+
}
152+
})(config);
153+
135154
const accessToken = await (async (): Promise<string> => {
136155
const {
137156
AUTH0_DOMAIN,

‎src/tools/auth0/handlers/prompts.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,15 @@ export default class PromptsHandler extends DefaultHandler {
347347
partials,
348348
};
349349

350-
try {
351-
const screenRenderers = await this.getPromptScreenSettings();
352-
prompts.screenRenderers = screenRenderers;
353-
} catch (error) {
354-
log.warn(`Unable to fetch screen renderers: ${error}`);
350+
const includeExperimentalEA = this.config('AUTH0_EXPERIMENTAL_EA') || false;
351+
352+
if (includeExperimentalEA) {
353+
try {
354+
const screenRenderers = await this.getPromptScreenSettings();
355+
prompts.screenRenderers = screenRenderers;
356+
} catch (error) {
357+
log.warn(`Unable to fetch screen renderers: ${error}`);
358+
}
355359
}
356360

357361
return prompts;
@@ -527,8 +531,12 @@ export default class PromptsHandler extends DefaultHandler {
527531
await this.updateCustomTextSettings(customText);
528532
await this.updateCustomPromptsPartials(partials);
529533

530-
// Update screen renderers
531-
await this.updateScreenRenderers(screenRenderers);
534+
const includeExperimentalEA = this.config('AUTH0_EXPERIMENTAL_EA') || false;
535+
536+
if (includeExperimentalEA) {
537+
// Update screen renderers
538+
await this.updateScreenRenderers(screenRenderers);
539+
}
532540

533541
this.updated += 1;
534542
this.didUpdate(prompts);
@@ -608,7 +616,7 @@ export default class PromptsHandler extends DefaultHandler {
608616
} else {
609617
updatePayload = {
610618
...updatePrams,
611-
rendering_mode
619+
rendering_mode,
612620
};
613621
}
614622

‎src/tools/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ const constants = {
222222
'email-identifier-challenge': ['email-identifier-challenge'],
223223
passkeys: ['passkey-enrollment', 'passkey-enrollment-local'],
224224
captcha: ['interstitial-captcha'],
225+
login: ['login'],
226+
signup: ['signup'],
227+
'reset-password': ['reset-password-request', 'reset-password-email', 'reset-password', 'reset-password-success', 'reset-password-error'],
228+
225229
} as PromptScreenMapping,
226230
};
227231

‎src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export type Config = {
7878
AUTH0_EXCLUDED_CONNECTIONS?: string[];
7979
AUTH0_EXCLUDED_RESOURCE_SERVERS?: string[];
8080
AUTH0_EXCLUDED_DEFAULTS?: string[];
81+
AUTH0_EXPERIMENTAL_EA: boolean;
8182
}; // TODO: replace with a more accurate representation of the Config type
8283

8384
export type Asset = { [key: string]: any };

‎test/configFactory.test.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { expect } from 'chai';
2+
import { configFactory, ConfigFunction } from '../src/configFactory';
3+
import { Config } from '../src/types';
4+
5+
describe('configFactory', () => {
6+
let config: ReturnType<typeof configFactory>;
7+
8+
beforeEach(() => {
9+
config = configFactory();
10+
});
11+
12+
it('should set and get configuration values', () => {
13+
config.setValue('someKey' as keyof Config, 'someValue');
14+
expect(config('someKey' as keyof Config)).to.equal('someValue');
15+
});
16+
17+
it('should throw an error if no provider is set and key is not in settings', () => {
18+
expect(() => config('someKey' as keyof Config)).to.throw(
19+
'A configuration provider has not been set'
20+
);
21+
});
22+
23+
it('should use the provider function to get configuration values', () => {
24+
const providerFunction: ConfigFunction = (key) => {
25+
if ((key as string) === 'someKey') return 'providedValue';
26+
return null;
27+
};
28+
config.setProvider(providerFunction);
29+
expect(config('someKey' as keyof Config)).to.equal('providedValue');
30+
});
31+
32+
it('should prioritize settings over provider function', () => {
33+
config.setValue('someKey' as keyof Config, 'someValue');
34+
const providerFunction: ConfigFunction = (key) => {
35+
if ((key as string) === 'someKey') return 'providedValue';
36+
return null;
37+
};
38+
config.setProvider(providerFunction);
39+
expect(config('someKey' as keyof Config)).to.equal('someValue');
40+
});
41+
});

0 commit comments

Comments
 (0)