2.0.1 • Published 2 years ago
@anciitk/kratos-verify-session v2.0.1
kratos-verify-session
Propreity package to check Ory Kratos session and handle redirects accordingly
Install
npm install --save kratos-verify-session
Usage
import React, { Component } from 'react'
import Verify from 'kratos-verify-session'
import 'kratos-verify-session/dist/index.css'
class Example extends Component {
render() {
return <Verfiy
loginUrl: 'url to login page'
basePath: 'basePath of your main application' //eg http://localhost:3000
path: 'on path that you want to go' //eg dashboard
historyPush: 'funtion to push the new route in history'
setSessionState: 'funtion to update session state'
xenon: 'pass a xenon reference aftrer importing in your application'
ory: 'locally defined ory instance in your application'
sessionState: 'session state'
/>
}
}
session state
interface sessionState {
active: boolean
logoutUrl: string
user: UserCrediantials //type obtained from @anciitk/xenon
session: Session //type obtained from @ory/kratos-client
}
historyPush
for react
const app = ({history}) => {
// this function was provided by react router
history.push(/something)
}
for next
import { useRouter } from 'next/router'
const app = () => {
const router = useRouter()
historyPush = router.push
}
License
MIT © Mshivam2409