@anganyai/voice-sdk 0.0.4 → 0.0.5

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.
package/dist/index.js CHANGED
@@ -17418,27 +17418,33 @@ var Conversation = class extends EventEmitter {
17418
17418
  throw new AuthenticationError("Not authenticated");
17419
17419
  }
17420
17420
  this.logger.debug("\u2713 Authentication check passed");
17421
- this.logger.debug("=== STEP 2: GETTING ACCESS TOKEN ===");
17421
+ this.logger.debug("=== STEP 2: GETTING ACCESS TOKEN (OPTIONAL) ===");
17422
17422
  let accessToken = authStatus.tokens?.accessToken;
17423
17423
  this.logger.debug("OAuth access token", { hasOAuthToken: !!accessToken });
17424
17424
  if (!accessToken) {
17425
17425
  this.logger.debug("No OAuth access token in auth status, trying to get from AuthManager");
17426
- accessToken = await this.authManager.getAccessToken();
17426
+ try {
17427
+ accessToken = await this.authManager.getAccessToken();
17428
+ } catch {
17429
+ }
17427
17430
  this.logger.debug("Access token from AuthManager", { hasToken: !!accessToken });
17428
17431
  }
17429
17432
  if (!accessToken) {
17430
- this.logger.error("No access token available for API calls", {
17431
- hasOAuthToken: !!authStatus.tokens?.accessToken,
17432
- hasEphemeralCredentials: this.authManager.hasValidEphemeralCredentials()
17433
+ this.logger.debug("No OAuth access token, checking ephemeral credentials for API token");
17434
+ const cachedCreds = this.authManager.getCachedEphemeralCredentials();
17435
+ if (cachedCreds?.apiToken) {
17436
+ accessToken = cachedCreds.apiToken;
17437
+ this.logger.debug("Using API token from ephemeral credentials");
17438
+ }
17439
+ }
17440
+ if (!accessToken) {
17441
+ this.logger.info("No access token available - running in SIP-only mode (no transcription/API features)");
17442
+ } else {
17443
+ this.accessToken = accessToken;
17444
+ this.logger.debug("\u2713 Access token obtained for API calls", {
17445
+ tokenLength: accessToken.length
17433
17446
  });
17434
- throw new AuthenticationError(
17435
- "No access token available for API calls. Ephemeral credentials are only for SIP/WebRTC connections."
17436
- );
17437
17447
  }
17438
- this.accessToken = accessToken;
17439
- this.logger.debug("\u2713 Access token obtained for API calls", {
17440
- tokenLength: accessToken.length
17441
- });
17442
17448
  this.logger.debug("=== STEP 3: ENSURING EPHEMERAL CREDENTIALS ===");
17443
17449
  if (!this.ephemeralCredentials) {
17444
17450
  this.logger.debug("Getting ephemeral credentials");
@@ -17547,19 +17553,23 @@ var Conversation = class extends EventEmitter {
17547
17553
  this.setupSipHandlers();
17548
17554
  this.logger.debug("Registering with SIP server");
17549
17555
  await this.sipManager.register();
17550
- this.transcriptionService.setTokenRefreshCallback(async () => {
17551
- this.logger.debug("TranscriptionService requesting fresh token");
17552
- const freshToken = await this.authManager.getAccessToken();
17553
- if (!freshToken) {
17554
- throw new Error("Unable to get fresh access token");
17555
- }
17556
- this.accessToken = freshToken;
17557
- this.logger.debug("Fresh token provided to TranscriptionService");
17558
- return freshToken;
17559
- });
17560
- this.logger.debug("Starting transcription stream");
17561
- await this.transcriptionService.start(this.accessToken);
17562
- this.setupTranscriptionHandlers();
17556
+ if (this.accessToken) {
17557
+ this.transcriptionService.setTokenRefreshCallback(async () => {
17558
+ this.logger.debug("TranscriptionService requesting fresh token");
17559
+ const freshToken = await this.authManager.getAccessToken();
17560
+ if (!freshToken) {
17561
+ throw new Error("Unable to get fresh access token");
17562
+ }
17563
+ this.accessToken = freshToken;
17564
+ this.logger.debug("Fresh token provided to TranscriptionService");
17565
+ return freshToken;
17566
+ });
17567
+ this.logger.debug("Starting transcription stream");
17568
+ await this.transcriptionService.start(this.accessToken);
17569
+ this.setupTranscriptionHandlers();
17570
+ } else {
17571
+ this.logger.info("Skipping transcription service - no access token available");
17572
+ }
17563
17573
  this.logger.debug("Making call to resource", { resourceId: this.options.resource });
17564
17574
  const callOptions = {
17565
17575
  resourceId: this.options.resource,