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

IMN-842 - Removing uuid and using crypto #1127

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/agreement-email-sender/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"testcontainers": "10.9.0",
"ts-node": "10.9.2",
"typescript": "5.4.5",
"uuid": "10.0.0",
"vitest": "1.6.0"
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/agreement-outbound-writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"testcontainers": "10.9.0",
"ts-node": "10.9.2",
"typescript": "5.4.5",
"uuid": "10.0.0",
"vitest": "1.6.0"
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/agreement-process/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"pagopa-interop-api-clients": "workspace:*",
"pagopa-interop-agreement-lifecycle": "workspace:*",
"ts-pattern": "5.2.0",
"uuid": "10.0.0",
"zod": "3.23.8"
}
}
1 change: 0 additions & 1 deletion packages/agreement-readmodel-writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"testcontainers": "10.9.0",
"ts-node": "10.9.2",
"typescript": "5.4.5",
"uuid": "10.0.0",
"vitest": "1.6.0",
"@anatine/zod-mock": "3.13.4"
},
Expand Down
1 change: 0 additions & 1 deletion packages/anac-certified-attributes-importer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"dependencies": {
"csv": "^6.3.2",
"dotenv-flow": "4.1.0",
"uuid": "10.0.0",
"pagopa-interop-commons": "workspace:*",
"pagopa-interop-models": "workspace:*",
"pagopa-interop-api-clients": "workspace:*",
Expand Down
1 change: 0 additions & 1 deletion packages/attribute-registry-process/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"pagopa-interop-api-clients": "workspace:*",
"pg-promise": "11.8.0",
"ts-pattern": "5.2.0",
"uuid": "10.0.0",
"zod": "3.23.8"
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/* eslint-disable @typescript-eslint/no-floating-promises */
import { randomUUID } from "crypto";
import { describe, expect, it } from "vitest";
import {
decodeProtobufPayload,
getMockAttribute,
getMockAuthData,
} from "pagopa-interop-commons-test";
import { genericLogger } from "pagopa-interop-commons";
import { v4 as uuidv4 } from "uuid";
import {
Attribute,
AttributeAddedV1,
Expand Down Expand Up @@ -214,7 +214,7 @@ describe("database test", () => {
features: [
{
type: "PersistentCertifier",
certifierId: uuidv4(),
certifierId: randomUUID(),
},
],
};
Expand Down Expand Up @@ -274,7 +274,7 @@ describe("database test", () => {
features: [
{
type: "PersistentCertifier",
certifierId: uuidv4(),
certifierId: randomUUID(),
},
],
};
Expand Down Expand Up @@ -342,7 +342,7 @@ describe("database test", () => {
features: [
{
type: "PersistentCertifier",
certifierId: uuidv4(),
certifierId: randomUUID(),
},
],
};
Expand Down Expand Up @@ -402,7 +402,7 @@ describe("database test", () => {
features: [
{
type: "PersistentCertifier",
certifierId: uuidv4(),
certifierId: randomUUID(),
},
],
};
Expand Down
1 change: 0 additions & 1 deletion packages/authorization-updater/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"pagopa-interop-commons": "workspace:*",
"pagopa-interop-models": "workspace:*",
"ts-pattern": "5.2.0",
"uuid": "10.0.0",
"zod": "3.23.8"
}
}
1 change: 0 additions & 1 deletion packages/backend-for-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
"pagopa-interop-models": "workspace:*",
"qs": "6.12.3",
"ts-pattern": "5.2.0",
"uuid": "10.0.0",
"yaml": "2.4.5",
"zod": "3.23.8"
}
Expand Down
1 change: 0 additions & 1 deletion packages/catalog-outbound-writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"testcontainers": "10.9.0",
"ts-node": "10.9.2",
"typescript": "5.4.5",
"uuid": "10.0.0",
"vitest": "1.6.0"
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/catalog-platformstate-writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"testcontainers": "10.9.0",
"ts-node": "10.9.2",
"typescript": "5.4.5",
"uuid": "10.0.0",
"vitest": "1.6.0"
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/catalog-process/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"pagopa-interop-models": "workspace:*",
"pagopa-interop-api-clients": "workspace:*",
"ts-pattern": "5.2.0",
"uuid": "10.0.0",
"zod": "3.23.8"
}
}
1 change: 0 additions & 1 deletion packages/catalog-readmodel-writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"testcontainers": "10.9.0",
"ts-node": "10.9.2",
"typescript": "5.4.5",
"uuid": "10.0.0",
"vitest": "1.6.0"
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/client-readmodel-writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"pagopa-interop-commons": "workspace:*",
"pagopa-interop-models": "workspace:*",
"ts-pattern": "5.2.0",
"uuid": "10.0.0",
"zod": "3.23.8"
}
}
1 change: 0 additions & 1 deletion packages/commons-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"testcontainers": "10.9.0",
"ts-pattern": "5.2.0",
"typescript": "5.4.5",
"uuid": "10.0.0",
"vitest": "1.6.0",
"zod": "3.23.8"
}
Expand Down
1 change: 0 additions & 1 deletion packages/commons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"rate-limiter-flexible": "5.0.3",
"redis": "4.6.15",
"ts-pattern": "5.2.0",
"uuid": "10.0.0",
"winston": "3.13.0",
"zod": "3.23.8",
"zod-validation-error": "3.3.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/commons/src/context/context.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { constants } from "http2";
import { randomUUID } from "crypto";
import {
ZodiosRouterContextRequestHandler,
zodiosContext,
} from "@zodios/express";
import { v4 as uuidv4 } from "uuid";
import { z } from "zod";
import {
CorrelationId,
Expand Down Expand Up @@ -63,7 +63,7 @@ export const contextMiddleware =

setCtx(correlationIdHeader);
} else {
setCtx(uuidv4());
setCtx(randomUUID());
}

return next();
Expand Down
1 change: 0 additions & 1 deletion packages/compute-agreements-consumer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"pagopa-interop-commons": "workspace:*",
"pagopa-interop-models": "workspace:*",
"ts-pattern": "5.2.0",
"uuid": "10.0.0",
"zod": "3.23.8"
}
}
1 change: 0 additions & 1 deletion packages/datalake-data-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"dotenv-flow": "4.1.0",
"date-fns": "3.6.0",
"mongodb": "6.7.0",
"uuid": "10.0.0",
"zod": "3.23.8"
}
}
1 change: 0 additions & 1 deletion packages/eservice-descriptors-archiver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
"pagopa-interop-models": "workspace:*",
"pagopa-interop-api-clients": "workspace:*",
"ts-pattern": "5.2.0",
"uuid": "10.0.0",
"zod": "3.23.8"
}
}
3 changes: 0 additions & 3 deletions packages/ivass-certified-attributes-importer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
"pagopa-interop-commons-test": "workspace:*",
"@types/uuid": "9.0.8",
"@types/adm-zip": "0.5.5",
"pagopa-interop-commons-test": "workspace:*",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, the dependency was duplicated

"prettier": "2.8.8",
"testcontainers": "10.9.0",
"ts-node": "10.9.2",
"typescript": "5.4.5",
"vitest": "1.6.0"
},
"dependencies": {
"ts-pattern": "5.2.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, the dependency was duplicated

"uuid": "10.0.0",
"@aws-sdk/client-s3": "3.387.0",
"adm-zip": "0.5.15",
"axios": "1.7.4",
Expand Down
1 change: 0 additions & 1 deletion packages/key-readmodel-writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"pagopa-interop-commons": "workspace:*",
"pagopa-interop-models": "workspace:*",
"ts-pattern": "5.2.0",
"uuid": "10.0.0",
"zod": "3.23.8"
}
}
1 change: 0 additions & 1 deletion packages/models/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"@types/node": "20.14.6",
"@types/uuid": "9.0.8",
"ts-pattern": "5.2.0",
"uuid": "10.0.0",
"zod": "3.23.8",
"zod-validation-error": "3.3.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/models/src/brandedIds.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { randomUUID } from "crypto";
import { z } from "zod";
import { v4 as uuidv4 } from "uuid";

export const CorrelationId = z.string().brand("CorrelationId");
export type CorrelationId = z.infer<typeof CorrelationId>;
Expand Down Expand Up @@ -159,7 +159,7 @@ type IDS =
// it infers the type of the ID based on how is used the result
// the 'as' is used to cast the uuid string to the inferred type
export function generateId<T extends IDS>(): T {
return uuidv4() as T;
return randomUUID() as T;
}

// This function is used to get a branded ID from a string
Expand Down
1 change: 0 additions & 1 deletion packages/notifier-seeder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"pagopa-interop-commons": "workspace:*",
"pagopa-interop-models": "workspace:*",
"ts-pattern": "5.2.0",
"uuid": "10.0.0",
"zod": "3.23.8"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { randomUUID } from "crypto";
import { AgreementEventEnvelopeV2 } from "pagopa-interop-models";
import { match } from "ts-pattern";
import { v4 as uuidv4 } from "uuid";
import { QueueMessage } from "../../queue-manager/queueMessage.js";
import { AgreementEventNotification } from "./agreementEventNotification.js";

Expand Down Expand Up @@ -41,7 +41,7 @@ export const buildAgreementMessage = (
event: AgreementEventEnvelopeV2,
agreementEvent: AgreementEventNotification
): QueueMessage => ({
messageUUID: uuidv4(),
messageUUID: randomUUID(),
eventJournalPersistenceId: event.stream_id,
eventJournalSequenceNumber: event.version,
eventTimestamp: Number(event.log_date),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { randomUUID } from "crypto";
import { match } from "ts-pattern";
import { v4 as uuidv4 } from "uuid";
import { AuthorizationEventEnvelopeV2 } from "pagopa-interop-models";
import { QueueMessage } from "../../queue-manager/queueMessage.js";
import { AuthorizationEventNotification } from "./authorizationEventNotification.js";
Expand Down Expand Up @@ -34,7 +34,7 @@ export const buildAuthorizationMessage = (
event: AuthorizationEventEnvelopeV2,
authorizationEvent: AuthorizationEventNotification
): QueueMessage => ({
messageUUID: uuidv4(),
messageUUID: randomUUID(),
eventJournalPersistenceId: event.stream_id,
eventJournalSequenceNumber: event.version,
eventTimestamp: Number(event.log_date),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { randomUUID } from "crypto";
import { EServiceEventEnvelopeV2 } from "pagopa-interop-models";
import { match } from "ts-pattern";
import { v4 as uuidv4 } from "uuid";
import { QueueMessage } from "../../queue-manager/queueMessage.js";
import { CatalogItemEventNotification } from "./catalogItemEventNotification.js";

Expand Down Expand Up @@ -59,7 +59,7 @@ export const eventV2TypeMapper = (
)
.exhaustive();

/*
/*
This method is used to build a message for catalog events, that to be sent to the notify queue,
it will be used to mantains compatibility with the old version of queue consumers.
Related issue https://pagopa.atlassian.net/browse/IMN-67
Expand All @@ -68,7 +68,7 @@ export const buildCatalogMessage = (
event: EServiceEventEnvelopeV2,
catalogItemEvent: CatalogItemEventNotification
): QueueMessage => ({
messageUUID: uuidv4(),
messageUUID: randomUUID(),
eventJournalPersistenceId: event.stream_id,
eventJournalSequenceNumber: event.version,
eventTimestamp: Number(event.log_date),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { randomUUID } from "crypto";
import { PurposeEventEnvelopeV2 } from "pagopa-interop-models";
import { match } from "ts-pattern";
import { v4 as uuidv4 } from "uuid";
import { QueueMessage } from "../../queue-manager/queueMessage.js";
import { PurposeEventNotification } from "./purposeEventNotification.js";

Expand Down Expand Up @@ -46,7 +46,7 @@ export const buildPurposeMessage = (
event: PurposeEventEnvelopeV2,
purposeEvent: PurposeEventNotification
): QueueMessage => ({
messageUUID: uuidv4(),
messageUUID: randomUUID(),
eventJournalPersistenceId: event.stream_id,
eventJournalSequenceNumber: event.version,
eventTimestamp: Number(event.log_date),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { randomUUID } from "crypto";
import { describe, expect, it, vi } from "vitest";

import {
Agreement,
AgreementAddedV2,
Expand All @@ -24,7 +24,6 @@ import {
unsafeBrandId,
} from "pagopa-interop-models";
import { genericLogger } from "pagopa-interop-commons";
import { v4 } from "uuid";
import {
getMockAgreement,
getMockClient,
Expand Down Expand Up @@ -135,7 +134,7 @@ describe("Notification tests", async () => {
sequence_num: 1,
stream_id: "d27f668f-630b-4889-a97f-2b7e39b24188",
version: 1,
correlation_id: v4(),
correlation_id: randomUUID(),
log_date: new Date(),
event_version: 2,
type: "EServiceDescriptorSuspended",
Expand All @@ -160,7 +159,7 @@ describe("Notification tests", async () => {
sequence_num: 2,
stream_id: mockPurpose.id,
version: 1,
correlation_id: v4(),
correlation_id: randomUUID(),
log_date: new Date(),
event_version: 2,
type: "PurposeAdded",
Expand Down Expand Up @@ -194,7 +193,7 @@ describe("Notification tests", async () => {
sequence_num: 2,
stream_id: mockAgreement.id,
version: 1,
correlation_id: v4(),
correlation_id: randomUUID(),
log_date: new Date(),
event_version: 2,
type: "AgreementAdded",
Expand Down Expand Up @@ -222,7 +221,7 @@ describe("Notification tests", async () => {
sequence_num: 3,
stream_id: mockClient.id,
version: 1,
correlation_id: v4(),
correlation_id: randomUUID(),
log_date: new Date(),
event_version: 2,
type: "ClientKeyAdded",
Expand Down
Loading