@guava-ai/guava-sdk 0.41.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,6 +62,7 @@ export class Call {
62
62
  private readonly _remoteStreamHandlers = new Set<(stream: MediaStream) => void>();
63
63
  private readonly _messageHandlers = new Set<(payload: Record<string, unknown>) => void>();
64
64
  private readonly _webrtcCode: string;
65
+ private readonly _clientToken?: string;
65
66
  private readonly _sockUrl: URL;
66
67
 
67
68
  private readonly _remoteAudio: HTMLAudioElement;
@@ -91,6 +92,7 @@ export class Call {
91
92
 
92
93
  constructor({
93
94
  webrtcCode,
95
+ clientToken,
94
96
  baseUrl = "https://app.goguava.ai/",
95
97
  connectingTone = new JingleTone(),
96
98
  leavingTone = new LeavingTone(),
@@ -100,6 +102,11 @@ export class Call {
100
102
  }: {
101
103
  /** Code used to authenticate with the signaling server. */
102
104
  webrtcCode: string;
105
+ /**
106
+ * Single-use token created by your backend. Required if the code was created with
107
+ * `require_token`. A token is consumed when the call starts, so use a new one for each call.
108
+ */
109
+ clientToken?: string;
103
110
  /** Base URL of the Guava server. Defaults to `https://app.goguava.ai/`. */
104
111
  baseUrl?: string;
105
112
  /** Played while the call is in the "connecting" state. Defaults to {@link JingleTone}. */
@@ -120,6 +127,7 @@ export class Call {
120
127
  audioTrack?: MediaStreamTrack;
121
128
  }) {
122
129
  this._webrtcCode = webrtcCode;
130
+ this._clientToken = clientToken;
123
131
  this._customPayload = customPayload;
124
132
  this._customAudioTrack = audioTrack;
125
133
  if (connectingTone !== "disabled") {
@@ -273,6 +281,7 @@ export class Call {
273
281
  body: JSON.stringify({
274
282
  webrtc_code: this._webrtcCode,
275
283
  chat_session_id: this._chatSessionId,
284
+ client_token: this._clientToken,
276
285
  }),
277
286
  });
278
287
  };