Skip to content

Commit bb982a9

Browse files
authored
Merge pull request #52 from notificationapi-com/LNd7qf8p/2043-bug-in-auth-user
Not encode auth parameters in the header
2 parents 8b48dd9 + 7f80782 commit bb982a9

File tree

4 files changed

+4
-16
lines changed

4 files changed

+4
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "notificationapi-js-client-sdk",
3-
"version": "4.7.0",
3+
"version": "4.7.1",
44
"description": "NotificationAPI client-side library for JavaScript",
55
"keywords": [
66
"notificationapi",

src/__tests__/askForWebPushPermission.test.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ const mockEndpoint = 'mockEndpoint';
1515
const mockKeys = { auth: 'auth', p256dh: 'p256dh' };
1616
const headers = {
1717
'content-type': 'application/json',
18-
Authorization:
19-
'Basic ' +
20-
btoa(
21-
`${encodeURIComponent(clientId)}:${encodeURIComponent(
22-
userId
23-
)}:${mockHashUserId}`
24-
)
18+
Authorization: 'Basic ' + btoa(`${clientId}:${userId}:${mockHashUserId}`)
2519
};
2620
const body = {
2721
webPushTokens: [

src/__tests__/identify.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ describe('when identify is called', () => {
6666

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

src/index.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,7 @@ class NotificationAPIClient implements NotificationAPIClientInterface {
299299
)}/users/${encodeURIComponent(userId)}`;
300300

301301
const authToken =
302-
'Basic ' +
303-
btoa(
304-
`${encodeURIComponent(clientId)}:${encodeURIComponent(userId)}:${
305-
userIdHash ?? ''
306-
}`
307-
);
302+
'Basic ' + btoa(`${clientId}:${userId}:${userIdHash ?? ''}`);
308303

309304
await fetch(url, {
310305
body: JSON.stringify(user),

0 commit comments

Comments
 (0)