From 1c84f55a7123c6aabacc18f225bc1327b8989608 Mon Sep 17 00:00:00 2001 From: Valdi Date: Thu, 15 Mar 2018 17:30:20 +0100 Subject: [PATCH] Full rework to use native components --- .babelrc | 7 +- .eslintrc.js | 67 +- .flowconfig | 97 - README.md | 407 ++-- android/build.gradle | 3 +- .../gradle/wrapper/gradle-wrapper.properties | 4 +- example/.buckconfig | 6 - example/index.android.js | 105 - example/index.ios.js | 105 - example/package.json | 13 - jsconfig.json | 16 + package.json | 17 +- src/__mocks__/async-storage.js | 17 + src/__mocks__/azure-auth.js | 30 + src/__mocks__/linking.js | 17 + src/__mocks__/react-native.js | 12 + .../__tests__/__snapshots__/auth.spec.js.snap | 73 + src/auth/__tests__/auth.spec.js | 173 ++ src/auth/__tests__/index.spec.js | 360 --- src/auth/authError.js | 6 +- src/auth/index.js | 102 +- src/index.js | 29 +- ...x.spec.js.snap => networking.spec.js.snap} | 71 +- .../{index.spec.js => networking.spec.js} | 41 +- src/networking/index.js | 37 +- .../__snapshots__/cache.spec.js.snap | 3 + src/token/__tests__/cache.spec.js | 22 + src/token/__tests__/scope.spec.js | 69 +- src/token/accessTokenItem.js | 32 + src/token/baseTokenItem.js | 56 + src/token/cache.js | 117 +- src/token/refreshTokenItem.js | 22 + src/token/scope.js | 112 +- src/types.js | 42 - src/utils/baseError.js | 9 +- src/utils/logger.js | 5 +- src/utils/validate.js | 2 +- src/webauth/ReactNativeAD.js | 281 --- src/webauth/__mocks__/auth0.js | 27 - src/webauth/__mocks__/linking.js | 17 - src/webauth/__mocks__/react-native.js | 9 - .../__snapshots__/agent.spec.js.snap | 2 +- src/webauth/__tests__/agent.spec.js | 20 +- src/webauth/index.js | 37 +- yarn.lock | 1929 ++++++++++++----- 45 files changed, 2555 insertions(+), 2073 deletions(-) delete mode 100644 .flowconfig delete mode 100644 example/.buckconfig delete mode 100644 example/index.android.js delete mode 100644 example/index.ios.js delete mode 100644 example/package.json create mode 100644 jsconfig.json create mode 100644 src/__mocks__/async-storage.js create mode 100644 src/__mocks__/azure-auth.js create mode 100644 src/__mocks__/linking.js create mode 100644 src/__mocks__/react-native.js create mode 100644 src/auth/__tests__/__snapshots__/auth.spec.js.snap create mode 100644 src/auth/__tests__/auth.spec.js delete mode 100644 src/auth/__tests__/index.spec.js rename src/networking/__tests__/__snapshots__/{index.spec.js.snap => networking.spec.js.snap} (66%) rename src/networking/__tests__/{index.spec.js => networking.spec.js} (76%) create mode 100644 src/token/__tests__/__snapshots__/cache.spec.js.snap create mode 100644 src/token/__tests__/cache.spec.js create mode 100644 src/token/accessTokenItem.js create mode 100644 src/token/baseTokenItem.js create mode 100644 src/token/refreshTokenItem.js delete mode 100644 src/types.js delete mode 100644 src/webauth/ReactNativeAD.js delete mode 100644 src/webauth/__mocks__/auth0.js delete mode 100644 src/webauth/__mocks__/linking.js delete mode 100644 src/webauth/__mocks__/react-native.js diff --git a/.babelrc b/.babelrc index a9ce136..bd33fab 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,8 @@ { - "presets": ["react-native"] + "presets": ["react-native"], + "plugins": [ + ["babel-plugin-transform-builtin-extend", { + "globals": ["Error", "Array"] + }] + ] } diff --git a/.eslintrc.js b/.eslintrc.js index ad3218a..cc1b054 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,7 +1,6 @@ module.exports = { "parser": "babel-eslint", - "plugins": [ - "flowtype" + "plugins": [ ], "env": { "es6": true, @@ -23,6 +22,7 @@ module.exports = { "warn", 4 ], + "no-console": 0, "linebreak-style": [ "error", "unix" @@ -34,67 +34,6 @@ module.exports = { "semi": [ "error", "never" - ], - "flowtype/boolean-style": [ - 2, - "boolean" - ], - "flowtype/define-flow-type": 1, - "flowtype/delimiter-dangle": [ - 2, - "never" - ], - "flowtype/generic-spacing": [ - 2, - "never" - ], - "flowtype/no-primitive-constructor-types": 2, - "flowtype/no-types-missing-file-annotation": 2, - "flowtype/no-weak-types": 0, - "flowtype/object-type-delimiter": [ - 2, - "comma" - ], - "flowtype/require-parameter-type": 2, - "flowtype/require-return-type": [ - 2, - "always", - { - "annotateUndefined": "never", - "excludeMatching": ["render"] - } - ], - "flowtype/require-valid-file-annotation": 2, - "flowtype/semi": [ - 2, - "always" - ], - "flowtype/space-after-type-colon": [ - 2, - "always" - ], - "flowtype/space-before-generic-bracket": [ - 2, - "never" - ], - "flowtype/space-before-type-colon": [ - 2, - "never" - ], - "flowtype/type-id-match": [ - 0, - "^([A-Z][a-z0-9]+)+$" - ], - "flowtype/union-intersection-spacing": [ - 2, - "always" - ], - "flowtype/use-flow-type": 1, - "flowtype/valid-syntax": 1 - }, - "settings": { - "flowtype": { - "onlyFilesWithFlowAnnotation": true - } + ] } }; \ No newline at end of file diff --git a/.flowconfig b/.flowconfig deleted file mode 100644 index baec12e..0000000 --- a/.flowconfig +++ /dev/null @@ -1,97 +0,0 @@ -[ignore] - -# We fork some components by platform. -.*/*.web.js -.*/*.android.js - -# Some modules have their own node_modules with overlap -.*/node_modules/node-haste/.* - -# Ugh -.*/node_modules/babel.* -.*/node_modules/babylon.* -.*/node_modules/invariant.* - -# Ignore react and fbjs where there are overlaps, but don't ignore -# anything that react-native relies on -.*/node_modules/fbjs/lib/Map.js -.*/node_modules/fbjs/lib/fetch.js -.*/node_modules/fbjs/lib/ExecutionEnvironment.js -.*/node_modules/fbjs/lib/ErrorUtils.js - -# Flow has a built-in definition for the 'react' module which we prefer to use -# over the currently-untyped source -.*/node_modules/react/react.js -.*/node_modules/react/lib/React.js -.*/node_modules/react/lib/ReactDOM.js - -.*/__mocks__/.* -.*/__tests__/.* - -.*/commoner/test/source/widget/share.js - -# Ignore commoner tests -.*/node_modules/commoner/test/.* - -# See https://github.com/facebook/flow/issues/442 -.*/react-tools/node_modules/commoner/lib/reader.js - -# Ignore jest -.*/node_modules/jest-cli/.* - -# Ignore Website -.*/website/.* - -# Ignore generators -.*/local-cli/generator.* - -# Ignore BUCK generated folders -.*\.buckd/ - -.*/node_modules/is-my-json-valid/test/.*\.json -.*/node_modules/iconv-lite/encodings/tables/.*\.json -.*/node_modules/y18n/test/.*\.json -.*/node_modules/spdx-license-ids/spdx-license-ids.json -.*/node_modules/spdx-exceptions/index.json -.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json -.*/node_modules/resolve/lib/core.json -.*/node_modules/jsonparse/samplejson/.*\.json -.*/node_modules/json5/test/.*\.json -.*/node_modules/ua-parser-js/test/.*\.json -.*/node_modules/builtin-modules/builtin-modules.json -.*/node_modules/binary-extensions/binary-extensions.json -.*/node_modules/url-regex/tlds.json -.*/node_modules/joi/.*\.json -.*/node_modules/isemail/.*\.json -.*/node_modules/tr46/.*\.json - - -[include] - -[libs] -node_modules/react-native/Libraries/react-native/react-native-interface.js -node_modules/react-native/flow -flow/ -node_modules/react-native-azure-ad/types.js - -[options] -module.system=haste - -esproposal.class_static_fields=enable -esproposal.class_instance_fields=enable - -munge_underscores=true - -module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' -module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\)$' -> 'RelativeImageStub' - -suppress_type=$FlowIssue -suppress_type=$FlowFixMe -suppress_type=$FixMe - -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-2]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-2]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ -suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy - -[version] -^0.66.0 diff --git a/README.md b/README.md index 62f8ec7..20694b8 100644 --- a/README.md +++ b/README.md @@ -1,324 +1,201 @@ # react-native-azure-auth -This project was originally forked from [https://github.com/wkh237/react-native-azure-ad](https://github.com/wkh237/react-native-azure-ad) and adapted to use the V2.0 version of the [Azure AD endponts](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-compare). - -************************************* - -An React Native module implements Azure AD V2.0 authentication flow using pure React Native API. You can use both web application flow and mobile application client_id with this module. - -* [Installation](#user-content-installation) -* [Usage](#user-content-usage-example) - * [Login](#user-content-login) - * [Logout](#user-content-logout) - * [RefreshToken](#user-content-refresh-token) -* [ADLoginView](#user-content-adloginviewwebview) -* [Class ReactNativeAD](#user-content-class-reactnativead) - * [Constructor](#user-content-constructor) - * [Properties](#user-content-properties) - * [config](#user-content-config-ADConfig) - * [credentials](#user-content-credentials-ADCredentials) - * [Frequently used methods](#user-content-frequently-used-methods) - * [getConfig ():ADConfig](#user-content-getconfig-adconfig) - * [getCredentials ():ADCredentials](#user-content-getcredentials-adcredentials) - * [assureToken (resource:string):Promise]() - * [Methods for internal mechanism](#user-content-methods-for-internal-mechanism) - * [getAccessToken (resource:string):string | null]() - * [saveCredentials (data:ADCredentials):Promise]() - * [refreshToken (resourceId:string):Promise]() - * [checkCredential (resourceId:string):Promise]() - * [grantAccessToken (grantType:string, params:any):Promise]() -* [Flow Types](#user-content-flow-types) +React Native library implementing Azure AD OAuth2 API + +## Preface + +This project was originally inspired by [https://github.com/auth0/react-native-azure-auth](https://github.com/auth0/react-native-azure-auth) and extensively re-worked to use the __V2.0__ version of the [Azure AD endponts](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-compare). +Also the token cache functionality is added. +`react-native-azure-auth` implements authentication flow using `fetch` API and native components. +You can use both web application flow and mobile (native) application client_id with this module. ## Installation -Install package from `npm` +Install `react-native-azure-auth` using [npm](https://www.npmjs.com) ```bash -npm install vmurin/react-native-azure-auth +npm install react-native-azure-auth --save ``` -react-native-azure-auth implements authentication flow using `fetch` API and `Webview` component in React Native, therefore there's no need to install Android and iOS native ADAL. - -## Usage Example - -### Login - -The following example will show an Azure authorize page in your app, when user successfully logged in, it triggers `onSuccess` method. - -```js - -import {ReactNativeAD, ADLoginView} from 'react-native-azure-auth' - -const CLIENT_ID = 'xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' - -class LandingView extends React.Component { - - constructor(props) { - super(props) - this.AzureADContext = { - client_id : CLIENT_ID, - // Optional - redirectUrl : 'http://localhost:8080', - // Optional - authority_host : 'https://login.microsoftonline.com/common/oauth2/authorize', - // Optional - tenant : 'common', - // Optional - prompt : 'none', - // This is required if client_id is a web application id - // but not recommended doing this way. - client_secret : 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', - resources : [ - 'https://graph.microsoft.com', - 'https://outlook.office365.com', - // ... more resources - ] - } - } - - render() { - - new ReactNativeAD({ - client_id: CLIENT_ID, - resources: [ - 'https://outlook.office365.com' - ]}) - - return - } - - onLoginSuccess(credentials) { - console.log(credentials[https://outlook.office365.com].access_token) - // use the access token .. - } - -} +Or via [yarn](https://yarnpkg.com/en/package/jest) +```bash +yarn add react-native-azure-auth ``` -### Logout +then you need to link the native module in `react-native-azure-auth` -When a ADLoginView has prop `needLogout` set to `true` it redirect user to AD logout page for logout. - -``` - +```bash +react-native link react-native-azure-auth ``` -### Refresh Token +### App Registration -Use `assureToken` method to assure `access_token` of specific resource is valid, when access token is expired, this method will attempt to refresh access token automatically and resolve renewed access token in promise. If it failed to renew the token, the access token in promise will be `undefined`, it means user may have to login again, so you might have to redirect user to ADLoginView for new authorization. +First, you will need to register your application with Microsoft Application Registration Portal. This will give you an Application ID for your application, as well as enable it to receive tokens. +1. Sign in to the [Microsoft Application Registration Portal](https://apps.dev.microsoft.com/). +1. Click **Add an App** in _Converged Application_ group. (You will also have the group _Azure AD only applications_ if you are logged in with a work or school account) +1. Enter a friendly name for the application, leave the checkbox "Let us help you get st arted" NOT selected and click on **"Create"** below to create the app. +1. Find the _Application ID_ value in **Properties** section, copy and save the value in a safe location. +1. In -Platforms- section click **Add Platform** +1. Choose _"Native Application"_ +1. Now add to **Userdefined Callback-URLs** the URL for needed platforms. See the URL format in section below. +1. The section Microsoft Graph Permissions is meant for admin consent only. You don't need to fill it out by app re gistration. +1. Click Save button below to complete the app registration. -``` -ReactNativeAD.getContext(CLIENT_ID).assureToken(RESOURCE_ID).then((token) => { +#### Callback URL(s) - // use token .. +Callback URLs are the URLs that Azure AD invokes after the authentication process. Azure routes your application back to this URL and appends additional parameters to it, including a token. Since callback URLs can be manipulated, you will need to add your application's URL to your apps's **Userdefined Callback-URLs**. This will enable Azure to recognize these URLs as valid. If omitted, authentication will not be successful. -}) +##### iOS +```text +{YOUR_BUNDLE_IDENTIFIER}://${YOUR_BUNDLE_IDENTIFIER}/ios/callback ``` -### ADLoginView:Webview +##### Android -`ADLoginView` is it's a wrapped [Webview](https://facebook.github.io/react-native/docs/webview.html#content) component, it will display the login page by given prop `context`, when user is authorized, it execute the function in prop `onSuccess`. +```text +{YOUR_APP_PACKAGE_NAME}://{YOUR_APP_PACKAGE_NAME}/android/callback +``` -#### props +### App Configuration +#### Android config -`style:object` **(opational)** +In the file `android/app/src/main/AndroidManifest.xml` you must make sure the **MainActivity** of the app has a **launchMode** value of `singleTask` and that it has the following intent filter: -Additional styles of the webview component. +```xml + + + + + + +``` -`context:ReactNativeAD` **Required** +The `applicationId` here should be the same as your app package name, and not the ID from MS App Portal. -Azure AD context instance that apply to this ADLoginView, it should be a `ReactNativeAD` instance, usually you will have one or more ReactNativeAD instances in your app, once you `new` a ReactNativeAD with a client_id in config, you can access the context globally in your this way +You would have the following **MainActivity** configuration: -```js -let ctx = ReactNativeAD.getContext('client-id-of-the-instance') +```xml + + + + + + + + + + + + ``` -`onSuccess:function` **(optional)** +> For more info please read [react native docs](https://facebook.github.io/react-native/docs/linking.html) -A function to execute when `ADLoginView` completes authorization flow. +#### iOS config -`needLogout:bool` **(optional)** +Inside the `ios` folder find the file `AppDelegate.[swift|m]` add the following to it -When it set to `true`, ADLoginView will logout user and redirect user to AD login page. +```objc +#import -`hideAfterLogin` **(optional)** +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url + sourceApplication:(NSString *)sourceApplication annotation:(id)annotation +{ + return [RCTLinkingManager application:application openURL:url + sourceApplication:sourceApplication annotation:annotation]; +} +``` -When this property set to `true`, ADLoginView will be hidden after logged in, in prevention of displaying an empty/error web page. +Inside the `ios` folder open the `Info.plist` and locate the value for `CFBundleIdentifier`, e.g. -`onURLChange` **(optional)** +```xml +CFBundleIdentifier +org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) +``` -A event listener which triggers when ADLoginView's URL change. +and then register a URL type entry using the value of `CFBundleIdentifier` as the value of `CFBundleURLSchemes` -### Class ReactNativeAD +```xml +CFBundleURLTypes + + + CFBundleTypeRole + None + CFBundleURLName + auth0 + CFBundleURLSchemes + + org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) + + + +``` -You will need to create at least one `ReactNativeAD` object in your application, the ReactNativeAD object stores, and update authentication information in [AsyncStorage](http://facebook.github.io/react-native/releases/0.25/docs/asyncstorage.html#asyncstorage) automatically, it also provides several API for access theses informations. +> The value `org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)` is the default for apps created with React Native CLI, you may have a different value. -#### Constructor +For more info please read [react native docs](https://facebook.github.io/react-native/docs/linking.html) -To create a ReactNativeAD instance you have to give a configuration object as the first argument of constructor. Once the ReactNativeAD object created, you can access it globally in your application like this : +## Usage ```js +import AzureAuth from 'react-native-azure-auth'; -new ReactNativeAD({ - client_id: 'client-id-#1', - resources: [ - 'https://outlook.office365.com' - ]}) - -// this will return the object we created above -let ctx = ReactNativeAD.getContext('client-id-#1') -// use the stored context -ctx.assureToken('https://outlook.office365.com').then((token) => { - ... -}) - - +const azureAuth = new AzureAuth({ + clientId: 'YOUR_CLIENT_ID' +}); ``` -The configuration object contains the following properties : - -`client_id:string` **Required** - -The application `client_id`, this property is required, it's also the identifier of each ReactNativeAD context. - -`redirect_uri:string` **Optional** - -An url that ADLoginView will be redirect when login success, this property is optional. - -`authority_host:string` **Optional** - -The url of authorization page, if not specified, it will use `https://login.microsoftonline.com//oauth2/authorize` by default, where `` will be replaced with property `tenant`, if the default tenant is `common`. - -`tenant:string` **Optional** - -The tenant id of application. - -`prompt:string` **Optional** - -Indicates the type of user interaction that is required. The only valid values are 'login', 'none' and 'consent'. For details, please refer to [this](https://docs.microsoft.com/en-us/azure/active-directory/active-directory-protocols-openid-connect-code) documentation. - -`client_secret:string` **Required if use web application client_id** - -This property is only required when your application uses a web application client_id, **but it is not recommended to do this way, because store client_secret in application could be dangerous**. - -`resouces:Array` **Required** - -A list of Azure AD resource endpoints, once user has authorized ADLoginView will try to acquire access token and related information of each resource endpoint you specified in this property. - - -#### Properties - -[`config:[ADConfig]`](#user-content-adconfig) - -This property stores configurations (such as client_id, resources ..) of a ReactNativeAD instance. +### Authorization with user interaction -[`credentials:[ADCredentials]`](#user-content-adcredentials) - -This property stores acquired credential informatio for each resource endpoint. It a hash map structured data, with resource id as key, and a [ReactNativeADCredential](#user-content-ReactNativeADCredential) object as value. - -### Frequently used methods - -#### getConfig ():[ADConfig](#user-content-adconfig) - -This method returns the ReactNativeAD instance's `config` property. - -#### getCredentials ()`:[ADCredentials](#user-content-adcredentials) - -This method returns the ReactNativeAD instance's `credentials` property. - -#### getAccessToken(resouceId:string):string | null - -Get access token by given resource id, if no corresponding token exists returns null. - -#### assureToken(resource:string):Promise - -Assure that access_token of a resource is valid, when access token is expired, this method will attempt to refresh access token automatically and resolve renewed access token in promise. If it failed to renew the token, the access token in promise will be `undefined`, it means user may have to login again, so you might have to redirect user to ADLoginView for new authorization. - -### Methods for internal mechanism - -#### saveCredentials(data:ADCredentials):Promise - -This method replace the ReactNativeAD instance's `credentials` property with the object in `data` argument. It will also save the each entry in `data` into AsyncStorage, with key = .. For example, if client_id of this ReactNativeAD instance is `eabc-123` and one of the entry's key is `http://graph.microsoft.com`(aka. resource id), then the data in this entry will be stored in AsyncStorage with key `eabc-123.http://graph.microsoft.com`. - -#### refreshToken(resourceId:string):Promise - -Refresh token of the resource, when credentials is empty, it will try to update access token for resource. The access token in promise is possible to be `undefined`, it means user may have to login again, so you might have to redirect user to ADLoginView for new authorization. - -#### checkCredential(resourceId:string):Promise - -Check credentials of the resource exist or not. - -#### grantAccessToken(grantType:string, params:any):Promise - -Get access_token by given `grant_type` and params, when this process success, it stores credentials in format of `ReactNativeADCredentials`, in both ReactNativeAD.credentials and AsyncStorage. - -### Flow Types - -#### ADConfig - -``` -{ - client_secret : string | null, - client_id : string | null, - redirect_uri : string | null, - tenant : string | null, - prompt : string | null, - resources : Array | null, -} +```js + try { + let tokens = await azureAuth.webAuth.authorize({scope: 'openid profile User.Read Mail.Read' }) + this.setState({ accessToken: tokens.accessToken }); + let info = await azureAuth.auth.msGraphRequest({token: tokens.accessToken, path: '/me'}) + this.setState({ user: info.displayName, userId: tokens.userId }) + } catch (error) { + console.log(error) + } ``` -#### ADCredentials +### Silent authorization -``` -{ - [key:string] : ReactNativeADCredential | null -} +```js + try { + // Try to get cached token or refresh an expired ones + let tokens = await azureAuth.auth.acquireTokenSilent({scope: 'Mail.Read', userId: this.state.userId}) + if (!tokens) { + // No cached tokens or the requested scope defines new not yet consented permissions + // Open a window for user interaction + tokens = await azureAuth.webAuth.authorize({scope: 'Mail.Read'}) + } + let mails = await azureAuth.auth.msGraphRequest({token: tokens.accessToken, path: '/me/mailFolders/Inbox/messages'}) + } catch (error) { + console.log(error) + } ``` -#### GrantTokenResp +## Issue Reporting -``` -{ - resource : string, - response : Object -} -``` +If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. -#### ReactNativeADConfig +## Author -``` -{ - client_id : string, - redirect_uri? : string, - authority_host : string, - tenant : string, - client_secret : string, - resources : any, - onSuccess : Function, -} -``` +[Vladimir Murin](https://github.com/vmurin) -#### ReactNativeADCredential -``` -{ - access_token : string, - expires_in : number, - expires_on : number, - id_token : string, - not_before : number, - pwd_exp : string, - pwd_url : string, - refresh_token : string, - resource : string, - scope : string, - token_type : 'Bearer' -} -``` +## License + +This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info. diff --git a/android/build.gradle b/android/build.gradle index b6a9220..dbaa9fc 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -5,10 +5,11 @@ project.ext { buildscript { repositories { jcenter() + google() } dependencies { - classpath 'com.android.tools.build:gradle:1.3.1' + classpath 'com.android.tools.build:gradle:3.0.1' } } diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties index 7ef781f..1fa20dd 100644 --- a/android/gradle/wrapper/gradle-wrapper.properties +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat May 20 15:53:53 ART 2017 +#Wed Feb 21 23:07:04 CET 2018 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip diff --git a/example/.buckconfig b/example/.buckconfig deleted file mode 100644 index 934256c..0000000 --- a/example/.buckconfig +++ /dev/null @@ -1,6 +0,0 @@ - -[android] - target = Google Inc.:Google APIs:23 - -[maven_repositories] - central = https://repo1.maven.org/maven2 diff --git a/example/index.android.js b/example/index.android.js deleted file mode 100644 index 1265bac..0000000 --- a/example/index.android.js +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Sample React Native App - * https://github.com/facebook/react-native - * @flow - */ - -import React, { - AppRegistry, - Component, - StyleSheet, - Text, - View -} from 'react-native'; - -import {ReactNativeAD, ADLoginView, Logger} from 'react-native-azure-ad' - -Logger.setLevel('TRACE') - -const config = { - client_id : 'client-id-of-your-app', - // redirectUrl : 'http://localhost:8080(optional)', - // authorityHost : 'https://login.microsoftonline.com//oauth2/authorize(optional)', - // tenant : 'common(optional)', - // client_secret : 'client-secret-of-your-app(optional)', - resources : [ - 'https://graph.microsoft.com', - 'https://outlook.office.com', - 'https://outlook.office365.com', - 'https://wiadvancetechnology.sharepoint.com', - 'https://graph.windows.net', - ] -} - -class RNAzureAD extends Component { - - - constructor(props) { - super(props) - new ReactNativeAD(config) - } - - render() { - return ( - - -