@paydock/client-sdk 1.147.0 → 1.148.0
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/bundles/index.cjs +227 -39
- package/bundles/index.cjs.d.ts +757 -581
- package/bundles/index.mjs +227 -39
- package/bundles/index.mjs.d.ts +757 -581
- package/bundles/types/api/api-charge-internal.d.ts +6 -1
- package/bundles/types/api/api-charge-internal.d.ts.map +1 -1
- package/bundles/types/canvas-3ds/canvas-3ds-event-map.d.ts +15 -0
- package/bundles/types/canvas-3ds/canvas-3ds-event-map.d.ts.map +1 -1
- package/bundles/types/canvas-3ds/canvas-3ds.d.ts +27 -0
- package/bundles/types/canvas-3ds/canvas-3ds.d.ts.map +1 -1
- package/bundles/types/canvas-3ds/index.d.ts +1 -1
- package/bundles/types/canvas-3ds/index.d.ts.map +1 -1
- package/bundles/types/canvas-3ds/services/gpayments-service.d.ts +36 -2
- package/bundles/types/canvas-3ds/services/gpayments-service.d.ts.map +1 -1
- package/bundles/types/canvas-3ds/services/standalone3ds-service.d.ts +10 -0
- package/bundles/types/canvas-3ds/services/standalone3ds-service.d.ts.map +1 -1
- package/bundles/types/index.d.ts +1 -1
- package/bundles/types/index.d.ts.map +1 -1
- package/bundles/widget.umd.js +227 -39
- package/bundles/widget.umd.js.d.ts +757 -581
- package/bundles/widget.umd.js.min.d.ts +757 -581
- package/bundles/widget.umd.min.js +1 -1
- package/docs/api-canvas3ds.md +31 -0
- package/package.json +11 -8
package/bundles/index.mjs
CHANGED
|
@@ -1863,7 +1863,7 @@ SDK.headerKeys = Object.freeze({
|
|
|
1863
1863
|
version: 'x-sdk-version',
|
|
1864
1864
|
type: 'x-sdk-type'
|
|
1865
1865
|
});
|
|
1866
|
-
SDK._version = 'v1.
|
|
1866
|
+
SDK._version = 'v1.148.0';
|
|
1867
1867
|
|
|
1868
1868
|
var ACCESS_HEADER_NAME = {
|
|
1869
1869
|
accessToken: 'x-access-token',
|
|
@@ -5012,6 +5012,7 @@ var Api = /*#__PURE__*/function (_ApiBase) {
|
|
|
5012
5012
|
|
|
5013
5013
|
var WALLET_CAPTURE_LINK = '/v1/charges/wallet/capture';
|
|
5014
5014
|
var WALLET_CALLBACK_LINK = '/v1/charges/wallet/callback';
|
|
5015
|
+
var STANDALONE_3DS_PROCESS_LINK = '/v1/charges/standalone-3ds/process';
|
|
5015
5016
|
var STANDALONE_3DS_HANDLE_LINK = '/v1/charges/standalone-3ds/handle';
|
|
5016
5017
|
var ApiChargeInternal = /*#__PURE__*/function () {
|
|
5017
5018
|
function ApiChargeInternal(api) {
|
|
@@ -5028,6 +5029,12 @@ var ApiChargeInternal = /*#__PURE__*/function () {
|
|
|
5028
5029
|
value: function walletCallback(payload) {
|
|
5029
5030
|
return this.api.getClientPromise('POST', WALLET_CALLBACK_LINK).send(payload);
|
|
5030
5031
|
}
|
|
5032
|
+
/** Two-step mode: runs the deferred Standalone 3DS authentication (AReq). Charge-token auth, like `standalone3dsHandle`. */
|
|
5033
|
+
}, {
|
|
5034
|
+
key: "standalone3dsProcess",
|
|
5035
|
+
value: function standalone3dsProcess(payload) {
|
|
5036
|
+
return this.api.getClientPromise('POST', STANDALONE_3DS_PROCESS_LINK).send(payload);
|
|
5037
|
+
}
|
|
5031
5038
|
}, {
|
|
5032
5039
|
key: "standalone3dsHandle",
|
|
5033
5040
|
value: function standalone3dsHandle() {
|
|
@@ -5388,6 +5395,51 @@ var IFRAME_STATUS;
|
|
|
5388
5395
|
IFRAME_STATUS["TIMEOUT"] = "AuthTimedOut";
|
|
5389
5396
|
IFRAME_STATUS["INVALID"] = "invalid_event";
|
|
5390
5397
|
})(IFRAME_STATUS || (IFRAME_STATUS = {}));
|
|
5398
|
+
/**
|
|
5399
|
+
* Maps a `/process` rejection onto the error object the one-step callback delivers for the same outcome
|
|
5400
|
+
* (`{ error_code, error_description, gateway_specific_description, process_error_code }`), so `error`
|
|
5401
|
+
* carries the same payload in both flows. Absent fields are left out.
|
|
5402
|
+
*/
|
|
5403
|
+
function toOutcomeError(err) {
|
|
5404
|
+
var _a, _b;
|
|
5405
|
+
if (err instanceof Error) {
|
|
5406
|
+
// no API envelope to map (the body was not the API's JSON): report it as unreachable, so the
|
|
5407
|
+
// merchant can tell this retryable case apart from a final API answer by `error_code` alone
|
|
5408
|
+
return {
|
|
5409
|
+
error_code: ERROR_CAUSE.SERVICE_UNREACHABLE,
|
|
5410
|
+
error_description: 'Network request failed: the service did not answer with a valid response.'
|
|
5411
|
+
};
|
|
5412
|
+
}
|
|
5413
|
+
var apiError = err !== null && err !== void 0 ? err : {};
|
|
5414
|
+
var gateway = (_b = (_a = apiError.details) === null || _a === void 0 ? void 0 : _a.messages) === null || _b === void 0 ? void 0 : _b[0];
|
|
5415
|
+
var fields = {
|
|
5416
|
+
error_code: apiError.code,
|
|
5417
|
+
error_description: apiError.message,
|
|
5418
|
+
gateway_specific_description: gateway === null || gateway === void 0 ? void 0 : gateway.gateway_specific_description,
|
|
5419
|
+
process_error_code: gateway === null || gateway === void 0 ? void 0 : gateway.gateway_specific_code
|
|
5420
|
+
};
|
|
5421
|
+
var outcomeError = {};
|
|
5422
|
+
for (var _i = 0, _Object$keys = Object.keys(fields); _i < _Object$keys.length; _i++) {
|
|
5423
|
+
var key = _Object$keys[_i];
|
|
5424
|
+
if (fields[key]) {
|
|
5425
|
+
outcomeError[key] = fields[key];
|
|
5426
|
+
}
|
|
5427
|
+
}
|
|
5428
|
+
return outcomeError;
|
|
5429
|
+
}
|
|
5430
|
+
/**
|
|
5431
|
+
* `true` when `/process` produced no API answer: the request never got a response (network, timeout, abort)
|
|
5432
|
+
* or the response body was not the API's JSON (e.g. an HTML page from a proxy in between).
|
|
5433
|
+
*/
|
|
5434
|
+
function isTransportFailure(err) {
|
|
5435
|
+
if (err instanceof Error) {
|
|
5436
|
+
return true;
|
|
5437
|
+
}
|
|
5438
|
+
var code = err === null || err === void 0 ? void 0 : err.code;
|
|
5439
|
+
return code === ERROR_CAUSE.SERVICE_UNREACHABLE || code === ERROR_CAUSE.ABORTED;
|
|
5440
|
+
}
|
|
5441
|
+
/** Callback `process_status` of a two-step charge: fingerprint done, authentication not started. */
|
|
5442
|
+
var PROCESS_STATUS_DEFERRED = 'deferred';
|
|
5391
5443
|
/**
|
|
5392
5444
|
* Event name constants emitted during the Standalone 3DS (GPayments) flow.
|
|
5393
5445
|
* Used internally by `GPaymentsService` and re-exported publicly as `CANVAS_3DS_EVENT`.
|
|
@@ -5401,6 +5453,11 @@ var GPAYMENTS_EVENT = {
|
|
|
5401
5453
|
DECOUPLED: 'chargeAuthDecoupled',
|
|
5402
5454
|
/** Challenge required — issuer demands user interaction. Payload: `Canvas3dsAuthPayload`. */
|
|
5403
5455
|
CHALLENGE: 'chargeAuthChallenge',
|
|
5456
|
+
/**
|
|
5457
|
+
* Two-step mode only: fingerprint done, SDK waiting for `Canvas3ds.authenticate()`. Emitted once, before any
|
|
5458
|
+
* outcome event (`INFO` may precede it); never for a one-step charge. Payload: `Canvas3dsReadyPayload`.
|
|
5459
|
+
*/
|
|
5460
|
+
READY: 'chargeAuthReady',
|
|
5404
5461
|
/**
|
|
5405
5462
|
* The challenge iframe fired its FIRST `load` after `chargeAuthChallenge` (the ACS page has painted),
|
|
5406
5463
|
* or the `CHALLENGE_LOADED_FALLBACK_MS` safety fallback elapsed without one. Emitted exactly once per
|
|
@@ -5476,6 +5533,14 @@ var GPaymentsService = /*#__PURE__*/function () {
|
|
|
5476
5533
|
this.resultPollTimer = null;
|
|
5477
5534
|
/** One-shot guard for the `chargeAuth` leg — the callback message may be delivered more than once. */
|
|
5478
5535
|
this.authHandled = false;
|
|
5536
|
+
/** Two-step mode: `charge_3ds_id` of the deferred callback message; `null` until it arrives (always for one-step). */
|
|
5537
|
+
this.deferredCharge3dsId = null;
|
|
5538
|
+
/** `authenticate()` latch; consumed when the deferred message arrives, reset only after a `/process` transport failure. */
|
|
5539
|
+
this.authenticateRequested = false;
|
|
5540
|
+
/** One `/process` call per widget instance (a transport failure allows one more `authenticate()`). */
|
|
5541
|
+
this.authenticationStarted = false;
|
|
5542
|
+
/** The single `/process` retry after a transport failure has been granted; the next failure is final. */
|
|
5543
|
+
this.authenticationRetryUsed = false;
|
|
5479
5544
|
this.iFrameEvent = new IFrameEvent(window);
|
|
5480
5545
|
}
|
|
5481
5546
|
return _createClass(GPaymentsService, [{
|
|
@@ -5561,7 +5626,16 @@ var GPaymentsService = /*#__PURE__*/function () {
|
|
|
5561
5626
|
});
|
|
5562
5627
|
}
|
|
5563
5628
|
_this2.removeIframes();
|
|
5564
|
-
if (
|
|
5629
|
+
if (data.process_status === PROCESS_STATUS_DEFERRED) {
|
|
5630
|
+
// two-step: announce readiness; authenticate now only if `authenticate()` was already called
|
|
5631
|
+
_this2.deferredCharge3dsId = data.charge_3ds_id;
|
|
5632
|
+
_this2.eventEmitter.emit(GPAYMENTS_EVENT.READY, {
|
|
5633
|
+
charge_3ds_id: data.charge_3ds_id
|
|
5634
|
+
});
|
|
5635
|
+
if (_this2.authenticateRequested) {
|
|
5636
|
+
_this2.performAuthentication(data.charge_3ds_id);
|
|
5637
|
+
}
|
|
5638
|
+
} else if (typeof data.process_status === 'string') {
|
|
5565
5639
|
// the API already ran the authentication inside the callback: no /process call needed
|
|
5566
5640
|
_this2.handleAuthenticationOutcome({
|
|
5567
5641
|
status: data.process_status,
|
|
@@ -5599,6 +5673,55 @@ var GPaymentsService = /*#__PURE__*/function () {
|
|
|
5599
5673
|
}
|
|
5600
5674
|
});
|
|
5601
5675
|
}
|
|
5676
|
+
/**
|
|
5677
|
+
* Two-step mode: run the deferred authentication (`POST /standalone-3ds/process`). Never throws: runs now if
|
|
5678
|
+
* the deferred message already arrived, otherwise as soon as it does; a no-op on one-step charges, repeated
|
|
5679
|
+
* calls or after a terminal outcome. The outcome flows through the usual events.
|
|
5680
|
+
*/
|
|
5681
|
+
}, {
|
|
5682
|
+
key: "authenticate",
|
|
5683
|
+
value: function authenticate() {
|
|
5684
|
+
if (this.authenticateRequested) {
|
|
5685
|
+
return;
|
|
5686
|
+
}
|
|
5687
|
+
this.authenticateRequested = true;
|
|
5688
|
+
if (this.deferredCharge3dsId !== null) {
|
|
5689
|
+
this.performAuthentication(this.deferredCharge3dsId);
|
|
5690
|
+
}
|
|
5691
|
+
}
|
|
5692
|
+
/**
|
|
5693
|
+
* Calls `/process` once per instance (reachable from both the deferred message and `authenticate()`). The
|
|
5694
|
+
* response has the callback-outcome shape, so the challenge / decoupled / result legs are shared with
|
|
5695
|
+
* one-step. A rejection surfaces as `error`, with the same error object shape as the one-step callback
|
|
5696
|
+
* (`toOutcomeError`). An API answer (stale session, rejected authentication…) is terminal. The first transport
|
|
5697
|
+
* failure is not: the AReq may have run with its response lost, so the latches are reset and the merchant may
|
|
5698
|
+
* call `authenticate()` once more — `/process` is idempotent and replays the stored outcome. A failure of that
|
|
5699
|
+
* retry, of any kind, is final.
|
|
5700
|
+
*/
|
|
5701
|
+
}, {
|
|
5702
|
+
key: "performAuthentication",
|
|
5703
|
+
value: function performAuthentication(charge3dsId) {
|
|
5704
|
+
var _this3 = this;
|
|
5705
|
+
if (this.authenticationStarted) {
|
|
5706
|
+
return;
|
|
5707
|
+
}
|
|
5708
|
+
this.authenticationStarted = true;
|
|
5709
|
+
this.api.charge().standalone3dsProcess({
|
|
5710
|
+
charge_3ds_id: charge3dsId
|
|
5711
|
+
}).then(function (authenticationResult) {
|
|
5712
|
+
return _this3.handleAuthenticationOutcome(authenticationResult, charge3dsId);
|
|
5713
|
+
}, function (err) {
|
|
5714
|
+
if (isTransportFailure(err) && !_this3.authenticationRetryUsed) {
|
|
5715
|
+
_this3.authenticationRetryUsed = true;
|
|
5716
|
+
_this3.authenticateRequested = false;
|
|
5717
|
+
_this3.authenticationStarted = false;
|
|
5718
|
+
} else {
|
|
5719
|
+
_this3.resultRead = true;
|
|
5720
|
+
_this3.finishChallengeLifecycle();
|
|
5721
|
+
}
|
|
5722
|
+
_this3.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this3.parseError(toOutcomeError(err), charge3dsId));
|
|
5723
|
+
});
|
|
5724
|
+
}
|
|
5602
5725
|
/**
|
|
5603
5726
|
* A message carries a processed outcome only when it has `process_status` AND comes from a trusted
|
|
5604
5727
|
* origin. Used by the result leg: an untrusted `process_status` is never acted upon — the SDK falls
|
|
@@ -5652,18 +5775,18 @@ var GPaymentsService = /*#__PURE__*/function () {
|
|
|
5652
5775
|
}, {
|
|
5653
5776
|
key: "startChallengeLifecycle",
|
|
5654
5777
|
value: function startChallengeLifecycle(charge3dsId) {
|
|
5655
|
-
var
|
|
5778
|
+
var _this4 = this;
|
|
5656
5779
|
this.clearChallengeLoadedTimer();
|
|
5657
5780
|
this.challengeLoadedEmitted = false;
|
|
5658
5781
|
this.challengeCompletedEmitted = false;
|
|
5659
5782
|
this.challengeLifecycleClosed = false;
|
|
5660
5783
|
return function () {
|
|
5661
5784
|
var _a;
|
|
5662
|
-
if (
|
|
5785
|
+
if (_this4.challengeLifecycleClosed || _this4.challengeLoadedEmitted || !((_a = _this4.iFrameAuthorization) === null || _a === void 0 ? void 0 : _a.isExist())) {
|
|
5663
5786
|
return;
|
|
5664
5787
|
}
|
|
5665
|
-
|
|
5666
|
-
|
|
5788
|
+
_this4.clearChallengeLoadedTimer();
|
|
5789
|
+
_this4.emitChallengeLoaded(charge3dsId, 'load');
|
|
5667
5790
|
};
|
|
5668
5791
|
}
|
|
5669
5792
|
/**
|
|
@@ -5673,17 +5796,17 @@ var GPaymentsService = /*#__PURE__*/function () {
|
|
|
5673
5796
|
}, {
|
|
5674
5797
|
key: "armChallengeLoadedFallback",
|
|
5675
5798
|
value: function armChallengeLoadedFallback(charge3dsId) {
|
|
5676
|
-
var
|
|
5799
|
+
var _this5 = this;
|
|
5677
5800
|
var _a;
|
|
5678
5801
|
if (!((_a = this.iFrameAuthorization) === null || _a === void 0 ? void 0 : _a.isExist())) {
|
|
5679
5802
|
return;
|
|
5680
5803
|
}
|
|
5681
5804
|
this.challengeLoadedTimer = setTimeout(function () {
|
|
5682
|
-
|
|
5683
|
-
if (
|
|
5805
|
+
_this5.challengeLoadedTimer = null;
|
|
5806
|
+
if (_this5.challengeLifecycleClosed || _this5.challengeLoadedEmitted) {
|
|
5684
5807
|
return;
|
|
5685
5808
|
}
|
|
5686
|
-
|
|
5809
|
+
_this5.emitChallengeLoaded(charge3dsId, 'timeout');
|
|
5687
5810
|
}, CHALLENGE_LOADED_FALLBACK_MS);
|
|
5688
5811
|
}
|
|
5689
5812
|
}, {
|
|
@@ -5760,7 +5883,7 @@ var GPaymentsService = /*#__PURE__*/function () {
|
|
|
5760
5883
|
}, {
|
|
5761
5884
|
key: "processResult",
|
|
5762
5885
|
value: function processResult(charge3dsId) {
|
|
5763
|
-
var
|
|
5886
|
+
var _this6 = this;
|
|
5764
5887
|
if (this.resultRead) {
|
|
5765
5888
|
return;
|
|
5766
5889
|
}
|
|
@@ -5768,15 +5891,15 @@ var GPaymentsService = /*#__PURE__*/function () {
|
|
|
5768
5891
|
this.finishChallengeLifecycle();
|
|
5769
5892
|
this.api.charge().standalone3dsHandle().then(function (result) {
|
|
5770
5893
|
var _a;
|
|
5771
|
-
|
|
5772
|
-
(_a =
|
|
5894
|
+
_this6.iFrameAuthorization.remove();
|
|
5895
|
+
(_a = _this6.iFrameSecondaryUrl) === null || _a === void 0 ? void 0 : _a.remove();
|
|
5773
5896
|
if (result.status === PROCESS_STANDALONE_3DS_STATUS.SUCCESS) {
|
|
5774
|
-
|
|
5897
|
+
_this6.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, _this6.parseResultData(result, charge3dsId));
|
|
5775
5898
|
} else {
|
|
5776
|
-
|
|
5899
|
+
_this6.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, _this6.parseResultData(result, charge3dsId));
|
|
5777
5900
|
}
|
|
5778
5901
|
}, function (err) {
|
|
5779
|
-
|
|
5902
|
+
_this6.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this6.parseError(err, charge3dsId));
|
|
5780
5903
|
});
|
|
5781
5904
|
}
|
|
5782
5905
|
/** Final (post-challenge) outcome delivered by the API through the callback message. */
|
|
@@ -5836,43 +5959,43 @@ var GPaymentsService = /*#__PURE__*/function () {
|
|
|
5836
5959
|
}, {
|
|
5837
5960
|
key: "doPolling",
|
|
5838
5961
|
value: function doPolling(url, charge3dsId, intervalMs) {
|
|
5839
|
-
var
|
|
5962
|
+
var _this7 = this;
|
|
5840
5963
|
this.stopResultPolling();
|
|
5841
5964
|
if (this.resultRead || this.challengeLifecycleClosed) {
|
|
5842
5965
|
return;
|
|
5843
5966
|
}
|
|
5844
5967
|
var schedule = function schedule() {
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5968
|
+
_this7.resultPollTimer = setTimeout(function () {
|
|
5969
|
+
_this7.resultPollTimer = null;
|
|
5970
|
+
_this7.doPolling(url, charge3dsId, intervalMs);
|
|
5848
5971
|
}, intervalMs);
|
|
5849
5972
|
};
|
|
5850
5973
|
this.externalAPI('GET', url).then(function (data) {
|
|
5851
|
-
if (
|
|
5974
|
+
if (_this7.resultRead || _this7.challengeLifecycleClosed) {
|
|
5852
5975
|
return;
|
|
5853
5976
|
}
|
|
5854
5977
|
if (!data.event || data.event === 'AuthResultNotReady') {
|
|
5855
5978
|
schedule();
|
|
5856
5979
|
} else if (data.event === 'AuthResultReady') {
|
|
5857
|
-
|
|
5858
|
-
|
|
5980
|
+
_this7.emitChallengeCompleted(charge3dsId, 'poll');
|
|
5981
|
+
_this7.processResult(charge3dsId);
|
|
5859
5982
|
} else {
|
|
5860
5983
|
throw new Error('Event not supported');
|
|
5861
5984
|
}
|
|
5862
5985
|
})["catch"](function (err) {
|
|
5863
5986
|
if (err instanceof ResultMonitorTransportError) {
|
|
5864
|
-
if (!
|
|
5987
|
+
if (!_this7.resultRead && !_this7.challengeLifecycleClosed) {
|
|
5865
5988
|
schedule();
|
|
5866
5989
|
}
|
|
5867
5990
|
return;
|
|
5868
5991
|
}
|
|
5869
|
-
|
|
5870
|
-
|
|
5992
|
+
_this7.finishChallengeLifecycle();
|
|
5993
|
+
_this7.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, _this7.parseError(err, charge3dsId));
|
|
5871
5994
|
});
|
|
5872
5995
|
}
|
|
5873
5996
|
/**
|
|
5874
|
-
* Branches on the authentication outcome delivered by the API through the callback message
|
|
5875
|
-
* (`process_status` → `status
|
|
5997
|
+
* Branches on the authentication outcome — delivered by the API through the callback message
|
|
5998
|
+
* (`process_status` → `status`) or, in two-step mode, returned by `/process` (same shape).
|
|
5876
5999
|
*/
|
|
5877
6000
|
}, {
|
|
5878
6001
|
key: "handleAuthenticationOutcome",
|
|
@@ -5942,17 +6065,38 @@ var Standalone3dsService = /*#__PURE__*/function () {
|
|
|
5942
6065
|
api.setEnv(this.env, this.alias);
|
|
5943
6066
|
switch (tokenData.service_type) {
|
|
5944
6067
|
case STANDALONE_3DS_GATEWAYS.GPAYMENTS:
|
|
5945
|
-
new GPaymentsService(this.container, api, this.eventEmitter, this.getTrustedMessageOrigins(api))
|
|
6068
|
+
this.gpaymentsService = new GPaymentsService(this.container, api, this.eventEmitter, this.getTrustedMessageOrigins(api));
|
|
6069
|
+
this.gpaymentsService.load(tokenData, options.title);
|
|
5946
6070
|
break;
|
|
5947
6071
|
}
|
|
5948
6072
|
}
|
|
5949
6073
|
/**
|
|
5950
|
-
*
|
|
5951
|
-
*
|
|
6074
|
+
* Two-step mode: forwards `Canvas3ds.authenticate()` to the provider flow. Calling it before `load()` is an
|
|
6075
|
+
* integration bug (nothing to authenticate yet): it emits `error` and is not remembered.
|
|
5952
6076
|
*/
|
|
6077
|
+
}, {
|
|
6078
|
+
key: "authenticate",
|
|
6079
|
+
value: function authenticate(token) {
|
|
6080
|
+
if (!this.gpaymentsService) {
|
|
6081
|
+
this.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, {
|
|
6082
|
+
charge_3ds_id: Standalone3dsService.readCharge3dsId(token),
|
|
6083
|
+
error: {
|
|
6084
|
+
message: 'Canvas3ds.authenticate() called before load()'
|
|
6085
|
+
}
|
|
6086
|
+
});
|
|
6087
|
+
return;
|
|
6088
|
+
}
|
|
6089
|
+
this.gpaymentsService.authenticate();
|
|
6090
|
+
}
|
|
6091
|
+
/** `charge_3ds_id` from the standalone 3DS charge token, `undefined` when it cannot be decoded. */
|
|
5953
6092
|
}, {
|
|
5954
6093
|
key: "getTrustedMessageOrigins",
|
|
5955
|
-
value:
|
|
6094
|
+
value:
|
|
6095
|
+
/**
|
|
6096
|
+
* Origins allowed to deliver a processed 3DS outcome to the page via postMessage: the Paydock API
|
|
6097
|
+
* (inline callback page) and the Paydock widget (remote-app landing page), for the current env/alias.
|
|
6098
|
+
*/
|
|
6099
|
+
function getTrustedMessageOrigins(api) {
|
|
5956
6100
|
var origins = [api.getApiOrigin()];
|
|
5957
6101
|
try {
|
|
5958
6102
|
var widgetEnv = new Env(WIDGET_URL, this.env);
|
|
@@ -5969,6 +6113,13 @@ var Standalone3dsService = /*#__PURE__*/function () {
|
|
|
5969
6113
|
this.env = env;
|
|
5970
6114
|
this.alias = alias;
|
|
5971
6115
|
}
|
|
6116
|
+
}], [{
|
|
6117
|
+
key: "readCharge3dsId",
|
|
6118
|
+
value: function readCharge3dsId(token) {
|
|
6119
|
+
var _a;
|
|
6120
|
+
var parsedToken = AccessToken.validateJWT(token);
|
|
6121
|
+
return parsedToken ? (_a = AccessToken.extractData(parsedToken.body)) === null || _a === void 0 ? void 0 : _a.charge_3ds_id : undefined;
|
|
6122
|
+
}
|
|
5972
6123
|
}]);
|
|
5973
6124
|
}();
|
|
5974
6125
|
|
|
@@ -6135,6 +6286,7 @@ var TOKEN_FORMAT$2;
|
|
|
6135
6286
|
* @param {string} AUTH_ERROR=chargeAuthReject
|
|
6136
6287
|
* @param {string} DECOUPLED=chargeAuthDecoupled
|
|
6137
6288
|
* @param {string} CHALLENGE=chargeAuthChallenge
|
|
6289
|
+
* @param {string} READY=chargeAuthReady - two-step mode only: fingerprint done, waiting for `authenticate()`
|
|
6138
6290
|
* @param {string} CHALLENGE_LOADED=chargeAuthChallengeLoaded - challenge iframe painted (first `load`, or 2.5 s fallback); reveal your challenge UI here
|
|
6139
6291
|
* @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
|
|
6140
6292
|
* @param {string} INFO=chargeAuthInfo
|
|
@@ -6264,6 +6416,39 @@ var Canvas3ds = /*#__PURE__*/function () {
|
|
|
6264
6416
|
});
|
|
6265
6417
|
}
|
|
6266
6418
|
}
|
|
6419
|
+
/**
|
|
6420
|
+
* Two-step mode only (`_3ds.authentication_flow: 'two_step'`): runs the authentication the API deferred after the
|
|
6421
|
+
* fingerprint. Call it when the shopper confirms (e.g. presses "Pay"); the outcome arrives through the
|
|
6422
|
+
* usual events (`chargeAuthChallenge`, `chargeAuthSuccess`, `chargeAuthReject`, `error`).
|
|
6423
|
+
*
|
|
6424
|
+
* Never throws. After `chargeAuthReady` the authentication starts at once; before it, the call is
|
|
6425
|
+
* remembered and runs as soon as the fingerprint completes. One-step charges, repeated calls and calls after
|
|
6426
|
+
* a terminal outcome are no-ops. For inbuilt 3DS (`html` / `url`) tokens it is a silent no-op: no event is
|
|
6427
|
+
* emitted at all, so do not wait for `error` there. Calling it before `load()` is an integration error: it emits `error` and
|
|
6428
|
+
* is not remembered. If `/process` could not be reached (`error` with `error_code` `service_unreachable` /
|
|
6429
|
+
* `aborted`), `authenticate()` may be called once more; any other `error`, and any failure of that retry,
|
|
6430
|
+
* is final.
|
|
6431
|
+
* No client-side deadline: a stale 3DS Server session surfaces as `error` / `chargeAuthReject`.
|
|
6432
|
+
*
|
|
6433
|
+
* @example
|
|
6434
|
+
* const widget = new Canvas3ds('#widget', token); // charge created with _3ds.authentication_flow: 'two_step'
|
|
6435
|
+
* widget.on('chargeAuthReady', () => payButton.disabled = false);
|
|
6436
|
+
* widget.on('chargeAuthChallenge', () => showChallengeModal());
|
|
6437
|
+
* widget.on('chargeAuthSuccess', (data) => completePayment(data.charge_3ds_id));
|
|
6438
|
+
* widget.on('chargeAuthReject', () => showDeclined());
|
|
6439
|
+
* widget.on('error', () => showError());
|
|
6440
|
+
* widget.load(); // fingerprint runs while the shopper reviews the order
|
|
6441
|
+
*
|
|
6442
|
+
* payButton.addEventListener('click', () => widget.authenticate());
|
|
6443
|
+
*/
|
|
6444
|
+
}, {
|
|
6445
|
+
key: "authenticate",
|
|
6446
|
+
value: function authenticate() {
|
|
6447
|
+
if (this.token.format !== TOKEN_FORMAT$2.STANDALONE_3DS) {
|
|
6448
|
+
return;
|
|
6449
|
+
}
|
|
6450
|
+
this.standalone3dsService.authenticate(this.token.content);
|
|
6451
|
+
}
|
|
6267
6452
|
/**
|
|
6268
6453
|
* Using this method you can hide widget after load
|
|
6269
6454
|
* @param {boolean} [saveSize=false] - using this param you can save iframe's size
|
|
@@ -45925,14 +46110,17 @@ var dbf = function (l) { return l == 1 ? 3 : l < 6 ? 2 : l == 9 ? 1 : 0; };
|
|
|
45925
46110
|
var slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };
|
|
45926
46111
|
// read zip header
|
|
45927
46112
|
var zh = function (d, b, z) {
|
|
45928
|
-
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);
|
|
45929
|
-
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];
|
|
45930
|
-
return [b2(d, b + 10), sc, su, fn, es +
|
|
46113
|
+
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);
|
|
46114
|
+
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];
|
|
46115
|
+
return [b2(d, b + 10), sc, su, fn, es + efl + b2(d, b + 32), off];
|
|
45931
46116
|
};
|
|
45932
46117
|
// read zip64 extra field
|
|
45933
|
-
var z64e = function (d, b) {
|
|
45934
|
-
|
|
45935
|
-
|
|
46118
|
+
var z64e = function (d, b, l) {
|
|
46119
|
+
var e = b + l;
|
|
46120
|
+
for (; b2(d, b) != 1; b += 4 + b2(d, b + 2)) {
|
|
46121
|
+
if (b + 4 > e)
|
|
46122
|
+
err(13);
|
|
46123
|
+
}
|
|
45936
46124
|
return [b8(d, b + 12), b8(d, b + 4), b8(d, b + 20)];
|
|
45937
46125
|
};
|
|
45938
46126
|
// extra field length
|
|
@@ -46535,7 +46723,7 @@ var Unzip = /*#__PURE__*/ (function () {
|
|
|
46535
46723
|
var sc_1 = b4(buf, i + 18), su_1 = b4(buf, i + 22);
|
|
46536
46724
|
var fn_1 = strFromU8(buf.subarray(i + 30, i += 30 + fnl), !u);
|
|
46537
46725
|
if (sc_1 == 4294967295) {
|
|
46538
|
-
_a = dd ? [-2] : z64e(buf, i), sc_1 = _a[0], su_1 = _a[1];
|
|
46726
|
+
_a = dd ? [-2] : z64e(buf, i, es), sc_1 = _a[0], su_1 = _a[1];
|
|
46539
46727
|
}
|
|
46540
46728
|
else if (dd)
|
|
46541
46729
|
sc_1 = -1;
|