Skip to content

Rewrite to TypeScript, add MessageV2/IPv6 support, CI and CLI#4

Open
antondalgren wants to merge 13 commits intomainfrom
sparoid-v2-typescript
Open

Rewrite to TypeScript, add MessageV2/IPv6 support, CI and CLI#4
antondalgren wants to merge 13 commits intomainfrom
sparoid-v2-typescript

Conversation

@antondalgren
Copy link

WHY are these changes introduced?

Ipv6 support

WHAT is this pull request doing?

  • Rewrite src and tests from .mjs to TypeScript
  • Add MessageV2 with IPv4/IPv6 CIDR range support
  • Add IPv6 public IP detection and global address discovery
  • Fix encrypt/prefixHmac to handle variable-length messages
  • Remove dist/ from git, build on prepublishOnly instead
  • Add CLI script (src/cli.ts) for sending auth from command line
  • Add GitHub Actions for CI (lint + test) and release (npm publish)
  • Migrate eslint to flat config with typescript-eslint

HOW was this pull request tested?

Specs, manually with the CLI and a compatible server.

- Rewrite src and tests from .mjs to TypeScript
- Add MessageV2 with IPv4/IPv6 CIDR range support
- Add IPv6 public IP detection and global address discovery
- Fix encrypt/prefixHmac to handle variable-length messages
- Remove dist/ from git, build on prepublishOnly instead
- Add CLI script (src/cli.ts) for sending auth from command line
- Add GitHub Actions for CI (lint + test) and release (npm publish)
- Migrate eslint to flat config with typescript-eslint
prepublishOnly already runs the build before npm publish.
@antondalgren antondalgren requested a review from a team as a code owner February 18, 2026 13:53
@antondalgren antondalgren requested review from Copilot and removed request for a team February 18, 2026 13:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the SPAroid client by migrating the codebase/tests to TypeScript and extending the auth message format to support IPv6 and CIDR ranges, while also adding a CLI and GitHub Actions workflows for CI/release.

Changes:

  • Rewrites source + tests from .mjs to TypeScript (NodeNext), with updated lint/build tooling.
  • Introduces MessageV2 supporting IPv4/IPv6 + range, plus IPv6 parsing and global address discovery.
  • Adds a CLI entrypoint and CI/release workflows; removes committed dist/ in favor of building on publish.

Reviewed changes

Copilot reviewed 15 out of 18 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
tsconfig.json Adds TS compiler configuration targeting NodeNext output to dist/.
test/test.ts Rewrites auth smoke test to TS/AVA.
test/test.mjs Removes legacy MJS test.
test/message.ts Adds TS tests for MessageV1/V2 layout and crypto round-trips.
test/ipv6.ts Adds TS tests for IPv6 string-to-buffer conversion.
src/sparoid.ts Rewrites auth flow in TS; adds IPv6/global IPv6 support and MessageV2 usage.
src/sparoid.mjs Removes legacy MJS implementation.
src/message.ts Adds MessageV1 and new MessageV2 serialization.
src/ipv6.ts Adds IPv6 parsing + global IPv6 discovery helpers.
src/cli.ts Adds CLI for sending auth packets from an INI file.
rollup.config.js Updates bundling to build CJS from compiled dist/sparoid.js.
package.json Updates scripts/tooling; updates exports/types to ship from dist/.
eslint.config.js Migrates ESLint to flat config with typescript-eslint.
dist/sparoid.cjs Removes committed build artifact.
.gitignore Ignores dist/ directory.
.github/workflows/release.yml Adds release workflow to lint/test and publish on tags.
.github/workflows/ci.yml Adds CI workflow to lint/test on PRs and main.
.eslintrc.json Removes legacy ESLint config.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@oskgu360
Copy link
Contributor

oskgu360 commented Feb 19, 2026

I don't wanna be that guy, but would be easier to review if this was seperate PRs 🙈 I'll give it a shot anyway tho

EDIT: Ah, it wasn't maybe up for review yet either

@antondalgren
Copy link
Author

I don't wanna be that guy, but would be easier to review if this was seperate PRs 🙈 I'll give it a shot anyway tho

EDIT: Ah, it wasn't maybe up for review yet either

Close enough to be ready. But the only real change that matters for js -> ts is sparoid.mjs -> sparoid.ts which is -96 and +104. What I could do is to extract the ci parts I think? Would that simplify it?

@oskgu360
Copy link
Contributor

I don't wanna be that guy, but would be easier to review if this was seperate PRs 🙈 I'll give it a shot anyway tho
EDIT: Ah, it wasn't maybe up for review yet either

Close enough to be ready. But the only real change that matters for js -> ts is sparoid.mjs -> sparoid.ts which is -96 and +104. What I could do is to extract the ci parts I think? Would that simplify it?

Nah, seems files are quite isolated to changes. Just read PR description at first and got a bit overloaded :) But I can manage, now when I actually looked at what files changed

Parse addresses like ::ffff:192.0.2.128 correctly instead of
silently producing wrong bytes from parseInt on dotted octets.
Avoids live HTTP requests in tests, making the test suite
offline-friendly and faster in CI.
Send all UDP packets via Promise.all instead of fire-and-forget.
Also filter out undefined results from publicIp discovery.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 19 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@antondalgren antondalgren requested a review from a team February 19, 2026 12:34
Remove MessageV1 usage from auth() and tests. Use unshift to
ensure the IPv4 V2 message is sent before IPv6 messages.
const [iniFile, host, portArg] = process.argv.slice(2)

if (!iniFile || !host) {
console.error("Usage: npx tsx src/cli.ts <ini-file> <host> [port]")
Copy link
Member

@baelter baelter Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of requiring npx tsx src/cli.ts ..., set up a proper CLI entry in package.json using the bin field and add a shebang (#!/usr/bin/env node) at the top of the script. This allows users to run the CLI with a simple command (e.g., sparoid), making installation and usage friendlier?

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.

4 participants