@@ -18,10 +18,10 @@ function buildNilauthInstancesWithDids(instances: NilauthInstance[]): NilauthIns
1818 } ) ) ;
1919}
2020
21- function extractRootIssuerDid ( envelope : Envelope ) : string {
21+ function extractRootIssuerDid ( envelope : Envelope ) : Did {
2222 const proofs = envelope . proofs ;
2323 const rootToken = proofs . length > 0 ? proofs [ proofs . length - 1 ] : envelope . nuc ;
24- return rootToken . payload . iss . didString ;
24+ return rootToken . payload . iss ;
2525}
2626
2727export function loadNucToken < P extends string = string , I extends Input = BlankInput , E extends AppEnv = AppEnv > (
@@ -139,14 +139,13 @@ export function loadSubjectAndVerifyAsBuilder<
139139 context,
140140 } ) ;
141141
142- // check revocations last because it's costly (in terms of network RTT)
142+ // Check revocations last because it's costly (in terms of network RTT)
143143 // Find the nilauth instance that issued the root token in the proof chain
144144 const rootIssuerDid = extractRootIssuerDid ( envelope ) ;
145- const matchingNilauth = nilauthInstances . find ( ( n ) => n . did . didString === rootIssuerDid ) ;
145+ const matchingNilauth = nilauthInstances . find ( ( n ) => Did . areEqual ( n . did , rootIssuerDid ) ) ;
146146
147147 if ( ! matchingNilauth ) {
148- // This shouldn't happen if validation passed, but handle defensively
149- log . error ( "No matching nilauth instance found for root issuer: %s" , rootIssuerDid ) ;
148+ log . error ( "No matching nilauth instance found for root issuer: %s" , rootIssuerDid . didString ) ;
150149 return c . text ( getReasonPhrase ( StatusCodes . UNAUTHORIZED ) , StatusCodes . UNAUTHORIZED ) ;
151150 }
152151
0 commit comments