Skip to content

Commit

Permalink
chore(backend): import open-payments generateJwk
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonianb committed Nov 28, 2022
1 parent 417e6a3 commit 4a453a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
11 changes: 5 additions & 6 deletions packages/backend/src/paymentPointerKey/routes.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createPublicKey } from 'crypto'
import jestOpenAPI from 'jest-openapi'
import { Knex } from 'knex'
import { generateJwk } from 'open-payments'
import { v4 as uuid } from 'uuid'

import { createContext } from '../tests/context'
Expand Down Expand Up @@ -101,11 +101,10 @@ describe('Payment Pointer Keys Routes', (): void => {

test('returns 200 with backend key', async (): Promise<void> => {
const config = await deps.use('config')
const jwk = {
...createPublicKey(config.privateKey).export({ format: 'jwk' }),
kid: config.keyId,
alg: 'EdDSA'
}
const jwk = generateJwk({
privateKey: config.privateKey,
keyId: config.keyId
})

const ctx = createContext<PaymentPointerContext>({
headers: { Accept: 'application/json' },
Expand Down
12 changes: 5 additions & 7 deletions packages/backend/src/paymentPointerKey/routes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createPublicKey } from 'crypto'
import { JWK } from 'open-payments'
import { generateJwk, JWK } from 'open-payments'

import { PaymentPointerContext } from '../app'
import { IAppConfig } from '../config/app'
Expand All @@ -22,11 +21,10 @@ export function createPaymentPointerKeyRoutes(
): PaymentPointerKeyRoutes {
const deps = {
...deps_,
jwk: {
...createPublicKey(deps_.config.privateKey).export({ format: 'jwk' }),
kid: deps_.config.keyId,
alg: 'EdDSA'
} as JWK
jwk: generateJwk({
privateKey: deps_.config.privateKey,
keyId: deps_.config.keyId
})
}

return {
Expand Down

0 comments on commit 4a453a9

Please sign in to comment.