| 816 | } |
| 817 | |
| 818 | export class OAuthProvider implements IOAuthProvider { |
| 819 | _providerId: string; |
| 820 | _customProvider: boolean; |
| 821 | _builder: com.google.firebase.auth.OAuthProvider.Builder; |
| 822 | constructor(providerId: string) { |
| 823 | this._providerId = providerId; |
| 824 | this._customProvider = false; |
| 825 | } |
| 826 | |
| 827 | get _isCustomProvider() { |
| 828 | return this._customProvider; |
| 829 | } |
| 830 | |
| 831 | addCustomParameter(key: string, value: string) { |
| 832 | if (!this._builder) { |
| 833 | this._builder = com.google.firebase.auth.OAuthProvider.newBuilder(this._providerId); |
| 834 | this._customProvider = true; |
| 835 | } |
| 836 | this._builder.addCustomParameter(key, value); |
| 837 | } |
| 838 | |
| 839 | setScopes(scopes: string[]) { |
| 840 | if (!this._builder) { |
| 841 | this._builder = com.google.firebase.auth.OAuthProvider.newBuilder(this._providerId); |
| 842 | this._customProvider = true; |
| 843 | } |
| 844 | if (Array.isArray(scopes)) { |
| 845 | const array = new java.util.ArrayList<string>(); |
| 846 | scopes.forEach((item) => { |
| 847 | array.add(item); |
| 848 | }); |
| 849 | this._builder.setScopes(array); |
| 850 | } |
| 851 | } |
| 852 | |
| 853 | credential(optionsOrIdToken: OAuthCredentialOptions | string | null, accessToken?: string) { |
| 854 | const builder = com.google.firebase.auth.OAuthProvider.newCredentialBuilder(this._providerId); |
| 855 | if (!optionsOrIdToken && accessToken) { |
| 856 | builder.setAccessToken(accessToken); |
| 857 | } else if (optionsOrIdToken) { |
| 858 | if (typeof optionsOrIdToken === 'string') { |
| 859 | builder.setAccessToken(accessToken); |
| 860 | } else if (typeof optionsOrIdToken === 'object') { |
| 861 | if (optionsOrIdToken.idToken && !optionsOrIdToken.rawNonce) { |
| 862 | builder.setIdToken(optionsOrIdToken.idToken).setAccessToken(optionsOrIdToken.accessToken); |
| 863 | } else if (optionsOrIdToken.idToken && optionsOrIdToken.rawNonce) { |
| 864 | builder.setIdTokenWithRawNonce(optionsOrIdToken.idToken, optionsOrIdToken.rawNonce); |
| 865 | } else { |
| 866 | builder.setAccessToken(optionsOrIdToken.accessToken).setIdTokenWithRawNonce(optionsOrIdToken.idToken, optionsOrIdToken.rawNonce); |
| 867 | } |
| 868 | } |
| 869 | } |
| 870 | return OAuthCredential.fromNative(builder.build() as any); |
| 871 | } |
| 872 | } |
| 873 | |
| 874 | export class TwitterAuthProvider { |
| 875 | static credential(token: string, secret: string) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…