New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@svrooij/sonos

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@svrooij/sonos - npm Package Compare versions

Comparing version 2.5.0-beta.7 to 2.5.0-beta.8

lib/helpers/ip-helper.d.ts

3

lib/index.d.ts

@@ -0,1 +1,2 @@

import IpHelper from './helpers/ip-helper';
import MetaDataHelper from './helpers/metadata-helper';

@@ -8,3 +9,3 @@ import SonosDevice from './sonos-device';

import { SmapiClient } from './musicservices/smapi-client';
export { MetaDataHelper, ServiceEvents, SmapiClient, SonosDevice, SonosDeviceDiscovery, SonosEvents, SonosEventListener, SonosManager, };
export { IpHelper, MetaDataHelper, ServiceEvents, SmapiClient, SonosDevice, SonosDeviceDiscovery, SonosEvents, SonosEventListener, SonosManager, };
//# sourceMappingURL=index.d.ts.map

@@ -6,3 +6,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.SonosManager = exports.SonosEventListener = exports.SonosEvents = exports.SonosDeviceDiscovery = exports.SonosDevice = exports.SmapiClient = exports.ServiceEvents = exports.MetaDataHelper = void 0;
exports.SonosManager = exports.SonosEventListener = exports.SonosEvents = exports.SonosDeviceDiscovery = exports.SonosDevice = exports.SmapiClient = exports.ServiceEvents = exports.MetaDataHelper = exports.IpHelper = void 0;
const ip_helper_1 = __importDefault(require("./helpers/ip-helper"));
exports.IpHelper = ip_helper_1.default;
const metadata_helper_1 = __importDefault(require("./helpers/metadata-helper"));

@@ -9,0 +11,0 @@ exports.MetaDataHelper = metadata_helper_1.default;

@@ -19,2 +19,3 @@ import { Debugger } from 'debug';

private debugger?;
private resolvedIp?;
protected get debug(): Debugger;

@@ -64,3 +65,3 @@ private events?;

* Creates an instance of the implemented service.
* @param {string} host The ip or the domainname of the sonos speaker
* @param {string} host The ip (or hostname) of the sonos speaker
* @param {number} [port=1400] The port of the sonos speaker (defaults to 1400)

@@ -73,2 +74,3 @@ * @param {string} [uuid=Guid.create().toString()] The uuid of the speaker, used for grouping and events.

get Uuid(): string;
private ResolveHostname;
/**

@@ -75,0 +77,0 @@ * SoapRequest will do a request that expects a Response

@@ -30,2 +30,3 @@ "use strict";

const debug_1 = __importDefault(require("debug"));
const ip_helper_1 = __importDefault(require("../helpers/ip-helper"));
const soap_helper_1 = __importDefault(require("../helpers/soap-helper"));

@@ -50,3 +51,3 @@ const xml_helper_1 = __importDefault(require("../helpers/xml-helper"));

* Creates an instance of the implemented service.
* @param {string} host The ip or the domainname of the sonos speaker
* @param {string} host The ip (or hostname) of the sonos speaker
* @param {number} [port=1400] The port of the sonos speaker (defaults to 1400)

@@ -72,2 +73,7 @@ * @param {string} [uuid=Guid.create().toString()] The uuid of the speaker, used for grouping and events.

}
async ResolveHostname() {
if (this.resolvedIp === undefined) {
this.resolvedIp = ip_helper_1.default.IsIpv4(this.host) ? this.host : await ip_helper_1.default.ResolveHostname(this.host);
}
}
// #region Protected requests handlers

@@ -85,2 +91,3 @@ /**

this.debug('%s()', action);
await this.ResolveHostname();
return await this.handleRequestAndParseResponse(this.generateRequest(action, undefined), action);

@@ -101,2 +108,3 @@ }

this.debug('%s(%o)', action, body);
await this.ResolveHostname();
return await this.handleRequestAndParseResponse(this.generateRequest(action, body), action);

@@ -114,2 +122,3 @@ }

this.debug('%s()', action);
await this.ResolveHostname();
return await this.handleRequest(this.generateRequest(action, undefined), action);

@@ -129,2 +138,3 @@ }

this.debug('%s(%o)', action, body);
await this.ResolveHostname();
return await this.handleRequest(this.generateRequest(action, body), action);

@@ -135,3 +145,4 @@ }

getUrl() {
return `http://${this.host}:${this.port}${this.controlUrl}`;
var _a;
return `http://${(_a = this.resolvedIp) !== null && _a !== void 0 ? _a : this.host}:${this.port}${this.controlUrl}`;
}

@@ -334,5 +345,7 @@ messageAction(action) {

async subscribeForEvents() {
var _a;
const callback = sonos_event_listener_1.default.DefaultInstance.GetEndpoint(this.uuid, this.serviceNane);
this.debug('Creating event subscription with callback: %s', callback);
const resp = await node_fetch_1.default(new node_fetch_1.Request(`http://${this.host}:${this.port}${this.eventSubUrl}`, {
await this.ResolveHostname();
const resp = await node_fetch_1.default(new node_fetch_1.Request(`http://${(_a = this.resolvedIp) !== null && _a !== void 0 ? _a : this.host}:${this.port}${this.eventSubUrl}`, {
method: 'SUBSCRIBE',

@@ -344,3 +357,3 @@ headers: {

},
timeout: 5000,
timeout: 15000,
}));

@@ -371,5 +384,7 @@ const sid = resp.ok ? resp.headers.get('sid') : undefined;

async renewEventSubscription() {
var _a;
this.debug('Renewing event subscription');
await this.ResolveHostname();
if (typeof this.sid === 'string' && this.sid !== '') {
const resp = await node_fetch_1.default(new node_fetch_1.Request(`http://${this.host}:${this.port}${this.eventSubUrl}`, {
const resp = await node_fetch_1.default(new node_fetch_1.Request(`http://${(_a = this.resolvedIp) !== null && _a !== void 0 ? _a : this.host}:${this.port}${this.eventSubUrl}`, {
method: 'SUBSCRIBE',

@@ -380,3 +395,3 @@ headers: {

},
timeout: 5000,
timeout: 15000,
}));

@@ -399,2 +414,3 @@ if (resp.ok) {

async cancelSubscription() {
var _a;
this.debug('Cancelling event subscription');

@@ -405,3 +421,3 @@ if (this.eventRenewInterval !== undefined) {

if (this.sid !== undefined) {
const resp = await node_fetch_1.default(new node_fetch_1.Request(`http://${this.host}:${this.port}${this.eventSubUrl}`, {
const resp = await node_fetch_1.default(new node_fetch_1.Request(`http://${(_a = this.resolvedIp) !== null && _a !== void 0 ? _a : this.host}:${this.port}${this.eventSubUrl}`, {
method: 'UNSUBSCRIBE',

@@ -411,3 +427,3 @@ headers: {

},
timeout: 5000,
timeout: 15000,
}));

@@ -414,0 +430,0 @@ sonos_event_listener_1.default.DefaultInstance.UnregisterSubscription(this.sid);

@@ -14,2 +14,3 @@ "use strict";

const smapi_client_1 = require("./musicservices/smapi-client");
const ip_helper_1 = __importDefault(require("./helpers/ip-helper"));
const json_helper_1 = __importDefault(require("./helpers/json-helper"));

@@ -58,2 +59,5 @@ const tts_helper_1 = __importDefault(require("./helpers/tts-helper"));

}
if (ip_helper_1.default.IsIpv4(this.host) === false) {
this.debug('Sonos devices don\'t like hostnames, resolve once is faster IpHelper.ResolveHostname(host)');
}
}

@@ -60,0 +64,0 @@ /**

@@ -12,2 +12,3 @@ "use strict";

const models_1 = require("./models");
const ip_helper_1 = __importDefault(require("./helpers/ip-helper"));
const tts_helper_1 = __importDefault(require("./helpers/tts-helper"));

@@ -37,3 +38,4 @@ /**

this.debug('InitializeFromDevice %s', host);
this.zoneService = new services_1.ZoneGroupTopologyService(host, port);
const ip = ip_helper_1.default.IsIpv4(host) ? host : await ip_helper_1.default.ResolveHostname(host);
this.zoneService = new services_1.ZoneGroupTopologyService(ip, port);
return await this.Initialize();

@@ -40,0 +42,0 @@ }

{
"name": "@svrooij/sonos",
"version": "2.5.0-beta.7",
"version": "2.5.0-beta.8",
"description": "A node library to control your sonos devices, written in typescript",

@@ -38,2 +38,3 @@ "main": "lib/index.js",

"@types/node-fetch": "^2.5.10",
"@types/node": "^16.11.7",
"@typescript-eslint/eslint-plugin": "^3.9.0",

@@ -40,0 +41,0 @@ "@typescript-eslint/parser": "^3.9.0",

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc