Desktop
Init
The init method is been used to initialize the SDK with the specified auth service and auth config. This returns the SDK instance with auth object to be used.
Leap Near SDK supports two types of authentication services. You can choose which one you want to go ahead with.
Web3Auth - https://web3auth.io/
Ramper - https://www.ramper.xyz/
1. Login via Web3Auth
Using Web3Auth, Leap Near SDK is supporting Google for now, where the user is expected to provide the following config.
import { LeapNearSdk } from '@leapwallet/leap-near-sdk'
const sdk = await LeapNearSdk.init({
auth_service: 'web3auth',
authConfig: { apiToken: YOUR_API_TOKEN }
})
2. Login via Ramper
For using the Ramper the params are specified below while initializing the SDK.
import { LeapNearSdk } from '@leapwallet/leap-near-sdk'
const sdk = await LeapNearSdk.init({
auth_service: 'ramper',
authConfig: { appName: 'Leap near board', theme: 'dark', apiToken: YOUR_API_TOKEN}
})
LeapNearSdk.auth
Once the SDK is been initialized with the expected auth provider, we would be getting the SDK object with auth
property.
The sdk.auth
contains the methods to
Connect to the social login,
Getting the user information
Logging out the user
auth.Connect
await sdk?.auth?.connect()
In the case of Web3Auth
auth.connect()
would show the google login screen for the user to select the account for which the wallet needs to be created. If the user comes the first time it will create the wallet in the near chain and if it is a returning user it will get the public address of the user.

In the case of Ramper
auth.connect()
would show the popup modal for doing the social login for the user. If the user comes the first time it will create the wallet in the near chain and if it is a returning user it will get the public address of the user.


auth.getUser
const signedData = await sdk?.auth?.getUser();
auth.getUser()
would provide the user information like,
auth.logout
const signedData = await sdk?.auth?.logout();
auth.logout()
will log the user out of the session.
Last updated