refactor: Remove client-side PDF parsing and add URL support#8
Merged
nickwinder merged 4 commits intomainfrom Jan 15, 2026
Merged
refactor: Remove client-side PDF parsing and add URL support#8nickwinder merged 4 commits intomainfrom
nickwinder merged 4 commits intomainfrom
Conversation
- Add allowUrlFetch option to client options (default: false) - Block automatic URL fetching by default for SSRF protection - Validate URL protocols (only http/https allowed) - Add helper method normalizeFileInput() to client - Update README.md with import statement in Quick Start - Add SSRF protection documentation section to README - Update and add tests for SSRF protection behavior Security: SSRF protection requires explicit opt-in for URL fetching. Users must set allowUrlFetch: true to enable client-side URL fetching.
- Remove getPdfPageCount, isValidPdf, and processRemoteFileInput functions - Remove allowUrlFetch client option (SSRF protection by design) - Most methods now accept FileInputWithUrl - URLs passed to server - Leverage API's native negative index support (-1 = last page) - sign() remains the only method requiring local files (API limitation) - Reduces bundle size by ~400 lines of PDF parsing code Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
3dd01ee to
00cc18e
Compare
ESLint forbids non-null assertions (!). Replaced array index accesses with explicit undefined checks that TypeScript can verify. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
HungKNguyen
approved these changes
Jan 15, 2026
Collaborator
HungKNguyen
left a comment
There was a problem hiding this comment.
One comment about the type checking for Action with File Input. Per DWS documentation that also support UrlInput. Also we might want to change the Python library as well, to match this new behavior
- Replace unsafe type assertion (as unknown as T) with getRemoteUrl() helper - Validate HTML assets upfront before calling registerAssets - Add comprehensive tests for URL support in action file inputs - Remove unused import and fix linting issues All 266 tests pass. Fixes all issues identified in PR #8 review. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Collaborator
|
Yeah you're right. I've followed up with a commit to support URLs for Action files |
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.
Why
This PR improves API correctness by aligning the SDK with how the server actually works, removing unnecessary client-side complexity.
The previous approach included client-side PDF validation, page counting, and SSRF protection logic. However, this was redundant - the DWS API already handles validation and supports features like negative page indices natively. By removing this client-side processing, we:
Summary
getPdfPageCount,isValidPdf, andprocessRemoteFileInputfunctions that were doing work the server already handlesFileInputWithUrl, allowing users to pass URLs directly (server fetches them)-1for "last page" instead of client-side page counting