Skip to content

Commit 9658f2b

Browse files
authored
Merge 645d1e7 into 12e7465
2 parents 12e7465 + 645d1e7 commit 9658f2b

27 files changed

+139
-15592
lines changed

packages-exp/auth-exp/index.node.ts

-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,3 @@
2121
* implementation that mandates having a separate entrypoint. Otherwise you can
2222
* just use index.ts
2323
*/
24-
25-
import { testFxn } from './src';
26-
27-
testFxn();

packages-exp/auth-exp/index.ts

-20
This file was deleted.

packages-exp/auth-exp/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"license": "Apache-2.0",
3838
"devDependencies": {
3939
"@rollup/plugin-strip": "^1.3.2",
40+
"@firebase/app-exp": "0.x",
4041
"rollup": "1.32.1",
4142
"rollup-plugin-json": "4.0.0",
4243
"rollup-plugin-replace": "2.2.0",

packages-exp/auth-exp/rollup.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const es5Builds = [
4848
* Browser Builds
4949
*/
5050
{
51-
input: 'index.ts',
51+
input: 'src/index.ts',
5252
output: [{ file: pkg.module, format: 'es', sourcemap: true }],
5353
plugins: es5BuildPlugins,
5454
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
@@ -84,7 +84,7 @@ const es2017Builds = [
8484
* Browser Builds
8585
*/
8686
{
87-
input: 'index.ts',
87+
input: 'src/index.ts',
8888
output: {
8989
file: pkg.esm2017,
9090
format: 'es',

packages-exp/auth-exp/src/core/action_code_url.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { AuthErrorCode, AUTH_ERROR_FACTORY } from './errors';
18+
import * as externs from '@firebase/auth-types-exp';
19+
1920
import { Operation } from '../model/action_code_info';
2021
import { Auth } from '../model/auth';
22+
import { AUTH_ERROR_FACTORY, AuthErrorCode } from './errors';
2123

2224
/**
2325
* Enums for fields in URL query string.
@@ -64,7 +66,7 @@ function parseDeepLink(url: string): string {
6466
return iOSDoubleDeepLink || iOSDeepLink || doubleDeepLink || link || url;
6567
}
6668

67-
export class ActionCodeURL {
69+
export class ActionCodeURL implements externs.ActionCodeURL {
6870
readonly apiKey: string;
6971
readonly code: string;
7072
readonly continueUrl: string | null;

packages-exp/auth-exp/src/core/auth/auth_impl.test.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import * as sinon from 'sinon';
2020
import * as sinonChai from 'sinon-chai';
2121

2222
import { FirebaseApp } from '@firebase/app-types-exp';
23+
import * as externs from '@firebase/auth-types-exp';
2324
import { FirebaseError } from '@firebase/util';
2425

2526
import { testUser } from '../../../test/mock_auth';
@@ -31,10 +32,7 @@ import { inMemoryPersistence } from '../persistence/in_memory';
3132
import { PersistenceUserManager } from '../persistence/persistence_user_manager';
3233
import { _getClientVersion, ClientPlatform } from '../util/version';
3334
import {
34-
DEFAULT_API_HOST,
35-
DEFAULT_API_SCHEME,
36-
DEFAULT_TOKEN_API_HOST,
37-
initializeAuth
35+
DEFAULT_API_HOST, DEFAULT_API_SCHEME, DEFAULT_TOKEN_API_HOST, initializeAuth
3836
} from './auth_impl';
3937

4038
use(sinonChai);
@@ -53,8 +51,8 @@ describe('core/auth/auth_impl', () => {
5351
let persistenceStub: sinon.SinonStubbedInstance<Persistence>;
5452

5553
beforeEach(() => {
56-
persistenceStub = sinon.stub(inMemoryPersistence);
57-
auth = initializeAuth(FAKE_APP, { persistence: inMemoryPersistence });
54+
persistenceStub = sinon.stub(inMemoryPersistence as Persistence);
55+
auth = initializeAuth(FAKE_APP, { persistence: inMemoryPersistence }) as Auth;
5856
});
5957

6058
afterEach(sinon.restore);
@@ -104,7 +102,7 @@ describe('core/auth/auth_impl', () => {
104102

105103
describe('#setPersistence', () => {
106104
it('swaps underlying persistence', async () => {
107-
const newPersistence = browserLocalPersistence;
105+
const newPersistence = browserLocalPersistence as Persistence;
108106
const newStub = sinon.stub(newPersistence);
109107
persistenceStub.get.returns(
110108
Promise.resolve(testUser('test').toPlainObject())
@@ -271,18 +269,20 @@ describe('core/auth/initializeAuth', () => {
271269

272270
describe('persistence manager creation', () => {
273271
let createManagerStub: sinon.SinonSpy;
272+
// const inMemory = inMemoryPersistence as Persistence;
273+
// const browserLocal = browserL
274274
beforeEach(() => {
275275
createManagerStub = sinon.spy(PersistenceUserManager, 'create');
276276
});
277277

278278
async function initAndWait(
279-
persistence: Persistence | Persistence[]
279+
persistence: externs.Persistence | externs.Persistence[]
280280
): Promise<Auth> {
281281
const auth = initializeAuth(FAKE_APP, { persistence });
282282
// Auth initializes async. We can make sure the initialization is
283283
// flushed by awaiting a method on the queue.
284284
await auth.setPersistence(inMemoryPersistence);
285-
return auth;
285+
return auth as Auth;
286286
}
287287

288288
it('converts single persistence to array', async () => {
@@ -294,7 +294,7 @@ describe('core/auth/initializeAuth', () => {
294294

295295
it('pulls the user from storage', async () => {
296296
sinon
297-
.stub(inMemoryPersistence, 'get')
297+
.stub(inMemoryPersistence as Persistence, 'get')
298298
.returns(Promise.resolve(testUser('uid').toPlainObject()));
299299
const auth = await initAndWait(inMemoryPersistence);
300300
expect(auth.currentUser!.uid).to.eq('uid');

packages-exp/auth-exp/src/core/auth/auth_impl.ts

+6-12
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,10 @@ import { getApp } from '@firebase/app-exp';
1919
import { FirebaseApp } from '@firebase/app-types-exp';
2020
import * as externs from '@firebase/auth-types-exp';
2121
import {
22-
CompleteFn,
23-
createSubscribe,
24-
ErrorFn,
25-
NextFn,
26-
Observer,
27-
Subscribe,
28-
Unsubscribe
22+
CompleteFn, createSubscribe, ErrorFn, NextFn, Observer, Subscribe, Unsubscribe
2923
} from '@firebase/util';
3024

31-
import { Auth, Config, Dependencies, NextOrObserver } from '../../model/auth';
25+
import { Auth, Dependencies, NextOrObserver } from '../../model/auth';
3226
import { User } from '../../model/user';
3327
import { AuthErrorCode } from '../errors';
3428
import { Persistence } from '../persistence';
@@ -58,7 +52,7 @@ class AuthImpl implements Auth {
5852

5953
constructor(
6054
public readonly name: string,
61-
public readonly config: Config,
55+
public readonly config: externs.Config,
6256
persistenceHierarchy: Persistence[]
6357
) {
6458
// This promise is intended to float; auth initialization happens in the
@@ -197,14 +191,14 @@ class AuthImpl implements Auth {
197191
export function initializeAuth(
198192
app: FirebaseApp = getApp(),
199193
deps?: Dependencies
200-
): Auth {
194+
): externs.Auth {
201195
const persistence = deps?.persistence || [];
202196
const hierarchy = Array.isArray(persistence) ? persistence : [persistence];
203197
const { apiKey, authDomain } = app.options;
204198

205199
// TODO: platform needs to be determined using heuristics
206200
assert(apiKey, app.name, AuthErrorCode.INVALID_API_KEY);
207-
const config: Config = {
201+
const config: externs.Config = {
208202
apiKey,
209203
authDomain,
210204
apiHost: DEFAULT_API_HOST,
@@ -213,7 +207,7 @@ export function initializeAuth(
213207
sdkClientVersion: _getClientVersion(ClientPlatform.BROWSER)
214208
};
215209

216-
return new AuthImpl(app.name, config, hierarchy);
210+
return new AuthImpl(app.name, config, hierarchy as Persistence[]);
217211
}
218212

219213
/** Helper class to wrap subscriber logic */

packages-exp/auth-exp/src/core/persistence/browser.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { expect } from 'chai';
1919
import * as sinon from 'sinon';
2020

2121
import { testUser } from '../../../test/mock_auth';
22-
import { PersistedBlob, PersistenceType } from './';
22+
import { PersistedBlob, Persistence, PersistenceType } from './';
2323
import { browserLocalPersistence, browserSessionPersistence } from './browser';
2424

2525
describe('core/persistence/browser', () => {
@@ -31,7 +31,7 @@ describe('core/persistence/browser', () => {
3131
afterEach(() => sinon.restore());
3232

3333
describe('browserLocalPersistence', () => {
34-
const persistence = browserLocalPersistence;
34+
const persistence: Persistence = browserLocalPersistence as Persistence;
3535

3636
it('should work with persistence type', async () => {
3737
const key = 'my-super-special-persistence-type';
@@ -74,7 +74,7 @@ describe('core/persistence/browser', () => {
7474
});
7575

7676
describe('browserSessionPersistence', () => {
77-
const persistence = browserSessionPersistence;
77+
const persistence = browserSessionPersistence as Persistence;
7878

7979
it('should work with persistence type', async () => {
8080
const key = 'my-super-special-persistence-type';

packages-exp/auth-exp/src/core/persistence/browser.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18-
import {
19-
Persistence,
20-
PersistenceType,
21-
PersistenceValue,
22-
STORAGE_AVAILABLE_KEY
23-
} from './';
18+
import * as externs from '@firebase/auth-types-exp';
19+
20+
import { Persistence, PersistenceType, PersistenceValue, STORAGE_AVAILABLE_KEY } from './';
2421

2522
class BrowserPersistence implements Persistence {
2623
type: PersistenceType = PersistenceType.LOCAL;
@@ -54,9 +51,9 @@ class BrowserPersistence implements Persistence {
5451
}
5552
}
5653

57-
export const browserLocalPersistence: Persistence = new BrowserPersistence(
54+
export const browserLocalPersistence: externs.Persistence = new BrowserPersistence(
5855
localStorage
5956
);
60-
export const browserSessionPersistence: Persistence = new BrowserPersistence(
57+
export const browserSessionPersistence: externs.Persistence = new BrowserPersistence(
6158
sessionStorage
6259
);

packages-exp/auth-exp/src/core/persistence/in_memory.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
import { expect } from 'chai';
1919

2020
import { testUser } from '../../../test/mock_auth';
21-
import { PersistenceType } from './';
22-
import { inMemoryPersistence as persistence } from './in_memory';
21+
import { Persistence, PersistenceType } from './';
22+
import { inMemoryPersistence } from './in_memory';
23+
24+
const persistence = inMemoryPersistence as Persistence;
2325

2426
describe('core/persistence/in_memory', () => {
2527
it('should work with persistence type', async () => {

packages-exp/auth-exp/src/core/persistence/in_memory.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
* limitations under the License.
1616
*/
1717

18+
import * as externs from '@firebase/auth-types-exp';
19+
1820
import { Persistence, PersistenceType, PersistenceValue } from '../persistence';
1921

2022
class InMemoryPersistence implements Persistence {
@@ -41,4 +43,4 @@ class InMemoryPersistence implements Persistence {
4143
}
4244
}
4345

44-
export const inMemoryPersistence: Persistence = new InMemoryPersistence();
46+
export const inMemoryPersistence: externs.Persistence = new InMemoryPersistence();

packages-exp/auth-exp/src/core/persistence/indexed_db.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ import { expect } from 'chai';
1919
import * as sinon from 'sinon';
2020

2121
import { testUser } from '../../../test/mock_auth';
22-
import { PersistenceType } from './';
23-
import { indexedDBLocalPersistence as persistence } from './indexed_db';
22+
import { Persistence, PersistenceType } from './';
23+
import { indexedDBLocalPersistence } from './indexed_db';
24+
25+
const persistence = indexedDBLocalPersistence as Persistence;
2426

2527
describe('core/persistence/indexed_db', () => {
2628
afterEach(sinon.restore);

packages-exp/auth-exp/src/core/persistence/indexed_db.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18+
import * as externs from '@firebase/auth-types-exp';
19+
1820
import {
19-
PersistedBlob,
20-
Persistence,
21-
PersistenceType,
22-
PersistenceValue,
23-
STORAGE_AVAILABLE_KEY
21+
PersistedBlob, Persistence, PersistenceType, PersistenceValue, STORAGE_AVAILABLE_KEY
2422
} from './';
2523

2624
export const DB_NAME = 'firebaseLocalStorageDb';
@@ -175,4 +173,4 @@ class IndexedDBLocalPersistence implements Persistence {
175173
}
176174
}
177175

178-
export const indexedDBLocalPersistence: Persistence = new IndexedDBLocalPersistence();
176+
export const indexedDBLocalPersistence: externs.Persistence = new IndexedDBLocalPersistence();

packages-exp/auth-exp/src/core/persistence/persistence_user_manager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export class PersistenceUserManager {
8888
userKey = _AUTH_USER_KEY_NAME
8989
): Promise<PersistenceUserManager> {
9090
if (!persistenceHierarchy.length) {
91-
return new PersistenceUserManager(inMemoryPersistence, auth, userKey);
91+
return new PersistenceUserManager(inMemoryPersistence as Persistence, auth, userKey);
9292
}
9393

9494
const key = _persistenceKeyName(userKey, auth.config.apiKey, auth.name);

packages-exp/auth-exp/src/core/persistence/react_native.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,10 @@
1515
* limitations under the License.
1616
*/
1717

18-
import {
19-
Persistence,
20-
PersistenceType,
21-
PersistenceValue,
22-
STORAGE_AVAILABLE_KEY
23-
} from './';
2418
import { ReactNativeAsyncStorage } from '@firebase/auth-types-exp';
2519

20+
import { Persistence, PersistenceType, PersistenceValue, STORAGE_AVAILABLE_KEY } from './';
21+
2622
/**
2723
* Persistence class that wraps AsyncStorage imported from `react-native` or `@react-native-community/async-storage`.
2824
*/

packages-exp/auth-exp/src/model/action_code_settings.ts renamed to packages-exp/auth-exp/src/core/strategies/action_code_settings.ts

+2-15
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { GetOobCodeRequest } from '../api/authentication/email_and_password';
18+
import { ActionCodeSettings } from '@firebase/auth-types-exp';
1919

20-
export interface ActionCodeSettings {
21-
android?: {
22-
installApp?: boolean;
23-
minimumVersion?: string;
24-
packageName: string;
25-
};
26-
handleCodeInApp?: boolean;
27-
iOS?: {
28-
bundleId: string;
29-
appStoreId: string;
30-
};
31-
url: string;
32-
dynamicLinkDomain?: string;
33-
}
20+
import { GetOobCodeRequest } from '../../api/authentication/email_and_password';
3421

3522
export function setActionCodeSettingsOnRequest(
3623
request: GetOobCodeRequest,

packages-exp/auth-exp/src/core/strategies/email.ts

+3-8
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,15 @@
1616
*/
1717

1818
import * as externs from '@firebase/auth-types-exp';
19+
import { ActionCodeSettings } from '@firebase/auth-types-exp';
1920

20-
import {
21-
createAuthUri,
22-
CreateAuthUriRequest
23-
} from '../../api/authentication/create_auth_uri';
21+
import { createAuthUri, CreateAuthUriRequest } from '../../api/authentication/create_auth_uri';
2422
import * as api from '../../api/authentication/email_and_password';
2523
import { Operation } from '../../model/action_code_info';
26-
import {
27-
ActionCodeSettings,
28-
setActionCodeSettingsOnRequest
29-
} from '../../model/action_code_settings';
3024
import { Auth } from '../../model/auth';
3125
import { User } from '../../model/user';
3226
import { _getCurrentUrl, _isHttpOrHttps } from '../util/location';
27+
import { setActionCodeSettingsOnRequest } from './action_code_settings';
3328

3429
export async function fetchSignInMethodsForEmail(
3530
auth: externs.Auth,

0 commit comments

Comments
 (0)