@cloudbase/js-sdk 3.6.2 → 3.6.3
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/CHANGELOG.md +6 -0
- package/ai/dist/index.esm.js +1 -1
- package/ai/dist/index.esm.js.map +1 -1
- package/ai/dist/index.js +1 -1
- package/ai/dist/index.js.map +1 -1
- package/app/dist/index.esm.js +1 -1
- package/app/dist/index.esm.js.map +1 -1
- package/app/dist/index.js +1 -1
- package/app/dist/index.js.map +1 -1
- package/app/dist/index.node.esm.js +1 -1
- package/app/dist/index.node.esm.js.map +1 -1
- package/app/dist/index.node.js +1 -1
- package/app/dist/index.node.js.map +1 -1
- package/auth/dist/index.esm.js +1 -1
- package/auth/dist/index.esm.js.map +1 -1
- package/auth/dist/index.js +1 -1
- package/auth/dist/index.js.map +1 -1
- package/core.d.ts +4331 -0
- package/core.node.d.ts +294 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.node.cjs.js +1 -1
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/index.node.esm.js +1 -1
- package/dist/index.node.esm.js.map +1 -1
- package/index.d.ts +5 -4268
- package/index.node.d.ts +13 -0
- package/miniprogram_dist/ai/index.d.ts +42 -0
- package/miniprogram_dist/ai/index.js +2 -0
- package/miniprogram_dist/apis/index.d.ts +5 -0
- package/miniprogram_dist/{apis.js → apis/index.js} +1 -1
- package/miniprogram_dist/app/index.d.ts +67 -0
- package/miniprogram_dist/app/index.js +2 -0
- package/miniprogram_dist/auth/index.d.ts +284 -0
- package/miniprogram_dist/auth/index.js +2 -0
- package/miniprogram_dist/cloudrun/index.d.ts +4 -0
- package/miniprogram_dist/cloudrun/index.js +1 -0
- package/miniprogram_dist/container/index.d.ts +13 -0
- package/miniprogram_dist/container/index.js +1 -0
- package/miniprogram_dist/database/index.d.ts +3 -0
- package/miniprogram_dist/functions/index.d.ts +2 -0
- package/miniprogram_dist/functions/index.js +1 -0
- package/miniprogram_dist/index.js +1 -1
- package/miniprogram_dist/model/index.d.ts +5 -0
- package/miniprogram_dist/model/index.js +1 -0
- package/miniprogram_dist/mysql/index.d.ts +3 -0
- package/miniprogram_dist/mysql/index.js +1 -0
- package/miniprogram_dist/oauth/index.d.ts +22 -0
- package/miniprogram_dist/oauth/index.js +2 -0
- package/miniprogram_dist/realtime/index.d.ts +2 -0
- package/miniprogram_dist/realtime/index.js +1 -0
- package/miniprogram_dist/storage/index.d.ts +13 -0
- package/miniprogram_dist/{storage.js → storage/index.js} +1 -1
- package/oauth/dist/index.esm.js +1 -1
- package/oauth/dist/index.esm.js.map +1 -1
- package/oauth/dist/index.js +1 -1
- package/oauth/dist/index.js.map +1 -1
- package/package.json +6 -2
- package/types/package.json +1 -1
- package/utilities/package.json +2 -2
- package/dist/index.d.ts +0 -9
- package/miniprogram_dist/ai.js +0 -2
- package/miniprogram_dist/app.js +0 -2
- package/miniprogram_dist/auth.js +0 -2
- package/miniprogram_dist/cloudrun.js +0 -1
- package/miniprogram_dist/container.js +0 -1
- package/miniprogram_dist/functions.js +0 -1
- package/miniprogram_dist/model.js +0 -1
- package/miniprogram_dist/mysql.js +0 -1
- package/miniprogram_dist/oauth.js +0 -2
- package/miniprogram_dist/realtime.js +0 -1
- /package/miniprogram_dist/{database.js → database/index.js} +0 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import type { ICloudbase, ICloudbaseConfig } from '@cloudbase/types';
|
|
2
|
+
import type { ICloudbaseCache } from '@cloudbase/types/cache';
|
|
3
|
+
import type { ICloudbaseRequest } from '@cloudbase/types/request';
|
|
4
|
+
import type { ICloudbaseAuthConfig, IUser, ILoginState } from '@cloudbase/types/auth';
|
|
5
|
+
import type { AuthOptions, Credentials } from '@cloudbase/oauth';
|
|
6
|
+
import { CloudbaseOAuth, AuthError, authModels } from '@cloudbase/oauth';
|
|
7
|
+
import { AuthV1Compat, WeixinAuthProvider, CustomAuthProvider, AnonymousAuthProvider } from './v1-compat';
|
|
8
|
+
import { CommonRes, DeleteMeReq, GetClaimsRes, GetUserIdentitiesRes, GetUserRes, LinkIdentityReq, LinkIdentityRes, OnAuthStateChangeCallback, ReauthenticateRes, ResendReq, ResendRes, ResetPasswordForEmailRes, ResetPasswordForOldReq, SetSessionReq, SignInAnonymouslyReq, SignInOAuthRes, SignInRes, SignInWithIdTokenReq, SignInWithOAuthReq, SignInWithOtpReq, SignInWithOtpRes, SignInWithPasswordReq, SignUpRes, UnlinkIdentityReq, UpdateUserReq, UpdateUserWithVerificationRes, VerifyOAuthReq, VerifyOAuthRes, VerifyOtpReq } from './type';
|
|
9
|
+
export type { SignInRes, GetUserRes, CommonRes, SignInWithOtpRes, SignInOAuthRes, GetClaimsRes, ResetPasswordForEmailRes, GetUserIdentitiesRes, LinkIdentityRes, ReauthenticateRes, ResendRes, UpdateUserWithVerificationRes, OnAuthStateChangeCallback, SignInWithPasswordReq, SignInWithIdTokenReq, SignInWithOAuthReq, VerifyOAuthReq, VerifyOtpReq, LinkIdentityReq, UnlinkIdentityReq, UpdateUserReq, SignInWithOtpReq, ResetPasswordForOldReq, ResendReq, SetSessionReq, DeleteMeReq, SignUpRes, } from './type';
|
|
10
|
+
interface UserInfo {
|
|
11
|
+
uid?: string;
|
|
12
|
+
gender?: string;
|
|
13
|
+
picture?: string;
|
|
14
|
+
email?: string;
|
|
15
|
+
email_verified?: boolean;
|
|
16
|
+
phone_number?: string;
|
|
17
|
+
username?: string;
|
|
18
|
+
name?: string;
|
|
19
|
+
birthdate?: string;
|
|
20
|
+
zoneinfo?: string;
|
|
21
|
+
locale?: string;
|
|
22
|
+
sub?: string;
|
|
23
|
+
created_from?: string;
|
|
24
|
+
}
|
|
25
|
+
interface IUserOptions {
|
|
26
|
+
cache: ICloudbaseCache;
|
|
27
|
+
oauthInstance: CloudbaseOAuth;
|
|
28
|
+
}
|
|
29
|
+
export declare class User implements IUser {
|
|
30
|
+
uid?: string;
|
|
31
|
+
gender?: string;
|
|
32
|
+
picture?: string;
|
|
33
|
+
email?: string;
|
|
34
|
+
emailVerified?: boolean;
|
|
35
|
+
phoneNumber?: string;
|
|
36
|
+
username?: string;
|
|
37
|
+
name?: string;
|
|
38
|
+
providers?: {
|
|
39
|
+
id?: string;
|
|
40
|
+
providerUserId?: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
}[];
|
|
43
|
+
birthdate?: string;
|
|
44
|
+
zoneinfo?: string;
|
|
45
|
+
locale?: string;
|
|
46
|
+
sub?: string;
|
|
47
|
+
createdFrom?: string;
|
|
48
|
+
open_id?: string;
|
|
49
|
+
private cache;
|
|
50
|
+
private oauthInstance;
|
|
51
|
+
constructor(options: IUserOptions);
|
|
52
|
+
checkLocalInfo(): Promise<void>;
|
|
53
|
+
checkLocalInfoAsync(): Promise<void>;
|
|
54
|
+
update(userInfo: authModels.UserProfile): Promise<void>;
|
|
55
|
+
updateUserBasicInfo(params: authModels.ModifyUserBasicInfoRequest): Promise<void>;
|
|
56
|
+
updatePassword(newPassword: string, oldPassword: string): Promise<void>;
|
|
57
|
+
updateUsername(username: string): Promise<void>;
|
|
58
|
+
refresh(params?: {
|
|
59
|
+
version?: string;
|
|
60
|
+
query?: any;
|
|
61
|
+
}): Promise<authModels.UserInfo>;
|
|
62
|
+
getLocalUserInfo(key?: string): string | boolean | Record<string, any>;
|
|
63
|
+
setLocalUserInfo(userInfo: any): void;
|
|
64
|
+
private getLocalUserInfoAsync;
|
|
65
|
+
private setUserInfo;
|
|
66
|
+
}
|
|
67
|
+
interface ILoginStateOptions extends IUserOptions {
|
|
68
|
+
envId: string;
|
|
69
|
+
}
|
|
70
|
+
export declare class LoginState implements ILoginState {
|
|
71
|
+
user: User;
|
|
72
|
+
oauthLoginState: any;
|
|
73
|
+
private oauthInstance;
|
|
74
|
+
private cache;
|
|
75
|
+
constructor(options: ILoginStateOptions);
|
|
76
|
+
checkLocalState(): void;
|
|
77
|
+
checkLocalStateAsync(): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
interface IAuthConfig extends ICloudbaseAuthConfig {
|
|
80
|
+
cache: ICloudbaseCache;
|
|
81
|
+
request?: ICloudbaseRequest;
|
|
82
|
+
runtime?: string;
|
|
83
|
+
}
|
|
84
|
+
declare class Auth extends AuthV1Compat {
|
|
85
|
+
readonly config: IAuthConfig;
|
|
86
|
+
oauthInstance: CloudbaseOAuth;
|
|
87
|
+
readonly cache: ICloudbaseCache;
|
|
88
|
+
private listeners;
|
|
89
|
+
private hasListenerSetUp;
|
|
90
|
+
constructor(config: IAuthConfig);
|
|
91
|
+
signInAnonymously(params: SignInAnonymouslyReq): Promise<SignInRes>;
|
|
92
|
+
signUp(params: authModels.SignUpRequest & {
|
|
93
|
+
phone?: string;
|
|
94
|
+
}): Promise<SignUpRes>;
|
|
95
|
+
signOut(params?: authModels.SignoutRequest): Promise<authModels.SignoutResponse & {
|
|
96
|
+
data: Object;
|
|
97
|
+
error: AuthError;
|
|
98
|
+
}>;
|
|
99
|
+
onAuthStateChange(callback: OnAuthStateChangeCallback): {
|
|
100
|
+
data: {
|
|
101
|
+
subscription: {
|
|
102
|
+
id: string;
|
|
103
|
+
callback: OnAuthStateChangeCallback;
|
|
104
|
+
unsubscribe: () => void;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
signInWithPassword(params: SignInWithPasswordReq): Promise<SignInRes>;
|
|
109
|
+
signInWithIdToken(params: SignInWithIdTokenReq): Promise<SignInRes>;
|
|
110
|
+
signInWithOtp(params: SignInWithOtpReq): Promise<SignInWithOtpRes>;
|
|
111
|
+
verifyOAuth(params?: VerifyOAuthReq): Promise<VerifyOAuthRes>;
|
|
112
|
+
signInWithOAuth(params: SignInWithOAuthReq): Promise<SignInOAuthRes>;
|
|
113
|
+
getClaims(): Promise<GetClaimsRes>;
|
|
114
|
+
resetPasswordForEmail(emailOrPhone: string, options?: {
|
|
115
|
+
redirectTo?: string;
|
|
116
|
+
}): Promise<ResetPasswordForEmailRes>;
|
|
117
|
+
resetPasswordForOld(params: ResetPasswordForOldReq): Promise<{
|
|
118
|
+
data: {
|
|
119
|
+
user: import("./type").User;
|
|
120
|
+
session: import("./type").Session;
|
|
121
|
+
};
|
|
122
|
+
error: any;
|
|
123
|
+
} | {
|
|
124
|
+
data: {
|
|
125
|
+
user: any;
|
|
126
|
+
session: any;
|
|
127
|
+
};
|
|
128
|
+
error: AuthError;
|
|
129
|
+
}>;
|
|
130
|
+
verifyOtp(params: VerifyOtpReq): Promise<SignInRes>;
|
|
131
|
+
getSession(): Promise<SignInRes>;
|
|
132
|
+
refreshSession(refresh_token?: string): Promise<SignInRes>;
|
|
133
|
+
getUser(isRefresh?: boolean): Promise<GetUserRes>;
|
|
134
|
+
refreshUser(): Promise<CommonRes>;
|
|
135
|
+
updateUser(params: UpdateUserReq): Promise<GetUserRes | UpdateUserWithVerificationRes>;
|
|
136
|
+
getUserIdentities(): Promise<GetUserIdentitiesRes>;
|
|
137
|
+
linkIdentity(params: LinkIdentityReq): Promise<LinkIdentityRes>;
|
|
138
|
+
unlinkIdentity(params: UnlinkIdentityReq): Promise<CommonRes>;
|
|
139
|
+
reauthenticate(): Promise<ReauthenticateRes>;
|
|
140
|
+
resend(params: ResendReq): Promise<ResendRes>;
|
|
141
|
+
setSession(params: SetSessionReq): Promise<SignInRes>;
|
|
142
|
+
exchangeCodeForSession(): Promise<void>;
|
|
143
|
+
deleteUser(params: DeleteMeReq): Promise<CommonRes>;
|
|
144
|
+
toDefaultLoginPage(params?: authModels.ToDefaultLoginPage): Promise<CommonRes>;
|
|
145
|
+
signInWithCustomTicket(getTickFn?: authModels.GetCustomSignTicketFn): Promise<SignInRes>;
|
|
146
|
+
signInWithOpenId({ useWxCloud }?: {
|
|
147
|
+
useWxCloud?: boolean;
|
|
148
|
+
}): Promise<SignInRes>;
|
|
149
|
+
signInWithPhoneAuth({ phoneCode, useWxCloud }: {
|
|
150
|
+
phoneCode?: string;
|
|
151
|
+
useWxCloud?: boolean;
|
|
152
|
+
}): Promise<SignInRes>;
|
|
153
|
+
bindPhoneNumber(params: authModels.BindPhoneRequest): Promise<void>;
|
|
154
|
+
unbindProvider(params: authModels.UnbindProviderRequest): Promise<void>;
|
|
155
|
+
bindEmail(params: authModels.BindEmailRequest): Promise<void>;
|
|
156
|
+
verify(params: authModels.VerifyRequest): Promise<authModels.VerifyResponse>;
|
|
157
|
+
getVerification(params: authModels.GetVerificationRequest, options?: {
|
|
158
|
+
withCaptcha: boolean;
|
|
159
|
+
}): Promise<authModels.GetVerificationResponse>;
|
|
160
|
+
get currentUser(): User;
|
|
161
|
+
getCurrentUser(isRefresh?: boolean): Promise<(authModels.UserInfo & Partial<User>) | null>;
|
|
162
|
+
signInAnonymouslyInWx({ useWxCloud, }?: {
|
|
163
|
+
useWxCloud?: boolean;
|
|
164
|
+
}): Promise<LoginState>;
|
|
165
|
+
bindOpenId(): Promise<void>;
|
|
166
|
+
signInWithUnionId(): Promise<LoginState>;
|
|
167
|
+
signInWithSms({ verificationInfo, verificationCode, phoneNum, bindInfo, }: {
|
|
168
|
+
verificationInfo?: {
|
|
169
|
+
verification_id: string;
|
|
170
|
+
is_user: boolean;
|
|
171
|
+
};
|
|
172
|
+
verificationCode?: string;
|
|
173
|
+
phoneNum?: string;
|
|
174
|
+
bindInfo?: any;
|
|
175
|
+
}): Promise<LoginState>;
|
|
176
|
+
signInWithEmail({ verificationInfo, verificationCode, bindInfo, email, }: {
|
|
177
|
+
verificationInfo?: {
|
|
178
|
+
verification_id: string;
|
|
179
|
+
is_user: boolean;
|
|
180
|
+
};
|
|
181
|
+
verificationCode?: string;
|
|
182
|
+
bindInfo?: any;
|
|
183
|
+
email?: string;
|
|
184
|
+
}): Promise<LoginState>;
|
|
185
|
+
setCustomSignFunc(getTickFn: authModels.GetCustomSignTicketFn): void;
|
|
186
|
+
signIn(params: authModels.SignInRequest): Promise<LoginState>;
|
|
187
|
+
setPassword(params: authModels.SetPasswordRequest): Promise<void>;
|
|
188
|
+
isUsernameRegistered(username: string): Promise<boolean>;
|
|
189
|
+
hasLoginState(): LoginState | null;
|
|
190
|
+
getLoginState(): Promise<LoginState>;
|
|
191
|
+
getUserInfo(): Promise<(authModels.UserInfo & Partial<User>) | null>;
|
|
192
|
+
getWedaUserInfo(): Promise<any>;
|
|
193
|
+
updateUserBasicInfo(params: authModels.ModifyUserBasicInfoRequest): Promise<void>;
|
|
194
|
+
getAuthHeader(): {};
|
|
195
|
+
bindWithProvider(params: authModels.BindWithProviderRequest): Promise<void>;
|
|
196
|
+
queryUser(queryObj: authModels.QueryUserProfileRequest): Promise<authModels.QueryUserProfileResponse>;
|
|
197
|
+
getAccessToken(): Promise<{
|
|
198
|
+
accessToken: string;
|
|
199
|
+
env: string;
|
|
200
|
+
}>;
|
|
201
|
+
grantProviderToken(params: authModels.GrantProviderTokenRequest): Promise<authModels.GrantProviderTokenResponse>;
|
|
202
|
+
patchProviderToken(params: authModels.PatchProviderTokenRequest): Promise<authModels.PatchProviderTokenResponse>;
|
|
203
|
+
signInWithProvider(params: authModels.SignInWithProviderRequest): Promise<LoginState>;
|
|
204
|
+
signInWithWechat(params?: any): Promise<LoginState>;
|
|
205
|
+
grantToken(params: authModels.GrantTokenRequest): Promise<LoginState>;
|
|
206
|
+
genProviderRedirectUri(params: authModels.GenProviderRedirectUriRequest): Promise<authModels.GenProviderRedirectUriResponse>;
|
|
207
|
+
resetPassword(params: authModels.ResetPasswordRequest): Promise<void>;
|
|
208
|
+
deviceAuthorize(params: authModels.DeviceAuthorizeRequest): Promise<authModels.DeviceAuthorizeResponse>;
|
|
209
|
+
sudo(params: authModels.SudoRequest): Promise<authModels.SudoResponse>;
|
|
210
|
+
deleteMe(params: authModels.WithSudoRequest): Promise<authModels.UserProfile>;
|
|
211
|
+
getProviders(): Promise<authModels.ProvidersResponse>;
|
|
212
|
+
loginScope(): Promise<string>;
|
|
213
|
+
loginGroups(): Promise<string[]>;
|
|
214
|
+
onLoginStateChanged(callback: Function): Promise<void>;
|
|
215
|
+
refreshTokenForce(params: {
|
|
216
|
+
version?: string;
|
|
217
|
+
}): Promise<Credentials>;
|
|
218
|
+
getCredentials(): Promise<Credentials>;
|
|
219
|
+
setCredentials(credentials: Credentials): Promise<void>;
|
|
220
|
+
getProviderSubType(): Promise<authModels.ProviderSubType>;
|
|
221
|
+
createCaptchaData(params: {
|
|
222
|
+
state: string;
|
|
223
|
+
redirect_uri?: string;
|
|
224
|
+
}): Promise<{
|
|
225
|
+
token: string;
|
|
226
|
+
data: string;
|
|
227
|
+
}>;
|
|
228
|
+
verifyCaptchaData(params: {
|
|
229
|
+
token: string;
|
|
230
|
+
key: string;
|
|
231
|
+
}): Promise<{
|
|
232
|
+
captcha_token: string;
|
|
233
|
+
expires_in: number;
|
|
234
|
+
}>;
|
|
235
|
+
getMiniProgramQrCode(params: authModels.GetMiniProgramQrCodeRequest): Promise<authModels.GetMiniProgramQrCodeResponse>;
|
|
236
|
+
getMiniProgramQrCodeStatus(params: authModels.GetMiniProgramQrCodeStatusRequest): Promise<authModels.GetMiniProgramQrCodeStatusResponse>;
|
|
237
|
+
modifyPassword(params: authModels.ModifyUserBasicInfoRequest): Promise<void>;
|
|
238
|
+
modifyPasswordWithoutLogin(params: authModels.ModifyPasswordWithoutLoginRequest): Promise<void>;
|
|
239
|
+
getUserBehaviorLog(params: authModels.GetUserBehaviorLog): Promise<authModels.GetUserBehaviorLogRes>;
|
|
240
|
+
signInWithUsername({ verificationInfo, verificationCode, username: rawUsername, bindInfo, loginType, }: {
|
|
241
|
+
verificationInfo?: authModels.GetVerificationResponse;
|
|
242
|
+
verificationCode?: string;
|
|
243
|
+
username?: string;
|
|
244
|
+
bindInfo?: any;
|
|
245
|
+
loginType?: string;
|
|
246
|
+
}): Promise<LoginState>;
|
|
247
|
+
createLoginState(params?: {
|
|
248
|
+
version?: string;
|
|
249
|
+
query?: any;
|
|
250
|
+
}, options?: {
|
|
251
|
+
asyncRefreshUser?: boolean;
|
|
252
|
+
userInfo?: any;
|
|
253
|
+
}): Promise<LoginState>;
|
|
254
|
+
setAccessKey(): Promise<void>;
|
|
255
|
+
protected formatPhone(phone: string): string;
|
|
256
|
+
private notifyListeners;
|
|
257
|
+
private setupListeners;
|
|
258
|
+
private convertToUser;
|
|
259
|
+
private validateParams;
|
|
260
|
+
private validateAtLeastOne;
|
|
261
|
+
private init;
|
|
262
|
+
}
|
|
263
|
+
type TInitAuthOptions = Pick<ICloudbaseAuthConfig, 'region' | 'persistence' | 'i18n' | 'accessKey' | 'useWxCloud' | 'auth'> & Partial<AuthOptions> & {
|
|
264
|
+
detectSessionInUrl?: boolean;
|
|
265
|
+
};
|
|
266
|
+
export declare function generateAuthInstance(config: TInitAuthOptions & {
|
|
267
|
+
sdkVersion?: string;
|
|
268
|
+
}, options?: {
|
|
269
|
+
clientId: ICloudbaseConfig['clientId'];
|
|
270
|
+
env: ICloudbaseConfig['env'];
|
|
271
|
+
apiOrigin?: string;
|
|
272
|
+
getApiOrigin?: () => string;
|
|
273
|
+
cache?: ICloudbaseCache;
|
|
274
|
+
platform?: ICloudbase['platform'];
|
|
275
|
+
app?: ICloudbase;
|
|
276
|
+
debug?: ICloudbaseAuthConfig['debug'];
|
|
277
|
+
detectSessionInUrl?: ICloudbaseAuthConfig['detectSessionInUrl'];
|
|
278
|
+
}): {
|
|
279
|
+
authInstance: Auth;
|
|
280
|
+
oauthInstance: CloudbaseOAuth;
|
|
281
|
+
};
|
|
282
|
+
export { UserInfo, Auth, WeixinAuthProvider, CustomAuthProvider, AnonymousAuthProvider };
|
|
283
|
+
export { AuthErrorCategory, AuthErrorCode, AuthError } from '@cloudbase/oauth';
|
|
284
|
+
export declare function registerAuth(app: Pick<ICloudbase, 'registerComponent'>): void;
|