diff --git a/package-lock.json b/package-lock.json index c8f9414..b9144db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,7 @@ "standard": "^17.1.0", "tree-kill": "^1.2.2", "typescript": "^5.6.3", - "wrangler": "^3.85.0" + "wrangler": "^3.86.1" } }, "node_modules/@achingbrain/ip-address": { @@ -282,10 +282,42 @@ "node": ">=16.13" } }, + "node_modules/@cloudflare/workerd-darwin-64": { + "version": "1.20241106.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20241106.1.tgz", + "integrity": "sha512-zxvaToi1m0qzAScrxFt7UvFVqU8DxrCO2CinM1yQkv5no7pA1HolpIrwZ0xOhR3ny64Is2s/J6BrRjpO5dM9Zw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-darwin-arm64": { + "version": "1.20241106.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20241106.1.tgz", + "integrity": "sha512-j3dg/42D/bPgfNP3cRUBxF+4waCKO/5YKwXNj+lnVOwHxDu+ne5pFw9TIkKYcWTcwn0ZUkbNZNM5rhJqRn4xbg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16" + } + }, "node_modules/@cloudflare/workerd-linux-64": { - "version": "1.20241022.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20241022.0.tgz", - "integrity": "sha512-RsNc19BQJG9yd+ngnjuDeG9ywZG+7t1L4JeglgceyY5ViMNMKVO7Zpbsu69kXslU9h6xyQG+lrmclg3cBpnhYA==", + "version": "1.20241106.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20241106.1.tgz", + "integrity": "sha512-Ih+Ye8E1DMBXcKrJktGfGztFqHKaX1CeByqshmTbODnWKHt6O65ax3oTecUwyC0+abuyraOpAtdhHNpFMhUkmw==", "cpu": [ "x64" ], @@ -298,10 +330,42 @@ "node": ">=16" } }, + "node_modules/@cloudflare/workerd-linux-arm64": { + "version": "1.20241106.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20241106.1.tgz", + "integrity": "sha512-mdQFPk4+14Yywn7n1xIzI+6olWM8Ybz10R7H3h+rk0XulMumCWUCy1CzIDauOx6GyIcSgKIibYMssVHZR30ObA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16" + } + }, + "node_modules/@cloudflare/workerd-windows-64": { + "version": "1.20241106.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20241106.1.tgz", + "integrity": "sha512-4rtcss31E/Rb/PeFocZfr+B9i1MdrkhsTBWizh8siNR4KMmkslU2xs2wPaH1z8+ErxkOsHrKRa5EPLh5rIiFeg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16" + } + }, "node_modules/@cloudflare/workers-shared": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workers-shared/-/workers-shared-0.7.0.tgz", - "integrity": "sha512-LLQRTqx7lKC7o2eCYMpyc5FXV8d0pUX6r3A+agzhqS9aoR5A6zCPefwQGcvbKx83ozX22ATZcemwxQXn12UofQ==", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workers-shared/-/workers-shared-0.7.1.tgz", + "integrity": "sha512-46cP5FCrl3TrvHeoHLb5SRuiDMKH5kc9Yvo36SAfzt8dqJI/qJRoY1GP3ioHn/gP7v2QIoUOTAzIl7Ml7MnfrA==", "dev": true, "dependencies": { "mime": "^3.0.0", @@ -312,9 +376,9 @@ } }, "node_modules/@cloudflare/workers-types": { - "version": "4.20241022.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-4.20241022.0.tgz", - "integrity": "sha512-1zOAw5QIDKItzGatzCrEpfLOB1AuMTwVqKmbw9B9eBfCUGRFNfJYMrJxIwcse9EmKahsQt2GruqU00pY/GyXgg==" + "version": "4.20241112.0", + "resolved": "https://registry.npmjs.org/@cloudflare/workers-types/-/workers-types-4.20241112.0.tgz", + "integrity": "sha512-Q4p9bAWZrX14bSCKY9to19xl0KMU7nsO5sJ2cTVspHoypsjPUMeQCsjHjmsO2C4Myo8/LPeDvmqFmkyNAPPYZw==" }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", @@ -7487,6 +7551,20 @@ "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -9829,9 +9907,9 @@ } }, "node_modules/miniflare": { - "version": "3.20241022.0", - "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20241022.0.tgz", - "integrity": "sha512-x9Fbq1Hmz1f0osIT9Qmj78iX4UpCP2EqlZnA/tzj/3+I49vc3Kq0fNqSSKplcdf6HlCHdL3fOBicmreQF4BUUQ==", + "version": "3.20241106.0", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20241106.0.tgz", + "integrity": "sha512-PjOoJKjUUofCueQskfhXlGvvHxZj36UAJAp1DnquMK88MFF50zCULblh0KXMSNM+bXeQYA94Gj06a7kfmBGxPw==", "dev": true, "dependencies": { "@cspotcode/source-map-support": "0.8.1", @@ -9842,8 +9920,8 @@ "glob-to-regexp": "^0.4.1", "stoppable": "^1.1.0", "undici": "^5.28.4", - "workerd": "1.20241022.0", - "ws": "^8.17.1", + "workerd": "1.20241106.1", + "ws": "^8.18.0", "youch": "^3.2.2", "zod": "^3.22.3" }, @@ -12752,9 +12830,9 @@ } }, "node_modules/workerd": { - "version": "1.20241022.0", - "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20241022.0.tgz", - "integrity": "sha512-jyGXsgO9DRcJyx6Ovv7gUyDPc3UYC2i/E0p9GFUg6GUzpldw4Y93y9kOmdfsOnKZ3+lY53veSiUniiBPE6Q2NQ==", + "version": "1.20241106.1", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20241106.1.tgz", + "integrity": "sha512-1GdKl0kDw8rrirr/ThcK66Kbl4/jd4h8uHx5g7YHBrnenY5SX1UPuop2cnCzYUxlg55kPjzIqqYslz1muRFgFw==", "dev": true, "hasInstallScript": true, "bin": { @@ -12764,11 +12842,11 @@ "node": ">=16" }, "optionalDependencies": { - "@cloudflare/workerd-darwin-64": "1.20241022.0", - "@cloudflare/workerd-darwin-arm64": "1.20241022.0", - "@cloudflare/workerd-linux-64": "1.20241022.0", - "@cloudflare/workerd-linux-arm64": "1.20241022.0", - "@cloudflare/workerd-windows-64": "1.20241022.0" + "@cloudflare/workerd-darwin-64": "1.20241106.1", + "@cloudflare/workerd-darwin-arm64": "1.20241106.1", + "@cloudflare/workerd-linux-64": "1.20241106.1", + "@cloudflare/workerd-linux-arm64": "1.20241106.1", + "@cloudflare/workerd-windows-64": "1.20241106.1" } }, "node_modules/workerpool": { @@ -12778,13 +12856,13 @@ "dev": true }, "node_modules/wrangler": { - "version": "3.85.0", - "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-3.85.0.tgz", - "integrity": "sha512-r5YCWUaF4ApLnloNE6jHHgRYdFzYHoajTlC1tns42UzQ2Ls63VAqD3b0cxOqzDUfmlSb3skpmu0B0Ssi3QWPAg==", + "version": "3.86.1", + "resolved": "https://registry.npmjs.org/wrangler/-/wrangler-3.86.1.tgz", + "integrity": "sha512-ujN74lPQCQRsMcvf48WLLZUqOqUbJJzt5+Xm5T3tGrpRJLW+dTB0ffvT/e2DBBvHZ7R52ZzZdm1akyLPsZmZ9Q==", "dev": true, "dependencies": { "@cloudflare/kv-asset-handler": "0.3.4", - "@cloudflare/workers-shared": "0.7.0", + "@cloudflare/workers-shared": "0.7.1", "@esbuild-plugins/node-globals-polyfill": "^0.2.3", "@esbuild-plugins/node-modules-polyfill": "^0.2.2", "blake3-wasm": "^2.1.5", @@ -12792,7 +12870,7 @@ "date-fns": "^4.1.0", "esbuild": "0.17.19", "itty-time": "^1.0.6", - "miniflare": "3.20241022.0", + "miniflare": "3.20241106.0", "nanoid": "^3.3.3", "path-to-regexp": "^6.3.0", "resolve": "^1.22.8", @@ -12800,7 +12878,7 @@ "selfsigned": "^2.0.1", "source-map": "^0.6.1", "unenv": "npm:unenv-nightly@2.0.0-20241024-111401-d4156ac", - "workerd": "1.20241022.0", + "workerd": "1.20241106.1", "xxhash-wasm": "^1.0.1" }, "bin": { @@ -12814,7 +12892,7 @@ "fsevents": "~2.3.2" }, "peerDependencies": { - "@cloudflare/workers-types": "^4.20241022.0" + "@cloudflare/workers-types": "^4.20241106.0" }, "peerDependenciesMeta": { "@cloudflare/workers-types": { diff --git a/package.json b/package.json index a38880a..233be57 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "standard": "^17.1.0", "tree-kill": "^1.2.2", "typescript": "^5.6.3", - "wrangler": "^3.85.0" + "wrangler": "^3.86.1" }, "standard": { "ignore": [ diff --git a/scripts/delegate-serve.js b/scripts/delegate-serve.js index 75c10cd..2fe96e2 100644 --- a/scripts/delegate-serve.js +++ b/scripts/delegate-serve.js @@ -38,24 +38,24 @@ cli proofs = client.proofs([ { can: Space.contentServe.can, - with: spaceDID, + with: spaceDID } ]) } /** @type {import('@ucanto/client').Principal<`did:${string}:${string}`>} */ const gatewayIdentity = { - did: () => gatewayDID, + did: () => gatewayDID } // @ts-expect-error - The client still needs to be updated to support the capability type const delegation = await client.createDelegation(gatewayIdentity, [Space.contentServe.can], { expiration: Infinity, - proofs, + proofs }) await client.capability.access.delegate({ - delegations: [delegation], + delegations: [delegation] }) const carResult = await delegation.archive() diff --git a/src/index.js b/src/index.js index d5dc2e3..88134b5 100644 --- a/src/index.js +++ b/src/index.js @@ -46,7 +46,7 @@ import { NoopSpanProcessor } from '@opentelemetry/sdk-trace-base' const handler = { /** @type {Handler} */ - fetch(request, env, ctx) { + fetch (request, env, ctx) { console.log(request.method, request.url) const middleware = composeMiddleware( // Prepare the Context @@ -60,11 +60,15 @@ const handler = { withAuthToken, withLocator, withGatewayIdentity, + // TODO: replace this with a handler to fetch the real delegations withDelegationStubs, // Rate-limit requests withRateLimit, + // Fetch CAR data - Double-check why this can't be placed after the authorized space middleware + withCarBlockHandler, + // Authorize requests withAuthorizedSpace, @@ -73,7 +77,6 @@ const handler = { withEgressTracker, // Fetch data - withCarBlockHandler, withContentClaimsDagula, withFormatRawHandler, withFormatCarHandler, @@ -91,7 +94,7 @@ const handler = { * @param {Environment} env * @param {*} _trigger */ -function config(env, _trigger) { +function config (env, _trigger) { if (env.HONEYCOMB_API_KEY) { return { exporter: { @@ -103,7 +106,7 @@ function config(env, _trigger) { } return { spanProcessors: new NoopSpanProcessor(), - service: { name: 'freeway' }, + service: { name: 'freeway' } } } export default process.env.FF_TELEMETRY_ENABLED === 'true' @@ -113,7 +116,7 @@ export default process.env.FF_TELEMETRY_ENABLED === 'true' /** * @type {Middleware} */ -export function withFormatRawHandler(handler) { +export function withFormatRawHandler (handler) { return async (request, env, ctx) => { const { headers } = request const { searchParams } = ctx @@ -131,7 +134,7 @@ export function withFormatRawHandler(handler) { /** * @type {Middleware} */ -export function withFormatCarHandler(handler) { +export function withFormatCarHandler (handler) { return async (request, env, ctx) => { const { headers } = request const { searchParams } = ctx diff --git a/src/middleware/index.js b/src/middleware/index.js index 3966896..add1201 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -8,4 +8,4 @@ export { withLocator } from './withLocator.js' export { withEgressTracker } from './withEgressTracker.js' export { withEgressClient } from './withEgressClient.js' export { withDelegationStubs } from './withDelegationStubs.js' -export { withGatewayIdentity } from './withGatewayIdentity.js' \ No newline at end of file +export { withGatewayIdentity } from './withGatewayIdentity.js' diff --git a/src/middleware/withAuthorizedSpace.js b/src/middleware/withAuthorizedSpace.js index 326c21e..8fde9b5 100644 --- a/src/middleware/withAuthorizedSpace.js +++ b/src/middleware/withAuthorizedSpace.js @@ -2,7 +2,6 @@ import { Verifier } from '@ucanto/principal' import { ok, access, Unauthorized } from '@ucanto/validator' import { HttpError } from '@web3-storage/gateway-lib/util' import * as serve from '../capabilities/serve.js' -import { Schema } from '@ucanto/client' /** * @import * as Ucanto from '@ucanto/interface' @@ -103,7 +102,7 @@ const authorize = async (space, ctx) => { }) if (relevantDelegationsResult.error) return relevantDelegationsResult - + // Create an invocation of the serve capability. const invocation = await serve.transportHttp .invoke({ @@ -113,7 +112,7 @@ const authorize = async (space, ctx) => { nb: { token: ctx.authToken }, - proofs: relevantDelegationsResult.ok, + proofs: relevantDelegationsResult.ok }) .delegate() @@ -122,7 +121,7 @@ const authorize = async (space, ctx) => { capability: serve.transportHttp, authority: ctx.gatewayIdentity, principal: Verifier, - validateAuthorization: () => ok({}), + validateAuthorization: () => ok({}) }) if (accessResult.error) { return accessResult diff --git a/src/middleware/withDelegationStubs.js b/src/middleware/withDelegationStubs.js index a8a3687..b9ab550 100644 --- a/src/middleware/withDelegationStubs.js +++ b/src/middleware/withDelegationStubs.js @@ -54,20 +54,20 @@ export const withDelegationStubs = (handler) => async (request, env, ctx) => { locator: stubSpace && isDIDKey(stubSpace) ? { - locate: async (digest, options) => { - const locateResult = await ctx.locator.locate(digest, options) - if (locateResult.error) return locateResult - return { - ok: { - ...locateResult.ok, - site: locateResult.ok.site.map((site) => ({ - ...site, - space: stubSpace - })) + locate: async (digest, options) => { + const locateResult = await ctx.locator.locate(digest, options) + if (locateResult.error) return locateResult + return { + ok: { + ...locateResult.ok, + site: locateResult.ok.site.map((site) => ({ + ...site, + space: stubSpace + })) + } } } } - } : ctx.locator }) } diff --git a/src/middleware/withEgressClient.js b/src/middleware/withEgressClient.js index 6770c1a..5d8de9b 100644 --- a/src/middleware/withEgressClient.js +++ b/src/middleware/withEgressClient.js @@ -16,7 +16,7 @@ import { DID } from '@ucanto/core' * * @type {Middleware} */ -export function withEgressClient(handler) { +export function withEgressClient (handler) { return async (req, env, ctx) => { if (env.FF_EGRESS_TRACKER_ENABLED !== 'true') { return handler(req, env, ctx) @@ -30,10 +30,10 @@ export function withEgressClient(handler) { * Creates a EgressClient instance with the given environment and establishes a connection to the UCanto Server. * * @param {Environment} env - * @param {import('./withEgressClient.types.js').EgressClientContext} ctx + * @param {import('./withEgressClient.types.js').EgressClientContext} ctx * @returns {Promise} */ -async function create(env, ctx) { +async function create (env, ctx) { return { /** * Records the egress bytes for the given resource. @@ -45,7 +45,7 @@ async function create(env, ctx) { * @returns {Promise} */ record: async (space, resource, bytes, servedAt) => - record(space, resource, bytes, servedAt, env, ctx), + record(space, resource, bytes, servedAt, env, ctx) } } @@ -57,11 +57,11 @@ async function create(env, ctx) { * @param {import('@ucanto/client').Principal<`did:${string}:${string}`>} principal * */ -async function connect(serverUrl, principal) { +async function connect (serverUrl, principal) { const connection = await UCantoClient.connect({ id: principal, codec: CAR.outbound, - channel: HTTP.open({ url: new URL(serverUrl) }), + channel: HTTP.open({ url: new URL(serverUrl) }) }) return connection @@ -78,7 +78,7 @@ async function connect(serverUrl, principal) { * @param {import('./withEgressClient.types.js').EgressClientContext} ctx - The egress client context * @returns {Promise} */ -async function record(space, resource, bytes, servedAt, env, ctx) { +async function record (space, resource, bytes, servedAt, env, ctx) { const uploadServicePrincipal = DID.parse(env.UPLOAD_SERVICE_DID) const connection = await connect(env.UPLOAD_API_URL, uploadServicePrincipal) @@ -91,7 +91,7 @@ async function record(space, resource, bytes, servedAt, env, ctx) { bytes, servedAt: Math.floor(servedAt.getTime() / 1000) }, - proofs: ctx.delegationProofs, + proofs: ctx.delegationProofs }) const res = await invocation.execute(connection) if (res.out.error) { diff --git a/src/middleware/withEgressTracker.js b/src/middleware/withEgressTracker.js index 0f21a14..7fcca91 100644 --- a/src/middleware/withEgressTracker.js +++ b/src/middleware/withEgressTracker.js @@ -5,14 +5,14 @@ */ /** - * The egress tracking handler must be enabled after the rate limiting, authorized space, - * and egress client handlers, and before any handler that serves the response body. - * It uses the Space & Data CID of the served content to record the egress in the egress client, + * The egress tracking handler must be enabled after the rate limiting, authorized space, + * and egress client handlers, and before any handler that serves the response body. + * It uses the Space & Data CID of the served content to record the egress in the egress client, * and it counts the bytes served with a TransformStream to determine the egress amount. * * @type {Middleware} */ -export function withEgressTracker(handler) { +export function withEgressTracker (handler) { return async (req, env, ctx) => { if (env.FF_EGRESS_TRACKER_ENABLED !== 'true') { return handler(req, env, ctx) @@ -65,7 +65,7 @@ export function withEgressTracker(handler) { * @template {Uint8Array} T * @returns {TransformStream} - The created TransformStream. */ -function createByteCountStream(onClose) { +function createByteCountStream (onClose) { let totalBytes = 0 return new TransformStream({ @@ -75,7 +75,7 @@ function createByteCountStream(onClose) { * If an error occurs, it signals an error to the controller and logs it. * The bytes are not counted in case of enqueuing an error. */ - async transform(chunk, controller) { + async transform (chunk, controller) { try { controller.enqueue(chunk) totalBytes += chunk.byteLength @@ -92,7 +92,7 @@ function createByteCountStream(onClose) { * If an error occurs, the egress is not recorded. * NOTE: The flush function is NOT called in case of a stream error. */ - async flush() { + async flush () { onClose(totalBytes) } }) diff --git a/src/middleware/withGatewayIdentity.js b/src/middleware/withGatewayIdentity.js index 8646319..edad3e3 100644 --- a/src/middleware/withGatewayIdentity.js +++ b/src/middleware/withGatewayIdentity.js @@ -10,12 +10,12 @@ import { ed25519 } from '@ucanto/principal' * * @type {import('@web3-storage/gateway-lib').Middleware} */ -export function withGatewayIdentity(handler) { +export function withGatewayIdentity (handler) { return async (req, env, ctx) => { const gatewaySigner = env.GATEWAY_PRINCIPAL_KEY ? ed25519.Signer.parse(env.GATEWAY_PRINCIPAL_KEY) : await ed25519.Signer.generate() - + const gatewayIdentity = gatewaySigner.withDID( /** @type {`did:${string}:${string}`} */ (env.GATEWAY_SERVICE_DID) ) diff --git a/src/middleware/withRateLimit.js b/src/middleware/withRateLimit.js index f4f8337..0c74d89 100644 --- a/src/middleware/withRateLimit.js +++ b/src/middleware/withRateLimit.js @@ -21,7 +21,7 @@ import { RATE_LIMIT_EXCEEDED } from '../constants.js' * * @type {Middleware} */ -export function withRateLimit(handler) { +export function withRateLimit (handler) { return async (req, env, ctx) => { if (env.FF_RATE_LIMITER_ENABLED !== 'true') { return handler(req, env, ctx) @@ -42,7 +42,7 @@ export function withRateLimit(handler) { * @param {RateLimiterContext} ctx * @returns {RateLimitService} */ -function create(env, ctx) { +function create (env, ctx) { return { /** * @param {import('multiformats/cid').CID} cid @@ -82,7 +82,7 @@ function create(env, ctx) { * @returns {Promise} * @throws {Error} if no rate limit API is found */ -async function isRateLimited(rateLimitAPI, cid) { +async function isRateLimited (rateLimitAPI, cid) { if (!rateLimitAPI) { throw new Error('no rate limit API found') } @@ -101,7 +101,7 @@ async function isRateLimited(rateLimitAPI, cid) { * @param {RateLimiterContext} ctx * @returns {Promise} */ -async function getTokenMetadata(env, authToken, ctx) { +async function getTokenMetadata (env, authToken, ctx) { const cachedValue = await env.AUTH_TOKEN_METADATA.get(authToken) // TODO: we should implement an SWR pattern here - record an expiry in the metadata and if the expiry has passed, re-validate the cache after // returning the value @@ -123,7 +123,7 @@ async function getTokenMetadata(env, authToken, ctx) { * @param {string} s * @returns {import('./withRateLimit.types.js').TokenMetadata} */ -function decode(s) { +function decode (s) { // TODO should this be dag-json? return JSON.parse(s) } @@ -132,20 +132,19 @@ function decode(s) { * @param {import('./withRateLimit.types.js').TokenMetadata} m * @returns {string} */ -function encode(m) { +function encode (m) { // TODO should this be dag-json? return JSON.stringify(m) } - /** * TODO: implement this function * * @param {string} authToken * @returns {Promise} */ -async function locateTokenMetadata(authToken) { +async function locateTokenMetadata (authToken) { // TODO I think this needs to check the content claims service (?) for any claims relevant to this token // TODO do we have a plan for this? need to ask Hannah if the indexing service covers this? return undefined -} \ No newline at end of file +} diff --git a/test/unit/middleware/withAuthorizedSpace.spec.js b/test/unit/middleware/withAuthorizedSpace.spec.js index d740d4c..a3dac91 100644 --- a/test/unit/middleware/withAuthorizedSpace.spec.js +++ b/test/unit/middleware/withAuthorizedSpace.spec.js @@ -137,7 +137,7 @@ describe('withAuthorizedSpace', async () => { ]), delegationProofs: [], gatewaySigner, - gatewayIdentity, + gatewayIdentity } ) diff --git a/test/unit/middleware/withEgressTracker.spec.js b/test/unit/middleware/withEgressTracker.spec.js index d4817cd..ea3dcfa 100644 --- a/test/unit/middleware/withEgressTracker.spec.js +++ b/test/unit/middleware/withEgressTracker.spec.js @@ -23,7 +23,7 @@ const env = /** @satisfies {EgressTrackerEnvironment} */ ({ DEBUG: 'true', - FF_EGRESS_TRACKER_ENABLED: 'true', + FF_EGRESS_TRACKER_ENABLED: 'true' }) const recordEgressMock = sinon.fake() @@ -39,7 +39,7 @@ const EgressClient = () => { } return { - record: recordEgressMock, + record: recordEgressMock } } const gatewaySigner = (await ed25519.Signer.generate()).signer