How to use the azure-iot-provisioning-device.ProvisioningDeviceConstants.apiVersion function in azure-iot-provisioning-device

To help you get started, we’ve selected a few azure-iot-provisioning-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-sdk-node / provisioning / transport / mqtt / src / mqtt.ts View on Github external
private _connect(request: RegistrationRequest, callback: (err?: Error) => void): void {

    /* Codes_SRS_NODE_PROVISIONING_MQTT_18_037: [ When connecting, `Mqtt` shall pass in the `X509` certificate that was passed into `setAuthentication` in the base `TransportConfig` object.] */
    /* Codes_SRS_NODE_PROVISIONING_MQTT_18_050: [ When connecting, `Mqtt` shall set `uri` in the base `TransportConfig` object to the 'mqtts://' + `provisioningDeviceHost`.] */
    /* Codes_SRS_NODE_PROVISIONING_MQTT_18_035: [ When connecting, `Mqtt` shall set `clientId` in the base `registrationRequest` object to the registrationId.] */
    /* Codes_SRS_NODE_PROVISIONING_MQTT_18_036: [ When connecting, `Mqtt` shall set the `clean` flag in the base `TransportConfig` object to true.] */
    /* Codes_SRS_NODE_PROVISIONING_MQTT_18_038: [ When connecting, `Mqtt` shall set the `username` in the base `TransportConfig` object to '/registrations//api-version=&clientVersion=>'.] */
    /* Codes_SRS_NODE_PROVISIONING_MQTT_18_039: [ If a uri is specified in the request object, `Mqtt` shall set it in the base `TransportConfig` object.] */
    let baseConfig: MqttBaseTransportConfig = {
      clientId: request.registrationId,
      clean: true,
      x509: this._auth,
      sharedAccessSignature: this._sas,
      username: request.idScope + '/registrations/' + request.registrationId + '/api-version=' + ProvisioningDeviceConstants.apiVersion + '&ClientVersion=' + encodeURIComponent(ProvisioningDeviceConstants.userAgent),
      uri: this._getConnectionUri(request)
    };

    /* Codes_SRS_NODE_PROVISIONING_MQTT_18_040: [ When connecting, `Mqtt` shall call `_mqttBase.connect`.] */
    this._mqttBase.connect(baseConfig, (err) => {
      if (err) {
        /* Codes_SRS_NODE_PROVISIONING_MQTT_18_041: [ If an error is returned from `_mqttBase.connect`, `Mqtt` shall call `callback` passing in the error.] */
        debug('connect error: ' + err.toString());
        callback(err);
      } else {
        /* Codes_SRS_NODE_PROVISIONING_MQTT_18_042: [ After connecting the transport, `Mqtt` will subscribe to '$dps/registrations/res/#'  by calling `_mqttBase.subscribe`.] */
        this._mqttBase.subscribe(responseTopic, { qos: 1 }, (err) => {
          if (err) {
            /* Codes_SRS_NODE_PROVISIONING_MQTT_18_043: [ If an error is returned from _mqttBase.subscribe, `Mqtt` shall call `callback` passing in the error.] */
            debug('subscribe error: ' + err.toString());
            callback(err);
github Azure / azure-iot-sdk-node / provisioning / transport / http / src / http.ts View on Github external
/*Codes_SRS_NODE_PROVISIONING_HTTP_06_006: [The `registrationRequest` will send a body in the message which contains a stringified JSON object with a `registrationId` property.] */
    let requestBody: DeviceRegistration = { registrationId : request.registrationId };

    /*Codes_SRS_NODE_PROVISIONING_HTTP_06_007: [The `registrationRequest` will, if utilizing TPM attestation, send a `tpm` property with the endorsement and storage key in the JSON body.] */
    if (this._tpmPublicKeys) {
      requestBody.tpm = this._tpmPublicKeys;
    }

    /*Codes_SRS_NODE_PROVISIONING_HTTP_06_008: [The `registrationRequest` will, if utilizing custom allocation data, send a `payload` property in the JSON body.] */
    if (request.payload) {
      requestBody.payload = request.payload;
    }

    /* Codes_SRS_NODE_PROVISIONING_HTTP_18_005: [ `registrationRequest` shall include the current `api-version` as a URL query string value named 'api-version'. ] */
    let path: string = '/' + request.idScope + '/registrations/' + request.registrationId + '/register?api-version=' + ProvisioningDeviceConstants.apiVersion;

    /* Codes_SRS_NODE_PROVISIONING_HTTP_18_008: [ If `forceRegistration` is specified, `registrationRequest` shall include this as a query string value named 'forceRegistration' ] */
    if (request.forceRegistration) {
      path += '&forceRegistration=true';
    }

    /* Codes_SRS_NODE_PROVISIONING_HTTP_18_006: [ `registrationRequest` shall specify the following in the Http header:
      Accept: application/json
      Content-Type: application/json; charset=utf-8 ] */
    let httpHeaders = JSON.parse(JSON.stringify(_defaultHeaders));

    if (this._sas) {
      httpHeaders.Authorization = this._sas;
    }

    debug('submitting PUT for ' + request.registrationId + ' to ' + path);
github Azure / azure-iot-sdk-node / provisioning / transport / amqp / src / amqp.ts View on Github external
_onEnter: (request, callback) => {
            const linkEndpoint = request.idScope + '/registrations/' + request.registrationId;
            const linkOptions = {
              properties: {
                'com.microsoft:api-version' : ProvisioningDeviceConstants.apiVersion
              }
            };

            /*Codes_SRS_NODE_PROVISIONING_AMQP_16_004: [The `registrationRequest` method shall attach a receiver link on the `/registrations/` endpoint with the following properties:
            ```
            com.microsoft:api-version: 
            com.microsoft:client-version: 
            ```]*/
            /*Codes_SRS_NODE_PROVISIONING_AMQP_16_014: [The `queryOperationStatus` method shall attach a receiver link on the `/registrations/` endpoint with the following properties:
            ```
            com.microsoft:api-version: 
            com.microsoft:client-version: 
            ```*/
            this._amqpBase.attachReceiverLink(linkEndpoint, linkOptions, (err, receiverLink) => {
              if (err) {
                debug('_amqpBase.attachReceiverLink failed');