-
Notifications
You must be signed in to change notification settings - Fork 938
Remove usage of the NODE_ADMIN global in RTDB #3736
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
Conversation
🦋 Changeset is good to goLatest commit: 6a0270a We got this. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Size Analysis ReportAffected Products
|
Type | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
size | ? | 8.90 kB | ? (?) |
size_with_ext_deps | ? | 17.3 kB | ? (?) |
Dependencies
Type | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
functions | ? | Click to show 52 depsbroadcastFidChange bufferToBase64UrlSafe callFidChangeCallbacks clearTimedOutRequest closeBroadcastChannel completeInstallationRegistration createInstallationRequest deleteInstallationRequest deleteInstallations encode extractAppConfig extractAuthTokenInfoFromResponse fetchAuthTokenFromServer fidChanged generateAuthTokenRequest generateFid getAuthorizationHeader getBroadcastChannel getDbPromise getDeleteEndpoint getErrorFromResponse getExpiresInFromResponseExpiresIn getGenerateAuthTokenEndpoint getHeaders getHeadersWithAuth getId getInstallationEntry getInstallationsEndpoint getKey getMissingValueError getToken hasAuthTokenRequestTimedOut hasInstallationRequestTimedOut isAuthTokenExpired isAuthTokenValid isEntryRegistered isServerError makeAuthTokenRequestInProgressEntry refreshAuthToken registerInstallation registerInstallations remove retryIfServerError set sleep triggerRegistrationIfNecessary update updateAuthTokenRequest updateInstallationRequest updateOrCreateInstallationEntry waitUntilAuthTokenRequest waitUntilFidRegistration |
? |
variables | ? | Click to show 23 depsDATABASE_NAME DATABASE_VERSION ERROR_DESCRIPTION_MAP ERROR_FACTORY INSTALLATIONS_API_URL INSTALLATIONS_NAME INSTALLATIONS_NAME_INTERNAL INTERNAL_AUTH_VERSION INVALID_FID OBJECT_STORE_NAME PACKAGE_VERSION PENDING_TIMEOUT_MS SERVICE SERVICE_NAME TOKEN_EXPIRATION_BUFFER VALID_FID_PATTERN broadcastChannel dbPromise fidChangeCallbacks internalFactory name publicFactory version |
? |
External Dependencies
Module | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
@firebase/util |
? | ErrorFactory FirebaseError |
? |
idb |
? | openDb |
? |
@firebase/app-exp |
? | _getProvider _registerComponent registerVersion |
? |
@firebase/component |
? | Component |
? |
getId
Size
Type | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
size | ? | 8.34 kB | ? (?) |
size_with_ext_deps | ? | 16.8 kB | ? (?) |
Dependencies
Type | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
functions | ? | Click to show 49 depsbroadcastFidChange bufferToBase64UrlSafe callFidChangeCallbacks clearTimedOutRequest closeBroadcastChannel completeInstallationRegistration createInstallationRequest encode extractAppConfig extractAuthTokenInfoFromResponse fetchAuthTokenFromServer fidChanged generateAuthTokenRequest generateFid getAuthorizationHeader getBroadcastChannel getDbPromise getErrorFromResponse getExpiresInFromResponseExpiresIn getGenerateAuthTokenEndpoint getHeaders getHeadersWithAuth getId getInstallationEntry getInstallationsEndpoint getKey getMissingValueError getToken hasAuthTokenRequestTimedOut hasInstallationRequestTimedOut isAuthTokenExpired isAuthTokenValid isEntryRegistered isServerError makeAuthTokenRequestInProgressEntry refreshAuthToken registerInstallation registerInstallations remove retryIfServerError set sleep triggerRegistrationIfNecessary update updateAuthTokenRequest updateInstallationRequest updateOrCreateInstallationEntry waitUntilAuthTokenRequest waitUntilFidRegistration |
? |
variables | ? | Click to show 23 depsDATABASE_NAME DATABASE_VERSION ERROR_DESCRIPTION_MAP ERROR_FACTORY INSTALLATIONS_API_URL INSTALLATIONS_NAME INSTALLATIONS_NAME_INTERNAL INTERNAL_AUTH_VERSION INVALID_FID OBJECT_STORE_NAME PACKAGE_VERSION PENDING_TIMEOUT_MS SERVICE SERVICE_NAME TOKEN_EXPIRATION_BUFFER VALID_FID_PATTERN broadcastChannel dbPromise fidChangeCallbacks internalFactory name publicFactory version |
? |
External Dependencies
Module | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
@firebase/util |
? | ErrorFactory FirebaseError |
? |
idb |
? | openDb |
? |
@firebase/app-exp |
? | _getProvider _registerComponent registerVersion |
? |
@firebase/component |
? | Component |
? |
getInstallations
Size
Type | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
size | ? | 8.43 kB | ? (?) |
size_with_ext_deps | ? | 16.9 kB | ? (?) |
Dependencies
Type | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
functions | ? | Click to show 50 depsbroadcastFidChange bufferToBase64UrlSafe callFidChangeCallbacks clearTimedOutRequest closeBroadcastChannel completeInstallationRegistration createInstallationRequest encode extractAppConfig extractAuthTokenInfoFromResponse fetchAuthTokenFromServer fidChanged generateAuthTokenRequest generateFid getAuthorizationHeader getBroadcastChannel getDbPromise getErrorFromResponse getExpiresInFromResponseExpiresIn getGenerateAuthTokenEndpoint getHeaders getHeadersWithAuth getId getInstallationEntry getInstallations getInstallationsEndpoint getKey getMissingValueError getToken hasAuthTokenRequestTimedOut hasInstallationRequestTimedOut isAuthTokenExpired isAuthTokenValid isEntryRegistered isServerError makeAuthTokenRequestInProgressEntry refreshAuthToken registerInstallation registerInstallations remove retryIfServerError set sleep triggerRegistrationIfNecessary update updateAuthTokenRequest updateInstallationRequest updateOrCreateInstallationEntry waitUntilAuthTokenRequest waitUntilFidRegistration |
? |
variables | ? | Click to show 23 depsDATABASE_NAME DATABASE_VERSION ERROR_DESCRIPTION_MAP ERROR_FACTORY INSTALLATIONS_API_URL INSTALLATIONS_NAME INSTALLATIONS_NAME_INTERNAL INTERNAL_AUTH_VERSION INVALID_FID OBJECT_STORE_NAME PACKAGE_VERSION PENDING_TIMEOUT_MS SERVICE SERVICE_NAME TOKEN_EXPIRATION_BUFFER VALID_FID_PATTERN broadcastChannel dbPromise fidChangeCallbacks internalFactory name publicFactory version |
? |
External Dependencies
Module | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
@firebase/util |
? | ErrorFactory FirebaseError |
? |
idb |
? | openDb |
? |
@firebase/app-exp |
? | _getProvider _registerComponent registerVersion |
? |
@firebase/component |
? | Component |
? |
getToken
Size
Type | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
size | ? | 8.35 kB | ? (?) |
size_with_ext_deps | ? | 16.8 kB | ? (?) |
Dependencies
Type | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
functions | ? | Click to show 49 depsbroadcastFidChange bufferToBase64UrlSafe callFidChangeCallbacks clearTimedOutRequest closeBroadcastChannel completeInstallationRegistration createInstallationRequest encode extractAppConfig extractAuthTokenInfoFromResponse fetchAuthTokenFromServer fidChanged generateAuthTokenRequest generateFid getAuthorizationHeader getBroadcastChannel getDbPromise getErrorFromResponse getExpiresInFromResponseExpiresIn getGenerateAuthTokenEndpoint getHeaders getHeadersWithAuth getId getInstallationEntry getInstallationsEndpoint getKey getMissingValueError getToken hasAuthTokenRequestTimedOut hasInstallationRequestTimedOut isAuthTokenExpired isAuthTokenValid isEntryRegistered isServerError makeAuthTokenRequestInProgressEntry refreshAuthToken registerInstallation registerInstallations remove retryIfServerError set sleep triggerRegistrationIfNecessary update updateAuthTokenRequest updateInstallationRequest updateOrCreateInstallationEntry waitUntilAuthTokenRequest waitUntilFidRegistration |
? |
variables | ? | Click to show 23 depsDATABASE_NAME DATABASE_VERSION ERROR_DESCRIPTION_MAP ERROR_FACTORY INSTALLATIONS_API_URL INSTALLATIONS_NAME INSTALLATIONS_NAME_INTERNAL INTERNAL_AUTH_VERSION INVALID_FID OBJECT_STORE_NAME PACKAGE_VERSION PENDING_TIMEOUT_MS SERVICE SERVICE_NAME TOKEN_EXPIRATION_BUFFER VALID_FID_PATTERN broadcastChannel dbPromise fidChangeCallbacks internalFactory name publicFactory version |
? |
External Dependencies
Module | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
@firebase/util |
? | ErrorFactory FirebaseError |
? |
idb |
? | openDb |
? |
@firebase/app-exp |
? | _getProvider _registerComponent registerVersion |
? |
@firebase/component |
? | Component |
? |
onIdChange
Size
Type | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
size | ? | 8.60 kB | ? (?) |
size_with_ext_deps | ? | 17.0 kB | ? (?) |
Dependencies
Type | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
functions | ? | Click to show 52 depsaddCallback broadcastFidChange bufferToBase64UrlSafe callFidChangeCallbacks clearTimedOutRequest closeBroadcastChannel completeInstallationRegistration createInstallationRequest encode extractAppConfig extractAuthTokenInfoFromResponse fetchAuthTokenFromServer fidChanged generateAuthTokenRequest generateFid getAuthorizationHeader getBroadcastChannel getDbPromise getErrorFromResponse getExpiresInFromResponseExpiresIn getGenerateAuthTokenEndpoint getHeaders getHeadersWithAuth getId getInstallationEntry getInstallationsEndpoint getKey getMissingValueError getToken hasAuthTokenRequestTimedOut hasInstallationRequestTimedOut isAuthTokenExpired isAuthTokenValid isEntryRegistered isServerError makeAuthTokenRequestInProgressEntry onIdChange refreshAuthToken registerInstallation registerInstallations remove removeCallback retryIfServerError set sleep triggerRegistrationIfNecessary update updateAuthTokenRequest updateInstallationRequest updateOrCreateInstallationEntry waitUntilAuthTokenRequest waitUntilFidRegistration |
? |
variables | ? | Click to show 23 depsDATABASE_NAME DATABASE_VERSION ERROR_DESCRIPTION_MAP ERROR_FACTORY INSTALLATIONS_API_URL INSTALLATIONS_NAME INSTALLATIONS_NAME_INTERNAL INTERNAL_AUTH_VERSION INVALID_FID OBJECT_STORE_NAME PACKAGE_VERSION PENDING_TIMEOUT_MS SERVICE SERVICE_NAME TOKEN_EXPIRATION_BUFFER VALID_FID_PATTERN broadcastChannel dbPromise fidChangeCallbacks internalFactory name publicFactory version |
? |
External Dependencies
Module | Base (d90ddd7) | Head (fb1f1e2) | Diff |
---|---|---|---|
@firebase/util |
? | ErrorFactory FirebaseError |
? |
idb |
? | openDb |
? |
@firebase/app-exp |
? | _getProvider _registerComponent registerVersion |
? |
@firebase/component |
? | Component |
? |
Test Logs
/** | ||
* This should allow the firebase-admin package to provide a custom version | ||
* to the backend | ||
*/ | ||
CONSTANTS.NODE_ADMIN = true; | ||
CONSTANTS.NODE_ADMIN = nodeAdmin; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove this constant since RTDB is the only consumer of it. If any other JS SDKs were used by the admin SDK in the future, they should not rely on this constant either.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should hold off on this. firebase-admin
does not pin its dependency against @firebase/database
, so we can only remove this in a major version bump to avoid breaking customers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I think I misunderstood -- this is all internal in this package and utils
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Feiyang1 so I still want isNodeSdk()
to work ... where does NODE_ADMIN
actually come from when it's not set in initStandalone
? Is it set in part of the build process?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It defaults to false
unless set by initStandalone
. https://github.com/firebase/firebase-js-sdk/blob/master/packages/util/src/constants.ts#L30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not comfortable removing this at the moment ... it's used within isNodeSdk()
which is used in many places including one place where module.exports
is redefined. I think removing this is likely to break something I don't understand. Maybe someone from JSCore feels confident enough to do it as a follow up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The check for CONSTANTS.NODE_ADMIN is unnecessary in isNodeSdk()
because CONSTANTS.NODE_CLIENT
will be always true when CONSTANTS.NODE_ADMIN
is true. Sure, I will do a follow up PR for this.
@schmidt-sebastian I need your codeowners review on this! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically LGTM, though I wonder if we can simplify this a bit: https://gist.github.com/schmidt-sebastian/08c74a0160809165fed81e31088cf8ce
If not, we can merge as is.
Binary Size ReportAffected SDKs
Test Logs |
@hsubox76 says I can merge over this error, so merging! |
Discussion
The
NODE_ADMIN
global means that the RTDB Admin and Client SDKs cannot coexist, whichever is initialized first will control the behavior.This is a problem for testing, where clients want to use the Admin SDK to do privileged actions but then test the behavior of the Client SDK with low privileges.
Testing
rules-unit-testing
API Changes
N/A