react-native-azure-auth-encrypted
Version:
Azure AD authentication in React Native using encrypted storage
789 lines (267 loc) • 16.1 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>WebAuth - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav>
<li class="nav-link nav-home-link"><a href="index.html">Home</a></li><li class="nav-heading">Classes</li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="Auth.html">Auth</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Auth.html#.acquireTokenSilent">acquireTokenSilent</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Auth.html#.clearPersistenCache">clearPersistenCache</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Auth.html#.exchange">exchange</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Auth.html#.loginUrl">loginUrl</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Auth.html#.logoutUrl">logoutUrl</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Auth.html#.msGraphRequest">msGraphRequest</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="Auth.html#.refreshTokens">refreshTokens</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="AzureAuth.html">AzureAuth</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="BaseError.html">BaseError</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="Client.html">Client</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="TokenCache.AccessTokenItem.html">AccessTokenItem</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="TokenCache.BaseTokenItem.html">BaseTokenItem</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="TokenCache.RefreshTokenItem.html">RefreshTokenItem</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="TokenCache.Scope.html">Scope</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="TokenCache.TokenCache.html">TokenCache</a></span></li><li class="nav-heading"><span class="nav-item-type type-class">C</span><span class="nav-item-name"><a href="WebAuth.html">WebAuth</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="WebAuth.html#.authorize">authorize</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="WebAuth.html#.clearSession">clearSession</a></span></li><li class="nav-heading"><a href="global.html">Globals</a></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#getAllUserTokenKeys">getAllUserTokenKeys</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#isIntersects">isIntersects</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#isSubsetOf">isSubsetOf</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#request">request</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#serializeParams">serializeParams</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#validate">validate</a></span></li>
</nav>
<div id="main">
<h1 class="page-title">WebAuth</h1>
<section>
<header>
<h2>
WebAuth
</h2>
</header>
<article>
<div class="container-overview">
<div class="section-method">
<h4 class="name" id="WebAuth"><span class="type-signature"></span>new WebAuth<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
<p>Helper to perform Auth against Azure AD login page</p>
<p>It will use <code>/authorize</code> endpoint of the Authorization Server (AS)
with Code Grant</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="webauth_index.js.html">webauth/index.js</a>, <a href="webauth_index.js.html#line8">line 8</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-code">https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols-oauth-code</a></li>
</ul>
</dd>
</dl>
</div>
</div>
<h3 class="subsection-title">Methods</h3>
<div class="section-method">
<h4 class="name" id=".authorize"><span class="type-signature">(async, static) </span>authorize<span class="signature">(options)</span><span class="type-signature"> → {Promise.<(BaseTokenItem|AccessTokenItem)>}</span></h4>
<div class="description">
<p>Starts the AuthN/AuthZ transaction against the AS in the in-app browser.</p>
<p>In iOS it will use <code>SFSafariViewController</code> and in Android <code>Chrome Custom Tabs</code>.</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="webauth_index.js.html">webauth/index.js</a>, <a href="webauth_index.js.html#line49">line 49</a>
</li></ul></dd>
<dt class="tag-see">See:</dt>
<dd class="tag-see">
<ul>
<li><a href="https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-scopes">https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-scopes</a></li>
<li><a href="https://learn.microsoft.com/en-us/entra/identity-platform/msal-js-sso#using-a-login-hint">https://learn.microsoft.com/en-us/entra/identity-platform/msal-js-sso#using-a-login-hint</a></li>
<li><a href="https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow">https://learn.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow</a></li>
</ul>
</dd>
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type"><code>Object</code></span>
</td>
<td class="description last">
<p>Parameters to send</p>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>scope</code></td>
<td class="type">
<span class="param-type"><code>String</code></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">
<p>Scopes requested for the issued tokens.
OpenID Connect scopes are always added to every request. <code>openid profile offline_access</code></p>
</td>
</tr>
<tr>
<td class="name"><code>prompt</code></td>
<td class="type">
<span class="param-type"><code>String</code></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">
<p>(optional) Indicates the type of user interaction that is required.
The only valid values are 'login', 'none', 'consent', and 'select_account'.</p>
</td>
</tr>
<tr>
<td class="name"><code>ephemeralSession</code></td>
<td class="type">
<span class="param-type"><code>Boolean</code></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">
<p>SSO. It only affects iOS with versions 13 and above.</p>
</td>
</tr>
<tr>
<td class="name"><code>login_hint</code></td>
<td class="type">
<span class="param-type"><code>String</code></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">
<p>(optional) Provides a hint to Microsoft Entra ID
about the user account attempting to sign in</p>
</td>
</tr>
<tr>
<td class="name"><code>extraQueryParameters</code></td>
<td class="type">
<span class="param-type"><code>Object</code></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">
<p>(optional) Additional query parameters to include in the authorization request.
Should be an object with string or number values (e.g., {domain_hint: 'contoso.com', custom_param: 'value'})</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<div class="section-returns">
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type:
</dt>
<dd>
<span class="param-type"><code>Promise.<(BaseTokenItem|AccessTokenItem)></code></span>
</dd>
</dl>
<div class="param-desc">
<p>Promise that resolves to a BaseTokenItem or AccessTokenItem containing the authentication result</p>
</div>
</div>
</div>
<div class="section-method">
<h4 class="name" id=".clearSession"><span class="type-signature">(static) </span>clearSession<span class="signature">(options)</span><span class="type-signature"> → {Promise}</span></h4>
<div class="description">
<p>Removes Azure session</p>
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="webauth_index.js.html">webauth/index.js</a>, <a href="webauth_index.js.html#line139">line 139</a>
</li></ul></dd>
</dl>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type"><code>Object</code></span>
</td>
<td class="description last">
<p>parameters to send</p>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>closeOnLoad</code></td>
<td class="type">
<span class="param-type"><code>Boolean</code></span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">
<p>close browser window on 'Loaded' event (works only on iOS)</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<div class="section-returns">
<h5>Returns:</h5>
<dl class="param-type">
<dt>
Type:
</dt>
<dd>
<span class="param-type"><code>Promise</code></span>
</dd>
</dl>
</div>
</div>
</article>
</section>
</div>
<br class="clear">
<footer>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.11</a> on Tue Sep 09 2025 13:24:03 GMT+0200 (Mitteleuropäische Sommerzeit) using the Minami theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/linenumber.js"></script>
</body>
</html>