@cloudbase/auth 2.23.3 → 2.24.0
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/SbaseApi.md +6383 -0
- package/dist/cjs/adapter.js +6 -3
- package/dist/cjs/index.d.ts +31 -28
- package/dist/cjs/index.js +124 -390
- package/dist/cjs/sbaseApi.d.ts +117 -0
- package/dist/cjs/sbaseApi.js +1515 -0
- package/dist/cjs/utils.d.ts +5 -0
- package/dist/cjs/utils.js +59 -0
- package/dist/esm/adapter.js +6 -3
- package/dist/esm/index.d.ts +31 -28
- package/dist/esm/index.js +121 -387
- package/dist/esm/sbaseApi.d.ts +117 -0
- package/dist/esm/sbaseApi.js +1511 -0
- package/dist/esm/utils.d.ts +5 -0
- package/dist/esm/utils.js +51 -0
- package/dist/miniprogram/index.js +1 -1
- package/package.json +5 -5
- package/src/adapter.ts +6 -2
- package/src/index.ts +306 -285
- package/src/sbaseApi.ts +1495 -0
- package/src/type.d.ts +303 -0
- package/src/utils.ts +69 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { ICloudbaseAuthConfig } from '@cloudbase/types/auth';
|
|
2
|
+
import type { authModels, CloudbaseOAuth } from '@cloudbase/oauth';
|
|
3
|
+
import type { ICloudbaseCache } from '@cloudbase/types/cache';
|
|
4
|
+
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, VerifyOtpReq } from './type';
|
|
5
|
+
import { LoginState, User } from '.';
|
|
6
|
+
export declare const isBrowser: () => boolean;
|
|
7
|
+
export declare class SbaseApi {
|
|
8
|
+
readonly config: ICloudbaseAuthConfig;
|
|
9
|
+
oauthInstance: CloudbaseOAuth;
|
|
10
|
+
readonly cache: ICloudbaseCache;
|
|
11
|
+
private listeners;
|
|
12
|
+
private hasListenerSetUp;
|
|
13
|
+
constructor(config: ICloudbaseAuthConfig & {
|
|
14
|
+
cache: ICloudbaseCache;
|
|
15
|
+
});
|
|
16
|
+
get currentUser(): User;
|
|
17
|
+
hasLoginState(): LoginState | null;
|
|
18
|
+
setAccessKey(): Promise<void>;
|
|
19
|
+
signIn(_params: authModels.SignInRequest): Promise<LoginState>;
|
|
20
|
+
signInWithProvider(_params: authModels.SignInWithProviderRequest): Promise<LoginState>;
|
|
21
|
+
genProviderRedirectUri(_params: authModels.GenProviderRedirectUriRequest): Promise<authModels.GenProviderRedirectUriResponse>;
|
|
22
|
+
getAccessToken(): Promise<{
|
|
23
|
+
accessToken: any;
|
|
24
|
+
env: string;
|
|
25
|
+
}>;
|
|
26
|
+
getUserInfo(): Promise<(authModels.UserInfo & Partial<User>) | null>;
|
|
27
|
+
updateUserBasicInfo(_params: authModels.ModifyUserBasicInfoRequest): Promise<void>;
|
|
28
|
+
setCustomSignFunc(_getTickFn: authModels.GetCustomSignTicketFn): void;
|
|
29
|
+
grantProviderToken(_params: authModels.GrantProviderTokenRequest): Promise<authModels.GrantProviderTokenResponse>;
|
|
30
|
+
bindWithProvider(_params: authModels.BindWithProviderRequest): Promise<void>;
|
|
31
|
+
signInWithUsername(_params: {
|
|
32
|
+
verificationInfo?: {
|
|
33
|
+
verification_id: string;
|
|
34
|
+
is_user: boolean;
|
|
35
|
+
};
|
|
36
|
+
verificationCode?: string;
|
|
37
|
+
username?: string;
|
|
38
|
+
bindInfo?: any;
|
|
39
|
+
loginType?: string;
|
|
40
|
+
autoSignUp?: boolean;
|
|
41
|
+
}): Promise<LoginState>;
|
|
42
|
+
getVerification(_params: authModels.GetVerificationRequest, _options?: {
|
|
43
|
+
withCaptcha: boolean;
|
|
44
|
+
}): Promise<authModels.GetVerificationResponse>;
|
|
45
|
+
createLoginState(_params?: {
|
|
46
|
+
version?: string;
|
|
47
|
+
query?: any;
|
|
48
|
+
}, _options?: {
|
|
49
|
+
asyncRefreshUser?: boolean;
|
|
50
|
+
}): Promise<LoginState>;
|
|
51
|
+
verify(_params: authModels.VerifyRequest): Promise<authModels.VerifyResponse>;
|
|
52
|
+
signInAnonymously(params: SignInAnonymouslyReq): Promise<SignInRes>;
|
|
53
|
+
signUp(params: authModels.SignUpRequest): Promise<SignUpRes>;
|
|
54
|
+
signOut(params?: authModels.SignoutRequest): Promise<void | authModels.SignoutReponse>;
|
|
55
|
+
onAuthStateChange(callback: OnAuthStateChangeCallback): {
|
|
56
|
+
data: {
|
|
57
|
+
subscription: {
|
|
58
|
+
id: string;
|
|
59
|
+
callback: OnAuthStateChangeCallback;
|
|
60
|
+
unsubscribe: () => void;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
signInWithPassword(params: SignInWithPasswordReq): Promise<SignInRes>;
|
|
65
|
+
signInWithIdToken(params: SignInWithIdTokenReq): Promise<SignInRes>;
|
|
66
|
+
signInWithOtp(params: SignInWithOtpReq): Promise<SignInWithOtpRes>;
|
|
67
|
+
verifyOAuth(params?: VerifyOAuthReq): Promise<SignInRes | LinkIdentityRes>;
|
|
68
|
+
signInWithOAuth(params: SignInWithOAuthReq): Promise<SignInOAuthRes>;
|
|
69
|
+
signInWithSSO(): Promise<void>;
|
|
70
|
+
signInWithWeb3(): Promise<void>;
|
|
71
|
+
getClaims(): Promise<GetClaimsRes>;
|
|
72
|
+
resetPasswordForEmail(emailOrPhone: string, options?: {
|
|
73
|
+
redirectTo?: string;
|
|
74
|
+
}): Promise<ResetPasswordForEmailRes>;
|
|
75
|
+
resetPasswordForOld(params: ResetPasswordForOldReq): Promise<{
|
|
76
|
+
data: {
|
|
77
|
+
user: import("./type").User;
|
|
78
|
+
session: import("./type").Session;
|
|
79
|
+
};
|
|
80
|
+
error: any;
|
|
81
|
+
} | {
|
|
82
|
+
data: {
|
|
83
|
+
user?: undefined;
|
|
84
|
+
session?: undefined;
|
|
85
|
+
};
|
|
86
|
+
error: any;
|
|
87
|
+
}>;
|
|
88
|
+
verifyOtp(params: VerifyOtpReq): Promise<SignInRes>;
|
|
89
|
+
getSession(): Promise<SignInRes>;
|
|
90
|
+
refreshSession(refresh_token?: string): Promise<SignInRes>;
|
|
91
|
+
getUser(): Promise<GetUserRes>;
|
|
92
|
+
refreshUser(): Promise<CommonRes>;
|
|
93
|
+
updateUser(params: UpdateUserReq): Promise<GetUserRes | UpdateUserWithVerificationRes>;
|
|
94
|
+
getUserIdentities(): Promise<GetUserIdentitiesRes>;
|
|
95
|
+
linkIdentity(params: LinkIdentityReq): Promise<LinkIdentityRes>;
|
|
96
|
+
unlinkIdentity(params: UnlinkIdentityReq): Promise<CommonRes>;
|
|
97
|
+
reauthenticate(): Promise<ReauthenticateRes>;
|
|
98
|
+
resend(params: ResendReq): Promise<ResendRes>;
|
|
99
|
+
setSession(params: SetSessionReq): Promise<SignInRes>;
|
|
100
|
+
exchangeCodeForSession(): Promise<void>;
|
|
101
|
+
deleteUser(params: DeleteMeReq): Promise<CommonRes>;
|
|
102
|
+
toDefaultLoginPage(params?: authModels.ToDefaultLoginPage): Promise<CommonRes>;
|
|
103
|
+
signInWithCustomTicket(getTickFn?: authModels.GetCustomSignTicketFn): Promise<SignInRes>;
|
|
104
|
+
signInWithOpenId({ useWxCloud }?: {
|
|
105
|
+
useWxCloud?: boolean;
|
|
106
|
+
}): Promise<SignInRes>;
|
|
107
|
+
signInWithPhoneAuth({ phoneCode }: {
|
|
108
|
+
phoneCode?: string;
|
|
109
|
+
}): Promise<SignInRes>;
|
|
110
|
+
private formatPhone;
|
|
111
|
+
private notifyListeners;
|
|
112
|
+
private init;
|
|
113
|
+
private setupListeners;
|
|
114
|
+
private convertToUser;
|
|
115
|
+
private validateParams;
|
|
116
|
+
private validateAtLeastOne;
|
|
117
|
+
}
|