Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing dependencies #1188

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions common/transport/amqp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
"typings": "index.d.ts",
"dependencies": {
"async": "^3.2.3",
"es5-ext": "0.10.53",
"azure-iot-common": "1.13.2",
"debug": "^4.3.1",
"lodash.merge": "^4.6.1",
"machina": "^4.0.2",
"rhea": "^1.0.15",
"uuid": "^8.3.2",
"ws": "^6.0.0"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions common/transport/amqp/src/amqp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { ReceiverLink } from './receiver_link';
import { AmqpLink } from './amqp_link_interface';
import { getErrorName } from './amqp_common_errors';
import { create_container as rheaCreateContainer, EventContext, AmqpError, Container, Connection, Session } from 'rhea';
import merge = require('lodash.merge');
import * as dbg from 'debug';
import * as async from 'async';

Expand Down Expand Up @@ -721,7 +720,7 @@ export class Amqp {
connectionParameters.sasl_mechanisms = {};
connectionParameters.sasl_mechanisms[config.saslMechanismName] = config.saslMechanism;
}
connectionParameters = merge(connectionParameters, config.policyOverride);
connectionParameters = Object.assign(connectionParameters, config.policyOverride);
this._config = config;
this._fsm.handle('connect', connectionParameters, done);
}
Expand Down
4 changes: 2 additions & 2 deletions common/transport/amqp/src/amqp_cbs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as machina from 'machina';
import * as uuid from 'uuid';
import { randomUUID } from 'node:crypto';
import * as async from 'async';
import { EventEmitter } from 'events';
import * as dbg from 'debug';
Expand Down Expand Up @@ -238,7 +238,7 @@ export class ClaimsBasedSecurityAgent extends EventEmitter {
//
// For CBS, the message id and correlation id are encoded as string
//
amqpMessage.message_id = uuid.v4();
amqpMessage.message_id = randomUUID();
amqpMessage.reply_to = 'cbs';

const outstandingPutToken: PutTokenOperation = {
Expand Down
4 changes: 2 additions & 2 deletions common/transport/amqp/src/receiver_link.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as machina from 'machina';
import * as dbg from 'debug';
import * as uuid from 'uuid';
import { randomUUID } from 'node:crypto';
import { EventEmitter } from 'events';
import { EventContext, AmqpError, Session, Receiver, ReceiverOptions, Delivery } from 'rhea';
import { errors, results } from 'azure-iot-common';
Expand Down Expand Up @@ -153,7 +153,7 @@ export class ReceiverLink extends EventEmitter implements AmqpLink {
this._attachingCallback = callback;
this._indicatedError = undefined;
this._receiverCloseOccurred = false;
this._rheaReceiverName = 'rheaReceiver_' + uuid.v4();
this._rheaReceiverName = 'rheaReceiver_' + randomUUID();
this._combinedOptions.name = this._rheaReceiverName;
debug(this.toString() + ': attaching receiver name: ' + this._rheaReceiverName + ' with address: ' + this._linkAddress);
//
Expand Down
4 changes: 2 additions & 2 deletions common/transport/amqp/src/sender_link.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as machina from 'machina';
import * as dbg from 'debug';
import * as uuid from 'uuid';
import { randomUUID } from 'node:crypto';
import { EventEmitter } from 'events';
import { EventContext, AmqpError, Session, Sender, SenderOptions } from 'rhea';
import { results, errors } from 'azure-iot-common';
Expand Down Expand Up @@ -214,7 +214,7 @@ export class SenderLink extends EventEmitter implements AmqpLink {
this._attachingCallback = callback;
this._indicatedError = undefined;
this._senderCloseOccurred = false;
this._rheaSenderName = 'rheaSender_' + uuid.v4();
this._rheaSenderName = 'rheaSender_' + randomUUID();
this._combinedOptions.name = this._rheaSenderName;
debug(this.toString() + ': Attaching sender name: ' + this._rheaSenderName + ' with address: ' + this._linkAddress);
//
Expand Down
4 changes: 1 addition & 3 deletions common/transport/http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
"@azure/core-auth": "^1.4.0",
"async": "^3.2.3",
"azure-iot-common": "1.13.2",
"debug": "^4.3.1",
"es5-ext": "0.10.53",
"uuid": "^8.3.2"
"debug": "^4.3.1"
},
"devDependencies": {
"@types/node": "^16.10.2",
Expand Down
4 changes: 2 additions & 2 deletions common/transport/http/src/rest_api_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { anHourFromNow, errors, SharedAccessSignature, X509 } from 'azure-iot-common';
import { Http as HttpBase, HttpRequestOptions } from './http';
import { AccessToken, TokenCredential } from '@azure/core-auth';
import * as uuid from 'uuid';
import { randomUUID } from 'node:crypto';
import { ClientRequest } from 'http';
import dbg = require('debug');
const debug = dbg('azure-iot-http-base.RestApiClient');
Expand Down Expand Up @@ -188,7 +188,7 @@ export class RestApiClient {
timeout?: number | HttpRequestOptions | RestApiClient.ResponseCallback,
requestOptions?: HttpRequestOptions | number | RestApiClient.ResponseCallback,
done?: RestApiClient.ResponseCallback): void {
httpHeaders['Request-Id'] = uuid.v4();
httpHeaders['Request-Id'] = randomUUID();
httpHeaders['User-Agent'] = this._userAgent;

let requestBodyString: string;
Expand Down
3 changes: 1 addition & 2 deletions common/transport/mqtt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"azure-iot-common": "1.13.2",
"debug": "^4.3.1",
"machina": "^4.0.2",
"mqtt": "^4.2.8",
"uuid": "^8.3.2"
"mqtt": "^4.2.8"
},
"devDependencies": {
"@types/node": "^16.10.2",
Expand Down
3 changes: 1 addition & 2 deletions device/transport/amqp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"azure-iot-device": "1.18.2",
"debug": "^4.3.1",
"machina": "^4.0.2",
"rhea": "^1.0.15",
"uuid": "^8.3.2"
"rhea": "^1.0.15"
},
"devDependencies": {
"@types/debug": "^4.1.5",
Expand Down
4 changes: 2 additions & 2 deletions device/transport/amqp/src/amqp_device_method_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

import { EventEmitter } from 'events';
import * as uuid from 'uuid';
import { randomUUID } from 'node:crypto';
import * as machina from 'machina';
import * as async from 'async';
import * as dbg from 'debug';
Expand Down Expand Up @@ -102,7 +102,7 @@ export class AmqpDeviceMethodClient extends EventEmitter {
const linkOptions: LinkOption = {
properties: {
'com.microsoft:api-version': endpoint.apiVersion,
'com.microsoft:channel-correlation-id': 'methods:' + uuid.v4()
'com.microsoft:channel-correlation-id': 'methods:' + randomUUID()
},
rcv_settle_mode: 0
};
Expand Down
6 changes: 3 additions & 3 deletions device/transport/amqp/src/amqp_twin_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { errors, endpoint, AuthenticationProvider } from 'azure-iot-common';
import { Amqp as BaseAmqpClient, AmqpMessage, SenderLink, ReceiverLink, AmqpTransportError, getErrorName } from 'azure-iot-amqp-base';
import { TwinProperties } from 'azure-iot-device';

import * as uuid from 'uuid';
import { randomUUID } from 'node:crypto';
import * as dbg from 'debug';
import rhea = require('rhea');

Expand Down Expand Up @@ -163,7 +163,7 @@ export class AmqpTwinClient extends EventEmitter {
/*Codes_SRS_NODE_DEVICE_AMQP_TWIN_06_006: [When a listener is added for the `response` event, and the `post` event is NOT already subscribed, upstream and downstream links are established via calls to `attachReceiverLink` and `attachSenderLink`.] */
/*Codes_SRS_NODE_DEVICE_AMQP_TWIN_06_012: [When a listener is added for the `post` event, and the `response` event is NOT already subscribed, upstream and downstream links are established via calls to `attachReceiverLink` and `attachSenderLine`.] */
/*Codes_SRS_NODE_DEVICE_AMQP_TWIN_16_036: [The same correlationId shall be used for both the sender and receiver links.]*/
const linkCorrelationId: string = uuid.v4().toString();
const linkCorrelationId: string = randomUUID().toString();
this._client.attachSenderLink( this._endpoint, this._generateTwinLinkProperties(linkCorrelationId), (senderLinkError?: Error, senderTransportObject?: any): void => {
if (senderLinkError) {
/* Codes_SRS_NODE_DEVICE_AMQP_TWIN_06_022: [If an error occurs on establishing the upstream or downstream link then the `error` event shall be emitted.] */
Expand Down Expand Up @@ -353,7 +353,7 @@ export class AmqpTwinClient extends EventEmitter {
amqpMessage.message_annotations.resource = resource;
}

const correlationId = uuid.v4();
const correlationId = randomUUID();
//
// Just a reminder here. The correlation id will not be serialized into a amqp uuid encoding (0x98).
// The service doesn't require it and leaving it as a string will be just fine.
Expand Down
3 changes: 1 addition & 2 deletions device/transport/mqtt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"azure-iot-device": "1.18.2",
"azure-iot-mqtt-base": "1.13.2",
"debug": "^4.3.1",
"machina": "^4.0.2",
"uuid": "^8.3.2"
"machina": "^4.0.2"
},
"devDependencies": {
"@types/mqtt": "0.0.34",
Expand Down
4 changes: 2 additions & 2 deletions device/transport/mqtt/src/mqtt_twin_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TwinProperties } from 'azure-iot-device';
import { MqttBase, translateError } from 'azure-iot-mqtt-base';
import * as querystring from 'querystring';
import * as url from 'url';
import * as uuid from 'uuid';
import { randomUUID } from 'node:crypto';
import * as machina from 'machina';
import * as dbg from 'debug';
const debug = dbg('azure-iot-device-mqtt:MqttTwinClient');
Expand Down Expand Up @@ -195,7 +195,7 @@ export class MqttTwinClient extends EventEmitter {
private _sendTwinRequest(method: string, resource: string, body: any, callback?: (err?: Error, result?: any) => void): void {
/*Codes_SRS_NODE_DEVICE_MQTT_TWIN_CLIENT_16_005: [The `requestId` property in the topic querystring should be set to a unique identifier that will be used to identify the response later on.]*/
/*Codes_SRS_NODE_DEVICE_MQTT_TWIN_CLIENT_16_015: [The `requestId` property in the topic querystring should be set to a unique identifier that will be used to identify the response later on.]*/
const requestId = uuid.v4();
const requestId = randomUUID();
const propString = '?$rid=' + requestId;

const topic = '$iothub/twin/' + method + resource + propString;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"codespaceinstall": "(cd device/samples/javascript && npm install & cd ../../../) && (cd device/samples/javascript/pnp && npm install & cd ../../../../) && (cd device/samples/typescript && npm install && npm run build)"
},
"devDependencies": {
"lerna": "^5.0.0",
"lerna": "^5.6.2",
"mocha": "^9.2.1"
},
"engines": {
Expand Down Expand Up @@ -35,6 +35,7 @@
"dependencies": {
"eslint-plugin-security": "^1.5.0",
"node-gyp": "^9.0.0",
"nodejs": "^0.0.0",
"typescript": "4.4.4"
}
}
1 change: 0 additions & 1 deletion provisioning/transport/mqtt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"typings": "index.d.ts",
"dependencies": {
"async": "^3.2.3",
"es5-ext": "0.10.53",
"azure-iot-common": "1.13.2",
"azure-iot-mqtt-base": "1.13.2",
"azure-iot-provisioning-device": "1.9.1",
Expand Down
6 changes: 3 additions & 3 deletions provisioning/transport/mqtt/src/mqtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
'use strict';

import { EventEmitter } from 'events';
import * as uuid from 'uuid';
import { randomUUID } from 'node:crypto';
import * as machina from 'machina';
import * as dbg from 'debug';
import * as queryString from 'querystring';
Expand Down Expand Up @@ -234,7 +234,7 @@ export class Mqtt extends EventEmitter implements X509ProvisioningTransport, Sym
* @private
*/
registrationRequest(request: RegistrationRequest, callback: (err?: Error, result?: DeviceRegistrationResult, response?: any, pollingInterval?: number) => void): void {
let rid = uuid.v4();
let rid = randomUUID();
debug('registration request given id of: ' + rid);
this._fsm.handle('registrationRequest', request, rid, (err, result, pollingInterval) => {
if (err) {
Expand All @@ -249,7 +249,7 @@ export class Mqtt extends EventEmitter implements X509ProvisioningTransport, Sym
* @private
*/
queryOperationStatus(request: RegistrationRequest, operationId: string, callback: (err?: Error, result?: DeviceRegistrationResult, response?: any, pollingInterval?: number) => void): void {
let rid = uuid.v4();
let rid = randomUUID();
debug('query operation request given id of: ' + rid);
this._fsm.handle('queryOperationStatus', request, rid, operationId, (err, result, pollingInterval) => {
if (err) {
Expand Down