Skip to content

Commit

Permalink
fix: redirect_uri or response_uri were not updated for new requests, …
Browse files Browse the repository at this point in the history
…resulting in recreating stale request objects
  • Loading branch information
nklomp committed Mar 4, 2024
1 parent 856b783 commit 3e3bcd7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/request-object/Payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const createRequestObjectPayload = async (opts: CreateAuthorizationReques
scope: payload.scope ?? Scope.OPENID,
//TODO implement /.well-known/openid-federation support in the OP side to resolve the client_id (URL) and retrieve the metadata
client_id: clientId ?? opts.requestObject.signature.did,
redirect_uri: payload.redirect_uri,
...(payload.redirect_uri && { redirect_uri: payload.redirect_uri }),
...(payload.response_uri && { response_uri: payload.response_uri }),
response_mode: payload.response_mode ?? ResponseMode.DIRECT_POST,
...(payload.id_token_hint && { id_token_hint: payload.id_token_hint }),
registration_uri: registration.clientMetadataOpts.reference_uri,
Expand Down
4 changes: 2 additions & 2 deletions src/rp/RP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,14 @@ export class RP {
throw Error(`A response or redirect URI is required at this point`);
} else {
if (responseURIType === 'redirect_uri') {
if (this._createRequestOptions?.requestObject?.payload && !this._createRequestOptions.requestObject?.payload?.redirect_uri) {
if (this._createRequestOptions?.requestObject?.payload) {
this._createRequestOptions.requestObject.payload.redirect_uri = responseURI;
}
if (!referenceURI && !this._createRequestOptions.payload?.redirect_uri) {
this._createRequestOptions.payload.redirect_uri = responseURI;
}
} else if (responseURIType === 'response_uri') {
if (this._createRequestOptions?.requestObject?.payload && !this._createRequestOptions.requestObject?.payload?.response_uri) {
if (this._createRequestOptions?.requestObject?.payload) {
this._createRequestOptions.requestObject.payload.response_uri = responseURI;
}
if (!referenceURI && !this._createRequestOptions.payload?.response_uri) {
Expand Down

0 comments on commit 3e3bcd7

Please sign in to comment.