diff --git a/core/packages/teeny-request/package.json b/core/packages/teeny-request/package.json index daf56ae73a7c..37f972db179f 100644 --- a/core/packages/teeny-request/package.json +++ b/core/packages/teeny-request/package.json @@ -52,7 +52,6 @@ "@types/mocha": "^10.0.10", "@types/node-fetch": "^2.6.12", "@types/sinon": "^17.0.3", - "@types/uuid": "^10.0.0", "c8": "^10.1.3", "codecov": "^3.8.3", "gts": "^6.0.2", diff --git a/core/paginator/package.json b/core/paginator/package.json index 721fff00e466..38a09d6953ff 100644 --- a/core/paginator/package.json +++ b/core/paginator/package.json @@ -37,7 +37,6 @@ "@types/node": "^22.13.8", "@types/proxyquire": "^1.3.31", "@types/sinon": "^17.0.4", - "@types/uuid": "^10.0.0", "c8": "^10.1.3", "codecov": "^3.8.3", "gts": "^6.0.2", @@ -49,8 +48,7 @@ "path-to-regexp": "^8.2.0", "proxyquire": "^2.1.3", "sinon": "^19.0.2", - "typescript": "^5.8.2", - "uuid": "^11.1.0" + "typescript": "^5.8.2" }, "dependencies": { "extend": "^3.0.2" diff --git a/core/paginator/test/index.ts b/core/paginator/test/index.ts index 8c790f293bce..2c8c4acd5055 100644 --- a/core/paginator/test/index.ts +++ b/core/paginator/test/index.ts @@ -17,7 +17,7 @@ import {describe, it, beforeEach, afterEach} from 'mocha'; import * as proxyquire from 'proxyquire'; import * as sinon from 'sinon'; import {PassThrough, Transform} from 'stream'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import * as P from '../src'; import {paginator, ParsedArguments} from '../src'; @@ -53,7 +53,7 @@ function createFakeStream() { } describe('paginator', () => { - const UUID = uuid.v1(); + const UUID = crypto.randomUUID(); function FakeClass() { // do nothing } @@ -124,7 +124,7 @@ describe('paginator', () => { /* eslint-disable @typescript-eslint/no-explicit-any */ const cls = new (FakeClass as any)(); - cls.uuid = uuid.v1(); + cls.uuid = crypto.randomUUID(); sandbox.stub(paginator, 'run_').callsFake((_, originalMethod) => { assert.strictEqual(originalMethod(), cls.uuid); diff --git a/handwritten/bigquery-storage/package.json b/handwritten/bigquery-storage/package.json index 4cff498f1ae9..6fb47d3133c3 100644 --- a/handwritten/bigquery-storage/package.json +++ b/handwritten/bigquery-storage/package.json @@ -49,7 +49,6 @@ "@types/mocha": "^10.0.10", "@types/node": "^22.13.14", "@types/sinon": "^21.0.0", - "@types/uuid": "^10.0.0", "avsc": "^5.7.9", "c8": "^10.1.3", "gapic-tools": "^1.0.1", @@ -66,7 +65,6 @@ "sinon": "21.0.3", "ts-loader": "^9.5.2", "typescript": "^5.8.2", - "uuid": "^11.1.0", "webpack": "^5.98.0", "webpack-cli": "^6.0.1" }, diff --git a/handwritten/bigquery-storage/system-test/managed_writer_client_test.ts b/handwritten/bigquery-storage/system-test/managed_writer_client_test.ts index a2c80746db1f..f31ea99e210c 100644 --- a/handwritten/bigquery-storage/system-test/managed_writer_client_test.ts +++ b/handwritten/bigquery-storage/system-test/managed_writer_client_test.ts @@ -16,7 +16,7 @@ import * as assert from 'assert'; import {readFileSync} from 'fs'; import * as path from 'path'; import {describe, it} from 'mocha'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import * as gax from 'google-gax'; import * as sinon from 'sinon'; import {BigQuery, TableSchema} from '@google-cloud/bigquery'; @@ -59,7 +59,7 @@ const FieldDescriptorProtoType = const GCLOUD_TESTS_PREFIX = 'nodejs_bqstorage_system_test'; const bigquery = new BigQuery(); const generateUuid = () => - `${GCLOUD_TESTS_PREFIX}_${uuid.v4()}`.replace(/-/gi, '_'); + `${GCLOUD_TESTS_PREFIX}_${crypto.randomUUID()}`.replace(/-/gi, '_'); const datasetId = generateUuid(); const sleep = (ms: number) => diff --git a/handwritten/bigquery-storage/system-test/reader_client_test.ts b/handwritten/bigquery-storage/system-test/reader_client_test.ts index 6949d4a07d83..ce9b53481afc 100644 --- a/handwritten/bigquery-storage/system-test/reader_client_test.ts +++ b/handwritten/bigquery-storage/system-test/reader_client_test.ts @@ -15,7 +15,7 @@ import * as assert from 'assert'; import {describe, it} from 'mocha'; import * as gax from 'google-gax'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import * as sinon from 'sinon'; import {BigQuery, TableRow, TableSchema} from '@google-cloud/bigquery'; import * as protos from '../protos/protos'; @@ -46,7 +46,7 @@ if (process.env.NODE_ENV === 'DEBUG') { const GCLOUD_TESTS_PREFIX = 'nodejs_bqstorage_system_test'; const bigquery = new BigQuery(); const generateUuid = () => - `${GCLOUD_TESTS_PREFIX}_${uuid.v4()}`.replace(/-/gi, '_'); + `${GCLOUD_TESTS_PREFIX}_${crypto.randomUUID()}`.replace(/-/gi, '_'); const datasetId = generateUuid(); const sleep = (ms: number) => diff --git a/handwritten/bigtable/package.json b/handwritten/bigtable/package.json index c0d768b960fa..48659886416f 100644 --- a/handwritten/bigtable/package.json +++ b/handwritten/bigtable/package.json @@ -91,7 +91,6 @@ "@types/proxyquire": "^1.3.31", "@types/pumpify": "^1.4.4", "@types/sinon": "^17.0.4", - "@types/uuid": "^10.0.0", "c8": "^10.1.3", "codecov": "^3.8.3", "gapic-tools": "^1.0.1", @@ -109,7 +108,6 @@ "tcp-port-used": "^1.0.2", "ts-loader": "^9.5.2", "typescript": "^5.8.2", - "uuid": "8.0.0", "webpack": "^5.98.0", "webpack-cli": "^6.0.1" }, diff --git a/handwritten/bigtable/system-test/common.ts b/handwritten/bigtable/system-test/common.ts index 06560422f17e..079f46ac74db 100644 --- a/handwritten/bigtable/system-test/common.ts +++ b/handwritten/bigtable/system-test/common.ts @@ -12,14 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import {Cluster} from '../src/cluster'; import * as inst from '../src/instance'; export const PREFIX = 'gt-'; export function generateId(resourceType: string) { - const newUuid = uuid.v1().substr(4, 4); + const newUuid = crypto.randomUUID().substr(4, 4); return `${PREFIX}${resourceType}-${newUuid}-${Date.now()}`; } diff --git a/handwritten/error-reporting/package.json b/handwritten/error-reporting/package.json index c443eccba6f4..ed7e169f1cc1 100644 --- a/handwritten/error-reporting/package.json +++ b/handwritten/error-reporting/package.json @@ -51,7 +51,6 @@ "@types/once": "^1.4.5", "@types/proxyquire": "^1.3.31", "@types/restify": "^8.0.0", - "@types/uuid": "^8.3.0", "boom": "^7.2.0", "c8": "^10.1.3", "codecov": "^3.6.2", @@ -67,8 +66,7 @@ "pack-n-play": "^2.0.0", "proxyquire": "^2.1.3", "restify": "^11.0.0", - "typescript": "^5.9.3", - "uuid": "^8.3.2" + "typescript": "^5.9.3" }, "overrides": { "undici": "5.28.4", diff --git a/handwritten/error-reporting/system-test/error-reporting.ts b/handwritten/error-reporting/system-test/error-reporting.ts index 9d47bbc1c265..f9f7212de683 100644 --- a/handwritten/error-reporting/system-test/error-reporting.ts +++ b/handwritten/error-reporting/system-test/error-reporting.ts @@ -28,7 +28,7 @@ import { ErrorsApiTransport, } from '../utils/errors-api-transport'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import * as util from 'util'; import * as path from 'path'; @@ -446,7 +446,7 @@ describe('Expected Behavior', () => { describe('error-reporting', () => { const SRC_ROOT = path.join(__dirname, '..', 'src'); - const UUID = uuid.v4(); + const UUID = crypto.randomUUID(); const BASE_NAME = 'error-reporting-system-test'; function buildName(suffix: string) { return [UUID, BASE_NAME, suffix].join('_'); diff --git a/handwritten/logging-bunyan/package.json b/handwritten/logging-bunyan/package.json index 8dc70c37e8be..9c2d6ca01489 100644 --- a/handwritten/logging-bunyan/package.json +++ b/handwritten/logging-bunyan/package.json @@ -65,7 +65,6 @@ "@types/mocha": "^9.0.0", "@types/node": "^20.4.9", "@types/proxyquire": "^1.3.28", - "@types/uuid": "^10.0.0", "bunyan": "^1.8.12", "c8": "^9.0.0", "codecov": "^3.0.2", @@ -80,8 +79,7 @@ "mocha": "^9.2.2", "post-install-check": "0.0.1", "proxyquire": "^2.0.1", - "typescript": "^5.1.6", - "uuid": "^10.0.0" + "typescript": "^5.1.6" }, "peerDependencies": { "bunyan": "*" diff --git a/handwritten/logging-bunyan/system-test/logging-bunyan.ts b/handwritten/logging-bunyan/system-test/logging-bunyan.ts index ec93e7343523..5c84b6e70a1e 100644 --- a/handwritten/logging-bunyan/system-test/logging-bunyan.ts +++ b/handwritten/logging-bunyan/system-test/logging-bunyan.ts @@ -17,7 +17,7 @@ import * as assert from 'assert'; import {describe, it} from 'mocha'; import * as bunyan from 'bunyan'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import * as types from '../src/types/core'; import {ErrorsApiTransport} from './errors-transport'; import {Logging, LogSync} from '@google-cloud/logging'; @@ -30,7 +30,7 @@ import * as instrumentation from '@google-cloud/logging/build/src/utils/instrume const WRITE_CONSISTENCY_DELAY_MS = 90000; const MESSAGE = 'Diagnostic test'; -const UUID = uuid.v4(); +const UUID = crypto.randomUUID(); function logName(name: string) { return `${UUID}_${name}`; } diff --git a/handwritten/logging-bunyan/system-test/test-middleware-express.ts b/handwritten/logging-bunyan/system-test/test-middleware-express.ts index 4e76584563e9..cce02629c75e 100644 --- a/handwritten/logging-bunyan/system-test/test-middleware-express.ts +++ b/handwritten/logging-bunyan/system-test/test-middleware-express.ts @@ -19,7 +19,7 @@ import * as assert from 'assert'; import {describe, it, before} from 'mocha'; import delay from 'delay'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import {express as elb} from '../src/index'; import {Logging} from '@google-cloud/logging'; @@ -27,7 +27,7 @@ const logging = new Logging(); const WRITE_CONSISTENCY_DELAY_MS = 20 * 1000; const TEST_TIMEOUT = WRITE_CONSISTENCY_DELAY_MS + 10 * 1000; -const LOG_NAME = `bunyan-system-test-${uuid.v4()}`; +const LOG_NAME = `bunyan-system-test-${crypto.randomUUID()}`; describe('express middleware', () => { let logger: elb.MiddlewareReturnType['logger']; @@ -40,7 +40,7 @@ describe('express middleware', () => { describe('global logger', () => { it('should properly write log entries', async function () { this.timeout(TEST_TIMEOUT); - const LOG_MESSAGE = `unique log message ${uuid.v4()}`; + const LOG_MESSAGE = `unique log message ${crypto.randomUUID()}`; logger.info(LOG_MESSAGE); await delay(WRITE_CONSISTENCY_DELAY_MS); @@ -55,7 +55,7 @@ describe('express middleware', () => { describe('request logging middleware', () => { it('should write request correlated log entries', function (done) { this.timeout(TEST_TIMEOUT); - const LOG_MESSAGE = `correlated log message ${uuid.v4()}`; + const LOG_MESSAGE = `correlated log message ${crypto.randomUUID()}`; const fakeRequest = {headers: {fake: 'header'}}; const fakeResponse = {}; const next = async () => { diff --git a/handwritten/logging/package.json b/handwritten/logging/package.json index 4e4b5caf722b..c3f69f1b02d4 100644 --- a/handwritten/logging/package.json +++ b/handwritten/logging/package.json @@ -65,8 +65,7 @@ "long": "^5.3.2", "on-finished": "^2.3.0", "pumpify": "^2.0.1", - "stream-events": "^1.0.5", - "uuid": "^9.0.0" + "stream-events": "^1.0.5" }, "devDependencies": { "@google-cloud/bigquery": "^7.0.0", @@ -86,7 +85,6 @@ "@types/proxyquire": "^1.3.28", "@types/pumpify": "^1.4.1", "@types/sinon": "^10.0.0", - "@types/uuid": "^9.0.0", "bignumber.js": "^9.0.0", "c8": "^9.0.0", "codecov": "^3.6.5", diff --git a/handwritten/logging/src/utils/context.ts b/handwritten/logging/src/utils/context.ts index 4233c09719a6..fecc3b6facd9 100644 --- a/handwritten/logging/src/utils/context.ts +++ b/handwritten/logging/src/utils/context.ts @@ -28,7 +28,6 @@ */ import * as http from 'http'; -import * as uuid from 'uuid'; import * as crypto from 'crypto'; import {trace, isSpanContextValid} from '@opentelemetry/api'; @@ -151,7 +150,7 @@ function toCloudTraceContext( * makeCloudTraceHeader generates valid X-Cloud-Trace-Context trace and spanId. */ function makeCloudTraceHeader(): string { - const trace = uuid.v4().replace(/-/g, ''); + const trace = crypto.randomUUID().replace(/-/g, ''); const spanId = spanRandomBuffer().toString('hex'); return `${trace}/${spanId}`; } diff --git a/handwritten/logging/system-test/logging.ts b/handwritten/logging/system-test/logging.ts index 266f881ebc94..1eff8f8a7530 100644 --- a/handwritten/logging/system-test/logging.ts +++ b/handwritten/logging/system-test/logging.ts @@ -22,7 +22,7 @@ import {describe, it} from 'mocha'; import {HOST_ADDRESS} from 'gcp-metadata'; import * as nock from 'nock'; import {Duplex} from 'stream'; -import {v4} from 'uuid'; +import * as crypto from 'crypto'; import {after, before} from 'mocha'; // eslint-disable-next-line @typescript-eslint/no-var-requires const http2spy = require('http2spy'); @@ -1003,7 +1003,7 @@ describe('Logging', () => { }); function generateName() { - return `${TESTS_PREFIX}-${Date.now()}-${v4().split('-').pop()}`; + return `${TESTS_PREFIX}-${Date.now()}-${crypto.randomUUID().split('-').pop()}`; } // Parse the time the resource was created using the resource id diff --git a/handwritten/pubsub/package.json b/handwritten/pubsub/package.json index 299fa8301546..ae4825bd4e93 100644 --- a/handwritten/pubsub/package.json +++ b/handwritten/pubsub/package.json @@ -83,7 +83,6 @@ "@types/proxyquire": "^1.3.31", "@types/sinon": "^21.0.0", "@types/tmp": "^0.2.6", - "@types/uuid": "^11.0.0", "c8": "^10.1.3", "codecov": "^3.8.3", "execa": "~5.1.0", @@ -105,7 +104,6 @@ "tmp": "^0.2.3", "ts-loader": "^9.5.2", "typescript": "^5.8.3", - "uuid": "^11.1.0", "webpack": "^5.99.5", "webpack-cli": "^6.0.1", "why-is-node-running": "^2.3.0", diff --git a/handwritten/pubsub/test/message-queues.ts b/handwritten/pubsub/test/message-queues.ts index f91129e7da6c..d44de1dfd73a 100644 --- a/handwritten/pubsub/test/message-queues.ts +++ b/handwritten/pubsub/test/message-queues.ts @@ -19,7 +19,7 @@ import {describe, it, before, beforeEach, afterEach} from 'mocha'; import {EventEmitter} from 'events'; import {CallOptions, GoogleError, loggingUtils, Status} from 'google-gax'; import * as sinon from 'sinon'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import defer = require('p-defer'); import * as messageTypes from '../src/message-queues'; @@ -55,7 +55,7 @@ class FakeSubscriber extends EventEmitter { constructor() { super(); - this.name = `projects/test/subscriptions/${uuid.v4()}`; + this.name = `projects/test/subscriptions/${crypto.randomUUID()}`; this.client = new FakeClient(); this.iEOS = false; } @@ -70,7 +70,7 @@ class FakeSubscriber extends EventEmitter { class FakeMessage { ackId: string; constructor() { - this.ackId = uuid.v4(); + this.ackId = crypto.randomUUID(); } } diff --git a/handwritten/pubsub/test/message-stream.ts b/handwritten/pubsub/test/message-stream.ts index 2463d17eb505..1df52f8db20a 100644 --- a/handwritten/pubsub/test/message-stream.ts +++ b/handwritten/pubsub/test/message-stream.ts @@ -20,7 +20,7 @@ import {grpc} from 'google-gax'; import * as proxyquire from 'proxyquire'; import * as sinon from 'sinon'; import {Duplex, PassThrough} from 'stream'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import * as defer from 'p-defer'; import {promisify} from 'util'; @@ -134,7 +134,7 @@ class FakeSubscriber { maxBytes: number; client: FakeGaxClient; constructor(client: FakeGaxClient) { - this.name = uuid.v4(); + this.name = crypto.randomUUID(); this.ackDeadline = Math.floor(Math.random() * 600); this.maxMessages = 20; this.maxBytes = 4000; diff --git a/handwritten/pubsub/test/subscriber.ts b/handwritten/pubsub/test/subscriber.ts index cdd4bdab9d36..d74cd76c005f 100644 --- a/handwritten/pubsub/test/subscriber.ts +++ b/handwritten/pubsub/test/subscriber.ts @@ -22,7 +22,7 @@ import {common as protobuf} from 'protobufjs'; import * as proxyquire from 'proxyquire'; import * as sinon from 'sinon'; import {PassThrough} from 'stream'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import * as opentelemetry from '@opentelemetry/api'; import {google} from '../protos/protos'; import * as defer from 'p-defer'; @@ -60,8 +60,8 @@ class FakePubSub { } } -const projectId = uuid.v4(); -const subId = uuid.v4(); +const projectId = crypto.randomUUID(); +const subId = crypto.randomUUID(); class FakeSubscription { name = `projects/${projectId}/subscriptions/${subId}`; @@ -170,11 +170,11 @@ class FakePreciseDate { } const RECEIVED_MESSAGE = { - ackId: uuid.v4(), + ackId: crypto.randomUUID(), message: { attributes: {}, data: Buffer.from('Hello, world!'), - messageId: uuid.v4(), + messageId: crypto.randomUUID(), orderingKey: 'ordering-key', publishTime: {seconds: 12, nanos: 32}, }, @@ -1168,13 +1168,13 @@ describe('Subscriber', () => { tracing.spanContextToContext(parentSpanContext)!, ); const messageWithSpanContext = { - ackId: uuid.v4(), + ackId: crypto.randomUUID(), message: { attributes: { [tracing.modernAttributeName]: JSON.stringify(parentSpanContext), }, data: Buffer.from('Hello, world!'), - messageId: uuid.v4(), + messageId: crypto.randomUUID(), orderingKey: 'ordering-key', publishTime: {seconds: 12, nanos: 32}, }, diff --git a/handwritten/pubsub/test/testResources.ts b/handwritten/pubsub/test/testResources.ts index 05550606d760..4503138e51cd 100644 --- a/handwritten/pubsub/test/testResources.ts +++ b/handwritten/pubsub/test/testResources.ts @@ -16,12 +16,12 @@ // across the two test structures, but because of the tangle of rootDirs // and package.json "files", it's hard to avoid it. -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; // Returns a shortened UUID that can be used to identify a // specific run of a specific test. function shortUUID() { - return uuid.v4().split('-').shift()!; + return crypto.randomUUID().split('-').shift()!; } export interface TokenMaker { diff --git a/handwritten/spanner/package.json b/handwritten/spanner/package.json index fef5dac5b1fc..7c07d72dfe9c 100644 --- a/handwritten/spanner/package.json +++ b/handwritten/spanner/package.json @@ -94,8 +94,7 @@ "stack-trace": "0.0.10", "stream-events": "^1.0.5", "teeny-request": "^10.0.0", - "through2": "^4.0.2", - "uuid": "^11.1.0" + "through2": "^4.0.2" }, "devDependencies": { "@grpc/reflection": "^1.0.4", diff --git a/handwritten/spanner/src/codec.ts b/handwritten/spanner/src/codec.ts index 0d4aaecc6d03..30a591b50807 100644 --- a/handwritten/spanner/src/codec.ts +++ b/handwritten/spanner/src/codec.ts @@ -27,13 +27,13 @@ import { isObject, isString, isUndefined, + isUuid, toArray, } from './helper'; import {Big} from 'big.js'; import {common as p} from 'protobufjs'; import {google as spannerClient} from '../protos/protos'; import {GoogleError} from 'google-gax'; -import * as uuid from 'uuid'; // eslint-disable-next-line @typescript-eslint/no-explicit-any export type Value = any; @@ -1170,7 +1170,7 @@ function getType(value: Value): Type { ); uuidUntypedFlagWarned = true; } - if (uuid.validate(value)) { + if (isUuid(value)) { return {type: 'unspecified'}; } } diff --git a/handwritten/spanner/src/helper.ts b/handwritten/spanner/src/helper.ts index 30692c13c79a..e50802bf5c1e 100644 --- a/handwritten/spanner/src/helper.ts +++ b/handwritten/spanner/src/helper.ts @@ -276,3 +276,12 @@ export function isError(value: any): boolean { Object.prototype.toString.call(value) === '[object Error]' ); } + +/** + * Checks if a value is a UUID. + * @param {*} value The value to check. + * @returns {Boolean} `true` if the value is a UUID, otherwise `false`. + */ +export function isUuid(value: any): boolean { + return typeof value === 'string' && /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i.test(value); +} diff --git a/handwritten/spanner/src/metrics/metrics-tracer-factory.ts b/handwritten/spanner/src/metrics/metrics-tracer-factory.ts index d928c6fa8322..8a56d8f3f140 100644 --- a/handwritten/spanner/src/metrics/metrics-tracer-factory.ts +++ b/handwritten/spanner/src/metrics/metrics-tracer-factory.ts @@ -15,7 +15,6 @@ import * as crypto from 'crypto'; import * as os from 'os'; import * as process from 'process'; -import {v4 as uuidv4} from 'uuid'; import {MeterProvider, MetricReader} from '@opentelemetry/sdk-metrics'; import {Counter, Histogram} from '@opentelemetry/api'; import {detectResources, Resource} from '@opentelemetry/resources'; @@ -410,7 +409,7 @@ export class MetricsTracerFactory { * @returns A unique string identifier for the client. */ private static _generateClientUId(): string { - const identifier = uuidv4(); + const identifier = crypto.randomUUID(); const pid = process.pid.toString(); let hostname = 'localhost'; diff --git a/handwritten/spanner/system-test/spanner.ts b/handwritten/spanner/system-test/spanner.ts index 5ee4fcbd706b..b7c5e3ac44fa 100644 --- a/handwritten/spanner/system-test/spanner.ts +++ b/handwritten/spanner/system-test/spanner.ts @@ -21,7 +21,6 @@ import pLimit = require('p-limit'); import concat = require('concat-stream'); import * as crypto from 'crypto'; import * as extend from 'extend'; -import * as uuid from 'uuid'; import { Backup, Database, @@ -59,7 +58,7 @@ import { CreateQueryPartitionsResponse, CreateReadPartitionsResponse, } from '../src/batch-transaction'; -import {isNull, isNumber} from '../src/helper'; +import {isNull, isNumber, isUuid} from '../src/helper'; const fs = require('fs'); const SKIP_BACKUPS = process.env.SKIP_BACKUPS; @@ -913,11 +912,11 @@ describe('Spanner', () => { }; it('GOOGLE_STANDARD_SQL should write uuid values', async () => { - await uuidInsert(Spanner.GOOGLE_STANDARD_SQL, uuid.v4()); + await uuidInsert(Spanner.GOOGLE_STANDARD_SQL, crypto.randomUUID()); }); it.skip('POSTGRESQL should write uuid values', async () => { - await uuidInsert(Spanner.POSTGRESQL, uuid.v4()); + await uuidInsert(Spanner.POSTGRESQL, crypto.randomUUID()); }); it('GOOGLE_STANDARD_SQL should write empty uuid array values', async () => { @@ -934,7 +933,7 @@ describe('Spanner', () => { }); it('GOOGLE_STANDARD_SQL should write uuid array values', async () => { - const values = [uuid.v4(), uuid.v4(), uuid.v4()]; + const values = [crypto.randomUUID(), crypto.randomUUID(), crypto.randomUUID()]; const {row} = await insert( {UUIDArray: values}, Spanner.GOOGLE_STANDARD_SQL, @@ -943,7 +942,7 @@ describe('Spanner', () => { }); it.skip('POSTGRESQL should write uuid array values', async () => { - const values = [uuid.v4(), uuid.v4(), uuid.v4()]; + const values = [crypto.randomUUID(), crypto.randomUUID(), crypto.randomUUID()]; const {row} = await insert({UUIDArray: values}, Spanner.POSTGRESQL); assert.deepStrictEqual(row.toJSON().UUIDArray, values); }); @@ -3968,7 +3967,7 @@ describe('Spanner', () => { describe('insert & query', () => { const ID = generateName('id'); const NAME = generateName('name'); - const UUID = uuid.v4(); + const UUID = crypto.randomUUID(); const FLOAT32 = 8.2; const FLOAT = 8.2; const INT = 2; @@ -4599,7 +4598,7 @@ describe('Spanner', () => { }; it('GOOGLE_STANDARD_SQL should bind the value when param type uuid is used', async () => { - const value = uuid.v4(); + const value = crypto.randomUUID(); const query = { sql: 'SELECT @v', params: { @@ -4613,7 +4612,7 @@ describe('Spanner', () => { }); it('GOOGLE_STANDARD_SQL should bind the value as uuid when param type is not specified', async () => { - const val = uuid.v4(); + const val = crypto.randomUUID(); const id = generateName('id'); try { await googleSqlTable.insert({SingerId: id, UUID: val}); @@ -4628,14 +4627,14 @@ describe('Spanner', () => { }; const [rows] = await DATABASE.run(query); assert.strictEqual(rows[0][0].value, id); - assert.strictEqual(uuid.validate(rows[0][1].value), true); + assert.strictEqual(isUuid(rows[0][1].value), true); } catch (err) { assert.ifError(err); } }); it.skip('POSTGRESQL should bind the value when param type uuid is used', async () => { - const value = uuid.v4(); + const value = crypto.randomUUID(); const query = { sql: 'SELECT $1', params: { @@ -4649,7 +4648,7 @@ describe('Spanner', () => { }); it.skip('POSTGRESQL should bind the value as uuid when param type is not specified', async () => { - const val = uuid.v4(); + const val = crypto.randomUUID(); const id = generateName('id'); try { await postgreSqlTable.insert({SingerId: id, UUID: val}); @@ -4664,14 +4663,14 @@ describe('Spanner', () => { }; const [rows] = await PG_DATABASE.run(query); assert.strictEqual(rows[0][0].value, id); - assert.strictEqual(uuid.validate(rows[0][1].value), true); + assert.strictEqual(isUuid(rows[0][1].value), true); } catch (err) { assert.ifError(err); } }); it('GOOGLE_STANDARD_SQL should bind arrays', async () => { - const values = [uuid.v4(), uuid.v4(), uuid.v4()]; + const values = [crypto.randomUUID(), crypto.randomUUID(), crypto.randomUUID()]; const query = { sql: 'SELECT @v', @@ -4711,7 +4710,7 @@ describe('Spanner', () => { }); it.skip('POSTGRESQL should bind arrays', async () => { - const values = [uuid.v4(), uuid.v4(), uuid.v4()]; + const values = [crypto.randomUUID(), crypto.randomUUID(), crypto.randomUUID()]; const query = { sql: 'SELECT $1', @@ -8874,7 +8873,7 @@ describe('Spanner', () => { }); function shortUUID() { - return uuid.v4().split('-').shift(); + return crypto.randomUUID().split('-').shift(); } function generateName(resourceType) { diff --git a/handwritten/spanner/test/codec.ts b/handwritten/spanner/test/codec.ts index 6406ad66067f..c889c7e79894 100644 --- a/handwritten/spanner/test/codec.ts +++ b/handwritten/spanner/test/codec.ts @@ -24,7 +24,7 @@ import {GrpcService} from '../src/common-grpc/service'; import {google} from '../protos/protos'; import {GoogleError} from 'google-gax'; import {util} from 'protobufjs'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import Long = util.Long; import {isString} from '../src/helper'; const singer = require('./data/singer'); @@ -1259,7 +1259,7 @@ describe('codec', () => { }); it('should decode UUID', () => { - const value = uuid.v4(); + const value = crypto.randomUUID(); const decoded = codec.decode(value, { code: google.spanner.v1.TypeCode.UUID, @@ -1676,7 +1676,7 @@ describe('codec', () => { }); it('should encode UUID', () => { - const value = uuid.v4(); + const value = crypto.randomUUID(); const encoded = codec.encode(value); @@ -1779,7 +1779,7 @@ describe('codec', () => { }); it('should determine if the uuid value is string', () => { - assert.deepStrictEqual(codec.getType(uuid.v4()), { + assert.deepStrictEqual(codec.getType(crypto.randomUUID()), { type: 'string', }); }); @@ -1788,7 +1788,7 @@ describe('codec', () => { const emitWarningStub = sandbox.stub(process, 'emitWarning'); try { process.env['SPANNER_ENABLE_UUID_AS_UNTYPED'] = 'true'; - assert.deepStrictEqual(codec.getType(uuid.v4()), { + assert.deepStrictEqual(codec.getType(crypto.randomUUID()), { type: 'unspecified', }); assert.strictEqual(emitWarningStub.calledOnce, true); @@ -1805,7 +1805,7 @@ describe('codec', () => { it('should determine if the uuid value is string when SPANNER_ENABLE_UUID_AS_UNTYPED is false', () => { try { process.env['SPANNER_ENABLE_UUID_AS_UNTYPED'] = 'false'; - assert.deepStrictEqual(codec.getType(uuid.v4()), { + assert.deepStrictEqual(codec.getType(crypto.randomUUID()), { type: 'string', }); } finally { diff --git a/handwritten/storage/conformance-test/conformanceCommon.ts b/handwritten/storage/conformance-test/conformanceCommon.ts index 65da9293811a..a206ea064fe8 100644 --- a/handwritten/storage/conformance-test/conformanceCommon.ts +++ b/handwritten/storage/conformance-test/conformanceCommon.ts @@ -16,7 +16,7 @@ import * as jsonToNodeApiMapping from './test-data/retryInvocationMap.json'; import * as libraryMethods from './libraryMethods'; import {Bucket, File, HmacKey, Notification, Storage} from '../src/'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import * as assert from 'assert'; import {DecorateRequestOptions} from '../src/nodejs-common'; import fetch from 'node-fetch'; @@ -231,5 +231,5 @@ async function getTestBenchRetryTest( } function shortUUID() { - return uuid.v1().split('-').shift(); + return crypto.randomUUID().split('-').shift(); } diff --git a/handwritten/storage/conformance-test/libraryMethods.ts b/handwritten/storage/conformance-test/libraryMethods.ts index 2dd2e586bebc..4358abe9c1dd 100644 --- a/handwritten/storage/conformance-test/libraryMethods.ts +++ b/handwritten/storage/conformance-test/libraryMethods.ts @@ -20,7 +20,7 @@ import { createTestFileFromBuffer, deleteTestFile, } from './testBenchUtil'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import {getDirName} from '../src/util.js'; const FILE_SIZE_BYTES = 9 * 1024 * 1024; @@ -393,7 +393,7 @@ export async function bucketUploadResumableInstancePrecondition( ) { const filePath = path.join( getDirName(), - `../conformance-test/test-data/tmp-${uuid.v4()}.txt` + `../conformance-test/test-data/tmp-${crypto.randomUUID()}.txt` ); createTestFileFromBuffer(FILE_SIZE_BYTES, filePath); if (options.bucket!.instancePreconditionOpts) { @@ -411,7 +411,7 @@ export async function bucketUploadResumableInstancePrecondition( export async function bucketUploadResumable(options: ConformanceTestOptions) { const filePath = path.join( getDirName(), - `../conformance-test/test-data/tmp-${uuid.v4()}.txt` + `../conformance-test/test-data/tmp-${crypto.randomUUID()}.txt` ); createTestFileFromBuffer(FILE_SIZE_BYTES, filePath); if (options.preconditionRequired) { diff --git a/handwritten/storage/package.json b/handwritten/storage/package.json index d796e736dbcb..f287bbe53aea 100644 --- a/handwritten/storage/package.json +++ b/handwritten/storage/package.json @@ -89,8 +89,7 @@ "mime": "^3.0.0", "p-limit": "^3.0.1", "retry-request": "^7.0.0", - "teeny-request": "^9.0.0", - "uuid": "^8.0.0" + "teeny-request": "^9.0.0" }, "devDependencies": { "@babel/cli": "^7.22.10", @@ -109,7 +108,6 @@ "@types/request": "^2.48.4", "@types/sinon": "^17.0.0", "@types/tmp": "0.2.6", - "@types/uuid": "^8.0.0", "@types/yargs": "^17.0.10", "c8": "^9.0.0", "form-data": "^4.0.4", diff --git a/handwritten/storage/src/nodejs-common/service.ts b/handwritten/storage/src/nodejs-common/service.ts index 6e2a6cb90789..9173a38f73d7 100644 --- a/handwritten/storage/src/nodejs-common/service.ts +++ b/handwritten/storage/src/nodejs-common/service.ts @@ -20,7 +20,7 @@ import { GoogleAuthOptions, } from 'google-auth-library'; import * as r from 'teeny-request'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import {Interceptor} from './service-object.js'; import { @@ -274,7 +274,7 @@ export class Service { 'User-Agent': userAgent, 'x-goog-api-client': `${getRuntimeTrackingString()} gccl/${ pkg.version - }-${getModuleFormat()} gccl-invocation-id/${uuid.v4()}`, + }-${getModuleFormat()} gccl-invocation-id/${crypto.randomUUID()}`, }; if (reqOpts[GCCL_GCS_CMD_KEY]) { diff --git a/handwritten/storage/src/nodejs-common/util.ts b/handwritten/storage/src/nodejs-common/util.ts index 9ba3051add3c..34b37c30f6a0 100644 --- a/handwritten/storage/src/nodejs-common/util.ts +++ b/handwritten/storage/src/nodejs-common/util.ts @@ -30,7 +30,7 @@ import retryRequest from 'retry-request'; import {Duplex, DuplexOptions, Readable, Transform, Writable} from 'stream'; import {teenyRequest} from 'teeny-request'; import {Interceptor} from './service-object.js'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import {DEFAULT_PROJECT_ID_TOKEN} from './service.js'; import { getModuleFormat, @@ -1028,7 +1028,7 @@ export class Util { 'User-Agent': getUserAgentString(), 'x-goog-api-client': `${getRuntimeTrackingString()} gccl/${ packageJson.version - }-${getModuleFormat()} gccl-invocation-id/${uuid.v4()}`, + }-${getModuleFormat()} gccl-invocation-id/${crypto.randomUUID()}`, }; if (gcclGcsCmd) { diff --git a/handwritten/storage/src/resumable-upload.ts b/handwritten/storage/src/resumable-upload.ts index af9e92a0cc2f..9ebbb6f37a85 100644 --- a/handwritten/storage/src/resumable-upload.ts +++ b/handwritten/storage/src/resumable-upload.ts @@ -29,7 +29,7 @@ import { import {Readable, Writable, WritableOptions} from 'stream'; import AsyncRetry from 'async-retry'; import {RetryOptions, PreconditionOptions} from './storage.js'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import { getRuntimeTrackingString, getModuleFormat, @@ -339,9 +339,9 @@ export class Upload extends Writable { isPartialUpload: boolean; private currentInvocationId = { - checkUploadStatus: uuid.v4(), - chunk: uuid.v4(), - uri: uuid.v4(), + checkUploadStatus: crypto.randomUUID(), + chunk: crypto.randomUUID(), + uri: crypto.randomUUID(), }; /** * A cache of buffers written to this instance, ready for consuming @@ -862,7 +862,7 @@ export class Upload extends Writable { try { const res = await this.makeRequest(reqOpts); // We have successfully got a URI we can now create a new invocation id - this.currentInvocationId.uri = uuid.v4(); + this.currentInvocationId.uri = crypto.randomUUID(); return res.headers.location; } catch (err) { const e = err as GaxiosError; @@ -1104,7 +1104,7 @@ export class Upload extends Writable { } // At this point we can safely create a new id for the chunk - this.currentInvocationId.chunk = uuid.v4(); + this.currentInvocationId.chunk = crypto.randomUUID(); const moreDataToUpload = await this.waitForNextChunk(); @@ -1234,7 +1234,7 @@ export class Upload extends Writable { const resp = await this.makeRequest(opts); // Successfully got the offset we can now create a new offset invocation id - this.currentInvocationId.checkUploadStatus = uuid.v4(); + this.currentInvocationId.checkUploadStatus = crypto.randomUUID(); return resp; } catch (e) { diff --git a/handwritten/storage/system-test/storage.ts b/handwritten/storage/system-test/storage.ts index 4e9fb0d4c509..3b32f90709cc 100644 --- a/handwritten/storage/system-test/storage.ts +++ b/handwritten/storage/system-test/storage.ts @@ -22,7 +22,6 @@ import pLimit from 'p-limit'; import {promisify} from 'util'; import * as path from 'path'; import * as tmp from 'tmp'; -import * as uuid from 'uuid'; import {ApiError} from '../src/nodejs-common/index.js'; import { AccessControlObject, @@ -1100,7 +1099,7 @@ describe('storage', function () { it('can be written to the bucket by project owner w/o configuration', async () => { await setUniformBucketLevelAccess(bucket, true); - const file = bucket.file(`file-${uuid.v4()}`); + const file = bucket.file(`file-${crypto.randomUUID()}`); return assert.doesNotReject(() => file.save('data')); }); }); @@ -1117,7 +1116,7 @@ describe('storage', function () { await createBucket(); await setUniformBucketLevelAccess(bucket, true); - file = bucket.file(`file-${uuid.v4()}`); + file = bucket.file(`file-${crypto.randomUUID()}`); await file.save('data', {resumable: false}); }); @@ -1175,7 +1174,7 @@ describe('storage', function () { }).timeout(UNIFORM_ACCESS_TIMEOUT); it('should preserve file ACL', async () => { - const file = bucket.file(`file-${uuid.v4()}`); + const file = bucket.file(`file-${crypto.randomUUID()}`); await file.save('data', {resumable: false}); await file.acl.update(customAcl); @@ -4537,7 +4536,7 @@ describe('storage', function () { } function shortUUID() { - return uuid.v1().split('-').shift(); + return crypto.randomUUID().split('-').shift(); } function generateName() { diff --git a/packages/google-cloud-aiplatform/samples/package.json b/packages/google-cloud-aiplatform/samples/package.json index 31c36e94fe63..2c9b3e9f96c1 100644 --- a/packages/google-cloud-aiplatform/samples/package.json +++ b/packages/google-cloud-aiplatform/samples/package.json @@ -17,7 +17,6 @@ }, "devDependencies": { "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-asset/samples/package.json b/packages/google-cloud-asset/samples/package.json index 5e953a9aea5a..49015e856995 100644 --- a/packages/google-cloud-asset/samples/package.json +++ b/packages/google-cloud-asset/samples/package.json @@ -19,7 +19,6 @@ "@google-cloud/bigquery": "^8.0.0", "@google-cloud/compute": "^6.0.0", "@google-cloud/storage": "^7.0.0", - "uuid": "^9.0.0", "yargs": "^17.0.0" }, "devDependencies": { diff --git a/packages/google-cloud-automl/samples/package.json b/packages/google-cloud-automl/samples/package.json index a67c0a1b1921..4826004c2867 100644 --- a/packages/google-cloud-automl/samples/package.json +++ b/packages/google-cloud-automl/samples/package.json @@ -24,7 +24,6 @@ "devDependencies": { "@google-cloud/storage": "^7.0.1", "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-certificatemanager/samples/package.json b/packages/google-cloud-certificatemanager/samples/package.json index 91df8a7e5fb1..7d98fa13fed1 100644 --- a/packages/google-cloud-certificatemanager/samples/package.json +++ b/packages/google-cloud-certificatemanager/samples/package.json @@ -19,7 +19,6 @@ "devDependencies": { "c8": "^10.0.0", "chai": "^4.2.0", - "mocha": "^9.0.0", - "uuid": "^9.0.0" + "mocha": "^9.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-compute/package.json b/packages/google-cloud-compute/package.json index d34cc7ff83e0..f6c3da7c75da 100644 --- a/packages/google-cloud-compute/package.json +++ b/packages/google-cloud-compute/package.json @@ -143,8 +143,7 @@ "mocha": "^11.1.0", "pack-n-play": "^3.0.0", "sinon": "21.0.3", - "typescript": "^5.8.2", - "uuid": "^11.1.0" + "typescript": "^5.8.2" }, "homepage": "https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-compute", "overrides": { diff --git a/packages/google-cloud-compute/samples/package.json b/packages/google-cloud-compute/samples/package.json index 84e3085f8c45..af979c88a9e0 100644 --- a/packages/google-cloud-compute/samples/package.json +++ b/packages/google-cloud-compute/samples/package.json @@ -23,7 +23,6 @@ "@google-cloud/storage": "^7.0.0", "chai": "^4.2.0", "mocha": "^8.0.0", - "proxyquire": "^2.0.1", - "uuid": "^9.0.0" + "proxyquire": "^2.0.1" } } \ No newline at end of file diff --git a/packages/google-cloud-compute/system-test/compute.js b/packages/google-cloud-compute/system-test/compute.js index e2464a8759c7..1c00c388cb2c 100644 --- a/packages/google-cloud-compute/system-test/compute.js +++ b/packages/google-cloud-compute/system-test/compute.js @@ -16,7 +16,7 @@ const assert = require('assert'); const expect = require('chai').expect; -const uuid = require('uuid'); +const crypto = require('crypto'); const compute = require('../'); const DiskType = compute.protos.google.cloud.compute.v1.AttachedDisk.Type; @@ -556,7 +556,7 @@ describe('Compute', () => { function generateName(customPrefix) { const TESTS_PREFIX = 'tsgapic'; - const resourceId = uuid.v4().split('-')[0]; + const resourceId = crypto.randomUUID().split('-')[0]; return `${TESTS_PREFIX}-${customPrefix}-${resourceId}`; } }); diff --git a/packages/google-cloud-contactcenterinsights/samples/package.json b/packages/google-cloud-contactcenterinsights/samples/package.json index dfb07960d605..0ce895378fc6 100644 --- a/packages/google-cloud-contactcenterinsights/samples/package.json +++ b/packages/google-cloud-contactcenterinsights/samples/package.json @@ -20,7 +20,6 @@ "devDependencies": { "c8": "^10.0.0", "chai": "^4.2.0", - "mocha": "^9.0.0", - "uuid": "^9.0.0" + "mocha": "^9.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-dataproc/samples/package.json b/packages/google-cloud-dataproc/samples/package.json index f1a427f119f8..f0ae7d379990 100644 --- a/packages/google-cloud-dataproc/samples/package.json +++ b/packages/google-cloud-dataproc/samples/package.json @@ -19,7 +19,6 @@ }, "devDependencies": { "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-dialogflow-cx/samples/package.json b/packages/google-cloud-dialogflow-cx/samples/package.json index 1f7e48a08a0c..b69f48c7be40 100644 --- a/packages/google-cloud-dialogflow-cx/samples/package.json +++ b/packages/google-cloud-dialogflow-cx/samples/package.json @@ -13,8 +13,7 @@ "test": "c8 mocha --timeout 600000 test/*.js" }, "dependencies": { - "@google-cloud/dialogflow-cx": "^5.8.1", - "uuid": "^9.0.0" + "@google-cloud/dialogflow-cx": "^5.8.1" }, "devDependencies": { "c8": "^10.0.0", diff --git a/packages/google-cloud-dialogflow-cx/samples/quickstart.js b/packages/google-cloud-dialogflow-cx/samples/quickstart.js index 11f6fd330dc9..a510c5ad49b6 100644 --- a/packages/google-cloud-dialogflow-cx/samples/quickstart.js +++ b/packages/google-cloud-dialogflow-cx/samples/quickstart.js @@ -46,12 +46,10 @@ async function main( const fs = require('fs'); const util = require('util'); - // Assumes uuid module has been installed from npm, - // npm i uuid: - const {v4} = require('uuid'); + const crypto = require('crypto'); async function detectIntentAudio() { - const sessionId = v4(); + const sessionId = crypto.randomUUID(); const sessionPath = client.projectLocationAgentSessionPath( projectId, location, diff --git a/packages/google-cloud-dialogflow/samples/package.json b/packages/google-cloud-dialogflow/samples/package.json index 98d741b22d7b..9232ab4772eb 100644 --- a/packages/google-cloud-dialogflow/samples/package.json +++ b/packages/google-cloud-dialogflow/samples/package.json @@ -17,7 +17,6 @@ "dependencies": { "@google-cloud/dialogflow": "^7.6.1", "pb-util": "^1.0.0", - "uuid": "^9.0.0", "yargs": "^17.0.0" }, "devDependencies": { diff --git a/packages/google-cloud-dns/package.json b/packages/google-cloud-dns/package.json index b88ab2b4c7a8..f9f52abf2df5 100644 --- a/packages/google-cloud-dns/package.json +++ b/packages/google-cloud-dns/package.json @@ -64,7 +64,6 @@ "@types/proxyquire": "^1.3.31", "@types/request": "^2.48.12", "@types/tmp": "^0.2.6", - "@types/uuid": "^11.0.0", "c8": "^10.1.3", "codecov": "^3.8.3", "gts": "^6.0.2", @@ -76,8 +75,7 @@ "mocha": "^11.1.0", "proxyquire": "^2.1.3", "tmp": "^0.2.3", - "typescript": "^5.8.2", - "uuid": "^11.1.0" + "typescript": "^5.8.2" }, "homepage": "https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-dns" } diff --git a/packages/google-cloud-dns/samples/package.json b/packages/google-cloud-dns/samples/package.json index 6a8f73b5187d..610da78fc7b7 100644 --- a/packages/google-cloud-dns/samples/package.json +++ b/packages/google-cloud-dns/samples/package.json @@ -19,7 +19,6 @@ }, "devDependencies": { "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-dns/samples/test/quickstart.test.js b/packages/google-cloud-dns/samples/test/quickstart.test.js index 9a9463ce991d..98e1063c77b6 100644 --- a/packages/google-cloud-dns/samples/test/quickstart.test.js +++ b/packages/google-cloud-dns/samples/test/quickstart.test.js @@ -18,12 +18,12 @@ const {execSync} = require('child_process'); const {assert} = require('chai'); const {describe, it, before, after} = require('mocha'); const {DNS} = require('@google-cloud/dns'); -const {v4} = require('uuid'); +const crypto = require('crypto'); const exec = cmd => execSync(cmd, {encoding: 'utf8'}); describe(__filename, () => { - const zoneName = `test-${v4().substr(0, 13)}`; + const zoneName = `test-${crypto.randomUUID().substr(0, 13)}`; const dns = new DNS(); before(async () => { diff --git a/packages/google-cloud-dns/system-test/dns.ts b/packages/google-cloud-dns/system-test/dns.ts index 7f0e59c5fc1a..ae8a87a232fb 100644 --- a/packages/google-cloud-dns/system-test/dns.ts +++ b/packages/google-cloud-dns/system-test/dns.ts @@ -17,7 +17,7 @@ import {describe, it, before, after} from 'mocha'; import * as fs from 'fs'; import * as tmp from 'tmp'; import * as util from 'util'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; // eslint-disable-next-line @typescript-eslint/no-var-requires const format = require('string-format-obj'); @@ -36,7 +36,7 @@ const delayMs = async (ms = 1000) => { // Only run the tests if there is a domain to test with. describe('dns', () => { - const ZONE_NAME = 'test-zone-' + uuid.v4().substr(0, 18); + const ZONE_NAME = 'test-zone-' + crypto.randomUUID().substr(0, 18); const ZONE = dns.zone(ZONE_NAME); const records = { @@ -321,7 +321,7 @@ describe('dns', () => { }); it('should replace records', async () => { - const name = 'test-zone-' + uuid.v4().substr(0, 18); + const name = 'test-zone-' + crypto.randomUUID().substr(0, 18); // Do this in a new zone so no existing records are affected. const [zone] = await dns.createZone(name, { dnsName: DNS_DOMAIN, diff --git a/packages/google-cloud-dns/test/zone.ts b/packages/google-cloud-dns/test/zone.ts index e4f4bdae2301..07681f51e591 100644 --- a/packages/google-cloud-dns/test/zone.ts +++ b/packages/google-cloud-dns/test/zone.ts @@ -19,7 +19,7 @@ import * as assert from 'assert'; import {describe, it, before, beforeEach} from 'mocha'; import * as proxyquire from 'proxyquire'; import {CoreOptions, OptionsWithUri, Response} from 'request'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import {Change, CreateChangeRequest} from '../src/change'; import {Record, RecordObject, RecordMetadata} from '../src/record'; @@ -211,9 +211,9 @@ describe('Zone', () => { function generateRecord(recordJson?: {}) { recordJson = Object.assign( { - name: uuid.v1(), - type: uuid.v1(), - rrdatas: [uuid.v1(), uuid.v1()], + name: crypto.randomUUID(), + type: crypto.randomUUID(), + rrdatas: [crypto.randomUUID(), crypto.randomUUID()], }, recordJson ); diff --git a/packages/google-cloud-documentai/samples/package.json b/packages/google-cloud-documentai/samples/package.json index 3222219efd71..428eab62e46e 100644 --- a/packages/google-cloud-documentai/samples/package.json +++ b/packages/google-cloud-documentai/samples/package.json @@ -15,8 +15,7 @@ "dependencies": { "@google-cloud/documentai": "^9.6.1", "@google-cloud/storage": "^7.0.0", - "p-queue": "^8.0.0", - "uuid": "^9.0.0" + "p-queue": "^8.0.0" }, "devDependencies": { "chai": "^4.2.0", diff --git a/packages/google-cloud-iot/samples/package.json b/packages/google-cloud-iot/samples/package.json index 2c3b383a80e2..6e5bd68829c7 100644 --- a/packages/google-cloud-iot/samples/package.json +++ b/packages/google-cloud-iot/samples/package.json @@ -25,7 +25,6 @@ "jsonwebtoken": "^9.0.0", "mocha": "^8.1.1", "mqtt": "^4.0.0", - "uuid": "^9.0.0", "yargs": "^17.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-kms/samples/package.json b/packages/google-cloud-kms/samples/package.json index d41a0de0c49c..dbf8086ea217 100644 --- a/packages/google-cloud-kms/samples/package.json +++ b/packages/google-cloud-kms/samples/package.json @@ -21,7 +21,6 @@ "devDependencies": { "c8": "^10.0.0", "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-language/samples/package.json b/packages/google-cloud-language/samples/package.json index 3c04ccd103cc..667a759a9be5 100644 --- a/packages/google-cloud-language/samples/package.json +++ b/packages/google-cloud-language/samples/package.json @@ -23,7 +23,6 @@ }, "devDependencies": { "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-monitoring/samples/package.json b/packages/google-cloud-monitoring/samples/package.json index b0a4f754d932..5dbb0eeda5df 100644 --- a/packages/google-cloud-monitoring/samples/package.json +++ b/packages/google-cloud-monitoring/samples/package.json @@ -19,7 +19,6 @@ }, "devDependencies": { "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-recaptchaenterprise/samples/package.json b/packages/google-cloud-recaptchaenterprise/samples/package.json index ecf1916aab27..9db1fcde1393 100644 --- a/packages/google-cloud-recaptchaenterprise/samples/package.json +++ b/packages/google-cloud-recaptchaenterprise/samples/package.json @@ -17,7 +17,6 @@ }, "devDependencies": { "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-secretmanager/samples/package.json b/packages/google-cloud-secretmanager/samples/package.json index 3f5524ab41a4..d77680f5fc96 100644 --- a/packages/google-cloud-secretmanager/samples/package.json +++ b/packages/google-cloud-secretmanager/samples/package.json @@ -19,7 +19,6 @@ "devDependencies": { "c8": "^10.0.0", "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-secretmanager/samples/test/quickstart.test.js b/packages/google-cloud-secretmanager/samples/test/quickstart.test.js index 19f21005bf9b..3d231674cfdc 100644 --- a/packages/google-cloud-secretmanager/samples/test/quickstart.test.js +++ b/packages/google-cloud-secretmanager/samples/test/quickstart.test.js @@ -16,12 +16,12 @@ const assert = require('assert'); const cp = require('child_process'); -const {v4} = require('uuid'); +const crypto = require('crypto'); const {before, it, describe} = require('mocha'); const {SecretManagerServiceClient} = require('@google-cloud/secret-manager'); const client = new SecretManagerServiceClient(); -const secretId = v4(); +const secretId = crypto.randomUUID(); const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); diff --git a/packages/google-cloud-securitycenter/samples/package.json b/packages/google-cloud-securitycenter/samples/package.json index 89c58ec5eba4..9ddff16f0a19 100644 --- a/packages/google-cloud-securitycenter/samples/package.json +++ b/packages/google-cloud-securitycenter/samples/package.json @@ -18,7 +18,6 @@ }, "devDependencies": { "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-servicedirectory/samples/package.json b/packages/google-cloud-servicedirectory/samples/package.json index da57e9b8b9f8..c8f430c07ac9 100644 --- a/packages/google-cloud-servicedirectory/samples/package.json +++ b/packages/google-cloud-servicedirectory/samples/package.json @@ -15,8 +15,7 @@ "dependencies": { "@google-cloud/service-directory": "^6.1.2", "eslint": "^8.0.0", - "json-schema": "^0.4.0", - "uuid": "^9.0.0" + "json-schema": "^0.4.0" }, "devDependencies": { "c8": "^10.0.0", diff --git a/packages/google-cloud-speech/package.json b/packages/google-cloud-speech/package.json index cdea3f676b11..65030334f4a5 100644 --- a/packages/google-cloud-speech/package.json +++ b/packages/google-cloud-speech/package.json @@ -54,8 +54,7 @@ "@types/pumpify": "^1.4.4", "google-gax": "^5.0.0", "pumpify": "^2.0.1", - "stream-events": "^1.0.5", - "uuid": "^11.1.0" + "stream-events": "^1.0.5" }, "devDependencies": { "@types/mocha": "^10.0.10", diff --git a/packages/google-cloud-speech/samples/package.json b/packages/google-cloud-speech/samples/package.json index a7026c4868ab..354c049a7351 100644 --- a/packages/google-cloud-speech/samples/package.json +++ b/packages/google-cloud-speech/samples/package.json @@ -29,7 +29,6 @@ "devDependencies": { "c8": "^10.0.0", "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-talent/samples/package.json b/packages/google-cloud-talent/samples/package.json index a625322ba584..c52ca9ca2a42 100644 --- a/packages/google-cloud-talent/samples/package.json +++ b/packages/google-cloud-talent/samples/package.json @@ -18,7 +18,6 @@ }, "dependencies": { "@google-cloud/talent": "^7.1.2", - "uuid": "^9.0.0", "yargs": "^17.0.0" }, "devDependencies": { diff --git a/packages/google-cloud-tasks/samples/package.json b/packages/google-cloud-tasks/samples/package.json index 8f73a456298e..44f73c12bc5a 100644 --- a/packages/google-cloud-tasks/samples/package.json +++ b/packages/google-cloud-tasks/samples/package.json @@ -21,7 +21,6 @@ }, "devDependencies": { "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-translate/samples/package.json b/packages/google-cloud-translate/samples/package.json index a70b384b121a..2a88622122f6 100644 --- a/packages/google-cloud-translate/samples/package.json +++ b/packages/google-cloud-translate/samples/package.json @@ -23,7 +23,6 @@ "devDependencies": { "@google-cloud/storage": "^7.0.0", "chai": "^4.2.0", - "mocha": "^8.0.0", - "uuid": "^9.0.0" + "mocha": "^8.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-video-livestream/samples/package.json b/packages/google-cloud-video-livestream/samples/package.json index f9466994acf9..fb8e960cba36 100644 --- a/packages/google-cloud-video-livestream/samples/package.json +++ b/packages/google-cloud-video-livestream/samples/package.json @@ -18,7 +18,6 @@ "devDependencies": { "c8": "^10.0.0", "chai": "^4.2.0", - "mocha": "^9.0.0", - "uuid": "^9.0.0" + "mocha": "^9.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-video-transcoder/samples/package.json b/packages/google-cloud-video-transcoder/samples/package.json index bbf940c6d021..d6f1fa5f3b0a 100644 --- a/packages/google-cloud-video-transcoder/samples/package.json +++ b/packages/google-cloud-video-transcoder/samples/package.json @@ -19,7 +19,6 @@ "devDependencies": { "@google-cloud/storage": "^7.0.0", "c8": "^10.0.0", - "mocha": "^8.1.1", - "uuid": "^9.0.0" + "mocha": "^8.1.1" } } \ No newline at end of file diff --git a/packages/google-cloud-vision/package.json b/packages/google-cloud-vision/package.json index 3e7bbc42ed5e..6f93ef6f8dbc 100644 --- a/packages/google-cloud-vision/package.json +++ b/packages/google-cloud-vision/package.json @@ -58,7 +58,6 @@ "@types/mocha": "^10.0.10", "@types/node": "^22.13.9", "@types/sinon": "^17.0.4", - "@types/uuid": "^11.0.0", "c8": "^10.1.3", "codecov": "^3.8.3", "gapic-tools": "^1.0.0", @@ -71,8 +70,7 @@ "mocha": "^11.1.0", "pack-n-play": "^3.0.0", "sinon": "21.0.3", - "typescript": "^5.8.2", - "uuid": "^11.1.0" + "typescript": "^5.8.2" }, "homepage": "https://github.com/googleapis/google-cloud-node/tree/main/packages/google-cloud-vision", "overrides": { diff --git a/packages/google-cloud-vision/samples/package.json b/packages/google-cloud-vision/samples/package.json index 19404f2e6a46..d8335c8a391f 100644 --- a/packages/google-cloud-vision/samples/package.json +++ b/packages/google-cloud-vision/samples/package.json @@ -22,7 +22,6 @@ "devDependencies": { "@google-cloud/storage": "^7.0.0", "chai": "^4.2.0", - "mocha": "^10.0.0", - "uuid": "^9.0.0" + "mocha": "^10.0.0" } } \ No newline at end of file diff --git a/packages/google-cloud-vision/system-test/vision.ts b/packages/google-cloud-vision/system-test/vision.ts index 17e53e036e09..30f57ad8ff13 100644 --- a/packages/google-cloud-vision/system-test/vision.ts +++ b/packages/google-cloud-vision/system-test/vision.ts @@ -17,7 +17,7 @@ import {describe, it, before, after} from 'mocha'; import * as fs from 'fs'; import * as path from 'path'; import {Storage} from '@google-cloud/storage'; -import * as uuid from 'uuid'; +import * as crypto from 'crypto'; import * as prototypes from '../protos/protos'; import * as vision from '../src'; @@ -131,6 +131,6 @@ describe('Vision', () => { }); function generateName() { - return TESTS_PREFIX + uuid.v1(); + return TESTS_PREFIX + crypto.randomUUID(); } }); diff --git a/packages/google-cloud-vmmigration/samples/package.json b/packages/google-cloud-vmmigration/samples/package.json index 1c3376700611..1661bc080800 100644 --- a/packages/google-cloud-vmmigration/samples/package.json +++ b/packages/google-cloud-vmmigration/samples/package.json @@ -19,7 +19,6 @@ "devDependencies": { "c8": "^10.0.0", "chai": "^4.2.0", - "mocha": "^9.0.0", - "uuid": "^9.0.0" + "mocha": "^9.0.0" } } \ No newline at end of file diff --git a/packages/google-container/samples/package.json b/packages/google-container/samples/package.json index 405abe4236a0..0387bbebb8f9 100644 --- a/packages/google-container/samples/package.json +++ b/packages/google-container/samples/package.json @@ -14,8 +14,7 @@ "test": "mocha test --timeout 1000000" }, "dependencies": { - "@google-cloud/container": "^6.7.1", - "uuid": "^9.0.0" + "@google-cloud/container": "^6.7.1" }, "devDependencies": { "chai": "^4.2.0", diff --git a/packages/google-devtools-containeranalysis/samples/package.json b/packages/google-devtools-containeranalysis/samples/package.json index 87125e4e143e..9f00eb543268 100644 --- a/packages/google-devtools-containeranalysis/samples/package.json +++ b/packages/google-devtools-containeranalysis/samples/package.json @@ -18,7 +18,6 @@ }, "devDependencies": { "chai": "^4.2.0", - "mocha": "^9.0.0", - "uuid": "^9.0.0" + "mocha": "^9.0.0" } } \ No newline at end of file diff --git a/packages/google-privacy-dlp/samples/package.json b/packages/google-privacy-dlp/samples/package.json index 2a66098ec2b4..f5d3fa204486 100644 --- a/packages/google-privacy-dlp/samples/package.json +++ b/packages/google-privacy-dlp/samples/package.json @@ -24,7 +24,6 @@ "chai": "^4.2.0", "mocha": "^8.0.0", "pixelmatch": "^7.0.0", - "pngjs": "^6.0.0", - "uuid": "^9.0.0" + "pngjs": "^6.0.0" } } \ No newline at end of file diff --git a/packages/google-storagetransfer/samples/package.json b/packages/google-storagetransfer/samples/package.json index 05415e2bfe1b..7b6e104149e9 100644 --- a/packages/google-storagetransfer/samples/package.json +++ b/packages/google-storagetransfer/samples/package.json @@ -20,7 +20,6 @@ "aws-sdk": "^2.1073.0", "c8": "^10.0.0", "chai": "^4.2.0", - "mocha": "^9.0.0", - "uuid": "^9.0.0" + "mocha": "^9.0.0" } } \ No newline at end of file diff --git a/packages/google-storagetransfer/samples/test/utils/bucket.js b/packages/google-storagetransfer/samples/test/utils/bucket.js index 8e2668266f09..ac3713b98f12 100644 --- a/packages/google-storagetransfer/samples/test/utils/bucket.js +++ b/packages/google-storagetransfer/samples/test/utils/bucket.js @@ -22,7 +22,7 @@ const { StorageTransferServiceClient, } = require('@google-cloud/storage-transfer'); const AWS = require('aws-sdk'); -const uuid = require('uuid'); +const crypto = require('crypto'); class BucketManager { constructor() { @@ -59,7 +59,7 @@ class BucketManager { * @returns {string} Name of bucket */ static generateBucketName() { - return `nodejs-sts-samples-${uuid.v4()}`; + return `nodejs-sts-samples-${crypto.randomUUID()}`; } /**