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