Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
devinivy committed Oct 30, 2023
1 parent f8c4611 commit 654c5c0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/pds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@
"@types/disposable-email": "^0.2.0",
"@types/express": "^4.17.13",
"@types/express-serve-static-core": "^4.17.36",
"@types/jsonwebtoken": "^8.5.9",
"@types/nodemailer": "^6.4.6",
"@types/pg": "^8.6.6",
"@types/qs": "^6.9.7",
"@types/sharp": "^0.31.0",
"axios": "^0.27.2",
"get-port": "^6.1.2",
"ws": "^8.12.0"
}
}
6 changes: 2 additions & 4 deletions packages/pds/tests/app-passwords.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TestNetworkNoAppView } from '@atproto/dev-env'
import AtpAgent from '@atproto/api'
import * as jwt from 'jsonwebtoken'
import * as jose from 'jose'

describe('app_passwords', () => {
let network: TestNetworkNoAppView
Expand Down Expand Up @@ -44,9 +44,7 @@ describe('app_passwords', () => {
})

it('creates an access token for an app with a restricted scope', () => {
const decoded = jwt.decode(appAgent.session?.accessJwt ?? '', {
json: true,
})
const decoded = jose.decodeJwt(appAgent.session?.accessJwt ?? '')
expect(decoded?.scope).toEqual('com.atproto.appPass')
})

Expand Down
10 changes: 5 additions & 5 deletions packages/pds/tests/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as jwt from 'jsonwebtoken'
import * as jose from 'jose'
import AtpAgent from '@atproto/api'
import { TestNetworkNoAppView, SeedClient } from '@atproto/dev-env'
import * as CreateSession from '@atproto/api/src/client/types/com/atproto/server/createSession'
Expand Down Expand Up @@ -157,9 +157,9 @@ describe('auth', () => {
const refresh1 = await refreshSession(account.refreshJwt)
const refresh2 = await refreshSession(account.refreshJwt)

const token0 = jwt.decode(account.refreshJwt, { json: true })
const token1 = jwt.decode(refresh1.refreshJwt, { json: true })
const token2 = jwt.decode(refresh2.refreshJwt, { json: true })
const token0 = jose.decodeJwt(account.refreshJwt)
const token1 = jose.decodeJwt(refresh1.refreshJwt)
const token2 = jose.decodeJwt(refresh2.refreshJwt)

expect(typeof token1?.jti).toEqual('string')
expect(token1?.jti).toEqual(token2?.jti)
Expand All @@ -175,7 +175,7 @@ describe('auth', () => {
password: 'password',
})
await refreshSession(account.refreshJwt)
const token = jwt.decode(account.refreshJwt, { json: true })
const token = jose.decodeJwt(account.refreshJwt)

// Update expiration (i.e. grace period) to end immediately
const refreshUpdated = await db.db
Expand Down
7 changes: 4 additions & 3 deletions packages/pds/tests/entryway.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Secp256k1Keypair, randomStr } from '@atproto/crypto'
import { SeedClient, TestPds, TestPlc, mockResolvers } from '@atproto/dev-env'
import * as pdsEntryway from '@atproto/pds-entryway'
import * as ui8 from 'uint8arrays'
import getPort from 'get-port'

describe('entryway', () => {
let plc: TestPlc
Expand All @@ -17,10 +18,10 @@ describe('entryway', () => {
beforeAll(async () => {
const jwtSigningKey = await Secp256k1Keypair.create({ exportable: true })
const plcRotationKey = await Secp256k1Keypair.create({ exportable: true })
const entrywayPort = await getPort()
plc = await TestPlc.create({})
pds = await TestPds.create({
port: plc.port + 1,
entrywayUrl: `http://localhost:${plc.port + 2}`,
entrywayUrl: `http://localhost:${entrywayPort}`,
entrywayJwtVerifyKeyK256PublicKeyHex: getPublicHex(jwtSigningKey),
entrywayPlcRotationKeyK256PublicKeyHex: getPublicHex(plcRotationKey),
adminPassword: 'admin-pass',
Expand All @@ -31,7 +32,7 @@ describe('entryway', () => {
})
entryway = await createEntryway({
dbPostgresSchema: 'entryway',
port: plc.port + 2,
port: entrywayPort,
adminPassword: 'admin-pass',
jwtSigningKeyK256PrivateKeyHex: await getPrivateHex(jwtSigningKey),
plcRotationKeyK256PrivateKeyHex: await getPrivateHex(plcRotationKey),
Expand Down
12 changes: 3 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 654c5c0

Please sign in to comment.