3.3.9 • Published 8 months ago

@futureverse/auth v3.3.9

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

Futureverse Auth

Provides an Open ID Connect Authentication library for FuturePass.

Installation

npm:

    npm install @futureverse/auth --save

yarn:

    yarn add @futureverse/auth

pnpm:

    pnpm add @futureverse/auth

bun:

    bun add @futureverse/auth

Register your client

First, you will need to register an OAuth2 client with the Pass Online Identity Provider using the Manage Clients Console:

Usage

PKCE Auth Client Setup

Use the same client ID and redirect URI for the environment you configured your client in.

import { FutureverseAuthClient } from '@futureverse/auth';

const authClient = new FutureverseAuthClient({
  clientId: '<your-client-id>',
  environment: 'production',
  redirectUri: '<your-redirect-uri>',
});

Custodial Sign in

You can either opt to sign in via popup or full page redirect.

// Sign in custodial options with popup
const type: 'email' | 'facebook' | 'google' = 'email';
await authClient.signInFuturepassPopup({ type });

// Sign in redirect flow
await authClient.signInFuturepassRedirect({ type });

Web3 Wallet Sign in

This method requires a signer interface. A message needs to be signed by the user so that the identity service can identify who they are.

Signer adapters are available from the Signer SDK.

import { EthereumSigner } from '@futureverse/signer';
...
// Sign in custodial options with popup
const type = 'eoa';
const address = '<selected-web3-wallet-address>';
const signer: Signer = new EthereumSigner(...);
await authClient.signInFuturepassPopup({ type, address }, signer);

// Sign in redirect flow
await authClient.signInFuturepassRedirect({ type, address }, signer);

Handle Redirect

Once the user has signed in, they will be redirected to the redirect URI that was set up in the client. This step is required for the user session to be updated and any open sign in popups to close automatically.

...
await authClient.loadUser();

Getting the user

This method can return the current user if signed in.

...
await authClient.getUser();

Sessions

The session object contains the user object as well as the FuturePass address and EOA address.

...
const session = authClient.userSession;
const futurepassAddress = session.futurepass;
const eoaAddress = session.eoa;
const user = session.user;

Sign out

...
// Redirect flow
await authClient.signOut({ flow: 'redirect' });
// Silent sign out
await authClient.signOut({ flow: 'silent' });
3.3.9

8 months ago

3.3.8

8 months ago

3.3.7

8 months ago

3.3.6

8 months ago

3.3.1

9 months ago

3.3.0

9 months ago

3.3.5

9 months ago

3.3.4

9 months ago

3.3.3

9 months ago

3.3.2

9 months ago

3.2.4

9 months ago

3.2.2

9 months ago

3.2.3

9 months ago

3.2.1

10 months ago

3.2.0

10 months ago

3.1.1

10 months ago

3.1.0

10 months ago

3.0.11

10 months ago

3.0.10

10 months ago

3.0.9

10 months ago

3.0.8

10 months ago

3.0.7

10 months ago

3.0.6

11 months ago

3.0.5-beta.0

11 months ago

3.0.5

11 months ago

3.0.4

11 months ago

3.0.3

11 months ago

3.0.2

11 months ago

3.0.1

11 months ago

3.0.0

11 months ago

2.3.3

11 months ago

2.3.2

11 months ago

2.3.1

11 months ago

2.3.0

11 months ago

2.2.3

11 months ago

2.2.2

11 months ago

2.2.1

11 months ago

2.2.0

11 months ago

2.1.1

11 months ago

2.1.0

11 months ago

2.0.4

11 months ago

2.0.3

11 months ago

2.0.2

12 months ago

2.0.1

12 months ago

2.0.0

12 months ago

1.1.2

12 months ago

1.1.1

12 months ago

1.1.0

12 months ago

1.0.0

12 months ago

0.2.0

12 months ago

0.1.1

12 months ago

0.1.0

12 months ago