@azure/web-pubsub 1.1.4-alpha.20241028.1 → 1.1.4-alpha.20241030.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"groupClient.js","sourceRoot":"","sources":["../../src/groupClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,SAAS,EAAmB,MAAM,2BAA2B,CAAC;AAEvE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAkK/C;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAuB7B;;OAEG;IACH,YAAY,MAAuB,EAAE,OAAe,EAAE,SAAiB;QAbvE;;WAEG;QACa,eAAU,GAAW,YAAY,CAAC;QAWhD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IACD;;;;;OAKG;IACI,KAAK,CAAC,aAAa,CACxB,YAAoB,EACpB,UAAqC,EAAE;QAEvC,IAAI,QAA2C,CAAC;QAChD,SAAS,UAAU,CAAC,WAAkC,EAAE,YAAqB;YAC3E,QAAQ,GAAG,WAAW,CAAC;YACvB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;QAED,OAAO,aAAa,CAAC,QAAQ,CAC3B,oCAAoC,EACpC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;YACvB,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,oBAAoB,CAC9C,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,SAAS,EACd,YAAY,kCAEP,cAAc,KACjB,UAAU,IAEb,CAAC;YAEF,IAAI,QAAS,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC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ACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,KAAK,CAAC,UAAU,CAAC,QAAgB,EAAE,UAAkC,EAAE;QAC5E,OAAO,aAAa,CAAC,QAAQ,CAAC,iCAAiC,EAAE,OAAO,EAAE,CAAC,cAAc,EAAE,EAAE;YAC3F,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,mBAAmB,CAC9C,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,SAAS,EACd,QAAQ,EACR,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAwBM,KAAK,CAAC,SAAS,CACpB,OAAoC,EACpC,UAA6D,EAAE;QAE/D,OAAO,aAAa,CAAC,QAAQ,CAAC,gCAAgC,EAAE,OAAO,EAAE,CAAC,cAAc,EAAE,EAAE;YAC1F,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,oBAAoB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;YAC/E,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CACtC,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,SAAS,EACd,WAAW,EACX,OAAc,EACd,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { CommonClientOptions, FullOperationResponse, OperationOptions } from \"@azure/core-client\";\nimport { RestError, RequestBodyType } from \"@azure/core-rest-pipeline\";\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport { tracingClient } from \"./tracing\";\nimport { getPayloadForMessage } from \"./utils\";\nimport { JSONTypes } from \"./hubClient\";\n\n/**\n * Options for constructing a GroupAdmin client.\n */\nexport interface GroupAdminClientOptions extends CommonClientOptions {}\n\n/**\n * Options for adding a connection to a group.\n */\nexport interface GroupAddConnectionOptions extends OperationOptions {}\n\n/**\n * Options for adding a user to a group.\n */\nexport interface GroupAddUserOptions extends OperationOptions {}\n\n/**\n * Options for checking if a user is in a group\n */\nexport interface GroupHasUserOptions extends OperationOptions {}\n\n/**\n * Options for removing a user from a group\n */\nexport interface GroupRemoveUserOptions extends OperationOptions {}\n\n/**\n * Options for removing a connection from a group\n */\nexport interface GroupRemoveConnectionOptions extends OperationOptions {}\n\n/**\n * Options for sending messages to a group.\n */\nexport interface GroupSendToAllOptions extends OperationOptions {\n /**\n * Connection ids to exclude from receiving this message.\n */\n excludedConnections?: string[];\n /**\n * The filter syntax to filter out the connections to send the messages to following OData filter syntax.\n * Examples:\n * * Exclude connections from `user1` and `user2`: `userId ne 'user1' and userId ne 'user2'`\n * * Exclude connections in `group1`: `not('group1' in groups)`\n * Details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax).\n */\n filter?: string;\n /**\n * The time-to-live (TTL) value in seconds for messages sent to the service.\n * 0 is the default value, which means the message never expires.\n * 300 is the maximum value.\n * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.\n * This parameter can help when the client's bandwidth is limited.\n */\n messageTtlSeconds?: number;\n}\n\n/**\n * Options for sending text messages to a group..\n */\nexport interface GroupSendTextToAllOptions extends GroupSendToAllOptions {\n /**\n * The content will be sent to the clients in plain text.\n */\n contentType: \"text/plain\";\n}\n\n/**\n * Options for closing all connections to a group.\n */\nexport interface GroupCloseAllConnectionsOptions extends OperationOptions {\n /**\n * Reason the connection is being closed.\n */\n reason?: string;\n}\n\nexport interface WebPubSubGroup {\n /**\n * The name of this group\n */\n readonly groupName: string;\n\n /**\n * The name of the hub this group belongs to\n */\n readonly hubName: string;\n\n /**\n * The Web PubSub API version being used by this client\n */\n readonly apiVersion: string;\n\n /**\n * The Web PubSub endpoint this client is connected to\n */\n readonly endpoint: string;\n\n /**\n * Add a specific connection to this group\n *\n * @param connectionId - The connection id to add to this group\n * @param options - Additional options\n */\n addConnection(connectionId: string, options?: GroupAddConnectionOptions): Promise<void>;\n\n /**\n * Remove a specific connection from this group\n *\n * @param connectionId - The connection id to remove from this group\n * @param options - Additional options\n */\n removeConnection(connectionId: string, options?: GroupRemoveConnectionOptions): Promise<void>;\n\n /**\n * Close all connections to the group\n *\n * @param options - Additional options\n */\n closeAllConnections(options?: GroupCloseAllConnectionsOptions): Promise<void>;\n\n /**\n * Add a user to this group\n *\n * @param username - The user name to add\n * @param options - Additional options\n */\n addUser(username: string, options?: GroupAddUserOptions): Promise<void>;\n\n /**\n * Remove a user from this group\n *\n * @param username - The user name to remove\n * @param options - Additional options\n */\n removeUser(username: string, options?: GroupRemoveUserOptions): Promise<void>;\n\n /**\n * Send a text message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>;\n /**\n * Send a json message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>;\n /**\n * Send a binary message to every connection in this group\n *\n * @param message - The binary message to send\n * @param options - Additional options\n */\n sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>;\n}\n\n/**\n * @hidden\n */\nexport class WebPubSubGroupImpl implements WebPubSubGroup {\n private client!: GeneratedClient;\n\n /**\n * The name of this group\n */\n public readonly groupName: string;\n\n /**\n * The name of the hub this group belongs to\n */\n public readonly hubName: string;\n\n /**\n * The Web PubSub API version being used by this client\n */\n public readonly apiVersion: string = \"2020-10-01\";\n\n /**\n * The Web PubSub endpoint this client is connected to\n */\n public endpoint!: string;\n\n /**\n * @internal\n */\n constructor(client: GeneratedClient, hubName: string, groupName: string) {\n this.client = client;\n this.groupName = groupName;\n this.hubName = hubName;\n }\n /**\n * Add a specific connection to this group\n *\n * @param connectionId - The connection id to add to this group\n * @param options - Additional options\n */\n public async addConnection(\n connectionId: string,\n options: GroupAddConnectionOptions = {},\n ): Promise<void> {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n\n return tracingClient.withSpan(\n \"WebPubSubGroupClient.addConnection\",\n options,\n async (updatedOptions) => {\n await this.client.webPubSub.addConnectionToGroup(\n this.hubName,\n this.groupName,\n connectionId,\n {\n ...updatedOptions,\n onResponse,\n },\n );\n\n if (response!.status === 404) {\n throw new RestError(`Connection id '${connectionId}' doesn't exist`, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n },\n );\n }\n\n /**\n * Remove a specific connection from this group\n *\n * @param connectionId - The connection id to remove from this group\n * @param options - Additional options\n */\n public async removeConnection(\n connectionId: string,\n options: GroupRemoveConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubGroupClient.removeConnection\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.removeConnectionFromGroup(\n this.hubName,\n this.groupName,\n connectionId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Close all connections to this group\n *\n * @param options - Additional options\n */\n public async closeAllConnections(options: GroupCloseAllConnectionsOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubGroupClient.closeAllConnections\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.closeGroupConnections(\n this.hubName,\n this.groupName,\n updatedOptions,\n );\n },\n );\n }\n /**\n * Add a user to this group\n *\n * @param username - The user name to add\n * @param options - Additional options\n */\n public async addUser(username: string, options: GroupAddUserOptions = {}): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubGroupClient.addUser\", options, (updatedOptions) => {\n return this.client.webPubSub.addUserToGroup(\n this.hubName,\n this.groupName,\n username,\n updatedOptions,\n );\n });\n }\n\n /**\n * Remove a user from this group\n *\n * @param username - The user name to remove\n * @param options - Additional options\n */\n public async removeUser(username: string, options: GroupRemoveUserOptions = {}): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubGroupClient.removeUser\", options, (updatedOptions) => {\n return this.client.webPubSub.removeUserFromGroup(\n this.hubName,\n this.groupName,\n username,\n updatedOptions,\n );\n });\n }\n\n /**\n * Send a text message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n public async sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>;\n /**\n * Send a json message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n public async sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>;\n /**\n * Send a binary message to every connection in this group\n *\n * @param message - The binary message to send\n * @param options - Additional options\n */\n public async sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>;\n\n public async sendToAll(\n message: JSONTypes | RequestBodyType,\n options: GroupSendToAllOptions | GroupSendTextToAllOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubGroupClient.sendToAll\", options, (updatedOptions) => {\n const { contentType, payload } = getPayloadForMessage(message, updatedOptions);\n return this.client.webPubSub.sendToGroup(\n this.hubName,\n this.groupName,\n contentType,\n payload as any,\n updatedOptions,\n );\n });\n }\n}\n"]}
1
+ {"version":3,"file":"groupClient.js","sourceRoot":"","sources":["../../src/groupClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAkK/C;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAuB7B;;OAEG;IACH,YAAY,MAAuB,EAAE,OAAe,EAAE,SAAiB;QAbvE;;WAEG;QACa,eAAU,GAAW,YAAY,CAAC;QAWhD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IACD;;;;;OAKG;IACI,KAAK,CAAC,aAAa,CACxB,YAAoB,EACpB,UAAqC,EAA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,CAAC,SAAS,EACd,WAAW,EACX,OAAc,EACd,cAAc,CACf,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n CommonClientOptions,\n FullOperationResponse,\n OperationOptions,\n} from \"@azure/core-client\";\nimport type { RequestBodyType } from \"@azure/core-rest-pipeline\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport type { GeneratedClient } from \"./generated/generatedClient\";\nimport { tracingClient } from \"./tracing\";\nimport { getPayloadForMessage } from \"./utils\";\nimport type { JSONTypes } from \"./hubClient\";\n\n/**\n * Options for constructing a GroupAdmin client.\n */\nexport interface GroupAdminClientOptions extends CommonClientOptions {}\n\n/**\n * Options for adding a connection to a group.\n */\nexport interface GroupAddConnectionOptions extends OperationOptions {}\n\n/**\n * Options for adding a user to a group.\n */\nexport interface GroupAddUserOptions extends OperationOptions {}\n\n/**\n * Options for checking if a user is in a group\n */\nexport interface GroupHasUserOptions extends OperationOptions {}\n\n/**\n * Options for removing a user from a group\n */\nexport interface GroupRemoveUserOptions extends OperationOptions {}\n\n/**\n * Options for removing a connection from a group\n */\nexport interface GroupRemoveConnectionOptions extends OperationOptions {}\n\n/**\n * Options for sending messages to a group.\n */\nexport interface GroupSendToAllOptions extends OperationOptions {\n /**\n * Connection ids to exclude from receiving this message.\n */\n excludedConnections?: string[];\n /**\n * The filter syntax to filter out the connections to send the messages to following OData filter syntax.\n * Examples:\n * * Exclude connections from `user1` and `user2`: `userId ne 'user1' and userId ne 'user2'`\n * * Exclude connections in `group1`: `not('group1' in groups)`\n * Details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax).\n */\n filter?: string;\n /**\n * The time-to-live (TTL) value in seconds for messages sent to the service.\n * 0 is the default value, which means the message never expires.\n * 300 is the maximum value.\n * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.\n * This parameter can help when the client's bandwidth is limited.\n */\n messageTtlSeconds?: number;\n}\n\n/**\n * Options for sending text messages to a group..\n */\nexport interface GroupSendTextToAllOptions extends GroupSendToAllOptions {\n /**\n * The content will be sent to the clients in plain text.\n */\n contentType: \"text/plain\";\n}\n\n/**\n * Options for closing all connections to a group.\n */\nexport interface GroupCloseAllConnectionsOptions extends OperationOptions {\n /**\n * Reason the connection is being closed.\n */\n reason?: string;\n}\n\nexport interface WebPubSubGroup {\n /**\n * The name of this group\n */\n readonly groupName: string;\n\n /**\n * The name of the hub this group belongs to\n */\n readonly hubName: string;\n\n /**\n * The Web PubSub API version being used by this client\n */\n readonly apiVersion: string;\n\n /**\n * The Web PubSub endpoint this client is connected to\n */\n readonly endpoint: string;\n\n /**\n * Add a specific connection to this group\n *\n * @param connectionId - The connection id to add to this group\n * @param options - Additional options\n */\n addConnection(connectionId: string, options?: GroupAddConnectionOptions): Promise<void>;\n\n /**\n * Remove a specific connection from this group\n *\n * @param connectionId - The connection id to remove from this group\n * @param options - Additional options\n */\n removeConnection(connectionId: string, options?: GroupRemoveConnectionOptions): Promise<void>;\n\n /**\n * Close all connections to the group\n *\n * @param options - Additional options\n */\n closeAllConnections(options?: GroupCloseAllConnectionsOptions): Promise<void>;\n\n /**\n * Add a user to this group\n *\n * @param username - The user name to add\n * @param options - Additional options\n */\n addUser(username: string, options?: GroupAddUserOptions): Promise<void>;\n\n /**\n * Remove a user from this group\n *\n * @param username - The user name to remove\n * @param options - Additional options\n */\n removeUser(username: string, options?: GroupRemoveUserOptions): Promise<void>;\n\n /**\n * Send a text message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>;\n /**\n * Send a json message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>;\n /**\n * Send a binary message to every connection in this group\n *\n * @param message - The binary message to send\n * @param options - Additional options\n */\n sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>;\n}\n\n/**\n * @hidden\n */\nexport class WebPubSubGroupImpl implements WebPubSubGroup {\n private client!: GeneratedClient;\n\n /**\n * The name of this group\n */\n public readonly groupName: string;\n\n /**\n * The name of the hub this group belongs to\n */\n public readonly hubName: string;\n\n /**\n * The Web PubSub API version being used by this client\n */\n public readonly apiVersion: string = \"2020-10-01\";\n\n /**\n * The Web PubSub endpoint this client is connected to\n */\n public endpoint!: string;\n\n /**\n * @internal\n */\n constructor(client: GeneratedClient, hubName: string, groupName: string) {\n this.client = client;\n this.groupName = groupName;\n this.hubName = hubName;\n }\n /**\n * Add a specific connection to this group\n *\n * @param connectionId - The connection id to add to this group\n * @param options - Additional options\n */\n public async addConnection(\n connectionId: string,\n options: GroupAddConnectionOptions = {},\n ): Promise<void> {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n\n return tracingClient.withSpan(\n \"WebPubSubGroupClient.addConnection\",\n options,\n async (updatedOptions) => {\n await this.client.webPubSub.addConnectionToGroup(\n this.hubName,\n this.groupName,\n connectionId,\n {\n ...updatedOptions,\n onResponse,\n },\n );\n\n if (response!.status === 404) {\n throw new RestError(`Connection id '${connectionId}' doesn't exist`, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n },\n );\n }\n\n /**\n * Remove a specific connection from this group\n *\n * @param connectionId - The connection id to remove from this group\n * @param options - Additional options\n */\n public async removeConnection(\n connectionId: string,\n options: GroupRemoveConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubGroupClient.removeConnection\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.removeConnectionFromGroup(\n this.hubName,\n this.groupName,\n connectionId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Close all connections to this group\n *\n * @param options - Additional options\n */\n public async closeAllConnections(options: GroupCloseAllConnectionsOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubGroupClient.closeAllConnections\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.closeGroupConnections(\n this.hubName,\n this.groupName,\n updatedOptions,\n );\n },\n );\n }\n /**\n * Add a user to this group\n *\n * @param username - The user name to add\n * @param options - Additional options\n */\n public async addUser(username: string, options: GroupAddUserOptions = {}): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubGroupClient.addUser\", options, (updatedOptions) => {\n return this.client.webPubSub.addUserToGroup(\n this.hubName,\n this.groupName,\n username,\n updatedOptions,\n );\n });\n }\n\n /**\n * Remove a user from this group\n *\n * @param username - The user name to remove\n * @param options - Additional options\n */\n public async removeUser(username: string, options: GroupRemoveUserOptions = {}): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubGroupClient.removeUser\", options, (updatedOptions) => {\n return this.client.webPubSub.removeUserFromGroup(\n this.hubName,\n this.groupName,\n username,\n updatedOptions,\n );\n });\n }\n\n /**\n * Send a text message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n public async sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>;\n /**\n * Send a json message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n public async sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>;\n /**\n * Send a binary message to every connection in this group\n *\n * @param message - The binary message to send\n * @param options - Additional options\n */\n public async sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>;\n\n public async sendToAll(\n message: JSONTypes | RequestBodyType,\n options: GroupSendToAllOptions | GroupSendTextToAllOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubGroupClient.sendToAll\", options, (updatedOptions) => {\n const { contentType, payload } = getPayloadForMessage(message, updatedOptions);\n return this.client.webPubSub.sendToGroup(\n this.hubName,\n this.groupName,\n contentType,\n payload as any,\n updatedOptions,\n );\n });\n }\n}\n"]}
@@ -2,7 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
  import { RestError } from "@azure/core-rest-pipeline";
4
4
  import { GeneratedClient } from "./generated/generatedClient";
5
- import { WebPubSubGroupImpl, } from "./groupClient";
5
+ import { WebPubSubGroupImpl } from "./groupClient";
6
6
  import { isTokenCredential } from "@azure/core-auth";
7
7
  import { webPubSubKeyCredentialPolicy } from "./webPubSubCredentialPolicy";
8
8
  import { tracingClient } from "./tracing";
@@ -1 +1 @@
1
- {"version":3,"file":"hubClient.js","sourceRoot":"","sources":["../../src/hubClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,SAAS,EAAmB,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAEL,kBAAkB,GAGnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAuC,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAM/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAmRnE;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAyDjC,YACE,0BAAkC,EAClC,cAA8D,EAC9D,aAAsD,EACtD,IAAoC;;QApDtC;;WAEG;QACa,eAAU,GAAW,YAAY,CAAC;QAmDhD,+BAA+B;QAC/B,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;YACvC,IAAI,CAAC,QAAQ,GAAG,0BAA0B,CAAC;YAC3C,IAAI,CAAC,OAAO,GAAG,aAAuB,CAAC;Y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B,SAAS,EACP,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,uBAAuB,MAAK,SAAS;wBACnD,CAAC,CAAC,IAAI;wBACN,CAAC,CAAC,GAAG,cAAc,CAAC,uBAAuB,GAAG;oBAClD,SAAS,EAAE,OAAO;iBACnB,CAAC;gBACF,IAAI,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,EAAE,CAAC;oBAC3B,WAAW,CAAC,OAAO,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,CAAC;gBAC/C,CAAC;gBACD,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;YAC9C,CAAC;YAED,OAAO;gBACL,KAAK;gBACL,OAAO;gBACP,GAAG,EAAE,GAAG,OAAO,iBAAiB,KAAK,EAAE;aACxC,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { CommonClientOptions, FullOperationResponse, OperationOptions } from \"@azure/core-client\";\nimport { RestError, RequestBodyType } from \"@azure/core-rest-pipeline\";\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport {\n WebPubSubGroup,\n WebPubSubGroupImpl,\n GroupAddConnectionOptions,\n GroupRemoveConnectionOptions,\n} from \"./groupClient\";\nimport { AzureKeyCredential, TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { webPubSubKeyCredentialPolicy } from \"./webPubSubCredentialPolicy\";\nimport { tracingClient } from \"./tracing\";\nimport { logger } from \"./logger\";\nimport { parseConnectionString } from \"./parseConnectionString\";\nimport jwt from \"jsonwebtoken\";\nimport { getPayloadForMessage } from \"./utils\";\nimport {\n GeneratedClientOptionalParams,\n AddToGroupsRequest,\n RemoveFromGroupsRequest,\n} from \"./generated\";\nimport { webPubSubReverseProxyPolicy } from \"./reverseProxyPolicy\";\n\n/**\n * Options for closing a connection to a hub.\n */\nexport interface HubCloseConnectionOptions extends OperationOptions {\n /**\n * Reason the connection is being closed.\n */\n reason?: string;\n}\n\n/**\n * Options for closing all connections to a hub.\n */\nexport interface HubCloseAllConnectionsOptions extends OperationOptions {\n /**\n * Reason the connection is being closed.\n */\n reason?: string;\n}\n\n/**\n * Options for closing all of a user's connections to a hub.\n */\nexport interface HubCloseUserConnectionsOptions extends OperationOptions {\n /**\n * Reason the connection is being closed.\n */\n reason?: string;\n}\n\n/**\n * Options for sending messages to hubs.\n */\nexport interface HubSendToAllOptions extends OperationOptions {\n /**\n * Connection ids to exclude from receiving this message.\n */\n excludedConnections?: string[];\n /**\n * The filter syntax to filter out the connections to send the messages to following OData filter syntax.\n * Examples:\n * * Exclude connections from `user1` and `user2`: `userId ne 'user1' and userId ne 'user2'`\n * * Exclude connections in `group1`: `not('group1' in groups)`\n * Details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax).\n */\n filter?: string;\n /**\n * The time-to-live (TTL) value in seconds for messages sent to the service.\n * 0 is the default value, which means the message never expires.\n * 300 is the maximum value.\n * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.\n * This parameter can help when the client's bandwidth is limited.\n */\n messageTtlSeconds?: number;\n}\n\n/**\n * Options for sending text messages to hubs.\n */\nexport interface HubSendTextToAllOptions extends HubSendToAllOptions {\n /**\n * The content will be sent to the clients in plain text.\n */\n contentType: \"text/plain\";\n}\n\n/**\n * Types which can be serialized and sent as JSON.\n */\nexport type JSONTypes = string | number | boolean | object;\n\n/**\n * Options for constructing a HubAdmin client.\n */\nexport interface WebPubSubServiceClientOptions extends CommonClientOptions {\n /**\n * Reverse proxy endpoint (for example, your Azure API management endpoint)\n */\n reverseProxyEndpoint?: string;\n /**\n * Options to configure the logging options.\n */\n loggingOptions?: WebPubSubServiceClientLogOptions;\n}\n\n/**\n * Options to configure the logging options.\n */\nexport declare interface WebPubSubServiceClientLogOptions {\n /**\n * Header names whose values will be logged when logging is enabled.\n * Defaults include a list of well-known safe headers. Any headers\n * specified in this field will be added to that list. Any other values will\n * be written to logs as \"REDACTED\".\n */\n additionalAllowedHeaderNames?: string[];\n /**\n * Query string names whose values will be logged when logging is enabled. By default no\n * query string values are logged.\n */\n additionalAllowedQueryParameters?: string[];\n}\n\n/**\n * Options for checking if a connection exists.\n */\nexport interface HasConnectionOptions extends OperationOptions {}\n\n/**\n * Options for checking if a group exists.\n */\nexport interface HubHasGroupOptions extends OperationOptions {}\n\n/**\n * Options for checking if a user exists.\n */\nexport interface HubHasUserOptions extends OperationOptions {}\n\n/**\n * Options for removing a user from all groups.\n */\nexport interface HubRemoveUserFromAllGroupsOptions extends HubCloseConnectionOptions {}\n\n/**\n * Options for sending a message to a specific connection.\n */\nexport interface HubSendToConnectionOptions extends OperationOptions {\n /**\n * The time-to-live (TTL) value in seconds for messages sent to the service.\n * 0 is the default value, which means the message never expires.\n * 300 is the maximum value.\n * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.\n * This parameter can help when the client's bandwidth is limited.\n */\n messageTtlSeconds?: number;\n}\n\n/**\n * Options for sending a text message to a connection.\n */\nexport interface HubSendTextToConnectionOptions extends HubSendToConnectionOptions {\n contentType: \"text/plain\";\n}\n\n/**\n * Options for sending a message to a user.\n */\nexport interface HubSendToUserOptions extends OperationOptions {\n /**\n * The filter syntax to filter out the connections to send the messages to following OData filter syntax.\n * Examples:\n * * Exclude connections in `group1`: `not('group1' in groups)`\n * * Send to connections in `group1` or `group2`: `'group1' in groups or `group2` in groups`\n * Details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax).\n */\n filter?: string;\n /**\n * The time-to-live (TTL) value in seconds for messages sent to the service.\n * 0 is the default value, which means the message never expires.\n * 300 is the maximum value.\n * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.\n * This parameter can help when the client's bandwidth is limited.\n */\n messageTtlSeconds?: number;\n}\n\n/**\n * Options for sending a text message to a user.\n */\nexport interface HubSendTextToUserOptions extends HubSendToUserOptions {\n /**\n * The content will be sent to the clients in plain text.\n */\n contentType: \"text/plain\";\n}\n\nexport type Permission = \"joinLeaveGroup\" | \"sendToGroup\";\n\n/**\n * Options for grant permissions to a connection\n */\nexport interface HubGrantPermissionOptions extends OperationOptions {\n /**\n * The meaning of the target depends on the specific permission.\n * For joinLeaveGroup and sendToGroup, targetName is a required parameter standing for the group name.\n */\n targetName?: string;\n}\n\n/**\n * Options for revoke permissions from a connection\n */\nexport interface HubRevokePermissionOptions extends OperationOptions {\n /**\n * The meaning of the target depends on the specific permission.\n * For joinLeaveGroup and sendToGroup, targetName is a required parameter standing for the group name.\n */\n targetName?: string;\n}\n\n/**\n * Options for checking if a connection has the specified permission\n */\nexport interface HubHasPermissionOptions extends OperationOptions {\n /**\n * The meaning of the target depends on the specific permission.\n * For joinLeaveGroup and sendToGroup, targetName is a required parameter standing for the group name.\n */\n targetName?: string;\n}\n\n/**\n * The type of client endpoint that is being requested.\n */\nexport type WebPubSubClientProtocol = \"default\" | \"mqtt\";\n\n/**\n * Options for generating a token to connect a client to the Azure Web Pubsub service.\n */\nexport interface GenerateClientTokenOptions extends OperationOptions {\n /**\n * The userId for the client.\n */\n userId?: string;\n\n /**\n * The roles that the connection with the generated token will have.\n * Roles give the client initial permissions to leave, join, or publish to groups when using PubSub subprotocol\n * * `webpubsub.joinLeaveGroup`: the client can join or leave any group\n * * `webpubsub.sendToGroup`: the client can send messages to any group\n * * `webpubsub.joinLeaveGroup.<group>`: the client can join or leave group `<group>`\n * * `webpubsub.sendToGroup.<group>`: the client can send messages to group `<group>`\n *\n * {@link https://azure.github.io/azure-webpubsub/references/pubsub-websocket-subprotocol#permissions}\n */\n roles?: string[];\n\n /**\n * Minutes until the token expires.\n */\n expirationTimeInMinutes?: number;\n\n /**\n * The groups to join when the client connects\n */\n groups?: string[];\n\n /**\n * The protocol type of the client\n * * `default`: Default WebPubSub Client. Example Client Connection URL: _wss://exampleHost.com/client/hubs/exampleHub_\n * * `mqtt`: MQTT Client. Example Client Connection URL: _wss://exampleHost.com/client/mqtt/hubs/exampleHub_\n */\n clientProtocol?: WebPubSubClientProtocol;\n}\n\n/**\n * A response containing the client token.\n */\nexport interface ClientTokenResponse {\n /**\n * The client token.\n */\n token: string;\n /**\n * The URL client connects to\n */\n baseUrl: string;\n /**\n * The URL client connects to with access_token query string\n */\n url: string;\n}\n\n/**\n * Client for connecting to a Web PubSub hub\n */\nexport class WebPubSubServiceClient {\n private readonly client: GeneratedClient;\n private credential!: AzureKeyCredential | TokenCredential;\n private readonly clientOptions?: WebPubSubServiceClientOptions;\n\n /**\n * The name of the hub this client is connected to\n */\n public readonly hubName: string;\n /**\n * The Web PubSub API version being used by this client\n */\n public readonly apiVersion: string = \"2024-01-01\";\n\n /**\n * The Web PubSub endpoint this client is connected to\n */\n public endpoint!: string;\n\n /**\n * Creates an instance of a WebPubSubServiceClient for sending messages and managing groups, connections, and users.\n *\n * Example usage:\n * ```ts\n * import { WebPubSubServiceClient } from \"@azure/web-pubsub\";\n * const connectionString = process.env['WEB_PUBSUB_CONNECTION_STRING'];\n * const client = new WebPubSubServiceClient(connectionString, 'chat');\n * ```\n *\n * @param connectionString - The connection string\n * @param hubName - The name of the hub to connect to. If omitted, '_default' is used.\n * @param options - Options to configure the http pipeline\n */\n constructor(connectionString: string, hubName: string, options?: WebPubSubServiceClientOptions);\n\n /**\n * Creates an instance of a WebPubSubServiceClient for sending messages and managing groups, connections, and users.\n *\n * Example usage:\n * ```ts\n * import { WebPubSubServiceClient, AzureKeyCredential } from \"@azure/web-pubsub\";\n * const cred = new AzureKeyCredential(\"<your web pubsub api key>\");\n * const endpoint = \"https://xxxx.webpubsubdev.azure.com\"\n * const client = new WebPubSubServiceClient(endpoint, cred, 'chat');\n * ```\n *\n * @param endpoint - The endpoint to connect to\n * @param credential - An AzureKeyCredential holding your service key\n * @param hubName - The name of the hub to connect to.\n * @param options - Options to configure the http pipeline\n */\n constructor(\n endpoint: string,\n credential: AzureKeyCredential | TokenCredential,\n hubName: string,\n options?: WebPubSubServiceClientOptions,\n );\n constructor(\n endpointOrConnectionString: string,\n credsOrHubName?: AzureKeyCredential | TokenCredential | string,\n hubNameOrOpts?: string | WebPubSubServiceClientOptions,\n opts?: WebPubSubServiceClientOptions,\n ) {\n // unpack constructor arguments\n if (typeof credsOrHubName === \"object\") {\n this.endpoint = endpointOrConnectionString;\n this.hubName = hubNameOrOpts as string;\n this.clientOptions = opts;\n this.credential = credsOrHubName;\n } else {\n const parsedCs = parseConnectionString(endpointOrConnectionString);\n this.endpoint = parsedCs.endpoint;\n this.credential = parsedCs.credential;\n this.hubName = credsOrHubName as string;\n this.clientOptions = hubNameOrOpts as WebPubSubServiceClientOptions;\n }\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...this.clientOptions,\n ...{\n apiVersion: this.apiVersion,\n loggingOptions: {\n additionalAllowedHeaderNames:\n this.clientOptions?.loggingOptions?.additionalAllowedHeaderNames,\n additionalAllowedQueryParameters:\n this.clientOptions?.loggingOptions?.additionalAllowedQueryParameters,\n logger: logger.info,\n },\n },\n ...(isTokenCredential(this.credential)\n ? {\n credential: this.credential,\n credentialScopes: [\"https://webpubsub.azure.com/.default\"],\n }\n : {}),\n };\n\n this.client = new GeneratedClient(this.endpoint, internalPipelineOptions);\n\n if (!isTokenCredential(this.credential)) {\n this.client.pipeline.addPolicy(webPubSubKeyCredentialPolicy(this.credential));\n }\n\n if (this.clientOptions?.reverseProxyEndpoint) {\n this.client.pipeline.addPolicy(\n webPubSubReverseProxyPolicy(this.clientOptions?.reverseProxyEndpoint),\n );\n }\n }\n\n /**\n * Get a client for a group\n * @param groupName - The name of the group to connect to.\n */\n public group(groupName: string): WebPubSubGroup {\n return new WebPubSubGroupImpl(this.client, this.hubName, groupName);\n }\n\n /**\n * Broadcast a text message to all connections on this hub.\n *\n * @param message - The text message to send\n * @param options - Additional options\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n public async sendToAll(message: string, options: HubSendTextToAllOptions): Promise<void>;\n /**\n * Broadcast a JSON message to all connections on this hub.\n *\n * @param message - The JSON message to send\n * @param options - Additional options\n */\n public async sendToAll(message: JSONTypes, options?: HubSendToAllOptions): Promise<void>;\n /**\n * Broadcast a binary message to all connections on this hub.\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n public async sendToAll(message: RequestBodyType, options?: HubSendToAllOptions): Promise<void>;\n\n public async sendToAll(\n message: RequestBodyType | JSONTypes,\n options: HubSendToAllOptions | HubSendTextToAllOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubServiceClient.sendToAll\", options, (updatedOptions) => {\n const { contentType, payload } = getPayloadForMessage(message, updatedOptions);\n return this.client.webPubSub.sendToAll(\n this.hubName,\n contentType,\n payload as any,\n updatedOptions,\n );\n });\n }\n\n /**\n * Send a text message to a specific user\n *\n * @param username - User name to send to\n * @param message - The text message to send\n * @param options - Additional options\n */\n public async sendToUser(\n username: string,\n message: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: HubSendTextToUserOptions,\n ): Promise<void>;\n\n /**\n * Send a JSON message to a specific user\n *\n * @param username - User name to send to\n * @param message - The josn message to send\n * @param options - Additional options\n */\n public async sendToUser(\n username: string,\n message: JSONTypes,\n options?: HubSendToUserOptions,\n ): Promise<void>;\n\n /**\n * Send a binary message to a specific user\n *\n * @param username - The user name to send to\n * @param message - The binary message to send\n * @param options - Additional options\n */\n public async sendToUser(\n username: string,\n message: RequestBodyType,\n options?: HubSendToUserOptions | HubSendTextToUserOptions,\n ): Promise<void>;\n public async sendToUser(\n username: string,\n message: RequestBodyType | JSONTypes,\n options: HubSendToUserOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.sendToUser\",\n options,\n (updatedOptions) => {\n const { contentType, payload } = getPayloadForMessage(message, updatedOptions);\n return this.client.webPubSub.sendToUser(\n this.hubName,\n username,\n contentType,\n payload as any,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Send a text message to a specific connection\n *\n * @param connectionId - Connection id to send to\n * @param message - The text message\n * @param options - Additional options\n */\n public async sendToConnection(\n connectionId: string,\n message: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: HubSendTextToConnectionOptions,\n ): Promise<void>;\n\n /**\n * Send a binary message to a specific connection\n *\n * @param connectionId - Connection id to send to\n * @param message - The JSON message\n * @param options - Additional options\n */\n public async sendToConnection(\n connectionId: string,\n message: JSONTypes,\n options?: HubSendToConnectionOptions,\n ): Promise<void>;\n\n /**\n * Send a binary message to a specific connection\n *\n * @param connectionId - Connection id to send to\n * @param message - The binary message\n * @param options - Additional options\n */\n public async sendToConnection(\n connectionId: string,\n message: RequestBodyType,\n options?: HubSendToConnectionOptions | HubSendTextToConnectionOptions,\n ): Promise<void>;\n public async sendToConnection(\n connectionId: string,\n message: RequestBodyType | JSONTypes,\n options: HubSendToConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.sendToConnection\",\n options,\n (updatedOptions) => {\n const { contentType, payload } = getPayloadForMessage(message, updatedOptions);\n\n return this.client.webPubSub.sendToConnection(\n this.hubName,\n connectionId,\n contentType,\n payload as any,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Check if a specific connection is connected to this hub\n *\n * @param connectionId - Connection id to check\n * @param options - Additional options\n */\n public async connectionExists(\n connectionId: string,\n options: HasConnectionOptions = {},\n ): Promise<boolean> {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.connectionExists\",\n options,\n async (updatedOptions) => {\n await this.client.webPubSub.connectionExists(this.hubName, connectionId, {\n ...updatedOptions,\n onResponse,\n });\n\n if (response!.status === 200) {\n return true;\n } else if (response!.status === 404) {\n return false;\n } else {\n // this is sad - wish this was handled by autorest.\n throw new RestError(response!.bodyAsText!, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n },\n );\n }\n\n /**\n * Close a specific connection to this hub\n *\n * @param connectionId - Connection id to close\n * @param options - Additional options\n */\n public async closeConnection(\n connectionId: string,\n options: HubCloseConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.closeConnection\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.closeConnection(this.hubName, connectionId, updatedOptions);\n },\n );\n }\n\n /**\n * Close all connections to this hub\n *\n * @param options - Additional options\n */\n public async closeAllConnections(options: HubCloseAllConnectionsOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.closeAllConnections\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.closeAllConnections(this.hubName, updatedOptions);\n },\n );\n }\n\n /**\n * Close all connections with the given user id\n *\n * @param user - User id to close\n * @param options - Additional options\n */\n public async closeUserConnections(\n userId: string,\n options: HubCloseUserConnectionsOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.closeUserConnections\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.closeUserConnections(this.hubName, userId, updatedOptions);\n },\n );\n }\n\n /**\n * Remove a specific user from all groups they are joined to\n * @param userId - The user id to remove from all groups\n * @param options - Additional options\n */\n public async removeUserFromAllGroups(\n userId: string,\n options: HubCloseConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.removeUserFromAllGroups\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.removeUserFromAllGroups(this.hubName, userId, updatedOptions);\n },\n );\n }\n\n /**\n * Remove a specific connection from all groups they are joined to\n * @param connectionId - The connection id to remove from all groups\n * @param options - Additional options\n */\n public async removeConnectionFromAllGroups(\n connectionId: string,\n options: HubCloseConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.removeConnectionFromAllGroups\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.removeConnectionFromAllGroups(\n this.hubName,\n connectionId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Add filtered connections to multiple groups\n * @param groups - A list of groups which target connections will be added into\n * @param filter - An OData filter which target connections satisfy\n * @param options - Additional options\n */\n public async addConnectionsToGroups(\n groups: string[],\n filter: string,\n options: GroupAddConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.addConnectionsToGroups\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.addConnectionsToGroups(\n this.hubName,\n {\n groups: groups,\n filter: filter,\n } as AddToGroupsRequest,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Remove filtered connections from multiple groups\n * @param groups - A list of groups which target connections will be removed from\n * @param filter - An OData filter which target connections satisfy\n * @param options - Additional options\n */\n public async removeConnectionsFromGroups(\n groups: string[],\n filter: string,\n options: GroupRemoveConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.removeConnectionsFromGroups\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.removeConnectionsFromGroups(\n this.hubName,\n {\n groups: groups,\n filter: filter,\n } as RemoveFromGroupsRequest,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Check if a particular group exists (i.e. has active connections).\n *\n * @param groupName - The group name to check for\n * @param options - Additional options\n */\n public async groupExists(groupName: string, options: HubHasGroupOptions = {}): Promise<boolean> {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.groupExists\",\n options,\n async (updatedOptions) => {\n await this.client.webPubSub.groupExists(this.hubName, groupName, {\n ...updatedOptions,\n onResponse,\n });\n\n if (response!.status === 200) {\n return true;\n } else if (response!.status === 404) {\n return false;\n } else {\n throw new RestError(response!.bodyAsText!, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n },\n );\n }\n\n /**\n * Check if a particular user is connected to this hub.\n *\n * @param username - The user name to check for\n * @param options - Additional options\n */\n public async userExists(username: string, options: HubHasUserOptions = {}): Promise<boolean> {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.userExists\",\n options,\n async (updatedOptions) => {\n await this.client.webPubSub.userExists(this.hubName, username, {\n ...updatedOptions,\n onResponse,\n });\n\n if (response!.status === 200) {\n return true;\n } else if (response!.status === 404) {\n return false;\n } else {\n // this is sad - wish this was handled by autorest.\n throw new RestError(response!.bodyAsText!, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n },\n );\n }\n\n /**\n * Grant permissions to a connection\n *\n * @param connectionId - The connection id to grant permissions to\n * @param Permission - The permission to grant\n * @param options - Additional options\n */\n public async grantPermission(\n connectionId: string,\n permission: Permission,\n options: HubGrantPermissionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.grantPermission\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.grantPermission(\n this.hubName,\n permission,\n connectionId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Revoke permissions from a connection\n *\n * @param connectionId - The connection id to revoke permissions from\n * @param Permission - The permission to revoke\n * @param options - Additional options\n */\n public async revokePermission(\n connectionId: string,\n permission: Permission,\n options: HubRevokePermissionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.revokePermission\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.revokePermission(\n this.hubName,\n permission,\n connectionId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Check if the connection has the specified permission\n *\n * @param connectionId - The connection id to check permission\n * @param Permission - The permission to check\n * @param options - Additional options\n */\n public async hasPermission(\n connectionId: string,\n permission: Permission,\n options: HubHasPermissionOptions = {},\n ): Promise<boolean> {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.hasPermission\",\n options,\n async (updatedOptions) => {\n await this.client.webPubSub.checkPermission(this.hubName, permission, connectionId, {\n ...updatedOptions,\n onResponse,\n });\n\n if (response!.status === 200) {\n return true;\n } else if (response!.status === 404) {\n return false;\n } else {\n // this is sad - wish this was handled by autorest.\n throw new RestError(response!.bodyAsText!, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n },\n );\n }\n\n /**\n * Generate a token for a client to connect to the Azure Web PubSub service.\n *\n * @param options - Additional options\n */\n public async getClientAccessToken(\n options: GenerateClientTokenOptions = {},\n ): Promise<ClientTokenResponse> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.getClientAccessToken\",\n options,\n async (updatedOptions) => {\n const endpoint = this.endpoint.endsWith(\"/\") ? this.endpoint : this.endpoint + \"/\";\n const clientEndpoint = endpoint.replace(/(http)(s?:\\/\\/)/gi, \"ws$2\");\n const clientProtocol = updatedOptions.clientProtocol;\n const clientPath =\n clientProtocol && clientProtocol === \"mqtt\"\n ? `clients/mqtt/hubs/${this.hubName}`\n : `client/hubs/${this.hubName}`;\n const baseUrl = clientEndpoint + clientPath;\n\n let token: string;\n if (isTokenCredential(this.credential)) {\n const response = await this.client.webPubSub.generateClientToken(\n this.hubName,\n updatedOptions,\n );\n token = response.token!;\n } else {\n const key = this.credential.key;\n const audience = endpoint + clientPath;\n const payload = {\n role: updatedOptions?.roles,\n \"webpubsub.group\": updatedOptions?.groups,\n };\n const signOptions: jwt.SignOptions = {\n audience: audience,\n expiresIn:\n updatedOptions?.expirationTimeInMinutes === undefined\n ? \"1h\"\n : `${updatedOptions.expirationTimeInMinutes}m`,\n algorithm: \"HS256\",\n };\n if (updatedOptions?.userId) {\n signOptions.subject = updatedOptions?.userId;\n }\n token = jwt.sign(payload, key, signOptions);\n }\n\n return {\n token,\n baseUrl,\n url: `${baseUrl}?access_token=${token}`,\n };\n },\n );\n }\n}\n"]}
1
+ {"version":3,"file":"hubClient.js","sourceRoot":"","sources":["../../src/hubClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAM9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAM/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAmRnE;;GAEG;AACH,MAAM,OAAO,sBAAsB;IAyDjC,YACE,0BAAkC,EAClC,cAA8D,EAC9D,aAAsD,EACtD,IAAoC;;QApDtC;;WAEG;QACa,eAAU,GAAW,YAAY,CAAC;QAmDhD,+BAA+B;QAC/B,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;YACvC,IAAI,CAAC,QAAQ,GAAG,0BAA0B,CAAC;YAC3C,IAAI,CAAC,OAAO,GAAG,aAAuB,CAAC;YACvC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;YAC1B,IAAI,CAAC,UAAU,GAAG,cAAc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wBACnD,CAAC,CAAC,IAAI;wBACN,CAAC,CAAC,GAAG,cAAc,CAAC,uBAAuB,GAAG;oBAClD,SAAS,EAAE,OAAO;iBACnB,CAAC;gBACF,IAAI,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,EAAE,CAAC;oBAC3B,WAAW,CAAC,OAAO,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,CAAC;gBAC/C,CAAC;gBACD,KAAK,GAAG,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;YAC9C,CAAC;YAED,OAAO;gBACL,KAAK;gBACL,OAAO;gBACP,GAAG,EAAE,GAAG,OAAO,iBAAiB,KAAK,EAAE;aACxC,CAAC;QACJ,CAAC,CACF,CAAC;IACJ,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n CommonClientOptions,\n FullOperationResponse,\n OperationOptions,\n} from \"@azure/core-client\";\nimport type { RequestBodyType } from \"@azure/core-rest-pipeline\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { GeneratedClient } from \"./generated/generatedClient\";\nimport type {\n WebPubSubGroup,\n GroupAddConnectionOptions,\n GroupRemoveConnectionOptions,\n} from \"./groupClient\";\nimport { WebPubSubGroupImpl } from \"./groupClient\";\nimport type { AzureKeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport { webPubSubKeyCredentialPolicy } from \"./webPubSubCredentialPolicy\";\nimport { tracingClient } from \"./tracing\";\nimport { logger } from \"./logger\";\nimport { parseConnectionString } from \"./parseConnectionString\";\nimport jwt from \"jsonwebtoken\";\nimport { getPayloadForMessage } from \"./utils\";\nimport type {\n GeneratedClientOptionalParams,\n AddToGroupsRequest,\n RemoveFromGroupsRequest,\n} from \"./generated\";\nimport { webPubSubReverseProxyPolicy } from \"./reverseProxyPolicy\";\n\n/**\n * Options for closing a connection to a hub.\n */\nexport interface HubCloseConnectionOptions extends OperationOptions {\n /**\n * Reason the connection is being closed.\n */\n reason?: string;\n}\n\n/**\n * Options for closing all connections to a hub.\n */\nexport interface HubCloseAllConnectionsOptions extends OperationOptions {\n /**\n * Reason the connection is being closed.\n */\n reason?: string;\n}\n\n/**\n * Options for closing all of a user's connections to a hub.\n */\nexport interface HubCloseUserConnectionsOptions extends OperationOptions {\n /**\n * Reason the connection is being closed.\n */\n reason?: string;\n}\n\n/**\n * Options for sending messages to hubs.\n */\nexport interface HubSendToAllOptions extends OperationOptions {\n /**\n * Connection ids to exclude from receiving this message.\n */\n excludedConnections?: string[];\n /**\n * The filter syntax to filter out the connections to send the messages to following OData filter syntax.\n * Examples:\n * * Exclude connections from `user1` and `user2`: `userId ne 'user1' and userId ne 'user2'`\n * * Exclude connections in `group1`: `not('group1' in groups)`\n * Details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax).\n */\n filter?: string;\n /**\n * The time-to-live (TTL) value in seconds for messages sent to the service.\n * 0 is the default value, which means the message never expires.\n * 300 is the maximum value.\n * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.\n * This parameter can help when the client's bandwidth is limited.\n */\n messageTtlSeconds?: number;\n}\n\n/**\n * Options for sending text messages to hubs.\n */\nexport interface HubSendTextToAllOptions extends HubSendToAllOptions {\n /**\n * The content will be sent to the clients in plain text.\n */\n contentType: \"text/plain\";\n}\n\n/**\n * Types which can be serialized and sent as JSON.\n */\nexport type JSONTypes = string | number | boolean | object;\n\n/**\n * Options for constructing a HubAdmin client.\n */\nexport interface WebPubSubServiceClientOptions extends CommonClientOptions {\n /**\n * Reverse proxy endpoint (for example, your Azure API management endpoint)\n */\n reverseProxyEndpoint?: string;\n /**\n * Options to configure the logging options.\n */\n loggingOptions?: WebPubSubServiceClientLogOptions;\n}\n\n/**\n * Options to configure the logging options.\n */\nexport declare interface WebPubSubServiceClientLogOptions {\n /**\n * Header names whose values will be logged when logging is enabled.\n * Defaults include a list of well-known safe headers. Any headers\n * specified in this field will be added to that list. Any other values will\n * be written to logs as \"REDACTED\".\n */\n additionalAllowedHeaderNames?: string[];\n /**\n * Query string names whose values will be logged when logging is enabled. By default no\n * query string values are logged.\n */\n additionalAllowedQueryParameters?: string[];\n}\n\n/**\n * Options for checking if a connection exists.\n */\nexport interface HasConnectionOptions extends OperationOptions {}\n\n/**\n * Options for checking if a group exists.\n */\nexport interface HubHasGroupOptions extends OperationOptions {}\n\n/**\n * Options for checking if a user exists.\n */\nexport interface HubHasUserOptions extends OperationOptions {}\n\n/**\n * Options for removing a user from all groups.\n */\nexport interface HubRemoveUserFromAllGroupsOptions extends HubCloseConnectionOptions {}\n\n/**\n * Options for sending a message to a specific connection.\n */\nexport interface HubSendToConnectionOptions extends OperationOptions {\n /**\n * The time-to-live (TTL) value in seconds for messages sent to the service.\n * 0 is the default value, which means the message never expires.\n * 300 is the maximum value.\n * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.\n * This parameter can help when the client's bandwidth is limited.\n */\n messageTtlSeconds?: number;\n}\n\n/**\n * Options for sending a text message to a connection.\n */\nexport interface HubSendTextToConnectionOptions extends HubSendToConnectionOptions {\n contentType: \"text/plain\";\n}\n\n/**\n * Options for sending a message to a user.\n */\nexport interface HubSendToUserOptions extends OperationOptions {\n /**\n * The filter syntax to filter out the connections to send the messages to following OData filter syntax.\n * Examples:\n * * Exclude connections in `group1`: `not('group1' in groups)`\n * * Send to connections in `group1` or `group2`: `'group1' in groups or `group2` in groups`\n * Details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax).\n */\n filter?: string;\n /**\n * The time-to-live (TTL) value in seconds for messages sent to the service.\n * 0 is the default value, which means the message never expires.\n * 300 is the maximum value.\n * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.\n * This parameter can help when the client's bandwidth is limited.\n */\n messageTtlSeconds?: number;\n}\n\n/**\n * Options for sending a text message to a user.\n */\nexport interface HubSendTextToUserOptions extends HubSendToUserOptions {\n /**\n * The content will be sent to the clients in plain text.\n */\n contentType: \"text/plain\";\n}\n\nexport type Permission = \"joinLeaveGroup\" | \"sendToGroup\";\n\n/**\n * Options for grant permissions to a connection\n */\nexport interface HubGrantPermissionOptions extends OperationOptions {\n /**\n * The meaning of the target depends on the specific permission.\n * For joinLeaveGroup and sendToGroup, targetName is a required parameter standing for the group name.\n */\n targetName?: string;\n}\n\n/**\n * Options for revoke permissions from a connection\n */\nexport interface HubRevokePermissionOptions extends OperationOptions {\n /**\n * The meaning of the target depends on the specific permission.\n * For joinLeaveGroup and sendToGroup, targetName is a required parameter standing for the group name.\n */\n targetName?: string;\n}\n\n/**\n * Options for checking if a connection has the specified permission\n */\nexport interface HubHasPermissionOptions extends OperationOptions {\n /**\n * The meaning of the target depends on the specific permission.\n * For joinLeaveGroup and sendToGroup, targetName is a required parameter standing for the group name.\n */\n targetName?: string;\n}\n\n/**\n * The type of client endpoint that is being requested.\n */\nexport type WebPubSubClientProtocol = \"default\" | \"mqtt\";\n\n/**\n * Options for generating a token to connect a client to the Azure Web Pubsub service.\n */\nexport interface GenerateClientTokenOptions extends OperationOptions {\n /**\n * The userId for the client.\n */\n userId?: string;\n\n /**\n * The roles that the connection with the generated token will have.\n * Roles give the client initial permissions to leave, join, or publish to groups when using PubSub subprotocol\n * * `webpubsub.joinLeaveGroup`: the client can join or leave any group\n * * `webpubsub.sendToGroup`: the client can send messages to any group\n * * `webpubsub.joinLeaveGroup.<group>`: the client can join or leave group `<group>`\n * * `webpubsub.sendToGroup.<group>`: the client can send messages to group `<group>`\n *\n * {@link https://azure.github.io/azure-webpubsub/references/pubsub-websocket-subprotocol#permissions}\n */\n roles?: string[];\n\n /**\n * Minutes until the token expires.\n */\n expirationTimeInMinutes?: number;\n\n /**\n * The groups to join when the client connects\n */\n groups?: string[];\n\n /**\n * The protocol type of the client\n * * `default`: Default WebPubSub Client. Example Client Connection URL: _wss://exampleHost.com/client/hubs/exampleHub_\n * * `mqtt`: MQTT Client. Example Client Connection URL: _wss://exampleHost.com/client/mqtt/hubs/exampleHub_\n */\n clientProtocol?: WebPubSubClientProtocol;\n}\n\n/**\n * A response containing the client token.\n */\nexport interface ClientTokenResponse {\n /**\n * The client token.\n */\n token: string;\n /**\n * The URL client connects to\n */\n baseUrl: string;\n /**\n * The URL client connects to with access_token query string\n */\n url: string;\n}\n\n/**\n * Client for connecting to a Web PubSub hub\n */\nexport class WebPubSubServiceClient {\n private readonly client: GeneratedClient;\n private credential!: AzureKeyCredential | TokenCredential;\n private readonly clientOptions?: WebPubSubServiceClientOptions;\n\n /**\n * The name of the hub this client is connected to\n */\n public readonly hubName: string;\n /**\n * The Web PubSub API version being used by this client\n */\n public readonly apiVersion: string = \"2024-01-01\";\n\n /**\n * The Web PubSub endpoint this client is connected to\n */\n public endpoint!: string;\n\n /**\n * Creates an instance of a WebPubSubServiceClient for sending messages and managing groups, connections, and users.\n *\n * Example usage:\n * ```ts\n * import { WebPubSubServiceClient } from \"@azure/web-pubsub\";\n * const connectionString = process.env['WEB_PUBSUB_CONNECTION_STRING'];\n * const client = new WebPubSubServiceClient(connectionString, 'chat');\n * ```\n *\n * @param connectionString - The connection string\n * @param hubName - The name of the hub to connect to. If omitted, '_default' is used.\n * @param options - Options to configure the http pipeline\n */\n constructor(connectionString: string, hubName: string, options?: WebPubSubServiceClientOptions);\n\n /**\n * Creates an instance of a WebPubSubServiceClient for sending messages and managing groups, connections, and users.\n *\n * Example usage:\n * ```ts\n * import { WebPubSubServiceClient, AzureKeyCredential } from \"@azure/web-pubsub\";\n * const cred = new AzureKeyCredential(\"<your web pubsub api key>\");\n * const endpoint = \"https://xxxx.webpubsubdev.azure.com\"\n * const client = new WebPubSubServiceClient(endpoint, cred, 'chat');\n * ```\n *\n * @param endpoint - The endpoint to connect to\n * @param credential - An AzureKeyCredential holding your service key\n * @param hubName - The name of the hub to connect to.\n * @param options - Options to configure the http pipeline\n */\n constructor(\n endpoint: string,\n credential: AzureKeyCredential | TokenCredential,\n hubName: string,\n options?: WebPubSubServiceClientOptions,\n );\n constructor(\n endpointOrConnectionString: string,\n credsOrHubName?: AzureKeyCredential | TokenCredential | string,\n hubNameOrOpts?: string | WebPubSubServiceClientOptions,\n opts?: WebPubSubServiceClientOptions,\n ) {\n // unpack constructor arguments\n if (typeof credsOrHubName === \"object\") {\n this.endpoint = endpointOrConnectionString;\n this.hubName = hubNameOrOpts as string;\n this.clientOptions = opts;\n this.credential = credsOrHubName;\n } else {\n const parsedCs = parseConnectionString(endpointOrConnectionString);\n this.endpoint = parsedCs.endpoint;\n this.credential = parsedCs.credential;\n this.hubName = credsOrHubName as string;\n this.clientOptions = hubNameOrOpts as WebPubSubServiceClientOptions;\n }\n\n const internalPipelineOptions: GeneratedClientOptionalParams = {\n ...this.clientOptions,\n ...{\n apiVersion: this.apiVersion,\n loggingOptions: {\n additionalAllowedHeaderNames:\n this.clientOptions?.loggingOptions?.additionalAllowedHeaderNames,\n additionalAllowedQueryParameters:\n this.clientOptions?.loggingOptions?.additionalAllowedQueryParameters,\n logger: logger.info,\n },\n },\n ...(isTokenCredential(this.credential)\n ? {\n credential: this.credential,\n credentialScopes: [\"https://webpubsub.azure.com/.default\"],\n }\n : {}),\n };\n\n this.client = new GeneratedClient(this.endpoint, internalPipelineOptions);\n\n if (!isTokenCredential(this.credential)) {\n this.client.pipeline.addPolicy(webPubSubKeyCredentialPolicy(this.credential));\n }\n\n if (this.clientOptions?.reverseProxyEndpoint) {\n this.client.pipeline.addPolicy(\n webPubSubReverseProxyPolicy(this.clientOptions?.reverseProxyEndpoint),\n );\n }\n }\n\n /**\n * Get a client for a group\n * @param groupName - The name of the group to connect to.\n */\n public group(groupName: string): WebPubSubGroup {\n return new WebPubSubGroupImpl(this.client, this.hubName, groupName);\n }\n\n /**\n * Broadcast a text message to all connections on this hub.\n *\n * @param message - The text message to send\n * @param options - Additional options\n */\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n public async sendToAll(message: string, options: HubSendTextToAllOptions): Promise<void>;\n /**\n * Broadcast a JSON message to all connections on this hub.\n *\n * @param message - The JSON message to send\n * @param options - Additional options\n */\n public async sendToAll(message: JSONTypes, options?: HubSendToAllOptions): Promise<void>;\n /**\n * Broadcast a binary message to all connections on this hub.\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n public async sendToAll(message: RequestBodyType, options?: HubSendToAllOptions): Promise<void>;\n\n public async sendToAll(\n message: RequestBodyType | JSONTypes,\n options: HubSendToAllOptions | HubSendTextToAllOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubServiceClient.sendToAll\", options, (updatedOptions) => {\n const { contentType, payload } = getPayloadForMessage(message, updatedOptions);\n return this.client.webPubSub.sendToAll(\n this.hubName,\n contentType,\n payload as any,\n updatedOptions,\n );\n });\n }\n\n /**\n * Send a text message to a specific user\n *\n * @param username - User name to send to\n * @param message - The text message to send\n * @param options - Additional options\n */\n public async sendToUser(\n username: string,\n message: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: HubSendTextToUserOptions,\n ): Promise<void>;\n\n /**\n * Send a JSON message to a specific user\n *\n * @param username - User name to send to\n * @param message - The josn message to send\n * @param options - Additional options\n */\n public async sendToUser(\n username: string,\n message: JSONTypes,\n options?: HubSendToUserOptions,\n ): Promise<void>;\n\n /**\n * Send a binary message to a specific user\n *\n * @param username - The user name to send to\n * @param message - The binary message to send\n * @param options - Additional options\n */\n public async sendToUser(\n username: string,\n message: RequestBodyType,\n options?: HubSendToUserOptions | HubSendTextToUserOptions,\n ): Promise<void>;\n public async sendToUser(\n username: string,\n message: RequestBodyType | JSONTypes,\n options: HubSendToUserOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.sendToUser\",\n options,\n (updatedOptions) => {\n const { contentType, payload } = getPayloadForMessage(message, updatedOptions);\n return this.client.webPubSub.sendToUser(\n this.hubName,\n username,\n contentType,\n payload as any,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Send a text message to a specific connection\n *\n * @param connectionId - Connection id to send to\n * @param message - The text message\n * @param options - Additional options\n */\n public async sendToConnection(\n connectionId: string,\n message: string,\n // eslint-disable-next-line @azure/azure-sdk/ts-naming-options\n options: HubSendTextToConnectionOptions,\n ): Promise<void>;\n\n /**\n * Send a binary message to a specific connection\n *\n * @param connectionId - Connection id to send to\n * @param message - The JSON message\n * @param options - Additional options\n */\n public async sendToConnection(\n connectionId: string,\n message: JSONTypes,\n options?: HubSendToConnectionOptions,\n ): Promise<void>;\n\n /**\n * Send a binary message to a specific connection\n *\n * @param connectionId - Connection id to send to\n * @param message - The binary message\n * @param options - Additional options\n */\n public async sendToConnection(\n connectionId: string,\n message: RequestBodyType,\n options?: HubSendToConnectionOptions | HubSendTextToConnectionOptions,\n ): Promise<void>;\n public async sendToConnection(\n connectionId: string,\n message: RequestBodyType | JSONTypes,\n options: HubSendToConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.sendToConnection\",\n options,\n (updatedOptions) => {\n const { contentType, payload } = getPayloadForMessage(message, updatedOptions);\n\n return this.client.webPubSub.sendToConnection(\n this.hubName,\n connectionId,\n contentType,\n payload as any,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Check if a specific connection is connected to this hub\n *\n * @param connectionId - Connection id to check\n * @param options - Additional options\n */\n public async connectionExists(\n connectionId: string,\n options: HasConnectionOptions = {},\n ): Promise<boolean> {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.connectionExists\",\n options,\n async (updatedOptions) => {\n await this.client.webPubSub.connectionExists(this.hubName, connectionId, {\n ...updatedOptions,\n onResponse,\n });\n\n if (response!.status === 200) {\n return true;\n } else if (response!.status === 404) {\n return false;\n } else {\n // this is sad - wish this was handled by autorest.\n throw new RestError(response!.bodyAsText!, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n },\n );\n }\n\n /**\n * Close a specific connection to this hub\n *\n * @param connectionId - Connection id to close\n * @param options - Additional options\n */\n public async closeConnection(\n connectionId: string,\n options: HubCloseConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.closeConnection\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.closeConnection(this.hubName, connectionId, updatedOptions);\n },\n );\n }\n\n /**\n * Close all connections to this hub\n *\n * @param options - Additional options\n */\n public async closeAllConnections(options: HubCloseAllConnectionsOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.closeAllConnections\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.closeAllConnections(this.hubName, updatedOptions);\n },\n );\n }\n\n /**\n * Close all connections with the given user id\n *\n * @param user - User id to close\n * @param options - Additional options\n */\n public async closeUserConnections(\n userId: string,\n options: HubCloseUserConnectionsOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.closeUserConnections\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.closeUserConnections(this.hubName, userId, updatedOptions);\n },\n );\n }\n\n /**\n * Remove a specific user from all groups they are joined to\n * @param userId - The user id to remove from all groups\n * @param options - Additional options\n */\n public async removeUserFromAllGroups(\n userId: string,\n options: HubCloseConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.removeUserFromAllGroups\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.removeUserFromAllGroups(this.hubName, userId, updatedOptions);\n },\n );\n }\n\n /**\n * Remove a specific connection from all groups they are joined to\n * @param connectionId - The connection id to remove from all groups\n * @param options - Additional options\n */\n public async removeConnectionFromAllGroups(\n connectionId: string,\n options: HubCloseConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.removeConnectionFromAllGroups\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.removeConnectionFromAllGroups(\n this.hubName,\n connectionId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Add filtered connections to multiple groups\n * @param groups - A list of groups which target connections will be added into\n * @param filter - An OData filter which target connections satisfy\n * @param options - Additional options\n */\n public async addConnectionsToGroups(\n groups: string[],\n filter: string,\n options: GroupAddConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.addConnectionsToGroups\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.addConnectionsToGroups(\n this.hubName,\n {\n groups: groups,\n filter: filter,\n } as AddToGroupsRequest,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Remove filtered connections from multiple groups\n * @param groups - A list of groups which target connections will be removed from\n * @param filter - An OData filter which target connections satisfy\n * @param options - Additional options\n */\n public async removeConnectionsFromGroups(\n groups: string[],\n filter: string,\n options: GroupRemoveConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.removeConnectionsFromGroups\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.removeConnectionsFromGroups(\n this.hubName,\n {\n groups: groups,\n filter: filter,\n } as RemoveFromGroupsRequest,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Check if a particular group exists (i.e. has active connections).\n *\n * @param groupName - The group name to check for\n * @param options - Additional options\n */\n public async groupExists(groupName: string, options: HubHasGroupOptions = {}): Promise<boolean> {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.groupExists\",\n options,\n async (updatedOptions) => {\n await this.client.webPubSub.groupExists(this.hubName, groupName, {\n ...updatedOptions,\n onResponse,\n });\n\n if (response!.status === 200) {\n return true;\n } else if (response!.status === 404) {\n return false;\n } else {\n throw new RestError(response!.bodyAsText!, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n },\n );\n }\n\n /**\n * Check if a particular user is connected to this hub.\n *\n * @param username - The user name to check for\n * @param options - Additional options\n */\n public async userExists(username: string, options: HubHasUserOptions = {}): Promise<boolean> {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.userExists\",\n options,\n async (updatedOptions) => {\n await this.client.webPubSub.userExists(this.hubName, username, {\n ...updatedOptions,\n onResponse,\n });\n\n if (response!.status === 200) {\n return true;\n } else if (response!.status === 404) {\n return false;\n } else {\n // this is sad - wish this was handled by autorest.\n throw new RestError(response!.bodyAsText!, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n },\n );\n }\n\n /**\n * Grant permissions to a connection\n *\n * @param connectionId - The connection id to grant permissions to\n * @param Permission - The permission to grant\n * @param options - Additional options\n */\n public async grantPermission(\n connectionId: string,\n permission: Permission,\n options: HubGrantPermissionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.grantPermission\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.grantPermission(\n this.hubName,\n permission,\n connectionId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Revoke permissions from a connection\n *\n * @param connectionId - The connection id to revoke permissions from\n * @param Permission - The permission to revoke\n * @param options - Additional options\n */\n public async revokePermission(\n connectionId: string,\n permission: Permission,\n options: HubRevokePermissionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.revokePermission\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.revokePermission(\n this.hubName,\n permission,\n connectionId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Check if the connection has the specified permission\n *\n * @param connectionId - The connection id to check permission\n * @param Permission - The permission to check\n * @param options - Additional options\n */\n public async hasPermission(\n connectionId: string,\n permission: Permission,\n options: HubHasPermissionOptions = {},\n ): Promise<boolean> {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.hasPermission\",\n options,\n async (updatedOptions) => {\n await this.client.webPubSub.checkPermission(this.hubName, permission, connectionId, {\n ...updatedOptions,\n onResponse,\n });\n\n if (response!.status === 200) {\n return true;\n } else if (response!.status === 404) {\n return false;\n } else {\n // this is sad - wish this was handled by autorest.\n throw new RestError(response!.bodyAsText!, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n },\n );\n }\n\n /**\n * Generate a token for a client to connect to the Azure Web PubSub service.\n *\n * @param options - Additional options\n */\n public async getClientAccessToken(\n options: GenerateClientTokenOptions = {},\n ): Promise<ClientTokenResponse> {\n return tracingClient.withSpan(\n \"WebPubSubServiceClient.getClientAccessToken\",\n options,\n async (updatedOptions) => {\n const endpoint = this.endpoint.endsWith(\"/\") ? this.endpoint : this.endpoint + \"/\";\n const clientEndpoint = endpoint.replace(/(http)(s?:\\/\\/)/gi, \"ws$2\");\n const clientProtocol = updatedOptions.clientProtocol;\n const clientPath =\n clientProtocol && clientProtocol === \"mqtt\"\n ? `clients/mqtt/hubs/${this.hubName}`\n : `client/hubs/${this.hubName}`;\n const baseUrl = clientEndpoint + clientPath;\n\n let token: string;\n if (isTokenCredential(this.credential)) {\n const response = await this.client.webPubSub.generateClientToken(\n this.hubName,\n updatedOptions,\n );\n token = response.token!;\n } else {\n const key = this.credential.key;\n const audience = endpoint + clientPath;\n const payload = {\n role: updatedOptions?.roles,\n \"webpubsub.group\": updatedOptions?.groups,\n };\n const signOptions: jwt.SignOptions = {\n audience: audience,\n expiresIn:\n updatedOptions?.expirationTimeInMinutes === undefined\n ? \"1h\"\n : `${updatedOptions.expirationTimeInMinutes}m`,\n algorithm: \"HS256\",\n };\n if (updatedOptions?.userId) {\n signOptions.subject = updatedOptions?.userId;\n }\n token = jwt.sign(payload, key, signOptions);\n }\n\n return {\n token,\n baseUrl,\n url: `${baseUrl}?access_token=${token}`,\n };\n },\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"reverseProxyPolicy.js","sourceRoot":"","sources":["../../src/reverseProxyPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,MAAM,CAAC,MAAM,+BAA+B,GAAG,6BAA6B,CAAC;AAE7E;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,QAAgB;IAC1D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxC,OAAO;QACL,IAAI,EAAE,+BAA+B;QACrC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YACrD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACvC,SAAS,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;YACpC,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n PipelineResponse,\n PipelineRequest,\n SendRequest,\n PipelinePolicy,\n} from \"@azure/core-rest-pipeline\";\n\nexport const webPubSubReverseProxyPolicyName = \"webPubSubReverseProxyPolicy\";\n\n/**\n * Create an HTTP pipeline policy to use a reverse proxy.\n * This is generally going to be an Azure APIM endpoint.\n * @internal\n */\nexport function webPubSubReverseProxyPolicy(endpoint: string): PipelinePolicy {\n const rpEndpointUrl = new URL(endpoint);\n return {\n name: webPubSubReverseProxyPolicyName,\n sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n const parsedUrl = new URL(request.url);\n parsedUrl.host = rpEndpointUrl.host;\n request.url = parsedUrl.toString();\n return next(request);\n },\n };\n}\n"]}
1
+ {"version":3,"file":"reverseProxyPolicy.js","sourceRoot":"","sources":["../../src/reverseProxyPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,MAAM,CAAC,MAAM,+BAA+B,GAAG,6BAA6B,CAAC;AAE7E;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,QAAgB;IAC1D,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IACxC,OAAO;QACL,IAAI,EAAE,+BAA+B;QACrC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YACrD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACvC,SAAS,CAAC,IAAI,GAAG,aAAa,CAAC,IAAI,CAAC;YACpC,OAAO,CAAC,GAAG,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PipelineResponse,\n PipelineRequest,\n SendRequest,\n PipelinePolicy,\n} from \"@azure/core-rest-pipeline\";\n\nexport const webPubSubReverseProxyPolicyName = \"webPubSubReverseProxyPolicy\";\n\n/**\n * Create an HTTP pipeline policy to use a reverse proxy.\n * This is generally going to be an Azure APIM endpoint.\n * @internal\n */\nexport function webPubSubReverseProxyPolicy(endpoint: string): PipelinePolicy {\n const rpEndpointUrl = new URL(endpoint);\n return {\n name: webPubSubReverseProxyPolicyName,\n sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n const parsedUrl = new URL(request.url);\n parsedUrl.host = rpEndpointUrl.host;\n request.url = parsedUrl.toString();\n return next(request);\n },\n };\n}\n"]}
@@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line\";\n\nfunction isRequestBody(obj: unknown): obj is RequestBodyType {\n return (\n typeof obj === \"function\" ||\n (typeof obj === \"object\" &&\n obj != null &&\n (obj.constructor.name === \"ArrayBuffer\" ||\n obj.constructor.name === \"Blob\" ||\n ArrayBuffer.isView(obj)))\n );\n}\n\nexport interface TextPlainPayload {\n contentType: \"text/plain\";\n payload: string;\n}\n\nexport interface JsonPayload {\n contentType: \"application/json\";\n payload: string;\n}\n\nexport interface BinaryPayload {\n contentType: \"application/octet-stream\";\n payload: RequestBodyType;\n}\n\nexport type Payload = TextPlainPayload | JsonPayload | BinaryPayload;\n\nexport function getPayloadForMessage(message: unknown, options: Record<string, any>): Payload {\n if (options?.contentType === \"text/plain\") {\n if (typeof message !== \"string\") {\n throw new TypeError(\"Message must be a string.\");\n }\n return { contentType: \"text/plain\", payload: message };\n } else if (isRequestBody(message)) {\n return { contentType: \"application/octet-stream\", payload: message };\n } else {\n return { contentType: \"application/json\", payload: JSON.stringify(message) };\n }\n}\n\nfunction formatNullAndUndefined(input: unknown): string | unknown {\n if (input === null || input === undefined) {\n return \"null\";\n }\n\n return input;\n}\n\nfunction escapeQuotesIfString(input: unknown, previous: string): string | unknown {\n let result = input;\n\n if (typeof input === \"string\") {\n result = input.replace(/'/g, \"''\");\n // check if we need to escape this literal\n if (!previous.trim().endsWith(\"'\")) {\n result = `'${result}'`;\n }\n }\n\n return result;\n}\n\n/**\n * Escapes an odata filter expression to avoid errors with quoting string literals.\n * Example usage:\n * ```ts\n * const userId = \"vic's\";\n * const anonymous = null;\n * const length = 3\n * const filter = odata`userId eq ${anonymous} or userId eq ${userId} or length(userId) > ${length}`;\n * ```\n * @param strings - Array of strings for the expression\n * @param values - Array of values for the expression\n */\nexport function odata(strings: TemplateStringsArray, ...values: unknown[]): string {\n const results = [];\n for (let i = 0; i < strings.length; i++) {\n results.push(strings[i]);\n if (i < values.length) {\n if (values[i] === null || values[i] === undefined) {\n results.push(formatNullAndUndefined(values[i]));\n } else {\n results.push(escapeQuotesIfString(values[i], strings[i]));\n }\n }\n }\n return results.join(\"\");\n}\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,SAAS,aAAa,CAAC,GAAY;IACjC,OAAO,CACL,OAAO,GAAG,KAAK,UAAU;QACzB,CAAC,OAAO,GAAG,KAAK,QAAQ;YACtB,GAAG,IAAI,IAAI;YACX,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,aAAa;gBACrC,GAAG,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM;gBAC/B,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAC9B,CAAC;AACJ,CAAC;AAmBD,MAAM,UAAU,oBAAoB,CAAC,OAAgB,EAAE,OAA4B;IACjF,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,MAAK,YAAY,EAAE,CAAC;QAC1C,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;YAChC,MAAM,IAAI,SAAS,CAAC,2BAA2B,CAAC,CAAC;QACnD,CAAC;QACD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IACzD,CAAC;SAAM,IAAI,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;QAClC,OAAO,EAAE,WAAW,EAAE,0BAA0B,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;IACvE,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;IAC/E,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAC,KAAc;IAC5C,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAC1C,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,KAAK,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ensed under the MIT License.\n\nimport type { RequestBodyType } from \"@azure/core-rest-pipeline\";\n\nfunction isRequestBody(obj: unknown): obj is RequestBodyType {\n return (\n typeof obj === \"function\" ||\n (typeof obj === \"object\" &&\n obj != null &&\n (obj.constructor.name === \"ArrayBuffer\" ||\n obj.constructor.name === \"Blob\" ||\n ArrayBuffer.isView(obj)))\n );\n}\n\nexport interface TextPlainPayload {\n contentType: \"text/plain\";\n payload: string;\n}\n\nexport interface JsonPayload {\n contentType: \"application/json\";\n payload: string;\n}\n\nexport interface BinaryPayload {\n contentType: \"application/octet-stream\";\n payload: RequestBodyType;\n}\n\nexport type Payload = TextPlainPayload | JsonPayload | BinaryPayload;\n\nexport function getPayloadForMessage(message: unknown, options: Record<string, any>): Payload {\n if (options?.contentType === \"text/plain\") {\n if (typeof message !== \"string\") {\n throw new TypeError(\"Message must be a string.\");\n }\n return { contentType: \"text/plain\", payload: message };\n } else if (isRequestBody(message)) {\n return { contentType: \"application/octet-stream\", payload: message };\n } else {\n return { contentType: \"application/json\", payload: JSON.stringify(message) };\n }\n}\n\nfunction formatNullAndUndefined(input: unknown): string | unknown {\n if (input === null || input === undefined) {\n return \"null\";\n }\n\n return input;\n}\n\nfunction escapeQuotesIfString(input: unknown, previous: string): string | unknown {\n let result = input;\n\n if (typeof input === \"string\") {\n result = input.replace(/'/g, \"''\");\n // check if we need to escape this literal\n if (!previous.trim().endsWith(\"'\")) {\n result = `'${result}'`;\n }\n }\n\n return result;\n}\n\n/**\n * Escapes an odata filter expression to avoid errors with quoting string literals.\n * Example usage:\n * ```ts\n * const userId = \"vic's\";\n * const anonymous = null;\n * const length = 3\n * const filter = odata`userId eq ${anonymous} or userId eq ${userId} or length(userId) > ${length}`;\n * ```\n * @param strings - Array of strings for the expression\n * @param values - Array of values for the expression\n */\nexport function odata(strings: TemplateStringsArray, ...values: unknown[]): string {\n const results = [];\n for (let i = 0; i < strings.length; i++) {\n results.push(strings[i]);\n if (i < values.length) {\n if (values[i] === null || values[i] === undefined) {\n results.push(formatNullAndUndefined(values[i]));\n } else {\n results.push(escapeQuotesIfString(values[i], strings[i]));\n }\n }\n }\n return results.join(\"\");\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"webPubSubCredentialPolicy.js","sourceRoot":"","sources":["../../src/webPubSubCredentialPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,OAAO,GAAG,MAAM,cAAc,CAAC;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,8BAA8B,CAAC;AAE/E;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,UAAyB;IACpE,OAAO;QACL,IAAI,EAAE,gCAAgC;QACtC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YACrD,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,GAAG,EAAE;gBAC/C,QAAQ,EAAE,OAAO,CAAC,GAAG;gBACrB,SAAS,EAAE,IAAI;gBACf,SAAS,EAAE,OAAO;aACnB,CAAC,CAAC;YACH,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,WAAW,EAAE,CAAC,CAAC;YAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { KeyCredential } from \"@azure/core-auth\";\nimport {\n PipelineResponse,\n PipelineRequest,\n SendRequest,\n PipelinePolicy,\n} from \"@azure/core-rest-pipeline\";\n\nimport jwt from \"jsonwebtoken\";\n\n/**\n * The programmatic identifier of the webPubSubKeyCredentialPolicy.\n */\nexport const webPubSubKeyCredentialPolicyName = \"webPubSubKeyCredentialPolicy\";\n\n/**\n * Create an HTTP pipeline policy to authenticate a request\n * using an `AzureKeyCredential` for Text Analytics\n * @internal\n */\nexport function webPubSubKeyCredentialPolicy(credential: KeyCredential): PipelinePolicy {\n return {\n name: webPubSubKeyCredentialPolicyName,\n sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n const bearerToken = jwt.sign({}, credential.key, {\n audience: request.url,\n expiresIn: \"1h\",\n algorithm: \"HS256\",\n });\n request.headers.set(\"Authorization\", `Bearer ${bearerToken}`);\n return next(request);\n },\n };\n}\n"]}
1
+ {"version":3,"file":"webPubSubCredentialPolicy.js","sourceRoot":"","sources":["../../src/webPubSubCredentialPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC,OAAO,GAAG,MAAM,cAAc,CAAC;AAE/B;;GAEG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,8BAA8B,CAAC;AAE/E;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAAC,UAAyB;IACpE,OAAO;QACL,IAAI,EAAE,gCAAgC;QACtC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YACrD,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,CAAC,GAAG,EAAE;gBAC/C,QAAQ,EAAE,OAAO,CAAC,GAAG;gBACrB,SAAS,EAAE,IAAI;gBACf,SAAS,EAAE,OAAO;aACnB,CAAC,CAAC;YACH,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,WAAW,EAAE,CAAC,CAAC;YAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { KeyCredential } from \"@azure/core-auth\";\nimport type {\n PipelineResponse,\n PipelineRequest,\n SendRequest,\n PipelinePolicy,\n} from \"@azure/core-rest-pipeline\";\n\nimport jwt from \"jsonwebtoken\";\n\n/**\n * The programmatic identifier of the webPubSubKeyCredentialPolicy.\n */\nexport const webPubSubKeyCredentialPolicyName = \"webPubSubKeyCredentialPolicy\";\n\n/**\n * Create an HTTP pipeline policy to authenticate a request\n * using an `AzureKeyCredential` for Text Analytics\n * @internal\n */\nexport function webPubSubKeyCredentialPolicy(credential: KeyCredential): PipelinePolicy {\n return {\n name: webPubSubKeyCredentialPolicyName,\n sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n const bearerToken = jwt.sign({}, credential.key, {\n audience: request.url,\n expiresIn: \"1h\",\n algorithm: \"HS256\",\n });\n request.headers.set(\"Authorization\", `Bearer ${bearerToken}`);\n return next(request);\n },\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"groups.spec.js","sourceRoot":"","sources":["../../test/groups.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,QAAQ,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,sBAAsB,EAAkB,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,eAAe,MAAM,WAAW,CAAC;AAGxC,uDAAuD;AAEvD,QAAQ,CAAC,mCAAmC,EAAE;IAC5C,IAAI,QAAkB,CAAC;IACvB,IAAI,MAAsB,CAAC;IAC3B,IAAI,YAA+C,CAAC;IACpD,SAAS,UAAU,CAAC,QAA+B;QACjD,YAAY,GAAG,QAAQ,CAAC;IAC1B,CAAC;IACD,UAAU,CAAC,KAAK;QACd,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1C,MAAM,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QACtC,MAAM,SAAS,GAAG,IAAI,sBAAsB,CAC1C,yBAAyB,CAAC,uBAAuB,CAAC,EAClD,YAAY,EACZ,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC,CACpC,CAAC;QAEF,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC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licensed under the MIT License.\n/* eslint-disable no-invalid-this */\nimport { Recorder, assertEnvironmentVariable } from \"@azure-tools/test-recorder\";\nimport { WebPubSubServiceClient, WebPubSubGroup } from \"../src\";\nimport { assert } from \"chai\";\nimport recorderOptions from \"./testEnv\";\nimport { FullOperationResponse } from \"@azure/core-client\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\n/* eslint-disable @typescript-eslint/no-invalid-this */\n\ndescribe(\"Group client working with a group\", function () {\n let recorder: Recorder;\n let client: WebPubSubGroup;\n let lastResponse: FullOperationResponse | undefined;\n function onResponse(response: FullOperationResponse): void {\n lastResponse = response;\n }\n beforeEach(async function () {\n recorder = new Recorder(this.currentTest);\n await recorder.start(recorderOptions);\n const hubClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n \"simplechat\",\n recorder.configureClientOptions({}),\n );\n\n client = hubClient.group(\"group\");\n });\n\n it(\"can broadcast to groups\", async () => {\n await client.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can broadcast to group with filter\", async () => {\n await client.sendToAll(\"hello\", {\n contentType: \"text/plain\",\n filter: \"userId ne 'user1'\",\n messageTtlSeconds: 60,\n onResponse,\n });\n assert.equal(lastResponse?.status, 202);\n\n let error;\n try {\n await client.sendToAll(\"hello\", {\n contentType: \"text/plain\",\n filter: \"invalid filter\",\n });\n } catch (e: any) {\n if (e.name !== \"RestError\") {\n throw e;\n }\n\n error = e;\n }\n assert.equal(error.statusCode, 400);\n assert.equal(\n JSON.parse(error.message).message,\n \"Invalid syntax for 'invalid filter': Syntax error at position 14 in 'invalid filter'. (Parameter 'filter')\",\n );\n });\n\n it(\"can manage connections\", async () => {\n // this endpoint returns 404 for connections not on the hub\n let error: RestError | undefined;\n try {\n await client.addConnection(\"xxxx\");\n } catch (e: any) {\n error = e;\n }\n\n assert.exists(error);\n assert.strictEqual(error?.name, \"RestError\");\n\n try {\n await client.removeConnection(\"xxxx\", { onResponse });\n } catch (e: any) {\n assert.exists(error);\n assert.strictEqual(error?.name, \"RestError\");\n }\n });\n\n // skipping until we can record better tests with an actual user active.\n it.skip(\"can manage users\", async () => {\n // service returns 404, this should likely be raised as an error but isn't\n // due to the swagger design\n await client.addUser(\"brian\");\n\n // service returns 404 and this throws.\n await client.removeUser(\"brian\");\n });\n\n afterEach(async function () {\n await recorder.stop();\n });\n});\n\ndescribe(\"client working with multiple groups\", function () {\n let recorder: Recorder;\n let lastResponse: FullOperationResponse | undefined;\n let hubClient: WebPubSubServiceClient;\n function onResponse(response: FullOperationResponse): void {\n lastResponse = response;\n }\n beforeEach(async function () {\n recorder = new Recorder(this.currentTest);\n await recorder.start(recorderOptions);\n hubClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n \"simplechat\",\n recorder.configureClientOptions({}),\n );\n });\n\n afterEach(async function () {\n await recorder.stop();\n });\n\n it(\"can join multiple groups with filter\", async (): Promise<void> => {\n await hubClient.addConnectionsToGroups([\"group1\", \"group2\"], \"userId eq 'user 1'\", {\n onResponse,\n });\n assert.equal(lastResponse?.status, 200);\n\n let error;\n try {\n await hubClient.addConnectionsToGroups([\"group1\", \"group2\"], \"invalid filter\");\n } catch (e: any) {\n if (e.name !== \"RestError\") {\n throw e;\n }\n\n error = e;\n }\n assert.equal(error.statusCode, 400);\n assert.equal(\n JSON.parse(error.message).message,\n \"Invalid syntax for 'invalid filter': Syntax error at position 14 in 'invalid filter'. (Parameter 'filter')\",\n );\n });\n\n it(\"can leave multiple groups with filter\", async () => {\n await hubClient.removeConnectionsFromGroups([\"group1\", \"group2\"], \"userId eq 'user 1'\", {\n onResponse,\n });\n assert.equal(lastResponse?.status, 200);\n\n let error;\n try {\n await hubClient.removeConnectionsFromGroups([\"group1\", \"group2\"], \"invalid filter\");\n } catch (e: any) {\n if (e.name !== \"RestError\") {\n throw e;\n }\n\n error = e;\n }\n assert.equal(error.statusCode, 400);\n assert.equal(\n JSON.parse(error.message).message,\n \"Invalid syntax for 'invalid filter': Syntax error at position 14 in 'invalid filter'. (Parameter 'filter')\",\n );\n });\n});\n"]}
1
+ {"version":3,"file":"groups.spec.js","sourceRoot":"","sources":["../../test/groups.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,QAAQ,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEjF,OAAO,EAAE,sBAAsB,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,eAAe,MAAM,WAAW,CAAC;AAGxC,uDAAuD;AAEvD,QAAQ,CAAC,mCAAmC,EAAE;IAC5C,IAAI,QAAkB,CAAC;IACvB,IAAI,MAAsB,CAAC;IAC3B,IAAI,YAA+C,CAAC;IACpD,SAAS,UAAU,CAAC,QAA+B;QACjD,YAAY,GAAG,QAAQ,CAAC;IAC1B,CAAC;IACD,UAAU,CAAC,KAAK;QACd,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1C,MAAM,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;QACtC,MAAM,SAAS,GAAG,IAAI,sBAAsB,CAC1C,yBAAyB,CAAC,uBAAuB,CAAC,EAClD,YAAY,EACZ,QAAQ,CAAC,sBAAsB,CAAC,EAAE,CAAC,CACpC,CAAC;QAEF,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,yBAAyB,EAAE,KAAK,IAAI,EAAE;QACvC,MAAM,MAAM,CAAC,SAAS,C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;gBAC3B,MAAM,CAAC,CAAC;YACV,CAAC;YAED,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QACpC,MAAM,CAAC,KAAK,CACV,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EACjC,4GAA4G,CAC7G,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,KAAK,IAAI,EAAE;QACrD,MAAM,SAAS,CAAC,2BAA2B,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,oBAAoB,EAAE;YACtF,UAAU;SACX,CAAC,CAAC;QACH,MAAM,CAAC,KAAK,CAAC,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAExC,IAAI,KAAK,CAAC;QACV,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,2BAA2B,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,CAAC;QACtF,CAAC;QAAC,OAAO,CAAM,EAAE,CAAC;YAChB,IAAI,CAAC,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;gBAC3B,MAAM,CAAC,CAAC;YACV,CAAC;YAED,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC;QACD,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QACpC,MAAM,CAAC,KAAK,CACV,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,OAAO,EACjC,4GAA4G,CAC7G,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n/* eslint-disable no-invalid-this */\nimport { Recorder, assertEnvironmentVariable } from \"@azure-tools/test-recorder\";\nimport type { WebPubSubGroup } from \"../src\";\nimport { WebPubSubServiceClient } from \"../src\";\nimport { assert } from \"chai\";\nimport recorderOptions from \"./testEnv\";\nimport type { FullOperationResponse } from \"@azure/core-client\";\nimport type { RestError } from \"@azure/core-rest-pipeline\";\n/* eslint-disable @typescript-eslint/no-invalid-this */\n\ndescribe(\"Group client working with a group\", function () {\n let recorder: Recorder;\n let client: WebPubSubGroup;\n let lastResponse: FullOperationResponse | undefined;\n function onResponse(response: FullOperationResponse): void {\n lastResponse = response;\n }\n beforeEach(async function () {\n recorder = new Recorder(this.currentTest);\n await recorder.start(recorderOptions);\n const hubClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n \"simplechat\",\n recorder.configureClientOptions({}),\n );\n\n client = hubClient.group(\"group\");\n });\n\n it(\"can broadcast to groups\", async () => {\n await client.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can broadcast to group with filter\", async () => {\n await client.sendToAll(\"hello\", {\n contentType: \"text/plain\",\n filter: \"userId ne 'user1'\",\n messageTtlSeconds: 60,\n onResponse,\n });\n assert.equal(lastResponse?.status, 202);\n\n let error;\n try {\n await client.sendToAll(\"hello\", {\n contentType: \"text/plain\",\n filter: \"invalid filter\",\n });\n } catch (e: any) {\n if (e.name !== \"RestError\") {\n throw e;\n }\n\n error = e;\n }\n assert.equal(error.statusCode, 400);\n assert.equal(\n JSON.parse(error.message).message,\n \"Invalid syntax for 'invalid filter': Syntax error at position 14 in 'invalid filter'. (Parameter 'filter')\",\n );\n });\n\n it(\"can manage connections\", async () => {\n // this endpoint returns 404 for connections not on the hub\n let error: RestError | undefined;\n try {\n await client.addConnection(\"xxxx\");\n } catch (e: any) {\n error = e;\n }\n\n assert.exists(error);\n assert.strictEqual(error?.name, \"RestError\");\n\n try {\n await client.removeConnection(\"xxxx\", { onResponse });\n } catch (e: any) {\n assert.exists(error);\n assert.strictEqual(error?.name, \"RestError\");\n }\n });\n\n // skipping until we can record better tests with an actual user active.\n it.skip(\"can manage users\", async () => {\n // service returns 404, this should likely be raised as an error but isn't\n // due to the swagger design\n await client.addUser(\"brian\");\n\n // service returns 404 and this throws.\n await client.removeUser(\"brian\");\n });\n\n afterEach(async function () {\n await recorder.stop();\n });\n});\n\ndescribe(\"client working with multiple groups\", function () {\n let recorder: Recorder;\n let lastResponse: FullOperationResponse | undefined;\n let hubClient: WebPubSubServiceClient;\n function onResponse(response: FullOperationResponse): void {\n lastResponse = response;\n }\n beforeEach(async function () {\n recorder = new Recorder(this.currentTest);\n await recorder.start(recorderOptions);\n hubClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n \"simplechat\",\n recorder.configureClientOptions({}),\n );\n });\n\n afterEach(async function () {\n await recorder.stop();\n });\n\n it(\"can join multiple groups with filter\", async (): Promise<void> => {\n await hubClient.addConnectionsToGroups([\"group1\", \"group2\"], \"userId eq 'user 1'\", {\n onResponse,\n });\n assert.equal(lastResponse?.status, 200);\n\n let error;\n try {\n await hubClient.addConnectionsToGroups([\"group1\", \"group2\"], \"invalid filter\");\n } catch (e: any) {\n if (e.name !== \"RestError\") {\n throw e;\n }\n\n error = e;\n }\n assert.equal(error.statusCode, 400);\n assert.equal(\n JSON.parse(error.message).message,\n \"Invalid syntax for 'invalid filter': Syntax error at position 14 in 'invalid filter'. (Parameter 'filter')\",\n );\n });\n\n it(\"can leave multiple groups with filter\", async () => {\n await hubClient.removeConnectionsFromGroups([\"group1\", \"group2\"], \"userId eq 'user 1'\", {\n onResponse,\n });\n assert.equal(lastResponse?.status, 200);\n\n let error;\n try {\n await hubClient.removeConnectionsFromGroups([\"group1\", \"group2\"], \"invalid filter\");\n } catch (e: any) {\n if (e.name !== \"RestError\") {\n throw e;\n }\n\n error = e;\n }\n assert.equal(error.statusCode, 400);\n assert.equal(\n JSON.parse(error.message).message,\n \"Invalid syntax for 'invalid filter': Syntax error at position 14 in 'invalid filter'. (Parameter 'filter')\",\n );\n });\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"hubs.spec.js","sourceRoot":"","sources":["../../test/hubs.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,eAAe,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,uDAAuD;AAEvD,QAAQ,CAAC,WAAW,EAAE;IACpB,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACxC,MAAM,UAAU,GAAG,oBAAoB,EAAE,CAAC;QAC1C,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;YAC1D,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE;gBACvB,IAAI,sBAAsB,CAAC,yBAAyB,CAAC,uBAAuB,CAAC,EAAE,UAAU,EAAE;oBACzF,YAAY,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE;iBAChC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;YAChE,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE;gBACvB,IAAI,sBAAsB,CACxB,yBAAyB,CAAC,cAAc,CAAC,EACzC,IAAI,kBAAkB,CAAC,yBAAyB,CAAC,aAAa,CAAC,CAAC,EAChE,UAAU,EACV;oBACE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IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;YAChD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;YACtD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,sBAAsB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n/* eslint-disable no-invalid-this */\nimport { Recorder, isLiveMode, assertEnvironmentVariable } from \"@azure-tools/test-recorder\";\nimport { WebPubSubServiceClient, AzureKeyCredential } from \"../src\";\nimport { assert } from \"@azure-tools/test-utils\";\nimport recorderOptions from \"./testEnv\";\nimport { FullOperationResponse } from \"@azure/core-client\";\nimport { createTestCredential } from \"@azure-tools/test-credential\";\n/* eslint-disable @typescript-eslint/no-invalid-this */\n\ndescribe(\"HubClient\", function () {\n describe(\"Constructing a HubClient\", () => {\n const credential = createTestCredential();\n it(\"takes a connection string, hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"), \"test-hub\", {\n retryOptions: { maxRetries: 2 },\n });\n });\n });\n\n it(\"takes an endpoint, an API key, a hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_ENDPOINT\"),\n new AzureKeyCredential(assertEnvironmentVariable(\"WPS_API_KEY\")),\n \"test-hub\",\n {\n retryOptions: { maxRetries: 2 },\n },\n );\n });\n });\n\n it(\"takes an endpoint, DefaultAzureCredential, a hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_ENDPOINT\"),\n credential,\n \"test-hub\",\n {\n retryOptions: { maxRetries: 2 },\n },\n );\n });\n });\n });\n\n describe(\"Working with a hub\", function () {\n let recorder: Recorder;\n let client: WebPubSubServiceClient;\n let lastResponse: FullOperationResponse | undefined;\n const credential = createTestCredential();\n function onResponse(response: FullOperationResponse): void {\n lastResponse = response;\n }\n beforeEach(async function () {\n recorder = new Recorder(this.currentTest);\n await recorder.start(recorderOptions);\n\n client = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n \"simplechat\",\n recorder.configureClientOptions({}),\n );\n });\n\n afterEach(async function () {\n await recorder.stop();\n });\n\n it(\"can broadcast\", async () => {\n await client.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can broadcast with filter\", async () => {\n await client.sendToAll(\"hello\", {\n contentType: \"text/plain\",\n filter: \"userId ne 'user1'\",\n messageTtlSeconds: 60,\n onResponse,\n });\n assert.equal(lastResponse?.status, 202);\n\n let error;\n try {\n await client.sendToAll(\"hello\", {\n contentType: \"text/plain\",\n filter: \"invalid filter\",\n });\n } catch (e: any) {\n if (e.name !== \"RestError\") {\n throw e;\n }\n\n error = e;\n }\n assert.equal(error.statusCode, 400);\n assert.equal(\n JSON.parse(error.message).message,\n \"Invalid syntax for 'invalid filter': Syntax error at position 14 in 'invalid filter'. (Parameter 'filter')\",\n );\n });\n\n it(\"can broadcast using the DAC\", async () => {\n const dacClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_ENDPOINT\"),\n credential,\n \"simplechat\",\n recorder.configureClientOptions({}),\n );\n\n await dacClient.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await dacClient.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await dacClient.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can broadcast using APIM\", async () => {\n const apimClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n \"simplechat\",\n recorder.configureClientOptions({\n reverseProxyEndpoint: assertEnvironmentVariable(\"WPS_REVERSE_PROXY_ENDPOINT\"),\n }),\n );\n\n await apimClient.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await apimClient.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await apimClient.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can send messages to a user\", async () => {\n await client.sendToUser(\"brian\", \"hello\", {\n contentType: \"text/plain\",\n onResponse,\n });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToUser(\"brian\", { x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToUser(\"brian\", binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can send to a user with filter\", async () => {\n await client.sendToUser(\"vic\", \"hello\", {\n contentType: \"text/plain\",\n filter: \"userId ne 'user1'\",\n onResponse,\n });\n assert.equal(lastResponse?.status, 202);\n\n let error;\n try {\n await client.sendToUser(\"brian\", \"hello\", {\n contentType: \"text/plain\",\n filter: \"invalid filter\",\n });\n } catch (e: any) {\n if (e.name !== \"RestError\") {\n throw e;\n }\n\n error = e;\n }\n assert.equal(error.statusCode, 400);\n assert.equal(\n JSON.parse(error.message).message,\n \"Invalid syntax for 'invalid filter': Syntax error at position 14 in 'invalid filter'. (Parameter 'filter')\",\n );\n });\n\n it(\"can send messages to a connection\", async () => {\n await client.sendToConnection(\"xxxx\", \"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToConnection(\"xxxx\", { x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n const binaryMessage = new Uint8Array(10);\n\n await client.sendToConnection(\"xxxx\", binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can manage users\", async () => {\n const res = await client.userExists(\"foo\");\n assert.ok(!res);\n await client.removeUserFromAllGroups(\"brian\", { onResponse });\n assert.equal(lastResponse?.status, 204);\n });\n\n it(\"can manage connections\", async () => {\n await client.removeConnectionFromAllGroups(\"xxx\", { onResponse });\n assert.equal(lastResponse?.status, 204);\n });\n\n it(\"can check if a connection exists\", async function () {\n // likely bug in recorder for this test - recording not generating properly\n if (!isLiveMode()) this.skip();\n const res = await client.connectionExists(\"xxx\");\n assert.ok(!res);\n });\n\n it(\"can grant permissions to connections\", async () => {\n let error;\n try {\n await client.grantPermission(\"xxx\", \"joinLeaveGroup\", { targetName: \"x\" });\n } catch (e: any) {\n if (e.name !== \"RestError\") {\n throw e;\n }\n\n error = e;\n }\n // grantPermission validates connection ids, so we expect an error here.\n assert.equal(error.statusCode, 404);\n });\n\n it(\"can revoke permissions from connections\", async function () {\n // likely bug in recorder for this test - recording not generating properly\n if (!isLiveMode()) this.skip();\n await client.revokePermission(\"invalid-id\", \"joinLeaveGroup\", { targetName: \"x\" });\n // Service doesn't throw error for invalid connection-ids\n });\n\n it(\"can trace through the various options\", async function () {\n await assert.supportsTracing(\n async (options) => {\n const promises: Promise<any>[] = [\n client.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse, ...options }),\n client.sendToUser(\"brian\", \"hello\", {\n contentType: \"text/plain\",\n onResponse,\n ...options,\n }),\n client.sendToConnection(\"xxxx\", \"hello\", {\n contentType: \"text/plain\",\n onResponse,\n ...options,\n }),\n client.connectionExists(\"xxxx\", options),\n client.closeConnection(\"xxxx\", options),\n client.closeAllConnections(options),\n client.closeUserConnections(\"xxxx\", options),\n client.removeUserFromAllGroups(\"foo\", options),\n client.groupExists(\"foo\", options),\n client.userExists(\"foo\", options),\n client.grantPermission(\"xxxx\", \"joinLeaveGroup\", { targetName: \"x\", ...options }),\n client.hasPermission(\"xxxx\", \"joinLeaveGroup\", { targetName: \"x\", ...options }),\n client.revokePermission(\"xxxx\", \"joinLeaveGroup\", options),\n client.getClientAccessToken(options),\n ];\n // We don't care about errors, only that we created (and closed) the appropriate spans.\n await Promise.all(promises.map((p) => p.catch(() => undefined)));\n },\n [\n \"WebPubSubServiceClient.sendToAll\",\n \"WebPubSubServiceClient.sendToUser\",\n \"WebPubSubServiceClient.sendToConnection\",\n \"WebPubSubServiceClient.connectionExists\",\n \"WebPubSubServiceClient.closeConnection\",\n \"WebPubSubServiceClient.closeAllConnections\",\n \"WebPubSubServiceClient.closeUserConnections\",\n \"WebPubSubServiceClient.removeUserFromAllGroups\",\n \"WebPubSubServiceClient.groupExists\",\n \"WebPubSubServiceClient.userExists\",\n \"WebPubSubServiceClient.grantPermission\",\n \"WebPubSubServiceClient.hasPermission\",\n \"WebPubSubServiceClient.revokePermission\",\n \"WebPubSubServiceClient.getClientAccessToken\",\n ],\n );\n });\n\n it(\"can generate client tokens\", async () => {\n const res = await client.getClientAccessToken({\n userId: \"brian\",\n groups: [\"group1\"],\n });\n const url = new URL(res.url);\n assert.ok(url.searchParams.has(\"access_token\"));\n assert.equal(url.host, new URL(client.endpoint).host);\n assert.equal(url.pathname, `/client/hubs/${client.hubName}`);\n });\n\n it(\"can generate client MQTT tokens\", async () => {\n const res = await client.getClientAccessToken({\n userId: \"brian\",\n groups: [\"group1\"],\n clientProtocol: \"mqtt\",\n });\n const url = new URL(res.url);\n assert.ok(url.searchParams.has(\"access_token\"));\n assert.equal(url.host, new URL(client.endpoint).host);\n assert.equal(url.pathname, `/clients/mqtt/hubs/${client.hubName}`);\n });\n });\n});\n"]}
1
+ {"version":3,"file":"hubs.spec.js","sourceRoot":"","sources":["../../test/hubs.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,eAAe,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,uDAAuD;AAEvD,QAAQ,CAAC,WAAW,EAAE;IACpB,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACxC,MAAM,UAAU,GAAG,oBAAoB,EAAE,CAAC;QAC1C,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;YAC1D,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE;gBACvB,IAAI,sBAAsB,CAAC,yBAAyB,CAAC,uBAAuB,CAAC,EAAE,UAAU,EAAE;oBACzF,YAAY,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE;iBAChC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;YAChE,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE;gBACvB,IAAI,sBAAsB,CACxB,yBAAyB,CAAC,cAAc,CAAC,EACzC,IAAI,kBAAkB,CAAC,yBAAyB,CAAC,aAAa,CAAC,CAAC,EAChE,UAAU,EACV;oBACE,YAAY,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE;iBAChC,CACF,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,o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CAAC,CAAC;YAChD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC;YACtD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,sBAAsB,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QACrE,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n/* eslint-disable no-invalid-this */\nimport { Recorder, isLiveMode, assertEnvironmentVariable } from \"@azure-tools/test-recorder\";\nimport { WebPubSubServiceClient, AzureKeyCredential } from \"../src\";\nimport { assert } from \"@azure-tools/test-utils\";\nimport recorderOptions from \"./testEnv\";\nimport type { FullOperationResponse } from \"@azure/core-client\";\nimport { createTestCredential } from \"@azure-tools/test-credential\";\n/* eslint-disable @typescript-eslint/no-invalid-this */\n\ndescribe(\"HubClient\", function () {\n describe(\"Constructing a HubClient\", () => {\n const credential = createTestCredential();\n it(\"takes a connection string, hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"), \"test-hub\", {\n retryOptions: { maxRetries: 2 },\n });\n });\n });\n\n it(\"takes an endpoint, an API key, a hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_ENDPOINT\"),\n new AzureKeyCredential(assertEnvironmentVariable(\"WPS_API_KEY\")),\n \"test-hub\",\n {\n retryOptions: { maxRetries: 2 },\n },\n );\n });\n });\n\n it(\"takes an endpoint, DefaultAzureCredential, a hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_ENDPOINT\"),\n credential,\n \"test-hub\",\n {\n retryOptions: { maxRetries: 2 },\n },\n );\n });\n });\n });\n\n describe(\"Working with a hub\", function () {\n let recorder: Recorder;\n let client: WebPubSubServiceClient;\n let lastResponse: FullOperationResponse | undefined;\n const credential = createTestCredential();\n function onResponse(response: FullOperationResponse): void {\n lastResponse = response;\n }\n beforeEach(async function () {\n recorder = new Recorder(this.currentTest);\n await recorder.start(recorderOptions);\n\n client = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n \"simplechat\",\n recorder.configureClientOptions({}),\n );\n });\n\n afterEach(async function () {\n await recorder.stop();\n });\n\n it(\"can broadcast\", async () => {\n await client.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can broadcast with filter\", async () => {\n await client.sendToAll(\"hello\", {\n contentType: \"text/plain\",\n filter: \"userId ne 'user1'\",\n messageTtlSeconds: 60,\n onResponse,\n });\n assert.equal(lastResponse?.status, 202);\n\n let error;\n try {\n await client.sendToAll(\"hello\", {\n contentType: \"text/plain\",\n filter: \"invalid filter\",\n });\n } catch (e: any) {\n if (e.name !== \"RestError\") {\n throw e;\n }\n\n error = e;\n }\n assert.equal(error.statusCode, 400);\n assert.equal(\n JSON.parse(error.message).message,\n \"Invalid syntax for 'invalid filter': Syntax error at position 14 in 'invalid filter'. (Parameter 'filter')\",\n );\n });\n\n it(\"can broadcast using the DAC\", async () => {\n const dacClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_ENDPOINT\"),\n credential,\n \"simplechat\",\n recorder.configureClientOptions({}),\n );\n\n await dacClient.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await dacClient.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await dacClient.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can broadcast using APIM\", async () => {\n const apimClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n \"simplechat\",\n recorder.configureClientOptions({\n reverseProxyEndpoint: assertEnvironmentVariable(\"WPS_REVERSE_PROXY_ENDPOINT\"),\n }),\n );\n\n await apimClient.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await apimClient.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await apimClient.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can send messages to a user\", async () => {\n await client.sendToUser(\"brian\", \"hello\", {\n contentType: \"text/plain\",\n onResponse,\n });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToUser(\"brian\", { x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToUser(\"brian\", binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can send to a user with filter\", async () => {\n await client.sendToUser(\"vic\", \"hello\", {\n contentType: \"text/plain\",\n filter: \"userId ne 'user1'\",\n onResponse,\n });\n assert.equal(lastResponse?.status, 202);\n\n let error;\n try {\n await client.sendToUser(\"brian\", \"hello\", {\n contentType: \"text/plain\",\n filter: \"invalid filter\",\n });\n } catch (e: any) {\n if (e.name !== \"RestError\") {\n throw e;\n }\n\n error = e;\n }\n assert.equal(error.statusCode, 400);\n assert.equal(\n JSON.parse(error.message).message,\n \"Invalid syntax for 'invalid filter': Syntax error at position 14 in 'invalid filter'. (Parameter 'filter')\",\n );\n });\n\n it(\"can send messages to a connection\", async () => {\n await client.sendToConnection(\"xxxx\", \"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToConnection(\"xxxx\", { x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n const binaryMessage = new Uint8Array(10);\n\n await client.sendToConnection(\"xxxx\", binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can manage users\", async () => {\n const res = await client.userExists(\"foo\");\n assert.ok(!res);\n await client.removeUserFromAllGroups(\"brian\", { onResponse });\n assert.equal(lastResponse?.status, 204);\n });\n\n it(\"can manage connections\", async () => {\n await client.removeConnectionFromAllGroups(\"xxx\", { onResponse });\n assert.equal(lastResponse?.status, 204);\n });\n\n it(\"can check if a connection exists\", async function () {\n // likely bug in recorder for this test - recording not generating properly\n if (!isLiveMode()) this.skip();\n const res = await client.connectionExists(\"xxx\");\n assert.ok(!res);\n });\n\n it(\"can grant permissions to connections\", async () => {\n let error;\n try {\n await client.grantPermission(\"xxx\", \"joinLeaveGroup\", { targetName: \"x\" });\n } catch (e: any) {\n if (e.name !== \"RestError\") {\n throw e;\n }\n\n error = e;\n }\n // grantPermission validates connection ids, so we expect an error here.\n assert.equal(error.statusCode, 404);\n });\n\n it(\"can revoke permissions from connections\", async function () {\n // likely bug in recorder for this test - recording not generating properly\n if (!isLiveMode()) this.skip();\n await client.revokePermission(\"invalid-id\", \"joinLeaveGroup\", { targetName: \"x\" });\n // Service doesn't throw error for invalid connection-ids\n });\n\n it(\"can trace through the various options\", async function () {\n await assert.supportsTracing(\n async (options) => {\n const promises: Promise<any>[] = [\n client.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse, ...options }),\n client.sendToUser(\"brian\", \"hello\", {\n contentType: \"text/plain\",\n onResponse,\n ...options,\n }),\n client.sendToConnection(\"xxxx\", \"hello\", {\n contentType: \"text/plain\",\n onResponse,\n ...options,\n }),\n client.connectionExists(\"xxxx\", options),\n client.closeConnection(\"xxxx\", options),\n client.closeAllConnections(options),\n client.closeUserConnections(\"xxxx\", options),\n client.removeUserFromAllGroups(\"foo\", options),\n client.groupExists(\"foo\", options),\n client.userExists(\"foo\", options),\n client.grantPermission(\"xxxx\", \"joinLeaveGroup\", { targetName: \"x\", ...options }),\n client.hasPermission(\"xxxx\", \"joinLeaveGroup\", { targetName: \"x\", ...options }),\n client.revokePermission(\"xxxx\", \"joinLeaveGroup\", options),\n client.getClientAccessToken(options),\n ];\n // We don't care about errors, only that we created (and closed) the appropriate spans.\n await Promise.all(promises.map((p) => p.catch(() => undefined)));\n },\n [\n \"WebPubSubServiceClient.sendToAll\",\n \"WebPubSubServiceClient.sendToUser\",\n \"WebPubSubServiceClient.sendToConnection\",\n \"WebPubSubServiceClient.connectionExists\",\n \"WebPubSubServiceClient.closeConnection\",\n \"WebPubSubServiceClient.closeAllConnections\",\n \"WebPubSubServiceClient.closeUserConnections\",\n \"WebPubSubServiceClient.removeUserFromAllGroups\",\n \"WebPubSubServiceClient.groupExists\",\n \"WebPubSubServiceClient.userExists\",\n \"WebPubSubServiceClient.grantPermission\",\n \"WebPubSubServiceClient.hasPermission\",\n \"WebPubSubServiceClient.revokePermission\",\n \"WebPubSubServiceClient.getClientAccessToken\",\n ],\n );\n });\n\n it(\"can generate client tokens\", async () => {\n const res = await client.getClientAccessToken({\n userId: \"brian\",\n groups: [\"group1\"],\n });\n const url = new URL(res.url);\n assert.ok(url.searchParams.has(\"access_token\"));\n assert.equal(url.host, new URL(client.endpoint).host);\n assert.equal(url.pathname, `/client/hubs/${client.hubName}`);\n });\n\n it(\"can generate client MQTT tokens\", async () => {\n const res = await client.getClientAccessToken({\n userId: \"brian\",\n groups: [\"group1\"],\n clientProtocol: \"mqtt\",\n });\n const url = new URL(res.url);\n assert.ok(url.searchParams.has(\"access_token\"));\n assert.equal(url.host, new URL(client.endpoint).host);\n assert.equal(url.pathname, `/clients/mqtt/hubs/${client.hubName}`);\n });\n });\n});\n"]}