index.d.ts 1.08 KB
Newer Older
陈帅's avatar
陈帅 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
import * as React from "react";
import * as H from "history";
import { RouteProps } from "react-router";

type authorityFN = () => string;

type authority = string | Array<string> | authorityFN | Promise<any>;

interface Secured {
  (authority: authority, error?: React.ReactNode): (
    target: React.ReactNode
  ) => React.ReactNode;
}

export interface AuthorizedRouteProps extends RouteProps {
  authority: authority;
}
export class AuthorizedRoute extends React.Component<
  AuthorizedRouteProps,
  any
> {
  constructor(props: AuthorizedRouteProps);
}

interface check {
  (
    authority: authority,
    target: React.ReactNode,
    Exception: React.ReactNode
  ): React.ReactNode;
}

interface AuthorizedProps {
  authority: authority;
  noMatch?: React.ReactNode;
}

export class Authorized extends React.Component<AuthorizedProps, any> {
  static Secured: Secured;
  static AuthorizedRoute: typeof AuthorizedRoute;
  static check: check;
  constructor(props: AuthorizedProps);
}

declare function renderAuthorize(currentAuthority: string): typeof Authorized;

export default renderAuthorize;