Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-msal

Package Overview
Dependencies
Maintainers
2
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-msal - npm Package Versions

1
46

3.0.0-beta.6

Diff

stashenergy
published 3.0.0-beta.5 •

stashenergy
published 3.0.0-beta.4 •

stashenergy
published 3.0.0-beta.3 •

stashenergy
published 3.0.0-beta.2 •

stashenergy
published 3.0.0-beta.1 •

stashenergy
published 2.0.3 •

Changelog

Source

3.0.0

Breaking changes

Default export

Default exported class renamed from MSALClient to PublicClientApplication and constructor now accepts an MSALConfiguration object instead of a clientId string.

-import MSALClient from 'react-native-msal';
+import MSALClient, { MSALConfiguration } from 'react-native-msal';
-const msalClient = new MSALClient(clientId);
+const config: MSALConfiguration = {
+    auth: {
+        clientId,
+    },
+};
+const msalClient = new MSALClient(config);
MSALAccount and accountIdentifier properties

The MSALAccount definition has been modified to include a new Claims dictionary. All methods that previously consumed the identifier from this type should now provide the entire MSALAccount object instead.

const result = msalClient.acquireTokenSilent({
  authority,
  scopes,
- accountIdentifier: account.identifier,
+ account,
});
signOut method

The signout method has been renamed signOut and authority removed from the MSALSignoutParams.

-await msalClient.signout({
-  authority,
+await msalClient.signOut({
removeAccount method

MSALRemoveAccountParams has been removed and so the removeAccount method only requires the account.

-await msalClient.removeAccount({
+await msalClient.removeAccount(
-  authority,
   account,
-})
+)
Webview parameters

ios_prefersEphemeralWebBrowserSession has moved from acquireToken() and signOut() parameters into the new webviewParameters in MSALInteractiveParams and MSALSignoutParams respectively.

-ios_prefersEphemeralWebBrowserSession: true,
+webviewParameters: {
+  ios_prefersEphemeralWebBrowserSession: true,
+},
expiresOn

MSALResult.expiresOn now returns a value in seconds instead of milliseconds.

MSALResult interface

The result returned from an acquireToken or acquireTokenSilent call no longer has an authority property.

Azure AD B2C usage

See example/src/b2cClient.ts, but at the very least, knownAuthorities should be added to the initial client constructor.

Testing

You'll need to mock the PublicClientApplication class for testing purposes. One way to do this:

// yourtestfile.test.ts
import PublicClientApplication from 'react-native-msal';
jest.mock('react-native-msal');

const MockPublicClientApplication = PublicClientApplication as jest.MockedClass<PublicClientApplication>;

it('Creates a mock instance without calling native functions', () => {
  const mockPca = new MockPublicClientApplication({ auth: { clientId: '1234' } });
  expect(MockPublicClientApplication).toHaveBeenCalledTimes(1);
  expect(mockPca).not.toBeNull();
});
stashenergy
published 2.0.2 •

stashenergy
published 2.0.1 •

stashenergy
published 2.0.0 •

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc