How to use the azure-iot-security-tpm.TpmSecurityClient function in azure-iot-security-tpm

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

github Azure / azure-iot-sdk-node / provisioning / device / samples / register_tpm.js View on Github external
// var ProvisioningTransport = require('azure-iot-provisioning-device-mqtt').MqttWs;

var tpmSecurity = require('azure-iot-security-tpm');
var ProvisioningDeviceClient = require('azure-iot-provisioning-device').ProvisioningDeviceClient;

//
// For the public clouds the address of the provisioning host would be: global.azure-devices-provisioning.net
//
var provisioningHost = '<replace with provisioning host entry point>';

//
// You can find your idScope in the portal overview section for your dps instance.
//
var idScope = '<the id scope for your dps instance>';

var securityClient = new tpmSecurity.TpmSecurityClient();

var provisioningClient = ProvisioningDeviceClient.create(provisioningHost, idScope, new ProvisioningTransport(), securityClient);
// Register the device.  Do not force a re-registration.
provisioningClient.register(function(err, result) {
  if (err) {
    console.log("error registering device: " + err);
  } else {
    console.log('registration succeeded');
    console.log('assigned hub=' + result.registrationState.assignedHub);
    console.log('deviceId=' + result.registrationState.deviceId);
    var tpmAuthenticationProvider = tpmSecurity.TpmAuthenticationProvider.fromTpmSecurityClient(result.registrationState.deviceId, result.registrationState.assignedHub, securityClient);
    var hubClient = Client.fromAuthenticationProvider(tpmAuthenticationProvider, iotHubTransport);

    var connectCallback = function (err) {
      if (err) {
        console.error('Could not connect: ' + err.message);
github Azure / azure-iot-sdk-node / provisioning / e2e / _provisioning_e2e.js View on Github external
this.initialize = function (callback) {
    var id = uuid.v4();
    self.deviceId = 'deleteMe_provisioning_node_e2e_' + id;
    self.registrationId = 'reg-' + id;
      if (!tpm) {
      tpm = new TssJs.Tpm(false);
    }
    securityClient = new TpmSecurityClient(self.registrationId, tpm);
    securityClient.getEndorsementKey(function(err, endorsementKey) {
      if (err) {
        callback(err);
      } else {
        ek = endorsementKey.toString('base64');
        callback();
      }
    });
  };

azure-iot-security-tpm

Azure IoT TPM security client

MIT
Latest version published 5 months ago

Package Health Score

81 / 100
Full package analysis

Similar packages