@paydock/client-sdk 1.147.0 → 1.148.0-beta

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.
@@ -1869,7 +1869,7 @@
1869
1869
  version: 'x-sdk-version',
1870
1870
  type: 'x-sdk-type'
1871
1871
  });
1872
- SDK._version = 'v1.147.0';
1872
+ SDK._version = 'v1.148.0-beta';
1873
1873
 
1874
1874
  var ACCESS_HEADER_NAME = {
1875
1875
  accessToken: 'x-access-token',
@@ -5018,6 +5018,7 @@
5018
5018
 
5019
5019
  var WALLET_CAPTURE_LINK = '/v1/charges/wallet/capture';
5020
5020
  var WALLET_CALLBACK_LINK = '/v1/charges/wallet/callback';
5021
+ var STANDALONE_3DS_PROCESS_LINK = '/v1/charges/standalone-3ds/process';
5021
5022
  var STANDALONE_3DS_HANDLE_LINK = '/v1/charges/standalone-3ds/handle';
5022
5023
  var ApiChargeInternal = /*#__PURE__*/function () {
5023
5024
  function ApiChargeInternal(api) {
@@ -5034,6 +5035,12 @@
5034
5035
  value: function walletCallback(payload) {
5035
5036
  return this.api.getClientPromise('POST', WALLET_CALLBACK_LINK).send(payload);
5036
5037
  }
5038
+ /** Two-step mode: runs the deferred Standalone 3DS authentication (AReq). Charge-token auth, like `standalone3dsHandle`. */
5039
+ }, {
5040
+ key: "standalone3dsProcess",
5041
+ value: function standalone3dsProcess(payload) {
5042
+ return this.api.getClientPromise('POST', STANDALONE_3DS_PROCESS_LINK).send(payload);
5043
+ }
5037
5044
  }, {
5038
5045
  key: "standalone3dsHandle",
5039
5046
  value: function standalone3dsHandle() {
@@ -5394,6 +5401,51 @@
5394
5401
  IFRAME_STATUS["TIMEOUT"] = "AuthTimedOut";
5395
5402
  IFRAME_STATUS["INVALID"] = "invalid_event";
5396
5403
  })(IFRAME_STATUS || (IFRAME_STATUS = {}));
5404
+ /**
5405
+ * Maps a `/process` rejection onto the error object the one-step callback delivers for the same outcome
5406
+ * (`{ error_code, error_description, gateway_specific_description, process_error_code }`), so `error`
5407
+ * carries the same payload in both flows. Absent fields are left out.
5408
+ */
5409
+ function toOutcomeError(err) {
5410
+ var _a, _b;
5411
+ if (err instanceof Error) {
5412
+ // no API envelope to map (the body was not the API's JSON): report it as unreachable, so the
5413
+ // merchant can tell this retryable case apart from a final API answer by `error_code` alone
5414
+ return {
5415
+ error_code: ERROR_CAUSE.SERVICE_UNREACHABLE,
5416
+ error_description: 'Network request failed: the service did not answer with a valid response.'
5417
+ };
5418
+ }
5419
+ var apiError = err !== null && err !== void 0 ? err : {};
5420
+ var gateway = (_b = (_a = apiError.details) === null || _a === void 0 ? void 0 : _a.messages) === null || _b === void 0 ? void 0 : _b[0];
5421
+ var fields = {
5422
+ error_code: apiError.code,
5423
+ error_description: apiError.message,
5424
+ gateway_specific_description: gateway === null || gateway === void 0 ? void 0 : gateway.gateway_specific_description,
5425
+ process_error_code: gateway === null || gateway === void 0 ? void 0 : gateway.gateway_specific_code
5426
+ };
5427
+ var outcomeError = {};
5428
+ for (var _i = 0, _Object$keys = Object.keys(fields); _i < _Object$keys.length; _i++) {
5429
+ var key = _Object$keys[_i];
5430
+ if (fields[key]) {
5431
+ outcomeError[key] = fields[key];
5432
+ }
5433
+ }
5434
+ return outcomeError;
5435
+ }
5436
+ /**
5437
+ * `true` when `/process` produced no API answer: the request never got a response (network, timeout, abort)
5438
+ * or the response body was not the API's JSON (e.g. an HTML page from a proxy in between).
5439
+ */
5440
+ function isTransportFailure(err) {
5441
+ if (err instanceof Error) {
5442
+ return true;
5443
+ }
5444
+ var code = err === null || err === void 0 ? void 0 : err.code;
5445
+ return code === ERROR_CAUSE.SERVICE_UNREACHABLE || code === ERROR_CAUSE.ABORTED;
5446
+ }
5447
+ /** Callback `process_status` of a two-step charge: fingerprint done, authentication not started. */
5448
+ var PROCESS_STATUS_DEFERRED = 'deferred';
5397
5449
  /**
5398
5450
  * Event name constants emitted during the Standalone 3DS (GPayments) flow.
5399
5451
  * Used internally by `GPaymentsService` and re-exported publicly as `CANVAS_3DS_EVENT`.
@@ -5407,6 +5459,11 @@
5407
5459
  DECOUPLED: 'chargeAuthDecoupled',
5408
5460
  /** Challenge required — issuer demands user interaction. Payload: `Canvas3dsAuthPayload`. */
5409
5461
  CHALLENGE: 'chargeAuthChallenge',
5462
+ /**
5463
+ * Two-step mode only: fingerprint done, SDK waiting for `Canvas3ds.authenticate()`. Emitted once, before any
5464
+ * outcome event (`INFO` may precede it); never for a one-step charge. Payload: `Canvas3dsReadyPayload`.
5465
+ */
5466
+ READY: 'chargeAuthReady',
5410
5467
  /**
5411
5468
  * The challenge iframe fired its FIRST `load` after `chargeAuthChallenge` (the ACS page has painted),
5412
5469
  * or the `CHALLENGE_LOADED_FALLBACK_MS` safety fallback elapsed without one. Emitted exactly once per
@@ -5482,6 +5539,14 @@
5482
5539
  this.resultPollTimer = null;
5483
5540
  /** One-shot guard for the `chargeAuth` leg — the callback message may be delivered more than once. */
5484
5541
  this.authHandled = false;
5542
+ /** Two-step mode: `charge_3ds_id` of the deferred callback message; `null` until it arrives (always for one-step). */
5543
+ this.deferredCharge3dsId = null;
5544
+ /** `authenticate()` latch; consumed when the deferred message arrives, reset only after a `/process` transport failure. */
5545
+ this.authenticateRequested = false;
5546
+ /** One `/process` call per widget instance (a transport failure allows one more `authenticate()`). */
5547
+ this.authenticationStarted = false;
5548
+ /** The single `/process` retry after a transport failure has been granted; the next failure is final. */
5549
+ this.authenticationRetryUsed = false;
5485
5550
  this.iFrameEvent = new IFrameEvent(window);
5486
5551
  }
5487
5552
  return _createClass(GPaymentsService, [{
@@ -5567,7 +5632,16 @@
5567
5632
  });
5568
5633
  }
5569
5634
  _this2.removeIframes();
5570
- if (typeof data.process_status === 'string') {
5635
+ if (data.process_status === PROCESS_STATUS_DEFERRED) {
5636
+ // two-step: announce readiness; authenticate now only if `authenticate()` was already called
5637
+ _this2.deferredCharge3dsId = data.charge_3ds_id;
5638
+ _this2.eventEmitter.emit(GPAYMENTS_EVENT.READY, {
5639
+ charge_3ds_id: data.charge_3ds_id
5640
+ });
5641
+ if (_this2.authenticateRequested) {
5642
+ _this2.performAuthentication(data.charge_3ds_id);
5643
+ }
5644
+ } else if (typeof data.process_status === 'string') {
5571
5645
  // the API already ran the authentication inside the callback: no /process call needed
5572
5646
  _this2.handleAuthenticationOutcome({
5573
5647
  status: data.process_status,
@@ -5605,6 +5679,55 @@
5605
5679
  }
5606
5680
  });
5607
5681
  }
5682
+ /**
5683
+ * Two-step mode: run the deferred authentication (`POST /standalone-3ds/process`). Never throws: runs now if
5684
+ * the deferred message already arrived, otherwise as soon as it does; a no-op on one-step charges, repeated
5685
+ * calls or after a terminal outcome. The outcome flows through the usual events.
5686
+ */
5687
+ }, {
5688
+ key: "authenticate",
5689
+ value: function authenticate() {
5690
+ if (this.authenticateRequested) {
5691
+ return;
5692
+ }
5693
+ this.authenticateRequested = true;
5694
+ if (this.deferredCharge3dsId !== null) {
5695
+ this.performAuthentication(this.deferredCharge3dsId);
5696
+ }
5697
+ }
5698
+ /**
5699
+ * Calls `/process` once per instance (reachable from both the deferred message and `authenticate()`). The
5700
+ * response has the callback-outcome shape, so the challenge / decoupled / result legs are shared with
5701
+ * one-step. A rejection surfaces as `error`, with the same error object shape as the one-step callback
5702
+ * (`toOutcomeError`). An API answer (stale session, rejected authentication…) is terminal. The first transport
5703
+ * failure is not: the AReq may have run with its response lost, so the latches are reset and the merchant may
5704
+ * call `authenticate()` once more — `/process` is idempotent and replays the stored outcome. A failure of that
5705
+ * retry, of any kind, is final.
5706
+ */
5707
+ }, {
5708
+ key: "performAuthentication",
5709
+ value: function performAuthentication(charge3dsId) {
5710
+ var _this3 = this;
5711
+ if (this.authenticationStarted) {
5712
+ return;
5713
+ }
5714
+ this.authenticationStarted = true;
5715
+ this.api.charge().standalone3dsProcess({
5716
+ charge_3ds_id: charge3dsId
5717
+ }).then(function (authenticationResult) {
5718
+ return _this3.handleAuthenticationOutcome(authenticationResult, charge3dsId);
5719
+ }, function (err) {
5720
+ if (isTransportFailure(err) && !_this3.authenticationRetryUsed) {
5721
+ _this3.authenticationRetryUsed = true;
5722
+ _this3.authenticateRequested = false;
5723
+ _this3.authenticationStarted = false;
5724
+ } else {
5725
+ _this3.resultRead = true;
5726
+ _this3.finishChallengeLifecycle();
5727
+ }
5728
+ _this3.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this3.parseError(toOutcomeError(err), charge3dsId));
5729
+ });
5730
+ }
5608
5731
  /**
5609
5732
  * A message carries a processed outcome only when it has `process_status` AND comes from a trusted
5610
5733
  * origin. Used by the result leg: an untrusted `process_status` is never acted upon — the SDK falls
@@ -5658,18 +5781,18 @@
5658
5781
  }, {
5659
5782
  key: "startChallengeLifecycle",
5660
5783
  value: function startChallengeLifecycle(charge3dsId) {
5661
- var _this3 = this;
5784
+ var _this4 = this;
5662
5785
  this.clearChallengeLoadedTimer();
5663
5786
  this.challengeLoadedEmitted = false;
5664
5787
  this.challengeCompletedEmitted = false;
5665
5788
  this.challengeLifecycleClosed = false;
5666
5789
  return function () {
5667
5790
  var _a;
5668
- if (_this3.challengeLifecycleClosed || _this3.challengeLoadedEmitted || !((_a = _this3.iFrameAuthorization) === null || _a === void 0 ? void 0 : _a.isExist())) {
5791
+ if (_this4.challengeLifecycleClosed || _this4.challengeLoadedEmitted || !((_a = _this4.iFrameAuthorization) === null || _a === void 0 ? void 0 : _a.isExist())) {
5669
5792
  return;
5670
5793
  }
5671
- _this3.clearChallengeLoadedTimer();
5672
- _this3.emitChallengeLoaded(charge3dsId, 'load');
5794
+ _this4.clearChallengeLoadedTimer();
5795
+ _this4.emitChallengeLoaded(charge3dsId, 'load');
5673
5796
  };
5674
5797
  }
5675
5798
  /**
@@ -5679,17 +5802,17 @@
5679
5802
  }, {
5680
5803
  key: "armChallengeLoadedFallback",
5681
5804
  value: function armChallengeLoadedFallback(charge3dsId) {
5682
- var _this4 = this;
5805
+ var _this5 = this;
5683
5806
  var _a;
5684
5807
  if (!((_a = this.iFrameAuthorization) === null || _a === void 0 ? void 0 : _a.isExist())) {
5685
5808
  return;
5686
5809
  }
5687
5810
  this.challengeLoadedTimer = setTimeout(function () {
5688
- _this4.challengeLoadedTimer = null;
5689
- if (_this4.challengeLifecycleClosed || _this4.challengeLoadedEmitted) {
5811
+ _this5.challengeLoadedTimer = null;
5812
+ if (_this5.challengeLifecycleClosed || _this5.challengeLoadedEmitted) {
5690
5813
  return;
5691
5814
  }
5692
- _this4.emitChallengeLoaded(charge3dsId, 'timeout');
5815
+ _this5.emitChallengeLoaded(charge3dsId, 'timeout');
5693
5816
  }, CHALLENGE_LOADED_FALLBACK_MS);
5694
5817
  }
5695
5818
  }, {
@@ -5766,7 +5889,7 @@
5766
5889
  }, {
5767
5890
  key: "processResult",
5768
5891
  value: function processResult(charge3dsId) {
5769
- var _this5 = this;
5892
+ var _this6 = this;
5770
5893
  if (this.resultRead) {
5771
5894
  return;
5772
5895
  }
@@ -5774,15 +5897,15 @@
5774
5897
  this.finishChallengeLifecycle();
5775
5898
  this.api.charge().standalone3dsHandle().then(function (result) {
5776
5899
  var _a;
5777
- _this5.iFrameAuthorization.remove();
5778
- (_a = _this5.iFrameSecondaryUrl) === null || _a === void 0 ? void 0 : _a.remove();
5900
+ _this6.iFrameAuthorization.remove();
5901
+ (_a = _this6.iFrameSecondaryUrl) === null || _a === void 0 ? void 0 : _a.remove();
5779
5902
  if (result.status === PROCESS_STANDALONE_3DS_STATUS.SUCCESS) {
5780
- _this5.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this5.parseResultData(result, charge3dsId));
5903
+ _this6.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this6.parseResultData(result, charge3dsId));
5781
5904
  } else {
5782
- _this5.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this5.parseResultData(result, charge3dsId));
5905
+ _this6.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this6.parseResultData(result, charge3dsId));
5783
5906
  }
5784
5907
  }, function (err) {
5785
- _this5.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this5.parseError(err, charge3dsId));
5908
+ _this6.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this6.parseError(err, charge3dsId));
5786
5909
  });
5787
5910
  }
5788
5911
  /** Final (post-challenge) outcome delivered by the API through the callback message. */
@@ -5842,43 +5965,43 @@
5842
5965
  }, {
5843
5966
  key: "doPolling",
5844
5967
  value: function doPolling(url, charge3dsId, intervalMs) {
5845
- var _this6 = this;
5968
+ var _this7 = this;
5846
5969
  this.stopResultPolling();
5847
5970
  if (this.resultRead || this.challengeLifecycleClosed) {
5848
5971
  return;
5849
5972
  }
5850
5973
  var schedule = function schedule() {
5851
- _this6.resultPollTimer = setTimeout(function () {
5852
- _this6.resultPollTimer = null;
5853
- _this6.doPolling(url, charge3dsId, intervalMs);
5974
+ _this7.resultPollTimer = setTimeout(function () {
5975
+ _this7.resultPollTimer = null;
5976
+ _this7.doPolling(url, charge3dsId, intervalMs);
5854
5977
  }, intervalMs);
5855
5978
  };
5856
5979
  this.externalAPI('GET', url).then(function (data) {
5857
- if (_this6.resultRead || _this6.challengeLifecycleClosed) {
5980
+ if (_this7.resultRead || _this7.challengeLifecycleClosed) {
5858
5981
  return;
5859
5982
  }
5860
5983
  if (!data.event || data.event === 'AuthResultNotReady') {
5861
5984
  schedule();
5862
5985
  } else if (data.event === 'AuthResultReady') {
5863
- _this6.emitChallengeCompleted(charge3dsId, 'poll');
5864
- _this6.processResult(charge3dsId);
5986
+ _this7.emitChallengeCompleted(charge3dsId, 'poll');
5987
+ _this7.processResult(charge3dsId);
5865
5988
  } else {
5866
5989
  throw new Error('Event not supported');
5867
5990
  }
5868
5991
  })["catch"](function (err) {
5869
5992
  if (err instanceof ResultMonitorTransportError) {
5870
- if (!_this6.resultRead && !_this6.challengeLifecycleClosed) {
5993
+ if (!_this7.resultRead && !_this7.challengeLifecycleClosed) {
5871
5994
  schedule();
5872
5995
  }
5873
5996
  return;
5874
5997
  }
5875
- _this6.finishChallengeLifecycle();
5876
- _this6.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this6.parseError(err, charge3dsId));
5998
+ _this7.finishChallengeLifecycle();
5999
+ _this7.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this7.parseError(err, charge3dsId));
5877
6000
  });
5878
6001
  }
5879
6002
  /**
5880
- * Branches on the authentication outcome delivered by the API through the callback message
5881
- * (`process_status` → `status`; same shape as the `/process` response body).
6003
+ * Branches on the authentication outcome — delivered by the API through the callback message
6004
+ * (`process_status` → `status`) or, in two-step mode, returned by `/process` (same shape).
5882
6005
  */
5883
6006
  }, {
5884
6007
  key: "handleAuthenticationOutcome",
@@ -5948,17 +6071,38 @@
5948
6071
  api.setEnv(this.env, this.alias);
5949
6072
  switch (tokenData.service_type) {
5950
6073
  case STANDALONE_3DS_GATEWAYS.GPAYMENTS:
5951
- new GPaymentsService(this.container, api, this.eventEmitter, this.getTrustedMessageOrigins(api)).load(tokenData, options.title);
6074
+ this.gpaymentsService = new GPaymentsService(this.container, api, this.eventEmitter, this.getTrustedMessageOrigins(api));
6075
+ this.gpaymentsService.load(tokenData, options.title);
5952
6076
  break;
5953
6077
  }
5954
6078
  }
5955
6079
  /**
5956
- * Origins allowed to deliver a processed 3DS outcome to the page via postMessage: the Paydock API
5957
- * (inline callback page) and the Paydock widget (remote-app landing page), for the current env/alias.
6080
+ * Two-step mode: forwards `Canvas3ds.authenticate()` to the provider flow. Calling it before `load()` is an
6081
+ * integration bug (nothing to authenticate yet): it emits `error` and is not remembered.
5958
6082
  */
6083
+ }, {
6084
+ key: "authenticate",
6085
+ value: function authenticate(token) {
6086
+ if (!this.gpaymentsService) {
6087
+ this.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, {
6088
+ charge_3ds_id: Standalone3dsService.readCharge3dsId(token),
6089
+ error: {
6090
+ message: 'Canvas3ds.authenticate() called before load()'
6091
+ }
6092
+ });
6093
+ return;
6094
+ }
6095
+ this.gpaymentsService.authenticate();
6096
+ }
6097
+ /** `charge_3ds_id` from the standalone 3DS charge token, `undefined` when it cannot be decoded. */
5959
6098
  }, {
5960
6099
  key: "getTrustedMessageOrigins",
5961
- value: function getTrustedMessageOrigins(api) {
6100
+ value:
6101
+ /**
6102
+ * Origins allowed to deliver a processed 3DS outcome to the page via postMessage: the Paydock API
6103
+ * (inline callback page) and the Paydock widget (remote-app landing page), for the current env/alias.
6104
+ */
6105
+ function getTrustedMessageOrigins(api) {
5962
6106
  var origins = [api.getApiOrigin()];
5963
6107
  try {
5964
6108
  var widgetEnv = new Env(WIDGET_URL, this.env);
@@ -5975,6 +6119,13 @@
5975
6119
  this.env = env;
5976
6120
  this.alias = alias;
5977
6121
  }
6122
+ }], [{
6123
+ key: "readCharge3dsId",
6124
+ value: function readCharge3dsId(token) {
6125
+ var _a;
6126
+ var parsedToken = AccessToken.validateJWT(token);
6127
+ return parsedToken ? (_a = AccessToken.extractData(parsedToken.body)) === null || _a === void 0 ? void 0 : _a.charge_3ds_id : undefined;
6128
+ }
5978
6129
  }]);
5979
6130
  }();
5980
6131
 
@@ -6141,6 +6292,7 @@
6141
6292
  * @param {string} AUTH_ERROR=chargeAuthReject
6142
6293
  * @param {string} DECOUPLED=chargeAuthDecoupled
6143
6294
  * @param {string} CHALLENGE=chargeAuthChallenge
6295
+ * @param {string} READY=chargeAuthReady - two-step mode only: fingerprint done, waiting for `authenticate()`
6144
6296
  * @param {string} CHALLENGE_LOADED=chargeAuthChallengeLoaded - challenge iframe painted (first `load`, or 2.5 s fallback); reveal your challenge UI here
6145
6297
  * @param {string} CHALLENGE_COMPLETED=chargeAuthChallengeCompleted - the shopper finished the challenge (issuer result delivered to the 3DS Server); cover the challenge iframe with your own loader until the terminal event
6146
6298
  * @param {string} INFO=chargeAuthInfo
@@ -6270,6 +6422,39 @@
6270
6422
  });
6271
6423
  }
6272
6424
  }
6425
+ /**
6426
+ * Two-step mode only (`_3ds.authentication_flow: 'two_step'`): runs the authentication the API deferred after the
6427
+ * fingerprint. Call it when the shopper confirms (e.g. presses "Pay"); the outcome arrives through the
6428
+ * usual events (`chargeAuthChallenge`, `chargeAuthSuccess`, `chargeAuthReject`, `error`).
6429
+ *
6430
+ * Never throws. After `chargeAuthReady` the authentication starts at once; before it, the call is
6431
+ * remembered and runs as soon as the fingerprint completes. One-step charges, repeated calls and calls after
6432
+ * a terminal outcome are no-ops. For inbuilt 3DS (`html` / `url`) tokens it is a silent no-op: no event is
6433
+ * emitted at all, so do not wait for `error` there. Calling it before `load()` is an integration error: it emits `error` and
6434
+ * is not remembered. If `/process` could not be reached (`error` with `error_code` `service_unreachable` /
6435
+ * `aborted`), `authenticate()` may be called once more; any other `error`, and any failure of that retry,
6436
+ * is final.
6437
+ * No client-side deadline: a stale 3DS Server session surfaces as `error` / `chargeAuthReject`.
6438
+ *
6439
+ * @example
6440
+ * const widget = new Canvas3ds('#widget', token); // charge created with _3ds.authentication_flow: 'two_step'
6441
+ * widget.on('chargeAuthReady', () => payButton.disabled = false);
6442
+ * widget.on('chargeAuthChallenge', () => showChallengeModal());
6443
+ * widget.on('chargeAuthSuccess', (data) => completePayment(data.charge_3ds_id));
6444
+ * widget.on('chargeAuthReject', () => showDeclined());
6445
+ * widget.on('error', () => showError());
6446
+ * widget.load(); // fingerprint runs while the shopper reviews the order
6447
+ *
6448
+ * payButton.addEventListener('click', () => widget.authenticate());
6449
+ */
6450
+ }, {
6451
+ key: "authenticate",
6452
+ value: function authenticate() {
6453
+ if (this.token.format !== TOKEN_FORMAT$2.STANDALONE_3DS) {
6454
+ return;
6455
+ }
6456
+ this.standalone3dsService.authenticate(this.token.content);
6457
+ }
6273
6458
  /**
6274
6459
  * Using this method you can hide widget after load
6275
6460
  * @param {boolean} [saveSize=false] - using this param you can save iframe's size
@@ -45931,14 +46116,17 @@
45931
46116
  var slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };
45932
46117
  // read zip header
45933
46118
  var zh = function (d, b, z) {
45934
- var fnl = b2(d, b + 28), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl, bs = b4(d, b + 20);
45935
- var _a = z && bs == 4294967295 ? z64e(d, es) : [bs, b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];
45936
- return [b2(d, b + 10), sc, su, fn, es + b2(d, b + 30) + b2(d, b + 32), off];
46119
+ var fnl = b2(d, b + 28), efl = b2(d, b + 30), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl, bs = b4(d, b + 20);
46120
+ var _a = z && bs == 4294967295 ? z64e(d, es, efl) : [bs, b4(d, b + 24), b4(d, b + 42)], sc = _a[0], su = _a[1], off = _a[2];
46121
+ return [b2(d, b + 10), sc, su, fn, es + efl + b2(d, b + 32), off];
45937
46122
  };
45938
46123
  // read zip64 extra field
45939
- var z64e = function (d, b) {
45940
- for (; b2(d, b) != 1; b += 4 + b2(d, b + 2))
45941
- ;
46124
+ var z64e = function (d, b, l) {
46125
+ var e = b + l;
46126
+ for (; b2(d, b) != 1; b += 4 + b2(d, b + 2)) {
46127
+ if (b + 4 > e)
46128
+ err(13);
46129
+ }
45942
46130
  return [b8(d, b + 12), b8(d, b + 4), b8(d, b + 20)];
45943
46131
  };
45944
46132
  // extra field length
@@ -46541,7 +46729,7 @@
46541
46729
  var sc_1 = b4(buf, i + 18), su_1 = b4(buf, i + 22);
46542
46730
  var fn_1 = strFromU8(buf.subarray(i + 30, i += 30 + fnl), !u);
46543
46731
  if (sc_1 == 4294967295) {
46544
- _a = dd ? [-2] : z64e(buf, i), sc_1 = _a[0], su_1 = _a[1];
46732
+ _a = dd ? [-2] : z64e(buf, i, es), sc_1 = _a[0], su_1 = _a[1];
46545
46733
  }
46546
46734
  else if (dd)
46547
46735
  sc_1 = -1;