import { parse } from "query-string" ; import { keysIn } from "ramda" ; import { compose , withHandlers } from "recompose" ; import { SessionToken } from "common" ; /**
 * Handler properties
 */ interface HandlerProps { callback ( id ) : void ; } /**
 * Callback enhancer
 */ export type WithCallback = HandlerProps ; return export const withCallback = ( ) => compose < WithCallback , { } > ( withHandlers < { } , HandlerProps > ( { callback : ( ) => id => { const { redirect } = parse ( location . search ) ; const path = ( redirect as string || "" ) . replace ( /^\// , "" ) ; const hash = keysIn ( id ) . map ( key => `${ key }=${ id [ key as keyof SessionToken ] }` ) . join ( "&" ) ; location . assign ( `//${ window . env . APP_ORIGIN }/${ path }#${ hash }` ) ; } } ) ) ;