diff --git a/src/api/invitation-accept-options.ts b/src/api/invitation-accept-options.ts index 5b3efa315..afc7996fc 100644 --- a/src/api/invitation-accept-options.ts +++ b/src/api/invitation-accept-options.ts @@ -5,6 +5,10 @@ import { SessionDescriptionHandlerModifier, SessionDescriptionHandlerOptions } f * @public */ export interface InvitationAcceptOptions { + /** + * Array of extra headers added to the response. + */ + extraHeaders?: Array; /** * Modifiers to pass to SessionDescriptionHandler during the initial INVITE transaction. */ diff --git a/src/api/invitation.ts b/src/api/invitation.ts index 535c9c385..85b43bce1 100644 --- a/src/api/invitation.ts +++ b/src/api/invitation.ts @@ -259,7 +259,7 @@ export class Invitation extends Session { this.stateTransition(SessionState.Establishing); return ( - this.sendAccept() + this.sendAccept(options) // eslint-disable-next-line @typescript-eslint/no-unused-vars .then(({ message, session }) => { session.delegate = { @@ -565,12 +565,14 @@ export class Invitation extends Session { * A version of `accept` which resolves a session when the 200 Ok response is sent. * @param options - Options bucket. */ - private sendAccept(): Promise { + private sendAccept(options: InvitationAcceptOptions = {}): Promise { const responseOptions = { sessionDescriptionHandlerOptions: this.sessionDescriptionHandlerOptions, sessionDescriptionHandlerModifiers: this.sessionDescriptionHandlerModifiers }; + const extraHeaders = options.extraHeaders || []; + // The UAS MAY send a final response to the initial request before // having received PRACKs for all unacknowledged reliable provisional // responses, unless the final response is 2xx and any of the @@ -588,12 +590,12 @@ export class Invitation extends Session { return this.waitForArrivalOfPrack() .then(() => clearTimeout(this.userNoAnswerTimer)) // Ported .then(() => this.generateResponseOfferAnswer(this.incomingInviteRequest, responseOptions)) - .then((body) => this.incomingInviteRequest.accept({ statusCode: 200, body })); + .then((body) => this.incomingInviteRequest.accept({ statusCode: 200, body, extraHeaders })); } clearTimeout(this.userNoAnswerTimer); // Ported return this.generateResponseOfferAnswer(this.incomingInviteRequest, responseOptions).then((body) => - this.incomingInviteRequest.accept({ statusCode: 200, body }) + this.incomingInviteRequest.accept({ statusCode: 200, body, extraHeaders }) ); }