Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

azure-iot-common

Package Overview
Dependencies
Maintainers
3
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

azure-iot-common - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

2

lib/authentication_provider.d.ts

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

type: AuthenticationType;
getDeviceCredentials(callback: (err: Error, credentials: TransportConfig) => void): void;
getDeviceCredentials(callback: (err: Error, credentials?: TransportConfig) => void): void;
}

@@ -258,1 +258,9 @@ /// <reference types="node" />

}
/**
* Error thrown when a low level security device/driver fails.
*
* @augments {Error}
*/
export declare class SecurityDeviceError extends Error {
constructor(message?: string);
}

@@ -508,2 +508,18 @@ /*! Copyright (c) Microsoft. All rights reserved.

exports.DeviceRegistrationFailedError = DeviceRegistrationFailedError;
/**
* Error thrown when a low level security device/driver fails.
*
* @augments {Error}
*/
var SecurityDeviceError = (function (_super) {
__extends(SecurityDeviceError, _super);
function SecurityDeviceError(message) {
_super.call(this, message);
this.name = 'SecurityDeviceError';
this.message = message;
Error.captureStackTrace(this, this.constructor);
}
return SecurityDeviceError;
}(Error));
exports.SecurityDeviceError = SecurityDeviceError;
//# sourceMappingURL=errors.js.map

@@ -0,4 +1,6 @@

/// <reference types="node" />
/*! Copyright (c) Microsoft. All rights reserved.
*! Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
import * as authorization from './authorization';
/**

@@ -59,2 +61,6 @@ * Shared access signature tokens are used to authenticate the connection when using symmetric keys (as opposed to x509 certificates) to secure the connection with the Azure IoT hub.

/**
* @private
*/
static createWithSigningFunction(credentials: authorization.TransportConfig, expiry: number, signingFunction: Function, callback: (err: Error, sas?: SharedAccessSignature) => void): void;
/**
* @method module:azure-iot-common.SharedAccessSignature.parse

@@ -61,0 +67,0 @@ * @description Instantiate a SharedAccessSignature token from a string.

@@ -104,2 +104,39 @@ /*! Copyright (c) Microsoft. All rights reserved.

/**
* @private
*/
SharedAccessSignature.createWithSigningFunction = function (credentials, expiry, signingFunction, callback) {
function throwRef(name, value) {
throw new ReferenceError('Argument \'' + name + '\' is ' + value);
}
/*Codes_SRS_NODE_COMMON_SAS_06_001: [If `credentials`, `expiry`, `signingFunction`, or `callback` are falsy, `createWithSigningFunction` shall throw `ReferenceError`.] */
if (!credentials)
throwRef('credentials', credentials);
if (!expiry)
throwRef('expiry', expiry);
if (!signingFunction)
throwRef('signingFunction', signingFunction);
if (!callback)
throwRef('callback', callback);
var sas = new SharedAccessSignature();
/*Codes_SRS_NODE_COMMON_SAS_06_002: [The `createWithSigningFunction` shall create a `SharedAccessSignature` object with an `sr` property formed by url encoding `credentials.host` + `/devices/` + `credentials.deviceId`.] */
sas.sr = authorization.encodeUriComponentStrict(credentials.host + '/devices/' + credentials.deviceId);
/*Codes_SRS_NODE_COMMON_SAS_06_003: [** The `createWithSigningFunction` shall create a `SharedAccessSignature` object with an `se` property containing the value of the parameter `expiry`.] */
sas.se = expiry;
/*Codes_SRS_NODE_COMMON_SAS_06_004: [The `createWithSigningFunction` shall create a `SharedAccessSignature` object with an optional property `skn`, if the `credentials.sharedAccessKeyName` is not falsy, The value of the `skn` property will be the url encoded value of `credentials.sharedAccessKeyName`.] */
if (credentials.sharedAccessKeyName) {
sas.skn = authorization.encodeUriComponentStrict(credentials.sharedAccessKeyName);
}
signingFunction(Buffer.from(authorization.stringToSign(sas.sr, sas.se.toString())), function (err, signed) {
if (err) {
/*Codes_SRS_NODE_COMMON_SAS_06_006: [** The `createWithSigningFunction` will invoke the `callback` function with an error value if an error occurred during the signing. **] */
callback(err);
}
else {
/*Codes_SRS_NODE_COMMON_SAS_06_005: [The `createWithSigningFunction` shall create a `SharedAccessSignature` object with a `sig` property with the SHA256 hash of the string sr + `\n` + se. The `sig` value will first be base64 encoded THEN url encoded.] */
sas.sig = authorization.encodeUriComponentStrict(signed.toString('base64'));
callback(null, sas);
}
});
};
/**
* @method module:azure-iot-common.SharedAccessSignature.parse

@@ -106,0 +143,0 @@ * @description Instantiate a SharedAccessSignature token from a string.

{
"name": "azure-iot-common",
"version": "1.3.0",
"version": "1.4.0",
"description": "Common components shared by Azure IoT device and service SDKs",

@@ -5,0 +5,0 @@ "author": "Microsoft Corporation",

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