@stacks/auth

The @stacks/auth package provides the auth logic used by the @stacks/connect library.

Installation

npm install @stacks/auth

UserSession

The Stacks authentication process enables secure user sign-in for web apps by generating and handling encrypted authentication requests. It involves setting up an app domain, configuring permissions, and creating a UserSession to manage user data.

Functions

isSignInPendingfunction

Determines if there is an incoming authentication response.

handlePendingSignInfunction

Processes the response and provides a userData object containing the user's identity, BNS username and profile information.

isUserSignedInfunction

Checks if the user is already authenticated.

loadUserDatafunction

Retrieves the user's profile data if the user is already authenticated.

encryptContentfunction

Encrypts user data for secure storage.

decryptContentfunction

Decrypts user data for secure storage.

const isPending = userSession.isSignInPending();

if (isPending) {
  userSession.handlePendingSignIn().then(userData => {
    // Do something with userData
  });
}

makeAuthRequest

The Stacks authentication process enables secure user sign-in for web apps by generating and handling encrypted authentication requests. It involves setting up an app domain, configuring permissions, and creating a UserSession to manage user data.

Parameters

transitKey
Required
string

The authentication payloads are encrypted during transit, the encryption key generated below provides this

redirectURI
Required
string

A URL which the authenticator or extension can redirect to with the authentication payload. This page should process the authentication payload.

manifestUri
Required
string

Set the location of your app manifest file. This file contains information about your app that is shown to the user during authentication.

scopesstring[]

Additional permissions the app is requesting

Last updated on