f325299d-c1a0-4376-98ae-ddb747d23da5

This commit is contained in:
Z User committed 2026-10-26 17:00:08 +00:00
1 parent 9c58e29472
commit be34f88822
22 files changed
+1361 -1

No files matched your search

+34
View File
@@ -474,4 +474,38 @@ model DunningRun {
createdAt DateTime @default(now())
}
// ---------------------------------------------------------------------------
// Public API (PRD §5.5) — API tokens with scopes, webhooks with HMAC signing
// ---------------------------------------------------------------------------
model ApiToken {
id String @id @default(cuid())
name String
// The token shown to the user ONCE. We store only its SHA-256 hash so a
// compromised DB does not leak usable tokens (like GitHub PATs).
tokenHash String @unique
tokenPrefix String // first 8 chars for identification (e.g. "aos_abc1…")
scopes String // JSON array of scope strings, e.g. ["crm.company:read","finance.invoice:read"]
lastUsedAt DateTime?
expiresAt DateTime?
revokedAt DateTime?
createdAt DateTime @default(now())
}
model Webhook {
id String @id @default(cuid())
url String // https endpoint to deliver to
events String // JSON array, e.g. ["invoice.paid","contract.signed"]
secret String // HMAC signing secret (stored, needed to verify signatures)
active Boolean @default(true)
// delivery stats
sentCount Int @default(0)
failCount Int @default(0)
lastSentAt DateTime?
lastStatus Int? // last HTTP status code received
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}