@@ -2,7 +2,14 @@ import * as appModule from "tns-core-modules/application";
22import { AndroidActivityResultEventData } from "tns-core-modules/application" ;
33import lazy from "tns-core-modules/utils/lazy" ;
44import { ad as AndroidUtils } from "tns-core-modules/utils/utils" ;
5- import { DataSnapshot , firestore , OnDisconnect as OnDisconnectBase , User } from "./firebase" ;
5+ import {
6+ DataSnapshot ,
7+ firestore ,
8+ GetAuthTokenOptions ,
9+ GetAuthTokenResult ,
10+ OnDisconnect as OnDisconnectBase ,
11+ User
12+ } from "./firebase" ;
613import {
714 DocumentSnapshot as DocumentSnapshotBase ,
815 FieldValue ,
@@ -128,7 +135,7 @@ firebase.toHashMap = obj => {
128135 if ( fieldValue . type === "ARRAY_UNION" ) {
129136 // nested arrays are not allowed, so harden against wrong usage: arrayUnion(["foo", "bar"]) vs arrayUnion("foo", "bar")
130137 let values : Array < any > = Array . isArray ( fieldValue . value [ 0 ] ) ? fieldValue . value [ 0 ] : fieldValue . value ;
131- values = values . map ( v => typeof ( v ) === "object" ? firebase . toHashMap ( v ) : v ) ;
138+ values = values . map ( v => typeof ( v ) === "object" ? firebase . toHashMap ( v ) : v ) ;
132139 node . put ( property , com . google . firebase . firestore . FieldValue . arrayUnion ( values ) ) ;
133140 } else if ( fieldValue . type === "ARRAY_REMOVE" ) {
134141 node . put ( property , com . google . firebase . firestore . FieldValue . arrayRemove ( Array . isArray ( fieldValue . value [ 0 ] ) ? fieldValue . value [ 0 ] : fieldValue . value ) ) ;
@@ -696,26 +703,19 @@ firebase.unlink = providerId => {
696703 } ) ;
697704} ;
698705
699- firebase . getAuthToken = arg => {
706+ firebase . getAuthToken = ( arg : GetAuthTokenOptions ) : Promise < GetAuthTokenResult > => {
700707 return new Promise ( ( resolve , reject ) => {
701708 try {
702709 const firebaseAuth = com . google . firebase . auth . FirebaseAuth . getInstance ( ) ;
703710 const user = firebaseAuth . getCurrentUser ( ) ;
704711 if ( user !== null ) {
705712 const onSuccessListener = new gmsTasks . OnSuccessListener ( {
706- onSuccess : getTokenResult => {
707- if ( arg . withClaims ) {
708- /* get token and custom claims previously set via the Firebase Admin SDK. */
709- resolve (
710- {
711- token : getTokenResult . getToken ( ) ,
712- claims : getTokenResult . getClaims ( )
713- }
714- ) ;
715- } else {
716- /* get just token without custom claims */
717- resolve ( getTokenResult . getToken ( ) ) ;
718- }
713+ onSuccess : tokenResult => {
714+ resolve ( {
715+ token : tokenResult . getToken ( ) ,
716+ claims : firebase . toJsObject ( tokenResult . getClaims ( ) ) ,
717+ signInProvider : tokenResult . getSignInProvider ( )
718+ } ) ;
719719 }
720720 } ) ;
721721
0 commit comments