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BACxC,IAAI,CAAC,cAAc,KAAK,KAAK,CAAC,cAAc,CAC7C,CAAC;SACH;aAAM;YACL,OAAO,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC;SAC3B;IACH,CAAC;IAED,MAAM;QACJ,IAAI,IAAI,GAAQ,IAAI,CAAC,IAAI,CAAC;QAC1B,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACjC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;SAC3B;QAED,OAAO;YACL,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,IAAI;YACJ,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CAAC;IACJ,CAAC;CACF;AAED,eAAe,UAAU,CAAC","sourcesContent":["import { UnavailabilityError } from '@unimodules/core';\n\nimport ExpoGoogleSignIn from './ExpoGoogleSignIn';\nimport GoogleAuthentication from './GoogleAuthentication';\nimport GoogleIdentity from './GoogleIdentity';\n\nclass GoogleUser extends GoogleIdentity {\n auth: GoogleAuthentication | null;\n scopes: string[];\n hostedDomain?: string;\n serverAuthCode?: string;\n\n constructor(options) {\n super(options);\n const { auth, scopes, hostedDomain, serverAuthCode } = options;\n\n this.auth = auth;\n this.scopes = scopes;\n this.hostedDomain = hostedDomain;\n this.serverAuthCode = serverAuthCode;\n }\n\n clearCache = async () => {\n if (!ExpoGoogleSignIn.clearCacheAsync) {\n return;\n }\n if (!this.auth || !this.auth.accessToken) {\n throw new Error('GoogleSignIn: GoogleUser.clearCache(): Invalid accessToken');\n }\n return await ExpoGoogleSignIn.clearCacheAsync({ token: this.auth.accessToken });\n };\n\n getHeaders = (): {\n [key: string]: string;\n } => {\n if (!this.auth || !this.auth.accessToken || !this.auth.accessToken.length) {\n throw new Error('GoogleSignIn: GoogleUser.getHeaders(): Invalid accessToken');\n }\n return {\n Authorization: `Bearer ${this.auth.accessToken}`,\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n };\n };\n\n refreshAuth = async (): Promise<GoogleAuthentication | null> => {\n if (!ExpoGoogleSignIn.getTokensAsync) {\n throw new UnavailabilityError('GoogleSignIn', 'getTokensAsync');\n }\n const response: {\n idToken?: string;\n accessToken?: string;\n auth?: {\n accessToken?: string;\n };\n } = await ExpoGoogleSignIn.getTokensAsync(false);\n if (response.idToken == null && this.auth) {\n response.idToken = this.auth.idToken;\n }\n if (!this.auth) {\n this.auth = new GoogleAuthentication(response);\n } else {\n this.auth.idToken = response.idToken;\n this.auth.accessToken = response.accessToken;\n }\n return this.auth;\n };\n\n equals(other: any): boolean {\n if (!super.equals(other) || !(other instanceof GoogleUser)) {\n return false;\n }\n\n if (this.auth != null) {\n return (\n this.auth.equals(other.auth) &&\n this.scopes === other.scopes &&\n this.hostedDomain === other.hostedDomain &&\n this.serverAuthCode === other.serverAuthCode\n );\n } else {\n return other.auth == null;\n }\n }\n\n toJSON(): { [key: string]: any } {\n let auth: any = this.auth;\n if (this.auth && this.auth.toJSON) {\n auth = this.auth.toJSON();\n }\n\n return {\n ...super.toJSON(),\n auth,\n scopes: this.scopes,\n hostedDomain: this.hostedDomain,\n serverAuthCode: this.serverAuthCode,\n };\n }\n}\n\nexport default GoogleUser;\n"]}
\No newline at end of file