Skip to content

presignAwsUrl

Presign a URL with SigV4 query parameters (X-Amz-* query style).

function presignAwsUrl(options): Promise<string>;

Defined in: src/utils/aws/sigv4.ts:408

Presign a URL with SigV4 query parameters (X-Amz-* query style).

Parameters

ParameterTypeDescription
optionsPresignAwsUrlOptionsThe URL, scope, credentials, and expiry to presign with.

Returns

Promise<string>

The input URL with X-Amz-* authentication parameters appended.

Remarks

Produces a URL that authenticates without any headers — the mechanism AWS WebSocket APIs (Amazon Transcribe streaming) require, since browsers cannot attach headers to WebSocket handshakes. Only the host header is signed; the payload hash defaults to the SHA-256 of an empty string.

Existing query parameters on the input URL (e.g. language-code, sample-rate) are included in the signature. When the credentials carry a session token, X-Amz-Security-Token is added and signed.

Example

const url = await presignAwsUrl({
  url:
    'wss://transcribestreaming.us-east-1.amazonaws.com:8443' +
    '/stream-transcription-websocket?language-code=en-US&media-encoding=pcm&sample-rate=16000',
  service: 'transcribe',
  region: 'us-east-1',
  credentials: { accessKeyId, secretAccessKey, sessionToken },
  expiresIn: 300,
});
const socket = new WebSocket(url);

© 2026 CompositeVoice. All rights reserved.

Font size
Contrast
Motion
Transparency