- Notifications
You must be signed in to change notification settings - Fork410
fix(rtdb): Apply fake credentials when getting rules for rtdb emulator#3028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -196,7 +196,7 @@ const RULES_URL_PATH = '.settings/rules.json'; | ||
| class DatabaseRulesClient { | ||
| private readonly dbUrl: string; | ||
| private readonly httpClient:DatabaseRulesHttpClient; | ||
| constructor(app: App, dbUrl: string) { | ||
| let parsedUrl = new URL(dbUrl); | ||
| @@ -208,7 +208,7 @@ class DatabaseRulesClient { | ||
| parsedUrl.pathname = path.join(parsedUrl.pathname, RULES_URL_PATH); | ||
| this.dbUrl = parsedUrl.toString(); | ||
| this.httpClient = newDatabaseRulesHttpClient(app as FirebaseApp); | ||
| } | ||
| /** | ||
| @@ -316,6 +316,16 @@ class DatabaseRulesClient { | ||
| } | ||
| } | ||
| class DatabaseRulesHttpClient extends AuthorizedHttpClient { | ||
| protected getToken(): Promise<string> { | ||
| const emulatorHost = process.env.FIREBASE_DATABASE_EMULATOR_HOST; | ||
| if (emulatorHost) { | ||
| return Promise.resolve('owner'); | ||
| } | ||
| return super.getToken(); | ||
| } | ||
| } | ||
Comment on lines +319 to +327 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. To improve readability and maintainability, it's a good practice to avoid magic strings. Consider defining classDatabaseRulesHttpClientextendsAuthorizedHttpClient{privatestaticreadonlyEMULATOR_AUTH_TOKEN='owner';protectedgetToken():Promise<string>{constemulatorHost=process.env.FIREBASE_DATABASE_EMULATOR_HOST;if(emulatorHost){returnPromise.resolve(DatabaseRulesHttpClient.EMULATOR_AUTH_TOKEN);}returnsuper.getToken();}} | ||
| function extractNamespace(parsedUrl: URL): string { | ||
| const ns = parsedUrl.searchParams.get('ns'); | ||
| if (ns) { | ||