feat: Twitter DM plugin + use minimatch to allow patterns in config request urls (#66)

This commit is contained in:
Hendrik Eeckhaut
2024-06-17 12:17:21 +02:00
committed by GitHub
parent 87e96c0f50
commit 884e55dccf
7 changed files with 148 additions and 31094 deletions

23605
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -27,6 +27,7 @@
"fast-deep-equal": "^3.1.3",
"fuse.js": "^6.6.2",
"level": "^8.0.0",
"minimatch": "^9.0.4",
"node-cache": "^5.1.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",

14
plugins/twitter_dm/index.d.ts vendored Normal file
View File

@@ -0,0 +1,14 @@
declare module 'main' {
// Extism exports take no params and return an I32
export function start(): I32;
export function two(): I32;
export function three(): I32;
export function config(): I32;
}
declare module 'extism:host' {
interface user {
redirect(ptr: I64): void;
notarize(ptr: I64): I64;
}
}

127
plugins/twitter_dm/index.js Normal file

File diff suppressed because one or more lines are too long

3
pnpm-lock.yaml generated
View File

@@ -38,6 +38,9 @@ dependencies:
level:
specifier: ^8.0.0
version: 8.0.1
minimatch:
specifier: ^9.0.4
version: 9.0.4
node-cache:
specifier: ^5.1.2
version: 5.1.2

View File

@@ -17,6 +17,7 @@ import {
} from '../entries/Background/cache';
import { getNotaryApi, getProxyApi } from './storage';
import { runPlugin } from './rpc';
import { minimatch } from 'minimatch';
const charwise = require('charwise');
@@ -180,7 +181,8 @@ export const makePlugin = async (
if (
!approvedRequests.find(
({ method, url }) => method === params.method && url === params.url,
({ method, url }) =>
method === params.method && minimatch(params.url, url),
)
) {
throw new Error(`Unapproved request - ${params.method}: ${params.url}`);

7488
yarn.lock

File diff suppressed because it is too large Load Diff