Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var provisioningServiceClient = require('azure-iot-provisioning-service').ProvisioningServiceClient;
var serviceClient = provisioningServiceClient.fromConnectionString(process.argv[2]);
var enrollment1 = {
registrationId: 'first',
provisioningStatus: 'disabled',
attestation: {
type: 'tpm',
tpm: {
endorsementKey: 'a'
}
}
};
var enrollment2 = {
registrationId: 'second',
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var assert = require('chai').assert;
var uuid = require('uuid');
var debug = require('debug')('azure-iot-provisioning-device-e2e');
var certHelper = require('./cert_helper');
var provisioningServiceClient = require('azure-iot-provisioning-service').ProvisioningServiceClient;
var serviceClient = provisioningServiceClient.fromConnectionString(process.env.IOT_PROVISIONING_SERVICE_CONNECTION_STRING);
var enrollment = {
registrationId: 'e2e-node-deleteme-psc-' + uuid.v4(),
attestation: {
type: 'tpm',
tpm: {
endorsementKey: "AToAAQALAAMAsgAgg3GXZ0SEs/gakMyNRqXXJP1S124GUgtk8qHaGzMUaaoABgCAAEMAEAgAAAAAAAEAtKEADl/sNRgmYAjP6gXmbccRaJoTnVixisUaek0OwAzFGN70xt9ZOYp6fhIwfcft3fdVKOrKpXYcTe72CGNkGJGlQz5ti9n2pQ0uJhcX8aefh4Onm7lVlUCQAVp1K0r6zI8vkEXWsBIvwvxk0eMJbFaq146kbTkJHIGczb89RkFH2TX+CgXeZOG9oXQzUNwktmTUacspamune5Wywc/ce8HsDFYchyUHogFhrZ/LPnzyTDXO8sSC5z5dvsUBtUME3iRYDyKgZOfBtmRMqQewD+4iH+ZEJjtsyJiWR8hFhyKROnOuqXfNFwjd5IcNU4wtlKO0cLyXmTOfQK6Da1pr5Q=="
}
},
provisioningStatus: "enabled",
capabilities: {
iotEdge: true
},
reprovisionPolicy: {
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var async = require('async');
var uuid = require('uuid');
var assert = require('chai').assert;
var crypto = require('crypto');
var debug = require('debug')('azure-iot-provisioning-device-e2e');
var Http = require('azure-iot-provisioning-device-http').Http;
var Amqp = require('azure-iot-provisioning-device-amqp').Amqp;
var AmqpWs = require('azure-iot-provisioning-device-amqp').AmqpWs;
var Mqtt = require('azure-iot-provisioning-device-mqtt').Mqtt;
var MqttWs = require('azure-iot-provisioning-device-mqtt').MqttWs;
var ProvisioningDeviceClient = require('azure-iot-provisioning-device').ProvisioningDeviceClient;
var ProvisioningServiceClient = require('azure-iot-provisioning-service').ProvisioningServiceClient;
var X509Security = require('azure-iot-security-x509').X509Security;
var Registry = require('azure-iothub').Registry;
var certHelper = require('./cert_helper');
var TpmSecurityClient = require('azure-iot-security-tpm').TpmSecurityClient;
var SymmetricKeySecurityClient = require('azure-iot-security-symmetric-key').SymmetricKeySecurityClient;
var TssJs = require("tss.js");
var idScope = process.env.IOT_PROVISIONING_DEVICE_IDSCOPE;
var provisioningConnectionString = process.env.IOT_PROVISIONING_SERVICE_CONNECTION_STRING;
var registryConnectionString = process.env.IOTHUB_CONNECTION_STRING;
var provisioningHost = process.env.IOT_PROVISIONING_DEVICE_ENDPOINT;
var provisioningServiceClient = ProvisioningServiceClient.fromConnectionString(provisioningConnectionString);
var registry = Registry.fromConnectionString(registryConnectionString);
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var provisioningServiceClient = require('azure-iot-provisioning-service').ProvisioningServiceClient;
var httpModule = require('azure-iot-provisioning-device-http');
var amqpModule = require('azure-iot-provisioning-device-amqp');
var mqttModule = require('azure-iot-provisioning-device-mqtt');
var dpsDeviceClientEndpoint = process.env.DPS_GLOBAL_DEVICE_ENDPOINT_INVALID_CERT;
var correctDisconnectMessage = function(err, done) {
if (err) {
if (err.amqpError && (err.amqpError.name === 'NotConnectedError')) {
done();
} else if (err.name && (err.name === 'NotConnectedError')) {
done();
} else if (err.code && (err.code === 'UNABLE_TO_VERIFY_LEAF_SIGNATURE')) {
done();
} else {
done();
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var provisioningServiceClient = require('azure-iot-provisioning-service').ProvisioningServiceClient;
var serviceClient = provisioningServiceClient.fromConnectionString(process.argv[2]);
var enrollment1 = {
registrationId: 'first',
attestation: {
type: 'tpm',
tpm: {
endorsementKey: 'a'
}
}
};
var enrollment2 = {
registrationId: 'second',
attestation: {
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var provisioningServiceClient = require('azure-iot-provisioning-service').ProvisioningServiceClient;
var argv = require('yargs')
.usage('Usage: $0 --connectionString ')
.option('connectionString', {
alias: 'c',
describe: 'The connection string for the Device Provisioning instance',
type: 'string',
demandOption: true
})
.argv;
var connectionString = argv.connectionString;
var serviceClient = provisioningServiceClient.fromConnectionString(connectionString);
var queryForEnrollments = serviceClient.createIndividualEnrollmentQuery({
"query": "*"
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var provisioningServiceClient = require('azure-iot-provisioning-service').ProvisioningServiceClient;
var serviceClient = provisioningServiceClient.fromConnectionString(process.argv[2]);
var endorsementKey = process.argv[3];
var enrollment = {
registrationId: 'first',
attestation: {
type: 'tpm',
tpm: {
endorsementKey: endorsementKey
}
}
};
serviceClient.createOrUpdateIndividualEnrollment(enrollment, function(err, enrollmentResponse) {
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var fs = require('fs');
var provisioningServiceClient = require('azure-iot-provisioning-service').ProvisioningServiceClient;
var serviceClient = provisioningServiceClient.fromConnectionString(process.argv[2]);
var enrollment = {
enrollmentGroupId: 'first',
attestation: {
type: 'x509',
x509: {
signingCertificates: {
primary: {
certificate: fs.readFileSync(process.argv[3], 'utf-8').toString()
}
}
}
},
provisioningStatus: 'disabled'
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var fs = require('fs');
var provisioningServiceClient = require('azure-iot-provisioning-service').ProvisioningServiceClient;
const path = require('path');
var argv = require('yargs')
.usage('Usage: $0 --deviceid --connectionstring ')
.option('deviceid', {
alias: 'd',
describe: 'Unique identifier for the device that shall be created',
type: 'string',
demandOption: true
})
.option('connectionstring', {
alias: 'c',
describe: 'The connection string for the Device Provisioning instance',
type: 'string',
demandOption: true
})