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

Use atob/btoa instead of Buffer for Base64 en/decode #11

Open
oscard0m opened this issue Mar 7, 2021 · 3 comments
Open

Use atob/btoa instead of Buffer for Base64 en/decode #11

oscard0m opened this issue Mar 7, 2021 · 3 comments
Labels
bug Something isn't working as documented, or is being fixed

Comments

@oscard0m
Copy link
Member

oscard0m commented Mar 7, 2021

Considerations:
Use polyfill for Node: https://github.com/gr2m/octoherd-script-normalize-package-repository-field/blob/0272b1555ba5479e01e7a240d3e5ec646024bf37/script.js#L85-L92

Originally posted here:
#3 (comment)

@oscard0m oscard0m added the bug Something isn't working as documented, or is being fixed label Mar 7, 2021
@gr2m
Copy link
Member

gr2m commented Mar 7, 2021

for reference: here is some good docs on base64: https://developer.mozilla.org/en-US/docs/Glossary/Base64. We might need to use TextEncoder instead of atob/btoa (see https://discourse.wicg.io/t/base64-with-textencoder-textdecoder/1307), I need to do some more research.

great insights: https://stackoverflow.com/questions/30631927/converting-to-base64-in-javascript-without-deprecated-escape-call

@gr2m
Copy link
Member

gr2m commented Mar 8, 2021

I'm making it an official @octokit plugin after all, as so many folks run into headaches with the repository contents APIs:
https://github.com/octokit/plugin-create-or-update-text-file.js

@gr2m
Copy link
Member

gr2m commented Mar 9, 2021

Plugin is ready. We'll see how it will hold up across node / browser / deno, but at least it has the universal base64 encoding/decoding logic in a single place, and it is definitely better to only use Buffer directly

Next step is to add the plugin to @octoherd/octokit and then update the scripts to use the new octokit.createOrUpdateTextFile() method instead of sending requests to get/update file contents and handle the encoding/decoding within the script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as documented, or is being fixed
Projects
None yet
Development

No branches or pull requests

2 participants