Coder Social home page Coder Social logo

Support for Shaarli about linkding-injector HOT 7 OPEN

sebw avatar sebw commented on July 28, 2024
Support for Shaarli

from linkding-injector.

Comments (7)

sebw avatar sebw commented on July 28, 2024 2

Hey @Fivefold

  1. one extension covering multiple bookmarking services would be even better!
  2. agree bookmark-injector would make sense
  3. I like the theme as it is!
  4. as much as I'd love to help out, I have never built an extension before and never wrote anything in node but I can definitely test, document or translate stuff! I actually gave a shot to building the extension, but the resulting ZIP wouldn't load (firefox reporting it corrupted, but can still install in debug mode, but quickly fail at the configuration step... I see the testConnection and get a 200 but get an error still).

from linkding-injector.

Fivefold avatar Fivefold commented on July 28, 2024 1

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 preferBuiltins: false to the resolve Plugin in rollup.js.

resolve({ browser: true }),

resolve({ browser: true }),

The resolve plugin itself is from @rollup/plugin-node-resolve and is specifically there to bundle node modules. Unfortunately I still got ReferenceErrors when trying to access stuff from imported node modules.

from linkding-injector.

Fivefold avatar Fivefold commented on July 28, 2024

Hey @sebw!

A few thoughts:

  1. Yeah, looks like most of the work would probably be on the configuration side (user UI for choosing linkding or Shaarli API and configuring that).

  2. This is likely not relevant to you personally but would probably mean the extension should be renamed to bookmark-injector or similar down the line.

  3. Of course the injected results would still be styled like linkding, but theming support is not essential and not something I'm willing to tackle for now.

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.

from linkding-injector.

Fivefold avatar Fivefold commented on July 28, 2024

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
You can do this completely outside of the extension context.

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.

from linkding-injector.

sebw avatar sebw commented on July 28, 2024

Here's a working example using jsonwebtoken library.

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)

from linkding-injector.

Fivefold avatar Fivefold commented on July 28, 2024

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.

from linkding-injector.

gingerbeardman avatar gingerbeardman commented on July 28, 2024

Just checking out the project and though I might be of help

from linkding-injector.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.