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

Not encode auth parameters in the header #52

Merged
merged 1 commit into from
Jun 5, 2024
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notificationapi-js-client-sdk",
"version": "4.7.0",
"version": "4.7.1",
"description": "NotificationAPI client-side library for JavaScript",
"keywords": [
"notificationapi",
Expand Down
8 changes: 1 addition & 7 deletions src/__tests__/askForWebPushPermission.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
const mockKeys = { auth: 'auth', p256dh: 'p256dh' };
const headers = {
'content-type': 'application/json',
Authorization:
'Basic ' +
btoa(
`${encodeURIComponent(clientId)}:${encodeURIComponent(
userId
)}:${mockHashUserId}`
)
Authorization: 'Basic ' + btoa(`${clientId}:${userId}:${mockHashUserId}`)
};
const body = {
webPushTokens: [
Expand Down Expand Up @@ -72,7 +66,7 @@

global.Notification = {
requestPermission: jest.fn().mockResolvedValue('granted')
} as any;

Check warning on line 69 in src/__tests__/askForWebPushPermission.test.ts

View workflow job for this annotation

GitHub Actions / Test & Build

Unexpected any. Specify a different type

(global.fetch as jest.Mock).mockReset();
notificationapi = new NotificationAPI({
Expand Down Expand Up @@ -170,7 +164,7 @@

global.Notification = {
requestPermission: jest.fn().mockResolvedValue('granted')
} as any;

Check warning on line 167 in src/__tests__/askForWebPushPermission.test.ts

View workflow job for this annotation

GitHub Actions / Test & Build

Unexpected any. Specify a different type

(global.fetch as jest.Mock).mockReset();
notificationapi = new NotificationAPI({
Expand Down
3 changes: 1 addition & 2 deletions src/__tests__/identify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ describe('when identify is called', () => {

it('with the right auth header', async () => {
expect(fetchMock.mock.calls[0][1]['headers']['Authorization']).toEqual(
'Basic ' +
btoa(`${encodeURIComponent(clientId)}:${encodeURIComponent(userId)}:`)
'Basic ' + btoa(`${clientId}:${userId}:`)
);
});

Expand Down
7 changes: 1 addition & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@
};
const translationsObject: TranslationObject =
supportedLanguages.reduce<TranslationObject>((acc, language) => {
acc[language] = {

Check warning on line 171 in src/index.ts

View workflow job for this annotation

GitHub Actions / Test & Build

Generic Object Injection Sink
translation: supportedLanguagesFile[language]

Check warning on line 172 in src/index.ts

View workflow job for this annotation

GitHub Actions / Test & Build

Generic Object Injection Sink
};
return acc;
}, {} as TranslationObject);
Expand Down Expand Up @@ -299,12 +299,7 @@
)}/users/${encodeURIComponent(userId)}`;

const authToken =
'Basic ' +
btoa(
`${encodeURIComponent(clientId)}:${encodeURIComponent(userId)}:${
userIdHash ?? ''
}`
);
'Basic ' + btoa(`${clientId}:${userId}:${userIdHash ?? ''}`);

await fetch(url, {
body: JSON.stringify(user),
Expand Down
Loading