@cloudbase/auth 3.2.1 → 3.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/auth",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "description": "cloudbase javascript sdk auth componets",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -32,14 +32,14 @@
32
32
  "license": "Apache-2.0",
33
33
  "dependencies": {
34
34
  "@cloudbase/adapter-wx_mp": "^1.3.1",
35
- "@cloudbase/oauth": "3.2.1",
36
- "@cloudbase/utilities": "3.2.1"
35
+ "@cloudbase/oauth": "3.3.0",
36
+ "@cloudbase/utilities": "3.3.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@cloudbase/types": "3.2.1",
39
+ "@cloudbase/types": "3.3.0",
40
40
  "@types/node": "^22.1.0",
41
41
  "terser-webpack-plugin": "^3.0.2",
42
42
  "webpack-bundle-analyzer": "^4.9.1"
43
43
  },
44
- "gitHead": "a8e7fc1e330db2b23c2e8e2f33abaffd6f1ee999"
44
+ "gitHead": "6a093765770ba0c11f052aab75f0361ea2cfe66a"
45
45
  }
package/src/index.ts CHANGED
@@ -641,7 +641,7 @@ class Auth extends AuthV1Compat {
641
641
  * @returns Promise<SignInWithOtpRes>
642
642
  */
643
643
  async signInWithOtp(params: SignInWithOtpReq): Promise<SignInWithOtpRes> {
644
- if (params.options?.shouldCreateUser === undefined || !!params.options?.shouldCreateUser) {
644
+ if (!params.options?.emailRedirectTo && (params.options?.shouldCreateUser === undefined || !!params.options?.shouldCreateUser)) {
645
645
  return this.signUp({
646
646
  email: params.email,
647
647
  phone: params.phone,
@@ -653,7 +653,10 @@ class Auth extends AuthV1Compat {
653
653
  this.validateAtLeastOne(params, [['email'], ['phone']], 'You must provide either an email or phone number')
654
654
 
655
655
  // 第一步:发送验证码并存储 verificationInfo
656
- const verificationInfo = await this.getVerification(params.email ? { email: params.email } : { phone_number: this.formatPhone(params.phone) },)
656
+ const verificationInfo = await this.getVerification({
657
+ email_redirect_to: params.options?.emailRedirectTo,
658
+ ...(params.email ? { email: params.email } : { phone_number: this.formatPhone(params.phone) }),
659
+ })
657
660
 
658
661
  return {
659
662
  data: {
package/src/type.ts CHANGED
@@ -291,6 +291,7 @@ export interface SignInWithOtpReq {
291
291
  phone?: string // 手机号(可选,与邮箱二选一)
292
292
  options?: {
293
293
  shouldCreateUser?: boolean // 如果用户不存在是否创建用户,默认为true
294
+ emailRedirectTo?: string // 邮箱登录回调地址,填写后则会发送认证链接至邮箱,否则发送验证码
294
295
  }
295
296
  }
296
297