1246 lines
43 KiB
HTML
1246 lines
43 KiB
HTML
<!doctype html>
|
|
<html class="no-js" lang="">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
|
<title>CICADA</title>
|
|
<meta name="description" content="">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
|
|
<link rel="stylesheet" href="../styles/style.css">
|
|
</head>
|
|
<body>
|
|
|
|
<div class="navbar navbar-default navbar-fixed-top visible-xs">
|
|
<a href="../" class="navbar-brand">CICADA</a>
|
|
<button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
|
|
</div>
|
|
|
|
<div class="xs-menu menu" id="mobile-menu">
|
|
<div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
|
|
</div>
|
|
|
|
<div class="container-fluid main">
|
|
<div class="row main">
|
|
<div class="hidden-xs menu">
|
|
<compodoc-menu mode="normal"></compodoc-menu>
|
|
</div>
|
|
<!-- START CONTENT -->
|
|
<div class="content injectable">
|
|
<div class="content-data">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ol class="breadcrumb">
|
|
<li>Injectables</li>
|
|
<li>AuthService</li>
|
|
</ol>
|
|
|
|
<ul class="nav nav-tabs" role="tablist">
|
|
<li class="active">
|
|
<a href="#info" role="tab" id="info-tab" data-toggle="tab" data-link="info">Info</a>
|
|
</li>
|
|
<li >
|
|
<a href="#source" role="tab" id="source-tab" data-toggle="tab" data-link="source">Source</a>
|
|
</li>
|
|
</ul>
|
|
|
|
<div class="tab-content">
|
|
<div class="tab-pane fade active in" id="c-info">
|
|
<p class="comment">
|
|
<h3>File</h3>
|
|
</p>
|
|
<p class="comment">
|
|
<code>src/app/_services/auth.service.ts</code>
|
|
</p>
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<h3 id="index">Index</h3>
|
|
<table class="table table-sm table-bordered index-table">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<h6><b>Properties</b></h6>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<ul class="index-list">
|
|
<li>
|
|
<a href="#mutableKeyStore">mutableKeyStore</a>
|
|
</li>
|
|
<li>
|
|
<a href="#sessionLoginCount">sessionLoginCount</a>
|
|
</li>
|
|
<li>
|
|
<a href="#sessionToken">sessionToken</a>
|
|
</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<h6><b>Methods</b></h6>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<ul class="index-list">
|
|
<li>
|
|
<a href="#getChallenge">getChallenge</a>
|
|
</li>
|
|
<li>
|
|
<a href="#getPrivateKey">getPrivateKey</a>
|
|
</li>
|
|
<li>
|
|
<span class="modifier">Async</span>
|
|
<a href="#getPublicKeys">getPublicKeys</a>
|
|
</li>
|
|
<li>
|
|
<a href="#getTrustedUsers">getTrustedUsers</a>
|
|
</li>
|
|
<li>
|
|
<a href="#getWithToken">getWithToken</a>
|
|
</li>
|
|
<li>
|
|
<span class="modifier">Async</span>
|
|
<a href="#init">init</a>
|
|
</li>
|
|
<li>
|
|
<a href="#login">login</a>
|
|
</li>
|
|
<li>
|
|
<span class="modifier">Async</span>
|
|
<a href="#loginResponse">loginResponse</a>
|
|
</li>
|
|
<li>
|
|
<a href="#loginView">loginView</a>
|
|
</li>
|
|
<li>
|
|
<a href="#logout">logout</a>
|
|
</li>
|
|
<li>
|
|
<a href="#sendResponse">sendResponse</a>
|
|
</li>
|
|
<li>
|
|
<span class="modifier">Async</span>
|
|
<a href="#setKey">setKey</a>
|
|
</li>
|
|
<li>
|
|
<a href="#setState">setState</a>
|
|
</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
|
|
<section>
|
|
<h3 id="constructor">Constructor</h3>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<code>constructor(httpClient: <a href="https://angular.io/api/common/http/HttpClient" target="_blank">HttpClient</a>, loggingService: <a href="../injectables/LoggingService.html">LoggingService</a>, errorDialogService: <a href="../injectables/ErrorDialogService.html">ErrorDialogService</a>)</code>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="17" class="link-to-prism">src/app/_services/auth.service.ts:17</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div>
|
|
<b>Parameters :</b>
|
|
<table class="params">
|
|
<thead>
|
|
<tr>
|
|
<td>Name</td>
|
|
<td>Type</td>
|
|
<td>Optional</td>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>httpClient</td>
|
|
|
|
<td>
|
|
<code><a href="https://angular.io/api/common/http/HttpClient" target="_blank" >HttpClient</a></code>
|
|
</td>
|
|
|
|
<td>
|
|
No
|
|
</td>
|
|
|
|
</tr>
|
|
<tr>
|
|
<td>loggingService</td>
|
|
|
|
<td>
|
|
<code><a href="../injectables/LoggingService.html" target="_self" >LoggingService</a></code>
|
|
</td>
|
|
|
|
<td>
|
|
No
|
|
</td>
|
|
|
|
</tr>
|
|
<tr>
|
|
<td>errorDialogService</td>
|
|
|
|
<td>
|
|
<code><a href="../injectables/ErrorDialogService.html" target="_self" >ErrorDialogService</a></code>
|
|
</td>
|
|
|
|
<td>
|
|
No
|
|
</td>
|
|
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
|
|
<section>
|
|
|
|
<h3 id="methods">
|
|
Methods
|
|
</h3>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="getChallenge"></a>
|
|
<span class="name">
|
|
<b>
|
|
getChallenge
|
|
</b>
|
|
<a href="#getChallenge"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<code>getChallenge()</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="84"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:84</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code>
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="getPrivateKey"></a>
|
|
<span class="name">
|
|
<b>
|
|
getPrivateKey
|
|
</b>
|
|
<a href="#getPrivateKey"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<code>getPrivateKey()</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="210"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:210</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >any</a></code>
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="getPublicKeys"></a>
|
|
<span class="name">
|
|
<b>
|
|
<span class="modifier">Async</span>
|
|
getPublicKeys
|
|
</b>
|
|
<a href="#getPublicKeys"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<span class="modifier-icon icon ion-ios-reset"></span>
|
|
<code>getPublicKeys()</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="200"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:200</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code>Promise<any></code>
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="getTrustedUsers"></a>
|
|
<span class="name">
|
|
<b>
|
|
getTrustedUsers
|
|
</b>
|
|
<a href="#getTrustedUsers"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<code>getTrustedUsers()</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="194"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:194</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >any</a></code>
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="getWithToken"></a>
|
|
<span class="name">
|
|
<b>
|
|
getWithToken
|
|
</b>
|
|
<a href="#getWithToken"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<code>getWithToken()</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="42"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:42</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code>
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="init"></a>
|
|
<span class="name">
|
|
<b>
|
|
<span class="modifier">Async</span>
|
|
init
|
|
</b>
|
|
<a href="#init"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<span class="modifier-icon icon ion-ios-reset"></span>
|
|
<code>init()</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="27"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:27</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code>Promise<void></code>
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="login"></a>
|
|
<span class="name">
|
|
<b>
|
|
login
|
|
</b>
|
|
<a href="#login"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<code>login()</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="98"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:98</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/boolean" target="_blank" >boolean</a></code>
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="loginResponse"></a>
|
|
<span class="name">
|
|
<b>
|
|
<span class="modifier">Async</span>
|
|
loginResponse
|
|
</b>
|
|
<a href="#loginResponse"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<span class="modifier-icon icon ion-ios-reset"></span>
|
|
<code>loginResponse(o: literal type)</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="116"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:116</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Parameters :</b>
|
|
<table class="params">
|
|
<thead>
|
|
<tr>
|
|
<td>Name</td>
|
|
<td>Type</td>
|
|
<td>Optional</td>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>o</td>
|
|
<td>
|
|
<code>literal type</code>
|
|
</td>
|
|
|
|
<td>
|
|
No
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div>
|
|
</div>
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code>Promise<any></code>
|
|
|
|
</div>
|
|
<div class="io-description">
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="loginView"></a>
|
|
<span class="name">
|
|
<b>
|
|
loginView
|
|
</b>
|
|
<a href="#loginView"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<code>loginView()</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="150"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:150</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code>
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="logout"></a>
|
|
<span class="name">
|
|
<b>
|
|
logout
|
|
</b>
|
|
<a href="#logout"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<code>logout()</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="188"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:188</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code>
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="sendResponse"></a>
|
|
<span class="name">
|
|
<b>
|
|
sendResponse
|
|
</b>
|
|
<a href="#sendResponse"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<code>sendResponse(hobaResponseEncoded: <a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank">any</a>)</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="61"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:61</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Parameters :</b>
|
|
<table class="params">
|
|
<thead>
|
|
<tr>
|
|
<td>Name</td>
|
|
<td>Type</td>
|
|
<td>Optional</td>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>hobaResponseEncoded</td>
|
|
<td>
|
|
<code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >any</a></code>
|
|
</td>
|
|
|
|
<td>
|
|
No
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div>
|
|
</div>
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code>Promise<boolean></code>
|
|
|
|
</div>
|
|
<div class="io-description">
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="setKey"></a>
|
|
<span class="name">
|
|
<b>
|
|
<span class="modifier">Async</span>
|
|
setKey
|
|
</b>
|
|
<a href="#setKey"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<span class="modifier-icon icon ion-ios-reset"></span>
|
|
<code>setKey(privateKeyArmored)</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="160"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:160</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Parameters :</b>
|
|
<table class="params">
|
|
<thead>
|
|
<tr>
|
|
<td>Name</td>
|
|
<td>Optional</td>
|
|
<td>Description</td>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>privateKeyArmored</td>
|
|
|
|
<td>
|
|
No
|
|
</td>
|
|
|
|
|
|
<td>
|
|
<ul>
|
|
<li>Private key.</li>
|
|
</ul>
|
|
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div>
|
|
</div>
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code>Promise<boolean></code>
|
|
|
|
</div>
|
|
<div class="io-description">
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="setState"></a>
|
|
<span class="name">
|
|
<b>
|
|
setState
|
|
</b>
|
|
<a href="#setState"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<code>setState(s)</code>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="38"
|
|
class="link-to-prism">src/app/_services/auth.service.ts:38</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td class="col-md-4">
|
|
|
|
<div class="io-description">
|
|
<b>Parameters :</b>
|
|
<table class="params">
|
|
<thead>
|
|
<tr>
|
|
<td>Name</td>
|
|
<td>Optional</td>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>s</td>
|
|
|
|
<td>
|
|
No
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div>
|
|
</div>
|
|
<div class="io-description">
|
|
<b>Returns : </b> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >void</a></code>
|
|
|
|
</div>
|
|
<div class="io-description">
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
<section>
|
|
|
|
<h3 id="inputs">
|
|
Properties
|
|
</h3>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="mutableKeyStore"></a>
|
|
<span class="name">
|
|
<b>
|
|
mutableKeyStore</b>
|
|
<a href="#mutableKeyStore"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<i>Type : </i> <code><a href="../interfaces/MutableKeyStore.html" target="_self" >MutableKeyStore</a></code>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="17" class="link-to-prism">src/app/_services/auth.service.ts:17</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="sessionLoginCount"></a>
|
|
<span class="name">
|
|
<b>
|
|
sessionLoginCount</b>
|
|
<a href="#sessionLoginCount"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<i>Type : </i> <code><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/number" target="_blank" >number</a></code>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<i>Default value : </i><code>0</code>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="16" class="link-to-prism">src/app/_services/auth.service.ts:16</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
<table class="table table-sm table-bordered">
|
|
<tbody>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<a name="sessionToken"></a>
|
|
<span class="name">
|
|
<b>
|
|
sessionToken</b>
|
|
<a href="#sessionToken"><span class="icon ion-ios-link"></span></a>
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<i>Type : </i> <code><a href="https://www.typescriptlang.org/docs/handbook/basic-types.html" target="_blank" >any</a></code>
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td class="col-md-4">
|
|
<div class="io-line">Defined in <a href="" data-line="15" class="link-to-prism">src/app/_services/auth.service.ts:15</a></div>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
</section>
|
|
|
|
</div>
|
|
|
|
|
|
<div class="tab-pane fade tab-source-code" id="c-source">
|
|
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from '@angular/core';
|
|
import { hobaParseChallengeHeader } from '@src/assets/js/hoba.js';
|
|
import { signChallenge } from '@src/assets/js/hoba-pgp.js';
|
|
import { environment } from '@src/environments/environment';
|
|
import { LoggingService } from '@app/_services/logging.service';
|
|
import { MutableKeyStore, MutablePgpKeyStore } from '@app/_pgp';
|
|
import { ErrorDialogService } from '@app/_services/error-dialog.service';
|
|
import { HttpClient } from '@angular/common/http';
|
|
import { HttpError } from '@app/_helpers/global-error-handler';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class AuthService {
|
|
sessionToken: any;
|
|
sessionLoginCount: number = 0;
|
|
mutableKeyStore: MutableKeyStore;
|
|
|
|
constructor(
|
|
private httpClient: HttpClient,
|
|
private loggingService: LoggingService,
|
|
private errorDialogService: ErrorDialogService
|
|
) {
|
|
this.mutableKeyStore = new MutablePgpKeyStore();
|
|
}
|
|
|
|
async init(): Promise<void> {
|
|
await this.mutableKeyStore.loadKeyring();
|
|
// TODO setting these together should be atomic
|
|
if (sessionStorage.getItem(btoa('CICADA_SESSION_TOKEN'))) {
|
|
this.sessionToken = sessionStorage.getItem(btoa('CICADA_SESSION_TOKEN'));
|
|
}
|
|
if (localStorage.getItem(btoa('CICADA_PRIVATE_KEY'))) {
|
|
await this.mutableKeyStore.importPrivateKey(localStorage.getItem(btoa('CICADA_PRIVATE_KEY')));
|
|
}
|
|
}
|
|
|
|
setState(s): void {
|
|
document.getElementById('state').innerHTML = s;
|
|
}
|
|
|
|
getWithToken(): void {
|
|
const xhr: XMLHttpRequest = new XMLHttpRequest();
|
|
xhr.responseType = 'text';
|
|
xhr.open('GET', environment.cicMetaUrl + window.location.search.substring(1));
|
|
xhr.setRequestHeader('Authorization', 'Bearer ' + this.sessionToken);
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
xhr.setRequestHeader('x-cic-automerge', 'none');
|
|
xhr.addEventListener('load', (e) => {
|
|
if (xhr.status === 401) {
|
|
throw new Error('login rejected');
|
|
}
|
|
this.sessionLoginCount++;
|
|
this.setState('Click button to log in');
|
|
return;
|
|
});
|
|
xhr.send();
|
|
}
|
|
|
|
// TODO rename to send signed challenge and set session. Also separate these responsibilities
|
|
sendResponse(hobaResponseEncoded: any): Promise<boolean> {
|
|
return new Promise((resolve, reject) => {
|
|
const xhr: XMLHttpRequest = new XMLHttpRequest();
|
|
xhr.responseType = 'text';
|
|
xhr.open('GET', environment.cicMetaUrl + window.location.search.substring(1));
|
|
xhr.setRequestHeader('Authorization', 'HOBA ' + hobaResponseEncoded);
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
xhr.setRequestHeader('x-cic-automerge', 'none');
|
|
xhr.addEventListener('load', (e) => {
|
|
if (xhr.status !== 200) {
|
|
const error = new HttpError(xhr.statusText, xhr.status);
|
|
return reject(error);
|
|
}
|
|
this.sessionToken = xhr.getResponseHeader('Token');
|
|
sessionStorage.setItem(btoa('CICADA_SESSION_TOKEN'), this.sessionToken);
|
|
this.sessionLoginCount++;
|
|
this.setState('Click button to log in');
|
|
return resolve(true);
|
|
});
|
|
xhr.send();
|
|
});
|
|
}
|
|
|
|
getChallenge(): void {
|
|
const xhr: XMLHttpRequest = new XMLHttpRequest();
|
|
xhr.responseType = 'arraybuffer';
|
|
xhr.open('GET', environment.cicMetaUrl + window.location.search.substring(1));
|
|
xhr.onload = async (e) => {
|
|
if (xhr.status === 401) {
|
|
const authHeader = xhr.getResponseHeader('WWW-Authenticate');
|
|
const o = hobaParseChallengeHeader(authHeader);
|
|
this.loginResponse(o);
|
|
}
|
|
};
|
|
xhr.send();
|
|
}
|
|
|
|
login(): boolean {
|
|
if (this.sessionToken !== undefined) {
|
|
try {
|
|
this.getWithToken();
|
|
return true;
|
|
} catch (e) {
|
|
this.loggingService.sendErrorLevelMessage('Login token failed', this, { error: e });
|
|
}
|
|
} else {
|
|
try {
|
|
this.getChallenge();
|
|
} catch (e) {
|
|
this.loggingService.sendErrorLevelMessage('Login challenge failed', this, { error: e });
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
async loginResponse(o: { challenge: string; realm: any }): Promise<any> {
|
|
return new Promise(async (resolve, reject) => {
|
|
try {
|
|
const r = await signChallenge(
|
|
o.challenge,
|
|
o.realm,
|
|
environment.cicMetaUrl,
|
|
this.mutableKeyStore
|
|
);
|
|
const sessionTokenResult: boolean = await this.sendResponse(r);
|
|
} catch (error) {
|
|
if (error instanceof HttpError) {
|
|
if (error.status === 403) {
|
|
this.errorDialogService.openDialog({
|
|
message: 'You are not authorized to use this system',
|
|
});
|
|
}
|
|
if (error.status === 401) {
|
|
this.errorDialogService.openDialog({
|
|
message:
|
|
'Unable to authenticate with the service. ' +
|
|
'Please speak with the staff at Grassroots ' +
|
|
'Economics for requesting access ' +
|
|
'staff@grassrootseconomics.net.',
|
|
});
|
|
}
|
|
}
|
|
// TODO define this error
|
|
this.errorDialogService.openDialog({ message: 'Incorrect key passphrase.' });
|
|
resolve(false);
|
|
}
|
|
});
|
|
}
|
|
|
|
loginView(): void {
|
|
document.getElementById('one').style.display = 'none';
|
|
document.getElementById('two').style.display = 'block';
|
|
this.setState('Click button to log in with PGP key ' + this.mutableKeyStore.getPrivateKeyId());
|
|
}
|
|
|
|
/**
|
|
* @throws
|
|
* @param privateKeyArmored - Private key.
|
|
*/
|
|
async setKey(privateKeyArmored): Promise<boolean> {
|
|
try {
|
|
const isValidKeyCheck = await this.mutableKeyStore.isValidKey(privateKeyArmored);
|
|
if (!isValidKeyCheck) {
|
|
throw Error('The private key is invalid');
|
|
}
|
|
// TODO leaving this out for now.
|
|
// const isEncryptedKeyCheck = await this.mutableKeyStore.isEncryptedPrivateKey(privateKeyArmored);
|
|
// if (!isEncryptedKeyCheck) {
|
|
// throw Error('The private key doesn\'t have a password!');
|
|
// }
|
|
const key = await this.mutableKeyStore.importPrivateKey(privateKeyArmored);
|
|
localStorage.setItem(btoa('CICADA_PRIVATE_KEY'), privateKeyArmored);
|
|
} catch (err) {
|
|
this.loggingService.sendErrorLevelMessage(
|
|
`Failed to set key: ${err.message || err.statusText}`,
|
|
this,
|
|
{ error: err }
|
|
);
|
|
this.errorDialogService.openDialog({
|
|
message: `Failed to set key: ${err.message || err.statusText}`,
|
|
});
|
|
return false;
|
|
}
|
|
this.loginView();
|
|
return true;
|
|
}
|
|
|
|
logout(): void {
|
|
sessionStorage.removeItem(btoa('CICADA_SESSION_TOKEN'));
|
|
this.sessionToken = undefined;
|
|
window.location.reload();
|
|
}
|
|
|
|
getTrustedUsers(): any {
|
|
const trustedUsers: Array<any> = [];
|
|
this.mutableKeyStore.getPublicKeys().forEach((key) => trustedUsers.push(key.users[0].userId));
|
|
return trustedUsers;
|
|
}
|
|
|
|
async getPublicKeys(): Promise<any> {
|
|
return await fetch(environment.publicKeysUrl).then((res) => {
|
|
if (!res.ok) {
|
|
// TODO does angular recommend an error interface?
|
|
throw Error(`${res.statusText} - ${res.status}`);
|
|
}
|
|
return res.text();
|
|
});
|
|
}
|
|
|
|
getPrivateKey(): any {
|
|
return this.mutableKeyStore.getPrivateKey();
|
|
}
|
|
}
|
|
</code></pre>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div><div class="search-results">
|
|
<div class="has-results">
|
|
<h1 class="search-results-title"><span class='search-results-count'></span> result-matching "<span class='search-query'></span>"</h1>
|
|
<ul class="search-results-list"></ul>
|
|
</div>
|
|
<div class="no-results">
|
|
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- END CONTENT -->
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
var COMPODOC_CURRENT_PAGE_DEPTH = 1;
|
|
var COMPODOC_CURRENT_PAGE_CONTEXT = 'injectable';
|
|
var COMPODOC_CURRENT_PAGE_URL = 'AuthService.html';
|
|
var MAX_SEARCH_RESULTS = 15;
|
|
</script>
|
|
|
|
<script src="../js/libs/custom-elements.min.js"></script>
|
|
<script src="../js/libs/lit-html.js"></script>
|
|
<!-- Required to polyfill modern browsers as code is ES5 for IE... -->
|
|
<script src="../js/libs/custom-elements-es5-adapter.js" charset="utf-8" defer></script>
|
|
<script src="../js/menu-wc.js" defer></script>
|
|
|
|
<script src="../js/libs/bootstrap-native.js"></script>
|
|
|
|
<script src="../js/libs/es6-shim.min.js"></script>
|
|
<script src="../js/libs/EventDispatcher.js"></script>
|
|
<script src="../js/libs/promise.min.js"></script>
|
|
<script src="../js/libs/zepto.min.js"></script>
|
|
|
|
<script src="../js/compodoc.js"></script>
|
|
|
|
<script src="../js/tabs.js"></script>
|
|
<script src="../js/menu.js"></script>
|
|
<script src="../js/libs/clipboard.min.js"></script>
|
|
<script src="../js/libs/prism.js"></script>
|
|
<script src="../js/sourceCode.js"></script>
|
|
<script src="../js/search/search.js"></script>
|
|
<script src="../js/search/lunr.min.js"></script>
|
|
<script src="../js/search/search-lunr.js"></script>
|
|
<script src="../js/search/search_index.js"></script>
|
|
<script src="../js/lazy-load-graphs.js"></script>
|
|
|
|
|
|
</body>
|
|
</html>
|