@dereekb/dbx-firebase 5.2.1 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/lib/auth/auth.mjs +8 -1
- package/esm2020/lib/auth/service/firebase.auth.service.delegate.mjs +22 -0
- package/esm2020/lib/auth/service/firebase.auth.service.mjs +44 -4
- package/esm2020/lib/auth/service/index.mjs +2 -1
- package/esm2020/lib/firebase/firebase.module.mjs +3 -3
- package/esm2020/lib/model/store/index.mjs +2 -1
- package/esm2020/lib/model/store/store.document.crud.mjs +43 -0
- package/esm2020/lib/model/store/store.document.mjs +26 -10
- package/esm2020/lib/model/store/store.subcollection.document.mjs +1 -1
- package/esm2020/lib/model/store/store.subcollection.rxjs.mjs +1 -1
- package/fesm2015/dereekb-dbx-firebase.mjs +141 -24
- package/fesm2015/dereekb-dbx-firebase.mjs.map +1 -1
- package/fesm2020/dereekb-dbx-firebase.mjs +145 -24
- package/fesm2020/dereekb-dbx-firebase.mjs.map +1 -1
- package/lib/auth/auth.d.ts +2 -0
- package/lib/auth/service/firebase.auth.service.d.ts +19 -1
- package/lib/auth/service/firebase.auth.service.delegate.d.ts +13 -0
- package/lib/auth/service/index.d.ts +1 -0
- package/lib/model/store/index.d.ts +1 -0
- package/lib/model/store/store.document.crud.d.ts +27 -0
- package/lib/model/store/store.document.d.ts +39 -11
- package/lib/model/store/store.subcollection.document.d.ts +3 -3
- package/package.json +6 -6
|
@@ -20,4 +20,4 @@ export function setParentStoreEffect(store) {
|
|
|
20
20
|
}));
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
23
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RvcmUuc3ViY29sbGVjdGlvbi5yeGpzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2F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ithoutParameters, addToSet, removeFromSet, filterMaybeValues, mapIterable, asArray, excludeValuesFromArray, containsStringAnyCase, forEachKeyValue, readableError, isMaybeSo } from '@dereekb/util';
|
|
1
|
+
import { urlWithoutParameters, cachedGetter, addToSet, removeFromSet, filterMaybeValues, mapIterable, asArray, excludeValuesFromArray, containsStringAnyCase, addToSetCopy, forEachKeyValue, readableError, isMaybeSo, firstValue } from '@dereekb/util';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { InjectionToken, Injectable, Inject, Optional, Component, Input, Directive, EventEmitter, Output, NgModule, Injector, forwardRef, Host } from '@angular/core';
|
|
4
4
|
import { getToken, initializeAppCheck, ReCaptchaV3Provider } from 'firebase/app-check';
|
|
5
|
-
import { switchMap, from, first, map, of, shareReplay, timeout, startWith, distinctUntilChanged, BehaviorSubject, combineLatest, tap,
|
|
5
|
+
import { switchMap, from, first, map, of, shareReplay, timeout, startWith, distinctUntilChanged, firstValueFrom, BehaviorSubject, combineLatest, tap, Subject, throttleTime, NEVER, filter, take, exhaustMap } from 'rxjs';
|
|
6
6
|
import * as i1 from '@angular/fire/app-check';
|
|
7
7
|
import { provideAppCheck } from '@angular/fire/app-check';
|
|
8
8
|
import * as i4 from '@angular/material/button';
|
|
@@ -15,7 +15,7 @@ import * as i3 from '@dereekb/dbx-web';
|
|
|
15
15
|
import { DbxRouterAnchorModule, DbxReadableErrorModule, DbxActionModule, DbxButtonModule } from '@dereekb/dbx-web';
|
|
16
16
|
import * as i3$1 from '@dereekb/dbx-core';
|
|
17
17
|
import { loggedInObsFromIsLoggedIn, loggedOutObsFromIsLoggedIn, authUserIdentifier, DbxInjectionContext, AbstractForwardDbxInjectionContextDirective, DBX_INJECTION_COMPONENT_DATA, DbxInjectionComponentModule, DbxAuthService, AbstractSubscriptionDirective, AbstractIfDirective, LockSetComponentStore } from '@dereekb/dbx-core';
|
|
18
|
-
import { filterMaybe, isNot, SubscriptionObject, cleanupDestroyable, accumulatorFlattenPageListLoadingState, useFirst, successResult, beginLoading, loadingStateFromObs, errorResult, cleanup } from '@dereekb/rxjs';
|
|
18
|
+
import { filterMaybe, isNot, SubscriptionObject, cleanupDestroyable, accumulatorFlattenPageListLoadingState, useFirst, successResult, beginLoading, loadingStateFromObs, errorResult, lazyFrom, cleanup } from '@dereekb/rxjs';
|
|
19
19
|
import * as i1$1 from '@angular/fire/auth';
|
|
20
20
|
import { authState, GoogleAuthProvider, FacebookAuthProvider, TwitterAuthProvider, GithubAuthProvider, signInWithPopup, createUserWithEmailAndPassword, signInWithEmailAndPassword, signInAnonymously, provideAuth, getAuth, connectAuthEmulator } from '@angular/fire/auth';
|
|
21
21
|
import { sendPasswordResetEmail } from 'firebase/auth';
|
|
@@ -121,6 +121,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
121
121
|
}] }, { type: i1.AppCheck }];
|
|
122
122
|
} });
|
|
123
123
|
|
|
124
|
+
function authUserInfoFromAuthUser(user) {
|
|
125
|
+
return {
|
|
126
|
+
displayName: user === null || user === void 0 ? void 0 : user.displayName,
|
|
127
|
+
email: user.email,
|
|
128
|
+
phoneNumber: user.phoneNumber,
|
|
129
|
+
photoURL: user.photoURL,
|
|
130
|
+
uid: user.uid
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function firebaseAuthTokenFromUser(user) {
|
|
134
|
+
return {
|
|
135
|
+
email: user.email,
|
|
136
|
+
emailVerified: user.emailVerified,
|
|
137
|
+
phoneNumber: user.phoneNumber
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
124
141
|
/**
|
|
125
142
|
* Derives a user state from the input firebase auth service.
|
|
126
143
|
*
|
|
@@ -159,16 +176,7 @@ function readValueFromIdToken(dbxFirebaseAuthService, readBooleanFromIdToken, de
|
|
|
159
176
|
}));
|
|
160
177
|
}
|
|
161
178
|
|
|
162
|
-
|
|
163
|
-
return {
|
|
164
|
-
displayName: user === null || user === void 0 ? void 0 : user.displayName,
|
|
165
|
-
email: user.email,
|
|
166
|
-
phoneNumber: user.phoneNumber,
|
|
167
|
-
photoURL: user.photoURL,
|
|
168
|
-
uid: user.uid
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
|
|
179
|
+
// MARK: Delegate
|
|
172
180
|
class DbxFirebaseAuthServiceDelegate {
|
|
173
181
|
}
|
|
174
182
|
const DEFAULT_DBX_FIREBASE_AUTH_SERVICE_DELEGATE = {
|
|
@@ -182,6 +190,7 @@ const DEFAULT_DBX_FIREBASE_AUTH_SERVICE_DELEGATE = {
|
|
|
182
190
|
return dbxFirebaseAuthService.authUserState$.pipe(map((x) => x === 'user'));
|
|
183
191
|
}
|
|
184
192
|
};
|
|
193
|
+
// MARK: Service
|
|
185
194
|
class DbxFirebaseAuthService {
|
|
186
195
|
constructor(firebaseAuth, delegate) {
|
|
187
196
|
this.firebaseAuth = firebaseAuth;
|
|
@@ -207,6 +216,21 @@ class DbxFirebaseAuthService {
|
|
|
207
216
|
this.authUserState$ = delegate.authUserStateObs(this).pipe(distinctUntilChanged(), shareReplay(1));
|
|
208
217
|
this.authRoles$ = delegate.authRolesObs(this);
|
|
209
218
|
this.isOnboarded$ = delegate.isOnboarded(this);
|
|
219
|
+
this._authRoleClaimsService = delegate.authRoleClaimsService;
|
|
220
|
+
}
|
|
221
|
+
rolesForClaims(claims) {
|
|
222
|
+
let result;
|
|
223
|
+
if (this._authRoleClaimsService) {
|
|
224
|
+
return this._authRoleClaimsService.toRoles(claims);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
console.warn('DbxFirebaseAuthService: rolesForClaims called with no authRoleClaimsService provided. An empty set is returned.');
|
|
228
|
+
result = new Set();
|
|
229
|
+
}
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
232
|
+
getAuthContextInfo() {
|
|
233
|
+
return firstValueFrom(this.authUser$).then((user) => (user ? new DbxFirebaseAuthContextInfo(this, user) : undefined));
|
|
210
234
|
}
|
|
211
235
|
logInWithGoogle() {
|
|
212
236
|
return this.logInWithPopup(new GoogleAuthProvider());
|
|
@@ -259,6 +283,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
259
283
|
type: Optional
|
|
260
284
|
}] }];
|
|
261
285
|
} });
|
|
286
|
+
/**
|
|
287
|
+
* FirebaseAuthContextInfo implementation from DbxFirebaseAuthService.
|
|
288
|
+
*/
|
|
289
|
+
class DbxFirebaseAuthContextInfo {
|
|
290
|
+
constructor(service, user) {
|
|
291
|
+
this.service = service;
|
|
292
|
+
this.user = user;
|
|
293
|
+
this._token = cachedGetter(() => firebaseAuthTokenFromUser(this.user));
|
|
294
|
+
}
|
|
295
|
+
get uid() {
|
|
296
|
+
return this.user.uid;
|
|
297
|
+
}
|
|
298
|
+
loadClaims() {
|
|
299
|
+
return this.user.getIdTokenResult().then((x) => x.claims);
|
|
300
|
+
}
|
|
301
|
+
loadAuthRoles() {
|
|
302
|
+
return this.loadClaims().then((x) => this.service.rolesForClaims(x));
|
|
303
|
+
}
|
|
304
|
+
get token() {
|
|
305
|
+
return this._token();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
262
308
|
|
|
263
309
|
class DbxFirebaseLoginTermsConfig {
|
|
264
310
|
}
|
|
@@ -1353,6 +1399,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
1353
1399
|
}]
|
|
1354
1400
|
}], ctorParameters: function () { return [{ type: DbxFirebaseLoginModuleRootConfig }, { type: DbxFirebaseAuthLoginService }]; } });
|
|
1355
1401
|
|
|
1402
|
+
function authRolesObsWithClaimsService(config) {
|
|
1403
|
+
const { addAuthUserStateToRoles: addAuthUserState, claimsService } = config;
|
|
1404
|
+
return (dbxFirebaseAuthService) => {
|
|
1405
|
+
let obs = dbxFirebaseAuthService.idTokenResult$.pipe(map((x) => claimsService.toRoles(x.claims)));
|
|
1406
|
+
if (addAuthUserState) {
|
|
1407
|
+
obs = obs.pipe(switchMap((authRoleSet) => dbxFirebaseAuthService.authUserState$.pipe(map((userState) => addToSetCopy(authRoleSet, [userState])))));
|
|
1408
|
+
}
|
|
1409
|
+
return obs;
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
function defaultDbxFirebaseAuthServiceDelegateWithClaimsService(config) {
|
|
1413
|
+
return {
|
|
1414
|
+
authUserStateObs: DEFAULT_DBX_FIREBASE_AUTH_SERVICE_DELEGATE.authUserStateObs,
|
|
1415
|
+
authRolesObs: authRolesObsWithClaimsService(config),
|
|
1416
|
+
isOnboarded: DEFAULT_DBX_FIREBASE_AUTH_SERVICE_DELEGATE.isOnboarded,
|
|
1417
|
+
authRoleClaimsService: config.claimsService
|
|
1418
|
+
};
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1356
1421
|
class DbxFirebaseAuthModule {
|
|
1357
1422
|
static forRoot(config) {
|
|
1358
1423
|
const providers = [
|
|
@@ -1456,7 +1521,7 @@ DbxFirebaseDefaultAppCheckProviderModule.ɵinj = i0.ɵɵngDeclareInjector({ minV
|
|
|
1456
1521
|
provider: new ReCaptchaV3Provider(appCheckOptions.reCaptchaV3),
|
|
1457
1522
|
isTokenAutoRefreshEnabled: (_c = appCheckOptions.isTokenAutoRefreshEnabled) !== null && _c !== void 0 ? _c : true
|
|
1458
1523
|
});
|
|
1459
|
-
console.
|
|
1524
|
+
console.log('Enabled AppCheck.');
|
|
1460
1525
|
}
|
|
1461
1526
|
else {
|
|
1462
1527
|
appCheck = undefined;
|
|
@@ -1488,7 +1553,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
1488
1553
|
provider: new ReCaptchaV3Provider(appCheckOptions.reCaptchaV3),
|
|
1489
1554
|
isTokenAutoRefreshEnabled: (_c = appCheckOptions.isTokenAutoRefreshEnabled) !== null && _c !== void 0 ? _c : true
|
|
1490
1555
|
});
|
|
1491
|
-
console.
|
|
1556
|
+
console.log('Enabled AppCheck.');
|
|
1492
1557
|
}
|
|
1493
1558
|
else {
|
|
1494
1559
|
appCheck = undefined;
|
|
@@ -2264,27 +2329,36 @@ class AbstractDbxFirebaseDocumentStore extends LockSetComponentStore {
|
|
|
2264
2329
|
super(...arguments);
|
|
2265
2330
|
// MARK: Effects
|
|
2266
2331
|
// MARK: Accessors
|
|
2332
|
+
this.currentFirestoreCollectionLike$ = this.state$.pipe(map((x) => { var _a; return (_a = x.firestoreCollection) !== null && _a !== void 0 ? _a : x.firestoreCollectionLike; }), distinctUntilChanged(), shareReplay(1));
|
|
2267
2333
|
this.currentFirestoreCollection$ = this.state$.pipe(map((x) => x.firestoreCollection), distinctUntilChanged(), shareReplay(1));
|
|
2334
|
+
this.firestoreCollectionLike$ = this.currentFirestoreCollectionLike$.pipe(filterMaybe());
|
|
2268
2335
|
this.firestoreCollection$ = this.currentFirestoreCollection$.pipe(filterMaybe());
|
|
2269
2336
|
this.currentInputId$ = this.state$.pipe(map((x) => x.id), distinctUntilChanged(), shareReplay(1));
|
|
2270
2337
|
this.inputId$ = this.currentInputId$.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
|
|
2338
|
+
this.currentInputKey$ = this.state$.pipe(map((x) => x.key), distinctUntilChanged(), shareReplay(1));
|
|
2339
|
+
this.inputKey$ = this.currentInputKey$.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
|
|
2271
2340
|
this.currentInputRef$ = this.state$.pipe(map((x) => x.ref), distinctUntilChanged(), shareReplay(1));
|
|
2272
2341
|
this.inputRef$ = this.currentInputRef$.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
|
|
2273
|
-
this.currentDocument$ = combineLatest([this.
|
|
2342
|
+
this.currentDocument$ = combineLatest([this.currentInputId$, this.currentInputKey$, this.currentInputRef$]).pipe(switchMap(([id, key, ref]) => {
|
|
2274
2343
|
let document;
|
|
2275
|
-
if (
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2344
|
+
if (ref) {
|
|
2345
|
+
document = this.firestoreCollectionLike$.pipe(map((x) => x.documentAccessor().loadDocument(ref)));
|
|
2346
|
+
}
|
|
2347
|
+
else if (key) {
|
|
2348
|
+
document = this.firestoreCollectionLike$.pipe(map((x) => x.documentAccessor().loadDocumentForKey(key)));
|
|
2349
|
+
}
|
|
2350
|
+
else if (id) {
|
|
2351
|
+
document = this.firestoreCollection$.pipe(map((x) => x.documentAccessor().loadDocumentForPath(id)));
|
|
2352
|
+
}
|
|
2353
|
+
else {
|
|
2354
|
+
document = of(undefined);
|
|
2282
2355
|
}
|
|
2283
2356
|
return document;
|
|
2284
2357
|
}), distinctUntilChanged(), shareReplay(1));
|
|
2285
2358
|
this.document$ = this.currentDocument$.pipe(filterMaybe(), distinctUntilChanged(), shareReplay(1));
|
|
2286
2359
|
this.documentLoadingState$ = this.currentDocument$.pipe(map((x) => (x ? successResult(x) : beginLoading())), shareReplay(1));
|
|
2287
2360
|
this.id$ = this.document$.pipe(map((x) => x.id), shareReplay());
|
|
2361
|
+
this.key$ = this.document$.pipe(map((x) => x.key), shareReplay());
|
|
2288
2362
|
this.ref$ = this.document$.pipe(map((x) => x.documentRef), shareReplay());
|
|
2289
2363
|
this.snapshot$ = this.document$.pipe(switchMap((x) => x.accessor.stream()), shareReplay(1));
|
|
2290
2364
|
this.snapshotLoadingState$ = this.currentDocument$.pipe(switchMap(() => loadingStateFromObs(this.snapshot$)), shareReplay(1));
|
|
@@ -2308,16 +2382,23 @@ class AbstractDbxFirebaseDocumentStore extends LockSetComponentStore {
|
|
|
2308
2382
|
}), shareReplay(1));
|
|
2309
2383
|
this.exists$ = this.currentData$.pipe(map((x) => isMaybeSo(x)), shareReplay(1));
|
|
2310
2384
|
this.doesNotExist$ = this.exists$.pipe(map((x) => !x), shareReplay(1));
|
|
2385
|
+
this.modelIdentity$ = this.document$.pipe(map((x) => x.modelIdentity), shareReplay(1));
|
|
2311
2386
|
// MARK: State Changes
|
|
2312
2387
|
/**
|
|
2313
2388
|
* Sets the id of the document to load.
|
|
2314
2389
|
*/
|
|
2315
2390
|
this.setId = this.updater((state, id) => (id ? Object.assign(Object.assign({}, state), { id, ref: undefined }) : Object.assign(Object.assign({}, state), { id })));
|
|
2391
|
+
/**
|
|
2392
|
+
* Sets the key of the document to load.
|
|
2393
|
+
*/
|
|
2394
|
+
this.setKey = this.updater((state, key) => (key ? Object.assign(Object.assign({}, state), { key, ref: undefined }) : Object.assign(Object.assign({}, state), { key })));
|
|
2316
2395
|
/**
|
|
2317
2396
|
* Sets the ref of the document to load.
|
|
2318
2397
|
*/
|
|
2319
2398
|
this.setRef = this.updater((state, ref) => (ref ? Object.assign(Object.assign({}, state), { id: undefined, ref }) : Object.assign(Object.assign({}, state), { ref })));
|
|
2399
|
+
this.clearRefs = this.updater((state) => (Object.assign(Object.assign({}, state), { id: undefined, key: undefined, ref: undefined })));
|
|
2320
2400
|
this.setFirestoreCollection = this.updater((state, firestoreCollection) => (Object.assign(Object.assign({}, state), { firestoreCollection })));
|
|
2401
|
+
this.setFirestoreCollectionLike = this.updater((state, firestoreCollectionLike) => (Object.assign(Object.assign({}, state), { firestoreCollectionLike })));
|
|
2321
2402
|
}
|
|
2322
2403
|
}
|
|
2323
2404
|
AbstractDbxFirebaseDocumentStore.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.2", ngImport: i0, type: AbstractDbxFirebaseDocumentStore, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
@@ -2326,6 +2407,42 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
2326
2407
|
type: Injectable
|
|
2327
2408
|
}] });
|
|
2328
2409
|
|
|
2410
|
+
/**
|
|
2411
|
+
* Creates a function for a store that DbxFirebaseDocumentStore captures the ModelFirebaseCreateFunction result and sets the key of the created value.
|
|
2412
|
+
*
|
|
2413
|
+
* @param store
|
|
2414
|
+
* @param fn
|
|
2415
|
+
* @returns
|
|
2416
|
+
*/
|
|
2417
|
+
function firebaseDocumentStoreCreateFunction(store, fn) {
|
|
2418
|
+
return (params) => loadingStateFromObs(lazyFrom(() => fn(params).then((result) => {
|
|
2419
|
+
const modelKeys = result.modelKeys;
|
|
2420
|
+
const firstKey = firstValue(modelKeys);
|
|
2421
|
+
if (firstKey) {
|
|
2422
|
+
store.setKey(firstKey);
|
|
2423
|
+
}
|
|
2424
|
+
return result;
|
|
2425
|
+
})));
|
|
2426
|
+
}
|
|
2427
|
+
function firebaseDocumentStoreUpdateFunction(store, fn) {
|
|
2428
|
+
return (params) => loadingStateFromObs(store.key$.pipe(first(), switchMap((key) => fn(Object.assign(Object.assign({}, params), { key // inject key into the parameters.
|
|
2429
|
+
})))));
|
|
2430
|
+
}
|
|
2431
|
+
/**
|
|
2432
|
+
* Deletes a function for a store that DbxFirebaseDocumentStore captures the ModelFirebaseDeleteFunction result and sets the key of the created value.
|
|
2433
|
+
*
|
|
2434
|
+
* @param store
|
|
2435
|
+
* @param fn
|
|
2436
|
+
* @returns
|
|
2437
|
+
*/
|
|
2438
|
+
function firebaseDocumentStoreDeleteFunction(store, fn) {
|
|
2439
|
+
return (params) => loadingStateFromObs(store.key$.pipe(first(), switchMap((key) => fn(Object.assign(Object.assign({}, params), { key // inject key into the parameters.
|
|
2440
|
+
})).then((result) => {
|
|
2441
|
+
store.clearRefs();
|
|
2442
|
+
return result;
|
|
2443
|
+
}))));
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2329
2446
|
function setParentStoreEffect(store) {
|
|
2330
2447
|
return store.effect((input) => {
|
|
2331
2448
|
return input.pipe(map((parentStore) => {
|
|
@@ -2526,5 +2643,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.2", ngImpor
|
|
|
2526
2643
|
* Generated bundle index. Do not edit.
|
|
2527
2644
|
*/
|
|
2528
2645
|
|
|
2529
|
-
export { AbstractConfiguredDbxFirebaseLoginButtonDirective, AbstractDbxFirebaseCollectionStore, AbstractDbxFirebaseCollectionWithParentStore, AbstractDbxFirebaseDocumentStore, AbstractDbxFirebaseDocumentWithParentStore, DBX_FIREBASE_MODEL_DOES_NOT_EXIST_ERROR, DBX_FIREBASE_OPTIONS_TOKEN, DBX_FIREBASE_ROUTER_SYNC_DEFAULT_ID_PARAM_KEY, DBX_FIRESTORE_CONTEXT_TOKEN, DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE, DEFAULT_DBX_FIREBASE_AUTH_SERVICE_DELEGATE, DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG, DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG_TOKEN, DEFAULT_FIREBASE_AUTH_LOGIN_PROVIDERS_TOKEN, DEFAULT_FIREBASE_AUTH_LOGIN_TERMS_COMPONENT_CLASS_TOKEN, DEFAULT_FIREBASE_LOGIN_METHOD_CATEGORY, DbxFirebaseAppCheckHttpInterceptor, DbxFirebaseAuthLoginService, DbxFirebaseAuthModule, DbxFirebaseAuthService, DbxFirebaseAuthServiceDelegate, DbxFirebaseCollectionChangeDirective, DbxFirebaseCollectionHasChangeDirective, DbxFirebaseCollectionListDirective, DbxFirebaseCollectionLoaderInstance, DbxFirebaseCollectionStoreDirective, DbxFirebaseCollectionWithParentStoreDirective, DbxFirebaseDefaultAppCheckProviderModule, DbxFirebaseDefaultAuthProviderModule, DbxFirebaseDefaultFirebaseProvidersModule, DbxFirebaseDefaultFirestoreProviderModule, DbxFirebaseDefaultFunctionsProviderModule, DbxFirebaseDefaultStorageProviderModule, DbxFirebaseDocumentAuthIdDirective, DbxFirebaseDocumentStoreDirective, DbxFirebaseDocumentStoreRouteIdDirective, DbxFirebaseEmailFormComponent, DbxFirebaseEmailRecoveryFormComponent, DbxFirebaseEmulatorModule, DbxFirebaseFirestoreCollectionModule, DbxFirebaseFunctionsModule, DbxFirebaseLoginAnonymousComponent, DbxFirebaseLoginAppleComponent, DbxFirebaseLoginButtonComponent, DbxFirebaseLoginButtonContainerComponent, DbxFirebaseLoginComponent, DbxFirebaseLoginContext, DbxFirebaseLoginContextBackButtonComponent, DbxFirebaseLoginContextDirective, DbxFirebaseLoginEmailComponent, DbxFirebaseLoginEmailContentComponent, DbxFirebaseLoginFacebookComponent, DbxFirebaseLoginGitHubComponent, DbxFirebaseLoginGoogleComponent, DbxFirebaseLoginListComponent, DbxFirebaseLoginMicrosoftComponent, DbxFirebaseLoginModule, DbxFirebaseLoginModuleRootConfig, DbxFirebaseLoginTermsComponent, DbxFirebaseLoginTermsSimpleComponent, DbxFirebaseLoginTwitterComponent, DbxFirebaseModelModule, DbxFirebaseModelStoreModule, DbxFirebaseModule, DbxFirebaseParsedEmulatorsConfig, DbxFirebaseRegisterComponent, DbxFirebaseRegisterEmailComponent, DbxFirestoreContextService, FIREBASE_AUTH_NETWORK_REQUEST_ERROR, FIREBASE_AUTH_USER_NOT_FOUND_ERROR, OAUTH_FIREBASE_LOGIN_METHOD_CATEGORY, authUserInfoFromAuthUser, authUserStateFromFirebaseAuthService, dbxFirebaseCollectionLoaderInstance, dbxFirebaseCollectionLoaderInstanceWithCollection, defaultFirebaseAuthLoginProvidersFactory, enableAppCheckDebugTokenGeneration, firebaseAuthErrorToReadableError, modelDoesNotExistError, provideDbxFirebaseCollectionStoreDirective, provideDbxFirebaseCollectionWithParentStoreDirective, provideDbxFirebaseDocumentStoreDirective, readValueFromIdToken, setParentStoreEffect };
|
|
2646
|
+
export { AbstractConfiguredDbxFirebaseLoginButtonDirective, AbstractDbxFirebaseCollectionStore, AbstractDbxFirebaseCollectionWithParentStore, AbstractDbxFirebaseDocumentStore, AbstractDbxFirebaseDocumentWithParentStore, DBX_FIREBASE_MODEL_DOES_NOT_EXIST_ERROR, DBX_FIREBASE_OPTIONS_TOKEN, DBX_FIREBASE_ROUTER_SYNC_DEFAULT_ID_PARAM_KEY, DBX_FIRESTORE_CONTEXT_TOKEN, DEFAULT_CONFIGURED_DBX_FIREBASE_LOGIN_BUTTON_TEMPLATE, DEFAULT_DBX_FIREBASE_AUTH_SERVICE_DELEGATE, DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG, DEFAULT_FIREBASE_AUTH_LOGIN_PASSWORD_CONFIG_TOKEN, DEFAULT_FIREBASE_AUTH_LOGIN_PROVIDERS_TOKEN, DEFAULT_FIREBASE_AUTH_LOGIN_TERMS_COMPONENT_CLASS_TOKEN, DEFAULT_FIREBASE_LOGIN_METHOD_CATEGORY, DbxFirebaseAppCheckHttpInterceptor, DbxFirebaseAuthContextInfo, DbxFirebaseAuthLoginService, DbxFirebaseAuthModule, DbxFirebaseAuthService, DbxFirebaseAuthServiceDelegate, DbxFirebaseCollectionChangeDirective, DbxFirebaseCollectionHasChangeDirective, DbxFirebaseCollectionListDirective, DbxFirebaseCollectionLoaderInstance, DbxFirebaseCollectionStoreDirective, DbxFirebaseCollectionWithParentStoreDirective, DbxFirebaseDefaultAppCheckProviderModule, DbxFirebaseDefaultAuthProviderModule, DbxFirebaseDefaultFirebaseProvidersModule, DbxFirebaseDefaultFirestoreProviderModule, DbxFirebaseDefaultFunctionsProviderModule, DbxFirebaseDefaultStorageProviderModule, DbxFirebaseDocumentAuthIdDirective, DbxFirebaseDocumentStoreDirective, DbxFirebaseDocumentStoreRouteIdDirective, DbxFirebaseEmailFormComponent, DbxFirebaseEmailRecoveryFormComponent, DbxFirebaseEmulatorModule, DbxFirebaseFirestoreCollectionModule, DbxFirebaseFunctionsModule, DbxFirebaseLoginAnonymousComponent, DbxFirebaseLoginAppleComponent, DbxFirebaseLoginButtonComponent, DbxFirebaseLoginButtonContainerComponent, DbxFirebaseLoginComponent, DbxFirebaseLoginContext, DbxFirebaseLoginContextBackButtonComponent, DbxFirebaseLoginContextDirective, DbxFirebaseLoginEmailComponent, DbxFirebaseLoginEmailContentComponent, DbxFirebaseLoginFacebookComponent, DbxFirebaseLoginGitHubComponent, DbxFirebaseLoginGoogleComponent, DbxFirebaseLoginListComponent, DbxFirebaseLoginMicrosoftComponent, DbxFirebaseLoginModule, DbxFirebaseLoginModuleRootConfig, DbxFirebaseLoginTermsComponent, DbxFirebaseLoginTermsSimpleComponent, DbxFirebaseLoginTwitterComponent, DbxFirebaseModelModule, DbxFirebaseModelStoreModule, DbxFirebaseModule, DbxFirebaseParsedEmulatorsConfig, DbxFirebaseRegisterComponent, DbxFirebaseRegisterEmailComponent, DbxFirestoreContextService, FIREBASE_AUTH_NETWORK_REQUEST_ERROR, FIREBASE_AUTH_USER_NOT_FOUND_ERROR, OAUTH_FIREBASE_LOGIN_METHOD_CATEGORY, authRolesObsWithClaimsService, authUserInfoFromAuthUser, authUserStateFromFirebaseAuthService, dbxFirebaseCollectionLoaderInstance, dbxFirebaseCollectionLoaderInstanceWithCollection, defaultDbxFirebaseAuthServiceDelegateWithClaimsService, defaultFirebaseAuthLoginProvidersFactory, enableAppCheckDebugTokenGeneration, firebaseAuthErrorToReadableError, firebaseAuthTokenFromUser, firebaseDocumentStoreCreateFunction, firebaseDocumentStoreDeleteFunction, firebaseDocumentStoreUpdateFunction, modelDoesNotExistError, provideDbxFirebaseCollectionStoreDirective, provideDbxFirebaseCollectionWithParentStoreDirective, provideDbxFirebaseDocumentStoreDirective, readValueFromIdToken, setParentStoreEffect };
|
|
2530
2647
|
//# sourceMappingURL=dereekb-dbx-firebase.mjs.map
|