fix(core): add ScopedStack.putAttachmentBytes() with the same gate as putAttachment()#74
Merged
Merged
Conversation
… putAttachment() Servers implementing the two-step POST /attachments flow had no scoped bytes-only upload — only the unscoped Stack.putAttachmentBytes(), which skips the permission layer entirely. Add ScopedStack.putAttachmentBytes(), gated identically to putAttachment() (anonymous denied, create grant on _attachment@1 required), and refactor putAttachment() to call it so the check lives in exactly one place. Fixes #71
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ScopedStackhad no bytes-only upload — servers implementing the spec's two-stepPOST /attachmentsflow had to either call the unscopedStack.putAttachmentBytes()(a live permission-layer bypass) or reimplement the grant check themselves (violating the layering decided in _config is unprotected: update can change stack ownership, hard delete bricks the stack, query exclusion is a per-adapter convention #67).ScopedStack.putAttachmentBytes(data), gated identically toScopedStack.putAttachment(): anonymous requesters denied,creategrant on_attachment@1required (owner bypasses).putAttachment()now delegates to it, so the check lives in exactly one place.docs/spec.md§Attachments: documents the new method alongside the existingStack/ScopedStackattachment methods, and statesPOST /attachments's authorization requirement (401 anonymous, 403 ungranted) explicitly.Test plan
ScopedStack.putAttachmentBytestest suite inpackages/core/tests/scoped-stack.test.ts: owner bypass, anonymous denial, no-grant denial, granted upload, default-grant upload, confirms no_attachment@1record is created, and confirmsputAttachment()still works end-to-end through the shared gate.pnpm -r build && pnpm -r typecheck && pnpm -r test— all packages pass (189 core tests, plus adapter/record/blob suites).Fixes #71
🤖 Generated with Claude Code
Generated by Claude Code