Skip to content

Support URL path in Electrum credentials for path-based API keys#928

Merged
lukasz-zimnoch merged 2 commits intomainfrom
electrum-path-auth
Mar 3, 2026
Merged

Support URL path in Electrum credentials for path-based API keys#928
lukasz-zimnoch merged 2 commits intomainfrom
electrum-path-auth

Conversation

@pdyraga
Copy link
Copy Markdown
Member

@pdyraga pdyraga commented Mar 3, 2026

Some Electrum RPC providers expose authenticated WebSocket endpoints where the API key is embedded in the URL path (e.g. wss://host:443/<api-key>). Previously, parseElectrumCredentials discarded the path component entirely, and silently produced NaN when the URL lacked an explicit port.

Added an optional path field to ElectrumCredentials and passed it through to the electrum-client-js constructor.

Additionally, the code now throws an explicit error when the port cannot be parsed from the URL. I wanted to keep the changes minimal and not change the port parsing code, but added an explicit error to avoid NaN during execution.

Added unit tests for fromUrl covering path extraction, missing port rejection, array input, and bare-slash normalization.

Comment thread typescript/package.json Outdated
Some Electrum RPC providers expose authenticated WebSocket endpoints
where the API key is embedded in the URL path (e.g.
wss://host:443/<api-key>). Previously, parseElectrumCredentials
discarded the path component entirely, and silently produced NaN
when the URL lacked an explicit port.

Add optional `path` field to ElectrumCredentials and pass it through
to the electrum-client-js constructor. Throw an explicit error when
the port cannot be parsed from the URL. Bump electrum-client-js to
a commit that accepts the path parameter in its constructor chain.

Add unit tests for fromUrl covering path extraction, missing port
rejection, array input, and bare-slash normalization.
@pdyraga pdyraga force-pushed the electrum-path-auth branch from b2ea191 to 64f200f Compare March 3, 2026 08:46
The new v0.2.0 version has just been released. It's the same code as the
previously referenced dev commit hash.
@pdyraga pdyraga marked this pull request as ready for review March 3, 2026 10:29
@lukasz-zimnoch lukasz-zimnoch merged commit 62ca20f into main Mar 3, 2026
48 checks passed
@lukasz-zimnoch lukasz-zimnoch deleted the electrum-path-auth branch March 3, 2026 10:46
@pdyraga pdyraga added this to the typescript/v3.1.0 milestone Mar 3, 2026
@pdyraga pdyraga added the 🔌 typescript TypeScript library label Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔌 typescript TypeScript library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants