How to use the azure-iot-common.SharedAccessSignature.create function in azure-iot-common

To help you get started, we’ve selected a few azure-iot-common 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 / service / lib / registry_http_simulated.js View on Github external
this.handleRequest = function (done, body) {
    var sig = SharedAccessSignature.parse(config.sharedAccessSignature);

    if (config.host === 'bad') {                      // bad host
      done(new Error('getaddrinfo ENOTFOUND bad'));
    }
    else if (sig.skn === 'bad') {                     // bad policy
      done(createError());
    }
    else {
      var cmpSig = SharedAccessSignature.create(sig.sr, sig.skn, 'bad', sig.se).toString();
      if (config.sharedAccessSignature === cmpSig) {  // bad key
        done(createError());
      }
      else {                                          // ok
        done(null, body, new Response(204));
      }
    }
  };
}
github Azure / azure-iot-sdk-node / device / core / src / shared_access_signature.ts View on Github external
export function create(host: string, deviceId: string, key: string, expiry: string | number): SharedAccessSignature {
  /*Codes_SRS_NODE_DEVICE_SAS_05_004: [ shall be the URL-encoded value of deviceId.]*/
  const uri = encodeUriComponentStrict(host + '/devices/' + deviceId);
  /*Codes_SRS_NODE_DEVICE_SAS_05_003: [The create method shall return the result of calling azure-iot-common.SharedAccessSignature.create with following arguments:
  resourceUri - host + '%2Fdevices%2F' + 
  keyName - null
  key - key
  expiry - expiry]*/
  return SharedAccessSignature.create(uri, null, key, expiry);
}
github Azure / azure-iot-sdks / node / service / lib / shared_access_signature.js View on Github external
create: function create(host, policy, key, expiry) {
    /*Codes_SRS_NODE_IOTHUB_SAS_05_003: [The create method shall return the result of calling azure-iot-common.SharedAccessSignature.create with following arguments:
    resourceUri - host
    keyName - policy
    key - key
    expiry - expiry]*/
    return Base.create(host, policy, key, expiry);
  },
  parse: function parse(source) {
github Azure / azure-iot-sdk-node / device / core / src / sak_authentication_provider.ts View on Github external
protected _sign(resourceUri: string, expiry: number, callback: (err: Error, signature?: string) => void): void {
    callback(null, SharedAccessSignature.create(resourceUri, this._credentials.sharedAccessKeyName, this._credentials.sharedAccessKey, expiry).toString());
  }
github Azure-Samples / raspberry-pi-web-simulator / src / lib / azure / iot-hub.js View on Github external
function calPasswd(connectionString) {
  var se = Math.round(new Date().getTime() / 1000) + 24 * 3600;
  var uri = encodeUriComponentStrict(connectionString['HostName'] + '/devices/' + connectionString['DeviceId']);
  return SharedAccessSignature.create(uri, null, connectionString['SharedAccessKey'], se).toString();
}
github Azure / azure-iot-sdk-node / service / src / shared_access_signature.ts View on Github external
export function create(host: string, policy: string, key: string, expiry: string | number): SharedAccessSignature {
  /*Codes_SRS_NODE_IOTHUB_SAS_05_003: [The create method shall return the result of calling azure-iot-common.SharedAccessSignature.create with following arguments:
  resourceUri - host
  keyName - policy
  key - key
  expiry - expiry]*/
  return SharedAccessSignature.create(host, policy, key, expiry);
}