index.d.ts 880 Bytes
Newer Older
1
import React from 'react';
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
2
import AuthorizedRoute, { authority } from './AuthorizedRoute';
jim's avatar
jim committed
3 4 5 6 7
export type IReactComponent<P = any> =
  | React.StatelessComponent<P>
  | React.ComponentClass<P>
  | React.ClassicComponentClass<P>;

ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
8 9 10 11
type Secured = (
  authority: authority,
  error?: React.ReactNode
) => <T extends IReactComponent>(target: T) => T;
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
12

ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
13 14 15 16 17
type check = <T extends IReactComponent, S extends IReactComponent>(
  authority: authority,
  target: T,
  Exception: S
) => T | S;
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
18

ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
19
export interface IAuthorizedProps {
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
20 21 22 23
  authority: authority;
  noMatch?: React.ReactNode;
}

ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
24 25 26 27
export class Authorized extends React.Component<IAuthorizedProps, any> {
  public static Secured: Secured;
  public static AuthorizedRoute: typeof AuthorizedRoute;
  public static check: check;
ι™ˆεΈ…'s avatar
ι™ˆεΈ… committed
28 29 30 31 32
}

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

export default renderAuthorize;