Skip to content

Commit

Permalink
fix: set client_id on authorization url
Browse files Browse the repository at this point in the history
  • Loading branch information
nklomp committed Jun 2, 2024
1 parent d51bf25 commit 04e7cb8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
11 changes: 7 additions & 4 deletions packages/client/lib/AuthorizationCodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const createAuthorizationRequestUrl = async ({
authorizationRequest: AuthorizationRequestOpts;
credentialOffer?: CredentialOfferRequestWithBaseUrl;
credentialConfigurationSupported?: Record<string, CredentialConfigurationSupportedV1_0_13>;
clientId?: string,
clientId?: string;
version?: OpenId4VCIVersion;
}): Promise<string> => {
function removeDisplayAndValueTypes(obj: any): void {
Expand All @@ -63,7 +63,10 @@ export const createAuthorizationRequestUrl = async ({
}

const { redirectUri } = authorizationRequest;
const client_id = clientId ?? authorizationRequest.clientId
const client_id = clientId ?? authorizationRequest.clientId;
if (!client_id) {
throw Error(`Cannot use PAR without a client_id value set`);
}
let { scope, authorizationDetails } = authorizationRequest;
const parMode = endpointMetadata?.credentialIssuerMetadata?.require_pushed_authorization_requests
? PARMode.REQUIRE
Expand Down Expand Up @@ -143,7 +146,7 @@ export const createAuthorizationRequestUrl = async ({
}),
authorization_details: JSON.stringify(handleAuthorizationDetails(endpointMetadata, authorizationDetails)),
...(redirectUri && { redirect_uri: redirectUri }),
...(client_id && { client_id }),
client_id,
...(credentialOffer?.issuerState && { issuer_state: credentialOffer.issuerState }),
scope,
};
Expand All @@ -168,7 +171,7 @@ export const createAuthorizationRequestUrl = async ({
}
} else {
debug(`PAR response: ${(parResponse.successBody, null, 2)}`);
queryObj = { request_uri: parResponse.successBody.request_uri };
queryObj = { client_id, request_uri: parResponse.successBody.request_uri };
}
}

Expand Down
11 changes: 6 additions & 5 deletions packages/common/lib/functions/IssuerMetadataUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,12 @@ export function getTypesFromCredentialSupported(
credentialSupported.format === 'jwt_vc_json-ld' ||
credentialSupported.format === 'ldp_vc'
) {
types = (credentialSupported.types
? (credentialSupported.types as string[])
: 'credential_definition' in credentialSupported
? credentialSupported.credential_definition?.type
: []) ?? [];
types =
(credentialSupported.types
? (credentialSupported.types as string[])
: 'credential_definition' in credentialSupported
? credentialSupported.credential_definition?.type
: []) ?? [];
} else if (credentialSupported.format === 'vc+sd-jwt') {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down

0 comments on commit 04e7cb8

Please sign in to comment.