🚀 Launch Week Day 2:Introducing Custom Tabs for Org Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

@authsignal/react

Package Overview
Dependencies
Maintainers
0
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@authsignal/react

Add `@authsignal/react` to your `package.json` dependencies.

Source
npmnpm
Version
0.0.3
Version published
Weekly downloads
52
-13.33%
Maintainers
0
Weekly downloads
 
Created
Source

đźš§ Work in progress: Not intended for production use. đźš§

Installation

Add @authsignal/react to your package.json dependencies.

NPM

npm install @authsignal/react

Yarn

yarn add @authsignal/react

Usage

Wrap your application with the AuthsignalProvider component.

import { AuthsignalProvider } from '@authsignal/react';

function App() {
  return (
    <AuthsignalProvider tenantId="<AUTHSIGNAL_TENANT_ID>" baseUrl="<AUTHSIGNAL_BASE_URL>">
      <Checkout />
    </AuthsignalProvider>
  );
}

Then use the AuthChallenge component to start the authentication flow.

import { AuthChallenge } from '@authsignal/react';

function Checkout() {
  const [authsignalToken, setAuthsignalToken] = React.useState(null);

  const handlePayment = async () => {
    // Return the Authsignal token from your server's track action call
    const response = await fetch('/api/payment', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
      },
    });

    const data = await response.json();

    setAuthsignalToken(data.authsignalToken);
  };

  return (
    <div>
      <button type="button" onClick={handlePayment}>Pay</button>

      {authsignalToken && (
        <AuthChallenge
          token={authsignalToken}
          onChallengeSuccess={() => {
            console.log("Payment successful");
          }}
          onCancel={() => {
            console.log("Payment cancelled");
          }}
          onTokenExpired={() => {
            console.log("Token expired");
          }}
        />
      )}
    </div>
  );
}

FAQs

Package last updated on 03 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts