Skip to content

Commit

Permalink
fix: correctly generate typescript definitions
Browse files Browse the repository at this point in the history
Resolves #21
  • Loading branch information
Jonathon Hill committed Dec 8, 2022
1 parent c0d7072 commit 563b125
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 70 deletions.
80 changes: 10 additions & 70 deletions dist/index.d.ts
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 };
9 changes: 9 additions & 0 deletions tsconfig.json
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
}
}

0 comments on commit 563b125

Please sign in to comment.