Sign In/Out

These are the functions you would use in your dApp to interact with Ramper. Import each from @ramper/ethereum

Sign in

const signIn: (clientAPIKey?: string) => Promise<SignInResult>

The sign in options such as which SSO providers to allow and which Web3 wallets to allow can be customized through the init function. It is recommend to call this function when the user clicks the Sign In Button on your web app. The clientAPIKey is optional. You can obtain it from Ramper Developer Console (coming soon)

Sign out

const signOut: () => Promise<void>

Response Types

type SignInResult = {
  method: 'ramper' | 'wallet' | 'none'
  user?: User
  apiGatingToken?: string
}

The method value is 'ramper' if the user logged in using SSO or email and a Ramper managed wallet is created for them. The method value is 'wallet' if the user used a Web3 wallet such as Metamask to log in. Lastly, the method returns 'none' if the user cancels the log in process. The user value contains information regarding the user that logged in. The apiGatingToken is generated based on the clientAPIKey if that value was provided on signIn. The apiGatingToken is an JWT idToken that can be decoded with the clientAPIKey. This key can be used to verify that the user has logged in properly. Example Response:

{
   "method":"ramper",
   "user":{
      "signupSource":"google.com",
      "UID":"iskWbvugB0RVsTt70jC7WguEdM02",
      "wallets":{
         "ethereum":{
            "publicKey":"0x2C682335C7E82364790004B8f37F712A18e2b80A",
            "creationDate":1653006881447,
            "walletId":"ethereum_0x2C682335C7E82364790004B8f37F712A18e2b80A",
            "blockchain":"ethereum"
         }
      }
   }
}

Related Data Types:

export type User = {
  wallets: Record<string, Wallet>
} & UserModel

export type UserModel = {
  UID: string
  signupSource: string
  notificationPreference?: string
  email?: string
  preferredCommunicationMethod?: string
  region?: string
}

export type WalletModel = {
  blockchain: string
  walletId: string
  publicKey: string
  creationDate: number // UTC Epoch
  provider?: string
}

export type Wallet = {
  getAddress: () => string
} & WalletModel

Last updated