Skip to content

withSecureBuffer()

SIP Protocol API Reference v0.7.2


SIP Protocol API Reference / withSecureBuffer

withSecureBuffer<T>(createSecret, useSecret): Promise<T>

Defined in: @sip-protocol/sdk/dist/index-CzWPI6Le.d.ts:3549

Execute a function with a secret buffer and ensure cleanup

Provides a safer pattern for using secrets - the buffer is automatically wiped after the function completes (or throws).

T

() => Uint8Array

Function to create the secret buffer

(secret) => T | Promise<T>

Function that uses the secret

Promise<T>

The result of useSecret

const signature = await withSecureBuffer(
() => generatePrivateKey(),
async (privateKey) => {
return signMessage(message, privateKey)
}
)
// privateKey is automatically wiped after signing