Skip to content

Commit

Permalink
allow did:web transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Nov 20, 2023
1 parent fa2b051 commit 6c63a86
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions packages/pds/src/api/com/atproto/temp/transferAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ export default function (server: Server, ctx: AppContext) {
store.repo.storage.getRootDetailed(),
)

const plcOp = await verifyDidAndPlcOp(
ctx,
did,
handle,
signingKey.did(),
input.body.plcOp,
)
const plcOp = did.startsWith('did:plc')
? await verifyDidAndPlcOp(
ctx,
did,
handle,
signingKey.did(),
input.body.plcOp,
)
: null

const { accessJwt, refreshJwt } = await ctx.accountManager.createAccount({
did,
Expand All @@ -32,11 +34,13 @@ export default function (server: Server, ctx: AppContext) {
repoRev: currRoot.rev,
})

try {
await ctx.plcClient.sendOperation(did, plcOp)
} catch (err) {
await ctx.accountManager.deleteAccount(did)
throw err
if (plcOp) {
try {
await ctx.plcClient.sendOperation(did, plcOp)
} catch (err) {
await ctx.accountManager.deleteAccount(did)
throw err
}
}

await ctx.sequencer.sequenceCommit(
Expand Down

0 comments on commit 6c63a86

Please sign in to comment.