mirror of
https://github.com/abrendan/MicDropMessages.git
synced 2025-08-25 14:02:03 +02:00
Initial commit
This commit is contained in:
9
node_modules/expect-ct/dist/index.d.ts
generated
vendored
Normal file
9
node_modules/expect-ct/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/// <reference types="node" />
|
||||
import { IncomingMessage, ServerResponse } from 'http';
|
||||
interface ExpectCtOptions {
|
||||
maxAge?: number;
|
||||
enforce?: boolean;
|
||||
reportUri?: string;
|
||||
}
|
||||
declare const _default: (options?: ExpectCtOptions | undefined) => (_req: IncomingMessage, res: ServerResponse, next: () => void) => void;
|
||||
export = _default;
|
29
node_modules/expect-ct/dist/index.js
generated
vendored
Normal file
29
node_modules/expect-ct/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
"use strict";
|
||||
function parseMaxAge(option) {
|
||||
if (option === undefined) {
|
||||
return 0;
|
||||
}
|
||||
if (typeof option !== 'number' || option < 0) {
|
||||
throw new Error(option + " is not a valid value for maxAge. Please choose a positive integer.");
|
||||
}
|
||||
return option;
|
||||
}
|
||||
function getHeaderValueFromOptions(options) {
|
||||
options = options || {};
|
||||
var directives = [];
|
||||
if (options.enforce) {
|
||||
directives.push('enforce');
|
||||
}
|
||||
directives.push("max-age=" + parseMaxAge(options.maxAge));
|
||||
if (options.reportUri) {
|
||||
directives.push("report-uri=\"" + options.reportUri + "\"");
|
||||
}
|
||||
return directives.join(', ');
|
||||
}
|
||||
module.exports = function expectCt(options) {
|
||||
var headerValue = getHeaderValueFromOptions(options);
|
||||
return function expectCt(_req, res, next) {
|
||||
res.setHeader('Expect-CT', headerValue);
|
||||
next();
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user