@cloudbase/auth 2.25.11 → 2.26.1
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/dist/cjs/index.js +22 -9
- package/dist/cjs/type.d.ts +3 -0
- package/dist/cjs/type.js +1 -1
- package/dist/esm/index.js +22 -9
- package/dist/esm/type.d.ts +3 -0
- package/dist/esm/type.js +1 -1
- package/dist/miniprogram/index.js +1 -1
- package/package.json +5 -5
- package/src/index.ts +11 -0
- package/src/type.ts +3 -0
package/src/index.ts
CHANGED
|
@@ -473,6 +473,9 @@ class Auth {
|
|
|
473
473
|
params: authModels.GetVerificationRequest,
|
|
474
474
|
options?: { withCaptcha: boolean },
|
|
475
475
|
): Promise<authModels.GetVerificationResponse> {
|
|
476
|
+
if (params.phone_number) {
|
|
477
|
+
params.phone_number = this.formatPhone(params.phone_number)
|
|
478
|
+
}
|
|
476
479
|
return this.oauthInstance.authApi.getVerification(params, options)
|
|
477
480
|
}
|
|
478
481
|
|
|
@@ -1390,6 +1393,7 @@ class Auth {
|
|
|
1390
1393
|
*/
|
|
1391
1394
|
async signUp(params: authModels.SignUpRequest & { phone?: string }): Promise<SignUpRes> {
|
|
1392
1395
|
if (params.phone_number || params.verification_code || params.verification_token || params.provider_token) {
|
|
1396
|
+
params.phone_number = this.formatPhone(params.phone_number)
|
|
1393
1397
|
await this.oauthInstance.authApi.signUp(params)
|
|
1394
1398
|
return this.createLoginState() as any
|
|
1395
1399
|
}
|
|
@@ -1574,6 +1578,13 @@ class Auth {
|
|
|
1574
1578
|
* @returns Promise<SignInWithOtpRes>
|
|
1575
1579
|
*/
|
|
1576
1580
|
async signInWithOtp(params: SignInWithOtpReq): Promise<SignInWithOtpRes> {
|
|
1581
|
+
if (params.options?.shouldCreateUser === undefined || !!params.options?.shouldCreateUser) {
|
|
1582
|
+
return this.signUp({
|
|
1583
|
+
email: params.email,
|
|
1584
|
+
phone: params.phone,
|
|
1585
|
+
})
|
|
1586
|
+
}
|
|
1587
|
+
|
|
1577
1588
|
try {
|
|
1578
1589
|
// 参数校验:email或phone必填其一
|
|
1579
1590
|
this.validateAtLeastOne(params, [['email'], ['phone']], 'You must provide either an email or phone number')
|
package/src/type.ts
CHANGED