New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@http4t/chrome-extension

Package Overview
Dependencies
Maintainers
4
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@http4t/chrome-extension - npm Package Compare versions

Comparing version 0.1.45 to 0.1.47

util/ErrorResponder.d.ts

14

background.d.ts

@@ -1,12 +0,4 @@

/// <reference types="chrome" />
import { HttpHandler, HttpRequest, HttpResponse } from "@http4t/core/contract";
import { ErrorAdapter } from "./ErrorAdapter";
import CreateProperties = chrome.tabs.CreateProperties;
import QueryInfo = chrome.tabs.QueryInfo;
import Tab = chrome.tabs.Tab;
export declare function rootUrl(request: HttpRequest): CreateProperties;
export declare function sameHost(request: HttpRequest): QueryInfo;
export declare function findOrCreateTab(queryInfo: QueryInfo, properties: CreateProperties): Promise<Tab>;
export declare const findTabByHost: TabFinder;
export declare type TabFinder = (request: HttpRequest) => Promise<Tab>;
import { ErrorResponder } from "./util/ErrorResponder";
import { TabFinder } from "./util/tabs";
export declare class SendToTabHandler implements HttpHandler {

@@ -22,3 +14,3 @@ private readonly findTab;

*/
export declare function startBackgroundListener(http?: HttpHandler, onError?: ErrorAdapter): void;
export declare function startBackgroundListener(http?: HttpHandler, onError?: ErrorResponder): void;
//# sourceMappingURL=background.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.startBackgroundListener = exports.SendToTabHandler = exports.findTabByHost = exports.findOrCreateTab = exports.sameHost = exports.rootUrl = void 0;
exports.startBackgroundListener = exports.SendToTabHandler = void 0;
const requests_1 = require("@http4t/core/requests");
const uri_1 = require("@http4t/core/uri");
const ErrorAdapter_1 = require("./ErrorAdapter");
const ErrorResponder_1 = require("./util/ErrorResponder");
const FetchMessage_1 = require("./FetchMessage");
function rootUrl(request) {
const requestUri = uri_1.Uri.of(request.uri);
const uri = uri_1.Uri.of({
scheme: requestUri.scheme,
authority: requestUri.authority,
path: "/"
});
return {
url: uri.toString(),
active: false
};
}
exports.rootUrl = rootUrl;
function sameHost(request) {
const requestUri = uri_1.Uri.of(request.uri);
const uri = uri_1.Uri.of({
scheme: requestUri.scheme,
authority: requestUri.authority,
path: "/*"
});
return { url: uri.toString() };
}
exports.sameHost = sameHost;
function findOrCreateTab(queryInfo, properties) {
return new Promise((resolve, reject) => chrome.tabs.query(queryInfo, (tabs) => {
console.log("tabs", tabs);
console.log("queryInfo", queryInfo);
const tab = tabs === null || tabs === void 0 ? void 0 : tabs[0];
if (tab)
return resolve(tab);
chrome.tabs.create(properties, (tab) => {
if (!tab) {
reject({ message: "Could not create tab", properties });
}
else {
resolve(tab);
}
return true;
});
}));
}
exports.findOrCreateTab = findOrCreateTab;
const findTabByHost = request => {
return findOrCreateTab(sameHost(request), rootUrl(request));
};
exports.findTabByHost = findTabByHost;
const tabs_1 = require("./util/tabs");
class SendToTabHandler {
constructor(findTab = exports.findTabByHost) {
constructor(findTab = tabs_1.findTabByHost) {
this.findTab = findTab;

@@ -61,3 +15,2 @@ }

.then(tab => {
console.log("tab", tab);
if (!tab)

@@ -81,3 +34,3 @@ throw {

*/
function startBackgroundListener(http = new SendToTabHandler(exports.findTabByHost), onError = ErrorAdapter_1.badGateway) {
function startBackgroundListener(http = new SendToTabHandler(tabs_1.findTabByHost), onError = ErrorResponder_1.badGateway) {
FetchMessage_1.handleFetchMessages(http, onError);

@@ -84,0 +37,0 @@ }

import {HttpHandler, HttpRequest, HttpResponse} from "@http4t/core/contract";
import {uriString} from "@http4t/core/requests";
import {Uri} from "@http4t/core/uri";
import {badGateway, ErrorAdapter} from "./ErrorAdapter";
import {badGateway, ErrorResponder} from "./util/ErrorResponder";
import {fetchMessage, handleFetchMessages} from "./FetchMessage";
import CreateProperties = chrome.tabs.CreateProperties;
import QueryInfo = chrome.tabs.QueryInfo;
import Tab = chrome.tabs.Tab;
import {findTabByHost, TabFinder} from "./util/tabs";
export function rootUrl(request: HttpRequest): CreateProperties {
const requestUri = Uri.of(request.uri);
const uri = Uri.of({
scheme: requestUri.scheme,
authority: requestUri.authority,
path: "/"
});
return {
url: uri.toString(),
active: false
};
}
export function sameHost(request: HttpRequest): QueryInfo {
const requestUri = Uri.of(request.uri);
const uri = Uri.of({
scheme: requestUri.scheme,
authority: requestUri.authority,
path: "/*"
});
return {url: uri.toString()};
}
export function findOrCreateTab(
queryInfo: QueryInfo,
properties: CreateProperties): Promise<Tab> {
return new Promise<Tab>((resolve, reject) =>
chrome.tabs.query(queryInfo, (tabs) => {
console.log("tabs", tabs);
console.log("queryInfo", queryInfo);
const tab = tabs?.[0];
if (tab)
return resolve(tab);
chrome.tabs.create(properties, (tab) => {
if (!tab) {
reject({message: "Could not create tab", properties})
} else {
resolve(tab);
}
return true;
})
}))
}
export const findTabByHost: TabFinder =
request => {
return findOrCreateTab(
sameHost(request),
rootUrl(request));
}
export type TabFinder = (request: HttpRequest) => Promise<Tab>;
export class SendToTabHandler implements HttpHandler {

@@ -72,3 +15,2 @@ constructor(private readonly findTab: TabFinder = findTabByHost) {

.then(tab => {
console.log("tab", tab);
if (!tab)

@@ -100,5 +42,5 @@ throw {

http: HttpHandler = new SendToTabHandler(findTabByHost),
onError: ErrorAdapter = badGateway
onError: ErrorResponder = badGateway
) {
handleFetchMessages(http, onError);
}
import { HttpHandler } from "@http4t/core/contract";
import { ErrorAdapter } from "./ErrorAdapter";
import { ErrorResponder } from "./util/ErrorResponder";
/**
* Handles requests sent by a background script which has called {@link startBackgroundListener}
*/
export declare function startContentScriptListener(http?: HttpHandler, onError?: ErrorAdapter): void;
export declare function startContentScriptListener(http?: HttpHandler, onError?: ErrorResponder): void;
//# sourceMappingURL=content.d.ts.map

@@ -5,3 +5,3 @@ "use strict";

const fetch_1 = require("@http4t/browser/fetch");
const ErrorAdapter_1 = require("./ErrorAdapter");
const ErrorResponder_1 = require("./util/ErrorResponder");
const FetchMessage_1 = require("./FetchMessage");

@@ -11,3 +11,3 @@ /**

*/
function startContentScriptListener(http = new fetch_1.FetchHandler(), onError = ErrorAdapter_1.badGateway) {
function startContentScriptListener(http = new fetch_1.FetchHandler(), onError = ErrorResponder_1.badGateway) {
FetchMessage_1.handleFetchMessages(http, onError);

@@ -14,0 +14,0 @@ }

import {FetchHandler} from "@http4t/browser/fetch";
import {HttpHandler} from "@http4t/core/contract";
import {badGateway, ErrorAdapter} from "./ErrorAdapter";
import {badGateway, ErrorResponder} from "./util/ErrorResponder";
import {handleFetchMessages} from "./FetchMessage";

@@ -11,4 +11,4 @@

http: HttpHandler = new FetchHandler(),
onError: ErrorAdapter = badGateway) {
onError: ErrorResponder = badGateway) {
handleFetchMessages(http, onError);
}
import { HttpHandler, HttpRequest, HttpResponse } from "@http4t/core/contract";
/**
* Wraps an HttpRequest to send to listeners
*/
export declare type FetchMessage = {

@@ -3,0 +6,0 @@ msg: "fetch";

import {HttpHandler, HttpRequest, HttpResponse} from "@http4t/core/contract";
/**
* Wraps an HttpRequest to send to listeners
*/
export type FetchMessage = { msg: "fetch", request: HttpRequest };

@@ -4,0 +7,0 @@

/// <reference types="chrome" />
import { HttpHandler, HttpRequest, HttpResponse } from "@http4t/core/contract";
import { ErrorAdapter } from "./ErrorAdapter";
import { ErrorResponder } from "./util/ErrorResponder";
import MessageOptions = chrome.runtime.MessageOptions;

@@ -14,5 +14,5 @@ /**

private readonly onError;
constructor(extensionId?: (request: HttpRequest) => any, options?: (request: HttpRequest) => MessageOptions, onError?: ErrorAdapter);
constructor(extensionId?: (request: HttpRequest) => any, options?: (request: HttpRequest) => MessageOptions, onError?: ErrorResponder);
handle(request: HttpRequest): Promise<HttpResponse>;
}
//# sourceMappingURL=FetchViaBackgroundScript.d.ts.map

@@ -13,3 +13,3 @@ "use strict";

exports.FetchViaBackgroundScript = void 0;
const ErrorAdapter_1 = require("./ErrorAdapter");
const ErrorResponder_1 = require("./util/ErrorResponder");
const FetchMessage_1 = require("./FetchMessage");

@@ -22,3 +22,3 @@ /**

class FetchViaBackgroundScript {
constructor(extensionId = () => undefined, options = () => ({}), onError = ErrorAdapter_1.badGateway) {
constructor(extensionId = () => undefined, options = () => ({}), onError = ErrorResponder_1.badGateway) {
this.extensionId = extensionId;

@@ -25,0 +25,0 @@ this.options = options;

import {HttpHandler, HttpRequest, HttpResponse} from "@http4t/core/contract";
import {badGateway, ErrorAdapter} from "./ErrorAdapter";
import {badGateway, ErrorResponder} from "./util/ErrorResponder";
import {fetchMessage} from "./FetchMessage";

@@ -17,3 +17,3 @@ import MessageOptions = chrome.runtime.MessageOptions;

() => ({}),
private readonly onError: ErrorAdapter =
private readonly onError: ErrorResponder =
badGateway) {

@@ -20,0 +20,0 @@ }

{
"name": "@http4t/chrome-extension",
"version": "0.1.45",
"version": "0.1.47",
"license": "Apache-2.0",

@@ -5,0 +5,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc