1.0.11 • Published 1 year ago

vite-plugin-local-token v1.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

vite-local-token

Vite plugin for local development. Set the token as local Cookie returned from SSO login.

Motivation

  • Support local developing if use SSO Authorization
  • previous way:
    • SSO login
    • return to the target page
    • get the authorization token in the url query
    • copy the token and paste it into Cookie

Usage

pnpm i -D vite-plugin-local-token
// vite.config.ts
import localToken from 'vite-plugin-local-token'

// @see https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    // ...other plugins
    localToken(/* options */),
  ],
})

Options

interface IOption {
  tokenKeyName: string;
  tokenQueryName: string;
  cookieControl?: string[];
}

// example
export default defineConfig({
  plugins: [
    react(),
    //@ts-ignore
    viteLocalTokenPlugin({
      // set cookie attributes
      cookieControl: ["HttpOnly", "Secure", "..."],
      // cookie Name
      tokenKeyName: "X-Isyscore-Permission-Sid",
      // name of the token in queries, eg: http://.....?token=xxxxx
      tokenQueryName: "token",
    }),
  ]
  }
)
1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago