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