mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +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>(
|
export async function sendExtensionRequest<T>(
|
||||||
ops: Omit<MessagesMetadata["makeRequest"]["req"], "requestDomain">,
|
ops: Omit<MessagesMetadata["makeRequest"]["req"], "requestDomain">,
|
||||||
): Promise<ExtensionMakeRequestResponse<T> | null> {
|
): Promise<ExtensionMakeRequestResponse<T> | null> {
|
||||||
return sendMessage("makeRequest", {
|
return sendMessage("makeRequest", ops);
|
||||||
requestDomain: window.location.origin, // TODO unsafe
|
|
||||||
...ops,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function setDomainRule(
|
export async function setDomainRule(
|
||||||
ops: Omit<MessagesMetadata["prepareStream"]["req"], "requestDomain">,
|
ops: Omit<MessagesMetadata["prepareStream"]["req"], "requestDomain">,
|
||||||
): Promise<MessagesMetadata["prepareStream"]["res"] | null> {
|
): Promise<MessagesMetadata["prepareStream"]["res"] | null> {
|
||||||
return sendMessage("prepareStream", {
|
return sendMessage("prepareStream", ops);
|
||||||
requestDomain: window.location.origin,
|
|
||||||
...ops,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function extensionInfo(): Promise<
|
export async function extensionInfo(): Promise<
|
||||||
MessagesMetadata["hello"]["res"] | null
|
MessagesMetadata["hello"]["res"] | null
|
||||||
> {
|
> {
|
||||||
const message = await sendMessage(
|
const message = await sendMessage("hello", {}, 300);
|
||||||
"hello",
|
|
||||||
{
|
|
||||||
requestDomain: window.location.origin,
|
|
||||||
},
|
|
||||||
300,
|
|
||||||
);
|
|
||||||
if (!message?.success) return null;
|
if (!message?.success) return null;
|
||||||
if (!message.allowed) return null;
|
if (!message.allowed) return null;
|
||||||
return message;
|
return message;
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
export interface ExtensionBaseRequest {
|
export interface ExtensionBaseRequest {}
|
||||||
requestDomain: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ExtensionBaseResponse<T = object> =
|
export type ExtensionBaseResponse<T = object> =
|
||||||
| ({
|
| ({
|
||||||
|
|
Loading…
Reference in a new issue