Skip to content

Commit cf40fe0

Browse files
committed
First pass at polyfill
1 parent 78df2a6 commit cf40fe0

File tree

114 files changed

+1081
-483
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+1081
-483
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,4 @@
2222
* just use index.ts
2323
*/
2424

25-
import { testFxn } from './src';
26-
27-
testFxn();
25+
export * from './index';

packages-exp/auth-compat-exp/index.rn.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,7 @@ import { AsyncStorage } from 'react-native';
2626

2727
import { getReactNativePersistence } from '@firebase/auth-exp/src/core/persistence/react_native';
2828

29+
export * from './index';
30+
2931
// eslint-disable-next-line @typescript-eslint/no-unused-vars
3032
const reactNativeLocalPersistence = getReactNativePersistence(AsyncStorage);

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

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @license
3-
* Copyright 2017 Google LLC
3+
* Copyright 2020 Google LLC
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -15,6 +15,66 @@
1515
* limitations under the License.
1616
*/
1717

18-
import { testFxn } from './src';
18+
import firebase from '@firebase/app';
19+
import { _FirebaseNamespace } from '@firebase/app-types/private';
20+
import * as externs from '@firebase/auth-types-exp';
21+
import {
22+
Component,
23+
ComponentType,
24+
InstantiationMode
25+
} from '@firebase/component';
26+
import '@firebase/installations';
27+
import { name, version } from './package.json';
28+
import { Auth } from './src/auth';
1929

20-
testFxn();
30+
const AUTH_TYPE = 'auth';
31+
32+
// Create auth components to register with firebase.
33+
// Provides Auth public APIs.
34+
function registerAuth(instance: _FirebaseNamespace): void {
35+
instance.INTERNAL.registerComponent(
36+
new Component(
37+
AUTH_TYPE,
38+
container => {
39+
// getImmediate for FirebaseApp will always succeed
40+
const app = container.getProvider('app').getImmediate();
41+
return new Auth(app);
42+
},
43+
ComponentType.PUBLIC
44+
)
45+
.setServiceProps({
46+
ActionCodeInfo: {
47+
Operation: {
48+
EMAIL_SIGNIN: externs.Operation.EMAIL_SIGNIN,
49+
PASSWORD_RESET: externs.Operation.PASSWORD_RESET,
50+
RECOVER_EMAIL: externs.Operation.RECOVER_EMAIL,
51+
REVERT_SECOND_FACTOR_ADDITION:
52+
externs.Operation.REVERT_SECOND_FACTOR_ADDITION,
53+
VERIFY_AND_CHANGE_EMAIL: externs.Operation.VERIFY_AND_CHANGE_EMAIL,
54+
VERIFY_EMAIL: externs.Operation.VERIFY_EMAIL
55+
}
56+
}
57+
// TODO(avolkovi): Expose the other top level properties
58+
// EmailAuthProvider,
59+
// FacebookAuthProvider,
60+
// GithubAuthProvider,
61+
// GoogleAuthProvider,
62+
// OAuthProvider,
63+
// SAMLAuthProvider,
64+
// PhoneAuthProvider,
65+
// RecaptchaVerifier,
66+
// TwitterAuthProvider,
67+
// Auth: {
68+
// Persistence
69+
// }
70+
// 'AuthCredential': fireauth.AuthCredential,
71+
// 'Error': fireauth.AuthError
72+
})
73+
.setInstantiationMode(InstantiationMode.LAZY)
74+
.setMultipleInstances(false)
75+
);
76+
77+
instance.registerVersion(name, version);
78+
}
79+
80+
registerAuth(firebase as _FirebaseNamespace);

packages-exp/auth-compat-exp/package.json

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
77
"main": "dist/index.node.cjs.js",
88
"browser": "dist/index.cjs.js",
9-
"module": "dist/index.esm.js",
9+
"module": "dist/index.esm5.js",
1010
"esm2017": "dist/index.esm2017.js",
1111
"react-native": "dist/index.rn.cjs.js",
1212
"files": [
@@ -16,7 +16,7 @@
1616
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1717
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
1818
"build": "rollup -c",
19-
"build:deps": "lerna run --scope @firebase/'{app,auth-compat-exp}' --include-dependencies build",
19+
"build:deps": "lerna run --scope @firebase/'{app,auth-types,auth-exp,auth-types-exp}' --include-dependencies build",
2020
"dev": "rollup -c -w",
2121
"test": "yarn type-check && run-p lint test:browser test:node",
2222
"test:browser": "karma start --single-run",
@@ -25,10 +25,13 @@
2525
"prepare": "yarn build"
2626
},
2727
"peerDependencies": {
28-
"@firebase/app-exp": "0.x",
29-
"@firebase/app-types-exp": "0.x",
28+
"@firebase/app": "0.x",
29+
"@firebase/auth-types": "0.x",
3030
"@firebase/auth-exp": "0.x",
31-
"@firebase/auth-types-exp": "0.x"
31+
"@firebase/auth-types-exp": "0.x",
32+
"@firebase/component": "0.x",
33+
"@firebase/installations": "0.x",
34+
"@firebase/util": "0.x"
3235
},
3336
"dependencies": {
3437
"tslib": "1.11.1"

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18+
import json from 'rollup-plugin-json';
1819
import typescriptPlugin from 'rollup-plugin-typescript2';
1920
import typescript from 'typescript';
2021
import pkg from './package.json';
@@ -23,10 +24,16 @@ const deps = Object.keys(
2324
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
2425
);
2526

27+
/**
28+
* Common plugins for all builds
29+
*/
30+
const commonPlugins = [json()];
31+
2632
/**
2733
* ES5 Builds
2834
*/
2935
const es5BuildPlugins = [
36+
...commonPlugins,
3037
typescriptPlugin({
3138
typescript
3239
})
@@ -40,7 +47,7 @@ const es5Builds = [
4047
input: 'index.ts',
4148
output: [
4249
{ file: pkg.browser, format: 'cjs', sourcemap: true },
43-
{ file: pkg.module, format: 'es', sourcemap: true }
50+
{ file: pkg.module, format: 'esm', sourcemap: true }
4451
],
4552
plugins: es5BuildPlugins,
4653
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
@@ -72,6 +79,7 @@ const es5Builds = [
7279
* ES2017 Builds
7380
*/
7481
const es2017BuildPlugins = [
82+
...commonPlugins,
7583
typescriptPlugin({
7684
typescript,
7785
tsconfigOverride: {

0 commit comments

Comments
 (0)