Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions client/src/lib/oauth-state-machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,22 @@ export const oauthTransitions: Record<OAuthStep, StateTransition> = {
clientMetadata.scope = scopesSupported.join(" ");
}

const fullInformation = await registerClient(context.serverUrl, {
metadata,
clientMetadata,
});
// Try DCR first, with static client as fallback
let fullInformation;
try {
fullInformation = await registerClient(context.serverUrl, {
metadata,
clientMetadata,
});
context.provider.saveClientInformation(fullInformation);
} catch (dcrError) {
// DCR failed, fallback to preregistered client
fullInformation = await context.provider.clientInformation();
if (!fullInformation) {
throw dcrError;
}
}

context.provider.saveClientInformation(fullInformation);
context.updateState({
oauthClientInfo: fullInformation,
oauthStep: "authorization_redirect",
Expand Down