{"_id":"@arun_h/rn-msal","name":"@arun_h/rn-msal","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@arun_h/rn-msal","version":"1.0.0","description":"React Native msal with iOS fix","main":"build/index.js","types":"build/index.d.ts","source":"src/index","scripts":{"build":"expo-module build","clean":"expo-module clean","expo-module":"expo-module","lint":"expo-module lint","test":"expo-module test","example":"yarn --cwd example","pods":"cd example && npx pod-install","bootstrap":"yarn example && yarn && yarn pods","predeploy":"yarn example build:web","deploy":"gh-pages -d example/web-build"},"keywords":["react-native","ios","android","msal","azure","b2c","aad","expo"],"repository":{"type":"git","url":"git+https://github.com/Arunhari333/rn-msal.git"},"author":{"name":"Arun"},"license":"MIT","bugs":{"url":"https://github.com/Arunhari333/rn-msal/issues"},"homepage":"https://github.com/Arunhari333/rn-msal#readme","dependencies":{"@azure/msal-browser":"^2.1.0","@expo/config-plugins":"^4.0.6"},"devDependencies":{"@commitlint/cli":"^16.1.0","@commitlint/config-conventional":"^16.0.0","@react-native-community/eslint-config":"^3.0.0","@types/jest":"^27.0.2","@types/react":"^17.0.5","@types/react-native":"^0.66.1","eslint":"^7.26.0","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0","expo-module-scripts":"^2.0.0","gh-pages":"^3.1.0","husky":"^7.0.0","jest":"^27.0.6","metro-react-native-babel-preset":"^0.66.0","prettier":"^2.3.0","react":"^17.0.2","react-native":"^0.64.1","semantic-release":"^19.0.2","typescript":"^4.2.4"},"peerDependencies":{"react":"*","react-native":"*"},"jest":{"preset":"react-native","modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"commitlint":{"extends":["@commitlint/config-conventional"]},"prettier":{"singleQuote":true,"tabWidth":2,"trailingComma":"es5","useTabs":false,"printWidth":120},"_id":"@arun_h/rn-msal@1.0.0","gitHead":"232ee93f63cd24e021ad3174c868f7347273613d","_nodeVersion":"20.18.3","_npmVersion":"10.8.2","dist":{"integrity":"sha512-yOJQpQq4anICrfTNxYU3HyoXQyJSZPMwS1OxNCC8cELjMyqKUA8UKhrQb+rReDzN8IYirwnuwQuOAT8SpnLgCQ==","shasum":"160867992a59f86ae5253d3025875e9c567b19d1","tarball":"https://registry.npmjs.org/@arun_h/rn-msal/-/rn-msal-1.0.0.tgz","fileCount":39,"unpackedSize":108132,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIF5V71MOdUQAS6STP0gRqPsN3QBpXxLMsKtqDs0rES43AiBvd4wp6cjRFPWu7cR9sj26KtLsAuAgawxw2gbXZAv3gw=="}]},"_npmUser":{"name":"arun_h","email":"arunhari3210@gmail.com"},"directories":{},"maintainers":[{"name":"arun_h","email":"arunhari3210@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rn-msal_1.0.0_1739780050497_0.9883365354475222"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-17T08:14:10.411Z","1.0.0":"2025-02-17T08:14:10.675Z","modified":"2025-02-17T08:14:10.977Z"},"maintainers":[{"name":"arun_h","email":"arunhari3210@gmail.com"}],"description":"React Native msal with iOS fix","homepage":"https://github.com/Arunhari333/rn-msal#readme","keywords":["react-native","ios","android","msal","azure","b2c","aad","expo"],"repository":{"type":"git","url":"git+https://github.com/Arunhari333/rn-msal.git"},"author":{"name":"Arun"},"bugs":{"url":"https://github.com/Arunhari333/rn-msal/issues"},"license":"MIT","readme":"# react-native-msal\r\n\r\n[![npm latest version](https://img.shields.io/npm/v/react-native-msal/latest.svg)](https://www.npmjs.com/package/react-native-msal)\r\n[![npm beta version](https://img.shields.io/npm/v/react-native-msal/beta.svg)](https://www.npmjs.com/package/react-native-msal)\r\n![ci status](https://github.com/stashenergy/react-native-msal/workflows/CI/badge.svg)\r\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\r\n\r\n<p align=\"center\">\r\n  <img src=\"_assets/ReactNativeMSALLogo.webp\" width=\"300\">\r\n</p>\r\n\r\n## Live Demo (Web)\r\n\r\n[https://stashenergy.github.io/react-native-msal/](https://stashenergy.github.io/react-native-msal/)\r\n\r\n## Table of Contents\r\n\r\n- [Install](#install)\r\n- [Setup](#setup)\r\n- [Use](#use)\r\n  - [PublicClientApplication class](#publicClientApplication-class)\r\n  - [B2C Applications](#b2c-applications)\r\n- [Example app](#example-app)\r\n- [Migrating between major versions](#migrating-between-major-versions)\r\n\r\n## Install\r\n\r\n**Requires React Native >=0.61**\r\n\r\nStable version:\r\n`$ yarn add react-native-msal`\r\n\r\nBeta version:\r\n`$ yarn add react-native-msal@beta`\r\n\r\nDon't forget to run `npx pod-install` after!\r\n\r\n## Setup\r\n\r\n### Expo\r\n\r\nFollow the [Expo setup guide](/docs/expo_setup.md)\r\n\r\n### Non-expo\r\n\r\nFollow the [Android setup guide](/docs/android_setup.md) and the [iOS setup guide](/docs/ios_setup.md)\r\n\r\n## Use\r\n\r\n```typescript\r\nimport PublicClientApplication from 'react-native-msal';\r\nimport type { MSALConfiguration /*, etc */ } from 'react-native-msal';\r\n\r\nconst config: MSALConfiguration = {\r\n  auth: {\r\n    clientId: 'your-client-id',\r\n    // This authority is used as the default in `acquireToken` and `acquireTokenSilent` if not provided to those methods.\r\n    // Defaults to 'https://login.microsoftonline.com/common'\r\n    authority: 'https://<authority url>',\r\n  },\r\n};\r\nconst scopes = ['scope1', 'scope2'];\r\n\r\n// Initialize the public client application:\r\nconst pca = new PublicClientApplication(config);\r\ntry {\r\n  await pca.init();\r\n} catch (error) {\r\n  console.error('Error initializing the pca, check your config.', error);\r\n}\r\n\r\n// Acquiring a token for the first time, you must call pca.acquireToken\r\nconst params: MSALInteractiveParams = { scopes };\r\nconst result: MSALResult | undefined = await pca.acquireToken(params);\r\n\r\n// On subsequent token acquisitions, you can call `pca.acquireTokenSilent`\r\n// Force the token to refresh with the `forceRefresh` option\r\nconst params: MSALSilentParams = {\r\n  account: result!.account, // or get this by filtering the result from `pca.getAccounts` (see below)\r\n  scopes,\r\n  forceRefresh: true,\r\n};\r\nconst result: MSALResult | undefined = await pca.acquireTokenSilent(params);\r\n\r\n// Get all accounts for which this application has refresh tokens\r\nconst accounts: MSALAccount[] = await pca.getAccounts();\r\n\r\n// Retrieve the account matching the identifier\r\nconst account: MSALAccount | undefined = await pca.getAccount(result!.account.identifier);\r\n\r\n// Remove all tokens from the cache for this application for the provided account\r\nconst success: boolean = await pca.removeAccount(result!.account);\r\n\r\n// Same as `pca.removeAccount` with the exception that, if called on iOS with the `signoutFromBrowser` option set to true, it will additionally remove the account from the system browser\r\nconst params: MSALSignoutParams = {\r\n  account: result!.account,\r\n  signoutFromBrowser: true,\r\n};\r\nconst success: boolean = await pca.signOut(params);\r\n```\r\n\r\n### B2C Applications\r\n\r\nThe `PublicClientApplication` class is a bit too bare bones for dealing with a B2C application, and you will need to write a bit of code to get the desired behavior.\r\n\r\nTo address this issue, the example app that is included in this repository includes a [`B2CClient` class](./example/src/b2cClient.ts) which contains a lot of the functionality you will need for a B2C app. You can copy this class right into your own React Native app and modify it to your liking. You can see it being used in the example's [`App.tsx`](./example/src/App.tsx)\r\n\r\nIf you would like to see this class included in the library itself, please let us know.\r\n\r\n## Example App\r\n\r\nAs mentioned above, the example app demonstrates a B2C implementation\r\n\r\nTo run the example locally, first clone the repo and run `$ yarn` to bootstrap the project. Then run the following for the desired platform:\r\n\r\niOS: `$ yarn example ios`\r\nAndroid: `$ yarn example android`\r\nWeb: `$ yarn example web` (the example app is also running live [here](https://stashenergy.github.io/react-native-msal/))\r\n\r\nIf you want to run the example using your own Azure application information:\r\n\r\n1. Register the redirect URLs in your tenant:\r\n   - Android: `msauth://com.example/Xo8WBi6jzSxKDVR4drqm84yr9iU%3D`\r\n   - iOS: `msauth.com.example://auth`\r\n   - Web (SPA): `http://localhost:19006`\r\n1. Update the `b2cConfig` and `b2cScopes` variables in `msalConfig.ts` with your details.\r\n\r\n## Migrating between major versions\r\n\r\nSee migration instructions in the [CHANGELOG](CHANGELOG.md).\r\n","readmeFilename":"README.md"}