Skip to content

Commit

Permalink
refactor(Node.js)!: return Uint8Array (not a Buffer) from base64url.d…
Browse files Browse the repository at this point in the history
…ecode
  • Loading branch information
panva committed Oct 25, 2023
1 parent 66a304a commit 02d5182
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/runtime/node/base64url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ function normalize(input: string | Uint8Array) {

const encode = (input: Uint8Array | string) => Buffer.from(input).toString('base64url')

export const decodeBase64 = (input: string) => Buffer.from(input, 'base64')
export const decodeBase64 = (input: string) => new Uint8Array(Buffer.from(input, 'base64'))
export const encodeBase64 = (input: Uint8Array | string) => Buffer.from(input).toString('base64')
export { encode }
export const decode = (input: Uint8Array | string) => Buffer.from(normalize(input), 'base64')
export const decode = (input: Uint8Array | string) =>
new Uint8Array(Buffer.from(normalize(input), 'base64'))

0 comments on commit 02d5182

Please sign in to comment.