@azure/web-pubsub 1.1.4-alpha.20241119.1 → 1.1.4-alpha.20241120.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. package/dist/commonjs/generated/generatedClient.d.ts +19 -0
  2. package/dist/commonjs/generated/generatedClient.d.ts.map +1 -0
  3. package/dist/commonjs/generated/generatedClient.js +76 -0
  4. package/dist/commonjs/generated/generatedClient.js.map +1 -0
  5. package/dist/commonjs/generated/generatedClientContext.d.ts +14 -0
  6. package/dist/commonjs/generated/generatedClientContext.d.ts.map +1 -0
  7. package/dist/commonjs/generated/generatedClientContext.js +46 -0
  8. package/dist/commonjs/generated/generatedClientContext.js.map +1 -0
  9. package/dist/commonjs/generated/index.d.ts +4 -0
  10. package/dist/commonjs/generated/index.d.ts.map +1 -0
  11. package/dist/commonjs/generated/index.js +16 -0
  12. package/dist/commonjs/generated/index.js.map +1 -0
  13. package/dist/commonjs/generated/models/index.d.ts +323 -0
  14. package/dist/commonjs/generated/models/index.d.ts.map +1 -0
  15. package/dist/commonjs/generated/models/index.js +27 -0
  16. package/dist/commonjs/generated/models/index.js.map +1 -0
  17. package/dist/commonjs/generated/models/mappers.d.ts +30 -0
  18. package/dist/commonjs/generated/models/mappers.d.ts.map +1 -0
  19. package/dist/commonjs/generated/models/mappers.js +463 -0
  20. package/dist/commonjs/generated/models/mappers.js.map +1 -0
  21. package/dist/commonjs/generated/models/parameters.d.ts +31 -0
  22. package/dist/commonjs/generated/models/parameters.d.ts.map +1 -0
  23. package/dist/commonjs/generated/models/parameters.js +335 -0
  24. package/dist/commonjs/generated/models/parameters.js.map +1 -0
  25. package/dist/commonjs/generated/operations/healthApi.d.ts +18 -0
  26. package/dist/commonjs/generated/operations/healthApi.d.ts.map +1 -0
  27. package/dist/commonjs/generated/operations/healthApi.js +43 -0
  28. package/dist/commonjs/generated/operations/healthApi.js.map +1 -0
  29. package/dist/commonjs/generated/operations/index.d.ts +3 -0
  30. package/dist/commonjs/generated/operations/index.d.ts.map +1 -0
  31. package/dist/commonjs/generated/operations/index.js +13 -0
  32. package/dist/commonjs/generated/operations/index.js.map +1 -0
  33. package/dist/commonjs/generated/operations/webPubSub.d.ts +249 -0
  34. package/dist/commonjs/generated/operations/webPubSub.d.ts.map +1 -0
  35. package/dist/commonjs/generated/operations/webPubSub.js +874 -0
  36. package/dist/commonjs/generated/operations/webPubSub.js.map +1 -0
  37. package/dist/commonjs/generated/operationsInterfaces/healthApi.d.ts +10 -0
  38. package/dist/commonjs/generated/operationsInterfaces/healthApi.d.ts.map +1 -0
  39. package/dist/commonjs/generated/operationsInterfaces/healthApi.js +10 -0
  40. package/dist/commonjs/generated/operationsInterfaces/healthApi.js.map +1 -0
  41. package/dist/commonjs/generated/operationsInterfaces/index.d.ts +3 -0
  42. package/dist/commonjs/generated/operationsInterfaces/index.d.ts.map +1 -0
  43. package/dist/commonjs/generated/operationsInterfaces/index.js +13 -0
  44. package/dist/commonjs/generated/operationsInterfaces/index.js.map +1 -0
  45. package/dist/commonjs/generated/operationsInterfaces/webPubSub.d.ts +224 -0
  46. package/dist/commonjs/generated/operationsInterfaces/webPubSub.d.ts.map +1 -0
  47. package/dist/commonjs/generated/operationsInterfaces/webPubSub.js +10 -0
  48. package/dist/commonjs/generated/operationsInterfaces/webPubSub.js.map +1 -0
  49. package/dist/commonjs/groupClient.d.ts +232 -0
  50. package/dist/commonjs/groupClient.d.ts.map +1 -0
  51. package/dist/commonjs/groupClient.js +101 -0
  52. package/dist/commonjs/groupClient.js.map +1 -0
  53. package/dist/commonjs/hubClient.d.ts +478 -0
  54. package/dist/commonjs/hubClient.d.ts.map +1 -0
  55. package/dist/commonjs/hubClient.js +372 -0
  56. package/dist/commonjs/hubClient.js.map +1 -0
  57. package/dist/commonjs/index.d.ts +5 -0
  58. package/dist/commonjs/index.d.ts.map +1 -0
  59. package/dist/commonjs/index.js +12 -0
  60. package/dist/commonjs/index.js.map +1 -0
  61. package/dist/commonjs/logger.d.ts +5 -0
  62. package/dist/commonjs/logger.d.ts.map +1 -0
  63. package/dist/commonjs/logger.js +11 -0
  64. package/dist/commonjs/logger.js.map +1 -0
  65. package/dist/commonjs/package.json +3 -0
  66. package/dist/commonjs/parseConnectionString.d.ts +8 -0
  67. package/dist/commonjs/parseConnectionString.d.ts.map +1 -0
  68. package/dist/commonjs/parseConnectionString.js +34 -0
  69. package/dist/commonjs/parseConnectionString.js.map +1 -0
  70. package/dist/commonjs/reverseProxyPolicy.d.ts +9 -0
  71. package/dist/commonjs/reverseProxyPolicy.d.ts.map +1 -0
  72. package/dist/commonjs/reverseProxyPolicy.js +25 -0
  73. package/dist/commonjs/reverseProxyPolicy.js.map +1 -0
  74. package/dist/commonjs/tracing.d.ts +3 -0
  75. package/dist/commonjs/tracing.d.ts.map +1 -0
  76. package/dist/commonjs/tracing.js +12 -0
  77. package/dist/commonjs/tracing.js.map +1 -0
  78. package/dist/commonjs/tsdoc-metadata.json +11 -0
  79. package/dist/commonjs/utils.d.ts +29 -0
  80. package/dist/commonjs/utils.d.ts.map +1 -0
  81. package/dist/commonjs/utils.js +73 -0
  82. package/dist/commonjs/utils.js.map +1 -0
  83. package/dist/commonjs/webPubSubCredentialPolicy.d.ts +13 -0
  84. package/dist/commonjs/webPubSubCredentialPolicy.d.ts.map +1 -0
  85. package/dist/commonjs/webPubSubCredentialPolicy.js +32 -0
  86. package/dist/commonjs/webPubSubCredentialPolicy.js.map +1 -0
  87. package/dist/esm/generated/generatedClient.d.ts +19 -0
  88. package/dist/esm/generated/generatedClient.d.ts.map +1 -0
  89. package/{dist-esm/src → dist/esm}/generated/generatedClient.js +1 -1
  90. package/dist/esm/generated/generatedClient.js.map +1 -0
  91. package/dist/esm/generated/generatedClientContext.d.ts +14 -0
  92. package/dist/esm/generated/generatedClientContext.d.ts.map +1 -0
  93. package/dist/esm/generated/generatedClientContext.js.map +1 -0
  94. package/dist/esm/generated/index.d.ts +4 -0
  95. package/dist/esm/generated/index.d.ts.map +1 -0
  96. package/{dist-esm/src → dist/esm}/generated/index.js +3 -3
  97. package/dist/esm/generated/index.js.map +1 -0
  98. package/dist/esm/generated/models/index.d.ts +323 -0
  99. package/dist/esm/generated/models/index.d.ts.map +1 -0
  100. package/dist/esm/generated/models/mappers.d.ts +30 -0
  101. package/dist/esm/generated/models/mappers.d.ts.map +1 -0
  102. package/dist/esm/generated/models/parameters.d.ts +31 -0
  103. package/dist/esm/generated/models/parameters.d.ts.map +1 -0
  104. package/{dist-esm/src → dist/esm}/generated/models/parameters.js +1 -1
  105. package/dist/esm/generated/models/parameters.js.map +1 -0
  106. package/dist/esm/generated/operations/healthApi.d.ts +18 -0
  107. package/dist/esm/generated/operations/healthApi.d.ts.map +1 -0
  108. package/{dist-esm/src → dist/esm}/generated/operations/healthApi.js +2 -2
  109. package/dist/esm/generated/operations/healthApi.js.map +1 -0
  110. package/dist/esm/generated/operations/index.d.ts +3 -0
  111. package/dist/esm/generated/operations/index.d.ts.map +1 -0
  112. package/{dist-esm/src/generated/operationsInterfaces → dist/esm/generated/operations}/index.js +2 -2
  113. package/dist/esm/generated/operations/index.js.map +1 -0
  114. package/dist/esm/generated/operations/webPubSub.d.ts +249 -0
  115. package/dist/esm/generated/operations/webPubSub.d.ts.map +1 -0
  116. package/{dist-esm/src → dist/esm}/generated/operations/webPubSub.js +2 -2
  117. package/dist/esm/generated/operations/webPubSub.js.map +1 -0
  118. package/dist/esm/generated/operationsInterfaces/healthApi.d.ts +10 -0
  119. package/dist/esm/generated/operationsInterfaces/healthApi.d.ts.map +1 -0
  120. package/{dist-esm/src → dist/esm}/generated/operationsInterfaces/healthApi.js.map +1 -1
  121. package/dist/esm/generated/operationsInterfaces/index.d.ts +3 -0
  122. package/dist/esm/generated/operationsInterfaces/index.d.ts.map +1 -0
  123. package/{dist-esm/src/generated/operations → dist/esm/generated/operationsInterfaces}/index.js +2 -2
  124. package/dist/esm/generated/operationsInterfaces/index.js.map +1 -0
  125. package/dist/esm/generated/operationsInterfaces/webPubSub.d.ts +224 -0
  126. package/dist/esm/generated/operationsInterfaces/webPubSub.d.ts.map +1 -0
  127. package/dist/esm/generated/operationsInterfaces/webPubSub.js.map +1 -0
  128. package/dist/esm/groupClient.d.ts +232 -0
  129. package/dist/esm/groupClient.d.ts.map +1 -0
  130. package/{dist-esm/src → dist/esm}/groupClient.js +2 -2
  131. package/dist/esm/groupClient.js.map +1 -0
  132. package/dist/esm/hubClient.d.ts +478 -0
  133. package/dist/esm/hubClient.d.ts.map +1 -0
  134. package/{dist-esm/src → dist/esm}/hubClient.js +9 -9
  135. package/dist/esm/hubClient.js.map +1 -0
  136. package/dist/esm/index.d.ts +5 -0
  137. package/dist/esm/index.d.ts.map +1 -0
  138. package/{dist-esm/src → dist/esm}/index.js +2 -2
  139. package/dist/esm/index.js.map +1 -0
  140. package/dist/esm/logger.d.ts +5 -0
  141. package/dist/esm/logger.d.ts.map +1 -0
  142. package/dist/esm/package.json +3 -0
  143. package/dist/esm/parseConnectionString.d.ts +8 -0
  144. package/dist/esm/parseConnectionString.d.ts.map +1 -0
  145. package/dist/esm/reverseProxyPolicy.d.ts +9 -0
  146. package/dist/esm/reverseProxyPolicy.d.ts.map +1 -0
  147. package/dist/esm/tracing.d.ts +3 -0
  148. package/dist/esm/tracing.d.ts.map +1 -0
  149. package/dist/esm/utils.d.ts +29 -0
  150. package/dist/esm/utils.d.ts.map +1 -0
  151. package/dist/esm/webPubSubCredentialPolicy.d.ts +13 -0
  152. package/dist/esm/webPubSubCredentialPolicy.d.ts.map +1 -0
  153. package/package.json +56 -52
  154. package/dist/index.js +0 -2441
  155. package/dist/index.js.map +0 -1
  156. package/dist-esm/samples-dev/broadcasting.js +0 -27
  157. package/dist-esm/samples-dev/broadcasting.js.map +0 -1
  158. package/dist-esm/samples-dev/directMessage.js +0 -20
  159. package/dist-esm/samples-dev/directMessage.js.map +0 -1
  160. package/dist-esm/samples-dev/managingGroups.js +0 -23
  161. package/dist-esm/samples-dev/managingGroups.js.map +0 -1
  162. package/dist-esm/src/generated/generatedClient.js.map +0 -1
  163. package/dist-esm/src/generated/generatedClientContext.js.map +0 -1
  164. package/dist-esm/src/generated/index.js.map +0 -1
  165. package/dist-esm/src/generated/models/parameters.js.map +0 -1
  166. package/dist-esm/src/generated/operations/healthApi.js.map +0 -1
  167. package/dist-esm/src/generated/operations/index.js.map +0 -1
  168. package/dist-esm/src/generated/operations/webPubSub.js.map +0 -1
  169. package/dist-esm/src/generated/operationsInterfaces/index.js.map +0 -1
  170. package/dist-esm/src/generated/operationsInterfaces/webPubSub.js.map +0 -1
  171. package/dist-esm/src/groupClient.js.map +0 -1
  172. package/dist-esm/src/hubClient.js.map +0 -1
  173. package/dist-esm/src/index.js.map +0 -1
  174. package/dist-esm/test/conn.spec.js +0 -23
  175. package/dist-esm/test/conn.spec.js.map +0 -1
  176. package/dist-esm/test/groups.spec.js +0 -138
  177. package/dist-esm/test/groups.spec.js.map +0 -1
  178. package/dist-esm/test/hubs.spec.js +0 -270
  179. package/dist-esm/test/hubs.spec.js.map +0 -1
  180. package/dist-esm/test/integration.spec.js +0 -299
  181. package/dist-esm/test/integration.spec.js.map +0 -1
  182. package/dist-esm/test/odata.spec.js +0 -15
  183. package/dist-esm/test/odata.spec.js.map +0 -1
  184. package/dist-esm/test/testEnv.js +0 -23
  185. package/dist-esm/test/testEnv.js.map +0 -1
  186. /package/{dist-esm/src → dist/esm}/generated/generatedClientContext.js +0 -0
  187. /package/{dist-esm/src → dist/esm}/generated/models/index.js +0 -0
  188. /package/{dist-esm/src → dist/esm}/generated/models/index.js.map +0 -0
  189. /package/{dist-esm/src → dist/esm}/generated/models/mappers.js +0 -0
  190. /package/{dist-esm/src → dist/esm}/generated/models/mappers.js.map +0 -0
  191. /package/{dist-esm/src → dist/esm}/generated/operationsInterfaces/healthApi.js +0 -0
  192. /package/{dist-esm/src → dist/esm}/generated/operationsInterfaces/webPubSub.js +0 -0
  193. /package/{dist-esm/src → dist/esm}/logger.js +0 -0
  194. /package/{dist-esm/src → dist/esm}/logger.js.map +0 -0
  195. /package/{dist-esm/src → dist/esm}/parseConnectionString.js +0 -0
  196. /package/{dist-esm/src → dist/esm}/parseConnectionString.js.map +0 -0
  197. /package/{dist-esm/src → dist/esm}/reverseProxyPolicy.js +0 -0
  198. /package/{dist-esm/src → dist/esm}/reverseProxyPolicy.js.map +0 -0
  199. /package/{dist-esm/src → dist/esm}/tracing.js +0 -0
  200. /package/{dist-esm/src → dist/esm}/tracing.js.map +0 -0
  201. /package/{dist-esm/src → dist/esm}/utils.js +0 -0
  202. /package/{dist-esm/src → dist/esm}/utils.js.map +0 -0
  203. /package/{dist-esm/src → dist/esm}/webPubSubCredentialPolicy.js +0 -0
  204. /package/{dist-esm/src → dist/esm}/webPubSubCredentialPolicy.js.map +0 -0
  205. /package/{types → dist}/web-pubsub.d.ts +0 -0
@@ -0,0 +1,478 @@
1
+ import type { CommonClientOptions, OperationOptions } from "@azure/core-client";
2
+ import type { RequestBodyType } from "@azure/core-rest-pipeline";
3
+ import type { WebPubSubGroup, GroupAddConnectionOptions, GroupRemoveConnectionOptions } from "./groupClient.js";
4
+ import type { AzureKeyCredential, TokenCredential } from "@azure/core-auth";
5
+ /**
6
+ * Options for closing a connection to a hub.
7
+ */
8
+ export interface HubCloseConnectionOptions extends OperationOptions {
9
+ /**
10
+ * Reason the connection is being closed.
11
+ */
12
+ reason?: string;
13
+ }
14
+ /**
15
+ * Options for closing all connections to a hub.
16
+ */
17
+ export interface HubCloseAllConnectionsOptions extends OperationOptions {
18
+ /**
19
+ * Reason the connection is being closed.
20
+ */
21
+ reason?: string;
22
+ }
23
+ /**
24
+ * Options for closing all of a user's connections to a hub.
25
+ */
26
+ export interface HubCloseUserConnectionsOptions extends OperationOptions {
27
+ /**
28
+ * Reason the connection is being closed.
29
+ */
30
+ reason?: string;
31
+ }
32
+ /**
33
+ * Options for sending messages to hubs.
34
+ */
35
+ export interface HubSendToAllOptions extends OperationOptions {
36
+ /**
37
+ * Connection ids to exclude from receiving this message.
38
+ */
39
+ excludedConnections?: string[];
40
+ /**
41
+ * The filter syntax to filter out the connections to send the messages to following OData filter syntax.
42
+ * Examples:
43
+ * * Exclude connections from `user1` and `user2`: `userId ne 'user1' and userId ne 'user2'`
44
+ * * Exclude connections in `group1`: `not('group1' in groups)`
45
+ * Details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax).
46
+ */
47
+ filter?: string;
48
+ /**
49
+ * The time-to-live (TTL) value in seconds for messages sent to the service.
50
+ * 0 is the default value, which means the message never expires.
51
+ * 300 is the maximum value.
52
+ * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.
53
+ * This parameter can help when the client's bandwidth is limited.
54
+ */
55
+ messageTtlSeconds?: number;
56
+ }
57
+ /**
58
+ * Options for sending text messages to hubs.
59
+ */
60
+ export interface HubSendTextToAllOptions extends HubSendToAllOptions {
61
+ /**
62
+ * The content will be sent to the clients in plain text.
63
+ */
64
+ contentType: "text/plain";
65
+ }
66
+ /**
67
+ * Types which can be serialized and sent as JSON.
68
+ */
69
+ export type JSONTypes = string | number | boolean | object;
70
+ /**
71
+ * Options for constructing a HubAdmin client.
72
+ */
73
+ export interface WebPubSubServiceClientOptions extends CommonClientOptions {
74
+ /**
75
+ * Reverse proxy endpoint (for example, your Azure API management endpoint)
76
+ */
77
+ reverseProxyEndpoint?: string;
78
+ /**
79
+ * Options to configure the logging options.
80
+ */
81
+ loggingOptions?: WebPubSubServiceClientLogOptions;
82
+ }
83
+ /**
84
+ * Options to configure the logging options.
85
+ */
86
+ export declare interface WebPubSubServiceClientLogOptions {
87
+ /**
88
+ * Header names whose values will be logged when logging is enabled.
89
+ * Defaults include a list of well-known safe headers. Any headers
90
+ * specified in this field will be added to that list. Any other values will
91
+ * be written to logs as "REDACTED".
92
+ */
93
+ additionalAllowedHeaderNames?: string[];
94
+ /**
95
+ * Query string names whose values will be logged when logging is enabled. By default no
96
+ * query string values are logged.
97
+ */
98
+ additionalAllowedQueryParameters?: string[];
99
+ }
100
+ /**
101
+ * Options for checking if a connection exists.
102
+ */
103
+ export interface HasConnectionOptions extends OperationOptions {
104
+ }
105
+ /**
106
+ * Options for checking if a group exists.
107
+ */
108
+ export interface HubHasGroupOptions extends OperationOptions {
109
+ }
110
+ /**
111
+ * Options for checking if a user exists.
112
+ */
113
+ export interface HubHasUserOptions extends OperationOptions {
114
+ }
115
+ /**
116
+ * Options for removing a user from all groups.
117
+ */
118
+ export interface HubRemoveUserFromAllGroupsOptions extends HubCloseConnectionOptions {
119
+ }
120
+ /**
121
+ * Options for sending a message to a specific connection.
122
+ */
123
+ export interface HubSendToConnectionOptions extends OperationOptions {
124
+ /**
125
+ * The time-to-live (TTL) value in seconds for messages sent to the service.
126
+ * 0 is the default value, which means the message never expires.
127
+ * 300 is the maximum value.
128
+ * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.
129
+ * This parameter can help when the client's bandwidth is limited.
130
+ */
131
+ messageTtlSeconds?: number;
132
+ }
133
+ /**
134
+ * Options for sending a text message to a connection.
135
+ */
136
+ export interface HubSendTextToConnectionOptions extends HubSendToConnectionOptions {
137
+ contentType: "text/plain";
138
+ }
139
+ /**
140
+ * Options for sending a message to a user.
141
+ */
142
+ export interface HubSendToUserOptions extends OperationOptions {
143
+ /**
144
+ * The filter syntax to filter out the connections to send the messages to following OData filter syntax.
145
+ * Examples:
146
+ * * Exclude connections in `group1`: `not('group1' in groups)`
147
+ * * Send to connections in `group1` or `group2`: `'group1' in groups or `group2` in groups`
148
+ * Details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax).
149
+ */
150
+ filter?: string;
151
+ /**
152
+ * The time-to-live (TTL) value in seconds for messages sent to the service.
153
+ * 0 is the default value, which means the message never expires.
154
+ * 300 is the maximum value.
155
+ * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.
156
+ * This parameter can help when the client's bandwidth is limited.
157
+ */
158
+ messageTtlSeconds?: number;
159
+ }
160
+ /**
161
+ * Options for sending a text message to a user.
162
+ */
163
+ export interface HubSendTextToUserOptions extends HubSendToUserOptions {
164
+ /**
165
+ * The content will be sent to the clients in plain text.
166
+ */
167
+ contentType: "text/plain";
168
+ }
169
+ export type Permission = "joinLeaveGroup" | "sendToGroup";
170
+ /**
171
+ * Options for grant permissions to a connection
172
+ */
173
+ export interface HubGrantPermissionOptions extends OperationOptions {
174
+ /**
175
+ * The meaning of the target depends on the specific permission.
176
+ * For joinLeaveGroup and sendToGroup, targetName is a required parameter standing for the group name.
177
+ */
178
+ targetName?: string;
179
+ }
180
+ /**
181
+ * Options for revoke permissions from a connection
182
+ */
183
+ export interface HubRevokePermissionOptions extends OperationOptions {
184
+ /**
185
+ * The meaning of the target depends on the specific permission.
186
+ * For joinLeaveGroup and sendToGroup, targetName is a required parameter standing for the group name.
187
+ */
188
+ targetName?: string;
189
+ }
190
+ /**
191
+ * Options for checking if a connection has the specified permission
192
+ */
193
+ export interface HubHasPermissionOptions extends OperationOptions {
194
+ /**
195
+ * The meaning of the target depends on the specific permission.
196
+ * For joinLeaveGroup and sendToGroup, targetName is a required parameter standing for the group name.
197
+ */
198
+ targetName?: string;
199
+ }
200
+ /**
201
+ * The type of client endpoint that is being requested.
202
+ */
203
+ export type WebPubSubClientProtocol = "default" | "mqtt" | "socketio";
204
+ /**
205
+ * Options for generating a token to connect a client to the Azure Web Pubsub service.
206
+ */
207
+ export interface GenerateClientTokenOptions extends OperationOptions {
208
+ /**
209
+ * The userId for the client.
210
+ */
211
+ userId?: string;
212
+ /**
213
+ * The roles that the connection with the generated token will have.
214
+ * Roles give the client initial permissions to leave, join, or publish to groups when using PubSub subprotocol
215
+ * * `webpubsub.joinLeaveGroup`: the client can join or leave any group
216
+ * * `webpubsub.sendToGroup`: the client can send messages to any group
217
+ * * `webpubsub.joinLeaveGroup.<group>`: the client can join or leave group `<group>`
218
+ * * `webpubsub.sendToGroup.<group>`: the client can send messages to group `<group>`
219
+ *
220
+ * {@link https://azure.github.io/azure-webpubsub/references/pubsub-websocket-subprotocol#permissions}
221
+ */
222
+ roles?: string[];
223
+ /**
224
+ * Minutes until the token expires.
225
+ */
226
+ expirationTimeInMinutes?: number;
227
+ /**
228
+ * The groups to join when the client connects
229
+ */
230
+ groups?: string[];
231
+ /**
232
+ * The protocol type of the client
233
+ * * `default`: Default WebPubSub Client. Example Client Connection URL: _wss://exampleHost.com/client/hubs/exampleHub_
234
+ * * `mqtt`: MQTT Client. Example Client Connection URL: _wss://exampleHost.com/client/mqtt/hubs/exampleHub_
235
+ */
236
+ clientProtocol?: WebPubSubClientProtocol;
237
+ }
238
+ /**
239
+ * A response containing the client token.
240
+ */
241
+ export interface ClientTokenResponse {
242
+ /**
243
+ * The client token.
244
+ */
245
+ token: string;
246
+ /**
247
+ * The URL client connects to
248
+ */
249
+ baseUrl: string;
250
+ /**
251
+ * The URL client connects to with access_token query string
252
+ */
253
+ url: string;
254
+ }
255
+ /**
256
+ * Client for connecting to a Web PubSub hub
257
+ */
258
+ export declare class WebPubSubServiceClient {
259
+ private readonly client;
260
+ private credential;
261
+ private readonly clientOptions?;
262
+ /**
263
+ * The name of the hub this client is connected to
264
+ */
265
+ readonly hubName: string;
266
+ /**
267
+ * The Web PubSub API version being used by this client
268
+ */
269
+ readonly apiVersion: string;
270
+ /**
271
+ * The Web PubSub endpoint this client is connected to
272
+ */
273
+ endpoint: string;
274
+ /**
275
+ * Creates an instance of a WebPubSubServiceClient for sending messages and managing groups, connections, and users.
276
+ *
277
+ * Example usage:
278
+ * ```ts
279
+ * import { WebPubSubServiceClient } from "@azure/web-pubsub";
280
+ * const connectionString = process.env['WEB_PUBSUB_CONNECTION_STRING'];
281
+ * const client = new WebPubSubServiceClient(connectionString, 'chat');
282
+ * ```
283
+ *
284
+ * @param connectionString - The connection string
285
+ * @param hubName - The name of the hub to connect to. If omitted, '_default' is used.
286
+ * @param options - Options to configure the http pipeline
287
+ */
288
+ constructor(connectionString: string, hubName: string, options?: WebPubSubServiceClientOptions);
289
+ /**
290
+ * Creates an instance of a WebPubSubServiceClient for sending messages and managing groups, connections, and users.
291
+ *
292
+ * Example usage:
293
+ * ```ts
294
+ * import { WebPubSubServiceClient, AzureKeyCredential } from "@azure/web-pubsub";
295
+ * const cred = new AzureKeyCredential("<your web pubsub api key>");
296
+ * const endpoint = "https://xxxx.webpubsubdev.azure.com"
297
+ * const client = new WebPubSubServiceClient(endpoint, cred, 'chat');
298
+ * ```
299
+ *
300
+ * @param endpoint - The endpoint to connect to
301
+ * @param credential - An AzureKeyCredential holding your service key
302
+ * @param hubName - The name of the hub to connect to.
303
+ * @param options - Options to configure the http pipeline
304
+ */
305
+ constructor(endpoint: string, credential: AzureKeyCredential | TokenCredential, hubName: string, options?: WebPubSubServiceClientOptions);
306
+ /**
307
+ * Get a client for a group
308
+ * @param groupName - The name of the group to connect to.
309
+ */
310
+ group(groupName: string): WebPubSubGroup;
311
+ /**
312
+ * Broadcast a text message to all connections on this hub.
313
+ *
314
+ * @param message - The text message to send
315
+ * @param options - Additional options
316
+ */
317
+ sendToAll(message: string, options: HubSendTextToAllOptions): Promise<void>;
318
+ /**
319
+ * Broadcast a JSON message to all connections on this hub.
320
+ *
321
+ * @param message - The JSON message to send
322
+ * @param options - Additional options
323
+ */
324
+ sendToAll(message: JSONTypes, options?: HubSendToAllOptions): Promise<void>;
325
+ /**
326
+ * Broadcast a binary message to all connections on this hub.
327
+ *
328
+ * @param message - The message to send
329
+ * @param options - Additional options
330
+ */
331
+ sendToAll(message: RequestBodyType, options?: HubSendToAllOptions): Promise<void>;
332
+ /**
333
+ * Send a text message to a specific user
334
+ *
335
+ * @param username - User name to send to
336
+ * @param message - The text message to send
337
+ * @param options - Additional options
338
+ */
339
+ sendToUser(username: string, message: string, options: HubSendTextToUserOptions): Promise<void>;
340
+ /**
341
+ * Send a JSON message to a specific user
342
+ *
343
+ * @param username - User name to send to
344
+ * @param message - The josn message to send
345
+ * @param options - Additional options
346
+ */
347
+ sendToUser(username: string, message: JSONTypes, options?: HubSendToUserOptions): Promise<void>;
348
+ /**
349
+ * Send a binary message to a specific user
350
+ *
351
+ * @param username - The user name to send to
352
+ * @param message - The binary message to send
353
+ * @param options - Additional options
354
+ */
355
+ sendToUser(username: string, message: RequestBodyType, options?: HubSendToUserOptions | HubSendTextToUserOptions): Promise<void>;
356
+ /**
357
+ * Send a text message to a specific connection
358
+ *
359
+ * @param connectionId - Connection id to send to
360
+ * @param message - The text message
361
+ * @param options - Additional options
362
+ */
363
+ sendToConnection(connectionId: string, message: string, options: HubSendTextToConnectionOptions): Promise<void>;
364
+ /**
365
+ * Send a binary message to a specific connection
366
+ *
367
+ * @param connectionId - Connection id to send to
368
+ * @param message - The JSON message
369
+ * @param options - Additional options
370
+ */
371
+ sendToConnection(connectionId: string, message: JSONTypes, options?: HubSendToConnectionOptions): Promise<void>;
372
+ /**
373
+ * Send a binary message to a specific connection
374
+ *
375
+ * @param connectionId - Connection id to send to
376
+ * @param message - The binary message
377
+ * @param options - Additional options
378
+ */
379
+ sendToConnection(connectionId: string, message: RequestBodyType, options?: HubSendToConnectionOptions | HubSendTextToConnectionOptions): Promise<void>;
380
+ /**
381
+ * Check if a specific connection is connected to this hub
382
+ *
383
+ * @param connectionId - Connection id to check
384
+ * @param options - Additional options
385
+ */
386
+ connectionExists(connectionId: string, options?: HasConnectionOptions): Promise<boolean>;
387
+ /**
388
+ * Close a specific connection to this hub
389
+ *
390
+ * @param connectionId - Connection id to close
391
+ * @param options - Additional options
392
+ */
393
+ closeConnection(connectionId: string, options?: HubCloseConnectionOptions): Promise<void>;
394
+ /**
395
+ * Close all connections to this hub
396
+ *
397
+ * @param options - Additional options
398
+ */
399
+ closeAllConnections(options?: HubCloseAllConnectionsOptions): Promise<void>;
400
+ /**
401
+ * Close all connections with the given user id
402
+ *
403
+ * @param user - User id to close
404
+ * @param options - Additional options
405
+ */
406
+ closeUserConnections(userId: string, options?: HubCloseUserConnectionsOptions): Promise<void>;
407
+ /**
408
+ * Remove a specific user from all groups they are joined to
409
+ * @param userId - The user id to remove from all groups
410
+ * @param options - Additional options
411
+ */
412
+ removeUserFromAllGroups(userId: string, options?: HubCloseConnectionOptions): Promise<void>;
413
+ /**
414
+ * Remove a specific connection from all groups they are joined to
415
+ * @param connectionId - The connection id to remove from all groups
416
+ * @param options - Additional options
417
+ */
418
+ removeConnectionFromAllGroups(connectionId: string, options?: HubCloseConnectionOptions): Promise<void>;
419
+ /**
420
+ * Add filtered connections to multiple groups
421
+ * @param groups - A list of groups which target connections will be added into
422
+ * @param filter - An OData filter which target connections satisfy
423
+ * @param options - Additional options
424
+ */
425
+ addConnectionsToGroups(groups: string[], filter: string, options?: GroupAddConnectionOptions): Promise<void>;
426
+ /**
427
+ * Remove filtered connections from multiple groups
428
+ * @param groups - A list of groups which target connections will be removed from
429
+ * @param filter - An OData filter which target connections satisfy
430
+ * @param options - Additional options
431
+ */
432
+ removeConnectionsFromGroups(groups: string[], filter: string, options?: GroupRemoveConnectionOptions): Promise<void>;
433
+ /**
434
+ * Check if a particular group exists (i.e. has active connections).
435
+ *
436
+ * @param groupName - The group name to check for
437
+ * @param options - Additional options
438
+ */
439
+ groupExists(groupName: string, options?: HubHasGroupOptions): Promise<boolean>;
440
+ /**
441
+ * Check if a particular user is connected to this hub.
442
+ *
443
+ * @param username - The user name to check for
444
+ * @param options - Additional options
445
+ */
446
+ userExists(username: string, options?: HubHasUserOptions): Promise<boolean>;
447
+ /**
448
+ * Grant permissions to a connection
449
+ *
450
+ * @param connectionId - The connection id to grant permissions to
451
+ * @param Permission - The permission to grant
452
+ * @param options - Additional options
453
+ */
454
+ grantPermission(connectionId: string, permission: Permission, options?: HubGrantPermissionOptions): Promise<void>;
455
+ /**
456
+ * Revoke permissions from a connection
457
+ *
458
+ * @param connectionId - The connection id to revoke permissions from
459
+ * @param Permission - The permission to revoke
460
+ * @param options - Additional options
461
+ */
462
+ revokePermission(connectionId: string, permission: Permission, options?: HubRevokePermissionOptions): Promise<void>;
463
+ /**
464
+ * Check if the connection has the specified permission
465
+ *
466
+ * @param connectionId - The connection id to check permission
467
+ * @param Permission - The permission to check
468
+ * @param options - Additional options
469
+ */
470
+ hasPermission(connectionId: string, permission: Permission, options?: HubHasPermissionOptions): Promise<boolean>;
471
+ /**
472
+ * Generate a token for a client to connect to the Azure Web PubSub service.
473
+ *
474
+ * @param options - Additional options
475
+ */
476
+ getClientAccessToken(options?: GenerateClientTokenOptions): Promise<ClientTokenResponse>;
477
+ }
478
+ //# sourceMappingURL=hubClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hubClient.d.ts","sourceRoot":"","sources":["../../src/hubClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EAEnB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAGjE,OAAO,KAAK,EACV,cAAc,EACd,yBAAyB,EACzB,4BAA4B,EAC7B,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAe5E;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IACjE;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,6BAA8B,SAAQ,gBAAgB;IACrE;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,8BAA+B,SAAQ,gBAAgB;IACtE;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;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,EACd,OAAO,GAAE,4BAAiC,GACzC,OAAO,CAAC,IAAI,CAAC;IAiBhB;;;;;OAKG;IACU,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC;IAiC/F;;;;;OAKG;IACU,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;IAkC5F;;;;;;OAMG;IACU,eAAe,CAC1B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,IAAI,CAAC;IAehB;;;;;;OAMG;IACU,gBAAgB,CAC3B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,IAAI,CAAC;IAehB;;;;;;OAMG;IACU,aAAa,CACxB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,OAAO,CAAC;IAkCnB;;;;OAIG;IACU,oBAAoB,CAC/B,OAAO,GAAE,0BAA+B,GACvC,OAAO,CAAC,mBAAmB,CAAC;CAsDhC"}
@@ -1,16 +1,16 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
  import { RestError } from "@azure/core-rest-pipeline";
4
- import { GeneratedClient } from "./generated/generatedClient";
5
- import { WebPubSubGroupImpl } from "./groupClient";
4
+ import { GeneratedClient } from "./generated/generatedClient.js";
5
+ import { WebPubSubGroupImpl } from "./groupClient.js";
6
6
  import { isTokenCredential } from "@azure/core-auth";
7
- import { webPubSubKeyCredentialPolicy } from "./webPubSubCredentialPolicy";
8
- import { tracingClient } from "./tracing";
9
- import { logger } from "./logger";
10
- import { parseConnectionString } from "./parseConnectionString";
7
+ import { webPubSubKeyCredentialPolicy } from "./webPubSubCredentialPolicy.js";
8
+ import { tracingClient } from "./tracing.js";
9
+ import { logger } from "./logger.js";
10
+ import { parseConnectionString } from "./parseConnectionString.js";
11
11
  import jwt from "jsonwebtoken";
12
- import { getPayloadForMessage } from "./utils";
13
- import { webPubSubReverseProxyPolicy } from "./reverseProxyPolicy";
12
+ import { getPayloadForMessage } from "./utils.js";
13
+ import { webPubSubReverseProxyPolicy } from "./reverseProxyPolicy.js";
14
14
  /**
15
15
  * Client for connecting to a Web PubSub hub
16
16
  */
@@ -334,7 +334,7 @@ export class WebPubSubServiceClient {
334
334
  const baseUrl = clientEndpoint + clientPath;
335
335
  let token;
336
336
  if (isTokenCredential(this.credential)) {
337
- const response = await this.client.webPubSub.generateClientToken(this.hubName, updatedOptions);
337
+ const response = await this.client.webPubSub.generateClientToken(this.hubName, Object.assign(Object.assign({}, updatedOptions), { clientType: clientProtocol }));
338
338
  token = response.token;
339
339
  }
340
340
  else {
@@ -0,0 +1 @@
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,gCAAgC,CAAC;AAMjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,GAAG,MAAM,cAAc,CAAC;AAC/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAMlD,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CA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KACjB,UAAU,EAAE,cAAc,IAC1B,CAAC;gBACH,KAAK,GAAG,QAAQ,CAAC,KAAM,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;gBAChC,MAAM,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;gBACvC,MAAM,OAAO,GAAG;oBACd,IAAI,EAAE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,KAAK;oBAC3B,iBAAiB,EAAE,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM;iBAC1C,CAAC;gBACF,MAAM,WAAW,GAAoB;oBACnC,QAAQ,EAAE,QAAQ;oBAClB,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 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.js\";\nimport type {\n WebPubSubGroup,\n GroupAddConnectionOptions,\n GroupRemoveConnectionOptions,\n} from \"./groupClient.js\";\nimport { WebPubSubGroupImpl } from \"./groupClient.js\";\nimport type { AzureKeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\nimport { webPubSubKeyCredentialPolicy } from \"./webPubSubCredentialPolicy.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport { logger } from \"./logger.js\";\nimport { parseConnectionString } from \"./parseConnectionString.js\";\nimport jwt from \"jsonwebtoken\";\nimport { getPayloadForMessage } from \"./utils.js\";\nimport type {\n GeneratedClientOptionalParams,\n AddToGroupsRequest,\n RemoveFromGroupsRequest,\n} from \"./generated/index.js\";\nimport { webPubSubReverseProxyPolicy } from \"./reverseProxyPolicy.js\";\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\" | \"socketio\";\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 let clientPath = `client/hubs/${this.hubName}`;\n switch (clientProtocol) {\n case \"mqtt\":\n clientPath = `clients/mqtt/hubs/${this.hubName}`;\n break;\n case \"socketio\":\n clientPath = `clients/socketio/hubs/${this.hubName}`;\n }\n const baseUrl = clientEndpoint + clientPath;\n\n let token: string;\n if (isTokenCredential(this.credential)) {\n const response = await this.client.webPubSub.generateClientToken(this.hubName, {\n ...updatedOptions,\n clientType: clientProtocol,\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"]}
@@ -0,0 +1,5 @@
1
+ export { AzureKeyCredential } from "@azure/core-auth";
2
+ export { WebPubSubServiceClient, HubSendToAllOptions, ClientTokenResponse, HubCloseConnectionOptions, HubCloseAllConnectionsOptions, HubCloseUserConnectionsOptions, GenerateClientTokenOptions, HasConnectionOptions, HubHasGroupOptions, HubHasUserOptions, WebPubSubServiceClientOptions, WebPubSubServiceClientLogOptions, HubRemoveUserFromAllGroupsOptions, HubSendToConnectionOptions, HubSendToUserOptions, HubGrantPermissionOptions, HubRevokePermissionOptions, HubHasPermissionOptions, HubSendTextToAllOptions, HubSendTextToConnectionOptions, HubSendTextToUserOptions, JSONTypes, Permission, WebPubSubClientProtocol, } from "./hubClient.js";
3
+ export { WebPubSubGroup, GroupAddConnectionOptions, GroupCloseAllConnectionsOptions, GroupAddUserOptions, GroupAdminClientOptions, GroupHasUserOptions, GroupRemoveConnectionOptions, GroupRemoveUserOptions, GroupSendTextToAllOptions, GroupSendToAllOptions, } from "./groupClient.js";
4
+ export { odata } from "./utils.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,EACzB,6BAA6B,EAC7B,8BAA8B,EAC9B,0BAA0B,EAC1B,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,6BAA6B,EAC7B,gCAAgC,EAChC,iCAAiC,EACjC,0BAA0B,EAC1B,oBAAoB,EACpB,yBAAyB,EACzB,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,EACvB,8BAA8B,EAC9B,wBAAwB,EACxB,SAAS,EACT,UAAU,EACV,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,cAAc,EACd,yBAAyB,EACzB,+BAA+B,EAC/B,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,4BAA4B,EAC5B,sBAAsB,EACtB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
@@ -1,6 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
3
  export { AzureKeyCredential } from "@azure/core-auth";
4
- export { WebPubSubServiceClient, } from "./hubClient";
5
- export { odata } from "./utils";
4
+ export { WebPubSubServiceClient, } from "./hubClient.js";
5
+ export { odata } from "./utils.js";
6
6
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,sBAAsB,GAwBvB,MAAM,gBAAgB,CAAC;AAaxB,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\nexport { AzureKeyCredential } from \"@azure/core-auth\";\nexport {\n WebPubSubServiceClient,\n HubSendToAllOptions,\n ClientTokenResponse,\n HubCloseConnectionOptions,\n HubCloseAllConnectionsOptions,\n HubCloseUserConnectionsOptions,\n GenerateClientTokenOptions,\n HasConnectionOptions,\n HubHasGroupOptions,\n HubHasUserOptions,\n WebPubSubServiceClientOptions,\n WebPubSubServiceClientLogOptions,\n HubRemoveUserFromAllGroupsOptions,\n HubSendToConnectionOptions,\n HubSendToUserOptions,\n HubGrantPermissionOptions,\n HubRevokePermissionOptions,\n HubHasPermissionOptions,\n HubSendTextToAllOptions,\n HubSendTextToConnectionOptions,\n HubSendTextToUserOptions,\n JSONTypes,\n Permission,\n WebPubSubClientProtocol,\n} from \"./hubClient.js\";\nexport {\n WebPubSubGroup,\n GroupAddConnectionOptions,\n GroupCloseAllConnectionsOptions,\n GroupAddUserOptions,\n GroupAdminClientOptions,\n GroupHasUserOptions,\n GroupRemoveConnectionOptions,\n GroupRemoveUserOptions,\n GroupSendTextToAllOptions,\n GroupSendToAllOptions,\n} from \"./groupClient.js\";\nexport { odata } from \"./utils.js\";\n"]}