8889841cPK@[||0 README.mdnuW+A# bonjour-service ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/onlxltd/bonjour-service/publish-release.yml?style=flat-square) ![npm bundle size](https://img.shields.io/bundlephobia/min/bonjour-service?style=flat-square) ![GitHub Release Date](https://img.shields.io/github/release-date/onlxltd/bonjour-service?style=flat-square) ![npm](https://img.shields.io/npm/dw/bonjour-service?color=%23888&style=flat-square) ![GitHub](https://img.shields.io/github/license/onlxltd/bonjour-service?style=flat-square) [![DeepScan grade](https://deepscan.io/api/teams/13435/projects/16430/branches/352351/badge/grade.svg?style=flat-square)](https://deepscan.io/dashboard#view=project&tid=13435&pid=16430&bid=352351) A Bonjour/Zeroconf protocol implementation in TypeScript. Publish services on the local network or discover existing services using multicast DNS. This is a rewrite of the project Bonjour (https://github.com/watson/bonjour) into modern TypeScript. ## Installation Add to your project dependencies using Yarn or NPM. #### Install with Yarn ``` yarn add bonjour-service ``` #### Install with NPM ``` npm install bonjour-service ``` ## Usage ```js import Bonjour from 'bonjour-service' const instance = new Bonjour() // advertise an HTTP server on port 3000 instance.publish({ name: 'My Web Server', type: 'http', port: 3000 }) // browse for all http services instance.find({ type: 'http' }, function (service) { console.log('Found an HTTP server:', service) }) ``` ## API ### Initializing ```js var instance = new Bonjour({ options }, errorCallback) ``` The `options` are optional and will be used when initializing the underlying multicast-dns server. For details see [the multicast-dns documentation](https://github.com/mafintosh/multicast-dns#mdns--multicastdnsoptions). `errorCallback` is an optional callback used to gracefully handle errors that would otherwise crash the process. While not being strictly required, providing this is highly recommended ### Publishing #### `var service = bonjour.publish(options)` Publishes a new service. Options are: - `name` (string) - `host` (string, optional) - defaults to local hostname - `port` (number) - `type` (string) - `subtypes` (array of strings, optional) - `protocol` (string, optional) - `udp` or `tcp` (default) - `txt` (object, optional) - a key/value object to broadcast as the TXT record IANA maintains a [list of official service types and port numbers](http://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml). #### `bonjour.unpublishAll([callback])` Unpublish all services. The optional `callback` will be called when the services have been unpublished. #### `bonjour.destroy()` Destroy the mdns instance. Closes the udp socket. ### Browser #### `var browser = bonjour.find(options[, onup])` Listen for services advertised on the network. An optional callback can be provided as the 2nd argument and will be added as an event listener for the `up` event. Options (all optional): - `type` (string) - `subtypes` (array of strings) - `protocol` (string) - defaults to `tcp` - `txt` (object) - passed into [dns-txt module](https://github.com/watson/dns-txt) contructor. Set to `{ binary: true }` if you want to keep the TXT records in binary #### `var browser = bonjour.findOne(options[, callback])` Listen for and call the `callback` with the first instance of a service matching the `options`. If no `callback` is given, it's expected that you listen for the `up` event. The returned `browser` will automatically stop it self after the first matching service. Options are the same as given in the `browser.find` function. #### `Event: up` Emitted every time a new service is found that matches the browser. #### `Event: down` Emitted every time an existing service emmits a goodbye message. #### `browser.services()` An array of services known by the browser to be online. #### `browser.start()` Start looking for matching services. #### `browser.stop()` Stop looking for matching services. #### `browser.update()` Broadcast the query again. ### Service #### `Event: up` Emitted when the service is up. #### `Event: error` Emitted if an error occurrs while publishing the service. #### `service.stop([callback])` Unpublish the service. The optional `callback` will be called when the service have been unpublished. #### `service.start()` Publish the service. #### `service.name` The name of the service, e.g. `Apple TV`. #### `service.type` The type of the service, e.g. `http`. #### `service.subtypes` An array of subtypes. Note that this property might be `null`. #### `service.protocol` The protocol used by the service, e.g. `tcp`. #### `service.host` The hostname or ip address where the service resides. #### `service.port` The port on which the service listens, e.g. `5000`. #### `service.fqdn` The fully qualified domain name of the service. E.g. if given the name `Foo Bar`, the type `http` and the protocol `tcp`, the `service.fqdn` property will be `Foo Bar._http._tcp.local`. #### `service.txt` The TXT record advertised by the service (a key/value object). Note that this property might be `null`. #### `service.published` A boolean indicating if the service is currently published. ## License MIT PK@[' dist/index.jsnuW+A"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Browser = exports.Service = exports.Bonjour = void 0; const registry_1 = __importDefault(require("./lib/registry")); const mdns_server_1 = __importDefault(require("./lib/mdns-server")); const browser_1 = __importDefault(require("./lib/browser")); exports.Browser = browser_1.default; const service_1 = __importDefault(require("./lib/service")); exports.Service = service_1.default; class Bonjour { constructor(opts, errorCallback) { this.server = new mdns_server_1.default(opts, errorCallback); this.registry = new registry_1.default(this.server); } publish(opts) { return this.registry.publish(opts); } unpublishAll(callback) { return this.registry.unpublishAll(callback); } find(opts = undefined, onup) { return new browser_1.default(this.server.mdns, opts, onup); } findOne(opts = undefined, timeout = 10000, callback) { const browser = new browser_1.default(this.server.mdns, opts); var timer; browser.once('up', (service) => { if (timer !== undefined) clearTimeout(timer); browser.stop(); if (callback) callback(service); }); timer = setTimeout(() => { browser.stop(); if (callback) callback(null); }, timeout); return browser; } destroy() { this.registry.destroy(); this.server.mdns.destroy(); } } exports.Bonjour = Bonjour; exports.default = Bonjour; //# sourceMappingURL=index.js.mapPK@[$l||dist/index.js.mapnuW+A{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AACA,8DAAyD;AACzD,oEAA4D;AAC5D,4DAAwD;AA8EP,kBA9E1C,iBAAO,CA8E0C;AA7ExD,4DAAwE;AA6E/D,kBA7EF,iBAAO,CA6EE;AA3EhB,MAAa,OAAO;IAUhB,YAAY,IAAgC,EAAE,aAAoC;QAC9E,IAAI,CAAC,MAAM,GAAO,IAAI,qBAAM,CAAC,IAAI,EAAE,aAAa,CAAC,CAAA;QACjD,IAAI,CAAC,QAAQ,GAAK,IAAI,kBAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC/C,CAAC;IAOM,OAAO,CAAC,IAAmB;QAC9B,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACtC,CAAC;IAOM,YAAY,CAAC,QAAuC;QACvD,OAAO,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAA;IAC/C,CAAC;IAQM,IAAI,CAAC,OAAkC,SAAS,EAAE,IAAiC;QACtF,OAAO,IAAI,iBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACpD,CAAC;IASM,OAAO,CAAC,OAAkC,SAAS,EAAE,OAAO,GAAG,KAAK,EAAE,QAA2B;QACpG,MAAM,OAAO,GAAY,IAAI,iBAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QAC5D,IAAI,KAAU,CAAA;QACd,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,OAAgB,EAAE,EAAE;YACpC,IAAG,KAAK,KAAK,SAAS;gBAAE,YAAY,CAAC,KAAK,CAAC,CAAA;YAC3C,OAAO,CAAC,IAAI,EAAE,CAAA;YACd,IAAG,QAAQ;gBAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;QAClC,CAAC,CAAC,CAAA;QACF,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACpB,OAAO,CAAC,IAAI,EAAE,CAAA;YACd,IAAG,QAAQ;gBAAE,QAAQ,CAAC,IAAI,CAAC,CAAA;QAC/B,CAAC,EAAE,OAAO,CAAC,CAAA;QACX,OAAO,OAAO,CAAA;IAClB,CAAC;IAKM,OAAO;QACV,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;QACvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAA;IAC9B,CAAC;CAEJ;AAzED,0BAyEC;AAID,kBAAe,OAAO,CAAA"}PK@[ mmdist/lib/utils/filter-txt.d.tsnuW+Aimport KeyValue from '../KeyValue'; declare const _default: (data: KeyValue) => {}; export default _default; PK@[ f-$$dist/lib/utils/filter-txt.jsnuW+A"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = (data) => Object.keys(data) .filter((key) => !key.includes('binary')) .reduce((cur, key) => { return Object.assign(cur, { [key]: data[key] }); }, {}); //# sourceMappingURL=filter-txt.js.mapPK@[$dist/lib/utils/filter-service.js.mapnuW+A{"version":3,"file":"filter-service.js","sourceRoot":"","sources":["../../../src/lib/utils/filter-service.ts"],"names":[],"mappings":";;AAOA,kBAAe,CAAC,OAAgB,EAAE,QAA8B,EAAW,EAAE;IACzE,IAAG,QAAQ,KAAK,SAAS;QAAE,OAAO,IAAI,CAAA;IACtC,IAAI,UAAU,GAAG,OAAO,CAAC,GAAG,CAAA;IAC5B,IAAI,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;SAC/B,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAClB,IAAI,UAAU,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;QAChC,IAAG,UAAU,KAAK,SAAS;YAAE,OAAO,KAAK,CAAA;QACzC,IAAG,KAAK,IAAI,UAAU;YAAE,OAAO,KAAK,CAAA;QACpC,OAAO,IAAI,CAAA;IACf,CAAC,CAAC,CAAA;IACN,IAAG,KAAK,CAAC,MAAM,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IACjC,IAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAA;IACtC,OAAO,IAAI,CAAA;AACf,CAAC,CAAA"}PK@[ "dist/lib/utils/filter-service.d.tsnuW+Aimport KeyValue from '../KeyValue'; import Service from '../service'; declare const _default: (service: Service, txtQuery: KeyValue | undefined) => boolean; export default _default; PK@[5 dist/lib/utils/filter-txt.js.mapnuW+A{"version":3,"file":"filter-txt.js","sourceRoot":"","sources":["../../../src/lib/utils/filter-txt.ts"],"names":[],"mappings":";;AAMA,kBAAe,CAAC,IAAc,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;KACnD,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KACxC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,GAAG,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA,CAAA,CAAC,EAAE,EAAE,CAAC,CAAA"}PK@[;KS~~ dist/lib/utils/filter-service.jsnuW+A"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = (service, txtQuery) => { if (txtQuery === undefined) return true; let serviceTxt = service.txt; let query = Object.entries(txtQuery) .map(([key, value]) => { let queryValue = serviceTxt[key]; if (queryValue === undefined) return false; if (value != queryValue) return false; return true; }); if (query.length == 0) return true; if (query.includes(false)) return false; return true; }; //# sourceMappingURL=filter-service.js.mapPK@[zQFFdist/lib/KeyValue.d.tsnuW+Atype KeyValue = { [key: string]: any; }; export default KeyValue; PK@[Βssdist/lib/KeyValue.js.mapnuW+A{"version":3,"file":"KeyValue.js","sourceRoot":"","sources":["../../src/lib/KeyValue.ts"],"names":[],"mappings":""}PK@[tpdist/lib/registry.jsnuW+A"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Registry = void 0; const array_flatten_1 = __importDefault(require("array-flatten")); const dns_equal_1 = __importDefault(require("dns-equal")); const service_1 = __importDefault(require("./service")); const REANNOUNCE_MAX_MS = 60 * 60 * 1000; const REANNOUNCE_FACTOR = 3; class Registry { constructor(server) { this.services = []; this.server = server; } publish(config) { function start(service, registry, opts) { if (service.activated) return; service.activated = true; registry.services.push(service); if (!(service instanceof service_1.default)) return; if (opts.probe) { registry.probe(registry.server.mdns, service, (exists) => { if (exists) { service.stop(); console.log(new Error('Service name is already in use on the network')); return; } registry.announce(registry.server, service); }); } else { registry.announce(registry.server, service); } } function stop(service, registry, callback) { if (!service.activated) return; if (!(service instanceof service_1.default)) return; registry.teardown(registry.server, service, callback); const index = registry.services.indexOf(service); if (index !== -1) registry.services.splice(index, 1); } const service = new service_1.default(config); service.start = start.bind(null, service, this); service.stop = stop.bind(null, service, this); service.start({ probe: config.probe !== false }); return service; } unpublishAll(callback) { this.teardown(this.server, this.services, callback); this.services = []; } destroy() { this.services.map(service => service.destroyed = true); } probe(mdns, service, callback) { var sent = false; var retries = 0; var timer; const send = () => { if (!service.activated || service.destroyed) return; mdns.query(service.fqdn, 'ANY', function () { sent = true; timer = setTimeout(++retries < 3 ? send : done, 250); timer.unref(); }); }; const onresponse = (packet) => { if (!sent) return; if (packet.answers.some(matchRR) || packet.additionals.some(matchRR)) done(true); }; const matchRR = (rr) => { return (0, dns_equal_1.default)(rr.name, service.fqdn); }; const done = (exists) => { mdns.removeListener('response', onresponse); clearTimeout(timer); callback(!!exists); }; mdns.on('response', onresponse); setTimeout(send, Math.random() * 250); } announce(server, service) { var delay = 1000; var packet = service.records(); server.register(packet); const broadcast = () => { if (!service.activated || service.destroyed) return; server.mdns.respond(packet, function () { if (!service.published) { service.activated = true; service.published = true; service.emit('up'); } delay = delay * REANNOUNCE_FACTOR; if (delay < REANNOUNCE_MAX_MS && !service.destroyed) { setTimeout(broadcast, delay).unref(); } }); }; broadcast(); } teardown(server, services, callback) { if (!Array.isArray(services)) services = [services]; services = services.filter((service) => service.activated); var records = array_flatten_1.default.depth(services.map(function (service) { service.activated = false; var records = service.records(); records.forEach((record) => { record.ttl = 0; }); return records; }), 1); if (records.length === 0) return callback && callback(); server.unregister(records); server.mdns.respond(records, function () { services.forEach(function (service) { service.published = false; }); if (typeof callback === "function") { callback.apply(null, arguments); } }); } } exports.Registry = Registry; exports.default = Registry; //# sourceMappingURL=registry.js.mapPK@[Z*dist/lib/registry.d.tsnuW+Aimport Server from './mdns-server'; import Service, { ServiceConfig } from './service'; export declare class Registry { private server; private services; constructor(server: Server); publish(config: ServiceConfig): Service; unpublishAll(callback: CallableFunction | undefined): void; destroy(): void; private probe; private announce; private teardown; } export default Registry; PK@[p255dist/lib/service.jsnuW+A"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Service = void 0; const os_1 = __importDefault(require("os")); const dns_txt_1 = __importDefault(require("./dns-txt")); const events_1 = require("events"); const service_types_1 = require("./service-types"); const TLD = '.local'; class Service extends events_1.EventEmitter { constructor(config) { super(); this.probe = true; this.published = false; this.activated = false; this.destroyed = false; this.txtService = new dns_txt_1.default(); if (!config.name) throw new Error('ServiceConfig requires `name` property to be set'); if (!config.type) throw new Error('ServiceConfig requires `type` property to be set'); if (!config.port) throw new Error('ServiceConfig requires `port` property to be set'); this.name = config.name.split('.').join('-'); this.protocol = config.protocol || 'tcp'; this.type = (0, service_types_1.toString)({ name: config.type, protocol: this.protocol }); this.port = config.port; this.host = config.host || os_1.default.hostname(); this.fqdn = `${this.name}.${this.type}${TLD}`; this.txt = config.txt; this.subtypes = config.subtypes; } records() { var records = [this.RecordPTR(this), this.RecordSRV(this), this.RecordTXT(this)]; for (let subtype of this.subtypes || []) { records.push(this.RecordSubtypePTR(this, subtype)); } let ifaces = Object.values(os_1.default.networkInterfaces()); for (let iface of ifaces) { let addrs = iface; for (let addr of addrs) { if (addr.internal || addr.mac === '00:00:00:00:00:00') continue; switch (addr.family) { case 'IPv4': records.push(this.RecordA(this, addr.address)); break; case 'IPv6': records.push(this.RecordAAAA(this, addr.address)); break; } } } return records; } RecordPTR(service) { return { name: `${service.type}${TLD}`, type: 'PTR', ttl: 28800, data: service.fqdn }; } RecordSubtypePTR(service, subtype) { return { name: `_${subtype}._sub.${service.type}${TLD}`, type: 'PTR', ttl: 28800, data: `${service.name}.${service.type}${TLD}` }; } RecordSRV(service) { return { name: service.fqdn, type: 'SRV', ttl: 120, data: { port: service.port, target: service.host } }; } RecordTXT(service) { return { name: service.fqdn, type: 'TXT', ttl: 4500, data: this.txtService.encode(service.txt) }; } RecordA(service, ip) { return { name: service.host, type: 'A', ttl: 120, data: ip }; } RecordAAAA(service, ip) { return { name: service.host, type: 'AAAA', ttl: 120, data: ip }; } } exports.Service = Service; exports.default = Service; //# sourceMappingURL=service.js.mapPK@[LFudist/lib/service.d.tsnuW+A/// import KeyValue from './KeyValue'; import { EventEmitter } from 'events'; export interface ServiceConfig { name: string; type: string; port: number; protocol?: 'tcp' | 'udp'; host?: string; fqdn?: string; subtypes?: Array; txt?: KeyValue; probe?: boolean; } export interface ServiceRecord { name: string; type: 'PTR' | 'SRV' | 'TXT' | 'A' | 'AAAA'; ttl: number; data: KeyValue | string | any; } export interface ServiceReferer { address: string; family: 'IPv4' | 'IPv6'; port: number; size: number; } export declare class Service extends EventEmitter { name: string; type: string; protocol: 'tcp' | 'udp'; port: number; host: string; fqdn: string; txt?: any; subtypes?: Array; addresses?: Array; referer?: ServiceReferer; probe: boolean; published: boolean; activated: boolean; destroyed: boolean; start?: any; stop?: any; private txtService; constructor(config: ServiceConfig); records(): Array; private RecordPTR; private RecordSubtypePTR; private RecordSRV; private RecordTXT; private RecordA; private RecordAAAA; } export default Service; PK@[( dist/lib/mdns-server.d.tsnuW+Aimport { ServiceRecord } from './service'; export declare class Server { mdns: any; private registry; private errorCallback; constructor(opts: any, errorCallback?: Function | undefined); register(records: Array | ServiceRecord): void; unregister(records: Array | ServiceRecord): void; private respondToQuery; private recordsFor; private isDuplicateRecord; private unique; } export default Server; PK@[dist/lib/browser.d.tsnuW+A/// import { EventEmitter } from 'events'; import Service from './service'; export interface BrowserConfig { type: string; protocol?: 'tcp' | 'udp'; subtypes?: Array; txt?: any; } export declare class Browser extends EventEmitter { private mdns; private onresponse; private serviceMap; private txt; private name?; private txtQuery; private wildcard; private _services; constructor(mdns: any, opts: any, onup?: (service: Service) => void); start(): void; stop(): void; update(): void; get services(): any[]; private addService; private removeService; private goodbyes; private buildServicesFor; } export default Browser; PK@[1dist/lib/mdns-server.jsnuW+A"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Server = void 0; const array_flatten_1 = __importDefault(require("array-flatten")); const es6_1 = __importDefault(require("fast-deep-equal/es6")); const multicast_dns_1 = __importDefault(require("multicast-dns")); const dns_equal_1 = __importDefault(require("dns-equal")); class Server { constructor(opts, errorCallback) { this.registry = {}; this.mdns = (0, multicast_dns_1.default)(opts); this.mdns.setMaxListeners(0); this.mdns.on('query', this.respondToQuery.bind(this)); this.errorCallback = errorCallback !== null && errorCallback !== void 0 ? errorCallback : function (err) { throw err; }; } register(records) { const shouldRegister = (record) => { var subRegistry = this.registry[record.type]; if (!subRegistry) { subRegistry = this.registry[record.type] = []; } else if (subRegistry.some(this.isDuplicateRecord(record))) { return; } subRegistry.push(record); }; if (Array.isArray(records)) { records.forEach(shouldRegister); } else { shouldRegister(records); } } unregister(records) { const shouldUnregister = (record) => { let type = record.type; if (!(type in this.registry)) { return; } this.registry[type] = this.registry[type].filter((i) => i.name !== record.name); }; if (Array.isArray(records)) { records.forEach(shouldUnregister); } else { shouldUnregister(records); } } respondToQuery(query) { let self = this; query.questions.forEach((question) => { var type = question.type; var name = question.name; var answers = type === 'ANY' ? array_flatten_1.default.depth(Object.keys(self.registry).map(self.recordsFor.bind(self, name)), 1) : self.recordsFor(name, type); if (answers.length === 0) return; var additionals = []; if (type !== 'ANY') { answers.forEach((answer) => { if (answer.type !== 'PTR') return; additionals = additionals .concat(self.recordsFor(answer.data, 'SRV')) .concat(self.recordsFor(answer.data, 'TXT')); }); additionals .filter(function (record) { return record.type === 'SRV'; }) .map(function (record) { return record.data.target; }) .filter(this.unique()) .forEach(function (target) { additionals = additionals .concat(self.recordsFor(target, 'A')) .concat(self.recordsFor(target, 'AAAA')); }); } self.mdns.respond({ answers: answers, additionals: additionals }, (err) => { if (err) { this.errorCallback(err); } }); }); } recordsFor(name, type) { if (!(type in this.registry)) { return []; } return this.registry[type].filter((record) => { var _name = ~name.indexOf('.') ? record.name : record.name.split('.')[0]; return (0, dns_equal_1.default)(_name, name); }); } isDuplicateRecord(a) { return (b) => { return a.type === b.type && a.name === b.name && (0, es6_1.default)(a.data, b.data); }; } unique() { var set = []; return (obj) => { if (~set.indexOf(obj)) return false; set.push(obj); return true; }; } } exports.Server = Server; exports.default = Server; //# sourceMappingURL=mdns-server.js.mapPK@[!,,dist/lib/dns-txt.d.tsnuW+A/// import KeyValue from './KeyValue'; export declare class DnsTxt { private binary; constructor(opts?: KeyValue); encode(data?: KeyValue): Buffer[]; decode(buffer: Buffer): KeyValue; decodeAll(buffer: Array): KeyValue; } export default DnsTxt; PK@[+Qqqdist/lib/KeyValue.jsnuW+A"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); //# sourceMappingURL=KeyValue.js.mapPK@[_˻dist/lib/service-types.js.mapnuW+A{"version":3,"file":"service-types.js","sourceRoot":"","sources":["../../src/lib/service-types.ts"],"names":[],"mappings":";;;AAcA,MAAM,MAAM,GAAG,CAAC,IAAY,EAAU,EAAE;IACpC,OAAO,GAAG,GAAG,IAAI,CAAA;AACrB,CAAC,CAAA;AAOD,MAAM,WAAW,GAAG,CAAC,GAAW,EAAW,EAAE;IACzC,IAAI,IAAI,GAAkB,CAAC,MAAM,EAAC,UAAU,EAAC,SAAS,CAAC,CAAA;IACvD,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAA;AAC7B,CAAC,CAAA;AAOM,MAAM,QAAQ,GAAG,CAAC,IAAiB,EAAO,EAAE;IAE/C,IAAI,SAAS,GAAgB;QACzB,IAAI,EAAU,IAAI,CAAC,IAAI;QACvB,QAAQ,EAAM,IAAI,CAAC,QAAQ;QAC3B,OAAO,EAAM,IAAI,CAAC,OAAO;KAC5B,CAAA;IAED,IAAI,OAAO,GAAe,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACnD,OAAO,OAAO;SACT,MAAM,CAAC,CAAC,CAAC,GAAG,EAAC,GAAG,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,GAAG,KAAK,S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"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Browser = void 0; const dns_txt_1 = __importDefault(require("./dns-txt")); const dns_equal_1 = __importDefault(require("dns-equal")); const events_1 = require("events"); const service_types_1 = require("./service-types"); const filter_service_1 = __importDefault(require("./utils/filter-service")); const filter_txt_1 = __importDefault(require("./utils/filter-txt")); const TLD = '.local'; const WILDCARD = '_services._dns-sd._udp' + TLD; class Browser extends events_1.EventEmitter { constructor(mdns, opts, onup) { super(); this.onresponse = null; this.serviceMap = {}; this.wildcard = false; this._services = []; if (typeof opts === 'function') return new Browser(mdns, null, opts); this.mdns = mdns; if (opts != null && opts.txt != null) { this.txt = new dns_txt_1.default(opts.txt); } else { this.txt = new dns_txt_1.default(); } if (!opts || !opts.type) { this.name = WILDCARD; this.wildcard = true; } else { this.name = (0, service_types_1.toString)({ name: opts.type, protocol: opts.protocol || 'tcp' }) + TLD; if (opts.name) this.name = opts.name + '.' + this.name; this.wildcard = false; } if (opts != null && opts.txt !== undefined) this.txtQuery = (0, filter_txt_1.default)(opts.txt); if (onup) this.on('up', onup); this.start(); } start() { if (this.onresponse || this.name === undefined) return; var self = this; var nameMap = {}; if (!this.wildcard) nameMap[this.name] = true; this.onresponse = (packet, rinfo) => { if (self.wildcard) { packet.answers.forEach((answer) => { if (answer.type !== 'PTR' || answer.name !== self.name || answer.name in nameMap) return; nameMap[answer.data] = true; self.mdns.query(answer.data, 'PTR'); }); } Object.keys(nameMap).forEach(function (name) { self.goodbyes(name, packet).forEach(self.removeService.bind(self)); var matches = self.buildServicesFor(name, packet, self.txt, rinfo); if (matches.length === 0) return; matches.forEach((service) => { if (self.serviceMap[service.fqdn]) return; self.addService(service); }); }); }; this.mdns.on('response', this.onresponse); this.update(); } stop() { if (!this.onresponse) return; this.mdns.removeListener('response', this.onresponse); this.onresponse = null; } update() { this.mdns.query(this.name, 'PTR'); } get services() { return this._services; } addService(service) { if ((0, filter_service_1.default)(service, this.txtQuery) === false) return; this._services.push(service); this.serviceMap[service.fqdn] = true; this.emit('up', service); } removeService(fqdn) { var service, index; this._services.some(function (s, i) { if ((0, dns_equal_1.default)(s.fqdn, fqdn)) { service = s; index = i; return true; } }); if (!service || index === undefined) return; this._services.splice(index, 1); delete this.serviceMap[fqdn]; this.emit('down', service); } goodbyes(name, packet) { return packet.answers.concat(packet.additionals) .filter((rr) => rr.type === 'PTR' && rr.ttl === 0 && (0, dns_equal_1.default)(rr.name, name)) .map((rr) => rr.data); } buildServicesFor(name, packet, txt, referer) { var records = packet.answers.concat(packet.additionals).filter((rr) => rr.ttl > 0); return records .filter((rr) => rr.type === 'PTR' && (0, dns_equal_1.default)(rr.name, name)) .map((ptr) => { const service = { addresses: [], subtypes: [] }; records.filter((rr) => { return (rr.type === 'PTR' && (0, dns_equal_1.default)(rr.data, ptr.data) && rr.name.includes('._sub')); }).forEach((rr) => { const types = (0, service_types_1.toType)(rr.name); service.subtypes.push(types.subtype); }); records .filter((rr) => { return (rr.type === 'SRV' || rr.type === 'TXT') && (0, dns_equal_1.default)(rr.name, ptr.data); }) .forEach((rr) => { if (rr.type === 'SRV') { var parts = rr.name.split('.'); var name = parts[0]; var types = (0, service_types_1.toType)(parts.slice(1, -1).join('.')); service.name = name; service.fqdn = rr.name; service.host = rr.data.target; service.referer = referer; service.port = rr.data.port; service.type = types.name; service.protocol = types.protocol; } else if (rr.type === 'TXT') { service.rawTxt = rr.data; service.txt = this.txt.decodeAll(rr.data); } }); if (!service.name) return; records .filter((rr) => (rr.type === 'A' || rr.type === 'AAAA') && (0, dns_equal_1.default)(rr.name, service.host)) .forEach((rr) => service.addresses.push(rr.data)); return service; }) .filter((rr) => !!rr); } } exports.Browser = Browser; exports.default = Browser; //# sourceMappingURL=browser.js.mapPK@[-uudist/lib/dns-txt.js.mapnuW+A{"version":3,"file":"dns-txt.js","sourceRoot":"","sources":["../../src/lib/dns-txt.ts"],"names":[],"mapp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,4BAqLC;AAED,kBAAe,QAAQ,CAAA"}PK@[ z~~dist/lib/service-types.jsnuW+A"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toType = exports.toString = void 0; const Prefix = (name) => { return '_' + name; }; const AllowedProp = (key) => { let keys = ['name', 'protocol', 'subtype']; return keys.includes(key); }; const toString = (data) => { let formatted = { name: data.name, protocol: data.protocol, subtype: data.subtype }; let entries = Object.entries(formatted); return entries .filter(([key, val]) => AllowedProp(key) && val !== undefined) .reduce((prev, [key, val]) => { switch (typeof val) { case 'object': val.map((i) => prev.push(Prefix(i))); break; default: prev.push(Prefix(val)); break; } return prev; }, []) .join('.'); }; exports.toString = toString; const toType = (string) => { let parts = string.split('.'); let subtype; for (let i in parts) { if (parts[i][0] !== '_') continue; parts[i] = parts[i].slice(1); } if (parts.includes('sub')) { subtype = parts.shift(); parts.shift(); } return { name: parts.shift(), protocol: parts.shift() || null, subtype: subtype }; }; exports.toType = toType; //# sourceMappingURL=service-types.js.mapPK@[`T dist/lib/service.js.mapnuW+A{"version":3,"file":"service.js","sourceRoot":"","sources":["../../src/lib/service.ts"],"names":[],"mappings":";;;;;;AAIA,4CAAiD;AACjD,wDAAwD;AAExD,mCAAqD;AACrD,mDAA8D;AAE9D,MAAM,GAAG,GAAW,QAAQ,CAAA;AA6B5B,MAAa,OAAQ,SAAQ,qBAAY;IAwBrC,YAAY,MAAqB;QAC7B,KAAK,EAAE,CAAA;QAZJ,UAAK,GAAoB,IAAI,CAAA;QAE7B,cAAS,GAAe,KAAK,CAAA;QAC7B,cAAS,GAAe,KAAK,CAAA;QAC7B,cAAS,GAAgB,KAAK,CAAA;QAUjC,IAAI,CAAC,UAAU,GAAG,IAAI,iBAAM,EAAE,CAAA;QAE9B,IAAI,CAAC,MAAM,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;QACtF,IAAI,CAAC,MAAM,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,kDAA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EAAI,OAAO,CAAC,IAAI;aACzB;SACJ,CAAA;IACL,CAAC;IAOO,SAAS,CAAC,OAAgB;QAC9B,OAAO;YACH,IAAI,EAAM,OAAO,CAAC,IAAI;YACtB,IAAI,EAAM,KAAK;YACf,GAAG,EAAO,IAAI;YACd,IAAI,EAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC;SAChD,CAAA;IACL,CAAC;IAQO,OAAO,CAAC,OAAgB,EAAE,EAAU;QACxC,OAAO;YACH,IAAI,EAAM,OAAO,CAAC,IAAI;YACtB,IAAI,EAAM,GAAG;YACb,GAAG,EAAO,GAAG;YACb,IAAI,EAAM,EAAE;SACf,CAAA;IACL,CAAC;IAQO,UAAU,CAAC,OAAgB,EAAE,EAAU;QAC3C,OAAO;YACH,IAAI,EAAM,OAAO,CAAC,IAAI;YACtB,IAAI,EAAM,MAAM;YAChB,GAAG,EAAO,GAAG;YACb,IAAI,EAAM,EAAE;SACf,CAAA;IACL,CAAC;CAEJ;AAnKD,0BAmKC;AAED,kBAAe,OAAO,CAAA"}PK@[;G  dist/lib/service-types.d.tsnuW+Aexport interface ServiceType { name?: string; protocol?: 'tcp' | 'udp' | string | null | undefined; subtype?: string | undefined; } export declare const toString: (data: ServiceType) => any; export declare const toType: (string: string) => ServiceType; PK@[UBdist/lib/mdns-server.js.mapnuW+A{"version":3,"file":"mdns-server.js","sourceRoot":"","sources":["../../src/lib/mdns-server.ts"],"names":[],"mappings":";;;;;;AAAA,kEAAgD;AAEhD,8DAAsD;AAEtD,kEAAgD;AAChD,0DAA4C;AAE5C,MAAa,MAAM;IAMf,YAAY,IAAS,EAAE,aAAoC;QAHnD,aAAQ,GAAgB,EAAE,CAAA;QAI9B,IAAI,CAAC,IAAI,GAAG,IAAA,uBAAY,EAAC,IAAI,CAAC,CAAA;QAC9B,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;QAC5B,IAAI,CAAC,IAAI,CAAC,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AC9B,CAAC,CAAC,CAAA;IACN,CAAC;IAEO,iBAAiB,CAAE,CAAgB;QACvC,OAAO,CAAC,CAAgB,EAAE,EAAE;YACxB,OAAO,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;gBACpB,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;gBACjB,IAAA,aAAS,EAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAA;QACjC,CAAC,CAAA;IACL,CAAC;IAEO,MAAM;QACV,IAAI,GAAG,GAAe,EAAE,CAAA;QACxB,OAAO,CAAC,GAAQ,EAAE,EAAE;YAChB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;gBAAE,OAAO,KAAK,CAAA;YACnC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YACb,OAAO,IAAI,CAAA;QACf,CAAC,CAAA;IACL,CAAC;CAEJ;AAjID,wBAiIC;AAED,kBAAe,MAAM,CAAA"}PK@[`=yydist/lib/dns-txt.jsnuW+A'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.DnsTxt = void 0; class DnsTxt { constructor(opts = {}) { this.binary = opts ? opts.binary : false; } encode(data = {}) { return Object.entries(data) .map(([key, value]) => { let item = `${key}=${value}`; return Buffer.from(item); }); } decode(buffer) { var data = {}; try { let format = buffer.toString(); let parts = format.split(/=(.+)/); let key = parts[0]; let value = parts[1]; data[key] = value; } catch (_) { } return data; } decodeAll(buffer) { return buffer .filter(i => i.length > 1) .map(i => this.decode(i)) .reduce((prev, curr) => { var obj = prev; let [key] = Object.keys(curr); let [value] = Object.values(curr); obj[key] = value; return obj; }, {}); } } exports.DnsTxt = DnsTxt; exports.default = DnsTxt; //# sourceMappingURL=dns-txt.js.mapPK@[vldist/index.d.tsnuW+Aimport Browser, { BrowserConfig } from './lib/browser'; import Service, { ServiceConfig, ServiceReferer } from './lib/service'; export declare class Bonjour { private server; private registry; constructor(opts?: ServiceConfig | undefined, errorCallback?: Function | undefined); publish(opts: ServiceConfig): Service; unpublishAll(callback?: CallableFunction | undefined): void; find(opts?: BrowserConfig | undefined, onup?: (service: Service) => void): Browser; findOne(opts?: BrowserConfig | undefined, timeout?: number, callback?: CallableFunction): Browser; destroy(): void; } export { Service, ServiceReferer, ServiceConfig, Browser, BrowserConfig }; export default Bonjour; PK@[,JZQQtypes/multicast-dns.d.tsnuW+Adeclare module 'multicast-dns' { function init(opts: any) export = init }PK@[)cctypes/dns-equal.d.tsnuW+Adeclare module 'dns-equal' { function equal(a: string, b: string): boolean export = equal }PK@[LICENSEnuW+AThe MIT License (MIT) Copyright (https://github.com/onlxltd/bonjour-service) (c) 2021 ON LX Limited Portions Copyright (Bonjour - https://github.com/watson/bonjour) (c) 2015-2016 Thomas Watson Steen Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. PK@[t@dd package.jsonnuW+A{ "name": "bonjour-service", "version": "1.1.1", "description": "A Bonjour/Zeroconf implementation in TypeScript", "main": "./dist/index.js", "types": "./dist/index.d.ts", "dependencies": { "array-flatten": "^2.1.2", "dns-equal": "^1.0.0", "fast-deep-equal": "^3.1.3", "multicast-dns": "^7.2.5" }, "devDependencies": { "@types/node": "^16.18.11", "@typescript-eslint/eslint-plugin": "^5.22.0", "@typescript-eslint/parser": "^5.22.0", "after-all": "^2.0.2", "eslint": "^8.15.0", "standard": "^17.0.0", "tape": "^5.2.2", "ts-node-dev": "^2.0.0", "typescript": "^4.4.4" }, "scripts": { "test": "standard --fix && tape test/*.js", "build": "tsc --removeComments true", "dev": "ts-node-dev --respawn --transpile-only ./src/index.ts", "example:simple": "node examples/simple" }, "repository": { "type": "git", "url": "https://github.com/onlxltd/bonjour-service.git" }, "keywords": [ "bonjour", "zeroconf", "zero", "configuration", "mdns", "dns", "service", "discovery", "multicast", "broadcast", "dns-sd" ], "author": "ON LX Lited (https://labs.onlx.ltd)", "license": "MIT", "bugs": { "url": "https://github.com/onlxltd/bonjour-service/issues" }, "homepage": "https://github.com/onlxltd/bonjour-service" } PK@[||0 README.mdnuW+APK@['  dist/index.jsnuW+APK@[$l||=dist/index.js.mapnuW+APK@[ mm!dist/lib/utils/filter-txt.d.tsnuW+APK@[ f-$$"dist/lib/utils/filter-txt.jsnuW+APK@[$%$dist/lib/utils/filter-service.js.mapnuW+APK@[ ":'dist/lib/utils/filter-service.d.tsnuW+APK@[5 B(dist/lib/utils/filter-txt.js.mapnuW+APK@[;KS~~ V*dist/lib/utils/filter-service.jsnuW+APK@[zQFF$-dist/lib/KeyValue.d.tsnuW+APK@[Βss-dist/lib/KeyValue.js.mapnuW+APK@[tpk.dist/lib/registry.jsnuW+APK@[Z*sBdist/lib/registry.d.tsnuW+APK@[p255XDdist/lib/service.jsnuW+APK@[LFuRdist/lib/service.d.tsnuW+APK@[( Xdist/lib/mdns-server.d.tsnuW+APK@[2Zdist/lib/browser.d.tsnuW+APK@[1Z]dist/lib/mdns-server.jsnuW+APK@[!,,rndist/lib/dns-txt.d.tsnuW+APK@[+Qqqodist/lib/KeyValue.jsnuW+APK@[_˻pdist/lib/service-types.js.mapnuW+APK@[wdist/lib/browser.jsnuW+APK@[-uudist/lib/dns-txt.js.mapnuW+APK@[nÏEEbdist/lib/browser.js.mapnuW+APK@[.Uuudist/lib/registry.js.mapnuW+APK@[ z~~dist/lib/service-types.jsnuW+APK@[`T rdist/lib/service.js.mapnuW+APK@[;G  ?dist/lib/service-types.d.tsnuW+APK@[UBdist/lib/mdns-server.js.mapnuW+APK@[`=yydist/lib/dns-txt.jsnuW+APK@[vlFdist/index.d.tsnuW+APK@[,JZQQLtypes/multicast-dns.d.tsnuW+APK@[)cctypes/dns-equal.d.tsnuW+APK@[LICENSEnuW+APK@[t@dd package.jsonnuW+APK## ,