1.4.50 • Published 2 months ago

propro-utils v1.4.50

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

propro-utils

propro-utils is a comprehensive Node.js middleware designed for handling both server-side and client-side authentication, notifcations and other utility functions. It's ideal for applications requiring robust authentication strategies and is highly customizable to fit various authentication needs.

Features

  • Dual Authentication Modes: Supports both server-side and client-side authentication.
  • Configurable: Offers a wide range of options for customizing the authentication process.
  • Lazy Loading: Efficiently initializes authentication modules on-demand.
  • Environment Validation: Ensures critical environment variables are set.
  • Error Management: Provides robust error handling during the authentication process.

Installation

Install the middleware using npm or Yarn:

npm install propro-utils
# or
yarn add propro-utils

## Usage

After installing the middleware, you can import it in your project:

```javascript
const proproAuthMiddleware = require("propro-utils");

Then, you can use the middleware in your server and client side code:

const express = require("express");
const app = express();
const proproAuthMiddleware = require("propro-utils");

// Initialize middleware with default parameters
app.use(proproAuthMiddleware());

// Or, initialize with custom settings
// For example, to use only server authentication:
app.use(proproAuthMiddleware(true, false));

// And to use only client authentication:
app.use(proproAuthMiddleware(false, true));

// Add options
app.use(
  proproAuthMiddleware({
    useServerAuth: true,
    serverOptions: {
      validateUser: async (userId) => {
        /* User validation logic */
      },
    secret = "RESTFULAPIs",
    authUrl = process.env.AUTH_URL,
    clientId = process.env.CLIENT_ID,
    clientSecret = process.env.CLIENT_SECRET,
    clientUrl = process.env.CLIENT_URL,
    redirectUri = process.env.REDIRECT_URI,
      onAuthFailRedirect: "/login",
      additionalChecks: async (req) => {
        /* Additional request checks */
      },
    },
    useClientAuth: false,
    clientOptions: {
      // Client-side authentication options
    },
  })
);

Configuration Options

  • useServerAuth (boolean): Enable or disable server-side authentication.
  • serverOptions (object): Configuration options for server-side authentication.
  • useClientAuth (boolean): Enable or disable client-side authentication.
  • clientOptions (object): Configuration options for client-side authentication.

Contributing

If you have suggestions for how propro-utils could be improved, or want to report a bug, open an issue! We'd love all and any contributions.

For more, check out the Contributing Guide.

License

ISC © 2023 ProPro devs@hubhub.app

1.4.39

2 months ago

1.4.38

2 months ago

1.4.40

2 months ago

1.4.42

2 months ago

1.4.41

2 months ago

1.4.44

2 months ago

1.4.43

2 months ago

1.4.46

2 months ago

1.4.45

2 months ago

1.4.48

2 months ago

1.4.47

2 months ago

1.4.49

2 months ago

1.4.50

2 months ago

1.4.31

2 months ago

1.4.33

2 months ago

1.4.32

2 months ago

1.4.35

2 months ago

1.4.34

2 months ago

1.4.37

2 months ago

1.4.36

2 months ago

1.4.29

2 months ago

1.4.30

2 months ago

1.4.28

2 months ago

1.4.26

2 months ago

1.4.27

2 months ago

1.4.24

2 months ago

1.4.23

2 months ago

1.4.25

2 months ago

1.4.6

2 months ago

1.4.5

2 months ago

1.4.4

2 months ago

1.4.3

2 months ago

1.4.2

2 months ago

1.4.1

2 months ago

1.4.20

2 months ago

1.4.22

2 months ago

1.4.21

2 months ago

1.4.9

2 months ago

1.4.11

2 months ago

1.4.8

2 months ago

1.4.10

2 months ago

1.4.7

2 months ago

1.4.13

2 months ago

1.4.12

2 months ago

1.4.15

2 months ago

1.4.14

2 months ago

1.4.17

2 months ago

1.4.16

2 months ago

1.4.19

2 months ago

1.4.18

2 months ago

1.4.0

3 months ago

1.3.42

3 months ago

1.3.43

3 months ago

1.3.46

3 months ago

1.3.47

3 months ago

1.3.44

3 months ago

1.3.45

3 months ago

1.3.48

3 months ago

1.3.49

3 months ago

1.3.39

3 months ago

1.3.40

3 months ago

1.3.41

3 months ago

1.3.31

3 months ago

1.3.32

3 months ago

1.3.30

3 months ago

1.3.35

3 months ago

1.3.36

3 months ago

1.3.33

3 months ago

1.3.34

3 months ago

1.3.37

3 months ago

1.3.38

3 months ago

1.3.29

3 months ago

1.3.25

3 months ago

1.3.28

3 months ago

1.3.26

3 months ago

1.3.27

3 months ago

1.3.24

3 months ago

1.3.21

3 months ago

1.3.22

3 months ago

1.3.23

3 months ago

1.3.19

4 months ago

1.3.20

4 months ago

1.3.17

4 months ago

1.3.18

4 months ago

1.3.14

4 months ago

1.3.15

4 months ago

1.3.16

4 months ago

1.3.10

4 months ago

1.3.9

4 months ago

1.3.13

4 months ago

1.3.11

4 months ago

1.3.12

4 months ago

1.3.8

4 months ago