Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated sqlite3 version #73

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"form-data": "^2.3.3",
"got": "^9.4.0",
"node-stream-zip": "^1.3.7",
"sqlite3": "^4.0.2"
"sqlite3": "^5.1.2"
},
"devDependencies": {
"@babel/core": "^7.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/HttpService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class HTTPService {
});
}

public post(url: string, data: got.GotJSONOptions): Promise<object> {
public post(url: string, data: got.GotFormOptions<string>): Promise<object> {
if (this.debug) {
Logger.debug(`POST - ${url}`);
}
Expand All @@ -49,7 +49,7 @@ export default class HTTPService {
got
.post(url, data)
.then(response => {
resolve(response.body);
resolve(JSON.parse(response.body));
})
.catch(err => {
reject(err);
Expand Down
28 changes: 14 additions & 14 deletions src/resources/OAuthResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,25 @@ export default class OAuthResource extends BungieResource {
* @memberof Traveler
*/
public getAccessToken(code: string, oauthClientId?: string, oauthClientSecret?: string): Promise<OAuthResponse> {
let form = new FormData();
form.append('client_id', oauthClientId);
form.append('code', code);
form.append('grant_type', 'authorization_code');
const form = {
client_id: oauthClientId,
code,
grant_type: 'authorization_code',
}

let options: got.GotJSONOptions = {
let options: got.GotFormOptions<string> = {
body: form,
headers:
oauthClientId && oauthClientSecret
? {
authorization: `Basic ${new Buffer(`${oauthClientId}:${oauthClientSecret}`).toString('base64')}`,
'content-type': 'application/x-www-form-urlencoded',
'user-agent': this.userAgent
}
: {
'content-type': 'application/x-www-form-urlencoded',
: {
'user-agent': this.userAgent
},

json: true
form: true
};
return new Promise<OAuthResponse>((resolve, reject) => {
this.httpService
Expand Down Expand Up @@ -111,17 +110,18 @@ export default class OAuthResource extends BungieResource {
* @memberof Traveler
*/
public refreshToken(refreshToken: string, oauthClientId: string, oauthClientSecret: string): Promise<OAuthResponse> {
let form = new FormData();
form.append('refresh_token', refreshToken);
form.append('grant_type', 'refresh_token');
const form = {
refresh_token: refreshToken,
grant_type: 'refresh_token',
}

const options: got.GotJSONOptions = {
const options: got.GotFormOptions<string> = {
body: form,
headers: {
authorization: `Basic ${new Buffer(`${oauthClientId}:${oauthClientSecret}`).toString('base64')}`,
'content-type': 'application/x-www-form-urlencoded'
},
json: true
form: true
};

return new Promise<OAuthResponse>((resolve, reject) => {
Expand Down
Loading