-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly generate typescript definitions
Resolves #21
- Loading branch information
Jonathon Hill
committed
Dec 8, 2022
1 parent
c0d7072
commit 563b125
Showing
2 changed files
with
19 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,16 @@ | ||
import qs from 'qs'; | ||
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; | ||
|
||
function oauth(axios, { url, ...credentials }) { | ||
return (moreCredentials = {}) => { | ||
const body = { | ||
...credentials, | ||
...moreCredentials | ||
}; | ||
if ("scope" in body && !body.scope) { | ||
delete body.scope; | ||
} | ||
return axios({ | ||
url, | ||
method: "post", | ||
data: qs.stringify(body) | ||
}).then((res) => res.data); | ||
}; | ||
} | ||
|
||
function authorizationCode(axios, url, client_id, client_secret, redirect_uri, code = null, scope = null) { | ||
const grant = oauth(axios, { | ||
url, | ||
grant_type: "authorization_code", | ||
client_id, | ||
client_secret, | ||
redirect_uri, | ||
code, | ||
scope | ||
}); | ||
return (code2 = null, scope2 = null) => grant({ code: code2, scope: scope2 }); | ||
} | ||
declare function clientCredentials(axios: any, url: any, client_id: any, client_secret: any, scope?: any): (scope: any) => any; | ||
|
||
function clientCredentials(axios, url, client_id, client_secret, scope = null) { | ||
const grant = oauth(axios, { | ||
url, | ||
grant_type: "client_credentials", | ||
client_id, | ||
client_secret, | ||
scope | ||
}); | ||
return (scope2) => grant(scope2 ? { scope: scope2 } : null); | ||
} | ||
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; | ||
|
||
function ownerCredentials(axios, url, client_id, client_secret, username = null, password = null, scope = null) { | ||
const grant = oauth(axios, { | ||
url, | ||
grant_type: "password", | ||
client_id, | ||
client_secret, | ||
username, | ||
password, | ||
scope | ||
}); | ||
return (username2 = null, password2 = null, scope2 = null) => grant({ username: username2, password: password2, scope: scope2 }); | ||
} | ||
declare function refreshToken(axios: any, url: any, client_id: any, client_secret: any, refresh_token?: any, scope?: any): (refresh_token?: any, scope?: any) => any; | ||
|
||
function refreshToken(axios, url, client_id, client_secret, refresh_token = null, scope = null) { | ||
const grant = oauth(axios, { | ||
url, | ||
grant_type: "refresh_token", | ||
client_id, | ||
client_secret, | ||
refresh_token, | ||
scope | ||
}); | ||
return (refresh_token2 = null, scope2 = null) => grant({ refresh_token: refresh_token2, scope: scope2 }); | ||
declare namespace _default { | ||
export { authorizationCode }; | ||
export { clientCredentials }; | ||
export { ownerCredentials }; | ||
export { refreshToken }; | ||
} | ||
|
||
var index = { | ||
authorizationCode, | ||
clientCredentials, | ||
ownerCredentials, | ||
refreshToken | ||
}; | ||
|
||
export { index as default }; | ||
export { _default as default }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": true, | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"outDir": "dist", | ||
"declarationMap": true | ||
} | ||
} |