Skip to content

Commit ff484d6

Browse files
refactor: remove uuid dependency and use crypto.randomUUID for UUID generation
1 parent ce9de63 commit ff484d6

File tree

5 files changed

+6
-31
lines changed

5 files changed

+6
-31
lines changed

package-lock.json

Lines changed: 1 addition & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,7 @@
215215
"google-auth-library": "^9.14.2",
216216
"jsonwebtoken": "^9.0.0",
217217
"jwks-rsa": "^3.1.0",
218-
"node-forge": "^1.3.1",
219-
"uuid": "^11.0.2"
218+
"node-forge": "^1.3.1"
220219
},
221220
"optionalDependencies": {
222221
"@google-cloud/firestore": "^7.11.0",
@@ -241,7 +240,6 @@
241240
"@types/request-promise": "^4.1.41",
242241
"@types/sinon": "^17.0.2",
243242
"@types/sinon-chai": "^3.0.0",
244-
"@types/uuid": "^10.0.0",
245243
"@typescript-eslint/eslint-plugin": "^7.16.1",
246244
"@typescript-eslint/parser": "^7.16.1",
247245
"bcrypt": "^6.0.0",

src/eventarc/eventarc-client-internal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class EventarcApiClient {
7878
*
7979
* The following CloudEvent fields are auto-populated if not set:
8080
* * specversion - `1.0`
81-
* * id - uuidv4()
81+
* * id - a randomly generated UUID v4 string
8282
* * source - populated with `process.env.EVENTARC_CLOUD_EVENT_SOURCE` and
8383
* if not set an error is thrown.
8484
*

src/eventarc/eventarc-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18+
import { randomUUID } from 'crypto';
1819
import { PrefixedFirebaseError } from '../utils/error';
1920
import { CloudEvent } from './cloudevent';
20-
import { v4 as uuid } from 'uuid';
2121
import * as validator from '../utils/validator';
2222

2323
// List of CloudEvent properties that are handled "by hand" and should be skipped by
@@ -50,7 +50,7 @@ export function toCloudEventProtoFormat(ce: CloudEvent): any {
5050
}
5151
const out: Record<string, any> = {
5252
'@type': 'type.googleapis.com/io.cloudevents.v1.CloudEvent',
53-
'id': ce.id ?? uuid(),
53+
'id': ce.id ?? randomUUID(),
5454
'type': ce.type,
5555
'specVersion': ce.specversion ?? '1.0',
5656
'source': source

test/unit/remote-config/condition-evaluator.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import {
2626
NamedCondition,
2727
OneOfCondition,
2828
} from '../../../src/remote-config/remote-config-api';
29-
import { v4 as uuidv4 } from 'uuid';
3029
import { clone } from 'lodash';
3130
import * as crypto from 'crypto';
3231

@@ -907,7 +906,7 @@ describe('ConditionEvaluator', () => {
907906
...clone(condition),
908907
seed: 'seed'
909908
};
910-
const context = { randomizationId: uuidv4() }
909+
const context = { randomizationId: crypto.randomUUID() }
911910
if (conditionEvaluator.evaluateConditions([{
912911
name: 'is_enabled',
913912
condition: { percent: clonedCondition }

0 commit comments

Comments
 (0)