Skip to content

Commit

Permalink
fix: prefetch crash (#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
zibs authored Aug 1, 2024
1 parent ae5fa46 commit 438d512
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-lies-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-native-app-auth': patch
---

fix hard crash if config object was incorrect
12 changes: 7 additions & 5 deletions packages/react-native-app-auth/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@ import base64 from 'react-native-base64';

const { RNAppAuth } = NativeModules;

const validateIssuerOrServiceConfigurationEndpoints = (issuer, serviceConfiguration) =>
const validateIssuer = issuer => typeof issuer === 'string' && issuer.length;
const validateIssuerOrServiceConfigurationEndpoints = (issuer, serviceConfiguration) => {
invariant(
typeof issuer === 'string' ||
validateIssuer(issuer) ||
(serviceConfiguration &&
typeof serviceConfiguration.authorizationEndpoint === 'string' &&
typeof serviceConfiguration.tokenEndpoint === 'string'),
'Config error: you must provide either an issuer or a service endpoints'
);
};
const validateIssuerOrServiceConfigurationRegistrationEndpoint = (issuer, serviceConfiguration) =>
invariant(
typeof issuer === 'string' ||
validateIssuer(issuer) ||
(serviceConfiguration && typeof serviceConfiguration.registrationEndpoint === 'string'),
'Config error: you must provide either an issuer or a registration endpoint'
);
const validateIssuerOrServiceConfigurationRevocationEndpoint = (issuer, serviceConfiguration) =>
invariant(
typeof issuer === 'string' ||
validateIssuer(issuer) ||
(serviceConfiguration && typeof serviceConfiguration.revocationEndpoint === 'string'),
'Config error: you must provide either an issuer or a revocation endpoint'
);
const validateIssuerOrServiceConfigurationEndSessionEndpoint = (issuer, serviceConfiguration) =>
invariant(
typeof issuer === 'string' ||
validateIssuer(issuer) ||
(serviceConfiguration && typeof serviceConfiguration.endSessionEndpoint === 'string'),
'Config error: you must provide either an issuer or an end session endpoint'
);
Expand Down

0 comments on commit 438d512

Please sign in to comment.