-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(utils): manally conver from b64 to b64url to avoid web polyfill i…
…ssues
- Loading branch information
dtfiedler
committed
May 2, 2024
1 parent
40be70a
commit 766035c
Showing
3 changed files
with
45 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { fromB64Url, toB64Url } from '../../src/utils/base64'; | ||
|
||
describe('b64utils', () => { | ||
it('should properly convert a buffer to base64url string', async () => { | ||
const input = Buffer.from('hello+_world_+', 'base64'); | ||
const expected = input.toString('base64url'); | ||
expect(toB64Url(input)).toEqual(expected); | ||
}); | ||
|
||
it('should properly convert a base64 string to a buffer', async () => { | ||
const b64url = Buffer.from('hello+_world_+').toString('base64url'); | ||
const expected = Buffer.from(b64url, 'base64url'); | ||
expect(fromB64Url(b64url)).toEqual(expected); | ||
}); | ||
}); |