跳到内容
CADCAMFUN
文档

文档

验证

帐户登录、注册、恢复、验证、魔术链接、会话查找和密钥注册。

从英文自动翻译。 查看英文原文

调试台

将这些请求发送到您自己正在运行的 sidecar。值保留在此浏览器中。

未连接
这是如何运作的

sidecar 侦听启动时选择的环回端口并将其打印在其中 ready 线;使用该 URL 和 CADCAMFUN_TOKEN 它是从开始的。请求直接从该页面发送到该地址。

sidecar 仅将 CORS 标头发送到 Tauri 源并发送到 http://localhost 或 http://127.0.0.1 在任何端口上。浏览器会阻止托管文档的响应,因此请在本地运行文档(bun run dev 中 packages/web) 使用游乐场,或将请求复制为curl。要在不接触真实数据的情况下进行实验,请使用以下命令启动 sidecar CADCAMFUN_DATA_DIR 指向一个一次性目录 - 请参阅 aPI 演练.

运营

15 个端点,位于 auth 组,由 sidecar 自己生成 开放API文档。受保护的操作需要 Authorization: Bearer $CADCAMFUN_TOKEN;看 验证。行为和限制在 子系统指南.

邮政 /api/auth/identity/start auth.identityStart
邮政 /api/auth/identity/poll auth.identityPoll
邮政 /api/auth/identity/cancel auth.identityCancel
邮政 /api/auth/forgot-password auth.forgotPassword
邮政 /api/auth/reset-password auth.resetPassword
邮政 /api/auth/send-magic-link auth.sendMagicLink
邮政 /api/auth/send-verification-email auth.sendVerificationEmail
邮政 /api/auth/verify-email auth.verifyEmail
邮政 /api/auth/signout auth.signout
得到 /api/auth/get-session auth.getSession
邮政 /api/auth/signin-direct auth.signinDirect
邮政 /api/auth/signup auth.signup
邮政 /api/auth/test-direct-create auth.testDirectCreate
邮政 /api/auth/verify-magic-link auth.verifyMagicLink
邮政 /api/auth/passkey-register auth.registerPasskey
3D 中的身份验证操作 拖动进行轨道旋转·滚动进行缩放·右键拖动进行平移
每个操作一个块 (15),按此页面的每个资源部分堆叠,并按方法着色:绿色 GET、橙色 POST、蓝色 PUT、紫色 PATCH、红色 DELETE。在构建时从 OpenAPI 文档生成。

/api/auth/identity

邮政 /api/auth/identity/start # auth.identityStart

需要 Authorization: Bearer <token>.

回应
200 目的 application/json
{
  id: string
  url: string
  issuer: string
}
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
获取示例
auth.identityStart
// Not generated in the Promise SDK (multipart, binary or raw body): call it with fetch.
const response = await fetch(`${process.env.CADCAMFUN_URL}/api/auth/identity/start`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
curl
POST /api/auth/identity/start
curl --request POST "${CADCAMFUN_URL}/api/auth/identity/start" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}"
尝试一下
邮政 /api/auth/identity/poll # auth.identityPoll

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  id: string
}
回应
200 对象|对象|目的 application/json
{
  status: "pending"
} | {
  status: "complete"
  tokens: {
    access: string
    refresh: string
    expiresAt: number | "Infinity" | "-Infinity" | "NaN"
  }
} | {
  status: "failed"
  message: string
}
400 AuthBadRequestEncoded application/json
AuthBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
获取示例
auth.identityPoll
// Not generated in the Promise SDK (multipart, binary or raw body): call it with fetch.
const response = await fetch(`${process.env.CADCAMFUN_URL}/api/auth/identity/poll`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
curl
POST /api/auth/identity/poll
curl --request POST "${CADCAMFUN_URL}/api/auth/identity/poll" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下
邮政 /api/auth/identity/cancel # auth.identityCancel

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  id: string
}
回应
200 目的 application/json
{
  success: true
  message: string
}
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
获取示例
auth.identityCancel
// Not generated in the Promise SDK (multipart, binary or raw body): call it with fetch.
const response = await fetch(`${process.env.CADCAMFUN_URL}/api/auth/identity/cancel`, {
  method: "POST",
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
curl
POST /api/auth/身份/取消
curl --request POST "${CADCAMFUN_URL}/api/auth/identity/cancel" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下

/api/auth/forgot-password

邮政 /api/auth/forgot-password # auth.forgotPassword

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  email?: string | null
  callbackURL?: string | null
}
回应
200 目的 application/json
{
  success: true
  message: string
  debugResetLink?: string | null
}
400 AuthBadRequestEncoded application/json
AuthBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
SDK示例
auth.forgotPassword
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// AuthForgotPasswordInput
const result = await client.auth.forgotPassword({
  email: "",
  callbackURL: ""
})
curl
POST /api/auth/忘记密码
curl --request POST "${CADCAMFUN_URL}/api/auth/forgot-password" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下

/api/auth/reset-password

邮政 /api/auth/reset-password # auth.resetPassword

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  token?: string | null
  newPassword?: string | null
  confirmPassword?: string | null
}
回应
200 目的 application/json
{
  success: true
  message: string
  user: {
    id: string
    email: string
    name: string | null
  }
}
400 AuthBadRequestEncoded application/json
AuthBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 AuthNotFoundEncoded application/json
AuthNotFoundEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
SDK示例
auth.resetPassword
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// AuthResetPasswordInput
const result = await client.auth.resetPassword({
  token: "",
  newPassword: "",
  confirmPassword: ""
})
curl
POST /api/auth/重置密码
curl --request POST "${CADCAMFUN_URL}/api/auth/reset-password" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下

/api/auth/send-verification-email

邮政 /api/auth/send-verification-email # auth.sendVerificationEmail

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  email?: string | null
  callbackURL?: string | null
}
回应
200 目的 application/json
{
  success: true
  message: string
  debug: {
    link: string
  }
}
400 AuthBadRequestEncoded application/json
AuthBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 AuthNotFoundEncoded application/json
AuthNotFoundEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
SDK示例
auth.sendVerificationEmail
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// AuthSendVerificationEmailInput
const result = await client.auth.sendVerificationEmail({
  email: "",
  callbackURL: ""
})
curl
POST /api/auth/发送验证电子邮件
curl --request POST "${CADCAMFUN_URL}/api/auth/send-verification-email" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下

/api/auth/verify-email

邮政 /api/auth/verify-email # auth.verifyEmail

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  token?: string | null
}
回应
200 目的 application/json
{
  success: true
  message: string
  user: {
    id: string
    email: string
    name: string | null
    emailVerified: string
  }
}
400 AuthBadRequestEncoded application/json
AuthBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 AuthNotFoundEncoded application/json
AuthNotFoundEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
SDK示例
auth.verifyEmail
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// AuthVerifyEmailInput
const result = await client.auth.verifyEmail({
  token: ""
})
curl
POST /api/auth/验证电子邮件
curl --request POST "${CADCAMFUN_URL}/api/auth/verify-email" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下

/api/auth/signout

邮政 /api/auth/signout # auth.signout

需要 Authorization: Bearer <token>.

回应
200 目的 application/json
{
  success: true
  message: string
}
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
SDK示例
auth.signout
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// no input
const result = await client.auth.signout()
curl
POST /api/auth/signout
curl --request POST "${CADCAMFUN_URL}/api/auth/signout" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}"
尝试一下

/api/auth/get-session

得到 /api/auth/get-session # auth.getSession

需要 Authorization: Bearer <token>.

回应
200 目的 application/json
{
  session: {
    user: {
      id: string
      email: string | null
      name: string | null
      emailVerified: string | null
      createdAt: string
      updatedAt: string
    }
    expires: string
    sessionToken?: string | null
  }
}
401 AuthUnauthorizedEncoded | AuthUnauthorizedEncoded |未经授权的编码 application/json
AuthUnauthorizedEncoded | UnauthorizedEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
响应示例 捕获·200
获取 /api/auth/get-session
{
  "session": {
    "user": {
      "id": "c942817d-0162-4291-84ff-77321d387acc",
      "email": "local@cadcamfun.local",
      "name": "Local user",
      "emailVerified": null,
      "createdAt": "2026-10-15T04:52:06.538Z",
      "updatedAt": "2026-10-15T04:52:06.538Z"
    },
    "expires": "2026-10-22T04:52:23.311Z"
  }
}
SDK示例
auth.getSession
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// no input
const result = await client.auth.getSession()
curl
获取 /api/auth/get-session
curl --request GET "${CADCAMFUN_URL}/api/auth/get-session" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}"
尝试一下

/api/auth/signin-direct

邮政 /api/auth/signin-direct # auth.signinDirect

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  email?: string | null
  password?: string | null
}
回应
200 目的 application/json
{
  success: true
  message: string
  user: {
    id: string
    email: string | null
    name: string | null
    emailVerified: string | null
    createdAt: string
  }
  token: string
}
400 AuthBadRequestEncoded application/json
AuthBadRequestEncoded
401 AuthUnauthorizedEncoded | AuthUnauthorizedEncoded |未经授权的编码 application/json
AuthUnauthorizedEncoded | UnauthorizedEncoded
404 AuthNotFoundEncoded application/json
AuthNotFoundEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
SDK示例
auth.signinDirect
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// AuthSigninDirectInput
const result = await client.auth.signinDirect({
  email: "",
  password: ""
})
curl
POST /api/auth/signin-direct
curl --request POST "${CADCAMFUN_URL}/api/auth/signin-direct" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下

/api/auth/signup

邮政 /api/auth/signup # auth.signup

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  email?: string | null
  password?: string | null
  confirmPassword?: string | null
  name?: string | null
}
回应
201 目的 application/json
{
  success: true
  message: string
  user: {
    id: string
    email: string | null
    name: string | null
    emailVerified: string | null
    createdAt: string
  }
}
400 AuthBadRequestEncoded application/json
AuthBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
SDK示例
auth.signup
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// AuthSignupInput
const result = await client.auth.signup({
  email: "",
  password: "",
  confirmPassword: "",
  name: ""
})
curl
POST /api/auth/注册
curl --request POST "${CADCAMFUN_URL}/api/auth/signup" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下

/api/auth/test-direct-create

邮政 /api/auth/test-direct-create # auth.testDirectCreate

需要 Authorization: Bearer <token>.

请求正文 · 必填 · application/json
{
  email?: string | null
  password?: string | null
  name?: string | null
}
回应
201 目的 application/json
{
  success: true
  message: string
  user: {
    id: string
    email: string | null
    name: string | null
    emailVerified: string | null
    createdAt: string
  }
}
400 TestCreateBadRequestEncoded application/json
TestCreateBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 TestCreateFailureEncoded application/json
TestCreateFailureEncoded
SDK示例
auth.testDirectCreate
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// AuthTestDirectCreateInput
const result = await client.auth.testDirectCreate({
  email: "",
  password: "",
  name: ""
})
curl
POST /api/auth/test-direct-create
curl --request POST "${CADCAMFUN_URL}/api/auth/test-direct-create" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
  --header "Content-Type: application/json" \
  --data-binary @request.json
尝试一下

/api/auth/passkey-register

邮政 /api/auth/passkey-register # auth.registerPasskey

需要 Authorization: Bearer <token>.

回应
200 任何 JSON 值 application/json
unknown
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
501 PasskeyNotImplementedEncoded application/json
PasskeyNotImplementedEncoded
SDK示例
auth.registerPasskey
import { CadCam } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

// no input
const result = await client.auth.registerPasskey()
curl
POST /api/auth/passkey-register
curl --request POST "${CADCAMFUN_URL}/api/auth/passkey-register" \
  --header "Authorization: Bearer ${CADCAMFUN_TOKEN}"
尝试一下

模式

可从该组的参数、主体和响应访问命名模式。一个 ? 标记可选字段; | null 标记可能存在空值的字段。

AuthBadRequestEncoded
{
  _tag: "AuthBadRequest"
  error: string
  details: string
}
AuthInternalEncoded
{
  _tag: "AuthInternal"
  error: string
  details: string
}
AuthNotFoundEncoded
{
  _tag: "AuthNotFound"
  error: string
  details: string
}
AuthUnauthorizedEncoded
{
  _tag: "AuthUnauthorized"
  error: string
  details: string
}
PasskeyNotImplementedEncoded
{
  _tag: "PasskeyNotImplemented"
  error: string
  details: string
  todoImplementation: {
    webauthn: string
    challengeGeneration: string
    credentialStorage: string
    userVerification: string
  }
}
TestCreateBadRequestEncoded
{
  _tag: "TestCreateBadRequest"
  error: string
}
TestCreateFailureEncoded
{
  _tag: "TestCreateFailure"
  error: string
  message: string
}
UnauthorizedEncoded
{
  _tag: "Unauthorized"
  message: string
}

呼叫该群组

操作 ID 的形式为 auth.<name>。生成的Promise SDK(@cadcamfun/api/sdk)将其中大部分暴露为 client.<namespace>.<method>(input), 在哪里 input 是路径参数和主体字段的一个平面对象;每张卡的 SDK 示例显示了确切的访问器和输入类型。不会生成分段上传、二进制或 JavaScript 响应以及原始 Webhook;这些卡片显示 fetch 改为。

Promise SDK 的错误
import { CadCam, ClientError } from "@cadcamfun/api/sdk"

const client = CadCam.make({
  baseUrl: process.env.CADCAMFUN_URL!,
  headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})

try {
  await client.projects.list()
} catch (error) {
  if (error instanceof ClientError) {
    // Transport | UnexpectedStatus | UnsupportedContentType | MalformedResponse | SseEventTooLarge
  } else {
    // a declared error body: switch on error._tag
  }
}

故障排除

症状可能的原因使固定
每次调用 401上次启动的令牌或丢失 Bearer 前缀发送 Authorization: Bearer <token> 使用边车启动时的令牌。
在任何事情发生之前的 400主体或参数与架构不匹配将有效负载与卡上的请求架构进行比较。
在别处可见的记录上出现 403 或 404代理账户不同发送正确的 x-session-token,或使用拥有该记录的本地配置文件。
409状态冲突,例如重复的名称或过时的分支头重新读取资源并使用当前数据重试。
尝试显示“被 CORS 阻止”这些文档是从非环回源提供的在本地运行文档或将请求复制为curl。
连接被拒绝Sidecar 在新端口上重新启动从新读取端口 ready 行。