Skip to content

Commit

Permalink
update plc lib on pds, test
Browse files Browse the repository at this point in the history
  • Loading branch information
devinivy committed Dec 18, 2023
1 parent fe21696 commit 7af8113
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 20 deletions.
2 changes: 1 addition & 1 deletion packages/pds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@atproto/syntax": "workspace:^",
"@atproto/xrpc": "workspace:^",
"@atproto/xrpc-server": "workspace:^",
"@did-plc/lib": "^0.0.1",
"@did-plc/lib": "^0.0.4",
"better-sqlite3": "^7.6.2",
"bytes": "^3.1.2",
"compression": "^1.7.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/pds/src/api/com/atproto/server/createAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { DidDocument, MINUTE, check } from '@atproto/common'
import { AtprotoData, ensureAtpDocument } from '@atproto/identity'
import { InvalidRequestError } from '@atproto/xrpc-server'
import { ExportableKeypair, Keypair, Secp256k1Keypair } from '@atproto/crypto'
import * as plc from '@did-plc/lib'
import disposable from 'disposable-email'
import {
baseNormalizeAndValidate,
normalizeAndValidateHandle,
} from '../../../../handle'
import * as plc from '@did-plc/lib'
import { Server } from '../../../../lexicon'
import { InputSchema as CreateAccountInput } from '../../../../lexicon/types/com/atproto/server/createAccount'
import AppContext from '../../../../context'
Expand Down
23 changes: 23 additions & 0 deletions packages/pds/tests/entryway.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as os from 'node:os'
import * as path from 'node:path'
import * as plcLib from '@did-plc/lib'
import AtpAgent from '@atproto/api'
import { Secp256k1Keypair, randomStr } from '@atproto/crypto'
import { SeedClient, TestPds, TestPlc, mockResolvers } from '@atproto/dev-env'
Expand Down Expand Up @@ -131,6 +132,28 @@ describe('entryway', () => {
expect(accountFromPds?.handle).toEqual('alice3.test')
expect(accountFromEntryway?.handle).toEqual('alice3.test')
})

it('does not allow bringing own op to account creation.', async () => {
const {
data: { signingKey },
} = await pdsAgent.api.com.atproto.server.reserveSigningKey({})
const rotationKey = await Secp256k1Keypair.create()
const plcCreate = await plcLib.createOp({
signingKey,
rotationKeys: [rotationKey.did(), entryway.ctx.plcRotationKey.did()],
handle: 'weirdalice.test',
pds: pds.ctx.cfg.service.publicUrl,
signer: rotationKey,
})
const tryCreateAccount = pdsAgent.api.com.atproto.server.createAccount(
{ did: plcCreate.did, plcOp: plcCreate.op, handle: 'weirdalice.test' },
{
headers: SeedClient.getHeaders(accessToken),
encoding: 'application/json',
},
)
await expect(tryCreateAccount).rejects.toThrow('invalid plc operation')
})
})

const createEntryway = async (
Expand Down
90 changes: 72 additions & 18 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 7af8113

Please sign in to comment.