mirror of
https://github.com/tlsnotary/tlsn-extension.git
synced 2026-01-08 22:58:04 -05:00
feat: Twitter DM plugin + use minimatch to allow patterns in config request urls (#66)
This commit is contained in:
23605
package-lock.json
generated
23605
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -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
14
plugins/twitter_dm/index.d.ts
vendored
Normal 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
127
plugins/twitter_dm/index.js
Normal file
File diff suppressed because one or more lines are too long
3
pnpm-lock.yaml
generated
3
pnpm-lock.yaml
generated
@@ -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
|
||||
|
||||
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user