Methods
Below are the methods provided by the Wepin React Native Login Library.
loginWithOauthProvider
An inappbrowser will open and proceed to log in to OAuth provider. Returns OAuth login info upon successful login.
Parameters
params
<object>
provider
<'google'|'naver'|'discord'|'apple'>
OAuth Login Provider
clientId
<string>
client id of OAuth Login Provider
Returns
Promise<LoginOauthResult>
provider
<'google'|'naver'|'discord'|'apple'>
The name of the OAuth provider used
token
<string>
The accessToken (if provider is "naver" or "discord") or idToken (if provider is "google" or "apple")
type
<'id_token'|'access_token'>
The type of OAuth token (e.g., idToken, accessToken)
Exception
Example
signUpWithEmailAndPassword
Sign up for Wepin Firebase with an email and password. For users who have not yet registered, a verification email will be sent, and a REQUIRED_EMAIL_VERIFIED
error will occur if verification is required. If the user is already registered, an EXISTED_EMAIL
error will occur, and you should proceed with the login process by calling loginWithEmailAndPassword. Upon successful login, Firebase login information is returned.
Parameters
email
<string>
User email
password
<string>
User password
locale
<string>
optionalLanguage for the verification email (default value: "en")
Returns
Promise<LoginResult>
provider
<string>
The provider used for the login (in this case, 'email')
token
<object>
idToken
<string>
The Wepin Firebase ID token
refreshToken
<string>
The Wepin Firebase refresh token
Exception
Example
loginWithEmailAndPassword
Logs in to Wepin Firebase using an email and password. If the login is successful, it returns Firebase login information.
Parameters
email
<string>
User emailpassword
<string>
User password
Returns
Promise<LoginResult>
provider
<'email'>
The provider used for the login (in this case, 'email')
token
<object>
idToken
<string>
The Wepin Firebase ID token
refreshToken
<string>
The Wepin Firebase refresh token
Exception
Example
loginWithIdToken
Logs in to Wepin Firebase using an external ID token. If the login is successful, it returns Firebase login information.
Parameters
params
<object>
idToken
<string>
ID token value to be used for loginsign
<string>
Signature value for the token provided as the first parameter (returned value ofgetSignForLogin()
)
Returns
Promise<LoginResult>
provider
<'external_token'>
The provider used for the login (in this case, 'external_token').token
<object>
idToken
<string>
The Wepin Firebase ID token
refreshToken
<string>
The Wepin Firebase refresh token
Exception
Example
loginWithAccessToken
Logs in to Wepin Firebase using an external access token. If the login is successful, it returns Firebase login information
Parameters
params
<object>
provider
<"naver"|"discord">
Provider that issued the access token
accessToken
<string>
Access token value to be used for login
sign
<string>
Signature value for the Access token (returned value of
getSignForLogin()
)
Returns
Promise<LoginResult>
provider
<string>
The provider used for the login (in this case, 'external_token')
token
<object>
idToken
<string>
The Wepin Firebase ID token
refreshToken
<string>
The Wepin Firebase refresh token
Exception
Example
getRefreshFirebaseToken
Retrieves information on the current Wepin Firebase token.
Parameters
None
Returns
Promise<LoginResult>
provider
<string>
The provider used for the login<'google'|'apple'|'naver'|'discord'|'email'|'external_token'>
token
<object>
idToken
<string>
The Wepin Firebase ID tokenrefreshToken
<string>
The Wepin Firebase refresh token
Exception
Example
loginWepin
Logs the user into Wepin using the Wepin Firebase token.
Parameters
params
<LoginResult>
Parameters from the return value of methods likeloginWithEmailAndPassword()
,loginWithIdToken()
, orloginWithAccessToken()
Returns
Promise<IWepinUser>
status
<'success'|'fail'>
The login status.
userInfo
<object>
optional - The user's information, including:userId
<string>
The user's ID
email
<string>
The user's email
provider
<'google'|'apple'|'naver'|'discord'|'email'|'external_token'>
The login provider
use2FA
<boolean>
Whether the user uses two-factor authentication
walletId
<string>
The user's wallet ID
userStatus
<object>
- The user's Wepin login status, including:loginStats
<'complete' | 'pinRequired' | 'registerRequired'>
If the user's
loginStatus
value is not 'complete', the user must register with Wepin.pinRequired
<boolean>
optionalWhether a PIN is required
token
<object>
The user's Wepin token
accessToken
<string>
The access tokenrefreshToken
<string>
The refresh token
Exception
Example
getCurrentWepinUser
Retrieves information about the currently logged-in user in Wepin.
Parameters
None
Returns
Promise<IWepinUser>
status
<'success'|'fail'>
The login status
userInfo
<object>
optional - The user's information, includinguserId
<string>
The user's ID
email
<string>
The user's email
provider
<'google'|'apple'|'naver'|'discord'|'email'|'external_token'>
The login provider
use2FA
<boolean>
Whether the user uses two-factor authentication
walletId
<string>
The user's wallet ID
userStatus
<object>
-The user's Wepin login status, including:loginStats
<'complete' | 'pinRequired' | 'registerRequired'>
If the user's
loginStatus
value is not 'complete', the user must register with WepinpinRequired
<boolean>
optionalWhether a PIN is required
token
<object>
The user's Wepin token
accessToken
<string>
The access tokenrefreshToken
<string>
The refresh token
Exception
Example
logout
Logs out the currently logged-in user from Wepin.
Parameters
None
Returns
Promise<boolean>
Exception
Example
getSignForLogin
Generates a signature for verifying the issuer. This method is mainly used to generate signatures for login-related information such as ID tokens and access tokens.
Parameters
privateKey
<string>
The authentication key used for signature generationmessage
<string>
The message or payload to be signed
The key for signing can be obtained from Wepin Workspace. In the Development Tools menu, click Get your authentication key on the Login tab to retrieve the authentication key.
Returns
<string> The generated signature
The private key (privateKey) must be securely stored and should not be exposed externally. To enhance security and protect sensitive information, it is recommended to execute the getSignForLogin()
method on the backend rather than the frontend. For details on how to generate signatures, please refer to the following document:
Example
finalize
Terminates the Wepin Login Library.
Parameters
None
Returns
Promise<void>
Example
WepinLoginException
INVALID_APP_KEY
"InvalidAppKey"
The Wepin app key is invalid.
INVALID_PARAMETER
"InvalidParameters"
One or more parameters provided are invalid or missing.
INVALID_LOGIN_PROVIDER
"InvalidLoginProvider"
The login provider specified is not supported or is invalid.
INVALID_TOKEN
"InvalidToken"
The token does not exist.
INVALID_LOGIN_SESSION
"InvalidLoginSession"
The login session information does not exist.
NOT_INITIALIZED_ERROR
"NotInitialized"
The WepinLoginLibrary has not been properly initialized.
ALREADY_INITIALIZED_ERROR
"AlreadyInitialized"
The WepinLoginLibrary is already initialized, so the logout operation cannot be performed again.
USER_CANCLED
"UserCancelled"
The user has cancelled the operation.
UNKNOWN_ERROR
"UnknownError"
An unknown error has occurred, and the cause is not identified.
NOT_CONNECTED_INTERNET
"NotConnectedInternet"
The system is unable to detect an active internet connection.
FAILED_LOGIN
"FailedLogin"
The login attempt has failed due to incorrect credentials or other issues.
ALREADY_LOGOUT
"AlreadyLogout"
The user is already logged out, so the logout operation cannot be performed again.
INVALID_EMAIL_DOMAIN
"InvalidEmailDomain"
The provided email address's domain is not allowed or recognized by the system.
FAILED_SEND_EMAIL
"FailedSendEmail"
The system encountered an error while sending an email. This is because the email address is invalid or we sent verification emails too often. Please change your email or try again after 1 minute.
REQUIRED_EMAIL_VERIFIED
"RequiredEmailVerified"
Email verification is required to proceed with the requested operation.
INCORRECT_EMAIL_FORM
"incorrectEmailForm"
The provided email address does not match the expected format.
INCORRECT_PASSWORD_FORM
"IncorrectPasswordForm"
The provided password does not meet the required format or criteria.
NOT_INITIALIZED_NETWORK
"NotInitializedNetwork"
The network or connection required for the operation has not been properly initialized.
REQUIRED_SIGNUP_EMAIL
"RequiredSignupEmail"
The user needs to sign up with an email address to proceed.
FAILED_EMAIL_VERIFIED
"FailedEmailVerified"
The WepinLoginLibrary encountered an issue while attempting to verify the provided email address.
FAILED_PASSWORD_SETTING
"failedPasswordSetting"
Failed to set the password. This could be due to issues with the provided password or internal errors during the password setting process.
EXISTED_EMAIL
"ExistedEmail"
The provided email address is already registered. This error occurs when attempting to sign up with an email that is already in use.
Last updated