-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
184 lines (166 loc) · 5.53 KB
/
index.d.ts
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/* eslint-disable max-classes-per-file */
// Type definitions for react-google-login v2.5.4
// Project: https://github.com/anthonyjgrove/react-google-login
// Definitions by: Ruslan Ibragimov <https://github.com/IRus>
import {Component, ReactNode, CSSProperties} from 'react';
export as namespace ReactGoogleLogin;
interface AuthResponse {
readonly access_token: string;
readonly id_token: string;
readonly login_hint: string;
readonly scope: string;
readonly expires_in: number;
readonly first_issued_at: number;
readonly expires_at: number;
}
interface BasicProfile {
getId(): string;
getEmail(): string;
getName(): string;
getGivenName(): string;
getFamilyName(): string;
getImageUrl(): string;
}
// Based on https://developers.google.com/identity/sign-in/web/reference
export interface GoogleLoginResponse {
getBasicProfile(): BasicProfile;
getAuthResponse(includeAuthorizationData?: boolean): AuthResponse;
reloadAuthResponse(): Promise<AuthResponse>;
getGrantedScopes(): string;
getHostedDomain(): string;
getId(): string;
isSignedIn(): boolean;
hasGrantedScopes(scopes: string): boolean;
disconnect(): void;
grantOfflineAccess(options: GrantOfflineAccessOptions): Promise<GoogleLoginResponseOffline>;
signIn(options: SignInOptions): Promise<any>;
grant(options: SignInOptions): Promise<any>;
// google-login.js sez: offer renamed response keys to names that match use
googleId: string;
tokenObj: AuthResponse;
tokenId: string;
accessToken: string;
readonly code?: string;//does not exist but here to satisfy typescript compatibility
profileObj: {
googleId: string;
imageUrl: string;
email: string;
name: string;
givenName: string;
familyName: string;
}
}
interface GrantOfflineAccessOptions {
readonly scope?: string;
readonly redirect_uri?: string;
}
interface SignInOptions {
readonly scope?: string;
readonly app_package_name?: string;
readonly fetch_basic_profile?: boolean;
readonly prompt?: string;
}
export interface GoogleLoginResponseOffline {
readonly code: string;
}
export interface GoogleLoginProps {
readonly onSuccess?: (response: GoogleLoginResponse | GoogleLoginResponseOffline) => void,
readonly onAutoLoadFinished?: (successLogin: boolean) => void,
readonly onFailure?: (error: any) => void,
readonly onScriptLoadFailure?: (error: any) => void,
readonly onRequest?: () => void,
readonly clientId: string,
readonly jsSrc?: string,
readonly buttonText?: string,
readonly scope?: string,
readonly className?: string,
readonly redirectUri?: string,
readonly cookiePolicy?: string,
readonly loginHint?: string,
readonly hostedDomain?: string,
readonly prompt?: string,
readonly responseType?: string,
readonly children?: ReactNode,
readonly style?: CSSProperties,
readonly icon?: boolean,
readonly theme?: "light" | "dark",
readonly tag?: string,
readonly disabled?: boolean;
readonly autoLoad?: boolean;
readonly uxMode?: string;
readonly disabledStyle?: CSSProperties;
readonly fetchBasicProfile?: boolean;
readonly isSignedIn?: boolean;
readonly type?: string;
readonly accessType?: string;
readonly render?: (props: { onClick: () => void, disabled?: boolean }) => JSX.Element;
}
export class GoogleLogin extends Component<GoogleLoginProps, unknown> {
public signIn(e?: Event): void;
}
export interface GoogleLogoutProps {
readonly clientId: string,
readonly onLogoutSuccess?: () => void;
readonly onFailure?: () => void;
readonly buttonText?: string;
readonly className?: string;
readonly children?: ReactNode;
readonly jsSrc?: string;
readonly style?: CSSProperties;
readonly icon?: boolean,
readonly disabled?: boolean;
readonly disabledStyle?: CSSProperties;
readonly tag?: string;
readonly render?: (props: { onClick: () => void, disabled?: boolean }) => JSX.Element;
}
export class GoogleLogout extends Component<GoogleLogoutProps, unknown> {
public signOut(): void;
}
export interface UseGoogleLogoutResponse {
signOut: () => void;
loaded: boolean;
}
export interface UseGoogleLogoutProps {
readonly clientId: string,
readonly onLogoutSuccess?: () => void;
readonly onFailure?: () => void;
readonly accessType?: string;
readonly fetchBasicProfile?: boolean;
readonly cookiePolicy?: string;
readonly loginHint?: string;
readonly hostedDomain?: string;
readonly redirectUri?: string,
readonly discoveryDocs?: any;
readonly scope?: string,
readonly uxMode?: string;
readonly jsSrc?: string;
}
export function useGoogleLogout(input: UseGoogleLogoutProps): UseGoogleLogoutResponse;
export interface UseGoogleLoginResponse {
signIn: () => void;
loaded: boolean;
}
export interface UseGoogleLoginProps {
readonly onSuccess?: (response: GoogleLoginResponse | GoogleLoginResponseOffline) => void,
readonly onFailure?: (error: any) => void,
readonly onScriptLoadFailure?: (error: any) => void,
readonly onAutoLoadFinished?: (successLogin: boolean) => void,
readonly clientId: string,
readonly jsSrc?: string,
readonly onRequest?: () => void,
readonly scope?: string,
readonly redirectUri?: string,
readonly cookiePolicy?: string,
readonly loginHint?: string,
readonly hostedDomain?: string,
readonly prompt?: string,
readonly responseType?: string,
readonly autoLoad?: boolean;
readonly uxMode?: string;
readonly fetchBasicProfile?: boolean;
readonly isSignedIn?: boolean;
readonly discoveryDocs?: any;
readonly accessType?: string;
}
export function useGoogleLogin(input: UseGoogleLoginProps): UseGoogleLoginResponse;
export default GoogleLogin;