Skip to content

Commit

Permalink
sync up w entryway branch
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 1, 2023
1 parent 93872c2 commit 4f53ff4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 67 deletions.
2 changes: 1 addition & 1 deletion packages/pds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@atproto/bsky": "workspace:^",
"@atproto/dev-env": "workspace:^",
"@atproto/lex-cli": "workspace:^",
"@atproto/pds-entryway": "npm:@atproto/[email protected].1",
"@atproto/pds-entryway": "npm:@atproto/[email protected].2",
"@did-plc/server": "^0.0.1",
"@types/cors": "^2.8.12",
"@types/disposable-email": "^0.2.0",
Expand Down
69 changes: 8 additions & 61 deletions packages/pds/tests/entryway.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import assert from 'node:assert'
import * as os from 'node:os'
import * as path from 'node:path'
import AtpAgent from '@atproto/api'
Expand Down Expand Up @@ -49,7 +48,7 @@ describe('entryway', () => {
.values({
did: pds.ctx.cfg.service.did,
host: new URL(pds.ctx.cfg.service.publicUrl).host,
weight: 0,
weight: 1,
})
.execute()
pdsAgent = pds.getClient()
Expand All @@ -65,22 +64,17 @@ describe('entryway', () => {
})

it('creates account.', async () => {
const {
data: { did },
} = await entrywayAgent.api.com.atproto.server.createAccount({
const res = await entrywayAgent.api.com.atproto.server.createAccount({
email: '[email protected]',
handle: 'alice.test',
password: 'test123',
})
await moveAccountToPds(did, pds, { entryway, plc })
const {
data: { accessJwt },
} = await entrywayAgent.api.com.atproto.server.createSession({
identifier: '[email protected]',
password: 'test123',
})
alice = did
accessToken = accessJwt
alice = res.data.did
accessToken = res.data.accessJwt

const account = await pds.ctx.accountManager.getAccount(alice)
expect(account?.did).toEqual(alice)
expect(account?.handle).toEqual('alice.test')
})

it('auths with both services.', async () => {
Expand Down Expand Up @@ -168,53 +162,6 @@ const createEntryway = async (
return server
}

// @TODO temporary helper while createAccount flow isn't complete w/ reserveSigningKey
const moveAccountToPds = async (
did: string,
pds: TestPds,
services: { entryway: pdsEntryway.PDS; plc: TestPlc },
) => {
const { entryway, plc } = services
const account = await entryway.ctx.services
.account(entryway.ctx.db)
.getAccount(did)
assert(account)
const signingKey = await Secp256k1Keypair.create({ exportable: true })
const commit = await pds.ctx.actorStore.create(
did,
signingKey,
(actorTxn) => {
return actorTxn.repo.createRepo([])
},
)
await pds.ctx.accountManager.createAccount({
did,
email: `${did}@email.invalid`,
handle: account.handle,
password: randomStr(8, 'base32'),
repoCid: commit.cid,
repoRev: commit.rev,
inviteCode: undefined,
})
const plcClient = plc.getClient()
await plcClient.updatePds(
did,
entryway.ctx.plcRotationKey,
pds.ctx.cfg.service.publicUrl,
)
await plcClient.updateAtprotoKey(
did,
entryway.ctx.plcRotationKey,
signingKey.did(),
)
await entryway.ctx.services.repo(entryway.ctx.db).deleteRepo(did)
await entryway.ctx.db.db
.updateTable('user_account')
.set({ pdsId: entryway.ctx.db.db.selectFrom('pds').select('id').limit(1) })
.where('did', '=', did)
.execute()
}

const getPublicHex = (key: Secp256k1Keypair) => {
return key.publicKeyStr('hex')
}
Expand Down
2 changes: 1 addition & 1 deletion packages/pds/tests/transfer-repo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('transfer repo', () => {
pds = await TestPds.create({
entrywayUrl: `http://localhost:${entrywayPort}`,
entrywayJwtVerifyKeyK256PublicKeyHex: getPublicHex(jwtSigningKey),
entrywayPlcRotationKeyK256PublicKeyHex: getPublicHex(plcRotationKey),
entrywayPlcRotationKey: plcRotationKey.did(),
adminPassword: 'admin-pass',
serviceHandleDomains: [],
didPlcUrl: plc.url,
Expand Down
8 changes: 4 additions & 4 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 4f53ff4

Please sign in to comment.