mirror of
https://github.com/abrendan/MicDropMessages.git
synced 2025-08-25 14:02:03 +02:00
Initial commit
This commit is contained in:
7
node_modules/referrer-policy/dist/index.d.ts
generated
vendored
Normal file
7
node_modules/referrer-policy/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/// <reference types="node" />
|
||||
import { IncomingMessage, ServerResponse } from 'http';
|
||||
interface ReferrerPolicyOptions {
|
||||
policy?: string | string[];
|
||||
}
|
||||
declare const _default: (options?: ReferrerPolicyOptions | undefined) => (_req: IncomingMessage, res: ServerResponse, next: () => void) => void;
|
||||
export = _default;
|
53
node_modules/referrer-policy/dist/index.js
generated
vendored
Normal file
53
node_modules/referrer-policy/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
"use strict";
|
||||
function getHeaderValueFromOptions(options) {
|
||||
var DEFAULT_POLICY = 'no-referrer';
|
||||
var ALLOWED_POLICIES = [
|
||||
'no-referrer',
|
||||
'no-referrer-when-downgrade',
|
||||
'same-origin',
|
||||
'origin',
|
||||
'strict-origin',
|
||||
'origin-when-cross-origin',
|
||||
'strict-origin-when-cross-origin',
|
||||
'unsafe-url',
|
||||
''
|
||||
];
|
||||
options = options || {};
|
||||
var policyOption;
|
||||
if ('policy' in options) {
|
||||
policyOption = options.policy;
|
||||
}
|
||||
else {
|
||||
policyOption = DEFAULT_POLICY;
|
||||
}
|
||||
var policies = Array.isArray(policyOption) ? policyOption : [policyOption];
|
||||
if (policies.length === 0) {
|
||||
throw new Error('At least one policy must be supplied.');
|
||||
}
|
||||
var policiesSeen = new Set();
|
||||
policies.forEach(function (policy) {
|
||||
if ((typeof policy !== 'string') || (ALLOWED_POLICIES.indexOf(policy) === -1)) {
|
||||
var allowedPoliciesErrorList = ALLOWED_POLICIES.map(function (policy) {
|
||||
if (policy.length) {
|
||||
return "\"" + policy + "\"";
|
||||
}
|
||||
else {
|
||||
return 'and the empty string';
|
||||
}
|
||||
}).join(', ');
|
||||
throw new Error("\"" + policy + "\" is not a valid policy. Allowed policies: " + allowedPoliciesErrorList + ".");
|
||||
}
|
||||
if (policiesSeen.has(policy)) {
|
||||
throw new Error("\"" + policy + "\" specified more than once. No duplicates are allowed.");
|
||||
}
|
||||
policiesSeen.add(policy);
|
||||
});
|
||||
return policies.join(',');
|
||||
}
|
||||
module.exports = function referrerPolicy(options) {
|
||||
var headerValue = getHeaderValueFromOptions(options);
|
||||
return function referrerPolicy(_req, res, next) {
|
||||
res.setHeader('Referrer-Policy', headerValue);
|
||||
next();
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user