-
Notifications
You must be signed in to change notification settings - Fork 898
Commit
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,8 +51,16 @@ const ServerValue = Database.ServerValue; | |
* @param app A valid FirebaseApp-like object | ||
* @param url A valid Firebase databaseURL | ||
* @param version custom version e.g. firebase-admin version | ||
* @param thirdPartyAuth Whether to use third party auth for this client (`true` | ||
* for NodeJS users that use the client with end user credentials, `false` for | ||
* Firebase Admin) | ||
*/ | ||
export function initStandalone(app: FirebaseApp, url: string, version: string) { | ||
export function initStandalone( | ||
app: FirebaseApp, | ||
url: string, | ||
version: string, | ||
thirdPartyAuth = false | ||
) { | ||
/** | ||
* This should allow the firebase-admin package to provide a custom version | ||
* to the backend | ||
|
@@ -81,7 +89,12 @@ export function initStandalone(app: FirebaseApp, url: string, version: string) { | |
); | ||
|
||
return { | ||
instance: RepoManager.getInstance().databaseFromApp(app, authProvider, url), | ||
instance: RepoManager.getInstance().databaseFromApp( | ||
app, | ||
authProvider, | ||
url, | ||
thirdPartyAuth | ||
), | ||
namespace: { | ||
Reference, | ||
Query, | ||
|
@@ -112,7 +125,8 @@ export function registerDatabase(instance: FirebaseNamespace) { | |
return RepoManager.getInstance().databaseFromApp( | ||
app, | ||
authProvider, | ||
url | ||
url, | ||
/* thirdPartyAuth= */ true | ||
); | ||
}, | ||
ComponentType.PUBLIC | ||
|
@@ -136,7 +150,8 @@ export function registerDatabase(instance: FirebaseNamespace) { | |
instance.registerVersion(name, version, 'node'); | ||
|
||
if (isNodeSdk()) { | ||
module.exports = Object.assign({}, namespace, { initStandalone }); | ||
module.exports = (app: FirebaseApp, url: string, version: string) => | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
samtstern
Contributor
|
||
initStandalone(app, url, version, /* thirdPartyAuth= */ true); | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,10 +112,10 @@ export class FirebaseAuthTokenProvider implements AuthTokenProvider { | |
} | ||
} | ||
|
||
/* Auth token provider used to connect to the Emulator. */ | ||
export class EmptyAuthTokenProvider implements AuthTokenProvider { | ||
/* Auth token provider that the Admin SDK uses to connect to the Emulator. */ | ||
export class EmptyAdminAuthTokenProvider implements AuthTokenProvider { | ||
getToken(forceRefresh: boolean): Promise<FirebaseAuthTokenData> { | ||
return Promise.resolve({ accessToken: '' }); | ||
return Promise.resolve({ accessToken: 'Bearer owner' }); | ||
This comment has been minimized.
Sorry, something went wrong.
samtstern
Contributor
|
||
} | ||
addTokenChangeListener(listener: (token: string | null) => void): void {} | ||
removeTokenChangeListener(listener: (token: string | null) => void): void {} | ||
|
isNodeSdk()
is defined as:I think we want
thirdPartyAuth= !Constants.NODE_ADMIN
unless I am misunderstanding.