mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Update koa-sslify. Change module export from commonjs to esmodule (#35377)
* Update index.d.ts * Update koa-sslify-tests.ts
This commit is contained in:
parent
136dd4d7d7
commit
a22f9a688e
113
types/koa-sslify/index.d.ts
vendored
113
types/koa-sslify/index.d.ts
vendored
@ -2,79 +2,74 @@
|
||||
// Project: https://github.com/turboMaCk/koa-sslify#readme
|
||||
// Definitions by: Matthew Bull <https://github.com/wingsbob>
|
||||
// Mihkel Sokk <https://github.com/msokk>
|
||||
// wujingtao <https://github.com/mx601595686>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import * as koa from "koa";
|
||||
|
||||
declare namespace sslify {
|
||||
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;
|
||||
}
|
||||
import koa = require('koa');
|
||||
|
||||
export interface Options {
|
||||
/**
|
||||
* Default HTTPS resolver
|
||||
* This works when using node.js TLS support
|
||||
* Function used to test if request is secure
|
||||
*/
|
||||
function httpsResolver(ctx: koa.Context): boolean;
|
||||
|
||||
resolver?: (ctx: koa.Context) => boolean;
|
||||
/**
|
||||
* x-forwarded-proto header resolver
|
||||
* common for heroku gcp (ingress) etc
|
||||
* Hostname for redirect (uses request host if not set)
|
||||
*/
|
||||
function xForwardedProtoResolver(ctx: koa.Context): boolean;
|
||||
|
||||
hostname?: string;
|
||||
/**
|
||||
* Azure resolver
|
||||
* Azure is using `x-att-ssl` header
|
||||
* Port of HTTPS server
|
||||
*/
|
||||
function azureResolver(ctx: koa.Context): boolean;
|
||||
|
||||
port?: number;
|
||||
/**
|
||||
* Custom proto header factory
|
||||
* Avoid :443 port in redirect url
|
||||
*/
|
||||
function customProtoHeaderResolver(
|
||||
header: string
|
||||
): (ctx: koa.Context) => boolean;
|
||||
|
||||
skipDefaultPort?: boolean;
|
||||
/**
|
||||
* Resolver for `Forwarded` header
|
||||
* see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded
|
||||
* Ignore url path (redirect to domain)
|
||||
*/
|
||||
function forwardedResolver(ctx: koa.Context): boolean;
|
||||
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;
|
||||
}
|
||||
|
||||
declare function sslify(options?: sslify.Options): koa.Middleware;
|
||||
/**
|
||||
* Default HTTPS resolver
|
||||
* This works when using node.js TLS support
|
||||
*/
|
||||
export function httpsResolver(ctx: koa.Context): boolean;
|
||||
|
||||
export = sslify;
|
||||
/**
|
||||
* x-forwarded-proto header resolver
|
||||
* common for heroku gcp (ingress) etc
|
||||
*/
|
||||
export function xForwardedProtoResolver(ctx: koa.Context): boolean;
|
||||
|
||||
/**
|
||||
* Azure resolver
|
||||
* Azure is using `x-att-ssl` header
|
||||
*/
|
||||
export function azureResolver(ctx: koa.Context): boolean;
|
||||
|
||||
/**
|
||||
* Custom proto header factory
|
||||
*/
|
||||
export function customProtoHeaderResolver(header: string): (ctx: koa.Context) => boolean;
|
||||
|
||||
/**
|
||||
* Resolver for `Forwarded` header
|
||||
* see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded
|
||||
*/
|
||||
export function forwardedResolver(ctx: koa.Context): boolean;
|
||||
|
||||
export default function factory(options?: Options): koa.Middleware;
|
||||
|
||||
@ -1,24 +1,24 @@
|
||||
import Koa = require('koa');
|
||||
import sslify = require('koa-sslify');
|
||||
import sslify, { xForwardedProtoResolver, azureResolver, customProtoHeaderResolver, forwardedResolver } from 'koa-sslify';
|
||||
|
||||
new Koa().use(sslify());
|
||||
|
||||
new Koa().use(sslify({}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
resolver: sslify.xForwardedProtoResolver,
|
||||
resolver: xForwardedProtoResolver,
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
resolver: sslify.azureResolver,
|
||||
resolver: azureResolver,
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
resolver: sslify.customProtoHeaderResolver('x-protocol'),
|
||||
resolver: customProtoHeaderResolver('x-protocol'),
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
resolver: sslify.forwardedResolver,
|
||||
resolver: forwardedResolver,
|
||||
}));
|
||||
|
||||
new Koa().use(sslify({
|
||||
|
||||
Loading…
Reference in New Issue
Block a user