Skip to content

Commit

Permalink
fix(app-check): better validation of configuration
Browse files Browse the repository at this point in the history
some confusion came up while supporting users trying to adopt the new
style, this should help future intrepid developers
  • Loading branch information
mikehardy committed Feb 14, 2023
1 parent e0e9e3f commit df60d83
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/app-check/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,26 @@ class FirebaseAppCheckModule extends FirebaseModule {
}
this.native.setTokenAutoRefreshEnabled(options.isTokenAutoRefreshEnabled);

if (options.provider === undefined || options.provider.providerOptions === undefined) {
throw new Error('Invalid configuration: no provider or no provider options defined.');
}
if (Platform.OS === 'android') {
if (!isString(options.provider.providerOptions.android.provider)) {
throw new Error(
'Invalid configuration: no android provider configured while on android platform.',
);
}
return this.native.configureProvider(
options.provider.providerOptions.android.provider,
options.provider.providerOptions.android.debugToken,
);
}
if (Platform.OS === 'ios' || Platform.OS === 'macos') {
if (!isString(options.provider.providerOptions.apple.provider)) {
throw new Error(
'Invalid configuration: no apple provider configured while on apple platform.',
);
}
return this.native.configureProvider(
options.provider.providerOptions.apple.provider,
options.provider.providerOptions.apple.debugToken,
Expand Down

0 comments on commit df60d83

Please sign in to comment.