[go: up one dir, main page]

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

Added database for plugins #986

Merged
merged 40 commits into from
May 28, 2024
Merged

Added database for plugins #986

merged 40 commits into from
May 28, 2024

Conversation

Rider21
Copy link
Contributor
@Rider21 Rider21 commented Mar 4, 2024

Added database, cookie manager for plugins
Added copying from webview localStorage, sessionStorage

@nyagami
Copy link
Member
nyagami commented Mar 5, 2024

isnt cookie managed by React Native Network?

@Rider21
Copy link
Contributor Author
Rider21 commented Mar 5, 2024

Yes, they are managed, but you can't interact with them,
I made a wrapper under react-native-cookies/cookies, so from the plugin you can add, modify, check, delete site cookies

commit da4d7e8
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Fri Mar 8 13:21:19 2024 +0300

    /

commit 592c4db
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Fri Mar 8 13:20:34 2024 +0300

    test

commit 6324050
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Fri Mar 8 12:38:13 2024 +0300

    /

commit 591d259
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Fri Mar 8 11:42:03 2024 +0300

    fix progressbar

commit 3d34cfb
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 21:13:49 2024 +0300

    forgot

commit c36d090
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 20:51:31 2024 +0300

    /

commit 3c4e43b
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 20:15:38 2024 +0300

    /

commit 0a20a48
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 19:46:31 2024 +0300

    add zIndex

commit 7d44901
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 19:27:32 2024 +0300

    test

commit b585d5e
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 18:28:49 2024 +0300

    /

commit cb7241c
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 18:06:30 2024 +0300

    Update Appbar.tsx

commit 5fab766
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 17:55:24 2024 +0300

    Update WebviewScreen.tsx

commit aec9b92
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 17:15:16 2024 +0300

    xd

commit 1fa385b
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 17:11:23 2024 +0300

    2

commit 589870d
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 16:28:24 2024 +0300

    1

commit 343d2dd
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 16:11:08 2024 +0300

    test

commit f2dbf34
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Thu Mar 7 14:36:48 2024 +0300

    test

commit 04c04d9
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Wed Mar 6 22:37:45 2024 +0300

    test zoom

commit 6b80559
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Wed Mar 6 22:33:55 2024 +0300

    fix

commit 287ce94
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Wed Mar 6 19:00:01 2024 +0300

    test

commit 67bdddc
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Wed Mar 6 11:10:22 2024 +0300

    Test newArch

commit 7623537
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Tue Mar 5 20:49:29 2024 +0300

    Update Appbar.tsx

commit 2a876cb
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Tue Mar 5 20:42:28 2024 +0300

    modal

commit ba4cade
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Tue Mar 5 16:50:38 2024 +0300

    1

commit 6c14a18
Author: Rider21 <58046032+Rider21@users.noreply.github.com>
Date:   Tue Mar 5 14:54:27 2024 +0300

    test
@Rider21 Rider21 marked this pull request as ready for review March 11, 2024 15:26
@nyagami
Copy link
Member
nyagami commented Mar 17, 2024

Yes, they are managed, but you can't interact with them, I made a wrapper under react-native-cookies/cookies, so from the plugin you can add, modify, check, delete site cookies

But is cookie management that important. Instead of remove/edit one cookie, users can just open webview, old cookies will be overrided.

@Rider21
Copy link
Contributor Author
Rider21 commented Mar 17, 2024

I don't know, but this process can be automated with these functions.

@Rider21
Copy link
Contributor Author
Rider21 commented Mar 17, 2024

By the way, do you think I need to redo copying from webview of localStorage, sessionStorage objects via java (directly).
Right now it is implemented through injecting js code

@Rider21 Rider21 marked this pull request as draft March 19, 2024 10:26
@Rider21 Rider21 marked this pull request as ready for review April 2, 2024 13:00
src/plugins/helpers/storage.ts Outdated Show resolved Hide resolved
@@ -119,6 +121,11 @@ const installPlugin = async (url: string): Promise<Plugin | undefined> => {

const uninstallPlugin = async (_plugin: PluginItem) => {
plugins[_plugin.id] = undefined;
storage.mmkv.getAllKeys().forEach(key => {
if (key.startsWith(_plugin.id)) {
storage.mmkv.delete(key);
Copy link
Member

Choose a reason for hiding this comment

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

why do you use mmkv's delete method instead of storage instance's one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't have access to localStorage, sessionStorage.

Copy link
Member

Choose a reason for hiding this comment

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

  clearAll(pluginID: string): void {
    const keysToRemove = this.getAllKeys(pluginID);
    keysToRemove.forEach(key => this.delete(pluginID, key));
  }

but you declare this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The storage.getAllKeys function will only return keys that were set using storage.set.
It will not return keys to localStorage, sessionStorage.
(these can only be retrieved via a separate instance and are read-only, example).

@nyagami
Copy link
Member
nyagami commented May 8, 2024

There're some vulnerabilities,I can set/get/delete stored values in plugin A from plugin B code right?
Since we had plugin repositories feature, users could be nuked by some trollers

@Rider21
Copy link
Contributor Author
Rider21 commented May 8, 2024

Yes, it's true, it can be fixed.
But I don't see the point of fixing it. The running plugin has too many permissions.
They could just write something like.

import { MMKV } from 'react-native-mmkv';

const store = new MMKV({ id: 'plugin_db' });
store.clearAll();

Co-authored-by: nyagami <hoangquan05112002@gmail.com>
@nyagami
Copy link
Member
nyagami commented May 8, 2024

Yes, it's true, it can be fixed. But I don't see the point of fixing it. The running plugin has too many permissions. They could just write something like.

import { MMKV } from 'react-native-mmkv';

const store = new MMKV({ id: 'plugin_db' });
store.clearAll();

No, plugin does not have that privilege. They are literally standalone scripts and dont have module accesses.
The import keyword in plugin code is just a hack. import would be converted into declared require function which is refer to https://github.com/LNReader/lnreader/blob/e2d22a5b05a47b57e1f46ccfb6d8dd3ebb05bcc8/src/plugins/pluginManager.ts#L23C1-L38C3

@nyagami
Copy link
Member
nyagami commented May 11, 2024

LGTM, Im going to test in devices

@nyagami
Copy link
Member
nyagami commented May 22, 2024

You need to resolve Typescript errors. My editor is screaming

@nyagami nyagami merged commit e50b6c4 into LNReader:master May 28, 2024
1 check passed
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.

2 participants