mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-01 15:50:13 +00:00
[koa-sslify] Update types to v4
This commit is contained in:
83
types/koa-sslify/index.d.ts
vendored
83
types/koa-sslify/index.d.ts
vendored
@@ -1,25 +1,80 @@
|
||||
// Type definitions for koa-sslify 2.1
|
||||
// Type definitions for koa-sslify 4.0
|
||||
// Project: https://github.com/turboMaCk/koa-sslify#readme
|
||||
// Definitions by: Matthew Bull <https://github.com/wingsbob>
|
||||
// Mihkel Sokk <https://github.com/msokk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as koa from 'koa';
|
||||
import * as koa from "koa";
|
||||
|
||||
declare namespace sslify {
|
||||
interface Options {
|
||||
trustProtoHeader?: boolean;
|
||||
trustAzureHeader?: boolean;
|
||||
port?: number;
|
||||
hostname?: string;
|
||||
ignoreUrl?: boolean;
|
||||
temporary?: boolean;
|
||||
redirectMethods?: string[];
|
||||
internalRedirectMethods?: string[];
|
||||
specCompliantDisallow?: boolean;
|
||||
}
|
||||
interface Options {
|
||||
/**
|
||||
* Function used to test if request is secure
|
||||
*/
|
||||
resolver?: (ctx: koa.Context) => boolean;
|
||||
/**
|
||||
* Hostname for redirect (uses request host if not set)
|
||||
*/
|
||||
hostname?: string;
|
||||
/**
|
||||
* Port of HTTPS server
|
||||
*/
|
||||
port?: number;
|
||||
/**
|
||||
* Avoid :443 port in redirect url
|
||||
*/
|
||||
skipDefaultPort?: boolean;
|
||||
/**
|
||||
* Ignore url path (redirect to domain)
|
||||
*/
|
||||
ignoreUrl?: boolean;
|
||||
/**
|
||||
* Temporary mode (use 307 Temporary Redirect)
|
||||
*/
|
||||
temporary?: boolean;
|
||||
/**
|
||||
* Whitelist methods that should be redirected
|
||||
*/
|
||||
redirectMethods?: string[];
|
||||
/**
|
||||
* Status returned for disallowed methods
|
||||
*/
|
||||
disallowStatus?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default HTTPS resolver
|
||||
* This works when using node.js TLS support
|
||||
*/
|
||||
function httpsResolver(ctx: koa.Context): boolean;
|
||||
|
||||
/**
|
||||
* x-forwarded-proto header resolver
|
||||
* common for heroku gcp (ingress) etc
|
||||
*/
|
||||
function xForwardedProtoResolver(ctx: koa.Context): boolean;
|
||||
|
||||
/**
|
||||
* Azure resolver
|
||||
* Azure is using `x-att-ssl` header
|
||||
*/
|
||||
function azureResolver(ctx: koa.Context): boolean;
|
||||
|
||||
/**
|
||||
* Custom proto header factory
|
||||
*/
|
||||
function customProtoHeaderResolver(
|
||||
header: string
|
||||
): (ctx: koa.Context) => boolean;
|
||||
|
||||
/**
|
||||
* Resolver for `Forwarded` header
|
||||
* see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded
|
||||
*/
|
||||
function forwardedResolver(ctx: koa.Context): boolean;
|
||||
}
|
||||
|
||||
declare function sslify(options: sslify.Options): koa.Middleware;
|
||||
declare function sslify(options?: sslify.Options): koa.Middleware;
|
||||
|
||||
export = sslify;
|
||||
|
||||
@@ -1,40 +1,50 @@
|
||||
import Koa = require('koa');
|
||||
import sslify = require('koa-sslify');
|
||||
|
||||
new Koa().use(sslify());
|
||||
|
||||
new Koa().use(sslify({}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
trustAzureHeader: true,
|
||||
resolver: sslify.xForwardedProtoResolver,
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
trustProtoHeader: true,
|
||||
resolver: sslify.azureResolver,
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
specCompliantDisallow: true,
|
||||
resolver: sslify.customProtoHeaderResolver('x-protocol'),
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
port: 1234,
|
||||
resolver: sslify.forwardedResolver,
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
hostname: 'my-host',
|
||||
disallowStatus: 405,
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
temporary: false,
|
||||
port: 1234,
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
internalRedirectMethods: ['GET'],
|
||||
hostname: 'my-host',
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
redirectMethods: ['GET'],
|
||||
temporary: false,
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
ignoreUrl: true,
|
||||
redirectMethods: ['GET'],
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
skipDefaultPort: false,
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
ignoreUrl: true,
|
||||
}));
|
||||
|
||||
@@ -1,23 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"koa-sslify-tests.ts"
|
||||
]
|
||||
}
|
||||
"files": ["index.d.ts", "koa-sslify-tests.ts"]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user