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

@kasko/fe-webapp-utils-lib

Package Overview
Dependencies
Maintainers
10
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kasko/fe-webapp-utils-lib - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

dist/server/get-body.d.ts

7

CHANGELOG.md
# Changelog
## [v2.1.0](https://github.com/kasko/fe-webapp-utils-lib/compare/v2.0.0...v2.1.0) (2023-08-28)
## Feature
- Mock `/sales_leads` requests;
## Other
- Exports `MockedAPIMiddleware` type;
## [v2.0.0](https://github.com/kasko/fe-webapp-utils-lib/compare/v1.3.2...v2.0.0) (2023-08-25)

@@ -4,0 +11,0 @@ ## Breaking Change

2

dist/server.d.ts
/// <reference types="node" />
export { mockApi } from './server/mock-api';
export { mockApi, type MockedAPIMiddleware } from './server/mock-api';
export interface WebappConfig {

@@ -4,0 +4,0 @@ outbase: string;

@@ -267,2 +267,5 @@ "use strict";

// src/server/default-mock-api.ts
var import_node_crypto = require("node:crypto");
// src/server/resources/touchpoint.json

@@ -519,2 +522,28 @@ var touchpoint_default = {

// src/server/get-body.ts
async function getBody(req) {
try {
const buffers = [];
for await (const chunk of req) {
buffers.push(chunk);
}
return JSON.parse(Buffer.concat(buffers).toString());
} catch (e) {
return e;
}
}
// src/server/colors.ts
var COLOR = {
green: "\x1B[32m",
blue: "\x1B[34m",
red: "\x1B[31m",
white: "\x1B[39m",
gray: "\x1B[2m",
reset: "\x1B[0m"
};
var green = (value) => `${COLOR.green}${value}${COLOR.reset}`;
var blue = (value) => `${COLOR.blue}${value}${COLOR.reset}`;
var gray = (value) => `${COLOR.gray}${value}${COLOR.reset}`;
// src/server/default-mock-api.ts

@@ -524,2 +553,3 @@ function createMockApiRules(mockedApi) {

}
var requestCache = {};
var defaultMockApiRules = createMockApiRules({

@@ -573,2 +603,38 @@ "/services/(.*)": (req, res, _params) => {

res.end(JSON.stringify(claims_default));
},
"POST /sales_leads": async (req, res) => {
const id = `tsl_${(0, import_node_crypto.randomUUID)().replace(/-/g, "")}`;
const body = await getBody(req);
const salesLeadCacheKey = `sales_lead:${id}`;
requestCache[salesLeadCacheKey] = { id, ...body };
const urlConfig = { save_for_later_token: id };
console.log(` > Sales lead: ${blue(`http://${req.headers.host}/${body.integration_id}?config=${encodeURIComponent(JSON.stringify(urlConfig))}`)}`);
console.log(` Access pin: any 8 character string
`);
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify(requestCache[salesLeadCacheKey]));
},
"PATCH /sales_leads/:id": async (req, res, params) => {
const id = params.id;
const body = await getBody(req);
const salesLeadCacheKey = `sales_lead:${id}`;
requestCache[salesLeadCacheKey] = { id, ...body };
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify(requestCache[salesLeadCacheKey]));
},
"POST /sales_leads/:id": (_req, res, params) => {
const id = params.id;
const salesLeadCacheKey = `sales_lead:${id}`;
if (!requestCache[salesLeadCacheKey]) {
res.writeHead(404, { "Content-Type": "application/json" });
res.end(
JSON.stringify({
status: "Not Found",
message: `Sales lead with id "${id}" found.`
})
);
return;
}
res.writeHead(200, { "Content-Type": "application/json" });
res.end(JSON.stringify(requestCache[salesLeadCacheKey]));
}

@@ -653,17 +719,2 @@ });

var import_osenv = __toESM(require_osenv());
// src/server/colors.ts
var COLOR = {
green: "\x1B[32m",
blue: "\x1B[34m",
red: "\x1B[31m",
white: "\x1B[39m",
gray: "\x1B[2m",
reset: "\x1B[0m"
};
var green = (value) => `${COLOR.green}${value}${COLOR.reset}`;
var blue = (value) => `${COLOR.blue}${value}${COLOR.reset}`;
var gray = (value) => `${COLOR.gray}${value}${COLOR.reset}`;
// src/server/fetch-plugin-assets.ts
var localDevJsonPath = `${import_osenv.default.home()}/.kasko/local-kasko.json`;

@@ -670,0 +721,0 @@ function readLocalDevJson() {

@@ -25,2 +25,9 @@ /// <reference types="node" />

'POST /claims': (_req: import("http").IncomingMessage, res: import("http").ServerResponse<import("http").IncomingMessage>, _params: {}) => void;
'POST /sales_leads': (req: import("http").IncomingMessage, res: import("http").ServerResponse<import("http").IncomingMessage>) => Promise<void>;
'PATCH /sales_leads/:id': (req: import("http").IncomingMessage, res: import("http").ServerResponse<import("http").IncomingMessage>, params: {
id: string;
}) => Promise<void>;
'POST /sales_leads/:id': (_req: import("http").IncomingMessage, res: import("http").ServerResponse<import("http").IncomingMessage>, params: {
id: string;
}) => void;
};
{
"name": "@kasko/fe-webapp-utils-lib",
"version": "2.0.0",
"version": "2.1.0",
"main": "./dist/index.js",

@@ -5,0 +5,0 @@ "types": "./dist/index.d.ts",

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