### Automated Setup for Multi-Wallet Menu Project (Shell) Source: https://github.com/id-daniel-mccoy/ic-auth/blob/main/README.md This snippet provides shell commands to quickly clone the multi-wallet menu example project from GitHub, navigate into its directory, and run an automated setup script. This method requires DFX 0.15.1+ and Node 18 + NPM to be pre-installed and configured. ```bash git clone https://github.com/cp-daniel-mccoy/multi-wallet-menu.git cd multi-wallet-menu npm run setup ``` -------------------------------- ### Manual Setup for Multi-Wallet Menu Project (Shell) Source: https://github.com/id-daniel-mccoy/ic-auth/blob/main/README.md This snippet offers a sequence of manual shell commands for setting up the multi-wallet menu project if the automated setup fails. It includes installing Node.js dependencies, fixing audit issues, starting a clean DFX replica in the background, deploying canisters, and then stopping the replica. ```bash npm install npm audit fix dfx start --clean --background dfx deploy dfx stop ``` -------------------------------- ### Basic Setup for Multi-Wallet Support Source: https://github.com/id-daniel-mccoy/ic-auth/blob/main/README.md Initial setup for supporting multiple wallets, including importing necessary functions and types from `ic-auth`, defining canister ID and whitelist, and creating a basic asynchronous login handler. ```typescript import { PlugLogin, StoicLogin, NFIDLogin, IdentityLogin, Types } from 'ic-auth'; const canisterID = "oyjva-2yaaa-aaaam-qbaya-cai"; const whitelist = ["oyjva-2yaaa-aaaam-qbaya-cai"]; const handleLogin = async() => { const userObject = await PlugLogin(whitelist); console.log(userObject); // Handle code will go here... } ``` -------------------------------- ### Install IC-Auth NPM Package Source: https://github.com/id-daniel-mccoy/ic-auth/blob/main/README.md Instructions to install the `ic-auth` package using npm and fix any audit issues, preparing the development environment. ```shell npm install ic-auth && npm audit fix ``` -------------------------------- ### Polyfill Buffer and Global for Dfinity Agent Compatibility Source: https://github.com/id-daniel-mccoy/ic-auth/blob/main/index.html This JavaScript snippet provides necessary polyfills for the 'Buffer' and 'window.global' objects. It is explicitly stated as a requirement for the '@dfinity/agent' library, indicating it resolves a dependency or compatibility issue within a browser environment by making these objects globally accessible. ```JavaScript import { Buffer } from "buffer" window.global = window window.Buffer = Buffer ``` -------------------------------- ### Run Multi-Wallet Menu Project in Development Mode (Shell) Source: https://github.com/id-daniel-mccoy/ic-auth/blob/main/README.md This shell command initiates a local development instance of the multi-wallet menu project using Vite. This mode is suitable for active development and provides features like hot module reloading. ```bash npm run dev ``` -------------------------------- ### Run Multi-Wallet Menu Project in Production Mode (Shell) Source: https://github.com/id-daniel-mccoy/ic-auth/blob/main/README.md This shell command serves a compiled build of the multi-wallet menu project, typically used for testing the production-ready version on a dedicated server. It assumes the project has already been built. ```bash npm run serve ``` -------------------------------- ### Handle Single Wallet Login with Plug Source: https://github.com/id-daniel-mccoy/ic-auth/blob/main/README.md Shows how to create an asynchronous function to handle a user login specifically with Plug wallet. It includes defining a whitelist of canister IDs required by Plug and logging the returned UserObject. ```typescript const whitelist = ["oyjva-2yaaa-aaaam-qbaya-cai"]; const handleLogin = async() => { const userObject = await PlugLogin(whitelist); console.log(userObject); // Handle code will go here... } ``` -------------------------------- ### Attach Multi-Wallet Login Handler to UI Buttons (JavaScript/JSX) Source: https://github.com/id-daniel-mccoy/ic-auth/blob/main/README.md This JavaScript/JSX snippet demonstrates how to create a simple UI menu with buttons, each triggering a specific multi-wallet login method (Plug, Stoic, NFID, Identity) using an asynchronous `handleLogin` function. It assumes `handleLogin` is already defined to manage different wallet inputs. ```js