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)
LoginType Related
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
LoginState Related
Deprecated APIs (Properties) | Description |
---|---|
Auth.onLoginStateExpired | After SDK login is completed, the login state is maintained internally, eliminating the need for developers to handle expiration. |
LoginState.loginType | Deprecated loginType |
LoginState.isAnonymousAuth | Deprecated loginType |
LoginState.isCustomAuth | Deprecated loginType |
LoginState.isWeixinAuth | Deprecated loginType |
LoginState.isUsernameAuth | Deprecated loginType |
AuthProvider Related
Deprecated APIs (Properties) | Description |
---|---|
Auth.weixinAuthProvider | Replaced by the unified third-party authorization login interface. Refer to the interface. |
Auth.customAuthProvider | Deprecated customAuthProvider, replaced by Auth.signInWithCustomTicket |
Auth.anonymousAuthProvider | Deprecated anonymousAuthProvider, replaced by Auth.signInAnonymously |
User Related
Deprecated properties
API (Property) | Description |
---|---|
User.loginType | Deprecated loginType |
User.openid | Deprecated User.openid. Use the new property User.providers instead. |
User.wxOpenId | Deprecated User.wxOpenId. Use the new property User.providers instead. |
User.wxPublicId | Deprecated User.wxPublicId. Use the new property User.providers instead. |
User.qqMiniOpenId | Deprecated User.qqMiniOpenId. Use the new property User.providers instead. |
User.customUserId | Deprecated User.customUserId. Use User.uid as the user unique identifier. |
User.nickName | Deprecated User.nickName. For nickname, use the new property User.name. |
User.avatarUrl | Deprecated User.avatarUrl. For avatar, use the new property User.picture. |
User.hasPassword | Deprecated User.hasPassword |
User.location | Deprecated User.location |
User.linkWithTicket | Deprecated. Currently, the custom login userId matches the CloudBase uid, so no linking operation is required. |
User.linkWithRedirect | Deprecated User.linkWithRedirect. Use the new interface Auth.bindWithProvider instead. |
User.linkWithPhoneNumber | Deprecated User.linkWithPhoneNumber. Use the new interface Auth.bindPhoneNumber instead. |
User.updateEmail | Deprecated User.updateEmail. Use the new interface Auth.bindEmail instead. |
User.updatePhoneNumber | Deprecated User.updatePhoneNumber. Use Auth.bindPhoneNumber instead. |
New property
API (Property) | Description |
---|---|
User.name | User nickname (distinct from login username User.username) |
User.picture | User-uploaded avatar |
User.phone_number | User-bound phone number |
User.email_verified | User email verification status |
User.birthdate | User's birthday |
User.locale | User's preferred language |
User.zoneinfo | Timezone |
User.providers | Refer to UserProfileProvider |
UserProfileProvider
Field | Description |
---|---|
id | Default built-in third-party provider IDs: wx_open, wx_mp |
provider_user_id | Third-party provider user id (e.g., wxopenid) |
name | Name |
Auth API Related
Add API
API | Description |
---|---|
Auth.signIn | Login API (excluding anonymous login and third-party login) |
Auth.signUp | Registration API |
Auth.getVerification | Unified verification code retrieval API (phone number, email) |
Auth.bindPhoneNumber | Bind/Update phone number (The original user information update method is no longer supported) |
Auth.bindEmail | Bind/Update email (The original user information update method is no longer supported) |
Auth.bindWithProvider | Bind third-party platforms (e.g., WeChat Open/Official Account Platform) |
Auth.unbindProvider | Unbind third-party platforms |
Auth.setPassword | Set password |
Auth.queryUser | Query user information by conditions |
Auth.signInWithProvider | Third-party platform login |