Socket
Socket
Sign inDemoInstall

bonjour-service

Package Overview
Dependencies
7
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.12 to 1.0.13

.github/workflows/build-and-test.yml

2

dist/index.d.ts

@@ -10,3 +10,3 @@ import Browser, { BrowserConfig } from './lib/browser';

find(opts?: BrowserConfig | undefined, onup?: (service: Service) => void): Browser;
findOne(opts: BrowserConfig | undefined, timeout: number | undefined, callback: CallableFunction): Browser;
findOne(opts?: BrowserConfig | undefined, timeout?: number, callback?: CallableFunction): Browser;
destroy(): void;

@@ -13,0 +13,0 @@ }

@@ -16,2 +16,3 @@ /// <reference types="node" />

private name?;
private txtQuery;
private wildcard;

@@ -18,0 +19,0 @@ private _services;

@@ -7,6 +7,8 @@ "use strict";

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 dns_txt_1 = __importDefault(require("./dns-txt"));
const dnsEqual = require('dns-equal');
const filter_service_1 = __importDefault(require("./utils/filter-service"));
const filter_txt_1 = __importDefault(require("./utils/filter-txt"));
const TLD = '.local';

@@ -40,2 +42,4 @@ const WILDCARD = '_services._dns-sd._udp' + TLD;

}
if (opts != null && opts.txt !== undefined)
this.txtQuery = (0, filter_txt_1.default)(opts.txt);
if (onup)

@@ -89,2 +93,4 @@ this.on('up', onup);

addService(service) {
if ((0, filter_service_1.default)(service, this.txtQuery) === false)
return;
this._services.push(service);

@@ -97,3 +103,3 @@ this.serviceMap[service.fqdn] = true;

this._services.some(function (s, i) {
if (dnsEqual(s.fqdn, fqdn)) {
if ((0, dns_equal_1.default)(s.fqdn, fqdn)) {
service = s;

@@ -112,3 +118,3 @@ index = i;

return packet.answers.concat(packet.additionals)
.filter((rr) => rr.type === 'PTR' && rr.ttl === 0 && dnsEqual(rr.name, name))
.filter((rr) => rr.type === 'PTR' && rr.ttl === 0 && (0, dns_equal_1.default)(rr.name, name))
.map((rr) => rr.data);

@@ -119,5 +125,5 @@ }

return records
.filter((rr) => rr.type === 'PTR' && dnsEqual(rr.name, name))
.filter((rr) => rr.type === 'PTR' && (0, dns_equal_1.default)(rr.name, name))
.map((ptr) => {
var service = {
const service = {
addresses: []

@@ -127,3 +133,3 @@ };

.filter((rr) => {
return (rr.type === 'SRV' || rr.type === 'TXT') && dnsEqual(rr.name, ptr.data);
return (rr.type === 'SRV' || rr.type === 'TXT') && (0, dns_equal_1.default)(rr.name, ptr.data);
})

@@ -152,3 +158,3 @@ .forEach((rr) => {

records
.filter((rr) => (rr.type === 'A' || rr.type === 'AAAA') && dnsEqual(rr.name, service.host))
.filter((rr) => (rr.type === 'A' || rr.type === 'AAAA') && (0, dns_equal_1.default)(rr.name, service.host))
.forEach((rr) => service.addresses.push(rr.data));

@@ -155,0 +161,0 @@ return service;

/// <reference types="node" />
declare type KeyValue = {
[key: string]: any;
};
import KeyValue from './KeyValue';
export declare class DnsTxt {

@@ -6,0 +4,0 @@ private binary;

@@ -6,3 +6,2 @@ import Server from './mdns-server';

private services;
private activated;
constructor(server: Server);

@@ -12,4 +11,2 @@ publish(config: ServiceConfig): Service;

destroy(): void;
private start;
private stop;
private probe;

@@ -16,0 +13,0 @@ private announce;

@@ -15,9 +15,39 @@ "use strict";

this.services = [];
this.activated = false;
this.server = server;
}
publish(config) {
let service = new service_1.default(config);
service.start = this.start.bind(service, this);
service.stop = this.stop.bind(service, this);
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 });

@@ -33,34 +63,2 @@ return service;

}
start(registry, opts) {
if (this.activated)
return;
this.activated = true;
registry.services.push(this);
if (!(this instanceof service_1.default))
return;
if (opts.probe) {
var service = this;
registry.probe(registry.server.mdns, this, (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, this);
}
}
stop(registry, callback) {
if (!this.activated)
return;
if (!(this instanceof service_1.default))
return;
registry.teardown(registry.server, this, callback);
var index = registry.services.indexOf(this);
if (index !== -1)
registry.services.splice(index, 1);
}
probe(mdns, service, callback) {

@@ -67,0 +65,0 @@ var sent = false;

/// <reference types="node" />
import KeyValue from './KeyValue';
import { EventEmitter } from 'events';

@@ -11,5 +12,3 @@ export interface ServiceConfig {

subtypes?: Array<string>;
txt?: {
[key: string]: any;
};
txt?: KeyValue;
probe?: boolean;

@@ -21,5 +20,3 @@ }

ttl: number;
data: {
[key: string]: any;
} | string | any;
data: KeyValue | string | any;
}

@@ -26,0 +23,0 @@ export interface ServiceReferer {

@@ -8,5 +8,5 @@ "use strict";

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 dns_txt_1 = __importDefault(require("./dns-txt"));
const TLD = '.local';

@@ -21,2 +21,8 @@ class Service extends events_1.EventEmitter {

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;

@@ -23,0 +29,0 @@ this.protocol = config.protocol || 'tcp';

@@ -7,3 +7,3 @@ const { Bonjour } = require('../dist')

let browser = service.find({ type: 'http' })
const browser = service.find({ type: 'http' })

@@ -10,0 +10,0 @@ browser.on('up', (service) => {

{
"name": "bonjour-service",
"version": "1.0.12",
"version": "1.0.13",
"description": "A Bonjour/Zeroconf implementation in TypeScript",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"dependencies": {

@@ -10,10 +11,10 @@ "array-flatten": "^2.1.2",

"fast-deep-equal": "^3.1.3",
"multicast-dns": "^7.2.4"
"multicast-dns": "^7.2.5"
},
"devDependencies": {
"@types/node": "^14.14.35",
"@typescript-eslint/eslint-plugin": "^4.19.0",
"@typescript-eslint/parser": "^4.19.0",
"@typescript-eslint/eslint-plugin": "^5.22.0",
"@typescript-eslint/parser": "^5.22.0",
"after-all": "^2.0.2",
"eslint": "^8.13.0",
"eslint": "^8.15.0",
"standard": "^17.0.0",

@@ -20,0 +21,0 @@ "tape": "^5.2.2",

{
"compilerOptions": {
/* Visit https://aka.ms/tsconfig.json to read more about this file */
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "./dist", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
"baseUrl": ".", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
"allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
/* Advanced Options */
"skipLibCheck": true, /* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
"target": "es6",
"module": "commonjs",
"declaration": true,
"sourceMap": true,
"outDir": "./dist",
"strict": true,
"moduleResolution": "node",
"baseUrl": ".",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc