Skip to content

Commit

Permalink
chore: clean up debugger instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
fforbeck committed Nov 8, 2024
1 parent 2609b21 commit b045c81
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 18 deletions.
15 changes: 4 additions & 11 deletions src/middleware/withAuthorizedSpace.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { Schema } from '@ucanto/client'
*/
export function withAuthorizedSpace(handler) {
return async (request, env, ctx) => {
debugger
const { locator, dataCid } = ctx
const locRes = await locator.locate(dataCid.multihash)
if (locRes.error) {
Expand Down Expand Up @@ -58,7 +57,6 @@ export function withAuthorizedSpace(handler) {
.filter((s) => s !== undefined)

try {
debugger
// First space to successfully authorize is the one we'll use.
const { space: selectedSpace, delegationProofs } = await Promise.any(
spaces.map(async (space) => {
Expand All @@ -67,15 +65,13 @@ export function withAuthorizedSpace(handler) {
return result.ok
})
)
debugger
return handler(request, env, {
...ctx,
space: selectedSpace,
delegationProofs,
locator: spaceScopedLocator(locator, selectedSpace)
})
} catch (error) {
debugger
// If all Spaces failed to authorize, throw the first error.
if (
error instanceof AggregateError &&
Expand Down Expand Up @@ -122,19 +118,16 @@ const authorize = async (space, ctx) => {
.delegate()

// Validate the invocation.
debugger
const accessResult = await access(invocation, {
capability: serve.transportHttp,
authority: ctx.gatewayIdentity,
principal: Verifier,
validateAuthorization: () => ok({}),
resolveDIDKey: async (did) => {
debugger
if (did === ctx.gatewayIdentity.did()) return ok(ctx.gatewayIdentity.toDIDKey())
throw new Error(`Unknown DID: ${did}`)
}
// resolveDIDKey: async (did) => {
// if (did === ctx.gatewayIdentity.did()) return ok(ctx.gatewayIdentity.toDIDKey())
// throw new Error(`Unknown DID: ${did}`)
// }
})
debugger
if (accessResult.error) {
return accessResult
}
Expand Down
1 change: 0 additions & 1 deletion src/middleware/withCarBlockHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { base58btc } from 'multiformats/bases/base58'

export function withCarBlockHandler (handler) {
return async (request, env, ctx) => {
debugger
const { dataCid, searchParams } = ctx
if (!dataCid) throw new Error('missing data CID')

Expand Down
7 changes: 3 additions & 4 deletions src/middleware/withEgressClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { Space } from '@web3-storage/capabilities'
export function withEgressClient(handler) {
return async (req, env, ctx) => {
const egressClient = await create(env, ctx)
debugger
return handler(req, env, { ...ctx, egressClient })
}
}
Expand Down Expand Up @@ -82,10 +81,10 @@ async function connect(serverUrl, principal) {
async function record(space, resource, bytes, servedAt, connection, ctx) {
const egressRecord = Space.egressRecord
const invoke = egressRecord.invoke.bind(egressRecord)

debugger
const invocation = invoke({
issuer: ctx.gatewayIdentity,
audience: ctx.gatewayIdentity, // TODO should it be the upload service DID?
audience: ctx.gatewayIdentity,
with: SpaceDID.from(space),
nb: {
resource,
Expand All @@ -94,7 +93,7 @@ async function record(space, resource, bytes, servedAt, connection, ctx) {
},
proofs: ctx.delegationProofs ? ctx.delegationProofs : []
})

debugger
const res = await invocation.execute(connection)
if (res.out.error) {
console.error(`Failed to record egress for space ${space}`, res.out.error)
Expand Down
1 change: 0 additions & 1 deletion src/middleware/withEgressTracker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*/
export function withEgressTracker(handler) {
return async (req, env, ctx) => {
debugger
if (env.FF_EGRESS_TRACKER_ENABLED !== 'true') {
return handler(req, env, ctx)
}
Expand Down
1 change: 0 additions & 1 deletion src/middleware/withGatewayIdentity.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export function withGatewayIdentity(handler) {
const gatewaySigner = env.GATEWAY_PRINCIPAL_KEY
? ed25519.Signer.parse(env.GATEWAY_PRINCIPAL_KEY)
: await ed25519.Signer.generate()
debugger
return handler(req, env, { ...ctx, gatewaySigner, gatewayIdentity: gatewaySigner.withDID(GATEWAY_DID) })
}
}

0 comments on commit b045c81

Please sign in to comment.