| 768 | } |
| 769 | |
| 770 | export class OAuthProvider implements IOAuthProvider { |
| 771 | _providerId: string; |
| 772 | _customParameters: { [key: string]: string }; |
| 773 | _scopes: string[]; |
| 774 | constructor(providerId: string) { |
| 775 | this._providerId = providerId; |
| 776 | this._customParameters = {}; |
| 777 | this._scopes = []; |
| 778 | } |
| 779 | |
| 780 | get _builder() { |
| 781 | const builder = FIROAuthProvider.providerWithProviderID(this._providerId); |
| 782 | builder.customParameters = this._customParameters as any; |
| 783 | builder.scopes = this._scopes as any; |
| 784 | return builder; |
| 785 | } |
| 786 | |
| 787 | addCustomParameter(key: string, value: string) { |
| 788 | this._customParameters[key] = value; |
| 789 | } |
| 790 | |
| 791 | setScopes(scopes: string[]) { |
| 792 | if (Array.isArray(scopes)) { |
| 793 | this._scopes = scopes; |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | credential(optionsOrIdToken: OAuthCredentialOptions | string | null, accessToken?: string) { |
| 798 | let provider; |
| 799 | if (!optionsOrIdToken && accessToken) { |
| 800 | provider = FIROAuthProvider.credentialWithProviderIDAccessToken(this._providerId, accessToken); |
| 801 | } else if (optionsOrIdToken) { |
| 802 | if (typeof optionsOrIdToken === 'string') { |
| 803 | provider = FIROAuthProvider.credentialWithProviderIDAccessToken(this._providerId, optionsOrIdToken); |
| 804 | } else if (typeof optionsOrIdToken === 'object') { |
| 805 | if (optionsOrIdToken.idToken && !optionsOrIdToken.rawNonce) { |
| 806 | provider = FIROAuthProvider.credentialWithProviderIDIDTokenAccessToken(this._providerId, optionsOrIdToken.idToken, optionsOrIdToken.accessToken); |
| 807 | } else if (optionsOrIdToken.idToken && optionsOrIdToken.rawNonce) { |
| 808 | provider = FIROAuthProvider.credentialWithProviderIDIDTokenRawNonce(this._providerId, optionsOrIdToken.idToken, optionsOrIdToken.rawNonce); |
| 809 | } else { |
| 810 | provider = FIROAuthProvider.credentialWithProviderIDIDTokenRawNonceAccessToken(this._providerId, optionsOrIdToken.idToken, optionsOrIdToken.rawNonce, optionsOrIdToken.accessToken); |
| 811 | } |
| 812 | } |
| 813 | } |
| 814 | return OAuthCredential.fromNative(provider); |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | export class TwitterAuthProvider { |
| 819 | static credential(token: string, secret: string) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…