{"version":3,"file":"index.cjs","names":["Builder","XMLParser","METHOD_CALL","SIGNAL","ERROR","METHOD_RETURN","EventEmitter","callable","EventEmitter","METHOD_RETURN","EventEmitter","handleMessage","handleMethod","execFile","SHIFT_32","marshall","marshallBody","Duplex","EventEmitter"],"sources":["../src/validators.ts","../src/errors.ts","../src/guards.ts","../src/introspect-xml.ts","../src/constants.ts","../src/message-type.ts","../src/signature.ts","../src/client/proxy-interface.ts","../src/client/proxy-object.ts","../src/variant.ts","../src/service/interface.ts","../src/service/handlers.ts","../src/service/object.ts","../src/bus.ts","../src/address/launchd.ts","../src/address/x11-fs.ts","../src/address/xdg.ts","../src/address/session-bus.ts","../src/readline.ts","../src/handshake.ts","../src/dbus-buffer.ts","../src/header-signature.ts","../src/align.ts","../src/marshallers.ts","../src/put.ts","../src/marshall.ts","../src/message.ts","../src/marshall-compat.ts","../src/connection.ts","../src/library-options.ts","../src/index.ts"],"sourcesContent":["/**\n * Utility functions to validate bus names, interface names, and object paths.\n *\n * @module validators\n */\n\nimport type { Assert } from '@/guards';\n\nconst busNameRe = /^[A-Za-z_-][A-Za-z0-9_-]*$/;\n/**\n * Validate the string as a valid bus name.\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus}\n *\n * @static\n * @param {string} name - The name to validate as a valid bus name.\n * @returns {boolean} - Whether the string is a valid bus name.\n */\nexport const isBusNameValid = (name: unknown): name is string => {\n  if (typeof name !== 'string') {\n    return false;\n  }\n\n  if (name.startsWith(':')) {\n    // a unique bus name\n    return true;\n  }\n\n  // a well-known bus name\n  return !!(\n    name.length > 0 &&\n    name.length <= 255 &&\n    name[0] !== '.' &&\n    name.includes('.') &&\n    name.split('.').every((n) => n && busNameRe.test(n))\n  );\n};\n\n/**\n * Throws an error if the given string is not a valid bus name.\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-bus}\n *\n * @static\n * @param {string} name - The name to validate as a bus name.\n */\nexport const assertBusNameValid: Assert<string> = (name) => {\n  if (!isBusNameValid(name)) {\n    throw new Error(`Invalid bus name: ${String(name)}`);\n  }\n};\n\nconst pathRe = /^[A-Za-z0-9_]+$/;\n/**\n * Validate the string as a valid object path.\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path}\n *\n * @static\n * @param {string} path - The string to validate as an object path.\n * @returns {boolean} - Whether the string is a valid object path.\n */\nexport const isObjectPathValid = (path: unknown): path is string => {\n  return !!(\n    typeof path === 'string' &&\n    path &&\n    path[0] === '/' &&\n    (path.length === 1 ||\n      (path[path.length - 1] !== '/' &&\n        path\n          .split('/')\n          .slice(1)\n          .every((p) => p && pathRe.test(p))))\n  );\n};\n\n/**\n * Throws an error if the given string is not a valid object path.\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-marshaling-object-path}\n *\n * @static\n * @param {string} path - The string to validate as an object path.\n * @returns {boolean} - Whether the string is a valid object path.\n */\nexport const assertObjectPathValid: Assert<string> = (path) => {\n  if (!isObjectPathValid(path)) {\n    throw new Error(`Invalid object path: ${String(path)}`);\n  }\n};\n\nconst elementRe = /^[A-Za-z_][A-Za-z0-9_]*$/;\n/**\n * Validate the string as a valid interface name.\n * see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-interface}\n *\n * @static\n * @param {string} name - The string to validate as an interface name.\n * @returns {boolean} - Whether the string is a valid interface name.\n */\nexport const isInterfaceNameValid = (name: unknown): name is string => {\n  return !!(\n    typeof name === 'string' &&\n    name &&\n    name.length > 0 &&\n    name.length <= 255 &&\n    name[0] !== '.' &&\n    name.includes('.') &&\n    name.split('.').every((n) => n && elementRe.test(n))\n  );\n};\n\n/**\n * Throws an error if the given string is not a valid interface name.\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-interface}\n *\n * @static\n * @param {string} name - The string to validate as an interface name.\n */\nexport const assertInterfaceNameValid: Assert<string> = (name) => {\n  if (!isInterfaceNameValid(name)) {\n    throw new Error(`Invalid interface name: ${String(name)}`);\n  }\n};\n\n/**\n * Validate the string is a valid member name\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-interface}\n *\n * @static\n * @param {string} name - The string to validate as a member name.\n * @returns {boolean} - Whether the string is a valid member name.\n */\nexport const isMemberNameValid = (name: unknown): name is string => {\n  return !!(\n    typeof name === 'string' &&\n    name &&\n    name.length > 0 &&\n    name.length <= 255 &&\n    elementRe.test(name)\n  );\n};\n\n/**\n * Throws an error if the string is not a valid member name.\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-names-interface}\n *\n * @static\n * @param {string} name - The string to validate as a member name.\n */\nexport const assertMemberNameValid: Assert<string> = (name) => {\n  if (!isMemberNameValid(name)) {\n    throw new Error(`Invalid member name: ${String(name)}`);\n  }\n};\n","import { assertInterfaceNameValid } from '@/validators';\n/**\n * An error that can be thrown from DBus [`Interface`]{@link\n * module:interface~Interface} [methods]{@link module:interface.method} and\n * [property]{@link module:interface.property} getters and setters to return\n * the error to the client.\n *\n * This class will also be thrown by {@link ProxyInterface} method calls when\n * the interface method returns an error to the method call.\n *\n * @param {string} type - The type of error. Must be a valid DBus member name.\n * @param {string} text - The error text. Will be seen by the client.\n */\nexport class DBusError extends Error {\n  type: string;\n  text: string;\n  reply: unknown;\n\n  /**\n   * Construct a new `DBusError` with the given type and text.\n   */\n  constructor(type: string, text?: string, reply: unknown = null) {\n    assertInterfaceNameValid(type);\n    text = text || '';\n    super(text);\n    this.name = 'DBusError';\n    this.type = type;\n    this.text = text;\n    this.reply = reply;\n  }\n}\n","export type Assert<T> = (value: unknown) => asserts value is T;\n\nexport const isRecord = (value: unknown): value is Record<string, unknown> => {\n  return typeof value === 'object' && value !== null && !Array.isArray(value);\n};\n","import Builder, { type XMLBuilder } from 'fast-xml-builder';\nimport { XMLParser } from 'fast-xml-parser';\n\nconst ARRAY_TAGS = ['node', 'interface', 'method', 'signal', 'property', 'arg', 'annotation'];\n\nexport const createIntrospectBuilder = (): XMLBuilder => {\n  return new Builder({\n    ignoreAttributes: false,\n    attributesGroupName: '$',\n    attributeNamePrefix: '',\n    format: true,\n    suppressEmptyNode: true,\n  });\n};\n\nexport const createIntrospectParser = (): XMLParser => {\n  return new XMLParser({\n    ignoreAttributes: false,\n    attributesGroupName: '$',\n    attributeNamePrefix: '',\n    isArray: (name, jpath) => {\n      if (name === 'node' && jpath === 'node') {\n        return false;\n      }\n      return ARRAY_TAGS.includes(name);\n    },\n  });\n};\n","/**\n * @class\n *\n * A flag enum for {@link MessageBus#requestName} to configure the name request\n * options.\n *\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-request-name}\n */\nexport class NameFlag {\n  /**\n   * This name allows other clients to replace it as the name owner on a request.\n   *\n   * @memberof NameFlag\n   * @static\n   * @constant\n   */\n  static readonly ALLOW_REPLACEMENT = 1;\n\n  /**\n   * This request should replace an existing name if that name allows\n   * replacement.\n   *\n   * @memberof NameFlag\n   * @static\n   * @constant\n   */\n  static readonly REPLACE_EXISTING = 2;\n\n  /**\n   * This request should not enter the queue of clients requesting this name if\n   * it is taken.\n   *\n   * @memberof NameFlag\n   * @static\n   * @constant\n   */\n  static readonly DO_NOT_QUEUE = 4;\n}\n\n/**\n * @class\n *\n * An enum for the return value of {@link MessageBus#requestName} to indicate\n * the status of the name request.\n *\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-request-name}\n */\nexport class RequestNameReply {\n  /**\n   * The application trying to request ownership of a name is already the owner\n   * of it.\n   *\n   * @memberof RequestNameReply\n   * @static\n   * @constant\n   */\n  static readonly PRIMARY_OWNER = 1;\n\n  /**\n   * The name already had an owner, `DBUS_NAME_FLAG_DO_NOT_QUEUE` was not\n   * specified, and either the current owner did not specify\n   * `DBUS_NAME_FLAG_ALLOW_REPLACEMENT` or the requesting application did not\n   * specify `DBUS_NAME_FLAG_REPLACE_EXISTING`.\n   *\n   * @memberof RequestNameReply\n   * @static\n   * @constant\n   */\n  static readonly IN_QUEUE = 2;\n\n  /**\n   * The name already has an owner, `DBUS_NAME_FLAG_DO_NOT_QUEUE` was specified,\n   * and either `DBUS_NAME_FLAG_ALLOW_REPLACEMENT` was not specified by the\n   * current owner, or `DBUS_NAME_FLAG_REPLACE_EXISTING` was not specified by the\n   * requesting application.\n   *\n   * @memberof RequestNameReply\n   * @static\n   * @constant\n   */\n  static readonly EXISTS = 3;\n\n  /**\n   * The application trying to request ownership of a name is already the owner\n   * of it.\n   *\n   * @memberof RequestNameReply\n   * @static\n   * @constant\n   */\n  static readonly ALREADY_OWNER = 4;\n}\n\n/**\n * @class\n *\n * An enum for the return value of {@link MessageBus#releaseName} to indicate\n * the status of the release name request.\n *\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#bus-messages-release-name}\n */\nexport class ReleaseNameReply {\n  /**\n   * The caller has released his claim on the given name. Either the caller was\n   * the primary owner of the name, and the name is now unused or taken by\n   * somebody waiting in the queue for the name, or the caller was waiting in the\n   * queue for the name and has now been removed from the queue.\n   *\n   * @memberof ReleaseNameReply\n   * @static\n   * @constant\n   */\n  static readonly RELEASED = 1;\n\n  /**\n   * The given name does not exist on this bus.\n   *\n   * @memberof ReleaseNameReply\n   * @static\n   * @constant\n   */\n  static readonly NON_EXISTENT = 2;\n\n  /**\n   * The caller was not the primary owner of this name, and was also not waiting\n   * in the queue to own this name.\n   *\n   * @memberof ReleaseNameReply\n   * @static\n   * @constant\n   */\n  static readonly NOT_OWNER = 3;\n}\n\n/**\n * @class\n *\n * An enum value for the {@link Message} `type` member to indicate the type of message.\n *\n * @see https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol\n */\nexport class MessageType {\n  /**\n   * The message is a method call.\n   *\n   * @memberof MessageType\n   * @static\n   * @constant\n   */\n  static readonly METHOD_CALL = 1;\n\n  /**\n   * The message is a method return to a previous call.\n   *\n   * @memberof MessageType\n   * @static\n   * @constant\n   */\n  static readonly METHOD_RETURN = 2;\n\n  /**\n   * The message is an error reply.\n   *\n   * @memberof MessageType\n   * @static\n   * @constant\n   */\n  static readonly ERROR = 3;\n\n  /**\n   * The message is a signal.\n   *\n   * @memberof MessageType\n   * @static\n   * @constant\n   */\n  static readonly SIGNAL = 4;\n}\n\n/**\n * @class\n *\n * An flag enum for the {@link Message} `flags` member to configure behavior\n * for message processing.\n *\n * @see https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol\n */\nexport class MessageFlag {\n  /**\n   * No reply is expected from this message.\n   *\n   * @memberof MessageFlag\n   * @static\n   * @constant\n   */\n  static readonly NO_REPLY_EXPECTED = 1;\n\n  /**\n   * This message should not autostart a service.\n   *\n   * @memberof MessageFlag\n   * @static\n   * @constant\n   */\n  static readonly NO_AUTO_START = 2;\n}\n\nexport const MAX_INT64_STR = '9223372036854775807';\nexport const MIN_INT64_STR = '-9223372036854775807';\nexport const MAX_UINT64_STR = '18446744073709551615';\nexport const MIN_UINT64_STR = '0';\n\nexport interface BigIntConstants {\n  MAX_INT64: bigint;\n  MIN_INT64: bigint;\n  MAX_UINT64: bigint;\n  MIN_UINT64: bigint;\n}\n\nlet _BigIntConstants: BigIntConstants | null = null;\n\nexport const _getBigIntConstants = (): BigIntConstants => {\n  if (_BigIntConstants !== null) {\n    return _BigIntConstants;\n  }\n\n  _BigIntConstants = {\n    MAX_INT64: BigInt(MAX_INT64_STR),\n    MIN_INT64: BigInt(MIN_INT64_STR),\n    MAX_UINT64: BigInt(MAX_UINT64_STR),\n    MIN_UINT64: BigInt(MIN_UINT64_STR),\n  };\n\n  return _BigIntConstants;\n};\n\nexport const headerTypeName: readonly (string | null)[] = [\n  null,\n  'path',\n  'interface',\n  'member',\n  'errorName',\n  'replySerial',\n  'destination',\n  'sender',\n  'signature',\n  'unixFd',\n];\n\n// TODO: merge to single hash? e.g path -> [1, 'o']\nexport const fieldSignature = {\n  path: 'o',\n  interface: 's',\n  member: 's',\n  errorName: 's',\n  replySerial: 'u',\n  destination: 's',\n  sender: 's',\n  signature: 'g',\n  unixFd: 'u',\n} as const;\n\nexport const headerTypeId = {\n  path: 1,\n  interface: 2,\n  member: 3,\n  errorName: 4,\n  replySerial: 5,\n  destination: 6,\n  sender: 7,\n  signature: 8,\n  unixFd: 9,\n} as const;\n\nexport const protocolVersion = 1;\n\nexport const endianness = {\n  le: 108,\n  be: 66,\n} as const;\n\nexport const messageSignature = 'yyyyuua(yv)';\n\nexport const defaultAuthMethods = ['EXTERNAL', 'DBUS_COOKIE_SHA1', 'ANONYMOUS'];\n","import { MessageType } from '@/constants';\nimport {\n  assertBusNameValid,\n  assertInterfaceNameValid,\n  assertObjectPathValid,\n  assertMemberNameValid,\n} from '@/validators';\n\nconst { METHOD_CALL, METHOD_RETURN, ERROR, SIGNAL } = MessageType;\n\ntype RequiredField = 'path' | 'member' | 'interface' | 'errorName' | 'replySerial';\n\nexport interface MessageLike {\n  type?: number;\n  serial?: number | null;\n  path?: string;\n  interface?: string;\n  member?: string;\n  errorName?: string;\n  replySerial?: number;\n  destination?: string;\n  sender?: string;\n  signature?: string;\n  body?: unknown[];\n  flags?: number;\n}\n\n/**\n * @class\n * A `Message` is a class used for sending and receiving messages through the\n * {@link MessageBus} with the low-level api. `Message`s can be constructed by\n * the user directly for method calls or with the static convenience methods on\n * this class for the other types of messages. `Message`s can be sent through a\n * connected MessageBus with {@link MessageBus#call} for method calls that\n * expect a reply from the server or {@link MessageBus#send} for messages that\n * do not expect a reply. See those methods for an example of how to use this\n * class.\n *\n * @see https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol\n *\n * @param {object} options - Options to construct this `Message` with. See the\n * corresponding member for more information.\n * @param {MessageType} [options.type={@link MessageType.METHOD_CALL}]\n * @param {int} [options.serial]\n * @param {string} [options.destination]\n * @param {string} [options.path]\n * @param {string} [options.interface] - Required for signals.\n * @param {string} [options.member] - Required for method calls and signals.\n * @param {string} [options.signature='']\n * @param {Array} [options.body=[]] -  Must match the signature.\n * @param {string} [options.errorName] - Must be a valid interface name.\n * Required for errors.\n * @param {string} [options.replySerial] - Required for errors and method returns.\n * @param {MessageFlags} [options.flags]\n */\nexport class Message {\n  type: number;\n  _sent: boolean;\n  private _serial: number | null;\n  path: string;\n  interface: string;\n  member: string;\n  errorName: string;\n  replySerial: number | undefined;\n  destination: string;\n  sender: string;\n  signature: string;\n  body: unknown[];\n  flags: number;\n\n  /**\n   * Construct a new `Message` to send on the bus.\n   */\n  constructor(msg: MessageLike) {\n    /**\n     * @member {MessageType} - The type of message this is.\n     */\n    this.type = msg.type ? msg.type : METHOD_CALL;\n    this._sent = false;\n    this._serial =\n      msg.serial === undefined || msg.serial === null || Number.isNaN(msg.serial)\n        ? null\n        : msg.serial;\n    /**\n     * @member {string} - The name of the object path for the message.\n     * Required for method calls and signals.\n     */\n    this.path = msg.path as string;\n    /**\n     * @member {string} - The destination interface for this message.\n     */\n    this.interface = msg.interface as string;\n    /**\n     * @member {string} - The destination member on the interface for this message.\n     */\n    this.member = msg.member as string;\n    /**\n     * @member {string} - The name of the error if this is a message of type\n     * `ERROR`. Must be a valid interface name.\n     */\n    this.errorName = msg.errorName as string;\n    /**\n     * @member {int} - The serial for the message this is in reply to. Set for\n     * types `ERROR` and `METHOD_RETURN`.\n     */\n    this.replySerial = msg.replySerial;\n    /**\n     * @member {string} - The address on the bus to send the message\n     * to.\n     */\n    this.destination = msg.destination as string;\n    /**\n     * @member {string} - The name of the bus from which this message was sent.\n     * Set by the {@link MessageBus}.\n     */\n    this.sender = msg.sender as string;\n    /**\n     * @member {string} - The type signature for the body args.\n     */\n    this.signature = msg.signature || '';\n    /**\n     * @member {Array} - The body arguments for this message. Must match the signature.\n     */\n    this.body = msg.body || [];\n    /**\n     * @member {MessageFlags} - The flags for this message.\n     */\n    this.flags = msg.flags || 0;\n\n    if (this.destination) {\n      assertBusNameValid(this.destination);\n    }\n\n    if (this.interface) {\n      assertInterfaceNameValid(this.interface);\n    }\n\n    if (this.path) {\n      assertObjectPathValid(this.path);\n    }\n\n    if (this.member) {\n      assertMemberNameValid(this.member);\n    }\n\n    if (this.errorName) {\n      assertInterfaceNameValid(this.errorName);\n    }\n\n    const requireFields = (...fields: RequiredField[]): void => {\n      for (const field of fields) {\n        if (this[field] === undefined) {\n          throw new Error(`Message is missing a required field: ${field}`);\n        }\n      }\n    };\n\n    // validate required fields\n    switch (this.type) {\n      case METHOD_CALL:\n        requireFields('path', 'member');\n        break;\n      case SIGNAL:\n        requireFields('path', 'member', 'interface');\n        break;\n      case ERROR:\n        requireFields('errorName', 'replySerial');\n        break;\n      case METHOD_RETURN:\n        requireFields('replySerial');\n        break;\n      default:\n        throw new Error(`Got unknown message type: ${this.type}`);\n    }\n  }\n\n  /**\n   * @member {int} - The serial of the message to track through the bus.  You\n   * must use {@link MessageBus#newSerial} to get this serial. If not set, it\n   * will be set automatically when the message is sent.\n   */\n  get serial(): number | null {\n    return this._serial;\n  }\n\n  set serial(value: number | null) {\n    this._sent = false;\n    this._serial = value;\n  }\n\n  /**\n   * Construct a new `Message` of type `ERROR` in reply to the given `Message`.\n   *\n   * @param {Message} msg - The `Message` this error is in reply to.\n   * @param {string} errorName - The name of the error. Must be a valid\n   * interface name.\n   * @param {string} [errorText='An error occurred.'] - An error message for\n   * the error.\n   */\n  static newError(msg: Message, errorName: string, errorText = 'An error occurred.'): Message {\n    assertInterfaceNameValid(errorName);\n    return new Message({\n      type: ERROR,\n      replySerial: msg.serial ?? undefined,\n      destination: msg.sender,\n      errorName: errorName,\n      signature: 's',\n      body: [errorText],\n    });\n  }\n\n  /**\n   * Construct a new `Message` of type `METHOD_RETURN` in reply to the given\n   * message.\n   *\n   * @param {Message} msg - The `Message` this `Message` is in reply to.\n   * @param {string} signature - The signature for the message body.\n   * @param {Array} body - The body of the message as an array of arguments.\n   * Must match the signature.\n   */\n  static newMethodReturn(msg: Message, signature = '', body: unknown[] = []): Message {\n    return new Message({\n      type: METHOD_RETURN,\n      replySerial: msg.serial ?? undefined,\n      destination: msg.sender,\n      signature: signature,\n      body: body,\n    });\n  }\n\n  /**\n   * Construct a new `Message` of type `SIGNAL` to broadcast on the bus.\n   *\n   * @param {string} path - The object path of this signal.\n   * @param {string} iface - The interface of this signal.\n   * @param {string} signature - The signature of the message body.\n   * @param {Array] body - The body of the message as an array of arguments.\n   * Must match the signature.\n   */\n  static newSignal(\n    path: string,\n    iface: string,\n    name: string,\n    signature = '',\n    body: unknown[] = [],\n  ): Message {\n    return new Message({\n      type: SIGNAL,\n      interface: iface,\n      path: path,\n      member: name,\n      signature: signature,\n      body: body,\n    });\n  }\n}\n","// parse signature from string to tree\n\nexport interface SignatureNode {\n  type: string;\n  child: SignatureNode[];\n}\n\nconst match: Record<string, string> = {\n  '{': '}',\n  '(': ')',\n};\n\nconst knownTypes: Record<string, boolean> = {};\n'(){}ybnqiuxtdsogarvehm*?@&^'.split('').forEach((c) => {\n  knownTypes[c] = true;\n});\n\nexport const parseSignature = (signature: string): SignatureNode[] => {\n  let index = 0;\n  const next = (): string | null => {\n    if (index < signature.length) {\n      const c = signature[index];\n      ++index;\n      return c ?? null;\n    }\n    return null;\n  };\n\n  const parseOne = (c: string): SignatureNode => {\n    const checkNotEnd = (ch: string | null): string => {\n      if (!ch) {\n        throw new Error('Bad signature: unexpected end');\n      }\n      return ch;\n    };\n\n    if (!knownTypes[c]) {\n      throw new Error(`Unknown type: \"${c}\" in signature \"${signature}\"`);\n    }\n\n    let ele: string | null;\n    const res: SignatureNode = { type: c, child: [] };\n    switch (c) {\n      case 'a': // array\n        res.child.push(parseOne(checkNotEnd(next())));\n        return res;\n      case '{': // dict entry\n      case '(': // struct\n        while ((ele = next()) !== null && ele !== match[c]) {\n          res.child.push(parseOne(ele));\n        }\n        checkNotEnd(ele);\n        return res;\n    }\n    return res;\n  };\n\n  const ret: SignatureNode[] = [];\n  let c: string | null;\n  while ((c = next()) !== null) {\n    ret.push(parseOne(c));\n  }\n  return ret;\n};\n\nexport const collapseSignature = (value: SignatureNode): string => {\n  if (value.child.length === 0) {\n    return value.type;\n  }\n\n  let type = value.type;\n  for (const child of value.child) {\n    type += collapseSignature(child);\n  }\n  if (type[0] === '{') {\n    type += '}';\n  } else if (type[0] === '(') {\n    type += ')';\n  }\n  return type;\n};\n","import { EventEmitter } from 'node:events';\n\nimport { isRecord } from '@/guards';\nimport { isInterfaceNameValid, isMemberNameValid } from '@/validators';\n\nimport type { ProxyObject } from './proxy-object';\nimport type { Message } from '@/message-type';\n\nexport interface ProxySignalInfo {\n  name: string;\n  signature: string;\n}\n\nexport interface ProxyMethodInfo {\n  name: string;\n  inSignature: string;\n  outSignature: string;\n}\n\nexport interface ProxyPropertyInfo {\n  name: string;\n  type: string;\n  access: string;\n}\n\nclass ProxyListener {\n  refcount = 0;\n  readonly fn: (msg: Message) => void;\n\n  constructor(signal: ProxySignalInfo, iface: ProxyInterface) {\n    this.fn = (msg) => {\n      const { body, signature, sender } = msg;\n      if (iface.$object.bus._nameOwners[iface.$object.name] !== sender) {\n        return;\n      }\n      if (signature !== signal.signature) {\n        console.error(\n          `warning: got signature ${signature} for signal ${msg.interface ?? ''}.${signal.name} (expected ${signal.signature})`,\n        );\n        return;\n      }\n      iface.emit(signal.name, ...(body ?? []));\n    };\n  }\n}\n\n/**\n * A class to represent a proxy to an interface exported on the bus to be used\n * by a client. A `ProxyInterface` is gotten by interface name from the {@link\n * ProxyObject} from the {@link MessageBus}. This class is constructed\n * dynamically based on the introspection data on the bus. The advertised\n * methods of the interface are exposed as class methods that take arguments\n * and return a Promsie that resolves to types specified by the type signature\n * of the DBus method. The `ProxyInterface` is an `EventEmitter` that emits\n * events with types that are specified by the type signature of the DBus\n * signal advertised on the bus when that signal is received.\n *\n * If an interface method call returns an error, `ProxyInterface` method call\n * will throw a {@link DBusError}.\n */\nexport class ProxyInterface extends EventEmitter<Record<string, unknown[]>> {\n  $name: string;\n  $object: ProxyObject;\n  $properties: ProxyPropertyInfo[];\n  $methods: ProxyMethodInfo[];\n  $signals: ProxySignalInfo[];\n  private readonly $listeners: Record<string, ProxyListener>;\n\n  /**\n   * Create a new `ProxyInterface`. This constructor should not be called\n   * directly. Use {@link ProxyObject#getInterface} to get a proxy interface.\n   */\n  constructor(name: string, object: ProxyObject) {\n    super();\n    this.$name = name;\n    this.$object = object;\n    this.$properties = [];\n    this.$methods = [];\n    this.$signals = [];\n    this.$listeners = {};\n\n    const getEventDetails = (eventName: string): [ProxySignalInfo, string] | [null, null] => {\n      const signal = this.$signals.find((s) => s.name === eventName);\n      if (!signal) {\n        return [null, null];\n      }\n\n      const detailedEvent = JSON.stringify({\n        path: this.$object.path,\n        interface: this.$name,\n        member: eventName,\n      });\n\n      return [signal, detailedEvent];\n    };\n\n    this.on('removeListener', (eventName: string) => {\n      const [signal, detailedEvent] = getEventDetails(eventName);\n\n      if (!signal || detailedEvent === null) {\n        return;\n      }\n\n      const proxyListener = this._getEventListener(signal);\n\n      if (proxyListener.refcount <= 0) {\n        return;\n      }\n\n      proxyListener.refcount -= 1;\n      if (proxyListener.refcount > 0) {\n        return;\n      }\n\n      this.$object.bus\n        ._removeMatch(this._signalMatchRuleString(eventName))\n        .catch((error: unknown) => {\n          this.$object.bus.emit('error', error);\n        });\n      this.$object.bus._signals.removeListener(detailedEvent, proxyListener.fn);\n    });\n\n    this.on('newListener', (eventName: string) => {\n      const [signal, detailedEvent] = getEventDetails(eventName);\n\n      if (!signal || detailedEvent === null) {\n        return;\n      }\n\n      const proxyListener = this._getEventListener(signal);\n\n      if (proxyListener.refcount > 0) {\n        proxyListener.refcount += 1;\n        return;\n      }\n\n      proxyListener.refcount = 1;\n\n      this.$object.bus._addMatch(this._signalMatchRuleString(eventName)).catch((error: unknown) => {\n        this.$object.bus.emit('error', error);\n      });\n      this.$object.bus._signals.on(detailedEvent, proxyListener.fn);\n    });\n  }\n\n  _signalMatchRuleString(eventName: string): string {\n    return `type='signal',sender='${this.$object.name}',interface='${this.$name}',path='${this.$object.path}',member='${eventName}'`;\n  }\n\n  _getEventListener(signal: ProxySignalInfo): ProxyListener {\n    const existing = this.$listeners[signal.name];\n    if (existing) {\n      return existing;\n    }\n    const listener = new ProxyListener(signal, this);\n    this.$listeners[signal.name] = listener;\n    return listener;\n  }\n\n  static _fromXml(object: ProxyObject, xml: unknown): ProxyInterface | null {\n    if (!isRecord(xml) || !isRecord(xml.$) || !isInterfaceNameValid(xml.$.name)) {\n      return null;\n    }\n\n    const name = xml.$.name;\n    const iface = new ProxyInterface(name, object);\n\n    if (Array.isArray(xml.property)) {\n      for (const p of xml.property) {\n        // TODO validation\n        if (\n          isRecord(p) &&\n          isRecord(p.$) &&\n          typeof p.$.name === 'string' &&\n          typeof p.$.type === 'string'\n        ) {\n          iface.$properties.push({\n            name: p.$.name,\n            type: p.$.type,\n            access: typeof p.$.access === 'string' ? p.$.access : 'readwrite',\n          });\n        }\n      }\n    }\n\n    if (Array.isArray(xml.signal)) {\n      for (const s of xml.signal) {\n        if (!isRecord(s) || !isRecord(s.$) || !isMemberNameValid(s.$.name)) {\n          continue;\n        }\n        const signal: ProxySignalInfo = {\n          name: s.$.name,\n          signature: '',\n        };\n\n        if (Array.isArray(s.arg)) {\n          for (const a of s.arg) {\n            if (isRecord(a) && isRecord(a.$) && typeof a.$.type === 'string') {\n              // TODO signature validation\n              signal.signature += a.$.type;\n            }\n          }\n        }\n\n        iface.$signals.push(signal);\n      }\n    }\n\n    if (Array.isArray(xml.method)) {\n      for (const m of xml.method) {\n        if (!isRecord(m) || !isRecord(m.$) || !isMemberNameValid(m.$.name)) {\n          continue;\n        }\n        const method: ProxyMethodInfo = {\n          name: m.$.name,\n          inSignature: '',\n          outSignature: '',\n        };\n\n        if (Array.isArray(m.arg)) {\n          for (const a of m.arg) {\n            if (!isRecord(a) || !isRecord(a.$) || typeof a.$.type !== 'string') {\n              continue;\n            }\n            if (a.$.direction === 'in') {\n              method.inSignature += a.$.type;\n            } else if (a.$.direction === 'out') {\n              method.outSignature += a.$.type;\n            }\n          }\n        }\n\n        // TODO signature validation\n        iface.$methods.push(method);\n\n        const methodName = method.name;\n        const inSignature = method.inSignature;\n        const outSignature = method.outSignature;\n        Reflect.set(iface, methodName, (...args: unknown[]): Promise<unknown> => {\n          return object._callMethod(name, methodName, inSignature, outSignature, ...args);\n        });\n      }\n    }\n\n    return iface;\n  }\n}\n\nexport type ClientInterface = ProxyInterface;\n","import { DBusError } from '@/errors';\nimport { isRecord } from '@/guards';\nimport { createIntrospectParser } from '@/introspect-xml';\nimport { Message } from '@/message-type';\nimport { parseSignature } from '@/signature';\nimport { assertBusNameValid, assertObjectPathValid, isObjectPathValid } from '@/validators';\n\nimport { ProxyInterface } from './proxy-interface';\n\nimport type { MessageBus } from '@/bus';\nimport type { XMLParser } from 'fast-xml-parser';\n\nexport type ObjectPath = string;\n\n/**\n * A class that represents a proxy to a DBus object. The `ProxyObject` contains\n * `ProxyInterface`s and a list of `node`s which are object paths of child\n * objects. A `ProxyObject` is created through {@link\n * MessageBus#getProxyObject} for a given well-known name and object path.\n * An interface can be gotten through {@link ProxyObject#getInterface} and can\n * be used to call methods and receive signals for that interface.\n */\nexport class ProxyObject {\n  bus: MessageBus;\n  name: string;\n  path: ObjectPath;\n  nodes: ObjectPath[];\n  interfaces: Record<string, ProxyInterface>;\n  private readonly _parser: XMLParser;\n\n  /**\n   * Create a new `ProxyObject`. This constructor should not be called\n   * directly. Use {@link MessageBus#getProxyObject} to get a proxy object.\n   */\n  constructor(bus: MessageBus, name: string, path: string) {\n    assertBusNameValid(name);\n    assertObjectPathValid(path);\n    this.bus = bus;\n    this.name = name;\n    this.path = path;\n    this.nodes = [];\n    this.interfaces = {};\n    this._parser = createIntrospectParser();\n  }\n\n  /**\n   * Get a {@link ProxyInterface} for the given interface name.\n   *\n   * @param name {string} - the interface name to get.\n   * @throws {Error} Throws an error if the interface is not found on this object.\n   */\n  getInterface<T extends ProxyInterface = ProxyInterface>(name: string): T {\n    const iface = this.interfaces[name];\n    if (iface === undefined) {\n      throw new Error(`interface not found in proxy object: ${name}`);\n    }\n    return iface as T;\n  }\n\n  private _initXml(data: unknown): void {\n    if (!isRecord(data)) {\n      return;\n    }\n    const root = data.node;\n    if (!isRecord(root)) {\n      return;\n    }\n\n    if (Array.isArray(root.node)) {\n      for (const n of root.node) {\n        if (isRecord(n) && isRecord(n.$) && typeof n.$.name === 'string') {\n          const path = `${this.path}/${n.$.name}`;\n          if (isObjectPathValid(path)) {\n            this.nodes.push(path);\n          }\n        }\n      }\n    }\n\n    if (Array.isArray(root.interface)) {\n      for (const i of root.interface) {\n        const iface = ProxyInterface._fromXml(this, i);\n        if (iface !== null) {\n          this.interfaces[iface.$name] = iface;\n        }\n      }\n    }\n  }\n\n  async _init(xml?: string): Promise<this> {\n    if (xml) {\n      this._initXml(this._parser.parse(xml));\n\n      const nameOwnerMessage = new Message({\n        destination: 'org.freedesktop.DBus',\n        path: '/org/freedesktop/DBus',\n        interface: 'org.freedesktop.DBus',\n        member: 'GetNameOwner',\n        signature: 's',\n        body: [this.name],\n      });\n\n      try {\n        const msg = await this.bus.call(nameOwnerMessage);\n        const owner = msg?.body[0];\n        if (typeof owner === 'string') {\n          this.bus._nameOwners[this.name] = owner;\n        }\n      } catch (err) {\n        if (err instanceof DBusError && err.type === 'org.freedesktop.DBus.Error.NameHasNoOwner') {\n          return this;\n        }\n        throw err;\n      }\n      return this;\n    }\n\n    const introspectMessage = new Message({\n      destination: this.name,\n      path: this.path,\n      interface: 'org.freedesktop.DBus.Introspectable',\n      member: 'Introspect',\n      signature: '',\n      body: [],\n    });\n\n    const msg = await this.bus.call(introspectMessage);\n    const introspectXml = msg?.body[0];\n    if (typeof introspectXml === 'string') {\n      this._initXml(this._parser.parse(introspectXml));\n    }\n    return this;\n  }\n\n  _callMethod(\n    iface: string,\n    member: string,\n    inSignature: string,\n    outSignature: string,\n    ...args: unknown[]\n  ): Promise<unknown> {\n    const methodCallMessage = new Message({\n      destination: this.name,\n      interface: iface,\n      path: this.path,\n      member: member,\n      signature: inSignature,\n      body: args,\n    });\n\n    return this.bus.call(methodCallMessage).then((msg) => {\n      const outSignatureTree = parseSignature(outSignature);\n      if (outSignatureTree.length === 0) {\n        return null;\n      }\n      if (outSignatureTree.length === 1) {\n        return msg?.body[0];\n      }\n      return msg?.body;\n    });\n  }\n}\n","/**\n * @class\n * A class to represent DBus variants for both the client and service\n * interfaces. The {@link ProxyInterface} and [`Interface`]{@link\n * module:interface~Interface} methods, signals, and properties will use this\n * type to represent variant types. The user should use this class directly for\n * sending variants to methods if their signature expects the type to be a\n * variant.\n *\n * @example\n * let str = new Variant('s', 'hello');\n * let num = new Variant('d', 53);\n * let map = new Variant('a{ss}', { foo: 'bar' });\n * let list = new Variant('as', [ 'foo', 'bar' ]);\n */\nexport class Variant<T = unknown> {\n  signature: string;\n  value: T;\n\n  /**\n   * Construct a new `Variant` with the given signature and value.\n   * @param {string} signature - a DBus type signature for the `Variant`.\n   * @param {any} value - the value of the `Variant` with type specified by the type signature.\n   */\n  constructor();\n  constructor(signature: string, value: T);\n  constructor(signature?: string, value?: T) {\n    this.signature = signature ?? '';\n    this.value = value as T;\n  }\n}\n","/**\n * A module for exporting interfaces on a name on the message bus.\n *\n * @module interface\n */\nimport { EventEmitter } from 'node:events';\n\nimport { parseSignature, collapseSignature } from '@/signature';\nimport { assertInterfaceNameValid, assertMemberNameValid } from '@/validators';\nimport { Variant } from '@/variant';\n\nimport type {\n  IntrospectInterface,\n  IntrospectArg,\n  IntrospectAnnotation,\n  IntrospectProperty,\n  IntrospectMethod,\n  IntrospectSignal,\n} from '@/introspect-types';\nimport type { SignatureNode } from '@/signature';\n\n/**\n * Used for [`Interface`]{@link module:interface~Interface} [property]{@link\n * module:interface.property} options to specify that clients have read access\n * to the property.\n *\n * @static\n */\nexport const ACCESS_READ: PropertyAccess = 'read';\n\n/**\n * Used for [`Interface`]{@link module:interface~Interface} [property]{@link\n * module:interface.property} options to specify that clients have write access\n * to the property.\n *\n * @static\n */\nexport const ACCESS_WRITE: PropertyAccess = 'write';\n\n/**\n * Used for [`Interface`]{@link module:interface~Interface} [property]{@link\n * module:interface.property} options to specify that clients have read and\n * write access to the property.\n *\n * @static\n */\nexport const ACCESS_READWRITE: PropertyAccess = 'readwrite';\n\nexport type PropertyAccess = 'read' | 'write' | 'readwrite';\n\nexport interface PropertyOptions {\n  signature: string;\n  access?: PropertyAccess;\n  name?: string;\n  disabled?: boolean;\n}\n\nexport interface MethodOptions {\n  inSignature?: string;\n  outSignature?: string;\n  name?: string;\n  disabled?: boolean;\n  noReply?: boolean;\n}\n\nexport interface SignalOptions {\n  signature?: string;\n  name?: string;\n  disabled?: boolean;\n}\n\nexport interface ConfigureMembersOptions {\n  properties?: Record<string, PropertyOptions>;\n  methods?: Record<string, MethodOptions>;\n  signals?: Record<string, SignalOptions>;\n}\n\ntype InterfaceMethodFn = (...args: never[]) => unknown;\n\nexport interface PropertyOptionsResolved {\n  signature: string;\n  signatureTree: SignatureNode[];\n  access: PropertyAccess;\n  name: string;\n  disabled: boolean;\n}\n\nexport interface MethodOptionsResolved {\n  inSignature: string;\n  outSignature: string;\n  inSignatureTree: SignatureNode[];\n  outSignatureTree: SignatureNode[];\n  name: string;\n  disabled: boolean;\n  noReply: boolean;\n  fn: InterfaceMethodFn;\n}\n\nexport interface SignalOptionsResolved {\n  signature: string;\n  signatureTree: SignatureNode[];\n  name: string;\n  disabled: boolean;\n  fn: InterfaceMethodFn;\n}\n\nexport const invokeMethod = (\n  fn: InterfaceMethodFn,\n  thisArg: Interface,\n  args: unknown[],\n): unknown => {\n  // the stored method is callable with the message body; bridge the strict signature\n  const callable = fn as (...a: unknown[]) => unknown;\n  return callable.apply(thisArg, args);\n};\n\ntype PropertyDecoratorContext =\n  | ClassFieldDecoratorContext<Interface, unknown>\n  | ClassGetterDecoratorContext<Interface, unknown>\n  | ClassSetterDecoratorContext<Interface, unknown>\n  | ClassAccessorDecoratorContext<Interface, unknown>;\n\nexport interface DualPropertyDecorator {\n  (value: unknown, context: PropertyDecoratorContext): void;\n  (target: object, propertyKey: string | symbol): void;\n}\n\nexport interface DualMethodDecorator {\n  (value: InterfaceMethodFn, context: ClassMethodDecoratorContext<Interface>): void;\n  (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\n}\n\nexport interface DualSignalDecorator {\n  <T extends InterfaceMethodFn>(value: T, context: ClassMethodDecoratorContext<Interface>): T;\n  (target: object, propertyKey: string | symbol, descriptor: PropertyDescriptor): void;\n}\n\nconst isDecoratorContext = (value: unknown): value is DecoratorContext =>\n  typeof value === 'object' && value !== null && 'kind' in value;\n\nconst defineLegacyMember = (\n  target: object,\n  bag: '$properties' | '$methods' | '$signals',\n  key: string,\n  resolved: PropertyOptionsResolved | MethodOptionsResolved | SignalOptionsResolved,\n): void => {\n  const store = target as Record<string, Record<string, typeof resolved> | undefined>;\n  const bagObj: Record<string, typeof resolved> =\n    Object.prototype.hasOwnProperty.call(store, bag) && store[bag] ? store[bag] : { ...store[bag] };\n  store[bag] = bagObj;\n  bagObj[key] = resolved;\n};\n\nconst makePropertyResolved = (\n  options: PropertyOptions,\n  signatureTree: SignatureNode[],\n  name: string,\n): PropertyOptionsResolved => {\n  assertMemberNameValid(name);\n  return {\n    signature: options.signature,\n    signatureTree,\n    access: options.access ?? ACCESS_READWRITE,\n    name,\n    disabled: !!options.disabled,\n  };\n};\n\nconst makeMethodResolved = (\n  options: MethodOptions,\n  name: string,\n  fn: InterfaceMethodFn,\n): MethodOptionsResolved => {\n  assertMemberNameValid(name);\n  return {\n    name,\n    disabled: !!options.disabled,\n    noReply: !!options.noReply,\n    inSignature: options.inSignature ?? '',\n    outSignature: options.outSignature ?? '',\n    inSignatureTree: parseSignature(options.inSignature ?? ''),\n    outSignatureTree: parseSignature(options.outSignature ?? ''),\n    fn,\n  };\n};\n\nconst makeSignalResolved = (\n  options: SignalOptions,\n  name: string,\n  fn: InterfaceMethodFn,\n): SignalOptionsResolved => {\n  assertMemberNameValid(name);\n  return {\n    name,\n    signature: options.signature ?? '',\n    signatureTree: parseSignature(options.signature ?? ''),\n    disabled: !!options.disabled,\n    fn,\n  };\n};\n\nconst makeSignalWrapper = (resolved: SignalOptionsResolved) =>\n  function (this: Interface, ...args: unknown[]): unknown {\n    if (resolved.disabled) {\n      throw new Error('tried to call a disabled signal');\n    }\n    const result = invokeMethod(resolved.fn, this, args);\n    this.$emitter.emit('signal', resolved, result);\n    return undefined;\n  };\n\n/**\n * A decorator function to define an [`Interface`]{@link\n * module:interface~Interface} class member as a property.  The property will\n * be gotten and set from the class when users call the standard DBus methods\n * `org.freedesktop.DBus.Properties.Get`,\n * `org.freedesktop.DBus.Properties.Set`, and\n * `org.freedesktop.DBus.Properties.GetAll`. The property getters and setters\n * may throw a {@link DBusError} with an error name and message to return the\n * error to the client.\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#type-system}\n *\n * @static\n *\n * @param {object} options - The options for this property.\n * @param {string} options.signature - The DBus type signature for this property.\n * @param {access} [options.access=ACCESS_READWRITE] - The read and write\n * access of the property for clients (effects `Get` and `Set` property methods).\n * @param {string} [options.name] - The name of this property on the bus.\n * Defaults to the name of the class member being decorated.\n * @param {bool} [options.disabled=false] - Whether or not this property\n * will be advertised on the bus.\n */\nexport const property = (options: PropertyOptions): DualPropertyDecorator => {\n  if (!options.signature) {\n    throw new Error('missing signature for property');\n  }\n  const signatureTree = parseSignature(options.signature);\n  return (target: unknown, context: unknown): void => {\n    if (isDecoratorContext(context)) {\n      const ctx = context as PropertyDecoratorContext;\n      const key = String(ctx.name);\n      const resolved = makePropertyResolved(options, signatureTree, options.name ?? key);\n      ctx.addInitializer(function (this: Interface) {\n        (this.$properties ??= {})[key] = resolved;\n      });\n    } else {\n      const key = String(context as string | symbol);\n      const resolved = makePropertyResolved(options, signatureTree, options.name ?? key);\n      defineLegacyMember(target as object, '$properties', key, resolved);\n    }\n  };\n};\n\n/**\n * A decorator function to define an [`Interface`]{@link\n * module:interface~Interface} class member as a method. The method will be\n * called when the client calls it on the bus with the given arguments with\n * types specified by the `inSignature` in the method options.  The method\n * should return a result specified by the `outSignature` which will be\n * returned to the client over the message bus. If multiple output parameters\n * are specified in the `outSignature`, they should be returned within an\n * array.\n *\n * The method may also be `async` or return a `Promise` with the result and the\n * reply will be sent once the promise returns with a response body.\n *\n * The method may throw a {@link DBusError} with an error name and\n * message to return the error to the client.\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#type-system}\n *\n * @static\n *\n * @param {object} options - The options for this method.\n * @param {string} [options.inSignature=\"\"] - The DBus type signature for the\n * input to this method.\n * @param {string} [options.outSignature=\"\"] - The DBus type signature for the\n * output of this method.\n * @param {string} [options.name] - The name of this method on the bus.\n * Defaults to the name of the class member being decorated.\n * @param {bool} [options.disabled=false] - Whether or not this property\n * will be advertised on the bus.\n */\nexport const method = (options: MethodOptions = {}): DualMethodDecorator => {\n  return (target: unknown, context: unknown, descriptor?: PropertyDescriptor): void => {\n    if (isDecoratorContext(context)) {\n      const ctx = context as ClassMethodDecoratorContext<Interface>;\n      const key = String(ctx.name);\n      const resolved = makeMethodResolved(\n        options,\n        options.name ?? key,\n        target as InterfaceMethodFn,\n      );\n      ctx.addInitializer(function (this: Interface) {\n        (this.$methods ??= {})[key] = resolved;\n      });\n    } else {\n      const key = String(context as string | symbol);\n      const resolved = makeMethodResolved(\n        options,\n        options.name ?? key,\n        descriptor?.value as InterfaceMethodFn,\n      );\n      defineLegacyMember(target as object, '$methods', key, resolved);\n    }\n  };\n};\n\n/**\n * A decorator function to define an [`Interface`]{@link\n * module:interface~Interface} class member as a signal. To emit the signal on\n * the bus to listeners, just call the decorated method and the signal will be\n * emitted with the returned value with types specified by the `signature` in\n * the signal options. If the signal has multiple output parameters, they\n * should be returned in an array.\n * @see {@link https://dbus.freedesktop.org/doc/dbus-specification.html#type-system}\n *\n * @static\n *\n * @param {object} options - The options for this property.\n * @param {string} options.signature - The DBus type signature for this signal.\n * @param {string} [options.name] - The name of this signal on the bus.\n * Defaults to the name of the class member being decorated.\n * @param {bool} [options.disabled=false] - Whether or not this property\n * will be advertised on the bus.\n */\nexport const signal = (options: SignalOptions = {}): DualSignalDecorator => {\n  const decorate = (\n    target: unknown,\n    context: unknown,\n    descriptor?: PropertyDescriptor,\n  ): unknown => {\n    if (isDecoratorContext(context)) {\n      const ctx = context as ClassMethodDecoratorContext<Interface>;\n      const key = String(ctx.name);\n      const resolved = makeSignalResolved(\n        options,\n        options.name ?? key,\n        target as InterfaceMethodFn,\n      );\n      ctx.addInitializer(function (this: Interface) {\n        (this.$signals ??= {})[key] = resolved;\n      });\n      return makeSignalWrapper(resolved);\n    }\n    const key = String(context as string | symbol);\n    const resolved = makeSignalResolved(\n      options,\n      options.name ?? key,\n      descriptor?.value as InterfaceMethodFn,\n    );\n    defineLegacyMember(target as object, '$signals', key, resolved);\n    if (descriptor) {\n      descriptor.value = makeSignalWrapper(resolved);\n    }\n    return descriptor;\n  };\n  return decorate as unknown as DualSignalDecorator;\n};\n\n/**\n * The `Interface` is an abstract class used for defining and exporting an\n * interface on a DBus name. You can override this class to make your own DBus\n * interfaces. Use the decorators within this module to define the\n * [properties]{@link module:interface.property}, [methods]{@link\n * module:interface.method}, and [signals]{@link module:interface.signal} that\n * the interface has. These will be advertised to users in the introspection\n * xml gotten by the `org.freedesktop.DBus.Introspect` method on the name. See\n * the documentation for the decorators for more information. The constructor\n * of the `Interface` should call `super()` with the name of the interface that\n * will be exported.\n *\n * @example\n * class MyInterface extends Interface {\n *    constructor() {\n *      super('org.test.interface_name');\n *    }\n *    // define properties, methods, and signals with decorated functions\n * }\n * let bus = dbus.sessionBus();\n * let name = await bus.requestName('org.test.bus_name');\n * let iface = new MyInterface();\n * name.export('/org/test/path', iface);\n */\ninterface InterfaceEmitterEvents {\n  signal: [options: SignalOptionsResolved, result: unknown];\n  'properties-changed': [\n    changedProperties: Record<string, Variant>,\n    invalidatedProperties: string[],\n  ];\n}\n\nexport class Interface extends EventEmitter {\n  $name: string;\n  $emitter: EventEmitter<InterfaceEmitterEvents>;\n  $properties?: Record<string, PropertyOptionsResolved>;\n  $methods?: Record<string, MethodOptionsResolved>;\n  $signals?: Record<string, SignalOptionsResolved>;\n\n  /**\n   * Create an interface. This should be called with the name of the interface\n   * in the class that extends it.\n   */\n  constructor(name: string) {\n    super();\n    assertInterfaceNameValid(name);\n    this.$name = name;\n    this.$emitter = new EventEmitter<InterfaceEmitterEvents>();\n  }\n\n  /**\n   * An alternative to the decorator functions to configure\n   * [`Interface`]{@link module:interface~Interface} DBus members when\n   * decorators cannot be supported.\n   *\n   * *Calling this method twice on the same `Interface` or mixing this method\n   * with the decorator interface will result in undefined behavior that may be\n   * specified at a future time.*\n   *\n   * @static\n   * @param members {Object} - Member configuration object.\n   */\n  static configureMembers(members: ConfigureMembersOptions): void {\n    const properties = members.properties ?? {};\n    const methods = members.methods ?? {};\n    const signals = members.signals ?? {};\n\n    // configureMembers operates on arbitrary member names; access methods on the\n    // prototype dynamically by their configured key\n    const protoFns = this.prototype as unknown as Record<string, InterfaceMethodFn>;\n    const protoProps: Record<string, PropertyOptionsResolved> = {};\n    const protoMethods: Record<string, MethodOptionsResolved> = {};\n    const protoSignals: Record<string, SignalOptionsResolved> = {};\n\n    for (const k of Object.keys(properties)) {\n      const options = properties[k];\n      if (options === undefined) {\n        continue;\n      }\n      const name = options.name ?? k;\n      const access = options.access ?? ACCESS_READWRITE;\n      if (!options.signature) {\n        throw new Error('missing signature for property');\n      }\n      assertMemberNameValid(name);\n      protoProps[name] = {\n        signature: options.signature,\n        signatureTree: parseSignature(options.signature),\n        access,\n        name,\n        disabled: !!options.disabled,\n      };\n    }\n\n    for (const k of Object.keys(methods)) {\n      const options = methods[k];\n      if (options === undefined) {\n        continue;\n      }\n      const name = options.name ?? k;\n      assertMemberNameValid(name);\n      const fn = protoFns[k];\n      if (typeof fn !== 'function') {\n        throw new Error(`configureMembers: no method '${k}' found on the class`);\n      }\n      protoMethods[name] = {\n        name,\n        disabled: !!options.disabled,\n        noReply: !!options.noReply,\n        inSignature: options.inSignature ?? '',\n        outSignature: options.outSignature ?? '',\n        inSignatureTree: parseSignature(options.inSignature ?? ''),\n        outSignatureTree: parseSignature(options.outSignature ?? ''),\n        fn,\n      };\n    }\n\n    for (const k of Object.keys(signals)) {\n      const options = signals[k];\n      if (options === undefined) {\n        continue;\n      }\n      const name = options.name ?? k;\n      assertMemberNameValid(name);\n      const fn = protoFns[k];\n      if (typeof fn !== 'function') {\n        throw new Error(`configureMembers: no method '${k}' found on the class`);\n      }\n      const resolved: SignalOptionsResolved = {\n        name,\n        signature: options.signature ?? '',\n        signatureTree: parseSignature(options.signature ?? ''),\n        disabled: !!options.disabled,\n        fn,\n      };\n      protoFns[k] = function (this: Interface, ...args: unknown[]): unknown {\n        if (resolved.disabled) {\n          throw new Error('tried to call a disabled signal');\n        }\n        const result = invokeMethod(resolved.fn, this, args);\n        this.$emitter.emit('signal', resolved, result);\n        return undefined;\n      };\n      protoSignals[name] = resolved;\n    }\n\n    this.prototype.$properties = protoProps;\n    this.prototype.$methods = protoMethods;\n    this.prototype.$signals = protoSignals;\n  }\n\n  /**\n   * Emit the `PropertiesChanged` signal on an [`Interface`s]{@link\n   * module:interface~Interface} associated standard\n   * `org.freedesktop.DBus.Properties` interface with a map of new values and\n   * invalidated properties. Pass the properties as JavaScript values.\n   *\n   * @static\n   * @example\n   * Interface.emitPropertiesChanged({ SomeProperty: 'bar' }, ['InvalidedProperty']);\n   *\n   * @param {module:interface~Interface} - the `Interface` to emit the `PropertiesChanged` signal on\n   * @param {Object} - A map of property names and new property values that are changed.\n   * @param {string[]} - A list of invalidated properties.\n   */\n  static emitPropertiesChanged(\n    iface: Interface,\n    changedProperties: Record<string, unknown>,\n    invalidatedProperties: string[] = [],\n  ): void {\n    if (\n      !Array.isArray(invalidatedProperties) ||\n      !invalidatedProperties.every((p) => typeof p === 'string')\n    ) {\n      throw new Error('invalidated properties must be an array of strings');\n    }\n\n    // we transform them to variants here based on property signatures so they\n    // don't have to\n    const properties = iface.$properties ?? {};\n    const changedPropertiesVariants: Record<string, Variant> = {};\n    for (const p of Object.keys(changedProperties)) {\n      const propOptions = properties[p];\n      if (propOptions === undefined) {\n        throw new Error(`got properties changed with unknown property: ${p}`);\n      }\n      changedPropertiesVariants[p] = new Variant(propOptions.signature, changedProperties[p]);\n    }\n    iface.$emitter.emit('properties-changed', changedPropertiesVariants, invalidatedProperties);\n  }\n\n  $introspect(): IntrospectInterface {\n    // TODO cache xml when the interface is declared\n    const xml: IntrospectInterface = {\n      $: {\n        name: this.$name,\n      },\n    };\n\n    const properties = this.$properties ?? {};\n    const propertyXml: IntrospectProperty[] = [];\n    for (const p of Object.keys(properties)) {\n      const property = properties[p];\n      if (property === undefined || property.disabled) {\n        continue;\n      }\n      propertyXml.push({\n        $: {\n          name: property.name,\n          type: property.signature,\n          access: property.access,\n        },\n      });\n    }\n    if (propertyXml.length) {\n      xml.property = propertyXml;\n    }\n\n    const methods = this.$methods ?? {};\n    const methodXml: IntrospectMethod[] = [];\n    for (const m of Object.keys(methods)) {\n      const methodOptions = methods[m];\n      if (methodOptions === undefined || methodOptions.disabled) {\n        continue;\n      }\n\n      const args: IntrospectArg[] = [];\n      for (const signatureNode of methodOptions.inSignatureTree) {\n        args.push({\n          $: {\n            direction: 'in',\n            type: collapseSignature(signatureNode),\n          },\n        });\n      }\n      for (const signatureNode of methodOptions.outSignatureTree) {\n        args.push({\n          $: {\n            direction: 'out',\n            type: collapseSignature(signatureNode),\n          },\n        });\n      }\n\n      const annotations: IntrospectAnnotation[] = [];\n      if (methodOptions.noReply) {\n        annotations.push({\n          $: {\n            name: 'org.freedesktop.DBus.Method.NoReply',\n            value: 'true',\n          },\n        });\n      }\n\n      methodXml.push({\n        $: { name: methodOptions.name },\n        arg: args,\n        annotation: annotations,\n      });\n    }\n    if (methodXml.length) {\n      xml.method = methodXml;\n    }\n\n    const signals = this.$signals ?? {};\n    const signalXml: IntrospectSignal[] = [];\n    for (const s of Object.keys(signals)) {\n      const signalOptions = signals[s];\n      if (signalOptions === undefined || signalOptions.disabled) {\n        continue;\n      }\n      const args: IntrospectArg[] = [];\n      for (const signatureNode of signalOptions.signatureTree) {\n        args.push({\n          $: {\n            type: collapseSignature(signatureNode),\n          },\n        });\n      }\n      signalXml.push({\n        $: { name: signalOptions.name },\n        arg: args,\n      });\n    }\n    if (signalXml.length) {\n      xml.signal = signalXml;\n    }\n\n    return xml;\n  }\n}\n","import { readFileSync } from 'node:fs';\n\nimport { MessageType } from '@/constants';\nimport { DBusError } from '@/errors';\nimport { Message } from '@/message-type';\nimport { isObjectPathValid, isInterfaceNameValid, isMemberNameValid } from '@/validators';\nimport { Variant } from '@/variant';\n\nimport { ACCESS_READ, ACCESS_WRITE, ACCESS_READWRITE, invokeMethod } from './interface';\n\nimport type { ServiceBus } from './types';\n\nconst { METHOD_RETURN } = MessageType;\n\nconst INVALID_ARGS = 'org.freedesktop.DBus.Error.InvalidArgs';\n\nconst errorStack = (e: unknown): string => {\n  return e instanceof Error ? (e.stack ?? e.message) : String(e);\n};\n\nconst sendServiceError = (bus: ServiceBus, msg: Message, errorMessage: string): void => {\n  bus.send(\n    Message.newError(msg, 'com.github.dbus_next.ServiceError', `Service error: ${errorMessage}`),\n  );\n};\n\nconst handleIntrospect = (bus: ServiceBus, msg: Message, path: string): void => {\n  bus.send(Message.newMethodReturn(msg, 's', [bus._introspect(path)]));\n};\n\nconst handleGetProperty = (bus: ServiceBus, msg: Message, path: string): void => {\n  const ifaceName = msg.body[0];\n  const prop = msg.body[1];\n\n  if (!bus._serviceObjects[path]) {\n    bus.send(Message.newError(msg, INVALID_ARGS, `Path not exported on bus: '${path}'`));\n    return;\n  }\n\n  const obj = bus._getServiceObject(path);\n  const iface = typeof ifaceName === 'string' ? obj.interfaces[ifaceName] : undefined;\n  // TODO An empty string may be provided for the interface name; in this case,\n  // if there are multiple properties on an object with the same name, the\n  // results are undefined (picking one by according to an arbitrary\n  // deterministic rule, or returning an error, are the reasonable\n  // possibilities).\n  if (!iface) {\n    bus.send(Message.newError(msg, INVALID_ARGS, `No such interface: '${String(ifaceName)}'`));\n    return;\n  }\n\n  const properties = iface.$properties ?? {};\n\n  let options = null;\n  let propertyKey = null;\n  for (const k of Object.keys(properties)) {\n    const candidate = properties[k];\n    if (candidate !== undefined && candidate.name === prop && !candidate.disabled) {\n      options = candidate;\n      propertyKey = k;\n      break;\n    }\n  }\n  if (options === null || propertyKey === null) {\n    bus.send(Message.newError(msg, INVALID_ARGS, `No such property: '${String(prop)}'`));\n    return;\n  }\n\n  let propertyValue: unknown;\n\n  try {\n    propertyValue = Reflect.get(iface, propertyKey);\n  } catch (e) {\n    if (e instanceof DBusError) {\n      bus.send(Message.newError(msg, e.type, e.text));\n    } else {\n      sendServiceError(bus, msg, `The service threw an error.\\n${errorStack(e)}`);\n    }\n    return;\n  }\n\n  if (propertyValue instanceof DBusError) {\n    bus.send(Message.newError(msg, propertyValue.type, propertyValue.text));\n    return;\n  } else if (propertyValue === undefined) {\n    sendServiceError(bus, msg, 'tried to get a property that is not set: ' + String(prop));\n    return;\n  }\n\n  if (!(options.access === ACCESS_READWRITE || options.access === ACCESS_READ)) {\n    bus.send(\n      Message.newError(msg, INVALID_ARGS, `Property does not have read access: '${String(prop)}'`),\n    );\n  }\n\n  const body = new Variant(options.signature, propertyValue);\n\n  bus.send(Message.newMethodReturn(msg, 'v', [body]));\n};\n\nconst handleGetAllProperties = (bus: ServiceBus, msg: Message, path: string): void => {\n  const ifaceName = msg.body[0];\n\n  if (!bus._serviceObjects[path]) {\n    bus.send(Message.newError(msg, INVALID_ARGS, `Path not exported on bus: '${path}'`));\n    return;\n  }\n\n  const obj = bus._getServiceObject(path);\n  const iface = typeof ifaceName === 'string' ? obj.interfaces[ifaceName] : undefined;\n\n  const result: Record<string, Variant> = {};\n  if (iface) {\n    const properties = iface.$properties ?? {};\n    for (const k of Object.keys(properties)) {\n      const p = properties[k];\n      if (\n        p === undefined ||\n        !(p.access === ACCESS_READ || p.access === ACCESS_READWRITE) ||\n        p.disabled\n      ) {\n        continue;\n      }\n\n      let value: unknown;\n      try {\n        value = Reflect.get(iface, k);\n      } catch (e) {\n        if (e instanceof DBusError) {\n          bus.send(Message.newError(msg, e.type, e.text));\n        } else {\n          sendServiceError(bus, msg, `The service threw an error.\\n${errorStack(e)}`);\n        }\n        return;\n      }\n      if (value instanceof DBusError) {\n        bus.send(Message.newError(msg, value.type, value.text));\n        return;\n      } else if (value === undefined) {\n        sendServiceError(bus, msg, 'tried to get a property that is not set: ' + p.name);\n        return;\n      }\n\n      result[p.name] = new Variant(p.signature, value);\n    }\n  }\n\n  bus.send(Message.newMethodReturn(msg, 'a{sv}', [result]));\n};\n\nconst handleSetProperty = (bus: ServiceBus, msg: Message, path: string): void => {\n  const ifaceName = msg.body[0];\n  const prop = msg.body[1];\n  const value = msg.body[2];\n\n  if (!bus._serviceObjects[path]) {\n    bus.send(Message.newError(msg, INVALID_ARGS, `Path not exported on bus: '${path}'`));\n    return;\n  }\n\n  const obj = bus._getServiceObject(path);\n  const iface = typeof ifaceName === 'string' ? obj.interfaces[ifaceName] : undefined;\n\n  if (!iface) {\n    bus.send(Message.newError(msg, INVALID_ARGS, `Interface not found: '${String(ifaceName)}'`));\n    return;\n  }\n\n  const properties = iface.$properties ?? {};\n  let options = null;\n  let propertyKey = null;\n  for (const k of Object.keys(properties)) {\n    const candidate = properties[k];\n    if (candidate !== undefined && candidate.name === prop && !candidate.disabled) {\n      options = candidate;\n      propertyKey = k;\n      break;\n    }\n  }\n\n  if (options === null || propertyKey === null) {\n    bus.send(Message.newError(msg, INVALID_ARGS, `No such property: '${String(prop)}'`));\n    return;\n  }\n\n  if (!(options.access === ACCESS_WRITE || options.access === ACCESS_READWRITE)) {\n    bus.send(\n      Message.newError(msg, INVALID_ARGS, `Property does not have write access: '${String(prop)}'`),\n    );\n  }\n\n  if (!(value instanceof Variant)) {\n    bus.send(\n      Message.newError(\n        msg,\n        INVALID_ARGS,\n        `Cannot set property '${String(prop)}' with a non-variant value`,\n      ),\n    );\n    return;\n  }\n\n  if (value.signature !== options.signature) {\n    bus.send(\n      Message.newError(\n        msg,\n        INVALID_ARGS,\n        `Cannot set property '${String(prop)}' with signature '${value.signature}' (expected '${options.signature}')`,\n      ),\n    );\n    return;\n  }\n\n  try {\n    Reflect.set(iface, propertyKey, value.value);\n  } catch (e) {\n    if (e instanceof DBusError) {\n      bus.send(Message.newError(msg, e.type, e.text));\n    } else {\n      sendServiceError(bus, msg, `The service threw an error.\\n${errorStack(e)}`);\n    }\n    return;\n  }\n\n  bus.send(Message.newMethodReturn(msg, '', []));\n};\n\nconst handleStdIfaces = (bus: ServiceBus, msg: Message): boolean => {\n  const { member, path, signature } = msg;\n\n  const ifaceName = msg.interface;\n\n  if (!isInterfaceNameValid(ifaceName)) {\n    bus.send(Message.newError(msg, INVALID_ARGS, `Invalid interface name: '${String(ifaceName)}'`));\n    return true;\n  }\n\n  if (!isMemberNameValid(member)) {\n    bus.send(Message.newError(msg, INVALID_ARGS, `Invalid member name: '${String(member)}'`));\n    return true;\n  }\n\n  if (!isObjectPathValid(path)) {\n    bus.send(Message.newError(msg, INVALID_ARGS, `Invalid path name: '${String(path)}'`));\n    return true;\n  }\n\n  if (\n    ifaceName === 'org.freedesktop.DBus.Introspectable' &&\n    member === 'Introspect' &&\n    !signature\n  ) {\n    handleIntrospect(bus, msg, path);\n    return true;\n  } else if (ifaceName === 'org.freedesktop.DBus.Properties') {\n    if (member === 'Get' && signature === 'ss') {\n      handleGetProperty(bus, msg, path);\n      return true;\n    } else if (member === 'Set' && signature === 'ssv') {\n      handleSetProperty(bus, msg, path);\n      return true;\n    } else if (member === 'GetAll') {\n      handleGetAllProperties(bus, msg, path);\n      return true;\n    }\n  } else if (ifaceName === 'org.freedesktop.DBus.Peer') {\n    if (member === 'Ping' && !signature) {\n      bus._connection.message({\n        type: METHOD_RETURN,\n        serial: bus._serial++,\n        replySerial: msg.serial ?? undefined,\n        destination: msg.sender,\n      });\n      return true;\n    } else if (member === 'GetMachineId' && !signature) {\n      const machineId = readFileSync('/var/lib/dbus/machine-id').toString().trim();\n      bus._connection.message({\n        type: METHOD_RETURN,\n        serial: bus._serial++,\n        replySerial: msg.serial ?? undefined,\n        destination: msg.sender,\n        signature: 's',\n        body: [machineId],\n      });\n      return true;\n    }\n  }\n\n  return false;\n};\n\nexport const handleMessage = (msg: Message, bus: ServiceBus): boolean => {\n  const { path } = msg;\n  const member = msg.member;\n  const signature = msg.signature || '';\n\n  const ifaceName = msg.interface;\n\n  if (handleStdIfaces(bus, msg)) {\n    return true;\n  }\n\n  if (path === undefined || !bus._serviceObjects[path]) {\n    return false;\n  }\n\n  const obj = bus._getServiceObject(path);\n  const iface = typeof ifaceName === 'string' ? obj.interfaces[ifaceName] : undefined;\n\n  if (!iface) {\n    return false;\n  }\n\n  const methods = iface.$methods ?? {};\n  for (const m of Object.keys(methods)) {\n    const method = methods[m];\n    if (method === undefined) {\n      continue;\n    }\n\n    const handleError = (e: unknown): void => {\n      if (e instanceof DBusError) {\n        bus.send(Message.newError(msg, e.type, e.text));\n      } else {\n        sendServiceError(bus, msg, `The service threw an error.\\n${errorStack(e)}`);\n      }\n    };\n\n    if (method.name === member && method.inSignature === signature) {\n      let result: unknown;\n      try {\n        result = invokeMethod(method.fn, iface, msg.body);\n      } catch (e) {\n        handleError(e);\n        return true;\n      }\n\n      const sendReply = (body: unknown): void => {\n        if (method.noReply) return;\n        let replyBody: unknown[];\n        if (body === undefined) {\n          replyBody = [];\n        } else if (method.outSignatureTree.length === 1) {\n          replyBody = [body];\n        } else if (method.outSignatureTree.length === 0) {\n          sendServiceError(\n            bus,\n            msg,\n            `method ${iface.$name}.${method.name} was not expected to return a body.`,\n          );\n          return;\n        } else if (!Array.isArray(body)) {\n          sendServiceError(\n            bus,\n            msg,\n            `method ${iface.$name}.${method.name} expected to return multiple arguments in an array (signature: '${method.outSignature}')`,\n          );\n          return;\n        } else {\n          replyBody = body;\n        }\n\n        if (method.outSignatureTree.length !== replyBody.length) {\n          sendServiceError(\n            bus,\n            msg,\n            `method ${iface.$name}.${m} returned the wrong number of arguments (got ${replyBody.length} expected ${method.outSignatureTree.length}) for signature '${method.outSignature}'`,\n          );\n          return;\n        }\n\n        bus.send(Message.newMethodReturn(msg, method.outSignature, replyBody));\n      };\n\n      if (result instanceof Promise) {\n        result.then(sendReply).catch(handleError);\n      } else {\n        sendReply(result);\n      }\n\n      return true;\n    }\n  }\n\n  return false;\n};\n","import { Message } from '@/message-type';\nimport { assertObjectPathValid } from '@/validators';\n\nimport { Interface } from './interface';\n\nimport type { SignalOptionsResolved } from './interface';\nimport type { ServiceBus } from './types';\nimport type { IntrospectInterface } from '@/introspect-types';\nimport type { Variant } from '@/variant';\n\ntype PropertiesChangedHandler = (\n  changedProperties: Record<string, Variant>,\n  invalidatedProperties: string[],\n) => void;\ntype SignalHandler = (options: SignalOptionsResolved, result: unknown) => void;\n\nexport class ServiceObject {\n  path: string;\n  bus: ServiceBus;\n  interfaces: Record<string, Interface>;\n  private _handlers: Record<\n    string,\n    { propertiesChanged: PropertiesChangedHandler; signal: SignalHandler }\n  >;\n\n  constructor(path: string, bus: ServiceBus) {\n    assertObjectPathValid(path);\n    this.path = path;\n    this.bus = bus;\n    this.interfaces = {};\n    this._handlers = {};\n  }\n\n  addInterface(iface: Interface): void {\n    if (!(iface instanceof Interface)) {\n      throw new Error(\n        `object.addInterface takes an Interface as the first argument (got ${String(iface)})`,\n      );\n    }\n    if (this.interfaces[iface.$name]) {\n      throw new Error(`an interface with name '${iface.$name}' is already exported on this object`);\n    }\n    this.interfaces[iface.$name] = iface;\n\n    const propertiesChangedHandler: PropertiesChangedHandler = (\n      changedProperties,\n      invalidatedProperties,\n    ) => {\n      const body = [iface.$name, changedProperties, invalidatedProperties];\n      this.bus.send(\n        Message.newSignal(\n          this.path,\n          'org.freedesktop.DBus.Properties',\n          'PropertiesChanged',\n          'sa{sv}as',\n          body,\n        ),\n      );\n    };\n\n    const signalHandler: SignalHandler = (options, result) => {\n      // TODO lots of repeated code with the method handler here\n      const { signature, signatureTree, name } = options;\n      let body: unknown[];\n      if (result === undefined) {\n        body = [];\n      } else if (signatureTree.length === 1) {\n        body = [result];\n      } else if (!Array.isArray(result)) {\n        throw new Error(\n          `signal ${iface.$name}.${name} expected to return multiple arguments in an array (signature: '${signature}')`,\n        );\n      } else {\n        body = result;\n      }\n\n      if (signatureTree.length !== body.length) {\n        throw new Error(\n          `signal ${iface.$name}.${name} returned the wrong number of arguments (got ${body.length} expected ${signatureTree.length}) for signature '${signature}'`,\n        );\n      }\n\n      this.bus.send(Message.newSignal(this.path, iface.$name, name, signature, body));\n    };\n\n    this._handlers[iface.$name] = {\n      propertiesChanged: propertiesChangedHandler,\n      signal: signalHandler,\n    };\n\n    iface.$emitter.on('signal', signalHandler);\n    iface.$emitter.on('properties-changed', propertiesChangedHandler);\n  }\n\n  removeInterface(iface: Interface): void {\n    if (!(iface instanceof Interface)) {\n      throw new Error(\n        `object.removeInterface takes an Interface as the first argument (got ${String(iface)})`,\n      );\n    }\n    if (!this.interfaces[iface.$name]) {\n      throw new Error(`Interface ${iface.$name} not exported on this object`);\n    }\n    const handlers = this._handlers[iface.$name];\n    if (handlers !== undefined) {\n      iface.$emitter.removeListener('signal', handlers.signal);\n      iface.$emitter.removeListener('properties-changed', handlers.propertiesChanged);\n    }\n    delete this._handlers[iface.$name];\n    delete this.interfaces[iface.$name];\n  }\n\n  introspect(): IntrospectInterface[] {\n    const interfaces = ServiceObject.defaultInterfaces();\n\n    for (const i of Object.keys(this.interfaces)) {\n      const iface = this.interfaces[i];\n      if (iface !== undefined) {\n        interfaces.push(iface.$introspect());\n      }\n    }\n\n    return interfaces;\n  }\n\n  static defaultInterfaces(): IntrospectInterface[] {\n    return [\n      {\n        $: { name: 'org.freedesktop.DBus.Introspectable' },\n        method: [\n          {\n            $: { name: 'Introspect' },\n            arg: [\n              {\n                $: { name: 'data', direction: 'out', type: 's' },\n              },\n            ],\n          },\n        ],\n      },\n      {\n        $: { name: 'org.freedesktop.DBus.Peer' },\n        method: [\n          {\n            $: { name: 'GetMachineId' },\n            arg: [{ $: { direction: 'out', name: 'machine_uuid', type: 's' } }],\n          },\n          {\n            $: { name: 'Ping' },\n          },\n        ],\n      },\n      {\n        $: { name: 'org.freedesktop.DBus.Properties' },\n        method: [\n          {\n            $: { name: 'Get' },\n            arg: [\n              { $: { direction: 'in', type: 's' } },\n              { $: { direction: 'in', type: 's' } },\n              { $: { direction: 'out', type: 'v' } },\n            ],\n          },\n          {\n            $: { name: 'Set' },\n            arg: [\n              { $: { direction: 'in', type: 's' } },\n              { $: { direction: 'in', type: 's' } },\n              { $: { direction: 'in', type: 'v' } },\n            ],\n          },\n          {\n            $: { name: 'GetAll' },\n            arg: [\n              { $: { direction: 'in', type: 's' } },\n              { $: { direction: 'out', type: 'a{sv}' } },\n            ],\n          },\n        ],\n        signal: [\n          {\n            $: { name: 'PropertiesChanged' },\n            arg: [{ $: { type: 's' } }, { $: { type: 'a{sv}' } }, { $: { type: 'as' } }],\n          },\n        ],\n      },\n    ];\n  }\n}\n","import { EventEmitter } from 'node:events';\n\nimport { ProxyObject } from '@/client';\nimport { MessageType, MessageFlag } from '@/constants';\nimport { DBusError } from '@/errors';\nimport { createIntrospectBuilder } from '@/introspect-xml';\nimport { Message } from '@/message-type';\nimport {\n  ServiceObject,\n  handleMessage as handleMethod,\n  type ServiceBus,\n  type Interface,\n} from '@/service';\nimport { assertBusNameValid, assertObjectPathValid } from '@/validators';\n\nimport type { DBusConnection } from '@/connection';\nimport type { IntrospectInterface } from '@/introspect-types';\nimport type { XMLBuilder } from 'fast-xml-builder';\n\nconst { METHOD_CALL, METHOD_RETURN, ERROR, SIGNAL } = MessageType;\nconst { NO_REPLY_EXPECTED } = MessageFlag;\n\nconst xmlHeader =\n  '<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" \"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\\n';\nconst nameOwnerMatchRule =\n  \"type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',path='/org/freedesktop/DBus',member='NameOwnerChanged'\";\n\ninterface IntrospectDocument {\n  node: {\n    $?: { name?: string };\n    node: Array<{ $: { name: string } }>;\n    interface?: IntrospectInterface[];\n  };\n}\n\ninterface MessageBusEvents {\n  connect: [];\n  message: [message: Message];\n}\n\n/**\n * @class\n * The `MessageBus` is a class for interacting with a DBus message bus capable\n * of requesting a service [`Name`]{@link module:interface~Name} to export an\n * [`Interface`]{@link module:interface~Interface}, or getting a proxy object\n * to interact with an existing name on the bus as a client. A `MessageBus` is\n * created with `dbus.sessionBus()` or `dbus.systemBus()` methods of the\n * dbus-next module.\n */\nexport class MessageBus extends EventEmitter<MessageBusEvents> implements ServiceBus {\n  name: string | null;\n  /** @internal */ private _builder: XMLBuilder;\n  /** @internal */ _connection: DBusConnection;\n  /** @internal */ _serial: number;\n  /** @internal */ private readonly _methodReturnHandlers: Record<number, (reply: Message) => void>;\n  /** @internal */ _signals: EventEmitter<Record<string, [message: Message]>>;\n  /** @internal */ _nameOwners: Record<string, string>;\n  /** @internal */ readonly _methodHandlers: Array<(msg: Message) => unknown>;\n  /** @internal */ _serviceObjects: Record<string, ServiceObject | undefined>;\n  /** @internal */ private _isHighLevelClientInitialized: boolean;\n  /** @internal */ private readonly _matchRules: Record<string, number>;\n\n  /**\n   * Create a new `MessageBus`. This constructor is not to be called directly.\n   * Use `dbus.sessionBus()` or `dbus.systemBus()` to set up the connection to\n   * the bus.\n   */\n  constructor(conn: DBusConnection) {\n    super();\n    this._builder = createIntrospectBuilder();\n    this._connection = conn;\n    this._serial = 1;\n    this._methodReturnHandlers = {};\n    this._signals = new EventEmitter<Record<string, [message: Message]>>();\n    this._nameOwners = {};\n    this._methodHandlers = [];\n    this._serviceObjects = {};\n    this._isHighLevelClientInitialized = false;\n\n    // An object with match rule keys and refcount values. Used only by\n    // the internal high-level function `_addMatch` for refcounting.\n    this._matchRules = {};\n\n    this.name = null;\n\n    const handleSignal = (msg: Message): void => {\n      // if this is a name owner changed message, cache the new name owner\n      const { sender, path, interface: iface, member } = msg;\n      if (\n        sender === 'org.freedesktop.DBus' &&\n        path === '/org/freedesktop/DBus' &&\n        iface === 'org.freedesktop.DBus' &&\n        member === 'NameOwnerChanged'\n      ) {\n        const name = msg.body[0];\n        const newOwner = msg.body[2];\n        if (typeof name === 'string' && typeof newOwner === 'string' && !name.startsWith(':')) {\n          this._nameOwners[name] = newOwner;\n        }\n      }\n\n      const mangled = JSON.stringify({\n        path: msg.path,\n        interface: msg.interface,\n        member: msg.member,\n      });\n      this._signals.emit(mangled, msg);\n    };\n\n    const handleMessage = (msg: Message): void => {\n      // Don't handle messages that aren't destined for us. This might happen\n      // when we become a monitor.\n      if (this.name && msg.destination) {\n        if (msg.destination[0] === ':' && msg.destination !== this.name) {\n          return;\n        }\n        if (this._nameOwners[msg.destination] && this._nameOwners[msg.destination] !== this.name) {\n          return;\n        }\n      }\n\n      if (msg.type === METHOD_RETURN || msg.type === ERROR) {\n        if (msg.replySerial === undefined) {\n          return;\n        }\n        const handler = this._methodReturnHandlers[msg.replySerial];\n        if (handler) {\n          delete this._methodReturnHandlers[msg.replySerial];\n          handler(msg);\n        }\n      } else if (msg.type === SIGNAL) {\n        handleSignal(msg);\n      } else {\n        // methodCall (needs to be handled)\n        let handled: unknown = false;\n\n        for (const handler of this._methodHandlers) {\n          // run installed method handlers first\n          handled = handler(msg);\n          if (handled) {\n            break;\n          }\n        }\n\n        if (!handled) {\n          handled = handleMethod(msg, this);\n        }\n\n        if (!handled) {\n          this.send(\n            Message.newError(\n              msg,\n              'org.freedesktop.DBus.Error.UnknownMethod',\n              `Method '${msg.member ?? ''}' on interface '${msg.interface ?? '(none)'}' does not exist`,\n            ),\n          );\n        }\n      }\n    };\n\n    conn.on('message', (msg: Message) => {\n      try {\n        // TODO: document this signal\n        this.emit('message', msg);\n        handleMessage(msg);\n      } catch (e) {\n        const stack = e instanceof Error ? e.stack : String(e);\n        this.send(\n          Message.newError(\n            msg,\n            'com.github.dbus_next.Error',\n            `The DBus library encountered an error.\\n${stack}`,\n          ),\n        );\n      }\n    });\n\n    conn.on('error', (err: unknown) => {\n      // forward network and stream errors\n      this.emit('error', err);\n    });\n\n    const helloMessage = new Message({\n      path: '/org/freedesktop/DBus',\n      destination: 'org.freedesktop.DBus',\n      interface: 'org.freedesktop.DBus',\n      member: 'Hello',\n    });\n\n    this.call(helloMessage)\n      .then((msg) => {\n        const name = msg?.body[0];\n        if (typeof name === 'string') {\n          this.name = name;\n        }\n        this.emit('connect');\n      })\n      .catch((err: unknown) => {\n        this.emit('error', err);\n      });\n  }\n\n  /**\n   * Get a {@link ProxyObject} on the bus for the given name and path for\n   * interacting with a service as a client.\n   */\n  async getProxyObject(name: string, path: string, xml?: string): Promise<ProxyObject> {\n    const obj = new ProxyObject(this, name, path);\n\n    const objInitPromise = obj._init(xml);\n\n    await this._initHighLevelClient();\n\n    return objInitPromise;\n  }\n\n  /**\n   * Request a well-known name on the bus.\n   */\n  async requestName(name: string, flags?: number): Promise<number> {\n    const nameFlags = flags || 0;\n    assertBusNameValid(name);\n    const requestNameMessage = new Message({\n      path: '/org/freedesktop/DBus',\n      destination: 'org.freedesktop.DBus',\n      interface: 'org.freedesktop.DBus',\n      member: 'RequestName',\n      signature: 'su',\n      body: [name, nameFlags],\n    });\n    const msg = await this.call(requestNameMessage);\n    return msg?.body[0] as number;\n  }\n\n  /**\n   * Release this name. Requests that the name should no longer be owned by the\n   * {@link MessageBus}.\n   */\n  async releaseName(name: string): Promise<number> {\n    const msg = new Message({\n      path: '/org/freedesktop/DBus',\n      destination: 'org.freedesktop.DBus',\n      interface: 'org.freedesktop.DBus',\n      member: 'ReleaseName',\n      signature: 's',\n      body: [name],\n    });\n    const reply = await this.call(msg);\n    return reply?.body[0] as number;\n  }\n\n  /**\n   * Disconnect this `MessageBus` from the bus.\n   */\n  disconnect(): void {\n    this._connection.stream?.end();\n    this._signals.removeAllListeners();\n  }\n\n  /**\n   * Get a new serial for this bus.\n   */\n  newSerial(): number {\n    return this._serial++;\n  }\n\n  addMethodHandler(fn: (msg: Message) => unknown): void {\n    this._methodHandlers.push(fn);\n  }\n\n  removeMethodHandler(fn: (msg: Message) => unknown): void {\n    for (let i = 0; i < this._methodHandlers.length; ++i) {\n      if (this._methodHandlers[i] === fn) {\n        this._methodHandlers.splice(i, 1);\n      }\n    }\n  }\n\n  /**\n   * Send a {@link Message} of type {@link MessageType.METHOD_CALL} to the bus\n   * and wait for the reply.\n   */\n  call(msg: Message): Promise<Message | null> {\n    return new Promise((resolve, reject) => {\n      if (!(msg instanceof Message)) {\n        throw new Error('The call() method takes a Message class as the first argument.');\n      }\n      if (msg.type !== METHOD_CALL) {\n        throw new Error('Only messages of type METHOD_CALL can expect a call reply.');\n      }\n      if (msg.serial === null || msg._sent) {\n        msg.serial = this.newSerial();\n      }\n      msg._sent = true;\n      const serial = msg.serial;\n      if (serial === null) {\n        reject(new Error('message has no serial'));\n        return;\n      }\n      if (msg.flags & NO_REPLY_EXPECTED) {\n        resolve(null);\n      } else {\n        this._methodReturnHandlers[serial] = (reply) => {\n          if (msg.destination && reply.sender) {\n            this._nameOwners[msg.destination] = reply.sender;\n          }\n          if (reply.type === ERROR) {\n            const errorName = reply.errorName ?? 'org.freedesktop.DBus.Error.Failed';\n            const errorText = typeof reply.body[0] === 'string' ? reply.body[0] : undefined;\n            reject(new DBusError(errorName, errorText, reply));\n          } else {\n            resolve(reply);\n          }\n        };\n      }\n      this._connection.message(msg);\n    });\n  }\n\n  /**\n   * Send a {@link Message} on the bus that does not expect a reply.\n   */\n  send(msg: Message): void {\n    if (!(msg instanceof Message)) {\n      throw new Error('The send() method takes a Message class as the first argument.');\n    }\n    if (msg.serial === null || msg._sent) {\n      msg.serial = this.newSerial();\n    }\n    this._connection.message(msg);\n  }\n\n  /**\n   * Export an [`Interface`]{@link module:interface~Interface} on the bus.\n   */\n  export(path: string, iface: Interface): void {\n    const obj = this._getServiceObject(path);\n    obj.addInterface(iface);\n  }\n\n  /**\n   * Unexport an `Interface` on the bus.\n   */\n  unexport(path: string, iface?: Interface | null): void {\n    if (!iface) {\n      this._removeServiceObject(path);\n    } else {\n      const obj = this._getServiceObject(path);\n      obj.removeInterface(iface);\n      if (Object.keys(obj.interfaces).length === 0) {\n        this._removeServiceObject(path);\n      }\n    }\n  }\n\n  /** @internal */ private async _initHighLevelClient(): Promise<void> {\n    if (this._isHighLevelClientInitialized) {\n      return;\n    }\n\n    try {\n      await this._addMatch(nameOwnerMatchRule);\n    } catch (error) {\n      this.emit('error', error);\n      return;\n    }\n\n    this._isHighLevelClientInitialized = true;\n  }\n\n  /** @internal */ _introspect(path: string): string {\n    assertObjectPathValid(path);\n    const document: IntrospectDocument = {\n      node: {\n        node: [],\n      },\n    };\n\n    const serviceObject = this._serviceObjects[path];\n    if (serviceObject) {\n      document.node.interface = serviceObject.introspect();\n    }\n\n    const pathSplit = path.split('/').filter((n) => n);\n\n    const children = new Set<string>();\n\n    for (const key of Object.keys(this._serviceObjects)) {\n      const keySplit = key.split('/').filter((n) => n);\n      if (keySplit.length <= pathSplit.length) {\n        continue;\n      }\n      if (pathSplit.every((v, i) => v === keySplit[i])) {\n        const child = keySplit[pathSplit.length];\n        if (child !== undefined) {\n          children.add(child);\n        }\n      }\n    }\n\n    for (const child of children) {\n      document.node.node.push({\n        $: {\n          name: child,\n        },\n      });\n    }\n\n    return xmlHeader + this._builder.build(document);\n  }\n\n  /** @internal */ _getServiceObject(path: string): ServiceObject {\n    assertObjectPathValid(path);\n    const existing = this._serviceObjects[path];\n    if (existing !== undefined) {\n      return existing;\n    }\n    const created = new ServiceObject(path, this);\n    this._serviceObjects[path] = created;\n    return created;\n  }\n\n  /** @internal */ private _removeServiceObject(path: string): void {\n    assertObjectPathValid(path);\n    const obj = this._serviceObjects[path];\n    if (obj !== undefined) {\n      for (const i of Object.keys(obj.interfaces)) {\n        const iface = obj.interfaces[i];\n        if (iface !== undefined) {\n          obj.removeInterface(iface);\n        }\n      }\n      delete this._serviceObjects[path];\n    }\n  }\n\n  /** @internal */ _addMatch(match: string): Promise<unknown> {\n    const current = this._matchRules[match];\n    if (current !== undefined) {\n      this._matchRules[match] = current + 1;\n      return Promise.resolve();\n    }\n\n    this._matchRules[match] = 1;\n\n    // TODO catch error and update refcount\n    const msg = new Message({\n      path: '/org/freedesktop/DBus',\n      destination: 'org.freedesktop.DBus',\n      interface: 'org.freedesktop.DBus',\n      member: 'AddMatch',\n      signature: 's',\n      body: [match],\n    });\n    return this.call(msg);\n  }\n\n  /** @internal */ _removeMatch(match: string): Promise<unknown> {\n    if (!this._connection.stream?.writable) {\n      return Promise.resolve();\n    }\n\n    const current = this._matchRules[match];\n    if (current !== undefined) {\n      this._matchRules[match] = current - 1;\n      if (current - 1 > 0) {\n        return Promise.resolve();\n      }\n    } else {\n      return Promise.resolve();\n    }\n\n    delete this._matchRules[match];\n\n    // TODO catch error and update refcount\n    const msg = new Message({\n      path: '/org/freedesktop/DBus',\n      destination: 'org.freedesktop.DBus',\n      interface: 'org.freedesktop.DBus',\n      member: 'RemoveMatch',\n      signature: 's',\n      body: [match],\n    });\n    return this.call(msg);\n  }\n}\n","import { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\n\nconst execFileAsync = promisify(execFile);\n\n/**\n * Resolve the session bus address on macOS, where the D-Bus session bus is\n * managed by launchd. The socket path is exposed via the\n * `DBUS_LAUNCHD_SESSION_BUS_SOCKET` variable, which is read from the\n * environment when present, or otherwise queried through `launchctl getenv`\n * (the variable is usually scoped to the launchd session, not inherited).\n * Returns `null` when the socket cannot be located.\n */\nexport const getDbusAddressFromLaunchd = async (): Promise<string | null> => {\n  const fromEnv = process.env.DBUS_LAUNCHD_SESSION_BUS_SOCKET;\n  if (fromEnv) {\n    return `unix:path=${fromEnv}`;\n  }\n\n  try {\n    const { stdout } = await execFileAsync(\n      'launchctl',\n      ['getenv', 'DBUS_LAUNCHD_SESSION_BUS_SOCKET'],\n      { encoding: 'utf8' },\n    );\n    const socket = stdout.trim();\n    if (socket) {\n      return `unix:path=${socket}`;\n    }\n  } catch {\n    // launchctl is unavailable or the variable is unset; fall through to null\n  }\n\n  return null;\n};\n","import { readFile } from 'node:fs/promises';\n\nexport const getDbusAddressFromFs = async (): Promise<string> => {\n  const home = process.env.HOME;\n  const display = process.env.DISPLAY;\n  if (!display) {\n    throw new Error('could not get DISPLAY environment variable to get dbus address');\n  }\n\n  const reg = /.*:([0-9]+)\\.?.*/;\n  const match = display.match(reg);\n\n  if (!match || !match[1]) {\n    throw new Error('could not parse DISPLAY environment variable to get dbus address');\n  }\n\n  const displayNum = match[1];\n\n  const machineId = (await readFile('/var/lib/dbus/machine-id')).toString().trim();\n  const dbusInfo = (await readFile(`${home}/.dbus/session-bus/${machineId}-${displayNum}`))\n    .toString()\n    .trim();\n  for (const rawLine of dbusInfo.split('\\n')) {\n    const line = rawLine.trim();\n    if (line.startsWith('DBUS_SESSION_BUS_ADDRESS=')) {\n      const value = line.split('DBUS_SESSION_BUS_ADDRESS=')[1];\n      if (!value) {\n        throw new Error('DBUS_SESSION_BUS_ADDRESS variable is set incorrectly in dbus info file');\n      }\n\n      const removeQuotes = /^['\"]?(.*?)['\"]?$/;\n      const quoted = value.match(removeQuotes);\n      return quoted?.[1] ?? value;\n    }\n  }\n\n  throw new Error('DBUS_SESSION_BUS_ADDRESS was not set in dbus info file');\n};\n","import { access } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n * Resolve the session bus address from the systemd / XDG runtime directory\n * (`$XDG_RUNTIME_DIR/bus`). This is the modern session bus location and is\n * independent of the display server, so it works on both Wayland and X11.\n * Returns `null` when the socket cannot be located.\n */\nexport const getDbusAddressFromXdg = async (): Promise<string | null> => {\n  const runtimeDir = process.env.XDG_RUNTIME_DIR;\n  if (!runtimeDir) {\n    return null;\n  }\n  const socketPath = join(runtimeDir, 'bus');\n  try {\n    await access(socketPath);\n  } catch {\n    return null;\n  }\n  return `unix:path=${socketPath}`;\n};\n","import { getDbusAddressFromLaunchd } from './launchd';\nimport { getDbusAddressFromFs } from './x11-fs';\nimport { getDbusAddressFromXdg } from './xdg';\n\n/**\n * Discover the session bus address using platform-aware fallbacks. This is\n * tried after an explicit `busAddress` option and the\n * `DBUS_SESSION_BUS_ADDRESS` environment variable. Throws if no address can be\n * determined.\n */\nexport const resolveSessionBusAddress = async (): Promise<string> => {\n  if (process.platform === 'darwin') {\n    const fromLaunchd = await getDbusAddressFromLaunchd();\n    if (fromLaunchd !== null) {\n      return fromLaunchd;\n    }\n  }\n\n  const fromXdg = await getDbusAddressFromXdg();\n  if (fromXdg !== null) {\n    return fromXdg;\n  }\n\n  // legacy X11 fallback (~/.dbus/session-bus keyed by $DISPLAY)\n  try {\n    return await getDbusAddressFromFs();\n  } catch {\n    const tried =\n      process.platform === 'darwin'\n        ? 'launchd, $XDG_RUNTIME_DIR/bus, and the X11 session bus file'\n        : '$XDG_RUNTIME_DIR/bus and the X11 session bus file';\n    throw new Error(`could not determine the D-Bus session bus address (tried ${tried})`);\n  }\n};\n","import { once } from 'node:events';\n\nimport type { Readable } from 'node:stream';\n\nexport const readLine = async (stream: Readable): Promise<Buffer> => {\n  const bytes: number[] = [];\n  let b: number | undefined;\n  while (b !== 0x0a) {\n    const buf: unknown = stream.read(1);\n    b = Buffer.isBuffer(buf) ? buf[0] : undefined;\n    if (b === undefined) {\n      await once(stream, 'readable');\n    } else if (b !== 0x0a) {\n      bytes.push(b);\n    }\n  }\n  return Buffer.from(bytes);\n};\n","import { createHash, randomBytes } from 'node:crypto';\nimport { stat, readFile } from 'node:fs/promises';\nimport { join } from 'node:path';\n\nimport { defaultAuthMethods } from '@/constants';\nimport { readLine } from '@/readline';\n\nimport type { DBusStream } from '@/stream-types';\n\nexport type AuthMethod = 'EXTERNAL' | 'DBUS_COOKIE_SHA1' | 'ANONYMOUS';\n\nexport interface HandshakeOptions {\n  authMethods?: string[];\n}\n\nconst sha1 = (input: string): string => {\n  const shasum = createHash('sha1');\n  shasum.update(input);\n  return shasum.digest('hex');\n};\n\nconst getUserHome = (): string => {\n  const home = process.env[process.platform === 'win32' ? 'USERPROFILE' : 'HOME'];\n  if (home === undefined) {\n    throw new Error('could not determine the user home directory');\n  }\n  return home;\n};\n\nconst hexlify = (input: string): string => {\n  return Buffer.from(input.toString(), 'ascii').toString('hex');\n};\n\nconst getCookie = async (context: string, id: string): Promise<string> => {\n  // http://dbus.freedesktop.org/doc/dbus-specification.html#auth-mechanisms-sha\n  const home = getUserHome();\n  const dirname = join(home, '.dbus-keyrings');\n  // > There is a default context, \"org_freedesktop_general\" that's used by servers that do not specify otherwise.\n  const ctx = context.length === 0 ? 'org_freedesktop_general' : context;\n  const filename = join(dirname, ctx);\n\n  // check it's not writable by others and readable by user\n  const st = await stat(dirname);\n  if (st.mode & 0o22) {\n    throw new Error('User keyrings directory is writeable by other users. Aborting authentication');\n  }\n  const getuid = process.getuid;\n  if (getuid !== undefined && st.uid !== getuid.call(process)) {\n    throw new Error(\n      'Keyrings directory is not owned by the current user. Aborting authentication!',\n    );\n  }\n\n  const keyrings = await readFile(filename, 'ascii');\n  for (const line of keyrings.split('\\n')) {\n    const data = line.split(' ');\n    if (id === data[0] && data[2] !== undefined) {\n      return data[2];\n    }\n  }\n  throw new Error('cookie not found');\n};\n\nconst negotiateUnixFd = async (stream: DBusStream): Promise<void> => {\n  stream.write('NEGOTIATE_UNIX_FD\\r\\n');\n  const res = (await readLine(stream)).toString('ascii').trim();\n  if (res === 'AGREE_UNIX_FD') {\n    // ok\n  } else if (res === 'ERROR') {\n    stream.supportsUnixFd = false;\n  } else {\n    throw new Error(`unix fd negotiation failed: ${res}`);\n  }\n  stream.write('BEGIN\\r\\n');\n};\n\nconst tryAuth = async (stream: DBusStream, methods: string[]): Promise<string> => {\n  const getuid = process.getuid;\n  const uid = getuid !== undefined ? getuid.call(process) : 0;\n  const id = hexlify(`${uid}`);\n\n  for (let i = 0; i < methods.length; i++) {\n    const authMethod = methods[i];\n\n    switch (authMethod) {\n      case 'EXTERNAL':\n        stream.write(`AUTH ${authMethod} ${id}\\r\\n`);\n        break;\n      case 'DBUS_COOKIE_SHA1': {\n        stream.write(`AUTH ${authMethod} ${id}\\r\\n`);\n        const parts = (await readLine(stream)).toString().split(' ');\n        const challenge = parts[1];\n        if (challenge === undefined) {\n          throw new Error('invalid DBUS_COOKIE_SHA1 challenge');\n        }\n        const data = Buffer.from(challenge.trim(), 'hex').toString().split(' ');\n        const cookieContext = data[0] ?? '';\n        const cookieId = data[1] ?? '';\n        const serverChallenge = data[2] ?? '';\n        // any random 16 bytes should work, sha1(rnd) to make it simplier\n        const clientChallenge = randomBytes(16).toString('hex');\n        const cookie = await getCookie(cookieContext, cookieId);\n        const response = sha1([serverChallenge, clientChallenge, cookie].join(':'));\n        const reply = hexlify(clientChallenge + response);\n        stream.write(`DATA ${reply}\\r\\n`);\n        break;\n      }\n      case 'ANONYMOUS':\n        stream.write('AUTH ANONYMOUS \\r\\n');\n        break;\n      default:\n        console.error(`Unsupported auth method: ${String(authMethod)}`);\n        break;\n    }\n\n    const line = await readLine(stream);\n    const ok = line.toString('ascii').match(/^([A-Za-z]+) (.*)/);\n    if (ok && ok[1] === 'OK') {\n      const guid = ok[2] ?? ''; // ok[2] = guid. Do we need it?\n      if (stream.supportsUnixFd) {\n        await negotiateUnixFd(stream);\n      } else {\n        stream.write('BEGIN\\r\\n');\n      }\n      return guid;\n    }\n\n    // TODO: parse error!\n    if (i === methods.length - 1) {\n      throw new Error(`authentication failed: ${line.toString('ascii').trim()}`);\n    }\n  }\n\n  throw new Error('No authentication methods left to try');\n};\n\nexport const clientHandshake = (stream: DBusStream, opts: HandshakeOptions): Promise<string> => {\n  const authMethods = opts.authMethods ?? defaultAuthMethods;\n  stream.write('\\0');\n  return tryAuth(stream, authMethods.slice());\n};\n","import { endianness } from '@/constants';\nimport { parseSignature } from '@/signature';\n\nimport type { SignatureNode } from '@/signature';\n\nconst LE = endianness.le;\nconst SHIFT_32 = BigInt(32);\n\nexport interface DBusBufferOptions {\n  ayBuffer?: boolean;\n}\n\n// Buffer + position + global start position ( used in alignment )\nexport class DBusBuffer {\n  options: { ayBuffer: boolean };\n  buffer: Buffer;\n  endian: number;\n  fds: number[] | null | undefined;\n  startPos: number;\n  pos: number;\n\n  constructor(\n    buffer: Buffer,\n    startPos: number | undefined,\n    endian: number,\n    fds?: number[] | null,\n    options?: DBusBufferOptions,\n  ) {\n    this.options = {\n      ayBuffer: options?.ayBuffer === undefined ? true : options.ayBuffer,\n    };\n    this.buffer = buffer;\n    this.endian = endian;\n    this.fds = fds;\n    this.startPos = startPos || 0;\n    this.pos = 0;\n  }\n\n  align(power: number): void {\n    const allbits = (1 << power) - 1;\n    const paddedOffset = ((this.pos + this.startPos + allbits) >> power) << power;\n    this.pos = paddedOffset - this.startPos;\n  }\n\n  readInt8(): number {\n    this.pos++;\n    return this.buffer[this.pos - 1] ?? 0;\n  }\n\n  readSInt16(): number {\n    this.align(1);\n\n    const res =\n      this.endian === LE ? this.buffer.readInt16LE(this.pos) : this.buffer.readInt16BE(this.pos);\n\n    this.pos += 2;\n    return res;\n  }\n\n  readInt16(): number {\n    this.align(1);\n\n    const res =\n      this.endian === LE ? this.buffer.readUInt16LE(this.pos) : this.buffer.readUInt16BE(this.pos);\n\n    this.pos += 2;\n    return res;\n  }\n\n  readSInt32(): number {\n    this.align(2);\n\n    const res =\n      this.endian === LE ? this.buffer.readInt32LE(this.pos) : this.buffer.readInt32BE(this.pos);\n\n    this.pos += 4;\n    return res;\n  }\n\n  readInt32(): number {\n    this.align(2);\n\n    const res =\n      this.endian === LE ? this.buffer.readUInt32LE(this.pos) : this.buffer.readUInt32BE(this.pos);\n\n    this.pos += 4;\n    return res;\n  }\n\n  readDouble(): number {\n    this.align(3);\n\n    const res =\n      this.endian === LE ? this.buffer.readDoubleLE(this.pos) : this.buffer.readDoubleBE(this.pos);\n\n    this.pos += 8;\n    return res;\n  }\n\n  readString(len: number): string {\n    if (len === 0) {\n      this.pos++;\n      return '';\n    }\n    const res = this.buffer.toString('utf8', this.pos, this.pos + len);\n    this.pos += len + 1; // dbus strings are always zero-terminated ('s' and 'g' types)\n    return res;\n  }\n\n  readTree(tree: SignatureNode): unknown {\n    switch (tree.type) {\n      case '(':\n      case '{':\n      case 'r':\n        this.align(3);\n        return this.readStruct(tree.child);\n      case 'a': {\n        if (!tree.child || tree.child.length !== 1) {\n          throw new Error('Incorrect array element signature');\n        }\n        const childType = tree.child[0];\n        if (childType === undefined) {\n          throw new Error('Incorrect array element signature');\n        }\n        return this.readArray(childType, this.readInt32());\n      }\n      case 'v':\n        return this.readVariant();\n      default:\n        return this.readSimpleType(tree.type);\n    }\n  }\n\n  read(signature: string): unknown[] {\n    const tree = parseSignature(signature);\n    return this.readStruct(tree);\n  }\n\n  readVariant(): [SignatureNode[], unknown[]] {\n    const signature = this.readSimpleType('g');\n    if (typeof signature !== 'string') {\n      throw new Error('variant signature was not a string');\n    }\n    const tree = parseSignature(signature);\n    return [tree, this.readStruct(tree)];\n  }\n\n  readStruct(struct: SignatureNode[]): unknown[] {\n    const result: unknown[] = [];\n    for (const ele of struct) {\n      result.push(this.readTree(ele));\n    }\n    return result;\n  }\n\n  readArray(eleType: SignatureNode, arrayBlobSize: number): unknown[] | Buffer {\n    const start = this.pos;\n\n    // special case: treat ay as Buffer\n    if (eleType.type === 'y' && this.options.ayBuffer) {\n      this.pos += arrayBlobSize;\n      return this.buffer.subarray(start, this.pos);\n    }\n\n    // end of array is start of first element + array size\n    // we need to add 4 bytes if not on 8-byte boundary\n    // and array element needs 8 byte alignment\n    if (['x', 't', 'd', '{', '(', 'r'].includes(eleType.type)) {\n      this.align(3);\n    }\n    const end = this.pos + arrayBlobSize;\n    const result: unknown[] = [];\n    while (this.pos < end) {\n      result.push(this.readTree(eleType));\n    }\n    return result;\n  }\n\n  readSimpleType(t: string): number | bigint | string | boolean {\n    let len: number;\n    let word0: number;\n    let word1: number;\n    switch (t) {\n      case 'y':\n        return this.readInt8();\n      case 'b':\n        // TODO: spec says that true is strictly 1 and false is strictly 0\n        // shold we error (or warn?) when non 01 values?\n        return !!this.readInt32();\n      case 'n':\n        return this.readSInt16();\n      case 'q':\n        return this.readInt16();\n      case 'h': {\n        const idx = this.readInt32();\n        if (!this.fds || this.fds.length <= idx) throw new Error('No FDs available');\n        const fd = this.fds[idx];\n        if (fd === undefined) throw new Error('No FDs available');\n        return fd;\n      }\n      case 'u':\n        return this.readInt32();\n      case 'i':\n        return this.readSInt32();\n      case 'g':\n        len = this.readInt8();\n        return this.readString(len);\n      case 's':\n      case 'o':\n        len = this.readInt32();\n        return this.readString(len);\n      // TODO: validate object path here\n      // if (t === 'o' && !isValidObjectPath(str))\n      //  throw new Error('string is not a valid object path'));\n      case 'x': {\n        // signed\n        this.align(3);\n        word0 = this.readInt32();\n        word1 = this.readInt32();\n        const combined = (BigInt(word1) << SHIFT_32) | BigInt(word0);\n        return BigInt.asIntN(64, combined);\n      }\n      case 't': {\n        // unsigned\n        this.align(3);\n        word0 = this.readInt32();\n        word1 = this.readInt32();\n        const combined = (BigInt(word1) << SHIFT_32) | BigInt(word0);\n        return BigInt.asUintN(64, combined);\n      }\n      case 'd':\n        return this.readDouble();\n      default:\n        throw new Error(`Unsupported type: ${t}`);\n    }\n  }\n}\n","import type { SignatureNode } from '@/signature';\n\nexport const headerSignature: SignatureNode[] = [\n  {\n    type: 'a',\n    child: [\n      {\n        type: '(',\n        child: [\n          { type: 'y', child: [] },\n          { type: 'v', child: [] },\n        ],\n      },\n    ],\n  },\n];\n","import type { Put } from '@/put';\n\nexport const align = (ps: Put, n: number): void => {\n  const pad = n - (ps._offset % n);\n  if (pad === 0 || pad === n) return;\n  // TODO: write8(0) in a loop (3 to 7 times here) could be more efficient\n  ps.put(Buffer.alloc(pad));\n  ps._offset += pad;\n};\n","import { align } from '@/align';\nimport { _getBigIntConstants } from '@/constants';\nimport { parseSignature } from '@/signature';\n\nimport type { Assert } from '@/guards';\nimport type { Put } from '@/put';\n\nconst MASK_32 = BigInt(0xffffffff);\nconst SHIFT_32 = BigInt(32);\n\nconst bigIntToWords = (value: bigint): { low: number; high: number } => {\n  const u = BigInt.asUintN(64, value);\n  const low = Number(u & MASK_32);\n  const high = Number((u >> SHIFT_32) & MASK_32);\n  return { low, high };\n};\n\nexport interface SimpleMarshaller {\n  check(data: unknown): void;\n  marshall(ps: Put, data: unknown): void;\n}\n\n/*\n * MakeSimpleMarshaller\n * @param signature - the signature of the data you want to check\n * @returns a simple marshaller with the \"check\" method\n *\n * check returns nothing - it only raises errors if the data is\n * invalid for the signature\n */\nexport const MakeSimpleMarshaller = (signature: string): SimpleMarshaller => {\n  switch (signature) {\n    case 'o':\n    // object path\n    // TODO: verify object path here?\n    case 's':\n      // STRING\n      return {\n        check(data) {\n          checkValidString(data);\n        },\n        marshall(ps, data) {\n          checkValidString(data);\n          // utf8 string\n          align(ps, 4);\n          const buff = Buffer.from(data, 'utf8');\n          ps.word32le(buff.length).put(buff).word8(0);\n          ps._offset += 5 + buff.length;\n        },\n      };\n    case 'g':\n      // SIGNATURE\n      return {\n        check(data) {\n          checkValidString(data);\n          checkValidSignature(data);\n        },\n        marshall(ps, data) {\n          checkValidString(data);\n          checkValidSignature(data);\n          // signature\n          const buff = Buffer.from(data, 'ascii');\n          ps.word8(data.length).put(buff).word8(0);\n          ps._offset += 2 + buff.length;\n        },\n      };\n    case 'y':\n      // BYTE\n      return {\n        check(data) {\n          checkInteger(data);\n          checkRange(0x00, 0xff, data);\n        },\n        marshall(ps, data) {\n          checkInteger(data);\n          checkRange(0x00, 0xff, data);\n          ps.word8(data);\n          ps._offset++;\n        },\n      };\n    case 'b':\n      // BOOLEAN\n      return {\n        check(data) {\n          checkBoolean(data);\n        },\n        marshall(ps, data) {\n          checkBoolean(data);\n          // booleans serialised as 0/1 unsigned 32 bit int\n          const value = data ? 1 : 0;\n          align(ps, 4);\n          ps.word32le(value);\n          ps._offset += 4;\n        },\n      };\n    case 'n':\n      // INT16\n      return {\n        check(data) {\n          checkInteger(data);\n          checkRange(-0x7fff - 1, 0x7fff, data);\n        },\n        marshall(ps, data) {\n          checkInteger(data);\n          checkRange(-0x7fff - 1, 0x7fff, data);\n          align(ps, 2);\n          const buff = Buffer.alloc(2);\n          buff.writeInt16LE(data, 0);\n          ps.put(buff);\n          ps._offset += 2;\n        },\n      };\n    case 'q':\n      // UINT16\n      return {\n        check(data) {\n          checkInteger(data);\n          checkRange(0, 0xffff, data);\n        },\n        marshall(ps, data) {\n          checkInteger(data);\n          checkRange(0, 0xffff, data);\n          align(ps, 2);\n          ps.word16le(data);\n          ps._offset += 2;\n        },\n      };\n    case 'h':\n    case 'i':\n      // INT32\n      return {\n        check(data) {\n          checkInteger(data);\n          checkRange(-0x7fffffff - 1, 0x7fffffff, data);\n        },\n        marshall(ps, data) {\n          checkInteger(data);\n          checkRange(-0x7fffffff - 1, 0x7fffffff, data);\n          align(ps, 4);\n          const buff = Buffer.alloc(4);\n          buff.writeInt32LE(data, 0);\n          ps.put(buff);\n          ps._offset += 4;\n        },\n      };\n    case 'u':\n      // UINT32\n      return {\n        check(data) {\n          checkInteger(data);\n          checkRange(0, 0xffffffff, data);\n        },\n        marshall(ps, data) {\n          checkInteger(data);\n          checkRange(0, 0xffffffff, data);\n          // 32 t unsigned int\n          align(ps, 4);\n          ps.word32le(data);\n          ps._offset += 4;\n        },\n      };\n    case 't':\n      // UINT64\n      return {\n        check(data) {\n          checkLong(data, false);\n        },\n        marshall(ps, data) {\n          const value = checkLong(data, false);\n          align(ps, 8);\n          const { low, high } = bigIntToWords(value);\n          ps.word32le(low);\n          ps.word32le(high);\n          ps._offset += 8;\n        },\n      };\n    case 'x':\n      // INT64\n      return {\n        check(data) {\n          checkLong(data, true);\n        },\n        marshall(ps, data) {\n          const value = checkLong(data, true);\n          align(ps, 8);\n          const { low, high } = bigIntToWords(value);\n          ps.word32le(low);\n          ps.word32le(high);\n          ps._offset += 8;\n        },\n      };\n    case 'd':\n      // DOUBLE\n      return {\n        check(data) {\n          checkDouble(data);\n        },\n        marshall(ps, data) {\n          checkDouble(data);\n          align(ps, 8);\n          const buff = Buffer.alloc(8);\n          buff.writeDoubleLE(data, 0);\n          ps.put(buff);\n          ps._offset += 8;\n        },\n      };\n    default:\n      throw new Error(`Unknown data type format: ${signature}`);\n  }\n};\n\nconst checkValidString: Assert<string> = (data) => {\n  if (typeof data !== 'string') {\n    throw new Error(`Data: ${String(data)} was not of type string`);\n  } else if (data.includes('\\0')) {\n    throw new Error('String contains null byte');\n  }\n};\n\nconst checkValidSignature = (data: string): void => {\n  if (data.length > 0xff) {\n    throw new Error(`Data: ${data} is too long for signature type (${data.length} > 255)`);\n  }\n\n  let parenCount = 0;\n  for (let ii = 0; ii < data.length; ++ii) {\n    if (parenCount > 32) {\n      throw new Error(`Maximum container type nesting exceeded in signature type:${data}`);\n    }\n    switch (data[ii]) {\n      case '(':\n        ++parenCount;\n        break;\n      case ')':\n        --parenCount;\n        break;\n      default:\n        /* no-op */\n        break;\n    }\n  }\n  parseSignature(data);\n};\n\nconst checkRange = (minValue: number, maxValue: number, data: number): void => {\n  if (data > maxValue || data < minValue) {\n    throw new Error('Number outside range');\n  }\n};\n\nconst checkInteger: Assert<number> = (data) => {\n  if (typeof data !== 'number') {\n    throw new Error(`Data: ${String(data)} was not of type number`);\n  }\n  if (Math.floor(data) !== data) {\n    throw new Error(`Data: ${String(data)} was not an integer`);\n  }\n};\n\nconst checkBoolean: Assert<boolean | 0 | 1> = (data) => {\n  if (!(typeof data === 'boolean' || data === 0 || data === 1)) {\n    throw new Error(`Data: ${String(data)} was not of type boolean`);\n  }\n};\n\nconst checkDouble: Assert<number> = (data) => {\n  if (typeof data !== 'number') {\n    throw new Error(`Data: ${String(data)} was not of type number`);\n  } else if (Number.isNaN(data)) {\n    throw new Error(`Data: ${String(data)} was not a number`);\n  } else if (!Number.isFinite(data)) {\n    throw new Error('Number outside range');\n  }\n};\n\nconst checkLong = (data: unknown, signed: boolean): bigint => {\n  const { MAX_INT64, MIN_INT64, MAX_UINT64, MIN_UINT64 } = _getBigIntConstants();\n\n  let value: bigint;\n  if (typeof data === 'bigint') {\n    value = data;\n  } else if (typeof data === 'number' || typeof data === 'string') {\n    value = BigInt(data);\n  } else {\n    throw new Error(`Data: ${String(data)} could not be converted to a 64-bit integer`);\n  }\n\n  if (signed) {\n    if (value > MAX_INT64) {\n      throw new Error('data was out of range (greater than max int64)');\n    } else if (value < MIN_INT64) {\n      throw new Error('data was out of range (less than min int64)');\n    }\n  } else {\n    if (value > MAX_UINT64) {\n      throw new Error('data was out of range (greater than max uint64)');\n    } else if (value < MIN_UINT64) {\n      throw new Error('data was out of range (less than min uint64)');\n    }\n  }\n\n  return value;\n};\n","export class Put {\n  _offset = 0;\n  private readonly chunks: Buffer[] = [];\n\n  word8(value: number): this {\n    const buf = Buffer.alloc(1);\n    buf.writeUInt8(value & 0xff, 0);\n    this.chunks.push(buf);\n    return this;\n  }\n\n  word16le(value: number): this {\n    const buf = Buffer.alloc(2);\n    buf.writeUInt16LE(value & 0xffff, 0);\n    this.chunks.push(buf);\n    return this;\n  }\n\n  word32le(value: number): this {\n    const buf = Buffer.alloc(4);\n    buf.writeUInt32LE(value >>> 0, 0);\n    this.chunks.push(buf);\n    return this;\n  }\n\n  put(buffer: Buffer): this {\n    this.chunks.push(buffer);\n    return this;\n  }\n\n  buffer(): Buffer {\n    return Buffer.concat(this.chunks);\n  }\n}\n\nexport const put = (): Put => {\n  return new Put();\n};\n","import assert from 'node:assert';\n\nimport { align } from '@/align';\nimport { MakeSimpleMarshaller } from '@/marshallers';\nimport { put } from '@/put';\nimport { parseSignature } from '@/signature';\n\nimport type { Put } from '@/put';\nimport type { SignatureNode } from '@/signature';\n\nexport const marshall = (signature: string, data: unknown, offset = 0, fds?: number[]): Buffer => {\n  const tree = parseSignature(signature);\n  if (!Array.isArray(data) || data.length !== tree.length) {\n    throw new Error(\n      `message body does not match message signature. Body:${JSON.stringify(\n        data,\n      )}, signature:${signature}`,\n    );\n  }\n  const putstream = put();\n  putstream._offset = offset;\n  const buf = writeStruct(putstream, tree, data, fds).buffer();\n  return buf;\n};\n\n// TODO: serialise JS objects as a{sv}\n// function writeHash(ps, treeKey, treeVal, data) {\n//\n// }\n\nconst writeStruct = (ps: Put, tree: SignatureNode[], data: unknown[], fds?: number[]): Put => {\n  if (tree.length !== data.length) {\n    throw new Error('Invalid struct data');\n  }\n  for (let i = 0; i < tree.length; ++i) {\n    const ele = tree[i];\n    if (ele === undefined) {\n      throw new Error('Invalid struct data');\n    }\n    write(ps, ele, data[i], fds);\n  }\n  return ps;\n};\n\nconst write = (ps: Put, ele: SignatureNode, data: unknown, fds?: number[]): void => {\n  switch (ele.type) {\n    case '(':\n    case '{': {\n      align(ps, 8);\n      if (!Array.isArray(data)) {\n        throw new Error('Invalid struct data');\n      }\n      writeStruct(ps, ele.child, data, fds);\n      return;\n    }\n    case 'a': {\n      // array serialisation:\n      // length of array body aligned at 4 byte boundary\n      // (optional 4 bytes to align first body element on 8-byte boundary if element\n      // body\n      const childType = ele.child[0];\n      if (childType === undefined) {\n        throw new Error('Incorrect array element signature');\n      }\n      let items: ArrayLike<unknown>;\n      if (Array.isArray(data)) {\n        items = data;\n      } else if (Buffer.isBuffer(data)) {\n        items = data;\n      } else {\n        throw new Error('Expecting an array for array signature');\n      }\n      const arrPut = put();\n      arrPut._offset = ps._offset;\n      const _offset = arrPut._offset;\n      writeSimple(arrPut, 'u', 0); // array length placeholder\n      const lengthOffset = arrPut._offset - 4 - _offset;\n      // we need to align here because alignment is not included in array length\n      if (['x', 't', 'd', '{', '('].includes(childType.type)) {\n        align(arrPut, 8);\n      }\n      const startOffset = arrPut._offset;\n      for (let i = 0; i < items.length; ++i) {\n        write(arrPut, childType, items[i], fds);\n      }\n      const arrBuff = arrPut.buffer();\n      const length = arrPut._offset - startOffset;\n      // lengthOffset in the range 0 to 3 depending on number of align bytes padded _before_ arrayLength\n      arrBuff.writeUInt32LE(length, lengthOffset);\n      ps.put(arrBuff);\n      ps._offset += arrBuff.length;\n      return;\n    }\n    case 'v': {\n      // TODO: allow serialisation of simple types as variants, e. g 123 -> ['u', 123], true -> ['b', 1], 'abc' -> ['s', 'abc']\n      if (!Array.isArray(data) || data.length !== 2) {\n        throw new Error('variant data should be [signature, data]');\n      }\n      const variantSignature = data[0];\n      if (typeof variantSignature !== 'string') {\n        throw new Error('variant signature should be a string');\n      }\n      const signatureEle: SignatureNode = {\n        type: 'g',\n        child: [],\n      };\n      write(ps, signatureEle, variantSignature, fds);\n      const tree = parseSignature(variantSignature);\n      assert(tree.length === 1);\n      const valueEle = tree[0];\n      if (valueEle === undefined) {\n        throw new Error('variant signature must have a single complete type');\n      }\n      write(ps, valueEle, data[1], fds);\n      return;\n    }\n    case 'h': {\n      if (fds) {\n        if (typeof data !== 'number') {\n          throw new Error('Expected a file descriptor (number) for type h');\n        }\n        const idx = fds.push(data);\n        writeSimple(ps, ele.type, idx - 1);\n        return;\n      }\n      writeSimple(ps, ele.type, data);\n      return;\n    }\n    default:\n      writeSimple(ps, ele.type, data);\n  }\n};\n\nconst stringTypes = ['g', 'o', 's'];\n\nconst writeSimple = (ps: Put, type: string, data: unknown): Put => {\n  if (data === undefined) {\n    throw new Error(\"Serialisation of JS 'undefined' type is not supported by d-bus\");\n  }\n  if (data === null) {\n    throw new Error('Serialisation of null value is not supported by d-bus');\n  }\n\n  let value: unknown = data;\n  if (Buffer.isBuffer(value)) value = value.toString(); // encoding?\n  if (stringTypes.includes(type) && typeof value !== 'string') {\n    throw new Error(\n      `Expected string or buffer argument, got ${JSON.stringify(data)} of type '${type}'`,\n    );\n  }\n\n  const simpleMarshaller = MakeSimpleMarshaller(type);\n  simpleMarshaller.marshall(ps, value);\n  return ps;\n};\n","import {\n  MessageType,\n  endianness,\n  headerTypeName,\n  headerTypeId,\n  fieldSignature,\n  protocolVersion,\n} from '@/constants';\nimport { DBusBuffer } from '@/dbus-buffer';\nimport { headerSignature } from '@/header-signature';\nimport { marshall as marshallBody } from '@/marshall';\n\nimport type { DBusBufferOptions } from '@/dbus-buffer';\nimport type { Readable } from 'node:stream';\n\nexport interface RawMessage {\n  serial?: number | null;\n  type?: number;\n  flags?: number;\n  signature?: string;\n  body?: unknown[];\n  path?: string;\n  interface?: string;\n  member?: string;\n  errorName?: string;\n  replySerial?: number;\n  destination?: string;\n  sender?: string;\n  unixFd?: number;\n}\n\nconst messageFieldNames = [\n  'path',\n  'interface',\n  'member',\n  'errorName',\n  'replySerial',\n  'destination',\n  'sender',\n  'signature',\n  'unixFd',\n] as const;\n\nconst extractReadResult = (readBuf: unknown): { data: Buffer; fds: number[] | null } | null => {\n  if (Buffer.isBuffer(readBuf)) {\n    return { data: readBuf, fds: null };\n  }\n  if (readBuf !== null && typeof readBuf === 'object' && 'data' in readBuf) {\n    const data = readBuf.data;\n    if (!Buffer.isBuffer(data)) {\n      return null;\n    }\n    const fds = 'fds' in readBuf && Array.isArray(readBuf.fds) ? readBuf.fds : null;\n    return { data, fds };\n  }\n  return null;\n};\n\nconst parseHeaderEntry = (entry: unknown): { id: number; value: unknown } | null => {\n  if (!Array.isArray(entry) || entry.length < 2) {\n    return null;\n  }\n  const id = entry[0];\n  const variant = entry[1];\n  if (typeof id !== 'number' || !Array.isArray(variant) || variant.length < 2) {\n    return null;\n  }\n  const valueArr = variant[1];\n  if (!Array.isArray(valueArr)) {\n    return null;\n  }\n  return { id, value: valueArr[0] };\n};\n\nconst assignHeaderField = (msg: RawMessage, name: string, value: unknown): void => {\n  switch (name) {\n    case 'path':\n    case 'interface':\n    case 'member':\n    case 'errorName':\n    case 'destination':\n    case 'sender':\n    case 'signature':\n      if (typeof value === 'string') {\n        msg[name] = value;\n      }\n      break;\n    case 'replySerial':\n    case 'unixFd':\n      if (typeof value === 'number') {\n        msg[name] = value;\n      }\n      break;\n    default:\n      break;\n  }\n};\n\nexport const unmarshalMessages = (\n  stream: Readable,\n  onMessage: (message: RawMessage) => void,\n  opts: DBusBufferOptions,\n): void => {\n  let state = 0; // 0: header, 1: fields + body\n  let header: Buffer | null = null;\n  let fieldsLength = 0;\n  let fieldsLengthPadded = 0;\n  let fieldsAndBodyLength = 0;\n  let bodyLength = 0;\n  let endian = 0;\n  const LE = endianness.le;\n  stream.on('readable', () => {\n    while (true) {\n      if (state === 0) {\n        const readHeader: unknown = stream.read(16);\n        if (!Buffer.isBuffer(readHeader)) {\n          break;\n        }\n        header = readHeader;\n        state = 1;\n\n        endian = header.readUInt8(0);\n\n        fieldsLength = endian === LE ? header.readUInt32LE(12) : header.readUInt32BE(12);\n        fieldsLengthPadded = ((fieldsLength + 7) >> 3) << 3;\n        bodyLength = endian === LE ? header.readUInt32LE(4) : header.readUInt32BE(4);\n        fieldsAndBodyLength = fieldsLengthPadded + bodyLength;\n      } else {\n        const readBuf: unknown = stream.read(fieldsAndBodyLength);\n        // usockets return object with { data, fds }\n        const extracted = extractReadResult(readBuf);\n        if (!extracted || header === null) {\n          break;\n        }\n        state = 0;\n\n        const headerEntry = headerSignature[0];\n        const arraySignature = headerEntry?.child[0];\n        if (arraySignature === undefined) {\n          throw new Error('invalid header signature');\n        }\n\n        const messageBuffer = new DBusBuffer(extracted.data, 0, endian, extracted.fds, opts);\n        const unmarshalledHeader = messageBuffer.readArray(arraySignature, fieldsLength);\n        messageBuffer.align(3);\n        const message: RawMessage = {};\n        message.serial = endian === LE ? header.readUInt32LE(8) : header.readUInt32BE(8);\n\n        if (Array.isArray(unmarshalledHeader)) {\n          for (const rawEntry of unmarshalledHeader) {\n            const entry = parseHeaderEntry(rawEntry);\n            if (entry === null) {\n              continue;\n            }\n            const headerName = headerTypeName[entry.id];\n            if (typeof headerName === 'string') {\n              assignHeaderField(message, headerName, entry.value);\n            }\n          }\n        }\n\n        message.type = header.readUInt8(1);\n        message.flags = header.readUInt8(2);\n\n        if (bodyLength > 0 && message.signature) {\n          message.body = messageBuffer.read(message.signature);\n        }\n        onMessage(message);\n      }\n    }\n  });\n};\n\n// given buffer which contains entire message deserialise it\n// TODO: factor out common code\nexport const unmarshall = (buff: Buffer, opts?: DBusBufferOptions): RawMessage => {\n  const endian = buff.readUInt8(0);\n  const msgBuf = new DBusBuffer(buff, 0, endian, null, opts);\n  const headers = msgBuf.read('yyyyuua(yv)');\n  const message: RawMessage = {};\n  const headerArray = headers[6];\n  if (Array.isArray(headerArray)) {\n    for (const rawEntry of headerArray) {\n      const entry = parseHeaderEntry(rawEntry);\n      if (entry === null) {\n        continue;\n      }\n      const headerName = headerTypeName[entry.id];\n      if (typeof headerName === 'string') {\n        assignHeaderField(message, headerName, entry.value);\n      }\n    }\n  }\n  const type = headers[1];\n  const flags = headers[2];\n  const serial = headers[5];\n  message.type = typeof type === 'number' ? type : undefined;\n  message.flags = typeof flags === 'number' ? flags : undefined;\n  message.serial = typeof serial === 'number' ? serial : undefined;\n  msgBuf.align(3);\n  if (message.signature) {\n    message.body = msgBuf.read(message.signature);\n  }\n  return message;\n};\n\nexport const marshall = (message: RawMessage): [Buffer, number[]] => {\n  const serial = message.serial;\n  if (!serial) throw new Error('Missing or invalid serial');\n  const flags = message.flags || 0;\n  const type = message.type || MessageType.METHOD_CALL;\n  let bodyLength = 0;\n  let bodyBuff: Buffer | undefined;\n  const fds: number[] = [];\n  if (message.signature && message.body) {\n    bodyBuff = marshallBody(message.signature, message.body, 0, fds);\n    bodyLength = bodyBuff.length;\n    message.unixFd = fds.length;\n  }\n  const header = [endianness.le, type, flags, protocolVersion, bodyLength, serial];\n  const headerBuff = marshallBody('yyyyuu', header);\n  const fields: Array<[number, [string, unknown]]> = [];\n  for (const fieldName of messageFieldNames) {\n    const fieldVal = message[fieldName];\n    if (fieldVal) {\n      fields.push([headerTypeId[fieldName], [fieldSignature[fieldName], fieldVal]]);\n    }\n  }\n  const fieldsBuff = marshallBody('a(yv)', [fields], 12);\n  const headerLenAligned = ((headerBuff.length + fieldsBuff.length + 7) >> 3) << 3;\n  const messageLen = headerLenAligned + bodyLength;\n  const messageBuff = Buffer.alloc(messageLen);\n  headerBuff.copy(messageBuff);\n  fieldsBuff.copy(messageBuff, headerBuff.length);\n  if (bodyLength > 0 && bodyBuff) bodyBuff.copy(messageBuff, headerLenAligned);\n\n  return [messageBuff, fds];\n};\n","import { marshall } from '@/message';\nimport { parseSignature, collapseSignature } from '@/signature';\nimport { Variant } from '@/variant';\n\nimport type { RawMessage } from '@/message';\nimport type { SignatureNode } from '@/signature';\n\nconst isSignatureNode = (x: unknown): x is SignatureNode => {\n  return typeof x === 'object' && x !== null && 'type' in x && typeof x.type === 'string';\n};\n\nconst isPlainObject = (value: unknown): value is Record<string, unknown> => {\n  return (\n    typeof value === 'object' &&\n    value !== null &&\n    !Array.isArray(value) &&\n    !Buffer.isBuffer(value) &&\n    !(value instanceof Variant)\n  );\n};\n\nconst valueIsMarshallVariant = (value: unknown): value is [SignatureNode[], unknown[]] => {\n  // used for the marshaller variant type\n  if (!Array.isArray(value) || value.length !== 2) {\n    return false;\n  }\n  const treePart = value[0];\n  if (!Array.isArray(treePart) || treePart.length === 0) {\n    return false;\n  }\n  return isSignatureNode(treePart[0]);\n};\n\nconst marshallVariantToJs = (variant: [SignatureNode[], unknown[]]): unknown => {\n  // XXX The marshaller uses a different body format than what the connection\n  // is expected to emit. These two formats should be unified.\n  // parses a single complete variant in marshall format\n  const type = variant[0][0];\n  const value = variant[1][0];\n\n  if (type === undefined) {\n    throw new Error('variant is missing a type');\n  }\n\n  if (!type.child.length) {\n    if (valueIsMarshallVariant(value)) {\n      const innerType = value[0][0];\n      if (innerType === undefined) {\n        throw new Error('variant is missing a type');\n      }\n      return new Variant(collapseSignature(innerType), marshallVariantToJs(value));\n    } else {\n      return value;\n    }\n  }\n\n  if (type.type === 'a') {\n    const childType = type.child[0];\n    if (childType === undefined) {\n      throw new Error('array is missing an element type');\n    }\n    if (childType.type === 'y') {\n      // this gives us a buffer\n      return value;\n    } else if (childType.type === '{') {\n      // this is an array of dictionary entries\n      const result: Record<string, unknown> = {};\n      if (Array.isArray(value)) {\n        const valueType = childType.child[1];\n        if (valueType === undefined) {\n          throw new Error('dictionary entry is missing a value type');\n        }\n        for (const entry of value) {\n          if (Array.isArray(entry) && entry.length >= 2) {\n            // dictionary keys must have basic types\n            result[String(entry[0])] = marshallVariantToJs([[valueType], [entry[1]]]);\n          }\n        }\n      }\n      return result;\n    } else {\n      // other arrays only have one type\n      const result: unknown[] = [];\n      if (Array.isArray(value)) {\n        for (const item of value) {\n          result.push(marshallVariantToJs([[childType], [item]]));\n        }\n      }\n      return result;\n    }\n  } else if (type.type === '(') {\n    // structs have types equal to the number of children\n    const result: unknown[] = [];\n    if (Array.isArray(value)) {\n      for (let i = 0; i < value.length; ++i) {\n        const memberType = type.child[i];\n        if (memberType === undefined) {\n          throw new Error('struct member is missing a type');\n        }\n        result.push(marshallVariantToJs([[memberType], [value[i]]]));\n      }\n    }\n    return result;\n  }\n\n  return undefined;\n};\n\nexport const messageToJsFmt = (message: RawMessage): RawMessage => {\n  // XXX The marshaller uses a different body format than what the connection\n  // is expected to emit. These two formats should be unified.\n  const signature = message.signature ?? '';\n  const body = message.body ?? [];\n  const bodyJs: unknown[] = [];\n  const signatureTree = parseSignature(signature);\n  for (let i = 0; i < signatureTree.length; ++i) {\n    const tree = signatureTree[i];\n    if (tree === undefined) {\n      continue;\n    }\n    bodyJs.push(marshallVariantToJs([[tree], [body[i]]]));\n  }\n\n  message.body = bodyJs;\n  message.signature = signature;\n  return message;\n};\n\nexport const jsToMarshalFmt = (\n  signature: string | SignatureNode,\n  value: unknown,\n): [string, unknown] => {\n  // XXX The connection accepts a message body in plain js format and converts\n  // it to the marshaller format for writing. These two formats should be\n  // unified.\n  if (value === undefined) {\n    const signatureStr = typeof signature === 'string' ? signature : collapseSignature(signature);\n    throw new Error(`expected value for signature: ${signatureStr}`);\n  }\n\n  let signatureStr: string;\n  let node: SignatureNode;\n  if (typeof signature === 'string') {\n    signatureStr = signature;\n    const parsed = parseSignature(signature)[0];\n    if (parsed === undefined) {\n      throw new Error(`expected a complete type for signature: ${signature}`);\n    }\n    node = parsed;\n  } else {\n    signatureStr = collapseSignature(signature);\n    node = signature;\n  }\n\n  if (node.child.length === 0) {\n    if (node.type === 'v') {\n      if (!(value instanceof Variant)) {\n        throw new Error(`expected a Variant for value (got ${typeof value})`);\n      }\n      return [node.type, jsToMarshalFmt(value.signature, value.value)];\n    } else {\n      return [node.type, value];\n    }\n  }\n\n  const childType = node.child[0];\n\n  if (\n    node.type === 'a' &&\n    childType !== undefined &&\n    childType.type === 'y' &&\n    Buffer.isBuffer(value)\n  ) {\n    // special case: ay is a buffer\n    return [signatureStr, value];\n  } else if (node.type === 'a') {\n    if (childType === undefined) {\n      throw new Error(`invalid array signature '${signatureStr}'`);\n    }\n    const result: unknown[] = [];\n    if (childType.type === 'y') {\n      if (!Array.isArray(value)) {\n        throw new Error(`expecting an array for signature '${signatureStr}' (got ${typeof value})`);\n      }\n      return [signatureStr, value];\n    } else if (childType.type === '{') {\n      // this is an array of dictionary elements\n      if (!isPlainObject(value)) {\n        throw new Error(\n          `expecting an object for signature '${signatureStr}' (got ${typeof value})`,\n        );\n      }\n      const keyNode = childType.child[0];\n      const valNode = childType.child[1];\n      for (const rawKey of Object.keys(value)) {\n        const v = value[rawKey];\n        // js always converts keys of objects to string\n        // convert them back if the signature requires it\n        let key: string | number | boolean = rawKey;\n        if (keyNode) {\n          const keyType = keyNode.type;\n          if (['y', 'n', 'q', 'i', 'x', 't'].includes(keyType)) {\n            // key should be integer\n            key = parseInt(rawKey, 10);\n          } else if (['b'].includes(keyType)) {\n            // key should be boolean\n            if (!(rawKey === 'true' || rawKey === 'false')) {\n              throw new Error(\n                `error parsing dict key for signature '${signatureStr}' (key: ${rawKey})`,\n              );\n            }\n            key = rawKey === 'true';\n          }\n        }\n        if (v instanceof Variant) {\n          result.push([key, jsToMarshalFmt(v.signature, v.value)]);\n        } else {\n          if (valNode === undefined) {\n            throw new Error(`invalid dictionary signature '${signatureStr}'`);\n          }\n          result.push([key, jsToMarshalFmt(valNode, v)[1]]);\n        }\n      }\n    } else {\n      if (!Array.isArray(value)) {\n        throw new Error(`expecting an array for signature '${signatureStr}' (got ${typeof value})`);\n      }\n      for (const v of value) {\n        if (v instanceof Variant) {\n          result.push(jsToMarshalFmt(v.signature, v.value));\n        } else {\n          result.push(jsToMarshalFmt(childType, v)[1]);\n        }\n      }\n    }\n    return [signatureStr, result];\n  } else if (node.type === '(') {\n    if (!Array.isArray(value)) {\n      throw new Error(`expecting an array for signature '${signatureStr}' (got ${typeof value})`);\n    }\n    if (value.length !== node.child.length) {\n      throw new Error(\n        `expecting struct to have ${node.child.length} members (got ${value.length} members)`,\n      );\n    }\n    const result: unknown[] = [];\n    for (let i = 0; i < value.length; ++i) {\n      const v = value[i];\n      const memberNode = node.child[i];\n      if (memberNode === undefined) {\n        throw new Error(`invalid struct signature '${signatureStr}'`);\n      }\n      if (memberNode.type === 'v') {\n        if (!(v instanceof Variant)) {\n          throw new Error(`expected a Variant for struct member ${i + 1} (got ${String(v)})`);\n        }\n        result.push(jsToMarshalFmt(v.signature, v.value));\n      } else {\n        result.push(jsToMarshalFmt(memberNode, v)[1]);\n      }\n    }\n    return [signatureStr, result];\n  } else {\n    throw new Error(`got unknown complex type: ${node.type}`);\n  }\n};\n\nexport const marshallMessage = (msg: RawMessage): [Buffer, number[]] => {\n  // XXX The connection accepts a message body in plain js format and converts\n  // it to the marshaller format for writing. These two formats should be\n  // unified.\n  const signature = msg.signature ?? '';\n  const body = msg.body ?? [];\n\n  const signatureTree = parseSignature(signature);\n\n  if (signatureTree.length !== body.length) {\n    throw new Error(\n      `Expected ${signatureTree.length} body elements for signature '${signature}' (got ${body.length})`,\n    );\n  }\n\n  const marshallerBody: unknown[] = [];\n  for (let i = 0; i < body.length; ++i) {\n    const sigNode = signatureTree[i];\n    if (sigNode === undefined) {\n      throw new Error(\n        `Expected ${signatureTree.length} body elements for signature '${signature}'`,\n      );\n    }\n    if (sigNode.type === 'v') {\n      const v = body[i];\n      if (!(v instanceof Variant)) {\n        throw new Error(\n          `Expected a Variant() argument for position ${i + 1} (value='${String(body[i])}')`,\n        );\n      }\n      marshallerBody.push(jsToMarshalFmt(v.signature, v.value));\n    } else {\n      marshallerBody.push(jsToMarshalFmt(sigNode, body[i])[1]);\n    }\n  }\n\n  msg.signature = signature;\n  msg.body = marshallerBody;\n  return marshall(msg);\n};\n","import { spawn } from 'node:child_process';\nimport { EventEmitter } from 'node:events';\nimport { createConnection as netCreateConnection } from 'node:net';\nimport { Duplex } from 'node:stream';\n\nimport { resolveSessionBusAddress } from '@/address';\nimport { clientHandshake } from '@/handshake';\nimport { messageToJsFmt, marshallMessage } from '@/marshall-compat';\nimport { unmarshalMessages } from '@/message';\nimport { Message } from '@/message-type';\n\nimport type { DBusBufferOptions } from '@/dbus-buffer';\nimport type { AuthMethod, HandshakeOptions } from '@/handshake';\nimport type { RawMessage } from '@/message';\nimport type { DBusStream } from '@/stream-types';\n\nexport interface ConnectionOptions extends HandshakeOptions, DBusBufferOptions {\n  busAddress?: string;\n  negotiateUnixFd?: boolean;\n}\n\nexport interface SystemBusOptions {\n  negotiateUnixFd?: boolean;\n}\n\nexport interface SessionBusOptions {\n  authMethods?: AuthMethod[];\n  busAddress?: string;\n}\n\nconst createStream = async (opts: ConnectionOptions): Promise<DBusStream> => {\n  // TODO according to the dbus spec, we should start a new server if the bus\n  // address cannot be found.\n  let busAddress = opts.busAddress;\n  if (!busAddress) {\n    busAddress = process.env.DBUS_SESSION_BUS_ADDRESS;\n  }\n  if (!busAddress) {\n    busAddress = await resolveSessionBusAddress();\n  }\n\n  const addresses = busAddress.split(';');\n  for (let i = 0; i < addresses.length; ++i) {\n    const address = addresses[i];\n    const isLast = i === addresses.length - 1;\n    if (address === undefined) {\n      continue;\n    }\n    const familyParams = address.split(':');\n    const family = familyParams[0];\n    const paramsStr = familyParams[1];\n    if (family === undefined || paramsStr === undefined) {\n      if (!isLast) {\n        continue;\n      }\n      throw new Error(`invalid bus address (missing parameters): ${address}`);\n    }\n    const params: Record<string, string> = {};\n    paramsStr.split(',').forEach(function (p) {\n      const eq = p.indexOf('=');\n      if (eq > 0) {\n        params[p.slice(0, eq)] = p.slice(eq + 1);\n      }\n    });\n\n    try {\n      switch (family.toLowerCase()) {\n        case 'tcp': {\n          const host = params.host || 'localhost';\n          const port = params.port;\n          if (!port) {\n            throw new Error(\n              \"not enough parameters for 'tcp' connection. you need to specify a 'port'\",\n            );\n          }\n          return netCreateConnection(Number(port), host);\n        }\n        case 'unix': {\n          if (params.socket) {\n            return netCreateConnection(params.socket);\n          }\n          if (params.abstract) {\n            return netCreateConnection('\\u0000' + params.abstract);\n          }\n          if (params.path) {\n            return netCreateConnection(params.path);\n          }\n          throw new Error(\n            \"not enough parameters for 'unix' connection. you need to specify 'socket' or 'abstract' or 'path' parameter\",\n          );\n        }\n        case 'unixexec': {\n          const command = params.path;\n          if (!command) {\n            throw new Error(\n              \"not enough parameters for 'unixexec' connection. you need to specify a 'path'\",\n            );\n          }\n          const args: string[] = [];\n          for (let n = 1; ; n++) {\n            const arg = params[`arg${n}`];\n            if (arg === undefined) {\n              break;\n            }\n            args.push(arg);\n          }\n          const child = spawn(command, args);\n          const childStdout = child.stdout;\n          const childStdin = child.stdin;\n          if (!childStdout || !childStdin) {\n            throw new Error('failed to open stdio for unixexec connection');\n          }\n          const stream: DBusStream = new Duplex({\n            read() {},\n            write(chunk, _encoding, callback) {\n              childStdin.write(chunk, (err) => callback(err));\n            },\n          });\n          childStdout.on('data', (chunk) => stream.push(chunk));\n          childStdout.on('end', () => stream.push(null));\n          childStdout.on('error', (err) => stream.destroy(err));\n          // duplex socket is auto connected so emit connect event next tick\n          queueMicrotask(() => stream.emit('connect'));\n          return stream;\n        }\n        default: {\n          throw new Error('unknown address type:' + family);\n        }\n      }\n    } catch (e) {\n      if (!isLast) {\n        console.warn(e instanceof Error ? e.message : String(e));\n        continue;\n      }\n      throw e;\n    }\n  }\n  throw new Error(`could not connect to any bus address: ${busAddress}`);\n};\n\ninterface DBusConnectionEvents {\n  connect: [];\n  message: [message: Message];\n  end: [];\n}\n\nexport class DBusConnection extends EventEmitter<DBusConnectionEvents> {\n  stream?: DBusStream;\n  guid?: string;\n  state?: 'connected' | 'ended';\n  private readonly _messages: RawMessage[] = [];\n  private readonly _opts: ConnectionOptions;\n\n  constructor(opts?: ConnectionOptions) {\n    super();\n    this._opts = opts ?? {};\n\n    // pre-connect: buffer messages until connected, then flush\n    this.once('connect', () => {\n      this.state = 'connected';\n      for (const msg of this._messages) {\n        this._write(msg);\n      }\n      this._messages.length = 0;\n    });\n\n    // resolving the bus address (or opening the socket) failed; surface the\n    // error so the caller has a chance to attach an 'error' listener instead of\n    // getting a synchronous throw\n    createStream(this._opts)\n      .then((stream) => {\n        this._wireStream(stream);\n      })\n      .catch((err: unknown) => {\n        this.emit('error', err);\n      });\n  }\n\n  private _wireStream(stream: DBusStream): void {\n    this.stream = stream;\n    stream.setNoDelay?.();\n\n    stream.on('error', (err: Error) => {\n      // forward network and stream errors\n      this.emit('error', err);\n    });\n\n    stream.on('end', () => {\n      this.emit('end');\n      this.state = 'ended';\n    });\n\n    const afterHandshake = (guid: string): void => {\n      this.guid = guid;\n      this.emit('connect');\n      unmarshalMessages(\n        stream,\n        (rawMessage) => {\n          try {\n            this.emit('message', new Message(messageToJsFmt(rawMessage)));\n          } catch (err) {\n            this.emit('error', err);\n            return;\n          }\n        },\n        this._opts,\n      );\n    };\n\n    stream.once('connect', () => {\n      clientHandshake(stream, this._opts)\n        .then(afterHandshake)\n        .catch((err: unknown) => {\n          this.emit('error', err);\n        });\n    });\n  }\n\n  private _write(msg: RawMessage): void {\n    const stream = this.stream;\n    if (!stream || !stream.writable) {\n      throw new Error('Cannot send message, stream is closed');\n    }\n    const [data, fds] = marshallMessage(msg);\n    if (stream.supportsUnixFd) {\n      stream.write({ data, fds });\n    } else {\n      if (fds.length > 0) {\n        console.warn('Sending file descriptors is not supported in current bus connection');\n      }\n      stream.write(data);\n    }\n  }\n\n  message(msg: RawMessage): void {\n    if (this.state !== 'connected') {\n      this._messages.push(msg);\n      return;\n    }\n    this._write(msg);\n  }\n\n  end(): this {\n    this.stream?.end();\n    return this;\n  }\n}\n\nexport const createConnection = (opts?: ConnectionOptions) => new DBusConnection(opts);\n","const libraryOptions = {\n  bigIntCompat: false,\n};\n\nexport const getBigIntCompat = (): boolean => {\n  return libraryOptions.bigIntCompat;\n};\n\nexport const setBigIntCompat = (val: boolean): void => {\n  if (typeof val !== 'boolean') {\n    throw new Error('dbus.setBigIntCompat() must be called with a boolean parameter');\n  }\n  libraryOptions.bigIntCompat = val;\n};\n","import { MessageBus } from '@/bus';\nimport { createConnection } from '@/connection';\nimport {\n  ACCESS_READ,\n  ACCESS_WRITE,\n  ACCESS_READWRITE,\n  property,\n  method,\n  signal,\n  Interface,\n} from '@/service';\n\nimport type { ConnectionOptions } from '@/connection';\n\nconst createClient = (params: ConnectionOptions): MessageBus => {\n  const connection = createConnection(params);\n  return new MessageBus(connection);\n};\n\n/**\n * Create a new {@link MessageBus} client on the DBus system bus to connect to\n * interfaces or request service names. Connects to the socket specified by the\n * `DBUS_SYSTEM_BUS_ADDRESS` environment variable or\n * `unix:path=/var/run/dbus/system_bus_socket`.\n */\nexport const systemBus = (opts?: ConnectionOptions): MessageBus => {\n  return createClient({\n    ...opts,\n    busAddress: process.env.DBUS_SYSTEM_BUS_ADDRESS || 'unix:path=/var/run/dbus/system_bus_socket',\n  });\n};\n\n/**\n * Create a new {@link MessageBus} client on the DBus session bus to connect to\n * interfaces or request service names.\n */\nexport const sessionBus = (opts?: ConnectionOptions): MessageBus => {\n  return createClient(opts ?? {});\n};\n\nexport { setBigIntCompat } from '@/library-options';\n\nexport {\n  NameFlag,\n  RequestNameReply,\n  ReleaseNameReply,\n  MessageType,\n  MessageFlag,\n} from '@/constants';\n\nexport { Variant } from '@/variant';\nexport { Message } from '@/message-type';\nexport { DBusError } from '@/errors';\nexport { MessageBus } from '@/bus';\n\nconst interfaceNs = {\n  ACCESS_READ,\n  ACCESS_WRITE,\n  ACCESS_READWRITE,\n  property,\n  method,\n  signal,\n  Interface,\n};\n\nexport { interfaceNs as interface };\n\nexport * as validators from '@/validators';\n\nexport type { ClientInterface, ObjectPath, ProxyObject, ProxyInterface } from '@/client';\nexport type { ConnectionOptions, SessionBusOptions, SystemBusOptions } from '@/connection';\nexport type { AuthMethod } from '@/handshake';\nexport type { MessageLike } from '@/message-type';\nexport type {\n  Interface,\n  PropertyOptions,\n  MethodOptions,\n  SignalOptions,\n  PropertyAccess,\n} from '@/service';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,YAAY;;;;;;;;;AASlB,MAAa,kBAAkB,SAAkC;CAC/D,IAAI,OAAO,SAAS,UAClB,OAAO;CAGT,IAAI,KAAK,WAAW,GAAG,GAErB,OAAO;CAIT,OAAO,CAAC,EACN,KAAK,SAAS,KACd,KAAK,UAAU,OACf,KAAK,OAAO,OACZ,KAAK,SAAS,GAAG,KACjB,KAAK,MAAM,GAAG,CAAC,CAAC,OAAO,MAAM,KAAK,UAAU,KAAK,CAAC,CAAC;AAEvD;;;;;;;;AASA,MAAa,sBAAsC,SAAS;CAC1D,IAAI,CAAC,eAAe,IAAI,GACtB,MAAM,IAAI,MAAM,qBAAqB,OAAO,IAAI,GAAG;AAEvD;AAEA,MAAM,SAAS;;;;;;;;;AASf,MAAa,qBAAqB,SAAkC;CAClE,OAAO,CAAC,EACN,OAAO,SAAS,YAChB,QACA,KAAK,OAAO,QACX,KAAK,WAAW,KACd,KAAK,KAAK,SAAS,OAAO,OACzB,KACG,MAAM,GAAG,CAAC,CACV,MAAM,CAAC,CAAC,CACR,OAAO,MAAM,KAAK,OAAO,KAAK,CAAC,CAAC;AAE3C;;;;;;;;;AAUA,MAAa,yBAAyC,SAAS;CAC7D,IAAI,CAAC,kBAAkB,IAAI,GACzB,MAAM,IAAI,MAAM,wBAAwB,OAAO,IAAI,GAAG;AAE1D;AAEA,MAAM,YAAY;;;;;;;;;AASlB,MAAa,wBAAwB,SAAkC;CACrE,OAAO,CAAC,EACN,OAAO,SAAS,YAChB,QACA,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