-
-
Notifications
You must be signed in to change notification settings - Fork 888
/
Copy pathindex.js.flow
114 lines (102 loc) · 3.05 KB
/
index.js.flow
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// @flow
import * as React from 'react';
import { typeof View } from 'react-native';
export type ConfigureParams = $ReadOnly<{|
iosClientId?: string,
googleServicePlistPath?: string,
offlineAccess?: boolean,
webClientId?: string,
scopes?: string[],
hostedDomain?: string,
forceCodeForRefreshToken?: boolean,
accountName?: string,
openIdRealm?: string,
profileImageSize?: number,
|}>;
export type SignInParams = $ReadOnly<{|
loginHint?: string,
|}>;
export type AddScopesParams = $ReadOnly<{|
/**
* The Google API scopes to request access to. Default is email and profile.
*/
scopes?: string[],
|}>;
export type GoogleSigninButtonProps = $ReadOnly<{|
...React.ElementConfig<View>,
size?: number,
color?: string,
disabled?: boolean,
onPress?: () => any,
|}>;
declare export class GoogleSigninButton extends React.Component<GoogleSigninButtonProps> {
static Size: {
Icon: number,
Standard: number,
Wide: number,
};
static Color: {
Auto: string,
Light: string,
Dark: string,
};
}
export type HasPlayServicesParams = $ReadOnly<{|
showPlayServicesUpdateDialog: boolean,
|}>;
export type User = {|
user: {|
id: string,
name: ?string, // full name
email: string,
photo: ?string, // url
familyName: ?string,
givenName: ?string,
|},
scopes: string[], // on iOS this is empty array if no additional scopes are defined
idToken: string,
/**
* Not null only if a valid webClientId and offlineAccess: true was
* specified in configure().
*/
serverAuthCode: ?string,
|};
// Android Status codes: https://developers.google.com/android/reference/com/google/android/gms/auth/api/signin/GoogleSignInStatusCodes
type StatusCodes = $ReadOnly<{
SIGN_IN_CANCELLED: string,
IN_PROGRESS: string,
PLAY_SERVICES_NOT_AVAILABLE: string,
SIGN_IN_REQUIRED: string,
}>;
declare export var statusCodes: StatusCodes;
export type SignInSuccessResponse = {|
type: 'success';
data: User;
|};
export type CancelledResponse = {|
type: 'cancelled';
data: null;
|};
export type NoSavedCredentialFound = {|
type: 'noSavedCredentialFound';
data: null;
|};
export type SignInResponse = SignInSuccessResponse | CancelledResponse;
export type SignInSilentlyResponse =
| SignInSuccessResponse
| NoSavedCredentialFound;
// the functions are not static class functions in fact
// but using static keyword works well for this case
declare export class GoogleSignin {
static hasPlayServices: (params?: HasPlayServicesParams) => Promise<boolean>;
static configure: (params?: ConfigureParams) => void;
static signInSilently: () => Promise<SignInSilentlyResponse>;
static signIn: (params?: SignInParams) => Promise<SignInResponse>;
static addScopes: (params: AddScopesParams) => Promise<SignInResponse | null>;
static signOut: () => Promise<null>;
static revokeAccess: () => Promise<null>;
static hasPreviousSignIn: () => boolean;
static getCurrentUser(): User | null;
static clearCachedAccessToken(token: string): Promise<null>;
static getTokens(): Promise<{ idToken: string, accessToken: string }>;
}