Passport SDK v5.0
  • Overview
  • Account Lifecycle
  • Integration
    • Client Side Enablement
    • Credenza Presence (Optional Visual Elements)
    • Account Provisioning (Sign-up)
      • New Authentication System
      • Existing Authentication System - New Customer
      • Existing Authentication System - Existing Customer
  • Passport Subsequent Logins
  • Post-Login Capabilities
    • Account Information Access
    • Blockchain Wallet Access
  • Smart Contract Interactions
    • Instantiating The Contract Object (Server-Side)
    • Instantiating The Contract Object (Client-side)
    • Calling Contracts
  • Monetary Transactions
  • Appendix I: Passport Configuration Options
    • Magic
    • Ethers.js
    • Installation
    • Usage
    • Passport Instance Properties
    • Passport Static Properties
    • Modes
    • Supported query params
  • Transaction UI v3.0 (now part of Passport)
    • Magic
    • Ethers.js
    • Installation
    • Usage
    • Apple Pay
    • Google Pay
    • Methods
    • Events
  • Appendix II: MetaMembership Contract Access
  • Appendix III: Ledger Contract Access
  • Appendix IV: Decentralized Commerce Configuration
Powered by GitBook
LogoLogo

©2023 Credenza. All rights reserved.

On this page
  • Code Mode
  • Navigation mode
  • UI mode
  • Events
  1. Appendix I: Passport Configuration Options

Modes

Passport can be used in 3 modes: Code, Navigation, and UI.

Code Mode

Login

const params = ['metamask'] || ['magicLink', {email:string}] || ['magicSms', {phone: string}]a
const params = ['metamask'] || ['magicLink', {email:string}] || ['magicSms', {phone: string}]
const user = await passport.login(...params)

Logout

await passport.logout()

Get ethers provider

await passport.getWeb3Provider():Promise // returns Ethers provider

Check membership

await passport.checkMembership(ownerAddress:string):Promise<{isMember:boolean, meta: unknown}>

Get current user roles

await passport.getRoles():Promise<(Admin | Superadmin | User)[]>

Get current user NFTs

await passport.getNfts():Promise<({
  amount: number
  contract_type: string // e.g. "ERC721"
  name: string
  symbol: string
  token_address: string
  token_id: string
  token_uri: string
})[]>

Get CRED Contract

await passport.getCREDContract():Promise<({
  address: string
  decimals: number
  contract: ethers.Contract
})>

Navigation mode

Show navigation panel

passport.showNavigation({bottom: 5px, right: 5px}); // Bottom right corner

Hide navigation panel

passport.hideNavigation();

UI mode

Open UI

passport.openUI() // defaults to Credenza.pages.PROFILE

Close UI

passport.close()

Events

Triggers when user logs in

passport.onLogin(({provider, opts}) => {
  console.log('User is logged in with passport', {provider, opts})
})

Triggers when a user updates profile (extended registration also uses this event)

passport.onUpdateProfile((user) => {
  console.log('User profile updated: ', user)
})

Triggers when a user logs out

passport.onLogout(async () => {
  console.log('User is logged out with passport')
})

Triggers when a payment is completed

passport.onPayment(async ({type: string, data: any}) => {
  console.log('Payment', {type, data})
})

Triggers when passport throws an exception

passport.onError(({provider, error}) => {
  console.log('Passport error', {provider, error})
})
PreviousPassport Static PropertiesNextSupported query params

Last updated 1 year ago