wealthica-sdk-js 0.0.15 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -238,7 +238,8 @@ This method accepts the same parameters as `user.getConnectData()` except for `r
238
238
  ```javascript
239
239
  user.connect({
240
240
  // additional options
241
- }).onConnection(institution => {
241
+ }).onConnection((institution, data) => {
242
+ console.log('provider', data.provider);
242
243
  // Send the institution to your server
243
244
  sendToServer('/some-route', institution);
244
245
  }).onError(error => {
@@ -257,7 +258,8 @@ Connection response are provided via callbacks.
257
258
  ```javascript
258
259
  user.reconnect('INSTITUTION_ID', {
259
260
  // additional options
260
- }).onConnection(institution => {
261
+ }).onConnection(((institution, data) => {
262
+ console.log('provider', data.provider);
261
263
  // Send the institution to your server
262
264
  sendToServer('/some-route', institution);
263
265
  }).onError(error => {
@@ -6391,13 +6391,18 @@ var API = /*#__PURE__*/function () {
6391
6391
  case 'success':
6392
6392
  {
6393
6393
  // Connection success
6394
- this._triggerCallback(CALLBACK_CONNECTION, result.institution);
6394
+ this._triggerCallback(CALLBACK_CONNECTION, {
6395
+ institution: result.institution,
6396
+ provider: result.provider
6397
+ });
6395
6398
  break;
6396
6399
  }
6397
6400
  case 'error':
6398
6401
  {
6399
6402
  // Connection error
6400
- this._triggerCallback(CALLBACK_ERROR, result.error);
6403
+ this._triggerCallback(CALLBACK_ERROR, {
6404
+ error: result.error
6405
+ });
6401
6406
  break;
6402
6407
  }
6403
6408
  case 'close':
@@ -6470,11 +6475,21 @@ var API = /*#__PURE__*/function () {
6470
6475
  var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6471
6476
  // onConnection and onError callbacks are only triggered once per widget session.
6472
6477
  if ([CALLBACK_CONNECTION, CALLBACK_ERROR].includes(callback)) {
6473
- // Mark widget as inactive so it's cleaned up by the doneWatcher.
6478
+ // Mark widget as inactive, so it's cleaned up by the doneWatcher.
6474
6479
  this._widgetActive = false;
6480
+ var additionalData = null;
6475
6481
  if (this._widgetOpened) {
6476
6482
  this._widgetOpened = false;
6477
- if (this[callback]) this[callback](payload);
6483
+ if (callback === CALLBACK_CONNECTION) {
6484
+ additionalData = {
6485
+ // Institution type passed only on success,
6486
+ // on error it appears in error object, so we don't need to duplicate it
6487
+ provider: payload.provider
6488
+ };
6489
+ }
6490
+ if (this[callback]) {
6491
+ this[callback](payload.institution || payload.error, additionalData);
6492
+ }
6478
6493
  }
6479
6494
  return;
6480
6495
  }
package/dist/wealthica.js CHANGED
@@ -6381,13 +6381,18 @@ var API = /*#__PURE__*/function () {
6381
6381
  case 'success':
6382
6382
  {
6383
6383
  // Connection success
6384
- this._triggerCallback(CALLBACK_CONNECTION, result.institution);
6384
+ this._triggerCallback(CALLBACK_CONNECTION, {
6385
+ institution: result.institution,
6386
+ provider: result.provider
6387
+ });
6385
6388
  break;
6386
6389
  }
6387
6390
  case 'error':
6388
6391
  {
6389
6392
  // Connection error
6390
- this._triggerCallback(CALLBACK_ERROR, result.error);
6393
+ this._triggerCallback(CALLBACK_ERROR, {
6394
+ error: result.error
6395
+ });
6391
6396
  break;
6392
6397
  }
6393
6398
  case 'close':
@@ -6460,11 +6465,21 @@ var API = /*#__PURE__*/function () {
6460
6465
  var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6461
6466
  // onConnection and onError callbacks are only triggered once per widget session.
6462
6467
  if ([CALLBACK_CONNECTION, CALLBACK_ERROR].includes(callback)) {
6463
- // Mark widget as inactive so it's cleaned up by the doneWatcher.
6468
+ // Mark widget as inactive, so it's cleaned up by the doneWatcher.
6464
6469
  this._widgetActive = false;
6470
+ var additionalData = null;
6465
6471
  if (this._widgetOpened) {
6466
6472
  this._widgetOpened = false;
6467
- if (this[callback]) this[callback](payload);
6473
+ if (callback === CALLBACK_CONNECTION) {
6474
+ additionalData = {
6475
+ // Institution type passed only on success,
6476
+ // on error it appears in error object, so we don't need to duplicate it
6477
+ provider: payload.provider
6478
+ };
6479
+ }
6480
+ if (this[callback]) {
6481
+ this[callback](payload.institution || payload.error, additionalData);
6482
+ }
6468
6483
  }
6469
6484
  return;
6470
6485
  }