@azure/communication-identity 1.3.2-alpha.20241231.2 → 1.3.2-alpha.20250109.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"communicationIdentityClient.d.ts","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,kCAAkC,EAClC,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,eAAe,EACf,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAM/E,OAAO,KAAK,EAAiC,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAWvE;;GAEG;AACH,qBAAa,2BAA2B;IACtC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAE5C;;;;;OAKG;gBACgB,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kCAAkC;IAEzF;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,aAAa,EACzB,OAAO,CAAC,EAAE,kCAAkC;IAE9C;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,eAAe,EAC3B,OAAO,CAAC,EAAE,kCAAkC;IA+B9C;;;;;;OAMG;IACI,QAAQ,CACb,IAAI,EAAE,2BAA2B,EACjC,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,wBAAwB,CAAC;IAUpC;;;;;OAKG;IACI,YAAY,CACjB,IAAI,EAAE,2BAA2B,EAEjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IAEI,UAAU,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAgBvF;;;;;OAKG;IACI,kBAAkB,CACvB,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,sBAAsB,CAAC;IAkBlC;;;;;OAKG;IACI,UAAU,CACf,IAAI,EAAE,2BAA2B,EAEjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IACI,oBAAoB,CACzB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,wBAAwB,CAAC;CAerC"}
1
+ {"version":3,"file":"communicationIdentityClient.d.ts","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,kCAAkC,EAClC,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,eAAe,EACf,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAM/E,OAAO,KAAK,EAAiC,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAWvE;;GAEG;AACH,qBAAa,2BAA2B;IACtC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAE5C;;;;;OAKG;gBACgB,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kCAAkC;IAEzF;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,aAAa,EACzB,OAAO,CAAC,EAAE,kCAAkC;IAE9C;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,eAAe,EAC3B,OAAO,CAAC,EAAE,kCAAkC;IA+B9C;;;;;;OAMG;IACI,QAAQ,CACb,IAAI,EAAE,2BAA2B,EACjC,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,wBAAwB,CAAC;IAUpC;;;;;OAKG;IACI,YAAY,CACjB,IAAI,EAAE,2BAA2B,EACjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IACI,UAAU,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAgBvF;;;;;OAKG;IACI,kBAAkB,CACvB,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,sBAAsB,CAAC;IAkBlC;;;;;OAKG;IACI,UAAU,CACf,IAAI,EAAE,2BAA2B,EACjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IACI,oBAAoB,CACzB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,wBAAwB,CAAC;CAerC"}
@@ -42,9 +42,7 @@ export class CommunicationIdentityClient {
42
42
  * @param user - The user whose tokens are being revoked.
43
43
  * @param options - Additional options for the request.
44
44
  */
45
- revokeTokens(user,
46
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
47
- options = {}) {
45
+ revokeTokens(user, options = {}) {
48
46
  return tracingClient.withSpan("CommunicationIdentity-revokeTokens", options, async (updatedOptions) => {
49
47
  await this.client.communicationIdentityOperations.revokeAccessTokens(user.communicationUserId, updatedOptions);
50
48
  });
@@ -54,7 +52,6 @@ export class CommunicationIdentityClient {
54
52
  *
55
53
  * @param options - Additional options for the request.
56
54
  */
57
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
58
55
  createUser(options = {}) {
59
56
  return tracingClient.withSpan("CommunicationIdentity-createUser", options, async (updatedOptions) => {
60
57
  const result = await this.client.communicationIdentityOperations.create(Object.assign({ expiresInMinutes: undefined }, updatedOptions));
@@ -81,9 +78,7 @@ export class CommunicationIdentityClient {
81
78
  * @param user - The user being deleted.
82
79
  * @param options - Additional options for the request.
83
80
  */
84
- deleteUser(user,
85
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
86
- options = {}) {
81
+ deleteUser(user, options = {}) {
87
82
  return tracingClient.withSpan("CommunicationIdentity-deleteUser", options, async (updatedOptions) => {
88
83
  await this.client.communicationIdentityOperations.delete(user.communicationUserId, updatedOptions);
89
84
  });
@@ -1 +1 @@
1
- {"version":3,"file":"communicationIdentityClient.js","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,oCAAoC,GAAG,CAC3C,OAAY,EACmC,EAAE,CACjD,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAqCtC,YACE,0BAAkC,EAClC,mBAA0F,EAC1F,eAAmD,EAAE;QAErD,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,oBAAoB,CAC9C,0BAA0B,EAC1B,mBAAmB,CACpB,CAAC;QACF,MAAM,OAAO,GAAG,oCAAoC,CAAC,mBAAmB,CAAC;YACvE,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,YAAY,CAAC;QAEjB,MAAM,uBAAuB,mCACxB,OAAO,GACP;YACD,cAAc,EAAE;gBACd,MAAM,EAAE,MAAM,CAAC,IAAI;aACpB;SACF,CACF,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAkB,CAAC,GAAG,kBAAI,QAAQ,EA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AccessToken,\n CommunicationIdentityClientOptions,\n CommunicationUserToken,\n GetTokenForTeamsUserOptions,\n CreateUserAndTokenOptions,\n GetTokenOptions,\n TokenScope,\n} from \"./models.js\";\nimport type { CommunicationUserIdentifier } from \"@azure/communication-common\";\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport type { InternalClientPipelineOptions, OperationOptions } from \"@azure/core-client\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport { IdentityRestClient } from \"./generated/src/identityRestClient.js\";\nimport { logger } from \"./common/logger.js\";\nimport { tracingClient } from \"./generated/src/tracing.js\";\n\nconst isCommunicationIdentityClientOptions = (\n options: any,\n): options is CommunicationIdentityClientOptions =>\n options && !isTokenCredential(options) && !isKeyCredential(options);\n\n/**\n * Client class for interacting with Azure Communication Services User Token Management.\n */\nexport class CommunicationIdentityClient {\n /**\n * A reference to the auto-generated UserToken HTTP client.\n */\n private readonly client: IdentityRestClient;\n\n /**\n * Initializes a new instance of the CommunicationIdentity class.\n * @param connectionString - Connection string to connect to an Azure Communication Service resource.\n * Example: \"endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret\";\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(connectionString: string, options?: CommunicationIdentityClientOptions);\n\n /**\n * Initializes a new instance of the CommunicationIdentity class using an Azure KeyCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the AzureKeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: KeyCredential,\n options?: CommunicationIdentityClientOptions,\n );\n /**\n * Initializes a new instance of the CommunicationIdentity class using a TokenCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net)\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options?: CommunicationIdentityClientOptions,\n );\n\n public constructor(\n connectionStringOrEndpoint: string,\n credentialOrOptions?: KeyCredential | CommunicationIdentityClientOptions | TokenCredential,\n maybeOptions: CommunicationIdentityClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(\n connectionStringOrEndpoint,\n credentialOrOptions,\n );\n const options = isCommunicationIdentityClientOptions(credentialOrOptions)\n ? credentialOrOptions\n : maybeOptions;\n\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n this.client = new IdentityRestClient(url, { endpoint: url, ...internalPipelineOptions });\n\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.client.pipeline.addPolicy(authPolicy);\n }\n\n /**\n * Creates a scoped user token.\n *\n * @param user - The user whose tokens are being issued.\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public getToken(\n user: CommunicationUserIdentifier,\n scopes: TokenScope[],\n options: GetTokenOptions = {},\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\"CommunicationIdentity-issueToken\", options, (updatedOptions) => {\n return this.client.communicationIdentityOperations.issueAccessToken(\n user.communicationUserId,\n scopes,\n { expiresInMinutes: options.tokenExpiresInMinutes, ...updatedOptions },\n );\n });\n }\n\n /**\n * Revokes all data and tokens created for a user.\n *\n * @param user - The user whose tokens are being revoked.\n * @param options - Additional options for the request.\n */\n public revokeTokens(\n user: CommunicationUserIdentifier,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-revokeTokens\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.revokeAccessTokens(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Creates a single user.\n *\n * @param options - Additional options for the request.\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n public createUser(options: OperationOptions = {}): Promise<CommunicationUserIdentifier> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUser\",\n options,\n async (updatedOptions) => {\n const result = await this.client.communicationIdentityOperations.create({\n expiresInMinutes: undefined,\n ...updatedOptions,\n });\n return {\n communicationUserId: result.identity.id,\n };\n },\n );\n }\n\n /**\n * Creates a single user and a token simultaneously.\n *\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public createUserAndToken(\n scopes: TokenScope[],\n options: CreateUserAndTokenOptions = {},\n ): Promise<CommunicationUserToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUserAndToken\",\n options,\n async (updatedOptions) => {\n const { identity, accessToken } = await this.client.communicationIdentityOperations.create({\n createTokenWithScopes: scopes,\n expiresInMinutes: options.tokenExpiresInMinutes,\n ...updatedOptions,\n });\n return {\n ...accessToken!,\n user: { communicationUserId: identity.id },\n };\n },\n );\n }\n\n /**\n * Triggers revocation event for user and deletes all its data.\n *\n * @param user - The user being deleted.\n * @param options - Additional options for the request.\n */\n public deleteUser(\n user: CommunicationUserIdentifier,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-deleteUser\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.delete(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Exchanges an Azure AD access token of a Teams user for a new Communication Identity access token with a matching expiration time.\n *\n * @param options - Options used to exchange an Azure AD access token of a Teams user for a new Communication Identity access token.\n */\n public getTokenForTeamsUser(\n options: GetTokenForTeamsUserOptions,\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-getTokenForTeamsUser\",\n options,\n (updatedOptions) => {\n const { teamsUserAadToken, clientId, userObjectId } = updatedOptions;\n return this.client.communicationIdentityOperations.exchangeTeamsUserAccessToken(\n teamsUserAadToken,\n clientId,\n userObjectId,\n updatedOptions,\n );\n },\n );\n }\n}\n"]}
1
+ {"version":3,"file":"communicationIdentityClient.js","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,oCAAoC,GAAG,CAC3C,OAAY,EACmC,EAAE,CACjD,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAqCtC,YACE,0BAAkC,EAClC,mBAA0F,EAC1F,eAAmD,EAAE;QAErD,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,oBAAoB,CAC9C,0BAA0B,EAC1B,mBAAmB,CACpB,CAAC;QACF,MAAM,OAAO,GAAG,oCAAoC,CAAC,mBAAmB,CAAC;YACvE,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,YAAY,CAAC;QAEjB,MAAM,uBAAuB,mCACxB,OAAO,GACP;YACD,cAAc,EAAE;gBACd,MAAM,EAAE,MAAM,CAAC,IAAI;aACpB;SACF,CACF,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAkB,CAAC,GAAG,kBAAI,QAAQ,EAAE,GAAG,IAAK,uBAAuB,EAAG,CAAC;QAEzF,MAAM,UAAU,GAAG,6BAA6B,CAAC,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,MAAM,CAAC,QA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c,EAAE,EAAE;YACvB,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,+BAA+B,CAAC,MAAM,iBACxF,qBAAqB,EAAE,MAAM,EAC7B,gBAAgB,EAAE,OAAO,CAAC,qBAAqB,IAC5C,cAAc,EACjB,CAAC;YACH,uCACK,WAAY,KACf,IAAI,EAAE,EAAE,mBAAmB,EAAE,QAAQ,CAAC,EAAE,EAAE,IAC1C;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,UAAU,CACf,IAAiC,EACjC,UAA4B,EAAE;QAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,kCAAkC,EAClC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,IAAI,CAAC,MAAM,CAAC,+BAA+B,CAAC,MAAM,CACtD,IAAI,CAAC,mBAAmB,EACxB,cAAc,CACf,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,oBAAoB,CACzB,OAAoC;QAEpC,OAAO,aAAa,CAAC,QAAQ,CAC3B,4CAA4C,EAC5C,OAAO,EACP,CAAC,cAAc,EAAE,EAAE;YACjB,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,cAAc,CAAC;YACrE,OAAO,IAAI,CAAC,MAAM,CAAC,+BAA+B,CAAC,4BAA4B,CAC7E,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,cAAc,CACf,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n CommunicationAccessToken,\n CommunicationIdentityClientOptions,\n CommunicationUserToken,\n GetTokenForTeamsUserOptions,\n CreateUserAndTokenOptions,\n GetTokenOptions,\n TokenScope,\n} from \"./models.js\";\nimport type { CommunicationUserIdentifier } from \"@azure/communication-common\";\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport type { InternalClientPipelineOptions, OperationOptions } from \"@azure/core-client\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport { IdentityRestClient } from \"./generated/src/identityRestClient.js\";\nimport { logger } from \"./common/logger.js\";\nimport { tracingClient } from \"./generated/src/tracing.js\";\n\nconst isCommunicationIdentityClientOptions = (\n options: any,\n): options is CommunicationIdentityClientOptions =>\n options && !isTokenCredential(options) && !isKeyCredential(options);\n\n/**\n * Client class for interacting with Azure Communication Services User Token Management.\n */\nexport class CommunicationIdentityClient {\n /**\n * A reference to the auto-generated UserToken HTTP client.\n */\n private readonly client: IdentityRestClient;\n\n /**\n * Initializes a new instance of the CommunicationIdentity class.\n * @param connectionString - Connection string to connect to an Azure Communication Service resource.\n * Example: \"endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret\";\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(connectionString: string, options?: CommunicationIdentityClientOptions);\n\n /**\n * Initializes a new instance of the CommunicationIdentity class using an Azure KeyCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the AzureKeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: KeyCredential,\n options?: CommunicationIdentityClientOptions,\n );\n /**\n * Initializes a new instance of the CommunicationIdentity class using a TokenCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net)\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options?: CommunicationIdentityClientOptions,\n );\n\n public constructor(\n connectionStringOrEndpoint: string,\n credentialOrOptions?: KeyCredential | CommunicationIdentityClientOptions | TokenCredential,\n maybeOptions: CommunicationIdentityClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(\n connectionStringOrEndpoint,\n credentialOrOptions,\n );\n const options = isCommunicationIdentityClientOptions(credentialOrOptions)\n ? credentialOrOptions\n : maybeOptions;\n\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n this.client = new IdentityRestClient(url, { endpoint: url, ...internalPipelineOptions });\n\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.client.pipeline.addPolicy(authPolicy);\n }\n\n /**\n * Creates a scoped user token.\n *\n * @param user - The user whose tokens are being issued.\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public getToken(\n user: CommunicationUserIdentifier,\n scopes: TokenScope[],\n options: GetTokenOptions = {},\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\"CommunicationIdentity-issueToken\", options, (updatedOptions) => {\n return this.client.communicationIdentityOperations.issueAccessToken(\n user.communicationUserId,\n scopes,\n { expiresInMinutes: options.tokenExpiresInMinutes, ...updatedOptions },\n );\n });\n }\n\n /**\n * Revokes all data and tokens created for a user.\n *\n * @param user - The user whose tokens are being revoked.\n * @param options - Additional options for the request.\n */\n public revokeTokens(\n user: CommunicationUserIdentifier,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-revokeTokens\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.revokeAccessTokens(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Creates a single user.\n *\n * @param options - Additional options for the request.\n */\n public createUser(options: OperationOptions = {}): Promise<CommunicationUserIdentifier> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUser\",\n options,\n async (updatedOptions) => {\n const result = await this.client.communicationIdentityOperations.create({\n expiresInMinutes: undefined,\n ...updatedOptions,\n });\n return {\n communicationUserId: result.identity.id,\n };\n },\n );\n }\n\n /**\n * Creates a single user and a token simultaneously.\n *\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public createUserAndToken(\n scopes: TokenScope[],\n options: CreateUserAndTokenOptions = {},\n ): Promise<CommunicationUserToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUserAndToken\",\n options,\n async (updatedOptions) => {\n const { identity, accessToken } = await this.client.communicationIdentityOperations.create({\n createTokenWithScopes: scopes,\n expiresInMinutes: options.tokenExpiresInMinutes,\n ...updatedOptions,\n });\n return {\n ...accessToken!,\n user: { communicationUserId: identity.id },\n };\n },\n );\n }\n\n /**\n * Triggers revocation event for user and deletes all its data.\n *\n * @param user - The user being deleted.\n * @param options - Additional options for the request.\n */\n public deleteUser(\n user: CommunicationUserIdentifier,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-deleteUser\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.delete(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Exchanges an Azure AD access token of a Teams user for a new Communication Identity access token with a matching expiration time.\n *\n * @param options - Options used to exchange an Azure AD access token of a Teams user for a new Communication Identity access token.\n */\n public getTokenForTeamsUser(\n options: GetTokenForTeamsUserOptions,\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-getTokenForTeamsUser\",\n options,\n (updatedOptions) => {\n const { teamsUserAadToken, clientId, userObjectId } = updatedOptions;\n return this.client.communicationIdentityOperations.exchangeTeamsUserAccessToken(\n teamsUserAadToken,\n clientId,\n userObjectId,\n updatedOptions,\n );\n },\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"communicationIdentityClient.d.ts","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,kCAAkC,EAClC,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,eAAe,EACf,UAAU,EACX,MA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,wBAAwB,CAAC;CAerC"}
1
+ {"version":3,"file":"communicationIdentityClient.d.ts","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,kCAAkC,EAClC,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,eAAe,EACf,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAM/E,OAAO,KAAK,EAAiC,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAWvE;;GAEG;AACH,qBAAa,2BAA2B;IACtC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAE5C;;;;;OAKG;gBACgB,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kCAAkC;IAEzF;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,aAAa,EACzB,OAAO,CAAC,EAAE,kCAAkC;IAE9C;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,eAAe,EAC3B,OAAO,CAAC,EAAE,kCAAkC;IA+B9C;;;;;;OAMG;IACI,QAAQ,CACb,IAAI,EAAE,2BAA2B,EACjC,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,wBAAwB,CAAC;IAUpC;;;;;OAKG;IACI,YAAY,CACjB,IAAI,EAAE,2BAA2B,EACjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IACI,UAAU,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAgBvF;;;;;OAKG;IACI,kBAAkB,CACvB,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,sBAAsB,CAAC;IAkBlC;;;;;OAKG;IACI,UAAU,CACf,IAAI,EAAE,2BAA2B,EACjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IACI,oBAAoB,CACzB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,wBAAwB,CAAC;CAerC"}
@@ -45,9 +45,7 @@ class CommunicationIdentityClient {
45
45
  * @param user - The user whose tokens are being revoked.
46
46
  * @param options - Additional options for the request.
47
47
  */
48
- revokeTokens(user,
49
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
50
- options = {}) {
48
+ revokeTokens(user, options = {}) {
51
49
  return tracing_js_1.tracingClient.withSpan("CommunicationIdentity-revokeTokens", options, async (updatedOptions) => {
52
50
  await this.client.communicationIdentityOperations.revokeAccessTokens(user.communicationUserId, updatedOptions);
53
51
  });
@@ -57,7 +55,6 @@ class CommunicationIdentityClient {
57
55
  *
58
56
  * @param options - Additional options for the request.
59
57
  */
60
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
61
58
  createUser(options = {}) {
62
59
  return tracing_js_1.tracingClient.withSpan("CommunicationIdentity-createUser", options, async (updatedOptions) => {
63
60
  const result = await this.client.communicationIdentityOperations.create(Object.assign({ expiresInMinutes: undefined }, updatedOptions));
@@ -84,9 +81,7 @@ class CommunicationIdentityClient {
84
81
  * @param user - The user being deleted.
85
82
  * @param options - Additional options for the request.
86
83
  */
87
- deleteUser(user,
88
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
89
- options = {}) {
84
+ deleteUser(user, options = {}) {
90
85
  return tracing_js_1.tracingClient.withSpan("CommunicationIdentity-deleteUser", options, async (updatedOptions) => {
91
86
  await this.client.communicationIdentityOperations.delete(user.communicationUserId, updatedOptions);
92
87
  });
@@ -1 +1 @@
1
- {"version":3,"file":"communicationIdentityClient.js","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":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CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,UAAU,CACf,IAAiC;IACjC,8DAA8D;IAC9D,UAA4B,EAAE;QAE9B,OAAO,0BAAa,CAAC,QAAQ,CAC3B,kCAAkC,EAClC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,IAAI,CAAC,MAAM,CAAC,+BAA+B,CAAC,MAAM,CACtD,IAAI,CAAC,mBAAmB,EACxB,cAAc,CACf,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,oBAAoB,CACzB,OAAoC;QAEpC,OAAO,0BAAa,CAAC,QAAQ,CAC3B,4CAA4C,EAC5C,OAAO,EACP,CAAC,cAAc,EAAE,EAAE;YACjB,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,cAAc,CAAC;YACrE,OAAO,IAAI,CAAC,MAAM,CAAC,+BAA+B,CAAC,4BAA4B,CAC7E,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,cAAc,CACf,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AA3MD,kEA2MC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n CommunicationAccessToken,\n CommunicationIdentityClientOptions,\n CommunicationUserToken,\n GetTokenForTeamsUserOptions,\n CreateUserAndTokenOptions,\n GetTokenOptions,\n TokenScope,\n} from \"./models.js\";\nimport type { CommunicationUserIdentifier } from \"@azure/communication-common\";\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport type { InternalClientPipelineOptions, OperationOptions } from \"@azure/core-client\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport { IdentityRestClient } from \"./generated/src/identityRestClient.js\";\nimport { logger } from \"./common/logger.js\";\nimport { tracingClient } from \"./generated/src/tracing.js\";\n\nconst isCommunicationIdentityClientOptions = (\n options: any,\n): options is CommunicationIdentityClientOptions =>\n options && !isTokenCredential(options) && !isKeyCredential(options);\n\n/**\n * Client class for interacting with Azure Communication Services User Token Management.\n */\nexport class CommunicationIdentityClient {\n /**\n * A reference to the auto-generated UserToken HTTP client.\n */\n private readonly client: IdentityRestClient;\n\n /**\n * Initializes a new instance of the CommunicationIdentity class.\n * @param connectionString - Connection string to connect to an Azure Communication Service resource.\n * Example: \"endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret\";\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(connectionString: string, options?: CommunicationIdentityClientOptions);\n\n /**\n * Initializes a new instance of the CommunicationIdentity class using an Azure KeyCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the AzureKeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: KeyCredential,\n options?: CommunicationIdentityClientOptions,\n );\n /**\n * Initializes a new instance of the CommunicationIdentity class using a TokenCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net)\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options?: CommunicationIdentityClientOptions,\n );\n\n public constructor(\n connectionStringOrEndpoint: string,\n credentialOrOptions?: KeyCredential | CommunicationIdentityClientOptions | TokenCredential,\n maybeOptions: CommunicationIdentityClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(\n connectionStringOrEndpoint,\n credentialOrOptions,\n );\n const options = isCommunicationIdentityClientOptions(credentialOrOptions)\n ? credentialOrOptions\n : maybeOptions;\n\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n this.client = new IdentityRestClient(url, { endpoint: url, ...internalPipelineOptions });\n\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.client.pipeline.addPolicy(authPolicy);\n }\n\n /**\n * Creates a scoped user token.\n *\n * @param user - The user whose tokens are being issued.\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public getToken(\n user: CommunicationUserIdentifier,\n scopes: TokenScope[],\n options: GetTokenOptions = {},\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\"CommunicationIdentity-issueToken\", options, (updatedOptions) => {\n return this.client.communicationIdentityOperations.issueAccessToken(\n user.communicationUserId,\n scopes,\n { expiresInMinutes: options.tokenExpiresInMinutes, ...updatedOptions },\n );\n });\n }\n\n /**\n * Revokes all data and tokens created for a user.\n *\n * @param user - The user whose tokens are being revoked.\n * @param options - Additional options for the request.\n */\n public revokeTokens(\n user: CommunicationUserIdentifier,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-revokeTokens\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.revokeAccessTokens(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Creates a single user.\n *\n * @param options - Additional options for the request.\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n public createUser(options: OperationOptions = {}): Promise<CommunicationUserIdentifier> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUser\",\n options,\n async (updatedOptions) => {\n const result = await this.client.communicationIdentityOperations.create({\n expiresInMinutes: undefined,\n ...updatedOptions,\n });\n return {\n communicationUserId: result.identity.id,\n };\n },\n );\n }\n\n /**\n * Creates a single user and a token simultaneously.\n *\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public createUserAndToken(\n scopes: TokenScope[],\n options: CreateUserAndTokenOptions = {},\n ): Promise<CommunicationUserToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUserAndToken\",\n options,\n async (updatedOptions) => {\n const { identity, accessToken } = await this.client.communicationIdentityOperations.create({\n createTokenWithScopes: scopes,\n expiresInMinutes: options.tokenExpiresInMinutes,\n ...updatedOptions,\n });\n return {\n ...accessToken!,\n user: { communicationUserId: identity.id },\n };\n },\n );\n }\n\n /**\n * Triggers revocation event for user and deletes all its data.\n *\n * @param user - The user being deleted.\n * @param options - Additional options for the request.\n */\n public deleteUser(\n user: CommunicationUserIdentifier,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-deleteUser\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.delete(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Exchanges an Azure AD access token of a Teams user for a new Communication Identity access token with a matching expiration time.\n *\n * @param options - Options used to exchange an Azure AD access token of a Teams user for a new Communication Identity access token.\n */\n public getTokenForTeamsUser(\n options: GetTokenForTeamsUserOptions,\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-getTokenForTeamsUser\",\n options,\n (updatedOptions) => {\n const { teamsUserAadToken, clientId, userObjectId } = updatedOptions;\n return this.client.communicationIdentityOperations.exchangeTeamsUserAccessToken(\n teamsUserAadToken,\n clientId,\n userObjectId,\n updatedOptions,\n );\n },\n );\n }\n}\n"]}
1
+ {"version":3,"file":"communicationIdentityClient.js","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAYlC,sEAIqC;AAGrC,gDAAqD;AACrD,iFAA2E;AAC3E,kDAA4C;AAC5C,2DAA2D;AAE3D,MAAM,oCAAoC,GAAG,CAC3C,OAAY,EACmC,EAAE,CACjD,OAAO,IAAI,CAAC,IAAA,6BAAiB,EAAC,OAAO,CAAC,IAAI,CAAC,IAAA,sCAAe,EAAC,OAAO,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAa,2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AED;;;;OAIG;IACI,oBAAoB,CACzB,OAAoC;QAEpC,OAAO,0BAAa,CAAC,QAAQ,CAC3B,4CAA4C,EAC5C,OAAO,EACP,CAAC,cAAc,EAAE,EAAE;YACjB,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,cAAc,CAAC;YACrE,OAAO,IAAI,CAAC,MAAM,CAAC,+BAA+B,CAAC,4BAA4B,CAC7E,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,cAAc,CACf,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAxMD,kEAwMC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n CommunicationAccessToken,\n CommunicationIdentityClientOptions,\n CommunicationUserToken,\n GetTokenForTeamsUserOptions,\n CreateUserAndTokenOptions,\n GetTokenOptions,\n TokenScope,\n} from \"./models.js\";\nimport type { CommunicationUserIdentifier } from \"@azure/communication-common\";\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport type { InternalClientPipelineOptions, OperationOptions } from \"@azure/core-client\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport { IdentityRestClient } from \"./generated/src/identityRestClient.js\";\nimport { logger } from \"./common/logger.js\";\nimport { tracingClient } from \"./generated/src/tracing.js\";\n\nconst isCommunicationIdentityClientOptions = (\n options: any,\n): options is CommunicationIdentityClientOptions =>\n options && !isTokenCredential(options) && !isKeyCredential(options);\n\n/**\n * Client class for interacting with Azure Communication Services User Token Management.\n */\nexport class CommunicationIdentityClient {\n /**\n * A reference to the auto-generated UserToken HTTP client.\n */\n private readonly client: IdentityRestClient;\n\n /**\n * Initializes a new instance of the CommunicationIdentity class.\n * @param connectionString - Connection string to connect to an Azure Communication Service resource.\n * Example: \"endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret\";\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(connectionString: string, options?: CommunicationIdentityClientOptions);\n\n /**\n * Initializes a new instance of the CommunicationIdentity class using an Azure KeyCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the AzureKeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: KeyCredential,\n options?: CommunicationIdentityClientOptions,\n );\n /**\n * Initializes a new instance of the CommunicationIdentity class using a TokenCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net)\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options?: CommunicationIdentityClientOptions,\n );\n\n public constructor(\n connectionStringOrEndpoint: string,\n credentialOrOptions?: KeyCredential | CommunicationIdentityClientOptions | TokenCredential,\n maybeOptions: CommunicationIdentityClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(\n connectionStringOrEndpoint,\n credentialOrOptions,\n );\n const options = isCommunicationIdentityClientOptions(credentialOrOptions)\n ? credentialOrOptions\n : maybeOptions;\n\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n this.client = new IdentityRestClient(url, { endpoint: url, ...internalPipelineOptions });\n\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.client.pipeline.addPolicy(authPolicy);\n }\n\n /**\n * Creates a scoped user token.\n *\n * @param user - The user whose tokens are being issued.\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public getToken(\n user: CommunicationUserIdentifier,\n scopes: TokenScope[],\n options: GetTokenOptions = {},\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\"CommunicationIdentity-issueToken\", options, (updatedOptions) => {\n return this.client.communicationIdentityOperations.issueAccessToken(\n user.communicationUserId,\n scopes,\n { expiresInMinutes: options.tokenExpiresInMinutes, ...updatedOptions },\n );\n });\n }\n\n /**\n * Revokes all data and tokens created for a user.\n *\n * @param user - The user whose tokens are being revoked.\n * @param options - Additional options for the request.\n */\n public revokeTokens(\n user: CommunicationUserIdentifier,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-revokeTokens\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.revokeAccessTokens(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Creates a single user.\n *\n * @param options - Additional options for the request.\n */\n public createUser(options: OperationOptions = {}): Promise<CommunicationUserIdentifier> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUser\",\n options,\n async (updatedOptions) => {\n const result = await this.client.communicationIdentityOperations.create({\n expiresInMinutes: undefined,\n ...updatedOptions,\n });\n return {\n communicationUserId: result.identity.id,\n };\n },\n );\n }\n\n /**\n * Creates a single user and a token simultaneously.\n *\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public createUserAndToken(\n scopes: TokenScope[],\n options: CreateUserAndTokenOptions = {},\n ): Promise<CommunicationUserToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUserAndToken\",\n options,\n async (updatedOptions) => {\n const { identity, accessToken } = await this.client.communicationIdentityOperations.create({\n createTokenWithScopes: scopes,\n expiresInMinutes: options.tokenExpiresInMinutes,\n ...updatedOptions,\n });\n return {\n ...accessToken!,\n user: { communicationUserId: identity.id },\n };\n },\n );\n }\n\n /**\n * Triggers revocation event for user and deletes all its data.\n *\n * @param user - The user being deleted.\n * @param options - Additional options for the request.\n */\n public deleteUser(\n user: CommunicationUserIdentifier,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-deleteUser\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.delete(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Exchanges an Azure AD access token of a Teams user for a new Communication Identity access token with a matching expiration time.\n *\n * @param options - Options used to exchange an Azure AD access token of a Teams user for a new Communication Identity access token.\n */\n public getTokenForTeamsUser(\n options: GetTokenForTeamsUserOptions,\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-getTokenForTeamsUser\",\n options,\n (updatedOptions) => {\n const { teamsUserAadToken, clientId, userObjectId } = updatedOptions;\n return this.client.communicationIdentityOperations.exchangeTeamsUserAccessToken(\n teamsUserAadToken,\n clientId,\n userObjectId,\n updatedOptions,\n );\n },\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"communicationIdentityClient.d.ts","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,kCAAkC,EAClC,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,eAAe,EACf,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAM/E,OAAO,KAAK,EAAiC,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAWvE;;GAEG;AACH,qBAAa,2BAA2B;IACtC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAE5C;;;;;OAKG;gBACgB,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kCAAkC;IAEzF;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,aAAa,EACzB,OAAO,CAAC,EAAE,kCAAkC;IAE9C;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,eAAe,EAC3B,OAAO,CAAC,EAAE,kCAAkC;IA+B9C;;;;;;OAMG;IACI,QAAQ,CACb,IAAI,EAAE,2BAA2B,EACjC,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,wBAAwB,CAAC;IAUpC;;;;;OAKG;IACI,YAAY,CACjB,IAAI,EAAE,2BAA2B,EAEjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IAEI,UAAU,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAgBvF;;;;;OAKG;IACI,kBAAkB,CACvB,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,sBAAsB,CAAC;IAkBlC;;;;;OAKG;IACI,UAAU,CACf,IAAI,EAAE,2BAA2B,EAEjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IACI,oBAAoB,CACzB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,wBAAwB,CAAC;CAerC"}
1
+ {"version":3,"file":"communicationIdentityClient.d.ts","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,kCAAkC,EAClC,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,eAAe,EACf,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAM/E,OAAO,KAAK,EAAiC,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAWvE;;GAEG;AACH,qBAAa,2BAA2B;IACtC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAE5C;;;;;OAKG;gBACgB,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kCAAkC;IAEzF;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,aAAa,EACzB,OAAO,CAAC,EAAE,kCAAkC;IAE9C;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,eAAe,EAC3B,OAAO,CAAC,EAAE,kCAAkC;IA+B9C;;;;;;OAMG;IACI,QAAQ,CACb,IAAI,EAAE,2BAA2B,EACjC,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,wBAAwB,CAAC;IAUpC;;;;;OAKG;IACI,YAAY,CACjB,IAAI,EAAE,2BAA2B,EACjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IACI,UAAU,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAgBvF;;;;;OAKG;IACI,kBAAkB,CACvB,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,sBAAsB,CAAC;IAkBlC;;;;;OAKG;IACI,UAAU,CACf,IAAI,EAAE,2BAA2B,EACjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IACI,oBAAoB,CACzB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,wBAAwB,CAAC;CAerC"}
@@ -42,9 +42,7 @@ export class CommunicationIdentityClient {
42
42
  * @param user - The user whose tokens are being revoked.
43
43
  * @param options - Additional options for the request.
44
44
  */
45
- revokeTokens(user,
46
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
47
- options = {}) {
45
+ revokeTokens(user, options = {}) {
48
46
  return tracingClient.withSpan("CommunicationIdentity-revokeTokens", options, async (updatedOptions) => {
49
47
  await this.client.communicationIdentityOperations.revokeAccessTokens(user.communicationUserId, updatedOptions);
50
48
  });
@@ -54,7 +52,6 @@ export class CommunicationIdentityClient {
54
52
  *
55
53
  * @param options - Additional options for the request.
56
54
  */
57
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
58
55
  createUser(options = {}) {
59
56
  return tracingClient.withSpan("CommunicationIdentity-createUser", options, async (updatedOptions) => {
60
57
  const result = await this.client.communicationIdentityOperations.create(Object.assign({ expiresInMinutes: undefined }, updatedOptions));
@@ -81,9 +78,7 @@ export class CommunicationIdentityClient {
81
78
  * @param user - The user being deleted.
82
79
  * @param options - Additional options for the request.
83
80
  */
84
- deleteUser(user,
85
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
86
- options = {}) {
81
+ deleteUser(user, options = {}) {
87
82
  return tracingClient.withSpan("CommunicationIdentity-deleteUser", options, async (updatedOptions) => {
88
83
  await this.client.communicationIdentityOperations.delete(user.communicationUserId, updatedOptions);
89
84
  });
@@ -1 +1 @@
1
- {"version":3,"file":"communicationIdentityClient.js","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,oCAAoC,GAAG,CAC3C,OAAY,EACmC,EAAE,CACjD,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAqCtC,YACE,0BAAkC,EAClC,mBAA0F,EAC1F,eAAmD,EAAE;QAErD,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,oBAAoB,CAC9C,0BAA0B,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C,cAAc,EAAE,EAAE;YACjB,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,cAAc,CAAC;YACrE,OAAO,IAAI,CAAC,MAAM,CAAC,+BAA+B,CAAC,4BAA4B,CAC7E,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,cAAc,CACf,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n CommunicationAccessToken,\n CommunicationIdentityClientOptions,\n CommunicationUserToken,\n GetTokenForTeamsUserOptions,\n CreateUserAndTokenOptions,\n GetTokenOptions,\n TokenScope,\n} from \"./models.js\";\nimport type { CommunicationUserIdentifier } from \"@azure/communication-common\";\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport type { InternalClientPipelineOptions, OperationOptions } from \"@azure/core-client\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport { IdentityRestClient } from \"./generated/src/identityRestClient.js\";\nimport { logger } from \"./common/logger.js\";\nimport { tracingClient } from \"./generated/src/tracing.js\";\n\nconst isCommunicationIdentityClientOptions = (\n options: any,\n): options is CommunicationIdentityClientOptions =>\n options && !isTokenCredential(options) && !isKeyCredential(options);\n\n/**\n * Client class for interacting with Azure Communication Services User Token Management.\n */\nexport class CommunicationIdentityClient {\n /**\n * A reference to the auto-generated UserToken HTTP client.\n */\n private readonly client: IdentityRestClient;\n\n /**\n * Initializes a new instance of the CommunicationIdentity class.\n * @param connectionString - Connection string to connect to an Azure Communication Service resource.\n * Example: \"endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret\";\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(connectionString: string, options?: CommunicationIdentityClientOptions);\n\n /**\n * Initializes a new instance of the CommunicationIdentity class using an Azure KeyCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the AzureKeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: KeyCredential,\n options?: CommunicationIdentityClientOptions,\n );\n /**\n * Initializes a new instance of the CommunicationIdentity class using a TokenCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net)\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options?: CommunicationIdentityClientOptions,\n );\n\n public constructor(\n connectionStringOrEndpoint: string,\n credentialOrOptions?: KeyCredential | CommunicationIdentityClientOptions | TokenCredential,\n maybeOptions: CommunicationIdentityClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(\n connectionStringOrEndpoint,\n credentialOrOptions,\n );\n const options = isCommunicationIdentityClientOptions(credentialOrOptions)\n ? credentialOrOptions\n : maybeOptions;\n\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n this.client = new IdentityRestClient(url, { endpoint: url, ...internalPipelineOptions });\n\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.client.pipeline.addPolicy(authPolicy);\n }\n\n /**\n * Creates a scoped user token.\n *\n * @param user - The user whose tokens are being issued.\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public getToken(\n user: CommunicationUserIdentifier,\n scopes: TokenScope[],\n options: GetTokenOptions = {},\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\"CommunicationIdentity-issueToken\", options, (updatedOptions) => {\n return this.client.communicationIdentityOperations.issueAccessToken(\n user.communicationUserId,\n scopes,\n { expiresInMinutes: options.tokenExpiresInMinutes, ...updatedOptions },\n );\n });\n }\n\n /**\n * Revokes all data and tokens created for a user.\n *\n * @param user - The user whose tokens are being revoked.\n * @param options - Additional options for the request.\n */\n public revokeTokens(\n user: CommunicationUserIdentifier,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-revokeTokens\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.revokeAccessTokens(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Creates a single user.\n *\n * @param options - Additional options for the request.\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n public createUser(options: OperationOptions = {}): Promise<CommunicationUserIdentifier> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUser\",\n options,\n async (updatedOptions) => {\n const result = await this.client.communicationIdentityOperations.create({\n expiresInMinutes: undefined,\n ...updatedOptions,\n });\n return {\n communicationUserId: result.identity.id,\n };\n },\n );\n }\n\n /**\n * Creates a single user and a token simultaneously.\n *\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public createUserAndToken(\n scopes: TokenScope[],\n options: CreateUserAndTokenOptions = {},\n ): Promise<CommunicationUserToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUserAndToken\",\n options,\n async (updatedOptions) => {\n const { identity, accessToken } = await this.client.communicationIdentityOperations.create({\n createTokenWithScopes: scopes,\n expiresInMinutes: options.tokenExpiresInMinutes,\n ...updatedOptions,\n });\n return {\n ...accessToken!,\n user: { communicationUserId: identity.id },\n };\n },\n );\n }\n\n /**\n * Triggers revocation event for user and deletes all its data.\n *\n * @param user - The user being deleted.\n * @param options - Additional options for the request.\n */\n public deleteUser(\n user: CommunicationUserIdentifier,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-deleteUser\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.delete(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Exchanges an Azure AD access token of a Teams user for a new Communication Identity access token with a matching expiration time.\n *\n * @param options - Options used to exchange an Azure AD access token of a Teams user for a new Communication Identity access token.\n */\n public getTokenForTeamsUser(\n options: GetTokenForTeamsUserOptions,\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-getTokenForTeamsUser\",\n options,\n (updatedOptions) => {\n const { teamsUserAadToken, clientId, userObjectId } = updatedOptions;\n return this.client.communicationIdentityOperations.exchangeTeamsUserAccessToken(\n teamsUserAadToken,\n clientId,\n userObjectId,\n updatedOptions,\n );\n },\n );\n }\n}\n"]}
1
+ {"version":3,"file":"communicationIdentityClient.js","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,oCAAoC,GAAG,CAC3C,OAAY,EACmC,EAAE,CACjD,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAqCtC,YACE,0BAAkC,EAClC,mBAA0F,EAC1F,eAAmD,EAAE;QAErD,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,oBAAoB,CAC9C,0BAA0B,EAC1B,mBAAmB,CACpB,CAAC;QACF,MAAM,OAAO,GAAG,oCAAoC,CAAC,mBAAmB,CAAC;YACvE,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,YAA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jB,QAAQ,EACR,YAAY,EACZ,cAAc,CACf,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n CommunicationAccessToken,\n CommunicationIdentityClientOptions,\n CommunicationUserToken,\n GetTokenForTeamsUserOptions,\n CreateUserAndTokenOptions,\n GetTokenOptions,\n TokenScope,\n} from \"./models.js\";\nimport type { CommunicationUserIdentifier } from \"@azure/communication-common\";\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport type { InternalClientPipelineOptions, OperationOptions } from \"@azure/core-client\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport { IdentityRestClient } from \"./generated/src/identityRestClient.js\";\nimport { logger } from \"./common/logger.js\";\nimport { tracingClient } from \"./generated/src/tracing.js\";\n\nconst isCommunicationIdentityClientOptions = (\n options: any,\n): options is CommunicationIdentityClientOptions =>\n options && !isTokenCredential(options) && !isKeyCredential(options);\n\n/**\n * Client class for interacting with Azure Communication Services User Token Management.\n */\nexport class CommunicationIdentityClient {\n /**\n * A reference to the auto-generated UserToken HTTP client.\n */\n private readonly client: IdentityRestClient;\n\n /**\n * Initializes a new instance of the CommunicationIdentity class.\n * @param connectionString - Connection string to connect to an Azure Communication Service resource.\n * Example: \"endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret\";\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(connectionString: string, options?: CommunicationIdentityClientOptions);\n\n /**\n * Initializes a new instance of the CommunicationIdentity class using an Azure KeyCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the AzureKeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: KeyCredential,\n options?: CommunicationIdentityClientOptions,\n );\n /**\n * Initializes a new instance of the CommunicationIdentity class using a TokenCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net)\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options?: CommunicationIdentityClientOptions,\n );\n\n public constructor(\n connectionStringOrEndpoint: string,\n credentialOrOptions?: KeyCredential | CommunicationIdentityClientOptions | TokenCredential,\n maybeOptions: CommunicationIdentityClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(\n connectionStringOrEndpoint,\n credentialOrOptions,\n );\n const options = isCommunicationIdentityClientOptions(credentialOrOptions)\n ? credentialOrOptions\n : maybeOptions;\n\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n this.client = new IdentityRestClient(url, { endpoint: url, ...internalPipelineOptions });\n\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.client.pipeline.addPolicy(authPolicy);\n }\n\n /**\n * Creates a scoped user token.\n *\n * @param user - The user whose tokens are being issued.\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public getToken(\n user: CommunicationUserIdentifier,\n scopes: TokenScope[],\n options: GetTokenOptions = {},\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\"CommunicationIdentity-issueToken\", options, (updatedOptions) => {\n return this.client.communicationIdentityOperations.issueAccessToken(\n user.communicationUserId,\n scopes,\n { expiresInMinutes: options.tokenExpiresInMinutes, ...updatedOptions },\n );\n });\n }\n\n /**\n * Revokes all data and tokens created for a user.\n *\n * @param user - The user whose tokens are being revoked.\n * @param options - Additional options for the request.\n */\n public revokeTokens(\n user: CommunicationUserIdentifier,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-revokeTokens\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.revokeAccessTokens(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Creates a single user.\n *\n * @param options - Additional options for the request.\n */\n public createUser(options: OperationOptions = {}): Promise<CommunicationUserIdentifier> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUser\",\n options,\n async (updatedOptions) => {\n const result = await this.client.communicationIdentityOperations.create({\n expiresInMinutes: undefined,\n ...updatedOptions,\n });\n return {\n communicationUserId: result.identity.id,\n };\n },\n );\n }\n\n /**\n * Creates a single user and a token simultaneously.\n *\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public createUserAndToken(\n scopes: TokenScope[],\n options: CreateUserAndTokenOptions = {},\n ): Promise<CommunicationUserToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUserAndToken\",\n options,\n async (updatedOptions) => {\n const { identity, accessToken } = await this.client.communicationIdentityOperations.create({\n createTokenWithScopes: scopes,\n expiresInMinutes: options.tokenExpiresInMinutes,\n ...updatedOptions,\n });\n return {\n ...accessToken!,\n user: { communicationUserId: identity.id },\n };\n },\n );\n }\n\n /**\n * Triggers revocation event for user and deletes all its data.\n *\n * @param user - The user being deleted.\n * @param options - Additional options for the request.\n */\n public deleteUser(\n user: CommunicationUserIdentifier,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-deleteUser\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.delete(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Exchanges an Azure AD access token of a Teams user for a new Communication Identity access token with a matching expiration time.\n *\n * @param options - Options used to exchange an Azure AD access token of a Teams user for a new Communication Identity access token.\n */\n public getTokenForTeamsUser(\n options: GetTokenForTeamsUserOptions,\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-getTokenForTeamsUser\",\n options,\n (updatedOptions) => {\n const { teamsUserAadToken, clientId, userObjectId } = updatedOptions;\n return this.client.communicationIdentityOperations.exchangeTeamsUserAccessToken(\n teamsUserAadToken,\n clientId,\n userObjectId,\n updatedOptions,\n );\n },\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"communicationIdentityClient.d.ts","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,kCAAkC,EAClC,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,eAAe,EACf,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAM/E,OAAO,KAAK,EAAiC,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAWvE;;GAEG;AACH,qBAAa,2BAA2B;IACtC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAE5C;;;;;OAKG;gBACgB,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kCAAkC;IAEzF;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,aAAa,EACzB,OAAO,CAAC,EAAE,kCAAkC;IAE9C;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,eAAe,EAC3B,OAAO,CAAC,EAAE,kCAAkC;IA+B9C;;;;;;OAMG;IACI,QAAQ,CACb,IAAI,EAAE,2BAA2B,EACjC,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,wBAAwB,CAAC;IAUpC;;;;;OAKG;IACI,YAAY,CACjB,IAAI,EAAE,2BAA2B,EAEjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IAEI,UAAU,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAgBvF;;;;;OAKG;IACI,kBAAkB,CACvB,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,sBAAsB,CAAC;IAkBlC;;;;;OAKG;IACI,UAAU,CACf,IAAI,EAAE,2BAA2B,EAEjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IACI,oBAAoB,CACzB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,wBAAwB,CAAC;CAerC"}
1
+ {"version":3,"file":"communicationIdentityClient.d.ts","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,wBAAwB,EACxB,kCAAkC,EAClC,sBAAsB,EACtB,2BAA2B,EAC3B,yBAAyB,EACzB,eAAe,EACf,UAAU,EACX,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAM/E,OAAO,KAAK,EAAiC,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1F,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAWvE;;GAEG;AACH,qBAAa,2BAA2B;IACtC;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAE5C;;;;;OAKG;gBACgB,gBAAgB,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kCAAkC;IAEzF;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,aAAa,EACzB,OAAO,CAAC,EAAE,kCAAkC;IAE9C;;;;;OAKG;gBAED,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,eAAe,EAC3B,OAAO,CAAC,EAAE,kCAAkC;IA+B9C;;;;;;OAMG;IACI,QAAQ,CACb,IAAI,EAAE,2BAA2B,EACjC,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,wBAAwB,CAAC;IAUpC;;;;;OAKG;IACI,YAAY,CACjB,IAAI,EAAE,2BAA2B,EACjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IACI,UAAU,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAgBvF;;;;;OAKG;IACI,kBAAkB,CACvB,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,sBAAsB,CAAC;IAkBlC;;;;;OAKG;IACI,UAAU,CACf,IAAI,EAAE,2BAA2B,EACjC,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;OAIG;IACI,oBAAoB,CACzB,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,wBAAwB,CAAC;CAerC"}
@@ -42,9 +42,7 @@ export class CommunicationIdentityClient {
42
42
  * @param user - The user whose tokens are being revoked.
43
43
  * @param options - Additional options for the request.
44
44
  */
45
- revokeTokens(user,
46
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
47
- options = {}) {
45
+ revokeTokens(user, options = {}) {
48
46
  return tracingClient.withSpan("CommunicationIdentity-revokeTokens", options, async (updatedOptions) => {
49
47
  await this.client.communicationIdentityOperations.revokeAccessTokens(user.communicationUserId, updatedOptions);
50
48
  });
@@ -54,7 +52,6 @@ export class CommunicationIdentityClient {
54
52
  *
55
53
  * @param options - Additional options for the request.
56
54
  */
57
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
58
55
  createUser(options = {}) {
59
56
  return tracingClient.withSpan("CommunicationIdentity-createUser", options, async (updatedOptions) => {
60
57
  const result = await this.client.communicationIdentityOperations.create(Object.assign({ expiresInMinutes: undefined }, updatedOptions));
@@ -81,9 +78,7 @@ export class CommunicationIdentityClient {
81
78
  * @param user - The user being deleted.
82
79
  * @param options - Additional options for the request.
83
80
  */
84
- deleteUser(user,
85
- // eslint-disable-next-line @azure/azure-sdk/ts-naming-options
86
- options = {}) {
81
+ deleteUser(user, options = {}) {
87
82
  return tracingClient.withSpan("CommunicationIdentity-deleteUser", options, async (updatedOptions) => {
88
83
  await this.client.communicationIdentityOperations.delete(user.communicationUserId, updatedOptions);
89
84
  });
@@ -1 +1 @@
1
- {"version":3,"file":"communicationIdentityClient.js","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,oCAAoC,GAAG,CAC3C,OAAY,EACmC,EAAE,CACjD,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAqCtC,YACE,0BAAkC,EAClC,mBAA0F,EAC1F,eAAmD,EAAE;QAErD,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,oBAAoB,CAC9C,0BAA0B,EAC1B,mBAAmB,CACpB,CAAC;QACF,MAAM,OAAO,GAAG,oCAAoC,CAAC,mBAAmB,CAAC;YACvE,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,YAAY,CAAC;QAEjB,MAAM,uBAAuB,mCACxB,OAAO,GACP;YACD,cAAc,EAAE;gBACd,MAAM,EAAE,MAAM,CAAC,IAAI;aACpB;SACF,CACF,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAkB,CAAC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MIT License.\n\nimport type {\n CommunicationAccessToken,\n CommunicationIdentityClientOptions,\n CommunicationUserToken,\n GetTokenForTeamsUserOptions,\n CreateUserAndTokenOptions,\n GetTokenOptions,\n TokenScope,\n} from \"./models.js\";\nimport type { CommunicationUserIdentifier } from \"@azure/communication-common\";\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport type { InternalClientPipelineOptions, OperationOptions } from \"@azure/core-client\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport { IdentityRestClient } from \"./generated/src/identityRestClient.js\";\nimport { logger } from \"./common/logger.js\";\nimport { tracingClient } from \"./generated/src/tracing.js\";\n\nconst isCommunicationIdentityClientOptions = (\n options: any,\n): options is CommunicationIdentityClientOptions =>\n options && !isTokenCredential(options) && !isKeyCredential(options);\n\n/**\n * Client class for interacting with Azure Communication Services User Token Management.\n */\nexport class CommunicationIdentityClient {\n /**\n * A reference to the auto-generated UserToken HTTP client.\n */\n private readonly client: IdentityRestClient;\n\n /**\n * Initializes a new instance of the CommunicationIdentity class.\n * @param connectionString - Connection string to connect to an Azure Communication Service resource.\n * Example: \"endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret\";\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(connectionString: string, options?: CommunicationIdentityClientOptions);\n\n /**\n * Initializes a new instance of the CommunicationIdentity class using an Azure KeyCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the AzureKeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: KeyCredential,\n options?: CommunicationIdentityClientOptions,\n );\n /**\n * Initializes a new instance of the CommunicationIdentity class using a TokenCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net)\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options?: CommunicationIdentityClientOptions,\n );\n\n public constructor(\n connectionStringOrEndpoint: string,\n credentialOrOptions?: KeyCredential | CommunicationIdentityClientOptions | TokenCredential,\n maybeOptions: CommunicationIdentityClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(\n connectionStringOrEndpoint,\n credentialOrOptions,\n );\n const options = isCommunicationIdentityClientOptions(credentialOrOptions)\n ? credentialOrOptions\n : maybeOptions;\n\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n this.client = new IdentityRestClient(url, { endpoint: url, ...internalPipelineOptions });\n\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.client.pipeline.addPolicy(authPolicy);\n }\n\n /**\n * Creates a scoped user token.\n *\n * @param user - The user whose tokens are being issued.\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public getToken(\n user: CommunicationUserIdentifier,\n scopes: TokenScope[],\n options: GetTokenOptions = {},\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\"CommunicationIdentity-issueToken\", options, (updatedOptions) => {\n return this.client.communicationIdentityOperations.issueAccessToken(\n user.communicationUserId,\n scopes,\n { expiresInMinutes: options.tokenExpiresInMinutes, ...updatedOptions },\n );\n });\n }\n\n /**\n * Revokes all data and tokens created for a user.\n *\n * @param user - The user whose tokens are being revoked.\n * @param options - Additional options for the request.\n */\n public revokeTokens(\n user: CommunicationUserIdentifier,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-revokeTokens\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.revokeAccessTokens(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Creates a single user.\n *\n * @param options - Additional options for the request.\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n public createUser(options: OperationOptions = {}): Promise<CommunicationUserIdentifier> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUser\",\n options,\n async (updatedOptions) => {\n const result = await this.client.communicationIdentityOperations.create({\n expiresInMinutes: undefined,\n ...updatedOptions,\n });\n return {\n communicationUserId: result.identity.id,\n };\n },\n );\n }\n\n /**\n * Creates a single user and a token simultaneously.\n *\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public createUserAndToken(\n scopes: TokenScope[],\n options: CreateUserAndTokenOptions = {},\n ): Promise<CommunicationUserToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUserAndToken\",\n options,\n async (updatedOptions) => {\n const { identity, accessToken } = await this.client.communicationIdentityOperations.create({\n createTokenWithScopes: scopes,\n expiresInMinutes: options.tokenExpiresInMinutes,\n ...updatedOptions,\n });\n return {\n ...accessToken!,\n user: { communicationUserId: identity.id },\n };\n },\n );\n }\n\n /**\n * Triggers revocation event for user and deletes all its data.\n *\n * @param user - The user being deleted.\n * @param options - Additional options for the request.\n */\n public deleteUser(\n user: CommunicationUserIdentifier,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-deleteUser\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.delete(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Exchanges an Azure AD access token of a Teams user for a new Communication Identity access token with a matching expiration time.\n *\n * @param options - Options used to exchange an Azure AD access token of a Teams user for a new Communication Identity access token.\n */\n public getTokenForTeamsUser(\n options: GetTokenForTeamsUserOptions,\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-getTokenForTeamsUser\",\n options,\n (updatedOptions) => {\n const { teamsUserAadToken, clientId, userObjectId } = updatedOptions;\n return this.client.communicationIdentityOperations.exchangeTeamsUserAccessToken(\n teamsUserAadToken,\n clientId,\n userObjectId,\n updatedOptions,\n );\n },\n );\n }\n}\n"]}
1
+ {"version":3,"file":"communicationIdentityClient.js","sourceRoot":"","sources":["../../src/communicationIdentityClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAYlC,OAAO,EACL,6BAA6B,EAC7B,eAAe,EACf,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,oCAAoC,GAAG,CAC3C,OAAY,EACmC,EAAE,CACjD,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAqCtC,YACE,0BAAkC,EAClC,mBAA0F,EAC1F,eAAmD,EAAE;QAErD,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,oBAAoB,CAC9C,0BAA0B,EAC1B,mBAAmB,CACpB,CAAC;QACF,MAAM,OAAO,GAAG,oCAAoC,CAAC,mBAAmB,CAAC;YACvE,CAAC,CAAC,mBAAmB;YACrB,CAAC,CAAC,YAAY,CAAC;QAEjB,MAAM,uBAAuB,mCACxB,OAAO,GACP;YACD,cAAc,EAAE;gBACd,MAAM,EAAE,MAAM,CAAC,IAAI;aACpB;SACF,CACF,CAAC;QAEF,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAkB,CAAC,GAAG,kBAAI,QAAQ,EAAE,GAAG,IAAK,uBAAuB,EAAG,CAAC;QAEzF,MAAM,UAAU,GAAG,6BAA6B,CAAC,UAAU,CAAC,CAAC;QAC7D,IA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AO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,+BAA+B,CAAC,MAAM,iBACxF,qBAAqB,EAAE,MAAM,EAC7B,gBAAgB,EAAE,OAAO,CAAC,qBAAqB,IAC5C,cAAc,EACjB,CAAC;YACH,uCACK,WAAY,KACf,IAAI,EAAE,EAAE,mBAAmB,EAAE,QAAQ,CAAC,EAAE,EAAE,IAC1C;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACI,UAAU,CACf,IAAiC,EACjC,UAA4B,EAAE;QAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,kCAAkC,EAClC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,IAAI,CAAC,MAAM,CAAC,+BAA+B,CAAC,MAAM,CACtD,IAAI,CAAC,mBAAmB,EACxB,cAAc,CACf,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAED;;;;OAIG;IACI,oBAAoB,CACzB,OAAoC;QAEpC,OAAO,aAAa,CAAC,QAAQ,CAC3B,4CAA4C,EAC5C,OAAO,EACP,CAAC,cAAc,EAAE,EAAE;YACjB,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,cAAc,CAAC;YACrE,OAAO,IAAI,CAAC,MAAM,CAAC,+BAA+B,CAAC,4BAA4B,CAC7E,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,cAAc,CACf,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n CommunicationAccessToken,\n CommunicationIdentityClientOptions,\n CommunicationUserToken,\n GetTokenForTeamsUserOptions,\n CreateUserAndTokenOptions,\n GetTokenOptions,\n TokenScope,\n} from \"./models.js\";\nimport type { CommunicationUserIdentifier } from \"@azure/communication-common\";\nimport {\n createCommunicationAuthPolicy,\n isKeyCredential,\n parseClientArguments,\n} from \"@azure/communication-common\";\nimport type { InternalClientPipelineOptions, OperationOptions } from \"@azure/core-client\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport { IdentityRestClient } from \"./generated/src/identityRestClient.js\";\nimport { logger } from \"./common/logger.js\";\nimport { tracingClient } from \"./generated/src/tracing.js\";\n\nconst isCommunicationIdentityClientOptions = (\n options: any,\n): options is CommunicationIdentityClientOptions =>\n options && !isTokenCredential(options) && !isKeyCredential(options);\n\n/**\n * Client class for interacting with Azure Communication Services User Token Management.\n */\nexport class CommunicationIdentityClient {\n /**\n * A reference to the auto-generated UserToken HTTP client.\n */\n private readonly client: IdentityRestClient;\n\n /**\n * Initializes a new instance of the CommunicationIdentity class.\n * @param connectionString - Connection string to connect to an Azure Communication Service resource.\n * Example: \"endpoint=https://contoso.eastus.communications.azure.net/;accesskey=secret\";\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(connectionString: string, options?: CommunicationIdentityClientOptions);\n\n /**\n * Initializes a new instance of the CommunicationIdentity class using an Azure KeyCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net).\n * @param credential - An object that is used to authenticate requests to the service. Use the AzureKeyCredential or `@azure/identity` to create a credential.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: KeyCredential,\n options?: CommunicationIdentityClientOptions,\n );\n /**\n * Initializes a new instance of the CommunicationIdentity class using a TokenCredential.\n * @param endpoint - The endpoint of the service (ex: https://contoso.eastus.communications.azure.net)\n * @param credential - TokenCredential that is used to authenticate requests to the service.\n * @param options - Optional. Options to configure the HTTP pipeline.\n */\n public constructor(\n endpoint: string,\n credential: TokenCredential,\n options?: CommunicationIdentityClientOptions,\n );\n\n public constructor(\n connectionStringOrEndpoint: string,\n credentialOrOptions?: KeyCredential | CommunicationIdentityClientOptions | TokenCredential,\n maybeOptions: CommunicationIdentityClientOptions = {},\n ) {\n const { url, credential } = parseClientArguments(\n connectionStringOrEndpoint,\n credentialOrOptions,\n );\n const options = isCommunicationIdentityClientOptions(credentialOrOptions)\n ? credentialOrOptions\n : maybeOptions;\n\n const internalPipelineOptions: InternalClientPipelineOptions = {\n ...options,\n ...{\n loggingOptions: {\n logger: logger.info,\n },\n },\n };\n\n this.client = new IdentityRestClient(url, { endpoint: url, ...internalPipelineOptions });\n\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.client.pipeline.addPolicy(authPolicy);\n }\n\n /**\n * Creates a scoped user token.\n *\n * @param user - The user whose tokens are being issued.\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public getToken(\n user: CommunicationUserIdentifier,\n scopes: TokenScope[],\n options: GetTokenOptions = {},\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\"CommunicationIdentity-issueToken\", options, (updatedOptions) => {\n return this.client.communicationIdentityOperations.issueAccessToken(\n user.communicationUserId,\n scopes,\n { expiresInMinutes: options.tokenExpiresInMinutes, ...updatedOptions },\n );\n });\n }\n\n /**\n * Revokes all data and tokens created for a user.\n *\n * @param user - The user whose tokens are being revoked.\n * @param options - Additional options for the request.\n */\n public revokeTokens(\n user: CommunicationUserIdentifier,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-revokeTokens\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.revokeAccessTokens(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Creates a single user.\n *\n * @param options - Additional options for the request.\n */\n public createUser(options: OperationOptions = {}): Promise<CommunicationUserIdentifier> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUser\",\n options,\n async (updatedOptions) => {\n const result = await this.client.communicationIdentityOperations.create({\n expiresInMinutes: undefined,\n ...updatedOptions,\n });\n return {\n communicationUserId: result.identity.id,\n };\n },\n );\n }\n\n /**\n * Creates a single user and a token simultaneously.\n *\n * @param scopes - Scopes to include in the token.\n * @param options - Additional options for the request.\n */\n public createUserAndToken(\n scopes: TokenScope[],\n options: CreateUserAndTokenOptions = {},\n ): Promise<CommunicationUserToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-createUserAndToken\",\n options,\n async (updatedOptions) => {\n const { identity, accessToken } = await this.client.communicationIdentityOperations.create({\n createTokenWithScopes: scopes,\n expiresInMinutes: options.tokenExpiresInMinutes,\n ...updatedOptions,\n });\n return {\n ...accessToken!,\n user: { communicationUserId: identity.id },\n };\n },\n );\n }\n\n /**\n * Triggers revocation event for user and deletes all its data.\n *\n * @param user - The user being deleted.\n * @param options - Additional options for the request.\n */\n public deleteUser(\n user: CommunicationUserIdentifier,\n options: OperationOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-deleteUser\",\n options,\n async (updatedOptions) => {\n await this.client.communicationIdentityOperations.delete(\n user.communicationUserId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Exchanges an Azure AD access token of a Teams user for a new Communication Identity access token with a matching expiration time.\n *\n * @param options - Options used to exchange an Azure AD access token of a Teams user for a new Communication Identity access token.\n */\n public getTokenForTeamsUser(\n options: GetTokenForTeamsUserOptions,\n ): Promise<CommunicationAccessToken> {\n return tracingClient.withSpan(\n \"CommunicationIdentity-getTokenForTeamsUser\",\n options,\n (updatedOptions) => {\n const { teamsUserAadToken, clientId, userObjectId } = updatedOptions;\n return this.client.communicationIdentityOperations.exchangeTeamsUserAccessToken(\n teamsUserAadToken,\n clientId,\n userObjectId,\n updatedOptions,\n );\n },\n );\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/communication-identity",
3
- "version": "1.3.2-alpha.20241231.2",
3
+ "version": "1.3.2-alpha.20250109.1",
4
4
  "description": "SDK for Azure Communication service which facilitates user token administration.",
5
5
  "sdk-type": "client",
6
6
  "main": "./dist/commonjs/index.js",