index.d.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import * as React from "react";
  2. import * as H from "history";
  3. import { RouteProps } from "react-router";
  4. type authorityFN = () => string;
  5. type authority = string | Array<string> | authorityFN | Promise<any>;
  6. interface Secured {
  7. (authority: authority, error?: React.ReactNode): (
  8. target: React.ReactNode
  9. ) => React.ReactNode;
  10. }
  11. export interface AuthorizedRouteProps extends RouteProps {
  12. authority: authority;
  13. }
  14. export class AuthorizedRoute extends React.Component<
  15. AuthorizedRouteProps,
  16. any
  17. > {
  18. constructor(props: AuthorizedRouteProps);
  19. }
  20. interface check {
  21. (
  22. authority: authority,
  23. target: React.ReactNode,
  24. Exception: React.ReactNode
  25. ): React.ReactNode;
  26. }
  27. interface AuthorizedProps {
  28. authority: authority;
  29. noMatch?: React.ReactNode;
  30. }
  31. export class Authorized extends React.Component<AuthorizedProps, any> {
  32. static Secured: Secured;
  33. static AuthorizedRoute: typeof AuthorizedRoute;
  34. static check: check;
  35. constructor(props: AuthorizedProps);
  36. }
  37. declare function renderAuthorize(currentAuthority: string): typeof Authorized;
  38. export default renderAuthorize;