Skip to content

Commit

Permalink
remove resolveDIDKey from ucanto server definition
Browse files Browse the repository at this point in the history
  • Loading branch information
fforbeck committed Dec 9, 2024
1 parent 38f0047 commit 8ecc001
Showing 1 changed file with 0 additions and 20 deletions.
20 changes: 0 additions & 20 deletions src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,5 @@ export function createServer (ctx, service) {
catch: err => console.error(err),
// TODO: wire into revocations
validateAuthorization: () => ({ ok: {} }),
// @ts-expect-error - The type is not defined in the ucan package, but it supports the method.
resolveDIDKey: (did) => resolveDIDKey(did, ctx)
})
}
/**
* Resolves the DID key for the given DID.
*
* @param {import('@ucanto/interface').DID} did - The DID to resolve
* @param {import('../middleware/withUcanInvocationHandler.types.js').Context} ctx - The application context
*/
const resolveDIDKey = (did, ctx) => {
if (did) {
if (did.startsWith('did:web') && did === ctx.gatewayIdentity.did()) {
return ok(ctx.gatewaySigner.toDIDKey())
}
if (did.startsWith('did:key')) {
return ok(did)
}
}

return error(new DIDResolutionError(did))
}

0 comments on commit 8ecc001

Please sign in to comment.