2.0.1 • Published 2 years ago

@anciitk/kratos-verify-session v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

kratos-verify-session

Propreity package to check Ory Kratos session and handle redirects accordingly

NPM JavaScript Style Guide

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

2.0.1

2 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.0.8

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.0.3

3 years ago

2.0.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago