npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@credenza3/passport-sui

v0.0.40

Published

Credenza Passport

Downloads

296

Readme

Credenza3 Passport

Installation

with npm

npm install @credenza3/passport

with yarn

yarn add @credenza3/passport-sui

with pnpm

pnpm install @credenza3/passport-sui

or include a script tag

<script src="https://cdn.jsdelivr.net/npm/@credenza3/passport-sui/dist/passport.umd.js"></script>
<script>
  const Passport = window.CredenzaPassport
</script>

or with esm

<script type="module">
  import {Passport} from 'https://cdn.jsdelivr.net/npm/@credenza3/passport-sui/+esm'
</script>

Usage

Create the Passport instance

const passport = new Passport({
  suiNetwork: "testnet" | "mainnet" | "devnet",
  clientId: "СREDENZA OAUTH CLIENT ID",
  config: {
    storedValuePackageId?: string;
    buyTokens?: true
    auth?: {
      extendedRegistration: false,
      credentials?: false
      google?: true
      ticketmaster?: false
      passwordless?: false
      zk?:false
    },
    nav?: {
      theme?: Passport.themes.BLACK,
      direction?: Passport.navDirections.BOTTOM,
    },
    email?: {
      templateId?: string // For custom email template usage
    },
    content?: {
      cloak?: boolean
      imageUrl?: 'https://yoursite.com/image.png', // Replaces default `Standford Socker` image
      signin: {
        title: "Your title!", // Replaces default ``
        description: "Your description.", // Replaces default ``
      },
      signup: {
        title: "Your title!", // Replaces default ``
        description: "Your description.", // Replaces default ``
      },
      logout: {
        title: "Your title!", // Replaces default ``
        description: "Your description!", // Replaces default ``
      },
      paymentResult?: {
        title?: "Your title!", // Replaces default `Success!`
        subtitle?: "Your subtitle!", // Replaces default `Your payment was successful!`
        description?: "Your description!", // Replaces default `Usually it takes us as many as a few minutes to deliver tokens to your account.`
      }
      progressVideos?: [{
        embedded: true,
        src: 'https://www.youtube.com/embed/tgbNymZ7vqY',
      }, {
        src: 'https://media.w3.org/2010/05/sintel/trailer.mp4'
      }]
    },
  },
})

await passport.init()

Passport instance Properties

isLoggedIn: boolean

suiNetwork: string

user: User instance

Passport static properties

Passport.version (string) Current package version

Passport.SuiNetworks (enum) Supported sui networks

Passport.pages = (enum) Available pages for logged in User

Passport.paymentTypes = (enum) Available payment types

Passport.themes = (enum) Available color schemas

Passport.navDirections = (enum) Available directions where passport nav bar will expand when opened

Passport.navMinimizationTogglerPositions = (enum) Available minimization toggler positions

Passport.events = (enum) Available events for passport.on() listener

Modes

Passport can be used in 3 modes: Code UI Navigation

Apple Pay

You must verify your domain. https://support.stripe.com/questions/enable-apple-pay-on-your-stripe-account Enabled by default on all supported devices and registered domains.

Google Pay

Is enabled on all supported devices by default

Code mode

Login with credentials

await passport.login(provider: "OAUTH", oauthType?: "CREDENTIALS" | "GOOGLE" | "PASSWORDLESS" | "TICKETMASTER")
// Do not provide is 'signUp' param if you want passport to try detect automatically.

Login with JWT

await passport.jwtLogin(
  opts: { validatorId: string, idToken?: string, accessToken?: string }
)

Logout

await passport.logout()

Switch chain

await passport.switchChain({suiNetworkName: string}):Promise<void> // any of Passport.suiNetwork

Get current session address

await passport.getAddress():Promise<string | null>

Get current user roles

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

Confirm email / phone number

await passport.confirmAccount({phoneCode?:number, emailCode?:number}):Promise<boolean>

Perform NFT or Membership payment

await passport.openUI(Passport.pages.PAYMENT, {
  title: string,
  subtitle: string,
  payments?: {
    credenzaStoredValue?: {
        disabled?: boolean //default - false
    },
  },
  assets: [
    {
      packageId: string,
      type: string //  "credenza_asset_collection" | "membership" | "decom" | "cred",
      assetId?: number, // only needed if type is  "credenza_asset_collection"
      amount?: number // can be used for type cred or credenza_asset_collection
    },
  ]

})

Check membership

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

Send Credenza Decom Token

await passport.sendNft({ packageId, recipient }: {
  recipient: string,
  packageId: string,
}):Promise<any>

Send tokens (CRED or Sui native)

Do not pass isNativeCoinTransfer if you transfer the CRED tokens. Pass true if you want to transfer SUI tokens.

await passport.sendTokens(opts: {
  address: string,
  amount: bigint | number,
  isSuiNativeCoinTransfer?: boolean
}): Promise<void>;

Request AirDrop

await passport.requestAirDrop({ amount, coinType }: {
  amount: number
  coinType?: string // default CURRENT_PACKAGE::cred::CRED
}):Promise<void>

Navigation mode

Show navigation panel

await passport.showNavigation({
  bottom?: "5px",
  right?: "5px",
  left?: "inherit",
  top?: "inherit",
}, {
  minimization?: {
    enabled?: boolean, // false
    toggler?: {
      enabled?: boolean, // false
      position?: Passport.navMinimizationTogglerPositions.(LEFT | RIGHT), // left
    }
  }
}); // Bottom right corner

Hide navigation panel

passport.hideNavigation();

Passport UI mode

Open UI (Use one of Credenza.pages.PROFILE, Credenza.pages.PASSPORT_ID)

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

Close UI

passport.close()

Open Passport alert

passport.toastAlert(
  message,
  type?: 'success' | 'warning' | 'failure' | 'info', // defaults to info
  opts?:{
    duration?: number // if -1 - then there is no timer and it stays untill dismissed,
    centered?: {
      enabled?: boolean,
      position?: 'top' | 'bottom' // can be used only for centered block
    }
  }
)

Open Passport rich alert


passport.openUI(Passport.pages.RICH_ALERT, {
  richAlertData: {
    title?: string,
    description?: string,
    actions?: [{
      text: string;
      link?: string;
      onClick?: (...args: unknown[]) => unknown;
    }]
  },
})

Destroy passport

passport.destroy()

Events (Most likely for Navigation and UI modes)

Listen for event

const unsubscribe = passport.on(Passport.events[eventName], (data) => {
  console.log(data)
})

Listen for event(Triggers once)

const unsubscribe = passport.once(Passport.events[eventName], (data) => {
  console.log(data)
})

Supported query params

Prepopulates email address on login / signup form.

?credenza_user_email=test%40test.com
// ?credenza_user_email=encodeURIComponent([email protected])

SSR

Passport is not build for the Server Side Rendering, but you still can make it work with the SSR app. Make sure you disable SSR for passport specific component or you can dynamically import passport after it's mounted e.g.

// svelte
onMount(() => {
  const {Passport} = (await import('@credenza3/passport-sui'))
})