wealthica-sdk-js 0.0.18 → 0.0.19

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
@@ -272,6 +272,49 @@ user.reconnect('INSTITUTION_ID', {
272
272
  });
273
273
  ```
274
274
 
275
+ ### Feature Flags
276
+
277
+ The `features` parameter accepts a comma-separated list of feature flags to enable specific behaviors in the Connect widget.
278
+
279
+ #### Available Feature Flags
280
+
281
+ **`quick_retry`** *(Available from v0.0.19+)*
282
+
283
+ Enables a quick retry option when temporary connection failures occur (e.g., timeout, temporary API issues).
284
+
285
+ - **Default:** Disabled
286
+ - **Behavior:** When enabled, users see a retry button instead of automatic widget closure after temporary failures
287
+ - **Retry Limit:** One retry attempt per session
288
+
289
+ **Usage Example:**
290
+
291
+ ```javascript
292
+ // Enable quick retry feature
293
+ user.connect({
294
+ provider: 'td',
295
+ features: 'quick_retry',
296
+ // ... other options
297
+ }).onConnection((institution) => {
298
+ console.log('Connected:', institution);
299
+ }).onError((error) => {
300
+ console.error('Error:', error);
301
+ }).onEvent((name, data) => {
302
+ // Listen for retry events
303
+ if (name === 'RETRY_ATTEMPT') {
304
+ console.log('User is retrying connection');
305
+ }
306
+ if (name === 'RETRY_DECLINED') {
307
+ console.log('User declined to retry');
308
+ }
309
+ });
310
+
311
+ // Enable multiple features
312
+ user.connect({
313
+ features: 'quick_retry,another_feature',
314
+ // ... other options
315
+ });
316
+ ```
317
+
275
318
  ### User APIs
276
319
 
277
320
  These methods return user data and thus require a Wealthica Connect SDK User instance. They automatically fetch a new token if necessary so you would not be bothered with tokens logic.
@@ -96,6 +96,10 @@ type ConnectDataOptions = {
96
96
  redirectURI: string;
97
97
  providers: Array<string> | undefined;
98
98
  providerGroups: Array<string> | undefined;
99
+ theme: string;
100
+ providersPerLine: number | string;
101
+ features: string;
102
+ webhookURI: string;
99
103
  }
100
104
 
101
105
  type ConnectData = {
@@ -96,6 +96,10 @@ type ConnectDataOptions = {
96
96
  redirectURI: string;
97
97
  providers: Array<string> | undefined;
98
98
  providerGroups: Array<string> | undefined;
99
+ theme: string;
100
+ providersPerLine: number | string;
101
+ features: string;
102
+ webhookURI: string;
99
103
  }
100
104
 
101
105
  type ConnectData = {
@@ -6000,6 +6000,7 @@ var API = /*#__PURE__*/function () {
6000
6000
  this._onWidgetMessage = this._onMessage.bind(this);
6001
6001
  this._widgetOpened = false;
6002
6002
  this._widgetActive = false;
6003
+ this._features = null;
6003
6004
  }
6004
6005
  _createClass(API, [{
6005
6006
  key: "_init",
@@ -6342,8 +6343,9 @@ var API = /*#__PURE__*/function () {
6342
6343
  case 0:
6343
6344
  _context5.prev = 0;
6344
6345
  _this._widgetOpened = true;
6345
- provider = options.provider, providers = options.providers, providerGroups = options.providerGroups, institutionId = options.institutionId, lang = options.lang, theme = options.theme, providersPerLine = options.providersPerLine, features = options.features, connectionType = options.connectionType, origin = options.origin, webhookURI = options.webhookURI;
6346
- _context5.next = 5;
6346
+ provider = options.provider, providers = options.providers, providerGroups = options.providerGroups, institutionId = options.institutionId, lang = options.lang, theme = options.theme, providersPerLine = options.providersPerLine, features = options.features, connectionType = options.connectionType, origin = options.origin, webhookURI = options.webhookURI; // Store features for timeout calculation
6347
+ _this._features = features;
6348
+ _context5.next = 6;
6347
6349
  return _this.getConnectData({
6348
6350
  provider: provider,
6349
6351
  providers: providers,
@@ -6356,7 +6358,7 @@ var API = /*#__PURE__*/function () {
6356
6358
  origin: origin,
6357
6359
  webhookURI: webhookURI
6358
6360
  });
6359
- case 5:
6361
+ case 6:
6360
6362
  _yield$_this$getConne = _context5.sent;
6361
6363
  url = _yield$_this$getConne.url;
6362
6364
  token = _yield$_this$getConne.token;
@@ -6378,18 +6380,18 @@ var API = /*#__PURE__*/function () {
6378
6380
  _this._widgetActive = true;
6379
6381
  _this._addListeners();
6380
6382
  _this._addWatchers();
6381
- _context5.next = 19;
6383
+ _context5.next = 20;
6382
6384
  break;
6383
- case 16:
6384
- _context5.prev = 16;
6385
+ case 17:
6386
+ _context5.prev = 17;
6385
6387
  _context5.t0 = _context5["catch"](0);
6386
6388
  _this._closeWidgetWithError(500, _context5.t0.message || 'Connection refused');
6387
- case 19:
6389
+ case 20:
6388
6390
  case "end":
6389
6391
  return _context5.stop();
6390
6392
  }
6391
6393
  }
6392
- }, _callee5, null, [[0, 16]]);
6394
+ }, _callee5, null, [[0, 17]]);
6393
6395
  }))();
6394
6396
  }
6395
6397
  }, {
@@ -6445,10 +6447,16 @@ var API = /*#__PURE__*/function () {
6445
6447
  key: "_addWatchers",
6446
6448
  value: function _addWatchers() {
6447
6449
  var _this2 = this;
6448
- // Watch for widget timeout (10 minutes)
6450
+ // Determine timeout based on features
6451
+ var hasQuickRetry = this._features && this._features.split(',').map(function (f) {
6452
+ return f.trim();
6453
+ }).includes('quick_retry');
6454
+ var timeoutMinutes = hasQuickRetry ? 30 : 10;
6455
+
6456
+ // Watch for widget timeout
6449
6457
  var timeoutWatcher = setTimeout(function () {
6450
6458
  _this2._closeWidgetWithError(400, 'Connection timeout');
6451
- }, 10 * 60 * 1000);
6459
+ }, timeoutMinutes * 60 * 1000);
6452
6460
 
6453
6461
  // Watch for widget status (whether closed by user or successfully finished) and clean it up
6454
6462
  var doneWatcher = setInterval(function () {
package/dist/wealthica.js CHANGED
@@ -5990,6 +5990,7 @@ var API = /*#__PURE__*/function () {
5990
5990
  this._onWidgetMessage = this._onMessage.bind(this);
5991
5991
  this._widgetOpened = false;
5992
5992
  this._widgetActive = false;
5993
+ this._features = null;
5993
5994
  }
5994
5995
  _createClass(API, [{
5995
5996
  key: "_init",
@@ -6332,8 +6333,9 @@ var API = /*#__PURE__*/function () {
6332
6333
  case 0:
6333
6334
  _context5.prev = 0;
6334
6335
  _this._widgetOpened = true;
6335
- provider = options.provider, providers = options.providers, providerGroups = options.providerGroups, institutionId = options.institutionId, lang = options.lang, theme = options.theme, providersPerLine = options.providersPerLine, features = options.features, connectionType = options.connectionType, origin = options.origin, webhookURI = options.webhookURI;
6336
- _context5.next = 5;
6336
+ provider = options.provider, providers = options.providers, providerGroups = options.providerGroups, institutionId = options.institutionId, lang = options.lang, theme = options.theme, providersPerLine = options.providersPerLine, features = options.features, connectionType = options.connectionType, origin = options.origin, webhookURI = options.webhookURI; // Store features for timeout calculation
6337
+ _this._features = features;
6338
+ _context5.next = 6;
6337
6339
  return _this.getConnectData({
6338
6340
  provider: provider,
6339
6341
  providers: providers,
@@ -6346,7 +6348,7 @@ var API = /*#__PURE__*/function () {
6346
6348
  origin: origin,
6347
6349
  webhookURI: webhookURI
6348
6350
  });
6349
- case 5:
6351
+ case 6:
6350
6352
  _yield$_this$getConne = _context5.sent;
6351
6353
  url = _yield$_this$getConne.url;
6352
6354
  token = _yield$_this$getConne.token;
@@ -6368,18 +6370,18 @@ var API = /*#__PURE__*/function () {
6368
6370
  _this._widgetActive = true;
6369
6371
  _this._addListeners();
6370
6372
  _this._addWatchers();
6371
- _context5.next = 19;
6373
+ _context5.next = 20;
6372
6374
  break;
6373
- case 16:
6374
- _context5.prev = 16;
6375
+ case 17:
6376
+ _context5.prev = 17;
6375
6377
  _context5.t0 = _context5["catch"](0);
6376
6378
  _this._closeWidgetWithError(500, _context5.t0.message || 'Connection refused');
6377
- case 19:
6379
+ case 20:
6378
6380
  case "end":
6379
6381
  return _context5.stop();
6380
6382
  }
6381
6383
  }
6382
- }, _callee5, null, [[0, 16]]);
6384
+ }, _callee5, null, [[0, 17]]);
6383
6385
  }))();
6384
6386
  }
6385
6387
  }, {
@@ -6435,10 +6437,16 @@ var API = /*#__PURE__*/function () {
6435
6437
  key: "_addWatchers",
6436
6438
  value: function _addWatchers() {
6437
6439
  var _this2 = this;
6438
- // Watch for widget timeout (10 minutes)
6440
+ // Determine timeout based on features
6441
+ var hasQuickRetry = this._features && this._features.split(',').map(function (f) {
6442
+ return f.trim();
6443
+ }).includes('quick_retry');
6444
+ var timeoutMinutes = hasQuickRetry ? 30 : 10;
6445
+
6446
+ // Watch for widget timeout
6439
6447
  var timeoutWatcher = setTimeout(function () {
6440
6448
  _this2._closeWidgetWithError(400, 'Connection timeout');
6441
- }, 10 * 60 * 1000);
6449
+ }, timeoutMinutes * 60 * 1000);
6442
6450
 
6443
6451
  // Watch for widget status (whether closed by user or successfully finished) and clean it up
6444
6452
  var doneWatcher = setInterval(function () {
@@ -96,6 +96,10 @@ type ConnectDataOptions = {
96
96
  redirectURI: string;
97
97
  providers: Array<string> | undefined;
98
98
  providerGroups: Array<string> | undefined;
99
+ theme: string;
100
+ providersPerLine: number | string;
101
+ features: string;
102
+ webhookURI: string;
99
103
  }
100
104
 
101
105
  type ConnectData = {