Skip to content

Commit 3de21d9

Browse files
author
CodeBuddy Attribution Bot
committed
fix(attribution): Skill 未引导正确处理环境ID的简写与完整形式 (issue_mnovxo2g_pc6qna)
1 parent be87755 commit 3de21d9

3 files changed

Lines changed: 16 additions & 15 deletions

File tree

config/source/skills/auth-tool/SKILL.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ Parameter mapping for downstream Web auth code:
135135
- `UserNameLogin` also enables the broader password-login surface exposed by `auth.signInWithPassword({ username|email|phone, password })`
136136
- `SmsVerificationConfig.Type = "apis"` requires both `Name` and `Method`
137137
- `EnvId` is always the CloudBase environment ID, not the publishable key
138+
- If the conversation only contains an environment alias, nickname, or other shorthand, resolve it to the canonical full `EnvId` first before generating auth config, SDK init examples, or console links
138139

139140
Internal behavior of `manageAppAuth(action="patchLoginStrategy")`:
140141

config/source/skills/auth-web/SKILL.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ Keep local `references/...` paths for files that ship with the current skill dir
5959

6060
**Use Case**: Web frontend projects using `@cloudbase/js-sdk@2.24.0+` for user authentication
6161
**Key Benefits**: Supabase-like Auth API shape, supports phone, email, anonymous, username/password, and third-party login methods
62-
**Official `@cloudbase/js-sdk` CDN**: `https://static.cloudbase.net/cloudbase-js-sdk/latest/cloudbase.full.js`
6362

64-
Use the same CDN address as `web-development`. Prefer npm installation in modern bundler projects, and use the CDN form for static HTML, no-build demos, or low-friction examples.
63+
Use npm installation for modern Web projects. In React, Vue, Vite, and other bundler-based apps, install and import `@cloudbase/js-sdk` from the project dependencies instead of using a CDN script.
6564

6665
## Prerequisites
6766

@@ -71,6 +70,7 @@ Use the same CDN address as `web-development`. Prefer npm installation in modern
7170
### Parameter map
7271

7372
- For username-style identifiers, the required precondition is `loginMethods.usernamePassword === true` from `queryAppAuth(action="getLoginConfig")`. If it is false, enable it with `manageAppAuth(action="patchLoginStrategy", patch={ usernamePassword: true })` before wiring frontend auth code.
73+
- If the conversation only provides an environment alias, nickname, or other shorthand, resolve it with `envQuery(action="list", alias=..., aliasExact=true)` first and use the returned canonical full `EnvId` for SDK init, console links, and generated config. Do not pass alias-like short forms directly into `cloudbase.init({ env })`.
7474
- Treat CloudBase Web Auth as **Supabase-like**, not “every `supabase-js` auth example is valid unchanged”
7575
- When `queryAppAuth` / `manageAppAuth` returns `sdkStyle: "supabase-like"` and `sdkHints`, follow those method and parameter hints first
7676
- `auth.signInWithOtp({ phone })` and `auth.signUp({ phone })` use the phone number in a `phone` field, not `phone_number`
@@ -85,10 +85,11 @@ Use the same CDN address as `web-development`. Prefer npm installation in modern
8585
## Quick Start
8686

8787
```js
88+
// npm install @cloudbase/js-sdk
8889
import cloudbase from '@cloudbase/js-sdk'
8990

9091
const app = cloudbase.init({
91-
env: `env`, // CloudBase environment ID
92+
env: `env-xxxxx`, // Canonical full CloudBase environment ID, not an alias or shorthand
9293
region: `region`, // CloudBase environment Region, default 'ap-shanghai'
9394
accessKey: 'publishable key', // required, get from auth-tool-cloudbase
9495
auth: { detectSessionInUrl: true }, // required
@@ -105,8 +106,9 @@ If the current task has not retrieved a real Publishable Key, omit `accessKey` i
105106

106107
**1. Phone OTP (Recommended)**
107108
- Automatically use `auth-tool-cloudbase` to turn on `SMS Login` through `manageAppAuth`
109+
- For phone registration, send the phone number to `auth.signUp({ phone, ... })` first, then call the returned `verifyOtp({ token })`. Do not swap the order.
108110
```js
109-
const { data, error } = await auth.signInWithOtp({ phone: '13800138000' })
111+
const { data, error } = await auth.signUp({ phone: '13800138000' })
110112
const { data: loginData, error: loginError } = await data.verifyOtp({ token:'123456' })
111113
```
112114

@@ -145,7 +147,7 @@ const emailVerifyResult = await emailSignUp.data.verifyOtp({ token: '123456' })
145147
// Phone Otp
146148
// Use only when the task explicitly requires phone numbers.
147149
// Phone Otp
148-
const phoneSignUp = await auth.signUp({ phone: '13800138000', nickname: 'User' })
150+
const phoneSignUp = await auth.signUp({ phone: '13800138000', password: 'pass123', nickname: 'User' })
149151
const phoneVerifyResult = await phoneSignUp.data.verifyOtp({ token: '123456' })
150152
```
151153

@@ -178,25 +180,21 @@ Do not use email OTP or email-only helpers for these flows unless the task expli
178180
const handleSendCode = async () => {
179181
try {
180182
const { data, error } = await auth.signUp({
181-
email,
182-
name: username || email.split('@')[0],
183+
phone,
184+
password: password || undefined,
183185
})
184186
if (error) throw error
185-
setSignUpData(data)
187+
verifyOtpRef.current = data.verifyOtp
186188
} catch (error) {
187189
console.error('Failed to send sign-up code', error)
188190
}
189191
}
190192

191193
const handleRegister = async () => {
192194
try {
193-
if (!signUpData?.verifyOtp) throw new Error('Please send the code first')
195+
if (!verifyOtpRef.current) throw new Error('Please send the code first')
194196

195-
const { error } = await signUpData.verifyOtp({
196-
email,
197-
token: code,
198-
type: 'signup',
199-
})
197+
const { error } = await verifyOtpRef.current({ token: code })
200198
if (error) throw error
201199
} catch (error) {
202200
console.error('Failed to complete sign-up', error)

config/source/skills/web-development/SKILL.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Use this section only when the Web project needs CloudBase platform features.
117117
- Use the CDN only for static HTML pages, quick demos, embedded snippets, or README examples
118118
- Only use documented CloudBase Web SDK APIs; do not invent methods or options
119119
- Keep a shared `app` or `auth` instance instead of re-initializing on every call
120+
- If the user only provides an environment alias, nickname, or other shorthand, resolve it to the canonical full `EnvId` before writing SDK init code, console links, or config files. Do not pass alias-like short forms directly into `cloudbase.init({ env })`.
120121

121122
### Authentication boundary
122123

@@ -134,10 +135,11 @@ Use this section only when the Web project needs CloudBase platform features.
134135
### CloudBase quick start
135136

136137
```js
138+
// npm install @cloudbase/js-sdk
137139
import cloudbase from "@cloudbase/js-sdk";
138140

139141
const app = cloudbase.init({
140-
env: "xxxx-yyy",
142+
env: "env-xxxxx", // Canonical full CloudBase environment ID
141143
});
142144

143145
const auth = app.auth();

0 commit comments

Comments
 (0)