mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-06-01 15:30:43 +00:00
466 lines
11 KiB
HTML
466 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset='UTF-8'>
|
|
<title>CoffeeScript API Documentation</title>
|
|
<script src='../../../../javascript/application.js'></script>
|
|
<script src='../../../../javascript/search.js'></script>
|
|
<link rel='stylesheet' href='../../../../stylesheets/application.css' type='text/css'>
|
|
</head>
|
|
<body>
|
|
<div id='base' data-path='../../../../'></div>
|
|
<div id='header'>
|
|
<div id='menu'>
|
|
<a href='../../../../alphabetical_index.html' title='Index'>
|
|
Index
|
|
</a>
|
|
»
|
|
<span class='title'>lib</span>
|
|
»
|
|
<span class='title'>resin</span>
|
|
»
|
|
<span class='title'>auth</span>
|
|
»
|
|
<span class='title'>auth.coffee</span>
|
|
</div>
|
|
</div>
|
|
<div id='content'>
|
|
<h1>
|
|
File:
|
|
auth.coffee
|
|
</h1>
|
|
<table class='box'>
|
|
<tr>
|
|
<td>Defined in:</td>
|
|
<td>lib/resin/auth</td>
|
|
</tr>
|
|
</table>
|
|
<h2>Method Summary</h2>
|
|
<ul class='summary'>
|
|
<li>
|
|
<span class='signature'>
|
|
<a href='#authenticate-'>
|
|
~
|
|
(void)
|
|
<b>authenticate</b><span>(credentials, callback)</span>
|
|
</a>
|
|
</span>
|
|
<span class='note private title'>Private</span>
|
|
<span class='desc'>
|
|
Authenticate with the server <pre><code>resin.auth.authenticate credentials, (error, token) -> throw error if error? console.log(token)
|
|
</code></pre>
|
|
</span>
|
|
</li>
|
|
<li>
|
|
<span class='signature'>
|
|
<a href='#login-'>
|
|
~
|
|
(void)
|
|
<b>login</b><span>(credentials, callback)</span>
|
|
</a>
|
|
</span>
|
|
<span class='desc'>
|
|
Login to Resin.io <p>Is the login is successful, the token is persisted between sessions.</p>
|
|
</span>
|
|
</li>
|
|
<li>
|
|
<span class='signature'>
|
|
<a href='#isLoggedIn-'>
|
|
~
|
|
(void)
|
|
<b>isLoggedIn</b><span>(callback)</span>
|
|
</a>
|
|
</span>
|
|
<span class='desc'>
|
|
Check if you're logged in <pre><code>resin.auth.isLoggedIn (isLoggedIn) -> if isLoggedIn
|
|
console.log('I\'m in!') else
|
|
console.log('Too bad!')
|
|
</code></pre>
|
|
</span>
|
|
</li>
|
|
<li>
|
|
<span class='signature'>
|
|
<a href='#getToken-'>
|
|
~
|
|
(void)
|
|
<b>getToken</b><span>(callback)</span>
|
|
</a>
|
|
</span>
|
|
<span class='desc'>
|
|
Get current logged in user's token <pre><code>resin.auth.getToken (error, token) -> throw error if error? console.log(token)
|
|
</code></pre>
|
|
</span>
|
|
</li>
|
|
<li>
|
|
<span class='signature'>
|
|
<a href='#logout-'>
|
|
~
|
|
(void)
|
|
<b>logout</b><span>(callback)</span>
|
|
</a>
|
|
</span>
|
|
<span class='desc'>
|
|
Logout from Resin.io <pre><code>resin.auth.logout (error) -> throw error if error? console.log('I\'m out!')
|
|
</code></pre>
|
|
</span>
|
|
</li>
|
|
<li>
|
|
<span class='signature'>
|
|
<a href='#parseCredentials-'>
|
|
~
|
|
(void)
|
|
<b>parseCredentials</b><span>(credentials, callback)</span>
|
|
</a>
|
|
</span>
|
|
<span class='note private title'>Private</span>
|
|
<span class='desc'>
|
|
Parse colon separated credentials <pre><code>resin.auth.parseCredentials 'johndoe:secret', (error, credentials) -> throw error if error? console.log(credentials.username) console.log(credentials.password)
|
|
</code></pre>
|
|
</span>
|
|
</li>
|
|
</ul>
|
|
<h2>Method Details</h2>
|
|
<div class='methods'>
|
|
<div class='method_details'>
|
|
<p class='signature' id='authenticate-'>
|
|
~
|
|
(void)
|
|
<b>authenticate</b><span>(credentials, callback)</span>
|
|
<span class='note private'>Private</span>
|
|
<br>
|
|
</p>
|
|
<div class='docstring'>
|
|
<div class='note'>
|
|
<strong>Note:</strong>
|
|
You should use login() when possible, as it takes care of saving the token as well.
|
|
</div>
|
|
<p>Authenticate with the server</p><pre><code>resin.auth.authenticate credentials, (error, token) -> throw error if error? console.log(token)
|
|
</code></pre>
|
|
</div>
|
|
<div class='tags'>
|
|
<h3>Parameters:</h3>
|
|
<ul class='param'>
|
|
<li>
|
|
<span class='name'>credentials</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>Object</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>in the form of username, password </span>
|
|
</li>
|
|
<li>
|
|
<span class='name'>callback</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>Function</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>callback (error, token) </span>
|
|
</li>
|
|
</ul>
|
|
<h3>
|
|
Options Hash:
|
|
(credentials):
|
|
</h3>
|
|
<ul class='options'>
|
|
<li>
|
|
<span class='name'>username</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>String</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>the username </span>
|
|
</li>
|
|
<li>
|
|
<span class='name'>password</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>String</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>user password </span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class='method_details'>
|
|
<p class='signature' id='login-'>
|
|
~
|
|
(void)
|
|
<b>login</b><span>(credentials, callback)</span>
|
|
<br>
|
|
</p>
|
|
<div class='docstring'>
|
|
<div class='note'>
|
|
<strong>Note:</strong>
|
|
This function saves the token to the directory configured in dataPrefix
|
|
</div>
|
|
<p>Login to Resin.io</p><p>Is the login is successful, the token is persisted between sessions.</p><pre><code>resin.auth.login credentials, (error) -> throw error if error? console.log('I\'m logged in!')
|
|
</code></pre>
|
|
</div>
|
|
<div class='tags'>
|
|
<h3>Parameters:</h3>
|
|
<ul class='param'>
|
|
<li>
|
|
<span class='name'>credentials</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>Object</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>in the form of username, password </span>
|
|
</li>
|
|
<li>
|
|
<span class='name'>callback</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>Function</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>callback (error) </span>
|
|
</li>
|
|
</ul>
|
|
<h3>
|
|
Options Hash:
|
|
(credentials):
|
|
</h3>
|
|
<ul class='options'>
|
|
<li>
|
|
<span class='name'>username</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>String</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>the username </span>
|
|
</li>
|
|
<li>
|
|
<span class='name'>password</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>String</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>user password </span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class='method_details'>
|
|
<p class='signature' id='isLoggedIn-'>
|
|
~
|
|
(void)
|
|
<b>isLoggedIn</b><span>(callback)</span>
|
|
<br>
|
|
</p>
|
|
<div class='docstring'>
|
|
<p>Check if you're logged in</p><pre><code>resin.auth.isLoggedIn (isLoggedIn) -> if isLoggedIn
|
|
console.log('I\'m in!') else
|
|
console.log('Too bad!')
|
|
</code></pre>
|
|
</div>
|
|
<div class='tags'>
|
|
<h3>Parameters:</h3>
|
|
<ul class='param'>
|
|
<li>
|
|
<span class='name'>callback</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>Function</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>callback (isLoggedIn) </span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class='method_details'>
|
|
<p class='signature' id='getToken-'>
|
|
~
|
|
(void)
|
|
<b>getToken</b><span>(callback)</span>
|
|
<br>
|
|
</p>
|
|
<div class='docstring'>
|
|
<div class='note'>
|
|
<strong>Note:</strong>
|
|
This function simply delegates to resin.token.getToken() for convenience
|
|
</div>
|
|
<p>Get current logged in user's token</p><pre><code>resin.auth.getToken (error, token) -> throw error if error? console.log(token)
|
|
</code></pre>
|
|
</div>
|
|
<div class='tags'>
|
|
<h3>Parameters:</h3>
|
|
<ul class='param'>
|
|
<li>
|
|
<span class='name'>callback</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>Function</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>callback (error, isLoggedIn) </span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class='method_details'>
|
|
<p class='signature' id='logout-'>
|
|
~
|
|
(void)
|
|
<b>logout</b><span>(callback)</span>
|
|
<br>
|
|
</p>
|
|
<div class='docstring'>
|
|
<div class='note todo'>
|
|
<strong>TODO:</strong>
|
|
Maybe we should post to /logout or something to invalidate the token on the server?
|
|
</div>
|
|
<p>Logout from Resin.io</p><pre><code>resin.auth.logout (error) -> throw error if error? console.log('I\'m out!')
|
|
</code></pre>
|
|
</div>
|
|
<div class='tags'>
|
|
<h3>Parameters:</h3>
|
|
<ul class='param'>
|
|
<li>
|
|
<span class='name'>callback</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>Function</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>callback (error) </span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<div class='method_details'>
|
|
<p class='signature' id='parseCredentials-'>
|
|
~
|
|
(void)
|
|
<b>parseCredentials</b><span>(credentials, callback)</span>
|
|
<span class='note private'>Private</span>
|
|
<br>
|
|
</p>
|
|
<div class='docstring'>
|
|
<div class='note todo'>
|
|
<strong>TODO:</strong>
|
|
This should be moved somewhere else, as it only used by the auth actions
|
|
</div>
|
|
<p>Parse colon separated credentials</p><pre><code>resin.auth.parseCredentials 'johndoe:secret', (error, credentials) -> throw error if error? console.log(credentials.username) console.log(credentials.password)
|
|
</code></pre>
|
|
</div>
|
|
<div class='tags'>
|
|
<h3>Parameters:</h3>
|
|
<ul class='param'>
|
|
<li>
|
|
<span class='name'>colon</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>String</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>separated credentials (username:password) </span>
|
|
</li>
|
|
<li>
|
|
<span class='name'>callback</span>
|
|
<span class='type'>
|
|
(
|
|
<tt>Function</tt>
|
|
)
|
|
</span>
|
|
—
|
|
<span class='desc'>callback (error, credentials) </span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id='footer'>
|
|
December 09, 14 12:47:37 by
|
|
<a href='https://github.com/coffeedoc/codo' title='CoffeeScript API documentation generator'>
|
|
Codo
|
|
</a>
|
|
2.0.9
|
|
✲
|
|
Press H to see the keyboard shortcuts
|
|
✲
|
|
<a href='http://twitter.com/netzpirat' target='_parent'>@netzpirat</a>
|
|
✲
|
|
<a href='http://twitter.com/_inossidabile' target='_parent'>@_inossidabile</a>
|
|
</div>
|
|
<iframe id='search_frame'></iframe>
|
|
<div id='fuzzySearch'>
|
|
<input type='text'>
|
|
<ol></ol>
|
|
</div>
|
|
<div id='help'>
|
|
<p>
|
|
Quickly fuzzy find classes, mixins, methods, file:
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
<span>T</span>
|
|
Open fuzzy finder dialog
|
|
</li>
|
|
</ul>
|
|
<p>
|
|
Control the navigation frame:
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
<span>L</span>
|
|
Toggle list view
|
|
</li>
|
|
<li>
|
|
<span>C</span>
|
|
Show class list
|
|
</li>
|
|
<li>
|
|
<span>I</span>
|
|
Show mixin list
|
|
</li>
|
|
<li>
|
|
<span>F</span>
|
|
Show file list
|
|
</li>
|
|
<li>
|
|
<span>M</span>
|
|
Show method list
|
|
</li>
|
|
<li>
|
|
<span>E</span>
|
|
Show extras list
|
|
</li>
|
|
</ul>
|
|
<p>
|
|
You can focus and blur the search input:
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
<span>S</span>
|
|
Focus search input
|
|
</li>
|
|
<li>
|
|
<span>Esc</span>
|
|
Blur search input
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html> |