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';
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}`;
}
// 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;
}