Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(mqttBase?: MqttBase) {
super();
this._mqttBase = mqttBase || new MqttBase();
this._config.pollingInterval = ProvisioningDeviceConstants.defaultPollingInterval;
const responseHandler = (topic: string, payload: any) => {
let payloadString: string = payload.toString('ascii');
debug('message received on ' + topic);
debug('request payload is: ' + payloadString);
/* Codes_SRS_NODE_PROVISIONING_MQTT_18_010: [ When waiting for responses, `registrationRequest` shall watch for messages with a topic named $dps/registrations/res//?$rid=.] */
/* Codes_SRS_NODE_PROVISIONING_MQTT_18_024: [ When waiting for responses, `queryOperationStatus` shall watch for messages with a topic named $dps/registrations/res//?$rid=.] */
let match = topic.match(/^\$dps\/registrations\/res\/(.*)\/\?(.*)$/);
if (!!match && match.length === 3) {
let queryParameters = queryString.parse(match[2]);
if (queryParameters.$rid) {
let rid: string = queryParameters.$rid as string;
if (this._operations[rid]) {
let status: number = Number(match[1]);
constructor(amqpBase?: Base) {
super();
this._amqpBase = amqpBase || new Base(true);
this._config.pollingInterval = ProvisioningDeviceConstants.defaultPollingInterval;
const amqpErrorListener = (err) => this._amqpStateMachine.handle('amqpError', err);
const responseHandler = (msg) => {
debug('got message with correlation_id: ' + msg.correlation_id);
/*Codes_SRS_NODE_PROVISIONING_AMQP_16_007: [The `registrationRequest` method shall call its callback with a `RegistrationResult` object parsed from the body of the response message which `correlation_id` matches the `correlation_id` of the request message sent on the sender link.]*/
/*Codes_SRS_NODE_PROVISIONING_AMQP_16_017: [The `queryOperationStatus` method shall call its callback with a `RegistrationResult` object parsed from the body of the response message which `correlation_id` matches the `correlation_id` of the request message sent on the sender link.]*/
const registrationResult = JSON.parse(msg.body.content);
if (this._operations[msg.correlation_id]) {
debug('Got the registration/operationStatus message we were looking for.');
const requestCallback = this._operations[msg.correlation_id];
delete this._operations[msg.correlation_id];
let retryAfterInMilliseconds: number;
/*Codes_SRS_NODE_PROVISIONING_AMQP_06_010: [If the amqp response to a request contains the application property`retry-after`, it will be interpreted as the number of seconds that should elapse before the next attempted operation. Otherwise default.] */
if (msg.application_properties && msg.application_properties[MessagePropertyNames.retryAfter]) {
retryAfterInMilliseconds = Number(msg.application_properties[MessagePropertyNames.retryAfter]) * 1000;
constructor(httpBase?: Base) {
super();
this._httpBase = httpBase || new Base();
this._config.pollingInterval = ProvisioningDeviceConstants.defaultPollingInterval;
this._config.timeoutInterval = ProvisioningDeviceConstants.defaultTimeoutInterval;
}