@cloudbase/js-sdk 2.24.3 → 2.24.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,6 +1,34 @@
1
1
  import { OrmClient, OrmRawQueryClient } from '@cloudbase/model';
2
2
  import { IMySqlClient } from '@cloudbase/mysql';
3
3
  import { authModels } from '@cloudbase/oauth';
4
+ import type {
5
+ SignInRes,
6
+ GetUserRes,
7
+ CommonRes,
8
+ SignInWithOtpRes,
9
+ SignInOAuthRes,
10
+ GetClaimsRes,
11
+ ResetPasswordForEmailRes,
12
+ GetUserIdentitiesRes,
13
+ LinkIdentityRes,
14
+ ReauthenticateRes,
15
+ ResendRes,
16
+ UpdateUserWithVerificationRes,
17
+ OnAuthStateChangeCallback,
18
+ SignInWithPasswordReq,
19
+ SignInWithIdTokenReq,
20
+ SignInWithOAuthReq,
21
+ VerifyOAuthReq,
22
+ VerifyOtpReq,
23
+ LinkIdentityReq,
24
+ UnlinkIdentityReq,
25
+ UpdateUserReq,
26
+ SignInWithOtpReq,
27
+ ResetPasswordForOldReq,
28
+ ResendReq,
29
+ SetSessionReq,
30
+ DeleteMeReq,
31
+ } from '@cloudbase/auth';
4
32
  import { AI } from '@cloudbase/ai';
5
33
  import { CloudbaseAdapter, ResponseObject } from '@cloudbase/adapter-interface'
6
34
  import { ICloudbaseUpgradedConfig, ICloudbase, Persistence } from '@cloudbase/types'
@@ -260,7 +288,7 @@ declare namespace cloudbase.app {
260
288
  *
261
289
  * @return {!cloudbase.auth.App} Auth实例
262
290
  */
263
- auth(options?: { persistence: cloudbase.auth.Persistence }): cloudbase.auth.App
291
+ auth: ((options?: { persistence: cloudbase.auth.Persistence }) => cloudbase.auth.App) & cloudbase.auth.App
264
292
  /**
265
293
  * 调用云函数
266
294
  *
@@ -758,8 +786,9 @@ declare namespace cloudbase.auth {
758
786
  * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetverification}
759
787
  *
760
788
  * @param params
789
+ * @param options
761
790
  */
762
- getVerification(params: authModels.GetVerificationRequest): Promise<authModels.GetVerificationResponse>
791
+ getVerification(params: authModels.GetVerificationRequest, options?: { withCaptcha: boolean }): Promise<authModels.GetVerificationResponse>
763
792
  /**
764
793
  * 匿名登录
765
794
  *
@@ -768,6 +797,54 @@ declare namespace cloudbase.auth {
768
797
  *
769
798
  */
770
799
  signInAnonymously(data?: { provider_token?: string }): Promise<ILoginState>
800
+ /**
801
+ * 小程序匿名登录
802
+ *
803
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninanonymouslyinwx}
804
+ *
805
+ * @param params
806
+ */
807
+ signInAnonymouslyInWx(params?: { useWxCloud?: boolean }): Promise<ILoginState>
808
+ /**
809
+ * 小程序绑定OpenID
810
+ *
811
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authbindopenid}
812
+ *
813
+ */
814
+ bindOpenId(): Promise<void>
815
+ /**
816
+ * 小程序unionId静默登录
817
+ *
818
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithunionid}
819
+ *
820
+ */
821
+ signInWithUnionId(): Promise<ILoginState>
822
+ /**
823
+ * 短信验证码登录
824
+ *
825
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithsms}
826
+ *
827
+ * @param params
828
+ */
829
+ signInWithSms(params: {
830
+ verificationInfo?: { verification_id: string; is_user: boolean }
831
+ verificationCode?: string
832
+ phoneNum?: string
833
+ bindInfo?: any
834
+ }): Promise<ILoginState>
835
+ /**
836
+ * 邮箱验证码登录
837
+ *
838
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithemail}
839
+ *
840
+ * @param params
841
+ */
842
+ signInWithEmail(params: {
843
+ verificationInfo?: { verification_id: string; is_user: boolean }
844
+ verificationCode?: string
845
+ email?: string
846
+ bindInfo?: any
847
+ }): Promise<ILoginState>
771
848
  /**
772
849
  * 设置获取自定义登录 ticket 的函数
773
850
  *
@@ -781,8 +858,10 @@ declare namespace cloudbase.auth {
781
858
  * 使用自定义登录 ticket 登录
782
859
  *
783
860
  * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithcustomticket}
861
+ *
862
+ * @param getTickFn
784
863
  */
785
- signInWithCustomTicket(): Promise<ILoginState>
864
+ signInWithCustomTicket(getTickFn?: authModels.GetCustomSignTicketFn): Promise<ILoginState>
786
865
  /**
787
866
  * 用户登录,目前支持手机号,邮箱,用户名密码登录
788
867
  *
@@ -808,6 +887,20 @@ declare namespace cloudbase.auth {
808
887
  * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetuserinfo}
809
888
  */
810
889
  getUserInfo(): Promise<IUserInfo>
890
+ /**
891
+ * 获取微搭插件用户信息
892
+ *
893
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetwedauserinfo}
894
+ */
895
+ getWedaUserInfo(): Promise<any>
896
+ /**
897
+ * 更新用户基本信息
898
+ *
899
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authupdateuserbasicinfo}
900
+ *
901
+ * @param params
902
+ */
903
+ updateUserBasicInfo(params: authModels.ModifyUserBasicInfoRequest): Promise<void>
811
904
  /**
812
905
  * 获取本地登录态-同步操作
813
906
  *
@@ -878,6 +971,12 @@ declare namespace cloudbase.auth {
878
971
  * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithprovider}
879
972
  */
880
973
  signInWithProvider(params: authModels.SignInWithProviderRequest): Promise<ILoginState>
974
+ /**
975
+ * 微信登录
976
+ *
977
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithwechat}
978
+ */
979
+ signInWithWechat(params?: any): Promise<ILoginState>
881
980
  grantToken(params: authModels.GrantTokenRequest): Promise<ILoginState>
882
981
  /**
883
982
  * 生成第三方平台授权 Uri (如微信二维码扫码授权网页)
@@ -920,7 +1019,75 @@ declare namespace cloudbase.auth {
920
1019
  loginScope(): Promise<string>
921
1020
  loginGroups(): Promise<string[]>
922
1021
  onLoginStateChanged(callback: Function)
923
- createLoginState(): Promise<ILoginState>
1022
+ createLoginState(params?: { version?: string; query?: any }, options?: { asyncRefreshUser?: boolean; userInfo?: any }): Promise<ILoginState>
1023
+ /**
1024
+ * 强制刷新token
1025
+ *
1026
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authrefreshtokenforce}
1027
+ *
1028
+ * @param params
1029
+ */
1030
+ refreshTokenForce(params: { version?: string }): Promise<authModels.Credentials>
1031
+ /**
1032
+ * 获取身份信息
1033
+ *
1034
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetcredentials}
1035
+ */
1036
+ getCredentials(): Promise<authModels.Credentials>
1037
+ /**
1038
+ * 写入身份信息
1039
+ *
1040
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsetcredentials}
1041
+ *
1042
+ * @param credentials
1043
+ */
1044
+ setCredentials(credentials: authModels.Credentials): Promise<void>
1045
+ /**
1046
+ * 获取身份源类型
1047
+ *
1048
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetprovidersubtype}
1049
+ */
1050
+ getProviderSubType(): Promise<authModels.ProviderSubType>
1051
+ /**
1052
+ * 创建验证码数据
1053
+ *
1054
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authcreatecaptchadata}
1055
+ *
1056
+ * @param params
1057
+ */
1058
+ createCaptchaData(params: { state: string; redirect_uri?: string }): Promise<any>
1059
+ /**
1060
+ * 验证验证码数据
1061
+ *
1062
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authverifycaptchadata}
1063
+ *
1064
+ * @param params
1065
+ */
1066
+ verifyCaptchaData(params: { token: string; key: string }): Promise<any>
1067
+ /**
1068
+ * 修改密码
1069
+ *
1070
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authmodifypassword}
1071
+ *
1072
+ * @param params
1073
+ */
1074
+ modifyPassword(params: authModels.ModifyUserBasicInfoRequest): Promise<void>
1075
+ /**
1076
+ * 未登录状态修改密码
1077
+ *
1078
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authmodifypasswordwithoutlogin}
1079
+ *
1080
+ * @param params
1081
+ */
1082
+ modifyPasswordWithoutLogin(params: authModels.ModifyPasswordWithoutLoginRequest): Promise<void>
1083
+ /**
1084
+ * 获取用户行为日志
1085
+ *
1086
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetuserbehaviorlog}
1087
+ *
1088
+ * @param params
1089
+ */
1090
+ getUserBehaviorLog(params: authModels.GetUserBehaviorLog): Promise<authModels.GetUserBehaviorLogRes>
924
1091
  /**
925
1092
  * 退出登录,请注意,匿名登录不支持退出
926
1093
  *
@@ -963,7 +1130,188 @@ declare namespace cloudbase.auth {
963
1130
  getMiniProgramQrCodeStatus(
964
1131
  params: authModels.GetMiniProgramQrCodeStatusRequest,
965
1132
  ): Promise<authModels.GetMiniProgramQrCodeStatusResponse>
966
- toDefaultLoginPage(params: authModels.ToDefaultLoginPage): Promise<void>
1133
+ toDefaultLoginPage(params?: authModels.ToDefaultLoginPage): Promise<void>
1134
+ /**
1135
+ * 监听认证状态变化
1136
+ *
1137
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authonauthstatechange}
1138
+ *
1139
+ * @param callback
1140
+ */
1141
+ onAuthStateChange(callback: OnAuthStateChangeCallback): { data: { subscription: { id: string; callback: Function; unsubscribe: () => void } } }
1142
+ /**
1143
+ * 使用用户名和密码登录
1144
+ *
1145
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithpassword}
1146
+ *
1147
+ * @param params
1148
+ */
1149
+ signInWithPassword(params: SignInWithPasswordReq): Promise<SignInRes>
1150
+ /**
1151
+ * 使用第三方平台 ID Token 登录
1152
+ *
1153
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithidtoken}
1154
+ *
1155
+ * @param params
1156
+ */
1157
+ signInWithIdToken(params: SignInWithIdTokenReq): Promise<SignInRes>
1158
+ /**
1159
+ * 使用一次性密码(OTP)登录
1160
+ *
1161
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithotp}
1162
+ *
1163
+ * @param params
1164
+ */
1165
+ signInWithOtp(params: SignInWithOtpReq): Promise<SignInWithOtpRes>
1166
+ /**
1167
+ * 校验第三方平台授权登录回调
1168
+ *
1169
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authverifyoauth}
1170
+ *
1171
+ * @param params
1172
+ */
1173
+ verifyOAuth(params?: VerifyOAuthReq): Promise<SignInRes>
1174
+ /**
1175
+ * 生成第三方平台授权 Uri
1176
+ *
1177
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithoauth}
1178
+ *
1179
+ * @param params
1180
+ */
1181
+ signInWithOAuth(params: SignInWithOAuthReq): Promise<SignInOAuthRes>
1182
+ /**
1183
+ * 获取用户声明信息
1184
+ *
1185
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetclaims}
1186
+ */
1187
+ getClaims(): Promise<GetClaimsRes>
1188
+ /**
1189
+ * 通过邮箱或手机号重置密码
1190
+ *
1191
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authresetpasswordforemail}
1192
+ *
1193
+ * @param emailOrPhone
1194
+ * @param options
1195
+ */
1196
+ resetPasswordForEmail(emailOrPhone: string, options?: { redirectTo?: string }): Promise<ResetPasswordForEmailRes>
1197
+ /**
1198
+ * 通过旧密码重置密码
1199
+ *
1200
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authresetpasswordforold}
1201
+ *
1202
+ * @param params
1203
+ */
1204
+ resetPasswordForOld(params: ResetPasswordForOldReq): Promise<SignInRes>
1205
+ /**
1206
+ * 验证一次性密码(OTP)
1207
+ *
1208
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authverifyotp}
1209
+ *
1210
+ * @param params
1211
+ */
1212
+ verifyOtp(params: VerifyOtpReq): Promise<SignInRes>
1213
+ /**
1214
+ * 获取当前会话
1215
+ *
1216
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetsession}
1217
+ */
1218
+ getSession(): Promise<SignInRes>
1219
+ /**
1220
+ * 刷新会话
1221
+ *
1222
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authrefreshsession}
1223
+ *
1224
+ * @param refresh_token
1225
+ */
1226
+ refreshSession(refresh_token?: string): Promise<SignInRes>
1227
+ /**
1228
+ * 获取当前用户详细信息
1229
+ *
1230
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetuser}
1231
+ */
1232
+ getUser(): Promise<GetUserRes>
1233
+ /**
1234
+ * 刷新用户信息
1235
+ *
1236
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authrefreshuser}
1237
+ */
1238
+ refreshUser(): Promise<CommonRes>
1239
+ /**
1240
+ * 更新用户信息
1241
+ *
1242
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authupdateuser}
1243
+ *
1244
+ * @param params
1245
+ */
1246
+ updateUser(params: UpdateUserReq): Promise<GetUserRes | UpdateUserWithVerificationRes>
1247
+ /**
1248
+ * 获取所有身份源
1249
+ *
1250
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authgetuseridentities}
1251
+ */
1252
+ getUserIdentities(): Promise<GetUserIdentitiesRes>
1253
+ /**
1254
+ * 绑定身份源到当前用户
1255
+ *
1256
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authlinkidentity}
1257
+ *
1258
+ * @param params
1259
+ */
1260
+ linkIdentity(params: LinkIdentityReq): Promise<LinkIdentityRes>
1261
+ /**
1262
+ * 解绑身份源
1263
+ *
1264
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authunlinkidentity}
1265
+ *
1266
+ * @param params
1267
+ */
1268
+ unlinkIdentity(params: UnlinkIdentityReq): Promise<CommonRes>
1269
+ /**
1270
+ * 重新认证
1271
+ *
1272
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authreauthenticate}
1273
+ */
1274
+ reauthenticate(): Promise<ReauthenticateRes>
1275
+ /**
1276
+ * 重新发送验证码
1277
+ *
1278
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authresend}
1279
+ *
1280
+ * @param params
1281
+ */
1282
+ resend(params: ResendReq): Promise<ResendRes>
1283
+ /**
1284
+ * 使用 access_token 和 refresh_token 设置会话
1285
+ *
1286
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsetsession}
1287
+ *
1288
+ * @param params
1289
+ */
1290
+ setSession(params: SetSessionReq): Promise<SignInRes>
1291
+ /**
1292
+ * 删除当前用户
1293
+ *
1294
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authdeleteuser}
1295
+ *
1296
+ * @param params
1297
+ */
1298
+ deleteUser(params: DeleteMeReq): Promise<CommonRes>
1299
+ /**
1300
+ * 小程序 openId 静默登录
1301
+ *
1302
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithopenid}
1303
+ *
1304
+ * @param params
1305
+ */
1306
+ signInWithOpenId(params?: { useWxCloud?: boolean }): Promise<SignInRes>
1307
+ /**
1308
+ * 小程序手机号授权登录
1309
+ *
1310
+ * 文档 {@link https://docs.cloudbase.net/api-reference/webv3/authentication#authsigninwithphoneauth}
1311
+ *
1312
+ * @param params
1313
+ */
1314
+ signInWithPhoneAuth(params: { phoneCode: string }): Promise<SignInRes>
967
1315
  }
968
1316
  }
969
1317
  /**