Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@appear.sh/introspector

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@appear.sh/introspector - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

lib/hooks.d.ts

3

lib/config.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveConfig = resolveConfig;
exports.resolveConfig = void 0;
const intercept_1 = require("./intercept");

@@ -9,1 +9,2 @@ const report_1 = require("./report");

}
exports.resolveConfig = resolveConfig;

@@ -28,3 +28,14 @@ import { AnySchemaType, ArraySchemaType, BooleanSchemaType, IntegerSchemaType, NullSchemaType, NumberSchemaType, ObjectSchemaType, SomeSchemaType, StringSchemaType } from "./jsonSchema.types";

};
matchSchema: (schema: NumberSchemaType) => schema is NumberSchemaType & {
matchSchema: (schema: NumberSchemaType) => schema is AnySchemaType & {
type: "number";
default?: number | undefined;
examples?: number[] | undefined;
enum?: number[] | undefined;
const?: number | undefined;
minimum?: number | undefined;
maximum?: number | undefined;
exclusiveMinimum?: number | boolean | undefined;
exclusiveMaximum?: number | boolean | undefined;
multipleOf?: number | undefined;
} & {
multipleOf: number;

@@ -65,3 +76,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "boolean";

@@ -77,3 +98,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "uuid";

@@ -89,3 +120,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "date";

@@ -102,3 +143,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "date-time";

@@ -114,3 +165,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "utc-date-time";

@@ -126,3 +187,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "hex";

@@ -138,3 +209,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "base64";

@@ -151,3 +232,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "git-uri";

@@ -164,3 +255,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "uri";

@@ -176,3 +277,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "email";

@@ -188,3 +299,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "filename";

@@ -279,3 +400,14 @@ };

};
matchSchema: (schema: NumberSchemaType) => schema is NumberSchemaType & {
matchSchema: (schema: NumberSchemaType) => schema is AnySchemaType & {
type: "number";
default?: number | undefined;
examples?: number[] | undefined;
enum?: number[] | undefined;
const?: number | undefined;
minimum?: number | undefined;
maximum?: number | undefined;
exclusiveMinimum?: number | boolean | undefined;
exclusiveMaximum?: number | boolean | undefined;
multipleOf?: number | undefined;
} & {
multipleOf: number;

@@ -313,3 +445,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "boolean";

@@ -324,3 +466,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "uuid";

@@ -335,3 +487,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "date";

@@ -347,3 +509,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "date-time";

@@ -358,3 +530,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "utc-date-time";

@@ -369,3 +551,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "hex";

@@ -380,3 +572,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "base64";

@@ -392,3 +594,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "git-uri";

@@ -404,3 +616,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "uri";

@@ -415,3 +637,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "email";

@@ -426,3 +658,13 @@ };

};
matchSchema: (schema: StringSchemaType) => schema is StringSchemaType & {
matchSchema: (schema: StringSchemaType) => schema is AnySchemaType & {
type: "string";
default?: string | undefined;
examples?: string[] | undefined;
enum?: string[] | undefined;
const?: string | undefined;
minLength?: number | undefined;
maxLength?: number | undefined;
pattern?: string | undefined;
format?: string | undefined;
} & {
format: "filename";

@@ -429,0 +671,0 @@ };

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.mergeSchemas = exports.schemaFromValue = exports.getType = exports.CONTENT_TYPES = void 0;
exports.fitsSchema = fitsSchema;
exports.fitsSchema = exports.mergeSchemas = exports.schemaFromValue = exports.getType = exports.CONTENT_TYPES = void 0;
const lodash_1 = require("lodash");

@@ -511,1 +510,2 @@ const helpers_1 = require("../helpers");

}
exports.fitsSchema = fitsSchema;
export { init, AppearIntrospector } from "./init";
export { DEFAULT_REPORTING_ENDPOINT } from "./report";
export { defaultInterceptFilter } from "./intercept";
export { process } from "./process";
export { AppearConfig } from "./config";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.process = exports.defaultInterceptFilter = exports.DEFAULT_REPORTING_ENDPOINT = exports.init = void 0;
exports.defaultInterceptFilter = exports.DEFAULT_REPORTING_ENDPOINT = exports.init = void 0;
var init_1 = require("./init");

@@ -10,3 +10,1 @@ Object.defineProperty(exports, "init", { enumerable: true, get: function () { return init_1.init; } });

Object.defineProperty(exports, "defaultInterceptFilter", { enumerable: true, get: function () { return intercept_1.defaultInterceptFilter; } });
var process_1 = require("./process");
Object.defineProperty(exports, "process", { enumerable: true, get: function () { return process_1.process; } });

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.init = init;
exports.init = void 0;
const config_1 = require("./config");

@@ -35,1 +35,2 @@ const intercept_1 = require("./intercept");

}
exports.init = init;

@@ -35,8 +35,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultInterceptFilter = void 0;
exports.intercept = intercept;
exports.intercept = exports.defaultInterceptFilter = void 0;
const interceptors_1 = require("@mswjs/interceptors");
const fetch_1 = require("@mswjs/interceptors/fetch");
const jsEnv = __importStar(require("browser-or-node"));
const process_1 = require("./process");
const contentTypes_1 = require("./contentTypes/contentTypes");
const helpers_1 = require("./helpers");
const defaultInterceptFilter = (request, response, config) => {

@@ -53,2 +53,72 @@ // Fetch & XHR don't have set destination

exports.defaultInterceptFilter = defaultInterceptFilter;
const getBodySchema = (input) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b, _c;
const clone = input.clone();
if (!clone.body)
return null;
const contentMediaType = (_c = (_b = (_a = clone.headers
.get("content-type")) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.split(";")[0]) === null || _c === void 0 ? void 0 : _c.trim();
if (/application\/(?:.*\+)?json/.test(contentMediaType !== null && contentMediaType !== void 0 ? contentMediaType : "")) {
// application/json;
// application/something+json;
// application/vnd.something-other+json;
const contentSchema = (0, contentTypes_1.schemaFromValue)(yield clone.json(), "in:body");
if (!contentSchema)
return null;
return {
type: "string",
contentSchema,
contentMediaType: contentMediaType,
};
}
else if (/application\/(?:.*\+)?xml/.test(contentMediaType !== null && contentMediaType !== void 0 ? contentMediaType : "")) {
// application/xml;
// application/something+xml;
// application/vnd.something-other+xml;
// todo add xml parsing
return { type: "string", contentMediaType: contentMediaType };
}
else if (contentMediaType === null || contentMediaType === void 0 ? void 0 : contentMediaType.includes("text/")) {
return { type: "string", contentMediaType: contentMediaType };
}
// todo add other types
// unknown type
return null;
});
const convertToOperation = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
const requestBody = yield getBodySchema(req);
const responseBody = yield getBodySchema(res);
const requestHeadersSchemaEntries = [...req.headers.entries()]
.map(([name, value]) => {
const schema = (0, contentTypes_1.schemaFromValue)(value, "in:header");
return schema ? [name, schema] : undefined;
})
.filter(helpers_1.isNonNullable);
const responseHeadersSchemaEntries = [...req.headers.entries()]
.map(([name, value]) => {
const schema = (0, contentTypes_1.schemaFromValue)(value, "in:header");
return schema ? [name, schema] : undefined;
})
.filter(helpers_1.isNonNullable);
const query = [...new URL(req.url, "http://localhost").searchParams.entries()]
.map(([name, value]) => {
const schema = (0, contentTypes_1.schemaFromValue)(value, "in:query");
return schema ? [name, schema] : undefined;
})
.filter(helpers_1.isNonNullable);
return {
request: {
method: req.method,
uri: req.url.split("?")[0], // remove query so we don't send raw values
headers: Object.fromEntries(requestHeadersSchemaEntries),
query: Object.fromEntries(query),
body: requestBody,
},
response: {
headers: Object.fromEntries(responseHeadersSchemaEntries),
statusCode: res.status,
body: responseBody,
},
};
});
function intercept(config, onOperation) {

@@ -76,3 +146,3 @@ return __awaiter(this, void 0, void 0, function* () {

});
interceptor.on("response", (_a) => __awaiter(this, [_a], void 0, function* ({ requestId, response }) {
interceptor.on("response", (_b) => __awaiter(this, [_b], void 0, function* ({ requestId, response }) {
const request = requests.get(requestId);

@@ -88,3 +158,3 @@ if (!request) {

}
const operation = yield (0, process_1.process)(request, response, config);
const operation = yield convertToOperation(request, response);
onOperation(operation);

@@ -100,1 +170,2 @@ }));

}
exports.intercept = intercept;

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

const report = (op) => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b;
var _c, _d;
const hash = xxhashjs_1.default.h32((0, fast_json_stable_stringify_1.default)(op), 1).toString(16);

@@ -49,3 +49,3 @@ // if it was already reported skip it

if (sendImmediately ||
bufferedOperations.length > ((_b = (_a = config.reporting) === null || _a === void 0 ? void 0 : _a.batchSize) !== null && _b !== void 0 ? _b : 10)) {
bufferedOperations.length > ((_d = (_c = config.reporting) === null || _c === void 0 ? void 0 : _c.batchSize) !== null && _d !== void 0 ? _d : 10)) {
return flush();

@@ -55,3 +55,3 @@ }

const flush = () => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b;
var _e, _f;
if (bufferedOperations.length === 0)

@@ -65,3 +65,3 @@ return;

// try send report, in case of error return operations back to batch
const endpoint = (_b = (_a = config.reporting) === null || _a === void 0 ? void 0 : _a.endpoint) !== null && _b !== void 0 ? _b : exports.DEFAULT_REPORTING_ENDPOINT;
const endpoint = (_f = (_e = config.reporting) === null || _e === void 0 ? void 0 : _e.endpoint) !== null && _f !== void 0 ? _f : exports.DEFAULT_REPORTING_ENDPOINT;
try {

@@ -68,0 +68,0 @@ const response = yield fetch(endpoint, {

{
"name": "@appear.sh/introspector",
"version": "0.0.4",
"version": "0.0.5",
"description": "",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"test": "vitest",
"build": "tsc",
"lint": "prettier .",
"lint:fix": "prettier --write .",
"prepublish": "rm -rf ./lib && pnpm run build --build --force"
},
"repository": {

@@ -38,10 +45,3 @@ "type": "git",

"xxhashjs": "^0.2.2"
},
"scripts": {
"test": "vitest",
"build": "tsc",
"lint": "prettier .",
"lint:fix": "prettier --write .",
"prepublish": "rm -rf ./lib && pnpm run build --build --force"
}
}
}

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