How to use the @azure/ms-rest-js.Constants function in @azure/ms-rest-js

To help you get started, we’ve selected a few @azure/ms-rest-js 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 / digitaltwins / e2e / model_repository_credentials.js View on Github external
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';

const AuthorizationHeader = require('@azure/ms-rest-js').Constants.HeaderConstants.AUTHORIZATION;
const crypto = require('crypto');
const ConnectionString = require('azure-iot-common').ConnectionString;

class ModelRepositoryCredentials {
  constructor(connectionString) {
    this._connectionString = ConnectionString.parse(connectionString, ['HostName', 'SharedAccessKeyName', 'SharedAccessKey', 'RepositoryId']);
  }

  signRequest(webResource) {
    webResource.headers.set(AuthorizationHeader, this._generateToken());
    return Promise.resolve(webResource);
  }

  getBaseUri() {
    return `https://${this._connectionString.HostName}`;
  }
github Azure / azure-iot-sdk-node / digitaltwins / samples / model_repository / model_repo.js View on Github external
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
const ModelRepoClient = require('azure-iot-digitaltwins-model-repository').DigitalTwinRepositoryService;
const AuthorizationHeader = require('@azure/ms-rest-js').Constants.HeaderConstants.AUTHORIZATION;
const crypto = require('crypto');
const ConnectionString = require('azure-iot-common').ConnectionString;

const apiVersion = '2019-07-01-Preview';

class SimpleTokenCredentials {
  constructor(connectionString) {
    this._connectionString = ConnectionString.parse(connectionString, ['HostName', 'RepositoryId', 'SharedAccessKey', 'SharedAccessKeyName']);
  }

  getBaseUri() {
    if (this._connectionString.HostName.startsWith('https://')) {
      return this._connectionString.HostName;
    } else {
      return 'https://' + this._connectionString.HostName;
    }