feat: implement TASK-WP1-01 registration transaction

This commit is contained in:
suyx
2026-07-28 15:54:28 +08:00
parent 1bf7e42294
commit f467e7c09f
15 changed files with 2191 additions and 4 deletions
+554
View File
@@ -1,6 +1,45 @@
{
"components": {
"schemas": {
"AuthenticatedUser": {
"additionalProperties": false,
"properties": {
"creator_name": {
"maxLength": 80,
"minLength": 1,
"type": "string"
},
"role": {
"enum": [
"user"
],
"type": "string"
},
"social_id": {
"maxLength": 80,
"minLength": 1,
"type": "string"
},
"status": {
"enum": [
"active"
],
"type": "string"
},
"user_id": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
"type": "string"
}
},
"required": [
"creator_name",
"role",
"social_id",
"status",
"user_id"
],
"type": "object"
},
"BootstrapResponse": {
"additionalProperties": false,
"properties": {
@@ -339,6 +378,23 @@
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
"type": "string"
},
"CreditSummary": {
"additionalProperties": false,
"properties": {
"available_balance": {
"type": "integer"
},
"reserved_balance": {
"minimum": 0,
"type": "integer"
}
},
"required": [
"available_balance",
"reserved_balance"
],
"type": "object"
},
"ErrorDetails": {
"additionalProperties": false,
"properties": {
@@ -553,6 +609,36 @@
"STORAGE_CAPACITY_EXCEEDED"
],
"type": "string"
},
{
"enum": [
"REGISTRATION_REJECTED"
],
"type": "string"
},
{
"enum": [
"REGISTRATION_REQUEST_INVALID"
],
"type": "string"
},
{
"enum": [
"IDEMPOTENCY_KEY_CONFLICT"
],
"type": "string"
},
{
"enum": [
"AUTH_SESSION_INVALID"
],
"type": "string"
},
{
"enum": [
"AUTH_SERVICE_UNAVAILABLE"
],
"type": "string"
}
]
},
@@ -915,6 +1001,139 @@
],
"type": "object"
},
"RegistrationCompleteHeaders": {
"additionalProperties": true,
"properties": {
"idempotency-key": {
"maxLength": 200,
"minLength": 32,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
}
},
"required": [
"idempotency-key"
],
"type": "object"
},
"RegistrationCompleteRequest": {
"additionalProperties": false,
"properties": {
"creator_name": {
"maxLength": 80,
"minLength": 1,
"type": "string"
},
"privacy_consent_accepted": {
"type": "boolean"
},
"privacy_notice_version": {
"maxLength": 80,
"minLength": 1,
"type": "string"
},
"registration_id": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
"type": "string"
},
"social_id": {
"maxLength": 80,
"minLength": 1,
"type": "string"
},
"verification_code": {
"pattern": "^[0-9]{6}$",
"type": "string"
}
},
"required": [
"creator_name",
"privacy_consent_accepted",
"privacy_notice_version",
"registration_id",
"social_id",
"verification_code"
],
"type": "object"
},
"RegistrationCompleteResponse": {
"additionalProperties": false,
"properties": {
"credits": {
"$ref": "#/components/schemas/CreditSummary"
},
"session_expires_at": {
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
"type": "string"
},
"status": {
"enum": [
"registered"
],
"type": "string"
},
"user": {
"$ref": "#/components/schemas/AuthenticatedUser"
}
},
"required": [
"credits",
"session_expires_at",
"status",
"user"
],
"type": "object"
},
"RegistrationSendRequest": {
"additionalProperties": false,
"properties": {
"email": {
"maxLength": 320,
"pattern": "^[^@\\s]{1,128}@[^@\\s]{1,190}$",
"type": "string"
},
"invite_code": {
"maxLength": 160,
"minLength": 8,
"type": "string"
}
},
"required": [
"email",
"invite_code"
],
"type": "object"
},
"RegistrationSendResponse": {
"additionalProperties": false,
"properties": {
"challenge_expires_at": {
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
"type": "string"
},
"registration_id": {
"pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$",
"type": "string"
},
"resend_available_at": {
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
"type": "string"
},
"status": {
"enum": [
"verification_sent"
],
"type": "string"
}
},
"required": [
"challenge_expires_at",
"registration_id",
"resend_available_at",
"status"
],
"type": "object"
},
"SseEvent": {
"anyOf": [
{
@@ -1087,6 +1306,36 @@
"STORAGE_CAPACITY_EXCEEDED"
],
"type": "string"
},
{
"enum": [
"REGISTRATION_REJECTED"
],
"type": "string"
},
{
"enum": [
"REGISTRATION_REQUEST_INVALID"
],
"type": "string"
},
{
"enum": [
"IDEMPOTENCY_KEY_CONFLICT"
],
"type": "string"
},
{
"enum": [
"AUTH_SESSION_INVALID"
],
"type": "string"
},
{
"enum": [
"AUTH_SERVICE_UNAVAILABLE"
],
"type": "string"
}
]
},
@@ -1124,6 +1373,48 @@
"state_version"
],
"type": "object"
},
"UserSessionResponse": {
"additionalProperties": false,
"properties": {
"audience": {
"enum": [
"user"
],
"type": "string"
},
"authenticated": {
"enum": [
true
],
"type": "boolean"
},
"credits": {
"$ref": "#/components/schemas/CreditSummary"
},
"csrf_token": {
"maxLength": 64,
"minLength": 43,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
},
"expires_at": {
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}Z$",
"type": "string"
},
"user": {
"$ref": "#/components/schemas/AuthenticatedUser"
}
},
"required": [
"audience",
"authenticated",
"credits",
"csrf_token",
"expires_at",
"user"
],
"type": "object"
}
}
},
@@ -1133,6 +1424,179 @@
},
"openapi": "3.1.0",
"paths": {
"/api/v1/auth/register/complete": {
"post": {
"operationId": "completeRegistration",
"parameters": [
{
"in": "header",
"name": "idempotency-key",
"required": true,
"schema": {
"maxLength": 200,
"minLength": 32,
"pattern": "^[A-Za-z0-9_-]+$",
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RegistrationCompleteRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RegistrationCompleteResponse"
}
}
},
"description": "Default Response"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"409": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"503": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
}
},
"tags": [
"Authentication"
]
}
},
"/api/v1/auth/register/send": {
"post": {
"operationId": "sendRegistrationCode",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RegistrationSendRequest"
}
}
},
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RegistrationSendResponse"
}
}
},
"description": "Default Response"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"409": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"503": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
}
},
"tags": [
"Authentication"
]
}
},
"/api/v1/auth/session": {
"get": {
"operationId": "getUserSession",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UserSessionResponse"
}
}
},
"description": "Default Response"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
},
"503": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorEnvelope"
}
}
},
"description": "Default Response"
}
},
"tags": [
"Authentication"
]
}
},
"/api/v1/bootstrap": {
"get": {
"operationId": "getBootstrap",
@@ -1375,6 +1839,36 @@
"STORAGE_CAPACITY_EXCEEDED"
],
"type": "string"
},
{
"enum": [
"REGISTRATION_REJECTED"
],
"type": "string"
},
{
"enum": [
"REGISTRATION_REQUEST_INVALID"
],
"type": "string"
},
{
"enum": [
"IDEMPOTENCY_KEY_CONFLICT"
],
"type": "string"
},
{
"enum": [
"AUTH_SESSION_INVALID"
],
"type": "string"
},
{
"enum": [
"AUTH_SERVICE_UNAVAILABLE"
],
"type": "string"
}
]
},
@@ -1809,6 +2303,36 @@
"STORAGE_CAPACITY_EXCEEDED"
],
"type": "string"
},
{
"enum": [
"REGISTRATION_REJECTED"
],
"type": "string"
},
{
"enum": [
"REGISTRATION_REQUEST_INVALID"
],
"type": "string"
},
{
"enum": [
"IDEMPOTENCY_KEY_CONFLICT"
],
"type": "string"
},
{
"enum": [
"AUTH_SESSION_INVALID"
],
"type": "string"
},
{
"enum": [
"AUTH_SERVICE_UNAVAILABLE"
],
"type": "string"
}
]
},
@@ -2284,6 +2808,36 @@
"STORAGE_CAPACITY_EXCEEDED"
],
"type": "string"
},
{
"enum": [
"REGISTRATION_REJECTED"
],
"type": "string"
},
{
"enum": [
"REGISTRATION_REQUEST_INVALID"
],
"type": "string"
},
{
"enum": [
"IDEMPOTENCY_KEY_CONFLICT"
],
"type": "string"
},
{
"enum": [
"AUTH_SESSION_INVALID"
],
"type": "string"
},
{
"enum": [
"AUTH_SERVICE_UNAVAILABLE"
],
"type": "string"
}
]
},