Skip to content

Commit a01da03

Browse files
authored
Merge pull request #119 from FormidableLabs/feature/support-no-scopes
Feature/support no scopes
2 parents f2c2011 + 84b54fb commit a01da03

File tree

3 files changed

+1
-29
lines changed

3 files changed

+1
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ with optional overrides.
8484
* **clientId** - (`string`) _REQUIRED_ your client id on the auth server
8585
* **clientSecret** - (`string`) client secret to pass to token exchange requests. :warning: Read more about [client secrets](#note-about-client-secrets)
8686
* **redirectUrl** - (`string`) _REQUIRED_ the url that links back to your app with the auth code
87-
* **scopes** - (`array<string>`) _REQUIRED_ the scopes for your token, e.g. `['email', 'offline_access']`
87+
* **scopes** - (`array<string>`) the scopes for your token, e.g. `['email', 'offline_access']`.
8888
* **additionalParameters** - (`object`) additional parameters that will be passed in the authorization request.
8989
Must be string values! E.g. setting `additionalParameters: { hello: 'world', foo: 'bar' }` would add
9090
`hello=world&foo=bar` to the authorization request.

index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { NativeModules, Platform } from 'react-native';
33

44
const { RNAppAuth } = NativeModules;
55

6-
const validateScopes = scopes =>
7-
invariant(scopes && scopes.length, 'Scope error: please add at least one scope');
86
const validateIssuerOrServiceConfigurationEndpoints = (issuer, serviceConfiguration) =>
97
invariant(
108
typeof issuer === 'string' ||
@@ -34,7 +32,6 @@ export const authorize = ({
3432
serviceConfiguration,
3533
dangerouslyAllowInsecureHttpRequests = false,
3634
}) => {
37-
validateScopes(scopes);
3835
validateIssuerOrServiceConfigurationEndpoints(issuer, serviceConfiguration);
3936
validateClientId(clientId);
4037
validateRedirectUrl(redirectUrl);
@@ -69,7 +66,6 @@ export const refresh = (
6966
},
7067
{ refreshToken }
7168
) => {
72-
validateScopes(scopes);
7369
validateIssuerOrServiceConfigurationEndpoints(issuer, serviceConfiguration);
7470
validateClientId(clientId);
7571
validateRedirectUrl(redirectUrl);

index.spec.js

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,6 @@ describe('AppAuth', () => {
7878
}).toThrow('Config error: clientId must be a string');
7979
});
8080

81-
it('throws an error when no scopes are passed in', () => {
82-
expect(() => {
83-
authorize({ ...config, scopes: undefined });
84-
}).toThrow('Scope error: please add at least one scope');
85-
});
86-
87-
it('throws an error when an empty scope array is passed in', () => {
88-
expect(() => {
89-
authorize({ ...config, scopes: [] });
90-
}).toThrow('Scope error: please add at least one scope');
91-
});
92-
9381
it('calls the native wrapper with the correct args on iOS', () => {
9482
authorize(config);
9583
expect(mockAuthorize).toHaveBeenCalledWith(
@@ -206,18 +194,6 @@ describe('AppAuth', () => {
206194
}).toThrow('Please pass in a refresh token');
207195
});
208196

209-
it('throws an error when no scopes are passed in', () => {
210-
expect(() => {
211-
refresh({ ...config, scopes: undefined }, { refreshToken: 'such-token' });
212-
}).toThrow('Scope error: please add at least one scope');
213-
});
214-
215-
it('throws an error when an empty scope array is passed in', () => {
216-
expect(() => {
217-
refresh({ ...config, scopes: [] }, { refreshToken: 'such-token' });
218-
}).toThrow('Scope error: please add at least one scope');
219-
});
220-
221197
it('calls the native wrapper with the correct args on iOS', () => {
222198
refresh({ ...config }, { refreshToken: 'such-token' });
223199
expect(mockRefresh).toHaveBeenCalledWith(

0 commit comments

Comments
 (0)