Skip to content

Commit

Permalink
chore: redirectUri fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderPostma committed Oct 2, 2024
1 parent 6900e09 commit b10e7a4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion packages/siop-oid4vp/lib/authorization-request/Payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const createAuthorizationRequestPayload = async (
...(state && { state }),
...(registration.payload && isTarget(PropertyTarget.AUTHORIZATION_REQUEST, registration.clientMetadataOpts.targets) ? registration.payload : {}),
...(claims && { claims }),
...(opts.redirectUri && { redirect_uri: opts.redirectUri })
...(opts.requestObject.payload?.redirectUri && { redirect_uri: opts.requestObject.payload.redirectUri })
}

return removeNullUndefined(authRequestPayload)
Expand Down
1 change: 0 additions & 1 deletion packages/siop-oid4vp/lib/authorization-request/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ interface AuthorizationRequestCommonOpts<CT extends ClaimPayloadCommonOpts> {
payload?: AuthorizationRequestPayloadOpts<CT>
requestObject: RequestObjectOpts<CT>
uriScheme?: Schema | string // Use a custom scheme for the URI. By default openid:// will be used
redirectUri?: string;
}

export type AuthorizationRequestOptsVID1 = AuthorizationRequestCommonOpts<ClaimPayloadOptsVID1>
Expand Down
10 changes: 3 additions & 7 deletions packages/siop-oid4vp/lib/rp/RP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,12 @@ export class RP {
responseURIType?: ResponseURIType
}): Promise<URI> {
const authorizationRequestOpts = this.newAuthorizationRequestOpts(opts)
if(authorizationRequestOpts.redirectUri !== undefined) {
authorizationRequestOpts.redirectUri = authorizationRequestOpts.redirectUri
if(authorizationRequestOpts.requestObject.payload?.redirectUri !== undefined) {
authorizationRequestOpts.requestObject.payload.redirectUri = authorizationRequestOpts.requestObject.payload.redirectUri
.replace(':correlation_id', opts.correlationId)
.replace(':correlationId', opts.correlationId)
if(typeof(opts.state) === 'string') {
authorizationRequestOpts.redirectUri = authorizationRequestOpts.redirectUri.replace(':state', opts.state)
authorizationRequestOpts.requestObject.payload.redirectUri = authorizationRequestOpts.requestObject.payload.redirectUri.replace(':state', opts.state)
}
}

Expand Down Expand Up @@ -302,10 +302,6 @@ export class RP {
newOpts.requestObject.payload.claims = { ...newOpts.requestObject.payload.claims, ...claimsWithTarget.propertyValue }
}
}

if(this._createRequestOptions.redirectUri !== undefined) {
newOpts.redirectUri = this._createRequestOptions.redirectUri
}
return newOpts
}

Expand Down

0 comments on commit b10e7a4

Please sign in to comment.