-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support for Shaarli #7
Comments
Hey @sebw! A few thoughts:
Is this a feature request only or do you intend to make a PR? In case of the latter I would ask you to wait until the next release. I'm in the process of changing the extension to support manifest v3 and that will include changes in a lot of files. |
Hey @Fivefold
|
Maybe you can write and test a JavaScript function for encoding/generation of the JWT token as shown for PHP at the shaarli docs https://github.com/shaarli/api-documentation/blob/master/api-authentication.md#php This would take some of the work off me. It will still most likely take weeks until I can actually get to implement it though. |
Here's a working example using let jwt = require('jsonwebtoken');
let now = Math.floor(Date.now() / 1000)
const shaarli_api_secret = 'shaarli-api-secret';
const payload = {
"iat": now
};
let token = jwt.sign(payload, shaarli_api_secret, { algorithm: 'HS512'});
console.log(token) |
Thank you very much, @sebw! Looks good and easy. Unfortunately I just found out using node modules in browser extensions requires bundling them with the extension. I'm using rollup as a bundler, mostly because I started from the code of the official linkding extension and it seemed to do the job well. I'm very inexperienced with rollup. It can probably bundle node modules too but it would likely take a lot of time for me to set it up just for encoding the JWT token. I might take a shot at it nontheless. Ideally, I'm looking for a vanilla JavaScript solution, although I'm not sure if JavaScript supports base64 encoding or sha512 hashing out of the box or how much trouble it would be to implement them. If you do know rollup that would be even better and cleaner though. |
Just checking out the project and though I might be of help
|
Thank you @gingerbeardman, this looks good! I wasn't aware of the subtlecrypto API. Will try it out the next time I take a shot at this. In the meantime I tried to get rollup to bundle node modules with the help of ChatGPT but even then I was unable to get the bundling working properly. Apparently it should be enough to add linkding-injector/rollup.config.js Line 56 in a66b0e8
linkding-injector/rollup.config.js Line 81 in a66b0e8
The |
Hey there!
Love this extension! Somehow Linkding still has a couple of issues that doesn't make it production ready for me.
I've use Shaarli for years and I would love a similar extension compatible with it.
I've looked at your code (even though I'm not versed in building browser extensions) and it looks like it would be fairly simple to transpose API calls from Linkding to Shaarli API calls.
Only difference is around auth, Shaarli works on a JWT token: https://github.com/shaarli/api-documentation/blob/master/api-authentication.md
API call for search is fairly classic:
https://bookmark.example.com/api/v1/links?searchterm=linux&limit=10
Output:
I can spin up a Shaarli instance if needed.
The text was updated successfully, but these errors were encountered: