Skip to content

add: base64url support #314

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

Closed

Conversation

jrschumacher
Copy link

Using string replaceAll since base64 is external base64-js.
Dependency does not yet support base64url beatgammit/base64-js#53

@SamuelScheit
Copy link

I also need base64url encoding support for my project,
@jrschumacher thank you for implementing it, I'll use your branch until this PR gets merged.

@Dabada
Copy link

Dabada commented Aug 31, 2022

Any news for this ? Please.

@ghost
Copy link

ghost commented Oct 16, 2022

same issue, any news?

@ChrisAntaki
Copy link

Thanks for coding this, @jrschumacher! Using it for a fork

@swetshaw
Copy link

I need base64url encoding support for my project, can we review and merge this ASAP?

@jrschumacher
Copy link
Author

It's probably not going to happen if it's been this long. Just use my branch or just wrap the base64 function in a string replace.

@TDola
Copy link

TDola commented Feb 22, 2023

Hopefully this is merged some day. It seems to work well
npm install feross/buffer#pull/314/head

Copy link
Collaborator

@dcousens dcousens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'll need to resolve the CI issues before I can merge though

@jrschumacher
Copy link
Author

jrschumacher commented Oct 6, 2023

@dcousens I removed trailing spaces on line 955 of index.js

@jrschumacher
Copy link
Author

@dcousens still interested in taking this?

Using string replaceAll since base64 is external base64-js.
Dependency does not yet support base64url beatgammit/base64-js#53
@jrschumacher jrschumacher force-pushed the add-base64url-support branch from 4da50f9 to f22ba44 Compare July 22, 2024 22:03
@jrschumacher
Copy link
Author

I rebased with the master branch and removed my lint scripts from the package.json to reduce conflicts.

@dcousens
Copy link
Collaborator

dcousens commented Jul 24, 2024

Thanks @jrschumacher, I'm happy to take this from here next I can, I need to check in on @chjj's pull request in #349, which might supersede this

@ST-DDT
Copy link

ST-DDT commented Nov 27, 2024

Would it be possible to merge and release this first since the other PR seems stuck for a long time now?

@SamVerschueren
Copy link

If the goal is to make it behave like Node.js, we also need to strip and add the padding.

function base64urlToBase64 (str) {
  // Replace '-' back to '+' and '_' back to '/'
  let base64 = str
    .replaceAll(BASE64URL_CHAR_62, BASE64_CHAR_62)
    .replaceAll(BASE64URL_CHAR_63, BASE64_CHAR_63)

  // Add padding ('=') if needed
  const padding = base64.length % 4

  if (padding > 0) {
    base64 += '='.repeat(4 - padding)
  }

  return base64;
}

function base64urlFromBase64 (str) {
  return str
    .replaceAll(BASE64_CHAR_62, BASE64URL_CHAR_62)
    .replaceAll(BASE64_CHAR_63, BASE64URL_CHAR_63)
    .replace(/=+$/, '')
}

@jrschumacher
Copy link
Author

@SamVerschueren given that this will be 3 years old this month, I'm going to close it since there doesn't seem any intention to move forward with it.

@jrschumacher
Copy link
Author

@SamVerschueren you might want to consider adding a PR to https://github.com/feross/base64-js

@SamVerschueren
Copy link

Yeah agreed. In the mean time I created my own fork to fix the issue. Just wanted to post it as additional information for people running into the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants