@azure/communication-signaling
Advanced tools
Comparing version 1.0.0-beta.7 to 1.0.0-beta.8
{ | ||
"name": "@azure/communication-signaling", | ||
"version": "1.0.0-beta.7", | ||
"version": "1.0.0-beta.8", | ||
"description": "Azure Communication Signaling Client", | ||
@@ -75,3 +75,3 @@ "sdk-type": "client", | ||
"@rollup/plugin-replace": "^2.2.1", | ||
"@skype/tstrouter": "2020.37.0-1.1-d26fc", | ||
"@skype/tstrouter": "2021.32.0-0.28-af1c4", | ||
"@types/chai": "^4.2.11", | ||
@@ -78,0 +78,0 @@ "@types/mocha": "^7.0.2", |
@@ -44,2 +44,3 @@ // Copyright (c) Microsoft Corporation. | ||
} from "./events/identifierModels"; | ||
import { MAX_NUMBER_OF_TOKEN_FETCH_RETRIES } from "./constants"; | ||
import { AzureLogger } from "@azure/logger"; | ||
@@ -104,3 +105,3 @@ import { AbortSignalLike, AccessToken } from '@azure/core-http'; | ||
*/ | ||
stop(): void; | ||
stop(isTokenExpired?: boolean): void; | ||
/** | ||
@@ -183,2 +184,3 @@ * Listen to connectionChanged events. | ||
private stateChangedListener: StateChangedListener = null; | ||
private tokenFetchRetries: number = 0; | ||
@@ -193,3 +195,15 @@ constructor( | ||
trouterSettings: createSettings(options), | ||
skypeTokenProvider: async () => Promise.resolve((await credential.getToken()).token), | ||
skypeTokenProvider: async (forceRefresh: boolean) => { | ||
if (forceRefresh) { | ||
this.tokenFetchRetries += 1; | ||
if (this.tokenFetchRetries > MAX_NUMBER_OF_TOKEN_FETCH_RETRIES) { | ||
this.stop(true); | ||
throw new Error("Access token is expired and failed to fetch a valid one after " + MAX_NUMBER_OF_TOKEN_FETCH_RETRIES + " retries"); | ||
} | ||
} else { | ||
this.tokenFetchRetries = 0; | ||
} | ||
return Promise.resolve((await credential.getToken()).token) | ||
}, | ||
telemetryConfig: { | ||
@@ -207,6 +221,6 @@ eventLogger: toTelemetrySender(logger), | ||
public stop(): void { | ||
public stop(isTokenExpired?: boolean): void { | ||
this.trouter.offStateChanged(this.stateChangedListener); | ||
this.trouter.clearMessageHandlers(); | ||
this.trouter.stop(); | ||
this.trouter.stop(isTokenExpired ?? this.tokenFetchRetries > MAX_NUMBER_OF_TOKEN_FETCH_RETRIES); | ||
} | ||
@@ -213,0 +227,0 @@ |
@@ -29,3 +29,3 @@ import { ChatEventId, BaseChatEvent, BaseChatMessageEvent, ChatMessageReceivedEvent, ChatMessageEditedEvent, ChatMessageDeletedEvent, ReadReceiptReceivedEvent, TypingIndicatorReceivedEvent, BaseChatThreadEvent, ChatParticipant, ChatThreadProperties, ChatThreadCreatedEvent, ChatThreadDeletedEvent, ChatThreadPropertiesUpdatedEvent, ParticipantsAddedEvent, ParticipantsRemovedEvent } from "./events/chat"; | ||
*/ | ||
stop(): void; | ||
stop(isTokenExpired?: boolean): void; | ||
/** | ||
@@ -81,5 +81,6 @@ * Listen to connectionChanged events. | ||
private stateChangedListener; | ||
private tokenFetchRetries; | ||
constructor(credential: CommunicationTokenCredential, logger: AzureLogger, options?: SignalingClientOptions); | ||
start(): void; | ||
stop(): void; | ||
stop(isTokenExpired?: boolean): void; | ||
on(event: "connectionChanged", listener: (state: ConnectionState) => void): void; | ||
@@ -86,0 +87,0 @@ on(event: "chatMessageReceived", listener: (payload: ChatMessageReceivedEvent) => void): void; |
@@ -226,5 +226,6 @@ import { AbortSignalLike } from '@azure/core-http'; | ||
private stateChangedListener; | ||
private tokenFetchRetries; | ||
constructor(credential: CommunicationTokenCredential, logger: AzureLogger, options?: SignalingClientOptions); | ||
start(): void; | ||
stop(): void; | ||
stop(isTokenExpired?: boolean): void; | ||
on(event: "connectionChanged", listener: (state: ConnectionState) => void): void; | ||
@@ -392,3 +393,3 @@ on(event: "chatMessageReceived", listener: (payload: ChatMessageReceivedEvent) => void): void; | ||
*/ | ||
stop(): void; | ||
stop(isTokenExpired?: boolean): void; | ||
/** | ||
@@ -395,0 +396,0 @@ * Listen to connectionChanged events. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3087613
28
11867