wealthica-sdk-js 0.0.15 → 0.0.17

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':
@@ -6446,8 +6451,10 @@ var API = /*#__PURE__*/function () {
6446
6451
  value: function _closeWidgetWithError(error_type, message) {
6447
6452
  this._closeWidget();
6448
6453
  this._triggerCallback(CALLBACK_ERROR, {
6449
- error_type: error_type,
6450
- message: message
6454
+ error: {
6455
+ error_type: error_type,
6456
+ message: message
6457
+ }
6451
6458
  });
6452
6459
  }
6453
6460
  }, {
@@ -6470,11 +6477,21 @@ var API = /*#__PURE__*/function () {
6470
6477
  var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6471
6478
  // onConnection and onError callbacks are only triggered once per widget session.
6472
6479
  if ([CALLBACK_CONNECTION, CALLBACK_ERROR].includes(callback)) {
6473
- // Mark widget as inactive so it's cleaned up by the doneWatcher.
6480
+ // Mark widget as inactive, so it's cleaned up by the doneWatcher.
6474
6481
  this._widgetActive = false;
6482
+ var additionalData = null;
6475
6483
  if (this._widgetOpened) {
6476
6484
  this._widgetOpened = false;
6477
- if (this[callback]) this[callback](payload);
6485
+ if (callback === CALLBACK_CONNECTION) {
6486
+ additionalData = {
6487
+ // Institution type passed only on success,
6488
+ // on error it appears in error object, so we don't need to duplicate it
6489
+ provider: payload.provider
6490
+ };
6491
+ }
6492
+ if (this[callback]) {
6493
+ this[callback](payload.institution || payload.error, additionalData);
6494
+ }
6478
6495
  }
6479
6496
  return;
6480
6497
  }
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':
@@ -6436,8 +6441,10 @@ var API = /*#__PURE__*/function () {
6436
6441
  value: function _closeWidgetWithError(error_type, message) {
6437
6442
  this._closeWidget();
6438
6443
  this._triggerCallback(CALLBACK_ERROR, {
6439
- error_type: error_type,
6440
- message: message
6444
+ error: {
6445
+ error_type: error_type,
6446
+ message: message
6447
+ }
6441
6448
  });
6442
6449
  }
6443
6450
  }, {
@@ -6460,11 +6467,21 @@ var API = /*#__PURE__*/function () {
6460
6467
  var payload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
6461
6468
  // onConnection and onError callbacks are only triggered once per widget session.
6462
6469
  if ([CALLBACK_CONNECTION, CALLBACK_ERROR].includes(callback)) {
6463
- // Mark widget as inactive so it's cleaned up by the doneWatcher.
6470
+ // Mark widget as inactive, so it's cleaned up by the doneWatcher.
6464
6471
  this._widgetActive = false;
6472
+ var additionalData = null;
6465
6473
  if (this._widgetOpened) {
6466
6474
  this._widgetOpened = false;
6467
- if (this[callback]) this[callback](payload);
6475
+ if (callback === CALLBACK_CONNECTION) {
6476
+ additionalData = {
6477
+ // Institution type passed only on success,
6478
+ // on error it appears in error object, so we don't need to duplicate it
6479
+ provider: payload.provider
6480
+ };
6481
+ }
6482
+ if (this[callback]) {
6483
+ this[callback](payload.institution || payload.error, additionalData);
6484
+ }
6468
6485
  }
6469
6486
  return;
6470
6487
  }