Skip to content
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

feat(auth): add initial support for Apple auth provider #2979

Merged
merged 1 commit into from
Dec 7, 2019
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
2 changes: 2 additions & 0 deletions packages/auth/ios/RNFBAuth/RNFBAuthModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,8 @@ - (FIRAuthCredential *)getCredentialForProvider:(NSString *)provider token:(NSSt
credential = [FIRFacebookAuthProvider credentialWithAccessToken:authToken];
} else if ([provider compare:@"google.com" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
credential = [FIRGoogleAuthProvider credentialWithIDToken:authToken accessToken:authTokenSecret];
} else if ([provider compare:@"apple.com" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
credential = [FIROAuthProvider credentialWithProviderID:provider IDToken:authToken rawNonce:authTokenSecret];
} else if ([provider compare:@"password" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
credential = [FIREmailAuthProvider credentialWithEmail:authToken password:authTokenSecret];
} else if ([provider compare:@"emailLink" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
Expand Down
10 changes: 10 additions & 0 deletions packages/auth/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@ export namespace FirebaseAuthTypes {
* ```
*/
GoogleAuthProvider: AuthProvider;
/**
* Apple auth provider implementation.
*
* #### Example
*
* ```js
* firebase.auth.AppleAuthProvider;
* ```
*/
AppleAuthProvider: AuthProvider;
/**
* Github auth provider implementation.
*
Expand Down
2 changes: 2 additions & 0 deletions packages/auth/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ import GoogleAuthProvider from './providers/GoogleAuthProvider';
import OAuthProvider from './providers/OAuthProvider';
import PhoneAuthProvider from './providers/PhoneAuthProvider';
import TwitterAuthProvider from './providers/TwitterAuthProvider';
import AppleAuthProvider from './providers/AppleAuthProvider';
import Settings from './Settings';
import User from './User';
import version from './version';

const statics = {
AppleAuthProvider,
EmailAuthProvider,
PhoneAuthProvider,
GoogleAuthProvider,
Expand Down
36 changes: 36 additions & 0 deletions packages/auth/lib/providers/AppleAuthProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2016-present Invertase Limited & Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this library except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

const providerId = 'apple.com';

export default class AppleAuthProvider {
constructor() {
throw new Error('`new AppleAuthProvider()` is not supported on the native Firebase SDKs.');
}

static get PROVIDER_ID() {
return providerId;
}

static credential(token, secret) {
return {
token,
secret,
providerId,
};
}
}