@fileverse-dev/formulajs 4.4.11-mod-89-patch-1 → 4.4.11-mod-89-patch-3

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.
@@ -1,4 +1,4 @@
1
- /* @fileverse-dev/formulajs v4.4.11-mod-89-patch-1 */
1
+ /* @fileverse-dev/formulajs v4.4.11-mod-89-patch-3 */
2
2
  var _excluded = [ "confirmations", "dataDecoded" ];
3
3
 
4
4
  function _objectWithoutProperties(e, t) {
@@ -18275,82 +18275,99 @@ function _typeof(o) {
18275
18275
  })));
18276
18276
  return _SMARTCONTRACT.apply(this, arguments);
18277
18277
  }
18278
+ function isExpired(createdAt) {
18279
+ if (!createdAt) return true;
18280
+ var expiryTs = createdAt + 60 * 60 * 1e3;
18281
+ return Date.now() > expiryTs;
18282
+ }
18278
18283
  function GNOSISPAY() {
18279
18284
  return _GNOSISPAY.apply(this, arguments);
18280
18285
  }
18281
18286
  function _GNOSISPAY() {
18282
18287
  _GNOSISPAY = _asyncToGenerator(_regeneratorRuntime().mark((function _callee28() {
18283
- var apiKeyKey, API_KEY, url, res, json;
18288
+ var GNOSIS_PAY_ACCESS, access, url, res, json, result;
18284
18289
  return _regeneratorRuntime().wrap((function _callee28$(_context31) {
18285
18290
  while (1) switch (_context31.prev = _context31.next) {
18286
18291
  case 0:
18287
18292
  _context31.prev = 0;
18288
- apiKeyKey = SERVICES_API_KEY.GnosisPay;
18289
- API_KEY = window.localStorage.getItem(apiKeyKey);
18290
- if (API_KEY) {
18291
- _context31.next = 5;
18293
+ GNOSIS_PAY_ACCESS = window.localStorage.getItem("GNOSIS_PAY_ACCESS");
18294
+ if (GNOSIS_PAY_ACCESS) {
18295
+ _context31.next = 4;
18292
18296
  break;
18293
18297
  }
18294
- throw new MissingApiKeyError(apiKeyKey);
18298
+ throw new MissingApiKeyError("GNOSIS_PAY_ACCESS");
18295
18299
 
18296
- case 5:
18300
+ case 4:
18301
+ access = JSON.parse(GNOSIS_PAY_ACCESS);
18302
+ if (!(!(access !== null && access !== void 0 && access.token) || isExpired(access === null || access === void 0 ? void 0 : access.createdAt))) {
18303
+ _context31.next = 7;
18304
+ break;
18305
+ }
18306
+ throw new ValidationError("Expired or invalid access token");
18307
+
18308
+ case 7:
18297
18309
  url = new URL("https://api.gnosispay.com/api/v1/transactions");
18298
- _context31.next = 8;
18310
+ _context31.next = 10;
18299
18311
  return fetch(url.toString(), {
18300
18312
  headers: {
18301
- Authorization: "Bearer ".concat(API_KEY),
18313
+ Authorization: "Bearer ".concat(access.token),
18302
18314
  "Content-Type": "application/json"
18303
18315
  }
18304
18316
  });
18305
18317
 
18306
- case 8:
18318
+ case 10:
18307
18319
  res = _context31.sent;
18308
18320
  if (res.ok) {
18309
- _context31.next = 11;
18321
+ _context31.next = 13;
18310
18322
  break;
18311
18323
  }
18312
- throw new NetworkError(apiKeyKey, res.status);
18324
+ throw new NetworkError("GNOSIS_PAY", res.status);
18313
18325
 
18314
- case 11:
18315
- _context31.next = 13;
18326
+ case 13:
18327
+ _context31.next = 15;
18316
18328
  return res.json();
18317
18329
 
18318
- case 13:
18330
+ case 15:
18319
18331
  json = _context31.sent;
18320
18332
  if (Array.isArray(json)) {
18321
- _context31.next = 16;
18333
+ _context31.next = 18;
18322
18334
  break;
18323
18335
  }
18324
- return _context31.abrupt("return", []);
18336
+ return _context31.abrupt("return", [ {
18337
+ message: "Unexpected response"
18338
+ } ]);
18325
18339
 
18326
- case 16:
18327
- return _context31.abrupt("return", json.map((function(tx) {
18340
+ case 18:
18341
+ result = json.map((function(transactions) {
18342
+ var _transactions$country, _transactions$merchan;
18328
18343
  return {
18329
- createdAt: tx.createdAt,
18330
- clearedAt: tx.clearedAt,
18331
- country: tx.country,
18332
- merchant: tx.merchant,
18333
- billingAmount: tx.billingAmount,
18334
- billingCurrency: tx.billingCurrency,
18335
- transactionAmount: tx.transactionAmount,
18336
- transactionCurrency: tx.transactionCurrency,
18337
- transactionType: tx.transactionType,
18338
- kind: tx.kind,
18339
- status: tx.status || null,
18340
- mcc: tx.mcc
18344
+ createdAt: transactions.createdAt,
18345
+ clearedAt: transactions.clearedAt,
18346
+ country: ((_transactions$country = transactions.country) === null || _transactions$country === void 0 ? void 0 : _transactions$country.name) || "",
18347
+ isPending: transactions.isPending,
18348
+ mcc: transactions.mcc,
18349
+ merchant: ((_transactions$merchan = transactions.merchant) === null || _transactions$merchan === void 0 ? void 0 : _transactions$merchan.name) || "",
18350
+ billingAmount: transactions.billingAmount,
18351
+ billingCurrency: transactions.billingCurrency,
18352
+ transactionAmount: transactions.transactionAmount,
18353
+ transactionCurrency: transactions.transactionCurrency,
18354
+ transactionType: transactions.transactionType,
18355
+ kind: transactions.kind,
18356
+ status: transactions.status
18341
18357
  };
18342
- })));
18358
+ }));
18359
+ return _context31.abrupt("return", result);
18343
18360
 
18344
- case 19:
18345
- _context31.prev = 19;
18361
+ case 22:
18362
+ _context31.prev = 22;
18346
18363
  _context31.t0 = _context31["catch"](0);
18347
18364
  return _context31.abrupt("return", errorMessageHandler(_context31.t0, "GNOSISPAY"));
18348
18365
 
18349
- case 22:
18366
+ case 25:
18350
18367
  case "end":
18351
18368
  return _context31.stop();
18352
18369
  }
18353
- }), _callee28, null, [ [ 0, 19 ] ]);
18370
+ }), _callee28, null, [ [ 0, 22 ] ]);
18354
18371
  })));
18355
18372
  return _GNOSISPAY.apply(this, arguments);
18356
18373
  }