|
1 |
| -import qs from 'qs'; |
| 1 | +declare function authorizationCode(axios: any, url: any, client_id: any, client_secret: any, redirect_uri: any, code?: any, scope?: any): (code?: any, scope?: any) => any; |
2 | 2 |
|
3 |
| -function oauth(axios, { url, ...credentials }) { |
4 |
| - return (moreCredentials = {}) => { |
5 |
| - const body = { |
6 |
| - ...credentials, |
7 |
| - ...moreCredentials |
8 |
| - }; |
9 |
| - if ("scope" in body && !body.scope) { |
10 |
| - delete body.scope; |
11 |
| - } |
12 |
| - return axios({ |
13 |
| - url, |
14 |
| - method: "post", |
15 |
| - data: qs.stringify(body) |
16 |
| - }).then((res) => res.data); |
17 |
| - }; |
18 |
| -} |
19 |
| - |
20 |
| -function authorizationCode(axios, url, client_id, client_secret, redirect_uri, code = null, scope = null) { |
21 |
| - const grant = oauth(axios, { |
22 |
| - url, |
23 |
| - grant_type: "authorization_code", |
24 |
| - client_id, |
25 |
| - client_secret, |
26 |
| - redirect_uri, |
27 |
| - code, |
28 |
| - scope |
29 |
| - }); |
30 |
| - return (code2 = null, scope2 = null) => grant({ code: code2, scope: scope2 }); |
31 |
| -} |
| 3 | +declare function clientCredentials(axios: any, url: any, client_id: any, client_secret: any, scope?: any): (scope: any) => any; |
32 | 4 |
|
33 |
| -function clientCredentials(axios, url, client_id, client_secret, scope = null) { |
34 |
| - const grant = oauth(axios, { |
35 |
| - url, |
36 |
| - grant_type: "client_credentials", |
37 |
| - client_id, |
38 |
| - client_secret, |
39 |
| - scope |
40 |
| - }); |
41 |
| - return (scope2) => grant(scope2 ? { scope: scope2 } : null); |
42 |
| -} |
| 5 | +declare function ownerCredentials(axios: any, url: any, client_id: any, client_secret: any, username?: any, password?: any, scope?: any): (username?: any, password?: any, scope?: any) => any; |
43 | 6 |
|
44 |
| -function ownerCredentials(axios, url, client_id, client_secret, username = null, password = null, scope = null) { |
45 |
| - const grant = oauth(axios, { |
46 |
| - url, |
47 |
| - grant_type: "password", |
48 |
| - client_id, |
49 |
| - client_secret, |
50 |
| - username, |
51 |
| - password, |
52 |
| - scope |
53 |
| - }); |
54 |
| - return (username2 = null, password2 = null, scope2 = null) => grant({ username: username2, password: password2, scope: scope2 }); |
55 |
| -} |
| 7 | +declare function refreshToken(axios: any, url: any, client_id: any, client_secret: any, refresh_token?: any, scope?: any): (refresh_token?: any, scope?: any) => any; |
56 | 8 |
|
57 |
| -function refreshToken(axios, url, client_id, client_secret, refresh_token = null, scope = null) { |
58 |
| - const grant = oauth(axios, { |
59 |
| - url, |
60 |
| - grant_type: "refresh_token", |
61 |
| - client_id, |
62 |
| - client_secret, |
63 |
| - refresh_token, |
64 |
| - scope |
65 |
| - }); |
66 |
| - return (refresh_token2 = null, scope2 = null) => grant({ refresh_token: refresh_token2, scope: scope2 }); |
| 9 | +declare namespace _default { |
| 10 | + export { authorizationCode }; |
| 11 | + export { clientCredentials }; |
| 12 | + export { ownerCredentials }; |
| 13 | + export { refreshToken }; |
67 | 14 | }
|
68 | 15 |
|
69 |
| -var index = { |
70 |
| - authorizationCode, |
71 |
| - clientCredentials, |
72 |
| - ownerCredentials, |
73 |
| - refreshToken |
74 |
| -}; |
75 |
| - |
76 |
| -export { index as default }; |
| 16 | +export { _default as default }; |
0 commit comments