Skip to content
This repository was archived by the owner on Dec 2, 2020. It is now read-only.

Prettier updated #39

Merged
merged 3 commits into from
Apr 6, 2020
Merged
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
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"jest": "^25.1.0",
"lolex": "^6.0.0",
"node-fetch": "^2.6.0",
"prettier": "^2.0.3",
"prettier": "^2.0.4",
"semantic-release": "^17.0.0",
"semantic-release-plugin-update-version-in-files": "^1.0.0",
"ts-jest": "^25.1.0",
Expand Down
20 changes: 9 additions & 11 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,15 @@ export async function auth(
// we are expecting a 404 error
}

return (
Object.assign(
{
type: "basic",
username: state.strategyOptions.username,
password: state.strategyOptions.password,
credentials,
},
state.totp ? { totp: state.totp } : null
) as BasicAuthentication
);
return Object.assign(
{
type: "basic",
username: state.strategyOptions.username,
password: state.strategyOptions.password,
credentials,
},
state.totp ? { totp: state.totp } : null
) as BasicAuthentication;
}

return getToken(state, options);
Expand Down
37 changes: 18 additions & 19 deletions src/get-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,26 +34,25 @@ export async function getToken(
state.strategyOptions.token.noteUrl ||
"https://github.com/octokit/auth-basic.js#readme";

const options =
Object.assign(
{
method: "POST",
url: "/authorizations",
headers: {
authorization: basicAuthorization,
},
note,
note_url: noteUrl,
scopes,
const options = Object.assign(
{
method: "POST",
url: "/authorizations",
headers: {
authorization: basicAuthorization,
},
fingerprint ? { fingerprint } : null,
state.strategyOptions.token.clientId
? {
client_id: state.strategyOptions.token.clientId,
client_secret: state.strategyOptions.token.clientSecret,
}
: null
) as EndpointOptions;
note,
note_url: noteUrl,
scopes,
},
fingerprint ? { fingerprint } : null,
state.strategyOptions.token.clientId
? {
client_id: state.strategyOptions.token.clientId,
client_secret: state.strategyOptions.token.clientSecret,
}
: null
) as EndpointOptions;

const {
data: { id, token },
Expand Down
16 changes: 7 additions & 9 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1077,20 +1077,18 @@ test('auth({type:"token", refresh: true})', async () => {
}),
});

const authentication1 =
(await auth({
type: "token",
})) as TokenAuthentication;
const authentication1 = (await auth({
type: "token",
})) as TokenAuthentication;

Math.random = jest.fn().mockReturnValue(0.456);
// < Math.random().toString(36).substr(2)
// > gez4w97rxp

const authentication2 =
(await auth({
type: "token",
refresh: true,
})) as TokenAuthentication;
const authentication2 = (await auth({
type: "token",
refresh: true,
})) as TokenAuthentication;

expect(authentication1.token).toEqual(
"1234567890abcdef1234567890abcdef12345678"
Expand Down