Comparing version 0.1.10 to 0.1.12
@@ -24,2 +24,3 @@ ## Classes | ||
* [.connect()](#Elarian+connect) | ||
* [.isConnected()](#Elarian+isConnected) | ||
* [.disconnect()](#Elarian+disconnect) | ||
@@ -86,2 +87,8 @@ * [.sendMessage(customer, channelNumber, message)](#Elarian+sendMessage) ⇒ <code>MessageStatus</code> | ||
**Kind**: instance method of [<code>Elarian</code>](#Elarian) | ||
<a name="Elarian+isConnected"></a> | ||
### elarian.isConnected() | ||
<p>Check if client is connected</p> | ||
**Kind**: instance method of [<code>Elarian</code>](#Elarian) | ||
<a name="Elarian+disconnect"></a> | ||
@@ -88,0 +95,0 @@ |
@@ -61,2 +61,6 @@ /* global window */ | ||
if (!opts.apiKey && !opts.authToken) { | ||
throw new Error('Either one of apiKey or authToken is required'); | ||
} | ||
const error = validate(opts, constraints); | ||
@@ -78,2 +82,5 @@ if (error) { | ||
data: null, | ||
connection: null, | ||
// eslint-disable-next-line no-console | ||
error: (err) => this.platform.log.error('Elarian Client Error: ', err), | ||
@@ -122,2 +129,11 @@ // Simulator | ||
platform: this.platform, | ||
errorHandler: this.eventListeners.error, | ||
connectionHandler: (status, err) => { | ||
if (['CLOSED', 'ERROR'].includes(status) && this._socket) { | ||
this.disconnect(); | ||
} | ||
if (this.eventListeners.connection) { | ||
this.eventListeners.connection(status, err); | ||
} | ||
}, | ||
notificationHandler: this.notificationHandler(this), | ||
@@ -137,2 +153,9 @@ }); | ||
/** | ||
* Check if client is connected | ||
*/ | ||
this.isConnected = function isConnected() { | ||
return this._client && this._socket; | ||
}; | ||
/** | ||
* Disconnect from the elarian server | ||
@@ -144,2 +167,4 @@ */ | ||
} | ||
this._client = null; | ||
this._socket = null; | ||
}; | ||
@@ -146,0 +171,0 @@ |
@@ -305,3 +305,3 @@ /* eslint-disable max-len */ | ||
} catch (error) { | ||
log.error(`NotificationError::${event}: `, error.message || error); | ||
log.error(`NotificationReplyError::${event}: `, error.message || error); | ||
} | ||
@@ -308,0 +308,0 @@ }) |
@@ -912,3 +912,3 @@ const Elarian = require('./client'); | ||
resolve(result.value); | ||
resolve(result.value || {}); | ||
} catch (ex) { | ||
@@ -915,0 +915,0 @@ reject(ex); |
@@ -495,2 +495,4 @@ const { RSocketClient } = require('rsocket-core'); | ||
keepAlive, | ||
errorHandler, | ||
connectionHandler, | ||
notificationHandler, | ||
@@ -517,4 +519,6 @@ } = connectionOptions; | ||
const transport = getTransport({ | ||
/* FIXME: This disables resumable transport | ||
resumeToken: Buffer.from(appId), | ||
sessionDurationSeconds: lifetime / 1000, | ||
*/ | ||
}); | ||
@@ -554,2 +558,5 @@ const client = new RSocketClient({ | ||
log.debug(`Transport status changed: ${status.kind}`); | ||
if (connectionHandler) { | ||
connectionHandler(status.kind, status.error); | ||
} | ||
if (status.kind === 'NOT_CONNECTED') { | ||
@@ -564,5 +571,16 @@ if (!started) { | ||
}, | ||
onError: (error) => { | ||
log.debug(`Transport error: ${error}`); | ||
if (errorHandler) { | ||
errorHandler(error); | ||
} | ||
}, | ||
onSubscribe: (subscription) => { | ||
log.debug('Transport subscribed'); | ||
subscription.request(Number.MAX_SAFE_INTEGER); | ||
}, | ||
onComplete: (signal) => { | ||
log.debug(`Transport closed: ${signal}`); | ||
}, | ||
}); | ||
@@ -569,0 +587,0 @@ |
{ | ||
"name": "elarian", | ||
"version": "0.1.10", | ||
"version": "0.1.12", | ||
"description": "Elrian JavaScript SDK", | ||
@@ -11,3 +11,6 @@ "main": "index.js", | ||
"lint": "eslint .", | ||
"build": "rm -rf docs/ dist/ && jsdoc -t node_modules/tsd-jsdoc/dist -c .jsdoc -R README.md -r lib/ && mv docs/types.d.ts ./ && jsdoc2md -c .jsdoc --files lib/** > docs/README.md && webpack", | ||
"build": "rm -rf docs/ dist/ && npm run build:types && npm run build:docs && npm run build:web", | ||
"build:types": "jsdoc -t node_modules/tsd-jsdoc/dist -c .jsdoc -r lib/ && mv docs/types.d.ts ./ ", | ||
"build:docs": "jsdoc -c .jsdoc -R README.md -r lib/ && jsdoc2md -c .jsdoc --files lib/** > docs/README.md", | ||
"build:web": "webpack", | ||
"prepublish": "npm run build" | ||
@@ -14,0 +17,0 @@ }, |
@@ -15,2 +15,6 @@ /** | ||
/** | ||
* <p>Check if client is connected</p> | ||
*/ | ||
isConnected(): void; | ||
/** | ||
* <p>Disconnect from the elarian server</p> | ||
@@ -17,0 +21,0 @@ */ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9752962
100
171816
2
3
4
16