Skip to content

withSecureBuffer()

SIP Protocol API Reference v0.7.0


SIP Protocol API Reference / withSecureBuffer

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

Defined in: @sip-protocol/sdk/dist/index-BYZbDjal.d.ts:3486

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