From 14dc3085d04e8d4bd78845b0a4a57e99a868946c Mon Sep 17 00:00:00 2001 From: Jared Russell Date: Mon, 17 Jul 2017 12:21:19 +0100 Subject: [PATCH] Add TypeScript definition file --- index.d.ts | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 59 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..554aa07 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,58 @@ +declare module 'redux-oidc' { + import { UserManager, UserManagerSettings, User } from 'oidc-client'; + import { Action, BaseAction } from 'redux-actions'; + import { Map, fromJS } from 'immutable'; + import { Middleware, Store } from 'redux'; + import * as React from 'react'; + + export interface UserState { + user: User; + isLoadingUser: boolean; + } + + export interface CallbackComponentProps { + userManager: UserManager; + successCallback: (user: User) => void; + errorCallback?: (error: Error) => void; + route?: string; + } + + export class CallbackComponent extends React.Component { } + + export interface OidcProviderProps { + userManager: UserManager; + store: Store; + } + + export class OidcProvider extends React.Component> { } + + // Components + export function createUserManager(options: UserManagerSettings): UserManager; + export function processSilentRenew(): void; + export function loadUser(store: TStore, userManager: UserManager): Promise; + export function reducer(state: UserState, action: Action): UserState; + export function immutableReducer(state: Map, action: Action): Map; + + // Constants + export const USER_EXPIRED: string; + export const REDIRECT_SUCCESS: string; + export const USER_LOADED: string; + export const SILENT_RENEW_ERROR: string; + export const SESSION_TERMINATED: string; + export const USER_EXPIRING: string; + export const USER_FOUND: string; + export const LOADING_USER: string; + export const USER_SIGNED_OUT: string; + + // Actions + export function userExpired(): BaseAction; + export function redirectSuccess(): Action; + export function userFound(): Action; + export function silentRenewError(): Action; + export function sessionTerminated(): BaseAction; + export function userExpiring(): BaseAction; + export function loadingUser(): BaseAction; + export function userSignedOut(): BaseAction; + + export default function createOidcMiddleware(userManager: UserManager): Middleware; +} \ No newline at end of file diff --git a/package.json b/package.json index b3304bb..c331122 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "3.0.0-beta.8", "description": "A package for managing OpenID Connect authentication in redux apps", "main": "dist/redux-oidc.js", + "types": "./index.d.ts", "scripts": { "test": "mocha-webpack --webpack-config webpack.config-test.js \"tests/**/*.test.js\"", "build": "webpack -p",