mirror of
https://github.com/movie-web/extension.git
synced 2025-09-13 18:13:25 +00:00
really really basic domain whitelisting
This commit is contained in:
15
src/utils/storage.ts
Normal file
15
src/utils/storage.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Storage } from '@plasmohq/storage';
|
||||
|
||||
export const DEFAULT_DOMAIN_WHITELIST = ['https://movie-web.app', 'http://localhost:5173'];
|
||||
|
||||
export const storage = new Storage();
|
||||
|
||||
export const domainIsInWhitelist = async (domain: string) => {
|
||||
const whitelist = await storage.get<string[]>('domainWhitelist');
|
||||
return whitelist?.some((d) => d.includes(domain)) ?? false;
|
||||
};
|
||||
|
||||
export const validateDomainWhiteList = async (domain: string) => {
|
||||
const isWhiteListed = await domainIsInWhitelist(domain);
|
||||
if (!isWhiteListed) throw new Error('Domain is not whitelisted');
|
||||
};
|
Reference in New Issue
Block a user