PDS cleanup (#265)
* clean up old todos * some more cleanup * remove server did for now
This commit is contained in:
parent
29463093c1
commit
7e6019fbda
packages
dev-env/src
server
@ -61,14 +61,6 @@ export class DevEnvServer {
|
||||
const serverBlockstore = new MemoryBlockstore()
|
||||
const keypair = await crypto.EcdsaKeypair.create()
|
||||
|
||||
const plcClient = new plc.PlcClient(this.env.plcUrl)
|
||||
const serverDid = await plcClient.createDid(
|
||||
keypair,
|
||||
keypair.did(),
|
||||
'pds.test',
|
||||
`http://localhost:${this.port}`,
|
||||
)
|
||||
|
||||
this.inst = await onServerReady(
|
||||
PDSServer(serverBlockstore, db, keypair, {
|
||||
debugMode: true,
|
||||
@ -76,7 +68,6 @@ export class DevEnvServer {
|
||||
hostname: 'localhost',
|
||||
port: this.port,
|
||||
didPlcUrl: this.env.plcUrl,
|
||||
serverDid: serverDid,
|
||||
recoveryKey: keypair.did(),
|
||||
testNameRegistry: this.env.testNameRegistry,
|
||||
jwtSecret: crytpo.randomBytes(8).toString('base64'),
|
||||
|
@ -29,8 +29,7 @@ export default function (server: Server) {
|
||||
})
|
||||
|
||||
server.com.atproto.getAccount(() => {
|
||||
// TODO
|
||||
return { encoding: '', body: {} }
|
||||
throw new InvalidRequestError('Not implemented')
|
||||
})
|
||||
|
||||
server.com.atproto.createAccount(async (_params, input, _req, res) => {
|
||||
@ -182,6 +181,6 @@ export default function (server: Server) {
|
||||
|
||||
server.com.atproto.deleteAccount(() => {
|
||||
// TODO
|
||||
return { encoding: '', body: {} }
|
||||
throw new InvalidRequestError('Not implemented')
|
||||
})
|
||||
}
|
||||
|
@ -45,7 +45,6 @@ export default function (server: Server) {
|
||||
})
|
||||
|
||||
server.com.atproto.deleteSession(() => {
|
||||
// TODO
|
||||
return { encoding: '', body: {} }
|
||||
throw new InvalidRequestError('Not implemented')
|
||||
})
|
||||
}
|
||||
|
@ -11,9 +11,8 @@ export interface ServerConfigValues {
|
||||
jwtSecret: string
|
||||
|
||||
didPlcUrl: string
|
||||
serverDid: string
|
||||
recoveryKey: string
|
||||
|
||||
recoveryKey: string
|
||||
adminPassword: string
|
||||
|
||||
inviteRequired: boolean
|
||||
@ -47,7 +46,6 @@ export class ServerConfig {
|
||||
const jwtSecret = process.env.JWT_SECRET || 'jwt_secret'
|
||||
|
||||
const didPlcUrl = process.env.DID_PLC_URL || 'http://localhost:2582'
|
||||
const serverDid = process.env.SERVER_DID || ''
|
||||
|
||||
if (typeof process.env.RECOVERY_KEY !== 'string') {
|
||||
throw new Error('No value provided for process.env.RECOVERY_KEY')
|
||||
@ -82,7 +80,6 @@ export class ServerConfig {
|
||||
dbPostgresUrl,
|
||||
dbPostgresSchema,
|
||||
jwtSecret,
|
||||
serverDid,
|
||||
recoveryKey,
|
||||
didPlcUrl,
|
||||
adminPassword,
|
||||
@ -135,10 +132,6 @@ export class ServerConfig {
|
||||
return this.cfg.didPlcUrl
|
||||
}
|
||||
|
||||
get serverDid() {
|
||||
return this.cfg.serverDid
|
||||
}
|
||||
|
||||
get recoveryKey() {
|
||||
return this.cfg.recoveryKey
|
||||
}
|
||||
|
@ -1,7 +0,0 @@
|
||||
import express from 'express'
|
||||
import WellKnown from './well-known'
|
||||
const router = express.Router()
|
||||
|
||||
router.use('/.well-known', WellKnown)
|
||||
|
||||
export default router
|
@ -1,46 +0,0 @@
|
||||
import express from 'express'
|
||||
import * as locals from '../locals'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
// did:web endpoint
|
||||
router.get('/did.json', async (req, res) => {
|
||||
const { db, config } = locals.get(res)
|
||||
const hostname = req.hostname
|
||||
|
||||
let userRecord: { username: string; did: string } | null = null
|
||||
try {
|
||||
userRecord = await db.getUser(hostname)
|
||||
} catch (e) {
|
||||
return res.status(500).end()
|
||||
}
|
||||
|
||||
if (!userRecord) {
|
||||
return res.status(404).end()
|
||||
}
|
||||
if (userRecord.did !== `did:web:${hostname}`) {
|
||||
return res.status(404).end()
|
||||
}
|
||||
// TODO
|
||||
// do we need to further verify this is a hostname we're controlling?
|
||||
// concerned about a forged Host header
|
||||
// -prf
|
||||
|
||||
return res.json({
|
||||
'@context': ['https://www.w3.org/ns/did/v1'],
|
||||
id: userRecord.did,
|
||||
alsoKnownAs: `https://${userRecord.username}`,
|
||||
verificationMethod: [
|
||||
// TODO
|
||||
],
|
||||
service: [
|
||||
{
|
||||
id: `${userRecord.did}#atpPds`,
|
||||
type: 'AtpPersonalDataServer',
|
||||
serviceEndpoint: config.origin,
|
||||
},
|
||||
],
|
||||
})
|
||||
})
|
||||
|
||||
export default router
|
@ -33,22 +33,12 @@ export const runTestServer = async (
|
||||
await plcDb.migrateToLatestOrThrow()
|
||||
const plcServer = plc.server(plcDb, plcPort)
|
||||
|
||||
// setup server did
|
||||
const plcClient = new plc.PlcClient(plcUrl)
|
||||
const recoveryKey = (await crypto.EcdsaKeypair.create()).did()
|
||||
const serverDid = await plcClient.createDid(
|
||||
keypair,
|
||||
recoveryKey,
|
||||
'pds.test',
|
||||
`http://localhost:${pdsPort}`,
|
||||
)
|
||||
|
||||
const config = new ServerConfig({
|
||||
debugMode: true,
|
||||
scheme: 'http',
|
||||
hostname: 'localhost',
|
||||
port: pdsPort,
|
||||
serverDid,
|
||||
recoveryKey,
|
||||
adminPassword: ADMIN_PASSWORD,
|
||||
inviteRequired: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user