@@ -3,7 +3,7 @@ import type { YogaInitialContext } from "graphql-yoga";
33import * as jose from "jose" ;
44import type { DbService } from "../db/db.service" ;
55import type { MetaEnvelope } from "../db/types" ;
6- import { newTraceId , timed } from "../utils/timing" ;
6+ import { timed } from "../utils/timing" ;
77
88export type VaultContext = YogaInitialContext & {
99 currentUser : string | null ;
@@ -64,14 +64,9 @@ export class VaultAccessGuard {
6464 expiresAt : now + JWKS_TTL_MS ,
6565 } ;
6666 jwksCache . set ( jwksUrl , cached ) ;
67- } else {
68- console . log ( "[timing] guard.validateToken.jwksCacheHit" ) ;
6967 }
7068
71- const { payload } = await timed (
72- "guard.validateToken.jwtVerify" ,
73- ( ) => jose . jwtVerify ( token , cached ! . jwks ) ,
74- ) ;
69+ const { payload } = await jose . jwtVerify ( token , cached . jwks ) ;
7570
7671 return payload ;
7772 } catch ( error ) {
@@ -252,13 +247,6 @@ export class VaultAccessGuard {
252247 ) => Promise < any > ,
253248 ) {
254249 return async ( parent : T , args : Args , context : VaultContext ) => {
255- const traceId = newTraceId ( "op" ) ;
256- const opKind = args . id
257- ? "id-targeted"
258- : args . envelopeId
259- ? "envelope-targeted"
260- : "bulk" ;
261- console . log ( `[timing] ${ traceId } guard.middleware.begin ${ opKind } ` ) ;
262250 // Check if this is storeMetaEnvelope operation (has input with ontology, payload, acl)
263251 const isStoreOperation =
264252 args . input &&
@@ -269,20 +257,14 @@ export class VaultAccessGuard {
269257 ! args . id ; // storeMetaEnvelope doesn't have id, updateMetaEnvelopeById does
270258
271259 // CRITICAL: Validate authentication BEFORE executing any resolver
272- await timed (
273- "guard.validateAuthentication" ,
274- ( ) => this . validateAuthentication ( context , isStoreOperation ) ,
275- traceId ,
260+ await timed ( "guard.validateAuthentication" , ( ) =>
261+ this . validateAuthentication ( context , isStoreOperation ) ,
276262 ) ;
277263
278264 // For operations that don't require a specific meta envelope ID (bulk queries)
279265 if ( ! args . id && ! args . envelopeId ) {
280266 // Authentication validated, now execute resolver
281- const result = await timed (
282- "guard.resolver(bulk)" ,
283- ( ) => resolver ( parent , args , context ) ,
284- traceId ,
285- ) ;
267+ const result = await resolver ( parent , args , context ) ;
286268
287269 // If the result is an array
288270 if ( Array . isArray ( result ) ) {
@@ -307,29 +289,19 @@ export class VaultAccessGuard {
307289 const metaEnvelopeId = args . id || args . envelopeId ;
308290 if ( ! metaEnvelopeId ) {
309291 // Authentication validated, now execute resolver
310- const result = await timed (
311- "guard.resolver(no-id)" ,
312- ( ) => resolver ( parent , args , context ) ,
313- traceId ,
314- ) ;
292+ const result = await resolver ( parent , args , context ) ;
315293 return this . filterACL ( result ) ;
316294 }
317295
318296 // Check if envelope exists and user has access
319- const { hasAccess, exists } = await timed (
320- "guard.checkAccess" ,
321- ( ) => this . checkAccess ( metaEnvelopeId , context ) ,
322- traceId ,
297+ const { hasAccess, exists } = await timed ( "guard.checkAccess" , ( ) =>
298+ this . checkAccess ( metaEnvelopeId , context ) ,
323299 ) ;
324300
325301 // For update operations with input, allow in-place creation if envelope doesn't exist
326302 if ( ! exists && args . input ) {
327303 // Envelope doesn't exist for this eName - allow in-place creation
328- const result = await timed (
329- "guard.resolver(in-place-create)" ,
330- ( ) => resolver ( parent , args , context ) ,
331- traceId ,
332- ) ;
304+ const result = await resolver ( parent , args , context ) ;
333305 return this . filterACL ( result ) ;
334306 }
335307
@@ -343,11 +315,7 @@ export class VaultAccessGuard {
343315 }
344316
345317 // Execute resolver and filter ACL
346- const result = await timed (
347- "guard.resolver(targeted)" ,
348- ( ) => resolver ( parent , args , context ) ,
349- traceId ,
350- ) ;
318+ const result = await resolver ( parent , args , context ) ;
351319
352320 // If result is null (envelope not found), return null
353321 if ( result === null ) {
0 commit comments