Skip to content

feat(key-card): add PDF keycard parsing via pdfjs-dist (WCN-19)#8509

Draft
mohammadalfaiyazbitgo wants to merge 1 commit intomasterfrom
feat/pdf-parser
Draft

feat(key-card): add PDF keycard parsing via pdfjs-dist (WCN-19)#8509
mohammadalfaiyazbitgo wants to merge 1 commit intomasterfrom
feat/pdf-parser

Conversation

@mohammadalfaiyazbitgo
Copy link
Copy Markdown
Contributor

@mohammadalfaiyazbitgo mohammadalfaiyazbitgo commented Apr 14, 2026

Summary

  • Implements extractKeycardEntriesFromPDF() in @bitgo/key-card, moving PDF upload/parse logic from the UI layer into the SDK (Linear: WCN-19)
  • Uses pdfjs-dist/webpack.mjs (Mozilla's official webpack entry point) so GlobalWorkerOptions.workerPort is auto-configured — no manual worker setup required
  • Reconstructs visual lines from PDF text nodes (sorted by page → y → x), then parses labelled sections A–D and their data: values with brace-depth tracking for multi-line JSON
  • Stops at the "BitGo KeyCard FAQ" section header
  • Exports KeycardEntry and PDFTextNode types publicly from @bitgo/key-card
  • Adds a ParseKeycard demo component in @bitgo/web-demo at /parse-keycard
  • Bumps root webpack to 5.106.1 (fixes an ESM module initialisation bug that caused Object.defineProperty called on non-object with pdfjs-dist v5 under webpack 5.98)

Test plan

  • Unit tests pass: yarn workspace @bitgo/key-card unit-test
  • TypeScript compiles cleanly: yarn workspace @bitgo/key-card tsc --noEmit
  • Manual: start web-demo (yarn workspace @bitgo/web-demo dev), navigate to /parse-keycard, upload a GG18 keycard PDF — table of parsed sections (A/B/C/D) should appear
  • Upload a second PDF in the same session (tests no cached broken module)
  • Validate parsed values via assertIsValidKey method on tss and utxo wallets.

🤖 Generated with Claude Code

@linear
Copy link
Copy Markdown

linear bot commented Apr 14, 2026

@mohammadalfaiyazbitgo mohammadalfaiyazbitgo marked this pull request as draft April 14, 2026 20:36
@mohammadalfaiyazbitgo mohammadalfaiyazbitgo force-pushed the feat/pdf-parser branch 2 times, most recently from 1c1757c to d4ab6b1 Compare April 15, 2026 03:48
@mohammadalfaiyazbitgo mohammadalfaiyazbitgo marked this pull request as ready for review April 15, 2026 03:53
Implements extractKeycardEntriesFromPDF() in @bitgo/key-card, moving
PDF upload/parse logic from the UI layer into the SDK (WCN-19).

- Adds pdfjs-dist dependency (v5) using the official webpack.mjs entry
  point so GlobalWorkerOptions.workerPort is auto-configured by webpack
  with no manual worker setup required
- Reconstructs visual text lines from PDF text nodes (page/y/x sort)
- Parses labelled keycard sections (A–D) and their data values with
  brace-depth tracking for multi-line JSON fields
- Stops parsing at the BitGo KeyCard FAQ header
- Exports KeycardEntry and PDFTextNode types from @bitgo/key-card
- Adds unit tests covering line reconstruction and section parsing
- Wires up a ParseKeycard demo component in @bitgo/web-demo
- Bumps root webpack to 5.106.1 (fixes ESM init bug with pdfjs-dist v5)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant