From 581835dd9fc0ba743439919dd60d01ad3b4a5c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Zg=C3=AErvaci?= Date: Fri, 12 Apr 2024 15:40:41 +0300 Subject: [PATCH] Improve documentation (#17) * docs: add licence Signed-off-by: andrei-zgirvaci * docs: add discord link Signed-off-by: andrei-zgirvaci * docs: add readme for packages Signed-off-by: andrei-zgirvaci * docs: add the main Readme Signed-off-by: andrei-zgirvaci * refactor: replace the deprecated `exclude` method Signed-off-by: andrei-zgirvaci * docs: improve the documentation Signed-off-by: andrei-zgirvaci * chore: remove the autogenerated `api` files Signed-off-by: andrei-zgirvaci * refactor: reorder providers Signed-off-by: andrei-zgirvaci * docs: improve documentation Signed-off-by: andrei-zgirvaci * docs: add documentation for docusaurus Signed-off-by: andrei-zgirvaci * docs: mention limitations for google Signed-off-by: andrei-zgirvaci * docs: mention limitations for microsoft Signed-off-by: andrei-zgirvaci * docs: improve description & add features section Signed-off-by: andrei-zgirvaci --------- Signed-off-by: andrei-zgirvaci --- LICENSE | 201 ++++++++++++++++++ README.md | 59 +++-- apps/sample-app/android/app/build.gradle | 2 +- apps/sample-app/src/app/SignedInProvider.tsx | 6 +- docs/docs/.gitignore | 2 + docs/docs/api/_category_.yml | 1 - docs/docs/api/classes/_category_.yml | 2 - docs/docs/api/classes/core_src.AuthModule.md | 154 -------------- docs/docs/api/index.md | 32 --- docs/docs/api/modules.md | 16 -- docs/docs/api/modules/_category_.yml | 2 - docs/docs/api/modules/core_src.md | 46 ---- docs/docs/api/modules/plugin_dropbox_src.md | 17 -- docs/docs/api/modules/plugin_facebook_src.md | 17 -- docs/docs/api/modules/plugin_google_src.md | 17 -- docs/docs/api/modules/plugin_microsoft_src.md | 17 -- docs/docs/core.mdx | 9 + docs/docs/dropbox.mdx | 9 + docs/docs/facebook.mdx | 9 + docs/docs/getting-started.md | 171 ++++++++++++++- docs/docs/google.mdx | 9 + docs/docs/microsoft.mdx | 9 + docs/docusaurus.config.ts | 34 +-- docs/sidebars.ts | 6 +- docs/tsconfig.json | 2 +- packages/core/README.md | 41 ++++ packages/core/src/AuthModule.ts | 25 +++ packages/core/src/index.tsx | 5 + packages/plugin-dropbox/README.md | 53 +++++ packages/plugin-dropbox/src/index.tsx | 5 + packages/plugin-facebook/README.md | 54 +++++ packages/plugin-facebook/src/index.tsx | 5 + packages/plugin-google/README.md | 59 +++++ packages/plugin-google/src/index.tsx | 5 + packages/plugin-microsoft/README.md | 65 ++++++ packages/plugin-microsoft/src/index.tsx | 5 + 36 files changed, 809 insertions(+), 362 deletions(-) create mode 100644 LICENSE create mode 100644 docs/docs/.gitignore delete mode 100644 docs/docs/api/_category_.yml delete mode 100644 docs/docs/api/classes/_category_.yml delete mode 100644 docs/docs/api/classes/core_src.AuthModule.md delete mode 100644 docs/docs/api/index.md delete mode 100644 docs/docs/api/modules.md delete mode 100644 docs/docs/api/modules/_category_.yml delete mode 100644 docs/docs/api/modules/core_src.md delete mode 100644 docs/docs/api/modules/plugin_dropbox_src.md delete mode 100644 docs/docs/api/modules/plugin_facebook_src.md delete mode 100644 docs/docs/api/modules/plugin_google_src.md delete mode 100644 docs/docs/api/modules/plugin_microsoft_src.md create mode 100644 docs/docs/core.mdx create mode 100644 docs/docs/dropbox.mdx create mode 100644 docs/docs/facebook.mdx create mode 100644 docs/docs/google.mdx create mode 100644 docs/docs/microsoft.mdx create mode 100644 packages/core/README.md create mode 100644 packages/plugin-dropbox/README.md create mode 100644 packages/plugin-facebook/README.md create mode 100644 packages/plugin-google/README.md create mode 100644 packages/plugin-microsoft/README.md diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 80a0b3b..66b856f 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,55 @@ -# React Native OMH Auth +

+ +
+
+

React Native OMH Auth

+

-React Native OMH Auth Core package +

+ NPM downloads + NPM version + License +

-## Installation +

+ Chat on Discord + Follow on Twitter +

-```bash -npm install --save @omh/react-native-auth-core -npm install --save @omh/react-native-auth-plugin-... -``` +--- -## Usage +**React Native OMH Auth** streamlines connecting your React Native app to authentication provider services by providing lightweight bridges to native OMH Auth SDKs on both iOS and Android. Supporting both Google Mobile Services (GMS) and non-GMS configurations, with a unified interface for easy incorporation of Google, Facebook, Microsoft, Dropbox and other supported third-party authentication providers. -```js -import {GoogleAuth} from '@omh/react-native-auth-google'; +## Features -await GoogleAuth.initialize(['openid', 'email', 'profile']); +- 📱 GMS and non-GMS support for all auth providers +- 🔗 Identical API across all providers +- 🌱 Easy configuration and setup +- ⚡️ Instant sign-in with native GMS, Facebook and Dropbox apps +- 🌐 Custom Tabs support for Android +- 💨 Lightweight modules -await googleAuthProvider.signIn(); -``` +## OMH Auth Modules + +This is the main directory of the mono-repo for React Native OMH Auth. If you're searching for a particular package, please click on the corresponding package link below. + +- [Core](/packages/core/README.md) +- [Google](/packages/plugin-google/README.md) +- [Facebook](/packages/plugin-facebook/README.md) +- [Microsoft](/packages/plugin-microsoft/README.md) +- [Dropbox](/packages/plugin-dropbox/README.md) + +## Documentation + +- [Quick Start](https://special-barnacle-93vn82m.pages.github.io/docs/getting-started) +- [Reference API](https://special-barnacle-93vn82m.pages.github.io/docs/api) ## Contributing -See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow. +- [Overview](https://special-barnacle-93vn82m.pages.github.io/docs/contributing) +- [Issues](https://github.com/openmobilehub/react-native-omh-auth/issues) +- [PRs](https://github.com/openmobilehub/react-native-omh-auth/pulls) + +## License + +- See [LICENSE](https://github.com/openmobilehub/react-native-omh-auth/blob/main/LICENSE) diff --git a/apps/sample-app/android/app/build.gradle b/apps/sample-app/android/app/build.gradle index bc3305f..7b12acb 100644 --- a/apps/sample-app/android/app/build.gradle +++ b/apps/sample-app/android/app/build.gradle @@ -141,7 +141,7 @@ android { // BUG: https://github.com/auth0/Auth0.Android/issues/598 packagingOptions { - exclude 'META-INF/DEPENDENCIES' + resources.excludes.add("META-INF/DEPENDENCIES") } } diff --git a/apps/sample-app/src/app/SignedInProvider.tsx b/apps/sample-app/src/app/SignedInProvider.tsx index fa427ca..a34eac6 100644 --- a/apps/sample-app/src/app/SignedInProvider.tsx +++ b/apps/sample-app/src/app/SignedInProvider.tsx @@ -25,15 +25,15 @@ export const getAuthProvider = async (provider: Providers) => { case PROVIDER_NAMES.FACEBOOK: await FacebookAuth.initialize({scopes: ['public_profile', 'email']}); return FacebookAuth; - case PROVIDER_NAMES.DROPBOX: - await DropboxAuth.initialize({scopes: ['account_info.read']}); - return DropboxAuth; case PROVIDER_NAMES.MICROSOFT: await MicrosoftAuth.initialize({ scopes: ['User.Read'], configFileName: 'ms_auth_config', }); return MicrosoftAuth; + case PROVIDER_NAMES.DROPBOX: + await DropboxAuth.initialize({scopes: ['account_info.read']}); + return DropboxAuth; } }; diff --git a/docs/docs/.gitignore b/docs/docs/.gitignore new file mode 100644 index 0000000..7a713f9 --- /dev/null +++ b/docs/docs/.gitignore @@ -0,0 +1,2 @@ +api/* +!api \ No newline at end of file diff --git a/docs/docs/api/_category_.yml b/docs/docs/api/_category_.yml deleted file mode 100644 index 24a4602..0000000 --- a/docs/docs/api/_category_.yml +++ /dev/null @@ -1 +0,0 @@ -label: "API" \ No newline at end of file diff --git a/docs/docs/api/classes/_category_.yml b/docs/docs/api/classes/_category_.yml deleted file mode 100644 index 55c7980..0000000 --- a/docs/docs/api/classes/_category_.yml +++ /dev/null @@ -1,2 +0,0 @@ -label: "Classes" -position: 3 \ No newline at end of file diff --git a/docs/docs/api/classes/core_src.AuthModule.md b/docs/docs/api/classes/core_src.AuthModule.md deleted file mode 100644 index 867fe92..0000000 --- a/docs/docs/api/classes/core_src.AuthModule.md +++ /dev/null @@ -1,154 +0,0 @@ ---- -id: "core_src.AuthModule" -title: "Class: AuthModule" -sidebar_label: "AuthModule" -custom_edit_url: null ---- - -[core/src](../modules/core_src.md).AuthModule - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `C` | [`BaseAuthConfig`](../modules/core_src.md#baseauthconfig) | - -## Constructors - -### constructor - -• **new AuthModule**\<`C`\>(`moduleName`): [`AuthModule`](core_src.AuthModule.md)\<`C`\> - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `C` | [`BaseAuthConfig`](../modules/core_src.md#baseauthconfig) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `moduleName` | `string` | - -#### Returns - -[`AuthModule`](core_src.AuthModule.md)\<`C`\> - -#### Defined in - -[core/src/AuthModule.ts:8](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/core/src/AuthModule.ts#L8) - -## Properties - -### authNativeModule - -• **authNativeModule**: `any` - -#### Defined in - -[core/src/AuthModule.ts:6](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/core/src/AuthModule.ts#L6) - -## Methods - -### getAccessToken - -▸ **getAccessToken**(): `Promise`\<`string`\> - -#### Returns - -`Promise`\<`string`\> - -#### Defined in - -[core/src/AuthModule.ts:26](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/core/src/AuthModule.ts#L26) - -___ - -### getUser - -▸ **getUser**(): `Promise`\<[`OmhUserProfile`](../modules/core_src.md#omhuserprofile)\> - -#### Returns - -`Promise`\<[`OmhUserProfile`](../modules/core_src.md#omhuserprofile)\> - -#### Defined in - -[core/src/AuthModule.ts:30](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/core/src/AuthModule.ts#L30) - -___ - -### initialize - -▸ **initialize**(`config`): `Promise`\<`void`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `config` | `C` | - -#### Returns - -`Promise`\<`void`\> - -#### Defined in - -[core/src/AuthModule.ts:18](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/core/src/AuthModule.ts#L18) - -___ - -### refreshAccessToken - -▸ **refreshAccessToken**(): `Promise`\<`string`\> - -#### Returns - -`Promise`\<`string`\> - -#### Defined in - -[core/src/AuthModule.ts:34](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/core/src/AuthModule.ts#L34) - -___ - -### revokeAccessToken - -▸ **revokeAccessToken**(): `Promise`\<`void`\> - -#### Returns - -`Promise`\<`void`\> - -#### Defined in - -[core/src/AuthModule.ts:38](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/core/src/AuthModule.ts#L38) - -___ - -### signIn - -▸ **signIn**(): `Promise`\<`void`\> - -#### Returns - -`Promise`\<`void`\> - -#### Defined in - -[core/src/AuthModule.ts:22](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/core/src/AuthModule.ts#L22) - -___ - -### signOut - -▸ **signOut**(): `Promise`\<`void`\> - -#### Returns - -`Promise`\<`void`\> - -#### Defined in - -[core/src/AuthModule.ts:42](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/core/src/AuthModule.ts#L42) diff --git a/docs/docs/api/index.md b/docs/docs/api/index.md deleted file mode 100644 index 8f11db1..0000000 --- a/docs/docs/api/index.md +++ /dev/null @@ -1,32 +0,0 @@ ---- -id: "index" -title: "react-native-omh-auth" -sidebar_label: "Readme" -sidebar_position: 0 -custom_edit_url: null ---- - -# React Native OMH Auth - -React Native OMH Auth Core package - -## Installation - -```bash -npm install --save @omh/react-native-auth-core -npm install --save @omh/react-native-auth-plugin-... -``` - -## Usage - -```js -import {GoogleAuth} from '@omh/react-native-auth-google'; - -await GoogleAuth.initialize(['openid', 'email', 'profile']); - -await googleAuthProvider.signIn(); -``` - -## Contributing - -See the [contributing guide](../contributing.mdx) to learn how to contribute to the repository and the development workflow. diff --git a/docs/docs/api/modules.md b/docs/docs/api/modules.md deleted file mode 100644 index 0442067..0000000 --- a/docs/docs/api/modules.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -id: "modules" -title: "react-native-omh-auth" -sidebar_label: "Table of Contents" -sidebar_position: 0.5 -hide_table_of_contents: true -custom_edit_url: null ---- - -## Modules - -- [core/src](modules/core_src.md) -- [plugin-dropbox/src](modules/plugin_dropbox_src.md) -- [plugin-facebook/src](modules/plugin_facebook_src.md) -- [plugin-google/src](modules/plugin_google_src.md) -- [plugin-microsoft/src](modules/plugin_microsoft_src.md) diff --git a/docs/docs/api/modules/_category_.yml b/docs/docs/api/modules/_category_.yml deleted file mode 100644 index 63f9c4e..0000000 --- a/docs/docs/api/modules/_category_.yml +++ /dev/null @@ -1,2 +0,0 @@ -label: "Modules" -position: 1 \ No newline at end of file diff --git a/docs/docs/api/modules/core_src.md b/docs/docs/api/modules/core_src.md deleted file mode 100644 index ccef017..0000000 --- a/docs/docs/api/modules/core_src.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -id: "core_src" -title: "Module: core/src" -sidebar_label: "core/src" -sidebar_position: 0 -custom_edit_url: null ---- - -## Classes - -- [AuthModule](../classes/core_src.AuthModule.md) - -## Type Aliases - -### BaseAuthConfig - -Ƭ **BaseAuthConfig**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `scopes` | `string`[] | - -#### Defined in - -[core/src/types.ts:1](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/core/src/types.ts#L1) - -___ - -### OmhUserProfile - -Ƭ **OmhUserProfile**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `email?` | `string` | -| `name?` | `string` | -| `profileImage?` | `string` | -| `surname?` | `string` | - -#### Defined in - -[core/src/types.ts:5](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/core/src/types.ts#L5) diff --git a/docs/docs/api/modules/plugin_dropbox_src.md b/docs/docs/api/modules/plugin_dropbox_src.md deleted file mode 100644 index 8a2489b..0000000 --- a/docs/docs/api/modules/plugin_dropbox_src.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -id: "plugin_dropbox_src" -title: "Module: plugin-dropbox/src" -sidebar_label: "plugin-dropbox/src" -sidebar_position: 0 -custom_edit_url: null ---- - -## Variables - -### default - -• `Const` **default**: [`AuthModule`](../classes/core_src.AuthModule.md)\<[`BaseAuthConfig`](core_src.md#baseauthconfig)\> - -#### Defined in - -[plugin-dropbox/src/index.tsx:4](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/plugin-dropbox/src/index.tsx#L4) diff --git a/docs/docs/api/modules/plugin_facebook_src.md b/docs/docs/api/modules/plugin_facebook_src.md deleted file mode 100644 index d84a9b0..0000000 --- a/docs/docs/api/modules/plugin_facebook_src.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -id: "plugin_facebook_src" -title: "Module: plugin-facebook/src" -sidebar_label: "plugin-facebook/src" -sidebar_position: 0 -custom_edit_url: null ---- - -## Variables - -### default - -• `Const` **default**: [`AuthModule`](../classes/core_src.AuthModule.md)\<[`BaseAuthConfig`](core_src.md#baseauthconfig)\> - -#### Defined in - -[plugin-facebook/src/index.tsx:4](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/plugin-facebook/src/index.tsx#L4) diff --git a/docs/docs/api/modules/plugin_google_src.md b/docs/docs/api/modules/plugin_google_src.md deleted file mode 100644 index 3fa7fe9..0000000 --- a/docs/docs/api/modules/plugin_google_src.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -id: "plugin_google_src" -title: "Module: plugin-google/src" -sidebar_label: "plugin-google/src" -sidebar_position: 0 -custom_edit_url: null ---- - -## Variables - -### default - -• `Const` **default**: [`AuthModule`](../classes/core_src.AuthModule.md)\<[`BaseAuthConfig`](core_src.md#baseauthconfig)\> - -#### Defined in - -[plugin-google/src/index.tsx:4](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/plugin-google/src/index.tsx#L4) diff --git a/docs/docs/api/modules/plugin_microsoft_src.md b/docs/docs/api/modules/plugin_microsoft_src.md deleted file mode 100644 index cfa4b90..0000000 --- a/docs/docs/api/modules/plugin_microsoft_src.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -id: "plugin_microsoft_src" -title: "Module: plugin-microsoft/src" -sidebar_label: "plugin-microsoft/src" -sidebar_position: 0 -custom_edit_url: null ---- - -## Variables - -### default - -• `Const` **default**: [`AuthModule`](../classes/core_src.AuthModule.md)\<`MicrosoftAuthConfig`\> - -#### Defined in - -[plugin-microsoft/src/index.tsx:6](https://github.com/openmobilehub/rn-omh-auth/blob/b43af64eae277675f57051591f993f84fd70cd48/packages/plugin-microsoft/src/index.tsx#L6) diff --git a/docs/docs/core.mdx b/docs/docs/core.mdx new file mode 100644 index 0000000..a401e64 --- /dev/null +++ b/docs/docs/core.mdx @@ -0,0 +1,9 @@ +--- +id: 'core' +title: '' +sidebar_label: 'Core' +--- + +import Readme from '../../packages/core/README.md'; + + diff --git a/docs/docs/dropbox.mdx b/docs/docs/dropbox.mdx new file mode 100644 index 0000000..72fce6e --- /dev/null +++ b/docs/docs/dropbox.mdx @@ -0,0 +1,9 @@ +--- +id: 'dropbox' +title: '' +sidebar_label: 'Dropbox' +--- + +import Readme from '../../packages/plugin-dropbox/README.md'; + + diff --git a/docs/docs/facebook.mdx b/docs/docs/facebook.mdx new file mode 100644 index 0000000..134bcd9 --- /dev/null +++ b/docs/docs/facebook.mdx @@ -0,0 +1,9 @@ +--- +id: 'facebook' +title: '' +sidebar_label: 'Facebook' +--- + +import Readme from '../../packages/plugin-facebook/README.md'; + + diff --git a/docs/docs/getting-started.md b/docs/docs/getting-started.md index edcb521..b92646c 100644 --- a/docs/docs/getting-started.md +++ b/docs/docs/getting-started.md @@ -6,20 +6,173 @@ sidebar_position: 1 React Native OMH Auth is a project that brings various native auth providers to React Native. It provides a single API to use different auth providers: -- Google via `@omh/react-native-auth-google` -- Facebook via `@omh/react-native-auth-facebook` -- Microsoft via `@omh/react-native-auth-microsoft` -- Dropbox via `@omh/react-native-auth-dropbox` +## Prerequisites + +Before getting started, the documentation assumes you are able to create a project with React Native. If you do not meet these prerequisites, follow the links below: + +[React Native - Setting up the development environment](https://reactnative.dev/docs/environment-setup) + +Additionally, the current versions of Android OMH libraries have a minimum Android API level requirement of **23**. In order for your Android application to build successfully, make sure that `minSdkVersion` is set to a value greater or equal to **23** in your [**android/build.gradle**](https://github.com/openmobilehub/react-native-omh-auth/blob/main/apps/sample-app/android/build.gradle#L4) file. + +## Compatibility + +| React Native | 2.0.0-beta | +| ------------ | ---------- | +| 0.73.6 | ✅ | ## Installation -To integrate React Native OMH Auth into your React Native project, you need to install the one of the plugins: +To integrate a React Native OMH Auth provider into your React Native project, you need to install one of the available libraries: + +| Provider | Package | +| --------- | ---------------------------------- | +| Google | `@omh/react-native-auth-google` | +| Facebook | `@omh/react-native-auth-facebook` | +| Microsoft | `@omh/react-native-auth-microsoft` | +| Dropbox | `@omh/react-native-auth-dropbox` | + +By running the following command: ```bash -npm add @omh/react-native-auth-* +npm add @omh/react-native-auth- +``` + +## Configuration + +Each provider requires you to specify different secrets. Please follow the individual provider configuration: + +- [Google](/packages/plugin-google/README.md#configuration) +- [Facebook](/packages/plugin-facebook/README.md#configuration) +- [Microsoft](/packages/plugin-microsoft/README.md#configuration) +- [Dropbox](/packages/plugin-dropbox/README.md#configuration) + +## Manual linking of the core package + +Each plugin requires that the `@omh/react-native-auth-core` module to be manually linked inside your Android application. Add the following line to your [**android/settings.gradle**](https://github.com/openmobilehub/react-native-omh-auth/blob/main/apps/sample-app/android/settings.gradle#L3) file: + +```gradle title="android/settings.gradle" {3} +rootProject.name = 'Example' +apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) +apply from: file("../node_modules/@omh/react-native-auth-core/android/native_modules.gradle") +include ':app' +includeBuild('../node_modules/@react-native/gradle-plugin') +``` + +## Usage + +:::info + +In this guide, we'll use the Google provider as an example. However, feel free to choose any other provider as the exposed methods are identical. They all inherit the [`AuthModule`](https://special-barnacle-93vn82m.pages.github.io/docs/api/classes/core_src.AuthModule#methods) from the [`@omh/react-native-auth-core`](https://github.com/openmobilehub/react-native-omh-auth/tree/main/packages/core), ensuring consistency across different providers. This means you won't need to learn any additional methods regardless of the provider you choose! + +::: + +### Initializing + +Before interacting with a provider, initialization is necessary. Each provider requires a specific configuration to be passed as an argument. + +```typescript +import GoogleAuthClient from '@omh/react-native-auth-google'; + +await GoogleAuthClient.initialize({scopes: ['openid', 'email', 'profile']}); ``` -### Requirements +### Sign in + +Initiates the sign-in process with the provider. + +```typescript +await GoogleAuthClient.signIn(); +``` + +### Get access token + +Retrieves the access token from the provider. + +```typescript +const accessToken = await GoogleAuthClient.getAccessToken(); +``` + +### Get user + +Obtains user information for the current signed-in user. Returns an object of type [`OmhUserProfile`](https://github.com/openmobilehub/react-native-omh-auth/blob/main/packages/core/src/types.ts#L5-L10). + +```typescript +type OmhUserProfile = { + name?: string; + surname?: string; + email?: string; + profileImage?: string; +}; + +const user: OmhUserProfile = await GoogleAuthClient.getUser(); +``` + +### Refresh access token + +Refreshes the access token if it has expired. + +```typescript +const newAccessToken = await GoogleAuthClient.refreshAccessToken(); +``` + +### Revoke access token + +Revokes the current access token. + +```typescript +await GoogleAuthClient.revokeAccessToken(); +``` + +### Sign out + +Initiates the sign-out process with the provider. + +```typescript +await GoogleAuthClient.signOut(); +``` + +For a more in depth view on the available methods, access the [Reference API](https://special-barnacle-93vn82m.pages.github.io/docs/api/classes/core_src.AuthModule#methods). + +## Sample app + +Explore the [sample app](/apps/sample-app) included in the repository to see the implementation of authentication with Google and other providers. + +## Troubleshooting + +### 2 files found with path 'META-INF/DEPENDENCIES' + +:::danger[Error] + +2 files found with path 'META-INF/DEPENDENCIES' from inputs:
\- ~/.gradle/caches/transforms-3/974cf06afa1f6a930c75c22e66ec0fcc/transformed/jetified-httpclient-4.5.13.jar
\- ~/.gradle/caches/transforms-3/435f87d6658aae4740f0a56a1a48eac1/transformed/jetified-httpcore-4.4.15.jar + +::: + +If you see the above error during the android build process, please add the following code snippet to your [**android/app/build.gradle**](https://github.com/openmobilehub/react-native-omh-auth/blob/main/apps/sample-app/android/app/build.gradle#L135-L137) file: + +```gradle title="android/app/build.gradle" {4-6} +android { + // ... other build settings + + packagingOptions { + resources.excludes.add("META-INF/DEPENDENCIES") + } +} +``` + +Please also check the related [GitHub issue](https://github.com/dropbox/dropbox-sdk-java/issues/517) for more context to the problem. + +### Unsupported class file major version 63 + +:::danger[Error] + +Failed to transform jackson-core-2.15.0.jar (com.fasterxml.jackson.core:jackson-core:2.15.0) to match attributes \{artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api\} + +::: + +If you see the above error during the android build process, please add the following code snippet to your [**android/gradle.properties**](https://github.com/openmobilehub/react-native-omh-auth/blob/main/apps/sample-app/android/gradle.properties#L43) file: + +```gradle title="android/gradle.properties" +android.jetifier.ignorelist=jackson-core,fastdoubleparser +``` -- [Node.js](https://nodejs.org/en/download/) version 20 or above and NPM -- A [React Native project](https://reactnative.dev/docs/environment-setup) with properly set up environment +Please also check the related [GitHub issue](https://github.com/auth0/Auth0.Android/issues/598) for more context to the problem. diff --git a/docs/docs/google.mdx b/docs/docs/google.mdx new file mode 100644 index 0000000..c641203 --- /dev/null +++ b/docs/docs/google.mdx @@ -0,0 +1,9 @@ +--- +id: 'google' +title: '' +sidebar_label: 'Google' +--- + +import Readme from '../../packages/plugin-google/README.md'; + + diff --git a/docs/docs/microsoft.mdx b/docs/docs/microsoft.mdx new file mode 100644 index 0000000..f44b5a9 --- /dev/null +++ b/docs/docs/microsoft.mdx @@ -0,0 +1,9 @@ +--- +id: 'microsoft' +title: '' +sidebar_label: 'Microsoft' +--- + +import Readme from '../../packages/plugin-microsoft/README.md'; + + diff --git a/docs/docusaurus.config.ts b/docs/docusaurus.config.ts index 7cb600f..3122ea6 100644 --- a/docs/docusaurus.config.ts +++ b/docs/docusaurus.config.ts @@ -71,12 +71,6 @@ const config: Config = { position: 'left', label: 'API', }, - // { - // type: 'docSidebar', - // sidebarId: 'advancedUsageSidebar', - // position: 'left', - // label: 'Advanced usage', - // }, { type: 'docSidebar', sidebarId: 'contributingSidebar', @@ -100,10 +94,6 @@ const config: Config = { label: 'Getting started', to: '/docs/getting-started', }, - // { - // label: 'Advanced usage', - // to: '/docs/advanced-usage', - // }, ], }, { @@ -122,6 +112,10 @@ const config: Config = { label: 'Twitter', href: 'https://twitter.com/openmobilehub', }, + { + label: 'Discord', + href: 'https://discord.com/invite/yTAFKbeVMw', + }, ], }, { @@ -164,8 +158,24 @@ const config: Config = { inIncludedFiles: true, replacements: [ { - pattern: ']\\(CONTRIBUTING.md\\)', - replace: '](../contributing.mdx)', + pattern: ']\\(/packages/core/README.md', + replace: '](../core.mdx', + }, + { + pattern: ']\\(/packages/plugin-google/README.md', + replace: '](../google.mdx', + }, + { + pattern: ']\\(/packages/plugin-facebook/README.md', + replace: '](../facebook.mdx', + }, + { + pattern: ']\\(/packages/plugin-microsoft/README.md', + replace: '](../microsoft.mdx', + }, + { + pattern: ']\\(/packages/plugin-dropbox/README.md', + replace: '](../dropbox.mdx', }, ], }, diff --git a/docs/sidebars.ts b/docs/sidebars.ts index 11ef5a0..13e204b 100644 --- a/docs/sidebars.ts +++ b/docs/sidebars.ts @@ -14,9 +14,13 @@ const sidebars: SidebarsConfig = { // By default, Docusaurus generates a sidebar from the docs folder structure gettingStartedSidebar: [ {type: 'doc', id: 'getting-started', label: 'Getting Started'}, + {type: 'doc', id: 'core', label: 'Core'}, + {type: 'doc', id: 'google', label: 'Google'}, + {type: 'doc', id: 'facebook', label: 'Facebook'}, + {type: 'doc', id: 'microsoft', label: 'Microsoft'}, + {type: 'doc', id: 'dropbox', label: 'Dropbox'}, ], apiSidebar: [{type: 'autogenerated', dirName: 'api'}], - // advancedUsageSidebar: [{type: 'autogenerated', dirName: 'advanced-usage'}], contributingSidebar: [ {type: 'doc', id: 'contributing', label: 'Contributing'}, ], diff --git a/docs/tsconfig.json b/docs/tsconfig.json index 8149661..a130337 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -4,5 +4,5 @@ "compilerOptions": { "baseUrl": "." }, - "include": ["src/**/*", "../packages/**/*"] + "include": ["src", "../packages"] } diff --git a/packages/core/README.md b/packages/core/README.md new file mode 100644 index 0000000..50af41c --- /dev/null +++ b/packages/core/README.md @@ -0,0 +1,41 @@ +

+ +
+
+

React Native OMH Auth - Core

+

+ +

+ NPM downloads + NPM version + License +

+ +

+ Chat on Discord + Follow on Twitter +

+ +--- + +## Installation + +```bash +npm add @omh/react-native-auth-core +``` + +## Usage + +The core modules exposes the [`OmhUserProfile`](https://special-barnacle-93vn82m.pages.github.io/docs/api/modules/core_src#omhuserprofile) type which you might find useful when working in a TypeScript React Native app. + +```typescript +import {type OmhUserProfile} from '@omh/react-native-auth-core'; + +// ... Auth Client initialization and sign in + +const user: OmhUserProfile = await AuthClient.getUser(); +``` + +## License + +- See [LICENSE](https://github.com/openmobilehub/react-native-omh-auth/blob/main/LICENSE) diff --git a/packages/core/src/AuthModule.ts b/packages/core/src/AuthModule.ts index 65c1830..967feac 100644 --- a/packages/core/src/AuthModule.ts +++ b/packages/core/src/AuthModule.ts @@ -15,30 +15,55 @@ export default class AuthModule { this.authNativeModule = authNativeModule; } + /** + * Initializes the authentication provider with the given configuration. + * @param config Configuration object required for initialization. + */ initialize(config: C): Promise { return this.authNativeModule.initialize(config); } + /** + * Initiates the sign-in process with the authentication provider. + */ signIn(): Promise { return this.authNativeModule.signIn(); } + /** + * Retrieves the access token from the authentication provider. + * @returns The access token if available, otherwise undefined. + */ getAccessToken(): Promise { return this.authNativeModule.getAccessToken(); } + /** + * Obtains user information for the current signed-in user. + * @returns An object containing user profile information. + */ getUser(): Promise { return this.authNativeModule.getUser(); } + /** + * Refreshes the access token if it has expired. + * @returns The new access token if refreshed, otherwise undefined. + */ refreshAccessToken(): Promise { return this.authNativeModule.refreshAccessToken(); } + /** + * Revokes the current access token. + */ revokeAccessToken(): Promise { return this.authNativeModule.revokeAccessToken(); } + /** + * Initiates the sign-out process with the authentication provider. + */ signOut(): Promise { return this.authNativeModule.signOut(); } diff --git a/packages/core/src/index.tsx b/packages/core/src/index.tsx index ad9ac94..d3cde4f 100644 --- a/packages/core/src/index.tsx +++ b/packages/core/src/index.tsx @@ -1,2 +1,7 @@ +/** + * React Native OMH Auth Core + * @module @omh/react-native-auth-core + */ + export * from './types'; export {default as AuthModule} from './AuthModule'; diff --git a/packages/plugin-dropbox/README.md b/packages/plugin-dropbox/README.md new file mode 100644 index 0000000..c0b567f --- /dev/null +++ b/packages/plugin-dropbox/README.md @@ -0,0 +1,53 @@ +

+ +
+
+

React Native OMH Auth - Dropbox

+

+ +

+ NPM downloads + NPM version + License +

+ +

+ Chat on Discord + Follow on Twitter +

+ +--- + +## Installation + +```bash +npm add @omh/react-native-auth-dropbox +``` + +## Configuration + +To access Dropbox APIs, generate a unique **App Key** for your app in the [Dropbox Console](https://www.dropbox.com/developers/apps). Once finished, add a new entry to your **android/local.properties** file: + +```bash title="android/local.properties" +DROPBOX_APP_KEY= +``` + +## Usage + +### Initializing + +Before interacting with Dropbox, initialization of the Dropbox Auth Client is necessary, requiring specific `scopes` to be configured. + +```typescript +import DropboxAuthClient from '@omh/react-native-auth-dropbox'; + +await DropboxAuthClient.initialize({scopes: ['account_info.read']}); +``` + +### Other methods + +Interacting with the Dropbox provider follows the same pattern as other providers since they all implement the `AuthModule` interface. For a comprehensive list of available methods, refer to the [Quick Start](https://special-barnacle-93vn82m.pages.github.io/docs/getting-started#sign-in) guide. + +## License + +- See [LICENSE](https://github.com/openmobilehub/react-native-omh-auth/blob/main/LICENSE) diff --git a/packages/plugin-dropbox/src/index.tsx b/packages/plugin-dropbox/src/index.tsx index 2ce0da6..cc78aa9 100644 --- a/packages/plugin-dropbox/src/index.tsx +++ b/packages/plugin-dropbox/src/index.tsx @@ -1,3 +1,8 @@ +/** + * React Native OMH Auth Dropbox Plugin + * @module @omh/react-native-dropbox-google + */ + import {AuthModule} from '@omh/react-native-auth-core'; const DROPBOX_MODULE_NAME = 'OmhDropbox'; diff --git a/packages/plugin-facebook/README.md b/packages/plugin-facebook/README.md new file mode 100644 index 0000000..e4876ef --- /dev/null +++ b/packages/plugin-facebook/README.md @@ -0,0 +1,54 @@ +

+ +
+
+

React Native OMH Auth - Facebook

+

+ +

+ NPM downloads + NPM version + License +

+ +

+ Chat on Discord + Follow on Twitter +

+ +--- + +## Installation + +```bash +npm add @omh/react-native-auth-facebook +``` + +## Configuration + +To access Facebook APIs, generate a unique **App ID** & **Client Token** for your app in the [Meta for Developers](https://developers.facebook.com/apps) and follow the additional [setup instructions](https://developers.facebook.com/docs/facebook-login/android). Once finished, add a new entry to your **android/local.properties** file: + +```bash title="android/local.properties" +FACEBOOK_APP_ID= +FACEBOOK_CLIENT_TOKEN= +``` + +## Usage + +### Initializing + +Before interacting with Facebook, initialization of the Facebook Auth Client is necessary, requiring specific `scopes` to be configured. + +```typescript +import FacebookAuthClient from '@omh/react-native-auth-facebook'; + +await FacebookAuthClient.initialize({scopes: ['public_profile', 'email']}); +``` + +### Other methods + +Interacting with the Facebook provider follows the same pattern as other providers since they all implement the `AuthModule` interface. For a comprehensive list of available methods, refer to the [Quick Start](https://special-barnacle-93vn82m.pages.github.io/docs/getting-started#sign-in) guide. + +## License + +- See [LICENSE](https://github.com/openmobilehub/react-native-omh-auth/blob/main/LICENSE) diff --git a/packages/plugin-facebook/src/index.tsx b/packages/plugin-facebook/src/index.tsx index 62ba647..533a1e3 100644 --- a/packages/plugin-facebook/src/index.tsx +++ b/packages/plugin-facebook/src/index.tsx @@ -1,3 +1,8 @@ +/** + * React Native OMH Auth Facebook Plugin + * @module @omh/react-native-auth-facebook + */ + import {AuthModule} from '@omh/react-native-auth-core'; const FACEBOOK_MODULE_NAME = 'OmhFacebook'; diff --git a/packages/plugin-google/README.md b/packages/plugin-google/README.md new file mode 100644 index 0000000..9448e3f --- /dev/null +++ b/packages/plugin-google/README.md @@ -0,0 +1,59 @@ +

+ +
+
+

React Native OMH Auth - Google (GMS/non-GMS)

+

+ +

+ NPM downloads + NPM version + License +

+ +

+ Chat on Discord + Follow on Twitter +

+ +--- + +## Installation + +```bash +npm add @omh/react-native-auth-google +``` + +## Configuration + +To access Google APIs, generate a unique **Client ID** for your app in the [Google Console](https://console.cloud.google.com/projectselector2) and follow the additional [setup instructions](https://developers.google.com/identity/protocols/oauth2/native-app#android). Once finished, add a new entry to your **android/local.properties** file: + +```bash title="android/local.properties" +GOOGLE_CLIENT_ID= +``` + +## Usage + +### Initializing + +Before interacting with Google, initialization of the Google Auth Client is necessary, requiring specific `scopes` to be configured. + +```typescript +import GoogleAuthClient from '@omh/react-native-auth-google'; + +await GoogleAuthClient.initialize({scopes: ['openid', 'email', 'profile']}); +``` + +### Other methods + +:::warning[KNOWN LIMITATIONS] + +On a [**GMS**](https://www.android.com/gms) enabled device, Google SDK automatically refreshes the access token in the background. Refreshing the access token manually on a GMS enabled device is not supported as of now. Instead the current access token will be returned when calling the `refreshAccessToken` method. + +::: + +Interacting with the Google provider follows the same pattern as other providers since they all implement the `AuthModule` interface. For a comprehensive list of available methods, refer to the [Quick Start](https://special-barnacle-93vn82m.pages.github.io/docs/getting-started#sign-in) guide. + +## License + +- See [LICENSE](https://github.com/openmobilehub/react-native-omh-auth/blob/main/LICENSE) diff --git a/packages/plugin-google/src/index.tsx b/packages/plugin-google/src/index.tsx index 3d08ee4..af0b475 100644 --- a/packages/plugin-google/src/index.tsx +++ b/packages/plugin-google/src/index.tsx @@ -1,3 +1,8 @@ +/** + * React Native OMH Auth Google Plugin + * @module @omh/react-native-auth-google + */ + import {AuthModule} from '@omh/react-native-auth-core'; const GOOGLE_MODULE_NAME = 'OmhGoogle'; diff --git a/packages/plugin-microsoft/README.md b/packages/plugin-microsoft/README.md new file mode 100644 index 0000000..81f325c --- /dev/null +++ b/packages/plugin-microsoft/README.md @@ -0,0 +1,65 @@ +

+ +
+
+

React Native OMH Auth - Microsoft

+

+ +

+ NPM downloads + NPM version + License +

+ +

+ Chat on Discord + Follow on Twitter +

+ +--- + +## Installation + +```bash +npm add @omh/react-native-auth-microsoft +``` + +## Configuration + +To access Microsoft APIs, generate a unique **Client ID** & **Signature Hash** for your app in the [Microsoft Azure](https://portal.azure.com) and follow the additional [setup instructions](https://learn.microsoft.com/en-us/azure/active-directory-b2c/configure-authentication-sample-android-app?tabs=kotlin). Once finished, add a new entry to your **android/local.properties** file: + +```bash title="android/local.properties" +MICROSOFT_SIGNATURE_HASH= +MICROSOFT_HOST_PATH=.MainApplication +``` + +Additionally, you will have to download the **ms_auth_config.json** file from the [Microsoft Azure](https://portal.azure.com) and add it in the **android/app/src/main/res/raw** directory. + +## Usage + +### Initializing + +Before interacting with Microsoft, initialization of the Microsoft Auth Client is necessary, requiring specific `scopes` and the `configFileName` to be configured. + +```typescript +import MicrosoftAuthClient from '@omh/react-native-auth-microsoft'; + +await MicrosoftAuthClient.initialize({ + scopes: ['User.Read'], + configFileName: 'ms_auth_config', +}); +``` + +### Other methods + +:::warning[Known limitations"] + +Due to current [limitations](https://github.com/AzureAD/microsoft-authentication-library-for-android/issues/1037) to the underlying Microsoft SDK, revoking a token is not supported as of now. Instead an error with the **"Method not supported."** message will be thrown when calling the `revokeAccessToken` method. + +::: + +Interacting with the Microsoft provider follows the same pattern as other providers since they all implement the `AuthModule` interface. For a comprehensive list of available methods, refer to the [Quick Start](https://special-barnacle-93vn82m.pages.github.io/docs/getting-started#sign-in) guide. + +## License + +- See [LICENSE](https://github.com/openmobilehub/react-native-omh-auth/blob/main/LICENSE) diff --git a/packages/plugin-microsoft/src/index.tsx b/packages/plugin-microsoft/src/index.tsx index aea9962..921a052 100644 --- a/packages/plugin-microsoft/src/index.tsx +++ b/packages/plugin-microsoft/src/index.tsx @@ -1,3 +1,8 @@ +/** + * React Native OMH Auth Microsoft Plugin + * @module @omh/react-native-auth-microsoft + */ + import {AuthModule} from '@omh/react-native-auth-core'; import {MicrosoftAuthConfig} from './types';