зеркало из
1
0
Форкнуть 0

Bump ACS SDK versions for samples/Server (#215)

Calling samples are already using ACS SDKs version 1.0.0
This is a step in bring Chat samples to the same dependencies.
This commit is contained in:
Prathmesh Prabhu 2021-05-06 10:11:50 -07:00 коммит произвёл GitHub
Родитель a7430c9527
Коммит ff44a62eed
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
9 изменённых файлов: 167 добавлений и 77 удалений

Просмотреть файл

@ -2,9 +2,8 @@ dependencies:
'@azure/communication-administration': 1.0.0-beta.3
'@azure/communication-calling': 1.0.1-beta.1
'@azure/communication-common-beta3': /@azure/communication-common/1.0.0-beta.3
'@azure/communication-identity': 1.0.0-beta.4
'@azure/communication-identity': 1.0.0
'@azure/communication-signaling-2': /@azure/communication-signaling/1.0.0-beta.2
'@azure/core-http': 1.2.3
'@azure/core-paging': 1.1.3
'@babel/core': 7.13.10
'@babel/preset-env': 7.13.10_@babel+core@7.13.10
@ -182,15 +181,15 @@ packages:
dev: false
resolution:
integrity: sha512-jjkAcO+dFKl6fjdI62mgImF7VJ48vRs6PfR5TfuswZQ758k1bHxnJfi8T1jS8F5JcBJGEzoUsaFCQD8Ae2eFgg==
/@azure/communication-chat/1.0.0-beta.3:
/@azure/communication-chat/1.0.0:
dependencies:
'@azure/abort-controller': 1.0.4
'@azure/communication-common': 1.0.0-beta.3
'@azure/communication-signaling': 1.0.0-beta.1
'@azure/core-auth': 1.2.0
'@azure/core-http': 1.2.3
'@azure/communication-common': 1.0.0
'@azure/communication-signaling': 1.0.0-beta.3
'@azure/core-auth': 1.3.0
'@azure/core-http': 1.2.4
'@azure/core-paging': 1.1.3
'@azure/core-tracing': 1.0.0-preview.9
'@azure/core-tracing': 1.0.0-preview.10
'@azure/logger': 1.0.2
'@opentelemetry/api': 0.10.2
events: 3.3.0
@ -199,14 +198,14 @@ packages:
engines:
node: '>=8.0.0'
resolution:
integrity: sha512-hhS9pI+cwh1omq8HnzB6aM10jInwZAYoyghJJihVAdg3nv3DqgV5DLi+cmPwHXrKteBEn5lIgR2MMCyQ4M4mxA==
integrity: sha512-2qdZwiYywurCH13mZHTV6rZNmvXYB8SGcLyAuzX6ACvBJk5Lk9GzckzdEeJzG/yY2s1q9GhVJdSalHf8DL4bVg==
/@azure/communication-chat/1.0.0-beta.4:
dependencies:
'@azure/abort-controller': 1.0.4
'@azure/communication-common': 1.0.0-beta.5
'@azure/communication-signaling': 1.0.0-beta.2
'@azure/core-auth': 1.2.0
'@azure/core-http': 1.2.3
'@azure/core-auth': 1.3.0
'@azure/core-http': 1.2.4
'@azure/core-paging': 1.1.3
'@azure/core-tracing': 1.0.0-preview.9
'@azure/logger': 1.0.2
@ -221,8 +220,8 @@ packages:
/@azure/communication-common/1.0.0:
dependencies:
'@azure/abort-controller': 1.0.4
'@azure/core-auth': 1.2.0
'@azure/core-http': 1.2.3
'@azure/core-auth': 1.3.0
'@azure/core-http': 1.2.4
'@opentelemetry/api': 0.10.2
events: 3.3.0
jwt-decode: 2.2.0
@ -235,8 +234,8 @@ packages:
/@azure/communication-common/1.0.0-beta.3:
dependencies:
'@azure/abort-controller': 1.0.4
'@azure/core-auth': 1.2.0
'@azure/core-http': 1.2.3
'@azure/core-auth': 1.3.0
'@azure/core-http': 1.2.4
'@opentelemetry/api': 0.10.2
events: 3.3.0
jwt-decode: 2.2.0
@ -249,8 +248,8 @@ packages:
/@azure/communication-common/1.0.0-beta.5:
dependencies:
'@azure/abort-controller': 1.0.4
'@azure/core-auth': 1.2.0
'@azure/core-http': 1.2.3
'@azure/core-auth': 1.3.0
'@azure/core-http': 1.2.4
'@opentelemetry/api': 0.10.2
events: 3.3.0
jwt-decode: 2.2.0
@ -260,15 +259,15 @@ packages:
node: '>=8.0.0'
resolution:
integrity: sha512-wNaw43z+7YoOyIDnhlDtqVgIK0rPl8bgv7vV0oBizw4+CinaUrG8EtYv0nZ7tH6Rr8R+ys9UhoPaS5d+JUVoJw==
/@azure/communication-identity/1.0.0-beta.4:
/@azure/communication-identity/1.0.0:
dependencies:
'@azure/abort-controller': 1.0.4
'@azure/communication-common': 1.0.0-beta.5
'@azure/communication-common': 1.0.0
'@azure/core-auth': 1.2.0
'@azure/core-http': 1.2.3
'@azure/core-lro': 1.0.3
'@azure/core-paging': 1.1.3
'@azure/core-tracing': 1.0.0-preview.9
'@azure/core-tracing': 1.0.0-preview.10
'@azure/logger': 1.0.2
'@opentelemetry/api': 0.10.2
events: 3.3.0
@ -277,10 +276,10 @@ packages:
engines:
node: '>=8.0.0'
resolution:
integrity: sha512-qd0N66bR16Xrjc0wSaUrUQDTZDNiabk+MWqfT+oNpTIPM5yvu78bjz4aMH7rFYxIOWWW4k6lxwB91ZdBXXn1/A==
integrity: sha512-fa220+fQn27JN8QtajeMe88rqrJn3qctT/8FV/abJe6tSBJlAWYXOHiIF3nCgSeyIb5F9pi7Fycd9M55OY4O9w==
/@azure/communication-signaling/1.0.0-beta.1:
dependencies:
'@azure/core-http': 1.2.3
'@azure/core-http': 1.2.4
'@azure/logger': 1.0.2
'@opentelemetry/api': 0.6.1
events: 3.3.0
@ -292,7 +291,7 @@ packages:
integrity: sha512-xxlGwbbTkEZAline8wrP75FLaOsT23nMukzIg5X/Cs6cQSQ/JKj7Uxq5Idxp9GgAYT+g+PAj+BJ929/jaselBQ==
/@azure/communication-signaling/1.0.0-beta.2:
dependencies:
'@azure/core-http': 1.2.3
'@azure/core-http': 1.2.4
'@azure/core-tracing': 1.0.0-preview.9
'@azure/logger': 1.0.2
'@opentelemetry/api': 0.10.2
@ -303,6 +302,19 @@ packages:
node: '>=8.0.0'
resolution:
integrity: sha512-2Nbm6OEtouz94kWiWu40VhG2ckTwAI4Ng7ji77yCha1obrVhzxA1wfveMZmEmXk4s7YGN5L7xAj/hFATe7WknQ==
/@azure/communication-signaling/1.0.0-beta.3:
dependencies:
'@azure/core-http': 1.2.4
'@azure/core-tracing': 1.0.0-preview.9
'@azure/logger': 1.0.2
'@opentelemetry/api': 0.10.2
events: 3.3.0
tslib: 1.14.1
dev: false
engines:
node: '>=8.0.0'
resolution:
integrity: sha512-WargzA8PMc9SEvQpjhM0vVq/HB0wGUScplW8Us9nEFLHy/ZvgVjbRHlCALCa/tlU/Pv3RgZhk7XuPfwip17MCQ==
/@azure/core-asynciterator-polyfill/1.0.0:
dev: false
resolution:
@ -316,6 +328,15 @@ packages:
node: '>=8.0.0'
resolution:
integrity: sha512-KUl+Nwn/Sm6Lw5d3U90m1jZfNSL087SPcqHLxwn2T6PupNKmcgsEbDjHB25gDvHO4h7pBsTlrdJAY7dz+Qk8GA==
/@azure/core-auth/1.3.0:
dependencies:
'@azure/abort-controller': 1.0.4
tslib: 2.1.0
dev: false
engines:
node: '>=8.0.0'
resolution:
integrity: sha512-kSDSZBL6c0CYdhb+7KuutnKGf2geeT+bCJAgccB0DD7wmNJSsQPcF7TcuoZX83B7VK4tLz/u+8sOO/CnCsYp8A==
/@azure/core-http/1.2.3:
dependencies:
'@azure/abort-controller': 1.0.4
@ -338,6 +359,28 @@ packages:
node: '>=8.0.0'
resolution:
integrity: sha512-g5C1zUJO5dehP2Riv+vy9iCYoS1UwKnZsBVCzanScz9A83LbnXKpZDa9wie26G9dfXUhQoFZoFT8LYWhPKmwcg==
/@azure/core-http/1.2.4:
dependencies:
'@azure/abort-controller': 1.0.4
'@azure/core-asynciterator-polyfill': 1.0.0
'@azure/core-auth': 1.3.0
'@azure/core-tracing': 1.0.0-preview.11
'@azure/logger': 1.0.2
'@types/node-fetch': 2.5.8
'@types/tunnel': 0.0.1
form-data: 3.0.1
node-fetch: 2.6.1
process: 0.11.10
tough-cookie: 4.0.0
tslib: 2.1.0
tunnel: 0.0.6
uuid: 8.3.2
xml2js: 0.4.23
dev: false
engines:
node: '>=8.0.0'
resolution:
integrity: sha512-cNumz3ckyFZY5zWOgcTHSO7AKRVwxbodG8WfcEGcdH+ZJL3KvJEI/vN58H6xk5v3ijulU2x/WPGJqrMVvcI79A==
/@azure/core-lro/1.0.3:
dependencies:
'@azure/abort-controller': 1.0.4
@ -357,6 +400,26 @@ packages:
node: '>=8.0.0'
resolution:
integrity: sha512-his7Ah40ThEYORSpIAwuh6B8wkGwO/zG7gqVtmSE4WAJ46e36zUDXTKReUCLBDc6HmjjApQQxxcRFy5FruG79A==
/@azure/core-tracing/1.0.0-preview.10:
dependencies:
'@opencensus/web-types': 0.0.7
'@opentelemetry/api': 0.10.2
tslib: 2.1.0
dev: false
engines:
node: '>=8.0.0'
resolution:
integrity: sha512-iIwjtMwQnsxB7cYkugMx+s4W1nfy3+pT/ceo+uW1fv4YDgYe84nh+QP0fEC9IH/3UATLSWbIBemdMHzk2APUrw==
/@azure/core-tracing/1.0.0-preview.11:
dependencies:
'@opencensus/web-types': 0.0.7
'@opentelemetry/api': 1.0.0-rc.0
tslib: 2.1.0
dev: false
engines:
node: '>=8.0.0'
resolution:
integrity: sha512-frF0pJc9HTmKncVokhBxCqipjbql02DThQ1ZJ9wLi7SDMLdPAFyDI5xZNzX5guLz+/DtPkY+SGK2li9FIXqshQ==
/@azure/core-tracing/1.0.0-preview.9:
dependencies:
'@opencensus/web-types': 0.0.7
@ -3687,6 +3750,12 @@ packages:
node: '>=8.0.0'
resolution:
integrity: sha512-wpufGZa7tTxw7eAsjXJtiyIQ42IWQdX9iUQp7ACJcKo1hCtuhLU+K2Nv1U6oRwT1oAlZTE6m4CgWKZBhOiau3Q==
/@opentelemetry/api/1.0.0-rc.0:
dev: false
engines:
node: '>=8.0.0'
resolution:
integrity: sha512-iXKByCMfrlO5S6Oh97BuM56tM2cIBB0XsL/vWF/AtJrJEKx4MC/Xdu0xDsGXMGcNWpqF7ujMsjjnp0+UHBwnDQ==
/@opentelemetry/context-base/0.10.2:
dev: false
engines:
@ -20792,7 +20861,7 @@ packages:
'@azure/communication-administration': 1.0.0-beta.3
'@azure/communication-calling': 1.0.1-beta.1
'@azure/communication-common': 1.0.0
'@azure/core-http': 1.2.3
'@azure/core-http': 1.2.4
'@babel/core': 7.13.10
'@babel/preset-env': 7.13.10_@babel+core@7.13.10
'@babel/preset-react': 7.12.13_@babel+core@7.13.10
@ -20860,7 +20929,7 @@ packages:
'@azure/communication-chat': 1.0.0-beta.4
'@azure/communication-common': 1.0.0-beta.3
'@azure/communication-signaling': 1.0.0-beta.1
'@azure/core-http': 1.2.3
'@azure/core-http': 1.2.4
'@fluentui/react': 7.164.1_b0d7ca8a0459a1df1ff516252688d92a
'@fluentui/react-icons-northstar': 0.51.7_b0d7ca8a0459a1df1ff516252688d92a
'@fluentui/react-northstar': 0.51.7_b0d7ca8a0459a1df1ff516252688d92a
@ -20997,7 +21066,7 @@ packages:
'@azure/communication-administration': 1.0.0-beta.3
'@azure/communication-calling': 1.0.1-beta.1
'@azure/communication-common': 1.0.0
'@azure/core-http': 1.2.3
'@azure/core-http': 1.2.4
'@babel/core': 7.13.10
'@babel/preset-env': 7.13.10_@babel+core@7.13.10
'@babel/preset-react': 7.12.13_@babel+core@7.13.10
@ -21139,7 +21208,7 @@ packages:
'@azure/communication-common-beta3': /@azure/communication-common/1.0.0-beta.3
'@azure/communication-signaling': 1.0.0-beta.1
'@azure/communication-signaling-2': /@azure/communication-signaling/1.0.0-beta.2
'@azure/core-http': 1.2.3
'@azure/core-http': 1.2.4
'@babel/core': 7.13.10
'@babel/preset-env': 7.13.10_@babel+core@7.13.10
'@fluentui/react': 7.164.1_b0d7ca8a0459a1df1ff516252688d92a
@ -21210,9 +21279,10 @@ packages:
version: 0.0.0
file:projects/server.tgz:
dependencies:
'@azure/communication-chat': 1.0.0-beta.3
'@azure/communication-common': 1.0.0-beta.3
'@azure/communication-identity': 1.0.0-beta.4
'@azure/communication-chat': 1.0.0
'@azure/communication-common': 1.0.0
'@azure/communication-identity': 1.0.0
'@azure/core-http': 1.2.4
'@types/cookie-parser': 1.4.2
'@types/copy-webpack-plugin': 6.4.0
'@types/cors': 2.8.10
@ -21255,7 +21325,7 @@ packages:
dev: false
name: '@rush-temp/server'
resolution:
integrity: sha512-ackzCLGN0wbDuoKMywSTx9Ge31TF5jHC+O4F6zRMnOm8p2hCNvwcwojGnnkRiYyJc2w6eHuUBp9yLwJ3wAh9hw==
integrity: sha512-xb3CKRaBb4wXiVhKyRN+xKtkgi0haFjT18B+4Gm536fYifPKzgh342MzIoKU1BssOWvV79OeQZ5Nfs4fW0J4Hg==
tarball: file:projects/server.tgz
version: 0.0.0
file:projects/storybook.tgz:
@ -21265,7 +21335,7 @@ packages:
'@azure/communication-chat': 1.0.0-beta.4
'@azure/communication-common': 1.0.0-beta.3
'@azure/communication-signaling': 1.0.0-beta.1
'@azure/core-http': 1.2.3
'@azure/core-http': 1.2.4
'@babel/core': 7.13.10
'@babel/preset-env': 7.13.10_@babel+core@7.13.10
'@fluentui/react': 7.164.1_b0d7ca8a0459a1df1ff516252688d92a
@ -21351,7 +21421,7 @@ packages:
dev: false
name: '@rush-temp/storybook'
resolution:
integrity: sha512-vVdp+J/SQmVVx6VV+2Ds5GP/3tExkYvoYti8G2vIA0hJsXr1okH93JvxffEmC/K4S6kh3FQnq34LrdE4sNHrbg==
integrity: sha512-NtWHAZmcTtxGO3QkQGnqADA0E6341OVOzn0Xw2IDrXkahxkvArEQLZBRG0WnttJ71FIkIhARy/YD+6+8Xwm+bg==
tarball: file:projects/storybook.tgz
version: 0.0.0
registry: ''
@ -21359,9 +21429,8 @@ specifiers:
'@azure/communication-administration': 1.0.0-beta.3
'@azure/communication-calling': 1.0.1-beta.1
'@azure/communication-common-beta3': npm:@azure/communication-common@1.0.0-beta.3
'@azure/communication-identity': 1.0.0-beta.4
'@azure/communication-identity': 1.0.0
'@azure/communication-signaling-2': npm:@azure/communication-signaling@1.0.0-beta.2
'@azure/core-http': ^1.2.3
'@azure/core-paging': ~1.1.3
'@babel/core': ^7.12.7
'@babel/preset-env': ^7.12.7

Просмотреть файл

@ -15,9 +15,9 @@
"lint:quiet": "eslint src src --ext .ts --quiet"
},
"dependencies": {
"@azure/communication-chat": "1.0.0-beta.3",
"@azure/communication-common": "1.0.0-beta.3",
"@azure/communication-identity": "1.0.0-beta.4",
"@azure/communication-chat": "1.0.0",
"@azure/communication-common": "1.0.0",
"@azure/communication-identity": "1.0.0",
"@types/cors": "^2.8.8",
"cookie-parser": "~1.4.4",
"cors": "^2.8.5",
@ -25,7 +25,8 @@
"eslint-plugin-header": "^3.1.0",
"express": "~4.16.1",
"http-errors": "~1.6.3",
"morgan": "~1.9.1"
"morgan": "~1.9.1",
"@azure/core-http": "1.2.4"
},
"devDependencies": {
"@types/cookie-parser": "^1.4.2",

Просмотреть файл

@ -15,10 +15,10 @@ const mockUserToken: CommunicationUserToken = {
expiresOn: new Date(0)
};
let createUserWithTokenSpy: jest.SpyInstance;
let createUserAndTokenSpy: jest.SpyInstance;
beforeAll(() => {
createUserWithTokenSpy = jest.spyOn(identity, 'createUserWithToken').mockImplementation(async () => mockUserToken);
createUserAndTokenSpy = jest.spyOn(identity, 'createUserAndToken').mockImplementation(async () => mockUserToken);
});
describe('app route tests', () => {
@ -26,27 +26,27 @@ describe('app route tests', () => {
const getResponse = await request(app).get('/token');
expect(getResponse.status).toEqual(200);
expect(getResponse.text).toEqual(JSON.stringify(mockUserToken));
expect(createUserWithTokenSpy).toHaveBeenLastCalledWith(['chat', 'voip']);
createUserWithTokenSpy.mockClear();
expect(createUserAndTokenSpy).toHaveBeenLastCalledWith(['chat', 'voip']);
createUserAndTokenSpy.mockClear();
const postResponse = await request(app).post('/token');
expect(postResponse.status).toEqual(200);
expect(postResponse.text).toEqual(JSON.stringify(mockUserToken));
expect(createUserWithTokenSpy).toHaveBeenLastCalledWith(['chat', 'voip']);
createUserWithTokenSpy.mockClear();
expect(createUserAndTokenSpy).toHaveBeenLastCalledWith(['chat', 'voip']);
createUserAndTokenSpy.mockClear();
});
test('/token?scope=chat,pstn should return a token with chat and pstn scopes with GET and POST requests', async () => {
const getResponse = await request(app).get('/token?scope=chat,pstn');
expect(getResponse.status).toEqual(200);
expect(getResponse.text).toEqual(JSON.stringify(mockUserToken));
expect(createUserWithTokenSpy).toHaveBeenLastCalledWith(['chat', 'pstn']);
createUserWithTokenSpy.mockClear();
expect(createUserAndTokenSpy).toHaveBeenLastCalledWith(['chat', 'pstn']);
createUserAndTokenSpy.mockClear();
const postResponse = await request(app).post('/token').send({ scope: 'chat,pstn' });
expect(postResponse.status).toEqual(200);
expect(postResponse.text).toEqual(JSON.stringify(mockUserToken));
expect(createUserWithTokenSpy).toHaveBeenLastCalledWith(['chat', 'pstn']);
createUserWithTokenSpy.mockClear();
expect(createUserAndTokenSpy).toHaveBeenLastCalledWith(['chat', 'pstn']);
createUserAndTokenSpy.mockClear();
});
});

Просмотреть файл

@ -1,24 +1,40 @@
// © Microsoft Corporation. All rights reserved.
import { AzureCommunicationUserCredential } from '@azure/communication-common';
import { ChatClient, CreateChatThreadRequest } from '@azure/communication-chat';
import { AzureCommunicationTokenCredential } from '@azure/communication-common';
import { ChatClient, CreateChatThreadOptions, CreateChatThreadRequest } from '@azure/communication-chat';
import { getEnvUrl } from '../envHelper';
import { GUID_FOR_INITIAL_TOPIC_NAME } from '../constants';
import { threadIdToModeratorCredentialMap } from './threadIdToModeratorTokenMap';
import { createUser, issueToken } from '../identityClient';
import { createUser, getToken } from '../identityClient';
export const createThread = async (topicName?: string): Promise<string> => {
const user = await createUser();
// create an on-demand auto-refreshing credential and store it
const credential = new AzureCommunicationUserCredential({
tokenRefresher: async () => (await issueToken(user, ['chat', 'voip'])).token
const credential = new AzureCommunicationTokenCredential({
tokenRefresher: async () => (await getToken(user, ['chat', 'voip'])).token,
refreshProactively: true
});
const chatClient = new ChatClient(getEnvUrl(), credential);
const request: CreateChatThreadRequest = {
topic: topicName ?? GUID_FOR_INITIAL_TOPIC_NAME,
members: [{ user }]
topic: topicName ?? GUID_FOR_INITIAL_TOPIC_NAME
};
const chatThreadClient = await chatClient.createChatThread(request);
threadIdToModeratorCredentialMap.set(chatThreadClient.threadId, credential);
return chatThreadClient.threadId;
const options: CreateChatThreadOptions = {
participants: [
{
id: {
communicationUserId: user.communicationUserId
}
}
]
};
const result = await chatClient.createChatThread(request, options);
const threadID = result.chatThread?.id;
if (!threadID) {
throw new Error(`Invalid or missing ID for newly created thread ${result.chatThread}`);
}
threadIdToModeratorCredentialMap.set(threadID, credential);
return threadID;
};

Просмотреть файл

@ -1,5 +1,5 @@
// © Microsoft Corporation. All rights reserved.
import { CommunicationUserCredential } from '@azure/communication-common';
import { CommunicationTokenCredential } from '@azure/communication-common';
export const threadIdToModeratorCredentialMap = new Map<string, CommunicationUserCredential>();
export const threadIdToModeratorCredentialMap = new Map<string, CommunicationTokenCredential>();

Просмотреть файл

@ -6,7 +6,8 @@ import {
CommunicationUserToken,
TokenScope
} from '@azure/communication-identity';
import { CommunicationUser } from '@azure/communication-common';
import { CommunicationUserIdentifier } from '@azure/communication-common';
import { OperationOptions } from '@azure/core-http';
import { getResourceConnectionString } from './envHelper';
// lazy init to allow mocks in test
@ -15,8 +16,11 @@ const getIdentityClient = (): CommunicationIdentityClient =>
identityClient ?? (identityClient = new CommunicationIdentityClient(getResourceConnectionString()));
// replicate here to allow for mocks in tests
export const createUser = (): Promise<CommunicationUser> => getIdentityClient().createUser();
export const issueToken = (user: CommunicationUser, scopes: TokenScope[]): Promise<CommunicationAccessToken> =>
getIdentityClient().issueToken(user, scopes);
export const createUserWithToken = (scopes: TokenScope[]): Promise<CommunicationUserToken> =>
getIdentityClient().createUserWithToken(scopes);
export const createUser = (): Promise<CommunicationUserIdentifier> => getIdentityClient().createUser();
export const getToken = (
user: CommunicationUserIdentifier,
scopes: TokenScope[],
options?: OperationOptions
): Promise<CommunicationAccessToken> => getIdentityClient().getToken(user, scopes);
export const createUserAndToken = (scopes: TokenScope[]): Promise<CommunicationUserToken> =>
getIdentityClient().createUserAndToken(scopes);

Просмотреть файл

@ -19,10 +19,10 @@ router.post('/:threadId', async function (req, res, next) {
const chatClient = new ChatClient(getEnvUrl(), moderatorCredential);
const chatThreadClient = await chatClient.getChatThreadClient(threadId);
await chatThreadClient.addMembers({
members: [
await chatThreadClient.addParticipants({
participants: [
{
user: { communicationUserId: addUserParam.Id },
id: { communicationUserId: addUserParam.Id },
displayName: addUserParam.DisplayName
}
]

Просмотреть файл

@ -2,7 +2,7 @@
import { CommunicationUserToken, TokenScope } from '@azure/communication-identity';
import * as express from 'express';
import { createUserWithToken } from '../lib/identityClient';
import { createUserAndToken } from '../lib/identityClient';
const router = express.Router();
@ -12,7 +12,7 @@ const router = express.Router();
*/
const handleUserTokenRequest = async (requestedScope?: string): Promise<CommunicationUserToken> => {
const scopes: TokenScope[] = requestedScope ? (requestedScope.split(',') as TokenScope[]) : ['chat', 'voip'];
return await createUserWithToken(scopes);
return await createUserAndToken(scopes);
};
/**

Просмотреть файл

@ -2,8 +2,8 @@
import * as express from 'express';
import { CommunicationUserToken } from '@azure/communication-identity';
import { CommunicationUser } from '@azure/communication-common';
import { issueToken } from '../lib/identityClient';
import { CommunicationUserIdentifier } from '@azure/communication-common';
import { getToken } from '../lib/identityClient';
const router = express.Router();
@ -12,10 +12,10 @@ router.post('/:id', async function (req, res, next) {
res.sendStatus(404);
}
const user: CommunicationUser = {
const user: CommunicationUserIdentifier = {
communicationUserId: req.params['id'] as string
};
const token = await issueToken(user, ['chat', 'voip']);
const token = await getToken(user, ['chat', 'voip']);
const userToken: CommunicationUserToken = {
user,
...token