Skip to content

Web3ForAuth0Actions allows developers to quickly introduce web3 capabilities into Auth0 Actions.

License

Notifications You must be signed in to change notification settings

lunarfoundation/Web3ForAuth0Actions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Lunar Foundation Logo

The future of money is digital.


NPM Package

Web3ForAuth0Actions

Brought to you by the Lunar Foundation. https://lunar.io

A library for web3 functionality that can be leveraged in Auth0 Actions. Requires Sign In With Ethereum (SIWE).

Getting Started

  1. Open your Auth0 management console and navigate to 'Actions | Library' in the left-hand sidebar.
  2. Click "Build Custom" in the header.
    • Select "Login / Post Login".
    • Select "Node 16" for the Runtime.
    • Click the "Create" button.
  3. Click on the "Dependencies" icon in the grey editor (the box icon).
    • Type "web3-for-auth0-actions" in the textbox and click "Create".
  4. Paste in the following code :
exports.onExecutePostLogin = async (event, api) => {

  // SHEPARD: If you have other apps that don't use this Action, exclude those from execution via Rules or Actions.
  if (event.client.client_id !== 'YOUR APP ID HERE') return;

  const { Web3ForAuth0Actions } = require("web3-for-auth0-actions");
  const ContractAddress = "YOUR CONTRACT ADDRESS HERE";

  Web3ForAuth0Actions.DebugMode = true;
  // SHEPARD: Chain Id '56' is the BNB Chain Mainnet. 
  let [isValidReturn, returnMessage] = await Web3ForAuth0Actions.validateWalletBalance(event, 56, 1, ContractAddress);
  console.log(`IsValidReturn: ${isValidReturn}`);
  console.log(`ReturnMessage: ${returnMessage}`);
  
  // SHEPARD: Bounce anyone that doesn't have the minimum balance in their wallet.
  if (!isValidReturn) {
    api.access.deny(returnMessage);
  }
};
  1. Click "Deploy" in the top right-hand corner.
  2. Click "Flows" under "Actions" in the left-hand side bar.
  3. Click "Login".
  4. On the right-hand side, under "Add Action", select "Custom".
  5. Drag your new Action into the Flow area.
  6. Click "Apply"
  7. Profit!!!

You now have some functioning badassery!

About

Web3ForAuth0Actions allows developers to quickly introduce web3 capabilities into Auth0 Actions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published