Skip to content

Publish pentest-calculator to npm with ESM exports and branding control#3

Merged
dmchaledev merged 2 commits into
mainfrom
claude/audit-npm-readiness-kbZ82
May 18, 2026
Merged

Publish pentest-calculator to npm with ESM exports and branding control#3
dmchaledev merged 2 commits into
mainfrom
claude/audit-npm-readiness-kbZ82

Conversation

@dmchaledev
Copy link
Copy Markdown
Contributor

Summary

This PR prepares the pentest-calculator web component for npm publication as @hailbytes/pentest-calculator, adding proper ESM exports, TypeScript declarations, a white-label branding toggle, and CI/CD workflows.

Key Changes

  • npm package configuration: Added package.json with proper ESM exports, type declarations, and metadata for public npm publication
  • ESM exports: Added export default and named exports to hailbytes-pentest-calculator.js so the component class can be imported directly (previously only side-effect registration was available)
  • Branding control: Added branding="off" attribute support to hide the "by HailBytes" footer and header badge for white-label embeds
    • Updated observedAttributes to include 'branding'
    • Added CSS rules to hide .hb-branding and .hailbytes-badge when attribute is set
    • Added footer HTML with link to https://hailbytes.com/asm
  • TypeScript declarations: Added index.d.ts with full type definitions for PentestInputs, PentestResult, and the HailbytesPentestCalculator class, plus global type augmentation for custom events
  • Documentation: Updated README.md with npm install instructions, usage examples for both bundlers and script tags, and links to related HailBytes calculator packages
  • CI/CD workflows:
    • Added .github/workflows/ci.yml for testing on Node 18, 20, 22
    • Added .github/workflows/publish.yml for automated npm publishing with provenance on git tags
  • Testing: Added test/smoke.test.mjs with minimal DOM shim to verify module exports and observed attributes
  • Project files: Added CHANGELOG.md, .gitignore, and updated footer branding

Implementation Details

  • The component maintains backward compatibility — existing <script> tag usage works unchanged
  • The branding="off" attribute is CSS-only (no JavaScript logic needed)
  • Smoke tests use Node's built-in node:test module with zero dev dependencies
  • npm publish is configured with provenance: true for supply chain security

https://claude.ai/code/session_01HevhhhYskCrTDfb2oxg7NK

…f", npm install docs

- hailbytes-pentest-calculator.js
  - Add 'branding' to observedAttributes
  - Add a real in-component footer with link to https://hailbytes.com/asm
    (previously there was only a non-clickable badge in the H1)
  - CSS rule :host([branding=off]) .hb-branding, .hailbytes-badge { display:none }
  - Add ESM exports (default + named class); previously only side-effect
- README.md
  - Replace "no npm install" with npm install + npm-CDN snippets
  - Document branding="off"
  - Add "See also" cross-link to sibling @hailbytes/* packages
  - Repoint built-by line to /asm
@dmchaledev dmchaledev merged commit 373f896 into main May 18, 2026
3 checks passed
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