Skip to content

Commit

Permalink
fix: rebase conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
njlie committed Aug 1, 2022
1 parent 5b0f70b commit 30c65a8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 63 deletions.
26 changes: 6 additions & 20 deletions packages/auth/src/accessToken/routes.test.ts
Expand Up @@ -315,12 +315,12 @@ describe('Access Token Routes', (): void => {
const ctx = createContext(
{
headers: {
Accept: 'application/json',
Accept: 'application/json'
},
url: `/token/${managementId}`,
method
},
{ managementId }
{ id: managementId }
)

await accessTokenRoutes.revoke(ctx)
Expand All @@ -339,22 +339,15 @@ describe('Access Token Routes', (): void => {
proof: 'httpsig',
resource_server: 'test'
}
const { signature, sigInput, contentDigest } = await generateSigHeaders(
url,
method
)
const ctx = createContext(
{
headers: {
Accept: 'application/json',
'Content-Digest': contentDigest,
Signature: signature,
'Signature-Input': sigInput
Accept: 'application/json'
},
url,
method
},
{ managementId }
{ id: managementId }
)

ctx.request.body = requestBody
Expand All @@ -376,22 +369,15 @@ describe('Access Token Routes', (): void => {
proof: 'httpsig',
resource_server: 'test'
}
const { signature, sigInput, contentDigest } = await generateSigHeaders(
url,
method
)
const ctx = createContext(
{
headers: {
Accept: 'application/json',
'Content-Digest': contentDigest,
Signature: signature,
'Signature-Input': sigInput
Accept: 'application/json'
},
url,
method
},
{ managementId }
{ id: managementId }
)

ctx.request.body = requestBody
Expand Down
30 changes: 0 additions & 30 deletions packages/auth/src/accessToken/routes.ts
Expand Up @@ -78,36 +78,6 @@ async function revokeToken(
deps: ServiceDependencies,
ctx: AppContext
): Promise<void> {
const sig = ctx.headers['signature']
const sigInput = ctx.headers['signature-input']

if (
!sig ||
!sigInput ||
typeof sig !== 'string' ||
typeof sigInput !== 'string'
) {
ctx.status = 400
ctx.body = {
error: 'invalid_request'
}
return
}

const verified = await deps.clientService.verifySigFromBoundKey(
sig,
sigInput,
'managementId',
ctx.params['managementId'],
ctx
)
if (!verified.success) {
ctx.status = verified.status || 401
ctx.body = {
error: verified.error || 'invalid_client'
}
}

await deps.accessTokenService.revoke(ctx.params['id'])
ctx.status = 204
}
Expand Down
10 changes: 4 additions & 6 deletions packages/auth/src/accessToken/service.test.ts
Expand Up @@ -81,7 +81,6 @@ describe('Access Token Service', (): void => {
}

const BASE_TOKEN = {
managementId: 'https://example.com/manage/12345',
expiresIn: 3600
}

Expand All @@ -105,7 +104,8 @@ describe('Access Token Service', (): void => {
token = await AccessToken.query(trx).insertAndFetch({
grantId: grant.id,
...BASE_TOKEN,
value: crypto.randomBytes(8).toString('hex').toUpperCase()
value: crypto.randomBytes(8).toString('hex').toUpperCase(),
managementId: v4()
})
}
)
Expand Down Expand Up @@ -201,9 +201,6 @@ describe('Access Token Service', (): void => {
token = await AccessToken.query(trx).findById(token.id)
expect(token).toBeUndefined()
})
test('Cannot revoke nonexistent token', async (): Promise<void> => {
expect(accessTokenService.revoke('uuid')).resolves.toBeInstanceOf(Error)
})
})

describe('Rotate', (): void => {
Expand All @@ -226,7 +223,8 @@ describe('Access Token Service', (): void => {
token = await AccessToken.query(trx).insertAndFetch({
grantId: grant.id,
...BASE_TOKEN,
value: crypto.randomBytes(8).toString('hex').toUpperCase()
value: crypto.randomBytes(8).toString('hex').toUpperCase(),
managementId: v4()
})
originalTokenValue = token.value
}
Expand Down
2 changes: 0 additions & 2 deletions packages/auth/src/app.ts
Expand Up @@ -195,7 +195,6 @@ export class App {
path,
method
}),
// TODO: httpsig middleware goes here if applicable
clientService.tokenHttpsigMiddleware,
route
)
Expand All @@ -206,7 +205,6 @@ export class App {
path,
method
}),
// TODO: httpsig middleware goes here if applicable
route
)
}
Expand Down
6 changes: 1 addition & 5 deletions packages/auth/src/grant/routes.test.ts
Expand Up @@ -18,11 +18,7 @@ import { Access } from '../access/model'
import { Grant, StartMethod, FinishMethod, GrantState } from '../grant/model'
import { GrantRequest } from '../grant/service'
import { AccessToken } from '../accessToken/model'
import {
generateSigHeaders,
SIGNATURE_METHOD,
SIGNATURE_TARGET_URI
} from '../tests/signature'
import { generateSigHeaders } from '../tests/signature'

export const KEY_REGISTRY_ORIGIN = 'https://openpayments.network'
export const TEST_KID_PATH = '/keys/base-test-key'
Expand Down

0 comments on commit 30c65a8

Please sign in to comment.