Skip to content

Commit 2044df6

Browse files
authored
[communication] Extract identity client into its own communication-identity package (Azure#13415)
1 parent 18ba5de commit 2044df6

File tree

130 files changed

+4311
-1281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+4311
-1281
lines changed

common/config/rush/pnpm-lock.yaml

Lines changed: 729 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rush.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@
382382
"projectFolder": "sdk/communication/communication-common",
383383
"versionPolicyName": "client"
384384
},
385+
{
386+
"packageName": "@azure/communication-identity",
387+
"projectFolder": "sdk/communication/communication-identity",
388+
"versionPolicyName": "client"
389+
},
385390
{
386391
"packageName": "@azure/communication-sms",
387392
"projectFolder": "sdk/communication/communication-sms",

sdk/communication/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ extends:
3434
safeName: azurecommunicationsms
3535
- name: azure-communication-chat
3636
safeName: azurecommunicationchat
37+
- name: azure-communication-identity
38+
safeName: azurecommunicationidentity

sdk/communication/communication-administration/CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44

55
### Added
66

7-
- `CommunicationIdentityClient` added a constructor that supports `TokenCredential`.
87
- `PhoneNumberAdministrationClient` added a constructor that supports `TokenCredential`.
98

109
### Breaking Changes
1110

12-
- Replaced `CommunicationUser` with `CommunicationUserIdentifier`.
11+
- `CommunicationIdentityClient` moved to the new `@azure/communication-identity` package.
1312

1413
### Key bug fixes
1514

sdk/communication/communication-administration/README.md

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Azure Communication Administration client library for JavaScript
22

3-
The administration library is used for managing users and tokens for Azure Communication Services. This library also provides capabilities for phone number administration.
3+
The administration library provides capabilities for phone number administration.
44

55
Acquired phone numbers can come with many capabilities, depending on the country, number type and phone plan. Examples of capabilities are SMS inbound and outbound usage, PSTN inbound and outbound usage. Phone numbers can also be assigned to a bot via a webhook URL.
66

@@ -21,7 +21,7 @@ npm install @azure/communication-administration
2121

2222
### Clients
2323

24-
The administration package exposes two clients. The `CommunicationIdentityClient` provides methods to manage users and their tokens. The `PhoneNumberAdministrationClient` provides methods to manage phone plans and numbers.
24+
The `PhoneNumberAdministrationClient` provides methods to manage phone plans and numbers.
2525

2626
### Phone plans overview
2727

@@ -41,95 +41,41 @@ Phone numbers can be assigned to a callback URL via the configure number API. As
4141

4242
## Authentication
4343

44-
You can get a key and/or connection string from your Communication Services resource in [Azure Portal][azure_portal]. Once you have a key, you can authenticate the `CommunicationIdentityClient` and `PhoneNumberAdministrationClient` with any of the following methods:
44+
You can get a key and/or connection string from your Communication Services resource in [Azure Portal][azure_portal]. Once you have a key, you can authenticate the `PhoneNumberAdministrationClient` with any of the following methods:
4545

4646
### Create `KeyCredential` with `AzureKeyCredential` before initializing the client
4747

4848
```typescript
4949
import { AzureKeyCredential } from "@azure/core-auth";
50-
import { CommunicationIdentityClient } from "@azure/communication-administration";
50+
import { PhoneNumberAdministrationClient } from "@azure/communication-administration";
5151

5252
const credential = new AzureKeyCredential(KEY);
53-
const client = new CommunicationIdentityClient(HOST, credential);
53+
const client = new PhoneNumberAdministrationClient(HOST, credential);
5454
```
5555

5656
### Using a connection string
5757

5858
```typescript
59-
import { CommunicationIdentityClient } from "@azure/communication-administration";
59+
import { PhoneNumberAdministrationClient } from "@azure/communication-administration";
6060

6161
const connectionString = `endpoint=HOST;accessKey=KEY`;
62-
const client = new CommunicationIdentityClient(connectionString);
62+
const client = new PhoneNumberAdministrationClient(connectionString);
6363
```
6464

6565
### Using Azure Active Directory Authentication
6666

6767
```typescript
68-
import { CommunicationIdentityClient } from "@azure/communication-administration";
68+
import { PhoneNumberAdministrationClient } from "@azure/communication-administration";
6969
import { DefaultAzureCredential } from "@azure/identity";
7070

7171
const credential = new DefaultAzureCredential();
72-
const client = new CommunicationIdentityClient(HOST, credential);
72+
const client = new PhoneNumberAdministrationClient(HOST, credential);
7373
```
7474

7575
If you use a key to initialize the client you will also need to provide the appropriate endpoint. You can get this endpoint from your Communication Services resource in [Azure Portal][azure_portal].
7676

7777
## Usage
7878

79-
### CommunicationIdentityClient
80-
81-
### Creating an instance of CommunicationIdentityClient
82-
83-
```typescript
84-
import { CommunicationIdentityClient } from "@azure/communication-administration";
85-
86-
const client = new CommunicationIdentityClient(CONNECTION_STRING);
87-
```
88-
89-
#### Creating a new user
90-
91-
Use the `createUser` method to create a new user.
92-
93-
```typescript
94-
const user = await client.createUser();
95-
```
96-
97-
#### Creating and refreshing a user token
98-
99-
Use the `issueToken` method to issue or refresh a token for an existing user. The method also takes in a list of communication token scopes. Scope options include:
100-
101-
- `chat` (Chat)
102-
- `pstn` (Public switched telephone network)
103-
- `voip` (Voice over IP)
104-
105-
```typescript
106-
let { token } = await client.issueToken(user, ["chat"]);
107-
```
108-
109-
To refresh the user token, issue another token with the same user.
110-
111-
```typescript
112-
{ token } = await client.issueToken(user, ["chat"]);
113-
```
114-
115-
#### Revoking tokens for a user
116-
117-
Use the `revokeTokens` method to revoke all the issued tokens of a user.
118-
119-
```typescript
120-
await client.revokeTokens(user);
121-
```
122-
123-
`revokeTokens` takes an optional second argument, `tokensValidFrom`. If this date is provided, `revokeTokens` will revoke all tokens issued before it. Otherwise, all tokens will be revoked.
124-
125-
#### Deleting a user
126-
127-
Use the `deleteUser` method to delete a user.
128-
129-
```typescript
130-
await client.deleteUser(user);
131-
```
132-
13379
### PhoneNumberAdministrationClient
13480

13581
#### Creating an instance of PhoneNumberAdministrationClient

sdk/communication/communication-administration/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"scripts": {
1010
"audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit",
1111
"build": "tsc -p . && rollup -c 2>&1 && api-extractor run --local",
12-
"build:autorest": "npm run build:autorest-identity && npm run build:autorest-phone",
13-
"build:autorest-identity": "autorest --typescript --version=3.0.6267 --v3 ./swagger/CommunicationIdentity.md && rushx format",
12+
"build:autorest": "npm run build:autorest-phone",
1413
"build:autorest-phone": "autorest --typescript --version=3.0.6267 --v3 ./swagger/PhoneNumber.md && rushx format",
1514
"build:clean": "rush update --recheck && rush rebuild && npm run build",
1615
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",

sdk/communication/communication-administration/recordings/browsers/communicationidentityclient_playbacklive/recording_successfully_issues_a_token_for_a_user_multiple_scopes.json

Lines changed: 0 additions & 22 deletions
This file was deleted.

sdk/communication/communication-administration/recordings/browsers/communicationidentityclient_playbacklive/recording_successfully_revokes_tokens_issued_for_a_user.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

sdk/communication/communication-administration/recordings/browsers/phonenumberadministrationclient_lists_playbacklive/recording_can_list_phone_numbers.json

Lines changed: 65 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/communication/communication-administration/recordings/browsers/phonenumberadministrationclient_lists_playbacklive/recording_can_list_phone_plans.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)