From 4f53ff41cbe8ccf28202079eee5c6847b8b804cf Mon Sep 17 00:00:00 2001 From: dholms Date: Wed, 1 Nov 2023 15:34:18 -0500 Subject: [PATCH] sync up w entryway branch --- packages/pds/package.json | 2 +- packages/pds/tests/entryway.test.ts | 69 +++--------------------- packages/pds/tests/transfer-repo.test.ts | 2 +- pnpm-lock.yaml | 8 +-- 4 files changed, 14 insertions(+), 67 deletions(-) diff --git a/packages/pds/package.json b/packages/pds/package.json index b116ffffd75..348641e8f16 100644 --- a/packages/pds/package.json +++ b/packages/pds/package.json @@ -78,7 +78,7 @@ "@atproto/bsky": "workspace:^", "@atproto/dev-env": "workspace:^", "@atproto/lex-cli": "workspace:^", - "@atproto/pds-entryway": "npm:@atproto/pds@0.3.0-entryway.1", + "@atproto/pds-entryway": "npm:@atproto/pds@0.3.0-entryway.2", "@did-plc/server": "^0.0.1", "@types/cors": "^2.8.12", "@types/disposable-email": "^0.2.0", diff --git a/packages/pds/tests/entryway.test.ts b/packages/pds/tests/entryway.test.ts index 233dd45a8ff..8925c1cbe73 100644 --- a/packages/pds/tests/entryway.test.ts +++ b/packages/pds/tests/entryway.test.ts @@ -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' @@ -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() @@ -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: 'alice@test.com', handle: 'alice.test', password: 'test123', }) - await moveAccountToPds(did, pds, { entryway, plc }) - const { - data: { accessJwt }, - } = await entrywayAgent.api.com.atproto.server.createSession({ - identifier: 'alice@test.com', - 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 () => { @@ -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') } diff --git a/packages/pds/tests/transfer-repo.test.ts b/packages/pds/tests/transfer-repo.test.ts index e9607a57ab1..2385d7caf9c 100644 --- a/packages/pds/tests/transfer-repo.test.ts +++ b/packages/pds/tests/transfer-repo.test.ts @@ -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, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 57a82deb2d7..5b0f451fe09 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -603,8 +603,8 @@ importers: specifier: workspace:^ version: link:../lex-cli '@atproto/pds-entryway': - specifier: npm:@atproto/pds@0.3.0-entryway.1 - version: /@atproto/pds@0.3.0-entryway.1 + specifier: npm:@atproto/pds@0.3.0-entryway.2 + version: /@atproto/pds@0.3.0-entryway.2 '@did-plc/server': specifier: ^0.0.1 version: 0.0.1 @@ -816,8 +816,8 @@ packages: one-webcrypto: 1.0.3 uint8arrays: 3.0.0 - /@atproto/pds@0.3.0-entryway.1: - resolution: {integrity: sha512-cF9EZLqfuBxp/kBB/o4Ve0A8doCU5ZG2R+61YtOp+12NYoftg+z20fsk893hoqHKqYgu9xaVQlZF3h2txsT3xg==} + /@atproto/pds@0.3.0-entryway.2: + resolution: {integrity: sha512-nj3cOgPBiX0PLMG8Wn6Vy9mpRa891nGDXiOURoeSzQPSJMkWlk/4SlfYEFSrGSHlBnkUNd1fKE3NsJMMQJ/Utg==} hasBin: true dependencies: '@atproto/api': link:packages/api