mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-20 14:37:43 +01:00
Remove requestDomain
This commit is contained in:
parent
3704dfba10
commit
6c7f1acece
2 changed files with 4 additions and 18 deletions
|
@ -36,31 +36,19 @@ function sendMessage<MessageKey extends keyof MessagesMetadata>(
|
|||
export async function sendExtensionRequest<T>(
|
||||
ops: Omit<MessagesMetadata["makeRequest"]["req"], "requestDomain">,
|
||||
): Promise<ExtensionMakeRequestResponse<T> | null> {
|
||||
return sendMessage("makeRequest", {
|
||||
requestDomain: window.location.origin, // TODO unsafe
|
||||
...ops,
|
||||
});
|
||||
return sendMessage("makeRequest", ops);
|
||||
}
|
||||
|
||||
export async function setDomainRule(
|
||||
ops: Omit<MessagesMetadata["prepareStream"]["req"], "requestDomain">,
|
||||
): Promise<MessagesMetadata["prepareStream"]["res"] | null> {
|
||||
return sendMessage("prepareStream", {
|
||||
requestDomain: window.location.origin,
|
||||
...ops,
|
||||
});
|
||||
return sendMessage("prepareStream", ops);
|
||||
}
|
||||
|
||||
export async function extensionInfo(): Promise<
|
||||
MessagesMetadata["hello"]["res"] | null
|
||||
> {
|
||||
const message = await sendMessage(
|
||||
"hello",
|
||||
{
|
||||
requestDomain: window.location.origin,
|
||||
},
|
||||
300,
|
||||
);
|
||||
const message = await sendMessage("hello", {}, 300);
|
||||
if (!message?.success) return null;
|
||||
if (!message.allowed) return null;
|
||||
return message;
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
export interface ExtensionBaseRequest {
|
||||
requestDomain: string;
|
||||
}
|
||||
export interface ExtensionBaseRequest {}
|
||||
|
||||
export type ExtensionBaseResponse<T = object> =
|
||||
| ({
|
||||
|
|
Loading…
Reference in a new issue