Skip to content

Commit

Permalink
fix dnt flag (#170)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinxh authored Aug 21, 2024
1 parent 9a9453f commit fadc6c1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/static/helpers/slasHelper.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const parameters = {
refreshToken: 'refresh_token',
usid: 'usid',
hint: 'hint',
dnt: true,
dnt: false,
};

const url =
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('Guest user flow', () => {
grant_type: 'authorization_code_pkce',
redirect_uri: 'redirect_uri',
usid: '048adcfb-aa93-4978-be9e-09cb569fdcb9',
dnt: 'true',
dnt: 'false',
},
};
const mockSlasClient = createMockSlasClient();
Expand Down Expand Up @@ -257,7 +257,7 @@ describe('Guest user flow', () => {
grant_type: 'client_credentials',
channel_id: 'site_id',
usid: 'usid',
dnt: 'true',
dnt: 'false',
},
};
expect(getAccessTokenMock).toBeCalledWith(expectedReqOptions);
Expand Down Expand Up @@ -301,7 +301,7 @@ describe('Registered B2C user flow', () => {
organizationId: 'organization_id',
redirect_uri: 'redirect_uri',
usid: '048adcfb-aa93-4978-be9e-09cb569fdcb9',
dnt: 'true',
dnt: 'false',
},
};

Expand Down Expand Up @@ -340,7 +340,7 @@ describe('Registered B2C user flow', () => {
channel_id: 'site_id',
organizationId: 'organization_id',
usid: '048adcfb-aa93-4978-be9e-09cb569fdcb9',
dnt: 'true',
dnt: 'false',
},
};
// slasClient is copied and tries to make an actual API call
Expand Down Expand Up @@ -443,7 +443,7 @@ describe('Refresh Token', () => {
channel_id: 'site_id',
grant_type: 'refresh_token',
refresh_token: 'refresh_token',
dnt: 'true',
dnt: 'false',
},
};
const token = slasHelper.refreshAccessToken(
Expand All @@ -466,7 +466,7 @@ describe('Refresh Token', () => {
client_id: 'client_id',
channel_id: 'site_id',
refresh_token: parameters.refreshToken,
dnt: 'true',
dnt: 'false',
},
};
const token = slasHelper.refreshAccessToken(
Expand Down
8 changes: 4 additions & 4 deletions src/static/helpers/slasHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export async function loginGuestUserPrivate(
grant_type: 'client_credentials',
channel_id: slasClient.clientConfig.parameters.siteId,
...(parameters.usid && {usid: parameters.usid}),
...(parameters.dnt && {dnt: parameters.dnt.toString()}),
...(parameters.dnt !== undefined && {dnt: parameters.dnt.toString()}),
},
};

Expand Down Expand Up @@ -247,7 +247,7 @@ export async function loginGuestUser(
grant_type: 'authorization_code_pkce',
redirect_uri: parameters.redirectURI,
usid: authResponse.usid,
...(parameters.dnt && {dnt: parameters.dnt.toString()}),
...(parameters.dnt !== undefined && {dnt: parameters.dnt.toString()}),
};

return slasClient.getAccessToken({body: tokenBody});
Expand Down Expand Up @@ -339,7 +339,7 @@ export async function loginRegisteredUserB2C(
organizationId: slasClient.clientConfig.parameters.organizationId,
redirect_uri: parameters.redirectURI,
usid: authResponse.usid,
...(parameters.dnt && {dnt: parameters.dnt.toString()}),
...(parameters.dnt !== undefined && {dnt: parameters.dnt.toString()}),
};
// using slas private client
if (credentials.clientSecret) {
Expand Down Expand Up @@ -387,7 +387,7 @@ export function refreshAccessToken(
refresh_token: parameters.refreshToken,
client_id: slasClient.clientConfig.parameters.clientId,
channel_id: slasClient.clientConfig.parameters.siteId,
...(parameters.dnt && {dnt: parameters.dnt.toString()}),
...(parameters.dnt !== undefined && {dnt: parameters.dnt.toString()}),
};

if (credentials && credentials.clientSecret) {
Expand Down

0 comments on commit fadc6c1

Please sign in to comment.