Skip to content

Commit 9da7d9e

Browse files
authored
chore(deps): remove uuid dependency (#42)
1 parent 77c15dc commit 9da7d9e

11 files changed

Lines changed: 42 additions & 73 deletions

File tree

.changeset/four-plums-relax.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@interledger/open-payments': patch
3+
'@interledger/openapi': patch
4+
'@interledger/http-signature-utils': patch
5+
---
6+
7+
Removed the `uuid` dependency in favor of the global `crypto.randomUUID()` API.

packages/http-signature-utils/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626
"dependencies": {
2727
"http-message-signatures": "^1.0.6",
2828
"httpbis-digest-headers": "^1.0.0",
29-
"jose": "^4.15.9",
30-
"uuid": "^9.0.1"
29+
"jose": "^4.15.9"
3130
},
3231
"devDependencies": {
33-
"@types/node": "^26.3.0",
34-
"@types/uuid": "^9.0.8"
32+
"@types/node": "^26.3.0"
3533
}
3634
}

packages/http-signature-utils/src/test-utils/keys.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import crypto from 'crypto'
2-
import { v4 } from 'uuid'
32

43
import { generateJwk, JWK } from '../utils/jwk'
54

@@ -13,7 +12,7 @@ export function generateTestKeys(): TestKeys {
1312

1413
return {
1514
publicKey: generateJwk({
16-
keyId: v4(),
15+
keyId: crypto.randomUUID(),
1716
privateKey
1817
}),
1918
privateKey

packages/open-payments/package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
},
3232
"devDependencies": {
3333
"@types/node": "^26.3.0",
34-
"@types/uuid": "^9.0.8",
3534
"nock": "14.0.17",
3635
"openapi-typescript": "^7.13.0"
3736
},
@@ -41,7 +40,6 @@
4140
"base64url": "^3.0.1",
4241
"http-message-signatures": "^0.1.2",
4342
"ky": "^1.14.3",
44-
"pino": "^8.21.0",
45-
"uuid": "^9.0.1"
43+
"pino": "^8.21.0"
4644
}
4745
}

packages/open-payments/src/client/grant.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
mockSubject
99
} from '../test/helpers'
1010
import * as requestors from './requests'
11-
import { v4 as uuid } from 'uuid'
1211
import { getAuthServerOpenAPI } from '../openapi'
1312
import { BaseDeps } from '.'
1413
import { GrantRequest } from '../types'
@@ -331,7 +330,7 @@ describe('grant', (): void => {
331330
.mockImplementation(mockResponseValidator as any)
332331

333332
const postSpy = jest.spyOn(requestors, 'post')
334-
const interact_ref = uuid()
333+
const interact_ref = crypto.randomUUID()
335334

336335
await createGrantRoutes({
337336
openApi,

packages/open-payments/src/client/incoming-payment.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
mockPublicIncomingPayment
2121
} from '../test/helpers'
2222
import nock from 'nock'
23-
import { v4 as uuid } from 'uuid'
2423
import * as requestors from './requests'
2524
import { getRSPath } from '../types'
2625
import { OpenPaymentsClientError } from './error'
@@ -333,7 +332,7 @@ describe('incoming-payment', (): void => {
333332
first | cursor
334333
${undefined} | ${undefined}
335334
${1} | ${undefined}
336-
${5} | ${uuid()}
335+
${5} | ${crypto.randomUUID()}
337336
`(
338337
'returns incoming payments list',
339338
async ({ first, cursor }): Promise<void> => {
@@ -375,8 +374,8 @@ describe('incoming-payment', (): void => {
375374
describe('backward pagination', (): void => {
376375
test.each`
377376
last | cursor
378-
${undefined} | ${uuid()}
379-
${5} | ${uuid()}
377+
${undefined} | ${crypto.randomUUID()}
378+
${5} | ${crypto.randomUUID()}
380379
`(
381380
'returns incoming payments list',
382381
async ({ last, cursor }): Promise<void> => {

packages/open-payments/src/client/outgoing-payment.test.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import {
1616
createTestDeps
1717
} from '../test/helpers'
1818
import nock from 'nock'
19-
import { v4 as uuid } from 'uuid'
2019
import * as requestors from './requests'
2120
import { OpenPaymentsClientError } from './error'
2221
import assert from 'assert'
@@ -133,7 +132,7 @@ describe('outgoing-payment', (): void => {
133132
first | cursor
134133
${undefined} | ${undefined}
135134
${1} | ${undefined}
136-
${5} | ${uuid()}
135+
${5} | ${crypto.randomUUID()}
137136
`(
138137
'returns outgoing payment list',
139138
async ({ first, cursor }): Promise<void> => {
@@ -174,8 +173,8 @@ describe('outgoing-payment', (): void => {
174173
describe('backward pagination', (): void => {
175174
test.each`
176175
last | cursor
177-
${undefined} | ${uuid()}
178-
${5} | ${uuid()}
176+
${undefined} | ${crypto.randomUUID()}
177+
${5} | ${crypto.randomUUID()}
179178
`(
180179
'returns outgoing payment list',
181180
async ({ last, cursor }): Promise<void> => {
@@ -287,8 +286,8 @@ describe('outgoing-payment', (): void => {
287286
})
288287

289288
describe('createOutgoingPayment', (): void => {
290-
const quoteId_ = `${serverAddress}/quotes/${uuid()}`
291-
const incomingPayment = `${serverAddress}/incoming-payments/${uuid()}`
289+
const quoteId_ = `${serverAddress}/quotes/${crypto.randomUUID()}`
290+
const incomingPayment = `${serverAddress}/incoming-payments/${crypto.randomUUID()}`
292291
const debitAmount = {
293292
value: '2500',
294293
assetCode: 'USD',
@@ -314,7 +313,7 @@ describe('outgoing-payment', (): void => {
314313
assert(!(quoteId && debitAmount))
315314

316315
const outgoingPayment = mockOutgoingPaymentWithSpentAmounts({
317-
quoteId: quoteId || uuid(),
316+
quoteId: quoteId || crypto.randomUUID(),
318317
metadata
319318
})
320319

@@ -368,7 +367,7 @@ describe('outgoing-payment', (): void => {
368367
},
369368
openApiValidators.successfulValidator,
370369
{
371-
quoteId: uuid(),
370+
quoteId: crypto.randomUUID(),
372371
walletAddress
373372
}
374373
)
@@ -402,7 +401,7 @@ describe('outgoing-payment', (): void => {
402401
},
403402
openApiValidators.failedValidator,
404403
{
405-
quoteId: uuid(),
404+
quoteId: crypto.randomUUID(),
406405
walletAddress
407406
}
408407
)
@@ -599,7 +598,7 @@ describe('outgoing-payment', (): void => {
599598

600599
const url = `${serverAddress}/outgoing-payments`
601600
const outgoingPaymentCreateArgs = {
602-
quoteId: uuid(),
601+
quoteId: crypto.randomUUID(),
603602
walletAddress
604603
}
605604

packages/open-payments/src/test/helpers.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
OutgoingPaymentWithSpentAmounts,
2323
Subject
2424
} from '../types'
25-
import { v4 as uuid } from 'uuid'
2625
import { ResponseValidator, ValidationError } from '@interledger/openapi'
2726
import base64url from 'base64url'
2827
import { BaseDeps } from '../client'
@@ -60,8 +59,8 @@ export const mockOpenApiResponseValidators = () => ({
6059
})
6160

6261
export const mockJwk = (overrides?: Partial<JWK>): JWK => ({
63-
x: uuid(),
64-
kid: uuid(),
62+
x: crypto.randomUUID(),
63+
kid: crypto.randomUUID(),
6564
alg: 'EdDSA',
6665
kty: 'OKP',
6766
crv: 'Ed25519',
@@ -89,7 +88,7 @@ export const mockWalletAddress = (
8988
export const mockIncomingPayment = (
9089
overrides?: Partial<IncomingPayment>
9190
): IncomingPayment => ({
92-
id: `https://example.com/.well-known/pay/incoming-payments/${uuid()}`,
91+
id: `https://example.com/.well-known/pay/incoming-payments/${crypto.randomUUID()}`,
9392
walletAddress: 'https://example.com/.well-known/pay',
9493
completed: false,
9594
incomingAmount: {
@@ -109,7 +108,7 @@ export const mockIncomingPayment = (
109108
export const mockIncomingPaymentWithPaymentMethods = (
110109
overrides?: Partial<IncomingPaymentWithPaymentMethods>
111110
): IncomingPaymentWithPaymentMethods => ({
112-
id: `https://example.com/.well-known/pay/incoming-payments/${uuid()}`,
111+
id: `https://example.com/.well-known/pay/incoming-payments/${crypto.randomUUID()}`,
113112
walletAddress: 'https://example.com/.well-known/pay',
114113
completed: false,
115114
incomingAmount: {
@@ -171,7 +170,7 @@ export const mockIncomingPaymentPaginationResult = (
171170
export const mockOutgoingPayment = (
172171
overrides?: Partial<OutgoingPayment>
173172
): OutgoingPayment => ({
174-
id: `https://example.com/.well-known/pay/outgoing-payments/${uuid()}`,
173+
id: `https://example.com/.well-known/pay/outgoing-payments/${crypto.randomUUID()}`,
175174
walletAddress: 'https://example.com/.well-known/pay',
176175
failed: false,
177176
debitAmount: {
@@ -189,8 +188,8 @@ export const mockOutgoingPayment = (
189188
assetScale: 2,
190189
value: '10'
191190
},
192-
quoteId: uuid(),
193-
receiver: uuid(),
191+
quoteId: crypto.randomUUID(),
192+
receiver: crypto.randomUUID(),
194193
metadata: { externalRef: 'INV #1', description: 'some description' },
195194
createdAt: new Date().toISOString(),
196195
...overrides
@@ -323,7 +322,7 @@ export const mockGrantRequest = (
323322
export const mockContinuationRequest = (
324323
overrides?: Partial<GrantContinuationRequest>
325324
): GrantContinuationRequest => ({
326-
interact_ref: uuid(),
325+
interact_ref: crypto.randomUUID(),
327326
...overrides
328327
})
329328

@@ -332,7 +331,7 @@ export const mockAccessToken = (
332331
): AccessToken => ({
333332
access_token: {
334333
value: '99C36C2A4DB5BEBC',
335-
manage: `http://example.com/token/${uuid()}`,
334+
manage: `http://example.com/token/${crypto.randomUUID()}`,
336335
access: [
337336
{
338337
type: 'incoming-payment',
@@ -345,7 +344,7 @@ export const mockAccessToken = (
345344
})
346345

347346
export const mockQuote = (overrides?: Partial<Quote>): Quote => ({
348-
id: `https://example.com/.well-known/pay/quotes/${uuid()}`,
347+
id: `https://example.com/.well-known/pay/quotes/${crypto.randomUUID()}`,
349348
receiver: 'https://example.com/.well-known/peer',
350349
walletAddress: 'https://example.com/.well-known/pay',
351350
debitAmount: {

packages/openapi/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
"devDependencies": {
3838
"@types/jest": "^30.0.0",
3939
"@types/koa": "2.15.2",
40-
"@types/uuid": "^9.0.8",
41-
"node-mocks-http": "^1.18.1",
42-
"uuid": "^9.0.1"
40+
"@types/node": "^26.3.0",
41+
"node-mocks-http": "^1.18.1"
4342
}
4443
}

packages/openapi/src/middleware.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Koa from 'koa'
22
import * as httpMocks from 'node-mocks-http'
3-
import { v4 as uuid } from 'uuid'
43
import assert from 'assert'
54
import {
65
createOpenAPI,
@@ -62,7 +61,7 @@ describe('OpenAPI Validator', (): void => {
6261
let next: jest.MockedFunction<() => Promise<void>>
6362
let validatePostMiddleware: AppMiddleware
6463
let validateListMiddleware: AppMiddleware
65-
const accountId = uuid()
64+
const accountId = crypto.randomUUID()
6665

6766
beforeAll((): void => {
6867
validatePostMiddleware = createValidatorMiddleware(openApi, {
@@ -230,7 +229,7 @@ describe('OpenAPI Validator', (): void => {
230229
pagination: { hasNextPage: false, hasPreviousPage: false },
231230
result: [
232231
{
233-
id: uuid(),
232+
id: crypto.randomUUID(),
234233
walletAddress: WALLET_ADDRESS,
235234
completed: false,
236235
receivedAmount: { value: '0', assetCode: 'USD', assetScale: 2 },
@@ -309,7 +308,7 @@ describe('OpenAPI Validator', (): void => {
309308
)
310309

311310
const body = {
312-
id: `https://${accountId}/incoming-payments/${uuid()}`,
311+
id: `https://${accountId}/incoming-payments/${crypto.randomUUID()}`,
313312
walletAddress: 'https://openpayments.dev/alice',
314313
receivedAmount: {
315314
value: '0',

0 commit comments

Comments
 (0)