marc0l92 / obsidian-jira-issue

This plugin allows you to track the progress of Atlassian Jira issues from your Obsidian notes.
https://marc0l92.github.io/obsidian-jira-issue/
GNU Affero General Public License v3.0
234 stars 36 forks source link

Switch out Buffer with btoa for building base64 Authorization header #10

Closed marcus-crane closed 2 years ago

marcus-crane commented 2 years ago

Closes #9

This PR switches out the usage of Buffer, a Node.js standard library module with the more widely available btoa which is available in every browser.

I originally went down the path of trying to use a buffer polyfill but try as I might, I couldn't actually get the module's code to be bundled into main.js as it does with moment for example.

I will note that Node.js has marked btoa as deprecated in favour of Buffer:

CleanShot 2022-05-03 at 22 39 27

The key bits here are probably

provided for compatibility with legacy web platform APIs

and

For code running using Node.js APIs

As scary as the message sounds, it does imply that btoa is fine to use if your use case is not strictly bound to Node.js which this plugin isn't really.

Anyway, it works for now regardless. It's probably worth investigating if there's something better down the line.

The next thing after this will be looking at the mobile table formatting since they're quite wide 😅

Before: Issues fail to load on iOS IMG_2302

After: Issues load on iOS IMG_2303

marcus-crane commented 2 years ago

Oops, it just occurred to me that I should have used a dummy Jira project but ah well, nothing too interesting to see 😅

marc0l92 commented 2 years ago

Thanks for your investigation on mobile platform. I would like to change a bit your implementation in order to use the deprecated function btoa only if the platform where the plugin is running is mobile.

I will decline your pull request and do the same changes with this additional check.

marcus-crane commented 2 years ago

No worries! Glad to be able to use this plugin on mobile officially 🙂