@azure/communication-signaling
Advanced tools
Comparing version 1.0.0-beta.15 to 1.0.0-beta.16
{ | ||
"name": "@azure/communication-signaling", | ||
"version": "1.0.0-beta.15", | ||
"version": "1.0.0-beta.16", | ||
"description": "Azure Communication Signaling Client", | ||
@@ -5,0 +5,0 @@ "sdk-type": "client", |
@@ -11,2 +11,5 @@ // Copyright (c) Microsoft Corporation. | ||
// GCC gov cloud URLs | ||
export const GCC_TROUTER_SERVICE_URL = "https://go.trouter.gcc.teams.microsoft.com/v4/a"; | ||
// DoD gov cloud URLs | ||
@@ -13,0 +16,0 @@ export const DOD_TROUTER_SERVICE_URL = "https://go.trouter.dod.teams.microsoft.us/v4/a"; |
@@ -6,3 +6,3 @@ // Copyright (c) Microsoft Corporation. | ||
import { CommunicationTokenCredential, SignalingClientOptions } from "./SignalingClient"; | ||
import { getCloudTypeFromCredential } from "./TrouterUtils"; | ||
import { parseTokenCredential } from "./TrouterUtils"; | ||
import { | ||
@@ -17,3 +17,4 @@ PUBLIC_TROUTER_SERVICE_URL, | ||
DOD_TROUTER_SERVICE_URL, | ||
CloudType | ||
CloudType, | ||
GCC_TROUTER_SERVICE_URL | ||
} from "./constants"; | ||
@@ -62,2 +63,10 @@ | ||
const createGccSettings = (): TrouterSettings => { | ||
const settings = createDefaultSettings(); | ||
settings.registrarServiceUrl = PUBLIC_REGISTRAR_SERVICE_URL; | ||
settings.trouterServiceUrl = GCC_TROUTER_SERVICE_URL; | ||
return settings; | ||
}; | ||
const createGcchSettings = (): TrouterSettings => { | ||
@@ -88,7 +97,9 @@ const settings = createDefaultSettings(); | ||
} else { | ||
const cloud = await getCloudTypeFromCredential(credential); | ||
if (cloud === CloudType.GccHigh) { | ||
const parsedTokenCredential = await parseTokenCredential(credential); | ||
if (parsedTokenCredential.cloudType === CloudType.GccHigh) { | ||
settings = createGcchSettings(); | ||
} else if (cloud === CloudType.Dod) { | ||
} else if (parsedTokenCredential.cloudType === CloudType.Dod) { | ||
settings = createDodSettings(); | ||
} else if (parsedTokenCredential.resourceLocation === `usgcc`) { | ||
settings = createGccSettings(); | ||
} else { | ||
@@ -95,0 +106,0 @@ settings = createDefaultSettings(); |
@@ -352,6 +352,8 @@ // Copyright (c) Microsoft Corporation. | ||
}; | ||
} else if (mri.startsWith(acsUserPrefix) | ||
|| mri.startsWith(acsGcchUserPrefix) | ||
|| mri.startsWith(acsDodUserPrefix) | ||
|| mri.startsWith(spoolUserPrefix)) { | ||
} else if ( | ||
mri.startsWith(acsUserPrefix) || | ||
mri.startsWith(acsGcchUserPrefix) || | ||
mri.startsWith(acsDodUserPrefix) || | ||
mri.startsWith(spoolUserPrefix) | ||
) { | ||
return { kind: "communicationUser", communicationUserId: mri }; | ||
@@ -384,13 +386,30 @@ } else { | ||
export const getCloudTypeFromCredential = async ( | ||
export const parseTokenCredential = async ( | ||
credential: CommunicationTokenCredential | ||
): Promise<CloudType> => { | ||
): Promise<ParsedTokenCredential> => { | ||
const accessToken = await credential.getToken(); | ||
let jwtToken = accessToken?.token; | ||
let parsedJwtToken = parseJWT(jwtToken); | ||
let identityMri = parsedJwtToken.skypeid; | ||
return getCloudTypeFromSkypeId(identityMri); | ||
const identityMri = parsedJwtToken.skypeid; | ||
const acsResourceId = parsedJwtToken.resourceId; | ||
const cloudType = getCloudTypeFromSkypeId(identityMri); | ||
const resourceLocation = parsedJwtToken.resourceLocation || ""; | ||
return { jwtToken, acsResourceId, identityMri, cloudType, resourceLocation }; | ||
}; | ||
export type ParsedTokenCredential = { | ||
// The original token | ||
jwtToken: string; | ||
// The ACS resource Id | ||
acsResourceId: string | undefined; | ||
// The MRI without the '8:' | ||
identityMri: string; | ||
// Public, Dod, GccHigh, Dod, AirGap08, or AirGap09 | ||
cloudType: CloudType; | ||
// Resource location | ||
resourceLocation: string; | ||
}; | ||
function getCloudTypeFromSkypeId(skypeId: string): CloudType { | ||
@@ -397,0 +416,0 @@ const cloudPrefix = skypeId.substring(0, skypeId.indexOf(":")); |
export declare const MAX_NUMBER_OF_TOKEN_FETCH_RETRIES = 3; | ||
export declare const GCCHIGH_TROUTER_SERVICE_URL = "https://go.trouter.gov.teams.microsoft.us/v4/a"; | ||
export declare const GCCHIGH_REGISTRAR_SERVICE_URL = "https://registrar.gov.teams.microsoft.us/V3/registrations"; | ||
export declare const GCC_TROUTER_SERVICE_URL = "https://go.trouter.gcc.teams.microsoft.com/v4/a"; | ||
export declare const DOD_TROUTER_SERVICE_URL = "https://go.trouter.dod.teams.microsoft.us/v4/a"; | ||
@@ -5,0 +6,0 @@ export declare const DOD_REGISTRAR_SERVICE_URL = "https://registrar.dod.teams.microsoft.us/V3/registrations"; |
@@ -10,2 +10,9 @@ import { MessageHandler, LogProvider, ITelemetrySender } from "@skype/tstrouter"; | ||
export declare function base64decode(encodedString: string): string; | ||
export declare const getCloudTypeFromCredential: (credential: CommunicationTokenCredential) => Promise<CloudType>; | ||
export declare const parseTokenCredential: (credential: CommunicationTokenCredential) => Promise<ParsedTokenCredential>; | ||
export declare type ParsedTokenCredential = { | ||
jwtToken: string; | ||
acsResourceId: string | undefined; | ||
identityMri: string; | ||
cloudType: CloudType; | ||
resourceLocation: string; | ||
}; |
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
3079129
12170