@avvyr/storefront-sdk - v0.19.0
    Preparing search index...

    Class AuthResource

    Index
    • Accept a company membership invite

      Parameters

      • token: string

      Returns Promise<AuthResponse>

    • Get the currently authenticated customer's profile

      Returns Promise<CustomerProfile>

    • Check if a customer is currently authenticated

      Returns boolean

    • Connect a provider to the signed-in customer's account. The way in for a Microsoft account whose email Microsoft does not confirm: sign in with email first, then connect here.

      Parameters

      Returns Promise<
          {
              company: SignInCompany;
              identities: LinkedIdentity[];
              success: boolean;
          },
      >

    • Logout the current customer

      Returns Promise<{ success: boolean }>

    • Which sign-in options the store has turned on, including the providers' public client ids.

      Returns Promise<AuthMethods>

    • Refresh the access token using a refresh token

      Parameters

      • refreshToken: string

      Returns Promise<Omit<AuthResponse, "customer">>

    • Send a magic link to the email

      Parameters

      • email: string

      Returns Promise<{ success: boolean }>

    • Manually set the customer access token. Useful when restoring from a persisted session.

      Parameters

      • token: string | null

      Returns void

    • Set or change the customer's password

      Parameters

      • password: string

      Returns Promise<{ success: boolean }>

    • Sign in with Klarna, Google or Microsoft: send the provider's id_token. Signs in a linked customer, links an existing customer with the same email when the provider confirms it, or creates an account (registration open, or the customer's organization matches a company's sign-in domain). Check outcome for "pending-approval" (no tokens) before treating the customer as signed in.

      Parameters

      Returns Promise<ProviderSignInResponse>

    • Disconnect a provider from the signed-in customer's account.

      Parameters

      Returns Promise<{ success: boolean }>

    • Verify a magic link token.

      Call this from a user gesture (a "Sign in" button on the landing page), never on page load: corporate email link scanners render the page and would consume the one-time token before the customer clicks.

      Parameters

      • token: string

      Returns Promise<AuthResponse>

    • Verify the six-digit code that was emailed alongside the magic link.

      email is the address the link was requested for; the code is bound to it server-side and dies after a few wrong attempts. Immune to link scanners and works across devices (request on desktop, read on phone).

      Parameters

      Returns Promise<AuthResponse>