Skip to content

Commit

Permalink
refactor: realise that named and default parameters do not mix
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneRifle committed Jun 1, 2021
1 parent b7578cc commit 23b7c27
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,11 @@ export class SgidClient {
})
}

authorizationUrl({
state,
authorizationUrl(
state: string,
scope = 'myinfo.nric_number openid',
nonce = generators.nonce(),
}: {
state: string
scope: string
nonce: string
}): { url: string; nonce: string } {
): { url: string; nonce: string } {
const url = this.sgID.authorizationUrl({
scope,
nonce,
Expand All @@ -77,16 +73,12 @@ export class SgidClient {
return sub
}

async callback({
code,
redirectUri = this.getRedirectUri(),
async callback(
code: string,
// use null to specify no nonce, per openid-client impl
nonce = null,
}: {
code: string
redirectUri: string
nonce: string | null
}): Promise<{ sub: string; accessToken: string }> {
nonce: string | null = null,
redirectUri = this.getRedirectUri(),
): Promise<{ sub: string; accessToken: string }> {
const { client_id, client_secret } = this.sgID.metadata
return this.sgID
.callback(
Expand Down

0 comments on commit 23b7c27

Please sign in to comment.