How to use the azure-iot-device.SharedAccessSignature.parse function in azure-iot-device

To help you get started, we’ve selected a few azure-iot-device examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-iot-sdks / node / device / transport / mqtt / lib / mqtt_simulated.js View on Github external
this.handleRequest = function (done) {
    var sig = SharedAccessSignature.parse(config.sharedAccessSignature);

    if (config.host === 'bad') {                      // bad host
      done(new Error('Invalid host address'));
    }
    else if (config.deviceId === 'bad') {             // bad policy
      done(makeError('Connection Refused'));
    }
    else if (config.gatewayHostName === 'bad') {      // bad gateway url
      done(makeError('Invalid gateway address'));
    }
    else {
      var cmpSig = (SharedAccessSignature.create(config.host, config.deviceId, 'bad', sig.se)).toString();
      if (config.sharedAccessSignature === cmpSig) {  // bad key
        done(makeError('Connection Refused'));
      }
      else {