|
17 | 17 | use SimpleSAML\Module\oidc\Services\NonceService; |
18 | 18 | use SimpleSAML\Module\oidc\Utils\RequestParamsResolver; |
19 | 19 | use SimpleSAML\Module\oidc\Utils\Routes; |
| 20 | +use SimpleSAML\Module\oidc\Utils\VciContextResolver; |
20 | 21 | use SimpleSAML\OpenID\Codebooks\AtContextsEnum; |
21 | 22 | use SimpleSAML\OpenID\Codebooks\ClaimsEnum; |
22 | 23 | use SimpleSAML\OpenID\Codebooks\CredentialFormatIdentifiersEnum; |
@@ -53,6 +54,7 @@ public function __construct( |
53 | 54 | protected readonly Did $did, |
54 | 55 | protected readonly IssuerStateRepository $issuerStateRepository, |
55 | 56 | protected readonly NonceService $nonceService, |
| 57 | + protected readonly VciContextResolver $vciContextResolver, |
56 | 58 | ) { |
57 | 59 | if (!$this->moduleConfig->getVciEnabled()) { |
58 | 60 | $this->loggerService->warning('Verifiable Credential capabilities not enabled.'); |
@@ -762,37 +764,10 @@ public function credential(Request $request): Response |
762 | 764 | } |
763 | 765 |
|
764 | 766 | if ($credentialFormatId === CredentialFormatIdentifiersEnum::VcSdJwt->value) { |
765 | | - // Always start with the VCDM 2.0 base context URL (mandatory). |
766 | | - $atContext = [AtContextsEnum::W3OrgNsCredentialsV2->value]; |
767 | | - |
768 | | - // If a JSON-LD context document is configured for this credential, |
769 | | - // append the module-hosted context URL so that verifiers can |
770 | | - // resolve the custom credential subject terms. |
771 | | - if ($this->moduleConfig->getVciCredentialJsonLdContextFor($resolvedCredentialIdentifier) !== null) { |
772 | | - $atContext[] = $this->routes->urlCredentialJsonLdContext($resolvedCredentialIdentifier); |
773 | | - } |
774 | | - |
775 | | - // Append any additional context URLs declared in the credential |
776 | | - // configuration's @context field (skipping the base W3C URL, |
777 | | - // which is already first in the list). |
778 | | - /** |
779 | | - * @psalm-suppress MixedArrayAccess |
780 | | - * @psalm-suppress MixedAssignment |
781 | | - */ |
782 | | - $configuredContexts = $resolvedCredentialConfiguration[ClaimsEnum::CredentialDefinition->value] |
783 | | - [ClaimsEnum::AtContext->value] ?? $resolvedCredentialConfiguration[ClaimsEnum::AtContext->value] ?? []; |
784 | | - if (is_array($configuredContexts)) { |
785 | | - /** @psalm-suppress MixedAssignment */ |
786 | | - foreach ($configuredContexts as $configuredContext) { |
787 | | - if ( |
788 | | - is_string($configuredContext) && |
789 | | - $configuredContext !== AtContextsEnum::W3OrgNsCredentialsV2->value && |
790 | | - !in_array($configuredContext, $atContext, true) |
791 | | - ) { |
792 | | - $atContext[] = $configuredContext; |
793 | | - } |
794 | | - } |
795 | | - } |
| 767 | + $atContext = $this->vciContextResolver->resolve( |
| 768 | + $resolvedCredentialIdentifier, |
| 769 | + $resolvedCredentialConfiguration, |
| 770 | + ); |
796 | 771 |
|
797 | 772 | $sdJwtPayload = [ |
798 | 773 | ClaimsEnum::AtContext->value => $atContext, |
@@ -839,6 +814,7 @@ public function credential(Request $request): Response |
839 | 814 | $this->loggerService->debug( |
840 | 815 | 'Verifiable credential issued successfully.', |
841 | 816 | ['token' => substr($token, 0, 20) . '...'], |
| 817 | + //['token' => $token], |
842 | 818 | ); |
843 | 819 | } |
844 | 820 |
|
|
0 commit comments