Add browser compatibility by replacing Node.js-specific dependencies#5
Draft
Add browser compatibility by replacing Node.js-specific dependencies#5
Conversation
Co-authored-by: igorovh <37638480+igorovh@users.noreply.github.com>
Co-authored-by: igorovh <37638480+igorovh@users.noreply.github.com>
Co-authored-by: igorovh <37638480+igorovh@users.noreply.github.com>
…ding Co-authored-by: igorovh <37638480+igorovh@users.noreply.github.com>
Co-authored-by: igorovh <37638480+igorovh@users.noreply.github.com>
…sabling Co-authored-by: igorovh <37638480+igorovh@users.noreply.github.com>
Co-authored-by: igorovh <37638480+igorovh@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix compatibility issues for @enhancer/auth-client in browsers
Add browser compatibility by replacing Node.js-specific dependencies
Feb 11, 2026
Member
|
@copilot i see that tests are failing |
Co-authored-by: igorovh <37638480+igorovh@users.noreply.github.com>
Author
Fixed! The tests were failing because the test mock fixtures ( Changes made:
All tests should now pass. Commit: 78ddd85 |
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.
Browser Compatibility Fix - Complete ✅
Problem Statement
The @enhancer/auth-client library could not run in browsers because it used Node.js-specific modules:
Bufferfor base64 encoding (Basic Auth headers)jsonwebtokenlibrary (depends on Node.js crypto, stream, http, https modules)Solution Implemented
1. ✅ Replaced
jsonwebtokenwithjoselibrarysrc/jwt/verifier.tsto usejose.jwtVerify()tests/mocks/fixtures.tsto usejose.SignJWT()for test token generation2. ✅ Created browser-compatible base64 utility
src/utils/base64.tswith runtime detectionbtoa/atobin browsers,Bufferin Node.jssrc/utils/http-client.tsto use new utility3. ✅ Updated build system
build.mjsusing esbuild (works without Bun)dist/browser/index.js)"browser"export in package.json4. ✅ Updated documentation
5. ✅ Fixed test failures
Testing & Validation
✅ All tests pass:
✅ Browser compatibility verified:
Changes Summary
jsonwebtoken,@types/jsonwebtokenjose,esbuild(dev)Build Output
dist/index.mjs(~2KB unbundled)dist/index.js(~2KB unbundled)dist/browser/index.js(~180KB bundled with jose)Security
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.