@paydock/client-sdk 1.10.71 → 1.10.72-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.
@@ -4,6 +4,8 @@ export declare class ApiChargeInternal {
4
4
  constructor(api: ApiInternal);
5
5
  walletCapture(payload: WalletCaptureBody): Promise<WalletCaptureResponse>;
6
6
  walletCallback(payload: WalletCallbackBody): Promise<WalletCallbackResponse>;
7
+ standalone3dsProcess(payload: Standalone3dsProcessBody): Promise<ProcessAuthenticationResponse>;
8
+ standalone3dsHandle(): Promise<HandleResponseInterface>;
7
9
  }
8
10
  interface WalletCaptureResponse {
9
11
  id: string;
@@ -42,4 +44,54 @@ interface WalletCallbackResponse {
42
44
  callback_rel: string;
43
45
  callback_url: string;
44
46
  }
47
+ interface Standalone3dsProcessBody {
48
+ charge_3ds_id: string;
49
+ }
50
+ export interface HandleResponseInterface {
51
+ status: string;
52
+ error: string;
53
+ result: {
54
+ reference: string;
55
+ reference_2: string;
56
+ identifier: string;
57
+ identifier_2: string;
58
+ identifier_3: string;
59
+ identifier_4: string;
60
+ identifier_5: string;
61
+ type: string;
62
+ status: string;
63
+ status_2: string;
64
+ status_code: string;
65
+ ref_token: string;
66
+ cancellation: string;
67
+ count: string;
68
+ version: string;
69
+ whitelist: {
70
+ status: string;
71
+ source: string;
72
+ };
73
+ result: string;
74
+ };
75
+ }
76
+ export interface ProcessAuthenticationResponse {
77
+ status: string;
78
+ error: string;
79
+ result: {
80
+ challenge: string;
81
+ challenge_url: string;
82
+ decoupled_challenge: boolean;
83
+ frictionless: boolean;
84
+ identifier: string;
85
+ identifier_3: string;
86
+ identifier_4: string;
87
+ reference: string;
88
+ reference_2: string;
89
+ secondary_url: string;
90
+ skipped: boolean;
91
+ status: string;
92
+ type: string;
93
+ version: string;
94
+ description?: string;
95
+ };
96
+ }
45
97
  export {};
@@ -1,6 +1,7 @@
1
- const PRE_AUTH_CHARGE_LINK = '/v1/charges/3ds';
2
1
  const WALLET_CAPTURE_LINK = '/v1/charges/wallet/capture';
3
2
  const WALLET_CALLBACK_LINK = '/v1/charges/wallet/callback';
3
+ const STANDALONE_3DS_PROCESS_LINK = '/v1/charges/standalone-3ds/process';
4
+ const STANDALONE_3DS_HANDLE_LINK = '/v1/charges/standalone-3ds/handle';
4
5
  export class ApiChargeInternal {
5
6
  constructor(api) {
6
7
  this.api = api;
@@ -15,5 +16,15 @@ export class ApiChargeInternal {
15
16
  .getClientPromise('POST', WALLET_CALLBACK_LINK)
16
17
  .send(payload);
17
18
  }
19
+ standalone3dsProcess(payload) {
20
+ return this.api
21
+ .getClientPromise('POST', STANDALONE_3DS_PROCESS_LINK)
22
+ .send(payload);
23
+ }
24
+ standalone3dsHandle() {
25
+ return this.api
26
+ .getClientPromise('GET', STANDALONE_3DS_HANDLE_LINK)
27
+ .send(undefined);
28
+ }
18
29
  }
19
30
  //# sourceMappingURL=../../src/lib/api/api-charge-internal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-charge-internal.js","sourceRoot":"","sources":["../../api/api-charge-internal.ts"],"names":[],"mappings":"AAGA,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAC/C,MAAM,mBAAmB,GAAG,4BAA4B,CAAC;AACzD,MAAM,oBAAoB,GAAG,6BAA6B,CAAC;AAE3D,MAAM,OAAO,iBAAiB;IAC1B,YAAsB,GAAgB;QAAhB,QAAG,GAAH,GAAG,CAAa;IACtC,CAAC;IAED,aAAa,CAAC,OAA0B;QACpC,OAAO,IAAI,CAAC,GAAG;aACV,gBAAgB,CAA2C,MAAM,EAAE,mBAAmB,CAAC;aACvF,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAED,cAAc,CAAC,OAA2B;QACtC,OAAO,IAAI,CAAC,GAAG;aACV,gBAAgB,CAA6C,MAAM,EAAE,oBAAoB,CAAC;aAC1F,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;CACJ"}
1
+ {"version":3,"file":"api-charge-internal.js","sourceRoot":"","sources":["../../api/api-charge-internal.ts"],"names":[],"mappings":"AAEA,MAAM,mBAAmB,GAAG,4BAA4B,CAAC;AACzD,MAAM,oBAAoB,GAAG,6BAA6B,CAAC;AAC3D,MAAM,2BAA2B,GAAG,oCAAoC,CAAC;AACzE,MAAM,0BAA0B,GAAG,mCAAmC,CAAC;AAEvE,MAAM,OAAO,iBAAiB;IAC1B,YAAsB,GAAgB;QAAhB,QAAG,GAAH,GAAG,CAAa;IACtC,CAAC;IAED,aAAa,CAAC,OAA0B;QACpC,OAAO,IAAI,CAAC,GAAG;aACV,gBAAgB,CAA2C,MAAM,EAAE,mBAAmB,CAAC;aACvF,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAED,cAAc,CAAC,OAA2B;QACtC,OAAO,IAAI,CAAC,GAAG;aACV,gBAAgB,CAA6C,MAAM,EAAE,oBAAoB,CAAC;aAC1F,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAED,oBAAoB,CAAC,OAAiC;QAClD,OAAO,IAAI,CAAC,GAAG;aACV,gBAAgB,CAA0D,MAAM,EAAE,2BAA2B,CAAC;aAC9G,IAAI,CAAC,OAAO,CAAC,CAAC;IACvB,CAAC;IAED,mBAAmB;QACf,OAAO,IAAI,CAAC,GAAG;aACV,gBAAgB,CAAoD,KAAK,EAAE,0BAA0B,CAAC;aACtG,IAAI,CAAC,SAAS,CAAC,CAAC;IACzB,CAAC;CACJ"}
@@ -3,6 +3,8 @@ import { Container } from '../components/container';
3
3
  import { IFrame } from '../components/iframe';
4
4
  import { IEventData, IFrameEvent } from '../components/iframe-event';
5
5
  import { Configuration } from '../widget/configuration';
6
+ import { Standalone3dsService } from '../canvas-3ds/services/index';
7
+ import { EventEmitter } from "../helper/event-emitter";
6
8
  /**
7
9
  * List of available token's content formats
8
10
  * @enum TOKEN_FORMAT
@@ -12,7 +14,8 @@ import { Configuration } from '../widget/configuration';
12
14
  */
13
15
  declare enum TOKEN_FORMAT {
14
16
  HTML = "html",
15
- URL = "url"
17
+ URL = "url",
18
+ STANDALONE_3DS = "standalone_3ds"
16
19
  }
17
20
  /**
18
21
  * List of available event's name
@@ -25,6 +28,17 @@ declare enum TOKEN_FORMAT {
25
28
  * @param {string} ADDITIONAL_DATA_REJECT=additionalDataCollectReject
26
29
  * @param {string} CHARGE_AUTH=chargeAuth
27
30
  */
31
+ /**
32
+ * List of available event's name for Standalone 3ds flow
33
+ * @const STANDALONE_3DS_EVENT
34
+ *
35
+ * @type {object}
36
+ * @param {string} CHARGE_AUTH_SUCCESS=chargeAuthSuccess
37
+ * @param {string} CHARGE_AUTH_REJECT=chargeAuthReject
38
+ * @param {string} CHARGE_AUTH_DECOUPLED=chargeAuthDecoupled
39
+ * @param {string} CHARGE_AUTH_CHALLENGE=chargeAuthChallenge
40
+ * @param {string} ERROR=error
41
+ */
28
42
  /**
29
43
  * Class Canvas3ds include method for working on html
30
44
  * @constructor
@@ -45,9 +59,11 @@ export declare class Canvas3ds {
45
59
  format: TOKEN_FORMAT;
46
60
  charge_3ds_id: string;
47
61
  };
62
+ protected standalone3dsService: Standalone3dsService;
48
63
  protected container: Container;
49
64
  protected iFrame: IFrame;
50
65
  protected event: IFrameEvent;
66
+ protected eventEmitter: EventEmitter;
51
67
  constructor(selector: string, token: string);
52
68
  protected static extractToken(token: string): {
53
69
  content: string;
@@ -2,6 +2,8 @@ import { Link, SECURE_3D } from '../components/link';
2
2
  import { Container } from '../components/container';
3
3
  import { IFrame } from '../components/iframe';
4
4
  import { IFrameEvent } from '../components/iframe-event';
5
+ import { Standalone3dsService } from '../canvas-3ds/services/index';
6
+ import { EventEmitter } from "../helper/event-emitter";
5
7
  /**
6
8
  * List of available token's content formats
7
9
  * @enum TOKEN_FORMAT
@@ -13,6 +15,7 @@ var TOKEN_FORMAT;
13
15
  (function (TOKEN_FORMAT) {
14
16
  TOKEN_FORMAT["HTML"] = "html";
15
17
  TOKEN_FORMAT["URL"] = "url";
18
+ TOKEN_FORMAT["STANDALONE_3DS"] = "standalone_3ds";
16
19
  })(TOKEN_FORMAT || (TOKEN_FORMAT = {}));
17
20
  /**
18
21
  * List of available event's name
@@ -25,6 +28,17 @@ var TOKEN_FORMAT;
25
28
  * @param {string} ADDITIONAL_DATA_REJECT=additionalDataCollectReject
26
29
  * @param {string} CHARGE_AUTH=chargeAuth
27
30
  */
31
+ /**
32
+ * List of available event's name for Standalone 3ds flow
33
+ * @const STANDALONE_3DS_EVENT
34
+ *
35
+ * @type {object}
36
+ * @param {string} CHARGE_AUTH_SUCCESS=chargeAuthSuccess
37
+ * @param {string} CHARGE_AUTH_REJECT=chargeAuthReject
38
+ * @param {string} CHARGE_AUTH_DECOUPLED=chargeAuthDecoupled
39
+ * @param {string} CHARGE_AUTH_CHALLENGE=chargeAuthChallenge
40
+ * @param {string} ERROR=error
41
+ */
28
42
  /**
29
43
  * Class Canvas3ds include method for working on html
30
44
  * @constructor
@@ -44,6 +58,8 @@ export class Canvas3ds {
44
58
  this.link.setParams({ ref_id: this.token.charge_3ds_id });
45
59
  this.container = new Container(selector);
46
60
  this.iFrame = new IFrame(this.container);
61
+ this.eventEmitter = new EventEmitter();
62
+ this.standalone3dsService = new Standalone3dsService(this.container, this.eventEmitter);
47
63
  this.event = new IFrameEvent(window);
48
64
  }
49
65
  static extractToken(token) {
@@ -58,6 +74,8 @@ export class Canvas3ds {
58
74
  this.iFrame.loadFromHtml(this.token.content, { title: '3d secure authentication' });
59
75
  else if (this.token.format === TOKEN_FORMAT.URL)
60
76
  this.iFrame.load(this.token.content, { title: '3d secure authentication' });
77
+ else if (this.token.format === TOKEN_FORMAT.STANDALONE_3DS)
78
+ this.standalone3dsService.load(this.token.content, { title: '3d secure authentication' });
61
79
  else
62
80
  console.error('Token contain unsupported payload');
63
81
  }
@@ -72,6 +90,7 @@ export class Canvas3ds {
72
90
  */
73
91
  setEnv(env, alias) {
74
92
  this.link.setEnv(env, alias);
93
+ this.standalone3dsService.setEnv(env, alias);
75
94
  for (let index in this.configs) {
76
95
  if (!this.configs.hasOwnProperty(index))
77
96
  continue;
@@ -93,14 +112,21 @@ export class Canvas3ds {
93
112
  * widget.on('chargeAuthReject').then(function (data) {
94
113
  * console.log(data);
95
114
  * });
96
- * @param {string} eventName - Available event names [EVENT]{@link EVENT}
115
+ * @param {string} eventName - Available event names [EVENT]{@link EVENT} [STANDALONE_3DS_EVENT]{@link STANDALONE_3DS_EVENT}
97
116
  * @param {listener} [cb]
98
117
  * @return {Promise<IEventData> | void}
99
118
  */
100
119
  on(eventName, cb) {
101
- if (typeof cb === 'function')
102
- return this.event.on(eventName, this.link.getParams().ref_id, cb);
103
- return new Promise((resolve) => this.event.on(eventName, this.link.getParams().ref_id, (res) => resolve(res)));
120
+ if (this.token.format === TOKEN_FORMAT.STANDALONE_3DS) {
121
+ if (typeof cb === 'function')
122
+ return this.eventEmitter.subscribe(eventName, cb);
123
+ return new Promise((resolve) => this.eventEmitter.subscribe(eventName, (res) => resolve(res)));
124
+ }
125
+ else {
126
+ if (typeof cb === 'function')
127
+ return this.event.on(eventName, this.link.getParams().ref_id, cb);
128
+ return new Promise((resolve) => this.event.on(eventName, this.link.getParams().ref_id, (res) => resolve(res)));
129
+ }
104
130
  }
105
131
  /**
106
132
  * Using this method you can hide widget after load
@@ -1 +1 @@
1
- {"version":3,"file":"canvas-3ds.js","sourceRoot":"","sources":["../../canvas-3ds/canvas-3ds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAqB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAG5E;;;;;;GAMG;AACH,IAAK,YAGJ;AAHD,WAAK,YAAY;IACb,6BAAa,CAAA;IACb,2BAAW,CAAA;AACf,CAAC,EAHI,YAAY,KAAZ,YAAY,QAG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CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;IAGD;;;OAGG;IACI,MAAM;QACT,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACrB,IAAI,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;CACJ"}
@@ -0,0 +1,42 @@
1
+ import { ApiInternal } from "../../api/api-internal";
2
+ import { Container } from "../../components/container";
3
+ import { IFrame } from "../../components/iframe";
4
+ import { IFrameEvent } from "../../components/iframe-event";
5
+ import { ITokenStandalone3DS } from "./standalone3ds-service";
6
+ import { EventEmitter } from "../../helper/event-emitter";
7
+ export declare enum PROCESS_STANDALONE_3DS_STATUS {
8
+ SUCCESS = "success",
9
+ ERROR = "error",
10
+ PENDING = "pending"
11
+ }
12
+ export declare const GPAYMENTS_EVENT: {
13
+ AUTH_SUCCESS: string;
14
+ AUTH_ERROR: string;
15
+ DECOUPLED: string;
16
+ CHALLENGE: string;
17
+ ERROR: string;
18
+ };
19
+ export declare class GPaymentsService {
20
+ protected container: Container;
21
+ protected api: ApiInternal;
22
+ protected eventEmitter: EventEmitter;
23
+ protected browserAndChallengeContainer: Container;
24
+ protected monitoringContainer: Container;
25
+ protected iFrameAuthorization: IFrame;
26
+ protected challengeAuthorization: IFrame;
27
+ protected iFrameSecondaryUrl: IFrame;
28
+ protected iFrameEvent: IFrameEvent;
29
+ protected resultRead: boolean;
30
+ constructor(container: Container, api: ApiInternal, eventEmitter: EventEmitter);
31
+ load({ initialization_url, secondary_url, charge_3ds_id }: ITokenStandalone3DS, title: string): void;
32
+ private initializeIFrames;
33
+ private hideIframes;
34
+ private setupIFrameEvents;
35
+ private parseResultData;
36
+ private parseHandleResponse;
37
+ private parseError;
38
+ private processResult;
39
+ private externalAPI;
40
+ private doPolling;
41
+ private performAuthentication;
42
+ }
@@ -0,0 +1,162 @@
1
+ import { Container } from "../../components/container";
2
+ import { IFrame } from "../../components/iframe";
3
+ import { EVENT, IFrameEvent } from "../../components/iframe-event";
4
+ const hiddenStyle = {
5
+ visibility: "hidden",
6
+ border: "0",
7
+ width: "0",
8
+ height: "0",
9
+ };
10
+ export var PROCESS_STANDALONE_3DS_STATUS;
11
+ (function (PROCESS_STANDALONE_3DS_STATUS) {
12
+ PROCESS_STANDALONE_3DS_STATUS["SUCCESS"] = "success";
13
+ PROCESS_STANDALONE_3DS_STATUS["ERROR"] = "error";
14
+ PROCESS_STANDALONE_3DS_STATUS["PENDING"] = "pending";
15
+ })(PROCESS_STANDALONE_3DS_STATUS || (PROCESS_STANDALONE_3DS_STATUS = {}));
16
+ export const GPAYMENTS_EVENT = {
17
+ AUTH_SUCCESS: 'chargeAuthSuccess',
18
+ AUTH_ERROR: 'chargeAuthReject',
19
+ DECOUPLED: 'chargeAuthDecoupled',
20
+ CHALLENGE: 'chargeAuthChallenge',
21
+ ERROR: 'error',
22
+ };
23
+ const AUTH_STATUS = {
24
+ REJECTED: 'rejected',
25
+ };
26
+ export class GPaymentsService {
27
+ constructor(container, api, eventEmitter) {
28
+ this.container = container;
29
+ this.api = api;
30
+ this.eventEmitter = eventEmitter;
31
+ this.resultRead = false;
32
+ this.iFrameEvent = new IFrameEvent(window);
33
+ }
34
+ load({ initialization_url, secondary_url, charge_3ds_id }, title) {
35
+ try {
36
+ this.setupIFrameEvents(charge_3ds_id);
37
+ this.initializeIFrames(initialization_url, secondary_url, title);
38
+ }
39
+ catch (err) {
40
+ this.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, this.parseError(err, charge_3ds_id));
41
+ }
42
+ }
43
+ initializeIFrames(initializationUrl, secondaryUrl, title, hideAuthorization = true) {
44
+ let divAuthorization = document.createElement("div");
45
+ divAuthorization.setAttribute("id", "paydock_authorization_iframe");
46
+ this.container.getElement().appendChild(divAuthorization);
47
+ this.browserAndChallengeContainer = new Container("#paydock_authorization_iframe");
48
+ this.iFrameAuthorization = new IFrame(this.browserAndChallengeContainer);
49
+ this.iFrameAuthorization.load(initializationUrl, { title });
50
+ let divSecondaryURL = document.createElement("div");
51
+ divSecondaryURL.setAttribute("id", "paydock_secondary_iframe");
52
+ this.container.getElement().appendChild(divSecondaryURL);
53
+ this.monitoringContainer = new Container("#paydock_secondary_iframe");
54
+ this.iFrameSecondaryUrl = new IFrame(this.monitoringContainer);
55
+ this.iFrameSecondaryUrl.load(secondaryUrl, { title });
56
+ this.hideIframes(hideAuthorization);
57
+ }
58
+ hideIframes(hideAuthorization = true) {
59
+ for (const prop in hiddenStyle) {
60
+ if (!hiddenStyle.hasOwnProperty(prop))
61
+ continue;
62
+ if (hideAuthorization)
63
+ this.iFrameAuthorization.setStyle(prop, hiddenStyle[prop]);
64
+ this.iFrameSecondaryUrl.setStyle(prop, hiddenStyle[prop]);
65
+ }
66
+ }
67
+ setupIFrameEvents(widgetId) {
68
+ this.iFrameEvent.on(EVENT.CHARGE_AUTH, widgetId, (data) => {
69
+ if (data.status === "MethodSkipped" /* SKIPPED */)
70
+ this.performAuthentication(data);
71
+ });
72
+ this.iFrameEvent.on(EVENT.CHARGE_AUTH_SUCCESS, widgetId, (data) => {
73
+ this.processResult(data.charge_3ds_id);
74
+ });
75
+ }
76
+ parseResultData({ status }, charge3dsId) {
77
+ return {
78
+ status,
79
+ charge_3ds_id: charge3dsId,
80
+ };
81
+ }
82
+ parseHandleResponse({ status, result }, charge3dsId) {
83
+ return {
84
+ status,
85
+ charge_3ds_id: charge3dsId,
86
+ result: {
87
+ description: result === null || result === void 0 ? void 0 : result.description,
88
+ },
89
+ };
90
+ }
91
+ parseError(data, charge3dsId) {
92
+ return { charge_3ds_id: charge3dsId, error: data };
93
+ }
94
+ processResult(charge3dsId) {
95
+ if (this.resultRead)
96
+ return;
97
+ this.resultRead = true;
98
+ this.api.charge().standalone3dsHandle().then((result) => {
99
+ this.iFrameAuthorization.remove();
100
+ this.iFrameSecondaryUrl.remove();
101
+ if (result.status === PROCESS_STANDALONE_3DS_STATUS.SUCCESS)
102
+ this.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, this.parseResultData(result, charge3dsId));
103
+ else
104
+ this.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, this.parseResultData(result, charge3dsId));
105
+ }, (err) => {
106
+ this.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, this.parseError(err, charge3dsId));
107
+ });
108
+ }
109
+ externalAPI(method, url) {
110
+ let request = new XMLHttpRequest();
111
+ request.open(method, url, true);
112
+ return new Promise((resolve, reject) => {
113
+ request.onload = () => {
114
+ try {
115
+ const body = JSON.parse(request.responseText);
116
+ resolve(body);
117
+ }
118
+ catch (error) {
119
+ reject(error);
120
+ }
121
+ };
122
+ request.send();
123
+ });
124
+ }
125
+ doPolling(url, charge3dsId) {
126
+ this.externalAPI("GET", url).then((data) => {
127
+ if (!data.event || data.event === "AuthResultNotReady")
128
+ setTimeout(() => {
129
+ this.doPolling(url, charge3dsId);
130
+ }, 2000);
131
+ else if (data.event === 'AuthResultReady')
132
+ this.processResult(charge3dsId);
133
+ else
134
+ throw new Error("Event not supported");
135
+ }).catch((err) => this.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, this.parseError(err, charge3dsId)));
136
+ }
137
+ performAuthentication({ charge_3ds_id }) {
138
+ this.iFrameAuthorization.remove();
139
+ this.iFrameSecondaryUrl.remove();
140
+ this.api.charge().standalone3dsProcess({ charge_3ds_id }).then((authenticationResult) => {
141
+ var _a, _b;
142
+ if (authenticationResult.status === "success" /* SUCCESS */)
143
+ this.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_SUCCESS, this.parseHandleResponse(authenticationResult, charge_3ds_id));
144
+ else if (authenticationResult.status === "pending" /* PENDING */) {
145
+ if ((_a = authenticationResult === null || authenticationResult === void 0 ? void 0 : authenticationResult.result) === null || _a === void 0 ? void 0 : _a.challenge) {
146
+ this.eventEmitter.emit(GPAYMENTS_EVENT.CHALLENGE, this.parseHandleResponse(authenticationResult, charge_3ds_id));
147
+ this.initializeIFrames(authenticationResult.result.challenge_url, 'authenticationResult.result.secondary_url', 'Authentication Challenge', false);
148
+ this.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
149
+ }
150
+ else if ((_b = authenticationResult === null || authenticationResult === void 0 ? void 0 : authenticationResult.result) === null || _b === void 0 ? void 0 : _b.decoupled_challenge) {
151
+ this.eventEmitter.emit(GPAYMENTS_EVENT.DECOUPLED, this.parseHandleResponse(authenticationResult, charge_3ds_id));
152
+ this.doPolling(authenticationResult.result.secondary_url, charge_3ds_id);
153
+ }
154
+ }
155
+ else
156
+ return this.eventEmitter.emit(GPAYMENTS_EVENT.AUTH_ERROR, this.parseHandleResponse(authenticationResult, charge_3ds_id));
157
+ }, (err) => {
158
+ this.eventEmitter.emit(GPAYMENTS_EVENT.ERROR, this.parseError(err, charge_3ds_id));
159
+ });
160
+ }
161
+ }
162
+ //# sourceMappingURL=../../../src/lib/canvas-3ds/services/gpayments-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gpayments-service.js","sourceRoot":"","sources":["../../../canvas-3ds/services/gpayments-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAKnE,MAAM,WAAW,GAAG;IAChB,UAAU,EAAE,QAAQ;IACpB,MAAM,EAAE,GAAG;IACX,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,GAAG;CACd,CAAC;AAEF,MAAM,CAAN,IAAY,6BAIX;AAJD,WAAY,6BAA6B;IACrC,oDAAmB,CAAA;IACnB,gDAAe,CAAA;IACf,oDAAmB,CAAA;AACvB,CAAC,EAJW,6BAA6B,KAA7B,6BAA6B,QAIxC;AAyBD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,YAAY,EAAE,mBAAmB;IACjC,UAAU,EAAE,kBAAkB;IAC9B,SAAS,EAAE,qBAAqB;IAChC,SAAS,EAAE,qBAAqB;IAChC,KAAK,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,0CAAE,mBAAmB,EAAE;oBAC1D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC,CAAC;oBACjH,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,MAAM,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;iBAC5E;aACJ;;gBACG,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,aAAa,CAAC,CAAC,CAAC;QACjI,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE;YACP,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC,CAAC;QACvF,CAAC,CAAC,CAAC;IACP,CAAC;CACJ"}
@@ -0,0 +1 @@
1
+ export { Standalone3dsService } from "./standalone3ds-service";
@@ -0,0 +1,2 @@
1
+ export { Standalone3dsService } from "./standalone3ds-service";
2
+ //# sourceMappingURL=../../../src/lib/canvas-3ds/services/index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../canvas-3ds/services/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Container } from "../../components/container";
2
+ import { EventEmitter } from "../../helper/event-emitter";
3
+ export interface ITokenStandalone3DS {
4
+ external_id?: string;
5
+ initialization_url?: string;
6
+ authorization_url?: string;
7
+ secondary_url?: string;
8
+ charge_3ds_id: string;
9
+ service_type: string;
10
+ }
11
+ export declare class Standalone3dsService {
12
+ protected container: Container;
13
+ protected eventEmitter: EventEmitter;
14
+ protected env: string;
15
+ protected alias: string;
16
+ constructor(container: Container, eventEmitter: any);
17
+ load(token: string, options: {
18
+ title: string;
19
+ }): void;
20
+ setEnv(env: string, alias?: string): void;
21
+ }
@@ -0,0 +1,32 @@
1
+ import { GPaymentsService } from "./gpayments-service";
2
+ import { AccessToken } from "../../helper/access-token";
3
+ import { ApiInternal, API_AUTH_TYPE } from "../../api/api-internal";
4
+ import { ENV } from "../../components/env";
5
+ const STANDALONE_3DS_GATEWAYS = {
6
+ GPAYMENTS: "GPayments",
7
+ };
8
+ export class Standalone3dsService {
9
+ constructor(container, eventEmitter) {
10
+ this.env = ENV.SANDBOX;
11
+ this.container = container;
12
+ this.eventEmitter = eventEmitter;
13
+ }
14
+ load(token, options) {
15
+ const parsedToken = AccessToken.validateJWT(token);
16
+ if (!parsedToken)
17
+ throw new Error("Invalid charge token");
18
+ const tokenData = AccessToken.extractData(parsedToken.body);
19
+ const api = new ApiInternal(token, API_AUTH_TYPE.TOKEN);
20
+ api.setEnv(this.env, this.alias);
21
+ switch (tokenData.service_type) {
22
+ case STANDALONE_3DS_GATEWAYS.GPAYMENTS:
23
+ new GPaymentsService(this.container, api, this.eventEmitter).load(tokenData, options.title);
24
+ break;
25
+ }
26
+ }
27
+ setEnv(env, alias) {
28
+ this.env = env;
29
+ this.alias = alias;
30
+ }
31
+ }
32
+ //# sourceMappingURL=../../../src/lib/canvas-3ds/services/standalone3ds-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standalone3ds-service.js","sourceRoot":"","sources":["../../../canvas-3ds/services/standalone3ds-service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAG3C,MAAM,uBAAuB,GAAG;IAC5B,SAAS,EAAE,WAAW;CACzB,CAAC;AAWF,MAAM,OAAO,oBAAoB;IAM7B,YAAY,SAAoB,EAAE,YAAY;QAHpC,QAAG,GAAG,GAAG,CAAC,OAAO,CAAC;QAIxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;IAEM,IAAI,CAAC,KAAa,EAAE,OAA0B;QACjD,MAAM,WAAW,GAAG,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACnD,IAAI,CAAC,WAAW;YAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;QAC1D,MAAM,SAAS,GAAG,WAAW,CAAC,WAAW,CAAsB,WAAW,CAAC,IAAI,CAAC,CAAC;QACjF,MAAM,GAAG,GAAG,IAAI,WAAW,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QACxD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QACjC,QAAQ,SAAS,CAAC,YAAY,EAAE;YAC5B,KAAK,uBAAuB,CAAC,SAAS;gBAClC,IAAI,gBAAgB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAC,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;gBAC3F,MAAM;SACb;IACL,CAAC;IAEM,MAAM,CAAC,GAAW,EAAE,KAAc;QACrC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ"}
@@ -12,5 +12,6 @@ export interface IAccessToken {
12
12
  }
13
13
  export declare class AccessToken {
14
14
  static validateJWT(jwt: string): IAccessToken;
15
+ static extractData<T>(body: IAccessToken['body']): T;
15
16
  static extractMeta<T>(body: IAccessToken['body']): T;
16
17
  }
@@ -14,6 +14,14 @@ export class AccessToken {
14
14
  return null;
15
15
  }
16
16
  }
17
+ static extractData(body) {
18
+ try {
19
+ return JSON.parse(atob(body.meta));
20
+ }
21
+ catch (_a) {
22
+ return null;
23
+ }
24
+ }
17
25
  static extractMeta(body) {
18
26
  try {
19
27
  const { meta } = JSON.parse(atob(body.meta));
@@ -1 +1 @@
1
- {"version":3,"file":"access-token.js","sourceRoot":"","sources":["../../helper/access-token.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,WAAW;IACb,MAAM,CAAC,WAAW,CAAC,GAAW;QACjC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS;YAAE,OAAO,IAAI,CAAC;QACpD,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM;YACrE,OAAO,IAAI,CAAC;QAEhB,IAAI;YACA,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YACvC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YACvC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;SACpC;QAAC,WAAM;YACJ,OAAO,IAAI,CAAC;SACf;IACL,CAAC;IAEM,MAAM,CAAC,WAAW,CAAI,IAA0B;QACnD,IAAI;YACA,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7C,OAAO,IAAI,CAAC;SACf;QAAC,WAAM;YACJ,OAAO,IAAI,CAAC;SACf;IACL,CAAC;CACJ"}
1
+ {"version":3,"file":"access-token.js","sourceRoot":"","sources":["../../helper/access-token.ts"],"names":[],"mappings":"AAaA,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.72-beta",
5
5
  "homepage": "https://paydock.com",
6
6
  "author": {},
7
7
  "bugs": {
package/slate.md CHANGED
@@ -829,6 +829,57 @@ This example shows how you can use a lot of other methods to settings your form
829
829
  </html>
830
830
  ```
831
831
 
832
+ ## Canvas 3ds for Standalone 3ds charges
833
+
834
+ After you initialized the 3ds charge via `v1/charges/standalone-3ds` API endpoint, you get a token used to initialized the Canvas3ds. All above information regarding setup, loading and initialization still apply.
835
+
836
+ ### Full example
837
+
838
+ ```html
839
+ <!DOCTYPE html>
840
+ <html lang="en">
841
+ <head>
842
+ <meta charset="UTF-8" />
843
+ <title>Title</title>
844
+ <style>
845
+ iframe {
846
+ border: 0;
847
+ width: 40%;
848
+ height: 450px;
849
+ }
850
+ </style>
851
+ </head>
852
+ <body>
853
+ <div id="widget3ds"></div>
854
+ <script src="https://app-sandbox.paydock.com/v1/widget.umd.js"></script>
855
+ <script>
856
+ var canvas3ds = new paydock.Canvas3ds("#widget3ds", "token");
857
+ canvas3ds.on("chargeAuthSuccess", function (data) {
858
+ console.log(data);
859
+ });
860
+ canvas3ds.on("chargeAuthReject", function (data) {
861
+ console.log(data);
862
+ });
863
+ canvas3ds.on("chargeAuthChallenge", function (data) {
864
+ console.log(data);
865
+ });
866
+ canvas3ds.on("chargeAuthDecoupled", function (data) {
867
+ console.log(data.result.description);
868
+ });
869
+ canvas3ds.on("error", function ({ charge_3ds_id, error }) {
870
+ console.log(error);
871
+ });
872
+ canvas3ds.load();
873
+ </script>
874
+ </body>
875
+ </html>
876
+ ```
877
+
878
+ **The chargeAuthSuccess event is executed both for frictionless flow, or for challenge flow after the customer has correctly authenticated with the bank using whatever challenge imposed.**
879
+ **The chargeAuthChallenge event is sent before starting a challenge flow (i.e. opening an IFrame for the customer to complete a challenge with ther bank)**
880
+ **The chargeAuthDecoupled event is sent when the flow is a decoupled challenge, alongside a `data.result.description` field that you must show to the customer, indicating the method the user must use to authenticate. For example this may happen by having the cardholder authenticating directly with their banking app through biometrics. Once the end customer does this, the Canvas3ds will be able to recognize the challenge result is ready and will either produce a chargeAuthSuccess or chargeAuthReject event**
881
+ **The error event is sent if an unexpected issue with the client library occurs. In such scenarios, you should consider the autentication process as interrupted**
882
+
832
883
  ## Vault Display Widget
833
884
  You can find description of all methods and parameters [here](https://www.npmjs.com/package/@paydock/client-sdk#vault-display-widget)
834
885