Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
aksalj committed Feb 1, 2024
2 parents ddc3a03 + 1f83fe4 commit fdbdaee
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 55 deletions.
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,17 @@ const elarian = await initializeClient({
appId: 'YOUR_APP_ID',
});

elarian.on('consentDenied', (userId, data) => {
elarian.on('consentDenied', (userId) => {
// ...
});

elarian.on('consentGranted', (userId, data) => {
// ...
});

const userId = 'abc...';
const { state } = await elarian.fetchAppState();
const data = JSON.parse(state.toString());
await elarian.updateAppState({ state: Buffer.from(JSON.stringify({ ...data, status: 'good boy' })) });
await elarian.updateAppState(Buffer.from(JSON.stringify({ ...data, status: 'good boy' })));

```

Expand Down Expand Up @@ -65,5 +68,5 @@ If you find a bug, please file an issue on [our issue tracker on GitHub](https:/

## Known Issues

- Missing method to lease/get/fetch user metadata
- `resumable` connection options prevents app from connecting
- Missing partial state updates
- Missing consent event notifications
2 changes: 1 addition & 1 deletion docs/Client.html
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.ht
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Jan 31 2024 10:52:19 GMT+0300 (East Africa Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Feb 01 2024 09:46:21 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
6 changes: 3 additions & 3 deletions docs/Elarian.html
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ <h4 class="name" id="fetchAppState"><span class="type-signature"></span>fetchApp

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="elarian.js.html">elarian.js</a>, <a href="elarian.js.html#line37">line 37</a>
<a href="elarian.js.html">elarian.js</a>, <a href="elarian.js.html#line29">line 29</a>
</li></ul></dd>


Expand Down Expand Up @@ -1109,7 +1109,7 @@ <h5>Parameters:</h5>

<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="elarian.js.html">elarian.js</a>, <a href="elarian.js.html#line61">line 61</a>
<a href="elarian.js.html">elarian.js</a>, <a href="elarian.js.html#line53">line 53</a>
</li></ul></dd>


Expand Down Expand Up @@ -1179,7 +1179,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.ht
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Jan 31 2024 10:52:19 GMT+0300 (East Africa Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Feb 01 2024 09:46:21 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
10 changes: 5 additions & 5 deletions docs/client.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h1 class="page-title">Source: client.js</h1>
* @param {ClientConfig} config
*/
function Client(config) {
const opts = {
const conf = {
...config,
};
const constraints = {
Expand All @@ -59,19 +59,19 @@ <h1 class="page-title">Source: client.js</h1>
},
};

const error = validate(opts, constraints);
const error = validate(conf, constraints);
if (error) {
throw error;
}

this.config = {
options: {
...conf,
options: conf.options || {
uris: {
social: 'id.elarian.com:443',
state: 'api.elarian.com:443',
},
},
...opts,
};
this._socialService = null;
this._appStateService = null;
Expand Down Expand Up @@ -221,7 +221,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.ht
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Jan 31 2024 10:52:19 GMT+0300 (East Africa Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Feb 01 2024 09:46:21 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
18 changes: 5 additions & 13 deletions docs/elarian.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,18 @@ <h1 class="page-title">Source: elarian.js</h1>

Elarian.prototype = Object.create(Client.prototype, { constructor: Elarian });

Elarian.prototype.fetchUserData = function fetchUserData() {
throw new Error('Not implemented');
};

Elarian.prototype.updateUserData = function updateUserData() {
throw new Error('Not implemented');
};

/**
* Lease app state
* @returns {AppState}
* @memberof Elarian
*/
Elarian.prototype.fetchAppState = function fetchAppState() {
const { appId, sessionId } = this.config;
const { appId, token } = this.config;
const service = this._getAppStateService();
return new Promise((resolve, reject) => {
const params = {
appId,
sessionId,
token,
};
service.GetAppState(params, (error, result) => {
if (error) {
Expand All @@ -91,14 +83,14 @@ <h1 class="page-title">Source: elarian.js</h1>
throw new Error('id and data are required');
}

const { appId, sessionId } = this.config;
const { appId, token } = this.config;
const service = this._getAppStateService();

return new Promise((resolve, reject) => {
const params = {
state: {
appId,
sessionId,
token,
state: data,
},
};
Expand Down Expand Up @@ -129,7 +121,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.ht
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Jan 31 2024 10:52:19 GMT+0300 (East Africa Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Feb 01 2024 09:46:21 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/global.html
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.ht
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Jan 31 2024 10:52:19 GMT+0300 (East Africa Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Feb 01 2024 09:46:21 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
15 changes: 9 additions & 6 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,17 @@ <h2>Usage</h2>
appId: 'YOUR_APP_ID',
});

elarian.on('consentDenied', (userId, data) => {
elarian.on('consentDenied', (userId) => {
// ...
});

elarian.on('consentGranted', (userId, data) => {
// ...
});

const userId = 'abc...';
const { state } = await elarian.fetchAppState();
const data = JSON.parse(state.toString());
await elarian.updateAppState({ state: Buffer.from(JSON.stringify({ ...data, status: 'good boy' })) });
await elarian.updateAppState(Buffer.from(JSON.stringify({ ...data, status: 'good boy' })));

</code></pre>
<h2>Documentation</h2>
Expand All @@ -90,8 +93,8 @@ <h2>Issues</h2>
<p>If you find a bug, please file an issue on <a href="https://github.com/ElarianLtd/javascript-sdk/issues">our issue tracker on GitHub</a>.</p>
<h2>Known Issues</h2>
<ul>
<li>Missing method to lease/get/fetch user metadata</li>
<li><code>resumable</code> connection options prevents app from connecting</li>
<li>Missing partial state updates</li>
<li>Missing consent event notifications</li>
</ul></article>
</section>

Expand All @@ -109,7 +112,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.ht
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Jan 31 2024 10:52:19 GMT+0300 (East Africa Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Feb 01 2024 09:46:21 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.ht
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Jan 31 2024 10:52:19 GMT+0300 (East Africa Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Feb 01 2024 09:46:21 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
2 changes: 1 addition & 1 deletion docs/utils_types.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Client.ht
<br class="clear">

<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Wed Jan 31 2024 10:52:19 GMT+0300 (East Africa Time)
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.2</a> on Thu Feb 01 2024 09:46:21 GMT+0300 (East Africa Time)
</footer>

<script> prettyPrint(); </script>
Expand Down
8 changes: 4 additions & 4 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { log } = utils;
* @param {ClientConfig} config
*/
function Client(config) {
const opts = {
const conf = {
...config,
};
const constraints = {
Expand All @@ -31,19 +31,19 @@ function Client(config) {
},
};

const error = validate(opts, constraints);
const error = validate(conf, constraints);
if (error) {
throw error;
}

this.config = {
options: {
...conf,
options: conf.options || {
uris: {
social: 'id.elarian.com:443',
state: 'api.elarian.com:443',
},
},
...opts,
};
this._socialService = null;
this._appStateService = null;
Expand Down
16 changes: 4 additions & 12 deletions lib/elarian.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,18 @@ function Elarian(config) {

Elarian.prototype = Object.create(Client.prototype, { constructor: Elarian });

Elarian.prototype.fetchUserData = function fetchUserData() {
throw new Error('Not implemented');
};

Elarian.prototype.updateUserData = function updateUserData() {
throw new Error('Not implemented');
};

/**
* Lease app state
* @returns {AppState}
* @memberof Elarian
*/
Elarian.prototype.fetchAppState = function fetchAppState() {
const { appId, sessionId } = this.config;
const { appId, token } = this.config;
const service = this._getAppStateService();
return new Promise((resolve, reject) => {
const params = {
appId,
sessionId,
token,
};
service.GetAppState(params, (error, result) => {
if (error) {
Expand All @@ -63,14 +55,14 @@ Elarian.prototype.updateAppState = function updateAppState(data) {
throw new Error('id and data are required');
}

const { appId, sessionId } = this.config;
const { appId, token } = this.config;
const service = this._getAppStateService();

return new Promise((resolve, reject) => {
const params = {
state: {
appId,
sessionId,
token,
state: data,
},
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elarian",
"version": "0.5.3",
"version": "0.5.4",
"description": "Elarian JavaScript SDK",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions test/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ module.exports = {
GetAppState: (call, callback) => {
const res = proto.AppState.constructor({
appId: process.env.APP_ID,
sessionId: process.env.SESSION_ID,
token: process.env.TOKEN,
state: Buffer.from(JSON.stringify({ abc: 1 })),
});
callback(null, res);
},
UpdateAppState: (call, callback) => {
const res = proto.AppState.constructor({
appId: process.env.APP_ID,
sessionId: process.env.SESSION_ID,
token: process.env.TOKEN,
state: Buffer.from(JSON.stringify({ abc: 1 })),
});
callback(null, res);
Expand Down

0 comments on commit fdbdaee

Please sign in to comment.