@front-finance/link
JS library for integrating with Front Finance
Install
With npm
:
npm install --save @front-finance/link
With yarn
yarn add @front-finance/link
Generating connection method
import { createFrontConnection } from '@front-finance/link';
const frontConnection = createFrontConnection({
clientId: '<Your Front Finance Client Id>',
onBrokerConnected: (brokerData: FrontPayload) => {
},
onExit: (error?: string) => {
if (error) {
} else {
}
}
Using connection to open auth link
To open authentication link rpovided by Front Finance Integration API you need to call openPopup
method:
frontConnection.openPopup(authLink)
ℹ️ See full source code example at react-example/src/ui/Front.tsx
import {
createFrontConnection,
FrontConnection,
FrontPayload
} from '@front-finance/link'
const [frontConnection, setFrontConnection] = useState<FrontConnection | null>(
null
)
useEffect(() => {
setFrontConnection(createFrontConnection(options))
}, [])
useEffect(() => {
if (authLink) {
frontConnection?.openPopup(authLink)
}
}, [frontConnection, authLink])
return <></>
Getting tokens
After successfull authentication on Front Finance user will be redirected back to provided callback URL.
FrontConnection
instance will check if URL contains query parameters, load broker tokens and fire the events.
Available Connection configuration options
ℹ️ See src/types/index.ts for exported types.
createFrontConnection
arguments
key | type |
---|
clientId | string |
onBrokerConnected | (payload: FrontPayload) => void |
onExit | ((error?: string | undefined) => void) | undefined |
createFrontConnection
return value
key | type |
---|
openLink | () => Promise<void> |
Typescript support
TypeScript definitions for @front-finance/link
are built into the npm package.