Skip to main content

Upgrade from SDK 1.x to 2.x

@cloudbase/js-sdk@2.x compared to 1.x, has redesigned the login module, while the usage of other resource modules (functions, database, storage) remains unchanged.

Migration Guide

Comparison of Login Modules Between New and Old Versions (Interfaces & Attributes)

The login module in SDK 2.x has removed the concept of loginType and no longer exposes types such as ANONYMOUS, WECHAT, CUSTOM, EMAIL, PHONE.

tip

Description

Deprecated APIs (Properties)Description
Auth.onLoginStateExpiredAfter SDK login is completed, the login state is maintained internally, eliminating the need for developers to handle expiration.
LoginState.loginTypeDeprecated loginType
LoginState.isAnonymousAuthDeprecated loginType
LoginState.isCustomAuthDeprecated loginType
LoginState.isWeixinAuthDeprecated loginType
LoginState.isUsernameAuthDeprecated loginType
Deprecated APIs (Properties)Description
Auth.weixinAuthProviderReplaced by the unified third-party authorization login interface. Refer to the interface.
Auth.customAuthProviderDeprecated customAuthProvider, replaced by Auth.signInWithCustomTicket
Auth.anonymousAuthProviderDeprecated anonymousAuthProvider, replaced by Auth.signInAnonymously

Deprecated properties

API (Property)Description
User.loginTypeDeprecated loginType
User.openidDeprecated User.openid. Use the new property User.providers instead.
User.wxOpenIdDeprecated User.wxOpenId. Use the new property User.providers instead.
User.wxPublicIdDeprecated User.wxPublicId. Use the new property User.providers instead.
User.qqMiniOpenIdDeprecated User.qqMiniOpenId. Use the new property User.providers instead.
User.customUserIdDeprecated User.customUserId. Use User.uid as the user unique identifier.
User.nickNameDeprecated User.nickName. For nickname, use the new property User.name.
User.avatarUrlDeprecated User.avatarUrl. For avatar, use the new property User.picture.
User.hasPasswordDeprecated User.hasPassword
User.locationDeprecated User.location
User.linkWithTicketDeprecated. Currently, the custom login userId matches the CloudBase uid, so no linking operation is required.
User.linkWithRedirectDeprecated User.linkWithRedirect. Use the new interface Auth.bindWithProvider instead.
User.linkWithPhoneNumberDeprecated User.linkWithPhoneNumber. Use the new interface Auth.bindPhoneNumber instead.
User.updateEmailDeprecated User.updateEmail. Use the new interface Auth.bindEmail instead.
User.updatePhoneNumberDeprecated User.updatePhoneNumber. Use Auth.bindPhoneNumber instead.

New property

API (Property)Description
User.nameUser nickname (distinct from login username User.username)
User.pictureUser-uploaded avatar
User.phone_numberUser-bound phone number
User.email_verifiedUser email verification status
User.birthdateUser's birthday
User.localeUser's preferred language
User.zoneinfoTimezone
User.providersRefer to UserProfileProvider

UserProfileProvider

FieldDescription
idDefault built-in third-party provider IDs: wx_open, wx_mp
provider_user_idThird-party provider user id (e.g., wxopenid)
nameName

Add API

APIDescription
Auth.signInLogin API (excluding anonymous login and third-party login)
Auth.signUpRegistration API
Auth.getVerificationUnified verification code retrieval API (phone number, email)
Auth.bindPhoneNumberBind/Update phone number (The original user information update method is no longer supported)
Auth.bindEmailBind/Update email (The original user information update method is no longer supported)
Auth.bindWithProviderBind third-party platforms (e.g., WeChat Open/Official Account Platform)
Auth.unbindProviderUnbind third-party platforms
Auth.setPasswordSet password
Auth.queryUserQuery user information by conditions
Auth.signInWithProviderThird-party platform login