Methods
Methods can be used after initializing the Wepin Login Library.
loginWithOauthProvider
Logs in to Wepin Firebase in a new window. Returns Firebase login information upon successful login.
If an error of required/register_email occurs, you will need to call the sendVerifyEmail
method.
Parameters
params
<object>provider
<'google'|'naver'|'discord'|'apple'|'line'|'facebook'> - Provider for Firebase loginwithLogout
<boolean> optionaltrue : Does not log out if already logged in.
false : Logs out and logs in again if already logged in.
Return value
Promise
<LoginResult| LoginErrorResult><LoginResult>
provider
<'google'|'naver'|'discord'|'apple'|'line'|'facebook'>token
<object>idToken
<string> wepin firebase idTokenrefreshToken
wepin firebase refreshToken
<LoginErrorResult>
error
<string> error messageidToken
<string> optional id token valueaccessToken
<string> optional accessToken token valueprovider
<'google'|'naver'|'discord'|'apple'|'line'|'facebook'> optional Provider that issued the access token
Exception
Invalid provider
: If the provider parameter is incorrectUser canceled
: If the user closes the window during loginInternal error
: For other exceptions
Example
response
LoginResult
LoginErrorResult
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 an auth/email-verified
error will occur if verification is required. If the user is already registered, an auth/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 addresspassword
<string>User email password
openWepinWallet
<boolean> optional Whether to show the Wepin Wallet authentication email page
Return Value
Promise
<LoginResult>provider
<'email'>token
<object>idToken
<string> wepin firebase idTokenrefreshToken
wepin firebase refreshToken
Exception
auth/email-verified
: A verification email has been sent, email verification is requiredauth/existed-email
: The email is already registeredfail/send-email
: Failed to send verification emailfail/email-verified
: Email verification failed
Example
response
loginWithEmailAndPassWord
Logs in to Wepin Firebase using email and password. Returns Firebase login information upon successful login.
Parameters
email
<string> User email addresspassword
<string>User email password
Return Value
Promise
<LoginResult>provider
<'email'>token
<object>idToken
<string> wepin firebase idTokenrefreshToken
wepin firebase refreshToken
Example
response
loginWithIdToken
Logs in to Wepin Firebase using an external IdToken. Returns Firebase login information upon successful login.
If an error of required/register_email
occurs, you will need to call the sendVerifyEmail
method.
Parameters
params
<object>token
<string> External IdToken used for loginsign
<string>Signature of the
token
provided as the first parameter (Signature Generation Methods)Starting from
@wepin/login-js
version 0.0.29, thesign
value is optional. If you choose to remove the authentication key issued from the Wepin Workspace, you may opt not to use thesign
value. (Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)The Auth Key menu is visible only if an authentication key was previously generated.
Return Value
Promise
<LoginResult | LoginErrorResult><LoginResult>
provider
<'external_token'>token
<object>idToken
<string> wepin firebase idTokenrefreshToken
wepin firebase refreshToken
<LoginErrorResult>
error
<string> error messageidToken
<string> optional id token value
Example
response
LoginResult
LoginErrorResult
loginWithAccessToken
Logs in to Wepin Firebase using an external Access Token. Returns Firebase login information upon successful login.
If an error of required/register_email
occurs, you will need to call the sendVerifyEmail
method.
Parameters
params
<object>provider
<'naver'|'discord'|'facebook'> Login provider from which the Access Token was issuedtoken
<string> External Access Token used for loginsign
<string>Signature of the token provided as the second parameter (Signature Generation Methods)
Starting from
@wepin/login-js
version 0.0.29, thesign
value is optional. If you choose to remove the authentication key issued from the Wepin Workspace, you may opt not to use thesign
value. (Wepin Workspace > Development Tools menu > Login tab > Auth Key > Delete)The Auth Key menu is visible only if an authentication key was previously generated.
Return Value
Promise
<LoginResult | LoginErrorResult><LoginResult>
provider
<'external_token'>token
<object>idToken
<string> wepin firebase idTokenrefreshToken
wepin firebase refreshToken
<LoginErrorResult>
error
<string> error messageaccessToken
<string> optional accessToken token valueprovider
<string> optional Provider that issued the access token
Example
response
LoginResult
LoginErrorResult
getSignForLogin
It generates a signature to verify the issuer. Mainly used to generate signatures for login-related information such as IdToken and Access Token.
Parameters
privKey
<string> Authentication key used to generate the signaturemessage
<string> 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.
Return Value
<string>
Signature value
The authentication key (privKey) should be stored securely and not exposed externally. To enhance security and protection of sensitive information, it is recommended to execute the getSignForLogin()
method on the backend rather than the frontend.
Example
sendVerifyEmail
The sendVerifyEmail
method allows you to register an email and request email verification. If an error of required/register_email
occurs, you must register the email and request verification. Once verification is completed, use the loginWithAccessToken
or loginWithIdToken
method to log in again with the previously used AccessToken or IdToken.
Supported Version
Supported in version
0.0.18
and later
Parameters
params
<ISendVerifyEmailParams>email
<string> The email address to be registered and verifiedprovider
<string> The login provider for Firebase. It must be one of the supported providers in lowercase, such as ‘google’, ‘naver’, ‘discord’, ‘apple’, ‘facebook’, or ‘line’. Refer to Wepin Social Login Auth Provider documentation for the full list of supported providers.idToken
<string> The id token to be used for loginaccessToken
<string> The access token to be used for login
Return Value
Promise<boolean>
Example
loginWepin
It logs the user into Wepin using the specified Login Provider and Token.
Parameters
The parameters for this method should utilize the return values from the loginWithOauthProvider()
, loginWithEmailAndPassword()
, loginWithIdToken()
, and loginWithAccessToken()
methods within this module.
provider
<'google'|'apple'|'naver'|'discord'|'external_token'|'email'> Login Providertoken
<object>idToken
<string> wepin firebase idTokenrefreshToken
wepin firebase refreshToken
Return Value
Promise
<IWepinUser>status
<'success'|'fail'> Login resultuserInfo
<object> optional Information of the logged-in useruserId <string> User's Wepin ID
email <string> User's email address
provider<'google'|'apple'|'naver'|'discord'|'email'|'external_token'> Logged-in Provider
use2FA <boolean> Whether 2FA is enabled for the user
userStatus
<object> Status information of the logged-in userloginStats
: <'complete' | 'pinRequired' | 'registerRequired'> If not 'complete', registration with Wepin is requiredpinRequired
<boolean> optional Whether the user's PIN number is required
token
<object> User's wepin firebase tokenidToken
<string> wepin firebase idTokenrefreshToken
wepin firebase refreshToken
Example
response
logout
It logs out the Wepin user.
Parameters
<void>
Return Value
Promise
<boolean>true if successful
Exception
Wepin login module Not initialized
: If the Wepin Login Library has not been initializedAlready logout
: If the user is already logged out
Example
finalize
It terminates the use of the Wepin Login Library.
Parameters
<void>
Return Value
<void>
Example
Last updated