Repository navigation
fix(v2): validate create body, honour token, fingerprint idempotency - #1808
Dev-Savio-hub wants to merge 2 commits into
Conversation
|
@Dev-Savio-hub Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Held: this PR removes the 401 "Bearer token required" check on |
|
Thanks for the work on the shared stream-core refactor. We can't merge this yet, for these reasons:
Please rebase on the latest main, restore the auth check, finish the merge so the handler uses |
Closes #1736
Summary
Applies the shared create-stream validation schema (
validateCreateStreamBody), token normalisation (normaliseToken), token allowlist checks (checkTokenAllowed/checkTokenAllowedForOrg), and fingerprinted idempotency (computeFingerprint+checkIdempotency/setIdempotency) toPOST /api/v2/streams. Also moves the per-org daily quota check (checkOrgDailyQuota) to run only after validation and allowlist checks succeed so malformed or rejected requests do not consume quota.Shared Core & Remaining v1 vs v2 Differences
Shared Core (
createStreamCoreinapp/lib/stream-core.ts)Both
POST /api/streams(v1) andPOST /api/v2/streams(v2) now delegate tocreateStreamCore(input):validateCreateStreamBody(body)and returns422 VALIDATION_ERRORwith field-leveldetailson failure.rawToken?.trim() || "XLM") vianormaliseToken, returning422 INVALID_TOKENon malformed asset strings.checkTokenAllowedForOrg(when anorgis provided) orcheckTokenAllowed, returning422 TOKEN_NOT_ALLOWEDwhen disallowed.beforePersistgate (used by v2 to charge the per-org daily quota only after all validation and allowlist checks pass).Streamentity with the normalisedtoken(replacing the hardcoded"XLM"in v2) and records the"created"lifecycle event viaappendStreamHistoryEvent.