Skip to content

Prepare for v0.5.0: Fix public API return types (Bytes → Uint8Array)#882

Closed
Copilot wants to merge 2 commits intoprepare-for-v5from
copilot/sub-pr-880-again
Closed

Prepare for v0.5.0: Fix public API return types (Bytes → Uint8Array)#882
Copilot wants to merge 2 commits intoprepare-for-v5from
copilot/sub-pr-880-again

Conversation

Copy link

Copilot AI commented Mar 7, 2026

The Bytes conditional type was incorrectly defined (comparing against string "undefined" and referencing the Buffer constructor rather than instance type), causing public API signatures to expose an environment-dependent type instead of a consistent Uint8Array.

Changes

  • src/types.ts: Removed the broken Bytes conditional type entirely; only IS_BUFFER_SUPPORTED remains
  • src/index.ts: encrypt and decrypt return types changed from BytesUint8Array
  • src/keys/PrivateKey.ts: secret getter return type changed from BytesUint8Array; removed stale // TODO: Uint8Array comment
  • src/keys/PublicKey.ts: uncompressed and compressed getter return types changed from BytesUint8Array

At runtime, Node.js environments still return Buffer (a Uint8Array subtype) for backwards compatibility, but the TypeScript contract is now consistently Uint8Array across all environments.

// v0.4.x — environment-dependent type, broken in browser TS projects
encrypt(...): Bytes  // Buffer | Uint8Array depending on conditional

// v0.5.0 — consistent public contract
encrypt(...): Uint8Array  // Buffer at runtime in Node (still assignable)

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: kigawas <4182346+kigawas@users.noreply.github.com>
Copilot AI changed the title [WIP] Prepare codebase for upcoming v0.5.0 release Prepare for v0.5.0: Fix public API return types (Bytes → Uint8Array) Mar 7, 2026
@kigawas kigawas closed this Mar 7, 2026
@kigawas kigawas reopened this Mar 7, 2026
@kigawas
Copy link
Member

kigawas commented Mar 7, 2026

Close this pr

@kigawas kigawas closed this Mar 7, 2026
@kigawas kigawas deleted the copilot/sub-pr-880-again branch March 9, 2026 07:59
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.

2 participants