@azure/web-pubsub-express 1.0.6-alpha.20250207.2 → 1.0.6-alpha.20250210.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -287,11 +287,11 @@ function getUserEventResponseHandler(userRequest, response) {
287
287
  response.setHeader("Content-Type", "application/octet-stream");
288
288
  break;
289
289
  }
290
- response.end(data !== null && data !== undefined ? data : "");
290
+ response.end(data !== null && data !== void 0 ? data : "");
291
291
  },
292
292
  fail(code, detail) {
293
293
  response.statusCode = code;
294
- response.end(detail !== null && detail !== undefined ? detail : "");
294
+ response.end(detail !== null && detail !== void 0 ? detail : "");
295
295
  },
296
296
  };
297
297
  return handler;
@@ -326,7 +326,7 @@ function tryGetWebPubSubEvent(req) {
326
326
  const disconnectd = "azure.webpubsub.sys.disconnected";
327
327
  const userPrefix = "azure.webpubsub.user.";
328
328
  const type = getHttpHeader(req, "ce-type");
329
- if (!(type === null || type === undefined ? undefined : type.startsWith(prefix))) {
329
+ if (!(type === null || type === void 0 ? void 0 : type.startsWith(prefix))) {
330
330
  return undefined;
331
331
  }
332
332
  if (type.startsWith(userPrefix)) {
@@ -440,7 +440,7 @@ function handleConnectErrorResponse(connectRequest, response, code, detail) {
440
440
  }
441
441
  else {
442
442
  response.statusCode = code;
443
- response.end(detail !== null && detail !== undefined ? detail : "");
443
+ response.end(detail !== null && detail !== void 0 ? detail : "");
444
444
  }
445
445
  }
446
446
  function isWebPubSubRequest(req) {
@@ -500,7 +500,7 @@ class CloudEventsDispatcher {
500
500
  if (Array.isArray(eventHandler)) {
501
501
  throw new Error("Unexpected WebPubSubEventHandlerOptions");
502
502
  }
503
- if ((eventHandler === null || eventHandler === undefined ? undefined : eventHandler.allowedEndpoints) !== undefined) {
503
+ if ((eventHandler === null || eventHandler === void 0 ? void 0 : eventHandler.allowedEndpoints) !== undefined) {
504
504
  this._allowedOrigins = eventHandler.allowedEndpoints.map((endpoint) => new node_url.URL(endpoint).host.toLowerCase());
505
505
  this._allowAll = false;
506
506
  }
@@ -540,14 +540,14 @@ class CloudEventsDispatcher {
540
540
  }
541
541
  // check if hub matches
542
542
  const hub = getHttpHeader(request, "ce-hub");
543
- if ((hub === null || hub === undefined ? undefined : hub.toUpperCase()) !== this.hub.toUpperCase()) {
543
+ if ((hub === null || hub === void 0 ? void 0 : hub.toUpperCase()) !== this.hub.toUpperCase()) {
544
544
  return false;
545
545
  }
546
546
  const isMqtt = isMqttRequest(request);
547
547
  // No need to read body if handler is not specified
548
548
  switch (eventType) {
549
549
  case EventType.Connect:
550
- if (!((_a = this.eventHandler) === null || _a === undefined ? undefined : _a.handleConnect)) {
550
+ if (!((_a = this.eventHandler) === null || _a === void 0 ? void 0 : _a.handleConnect)) {
551
551
  if (isMqtt)
552
552
  response.statusCode = 204;
553
553
  response.end();
@@ -555,19 +555,19 @@ class CloudEventsDispatcher {
555
555
  }
556
556
  break;
557
557
  case EventType.Connected:
558
- if (!((_b = this.eventHandler) === null || _b === undefined ? undefined : _b.onConnected)) {
558
+ if (!((_b = this.eventHandler) === null || _b === void 0 ? void 0 : _b.onConnected)) {
559
559
  response.end();
560
560
  return true;
561
561
  }
562
562
  break;
563
563
  case EventType.Disconnected:
564
- if (!((_c = this.eventHandler) === null || _c === undefined ? undefined : _c.onDisconnected)) {
564
+ if (!((_c = this.eventHandler) === null || _c === void 0 ? void 0 : _c.onDisconnected)) {
565
565
  response.end();
566
566
  return true;
567
567
  }
568
568
  break;
569
569
  case EventType.UserEvent:
570
- if (!((_d = this.eventHandler) === null || _d === undefined ? undefined : _d.handleUserEvent)) {
570
+ if (!((_d = this.eventHandler) === null || _d === void 0 ? void 0 : _d.handleUserEvent)) {
571
571
  response.end();
572
572
  return true;
573
573
  }
@@ -659,7 +659,7 @@ class WebPubSubEventHandler {
659
659
  constructor(hub, options) {
660
660
  var _a;
661
661
  this.hub = hub;
662
- const path = ((_a = options === null || options === undefined ? undefined : options.path) !== null && _a !== undefined ? _a : `/api/webpubsub/hubs/${hub}/`).toLowerCase();
662
+ const path = ((_a = options === null || options === void 0 ? void 0 : options.path) !== null && _a !== void 0 ? _a : `/api/webpubsub/hubs/${hub}/`).toLowerCase();
663
663
  this.path = path.endsWith("/") ? path : path + "/";
664
664
  this._cloudEventsHandler = new CloudEventsDispatcher(this.hub, options);
665
665
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/utils.ts","../../src/logger.ts","../../src/enum/MqttErrorCodes/mqttV311ConnectReturnCode.ts","../../src/enum/MqttErrorCodes/mqttV500ConnectReasonCode.ts","../../src/cloudEventsDispatcher.ts","../../src/webPubSubEventHandler.ts","../../src/enum/MqttErrorCodes/mqttDisconnectReasonCode.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IncomingMessage } from \"node:http\";\n\nfunction isJsonObject(obj: any): boolean {\n return obj && typeof obj === \"object\" && !Array.isArray(obj);\n}\n\nexport function toBase64JsonString(obj: Record<string, any>): string {\n return Buffer.from(JSON.stringify(obj)).toString(\"base64\");\n}\n\nexport function fromBase64JsonString(base64String: string | undefined): Record<string, any> {\n if (base64String === undefined) {\n return {};\n }\n\n try {\n const buf = Buffer.from(base64String, \"base64\").toString();\n const parsed = JSON.parse(buf);\n return isJsonObject(parsed) ? parsed : {};\n } catch (e: any) {\n console.warn(\"Unexpected state format:\" + e);\n return {};\n }\n}\n\nexport function getHttpHeader(req: IncomingMessage, key: string): string | undefined {\n if (!key) return undefined;\n\n // According to https://nodejs.org/api/http.html#http_class_http_incomingmessage, header names are always lower-cased\n const value = req.headers[key.toLowerCase()];\n\n if (value === undefined) {\n return undefined;\n }\n if (typeof value === \"string\") {\n return value;\n }\n\n return value[0];\n}\n\nexport function readRequestBody(req: IncomingMessage): Promise<Buffer> {\n return new Promise(function (resolve, reject) {\n const chunks: any = [];\n req.on(\"data\", function (chunk) {\n chunks.push(chunk);\n });\n req.on(\"end\", function () {\n const buffer = Buffer.concat(chunks);\n resolve(buffer);\n });\n // reject on request error\n req.on(\"error\", function (err) {\n // This is not a \"Second reject\", just a different sort of failure\n reject(err);\n });\n });\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createClientLogger } from \"@azure/logger\";\n\n/**\n * The \\@azure/logger configuration for this package.\n *\n * @internal\n */\nexport const logger = createClientLogger(\"web-pubsub-express\");\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * MQTT 3.1.1 Connect Return Codes.\n */\nexport enum MqttV311ConnectReturnCode {\n /**\n * 0x01: Connection refused, unacceptable protocol version\n * The Server does not support the level of the MQTT protocol requested by the Client.\n */\n UnacceptableProtocolVersion = 0x01,\n\n /**\n * 0x02: Connection refused, identifier rejected\n * The Client identifier is correct UTF-8 but not allowed by the Server.\n */\n IdentifierRejected = 0x02,\n\n /**\n * 0x03: Connection refused, server unavailable\n * The Network Connection has been made but the MQTT service is unavailable.\n */\n ServerUnavailable = 0x03,\n\n /**\n * 0x04: Connection refused, bad user name or password\n * The data in the user name or password is malformed.\n */\n BadUsernameOrPassword = 0x04,\n\n /**\n * 0x05: Connection refused, not authorized\n * The Client is not authorized to connect.\n */\n NotAuthorized = 0x05,\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * MQTT Connect Reason Codes\n * These codes represent the reasons for the outcome of an MQTT CONNECT packet as per MQTT 5.0 specification.\n */\nexport enum MqttV500ConnectReasonCode {\n /**\n * 0x80 - Unspecified error\n * Description: The Server does not wish to reveal the reason for the failure, or none of the other Reason Codes apply.\n */\n UnspecifiedError = 0x80,\n\n /**\n * 0x81 - Malformed Packet\n * Description: Data within the CONNECT packet could not be correctly parsed.\n */\n MalformedPacket = 0x81,\n\n /**\n * 0x82 - Protocol Error\n * Description: Data in the CONNECT packet does not conform to this specification.\n */\n ProtocolError = 0x82,\n\n /**\n * 0x83 - Implementation specific error\n * Description: The CONNECT is valid but is not accepted by this Server.\n */\n ImplementationSpecificError = 0x83,\n\n /**\n * 0x84 - Unsupported Protocol Version\n * Description: The Server does not support the version of the MQTT protocol requested by the Client.\n */\n UnsupportedProtocolVersion = 0x84,\n\n /**\n * 0x85 - Client Identifier not valid\n * Description: The Client Identifier is a valid string but is not allowed by the Server.\n */\n ClientIdentifierNotValid = 0x85,\n\n /**\n * 0x86 - Bad User Name or Password\n * Description: The Server does not accept the User Name or Password specified by the Client.\n */\n BadUserNameOrPassword = 0x86,\n\n /**\n * 0x87 - Not authorized\n * Description: The Client is not authorized to connect.\n */\n NotAuthorized = 0x87,\n\n /**\n * 0x88 - Server unavailable\n * Description: The MQTT Server is not available.\n */\n ServerUnavailable = 0x88,\n\n /**\n * 0x89 - Server busy\n * Description: The Server is busy. Try again later.\n */\n ServerBusy = 0x89,\n\n /**\n * 0x8A - Banned\n * Description: This Client has been banned by administrative action. Contact the server administrator.\n */\n Banned = 0x8a,\n\n /**\n * 0x8C - Bad authentication method\n * Description: The authentication method is not supported or does not match the authentication method currently in use.\n */\n BadAuthenticationMethod = 0x8c,\n\n /**\n * 0x90 - Topic Name invalid\n * Description: The Will Topic Name is not malformed, but is not accepted by this Server.\n */\n TopicNameInvalid = 0x90,\n\n /**\n * 0x95 - Packet too large\n * Description: The CONNECT packet exceeded the maximum permissible size.\n */\n PacketTooLarge = 0x95,\n\n /**\n * 0x97 - Quota exceeded\n * Description: An implementation or administrative imposed limit has been exceeded.\n */\n QuotaExceeded = 0x97,\n\n /**\n * 0x99 - Payload format invalid\n * Description: The Will Payload does not match the specified Payload Format Indicator.\n */\n PayloadFormatInvalid = 0x99,\n\n /**\n * 0x9A - Retain not supported\n * Description: The Server does not support retained messages, and Will Retain was set to 1.\n */\n RetainNotSupported = 0x9a,\n\n /**\n * 0x9B - QoS not supported\n * Description: The Server does not support the QoS set in Will QoS.\n */\n QosNotSupported = 0x9b,\n\n /**\n * 0x9C - Use another server\n * Description: The Client should temporarily use another server.\n */\n UseAnotherServer = 0x9c,\n\n /**\n * 0x9D - Server moved\n * Description: The Client should permanently use another server.\n */\n ServerMoved = 0x9d,\n\n /**\n * 0x9F - Connection rate exceeded\n * Description: The connection rate limit has been exceeded.\n */\n ConnectionRateExceeded = 0x9f,\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport * as utils from \"./utils.js\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport { URL } from \"node:url\";\nimport { logger } from \"./logger.js\";\n\nimport type {\n ConnectRequest,\n ConnectResponse,\n ConnectedRequest,\n ConnectionContext,\n ConnectResponseHandler,\n DisconnectedRequest,\n UserEventRequest,\n UserEventResponseHandler,\n WebPubSubEventHandlerOptions,\n MqttConnectRequest,\n MqttConnectErrorResponse,\n MqttConnectionContextProperties,\n ConnectErrorResponse,\n MqttDisconnectedRequest,\n} from \"./cloudEventsProtocols.js\";\nimport { MqttV311ConnectReturnCode } from \"./enum/MqttErrorCodes/mqttV311ConnectReturnCode.js\";\nimport { MqttV500ConnectReasonCode } from \"./enum/MqttErrorCodes/mqttV500ConnectReasonCode.js\";\n\nenum EventType {\n Connect,\n Connected,\n Disconnected,\n UserEvent,\n}\n\nfunction getConnectResponseHandler(\n connectRequest: ConnectRequest,\n response: ServerResponse,\n): ConnectResponseHandler {\n const states: Record<string, any> = connectRequest.context.states;\n let modified = false;\n const handler = {\n setState(name: string, value: unknown): void {\n states[name] = value;\n modified = true;\n },\n success(res?: ConnectResponse): void {\n if (modified) {\n response.setHeader(\"ce-connectionState\", utils.toBase64JsonString(states));\n }\n if (res === undefined) {\n response.statusCode = 204;\n response.end();\n } else {\n response.statusCode = 200;\n response.setHeader(\"Content-Type\", \"application/json; charset=utf-8\");\n response.end(JSON.stringify(res));\n }\n },\n fail(code: 400 | 401 | 500, detail?: string): void {\n handleConnectErrorResponse(connectRequest, response, code, detail);\n },\n failWith(res: ConnectErrorResponse | MqttConnectErrorResponse) {\n if (\"mqtt\" in res) {\n response.statusCode = getStatusCodeFromMqttConnectCode(res.mqtt.code);\n response.setHeader(\"Content-Type\", \"application/json; charset=utf-8\");\n response.end(JSON.stringify(res));\n } else {\n handleConnectErrorResponse(connectRequest, response, res.code, res.detail);\n }\n },\n };\n\n return handler;\n}\n\nfunction getUserEventResponseHandler(\n userRequest: UserEventRequest,\n response: ServerResponse,\n): UserEventResponseHandler {\n const states: Record<string, any> = userRequest.context.states;\n let modified = false;\n const handler = {\n setState(name: string, value: unknown): void {\n modified = true;\n states[name] = value;\n },\n success(data?: string | ArrayBuffer, dataType?: \"binary\" | \"text\" | \"json\"): void {\n response.statusCode = 200;\n if (modified) {\n response.setHeader(\"ce-connectionState\", utils.toBase64JsonString(states));\n }\n\n switch (dataType) {\n case \"json\":\n response.setHeader(\"Content-Type\", \"application/json; charset=utf-8\");\n break;\n case \"text\":\n response.setHeader(\"Content-Type\", \"text/plain; charset=utf-8\");\n break;\n default:\n response.setHeader(\"Content-Type\", \"application/octet-stream\");\n break;\n }\n response.end(data ?? \"\");\n },\n fail(code: 400 | 401 | 500, detail?: string): void {\n response.statusCode = code;\n response.end(detail ?? \"\");\n },\n };\n return handler;\n}\n\nfunction getContext(request: IncomingMessage, origin: string): ConnectionContext {\n const baseContext: ConnectionContext = {\n signature: utils.getHttpHeader(request, \"ce-signature\")!,\n userId: utils.getHttpHeader(request, \"ce-userid\"),\n hub: utils.getHttpHeader(request, \"ce-hub\")!,\n connectionId: utils.getHttpHeader(request, \"ce-connectionid\")!,\n eventName: utils.getHttpHeader(request, \"ce-eventname\")!,\n origin: origin,\n states: utils.fromBase64JsonString(utils.getHttpHeader(request, \"ce-connectionstate\")),\n clientProtocol: \"default\",\n };\n\n if (isMqttRequest(request)) {\n const mqttProperties: MqttConnectionContextProperties = {\n physicalConnectionId: utils.getHttpHeader(request, \"ce-physicalConnectionId\")!,\n sessionId: utils.getHttpHeader(request, \"ce-sessionId\"),\n };\n return {\n ...baseContext,\n clientProtocol: \"mqtt\",\n mqtt: mqttProperties,\n };\n } else {\n return baseContext;\n }\n}\n\nfunction tryGetWebPubSubEvent(req: IncomingMessage): EventType | undefined {\n // check ce-type to see if it is a valid WebPubSub CloudEvent request\n const prefix = \"azure.webpubsub.\";\n const connect = \"azure.webpubsub.sys.connect\";\n const connected = \"azure.webpubsub.sys.connected\";\n const disconnectd = \"azure.webpubsub.sys.disconnected\";\n const userPrefix = \"azure.webpubsub.user.\";\n const type = utils.getHttpHeader(req, \"ce-type\");\n if (!type?.startsWith(prefix)) {\n return undefined;\n }\n if (type.startsWith(userPrefix)) {\n return EventType.UserEvent;\n }\n switch (type) {\n case connect:\n return EventType.Connect;\n case connected:\n return EventType.Connected;\n case disconnectd:\n return EventType.Disconnected;\n default:\n return undefined;\n }\n}\n\nfunction getStatusCodeFromMqttConnectCode(\n mqttConnectCode: MqttV311ConnectReturnCode | MqttV500ConnectReasonCode,\n): number {\n if (mqttConnectCode < 0x80) {\n switch (mqttConnectCode) {\n case MqttV311ConnectReturnCode.UnacceptableProtocolVersion:\n case MqttV311ConnectReturnCode.IdentifierRejected:\n return 400; // BadRequest\n case MqttV311ConnectReturnCode.ServerUnavailable:\n return 503; // ServiceUnavailable\n case MqttV311ConnectReturnCode.BadUsernameOrPassword:\n case MqttV311ConnectReturnCode.NotAuthorized:\n return 401; // Unauthorized\n default:\n logger.warning(`Invalid MQTT connect return code: ${mqttConnectCode}.`);\n return 500; // InternalServerError\n }\n } else {\n switch (mqttConnectCode) {\n case MqttV500ConnectReasonCode.NotAuthorized:\n case MqttV500ConnectReasonCode.BadUserNameOrPassword:\n return 401; // Unauthorized\n case MqttV500ConnectReasonCode.ClientIdentifierNotValid:\n case MqttV500ConnectReasonCode.MalformedPacket:\n case MqttV500ConnectReasonCode.UnsupportedProtocolVersion:\n case MqttV500ConnectReasonCode.BadAuthenticationMethod:\n case MqttV500ConnectReasonCode.TopicNameInvalid:\n case MqttV500ConnectReasonCode.PayloadFormatInvalid:\n case MqttV500ConnectReasonCode.ImplementationSpecificError:\n case MqttV500ConnectReasonCode.PacketTooLarge:\n case MqttV500ConnectReasonCode.RetainNotSupported:\n case MqttV500ConnectReasonCode.QosNotSupported:\n return 400; // BadRequest\n case MqttV500ConnectReasonCode.QuotaExceeded:\n case MqttV500ConnectReasonCode.ConnectionRateExceeded:\n return 429; // TooManyRequests\n case MqttV500ConnectReasonCode.Banned:\n return 403; // Forbidden\n case MqttV500ConnectReasonCode.UseAnotherServer:\n case MqttV500ConnectReasonCode.ServerMoved:\n case MqttV500ConnectReasonCode.ServerUnavailable:\n case MqttV500ConnectReasonCode.ServerBusy:\n case MqttV500ConnectReasonCode.UnspecifiedError:\n return 500; // InternalServerError\n default:\n logger.warning(`Invalid MQTT connect return code: ${mqttConnectCode}.`);\n return 500; // InternalServerError\n }\n }\n}\n\nfunction getMqttConnectCodeFromStatusCode(\n statusCode: 400 | 401 | 500,\n protocolVersion: number,\n): MqttV311ConnectReturnCode | MqttV500ConnectReasonCode {\n if (protocolVersion === 4) {\n switch (statusCode) {\n case 400:\n return MqttV311ConnectReturnCode.BadUsernameOrPassword;\n case 401:\n return MqttV311ConnectReturnCode.NotAuthorized;\n case 500:\n return MqttV311ConnectReturnCode.ServerUnavailable;\n default:\n logger.warning(`Unsupported HTTP Status Code: ${statusCode}.`);\n return MqttV311ConnectReturnCode.ServerUnavailable;\n }\n } else if (protocolVersion === 5) {\n switch (statusCode) {\n case 400:\n return MqttV500ConnectReasonCode.BadUserNameOrPassword;\n case 401:\n return MqttV500ConnectReasonCode.NotAuthorized;\n case 500:\n return MqttV500ConnectReasonCode.UnspecifiedError;\n default:\n logger.warning(`Unsupported HTTP Status Code: ${statusCode}.`);\n return MqttV500ConnectReasonCode.UnspecifiedError;\n }\n } else {\n logger.warning(`Invalid MQTT protocol version: ${protocolVersion}.`);\n return MqttV311ConnectReturnCode.UnacceptableProtocolVersion;\n }\n}\n\nfunction handleConnectErrorResponse(\n connectRequest: ConnectRequest,\n response: ServerResponse,\n code: 400 | 401 | 500,\n detail?: string,\n): void {\n const isMqttReq = connectRequest.context.clientProtocol === \"mqtt\";\n if (isMqttReq) {\n const protocolVersion = (connectRequest as MqttConnectRequest).mqtt.protocolVersion;\n const mqttErrorResponse: MqttConnectErrorResponse = {\n mqtt: {\n code: getMqttConnectCodeFromStatusCode(code, protocolVersion),\n reason: detail,\n },\n };\n response.statusCode = code;\n response.setHeader(\"Content-Type\", \"application/json; charset=utf-8\");\n response.end(JSON.stringify(mqttErrorResponse));\n } else {\n response.statusCode = code;\n response.end(detail ?? \"\");\n }\n}\n\nfunction isWebPubSubRequest(req: IncomingMessage): boolean {\n return utils.getHttpHeader(req, \"ce-awpsversion\") !== undefined;\n}\n\nfunction isMqttRequest(req: IncomingMessage): boolean {\n const subprotocol = utils.getHttpHeader(req, \"ce-subprotocol\");\n const physicalConnectionId = utils.getHttpHeader(req, \"ce-physicalConnectionId\");\n return (\n subprotocol !== undefined &&\n subprotocol.toLowerCase().includes(\"mqtt\") &&\n physicalConnectionId !== undefined\n );\n}\n\nasync function readUserEventRequest(\n request: IncomingMessage,\n origin: string,\n): Promise<UserEventRequest | undefined> {\n const contentTypeheader = utils.getHttpHeader(request, \"content-type\");\n if (contentTypeheader === undefined) {\n return undefined;\n }\n\n const contentType = contentTypeheader.split(\";\")[0].trim();\n\n switch (contentType) {\n case \"application/octet-stream\":\n return {\n context: getContext(request, origin),\n data: await utils.readRequestBody(request),\n dataType: \"binary\",\n };\n case \"application/json\":\n return {\n context: getContext(request, origin),\n data: JSON.parse((await utils.readRequestBody(request)).toString()),\n dataType: \"json\",\n };\n case \"text/plain\":\n return {\n context: getContext(request, origin),\n data: (await utils.readRequestBody(request)).toString(),\n dataType: \"text\",\n };\n default:\n return undefined;\n }\n}\n\nasync function readSystemEventRequest<T extends { context: ConnectionContext }>(\n request: IncomingMessage,\n origin: string,\n): Promise<T> {\n const body = (await utils.readRequestBody(request)).toString();\n const parsedRequest = JSON.parse(body) as T;\n parsedRequest.context = getContext(request, origin);\n return parsedRequest;\n}\n\n/**\n * @internal\n */\nexport class CloudEventsDispatcher {\n private readonly _allowAll: boolean = true;\n private readonly _allowedOrigins: Array<string> = [];\n constructor(\n private hub: string,\n private eventHandler?: WebPubSubEventHandlerOptions,\n ) {\n if (Array.isArray(eventHandler)) {\n throw new Error(\"Unexpected WebPubSubEventHandlerOptions\");\n }\n if (eventHandler?.allowedEndpoints !== undefined) {\n this._allowedOrigins = eventHandler.allowedEndpoints.map((endpoint) =>\n new URL(endpoint).host.toLowerCase(),\n );\n this._allowAll = false;\n }\n }\n\n public handlePreflight(req: IncomingMessage, res: ServerResponse): boolean {\n if (!isWebPubSubRequest(req)) {\n return false;\n }\n const origin = utils.getHttpHeader(req, \"webhook-request-origin\");\n\n if (origin === undefined) {\n logger.warning(\"Expecting webhook-request-origin header.\");\n res.statusCode = 400;\n } else if (this._allowAll) {\n res.setHeader(\"WebHook-Allowed-Origin\", \"*\");\n } else {\n // service to do the check\n res.setHeader(\"WebHook-Allowed-Origin\", this._allowedOrigins);\n }\n\n res.end();\n return true;\n }\n\n public async handleRequest(request: IncomingMessage, response: ServerResponse): Promise<boolean> {\n if (!isWebPubSubRequest(request)) {\n return false;\n }\n\n // check if it is a valid WebPubSub cloud events\n const origin = utils.getHttpHeader(request, \"webhook-request-origin\");\n if (origin === undefined) {\n return false;\n }\n\n const eventType = tryGetWebPubSubEvent(request);\n if (eventType === undefined) {\n return false;\n }\n\n // check if hub matches\n const hub = utils.getHttpHeader(request, \"ce-hub\");\n if (hub?.toUpperCase() !== this.hub.toUpperCase()) {\n return false;\n }\n\n const isMqtt = isMqttRequest(request);\n // No need to read body if handler is not specified\n switch (eventType) {\n case EventType.Connect:\n if (!this.eventHandler?.handleConnect) {\n if (isMqtt) response.statusCode = 204;\n response.end();\n return true;\n }\n break;\n case EventType.Connected:\n if (!this.eventHandler?.onConnected) {\n response.end();\n return true;\n }\n break;\n case EventType.Disconnected:\n if (!this.eventHandler?.onDisconnected) {\n response.end();\n return true;\n }\n break;\n case EventType.UserEvent:\n if (!this.eventHandler?.handleUserEvent) {\n response.end();\n return true;\n }\n break;\n default:\n logger.warning(`Unknown EventType ${eventType}`);\n return false;\n }\n\n switch (eventType) {\n case EventType.Connect: {\n const connectRequest = isMqtt\n ? await readSystemEventRequest<MqttConnectRequest>(request, origin)\n : await readSystemEventRequest<ConnectRequest>(request, origin);\n // service passes out query property, assign it to queries\n connectRequest.queries = connectRequest.query;\n logger.verbose(connectRequest);\n this.eventHandler.handleConnect!(\n connectRequest,\n getConnectResponseHandler(connectRequest, response),\n );\n return true;\n }\n case EventType.Connected: {\n // for unblocking events, we responds to the service as early as possible\n response.end();\n const connectedRequest = await readSystemEventRequest<ConnectedRequest>(request, origin);\n logger.verbose(connectedRequest);\n this.eventHandler.onConnected!(connectedRequest);\n return true;\n }\n case EventType.Disconnected: {\n // for unblocking events, we responds to the service as early as possible\n response.end();\n const disconnectedRequest = isMqtt\n ? await readSystemEventRequest<MqttDisconnectedRequest>(request, origin)\n : await readSystemEventRequest<DisconnectedRequest>(request, origin);\n logger.verbose(disconnectedRequest);\n this.eventHandler.onDisconnected!(disconnectedRequest);\n return true;\n }\n case EventType.UserEvent: {\n const userRequest = await readUserEventRequest(request, origin);\n if (userRequest === undefined) {\n logger.warning(\n `Unsupported content type ${utils.getHttpHeader(request, \"content-type\")}`,\n );\n return false;\n }\n logger.verbose(userRequest);\n this.eventHandler.handleUserEvent!(\n userRequest,\n getUserEventResponseHandler(userRequest, response),\n );\n return true;\n }\n default:\n logger.warning(`Unknown EventType ${eventType}`);\n return false;\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type express from \"express-serve-static-core\";\n\nimport { CloudEventsDispatcher } from \"./cloudEventsDispatcher.js\";\nimport type { WebPubSubEventHandlerOptions } from \"./cloudEventsProtocols.js\";\n\n/**\n * The handler to handle incoming CloudEvents messages\n */\nexport class WebPubSubEventHandler {\n /**\n * The path this CloudEvents handler listens to\n */\n public readonly path: string;\n\n private _cloudEventsHandler: CloudEventsDispatcher;\n\n /**\n * Creates an instance of a WebPubSubEventHandler for handling incoming CloudEvents messages.\n *\n * Example usage:\n * ```ts\n * import express from \"express\";\n * import { WebPubSubEventHandler } from \"@azure/web-pubsub-express\";\n * const endpoint = \"https://xxxx.webpubsubdev.azure.com\"\n * const handler = new WebPubSubEventHandler('chat', {\n * handleConnect: (req, res) => {\n * console.log(JSON.stringify(req));\n * return {};\n * },\n * onConnected: req => {\n * console.log(JSON.stringify(req));\n * },\n * handleUserEvent: (req, res) => {\n * console.log(JSON.stringify(req));\n * res.success(\"Hey \" + req.data, req.dataType);\n * };\n * allowedEndpoints: [ endpoint ]\n * },\n * });\n * ```\n *\n * @param hub - The name of the hub to listen to\n * @param options - Options to configure the event handler\n */\n constructor(\n private hub: string,\n options?: WebPubSubEventHandlerOptions,\n ) {\n const path = (options?.path ?? `/api/webpubsub/hubs/${hub}/`).toLowerCase();\n this.path = path.endsWith(\"/\") ? path : path + \"/\";\n this._cloudEventsHandler = new CloudEventsDispatcher(this.hub, options);\n }\n\n /**\n * Get the middleware to process the CloudEvents requests\n */\n public getMiddleware(): express.RequestHandler {\n return async (\n req: express.Request,\n res: express.Response,\n next: express.NextFunction,\n ): Promise<void> => {\n // Request originalUrl can contain query while baseUrl + path not\n let requestUrl = (req.baseUrl + req.path).toLowerCase();\n\n // normalize the Url\n requestUrl = requestUrl.endsWith(\"/\") ? requestUrl : requestUrl + \"/\";\n if (requestUrl.startsWith(this.path)) {\n if (req.method === \"OPTIONS\") {\n if (this._cloudEventsHandler.handlePreflight(req, res)) {\n return;\n }\n } else if (req.method === \"POST\") {\n try {\n if (await this._cloudEventsHandler.handleRequest(req, res)) {\n return;\n }\n } catch (err: any) {\n next(err);\n return;\n }\n }\n }\n\n next();\n };\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * MQTT 5.0 Disconnect Reason Codes.\n */\nexport enum MqttDisconnectReasonCode {\n /**\n * 0x00 - Normal disconnection\n * Sent by: Client or Server\n * Description: Close the connection normally. Do not send the Will Message.\n */\n NormalDisconnection = 0x00,\n\n /**\n * 0x04 - Disconnect with Will Message\n * Sent by: Client\n * Description: The Client wishes to disconnect but requires that the Server also publishes its Will Message.\n */\n DisconnectWithWillMessage = 0x04,\n\n /**\n * 0x80 - Unspecified error\n * Sent by: Client or Server\n * Description: The Connection is closed but the sender either does not wish to reveal the reason, or none of the other Reason Codes apply.\n */\n UnspecifiedError = 0x80,\n\n /**\n * 0x81 - Malformed Packet\n * Sent by: Client or Server\n * Description: The received packet does not conform to this specification.\n */\n MalformedPacket = 0x81,\n\n /**\n * 0x82 - Protocol Error\n * Sent by: Client or Server\n * Description: An unexpected or out of order packet was received.\n */\n ProtocolError = 0x82,\n\n /**\n * 0x83 - Implementation specific error\n * Sent by: Client or Server\n * Description: The packet received is valid but cannot be processed by this implementation.\n */\n ImplementationSpecificError = 0x83,\n\n /**\n * 0x87 - Not authorized\n * Sent by: Server\n * Description: The request is not authorized.\n */\n NotAuthorized = 0x87,\n\n /**\n * 0x89 - Server busy\n * Sent by: Server\n * Description: The Server is busy and cannot continue processing requests from this Client.\n */\n ServerBusy = 0x89,\n\n /**\n * 0x8B - Server shutting down\n * Sent by: Server\n * Description: The Server is shutting down.\n */\n ServerShuttingDown = 0x8b,\n\n /**\n * 0x8D - Keep Alive timeout\n * Sent by: Server\n * Description: The Connection is closed because no packet has been received for 1.5 times the Keepalive time.\n */\n KeepAliveTimeout = 0x8d,\n\n /**\n * 0x8E - Session taken over\n * Sent by: Server\n * Description: Another Connection using the same ClientID has connected causing this Connection to be closed.\n */\n SessionTakenOver = 0x8e,\n\n /**\n * 0x8F - Topic Filter invalid\n * Sent by: Server\n * Description: The Topic Filter is correctly formed, but is not accepted by this Server.\n */\n TopicFilterInvalid = 0x8f,\n\n /**\n * 0x90 - Topic Name invalid\n * Sent by: Client or Server\n * Description: The Topic Name is correctly formed, but is not accepted by this Client or Server.\n */\n TopicNameInvalid = 0x90,\n\n /**\n * 0x93 - Receive Maximum exceeded\n * Sent by: Client or Server\n * Description: The Client or Server has received more than Receive Maximum publication for which it has not sent PUBACK or PUBCOMP.\n */\n ReceiveMaximumExceeded = 0x93,\n\n /**\n * 0x94 - Topic Alias invalid\n * Sent by: Client or Server\n * Description: The Client or Server has received a PUBLISH packet containing a Topic Alias which is greater than the Maximum Topic Alias it sent in the CONNECT or CONNACK packet.\n */\n TopicAliasInvalid = 0x94,\n\n /**\n * 0x95 - Packet too large\n * Sent by: Client or Server\n * Description: The packet size is greater than Maximum Packet Size for this Client or Server.\n */\n PacketTooLarge = 0x95,\n\n /**\n * 0x96 - Message rate too high\n * Sent by: Client or Server\n * Description: The received data rate is too high.\n */\n MessageRateTooHigh = 0x96,\n\n /**\n * 0x97 - Quota exceeded\n * Sent by: Client or Server\n * Description: An implementation or administrative imposed limit has been exceeded.\n */\n QuotaExceeded = 0x97,\n\n /**\n * 0x98 - Administrative action\n * Sent by: Client or Server\n * Description: The Connection is closed due to an administrative action.\n */\n AdministrativeAction = 0x98,\n\n /**\n * 0x99 - Payload format invalid\n * Sent by: Client or Server\n * Description: The payload format does not match the one specified by the Payload Format Indicator.\n */\n PayloadFormatInvalid = 0x99,\n\n /**\n * 0x9A - Retain not supported\n * Sent by: Server\n * Description: The Server does not support retained messages.\n */\n RetainNotSupported = 0x9a,\n\n /**\n * 0x9B - QoS not supported\n * Sent by: Server\n * Description: The Client specified a QoS greater than the QoS specified in a Maximum QoS in the CONNACK.\n */\n QosNotSupported = 0x9b,\n\n /**\n * 0x9C - Use another server\n * Sent by: Server\n * Description: The Client should temporarily change its Server.\n */\n UseAnotherServer = 0x9c,\n\n /**\n * 0x9D - Server moved\n * Sent by: Server\n * Description: The Server is moved and the Client should permanently change its server location.\n */\n ServerMoved = 0x9d,\n\n /**\n * 0x9E - Shared Subscriptions not supported\n * Sent by: Server\n * Description: The Server does not support Shared Subscriptions.\n */\n SharedSubscriptionsNotSupported = 0x9e,\n\n /**\n * 0x9F - Connection rate exceeded\n * Sent by: Server\n * Description: This connection is closed because the connection rate is too high.\n */\n ConnectionRateExceeded = 0x9f,\n\n /**\n * 0xA0 - Maximum connect time\n * Sent by: Server\n * Description: The maximum connection time authorized for this connection has been exceeded.\n */\n MaximumConnectTime = 0xa0,\n\n /**\n * 0xA1 - Subscription Identifiers not supported\n * Sent by: Server\n * Description: The Server does not support Subscription Identifiers; the subscription is not accepted.\n */\n SubscriptionIdentifiersNotSupported = 0xa1,\n\n /**\n * 0xA2 - Wildcard Subscriptions not supported\n * Sent by: Server\n * Description: The Server does not support Wildcard Subscriptions; the subscription is not accepted.\n */\n WildcardSubscriptionsNotSupported = 0xa2,\n}\n"],"names":["createClientLogger","MqttV311ConnectReturnCode","MqttV500ConnectReasonCode","utils.toBase64JsonString","utils.getHttpHeader","utils.fromBase64JsonString","utils.readRequestBody","URL","MqttDisconnectReasonCode"],"mappings":";;;;;;;AAAA;AACA;AAIA,SAAS,YAAY,CAAC,GAAQ,EAAA;AAC5B,IAAA,OAAO,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;AAC9D;AAEM,SAAU,kBAAkB,CAAC,GAAwB,EAAA;AACzD,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;AAC5D;AAEM,SAAU,oBAAoB,CAAC,YAAgC,EAAA;AACnE,IAAA,IAAI,YAAY,KAAK,SAAS,EAAE;AAC9B,QAAA,OAAO,EAAE;;AAGX,IAAA,IAAI;AACF,QAAA,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE;QAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;AAC9B,QAAA,OAAO,YAAY,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,EAAE;;IACzC,OAAO,CAAM,EAAE;AAC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AAA,CAAA,GAAA,oBAAyB;AAEzB;;;;AAIG;AACH,IAAA,wBAAA,CAAA,wBAAA,CAAA,qCAAA,CAAA,GAAA,GAAA,CAAA,GAAA,qCAA0C;AAE1C;;;;AAIG;AACH,IAAA,wBAAA,CAAA,wBAAA,CAAA,mCAAA,CAAA,GAAA,GAAA,CAAA,GAAA,mCAAwC;AAC1C,CAAC,EA3MWA,gCAAwB,KAAxBA,gCAAwB,GA2MnC,EAAA,CAAA,CAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/utils.ts","../../src/logger.ts","../../src/enum/MqttErrorCodes/mqttV311ConnectReturnCode.ts","../../src/enum/MqttErrorCodes/mqttV500ConnectReasonCode.ts","../../src/cloudEventsDispatcher.ts","../../src/webPubSubEventHandler.ts","../../src/enum/MqttErrorCodes/mqttDisconnectReasonCode.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { IncomingMessage } from \"node:http\";\n\nfunction isJsonObject(obj: any): boolean {\n return obj && typeof obj === \"object\" && !Array.isArray(obj);\n}\n\nexport function toBase64JsonString(obj: Record<string, any>): string {\n return Buffer.from(JSON.stringify(obj)).toString(\"base64\");\n}\n\nexport function fromBase64JsonString(base64String: string | undefined): Record<string, any> {\n if (base64String === undefined) {\n return {};\n }\n\n try {\n const buf = Buffer.from(base64String, \"base64\").toString();\n const parsed = JSON.parse(buf);\n return isJsonObject(parsed) ? parsed : {};\n } catch (e: any) {\n console.warn(\"Unexpected state format:\" + e);\n return {};\n }\n}\n\nexport function getHttpHeader(req: IncomingMessage, key: string): string | undefined {\n if (!key) return undefined;\n\n // According to https://nodejs.org/api/http.html#http_class_http_incomingmessage, header names are always lower-cased\n const value = req.headers[key.toLowerCase()];\n\n if (value === undefined) {\n return undefined;\n }\n if (typeof value === \"string\") {\n return value;\n }\n\n return value[0];\n}\n\nexport function readRequestBody(req: IncomingMessage): Promise<Buffer> {\n return new Promise(function (resolve, reject) {\n const chunks: any = [];\n req.on(\"data\", function (chunk) {\n chunks.push(chunk);\n });\n req.on(\"end\", function () {\n const buffer = Buffer.concat(chunks);\n resolve(buffer);\n });\n // reject on request error\n req.on(\"error\", function (err) {\n // This is not a \"Second reject\", just a different sort of failure\n reject(err);\n });\n });\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createClientLogger } from \"@azure/logger\";\n\n/**\n * The \\@azure/logger configuration for this package.\n *\n * @internal\n */\nexport const logger = createClientLogger(\"web-pubsub-express\");\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * MQTT 3.1.1 Connect Return Codes.\n */\nexport enum MqttV311ConnectReturnCode {\n /**\n * 0x01: Connection refused, unacceptable protocol version\n * The Server does not support the level of the MQTT protocol requested by the Client.\n */\n UnacceptableProtocolVersion = 0x01,\n\n /**\n * 0x02: Connection refused, identifier rejected\n * The Client identifier is correct UTF-8 but not allowed by the Server.\n */\n IdentifierRejected = 0x02,\n\n /**\n * 0x03: Connection refused, server unavailable\n * The Network Connection has been made but the MQTT service is unavailable.\n */\n ServerUnavailable = 0x03,\n\n /**\n * 0x04: Connection refused, bad user name or password\n * The data in the user name or password is malformed.\n */\n BadUsernameOrPassword = 0x04,\n\n /**\n * 0x05: Connection refused, not authorized\n * The Client is not authorized to connect.\n */\n NotAuthorized = 0x05,\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * MQTT Connect Reason Codes\n * These codes represent the reasons for the outcome of an MQTT CONNECT packet as per MQTT 5.0 specification.\n */\nexport enum MqttV500ConnectReasonCode {\n /**\n * 0x80 - Unspecified error\n * Description: The Server does not wish to reveal the reason for the failure, or none of the other Reason Codes apply.\n */\n UnspecifiedError = 0x80,\n\n /**\n * 0x81 - Malformed Packet\n * Description: Data within the CONNECT packet could not be correctly parsed.\n */\n MalformedPacket = 0x81,\n\n /**\n * 0x82 - Protocol Error\n * Description: Data in the CONNECT packet does not conform to this specification.\n */\n ProtocolError = 0x82,\n\n /**\n * 0x83 - Implementation specific error\n * Description: The CONNECT is valid but is not accepted by this Server.\n */\n ImplementationSpecificError = 0x83,\n\n /**\n * 0x84 - Unsupported Protocol Version\n * Description: The Server does not support the version of the MQTT protocol requested by the Client.\n */\n UnsupportedProtocolVersion = 0x84,\n\n /**\n * 0x85 - Client Identifier not valid\n * Description: The Client Identifier is a valid string but is not allowed by the Server.\n */\n ClientIdentifierNotValid = 0x85,\n\n /**\n * 0x86 - Bad User Name or Password\n * Description: The Server does not accept the User Name or Password specified by the Client.\n */\n BadUserNameOrPassword = 0x86,\n\n /**\n * 0x87 - Not authorized\n * Description: The Client is not authorized to connect.\n */\n NotAuthorized = 0x87,\n\n /**\n * 0x88 - Server unavailable\n * Description: The MQTT Server is not available.\n */\n ServerUnavailable = 0x88,\n\n /**\n * 0x89 - Server busy\n * Description: The Server is busy. Try again later.\n */\n ServerBusy = 0x89,\n\n /**\n * 0x8A - Banned\n * Description: This Client has been banned by administrative action. Contact the server administrator.\n */\n Banned = 0x8a,\n\n /**\n * 0x8C - Bad authentication method\n * Description: The authentication method is not supported or does not match the authentication method currently in use.\n */\n BadAuthenticationMethod = 0x8c,\n\n /**\n * 0x90 - Topic Name invalid\n * Description: The Will Topic Name is not malformed, but is not accepted by this Server.\n */\n TopicNameInvalid = 0x90,\n\n /**\n * 0x95 - Packet too large\n * Description: The CONNECT packet exceeded the maximum permissible size.\n */\n PacketTooLarge = 0x95,\n\n /**\n * 0x97 - Quota exceeded\n * Description: An implementation or administrative imposed limit has been exceeded.\n */\n QuotaExceeded = 0x97,\n\n /**\n * 0x99 - Payload format invalid\n * Description: The Will Payload does not match the specified Payload Format Indicator.\n */\n PayloadFormatInvalid = 0x99,\n\n /**\n * 0x9A - Retain not supported\n * Description: The Server does not support retained messages, and Will Retain was set to 1.\n */\n RetainNotSupported = 0x9a,\n\n /**\n * 0x9B - QoS not supported\n * Description: The Server does not support the QoS set in Will QoS.\n */\n QosNotSupported = 0x9b,\n\n /**\n * 0x9C - Use another server\n * Description: The Client should temporarily use another server.\n */\n UseAnotherServer = 0x9c,\n\n /**\n * 0x9D - Server moved\n * Description: The Client should permanently use another server.\n */\n ServerMoved = 0x9d,\n\n /**\n * 0x9F - Connection rate exceeded\n * Description: The connection rate limit has been exceeded.\n */\n ConnectionRateExceeded = 0x9f,\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport * as utils from \"./utils.js\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport { URL } from \"node:url\";\nimport { logger } from \"./logger.js\";\n\nimport type {\n ConnectRequest,\n ConnectResponse,\n ConnectedRequest,\n ConnectionContext,\n ConnectResponseHandler,\n DisconnectedRequest,\n UserEventRequest,\n UserEventResponseHandler,\n WebPubSubEventHandlerOptions,\n MqttConnectRequest,\n MqttConnectErrorResponse,\n MqttConnectionContextProperties,\n ConnectErrorResponse,\n MqttDisconnectedRequest,\n} from \"./cloudEventsProtocols.js\";\nimport { MqttV311ConnectReturnCode } from \"./enum/MqttErrorCodes/mqttV311ConnectReturnCode.js\";\nimport { MqttV500ConnectReasonCode } from \"./enum/MqttErrorCodes/mqttV500ConnectReasonCode.js\";\n\nenum EventType {\n Connect,\n Connected,\n Disconnected,\n UserEvent,\n}\n\nfunction getConnectResponseHandler(\n connectRequest: ConnectRequest,\n response: ServerResponse,\n): ConnectResponseHandler {\n const states: Record<string, any> = connectRequest.context.states;\n let modified = false;\n const handler = {\n setState(name: string, value: unknown): void {\n states[name] = value;\n modified = true;\n },\n success(res?: ConnectResponse): void {\n if (modified) {\n response.setHeader(\"ce-connectionState\", utils.toBase64JsonString(states));\n }\n if (res === undefined) {\n response.statusCode = 204;\n response.end();\n } else {\n response.statusCode = 200;\n response.setHeader(\"Content-Type\", \"application/json; charset=utf-8\");\n response.end(JSON.stringify(res));\n }\n },\n fail(code: 400 | 401 | 500, detail?: string): void {\n handleConnectErrorResponse(connectRequest, response, code, detail);\n },\n failWith(res: ConnectErrorResponse | MqttConnectErrorResponse) {\n if (\"mqtt\" in res) {\n response.statusCode = getStatusCodeFromMqttConnectCode(res.mqtt.code);\n response.setHeader(\"Content-Type\", \"application/json; charset=utf-8\");\n response.end(JSON.stringify(res));\n } else {\n handleConnectErrorResponse(connectRequest, response, res.code, res.detail);\n }\n },\n };\n\n return handler;\n}\n\nfunction getUserEventResponseHandler(\n userRequest: UserEventRequest,\n response: ServerResponse,\n): UserEventResponseHandler {\n const states: Record<string, any> = userRequest.context.states;\n let modified = false;\n const handler = {\n setState(name: string, value: unknown): void {\n modified = true;\n states[name] = value;\n },\n success(data?: string | ArrayBuffer, dataType?: \"binary\" | \"text\" | \"json\"): void {\n response.statusCode = 200;\n if (modified) {\n response.setHeader(\"ce-connectionState\", utils.toBase64JsonString(states));\n }\n\n switch (dataType) {\n case \"json\":\n response.setHeader(\"Content-Type\", \"application/json; charset=utf-8\");\n break;\n case \"text\":\n response.setHeader(\"Content-Type\", \"text/plain; charset=utf-8\");\n break;\n default:\n response.setHeader(\"Content-Type\", \"application/octet-stream\");\n break;\n }\n response.end(data ?? \"\");\n },\n fail(code: 400 | 401 | 500, detail?: string): void {\n response.statusCode = code;\n response.end(detail ?? \"\");\n },\n };\n return handler;\n}\n\nfunction getContext(request: IncomingMessage, origin: string): ConnectionContext {\n const baseContext: ConnectionContext = {\n signature: utils.getHttpHeader(request, \"ce-signature\")!,\n userId: utils.getHttpHeader(request, \"ce-userid\"),\n hub: utils.getHttpHeader(request, \"ce-hub\")!,\n connectionId: utils.getHttpHeader(request, \"ce-connectionid\")!,\n eventName: utils.getHttpHeader(request, \"ce-eventname\")!,\n origin: origin,\n states: utils.fromBase64JsonString(utils.getHttpHeader(request, \"ce-connectionstate\")),\n clientProtocol: \"default\",\n };\n\n if (isMqttRequest(request)) {\n const mqttProperties: MqttConnectionContextProperties = {\n physicalConnectionId: utils.getHttpHeader(request, \"ce-physicalConnectionId\")!,\n sessionId: utils.getHttpHeader(request, \"ce-sessionId\"),\n };\n return {\n ...baseContext,\n clientProtocol: \"mqtt\",\n mqtt: mqttProperties,\n };\n } else {\n return baseContext;\n }\n}\n\nfunction tryGetWebPubSubEvent(req: IncomingMessage): EventType | undefined {\n // check ce-type to see if it is a valid WebPubSub CloudEvent request\n const prefix = \"azure.webpubsub.\";\n const connect = \"azure.webpubsub.sys.connect\";\n const connected = \"azure.webpubsub.sys.connected\";\n const disconnectd = \"azure.webpubsub.sys.disconnected\";\n const userPrefix = \"azure.webpubsub.user.\";\n const type = utils.getHttpHeader(req, \"ce-type\");\n if (!type?.startsWith(prefix)) {\n return undefined;\n }\n if (type.startsWith(userPrefix)) {\n return EventType.UserEvent;\n }\n switch (type) {\n case connect:\n return EventType.Connect;\n case connected:\n return EventType.Connected;\n case disconnectd:\n return EventType.Disconnected;\n default:\n return undefined;\n }\n}\n\nfunction getStatusCodeFromMqttConnectCode(\n mqttConnectCode: MqttV311ConnectReturnCode | MqttV500ConnectReasonCode,\n): number {\n if (mqttConnectCode < 0x80) {\n switch (mqttConnectCode) {\n case MqttV311ConnectReturnCode.UnacceptableProtocolVersion:\n case MqttV311ConnectReturnCode.IdentifierRejected:\n return 400; // BadRequest\n case MqttV311ConnectReturnCode.ServerUnavailable:\n return 503; // ServiceUnavailable\n case MqttV311ConnectReturnCode.BadUsernameOrPassword:\n case MqttV311ConnectReturnCode.NotAuthorized:\n return 401; // Unauthorized\n default:\n logger.warning(`Invalid MQTT connect return code: ${mqttConnectCode}.`);\n return 500; // InternalServerError\n }\n } else {\n switch (mqttConnectCode) {\n case MqttV500ConnectReasonCode.NotAuthorized:\n case MqttV500ConnectReasonCode.BadUserNameOrPassword:\n return 401; // Unauthorized\n case MqttV500ConnectReasonCode.ClientIdentifierNotValid:\n case MqttV500ConnectReasonCode.MalformedPacket:\n case MqttV500ConnectReasonCode.UnsupportedProtocolVersion:\n case MqttV500ConnectReasonCode.BadAuthenticationMethod:\n case MqttV500ConnectReasonCode.TopicNameInvalid:\n case MqttV500ConnectReasonCode.PayloadFormatInvalid:\n case MqttV500ConnectReasonCode.ImplementationSpecificError:\n case MqttV500ConnectReasonCode.PacketTooLarge:\n case MqttV500ConnectReasonCode.RetainNotSupported:\n case MqttV500ConnectReasonCode.QosNotSupported:\n return 400; // BadRequest\n case MqttV500ConnectReasonCode.QuotaExceeded:\n case MqttV500ConnectReasonCode.ConnectionRateExceeded:\n return 429; // TooManyRequests\n case MqttV500ConnectReasonCode.Banned:\n return 403; // Forbidden\n case MqttV500ConnectReasonCode.UseAnotherServer:\n case MqttV500ConnectReasonCode.ServerMoved:\n case MqttV500ConnectReasonCode.ServerUnavailable:\n case MqttV500ConnectReasonCode.ServerBusy:\n case MqttV500ConnectReasonCode.UnspecifiedError:\n return 500; // InternalServerError\n default:\n logger.warning(`Invalid MQTT connect return code: ${mqttConnectCode}.`);\n return 500; // InternalServerError\n }\n }\n}\n\nfunction getMqttConnectCodeFromStatusCode(\n statusCode: 400 | 401 | 500,\n protocolVersion: number,\n): MqttV311ConnectReturnCode | MqttV500ConnectReasonCode {\n if (protocolVersion === 4) {\n switch (statusCode) {\n case 400:\n return MqttV311ConnectReturnCode.BadUsernameOrPassword;\n case 401:\n return MqttV311ConnectReturnCode.NotAuthorized;\n case 500:\n return MqttV311ConnectReturnCode.ServerUnavailable;\n default:\n logger.warning(`Unsupported HTTP Status Code: ${statusCode}.`);\n return MqttV311ConnectReturnCode.ServerUnavailable;\n }\n } else if (protocolVersion === 5) {\n switch (statusCode) {\n case 400:\n return MqttV500ConnectReasonCode.BadUserNameOrPassword;\n case 401:\n return MqttV500ConnectReasonCode.NotAuthorized;\n case 500:\n return MqttV500ConnectReasonCode.UnspecifiedError;\n default:\n logger.warning(`Unsupported HTTP Status Code: ${statusCode}.`);\n return MqttV500ConnectReasonCode.UnspecifiedError;\n }\n } else {\n logger.warning(`Invalid MQTT protocol version: ${protocolVersion}.`);\n return MqttV311ConnectReturnCode.UnacceptableProtocolVersion;\n }\n}\n\nfunction handleConnectErrorResponse(\n connectRequest: ConnectRequest,\n response: ServerResponse,\n code: 400 | 401 | 500,\n detail?: string,\n): void {\n const isMqttReq = connectRequest.context.clientProtocol === \"mqtt\";\n if (isMqttReq) {\n const protocolVersion = (connectRequest as MqttConnectRequest).mqtt.protocolVersion;\n const mqttErrorResponse: MqttConnectErrorResponse = {\n mqtt: {\n code: getMqttConnectCodeFromStatusCode(code, protocolVersion),\n reason: detail,\n },\n };\n response.statusCode = code;\n response.setHeader(\"Content-Type\", \"application/json; charset=utf-8\");\n response.end(JSON.stringify(mqttErrorResponse));\n } else {\n response.statusCode = code;\n response.end(detail ?? \"\");\n }\n}\n\nfunction isWebPubSubRequest(req: IncomingMessage): boolean {\n return utils.getHttpHeader(req, \"ce-awpsversion\") !== undefined;\n}\n\nfunction isMqttRequest(req: IncomingMessage): boolean {\n const subprotocol = utils.getHttpHeader(req, \"ce-subprotocol\");\n const physicalConnectionId = utils.getHttpHeader(req, \"ce-physicalConnectionId\");\n return (\n subprotocol !== undefined &&\n subprotocol.toLowerCase().includes(\"mqtt\") &&\n physicalConnectionId !== undefined\n );\n}\n\nasync function readUserEventRequest(\n request: IncomingMessage,\n origin: string,\n): Promise<UserEventRequest | undefined> {\n const contentTypeheader = utils.getHttpHeader(request, \"content-type\");\n if (contentTypeheader === undefined) {\n return undefined;\n }\n\n const contentType = contentTypeheader.split(\";\")[0].trim();\n\n switch (contentType) {\n case \"application/octet-stream\":\n return {\n context: getContext(request, origin),\n data: await utils.readRequestBody(request),\n dataType: \"binary\",\n };\n case \"application/json\":\n return {\n context: getContext(request, origin),\n data: JSON.parse((await utils.readRequestBody(request)).toString()),\n dataType: \"json\",\n };\n case \"text/plain\":\n return {\n context: getContext(request, origin),\n data: (await utils.readRequestBody(request)).toString(),\n dataType: \"text\",\n };\n default:\n return undefined;\n }\n}\n\nasync function readSystemEventRequest<T extends { context: ConnectionContext }>(\n request: IncomingMessage,\n origin: string,\n): Promise<T> {\n const body = (await utils.readRequestBody(request)).toString();\n const parsedRequest = JSON.parse(body) as T;\n parsedRequest.context = getContext(request, origin);\n return parsedRequest;\n}\n\n/**\n * @internal\n */\nexport class CloudEventsDispatcher {\n private readonly _allowAll: boolean = true;\n private readonly _allowedOrigins: Array<string> = [];\n constructor(\n private hub: string,\n private eventHandler?: WebPubSubEventHandlerOptions,\n ) {\n if (Array.isArray(eventHandler)) {\n throw new Error(\"Unexpected WebPubSubEventHandlerOptions\");\n }\n if (eventHandler?.allowedEndpoints !== undefined) {\n this._allowedOrigins = eventHandler.allowedEndpoints.map((endpoint) =>\n new URL(endpoint).host.toLowerCase(),\n );\n this._allowAll = false;\n }\n }\n\n public handlePreflight(req: IncomingMessage, res: ServerResponse): boolean {\n if (!isWebPubSubRequest(req)) {\n return false;\n }\n const origin = utils.getHttpHeader(req, \"webhook-request-origin\");\n\n if (origin === undefined) {\n logger.warning(\"Expecting webhook-request-origin header.\");\n res.statusCode = 400;\n } else if (this._allowAll) {\n res.setHeader(\"WebHook-Allowed-Origin\", \"*\");\n } else {\n // service to do the check\n res.setHeader(\"WebHook-Allowed-Origin\", this._allowedOrigins);\n }\n\n res.end();\n return true;\n }\n\n public async handleRequest(request: IncomingMessage, response: ServerResponse): Promise<boolean> {\n if (!isWebPubSubRequest(request)) {\n return false;\n }\n\n // check if it is a valid WebPubSub cloud events\n const origin = utils.getHttpHeader(request, \"webhook-request-origin\");\n if (origin === undefined) {\n return false;\n }\n\n const eventType = tryGetWebPubSubEvent(request);\n if (eventType === undefined) {\n return false;\n }\n\n // check if hub matches\n const hub = utils.getHttpHeader(request, \"ce-hub\");\n if (hub?.toUpperCase() !== this.hub.toUpperCase()) {\n return false;\n }\n\n const isMqtt = isMqttRequest(request);\n // No need to read body if handler is not specified\n switch (eventType) {\n case EventType.Connect:\n if (!this.eventHandler?.handleConnect) {\n if (isMqtt) response.statusCode = 204;\n response.end();\n return true;\n }\n break;\n case EventType.Connected:\n if (!this.eventHandler?.onConnected) {\n response.end();\n return true;\n }\n break;\n case EventType.Disconnected:\n if (!this.eventHandler?.onDisconnected) {\n response.end();\n return true;\n }\n break;\n case EventType.UserEvent:\n if (!this.eventHandler?.handleUserEvent) {\n response.end();\n return true;\n }\n break;\n default:\n logger.warning(`Unknown EventType ${eventType}`);\n return false;\n }\n\n switch (eventType) {\n case EventType.Connect: {\n const connectRequest = isMqtt\n ? await readSystemEventRequest<MqttConnectRequest>(request, origin)\n : await readSystemEventRequest<ConnectRequest>(request, origin);\n // service passes out query property, assign it to queries\n connectRequest.queries = connectRequest.query;\n logger.verbose(connectRequest);\n this.eventHandler.handleConnect!(\n connectRequest,\n getConnectResponseHandler(connectRequest, response),\n );\n return true;\n }\n case EventType.Connected: {\n // for unblocking events, we responds to the service as early as possible\n response.end();\n const connectedRequest = await readSystemEventRequest<ConnectedRequest>(request, origin);\n logger.verbose(connectedRequest);\n this.eventHandler.onConnected!(connectedRequest);\n return true;\n }\n case EventType.Disconnected: {\n // for unblocking events, we responds to the service as early as possible\n response.end();\n const disconnectedRequest = isMqtt\n ? await readSystemEventRequest<MqttDisconnectedRequest>(request, origin)\n : await readSystemEventRequest<DisconnectedRequest>(request, origin);\n logger.verbose(disconnectedRequest);\n this.eventHandler.onDisconnected!(disconnectedRequest);\n return true;\n }\n case EventType.UserEvent: {\n const userRequest = await readUserEventRequest(request, origin);\n if (userRequest === undefined) {\n logger.warning(\n `Unsupported content type ${utils.getHttpHeader(request, \"content-type\")}`,\n );\n return false;\n }\n logger.verbose(userRequest);\n this.eventHandler.handleUserEvent!(\n userRequest,\n getUserEventResponseHandler(userRequest, response),\n );\n return true;\n }\n default:\n logger.warning(`Unknown EventType ${eventType}`);\n return false;\n }\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type express from \"express-serve-static-core\";\n\nimport { CloudEventsDispatcher } from \"./cloudEventsDispatcher.js\";\nimport type { WebPubSubEventHandlerOptions } from \"./cloudEventsProtocols.js\";\n\n/**\n * The handler to handle incoming CloudEvents messages\n */\nexport class WebPubSubEventHandler {\n /**\n * The path this CloudEvents handler listens to\n */\n public readonly path: string;\n\n private _cloudEventsHandler: CloudEventsDispatcher;\n\n /**\n * Creates an instance of a WebPubSubEventHandler for handling incoming CloudEvents messages.\n *\n * Example usage:\n * ```ts\n * import express from \"express\";\n * import { WebPubSubEventHandler } from \"@azure/web-pubsub-express\";\n * const endpoint = \"https://xxxx.webpubsubdev.azure.com\"\n * const handler = new WebPubSubEventHandler('chat', {\n * handleConnect: (req, res) => {\n * console.log(JSON.stringify(req));\n * return {};\n * },\n * onConnected: req => {\n * console.log(JSON.stringify(req));\n * },\n * handleUserEvent: (req, res) => {\n * console.log(JSON.stringify(req));\n * res.success(\"Hey \" + req.data, req.dataType);\n * };\n * allowedEndpoints: [ endpoint ]\n * },\n * });\n * ```\n *\n * @param hub - The name of the hub to listen to\n * @param options - Options to configure the event handler\n */\n constructor(\n private hub: string,\n options?: WebPubSubEventHandlerOptions,\n ) {\n const path = (options?.path ?? `/api/webpubsub/hubs/${hub}/`).toLowerCase();\n this.path = path.endsWith(\"/\") ? path : path + \"/\";\n this._cloudEventsHandler = new CloudEventsDispatcher(this.hub, options);\n }\n\n /**\n * Get the middleware to process the CloudEvents requests\n */\n public getMiddleware(): express.RequestHandler {\n return async (\n req: express.Request,\n res: express.Response,\n next: express.NextFunction,\n ): Promise<void> => {\n // Request originalUrl can contain query while baseUrl + path not\n let requestUrl = (req.baseUrl + req.path).toLowerCase();\n\n // normalize the Url\n requestUrl = requestUrl.endsWith(\"/\") ? requestUrl : requestUrl + \"/\";\n if (requestUrl.startsWith(this.path)) {\n if (req.method === \"OPTIONS\") {\n if (this._cloudEventsHandler.handlePreflight(req, res)) {\n return;\n }\n } else if (req.method === \"POST\") {\n try {\n if (await this._cloudEventsHandler.handleRequest(req, res)) {\n return;\n }\n } catch (err: any) {\n next(err);\n return;\n }\n }\n }\n\n next();\n };\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * MQTT 5.0 Disconnect Reason Codes.\n */\nexport enum MqttDisconnectReasonCode {\n /**\n * 0x00 - Normal disconnection\n * Sent by: Client or Server\n * Description: Close the connection normally. Do not send the Will Message.\n */\n NormalDisconnection = 0x00,\n\n /**\n * 0x04 - Disconnect with Will Message\n * Sent by: Client\n * Description: The Client wishes to disconnect but requires that the Server also publishes its Will Message.\n */\n DisconnectWithWillMessage = 0x04,\n\n /**\n * 0x80 - Unspecified error\n * Sent by: Client or Server\n * Description: The Connection is closed but the sender either does not wish to reveal the reason, or none of the other Reason Codes apply.\n */\n UnspecifiedError = 0x80,\n\n /**\n * 0x81 - Malformed Packet\n * Sent by: Client or Server\n * Description: The received packet does not conform to this specification.\n */\n MalformedPacket = 0x81,\n\n /**\n * 0x82 - Protocol Error\n * Sent by: Client or Server\n * Description: An unexpected or out of order packet was received.\n */\n ProtocolError = 0x82,\n\n /**\n * 0x83 - Implementation specific error\n * Sent by: Client or Server\n * Description: The packet received is valid but cannot be processed by this implementation.\n */\n ImplementationSpecificError = 0x83,\n\n /**\n * 0x87 - Not authorized\n * Sent by: Server\n * Description: The request is not authorized.\n */\n NotAuthorized = 0x87,\n\n /**\n * 0x89 - Server busy\n * Sent by: Server\n * Description: The Server is busy and cannot continue processing requests from this Client.\n */\n ServerBusy = 0x89,\n\n /**\n * 0x8B - Server shutting down\n * Sent by: Server\n * Description: The Server is shutting down.\n */\n ServerShuttingDown = 0x8b,\n\n /**\n * 0x8D - Keep Alive timeout\n * Sent by: Server\n * Description: The Connection is closed because no packet has been received for 1.5 times the Keepalive time.\n */\n KeepAliveTimeout = 0x8d,\n\n /**\n * 0x8E - Session taken over\n * Sent by: Server\n * Description: Another Connection using the same ClientID has connected causing this Connection to be closed.\n */\n SessionTakenOver = 0x8e,\n\n /**\n * 0x8F - Topic Filter invalid\n * Sent by: Server\n * Description: The Topic Filter is correctly formed, but is not accepted by this Server.\n */\n TopicFilterInvalid = 0x8f,\n\n /**\n * 0x90 - Topic Name invalid\n * Sent by: Client or Server\n * Description: The Topic Name is correctly formed, but is not accepted by this Client or Server.\n */\n TopicNameInvalid = 0x90,\n\n /**\n * 0x93 - Receive Maximum exceeded\n * Sent by: Client or Server\n * Description: The Client or Server has received more than Receive Maximum publication for which it has not sent PUBACK or PUBCOMP.\n */\n ReceiveMaximumExceeded = 0x93,\n\n /**\n * 0x94 - Topic Alias invalid\n * Sent by: Client or Server\n * Description: The Client or Server has received a PUBLISH packet containing a Topic Alias which is greater than the Maximum Topic Alias it sent in the CONNECT or CONNACK packet.\n */\n TopicAliasInvalid = 0x94,\n\n /**\n * 0x95 - Packet too large\n * Sent by: Client or Server\n * Description: The packet size is greater than Maximum Packet Size for this Client or Server.\n */\n PacketTooLarge = 0x95,\n\n /**\n * 0x96 - Message rate too high\n * Sent by: Client or Server\n * Description: The received data rate is too high.\n */\n MessageRateTooHigh = 0x96,\n\n /**\n * 0x97 - Quota exceeded\n * Sent by: Client or Server\n * Description: An implementation or administrative imposed limit has been exceeded.\n */\n QuotaExceeded = 0x97,\n\n /**\n * 0x98 - Administrative action\n * Sent by: Client or Server\n * Description: The Connection is closed due to an administrative action.\n */\n AdministrativeAction = 0x98,\n\n /**\n * 0x99 - Payload format invalid\n * Sent by: Client or Server\n * Description: The payload format does not match the one specified by the Payload Format Indicator.\n */\n PayloadFormatInvalid = 0x99,\n\n /**\n * 0x9A - Retain not supported\n * Sent by: Server\n * Description: The Server does not support retained messages.\n */\n RetainNotSupported = 0x9a,\n\n /**\n * 0x9B - QoS not supported\n * Sent by: Server\n * Description: The Client specified a QoS greater than the QoS specified in a Maximum QoS in the CONNACK.\n */\n QosNotSupported = 0x9b,\n\n /**\n * 0x9C - Use another server\n * Sent by: Server\n * Description: The Client should temporarily change its Server.\n */\n UseAnotherServer = 0x9c,\n\n /**\n * 0x9D - Server moved\n * Sent by: Server\n * Description: The Server is moved and the Client should permanently change its server location.\n */\n ServerMoved = 0x9d,\n\n /**\n * 0x9E - Shared Subscriptions not supported\n * Sent by: Server\n * Description: The Server does not support Shared Subscriptions.\n */\n SharedSubscriptionsNotSupported = 0x9e,\n\n /**\n * 0x9F - Connection rate exceeded\n * Sent by: Server\n * Description: This connection is closed because the connection rate is too high.\n */\n ConnectionRateExceeded = 0x9f,\n\n /**\n * 0xA0 - Maximum connect time\n * Sent by: Server\n * Description: The maximum connection time authorized for this connection has been exceeded.\n */\n MaximumConnectTime = 0xa0,\n\n /**\n * 0xA1 - Subscription Identifiers not supported\n * Sent by: Server\n * Description: The Server does not support Subscription Identifiers; the subscription is not accepted.\n */\n SubscriptionIdentifiersNotSupported = 0xa1,\n\n /**\n * 0xA2 - Wildcard Subscriptions not supported\n * Sent by: Server\n * Description: The Server does not support Wildcard Subscriptions; the subscription is not accepted.\n */\n WildcardSubscriptionsNotSupported = 0xa2,\n}\n"],"names":["createClientLogger","MqttV311ConnectReturnCode","MqttV500ConnectReasonCode","utils.toBase64JsonString","utils.getHttpHeader","utils.fromBase64JsonString","utils.readRequestBody","URL","MqttDisconnectReasonCode"],"mappings":";;;;;;;AAAA;AACA;AAIA,SAAS,YAAY,CAAC,GAAQ,EAAA;AAC5B,IAAA,OAAO,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;AAC9D;AAEM,SAAU,kBAAkB,CAAC,GAAwB,EAAA;AACzD,IAAA,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;AAC5D;AAEM,SAAU,oBAAoB,CAAC,YAAgC,EAAA;AACnE,IAAA,IAAI,YAAY,KAAK,SAAS,EAAE;AAC9B,QAAA,OAAO,EAAE;;AAGX,IAAA,IAAI;AACF,QAAA,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC,QAAQ,EAAE;QAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC;AAC9B,QAA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,wBAA6B;AAE7B;;;;AAIG;AACH,IAAA,wBAAA,CAAA,wBAAA,CAAA,oBAAA,CAAA,GAAA,GAAA,CAAA,GAAA,oBAAyB;AAEzB;;;;AAIG;AACH,IAAA,wBAAA,CAAA,wBAAA,CAAA,qCAAA,CAAA,GAAA,GAAA,CAAA,GAAA,qCAA0C;AAE1C;;;;AAIG;AACH,IAAA,wBAAA,CAAA,wBAAA,CAAA,mCAAA,CAAA,GAAA,GAAA,CAAA,GAAA,mCAAwC;AAC1C,CAAC,EA3MWA,gCAAwB,KAAxBA,gCAAwB,GA2MnC,EAAA,CAAA,CAAA;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/web-pubsub-express",
3
- "version": "1.0.6-alpha.20250207.2",
3
+ "version": "1.0.6-alpha.20250210.1",
4
4
  "description": "Azure Web PubSub CloudEvents handlers",
5
5
  "sdk-type": "client",
6
6
  "scripts": {