Skip to content

First pass at polyfill #3517

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

Merged
merged 2 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages-exp/auth-compat-exp/index.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,4 @@
* just use index.ts
*/

import { testFxn } from './src';

testFxn();
export * from './index';
2 changes: 2 additions & 0 deletions packages-exp/auth-compat-exp/index.rn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ import { AsyncStorage } from 'react-native';

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

export * from './index';

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const reactNativeLocalPersistence = getReactNativePersistence(AsyncStorage);
66 changes: 63 additions & 3 deletions packages-exp/auth-compat-exp/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* Copyright 2017 Google LLC
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,66 @@
* limitations under the License.
*/

import { testFxn } from './src';
import firebase from '@firebase/app';
import { _FirebaseNamespace } from '@firebase/app-types/private';
import * as externs from '@firebase/auth-types-exp';
import {
Component,
ComponentType,
InstantiationMode
} from '@firebase/component';
import '@firebase/installations';
import { name, version } from './package.json';
import { Auth } from './src/auth';

testFxn();
const AUTH_TYPE = 'auth';

// Create auth components to register with firebase.
// Provides Auth public APIs.
function registerAuth(instance: _FirebaseNamespace): void {
instance.INTERNAL.registerComponent(
new Component(
AUTH_TYPE,
container => {
// getImmediate for FirebaseApp will always succeed
const app = container.getProvider('app').getImmediate();
return new Auth(app);
},
ComponentType.PUBLIC
)
.setServiceProps({
ActionCodeInfo: {
Operation: {
EMAIL_SIGNIN: externs.Operation.EMAIL_SIGNIN,
PASSWORD_RESET: externs.Operation.PASSWORD_RESET,
RECOVER_EMAIL: externs.Operation.RECOVER_EMAIL,
REVERT_SECOND_FACTOR_ADDITION:
externs.Operation.REVERT_SECOND_FACTOR_ADDITION,
VERIFY_AND_CHANGE_EMAIL: externs.Operation.VERIFY_AND_CHANGE_EMAIL,
VERIFY_EMAIL: externs.Operation.VERIFY_EMAIL
}
}
// TODO(avolkovi): Expose the other top level properties
// EmailAuthProvider,
// FacebookAuthProvider,
// GithubAuthProvider,
// GoogleAuthProvider,
// OAuthProvider,
// SAMLAuthProvider,
// PhoneAuthProvider,
// RecaptchaVerifier,
// TwitterAuthProvider,
// Auth: {
// Persistence
// }
// 'AuthCredential': fireauth.AuthCredential,
// 'Error': fireauth.AuthError
})
.setInstantiationMode(InstantiationMode.LAZY)
.setMultipleInstances(false)
);

instance.registerVersion(name, version);
}

registerAuth(firebase as _FirebaseNamespace);
13 changes: 8 additions & 5 deletions packages-exp/auth-compat-exp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"author": "Firebase <[email protected]> (https://firebase.google.com/)",
"main": "dist/index.node.cjs.js",
"browser": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"module": "dist/index.esm5.js",
"esm2017": "dist/index.esm2017.js",
"react-native": "dist/index.rn.cjs.js",
"files": [
Expand All @@ -16,7 +16,7 @@
"lint": "eslint -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"lint:fix": "eslint --fix -c .eslintrc.js '**/*.ts' --ignore-path '../../.gitignore'",
"build": "rollup -c",
"build:deps": "lerna run --scope @firebase/'{app,auth-compat-exp}' --include-dependencies build",
"build:deps": "lerna run --scope @firebase/'{app,auth-types,auth-exp,auth-types-exp}' --include-dependencies build",
"dev": "rollup -c -w",
"test": "yarn type-check && run-p lint test:browser test:node",
"test:browser": "karma start --single-run",
Expand All @@ -25,10 +25,13 @@
"prepare": "yarn build"
},
"peerDependencies": {
"@firebase/app-exp": "0.x",
"@firebase/app-types-exp": "0.x",
"@firebase/app": "0.x",
"@firebase/auth-types": "0.x",
"@firebase/auth-exp": "0.x",
"@firebase/auth-types-exp": "0.x"
"@firebase/auth-types-exp": "0.x",
"@firebase/component": "0.x",
"@firebase/installations": "0.x",
"@firebase/util": "0.x"
},
"dependencies": {
"tslib": "1.11.1"
Expand Down
10 changes: 9 additions & 1 deletion packages-exp/auth-compat-exp/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* limitations under the License.
*/

import json from 'rollup-plugin-json';
import typescriptPlugin from 'rollup-plugin-typescript2';
import typescript from 'typescript';
import pkg from './package.json';
Expand All @@ -23,10 +24,16 @@ const deps = Object.keys(
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
);

/**
* Common plugins for all builds
*/
const commonPlugins = [json()];

/**
* ES5 Builds
*/
const es5BuildPlugins = [
...commonPlugins,
typescriptPlugin({
typescript
})
Expand All @@ -40,7 +47,7 @@ const es5Builds = [
input: 'index.ts',
output: [
{ file: pkg.browser, format: 'cjs', sourcemap: true },
{ file: pkg.module, format: 'es', sourcemap: true }
{ file: pkg.module, format: 'esm', sourcemap: true }
],
plugins: es5BuildPlugins,
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
Expand Down Expand Up @@ -72,6 +79,7 @@ const es5Builds = [
* ES2017 Builds
*/
const es2017BuildPlugins = [
...commonPlugins,
typescriptPlugin({
typescript,
tsconfigOverride: {
Expand Down
Loading