From 83faa863334df376dccbed36fec0ca95662dd331 Mon Sep 17 00:00:00 2001 From: Chris Bianca Date: Sat, 23 Sep 2017 16:14:35 +0100 Subject: [PATCH] [auth] Add unsupported method errors for auth() and User --- lib/internals.js | 21 ++++++++++ lib/modules/auth/index.js | 25 +++++++++++ lib/modules/auth/user.js | 42 +++++++++++++++++++ package-lock.json | 2 +- .../project.pbxproj | 29 ++++++++++--- 5 files changed, 113 insertions(+), 6 deletions(-) diff --git a/lib/internals.js b/lib/internals.js index 3c0a6d52..b729e489 100644 --- a/lib/internals.js +++ b/lib/internals.js @@ -124,6 +124,27 @@ export default { return `Invalid FirebaseApp instance passed to firebase.${namespace}(app <--).`; }, + /** + * @return {string} + */ + ERROR_UNSUPPORTED_CLASS_METHOD(classname, method) { + return `${classname}.${method}() is unsupported by the native Firebase SDKs.`; + }, + + /** + * @return {string} + */ + ERROR_UNSUPPORTED_CLASS_PROPERTY(classname, property) { + return `${classname}.${property} is unsupported by the native Firebase SDKs.`; + }, + + /** + * @return {string} + */ + ERROR_UNSUPPORTED_MODULE_METHOD(module, method) { + return `firebase.${module._NAMESPACE}().${method}() is unsupported by the native Firebase SDKs.`; + }, + DEFAULT_APP_NAME, }, diff --git a/lib/modules/auth/index.js b/lib/modules/auth/index.js index c492c658..e81e1c6c 100644 --- a/lib/modules/auth/index.js +++ b/lib/modules/auth/index.js @@ -1,6 +1,7 @@ // @flow import User from './user'; import ModuleBase from './../../utils/ModuleBase'; +import INTERNALS from './../../internals'; import ConfirmationResult from './ConfirmationResult'; // providers @@ -269,6 +270,30 @@ export default class Auth extends ModuleBase { get namespace(): string { return 'firebase:auth'; } + + /** + * KNOWN UNSUPPORTED METHODS + */ + + getRedirectResult() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_MODULE_METHOD(Auth, 'getRedirectResult')); + } + + setPersistence() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_MODULE_METHOD(Auth, 'setPersistence')); + } + + signInAndRetrieveDataWithCredential() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_MODULE_METHOD(Auth, 'signInAndRetrieveDataWithCredential')); + } + + signInWithPopup() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_MODULE_METHOD(Auth, 'signInWithPopup')); + } + + signInWithRedirect() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_MODULE_METHOD(Auth, 'signInWithRedirect')); + } } export const statics = { diff --git a/lib/modules/auth/user.js b/lib/modules/auth/user.js index 8a973c09..95f64206 100644 --- a/lib/modules/auth/user.js +++ b/lib/modules/auth/user.js @@ -1,3 +1,5 @@ +import INTERNALS from './../../internals'; + /** * @url https://firebase.google.com/docs/reference/js/firebase.User */ @@ -197,4 +199,44 @@ export default class User { sendEmailVerification(): Promise { return this._auth._interceptUserValue(this._auth._native.sendEmailVerification()); } + + /** + * KNOWN UNSUPPORTED METHODS + */ + + linkAndRetrieveDataWithCredential() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_METHOD('User', 'linkAndRetrieveDataWithCredential')); + } + + linkWithPhoneNumber() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_METHOD('User', 'linkWithPhoneNumber')); + } + + linkWithPopup() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_METHOD('User', 'linkWithPopup')); + } + + linkWithRedirect() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_METHOD('User', 'linkWithRedirect')); + } + + reauthenticateWithPhoneNumber() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_METHOD('User', 'reauthenticateWithPhoneNumber')); + } + + reauthenticateWithPopup() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_METHOD('User', 'reauthenticateWithPopup')); + } + + reauthenticateWithRedirect() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_METHOD('User', 'reauthenticateWithRedirect')); + } + + updatePhoneNumber() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_METHOD('User', 'updatePhoneNumber')); + } + + get refreshToken() { + throw new Error(INTERNALS.STRINGS.ERROR_UNSUPPORTED_CLASS_PROPERTY('User', 'refreshToken')); + } } diff --git a/package-lock.json b/package-lock.json index eb03c8a0..693ef25d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-native-firebase", - "version": "2.1.3", + "version": "3.0.0-alpha.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/tests/ios/ReactNativeFirebaseDemo.xcodeproj/project.pbxproj b/tests/ios/ReactNativeFirebaseDemo.xcodeproj/project.pbxproj index fa0e9847..a84edf5d 100644 --- a/tests/ios/ReactNativeFirebaseDemo.xcodeproj/project.pbxproj +++ b/tests/ios/ReactNativeFirebaseDemo.xcodeproj/project.pbxproj @@ -28,7 +28,7 @@ 2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; 2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; 2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; - 2D02E4C21E0B4AEC006451C7 /* libRCTAnimation-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */; }; + 2D02E4C21E0B4AEC006451C7 /* libRCTAnimation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation.a */; }; 2D02E4C31E0B4AEC006451C7 /* libRCTImage-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E841DF850E9000B6D8A /* libRCTImage-tvOS.a */; }; 2D02E4C41E0B4AEC006451C7 /* libRCTLinking-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E881DF850E9000B6D8A /* libRCTLinking-tvOS.a */; }; 2D02E4C51E0B4AEC006451C7 /* libRCTNetwork-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAD3E8C1DF850E9000B6D8A /* libRCTNetwork-tvOS.a */; }; @@ -347,7 +347,7 @@ buildActionMask = 2147483647; files = ( 2D02E4C91E0B4AEC006451C7 /* libReact.a in Frameworks */, - 2D02E4C21E0B4AEC006451C7 /* libRCTAnimation-tvOS.a in Frameworks */, + 2D02E4C21E0B4AEC006451C7 /* libRCTAnimation.a in Frameworks */, 2D02E4C31E0B4AEC006451C7 /* libRCTImage-tvOS.a in Frameworks */, 2D02E4C41E0B4AEC006451C7 /* libRCTLinking-tvOS.a in Frameworks */, 2D02E4C51E0B4AEC006451C7 /* libRCTNetwork-tvOS.a in Frameworks */, @@ -496,7 +496,7 @@ isa = PBXGroup; children = ( 5E9157331DD0AC6500FF2AA8 /* libRCTAnimation.a */, - 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */, + 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation.a */, ); name = Products; sourceTree = ""; @@ -540,6 +540,15 @@ name = Products; sourceTree = ""; }; + 838F3D091F750EBA00EE5285 /* Recovered References */ = { + isa = PBXGroup; + children = ( + 0C76E33ACF004369AEB318B1 /* libRNVectorIcons.a */, + BBEE706291534F5F948A3805 /* libLRDRCTSimpleToast.a */, + ); + name = "Recovered References"; + sourceTree = ""; + }; 83CBB9F61A601CBA00E9B192 = { isa = PBXGroup; children = ( @@ -550,6 +559,7 @@ F50F62EA16044AFF8BD7CF63 /* Resources */, 0D55D6BB72314357439E4EE9 /* Pods */, 3F2926F67DDFAB9753757355 /* Frameworks */, + 838F3D091F750EBA00EE5285 /* Recovered References */, ); indentWidth = 2; sourceTree = ""; @@ -566,6 +576,15 @@ name = Products; sourceTree = ""; }; + 83F533111F76A95B0008C1A5 /* Recovered References */ = { + isa = PBXGroup; + children = ( + 0C76E33ACF004369AEB318B1 /* libRNVectorIcons.a */, + BBEE706291534F5F948A3805 /* libLRDRCTSimpleToast.a */, + ); + name = "Recovered References"; + sourceTree = ""; + }; 99788FE61E69DE2900F6820C /* Products */ = { isa = PBXGroup; children = ( @@ -943,10 +962,10 @@ remoteRef = 5E9157321DD0AC6500FF2AA8 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; }; - 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation-tvOS.a */ = { + 5E9157351DD0AC6500FF2AA8 /* libRCTAnimation.a */ = { isa = PBXReferenceProxy; fileType = archive.ar; - path = "libRCTAnimation-tvOS.a"; + path = libRCTAnimation.a; remoteRef = 5E9157341DD0AC6500FF2AA8 /* PBXContainerItemProxy */; sourceTree = BUILT_PRODUCTS_DIR; };