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

quidproquo-webserver

Package Overview
Dependencies
Maintainers
1
Versions
234
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quidproquo-webserver - npm Package Compare versions

Comparing version 0.0.26 to 0.0.27

lib/config/settings/defaultRouteOptions.d.ts

3

lib/config/QPQConfig.d.ts
export declare enum QPQWebServerConfigSettingType {
Route = "@quidproquo-webserver/config/Route",
Dns = "@quidproquo-webserver/config/Dns",
OpenApi = "@quidproquo-webserver/config/OpenApi"
OpenApi = "@quidproquo-webserver/config/OpenApi",
DefaultRouteOptions = "@quidproquo-webserver/config/DefaultRouteOptions"
}

@@ -9,2 +9,3 @@ "use strict";

QPQWebServerConfigSettingType["OpenApi"] = "@quidproquo-webserver/config/OpenApi";
QPQWebServerConfigSettingType["DefaultRouteOptions"] = "@quidproquo-webserver/config/DefaultRouteOptions";
})(QPQWebServerConfigSettingType = exports.QPQWebServerConfigSettingType || (exports.QPQWebServerConfigSettingType = {}));

@@ -0,3 +1,4 @@

export * from './defaultRouteOptions';
export * from './dns';
export * from './openApi';
export * from './route';

@@ -17,4 +17,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./defaultRouteOptions"), exports);
__exportStar(require("./dns"), exports);
__exportStar(require("./openApi"), exports);
__exportStar(require("./route"), exports);
import { QPQConfigSetting, HTTPMethod } from 'quidproquo-core';
export type RouteOptions = {};
export type RouteOptions = {
allowedOrigins?: string[];
};
export interface RouteQPQWebServerConfigSetting extends QPQConfigSetting {

@@ -4,0 +6,0 @@ method: HTTPMethod;

import { QPQConfig } from 'quidproquo-core';
import { RouteQPQWebServerConfigSetting } from './config/settings/route';
import { OpenApiQPQWebServerConfigSetting } from './config/settings/openApi';
import { HttpEventHeaders } from './types/HTTPEvent';
import { RouteOptions } from './config/settings/route';
export declare const getAllRoutes: (configs: QPQConfig) => RouteQPQWebServerConfigSetting[];

@@ -8,1 +10,5 @@ export declare const getAllOpenApiSpecs: (configs: QPQConfig) => OpenApiQPQWebServerConfigSetting[];

export declare const getDomainName: (configs: QPQConfig) => string;
export declare const getFeatureDomainName: (configs: QPQConfig) => string;
export declare const getHeaderValue: (header: string, headers: HttpEventHeaders) => string | null;
export declare const getAllowedOrigins: (configs: QPQConfig, route: RouteOptions) => string[];
export declare const getCorsHeaders: (configs: QPQConfig, route: RouteOptions, reqHeaders: HttpEventHeaders) => HttpEventHeaders;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDomainName = exports.getAllSrcEntries = exports.getAllOpenApiSpecs = exports.getAllRoutes = void 0;
exports.getCorsHeaders = exports.getAllowedOrigins = exports.getHeaderValue = exports.getFeatureDomainName = exports.getDomainName = exports.getAllSrcEntries = exports.getAllOpenApiSpecs = exports.getAllRoutes = void 0;
const quidproquo_core_1 = require("quidproquo-core");
const QPQConfig_1 = require("./config/QPQConfig");
const qpqCoreUtils_1 = require("quidproquo-core/lib/qpqCoreUtils");
const getAllRoutes = (configs) => {

@@ -25,4 +26,2 @@ const routes = quidproquo_core_1.qpqCoreUtils.getConfigSettings(configs, QPQConfig_1.QPQWebServerConfigSettingType.Route);

exports.getAllSrcEntries = getAllSrcEntries;
// Used in bundlers to know where and what to build and index
// Events, routes, etc
const getDomainName = (configs) => {

@@ -33,1 +32,42 @@ const dnsSettings = quidproquo_core_1.qpqCoreUtils.getConfigSetting(configs, QPQConfig_1.QPQWebServerConfigSettingType.Dns);

exports.getDomainName = getDomainName;
const getFeatureDomainName = (configs) => {
const feature = (0, qpqCoreUtils_1.getAppFeature)(configs);
const apexDomainName = (0, exports.getDomainName)(configs);
if (feature === 'production') {
return apexDomainName;
}
return `${feature}.${apexDomainName}`;
};
exports.getFeatureDomainName = getFeatureDomainName;
const getHeaderValue = (header, headers) => {
const headerAsLower = header.toLowerCase();
const realHeaderKey = Object.keys(headers).find((k) => k.toLowerCase() === headerAsLower);
if (!realHeaderKey) {
return null;
}
return headers[realHeaderKey] || null;
};
exports.getHeaderValue = getHeaderValue;
const getAllowedOrigins = (configs, route) => {
// Root domain
const rootDomain = `https://${(0, exports.getFeatureDomainName)(configs)}`;
// generic settings
const defaultRouteSettings = quidproquo_core_1.qpqCoreUtils.getConfigSettings(configs, QPQConfig_1.QPQWebServerConfigSettingType.DefaultRouteOptions) || [];
const defaultAllowedOrigins = defaultRouteSettings.reduce((acc, cur) => [...acc, ...(cur.routeOptions.allowedOrigins || [])], []);
// Route specific
const routeAllowedOrigins = route.allowedOrigins || [];
return [rootDomain, ...defaultAllowedOrigins, ...routeAllowedOrigins].map((o) => o.toLowerCase());
};
exports.getAllowedOrigins = getAllowedOrigins;
const getCorsHeaders = (configs, route, reqHeaders) => {
const origin = (0, exports.getHeaderValue)('origin', reqHeaders) || '';
const allowedOrigins = (0, exports.getAllowedOrigins)(configs, route);
const allowOrigin = allowedOrigins.find((ao) => ao === origin) || allowedOrigins[0];
return {
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Methods': '*',
'Access-Control-Allow-Origin': allowOrigin,
Vary: 'Origin',
};
};
exports.getCorsHeaders = getCorsHeaders;
import { HTTPMethod } from 'quidproquo-core';
export interface HttpEventHeaders {
[key: string]: undefined | string;
}
export interface HTTPEventParams<T> {

@@ -8,5 +11,3 @@ path: string;

body: T;
headers: {
[key: string]: undefined | string;
};
headers: HttpEventHeaders;
method: HTTPMethod;

@@ -13,0 +14,0 @@ correlation: string;

{
"name": "quidproquo-webserver",
"version": "0.0.26",
"version": "0.0.27",
"description": "",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

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