BlueGit

ict rusty-teams

Files

rusty-teams / crates / chatsvc / assets / discover_host.js

discover_host.js

Initial commit
metis Daniel Däschle · pushed by metis · 7 weeks ago
06e0ae51 History
discover_host.js 569 B Download Raw
1let response;
2try {
3 response = await fetch('https://teams.cloud.microsoft/api/authsvc/v1.0/authz', {
4 method: 'POST',
5 headers: {Authorization: 'Bearer ' + token},
6 });
7} catch (error) {
8 return {error: 'authz_unreachable'};
9}
10if (!response.ok) return {error: 'authz_http_' + response.status};
11let url = null;
12try {
13 const answer = await response.json();
14 url = answer.regionGtms.calling_trouterUrl;
15} catch (error) {
16 return {error: 'authz_shape'};
17}
18try {
19 return {host: new URL(url).host};
20} catch (error) {
21 return {error: 'authz_no_trouter_url'};
22}