Skip to content

Commit 44db431

Browse files
committed
add(provider): Fetch Criipto configuration on load
This will try to verify that the domain and client ID are correct, and throw if not.
1 parent df0bc36 commit 44db431

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/provider.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,20 @@ const CriiptoVerifyProvider = (props: CriiptoVerifyProviderOptions): React.React
217217
const configuration = await client.fetchOpenIDConfiguration();
218218
if (isSubscribed) setConfiguration(configuration);
219219
})();
220+
(async () => {
221+
try {
222+
// This tries to verify that the domain and client id are correct
223+
await client.fetchCriiptoConfiguration();
224+
} catch (error) {
225+
if (isSubscribed) {
226+
setResult(() => {
227+
// Throwing directly from the async function does nothing. But using a setState action
228+
// injects the error into the react render loop.
229+
throw error;
230+
});
231+
}
232+
}
233+
})();
220234

221235
return () => {
222236
isSubscribed = false;

0 commit comments

Comments
 (0)