Skip to content

Add null to databaseAuthVariableOverride #926

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2020

Conversation

MathBunny
Copy link
Contributor

I noticed that the databaseAuthVariableOverride does not accept null in the source:

export interface FirebaseAppOptions {
credential?: Credential;
databaseAuthVariableOverride?: object;
databaseURL?: string;
serviceAccountId?: string;
storageBucket?: string;
projectId?: string;
httpAgent?: Agent;
}

Meanwhile, in typings it accepts null:

credential?: admin.credential.Credential;
/**
* The object to use as the [`auth`](/docs/reference/security/database/#auth)
* variable in your Realtime Database Rules when the Admin SDK reads from or
* writes to the Realtime Database. This allows you to downscope the Admin SDK
* from its default full read and write privileges.
*
* You can pass `null` to act as an unauthenticated client.
*
* See
* [Authenticate with limited privileges](/docs/database/admin/start#authenticate-with-limited-privileges)
* for detailed documentation and code samples.
*/
databaseAuthVariableOverride?: Object | null;
/**
* The URL of the Realtime Database from which to read and write data.
*/
databaseURL?: string;
/**
* The ID of the service account to be used for signing custom tokens. This
* can be found in the `client_email` field of a service account JSON file.
*/
serviceAccountId?: string;

Another observation is object vs Object discrepancy, from my understanding object is generally preferred but I don't know if it's safe or worth changing the typings for this.

@MathBunny MathBunny self-assigned this Jul 3, 2020
@lahirumaramba
Copy link
Member

It makes sense to me. I am adding @rsgowman for his input as the null checks were added as part of #676

I think you are right. We probably should use object instead of Object. I see multiple places where we have used Object in code :)
https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html

Copy link
Member

@rsgowman rsgowman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks right to me; I'm sure I just missed adding the | null when I did that earlier PR. (Thanks!)

Re Object vs object: I also agree that we should be using object. It's a real easy mistake to make; I certainly didn't notice the discrepancy when working on #676 and it's a safe bet that the original author (and reviewer) didn't intend for this difference either.

I don't know the implications re api change though. It's worth running that by Hiranya. Either way, I'd lean towards submitting this as is and doing a separate PR for the s/Object/object change. (Lahiru, I'll let you and Hiranya work out the best path forward for that.)

@rsgowman rsgowman removed their assignment Jul 6, 2020
@lahirumaramba
Copy link
Member

Thank you, @rsgowman !

Copy link
Member

@lahirumaramba lahirumaramba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @MathBunny! LGTM!

@hiranya911
Copy link
Contributor

@schmidt-sebastian can you also take a quick look?

Copy link
Contributor

@hiranya911 hiranya911 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hiranya911 hiranya911 removed their assignment Jul 6, 2020
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MathBunny
Copy link
Contributor Author

Thanks @schmidt-sebastian - will merge this now and then will discuss with Hiranya and Lahiru next steps for the Object vs object discrepancy in another PR.

@MathBunny MathBunny merged commit c93893b into master Jul 6, 2020
@hiranya911 hiranya911 assigned MathBunny and unassigned hiranya911 Jul 6, 2020
@MathBunny MathBunny deleted the hlazu-db-auth-variable-override branch July 13, 2020 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants