API reference / @jsprismarine/nethernet / NetherNetIdentity
Class: NetherNetIdentity
Defined in: packages/nethernet/src/NetherNetIdentity.ts:55
A NetherNet identity: a P-384 key whose public half a session description carries, signed, in a=identity. A client refuses an answer without one, and Bedrock Dedicated Server refuses an offer without one.
A server's key must survive restarts: over plain HTTP the client remembers it the first time and asks the player about any other. NetherNetIdentity.loadOrCreate keeps it in a file.
Constructors
Constructor
new NetherNetIdentity(
privateKey,options?):NetherNetIdentity
Defined in: packages/nethernet/src/NetherNetIdentity.ts:66
Parameters
privateKey
KeyObject
A P-384 private key.
options?
How the identity presents itself; a server's by default.
Returns
NetherNetIdentity
Methods
sign()
sign(
description):Promise<string>
Defined in: packages/nethernet/src/NetherNetIdentity.ts:109
The description with a=identity added: a self-signed token carrying the public key as cpk, and a detached signature over the description's DTLS fingerprints, which binds the key to the certificate WebRTC will present.
Parameters
description
string
The SDP offer or answer, with its a=fingerprint lines.
Returns
Promise<string>
Throws
When the description has no fingerprint to sign.
client()
staticclient(domain?):NetherNetIdentity
Defined in: packages/nethernet/src/NetherNetIdentity.ts:85
A fresh client identity, for one connection.
Parameters
domain?
string = 'self'
The identity provider's domain, as the client names it.
Returns
NetherNetIdentity
loadOrCreate()
staticloadOrCreate(file):NetherNetIdentity
Defined in: packages/nethernet/src/NetherNetIdentity.ts:94
Reads the key from file, or makes one and writes it there, readable by its owner only.
Parameters
file
string
Where the PKCS #8 PEM key lives.
Returns
NetherNetIdentity