token

package
v0.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package token is the copy-paste enrollment token that carries what a peer needs to join: the JWT that authenticates it, and the hub's tunnel URL to dial.

The token IS the JWT, in JWS compact serialization (header.payload.signature). The tunnel URL rides in the audience claim, so there is one format on the wire and any JWT tool can read it. Tokens minted before v0.20 were a base64 JSON envelope wrapping the same JWT; Decode still accepts those so tokens already handed out keep working.

Transport encryption is the deployment's job — a TLS edge, ingress, or mesh in front of the hub — so the token carries no certificate: a wss:// tunnel URL dials TLS under the WebSocket (verified with the system roots), a ws:// one dials plaintext. https:// and http:// are accepted as aliases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JoinToken

type JoinToken struct {
	Peer      string // JWT subject
	TunnelURL string // JWT audience: e.g. wss://holt.example.com
	JWT       string // the compact JWS the peer presents on attach
}

JoinToken is the decoded view of a join token.

func Decode

func Decode(s string) (JoinToken, error)

Decode parses a join token: a compact JWS, or the pre-v0.20 base64 JSON envelope. The signature is NOT verified — the peer holds no key, and the hub is the one that checks it on attach.

func (JoinToken) WSURL

func (t JoinToken) WSURL() (string, error)

WSURL resolves the tunnel URL into its WebSocket form: ws and wss pass through, http maps to ws and https to wss (pre-WebSocket tokens keep working). Any other scheme, or a missing host, is an error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL