@cloudbase/oauth 1.2.0-beta → 2.2.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.
Files changed (125) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc +26 -0
  3. package/CHANGELOG.md +30 -0
  4. package/Dockerfile +15 -0
  5. package/README.md +183 -0
  6. package/_exmaple/assets/scripts/function/function.ts +99 -0
  7. package/_exmaple/assets/scripts/index.ts +101 -0
  8. package/_exmaple/assets/scripts/request.ts +11 -0
  9. package/_exmaple/index.html +15 -0
  10. package/_exmaple/package.json +33 -0
  11. package/_exmaple/tsconfig.json +71 -0
  12. package/_exmaple/typings.d.ts +0 -0
  13. package/_exmaple/webpack.config.js +42 -0
  14. package/dist/cjs/auth/apis.d.ts +55 -0
  15. package/dist/cjs/auth/apis.js +568 -0
  16. package/{auth → dist/cjs/auth}/consts.d.ts +9 -21
  17. package/dist/cjs/auth/consts.js +61 -0
  18. package/dist/cjs/auth/models.d.ts +354 -0
  19. package/dist/cjs/auth/models.js +3 -0
  20. package/dist/cjs/captcha/captcha.d.ts +35 -0
  21. package/dist/cjs/captcha/captcha.js +267 -0
  22. package/dist/cjs/index.d.ts +14 -0
  23. package/dist/cjs/index.js +63 -0
  24. package/{oauthclient → dist/cjs/oauth2client}/consts.d.ts +22 -1
  25. package/dist/cjs/oauth2client/consts.js +73 -0
  26. package/dist/cjs/oauth2client/interface.d.ts +15 -0
  27. package/dist/cjs/oauth2client/interface.js +10 -0
  28. package/dist/cjs/oauth2client/models.d.ts +47 -0
  29. package/dist/cjs/oauth2client/models.js +3 -0
  30. package/dist/cjs/oauth2client/oauth2client.d.ts +71 -0
  31. package/dist/cjs/oauth2client/oauth2client.js +640 -0
  32. package/dist/cjs/utils/function/single-promise.d.ts +5 -0
  33. package/dist/cjs/utils/function/single-promise.js +89 -0
  34. package/dist/cjs/utils/uuid.d.ts +1 -0
  35. package/dist/cjs/utils/uuid.js +12 -0
  36. package/dist/esm/auth/apis.d.ts +55 -0
  37. package/dist/esm/auth/apis.js +566 -0
  38. package/dist/esm/auth/consts.d.ts +54 -0
  39. package/dist/esm/auth/consts.js +58 -0
  40. package/dist/esm/auth/models.d.ts +354 -0
  41. package/dist/esm/auth/models.js +1 -0
  42. package/dist/esm/captcha/captcha.d.ts +35 -0
  43. package/dist/esm/captcha/captcha.js +264 -0
  44. package/dist/esm/index.d.ts +14 -0
  45. package/dist/esm/index.js +32 -0
  46. package/dist/esm/oauth2client/consts.d.ts +67 -0
  47. package/dist/esm/oauth2client/consts.js +70 -0
  48. package/dist/esm/oauth2client/interface.d.ts +15 -0
  49. package/dist/esm/oauth2client/interface.js +7 -0
  50. package/dist/esm/oauth2client/models.d.ts +47 -0
  51. package/dist/esm/oauth2client/models.js +1 -0
  52. package/dist/esm/oauth2client/oauth2client.d.ts +71 -0
  53. package/dist/esm/oauth2client/oauth2client.js +636 -0
  54. package/dist/esm/utils/function/single-promise.d.ts +5 -0
  55. package/dist/esm/utils/function/single-promise.js +86 -0
  56. package/dist/esm/utils/uuid.d.ts +1 -0
  57. package/dist/esm/utils/uuid.js +8 -0
  58. package/package.json +27 -14
  59. package/publish.sh +2 -0
  60. package/src/auth/apis.ts +642 -0
  61. package/src/auth/consts.ts +57 -0
  62. package/src/auth/models.ts +444 -0
  63. package/src/captcha/captcha.ts +222 -0
  64. package/src/index.ts +49 -0
  65. package/src/oauth2client/consts.ts +69 -0
  66. package/src/oauth2client/interface.ts +57 -0
  67. package/src/oauth2client/models.ts +61 -0
  68. package/src/oauth2client/oauth2client.ts +620 -0
  69. package/src/utils/function/single-promise.ts +40 -0
  70. package/src/utils/uuid.ts +11 -0
  71. package/tsconfig.esm.json +44 -0
  72. package/tsconfig.json +44 -0
  73. package/wiki/README.md +75 -0
  74. package/app/index.d.ts +0 -29
  75. package/app/index.js +0 -50
  76. package/app/index.js.map +0 -1
  77. package/app/internal.d.ts +0 -12
  78. package/app/internal.js +0 -25
  79. package/app/internal.js.map +0 -1
  80. package/app/openuri.d.ts +0 -20
  81. package/app/openuri.js +0 -106
  82. package/app/openuri.js.map +0 -1
  83. package/app/request.d.ts +0 -19
  84. package/app/request.js +0 -52
  85. package/app/request.js.map +0 -1
  86. package/app/storage.d.ts +0 -41
  87. package/app/storage.js +0 -35
  88. package/app/storage.js.map +0 -1
  89. package/auth/consts.js +0 -79
  90. package/auth/consts.js.map +0 -1
  91. package/auth/index.d.ts +0 -242
  92. package/auth/index.js +0 -550
  93. package/auth/index.js.map +0 -1
  94. package/auth/models.d.ts +0 -284
  95. package/auth/models.js +0 -4
  96. package/auth/models.js.map +0 -1
  97. package/captcha/index.d.ts +0 -45
  98. package/captcha/index.js +0 -135
  99. package/captcha/index.js.map +0 -1
  100. package/function/index.d.ts +0 -38
  101. package/function/index.js +0 -80
  102. package/function/index.js.map +0 -1
  103. package/index.d.ts +0 -8
  104. package/index.js +0 -17
  105. package/index.js.map +0 -1
  106. package/oauthclient/consts.js +0 -53
  107. package/oauthclient/consts.js.map +0 -1
  108. package/oauthclient/index.d.ts +0 -18
  109. package/oauthclient/index.js +0 -21
  110. package/oauthclient/index.js.map +0 -1
  111. package/oauthclient/interface.d.ts +0 -29
  112. package/oauthclient/interface.js +0 -10
  113. package/oauthclient/interface.js.map +0 -1
  114. package/oauthclient/models.d.ts +0 -40
  115. package/oauthclient/models.js +0 -3
  116. package/oauthclient/models.js.map +0 -1
  117. package/oauthclient/oauthclient.d.ts +0 -146
  118. package/oauthclient/oauthclient.js +0 -414
  119. package/oauthclient/oauthclient.js.map +0 -1
  120. package/utils/promise.d.ts +0 -18
  121. package/utils/promise.js +0 -48
  122. package/utils/promise.js.map +0 -1
  123. package/utils/uuid.d.ts +0 -5
  124. package/utils/uuid.js +0 -16
  125. package/utils/uuid.js.map +0 -1
package/auth/index.d.ts DELETED
@@ -1,242 +0,0 @@
1
- import { UserProfile, SignInRequest, SignUpRequest, VerifyRequest, VerifyResponse, GenProviderRedirectUriRequest, GenProviderRedirectUriResponse, GrantProviderTokenRequest, GrantProviderTokenResponse, PatchProviderTokenRequest, PatchProviderTokenResponse, SignInWithProviderRequest, BindWithProviderRequest, TransByProviderRequest, GrantTokenRequest, UnbindProviderRequest, CheckPasswordRequest, SetPasswordRequest, ChangeBoundProviderRequest, ChangeBoundProviderResponse, QueryUserProfileRequest, UpdatePasswordRequest, SudoRequest, SudoResponse, QueryUserProfileResponse, EditContactRequest, CheckIfUserExistResponse, CheckIfUserExistRequest, SendVerificationCodeRequest, SendVerificationCodeResponse, ResetPasswordRequest, AuthorizeRequest, AuthorizeResponse, AuthorizeInfoRequest, AuthorizeInfoResponse, RevokeDeviceRequest, WithSudoRequest, AuthorizeDeviceRequest, DeviceAuthorizeRequest, DeviceAuthorizeResponse, ProvidersResponse } from './models';
2
- import { Credentials, AuthClient } from '../oauthclient';
3
- import { Captcha } from '../captcha';
4
- import { App, RequestFn as appRequestFn } from "../app";
5
- export { ErrorType, VerificationUsages, DeviceAuthorizeState } from './consts';
6
- export { ResponseError } from '../oauthclient';
7
- export interface AuthOptions {
8
- credentialsClient: AuthClient;
9
- captcha: Captcha;
10
- }
11
- /**
12
- * Returns the existing `Auth` instance that is associated with the app
13
- */
14
- export declare function getAuth(app: App, initOptions?: any): Auth;
15
- export declare type GetCustomSignTicketFn = () => Promise<string>;
16
- /**
17
- * Auth
18
- */
19
- export declare class Auth {
20
- readonly request: appRequestFn;
21
- readonly credentialsClient: AuthClient;
22
- private _getCustomSignTicketFn?;
23
- /**
24
- * constructor
25
- * @param {AuthOptions} opts
26
- */
27
- constructor(opts: AuthOptions);
28
- /**
29
- * Sign in.
30
- * @param {SignInRequest} params A SignInRequest Object.
31
- * @return {Promise<Credentials>} A Promise<Credentials> object.
32
- */
33
- signIn(params: SignInRequest): Promise<Credentials>;
34
- /**
35
- * Sign in Anonymously
36
- * @return {Promise<Credentials>} A Promise<Credentials> object.
37
- */
38
- signInAnonymously(): Promise<Credentials>;
39
- /**
40
- * Sign up.
41
- * @param {SignUpRequest} params A SignUpRequest Object.
42
- * @return {Promise<Credentials>} A Promise<Credentials> object.
43
- */
44
- signUp(params: SignUpRequest): Promise<Credentials>;
45
- /**
46
- * Sign out.
47
- * @return {Object} A Promise<void> object.
48
- */
49
- signOut(): Promise<void>;
50
- /**
51
- * Revoke All Devices
52
- * @return {Object} A Promise<void> object.
53
- */
54
- revokeAllDevices(): Promise<void>;
55
- /**
56
- * Revoke Device
57
- * @return {Object} A Promise<void> object.
58
- */
59
- revokeDevice(params: RevokeDeviceRequest): Promise<void>;
60
- /**
61
- * Send the VerificationCode.
62
- * @param {SendVerificationCodeRequest} params A GetVerificationRequest Object.
63
- * @return {Promise<SendVerificationCodeResponse>} A Promise<GetVerificationResponse> object.
64
- */
65
- sendVerificationCode(params: SendVerificationCodeRequest): Promise<SendVerificationCodeResponse>;
66
- /**
67
- * Verify the code
68
- * @param {VerifyRequest} params A VerifyRequest Object.
69
- * @return {Promise<VerifyResponse>} A Promise<VerifyResponse> object.
70
- */
71
- verify(params: VerifyRequest): Promise<VerifyResponse>;
72
- /**
73
- * Reset Password
74
- * @param params A ResetPasswordRequest Object
75
- */
76
- resetPassword(params: ResetPasswordRequest): Promise<void>;
77
- /**
78
- * Gen provider redirect uri.
79
- * @param {GenProviderRedirectUriRequest} params A GenProviderRedirectUriRequest object.
80
- * @return {Promise<GenProviderRedirectUriResponse>} A Promise<GenProviderRedirectUriResponse> object.
81
- */
82
- genProviderRedirectUri(params: GenProviderRedirectUriRequest): Promise<GenProviderRedirectUriResponse>;
83
- /**
84
- * Grant provider token.
85
- * @param {GrantProviderTokenRequest} params A GrantProviderTokenRequest object.
86
- * @return {Promise<GrantProviderTokenResponse>} A Promise<GrantProviderTokenResponse> object.
87
- */
88
- grantProviderToken(params: GrantProviderTokenRequest): Promise<GrantProviderTokenResponse>;
89
- /**
90
- * Grant provider token.
91
- * @param {PatchProviderTokenRequest} params A PatchProviderTokenRequest object.
92
- * @return {Promise<PatchProviderTokenResponse>} A Promise<PatchProviderTokenResponse> object.
93
- */
94
- patchProviderToken(params: PatchProviderTokenRequest): Promise<PatchProviderTokenResponse>;
95
- /**
96
- * Signin with provider request.
97
- * @param {SignInWithProviderRequest} params A SignInWithProviderRequest object.
98
- * @return {Promise<Credentials>} A Promise<Credentials> object.
99
- */
100
- signInWithProvider(params: SignInWithProviderRequest): Promise<Credentials>;
101
- /**
102
- * Bind with provider
103
- * @param {BindWithProviderRequest} params A BindWithProviderRequest object.
104
- * @return {Promise<void>} A Promise<void> object.
105
- */
106
- bindWithProvider(params: BindWithProviderRequest): Promise<void>;
107
- /**
108
- * Get the user profile.
109
- * @return {Promise<UserProfile>} A Promise<UserProfile> object.
110
- */
111
- getUserProfile(): Promise<UserProfile>;
112
- /**
113
- * Get the user profile.
114
- * @return {Promise<UserProfile>} A Promise<UserProfile> object.
115
- */
116
- updateUserProfile(params: UserProfile): Promise<UserProfile>;
117
- /**
118
- * hasLoginState check if has login state
119
- * @return {Promise<boolean>} A Promise<boolean> object.
120
- */
121
- hasLoginState(): Promise<boolean>;
122
- /**
123
- * loginScope return scope of current token
124
- * @return {Promise<string>} A Promise<string> object.
125
- */
126
- loginScope(): Promise<string>;
127
- /**
128
- * Trans by provider.
129
- * @param {TransByProviderRequest} params A TransByProviderRequest object.
130
- * @return {Promise<Credentials>} A Promise<Credentials> object.
131
- */
132
- transByProvider(params: TransByProviderRequest): Promise<Credentials>;
133
- /**
134
- * Grant token.
135
- * @param {GrantTokenRequest} params A GrantTokenRequest object.
136
- * @return {Promise<Credentials>} A Promise<Credentials> object.
137
- */
138
- grantToken(params: GrantTokenRequest): Promise<Credentials>;
139
- /**
140
- * Get the provide list.
141
- * @return {Promise<ProvidersResponse>} A Promise<UserProfileProviderList> object.
142
- */
143
- getProviders(): Promise<ProvidersResponse>;
144
- /**
145
- * check if username is exist
146
- * @param params CheckIfUserExistRequest
147
- */
148
- checkIfUserExist(params: CheckIfUserExistRequest): Promise<CheckIfUserExistResponse>;
149
- /**
150
- * unbind provider.
151
- * @param {UnbindProviderRequest} params
152
- * @return {Promise<void>}
153
- */
154
- unbindProvider(params: UnbindProviderRequest): Promise<void>;
155
- /**
156
- * check Password.
157
- * @param {CheckPasswordRequest} params
158
- * @return {Promise<void>}
159
- */
160
- checkPassword(params: CheckPasswordRequest): Promise<void>;
161
- /**
162
- * Edit Contact 修改 手机号 或 邮箱
163
- * @param {EditContactRequest} params
164
- * @return {Promise<void>}
165
- */
166
- editContact(params: EditContactRequest): Promise<void>;
167
- /**
168
- * Set Password.
169
- * @param {SetPasswordRequest} params
170
- * @return {Promise<void>}
171
- */
172
- setPassword(params: SetPasswordRequest): Promise<void>;
173
- /**
174
- * updatePasswordByOld 使用旧密码修改密码,如果已经绑定手机号,请先:sudo,再修改密码
175
- * @param {UpdatePasswordRequest} params
176
- * @return {Promise<void>}
177
- */
178
- updatePasswordByOld(params: UpdatePasswordRequest): Promise<void>;
179
- /**
180
- * sudo
181
- * @param {sudo} params
182
- * @return {Promise<SudoResponse>}
183
- */
184
- sudo(params: SudoRequest): Promise<SudoResponse>;
185
- /**
186
- * Get the current user verification.
187
- * @param {SendVerificationCodeRequest} params A SendVerificationCodeToCurrentUser Object.
188
- * @return {Promise<SendVerificationCodeResponse>} A Promise<SendVerificationCodeResponse> object.
189
- */
190
- SendVerificationCodeToCurrentUser(params: SendVerificationCodeRequest): Promise<SendVerificationCodeResponse>;
191
- /**
192
- * change Bound provider.
193
- * @param {ChangeBoundProviderRequest} params A GetVerificationRequest Object.
194
- * @return {Promise<ChangeBoundProviderResponse>} A Promise<GetVerificationResponse> object.
195
- */
196
- changeBoundProvider(params: ChangeBoundProviderRequest): Promise<ChangeBoundProviderResponse>;
197
- /**
198
- * set the user profile.
199
- * @param {UserProfile} params A UserProfile Object.
200
- * @return {Promise<UserProfile>} A Promise<UserProfile> object.
201
- */
202
- setUserProfile(params: UserProfile): Promise<UserProfile>;
203
- /**
204
- * Delete me
205
- * @param params
206
- */
207
- deleteMe(params: WithSudoRequest): Promise<UserProfile>;
208
- /**
209
- * setCustomSignFunc set the get ticket function
210
- * @param getTickFn
211
- */
212
- setCustomSignFunc(getTickFn: GetCustomSignTicketFn): void;
213
- /**
214
- * SignInWithCustomTicket custom signIn
215
- * @constructor
216
- */
217
- SignInWithCustomTicket(): Promise<Credentials>;
218
- /**
219
- * queryUserProfile query user profile
220
- * @param params queryUserProfile query user profile
221
- */
222
- queryUserProfile(params: QueryUserProfileRequest): Promise<QueryUserProfileResponse>;
223
- /**
224
- * Authorize oauth Authorize
225
- * @param params
226
- * @constructor
227
- */
228
- authorize(params: AuthorizeRequest): Promise<AuthorizeResponse>;
229
- /**
230
- * authorize device
231
- * @param params
232
- */
233
- authorizeDevice(params: AuthorizeDeviceRequest): Promise<void>;
234
- deviceAuthorize(params: DeviceAuthorizeRequest): Promise<DeviceAuthorizeResponse>;
235
- /**
236
- * OAuth get authorize info
237
- * @param params
238
- * @constructor
239
- */
240
- authorizeInfo(params: AuthorizeInfoRequest): Promise<AuthorizeInfoResponse>;
241
- private static parseParamsToSearch;
242
- }