Skip to content

Commit

Permalink
feat: implement trust mark verify in js client
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmelati committed Jan 26, 2025
1 parent c99c2f2 commit 00d8b11
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import com.sphereon.oid.fed.client.fetch.FetchServiceAdapter
import com.sphereon.oid.fed.client.fetch.fetchService
import com.sphereon.oid.fed.client.services.entityConfigurationStatementService.EntityConfigurationStatementService
import com.sphereon.oid.fed.client.services.trustChainService.TrustChainService
import com.sphereon.oid.fed.client.types.ICryptoService
import com.sphereon.oid.fed.client.types.IFetchService
import com.sphereon.oid.fed.client.types.TrustChainResolveResponse
import com.sphereon.oid.fed.client.types.VerifyTrustChainResponse
import com.sphereon.oid.fed.client.services.trustMarkService.TrustMarkService
import com.sphereon.oid.fed.client.types.*
import com.sphereon.oid.fed.openapi.models.EntityConfigurationStatementDTO
import com.sphereon.oid.fed.openapi.models.Jwk
import kotlinx.coroutines.CoroutineScope
Expand Down Expand Up @@ -50,6 +48,7 @@ class FederationClientJS(

private val entityService = EntityConfigurationStatementService(context)
private val trustChainService = TrustChainService(context)
private val trustMarkService = TrustMarkService(context)
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default)

@JsName("resolveTrustChain")
Expand Down Expand Up @@ -86,4 +85,19 @@ class FederationClientJS(
entityService.fetchEntityConfigurationStatement(entityIdentifier)
}
}

@JsName("verifyTrustMark")
fun verifyTrustMarkJS(
trustMark: String,
trustAnchorConfig: EntityConfigurationStatementDTO,
currentTime: Int? = null
): Promise<TrustMarkValidationResponse> {
return scope.promise {
trustMarkService.validateTrustMark(
trustMark,
trustAnchorConfig,
currentTime?.toLong()
)
}
}
}

0 comments on commit 00d8b11

Please sign in to comment.