Skip to content

Commit 2a3894c

Browse files
committed
feat(scripts): 🔧 convert fix-config-hardlinks to mjs and add skills sync
- Convert fix-config-hardlinks.sh to Node.js implementation (fix-config-hardlinks.mjs) - Add skills directory sync from config/.claude/skills to config/.codebuddy/skills - Add SKILL.md files sync to config/rules/{skill-name}.md - Maintain all existing hard link functionality for Rules and MCP configs - Use ES modules with proper color escape sequences for strict mode compatibility
1 parent 0b18424 commit 2a3894c

File tree

12 files changed

+3178
-0
lines changed

12 files changed

+3178
-0
lines changed

config/.claude/skills/no-sql-skill/SKILL.md

Whitespace-only changes.
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
---
2+
name: auth-http-api-cloudbase
3+
description: Use when you need to implement CloudBase Auth v2 over raw HTTP endpoints (login/signup, tokens, user operations) from backends or scripts that are not using the Web or Node SDKs.
4+
alwaysApply: false
5+
---
6+
7+
## When to use this skill
8+
9+
Use this skill whenever you need to call **CloudBase Auth** via **raw HTTP APIs**, for example:
10+
11+
- Non-Node backends (Go, Python, Java, PHP, etc.)
12+
- Integration tests or admin scripts that use curl or language HTTP clients
13+
- Gateways or proxies that sit in front of CloudBase and manage tokens themselves
14+
15+
Do **not** use this skill for:
16+
17+
- Frontend Web login with `@cloudbase/js-sdk@2.x` (use **CloudBase Web Auth** skill)
18+
- Node.js code that uses `@cloudbase/node-sdk` (use **CloudBase Node Auth** skill)
19+
- Non-auth CloudBase features (database, storage, etc.)
20+
21+
## How to use this skill (for a coding agent)
22+
23+
1. **Clarify the scenario**
24+
- Confirm this code will call HTTP endpoints directly (not SDKs).
25+
- Ask for:
26+
- `env` – CloudBase environment ID
27+
- `clientId` / `clientSecret` – HTTP auth client credentials
28+
- Confirm whether the flow is login/sign-up, anonymous access, token management, or user operations.
29+
30+
2. **Set common variables once**
31+
- Use a shared set of shell variables for base URL and headers, then reuse them across scenarios.
32+
33+
3. **Pick a scenario from this file**
34+
- For login / sign-up, start with Scenarios 1–3.
35+
- For token lifecycle, use Scenarios 4–6.
36+
- For user info and profile changes, use Scenario 7.
37+
38+
4. **Never invent endpoints or fields**
39+
- Treat the URLs and JSON shapes in this file as canonical.
40+
- If you are unsure, consult the HTTP API docs under `/source-of-truth/auth/http-api/登录认证接口.info.mdx` and the specific `*.api.mdx` files.
41+
42+
## HTTP API basics
43+
44+
- **Base URL pattern**
45+
46+
- `https://${env}.ap-shanghai.tcb-api.tencentcloudapi.com/auth/v1/...`
47+
48+
- **Common headers**
49+
50+
- `x-device-id` – device or client identifier
51+
- `x-request-id` – unique request ID for tracing
52+
- `Authorization``Bearer <access_token>` for user endpoints
53+
- Or HTTP basic auth (`-u clientId:clientSecret`) for client-credential style endpoints
54+
55+
- **Reusable shell variables**
56+
57+
```bash
58+
env="your-env-id"
59+
deviceID="backend-service-1"
60+
requestID="$(uuidgen || echo manual-request-id)"
61+
clientId="your-client-id"
62+
clientSecret="your-client-secret"
63+
base="https://${env}.ap-shanghai.tcb-api.tencentcloudapi.com/auth/v1"
64+
```
65+
66+
## Core concepts (HTTP perspective)
67+
68+
- CloudBase Auth uses **JWT access tokens** plus **refresh tokens**.
69+
- HTTP login/sign-up endpoints usually return both `access_token` and `refresh_token`.
70+
- Most user-management endpoints require `Authorization: Bearer ${accessToken}`.
71+
- Verification flows (SMS/email) use separate `verification` endpoints before sign-up.
72+
73+
## Scenarios (flat list)
74+
75+
### Scenario 1: Sign-in with username/password
76+
77+
```bash
78+
curl "${base}/signin" \
79+
-X POST \
80+
-H "x-device-id: ${deviceID}" \
81+
-H "x-request-id: ${requestID}" \
82+
-u "${clientId}:${clientSecret}" \
83+
--data-raw '{"username":"test@example.com","password":"your password"}'
84+
```
85+
86+
- Use when the user already has a username (phone/email/username) and password.
87+
- Response includes `access_token`, `refresh_token`, and user info.
88+
89+
### Scenario 2: SMS sign-up with verification code
90+
91+
1. **Send verification code**
92+
93+
```bash
94+
curl "${base}/verification" \
95+
-X POST \
96+
-H "x-device-id: ${deviceID}" \
97+
-H "x-request-id: ${requestID}" \
98+
-u "${clientId}:${clientSecret}" \
99+
--data-raw '{"phone_number":"+86 13800000000"}'
100+
```
101+
102+
2. **Verify code**
103+
104+
```bash
105+
curl "${base}/verification/verify" \
106+
-X POST \
107+
-H "x-device-id: ${deviceID}" \
108+
-H "x-request-id: ${requestID}" \
109+
-u "${clientId}:${clientSecret}" \
110+
--data-raw '{"verification_code":"000000","verification_id":"<from previous step>"}'
111+
```
112+
113+
3. **Sign up**
114+
115+
```bash
116+
curl "${base}/signup" \
117+
-X POST \
118+
-H "x-device-id: ${deviceID}" \
119+
-H "x-request-id: ${requestID}" \
120+
-u "${clientId}:${clientSecret}" \
121+
--data-raw '{
122+
"phone_number":"+86 13800000000",
123+
"verification_code":"000000",
124+
"verification_token":"<from verify>",
125+
"name":"手机用户",
126+
"password":"password",
127+
"username":"username"
128+
}'
129+
```
130+
131+
- Use this pattern for SMS or email-based registration; adapt fields per docs.
132+
133+
### Scenario 3: Anonymous login
134+
135+
```bash
136+
curl "${base}/signin-anonymously" \
137+
-X POST \
138+
-H "x-device-id: ${deviceID}" \
139+
-H "x-request-id: ${requestID}" \
140+
-u "${clientId}:${clientSecret}" \
141+
--data-raw '{}'
142+
```
143+
144+
- Returns tokens for an **anonymous user** that you can later upgrade via sign-up.
145+
146+
### Scenario 4: Exchange refresh token for new access token
147+
148+
```bash
149+
curl "${base}/token" \
150+
-X POST \
151+
-H "x-device-id: ${deviceID}" \
152+
-H "x-request-id: ${requestID}" \
153+
-u "${clientId}:${clientSecret}" \
154+
--data-raw '{"grant_type":"refresh_token","refresh_token":"<refresh_token>"}'
155+
```
156+
157+
- Use when the frontend or another service sends you a refresh token and you need a fresh access token.
158+
159+
### Scenario 5: Introspect and validate a token
160+
161+
```bash
162+
curl "${base}/token/introspect?token=${accessToken}" \
163+
-H "x-request-id: ${requestID}" \
164+
-u "${clientId}:${clientSecret}"
165+
```
166+
167+
- Use for backend validation of tokens before trusting them.
168+
- Response indicates whether the token is active and may include claims.
169+
170+
### Scenario 6: Revoke a token (logout)
171+
172+
```bash
173+
curl "${base}/revoke" \
174+
-X POST \
175+
-H "x-request-id: ${requestID}" \
176+
-u "${clientId}:${clientSecret}" \
177+
--data-raw '{"token":"${accessToken}"}'
178+
```
179+
180+
- Call when logging a user out from the backend or on security events.
181+
182+
### Scenario 7: Basic user operations (me, update password, delete)
183+
184+
```bash
185+
# Get current user
186+
curl "${base}/user/me" \
187+
-H "Authorization: Bearer ${accessToken}"
188+
189+
# Change password
190+
curl "${base}/user/password" \
191+
-X PATCH \
192+
-H "Authorization: Bearer ${accessToken}" \
193+
--data-raw '{"old_password":"old","new_password":"new"}'
194+
```
195+
196+
- Other endpoints:
197+
- `DELETE ${base}/user/me` – delete current user.
198+
- `${base}/user/providers` plus bind/unbind APIs – manage third-party accounts.
199+
- Always secure these operations and log only minimal necessary data.

0 commit comments

Comments
 (0)