Compare commits
24
Commits
dev
...
4e13d4ab9a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e13d4ab9a | ||
|
|
c91b377c40 | ||
|
|
59841adf9c | ||
|
|
2187ef3d1c | ||
|
|
5bf93ef035 | ||
|
|
ba549a016b | ||
|
|
2546d05b25 | ||
|
|
24c2d34b3a | ||
|
|
b80af7ae58 | ||
|
|
8f17bb7ad4 | ||
|
|
081a87c492 | ||
|
|
b5a6c3657d | ||
|
|
ce0ac300f5 | ||
|
|
cbec4753a1 | ||
|
|
779dd574fc | ||
|
|
eb681a73da | ||
|
|
f404b63673 | ||
|
|
38f00fdeff | ||
|
|
5458214ad9 | ||
|
|
8ca80136f4 | ||
|
|
dc7afc272b | ||
|
|
913d5f4cb6 | ||
|
|
f26f8c7802 | ||
|
|
439c8773e6 |
No files matched your search
@@ -128,3 +128,25 @@ fields:
|
||||
maxItems: 3
|
||||
maxFileSize: "5MB"
|
||||
accept: ["application/pdf"]
|
||||
|
||||
imageFilter:
|
||||
shadow:
|
||||
- width: 800
|
||||
outputType: png
|
||||
removeBackground:
|
||||
color: "#FFFFFF"
|
||||
tolerance: 8
|
||||
fromEdges: true
|
||||
edgeBlur: 1.5
|
||||
referenceWidth: 1000
|
||||
dropShadow:
|
||||
color: "#000000"
|
||||
opacity: 0.25
|
||||
blur: 15
|
||||
offsetX: 8
|
||||
offsetY: 8
|
||||
padding: 20
|
||||
referenceWidth: 1000
|
||||
canvas: expand
|
||||
background: transparent
|
||||
flatten: "#FFFFFF"
|
||||
@@ -4,6 +4,18 @@ namespace: myapi
|
||||
meta:
|
||||
# wird in der Admin-UI zum Projekt aufgegeben
|
||||
imageUrl: https://source.unsplash.com/random/?internet
|
||||
tools:
|
||||
- name: demo-overview
|
||||
label:
|
||||
de: Demo-Übersicht
|
||||
en: Demo overview
|
||||
description:
|
||||
de: Beispiel-Tool für die Projekt-Übersicht
|
||||
en: Example project overview tool
|
||||
icon: view-dashboard-outline
|
||||
group: tools
|
||||
module: _/assets/tools/demo-overview/index.js
|
||||
capabilities: [db, ui, log]
|
||||
|
||||
# Liste aller möglichen Kollektionen (Listen, Seiten...) zum Projekt
|
||||
collections:
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# Beispiel für einen Asset-Eintrag mit Bildverarbeitung (imageProcessing)
|
||||
# (tibi-server, ProjectConfig.assets[]) — validiert gegen schemas/config/asset.schema.json.
|
||||
# Hinweis: cachePath ist optional. Explizit gesetzt ist er projektkontrolliert und
|
||||
# folgt den normalen Pfad-Gates: relativ zur config.yml, ".." nur mit
|
||||
# security.allowUpperPaths, absolut nur mit security.allowAbsolutePaths.
|
||||
# Ohne cachePath gilt cache.image.path (Standard ../cache/image,
|
||||
# operator-gesetzt, ".." dort ohne Flag erlaubt); ein Projekt kann ihn per
|
||||
# cache.image.path überschreiben.
|
||||
# Der Projekt-Namespace wird immer angehängt; das Verzeichnis wird beim ersten
|
||||
# Render angelegt. Die Ajv-Validierung prueft nur Form und Wertebereiche.
|
||||
name: product-images
|
||||
path: ./media/products
|
||||
imageProcessing:
|
||||
access: public
|
||||
cachePath: ./media-cache/products
|
||||
allowOriginal: false
|
||||
defaultFilter: shadow
|
||||
allowedInputTypes: ["image/jpeg", "image/png", "image/webp"]
|
||||
limits:
|
||||
maxInputBytes: 26214400
|
||||
maxPixels: 20000000
|
||||
imageFilter:
|
||||
shadow:
|
||||
- width: 800
|
||||
outputType: png
|
||||
removeBackground:
|
||||
color: "#FFFFFF"
|
||||
tolerance: 8
|
||||
fromEdges: true
|
||||
edgeBlur: 1.5
|
||||
referenceWidth: 1000
|
||||
dropShadow:
|
||||
color: "#000000"
|
||||
opacity: 0.25
|
||||
blur: 15
|
||||
offsetX: 8
|
||||
offsetY: 8
|
||||
padding: 20
|
||||
referenceWidth: 1000
|
||||
canvas: expand
|
||||
background: transparent
|
||||
flatten: "#FFFFFF"
|
||||
Vendored
+890
-7
@@ -272,6 +272,33 @@ declare global {
|
||||
| "bulkUpdate"
|
||||
| "bulkDelete"
|
||||
>
|
||||
/**
|
||||
* Document paths (dot notation, e.g. `security.twoFactor.secret`) whose
|
||||
* values are never written to the audit history. The values are dropped,
|
||||
* not replaced: the paths are recorded in `AuditEntry.redactedFields`
|
||||
* instead, so a client-side audit restore cannot write a placeholder into
|
||||
* the document. Snapshot backups (`snapshotPath`) are not affected.
|
||||
*/
|
||||
excludeFields?: string[]
|
||||
}
|
||||
|
||||
/** One audit history entry as returned by `GET /api/v1/audit`. */
|
||||
export interface AuditEntry {
|
||||
id?: string
|
||||
projectNamespace?: string
|
||||
projectName?: string
|
||||
collection: string
|
||||
action: string
|
||||
documentId?: string
|
||||
snapshot?: Record<string, unknown>
|
||||
changes?: Record<string, unknown>
|
||||
filter?: Record<string, unknown>
|
||||
/**
|
||||
* Paths removed from `snapshot`/`changes` because the collection lists
|
||||
* them in `audit.excludeFields`. Metadata only — the values are gone.
|
||||
*/
|
||||
redactedFields?: string[]
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export interface UploadConfig {
|
||||
@@ -343,6 +370,26 @@ declare global {
|
||||
export type PreviewConfig = string | EvalHtmlConfig | PreviewSlots
|
||||
|
||||
/** Image filter parameters — used in both CollectionConfig.imageFilter and ImagePackage.filter() */
|
||||
export interface RemoveBackgroundParams {
|
||||
color?: string
|
||||
tolerance?: number
|
||||
fromEdges?: boolean
|
||||
edgeBlur?: number
|
||||
referenceWidth?: number
|
||||
}
|
||||
|
||||
export interface DropShadowParams {
|
||||
color?: string
|
||||
opacity?: number
|
||||
blur?: number
|
||||
offsetX?: number
|
||||
offsetY?: number
|
||||
padding?: number
|
||||
referenceWidth?: number
|
||||
canvas?: "expand" | "fixed"
|
||||
background?: string
|
||||
}
|
||||
|
||||
export interface ImageFilterParams {
|
||||
width?: number
|
||||
height?: number
|
||||
@@ -355,7 +402,7 @@ declare global {
|
||||
| "catmullRom"
|
||||
| "lanczos"
|
||||
| "box"
|
||||
| "mitchellNetravili"
|
||||
| "mitchellNetravali"
|
||||
| "bSpline"
|
||||
| "gaussian"
|
||||
| "bartlett"
|
||||
@@ -386,7 +433,41 @@ declare global {
|
||||
lossless?: boolean
|
||||
skipLargerDimension?: boolean
|
||||
skipLargerFilesize?: boolean
|
||||
outputType?: "jpg" | "jpeg" | "png" | "webp"
|
||||
outputType?: "jpg" | "jpeg" | "png" | "webp" | "bmp" | "tiff" | "gif"
|
||||
removeBackground?: RemoveBackgroundParams
|
||||
dropShadow?: DropShadowParams
|
||||
flatten?: string
|
||||
}
|
||||
|
||||
/** Limits for asset image processing (`imageProcessing.limits`) */
|
||||
export interface AssetImageLimitsConfig {
|
||||
maxInputBytes?: number
|
||||
maxPixels?: number
|
||||
}
|
||||
|
||||
/** Asset image processing block (`imageProcessing`) */
|
||||
export interface AssetImageProcessingConfig {
|
||||
access: "public"
|
||||
/**
|
||||
* Optional cache directory. An explicit value is project-controlled:
|
||||
* relative to the project's config.yml, ".." needs
|
||||
* security.allowUpperPaths, absolute needs security.allowAbsolutePaths.
|
||||
* Omit to use cache.image.path (default ../cache/image).
|
||||
* The project namespace is appended; the directory is created lazily.
|
||||
*/
|
||||
cachePath?: string
|
||||
allowOriginal?: boolean
|
||||
defaultFilter?: string
|
||||
allowedInputTypes?: Array<"image/jpeg" | "image/png" | "image/webp">
|
||||
limits?: AssetImageLimitsConfig
|
||||
imageFilter: { [name: string]: ImageFilterParams[] } | string
|
||||
}
|
||||
|
||||
/** Asset config entry */
|
||||
export interface AssetConfig {
|
||||
name: string
|
||||
path: string
|
||||
imageProcessing?: AssetImageProcessingConfig
|
||||
}
|
||||
|
||||
/** Collection config as returned by context.collection() – JSON-serialized from Go CollectionConfig */
|
||||
@@ -573,7 +654,7 @@ declare global {
|
||||
lastReload: string
|
||||
namespace: string
|
||||
meta?: { [key: string]: any }
|
||||
assets?: { name: string; path: string }[]
|
||||
assets?: AssetConfig[]
|
||||
collections?: CollectionInfo[]
|
||||
actions?: ActionInfo[]
|
||||
jobs?: JobConfig[]
|
||||
@@ -593,6 +674,133 @@ declare global {
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
// ── Custom Tools (Admin) ─────────────────────────────────────────────────
|
||||
|
||||
/** Project config entry (`meta.tools[]`). */
|
||||
export interface AdminToolConfig {
|
||||
name: string
|
||||
label?: string | { [lang: string]: string }
|
||||
description?: string | { [lang: string]: string }
|
||||
icon?: string
|
||||
group?: string
|
||||
module: string | { eval: string }
|
||||
permissions?: string[]
|
||||
capabilities?: Array<"db" | "files" | "xlsx" | "ui" | "log" | "progress" | "state" | "action">
|
||||
settings?: Record<string, any>
|
||||
hidden?: boolean
|
||||
}
|
||||
|
||||
/** File handle handed to tools (data URL, no live Blob). */
|
||||
export interface AdminToolFile {
|
||||
src: string
|
||||
name: string
|
||||
type?: string
|
||||
size?: number
|
||||
}
|
||||
|
||||
/** Fail-fast batch result; no rollback. */
|
||||
export interface AdminToolBatchResult {
|
||||
ok: boolean
|
||||
failedIndex?: number
|
||||
error?: unknown
|
||||
}
|
||||
|
||||
export interface AdminToolDb {
|
||||
find(
|
||||
collection: string,
|
||||
opts?: Record<string, any>
|
||||
): Promise<CollectionDocument[]>
|
||||
count(collection: string, opts?: Record<string, any>): Promise<number>
|
||||
loadAll(
|
||||
collection: string,
|
||||
opts?: Record<string, any>,
|
||||
onProgress?: (done: number, total: number) => void
|
||||
): Promise<CollectionDocument[]>
|
||||
create(collection: string, data: Record<string, any>): Promise<CollectionDocument>
|
||||
update(collection: string, id: string, data: Record<string, any>): Promise<Partial<CollectionDocument>>
|
||||
delete(collection: string, id: string): Promise<void>
|
||||
updateMany(collection: string, items: Array<{ id: string; data: Record<string, any> }>): Promise<AdminToolBatchResult>
|
||||
deleteMany(collection: string, ids: string[]): Promise<AdminToolBatchResult>
|
||||
}
|
||||
|
||||
export interface AdminToolUi {
|
||||
supports(type: string): boolean
|
||||
slot(el: HTMLElement, element: any): void
|
||||
styles: CSSStyleSheet[]
|
||||
registerWidget(type: string, factory: (...args: any[]) => any, opts?: { replace?: boolean }): () => void
|
||||
render(el: HTMLElement, widget: Record<string, any>): void | (() => void)
|
||||
field(opts: Record<string, any>): any
|
||||
form(opts: Record<string, any>): any
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export interface AdminToolI18n {
|
||||
lang: string
|
||||
languages: string[]
|
||||
t(key: string, vars?: Record<string, unknown>): string
|
||||
text(value: string | Record<string, string> | undefined | null, vars?: Record<string, unknown>): string
|
||||
has(key: string): boolean
|
||||
add(lang: string, messages: Record<string, unknown>): () => void
|
||||
add(messages: Record<string, unknown>, lang?: string): () => void
|
||||
extend(lang: string, messages: Record<string, unknown>): () => void
|
||||
extend(messages: Record<string, unknown>, lang?: string): () => void
|
||||
onChange(cb: (lang: string) => void): () => void
|
||||
dispose?(): void
|
||||
}
|
||||
|
||||
/** Browser context handed to a tool module. `context === ctx`. */
|
||||
export interface AdminToolContext {
|
||||
context: AdminToolContext
|
||||
apiVersion: 1
|
||||
uiVersion: 1
|
||||
host: "tool" | "macro" | "server"
|
||||
capabilities: string[]
|
||||
project: ProjectInfo
|
||||
tool: AdminToolConfig
|
||||
auth: { id: string; username: string; role: number; permissions: string[] } | null
|
||||
db: AdminToolDb
|
||||
files: { get(input: File | Blob | string, name?: string): Promise<AdminToolFile> }
|
||||
xlsx: any
|
||||
/** Runs a project action (requires capability `action`); resolves with the final event/body. */
|
||||
action(
|
||||
name: string,
|
||||
options?: {
|
||||
method?: "get" | "post" | "put" | "delete"
|
||||
query?: Record<string, any>
|
||||
data?: Record<string, any>
|
||||
onProgress?: (event: Record<string, any>) => void
|
||||
onUploadProgress?: (loaded: number, total: number) => void
|
||||
signal?: AbortSignal
|
||||
}
|
||||
): Promise<Record<string, any>>
|
||||
state: Map<string, unknown>
|
||||
lang: string
|
||||
languages: string[]
|
||||
i18n: AdminToolI18n
|
||||
theme: { mode: "light" | "dark"; tokens: Record<string, string> }
|
||||
log(message: string, details?: unknown): void
|
||||
progress(done: number, total: number, label?: string): void
|
||||
signal: AbortSignal
|
||||
hostData: Record<string, any>
|
||||
asset(specifier: string): string
|
||||
ui: AdminToolUi
|
||||
}
|
||||
|
||||
export interface AdminToolModule {
|
||||
mount(
|
||||
el: HTMLElement,
|
||||
ctx: AdminToolContext
|
||||
): void | (() => void) | Promise<void | (() => void)>
|
||||
messages?: Record<string, Record<string, any>>
|
||||
}
|
||||
|
||||
export interface AdminToolException {
|
||||
status?: number
|
||||
msg: string
|
||||
json?: any
|
||||
}
|
||||
|
||||
|
||||
/** Represents a single audit log entry as received in audit.return hooks */
|
||||
export interface AuditLogEntry {
|
||||
id?: string
|
||||
@@ -895,6 +1103,23 @@ declare global {
|
||||
*
|
||||
*/
|
||||
project(): ProjectInfo
|
||||
/**
|
||||
* Read a project secret from `secrets:` in the project config.
|
||||
*
|
||||
* Secrets are never part of `project()`, a project API response or any
|
||||
* other JSON projection — hooks and actions only. Values are substituted
|
||||
* from `config.yml.env` like every other `${VAR}`.
|
||||
*
|
||||
* @param name secret name
|
||||
* @returns the value, or `null` when no such secret is configured
|
||||
*/
|
||||
secret(name: string): string | null
|
||||
|
||||
/**
|
||||
* Names of the configured project secrets (sorted). Values are never
|
||||
* included — this is for diagnostics and setup screens.
|
||||
*/
|
||||
secretNames(): string[]
|
||||
|
||||
/**
|
||||
* get server config object (sensitive fields like jwtSecret, adminTokens, apiKeys are excluded)
|
||||
@@ -1543,6 +1768,19 @@ declare global {
|
||||
): any
|
||||
}
|
||||
|
||||
/** Byte encodings shared by the crypto/base64 hook helpers. */
|
||||
export type ByteEncoding = "hex" | "base64" | "base64url" | "bytes"
|
||||
|
||||
/** AES-256-GCM output of `crypto.encrypt`; all fields are base64. */
|
||||
export interface SealedValue {
|
||||
/** Base64-encoded random 96-bit nonce (12 bytes). */
|
||||
iv: string
|
||||
/** Base64-encoded ciphertext without the authentication tag. */
|
||||
ciphertext: string
|
||||
/** Base64-encoded 128-bit authentication tag (16 bytes). */
|
||||
tag: string
|
||||
}
|
||||
|
||||
interface CryptoPackage {
|
||||
/**
|
||||
* get hex of sha256 hash
|
||||
@@ -1561,8 +1799,368 @@ declare global {
|
||||
* @returns hex hash
|
||||
*/
|
||||
md5(data: string): string
|
||||
|
||||
/**
|
||||
* Cryptographically secure random bytes (`crypto/rand`, never `Math.random`).
|
||||
*
|
||||
* `n` is the number of **bytes**, not characters; allowed range 1–4096.
|
||||
* Without options the raw bytes are returned (JSON output base64-encodes them,
|
||||
* like `fs.readFile(..., { bytes: true })`).
|
||||
*
|
||||
* @param n number of random bytes (1–4096)
|
||||
* @param options.encoding `hex` | `base64` | `base64url` | `bytes` (default `bytes`)
|
||||
*/
|
||||
randomBytes(n: number): Int8Array
|
||||
randomBytes(n: number, options: { encoding: "bytes" }): Int8Array
|
||||
randomBytes(
|
||||
n: number,
|
||||
options: { encoding: "hex" | "base64" | "base64url" }
|
||||
): string
|
||||
randomBytes(
|
||||
n: number,
|
||||
options: { encoding: ByteEncoding }
|
||||
): string | Int8Array
|
||||
|
||||
/**
|
||||
* URL-safe token from `n` random bytes.
|
||||
*
|
||||
* Default encoding is unpadded `base64url`: `randomToken(32)` yields 43
|
||||
* characters and 256 bit. `encoding: "bytes"` is rejected — a token is a string.
|
||||
*
|
||||
* @param n number of random bytes (1–4096)
|
||||
* @param options.encoding `base64url` (default) | `base64` | `hex`
|
||||
*/
|
||||
randomToken(n: number): string
|
||||
randomToken(
|
||||
n: number,
|
||||
options: { encoding: "hex" | "base64" | "base64url" }
|
||||
): string
|
||||
|
||||
/**
|
||||
* HMAC signature over `data`, keyed with `key`.
|
||||
*
|
||||
* Supported algorithms: `sha1` (TOTP/RFC 6238 requires it), `sha256`,
|
||||
* `sha512`. MD5 is not offered. `key` must not be empty. Output defaults
|
||||
* to hex.
|
||||
*
|
||||
* @param alg hash algorithm, case-insensitive
|
||||
* @param key secret key (string = UTF-8, or bytes)
|
||||
* @param data payload (string = UTF-8, or bytes)
|
||||
* @param options.encoding `hex` (default) | `base64` | `base64url` | `bytes`
|
||||
*/
|
||||
hmac(
|
||||
alg: "sha1" | "sha256" | "sha512" | (string & {}),
|
||||
key: string | Int8Array,
|
||||
data: string | Int8Array
|
||||
): string
|
||||
hmac(
|
||||
alg: "sha1" | "sha256" | "sha512" | (string & {}),
|
||||
key: string | Int8Array,
|
||||
data: string | Int8Array,
|
||||
options: { encoding: "bytes" }
|
||||
): Int8Array
|
||||
hmac(
|
||||
alg: "sha1" | "sha256" | "sha512" | (string & {}),
|
||||
key: string | Int8Array,
|
||||
data: string | Int8Array,
|
||||
options: { encoding: "hex" | "base64" | "base64url" }
|
||||
): string
|
||||
hmac(
|
||||
alg: string,
|
||||
key: string | Int8Array,
|
||||
data: string | Int8Array,
|
||||
options: { encoding: ByteEncoding }
|
||||
): string | Int8Array
|
||||
|
||||
/**
|
||||
* Constant-time comparison of two values (`hmac.Equal`).
|
||||
*
|
||||
* Use this for signatures, tokens and TOTP codes — never `===`, which
|
||||
* returns early and leaks how many leading characters matched.
|
||||
* Different lengths return `false` immediately: the length is not secret.
|
||||
*/
|
||||
timingSafeEqual(
|
||||
a: string | Int8Array,
|
||||
b: string | Int8Array
|
||||
): boolean
|
||||
|
||||
/**
|
||||
* Encrypt with AES-256-GCM. A fresh random 96-bit IV is generated for
|
||||
* every call; the authentication tag covers ciphertext and `aad`.
|
||||
*
|
||||
* `key` must be 32 bytes (use `deriveKey` or `randomBytes(32)`).
|
||||
* The returned object is JSON-safe: store `iv`, `ciphertext` and `tag`
|
||||
* as-is (all standard base64).
|
||||
*
|
||||
* @param plaintext string (UTF-8) or bytes
|
||||
* @param options.key 32-byte AES-256 key
|
||||
* @param options.aad optional additional authenticated data
|
||||
*/
|
||||
encrypt(
|
||||
plaintext: string | Int8Array,
|
||||
options: { key: string | Int8Array; aad?: string | Int8Array }
|
||||
): SealedValue
|
||||
|
||||
/**
|
||||
* Decrypt an AES-256-GCM value and verify its authentication tag.
|
||||
*
|
||||
* A wrong key, tampered ciphertext/tag or a different `aad` all fail
|
||||
* with the same error, so the caller cannot learn which part was wrong.
|
||||
*
|
||||
* @param sealed result of `encrypt` (base64 or raw bytes per field)
|
||||
* @param options.key 32-byte AES-256 key
|
||||
* @param options.aad must equal the value used by `encrypt`
|
||||
* @param options.encoding `utf8` (default) | `hex` | `base64` | `base64url` | `bytes`
|
||||
*/
|
||||
decrypt(
|
||||
sealed: SealedValue,
|
||||
options: { key: string | Int8Array; aad?: string | Int8Array }
|
||||
): string
|
||||
decrypt(
|
||||
sealed: SealedValue,
|
||||
options: { key: string | Int8Array; aad?: string | Int8Array; encoding: "bytes" }
|
||||
): Int8Array
|
||||
decrypt(
|
||||
sealed: SealedValue,
|
||||
options: { key: string | Int8Array; aad?: string | Int8Array; encoding: "hex" | "base64" | "base64url" }
|
||||
): string
|
||||
decrypt(
|
||||
sealed: SealedValue,
|
||||
options: { key: string | Int8Array; aad?: string | Int8Array; encoding: ByteEncoding }
|
||||
): string | Int8Array
|
||||
|
||||
/**
|
||||
* Derive a key with HKDF-SHA256 (no salt).
|
||||
*
|
||||
* Deterministic for the same secret and `info`, so use a stable `info`
|
||||
* per purpose (`"totp"`, `"recovery"`) instead of storing derived keys.
|
||||
* The secret must already be high-entropy (project secret or 32 random
|
||||
* bytes) — this is a KDF, not a password hash.
|
||||
*
|
||||
* @param secret high-entropy secret (string = UTF-8, or bytes)
|
||||
* @param options.info HKDF context, default empty
|
||||
* @param options.length output bytes, 16–64 (default 32). `encrypt`/
|
||||
* `decrypt` require exactly 32 bytes; use the raw output (no
|
||||
* `encoding`) as `key`.
|
||||
* @param options.encoding `hex` | `base64` | `base64url` | `bytes` (default `bytes`)
|
||||
*/
|
||||
deriveKey(
|
||||
secret: string | Int8Array,
|
||||
options?: { info?: string | Int8Array; length?: number }
|
||||
): Int8Array
|
||||
deriveKey(
|
||||
secret: string | Int8Array,
|
||||
options: { info?: string | Int8Array; length?: number; encoding: "hex" | "base64" | "base64url" }
|
||||
): string
|
||||
deriveKey(
|
||||
secret: string | Int8Array,
|
||||
options: { info?: string | Int8Array; length?: number; encoding: ByteEncoding }
|
||||
): string | Int8Array
|
||||
}
|
||||
|
||||
/**
|
||||
* Time-based one-time passwords (RFC 6238 / RFC 4226).
|
||||
*
|
||||
* All functions accept the secret as a base32 string (lowercase and
|
||||
* grouping whitespace allowed, as authenticator apps display it) or as
|
||||
* bytes. Stateless: replay protection, rate limiting and lockout are the
|
||||
* hook's responsibility.
|
||||
*/
|
||||
interface TotpPackage {
|
||||
/**
|
||||
* Current code for the given time step.
|
||||
*
|
||||
* @param secret base32 string or bytes
|
||||
* @param options.digits 6 (default), 7 or 8
|
||||
* @param options.period time step in seconds (default 30)
|
||||
* @param options.algorithm `sha1` (default) | `sha256` | `sha512`
|
||||
* @param options.t unix seconds to generate for (default: now)
|
||||
*/
|
||||
generate(secret: string | Int8Array, options?: TotpOptions): string
|
||||
|
||||
/**
|
||||
* Verify a user-supplied code in constant time.
|
||||
*
|
||||
* Returns `false` for wrong-length or non-numeric codes (user input),
|
||||
* never throws for them. The default window is ±1 step (clock skew).
|
||||
*
|
||||
* @param secret base32 string or bytes
|
||||
* @param code the entered digits
|
||||
* @param options.window accepted steps before/after (0–10, default 1)
|
||||
*/
|
||||
verify(
|
||||
secret: string | Int8Array,
|
||||
code: string,
|
||||
options?: TotpOptions & { window?: number }
|
||||
): boolean
|
||||
|
||||
/**
|
||||
* `otpauth://totp/...` URI for enrollment (QR code / manual entry).
|
||||
*
|
||||
* @param options.secret base32 string or bytes (required)
|
||||
* @param options.account account label, e.g. the user's mail (required)
|
||||
* @param options.issuer issuer name shown by the app (recommended)
|
||||
*/
|
||||
uri(options: TotpOptions & {
|
||||
secret: string | Int8Array
|
||||
account: string
|
||||
issuer?: string
|
||||
}): string
|
||||
}
|
||||
|
||||
export interface TotpOptions {
|
||||
/** 6 (default), 7 or 8 */
|
||||
digits?: number
|
||||
/** time step in seconds (1–3600, default 30) */
|
||||
period?: number
|
||||
/** `sha1` (default) | `sha256` | `sha512` */
|
||||
algorithm?: "sha1" | "sha256" | "sha512"
|
||||
/** unix seconds to generate/verify for (default: now) */
|
||||
t?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* WebAuthn Level 2 (passkeys and security keys), server side.
|
||||
*
|
||||
* The browser talks to the authenticator; these functions verify the
|
||||
* response. Stateless: challenge handling, storage, rate limiting and
|
||||
* replay protection are the hook's responsibility.
|
||||
*/
|
||||
interface WebAuthnPackage {
|
||||
/**
|
||||
* Verify an attestation and return the credential to store.
|
||||
*
|
||||
* Attestation `none` (browser default) and packed self-attestation are
|
||||
* verified; `packed` with an x5c certificate chain is rejected as
|
||||
* `unsupported_attestation` instead of being trusted.
|
||||
*/
|
||||
verifyRegistration(options: WebAuthnRegistrationOptions): WebAuthnRegistrationResult
|
||||
|
||||
/**
|
||||
* Verify a login assertion against the stored COSE public key.
|
||||
*
|
||||
* The signature covers `authenticatorData || SHA256(clientDataJSON)`.
|
||||
*/
|
||||
verifyAssertion(options: WebAuthnAssertionOptions): WebAuthnAssertionResult
|
||||
}
|
||||
|
||||
export interface WebAuthnRegistrationOptions {
|
||||
/** JSON from `navigator.credentials.create()`. */
|
||||
credential: WebAuthnCredentialJSON
|
||||
/** base64url of the challenge the server issued. */
|
||||
challenge: string
|
||||
/** relying party id, e.g. `shop.example.com`. */
|
||||
rpId: string
|
||||
/** accepted origin, exact match. */
|
||||
origin?: string
|
||||
/** accepted origins; wins over `origin` when set. */
|
||||
origins?: string[]
|
||||
/** demand the UV flag (biometric/PIN). Default false. */
|
||||
requireUserVerification?: boolean
|
||||
}
|
||||
|
||||
export interface WebAuthnAssertionOptions {
|
||||
/** JSON from `navigator.credentials.get()`. */
|
||||
credential: WebAuthnCredentialJSON
|
||||
/** base64url of the challenge the server issued. */
|
||||
challenge: string
|
||||
/** relying party id, e.g. `shop.example.com`. */
|
||||
rpId: string
|
||||
origin?: string
|
||||
origins?: string[]
|
||||
/** stored COSE key, as returned by `verifyRegistration`. */
|
||||
publicKey: string | Int8Array
|
||||
/** stored counter. Default 0. */
|
||||
signCount?: number
|
||||
requireUserVerification?: boolean
|
||||
/**
|
||||
* Accept credentials without a counter (synced passkeys report 0/0).
|
||||
* Default true; false demands a real counter.
|
||||
*/
|
||||
allowSignCountZero?: boolean
|
||||
}
|
||||
|
||||
/** PublicKeyCredential JSON. Binary fields are base64url or byte arrays. */
|
||||
export interface WebAuthnCredentialJSON {
|
||||
id: string
|
||||
rawId?: string | Int8Array
|
||||
type: string
|
||||
transports?: string[]
|
||||
response: {
|
||||
clientDataJSON: string | Int8Array
|
||||
attestationObject?: string | Int8Array
|
||||
authenticatorData?: string | Int8Array
|
||||
signature?: string | Int8Array
|
||||
userHandle?: string | Int8Array | null
|
||||
}
|
||||
}
|
||||
|
||||
export type WebAuthnErrorCode =
|
||||
| "malformed_credential"
|
||||
| "unsupported_type"
|
||||
| "malformed_client_data"
|
||||
| "type_mismatch"
|
||||
| "challenge_mismatch"
|
||||
| "origin_mismatch"
|
||||
| "cross_origin_not_allowed"
|
||||
| "rp_id_mismatch"
|
||||
| "malformed_authenticator_data"
|
||||
| "user_not_present"
|
||||
| "user_verification_required"
|
||||
| "credential_id_mismatch"
|
||||
| "unsupported_attestation"
|
||||
| "unsupported_algorithm"
|
||||
| "malformed_public_key"
|
||||
| "signature_invalid"
|
||||
| "sign_count_regression"
|
||||
|
||||
export type WebAuthnRegistrationResult =
|
||||
| {
|
||||
verified: true
|
||||
/** base64url credential id. */
|
||||
credentialId: string
|
||||
/** COSE public key, base64url. Persist it for `verifyAssertion`. */
|
||||
publicKey: string
|
||||
signCount: number
|
||||
/** Authenticator model as UUID; nil UUID for many platform passkeys. */
|
||||
aaguid: string
|
||||
/** `none`, `packed`, … */
|
||||
attestationFormat: string
|
||||
/**
|
||||
* Always `false` today: `none` carries no attestation and packed
|
||||
* self-attestation proves possession, not identity. An untrusted
|
||||
* AAGUID is spoofable and must not drive policy.
|
||||
*/
|
||||
attestationTrusted: boolean
|
||||
/** From `response.getTransports()`, unverified. */
|
||||
transports: string[]
|
||||
backupEligible: boolean
|
||||
backupState: boolean
|
||||
}
|
||||
| {
|
||||
verified: false
|
||||
error: WebAuthnErrorCode
|
||||
detail?: string
|
||||
}
|
||||
|
||||
export type WebAuthnAssertionResult =
|
||||
| {
|
||||
verified: true
|
||||
/** Persist this instead of the stored counter. */
|
||||
newSignCount: number
|
||||
userPresent: boolean
|
||||
userVerified: boolean
|
||||
backupEligible: boolean
|
||||
backupState: boolean
|
||||
/** base64url user handle, "" for non-discoverable credentials. */
|
||||
userHandle: string
|
||||
}
|
||||
| {
|
||||
verified: false
|
||||
error: WebAuthnErrorCode
|
||||
detail?: string
|
||||
}
|
||||
|
||||
interface JsonPackage {
|
||||
/**
|
||||
* parse json string to json
|
||||
@@ -1611,14 +2209,51 @@ declare global {
|
||||
: string
|
||||
}
|
||||
|
||||
/** RFC 4648 encoding variant shared by the base64 helpers. */
|
||||
export type BaseVariant = "base64" | "base64url" | "base32"
|
||||
|
||||
export interface Base64Options {
|
||||
/**
|
||||
* Alphabet: `base64` (default, `+/`), `base64url` (`-_`) or `base32`
|
||||
* (RFC 4648 §6, uppercase).
|
||||
*/
|
||||
variant?: BaseVariant
|
||||
/**
|
||||
* RFC padding. Default: `true` for `base64`, `false` for `base64url`
|
||||
* and `base32` (JWT parts and TOTP secrets are unpadded).
|
||||
*/
|
||||
padding?: boolean
|
||||
}
|
||||
|
||||
export interface Base64DecodeOptions extends Base64Options {
|
||||
/** Return raw bytes instead of a string (default: false). */
|
||||
returnBytes?: boolean
|
||||
}
|
||||
|
||||
interface Base64Package {
|
||||
encode(data: string | Int8Array): string
|
||||
/**
|
||||
* Encode a string/bytes value. Without options this is padded standard
|
||||
* base64 — the historical, unchanged behaviour.
|
||||
*/
|
||||
encode(data: string | Int8Array, options?: Base64Options): string
|
||||
|
||||
/**
|
||||
* Decode. Without an explicit `padding`, both padded and unpadded input
|
||||
* are accepted; `base32` additionally accepts lowercase and grouped
|
||||
* input ("MZXW 6YTB OI"). Alphabets stay strict.
|
||||
*/
|
||||
decode(data: string): string
|
||||
decode(data: string, options: { returnBytes: true }): Int8Array
|
||||
decode(data: string, options: { returnBytes: false }): string
|
||||
decode(
|
||||
data: string,
|
||||
options: { returnBytes?: boolean }
|
||||
options: Base64DecodeOptions & { returnBytes: true }
|
||||
): Int8Array
|
||||
decode(
|
||||
data: string,
|
||||
options: Base64DecodeOptions & { returnBytes?: false }
|
||||
): string
|
||||
decode(
|
||||
data: string,
|
||||
options: Base64DecodeOptions & { returnBytes: boolean }
|
||||
): string | Int8Array
|
||||
}
|
||||
|
||||
@@ -1672,6 +2307,60 @@ declare global {
|
||||
count(): number
|
||||
}
|
||||
|
||||
/**
|
||||
* Project-scoped named claims for single-flight work.
|
||||
*
|
||||
* A claim exists once per key and is released when the hook/job ends
|
||||
* (return, exception, panic, timeout) or via `release()`. No TTL, no LRU,
|
||||
* no configuration.
|
||||
*/
|
||||
interface LockPackage {
|
||||
/**
|
||||
* Claim a named lock.
|
||||
*
|
||||
* @param key Lock key, e.g. `"ssr:render:" + url`
|
||||
* @param options.waitMs Optional wait budget in milliseconds (default 0,
|
||||
* capped at 30000). Waits for the current owner to release.
|
||||
* @returns `{ acquired, key, reentrant? }`. `reentrant` is true when the
|
||||
* same execution already holds the key (never granted twice).
|
||||
*/
|
||||
acquire(key: string, options?: { waitMs?: number }): LockHandle
|
||||
|
||||
/**
|
||||
* Release this execution's claim.
|
||||
*
|
||||
* @returns `true` if this execution held and released the claim.
|
||||
*/
|
||||
release(key: string): boolean
|
||||
|
||||
/**
|
||||
* Whether this execution holds the key.
|
||||
*/
|
||||
isHeld(key: string): boolean
|
||||
|
||||
/**
|
||||
* Whether anybody holds the key.
|
||||
*/
|
||||
held(key: string): boolean
|
||||
|
||||
/**
|
||||
* Number of held claims in this project.
|
||||
*/
|
||||
count(): number
|
||||
|
||||
/**
|
||||
* Number of executions waiting for a claim.
|
||||
*/
|
||||
waiters(): number
|
||||
}
|
||||
|
||||
interface LockHandle {
|
||||
acquired: boolean
|
||||
key: string
|
||||
/** Set when the same execution tried to acquire its own claim. */
|
||||
reentrant?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* Project-scoped rate limiter with two strategies:
|
||||
* - **Backoff**: Exponential back-off per key (e.g. login brute-force protection).
|
||||
@@ -1836,14 +2525,208 @@ declare global {
|
||||
cookie: CookiePackage
|
||||
pdf: PdfPackage
|
||||
crypto: CryptoPackage
|
||||
totp: TotpPackage
|
||||
webauthn: WebAuthnPackage
|
||||
json: JsonPackage
|
||||
exec: ExecPackage
|
||||
base64: Base64Package
|
||||
channel: ChannelPackage
|
||||
cache: CachePackage
|
||||
lock: LockPackage
|
||||
ratelimit: RatelimitPackage
|
||||
}
|
||||
|
||||
// ── Admin API: login, second factor, WebAuthn ────────────────────
|
||||
// These describe the wire shapes of /api/v1/login and /api/v1/mfa, so the
|
||||
// admin UI and any client use the same contract as the server.
|
||||
|
||||
/** Every method that can appear in the `amr` claim, including the password. */
|
||||
export type AdminAuthMethod =
|
||||
| "pwd"
|
||||
| "totp"
|
||||
| "recovery"
|
||||
| "email"
|
||||
| "webauthn"
|
||||
| "trusted_device"
|
||||
| "impersonation"
|
||||
|
||||
/** Factors the login offer can contain (no password, no session markers). */
|
||||
export type AdminMfaMethod = Exclude<AdminAuthMethod, "pwd" | "trusted_device" | "impersonation">
|
||||
|
||||
/** Step-1 answer when a second factor is required. */
|
||||
export interface AdminMfaChallenge {
|
||||
mfaRequired: true
|
||||
pendingToken: string
|
||||
expiresIn: number
|
||||
/** Policy requires a factor and the grace period is over. */
|
||||
enrollmentRequired?: boolean
|
||||
methods: AdminMfaMethod[]
|
||||
/** Masked address when the e-mail factor is one of the methods. */
|
||||
emailHint?: string
|
||||
/** A real factor is still worthwhile (e-mail fallback relieved the login). */
|
||||
mfaEnrollmentRecommended?: boolean
|
||||
/** >0 when the server allows remembering this browser after the factor. */
|
||||
rememberDeviceDays?: number
|
||||
}
|
||||
|
||||
/** Step-1 answer for an account without an active factor. */
|
||||
export interface AdminLoginSession<U = unknown> {
|
||||
mfaRequired?: false
|
||||
token: string
|
||||
user: U
|
||||
amr?: AdminAuthMethod[]
|
||||
/** Inside the grace period: enrollment is recommended, not enforced. */
|
||||
mfaEnrollmentRecommended?: boolean
|
||||
}
|
||||
|
||||
export type AdminLoginResponse<U = unknown> = AdminLoginSession<U> | AdminMfaChallenge
|
||||
|
||||
export interface AdminMfaStatus {
|
||||
totpEnabled: boolean
|
||||
webauthnCredentials: number
|
||||
/** The e-mail code factor is explicit opt-in and never enabled automatically. */
|
||||
emailEnabled: boolean
|
||||
/** Masked verified address, e.g. `a***@example.com`. */
|
||||
email?: string
|
||||
emailVerified: boolean
|
||||
/** Server forces an e-mail code although no factor is enrolled. */
|
||||
emailFallback: boolean
|
||||
recoveryCodesRemaining: number
|
||||
enforced: boolean
|
||||
policy: "off" | "optional" | "required"
|
||||
}
|
||||
|
||||
/** Body of the first-factor-only password reset request. */
|
||||
export interface AdminPasswordResetRequest {
|
||||
username: string
|
||||
}
|
||||
|
||||
/** Completes a password reset; the server never returns a session here. */
|
||||
export interface AdminPasswordResetConfirm {
|
||||
username: string
|
||||
code: string
|
||||
password: string
|
||||
}
|
||||
|
||||
/** One browser that skips the login challenge. */
|
||||
export interface AdminTrustedDevice {
|
||||
id: string
|
||||
label: string
|
||||
createdAt: string
|
||||
lastUsedAt?: string
|
||||
expiresAt: string
|
||||
}
|
||||
|
||||
export interface AdminTrustedDevices {
|
||||
enabled: boolean
|
||||
days: number
|
||||
devices: AdminTrustedDevice[]
|
||||
}
|
||||
|
||||
export interface AdminMfaTotpEnrollment {
|
||||
secret: string
|
||||
otpauthUri: string
|
||||
}
|
||||
|
||||
export interface AdminMfaConfirmResult {
|
||||
enabled: boolean
|
||||
recoveryCodes: string[]
|
||||
}
|
||||
|
||||
export interface AdminStepUpResult {
|
||||
stepUpToken: string
|
||||
expiresIn: number
|
||||
}
|
||||
|
||||
export type AdminAuthenticatorTransport =
|
||||
| "usb"
|
||||
| "nfc"
|
||||
| "ble"
|
||||
| "internal"
|
||||
| "hybrid"
|
||||
| "smart-card"
|
||||
|
||||
export interface AdminWebAuthnDescriptor {
|
||||
type: "public-key"
|
||||
id: string
|
||||
transports?: AdminAuthenticatorTransport[]
|
||||
}
|
||||
|
||||
/** PublicKeyCredentialCreationOptions with base64url strings. */
|
||||
export interface AdminWebAuthnCreationOptions {
|
||||
challenge: string
|
||||
rp: { id: string; name: string }
|
||||
user: { id: string; name: string; displayName: string }
|
||||
pubKeyCredParams: { type: "public-key"; alg: number }[]
|
||||
timeout: number
|
||||
excludeCredentials?: AdminWebAuthnDescriptor[]
|
||||
authenticatorSelection?: {
|
||||
residentKey?: "required" | "preferred" | "discouraged"
|
||||
userVerification?: "required" | "preferred" | "discouraged"
|
||||
}
|
||||
attestation?: "none" | "indirect" | "direct" | "enterprise"
|
||||
}
|
||||
|
||||
/** PublicKeyCredentialRequestOptions with base64url strings. */
|
||||
export interface AdminWebAuthnRequestOptions {
|
||||
challenge: string
|
||||
rpId: string
|
||||
allowCredentials: AdminWebAuthnDescriptor[]
|
||||
timeout: number
|
||||
userVerification?: "required" | "preferred" | "discouraged"
|
||||
}
|
||||
|
||||
/** Serialised PublicKeyCredential as the server expects it. */
|
||||
export interface AdminWebAuthnCredentialJSON {
|
||||
id: string
|
||||
rawId: string
|
||||
type: "public-key"
|
||||
transports?: AdminAuthenticatorTransport[]
|
||||
response: {
|
||||
clientDataJSON: string
|
||||
attestationObject?: string
|
||||
authenticatorData?: string
|
||||
signature?: string
|
||||
userHandle?: string
|
||||
}
|
||||
}
|
||||
|
||||
/** Admin dashboard: how many accounts have a factor. */
|
||||
export interface AdminMfaOverview {
|
||||
users: number
|
||||
withFactor: number
|
||||
withoutFactor: number
|
||||
enforced: number
|
||||
policy: "off" | "optional" | "required"
|
||||
}
|
||||
|
||||
/** Admin view of one account's factor state. */
|
||||
export interface AdminUserMfaStatus {
|
||||
userId: string
|
||||
username: string
|
||||
mfaEnabled: boolean
|
||||
mfaEnforced: boolean
|
||||
status: AdminMfaStatus
|
||||
}
|
||||
|
||||
/** Options for the passwordless (first-factor) passkey login. */
|
||||
export interface AdminPasskeyOptions {
|
||||
publicKey: AdminWebAuthnRequestOptions
|
||||
/** Short-lived token that binds the assertion to the challenge. */
|
||||
challengeToken: string
|
||||
}
|
||||
|
||||
export interface AdminWebAuthnCredentialView {
|
||||
id: string
|
||||
label: string
|
||||
transports?: AdminAuthenticatorTransport[]
|
||||
aaguid?: string
|
||||
createdAt: string
|
||||
lastUsedAt?: string
|
||||
backupEligible: boolean
|
||||
backupState: boolean
|
||||
}
|
||||
|
||||
export interface HookException {
|
||||
status?: number
|
||||
html?: string
|
||||
|
||||
Generated
+16
-1
@@ -12,7 +12,8 @@
|
||||
"ajv": "^8.20.0",
|
||||
"ajv-formats": "^3.0.1",
|
||||
"glob": "^11.1.0",
|
||||
"js-yaml": "^4.1.1"
|
||||
"js-yaml": "^4.1.1",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
},
|
||||
"node_modules/@isaacs/cliui": {
|
||||
@@ -330,6 +331,20 @@
|
||||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.9.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
|
||||
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/which": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
|
||||
|
||||
+4
-2
@@ -5,13 +5,15 @@
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"validate:schemas": "node scripts/validate-schemas.mjs",
|
||||
"test": "npm run validate:schemas"
|
||||
"typecheck": "tsc -p tsconfig.json",
|
||||
"test": "npm run validate:schemas && npm run typecheck"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ajv": "^8.20.0",
|
||||
"ajv-formats": "^3.0.1",
|
||||
"glob": "^11.1.0",
|
||||
"js-yaml": "^4.1.1"
|
||||
"js-yaml": "^4.1.1",
|
||||
"typescript": "^5.9.3"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -13,6 +13,70 @@
|
||||
},
|
||||
"path": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageProcessing": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"access": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"public"
|
||||
]
|
||||
},
|
||||
"cachePath": {
|
||||
"type": "string",
|
||||
"description": "Optional cache directory for filtered variants. An explicit value is project-controlled: relative to the project's config.yml, \"..\" needs security.allowUpperPaths, absolute needs security.allowAbsolutePaths. Omit it to use cache.image.path (default ../cache/image). The project namespace is appended and the directory is created lazily.",
|
||||
"pattern": "^.+$"
|
||||
},
|
||||
"allowOriginal": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"defaultFilter": {
|
||||
"type": "string"
|
||||
},
|
||||
"allowedInputTypes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"image/jpeg",
|
||||
"image/png",
|
||||
"image/webp"
|
||||
]
|
||||
}
|
||||
},
|
||||
"limits": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"maxInputBytes": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 67108864
|
||||
},
|
||||
"maxPixels": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"maximum": 200000000
|
||||
}
|
||||
}
|
||||
},
|
||||
"imageFilter": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"$ref": "image-filter.schema.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"access",
|
||||
"imageFilter"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
|
||||
@@ -17,6 +17,10 @@
|
||||
"uploadPath": {
|
||||
"type": "string"
|
||||
},
|
||||
"imageCachePath": {
|
||||
"type": "string",
|
||||
"description": "Cache root for filtered image variants of this collection (relative to the config dir). Default: <configDir>/cache/images."
|
||||
},
|
||||
"upload": {
|
||||
"$ref": "collection.schema.json#/definitions/uploadConfig"
|
||||
},
|
||||
@@ -120,6 +124,14 @@
|
||||
"bulkDelete"
|
||||
]
|
||||
}
|
||||
},
|
||||
"excludeFields": {
|
||||
"description": "Document paths (dot notation) whose values are never stored in the audit history. The paths are recorded in AuditLog.redactedFields; snapshot backups are not affected.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
"fit": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"upscale": {
|
||||
"type": "boolean",
|
||||
"description": "With fit: also enlarge a source smaller than the box (legacy getimg.php behaviour). Default false."
|
||||
},
|
||||
"fill": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -33,7 +37,7 @@
|
||||
"catmullRom",
|
||||
"lanczos",
|
||||
"box",
|
||||
"mitchellNetravili",
|
||||
"mitchellNetravali",
|
||||
"bSpline",
|
||||
"gaussian",
|
||||
"bartlett",
|
||||
@@ -100,8 +104,109 @@
|
||||
"jpg",
|
||||
"jpeg",
|
||||
"png",
|
||||
"webp"
|
||||
"webp",
|
||||
"bmp",
|
||||
"tiff",
|
||||
"gif"
|
||||
]
|
||||
},
|
||||
"removeBackground": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"color": {
|
||||
"type": "string",
|
||||
"pattern": "^#[0-9a-fA-F]{6}$"
|
||||
},
|
||||
"tolerance": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"fromEdges": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"edgeBlur": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1000
|
||||
},
|
||||
"referenceWidth": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 100000
|
||||
}
|
||||
}
|
||||
},
|
||||
"dropShadow": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"color": {
|
||||
"type": "string",
|
||||
"pattern": "^#[0-9a-fA-F]{6}$"
|
||||
},
|
||||
"opacity": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"blur": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1000
|
||||
},
|
||||
"offsetX": {
|
||||
"type": "number",
|
||||
"minimum": -1000,
|
||||
"maximum": 1000
|
||||
},
|
||||
"offsetY": {
|
||||
"type": "number",
|
||||
"minimum": -1000,
|
||||
"maximum": 1000
|
||||
},
|
||||
"padding": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 10000
|
||||
},
|
||||
"referenceWidth": {
|
||||
"type": "integer",
|
||||
"minimum": 0,
|
||||
"maximum": 100000
|
||||
},
|
||||
"canvas": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"expand",
|
||||
"fixed"
|
||||
]
|
||||
},
|
||||
"reserve": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"shadow",
|
||||
"padding"
|
||||
],
|
||||
"description": "expand- canvas: 'shadow' keeps the blurred shadow inside the canvas (default), 'padding' only reserves the padding around the content and lets the shadow clip at the edge (legacy getimg.php behaviour)."
|
||||
},
|
||||
"background": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"pattern": "^#[0-9a-fA-F]{6}$"
|
||||
},
|
||||
{
|
||||
"const": "transparent"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"flatten": {
|
||||
"type": "string",
|
||||
"pattern": "^#[0-9a-fA-F]{6}$"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,13 @@
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z0-9_-]+$"
|
||||
},
|
||||
"secrets": {
|
||||
"description": "Values for hooks/actions only (JWT keys, SMTP passwords, ...). Substituted from config.yml.env like every other value; never part of a project API response or context.config.project(). Read them with context.config.secret(name).",
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
@@ -65,6 +72,21 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"ui": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"css": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tools": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "tool.schema.json"
|
||||
}
|
||||
},
|
||||
"i18n": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
@@ -89,6 +111,20 @@
|
||||
"code"
|
||||
]
|
||||
}
|
||||
},
|
||||
"messages": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
@@ -316,6 +352,44 @@
|
||||
"type": "string",
|
||||
"description": "Base directory for snapshot data, relative to configDir. Default: '{configDir}/snapshots'."
|
||||
},
|
||||
"cache": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"description": "Per-project cache settings. Same key names as the server's cache.image block.",
|
||||
"properties": {
|
||||
"image": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"description": "Derived image cache (filtered variants). Every value may only tighten cache.image.* of the server; path follows the usual security gates.",
|
||||
"properties": {
|
||||
"path": {
|
||||
"type": "string",
|
||||
"description": "Cache root for this project, relative to its config.yml. '..' needs security.allowUpperPaths, absolute needs security.allowAbsolutePaths."
|
||||
},
|
||||
"autoCleanup": {
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"description": "Retention limits; the switch, the schedule and the per-run I/O budget are server-controlled.",
|
||||
"properties": {
|
||||
"maxAge": {
|
||||
"type": "string",
|
||||
"description": "How long an unused variant may stay (Go duration, e.g. '168h'). Only shorter than cache.image.autoCleanup.maxAge."
|
||||
},
|
||||
"maxFiles": {
|
||||
"type": "integer",
|
||||
"minimum": 1,
|
||||
"description": "Maximum cache entries per cache directory. Only lower than cache.image.autoCleanup.maxFiles."
|
||||
},
|
||||
"tempMaxAge": {
|
||||
"type": "string",
|
||||
"description": "Lifetime of abandoned .tmp-* files (Go duration). Only shorter than cache.image.autoCleanup.tempMaxAge."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"snapshots": {
|
||||
"type": "array",
|
||||
"description": "List of snapshot profiles for automated point-in-time backups.",
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Custom Tool",
|
||||
"description": "Project custom tool entry (meta.tools[]).",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"name",
|
||||
"module"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"pattern": "^[a-z0-9][a-z0-9-_]*$"
|
||||
},
|
||||
"label": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"$ref": "defs.schema.json#/definitions/i18nText"
|
||||
}
|
||||
]
|
||||
},
|
||||
"description": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"$ref": "defs.schema.json#/definitions/i18nText"
|
||||
}
|
||||
]
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
},
|
||||
"group": {
|
||||
"type": "string"
|
||||
},
|
||||
"module": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"$ref": "defs.schema.json#/definitions/evalString"
|
||||
}
|
||||
]
|
||||
},
|
||||
"permissions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"capabilities": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"enum": [
|
||||
"db",
|
||||
"files",
|
||||
"xlsx",
|
||||
"ui",
|
||||
"log",
|
||||
"progress",
|
||||
"state",
|
||||
"action"
|
||||
]
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"type": "object"
|
||||
},
|
||||
"hidden": {
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,8 @@ const validations = [
|
||||
{ schema: "asset.schema.json", pattern: "demo-api/assets/*.y*ml" },
|
||||
// Server-level Abschnitt (config.yml des tibi-servers), Beispiel getrennt
|
||||
// vom Projekt-Demo unter examples/server/:
|
||||
{ schema: "embedding.schema.json", pattern: "examples/server/*.y*ml" },
|
||||
{ schema: "embedding.schema.json", pattern: "examples/server/embedding*.y*ml" },
|
||||
{ schema: "asset.schema.json", pattern: "examples/server/asset-*.y*ml" },
|
||||
]
|
||||
|
||||
let hasErrors = false
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"include": ["demo-api/**/*"],
|
||||
"include": ["demo-api/**/*", "types-test/**/*"],
|
||||
"compilerOptions": {
|
||||
"target": "es2020",
|
||||
"typeRoots": ["."],
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// Compile-time contract tests for the admin auth types. `tsc --noEmit` is the
|
||||
// runner: every Expect<...> must resolve to true, and the @ts-expect-error
|
||||
// lines must actually fail without the directive.
|
||||
|
||||
type Equal<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 ? true : false
|
||||
type Expect<T extends true> = T
|
||||
|
||||
const challenge: AdminMfaChallenge = {
|
||||
mfaRequired: true,
|
||||
pendingToken: "pending",
|
||||
expiresIn: 300,
|
||||
methods: ["webauthn", "totp", "recovery"],
|
||||
}
|
||||
type _ChallengeFlag = Expect<Equal<typeof challenge.mfaRequired, true>>
|
||||
type _ChallengeMethods = Expect<Equal<typeof challenge.methods, AdminMfaMethod[]>>
|
||||
type _AuthMethodIncludesPassword = Expect<Equal<AdminMfaMethod extends AdminAuthMethod ? true : false, true>>
|
||||
|
||||
declare const response: AdminLoginResponse<{ id: string }>
|
||||
|
||||
if (response.mfaRequired) {
|
||||
const pending: string = response.pendingToken
|
||||
const methods: AdminMfaMethod[] = response.methods
|
||||
// @ts-expect-error a challenge carries no session token
|
||||
response.token
|
||||
} else {
|
||||
const token: string = response.token
|
||||
const user: { id: string } = response.user
|
||||
const amr: AdminAuthMethod[] | undefined = response.amr
|
||||
}
|
||||
|
||||
const descriptor: AdminWebAuthnDescriptor = { type: "public-key", id: "abc" }
|
||||
const requestOptions: AdminWebAuthnRequestOptions = {
|
||||
challenge: "abc",
|
||||
rpId: "admin.example.com",
|
||||
allowCredentials: [descriptor],
|
||||
timeout: 60000,
|
||||
userVerification: "preferred",
|
||||
}
|
||||
|
||||
const credential: AdminWebAuthnCredentialJSON = {
|
||||
id: "abc",
|
||||
rawId: "abc",
|
||||
type: "public-key",
|
||||
response: { clientDataJSON: "e30", signature: "sig" },
|
||||
}
|
||||
type _AssertionSignature = Expect<Equal<typeof credential.response.signature, string | undefined>>
|
||||
|
||||
const view: AdminWebAuthnCredentialView = {
|
||||
id: "1",
|
||||
label: "YubiKey",
|
||||
createdAt: "2026-01-01T00:00:00Z",
|
||||
backupEligible: false,
|
||||
backupState: false,
|
||||
}
|
||||
|
||||
// The session branch must stay assignable without a factor.
|
||||
const session: AdminLoginSession<{ id: string }> = { token: "t", user: { id: "1" } }
|
||||
Reference in new issue
Block a user