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

cordova-plugin-msal

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-msal - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

4

package.json
{
"name": "cordova-plugin-msal",
"version": "3.0.0",
"version": "4.0.0",
"description": "A Cordova plugin providing a wrapper for Microsoft's MSAL library for Android and iOS.",

@@ -31,3 +31,3 @@ "cordova": {

"cordovaDependencies": {
"3.0.0": {
"4.0.0": {
"cordova-android": ">=9.0.0",

@@ -34,0 +34,0 @@ "cordova": ">=10.0.0",

@@ -6,14 +6,10 @@ # Cordova MSAL Plugin

## How do I install it?
You can specify three variables during installation: the tenant ID and client ID of your Identity Platform, and, if you're building for Android, a base64 sha1 hash of your keystore file. The latter of which can be obtained like this:
You can install it just like any other Cordova plugin. However, if you're building for Android, you need to specify an optional install variable: a base64 sha1 hash of your keystore file. It can be obtained like this:
<pre>
keytool -exportcert -alias yourkeystorealias -keystore path/to/your/keystore/file.keystore | openssl sha1 -binary | openssl base64
</pre>
If you aren't using AzureADMyOrg as one of your authorities, you can omit TENANT_ID, and if you're only building for iOS, you can omit KEY_HASH, but you really need to provide CLIENT_ID.
### Update:
Moving forward, TENANT_ID and CLIENT_ID are now deprecated as install variables and are now designed to be passed in msalInit() (see below).
### If you're using a CLI:
<pre>
cordova plugin add cordova-plugin-msal --variable TENANT_ID=your-tenant-guid-here-optional-deprecated --variable CLIENT_ID=your-client-guid-here-optional-deprecated --variable KEY_HASH=S0m3K3yh4shH3re=
cordova plugin add cordova-plugin-msal --variable KEY_HASH=S0m3K3yh4shH3re=
</pre>
Note that since the added support for multiple tentants/clients, you can now provide these IDs in via `msalInit` if they are not available at build time. These are now deprecated at install-time and will be removed soon.
### If you're using OutSystems

@@ -32,13 +28,5 @@ You should use my [forge component](https://www.outsystems.com/forge/Component_Overview.aspx?ProjectId=8038). But if you want to implement a wrapper yourself, or if you're here because you're using that component and you want additional documentation, continue reading:

"plugin": {
"url": "https://github.com/wrobins/cordova-plugin-msal.git#v3.0.0",
"url": "https://github.com/wrobins/cordova-plugin-msal.git#v4.0.0",
"variables": [
{
"name": "TENANT_ID",
"value": "your-tenant-guid-here-optional-deprecated"
},
{
"name": "CLIENT_ID",
"value": "your-client-guid-here-optional-deprecated"
},
{
"name": "KEY_HASH",

@@ -65,3 +53,3 @@ "value": "S0m3K3yh4shH3re="

```
The options parameter is an object that contains all of your MSAL configuration items, and is documented below. You can pass as much or as little of this object as you would like, or not even pass it at all. The full object, though, with all of the default options, looks like this:
The options parameter is an object that contains all of your MSAL configuration items, and is documented below. You can pass as much or as little of this object as you would like; the only required option is clientId. The full object, though, with all of the default options, looks like this:
```js

@@ -123,4 +111,10 @@ {

#### tenantId
If you are using a custom Azure tenant you need to supply it here. Default: 'common'
If you are using a custom Azure tenant you need to supply it here. If you aren't using AzureADMyOrg as one of your authorities, you can leave this alone. Default: 'common'
So at minimum, this is what msalInit() should look like when you call it:
```js
window.cordova.plugins.msalPlugin.msalInit(mySuccessFunction, myErrorHandler, {clientId: 'my-clid-id-guid'});
```
Ok, you have your plugin initialized with your organization's configuration. Here's how you sign users in and out:

@@ -310,3 +304,3 @@ ### Single Client

## Multiple tenants/client applications
You can now provide your `tenantId` or `clientId` in directly to the `msalInit` function via the `options` object. This means that the plugin can support swapping between different tenants/clients on the fly just by re-initialising the plugin with the new IDs. This is useful if you want to support different geographical regions or tenants without having to rebuild the app for each different configuration.
If you want to support different geographical regions or tenants without having to rebuild the app for each different configuration, you can swap your tenant or client at any time by simply calling msalInit() again and specify a new tenant and/or client ID:
```js

@@ -367,3 +361,3 @@ cordova.plugins.msalPlugin.msalInit(resolve, reject, {

## Troubleshooting
This plugin uses androidx features. If you get an error complaining about conflicting dependencies, you might need to add a couple of plugins to provide androidx compatibility, but your results may vary depending on if you are building locally or with a cloud-based utility.
This plugin uses androidx features. If you are trying to target certain older Android builds and get an error complaining about conflicting dependencies at buildtime, you might need to add a couple of plugins to provide androidx compatibility, but your results may vary depending on if you are building locally or with a cloud-based utility.
<pre>

@@ -370,0 +364,0 @@ cordova plugin add cordova-plugin-androidx

@@ -1,3 +0,1 @@

const clientID = CLIENT_ID;
const tenantId = TENANT_ID;
const msal = window.msal;

@@ -18,4 +16,4 @@

const providedConfig = JSON.parse(opts[0]);
msalConfig.auth.clientId = providedConfig.clientId || clientID;
msalConfig.auth.authority = `https://login.microsoftonline.com/${providedConfig.tenantId || tenantId}`;
msalConfig.auth.clientId = providedConfig.clientId;
msalConfig.auth.authority = `https://login.microsoftonline.com/${providedConfig.tenantId}`;
msalConfig.auth.knownAuthorities = providedConfig.authorities.filter(a => a.authorityUrl !== '').map(a => a.authorityUrl);

@@ -22,0 +20,0 @@ accountMode = providedConfig.accountMode;

@@ -72,3 +72,7 @@ module.exports = {

}
cordova.exec(successCallback, errorCallback, 'MsalPlugin', 'msalInit', [JSON.stringify(options)]);
if (options.clientId === '') {
errorCallback("Client ID is missing.");
} else {
cordova.exec(successCallback, errorCallback, 'MsalPlugin', 'msalInit', [JSON.stringify(options)]);
}
},

@@ -75,0 +79,0 @@ startLogger: function(updateCallback, errorCallback, containsPII = false, logLevel = 'VERBOSE') {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

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