Skip to content

Commit 6a95056

Browse files
committed
Refactor
1 parent b99b3d2 commit 6a95056

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

client/src/lib/oauth-state-machine.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,33 +89,26 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
8989
}
9090

9191
// Try DCR first, with static client as fallback
92+
let fullInformation;
9293
try {
93-
const fullInformation = await registerClient(context.serverUrl, {
94+
fullInformation = await registerClient(context.serverUrl, {
9495
metadata,
9596
clientMetadata,
9697
});
97-
9898
context.provider.saveClientInformation(fullInformation);
99-
context.updateState({
100-
oauthClientInfo: fullInformation,
101-
oauthStep: "authorization_redirect",
102-
});
103-
console.log({ fullInformation });
104-
return;
10599
} catch (dcrError) {
106-
console.error(dcrError);
107-
108100
// DCR failed, fallback to preregistered client
109-
const existingClientInfo = await context.provider.clientInformation();
110-
if (!existingClientInfo) {
101+
fullInformation = await context.provider.clientInformation();
102+
if (!fullInformation) {
111103
console.error("Neither dynamic client registration or preregistered client information was found");
112104
throw dcrError;
113105
}
114-
context.updateState({
115-
oauthClientInfo: existingClientInfo,
116-
oauthStep: "authorization_redirect",
117-
});
118106
}
107+
108+
context.updateState({
109+
oauthClientInfo: fullInformation,
110+
oauthStep: "authorization_redirect",
111+
});
119112
},
120113
},
121114

0 commit comments

Comments
 (0)