0.1.4 • Published 8 months ago

@finsel-dgi/pasby-react v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

This documentation includes installation instructions, basic usage, and a brief overview of the main components and functions.

@finsel-dgi/pasby-react

@finsel-dgi/pasby-react is a React-focused software development kit (SDK) designed to facilitate authentication processes using the Pasby authorization server. This library provides tools to manage user authentication flows, handle tokens, and interact with the Pasby API.

Installation

To install @finsel-dgi/pasby-react, use npm or yarn:

npm install @finsel-dgi/pasby-react

or

yarn add @finsel-dgi/pasby-react

Usage

Importing the Library

To use the library, import the necessary functions and components into your React application:

import { handshake, User } from '@finsel-dgi/pasby-react';

Authentication Flow

The primary function of this library is to manage the authentication flow with the Pasby authorization server. Below is an example of how to initiate a handshake process:

import { handshake } from '@finsel-dgi/pasby-react';

async function initiateHandshake(flow, code, pkceVerifier) {
  try {
    const response = await handshake({ flow, code, pkceVerifier });
    console.log('Access Token:', response.access);
    console.log('Challenge:', response.challenge);
  } catch (error) {
    console.error('Error during handshake:', error);
  }
}

User Data

The library provides a User interface to define the structure of user data. This can be used to manage and type-check user information within your application:

import { User } from '@finsel-dgi/pasby-react';

const user: User = {
  national: '123456789',
  country: 'CountryName',
  claims: {
    contact: {
      email: 'user@example.com',
      phone: '123-456-7890',
      emailVerified: true,
      phoneVerified: false,
    },
    address: {
      country: 'CountryName',
      city: 'CityName',
      countryCode: 'CN',
      formatted: '123 Main St, CityName, CountryName',
      postCode: '12345',
      place: 'PlaceName',
    },
    bio: {
      birthdate: '1990-01-01',
      gender: 'Non-binary',
      birthplace: 'CityName',
      birthnumber: 123456789,
      maritalStatus: 'Single',
      age: 34,
    },
    nationality: {
      pep: false,
      nationalities: ['CountryName'],
      residence: 'CityName',
      primary: 'CountryName',
    },
  },
};

API Reference

handshake(params: { flow: string, code: string, pkceVerifier: string }): Promise<{ exp: number, access: string, challenge: string }>

  • Description: Initiates a handshake process with the Pasby authorization server.
  • Parameters:
    • flow: The flow query value received by the redirect from the Pasby authorization server.
    • code: The handshake query value received by the redirect from the Pasby authorization server.
    • pkceVerifier: The PKCE verifier parsed to you when the login link was created.
  • Returns: A promise that resolves to an object containing the expiration time (exp), access token (access), and challenge (challenge).

Contributing

Contributions are welcome! Please feel free to submit a pull request or open an issue for any bugs or feature requests.

License

This project is licensed under the MIT License. See the LICENSE file for details.

This documentation provides a basic overview of how to use the @finsel-dgi/pasby-react library, including installation, usage examples, and API references. Adjust the content as necessary to fit any additional features or changes in your library.

0.1.4

8 months ago

0.1.2

8 months ago

0.1.3

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago