Документация
Аутентификация
Вход в учетную запись, регистрация, восстановление, проверка, магические ссылки, поиск сеанса и регистрация пароля.
Автоматически переведено с английского. Смотреть оригинал на английском
Отправьте эти запросы на свою работающую сайдкар. Значения остаются в этом браузере.
Как это работает
Сайдкар прослушивает порт обратной связи, выбранный при запуске, и печатает его в своем ready линия; используйте этот URL-адрес и CADCAMFUN_TOKEN с этого началось. Запросы идут прямо с этой страницы на этот адрес.
Sidecar отправляет заголовки CORS только источникам Tauri и http://localhost или http://127.0.0.1 в любом порту. Из размещенных документов браузер блокирует ответ, поэтому запускайте документы локально (bun run dev в packages/web), чтобы использовать игровую площадку, или скопируйте запрос как завиток. Чтобы поэкспериментировать, не затрагивая реальные данные, запустите сайдкар с помощью CADCAMFUN_DATA_DIR указал на одноразовый каталог — см. пошаговое руководство по API.
Операции
15 endpoint в auth группа, созданная на основе собственной сайдкара документ OpenAPI. Защищенные операции занимают 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 |
/api/auth/identity
auth.identityStart Требует Authorization: Bearer <token>.
200 объект application/json
{ id: string url: string issuer: string }
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
взять пример
// 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
curl --request POST "${CADCAMFUN_URL}/api/auth/identity/start" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" Попробуйте это
auth.identityPoll Требует Authorization: Bearer <token>.
{ 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
взять пример
// 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
curl --request POST "${CADCAMFUN_URL}/api/auth/identity/poll" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json Попробуйте это
auth.identityCancel Требует Authorization: Bearer <token>.
{ id: string }
200 объект application/json
{ success: true message: string }
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
взять пример
// 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
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
auth.forgotPassword Требует Authorization: Bearer <token>.
{ 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
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
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
auth.resetPassword Требует Authorization: Bearer <token>.
{ 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
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
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-magic-link
auth.sendMagicLink Требует Authorization: Bearer <token>.
{ email?: string | null callbackURL?: string | null }
200 объект application/json
{ success: true message: string debugMagicLink?: string | null }
400 AuthBadRequestEncoded application/json
AuthBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
Пример SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// AuthSendMagicLinkInput
const result = await client.auth.sendMagicLink({
email: "",
callbackURL: ""
}) curl
curl --request POST "${CADCAMFUN_URL}/api/auth/send-magic-link" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json Попробуйте это
/api/auth/send-verification-email
auth.sendVerificationEmail Требует Authorization: Bearer <token>.
{ 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
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
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
auth.verifyEmail Требует Authorization: Bearer <token>.
{ 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
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
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
auth.signout Требует Authorization: Bearer <token>.
200 объект application/json
{ success: true message: string }
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
Пример SDK
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
curl --request POST "${CADCAMFUN_URL}/api/auth/signout" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" Попробуйте это
/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 | НеавторизованныйКодированный application/json
AuthUnauthorizedEncoded | UnauthorizedEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
Пример ответа пойман · 200
{
"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
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
curl --request GET "${CADCAMFUN_URL}/api/auth/get-session" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" Попробуйте это
/api/auth/signin-direct
auth.signinDirect Требует Authorization: Bearer <token>.
{ 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 | НеавторизованныйКодированный application/json
AuthUnauthorizedEncoded | UnauthorizedEncoded
404 AuthNotFoundEncoded application/json
AuthNotFoundEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
Пример SDK
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
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
auth.signup Требует Authorization: Bearer <token>.
{ 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
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
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
auth.testDirectCreate Требует Authorization: Bearer <token>.
{ 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
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
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/verify-magic-link
auth.verifyMagicLink Требует Authorization: Bearer <token>.
{ token?: string | null }
200 объект application/json
{ success: true message: string user: { id: string email: string | null name: string | null } token?: string | null }
400 AuthBadRequestEncoded application/json
AuthBadRequestEncoded
401 UnauthorizedEncoded application/json
UnauthorizedEncoded
404 AuthNotFoundEncoded application/json
AuthNotFoundEncoded
500 AuthInternalEncoded application/json
AuthInternalEncoded
Пример SDK
import { CadCam } from "@cadcamfun/api/sdk"
const client = CadCam.make({
baseUrl: process.env.CADCAMFUN_URL!,
headers: { authorization: `Bearer ${process.env.CADCAMFUN_TOKEN}` },
})
// AuthVerifyMagicLinkInput
const result = await client.auth.verifyMagicLink({
token: ""
}) curl
curl --request POST "${CADCAMFUN_URL}/api/auth/verify-magic-link" \
--header "Authorization: Bearer ${CADCAMFUN_TOKEN}" \
--header "Content-Type: application/json" \
--data-binary @request.json Попробуйте это
/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
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
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 }
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 }
Звонок в эту группу
Идентификаторы операций имеют вид auth.<name>. Сгенерированный Promise SDK (@cadcamfun/api/sdk) выставляет большинство из них как client.<namespace>.<method>(input), где input представляет собой один плоский объект параметров пути и полей тела; В примере SDK каждой карты показаны точный метод доступа и тип ввода. Многочастные загрузки, двоичные ответы или ответы JavaScript, а также необработанные веб-перехватчики не генерируются; эти карты показывают fetch вместо этого.
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. |
| В соединении отказано | Сайдкар перезапустилась в новом порту | Прочтите порт из нового ready строка. |