@hyperfrontend/network-protocol/node/v1v1
Node.js-side V1 protocol: dynamic key exchange with time-based packet obfuscation.
V1 establishes per-channel encryption keys with a FirstMessageHandler handshake — neither end needs a pre-shared secret. Once established, the dynamic key encrypts the application payload while the obfuscation layer rotates a time-derived password (getTimeBasedPassword / getTimeBasedPasswords) on a configurable interval to harden against passive replay analysis. This entry point composes the lib/protocol/v1 factory with @hyperfrontend/cryptography/node and exposes createProtocol plus the supporting type surface. Wire-compatible with /browser/v1, so a Node service and a browser client can negotiate a V1 channel end-to-end. Use V1 when you need a zero-config secure channel; use /node/v2 when both ends share a long-lived secret.
API Reference
ƒ Functions
createObfuscatedHandshakeProtocolFactory<T>(createDynamicKeyEncryption: (provider: () => string) => EncryptionSuite<T>, createTimeIntervalObfuscation: (refreshRate: number) => ObfuscationSuite): (logger: Logger, refreshRate: number) => ProtocolProvider<T>
This is the Obfuscation-Only Handshake protocol model (V1):
- First message: NO encryption (obfuscation only) - key transmitted in payload
- Key capture: Dynamic key extracted from
packet.data.keyon receive - Subsequent messages: Encrypted with dynamically captured keys
- First outbound message: Obfuscated but NOT encrypted (no key exists yet)
- First inbound message: Deobfuscated, key extracted from
packet.data.key - Subsequent messages: Both obfuscated AND encrypted with dynamic keys
Both protocols use time-based obfuscation as an additional security layer.
Parameters
Returns
(logger: Logger, refreshRate: number) => ProtocolProvider<T>Example
Creating a protocol provider with obfuscated handshake
const createProvider = createObfuscatedHandshakeProtocolFactory(
createDynamicKeyEncryption,
createTimeIntervalObfuscation
)
const protocolProvider = createProvider(logger, 5)
const protocol = protocolProvider(sendFn, receiveFn)Returns
ProtocolProviderStoreExample
Creating and using a protocol provider store
const store = createProtocolProviderStore()
store.add('websocket', myProtocolProvider)
const provider = store.getByName('websocket')Parameters
| Name | Type | Description |
|---|---|---|
§name | string | The name to validate |
Returns
booleanExample
Validating protocol names
isValidName('websocket')
// => true
isValidName('')
// => falseParameters
| Name | Type | Description |
|---|---|---|
§protocol | unknown | The value to validate as a protocol |
Returns
ValidProtocolResultExample
Validating a protocol object
const result = isValidProtocol(myProtocol)
// => { packetEncryption: true, packetDecryption: true, ... }
const invalid = isValidProtocol({})
// => { packetEncryption: false, packetDecryption: undefined, ... }Parameters
| Name | Type | Description |
|---|---|---|
§protocolProvider | unknown | The value to validate as a protocol provider |
Returns
booleanExample
Validating a protocol provider function
isValidProtocolProvider(() => protocol)
// => true
isValidProtocolProvider('not-a-function')
// => falseParameters
| Name | Type | Description |
|---|---|---|
§receive | unknown | The value to validate as a receive function |
Returns
booleanExample
Validating a receive function
isValidReceiveFn((packet) => console.log(packet))
// => true
isValidReceiveFn(null)
// => falseParameters
| Name | Type | Description |
|---|---|---|
§send | unknown | The value to validate as a send function |
Returns
booleanExample
Validating a send function
isValidSendFn((packet) => websocket.send(packet))
// => true
isValidSendFn('not-a-function')
// => false◈ Interfaces
Properties
readonly add:(name: string, protocolProvider: ProtocolProvider<T>) => void— ◆ Types
type ValidProtocolResult = mapped● Variables
First Message Handling: The first message (before key exchange) is sent with obfuscation only. When received, the key is extracted and used for subsequent encrypted messages.
createObfuscatedHandshakeProtocolFactory instead. This alias exists for backward compatibility.