-
Notifications
You must be signed in to change notification settings - Fork 115
/
definitions.ts
168 lines (160 loc) · 5.33 KB
/
definitions.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
export interface OAuth2ClientPlugin {
/**
* Authenticate against a OAuth 2 provider.
* @param {OAuth2AuthenticateOptions} options
* @returns {Promise<any>} the resource url response
*/
authenticate(options: OAuth2AuthenticateOptions): Promise<any>;
/**
* Get a new access token based on the given refresh token.
* @param {OAuth2RefreshTokenOptions} options
* @returns {Promise<any>} the token endpoint response
*/
refreshToken(options: OAuth2RefreshTokenOptions): Promise<any>;
/**
* Logout from the authenticated OAuth 2 provider
* @param {OAuth2AuthenticateOptions} options Although not all options are needed. We simply reuse the options from authenticate
* @param {String} id_token Optional idToken, only for Android
* @returns {Promise<boolean>} true if the logout was successful else false.
*/
logout(options: OAuth2AuthenticateOptions, id_token?: string): Promise<boolean>;
}
export interface OAuth2RefreshTokenOptions {
/**
* The app id (client id) you get from the oauth provider like Google, Facebook,...
*/
appId: string;
/**
* Url for retrieving the access_token.
*/
accessTokenEndpoint: string;
/**
* The refresh token that will be used to obtain the new access token.
*/
refreshToken: string;
/**
* A space-delimited list of permissions that identify the resources that your application could access on the user's behalf.
*/
scope?: string;
}
export interface OAuth2AuthenticateBaseOptions {
/**
* The app id (client id) you get from the oauth provider like Google, Facebook,...
*
* required!
*/
appId?: string;
/**
* The base url for retrieving tokens depending on the response type from a OAuth 2 provider. e.g. https://accounts.google.com/o/oauth2/auth
*
* required!
*/
authorizationBaseUrl?: string;
/**
* Tells the authorization server which grant to execute. Be aware that a full code flow is not supported as clientCredentials are not included in requests.
*
* But you can retrieve the authorizationCode if you don't set a accessTokenEndpoint.
*
* required!
*/
responseType?: string;
/**
* Url to which the oauth provider redirects after authentication.
*
* required!
*/
redirectUrl?: string;
/**
* Url for retrieving the access_token by the authorization code flow.
*/
accessTokenEndpoint?: string;
/**
* Protected resource url. For authentication you only need the basic user details.
*/
resourceUrl?: string;
/**
* Enable PKCE if you need it.
*/
pkceEnabled?: boolean;
/**
* A space-delimited list of permissions that identify the resources that your application could access on the user's behalf.
* If you want to get a refresh token, you most likely will need the offline_access scope (only supported in Code Flow!)
*/
scope?: string;
/**
* A unique alpha numeric string used to prevent CSRF. If not set the plugin automatically generate a string
* and sends it as using state is recommended.
*/
state?: string;
/**
* Additional parameters for the created authorization url
*/
additionalParameters?: { [key: string]: string }
/**
* @since 3.0.0
*/
logsEnabled?: boolean;
/**
* @since 3.1.0 ... not implemented yet!
*/
logoutUrl?: string;
/**
* Additional headers for resource url request
* @since 3.0.0
*/
additionalResourceHeaders?: { [key: string]: string }
}
export interface OAuth2AuthenticateOptions extends OAuth2AuthenticateBaseOptions {
/**
* Custom options for the platform "web"
*/
web?: WebOption,
/**
* Custom options for the platform "android"
*/
android?: AndroidOptions,
/**
* Custom options for the platform "ios"
*/
ios?: IosOptions
}
export interface WebOption extends OAuth2AuthenticateBaseOptions {
/**
* Options for the window the plugin open for authentication. e.g. width=500,height=600,left=0,top=0
*/
windowOptions?: string;
/**
* Options for the window target. Defaults to _blank
*/
windowTarget?: string;
}
export interface AndroidOptions extends OAuth2AuthenticateBaseOptions {
/**
* Some oauth provider especially Facebook forces us to use their SDK for apps.
*
* Provide a class name implementing the 'ByteowlsCapacitorOauth2.OAuth2CustomHandler' protocol.
*/
customHandlerClass?: string;
/**
* Alternative to handle the activity result. The `onNewIntent` method is only call if the App was killed while logging in.
*/
handleResultOnNewIntent?: boolean;
/**
* Default handling the activity result.
*/
handleResultOnActivityResult?: boolean;
}
export interface IosOptions extends OAuth2AuthenticateBaseOptions {
/**
* If true the iOS 13+ feature Sign in with Apple (SiWA) try to build the scope from the standard "scope" parameter.
*
* If false scope is set to email and fullName.
*/
siwaUseScope?: boolean
/**
* Some oauth provider especially Facebook forces us to use their SDK for apps.
*
* Provide a class name implementing the 'ByteowlsCapacitorOauth2.OAuth2CustomHandler' protocol.
*/
customHandlerClass?: string;
}