@starfish-codes/hellgate 3.9.1 → 3.11.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/dist/__tests__/card-handler.spec.d.ts +1 -0
- package/dist/card/card-handler.d.ts +6 -2
- package/dist/card/coordinator/__tests__/card-handler-coordinator.spec.d.ts +1 -0
- package/dist/card/coordinator/typings.d.ts +9 -0
- package/dist/card/typings.d.ts +29 -0
- package/dist/card/ui/iframe/elements/base-element.d.ts +1 -0
- package/dist/card/ui/iframe/elements/card-expiration-month.d.ts +1 -0
- package/dist/card/ui/utils.d.ts +3 -1
- package/dist/hellgate-sdk.mjs +205 -162
- package/dist/hellgate-sdk.umd.js +1 -1
- package/package.json +7 -7
- package/dist/card/tokenization/basis_theory/constants.d.ts +0 -2
- package/dist/card/tokenization/basis_theory/index.d.ts +0 -2
- package/dist/card/tokenization/basis_theory/typings.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { CompleteActionResult, HellgateSession } from '../session';
|
|
2
2
|
import { Coordinator } from '../coordinator';
|
|
3
|
-
import { CreateCardFieldsOptions, CreateCardFormOptions, PaymentAdditionalData, RefreshSecurityCodeSessionStateDTO, TokenizeCardSessionStateDTO, TokenizedData } from './typings';
|
|
3
|
+
import { CreateCardFieldsOptions, CreateCardFormOptions, PaymentAdditionalData, RefreshSecurityCodeSessionStateDTO, TokenLifecycleMode, TokenizeCardSessionStateDTO, TokenizedData } from './typings';
|
|
4
4
|
import { CardElement, CardExpirationDateElement, CardNumberElement, CardVerificationCodeElement, TextElement } from './ui/elements';
|
|
5
5
|
import { CardElementBase } from './ui/elements/base-element';
|
|
6
6
|
import { CardExpirationMonthElement } from './ui/elements/card-expiration-month';
|
|
7
7
|
import { CardExpirationYearElement } from './ui/elements/card-expiration-year';
|
|
8
|
-
import { ChangeEvent, ElementBaseOptions } from './ui/typings';
|
|
8
|
+
import { CardSchema, ChangeEvent, ElementBaseOptions } from './ui/typings';
|
|
9
9
|
export type FormFieldState = Omit<ChangeEvent['data'], 'type'>;
|
|
10
10
|
export type CardHandlerSessionInitState = TokenizeCardSessionStateDTO | RefreshSecurityCodeSessionStateDTO;
|
|
11
11
|
type FormField<T extends CardElementBase<any, any>> = {
|
|
@@ -56,6 +56,10 @@ export declare class HellgateCardHandler {
|
|
|
56
56
|
updateFormState(): void;
|
|
57
57
|
private createFieldDefaultState;
|
|
58
58
|
private serializeAdditionalData;
|
|
59
|
+
private resolveLifecycleFields;
|
|
60
|
+
getLifecycle(): TokenLifecycleMode;
|
|
61
|
+
private getSessionSchemes;
|
|
59
62
|
private getCardDataValidationError;
|
|
60
63
|
}
|
|
64
|
+
export declare function resolveSchemes(sessionSchemes: CardSchema[] | undefined, userSchemes: CardSchema[] | undefined): CardSchema[] | undefined;
|
|
61
65
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CompleteActionResult } from '../../session';
|
|
2
2
|
import { FormFieldState } from '../card-handler';
|
|
3
3
|
import { PaymentAdditionalDataDTO, TokenizedData } from '../typings';
|
|
4
|
+
import { ElementBaseOptions } from '../ui/typings';
|
|
4
5
|
export type CardHandlerToCoordinatorMessage = {
|
|
5
6
|
type: 'card:tokenize';
|
|
6
7
|
additionalData?: PaymentAdditionalDataDTO;
|
|
@@ -34,3 +35,11 @@ export type ElementToCoordinatorMessage = {
|
|
|
34
35
|
state: FormFieldState;
|
|
35
36
|
};
|
|
36
37
|
};
|
|
38
|
+
export type CoordinatorToElementMessage = {
|
|
39
|
+
type: 'coordinator:element:update';
|
|
40
|
+
data: {
|
|
41
|
+
element: string;
|
|
42
|
+
key: string;
|
|
43
|
+
options: ElementBaseOptions;
|
|
44
|
+
};
|
|
45
|
+
};
|
package/dist/card/typings.d.ts
CHANGED
|
@@ -34,6 +34,20 @@ export type PaymentAdditionalData<FieldValue = AdditionalDataValue> = {
|
|
|
34
34
|
city?: FieldValue;
|
|
35
35
|
country?: FieldValue;
|
|
36
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Token lifecycle intent. When `true`, the resulting PCI token is
|
|
39
|
+
* ephemeral and cleaned up after a short TTL. When `false`, the token is
|
|
40
|
+
* persistent; use `false` only on cardholder consent. When omitted the SDK
|
|
41
|
+
* sends no lifecycle intent and the server decides.
|
|
42
|
+
*/
|
|
43
|
+
ephemeral?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Optional ISO-8601 timestamp setting an explicit expiration for the
|
|
46
|
+
* resulting PCI token. When present it takes precedence over `ephemeral`
|
|
47
|
+
* (subject to a server-side cap). Use this for a "Save my card" UX where
|
|
48
|
+
* the merchant chooses the exact retention window after cardholder consent.
|
|
49
|
+
*/
|
|
50
|
+
expiration_date?: string;
|
|
37
51
|
};
|
|
38
52
|
export type PaymentAdditionalDataDTO = PaymentAdditionalData<AdditionalDataValueDTO>;
|
|
39
53
|
export type ElementsCardData = {
|
|
@@ -52,11 +66,15 @@ export type TokenizeCardActionDTO = {
|
|
|
52
66
|
action: 'tokenize_card';
|
|
53
67
|
result: TokenizedData;
|
|
54
68
|
};
|
|
69
|
+
export type HellgateCardScheme = 'visa' | 'mastercard' | 'americanexpress' | 'discover' | 'dinersclub' | 'jcb' | 'unionpay';
|
|
70
|
+
export type TokenLifecycleMode = 'user_choice' | 'ephemeral_only' | 'persistent_only';
|
|
55
71
|
export type TokenizeCardConfig = {
|
|
56
72
|
provider: 'guardian';
|
|
57
73
|
api_key: string;
|
|
58
74
|
base_url: string;
|
|
59
75
|
jwk: JWK;
|
|
76
|
+
allowed_schemes?: HellgateCardScheme[];
|
|
77
|
+
lifecycle?: TokenLifecycleMode;
|
|
60
78
|
};
|
|
61
79
|
export type TokenizeCardSessionStateDTO = {
|
|
62
80
|
next_action: 'tokenize_card';
|
|
@@ -69,6 +87,17 @@ export type CardTokenizeData = {
|
|
|
69
87
|
security_code: string;
|
|
70
88
|
cardholder_name?: string;
|
|
71
89
|
additional_data: PaymentAdditionalData<string>;
|
|
90
|
+
/**
|
|
91
|
+
* Optional token lifecycle intent decrypted by Guardian inside the JWE.
|
|
92
|
+
* `true` requests an ephemeral PCI token, `false` a persistent one. Absent
|
|
93
|
+
* preserves Guardian's pre-existing default behavior.
|
|
94
|
+
*/
|
|
95
|
+
ephemeral?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Optional ISO-8601 expiration timestamp decrypted by Guardian inside the
|
|
98
|
+
* JWE. Wins over `ephemeral` server side.
|
|
99
|
+
*/
|
|
100
|
+
expiration_date?: string;
|
|
72
101
|
};
|
|
73
102
|
export type TokenizedCardMaskedData = {
|
|
74
103
|
account_number_last_four: string;
|
|
@@ -21,6 +21,7 @@ export declare abstract class IframeCardElementBase implements BaseElement<Eleme
|
|
|
21
21
|
private channel;
|
|
22
22
|
constructor(rootNode: Element, postMessageOptions: PostMessageOptions);
|
|
23
23
|
mount(): Promise<void>;
|
|
24
|
+
protected onMount(): void;
|
|
24
25
|
unmount(): void;
|
|
25
26
|
focus(): void;
|
|
26
27
|
blur(): void;
|
package/dist/card/ui/utils.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import { TokenizedCardMaskedData } from '../typings';
|
|
1
|
+
import { HellgateCardScheme, TokenizedCardMaskedData } from '../typings';
|
|
2
|
+
import { CardSchema } from './typings';
|
|
3
|
+
export declare function mapHellgateSchemesToCardSchema(schemes: HellgateCardScheme[]): CardSchema[];
|
|
2
4
|
export declare function getMaskedCardNumber(data: TokenizedCardMaskedData): string;
|
package/dist/hellgate-sdk.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
function
|
|
1
|
+
function C(i) {
|
|
2
2
|
return Array.isArray(i) ? i.filter(Boolean) : Object.fromEntries(Object.entries(i).map(([e, t]) => [
|
|
3
3
|
e,
|
|
4
|
-
typeof t == "object" && t && !Array.isArray(t) ?
|
|
4
|
+
typeof t == "object" && t && !Array.isArray(t) ? C(t) : t
|
|
5
5
|
]).filter(([e, t]) => typeof t == "object" && t && !Array.isArray(t) ? !!Object.keys(t).length : t != null && t != null));
|
|
6
6
|
}
|
|
7
7
|
function h(i, e) {
|
|
8
8
|
const t = { ...i, ...e }, r = Object.keys(t);
|
|
9
|
-
for (const
|
|
10
|
-
const
|
|
11
|
-
typeof
|
|
9
|
+
for (const a of r) {
|
|
10
|
+
const n = i[a], s = e[a];
|
|
11
|
+
typeof n == "object" && !Array.isArray(n) && n && typeof s == "object" && !Array.isArray(s) && s && (t[a] = h(n, s));
|
|
12
12
|
}
|
|
13
13
|
return t;
|
|
14
14
|
}
|
|
@@ -17,11 +17,11 @@ function E(i) {
|
|
|
17
17
|
throw i;
|
|
18
18
|
return i.json();
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function S(i) {
|
|
21
21
|
return `https://${window.HG_IFRAME_HOST ?? "sdk.hellgate.io"}/web/${i}/iframe/`;
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
class
|
|
23
|
+
const F = 2e3;
|
|
24
|
+
class k {
|
|
25
25
|
constructor(e, t) {
|
|
26
26
|
Object.defineProperty(this, "session", {
|
|
27
27
|
enumerable: !0,
|
|
@@ -104,14 +104,14 @@ class F {
|
|
|
104
104
|
configurable: !0,
|
|
105
105
|
writable: !0,
|
|
106
106
|
value: (r) => {
|
|
107
|
-
var
|
|
107
|
+
var a, n;
|
|
108
108
|
switch (r.next_action) {
|
|
109
109
|
case "3ds_check": {
|
|
110
110
|
this.initCheck3DSIframes(r.data.threeds_server_callback_url, r.data.mon_url);
|
|
111
111
|
break;
|
|
112
112
|
}
|
|
113
113
|
case "3ds_challenge": {
|
|
114
|
-
(
|
|
114
|
+
(a = this.onStartHandler) == null || a.call(this), this.disposeCheck3DSIframe(), this.startChallenge(r.data.challenge_url, r.data.result_mon_url);
|
|
115
115
|
break;
|
|
116
116
|
}
|
|
117
117
|
case "3ds_challenge_decoupled": {
|
|
@@ -119,7 +119,7 @@ class F {
|
|
|
119
119
|
break;
|
|
120
120
|
}
|
|
121
121
|
case null: {
|
|
122
|
-
this.dispose(), (
|
|
122
|
+
this.dispose(), (n = this.onFinishHandler) == null || n.call(this);
|
|
123
123
|
break;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -132,34 +132,34 @@ class F {
|
|
|
132
132
|
initCheck3DSIframes(e, t) {
|
|
133
133
|
const r = p();
|
|
134
134
|
r.insertAdjacentHTML("beforeend", `<iframe id="check_3ds_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${e}"></iframe>`);
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
const
|
|
138
|
-
s.source ===
|
|
135
|
+
const a = r.querySelector(`#check_3ds_${this.iframeId}`);
|
|
136
|
+
if (a) {
|
|
137
|
+
const n = (s) => {
|
|
138
|
+
s.source === a.contentWindow && this.session.completeAction({ action: "3ds_check", result: s.data });
|
|
139
139
|
};
|
|
140
|
-
window.addEventListener("message",
|
|
140
|
+
window.addEventListener("message", n), this.check3dsIframeDisposers.push(() => window.removeEventListener("message", n), () => a.remove());
|
|
141
141
|
}
|
|
142
142
|
if (t) {
|
|
143
143
|
r.insertAdjacentHTML("beforeend", `<iframe id="mon_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${t}"></iframe>`);
|
|
144
|
-
const
|
|
145
|
-
|
|
144
|
+
const n = r.querySelector(`#mon_${this.iframeId}`);
|
|
145
|
+
n && this.disposers.push(() => n.remove());
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
disposeCheck3DSIframe() {
|
|
149
149
|
this.check3dsIframeDisposers.forEach((e) => e()), this.check3dsIframeDisposers = [];
|
|
150
150
|
}
|
|
151
151
|
startChallenge(e, t) {
|
|
152
|
-
const r = p(),
|
|
153
|
-
this.domContainer.insertAdjacentHTML("beforeend", this.domContainer === r ? `<div id="cha_${this.iframeId}_wrap" style="background: #fff; position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 10000;">${
|
|
154
|
-
const
|
|
155
|
-
if (!
|
|
152
|
+
const r = p(), a = `<div style="display: flex; flex-direction: column; gap: 10px; align-items: center; ${this.domContainer === r ? 'border:0; max-width: 800px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width:100% " ' : 'border:0;" width="100%" height="100%"'}><iframe id="cha_${this.iframeId}" src="${e}" width="100%" height="500"></iframe>${this.labelText ? '<span id="tds_label_text" style="font-size: large;">' + this.labelText + "</span>" : ""}<div>`;
|
|
153
|
+
this.domContainer.insertAdjacentHTML("beforeend", this.domContainer === r ? `<div id="cha_${this.iframeId}_wrap" style="background: #fff; position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 10000;">${a}</div>` : a);
|
|
154
|
+
const n = this.domContainer.querySelector(`#cha_${this.iframeId}`), s = this.domContainer.querySelector(`#cha_${this.iframeId}_wrap`);
|
|
155
|
+
if (!n)
|
|
156
156
|
throw new Error("3DS Challenge Iframe initialization failed");
|
|
157
157
|
this.disposers.push(() => {
|
|
158
|
-
|
|
158
|
+
n.remove(), s == null || s.remove();
|
|
159
159
|
});
|
|
160
160
|
const o = new Promise((c) => {
|
|
161
161
|
const d = (u) => {
|
|
162
|
-
u.source !==
|
|
162
|
+
u.source !== n.contentWindow || u.data.event !== "AuthResultReady" || c({
|
|
163
163
|
...u.data,
|
|
164
164
|
requestor_trans_id: u.data.requestor_trans_id ?? u.data.requestorTransId,
|
|
165
165
|
// TODO: remove this field after the backend is updated
|
|
@@ -184,19 +184,19 @@ class F {
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
startDecoupledAuth(e, t, r) {
|
|
187
|
-
this.transactionId || (this.transactionId = r), this.decoupledAuthHandlers.forEach((
|
|
188
|
-
const
|
|
189
|
-
|
|
187
|
+
this.transactionId || (this.transactionId = r), this.decoupledAuthHandlers.forEach((n) => n(e));
|
|
188
|
+
const a = this.startAuthResultPolling(t, (n) => {
|
|
189
|
+
n.event === "AuthResultReady" && (this.session.completeAction({
|
|
190
190
|
action: "3ds_challenge_decoupled",
|
|
191
|
-
result: { ...
|
|
192
|
-
}),
|
|
191
|
+
result: { ...n, event: n.event }
|
|
192
|
+
}), a());
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
195
|
startAuthResultPolling(e, t) {
|
|
196
196
|
return window.clearTimeout(this.resultPollingTimer), this.resultPollingTimer = window.setTimeout(() => fetch(e).then((r) => E(r)).then((r) => {
|
|
197
197
|
this.startAuthResultPolling(e, t), t(r);
|
|
198
198
|
}).catch(() => {
|
|
199
|
-
}),
|
|
199
|
+
}), F), () => window.clearTimeout(this.resultPollingTimer);
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
function p() {
|
|
@@ -208,12 +208,12 @@ const y = {
|
|
|
208
208
|
backgroundColor: "transparent"
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
},
|
|
211
|
+
}, R = "DOM Element was not found";
|
|
212
212
|
var O;
|
|
213
213
|
(function(i) {
|
|
214
214
|
i.NOT_COMPLETE = "NOT_COMPLETE", i.SCHEME_NOT_SUPPORTED = "SCHEME_NOT_SUPPORTED", i.LUHN_CHECK_FAILED = "LUHN_CHECK_FAILED", i.INVALID_EXPIRY_DATE = "INVALID_EXPIRY_DATE";
|
|
215
215
|
})(O || (O = {}));
|
|
216
|
-
const
|
|
216
|
+
const j = (i) => i != null, $ = "v3.11.0";
|
|
217
217
|
class f {
|
|
218
218
|
constructor(e) {
|
|
219
219
|
if (Object.defineProperty(this, "options", {
|
|
@@ -246,7 +246,7 @@ class f {
|
|
|
246
246
|
configurable: !0,
|
|
247
247
|
writable: !0,
|
|
248
248
|
value: async ({ ...t }) => {
|
|
249
|
-
this.iframe &&
|
|
249
|
+
this.iframe && j(t.height) && (this.iframe.height = t.height), this.iframePostMessage({
|
|
250
250
|
type: "update",
|
|
251
251
|
data: {
|
|
252
252
|
...t,
|
|
@@ -283,21 +283,21 @@ class f {
|
|
|
283
283
|
var t;
|
|
284
284
|
(t = this.iframe) == null || t.remove(), this.iframe = null;
|
|
285
285
|
}
|
|
286
|
-
}), this.IFRAME_BASE_URL =
|
|
286
|
+
}), this.IFRAME_BASE_URL = S($), !this.IFRAME_BASE_URL)
|
|
287
287
|
throw new Error("IFRAME_BASE_URL not found");
|
|
288
288
|
}
|
|
289
289
|
mount(e) {
|
|
290
290
|
const t = typeof e == "string" ? document.querySelector(e) : e;
|
|
291
291
|
if (!t)
|
|
292
|
-
throw new Error(`${
|
|
292
|
+
throw new Error(`${R}: ${e}`);
|
|
293
293
|
t.innerHTML = `<iframe width="100%" height="29" src="${this.IFRAME_BASE_URL}?field=${this.type}&origin=${location.origin}"></iframe>`, this.iframe = t.querySelector("iframe");
|
|
294
|
-
const r = (
|
|
295
|
-
var
|
|
296
|
-
|
|
294
|
+
const r = (a) => {
|
|
295
|
+
var n;
|
|
296
|
+
a.source !== ((n = this.iframe) == null ? void 0 : n.contentWindow) || a.data.element !== this.type || this.emitEvent(a.data);
|
|
297
297
|
};
|
|
298
|
-
return window.addEventListener("message", r), new Promise((
|
|
299
|
-
this.on("ready", (
|
|
300
|
-
this.key =
|
|
298
|
+
return window.addEventListener("message", r), new Promise((a) => {
|
|
299
|
+
this.on("ready", (n) => {
|
|
300
|
+
this.key = n.key, this.update(this.options), a();
|
|
301
301
|
});
|
|
302
302
|
});
|
|
303
303
|
}
|
|
@@ -315,7 +315,7 @@ class f {
|
|
|
315
315
|
(r = (t = this.iframe) == null ? void 0 : t.contentWindow) == null || r.postMessage(e, this.IFRAME_BASE_URL);
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
class
|
|
318
|
+
class U extends f {
|
|
319
319
|
constructor() {
|
|
320
320
|
super(...arguments), Object.defineProperty(this, "type", {
|
|
321
321
|
enumerable: !0,
|
|
@@ -326,22 +326,22 @@ class $ extends f {
|
|
|
326
326
|
enumerable: !0,
|
|
327
327
|
configurable: !0,
|
|
328
328
|
writable: !0,
|
|
329
|
-
value:
|
|
329
|
+
value: A
|
|
330
330
|
}), Object.defineProperty(this, "putValue", {
|
|
331
331
|
enumerable: !0,
|
|
332
332
|
configurable: !0,
|
|
333
333
|
writable: !0,
|
|
334
|
-
value:
|
|
334
|
+
value: H
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
|
-
function
|
|
338
|
+
function A(i) {
|
|
339
339
|
return i ? Number(i) : null;
|
|
340
340
|
}
|
|
341
|
-
function
|
|
341
|
+
function H(i) {
|
|
342
342
|
return i ? i < 10 ? `0${i}` : String(i) : null;
|
|
343
343
|
}
|
|
344
|
-
class
|
|
344
|
+
class V extends f {
|
|
345
345
|
constructor() {
|
|
346
346
|
super(...arguments), Object.defineProperty(this, "type", {
|
|
347
347
|
enumerable: !0,
|
|
@@ -352,38 +352,38 @@ class U extends f {
|
|
|
352
352
|
enumerable: !0,
|
|
353
353
|
configurable: !0,
|
|
354
354
|
writable: !0,
|
|
355
|
-
value:
|
|
355
|
+
value: D
|
|
356
356
|
}), Object.defineProperty(this, "putValue", {
|
|
357
357
|
enumerable: !0,
|
|
358
358
|
configurable: !0,
|
|
359
359
|
writable: !0,
|
|
360
|
-
value:
|
|
360
|
+
value: T
|
|
361
361
|
});
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function D(i) {
|
|
365
365
|
if (!i)
|
|
366
366
|
return null;
|
|
367
367
|
const e = Number(i);
|
|
368
368
|
return e > 10 ? +`20${e}` : null;
|
|
369
369
|
}
|
|
370
|
-
function
|
|
370
|
+
function T(i) {
|
|
371
371
|
return i ? i >= 100 ? String(i).slice(-2) : String(i) : null;
|
|
372
372
|
}
|
|
373
|
-
function
|
|
373
|
+
function M(i) {
|
|
374
374
|
const [e = null, t = null] = (i ?? "").split("/").map((r) => r.trim());
|
|
375
375
|
return {
|
|
376
|
-
month:
|
|
377
|
-
year:
|
|
376
|
+
month: A(e),
|
|
377
|
+
year: D(t)
|
|
378
378
|
};
|
|
379
379
|
}
|
|
380
|
-
function
|
|
380
|
+
function I(i) {
|
|
381
381
|
if (!i)
|
|
382
382
|
return null;
|
|
383
383
|
const { month: e, year: t } = i;
|
|
384
|
-
return [
|
|
384
|
+
return [H(e), T(t)].filter(j).join(" / ");
|
|
385
385
|
}
|
|
386
|
-
class
|
|
386
|
+
class z extends f {
|
|
387
387
|
constructor() {
|
|
388
388
|
super(...arguments), Object.defineProperty(this, "type", {
|
|
389
389
|
enumerable: !0,
|
|
@@ -394,22 +394,22 @@ class V extends f {
|
|
|
394
394
|
enumerable: !0,
|
|
395
395
|
configurable: !0,
|
|
396
396
|
writable: !0,
|
|
397
|
-
value:
|
|
397
|
+
value: M
|
|
398
398
|
}), Object.defineProperty(this, "putValue", {
|
|
399
399
|
enumerable: !0,
|
|
400
400
|
configurable: !0,
|
|
401
401
|
writable: !0,
|
|
402
|
-
value:
|
|
402
|
+
value: I
|
|
403
403
|
});
|
|
404
404
|
}
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function L(i) {
|
|
407
407
|
return (i == null ? void 0 : i.replaceAll(" ", "")) ?? null;
|
|
408
408
|
}
|
|
409
|
-
function
|
|
409
|
+
function B(i) {
|
|
410
410
|
return i;
|
|
411
411
|
}
|
|
412
|
-
class
|
|
412
|
+
class Y extends f {
|
|
413
413
|
constructor() {
|
|
414
414
|
super(...arguments), Object.defineProperty(this, "type", {
|
|
415
415
|
enumerable: !0,
|
|
@@ -420,16 +420,16 @@ class B extends f {
|
|
|
420
420
|
enumerable: !0,
|
|
421
421
|
configurable: !0,
|
|
422
422
|
writable: !0,
|
|
423
|
-
value:
|
|
423
|
+
value: L
|
|
424
424
|
}), Object.defineProperty(this, "putValue", {
|
|
425
425
|
enumerable: !0,
|
|
426
426
|
configurable: !0,
|
|
427
427
|
writable: !0,
|
|
428
|
-
value:
|
|
428
|
+
value: B
|
|
429
429
|
});
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
|
-
class
|
|
432
|
+
class q extends f {
|
|
433
433
|
constructor() {
|
|
434
434
|
super(...arguments), Object.defineProperty(this, "type", {
|
|
435
435
|
enumerable: !0,
|
|
@@ -441,8 +441,8 @@ class Y extends f {
|
|
|
441
441
|
configurable: !0,
|
|
442
442
|
writable: !0,
|
|
443
443
|
value: (e) => e ? {
|
|
444
|
-
number: e.cardNumber ?
|
|
445
|
-
expiry_date: e.cardExpirationDate ?
|
|
444
|
+
number: e.cardNumber ? L(e.cardNumber) : null,
|
|
445
|
+
expiry_date: e.cardExpirationDate ? M(e.cardExpirationDate) : null,
|
|
446
446
|
cvc: e.cardVerificationCode ?? null
|
|
447
447
|
} : null
|
|
448
448
|
}), Object.defineProperty(this, "putValue", {
|
|
@@ -451,13 +451,13 @@ class Y extends f {
|
|
|
451
451
|
writable: !0,
|
|
452
452
|
value: (e) => e ? {
|
|
453
453
|
cardNumber: e.number ? e.number : null,
|
|
454
|
-
cardExpirationDate: e.expiry_date ?
|
|
454
|
+
cardExpirationDate: e.expiry_date ? I(e.expiry_date) : null,
|
|
455
455
|
cardVerificationCode: e.cvc ?? null
|
|
456
456
|
} : null
|
|
457
457
|
});
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
|
-
class
|
|
460
|
+
class G extends f {
|
|
461
461
|
constructor() {
|
|
462
462
|
super(...arguments), Object.defineProperty(this, "type", {
|
|
463
463
|
enumerable: !0,
|
|
@@ -500,23 +500,35 @@ class K extends f {
|
|
|
500
500
|
function b(i, e) {
|
|
501
501
|
switch (i) {
|
|
502
502
|
case "card":
|
|
503
|
-
return new
|
|
503
|
+
return new q(e);
|
|
504
504
|
case "cardNumber":
|
|
505
|
-
return new
|
|
505
|
+
return new Y(e);
|
|
506
506
|
case "cardExpirationDate":
|
|
507
|
-
return new
|
|
507
|
+
return new z(e);
|
|
508
508
|
case "cardExpirationMonth":
|
|
509
|
-
return new $(e);
|
|
510
|
-
case "cardExpirationYear":
|
|
511
509
|
return new U(e);
|
|
510
|
+
case "cardExpirationYear":
|
|
511
|
+
return new V(e);
|
|
512
512
|
case "cardVerificationCode":
|
|
513
|
-
return new
|
|
513
|
+
return new G(e);
|
|
514
514
|
case "text":
|
|
515
515
|
return new K(e);
|
|
516
516
|
default:
|
|
517
517
|
ASSERT_EXHAUSTIVE(i);
|
|
518
518
|
}
|
|
519
519
|
}
|
|
520
|
+
const W = {
|
|
521
|
+
visa: "visa",
|
|
522
|
+
mastercard: "mastercard",
|
|
523
|
+
americanexpress: "american-express",
|
|
524
|
+
discover: "discover",
|
|
525
|
+
dinersclub: "diners-club",
|
|
526
|
+
jcb: "jcb",
|
|
527
|
+
unionpay: "unionpay"
|
|
528
|
+
};
|
|
529
|
+
function X(i) {
|
|
530
|
+
return i.map((e) => W[e]).filter(Boolean);
|
|
531
|
+
}
|
|
520
532
|
function P(i) {
|
|
521
533
|
return [
|
|
522
534
|
i.issuer_identification_number,
|
|
@@ -572,14 +584,14 @@ class w {
|
|
|
572
584
|
var s;
|
|
573
585
|
if (this.hasFormElements())
|
|
574
586
|
throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");
|
|
575
|
-
const
|
|
587
|
+
const a = h({
|
|
576
588
|
disabled: !1,
|
|
577
589
|
autocomplete: "on",
|
|
578
590
|
style: { ...y }
|
|
579
591
|
}, r);
|
|
580
592
|
if (this.session.isNextAction("refresh_security_code") && ((s = this.session.state) != null && s.data)) {
|
|
581
593
|
const o = this.session.state.data;
|
|
582
|
-
|
|
594
|
+
a.cvcOnly = !0, a.value = {
|
|
583
595
|
number: P(o),
|
|
584
596
|
expiry_date: {
|
|
585
597
|
month: (o == null ? void 0 : o.expiry_month) ?? null,
|
|
@@ -588,37 +600,38 @@ class w {
|
|
|
588
600
|
cvc: null
|
|
589
601
|
};
|
|
590
602
|
}
|
|
591
|
-
|
|
603
|
+
a.schemes = x(this.getSessionSchemes(), a.schemes);
|
|
604
|
+
const n = b("card", a);
|
|
592
605
|
return this.cardElements.card = {
|
|
593
|
-
element:
|
|
606
|
+
element: n,
|
|
594
607
|
state: this.createFieldDefaultState()
|
|
595
|
-
}, this.addElementStateListener("card"),
|
|
608
|
+
}, this.addElementStateListener("card"), n;
|
|
596
609
|
}
|
|
597
610
|
}), Object.defineProperty(this, "createTextField", {
|
|
598
611
|
enumerable: !0,
|
|
599
612
|
configurable: !0,
|
|
600
613
|
writable: !0,
|
|
601
614
|
value: (r = {}) => {
|
|
602
|
-
const
|
|
615
|
+
const a = {
|
|
603
616
|
disabled: !1,
|
|
604
617
|
autocomplete: "on",
|
|
605
618
|
style: { ...y }
|
|
606
|
-
},
|
|
607
|
-
...h(
|
|
619
|
+
}, n = b("text", {
|
|
620
|
+
...h(a, { ...r })
|
|
608
621
|
});
|
|
609
|
-
return this.textElements.push(
|
|
622
|
+
return this.textElements.push(n), n;
|
|
610
623
|
}
|
|
611
624
|
}), Object.defineProperty(this, "tokenize", {
|
|
612
625
|
enumerable: !0,
|
|
613
626
|
configurable: !0,
|
|
614
627
|
writable: !0,
|
|
615
628
|
value: async (r) => {
|
|
616
|
-
var
|
|
617
|
-
if (((
|
|
629
|
+
var n, s;
|
|
630
|
+
if (((n = this.session.state) == null ? void 0 : n.next_action) !== "tokenize_card")
|
|
618
631
|
throw new Error(`The session's next_action='${(s = this.session.state) == null ? void 0 : s.next_action}'. tokenize() is available only if next_action='tokenize_card'`);
|
|
619
|
-
const
|
|
620
|
-
if (
|
|
621
|
-
throw
|
|
632
|
+
const a = this.getCardDataValidationError();
|
|
633
|
+
if (a)
|
|
634
|
+
throw a;
|
|
622
635
|
return this.coordinator.postMessage({
|
|
623
636
|
type: "card:tokenize",
|
|
624
637
|
additionalData: this.serializeAdditionalData(r)
|
|
@@ -663,9 +676,9 @@ class w {
|
|
|
663
676
|
value: async (r = {}) => {
|
|
664
677
|
if (!this.hasFormElements())
|
|
665
678
|
throw new Error("Card form must be initialized and completed before processing");
|
|
666
|
-
const
|
|
667
|
-
if (
|
|
668
|
-
throw
|
|
679
|
+
const a = this.getCardDataValidationError();
|
|
680
|
+
if (a)
|
|
681
|
+
throw a;
|
|
669
682
|
if (this.session.isNextAction("refresh_security_code"))
|
|
670
683
|
return this.refreshSecurityCode();
|
|
671
684
|
this.disableFormElements(!0);
|
|
@@ -673,13 +686,13 @@ class w {
|
|
|
673
686
|
return this.coordinator.postMessage({
|
|
674
687
|
type: "card:process",
|
|
675
688
|
additionalData: this.serializeAdditionalData(r)
|
|
676
|
-
}), new Promise((
|
|
689
|
+
}), new Promise((n, s) => {
|
|
677
690
|
this.coordinator.onMessage("card:process:response", (o) => {
|
|
678
|
-
o.result && o.success ?
|
|
691
|
+
o.result && o.success ? n(o.result) : s(new Error(o.error));
|
|
679
692
|
});
|
|
680
693
|
});
|
|
681
|
-
} catch (
|
|
682
|
-
throw this.disableFormElements(!1),
|
|
694
|
+
} catch (n) {
|
|
695
|
+
throw this.disableFormElements(!1), n;
|
|
683
696
|
}
|
|
684
697
|
}
|
|
685
698
|
}), this.cvcOnlyEnabled = this.session.isNextAction("refresh_security_code");
|
|
@@ -692,11 +705,12 @@ class w {
|
|
|
692
705
|
disabled: this.cvcOnlyEnabled,
|
|
693
706
|
autocomplete: "on",
|
|
694
707
|
style: { ...y }
|
|
695
|
-
}, { cardNumber: r = {}, securityCode:
|
|
708
|
+
}, { cardNumber: r = {}, securityCode: a = {}, ...n } = e, s = b("cardNumber", {
|
|
696
709
|
...h(t, {
|
|
697
|
-
...
|
|
710
|
+
...n,
|
|
698
711
|
...r,
|
|
699
712
|
cvcOnly: this.cvcOnlyEnabled,
|
|
713
|
+
schemes: x(this.getSessionSchemes(), r.schemes ?? n.schemes),
|
|
700
714
|
value: this.session.isNextAction("refresh_security_code") && ((l = this.session.state) != null && l.data) ? P(this.session.state.data) : null
|
|
701
715
|
})
|
|
702
716
|
}), o = b("cardVerificationCode", {
|
|
@@ -705,8 +719,8 @@ class w {
|
|
|
705
719
|
disabled: !1,
|
|
706
720
|
autofocus: this.cvcOnlyEnabled
|
|
707
721
|
}, {
|
|
708
|
-
...
|
|
709
|
-
...
|
|
722
|
+
...n,
|
|
723
|
+
...a
|
|
710
724
|
})
|
|
711
725
|
});
|
|
712
726
|
if (s.on("change", (d) => {
|
|
@@ -724,12 +738,12 @@ class w {
|
|
|
724
738
|
}, this.addElementStateListener("cardNumber"), this.addElementStateListener("cardVerificationCode"), e.expiryDateElement === "separate") {
|
|
725
739
|
const { expiryMonth: d = {}, expiryYear: u = {} } = e, _ = b("cardExpirationMonth", {
|
|
726
740
|
...h(t, {
|
|
727
|
-
...
|
|
741
|
+
...n,
|
|
728
742
|
...d
|
|
729
743
|
})
|
|
730
744
|
}), v = b("cardExpirationYear", {
|
|
731
745
|
...h(t, {
|
|
732
|
-
...
|
|
746
|
+
...n,
|
|
733
747
|
...u
|
|
734
748
|
})
|
|
735
749
|
});
|
|
@@ -743,7 +757,7 @@ class w {
|
|
|
743
757
|
} else {
|
|
744
758
|
const { expiryDate: d = {} } = e, u = b("cardExpirationDate", {
|
|
745
759
|
...h(t, {
|
|
746
|
-
...
|
|
760
|
+
...n,
|
|
747
761
|
...d,
|
|
748
762
|
value: this.session.isNextAction("refresh_security_code") && ((c = this.session.state) != null && c.data) ? {
|
|
749
763
|
month: this.session.state.data.expiry_month,
|
|
@@ -795,8 +809,8 @@ class w {
|
|
|
795
809
|
valid: !1
|
|
796
810
|
};
|
|
797
811
|
}
|
|
798
|
-
serializeAdditionalData({ cardholder_name: e, billing_address: t = {} }) {
|
|
799
|
-
return
|
|
812
|
+
serializeAdditionalData({ cardholder_name: e, billing_address: t = {}, ephemeral: r, expiration_date: a }) {
|
|
813
|
+
return C({
|
|
800
814
|
cardholder_name: m(e),
|
|
801
815
|
billing_address: {
|
|
802
816
|
line1: m(t.line1),
|
|
@@ -804,9 +818,35 @@ class w {
|
|
|
804
818
|
line3: m(t.line3),
|
|
805
819
|
city: m(t.city),
|
|
806
820
|
postal_code: m(t.postal_code)
|
|
807
|
-
}
|
|
821
|
+
},
|
|
822
|
+
...this.resolveLifecycleFields(r, a)
|
|
808
823
|
});
|
|
809
824
|
}
|
|
825
|
+
resolveLifecycleFields(e, t) {
|
|
826
|
+
switch (this.getLifecycle()) {
|
|
827
|
+
case "ephemeral_only":
|
|
828
|
+
return { ephemeral: !0 };
|
|
829
|
+
case "persistent_only":
|
|
830
|
+
return { ephemeral: !1 };
|
|
831
|
+
case "user_choice":
|
|
832
|
+
return {
|
|
833
|
+
ephemeral: typeof e == "boolean" ? e : void 0,
|
|
834
|
+
expiration_date: typeof t == "string" ? t : void 0
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
getLifecycle() {
|
|
839
|
+
var e, t;
|
|
840
|
+
return this.session.isNextAction("tokenize_card") ? ((t = (e = this.session.state) == null ? void 0 : e.data) == null ? void 0 : t.lifecycle) ?? "user_choice" : "user_choice";
|
|
841
|
+
}
|
|
842
|
+
getSessionSchemes() {
|
|
843
|
+
var t, r;
|
|
844
|
+
if (!this.session.isNextAction("tokenize_card"))
|
|
845
|
+
return;
|
|
846
|
+
const e = (t = this.session.state) == null ? void 0 : t.data;
|
|
847
|
+
if ((r = e == null ? void 0 : e.allowed_schemes) != null && r.length)
|
|
848
|
+
return X(e.allowed_schemes);
|
|
849
|
+
}
|
|
810
850
|
getCardDataValidationError() {
|
|
811
851
|
if (!this.state.complete)
|
|
812
852
|
return new Error(this.state.error ?? "Card data is not complete");
|
|
@@ -820,8 +860,11 @@ function m(i) {
|
|
|
820
860
|
if (i != null && i.key)
|
|
821
861
|
return { key: i.key };
|
|
822
862
|
}
|
|
823
|
-
|
|
824
|
-
|
|
863
|
+
function x(i, e) {
|
|
864
|
+
return i === void 0 ? e : i.length === 0 ? [] : e != null && e.length ? e.filter((t) => i.includes(t)) : i;
|
|
865
|
+
}
|
|
866
|
+
const J = "v3.11.0";
|
|
867
|
+
class Q {
|
|
825
868
|
constructor() {
|
|
826
869
|
if (Object.defineProperty(this, "iframe", {
|
|
827
870
|
enumerable: !0,
|
|
@@ -842,35 +885,35 @@ class G {
|
|
|
842
885
|
enumerable: !0,
|
|
843
886
|
configurable: !0,
|
|
844
887
|
writable: !0,
|
|
845
|
-
value: async (e, t, r) => (window.fetchMocker = { a: 1 }, new Promise((
|
|
888
|
+
value: async (e, t, r) => (window.fetchMocker = { a: 1 }, new Promise((a, n) => {
|
|
846
889
|
r == null || r.signal.addEventListener("abort", () => {
|
|
847
890
|
const l = new Error("Coordinator init aborted");
|
|
848
|
-
l.name = "AbortError",
|
|
891
|
+
l.name = "AbortError", n(l), this.dispose();
|
|
849
892
|
});
|
|
850
893
|
const s = document.createElement("div");
|
|
851
894
|
s.setAttribute("style", "position:absolute;width:0;height:0;overflow:hidden;"), s.setAttribute("data-hg-coordinator", ""), document.body.appendChild(s);
|
|
852
895
|
const o = `${this.iframeBaseUrl}?type=coordinator&sessionId=${e}&apiBaseUrl=${t}&origin=${encodeURIComponent(location.origin)}`;
|
|
853
896
|
if (s.innerHTML = `<iframe src="${o}" width="0" height="0" style="border:none;" tabindex="-1" aria-hidden="true"></iframe>`, this.iframe = s.querySelector("iframe"), !this.iframe) {
|
|
854
|
-
|
|
897
|
+
n(new Error("Failed to create coordinator iframe"));
|
|
855
898
|
return;
|
|
856
899
|
}
|
|
857
900
|
this.messageHandler = (l) => {
|
|
858
901
|
var c, d, u;
|
|
859
902
|
if (l.source === ((c = this.iframe) == null ? void 0 : c.contentWindow)) {
|
|
860
903
|
if (((d = l.data) == null ? void 0 : d.type) === "coordinator:ready") {
|
|
861
|
-
|
|
904
|
+
a();
|
|
862
905
|
return;
|
|
863
906
|
}
|
|
864
907
|
if (((u = l.data) == null ? void 0 : u.type) === "coordinator:error") {
|
|
865
|
-
|
|
908
|
+
n(l.data.error);
|
|
866
909
|
return;
|
|
867
910
|
}
|
|
868
911
|
}
|
|
869
912
|
}, window.addEventListener("message", this.messageHandler), this.iframe.addEventListener("error", () => {
|
|
870
|
-
|
|
913
|
+
n(new Error("Coordinator iframe failed to load"));
|
|
871
914
|
});
|
|
872
915
|
}))
|
|
873
|
-
}), this.iframeBaseUrl =
|
|
916
|
+
}), this.iframeBaseUrl = S(J), !this.iframeBaseUrl)
|
|
874
917
|
throw new Error("IFRAME_BASE_URL not found");
|
|
875
918
|
}
|
|
876
919
|
/**
|
|
@@ -883,8 +926,8 @@ class G {
|
|
|
883
926
|
}
|
|
884
927
|
onMessage(e, t) {
|
|
885
928
|
window.addEventListener("message", (r) => {
|
|
886
|
-
var
|
|
887
|
-
r.source === ((
|
|
929
|
+
var a, n;
|
|
930
|
+
r.source === ((a = this.iframe) == null ? void 0 : a.contentWindow) && ((n = r.data) == null ? void 0 : n.type) === e && t(r.data);
|
|
888
931
|
});
|
|
889
932
|
}
|
|
890
933
|
/**
|
|
@@ -897,7 +940,7 @@ class G {
|
|
|
897
940
|
this.iframe = null, e == null || e.remove();
|
|
898
941
|
}
|
|
899
942
|
}
|
|
900
|
-
class
|
|
943
|
+
class Z {
|
|
901
944
|
constructor(e = "https://api.hellgate.io", t = new AbortController()) {
|
|
902
945
|
Object.defineProperty(this, "abortCtrl", {
|
|
903
946
|
enumerable: !0,
|
|
@@ -931,8 +974,8 @@ class X {
|
|
|
931
974
|
this.abortCtrl.abort();
|
|
932
975
|
}
|
|
933
976
|
}
|
|
934
|
-
const
|
|
935
|
-
class
|
|
977
|
+
const ee = 2e3;
|
|
978
|
+
class te {
|
|
936
979
|
constructor(e, t) {
|
|
937
980
|
Object.defineProperty(this, "id", {
|
|
938
981
|
enumerable: !0,
|
|
@@ -968,39 +1011,39 @@ class Q {
|
|
|
968
1011
|
enumerable: !0,
|
|
969
1012
|
configurable: !0,
|
|
970
1013
|
writable: !0,
|
|
971
|
-
value: async () => new Promise((r,
|
|
972
|
-
const
|
|
973
|
-
s.next_action !== "wait" && (r(s),
|
|
1014
|
+
value: async () => new Promise((r, a) => {
|
|
1015
|
+
const n = this.onStateChange((s) => {
|
|
1016
|
+
s.next_action !== "wait" && (r(s), n());
|
|
974
1017
|
});
|
|
975
1018
|
this.updateSessionState().catch((s) => {
|
|
976
|
-
s instanceof Response && s.status === 404 &&
|
|
1019
|
+
s instanceof Response && s.status === 404 && a(new Error(`Session ${this.id} doesn't exist or has expired`)), a(s);
|
|
977
1020
|
});
|
|
978
1021
|
})
|
|
979
1022
|
}), Object.defineProperty(this, "onStateChange", {
|
|
980
1023
|
enumerable: !0,
|
|
981
1024
|
configurable: !0,
|
|
982
1025
|
writable: !0,
|
|
983
|
-
value: (r) => (this.stateChangeHandlers.push(r), this.state && r(this.state), () => this.stateChangeHandlers = this.stateChangeHandlers.filter((
|
|
1026
|
+
value: (r) => (this.stateChangeHandlers.push(r), this.state && r(this.state), () => this.stateChangeHandlers = this.stateChangeHandlers.filter((a) => a !== r))
|
|
984
1027
|
}), Object.defineProperty(this, "onClose", {
|
|
985
1028
|
enumerable: !0,
|
|
986
1029
|
configurable: !0,
|
|
987
1030
|
writable: !0,
|
|
988
1031
|
value: (r) => {
|
|
989
|
-
var
|
|
990
|
-
return ((
|
|
991
|
-
}) : (this.onCloseHandlers.push(r), () => this.onCloseHandlers = this.onCloseHandlers.filter((
|
|
1032
|
+
var a;
|
|
1033
|
+
return ((a = this.state) == null ? void 0 : a.next_action) === null ? (r(g(this.state)), () => {
|
|
1034
|
+
}) : (this.onCloseHandlers.push(r), () => this.onCloseHandlers = this.onCloseHandlers.filter((n) => n !== r));
|
|
992
1035
|
}
|
|
993
1036
|
}), Object.defineProperty(this, "completeAction", {
|
|
994
1037
|
enumerable: !0,
|
|
995
1038
|
configurable: !0,
|
|
996
1039
|
writable: !0,
|
|
997
1040
|
value: async (r) => {
|
|
998
|
-
const
|
|
999
|
-
return new Promise((
|
|
1041
|
+
const a = this.state;
|
|
1042
|
+
return new Promise((n, s) => {
|
|
1000
1043
|
const o = this.onStateChange((l) => {
|
|
1001
|
-
l.next_action !== (
|
|
1044
|
+
l.next_action !== (a == null ? void 0 : a.next_action) && l.next_action === null && (n(g(l)), o());
|
|
1002
1045
|
});
|
|
1003
|
-
this.api.completeAction(this.id, r).then((l) => this.newStateHandle(l, s)).catch(async (l) => s(await
|
|
1046
|
+
this.api.completeAction(this.id, r).then((l) => this.newStateHandle(l, s)).catch(async (l) => s(await re(l)));
|
|
1004
1047
|
});
|
|
1005
1048
|
}
|
|
1006
1049
|
}), Object.defineProperty(this, "completeSession", {
|
|
@@ -1008,7 +1051,7 @@ class Q {
|
|
|
1008
1051
|
configurable: !0,
|
|
1009
1052
|
writable: !0,
|
|
1010
1053
|
value: (r) => {
|
|
1011
|
-
this.onCloseHandlers.forEach((
|
|
1054
|
+
this.onCloseHandlers.forEach((a) => a(r)), this.stop();
|
|
1012
1055
|
}
|
|
1013
1056
|
}), Object.defineProperty(this, "dispose", {
|
|
1014
1057
|
enumerable: !0,
|
|
@@ -1034,26 +1077,26 @@ class Q {
|
|
|
1034
1077
|
var r;
|
|
1035
1078
|
switch (!e.next_action && e.status && (e.next_action = null), e.next_action) {
|
|
1036
1079
|
case "wait": {
|
|
1037
|
-
window.clearTimeout(this.pollingTimer), this.pollingTimer = window.setTimeout(() => this.updateSessionState(t).catch((
|
|
1038
|
-
|
|
1039
|
-
}),
|
|
1080
|
+
window.clearTimeout(this.pollingTimer), this.pollingTimer = window.setTimeout(() => this.updateSessionState(t).catch((a) => {
|
|
1081
|
+
a instanceof Response && a.status === 404 && (t == null || t(new Error(`Session ${this.id} has expired`)));
|
|
1082
|
+
}), ee);
|
|
1040
1083
|
break;
|
|
1041
1084
|
}
|
|
1042
1085
|
}
|
|
1043
|
-
e.next_action !== ((r = this.state) == null ? void 0 : r.next_action) && this.stateChangeHandlers.forEach((
|
|
1086
|
+
e.next_action !== ((r = this.state) == null ? void 0 : r.next_action) && this.stateChangeHandlers.forEach((a) => a(e)), e.next_action === null && this.completeSession(g(e)), this.state = e;
|
|
1044
1087
|
}
|
|
1045
1088
|
}
|
|
1046
|
-
async function
|
|
1089
|
+
async function re(i) {
|
|
1047
1090
|
return !i.ok && i.status >= 400 && i.status <= 500 ? i.json() : i;
|
|
1048
1091
|
}
|
|
1049
1092
|
function g(i) {
|
|
1050
1093
|
const e = { ...i };
|
|
1051
1094
|
return delete e.next_action, e;
|
|
1052
1095
|
}
|
|
1053
|
-
const
|
|
1096
|
+
const ie = {
|
|
1054
1097
|
base_url: "https://api.hellgate.io"
|
|
1055
1098
|
};
|
|
1056
|
-
class
|
|
1099
|
+
class N {
|
|
1057
1100
|
constructor(e, t, r) {
|
|
1058
1101
|
Object.defineProperty(this, "session", {
|
|
1059
1102
|
enumerable: !0,
|
|
@@ -1075,14 +1118,14 @@ class L {
|
|
|
1075
1118
|
configurable: !0,
|
|
1076
1119
|
writable: !0,
|
|
1077
1120
|
value: () => {
|
|
1078
|
-
this.session.dispose(), this.coordinator.dispose(), Object.values(this.paymentFlowHandlers).forEach((
|
|
1121
|
+
this.session.dispose(), this.coordinator.dispose(), Object.values(this.paymentFlowHandlers).forEach((a) => a == null ? void 0 : a.dispose());
|
|
1079
1122
|
}
|
|
1080
1123
|
}), Object.defineProperty(this, "onSessionComplete", {
|
|
1081
1124
|
enumerable: !0,
|
|
1082
1125
|
configurable: !0,
|
|
1083
1126
|
writable: !0,
|
|
1084
|
-
value: (
|
|
1085
|
-
this.session.onClose(
|
|
1127
|
+
value: (a) => {
|
|
1128
|
+
this.session.onClose(a);
|
|
1086
1129
|
}
|
|
1087
1130
|
});
|
|
1088
1131
|
}
|
|
@@ -1090,28 +1133,28 @@ class L {
|
|
|
1090
1133
|
return this.paymentFlowHandlers[e];
|
|
1091
1134
|
}
|
|
1092
1135
|
static async init(e, t = {}) {
|
|
1093
|
-
const { session: r, coordinator:
|
|
1094
|
-
return new
|
|
1095
|
-
CARD:
|
|
1136
|
+
const { session: r, coordinator: a, cardHandler: n, handler3DS: s } = await this.initHandlers(e, t);
|
|
1137
|
+
return new N(r, a, {
|
|
1138
|
+
CARD: n,
|
|
1096
1139
|
"3DS": s
|
|
1097
1140
|
});
|
|
1098
1141
|
}
|
|
1099
1142
|
static async initHandlers(e, t) {
|
|
1100
1143
|
const r = {
|
|
1101
|
-
...
|
|
1144
|
+
...ie,
|
|
1102
1145
|
...t
|
|
1103
|
-
},
|
|
1146
|
+
}, a = new Z(r.base_url, r.abortCtrl), n = new te(e, a), s = new Q();
|
|
1104
1147
|
s.onMessage("coordinator:session_state_change", (c) => {
|
|
1105
|
-
c.state.next_action !== "wait" &&
|
|
1148
|
+
c.state.next_action !== "wait" && n.newStateHandle(c.state);
|
|
1106
1149
|
}), await s.init(e, r.base_url, r.abortCtrl);
|
|
1107
|
-
const o =
|
|
1108
|
-
return { session:
|
|
1150
|
+
const o = n.isNextAction("tokenize_card") || n.isNextAction("refresh_security_code") ? await this.createCardHandler(n, s) : void 0, l = this.create3DSHandler(n, t);
|
|
1151
|
+
return { session: n, coordinator: s, cardHandler: o, handler3DS: l };
|
|
1109
1152
|
}
|
|
1110
1153
|
static createCardHandler(e, t) {
|
|
1111
1154
|
return w.init(e, t);
|
|
1112
1155
|
}
|
|
1113
1156
|
static create3DSHandler(e, t) {
|
|
1114
|
-
return new
|
|
1157
|
+
return new k(e, {
|
|
1115
1158
|
domContainer: t.challenge_3ds_container,
|
|
1116
1159
|
labelText: t.challenge_3ds_label_text
|
|
1117
1160
|
});
|
|
@@ -1119,17 +1162,17 @@ class L {
|
|
|
1119
1162
|
}
|
|
1120
1163
|
globalThis.HellgateSDK && (globalThis.Hellgate = globalThis.HellgateSDK.Hellgate, delete globalThis.HellgateSDK);
|
|
1121
1164
|
export {
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1165
|
+
q as CardElement,
|
|
1166
|
+
z as CardExpirationDateElement,
|
|
1167
|
+
Y as CardNumberElement,
|
|
1168
|
+
G as CardVerificationCodeElement,
|
|
1169
|
+
N as Hellgate,
|
|
1170
|
+
k as Hellgate3DSHandler,
|
|
1128
1171
|
w as HellgateCardHandler,
|
|
1129
1172
|
K as TextElement,
|
|
1130
1173
|
b as createElement,
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1174
|
+
L as extractCardNumberValue,
|
|
1175
|
+
M as extractExpiryDateValue,
|
|
1176
|
+
B as putCardNumberValue,
|
|
1177
|
+
I as putExpiryDateValue
|
|
1135
1178
|
};
|
package/dist/hellgate-sdk.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(c,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(c=typeof globalThis<"u"?globalThis:c||self,p(c.HellgateSDK={}))})(this,function(c){"use strict";function p(i){return Array.isArray(i)?i.filter(Boolean):Object.fromEntries(Object.entries(i).map(([e,t])=>[e,typeof t=="object"&&t&&!Array.isArray(t)?p(t):t]).filter(([e,t])=>typeof t=="object"&&t&&!Array.isArray(t)?!!Object.keys(t).length:t!=null&&t!=null))}function b(i,e){const t={...i,...e},r=Object.keys(t);for(const n of r){const a=i[n],s=e[n];typeof a=="object"&&!Array.isArray(a)&&a&&typeof s=="object"&&!Array.isArray(s)&&s&&(t[n]=b(a,s))}return t}function E(i){if(!i.ok)throw i;return i.json()}function S(i){return`https://${window.HG_IFRAME_HOST??"sdk.hellgate.io"}/web/${i}/iframe/`}const B=2e3;class j{constructor(e,t){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"iframeId",{enumerable:!0,configurable:!0,writable:!0,value:String(Math.floor(1e5+Math.random()*9e5))}),Object.defineProperty(this,"resultPollingTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"transactionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"decoupledAuthHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"disposers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"check3dsIframeDisposers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"domContainer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"labelText",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onStartHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFinishHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onDecoupledAuth",{enumerable:!0,configurable:!0,writable:!0,value:r=>{this.decoupledAuthHandlers.push(r)}}),Object.defineProperty(this,"onStartChallenge",{enumerable:!0,configurable:!0,writable:!0,value:r=>{this.onStartHandler=r}}),Object.defineProperty(this,"onChallengeFinished",{enumerable:!0,configurable:!0,writable:!0,value:r=>{this.onFinishHandler=r}}),Object.defineProperty(this,"sessionStateHandle",{enumerable:!0,configurable:!0,writable:!0,value:r=>{var n,a;switch(r.next_action){case"3ds_check":{this.initCheck3DSIframes(r.data.threeds_server_callback_url,r.data.mon_url);break}case"3ds_challenge":{(n=this.onStartHandler)==null||n.call(this),this.disposeCheck3DSIframe(),this.startChallenge(r.data.challenge_url,r.data.result_mon_url);break}case"3ds_challenge_decoupled":{this.startDecoupledAuth(r.data.cardholder_info,r.data.result_mon_url,r.data.transaction_id);break}case null:{this.dispose(),(a=this.onFinishHandler)==null||a.call(this);break}}}}),this.domContainer=t.domContainer??w(),this.disposers.push(this.session.onStateChange(this.sessionStateHandle)),this.labelText=t.labelText}dispose(){this.disposers.forEach(e=>e()),this.check3dsIframeDisposers.forEach(e=>e())}initCheck3DSIframes(e,t){const r=w();r.insertAdjacentHTML("beforeend",`<iframe id="check_3ds_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${e}"></iframe>`);const n=r.querySelector(`#check_3ds_${this.iframeId}`);if(n){const a=s=>{s.source===n.contentWindow&&this.session.completeAction({action:"3ds_check",result:s.data})};window.addEventListener("message",a),this.check3dsIframeDisposers.push(()=>window.removeEventListener("message",a),()=>n.remove())}if(t){r.insertAdjacentHTML("beforeend",`<iframe id="mon_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${t}"></iframe>`);const a=r.querySelector(`#mon_${this.iframeId}`);a&&this.disposers.push(()=>a.remove())}}disposeCheck3DSIframe(){this.check3dsIframeDisposers.forEach(e=>e()),this.check3dsIframeDisposers=[]}startChallenge(e,t){const r=w(),n=`<div style="display: flex; flex-direction: column; gap: 10px; align-items: center; ${this.domContainer===r?'border:0; max-width: 800px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width:100% " ':'border:0;" width="100%" height="100%"'}><iframe id="cha_${this.iframeId}" src="${e}" width="100%" height="500"></iframe>${this.labelText?'<span id="tds_label_text" style="font-size: large;">'+this.labelText+"</span>":""}<div>`;this.domContainer.insertAdjacentHTML("beforeend",this.domContainer===r?`<div id="cha_${this.iframeId}_wrap" style="background: #fff; position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 10000;">${n}</div>`:n);const a=this.domContainer.querySelector(`#cha_${this.iframeId}`),s=this.domContainer.querySelector(`#cha_${this.iframeId}_wrap`);if(!a)throw new Error("3DS Challenge Iframe initialization failed");this.disposers.push(()=>{a.remove(),s==null||s.remove()});const o=new Promise(d=>{const h=u=>{u.source!==a.contentWindow||u.data.event!=="AuthResultReady"||d({...u.data,requestor_trans_id:u.data.requestor_trans_id??u.data.requestorTransId,requestorTransId:void 0,param:u.data.param||void 0})};window.addEventListener("message",h),this.disposers.push(()=>window.removeEventListener("message",h))}),l=new Promise(d=>{const h=this.startAuthResultPolling(t,u=>{u.event==="AuthResultReady"&&(h(),d({requestor_trans_id:u.threeDSRequestorTransID,event:u.event}))})});Promise.any([o,l]).then(d=>{this.session.completeAction({action:"3ds_challenge",result:d})})}startDecoupledAuth(e,t,r){this.transactionId||(this.transactionId=r),this.decoupledAuthHandlers.forEach(a=>a(e));const n=this.startAuthResultPolling(t,a=>{a.event==="AuthResultReady"&&(this.session.completeAction({action:"3ds_challenge_decoupled",result:{...a,event:a.event}}),n())})}startAuthResultPolling(e,t){return window.clearTimeout(this.resultPollingTimer),this.resultPollingTimer=window.setTimeout(()=>fetch(e).then(r=>E(r)).then(r=>{this.startAuthResultPolling(e,t),t(r)}).catch(()=>{}),B),()=>window.clearTimeout(this.resultPollingTimer)}}function w(){return document.body}const _={base:{":disabled":{backgroundColor:"transparent"}}},Y="DOM Element was not found";var A;(function(i){i.NOT_COMPLETE="NOT_COMPLETE",i.SCHEME_NOT_SUPPORTED="SCHEME_NOT_SUPPORTED",i.LUHN_CHECK_FAILED="LUHN_CHECK_FAILED",i.INVALID_EXPIRY_DATE="INVALID_EXPIRY_DATE"})(A||(A={}));const H=i=>i!=null,q="v3.9.1";class m{constructor(e){if(Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"IFRAME_BASE_URL",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"subscriptions",{enumerable:!0,configurable:!0,writable:!0,value:{ready:[],blur:[],focus:[],keydown:[],change:[]}}),Object.defineProperty(this,"key",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"update",{enumerable:!0,configurable:!0,writable:!0,value:async({...t})=>{this.iframe&&H(t.height)&&(this.iframe.height=t.height),this.iframePostMessage({type:"update",data:{...t,value:t.value?this.putValue(t.value)??void 0:void 0}})}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"clear"})}}),Object.defineProperty(this,"focus",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"focus"})}}),Object.defineProperty(this,"blur",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"blur"})}}),Object.defineProperty(this,"unmount",{enumerable:!0,configurable:!0,writable:!0,value:()=>{var t;(t=this.iframe)==null||t.remove(),this.iframe=null}}),this.IFRAME_BASE_URL=S(q),!this.IFRAME_BASE_URL)throw new Error("IFRAME_BASE_URL not found")}mount(e){const t=typeof e=="string"?document.querySelector(e):e;if(!t)throw new Error(`${Y}: ${e}`);t.innerHTML=`<iframe width="100%" height="29" src="${this.IFRAME_BASE_URL}?field=${this.type}&origin=${location.origin}"></iframe>`,this.iframe=t.querySelector("iframe");const r=n=>{var a;n.source!==((a=this.iframe)==null?void 0:a.contentWindow)||n.data.element!==this.type||this.emitEvent(n.data)};return window.addEventListener("message",r),new Promise(n=>{this.on("ready",a=>{this.key=a.key,this.update(this.options),n()})})}on(e,t){return this.subscriptions[e].push(t),{unsubscribe:()=>this.subscriptions[e].splice(this.subscriptions[e].indexOf(t),1)}}emitEvent(e){var t;(t=this.subscriptions[e.type])==null||t.forEach(r=>r(e.data))}iframePostMessage(e){var t,r;(r=(t=this.iframe)==null?void 0:t.contentWindow)==null||r.postMessage(e,this.IFRAME_BASE_URL)}}class K extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardExpirationMonth"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:D}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:T})}}function D(i){return i?Number(i):null}function T(i){return i?i<10?`0${i}`:String(i):null}class W extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardExpirationYear"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:M}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:I})}}function M(i){if(!i)return null;const e=Number(i);return e>10?+`20${e}`:null}function I(i){return i?i>=100?String(i).slice(-2):String(i):null}function v(i){const[e=null,t=null]=(i??"").split("/").map(r=>r.trim());return{month:D(e),year:M(t)}}function O(i){if(!i)return null;const{month:e,year:t}=i;return[T(e),I(t)].filter(H).join(" / ")}class L extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardExpirationDate"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:v}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:O})}}function P(i){return(i==null?void 0:i.replaceAll(" ",""))??null}function N(i){return i}class F extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardNumber"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:P}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:N})}}class k extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"card"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e?{number:e.cardNumber?P(e.cardNumber):null,expiry_date:e.cardExpirationDate?v(e.cardExpirationDate):null,cvc:e.cardVerificationCode??null}:null}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e?{cardNumber:e.number?e.number:null,cardExpirationDate:e.expiry_date?O(e.expiry_date):null,cardVerificationCode:e.cvc??null}:null})}}class R extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardVerificationCode"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e})}}class $ extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"text"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e})}}function f(i,e){switch(i){case"card":return new k(e);case"cardNumber":return new F(e);case"cardExpirationDate":return new L(e);case"cardExpirationMonth":return new K(e);case"cardExpirationYear":return new W(e);case"cardVerificationCode":return new R(e);case"text":return new $(e);default:ASSERT_EXHAUSTIVE(i)}}function U(i){return[i.issuer_identification_number,"".padEnd(i.account_number_length-i.issuer_identification_number.length-i.account_number_last_four.length,"*"),i.account_number_last_four].join(" ")}class g{static async init(e,t){return new g(e,t)}constructor(e,t){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"coordinator",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:this.createFieldDefaultState()}),Object.defineProperty(this,"cardElements",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"textElements",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"cvcOnlyEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"createForm",{enumerable:!0,configurable:!0,writable:!0,value:(r={})=>{var s;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const n=b({disabled:!1,autocomplete:"on",style:{..._}},r);if(this.session.isNextAction("refresh_security_code")&&((s=this.session.state)!=null&&s.data)){const o=this.session.state.data;n.cvcOnly=!0,n.value={number:U(o),expiry_date:{month:(o==null?void 0:o.expiry_month)??null,year:(o==null?void 0:o.expiry_year)??null},cvc:null}}const a=f("card",n);return this.cardElements.card={element:a,state:this.createFieldDefaultState()},this.addElementStateListener("card"),a}}),Object.defineProperty(this,"createTextField",{enumerable:!0,configurable:!0,writable:!0,value:(r={})=>{const n={disabled:!1,autocomplete:"on",style:{..._}},a=f("text",{...b(n,{...r})});return this.textElements.push(a),a}}),Object.defineProperty(this,"tokenize",{enumerable:!0,configurable:!0,writable:!0,value:async r=>{var a,s;if(((a=this.session.state)==null?void 0:a.next_action)!=="tokenize_card")throw new Error(`The session's next_action='${(s=this.session.state)==null?void 0:s.next_action}'. tokenize() is available only if next_action='tokenize_card'`);const n=this.getCardDataValidationError();if(n)throw n;return this.coordinator.postMessage({type:"card:tokenize",additionalData:this.serializeAdditionalData(r)}),new Promise(o=>{this.coordinator.onMessage("card:tokenize:response",l=>{o(l.success?l.result:null)})})}}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:r=>{this.stateChangeHandlers.push(r),r(this.state)}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(r=>r==null?void 0:r.element.clear()),this.textElements.forEach(r=>r==null?void 0:r.clear())}}),Object.defineProperty(this,"reset",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(r=>r==null?void 0:r.element.unmount()),this.textElements.forEach(r=>r==null?void 0:r.unmount()),this.cardElements={},this.textElements=[],this.state=this.createFieldDefaultState()}}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.reset()}}),Object.defineProperty(this,"process",{enumerable:!0,configurable:!0,writable:!0,value:async(r={})=>{if(!this.hasFormElements())throw new Error("Card form must be initialized and completed before processing");const n=this.getCardDataValidationError();if(n)throw n;if(this.session.isNextAction("refresh_security_code"))return this.refreshSecurityCode();this.disableFormElements(!0);try{return this.coordinator.postMessage({type:"card:process",additionalData:this.serializeAdditionalData(r)}),new Promise((a,s)=>{this.coordinator.onMessage("card:process:response",o=>{o.result&&o.success?a(o.result):s(new Error(o.error))})})}catch(a){throw this.disableFormElements(!1),a}}}),this.cvcOnlyEnabled=this.session.isNextAction("refresh_security_code")}createFormFields(e={}){var l,d;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const t={disabled:this.cvcOnlyEnabled,autocomplete:"on",style:{..._}},{cardNumber:r={},securityCode:n={},...a}=e,s=f("cardNumber",{...b(t,{...a,...r,cvcOnly:this.cvcOnlyEnabled,value:this.session.isNextAction("refresh_security_code")&&((l=this.session.state)!=null&&l.data)?U(this.session.state.data):null})}),o=f("cardVerificationCode",{...b({...t,disabled:!1,autofocus:this.cvcOnlyEnabled},{...a,...n})});if(s.on("change",h=>{const u=h.cardBrand;o.update({cardType:u})}),this.cardElements={cardNumber:{element:s,state:this.createFieldDefaultState()},cardVerificationCode:{element:o,state:this.createFieldDefaultState()}},this.addElementStateListener("cardNumber"),this.addElementStateListener("cardVerificationCode"),e.expiryDateElement==="separate"){const{expiryMonth:h={},expiryYear:u={}}=e,V=f("cardExpirationMonth",{...b(t,{...a,...h})}),z=f("cardExpirationYear",{...b(t,{...a,...u})});return this.cardElements.cardExpirationMonth={element:V,state:this.createFieldDefaultState()},this.cardElements.cardExpirationYear={element:z,state:this.createFieldDefaultState()},this.addElementStateListener("cardExpirationMonth"),this.addElementStateListener("cardExpirationYear"),{cardNumber:s,expiryMonth:V,expiryYear:z,securityCode:o}}else{const{expiryDate:h={}}=e,u=f("cardExpirationDate",{...b(t,{...a,...h,value:this.session.isNextAction("refresh_security_code")&&((d=this.session.state)!=null&&d.data)?{month:this.session.state.data.expiry_month,year:this.session.state.data.expiry_year}:null})});return this.cardElements.cardExpirationDate={element:u,state:this.createFieldDefaultState()},this.addElementStateListener("cardExpirationDate"),{cardNumber:s,expiryDate:u,securityCode:o}}}async refreshSecurityCode(){return this.coordinator.postMessage({type:"card:refresh_security_code"}),new Promise((e,t)=>{this.coordinator.onMessage("card:refresh_security_code:response",r=>{r.result?e(r.result):t(new Error(r.error))})})}hasFormElements(){return!!Object.keys(this.cardElements).length}disableFormElements(e){Object.values(this.cardElements).forEach(({element:t})=>{t.update({disabled:e})})}addElementStateListener(e){const t=this.cardElements[e];t&&t.element.on("change",r=>{t.state=r,this.updateFormState()})}updateFormState(){const e=this.cvcOnlyEnabled&&this.cardElements.cardVerificationCode?[this.cardElements.cardVerificationCode]:Object.values(this.cardElements);e.length?this.state=e.reduce((t,{state:r})=>(t.valid=!!t.valid&&!!r.valid,t.complete=!!t.complete&&!!r.complete,t.empty=!!t.empty&&!!r.empty,t.error=t.error||r.error,t.errorCode=t.errorCode||r.errorCode,t),{valid:!0,complete:!0,empty:!0}):this.state=this.createFieldDefaultState(),this.stateChangeHandlers.forEach(t=>t(this.state))}createFieldDefaultState(){return{empty:!0,complete:!1,valid:!1}}serializeAdditionalData({cardholder_name:e,billing_address:t={}}){return p({cardholder_name:y(e),billing_address:{line1:y(t.line1),line2:y(t.line2),line3:y(t.line3),city:y(t.city),postal_code:y(t.postal_code)}})}getCardDataValidationError(){if(!this.state.complete)return new Error(this.state.error??"Card data is not complete");if(!this.state.valid)return new Error(`Card data is not valid. ${this.state.error}`)}}function y(i){if(typeof i=="string")return i;if(i!=null&&i.key)return{key:i.key}}const G="v3.9.1";class X{constructor(){if(Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"iframeBaseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"messageHandler",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"init",{enumerable:!0,configurable:!0,writable:!0,value:async(e,t,r)=>(window.fetchMocker={a:1},new Promise((n,a)=>{r==null||r.signal.addEventListener("abort",()=>{const l=new Error("Coordinator init aborted");l.name="AbortError",a(l),this.dispose()});const s=document.createElement("div");s.setAttribute("style","position:absolute;width:0;height:0;overflow:hidden;"),s.setAttribute("data-hg-coordinator",""),document.body.appendChild(s);const o=`${this.iframeBaseUrl}?type=coordinator&sessionId=${e}&apiBaseUrl=${t}&origin=${encodeURIComponent(location.origin)}`;if(s.innerHTML=`<iframe src="${o}" width="0" height="0" style="border:none;" tabindex="-1" aria-hidden="true"></iframe>`,this.iframe=s.querySelector("iframe"),!this.iframe){a(new Error("Failed to create coordinator iframe"));return}this.messageHandler=l=>{var d,h,u;if(l.source===((d=this.iframe)==null?void 0:d.contentWindow)){if(((h=l.data)==null?void 0:h.type)==="coordinator:ready"){n();return}if(((u=l.data)==null?void 0:u.type)==="coordinator:error"){a(l.data.error);return}}},window.addEventListener("message",this.messageHandler),this.iframe.addEventListener("error",()=>{a(new Error("Coordinator iframe failed to load"))})}))}),this.iframeBaseUrl=S(G),!this.iframeBaseUrl)throw new Error("IFRAME_BASE_URL not found")}postMessage(e){var t,r;(r=(t=this.iframe)==null?void 0:t.contentWindow)==null||r.postMessage(e,this.iframeBaseUrl)}onMessage(e,t){window.addEventListener("message",r=>{var n,a;r.source===((n=this.iframe)==null?void 0:n.contentWindow)&&((a=r.data)==null?void 0:a.type)===e&&t(r.data)})}dispose(){var t;this.postMessage({type:"coordinator:dispose"}),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null);const e=(t=this.iframe)==null?void 0:t.parentElement;this.iframe=null,e==null||e.remove()}}class J{constructor(e="https://api.hellgate.io",t=new AbortController){Object.defineProperty(this,"abortCtrl",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrl=e.endsWith("/")?e.substring(0,e.length-1):e}getSession(e){return fetch(`${this.baseUrl}/sessions/${e}`,{signal:this.abortCtrl.signal}).then(t=>E(t))}completeAction(e,t){return fetch(`${this.baseUrl}/sessions/${e}/complete-action`,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:JSON.stringify(t),signal:this.abortCtrl.signal}).then(r=>E(r))}cancelAll(){this.abortCtrl.abort()}}const Q=2e3;class Z{constructor(e,t){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"api",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"onCloseHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pollingTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"init",{enumerable:!0,configurable:!0,writable:!0,value:async()=>new Promise((r,n)=>{const a=this.onStateChange(s=>{s.next_action!=="wait"&&(r(s),a())});this.updateSessionState().catch(s=>{s instanceof Response&&s.status===404&&n(new Error(`Session ${this.id} doesn't exist or has expired`)),n(s)})})}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:r=>(this.stateChangeHandlers.push(r),this.state&&r(this.state),()=>this.stateChangeHandlers=this.stateChangeHandlers.filter(n=>n!==r))}),Object.defineProperty(this,"onClose",{enumerable:!0,configurable:!0,writable:!0,value:r=>{var n;return((n=this.state)==null?void 0:n.next_action)===null?(r(x(this.state)),()=>{}):(this.onCloseHandlers.push(r),()=>this.onCloseHandlers=this.onCloseHandlers.filter(a=>a!==r))}}),Object.defineProperty(this,"completeAction",{enumerable:!0,configurable:!0,writable:!0,value:async r=>{const n=this.state;return new Promise((a,s)=>{const o=this.onStateChange(l=>{l.next_action!==(n==null?void 0:n.next_action)&&l.next_action===null&&(a(x(l)),o())});this.api.completeAction(this.id,r).then(l=>this.newStateHandle(l,s)).catch(async l=>s(await ee(l)))})}}),Object.defineProperty(this,"completeSession",{enumerable:!0,configurable:!0,writable:!0,value:r=>{this.onCloseHandlers.forEach(n=>n(r)),this.stop()}}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.stop(),this.api.cancelAll()}})}isNextAction(e){var t;return((t=this.state)==null?void 0:t.next_action)===e}stop(){window.clearTimeout(this.pollingTimer),this.stateChangeHandlers=[],this.onCloseHandlers=[]}async updateSessionState(e){const t=await this.api.getSession(this.id);this.newStateHandle(t,e)}newStateHandle(e,t){var r;switch(!e.next_action&&e.status&&(e.next_action=null),e.next_action){case"wait":{window.clearTimeout(this.pollingTimer),this.pollingTimer=window.setTimeout(()=>this.updateSessionState(t).catch(n=>{n instanceof Response&&n.status===404&&(t==null||t(new Error(`Session ${this.id} has expired`)))}),Q);break}}e.next_action!==((r=this.state)==null?void 0:r.next_action)&&this.stateChangeHandlers.forEach(n=>n(e)),e.next_action===null&&this.completeSession(x(e)),this.state=e}}async function ee(i){return!i.ok&&i.status>=400&&i.status<=500?i.json():i}function x(i){const e={...i};return delete e.next_action,e}const te={base_url:"https://api.hellgate.io"};class C{constructor(e,t,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"coordinator",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"paymentFlowHandlers",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.session.dispose(),this.coordinator.dispose(),Object.values(this.paymentFlowHandlers).forEach(n=>n==null?void 0:n.dispose())}}),Object.defineProperty(this,"onSessionComplete",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.session.onClose(n)}})}use(e){return this.paymentFlowHandlers[e]}static async init(e,t={}){const{session:r,coordinator:n,cardHandler:a,handler3DS:s}=await this.initHandlers(e,t);return new C(r,n,{CARD:a,"3DS":s})}static async initHandlers(e,t){const r={...te,...t},n=new J(r.base_url,r.abortCtrl),a=new Z(e,n),s=new X;s.onMessage("coordinator:session_state_change",d=>{d.state.next_action!=="wait"&&a.newStateHandle(d.state)}),await s.init(e,r.base_url,r.abortCtrl);const o=a.isNextAction("tokenize_card")||a.isNextAction("refresh_security_code")?await this.createCardHandler(a,s):void 0,l=this.create3DSHandler(a,t);return{session:a,coordinator:s,cardHandler:o,handler3DS:l}}static createCardHandler(e,t){return g.init(e,t)}static create3DSHandler(e,t){return new j(e,{domContainer:t.challenge_3ds_container,labelText:t.challenge_3ds_label_text})}}c.CardElement=k,c.CardExpirationDateElement=L,c.CardNumberElement=F,c.CardVerificationCodeElement=R,c.Hellgate=C,c.Hellgate3DSHandler=j,c.HellgateCardHandler=g,c.TextElement=$,c.createElement=f,c.extractCardNumberValue=P,c.extractExpiryDateValue=v,c.putCardNumberValue=N,c.putExpiryDateValue=O,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});globalThis.HellgateSDK&&(globalThis.Hellgate=globalThis.HellgateSDK.Hellgate,delete globalThis.HellgateSDK);
|
|
1
|
+
(function(c,p){typeof exports=="object"&&typeof module<"u"?p(exports):typeof define=="function"&&define.amd?define(["exports"],p):(c=typeof globalThis<"u"?globalThis:c||self,p(c.HellgateSDK={}))})(this,function(c){"use strict";function p(i){return Array.isArray(i)?i.filter(Boolean):Object.fromEntries(Object.entries(i).map(([e,t])=>[e,typeof t=="object"&&t&&!Array.isArray(t)?p(t):t]).filter(([e,t])=>typeof t=="object"&&t&&!Array.isArray(t)?!!Object.keys(t).length:t!=null&&t!=null))}function b(i,e){const t={...i,...e},r=Object.keys(t);for(const a of r){const n=i[a],s=e[a];typeof n=="object"&&!Array.isArray(n)&&n&&typeof s=="object"&&!Array.isArray(s)&&s&&(t[a]=b(n,s))}return t}function E(i){if(!i.ok)throw i;return i.json()}function S(i){return`https://${window.HG_IFRAME_HOST??"sdk.hellgate.io"}/web/${i}/iframe/`}const Y=2e3;class j{constructor(e,t){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"iframeId",{enumerable:!0,configurable:!0,writable:!0,value:String(Math.floor(1e5+Math.random()*9e5))}),Object.defineProperty(this,"resultPollingTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"transactionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"decoupledAuthHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"disposers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"check3dsIframeDisposers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"domContainer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"labelText",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onStartHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFinishHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onDecoupledAuth",{enumerable:!0,configurable:!0,writable:!0,value:r=>{this.decoupledAuthHandlers.push(r)}}),Object.defineProperty(this,"onStartChallenge",{enumerable:!0,configurable:!0,writable:!0,value:r=>{this.onStartHandler=r}}),Object.defineProperty(this,"onChallengeFinished",{enumerable:!0,configurable:!0,writable:!0,value:r=>{this.onFinishHandler=r}}),Object.defineProperty(this,"sessionStateHandle",{enumerable:!0,configurable:!0,writable:!0,value:r=>{var a,n;switch(r.next_action){case"3ds_check":{this.initCheck3DSIframes(r.data.threeds_server_callback_url,r.data.mon_url);break}case"3ds_challenge":{(a=this.onStartHandler)==null||a.call(this),this.disposeCheck3DSIframe(),this.startChallenge(r.data.challenge_url,r.data.result_mon_url);break}case"3ds_challenge_decoupled":{this.startDecoupledAuth(r.data.cardholder_info,r.data.result_mon_url,r.data.transaction_id);break}case null:{this.dispose(),(n=this.onFinishHandler)==null||n.call(this);break}}}}),this.domContainer=t.domContainer??w(),this.disposers.push(this.session.onStateChange(this.sessionStateHandle)),this.labelText=t.labelText}dispose(){this.disposers.forEach(e=>e()),this.check3dsIframeDisposers.forEach(e=>e())}initCheck3DSIframes(e,t){const r=w();r.insertAdjacentHTML("beforeend",`<iframe id="check_3ds_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${e}"></iframe>`);const a=r.querySelector(`#check_3ds_${this.iframeId}`);if(a){const n=s=>{s.source===a.contentWindow&&this.session.completeAction({action:"3ds_check",result:s.data})};window.addEventListener("message",n),this.check3dsIframeDisposers.push(()=>window.removeEventListener("message",n),()=>a.remove())}if(t){r.insertAdjacentHTML("beforeend",`<iframe id="mon_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${t}"></iframe>`);const n=r.querySelector(`#mon_${this.iframeId}`);n&&this.disposers.push(()=>n.remove())}}disposeCheck3DSIframe(){this.check3dsIframeDisposers.forEach(e=>e()),this.check3dsIframeDisposers=[]}startChallenge(e,t){const r=w(),a=`<div style="display: flex; flex-direction: column; gap: 10px; align-items: center; ${this.domContainer===r?'border:0; max-width: 800px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width:100% " ':'border:0;" width="100%" height="100%"'}><iframe id="cha_${this.iframeId}" src="${e}" width="100%" height="500"></iframe>${this.labelText?'<span id="tds_label_text" style="font-size: large;">'+this.labelText+"</span>":""}<div>`;this.domContainer.insertAdjacentHTML("beforeend",this.domContainer===r?`<div id="cha_${this.iframeId}_wrap" style="background: #fff; position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 10000;">${a}</div>`:a);const n=this.domContainer.querySelector(`#cha_${this.iframeId}`),s=this.domContainer.querySelector(`#cha_${this.iframeId}_wrap`);if(!n)throw new Error("3DS Challenge Iframe initialization failed");this.disposers.push(()=>{n.remove(),s==null||s.remove()});const o=new Promise(d=>{const h=u=>{u.source!==n.contentWindow||u.data.event!=="AuthResultReady"||d({...u.data,requestor_trans_id:u.data.requestor_trans_id??u.data.requestorTransId,requestorTransId:void 0,param:u.data.param||void 0})};window.addEventListener("message",h),this.disposers.push(()=>window.removeEventListener("message",h))}),l=new Promise(d=>{const h=this.startAuthResultPolling(t,u=>{u.event==="AuthResultReady"&&(h(),d({requestor_trans_id:u.threeDSRequestorTransID,event:u.event}))})});Promise.any([o,l]).then(d=>{this.session.completeAction({action:"3ds_challenge",result:d})})}startDecoupledAuth(e,t,r){this.transactionId||(this.transactionId=r),this.decoupledAuthHandlers.forEach(n=>n(e));const a=this.startAuthResultPolling(t,n=>{n.event==="AuthResultReady"&&(this.session.completeAction({action:"3ds_challenge_decoupled",result:{...n,event:n.event}}),a())})}startAuthResultPolling(e,t){return window.clearTimeout(this.resultPollingTimer),this.resultPollingTimer=window.setTimeout(()=>fetch(e).then(r=>E(r)).then(r=>{this.startAuthResultPolling(e,t),t(r)}).catch(()=>{}),Y),()=>window.clearTimeout(this.resultPollingTimer)}}function w(){return document.body}const _={base:{":disabled":{backgroundColor:"transparent"}}},q="DOM Element was not found";var A;(function(i){i.NOT_COMPLETE="NOT_COMPLETE",i.SCHEME_NOT_SUPPORTED="SCHEME_NOT_SUPPORTED",i.LUHN_CHECK_FAILED="LUHN_CHECK_FAILED",i.INVALID_EXPIRY_DATE="INVALID_EXPIRY_DATE"})(A||(A={}));const H=i=>i!=null,K="v3.11.0";class m{constructor(e){if(Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"IFRAME_BASE_URL",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"subscriptions",{enumerable:!0,configurable:!0,writable:!0,value:{ready:[],blur:[],focus:[],keydown:[],change:[]}}),Object.defineProperty(this,"key",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"update",{enumerable:!0,configurable:!0,writable:!0,value:async({...t})=>{this.iframe&&H(t.height)&&(this.iframe.height=t.height),this.iframePostMessage({type:"update",data:{...t,value:t.value?this.putValue(t.value)??void 0:void 0}})}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"clear"})}}),Object.defineProperty(this,"focus",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"focus"})}}),Object.defineProperty(this,"blur",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"blur"})}}),Object.defineProperty(this,"unmount",{enumerable:!0,configurable:!0,writable:!0,value:()=>{var t;(t=this.iframe)==null||t.remove(),this.iframe=null}}),this.IFRAME_BASE_URL=S(K),!this.IFRAME_BASE_URL)throw new Error("IFRAME_BASE_URL not found")}mount(e){const t=typeof e=="string"?document.querySelector(e):e;if(!t)throw new Error(`${q}: ${e}`);t.innerHTML=`<iframe width="100%" height="29" src="${this.IFRAME_BASE_URL}?field=${this.type}&origin=${location.origin}"></iframe>`,this.iframe=t.querySelector("iframe");const r=a=>{var n;a.source!==((n=this.iframe)==null?void 0:n.contentWindow)||a.data.element!==this.type||this.emitEvent(a.data)};return window.addEventListener("message",r),new Promise(a=>{this.on("ready",n=>{this.key=n.key,this.update(this.options),a()})})}on(e,t){return this.subscriptions[e].push(t),{unsubscribe:()=>this.subscriptions[e].splice(this.subscriptions[e].indexOf(t),1)}}emitEvent(e){var t;(t=this.subscriptions[e.type])==null||t.forEach(r=>r(e.data))}iframePostMessage(e){var t,r;(r=(t=this.iframe)==null?void 0:t.contentWindow)==null||r.postMessage(e,this.IFRAME_BASE_URL)}}class G extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardExpirationMonth"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:D}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:T})}}function D(i){return i?Number(i):null}function T(i){return i?i<10?`0${i}`:String(i):null}class W extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardExpirationYear"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:M}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:I})}}function M(i){if(!i)return null;const e=Number(i);return e>10?+`20${e}`:null}function I(i){return i?i>=100?String(i).slice(-2):String(i):null}function v(i){const[e=null,t=null]=(i??"").split("/").map(r=>r.trim());return{month:D(e),year:M(t)}}function O(i){if(!i)return null;const{month:e,year:t}=i;return[T(e),I(t)].filter(H).join(" / ")}class L extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardExpirationDate"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:v}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:O})}}function P(i){return(i==null?void 0:i.replaceAll(" ",""))??null}function N(i){return i}class F extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardNumber"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:P}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:N})}}class k extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"card"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e?{number:e.cardNumber?P(e.cardNumber):null,expiry_date:e.cardExpirationDate?v(e.cardExpirationDate):null,cvc:e.cardVerificationCode??null}:null}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e?{cardNumber:e.number?e.number:null,cardExpirationDate:e.expiry_date?O(e.expiry_date):null,cardVerificationCode:e.cvc??null}:null})}}class R extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardVerificationCode"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e})}}class $ extends m{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"text"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:e=>e})}}function f(i,e){switch(i){case"card":return new k(e);case"cardNumber":return new F(e);case"cardExpirationDate":return new L(e);case"cardExpirationMonth":return new G(e);case"cardExpirationYear":return new W(e);case"cardVerificationCode":return new R(e);case"text":return new $(e);default:ASSERT_EXHAUSTIVE(i)}}const X={visa:"visa",mastercard:"mastercard",americanexpress:"american-express",discover:"discover",dinersclub:"diners-club",jcb:"jcb",unionpay:"unionpay"};function J(i){return i.map(e=>X[e]).filter(Boolean)}function U(i){return[i.issuer_identification_number,"".padEnd(i.account_number_length-i.issuer_identification_number.length-i.account_number_last_four.length,"*"),i.account_number_last_four].join(" ")}class g{static async init(e,t){return new g(e,t)}constructor(e,t){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"coordinator",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:this.createFieldDefaultState()}),Object.defineProperty(this,"cardElements",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"textElements",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"cvcOnlyEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"createForm",{enumerable:!0,configurable:!0,writable:!0,value:(r={})=>{var s;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const a=b({disabled:!1,autocomplete:"on",style:{..._}},r);if(this.session.isNextAction("refresh_security_code")&&((s=this.session.state)!=null&&s.data)){const o=this.session.state.data;a.cvcOnly=!0,a.value={number:U(o),expiry_date:{month:(o==null?void 0:o.expiry_month)??null,year:(o==null?void 0:o.expiry_year)??null},cvc:null}}a.schemes=V(this.getSessionSchemes(),a.schemes);const n=f("card",a);return this.cardElements.card={element:n,state:this.createFieldDefaultState()},this.addElementStateListener("card"),n}}),Object.defineProperty(this,"createTextField",{enumerable:!0,configurable:!0,writable:!0,value:(r={})=>{const a={disabled:!1,autocomplete:"on",style:{..._}},n=f("text",{...b(a,{...r})});return this.textElements.push(n),n}}),Object.defineProperty(this,"tokenize",{enumerable:!0,configurable:!0,writable:!0,value:async r=>{var n,s;if(((n=this.session.state)==null?void 0:n.next_action)!=="tokenize_card")throw new Error(`The session's next_action='${(s=this.session.state)==null?void 0:s.next_action}'. tokenize() is available only if next_action='tokenize_card'`);const a=this.getCardDataValidationError();if(a)throw a;return this.coordinator.postMessage({type:"card:tokenize",additionalData:this.serializeAdditionalData(r)}),new Promise(o=>{this.coordinator.onMessage("card:tokenize:response",l=>{o(l.success?l.result:null)})})}}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:r=>{this.stateChangeHandlers.push(r),r(this.state)}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(r=>r==null?void 0:r.element.clear()),this.textElements.forEach(r=>r==null?void 0:r.clear())}}),Object.defineProperty(this,"reset",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(r=>r==null?void 0:r.element.unmount()),this.textElements.forEach(r=>r==null?void 0:r.unmount()),this.cardElements={},this.textElements=[],this.state=this.createFieldDefaultState()}}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.reset()}}),Object.defineProperty(this,"process",{enumerable:!0,configurable:!0,writable:!0,value:async(r={})=>{if(!this.hasFormElements())throw new Error("Card form must be initialized and completed before processing");const a=this.getCardDataValidationError();if(a)throw a;if(this.session.isNextAction("refresh_security_code"))return this.refreshSecurityCode();this.disableFormElements(!0);try{return this.coordinator.postMessage({type:"card:process",additionalData:this.serializeAdditionalData(r)}),new Promise((n,s)=>{this.coordinator.onMessage("card:process:response",o=>{o.result&&o.success?n(o.result):s(new Error(o.error))})})}catch(n){throw this.disableFormElements(!1),n}}}),this.cvcOnlyEnabled=this.session.isNextAction("refresh_security_code")}createFormFields(e={}){var l,d;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const t={disabled:this.cvcOnlyEnabled,autocomplete:"on",style:{..._}},{cardNumber:r={},securityCode:a={},...n}=e,s=f("cardNumber",{...b(t,{...n,...r,cvcOnly:this.cvcOnlyEnabled,schemes:V(this.getSessionSchemes(),r.schemes??n.schemes),value:this.session.isNextAction("refresh_security_code")&&((l=this.session.state)!=null&&l.data)?U(this.session.state.data):null})}),o=f("cardVerificationCode",{...b({...t,disabled:!1,autofocus:this.cvcOnlyEnabled},{...n,...a})});if(s.on("change",h=>{const u=h.cardBrand;o.update({cardType:u})}),this.cardElements={cardNumber:{element:s,state:this.createFieldDefaultState()},cardVerificationCode:{element:o,state:this.createFieldDefaultState()}},this.addElementStateListener("cardNumber"),this.addElementStateListener("cardVerificationCode"),e.expiryDateElement==="separate"){const{expiryMonth:h={},expiryYear:u={}}=e,z=f("cardExpirationMonth",{...b(t,{...n,...h})}),B=f("cardExpirationYear",{...b(t,{...n,...u})});return this.cardElements.cardExpirationMonth={element:z,state:this.createFieldDefaultState()},this.cardElements.cardExpirationYear={element:B,state:this.createFieldDefaultState()},this.addElementStateListener("cardExpirationMonth"),this.addElementStateListener("cardExpirationYear"),{cardNumber:s,expiryMonth:z,expiryYear:B,securityCode:o}}else{const{expiryDate:h={}}=e,u=f("cardExpirationDate",{...b(t,{...n,...h,value:this.session.isNextAction("refresh_security_code")&&((d=this.session.state)!=null&&d.data)?{month:this.session.state.data.expiry_month,year:this.session.state.data.expiry_year}:null})});return this.cardElements.cardExpirationDate={element:u,state:this.createFieldDefaultState()},this.addElementStateListener("cardExpirationDate"),{cardNumber:s,expiryDate:u,securityCode:o}}}async refreshSecurityCode(){return this.coordinator.postMessage({type:"card:refresh_security_code"}),new Promise((e,t)=>{this.coordinator.onMessage("card:refresh_security_code:response",r=>{r.result?e(r.result):t(new Error(r.error))})})}hasFormElements(){return!!Object.keys(this.cardElements).length}disableFormElements(e){Object.values(this.cardElements).forEach(({element:t})=>{t.update({disabled:e})})}addElementStateListener(e){const t=this.cardElements[e];t&&t.element.on("change",r=>{t.state=r,this.updateFormState()})}updateFormState(){const e=this.cvcOnlyEnabled&&this.cardElements.cardVerificationCode?[this.cardElements.cardVerificationCode]:Object.values(this.cardElements);e.length?this.state=e.reduce((t,{state:r})=>(t.valid=!!t.valid&&!!r.valid,t.complete=!!t.complete&&!!r.complete,t.empty=!!t.empty&&!!r.empty,t.error=t.error||r.error,t.errorCode=t.errorCode||r.errorCode,t),{valid:!0,complete:!0,empty:!0}):this.state=this.createFieldDefaultState(),this.stateChangeHandlers.forEach(t=>t(this.state))}createFieldDefaultState(){return{empty:!0,complete:!1,valid:!1}}serializeAdditionalData({cardholder_name:e,billing_address:t={},ephemeral:r,expiration_date:a}){return p({cardholder_name:y(e),billing_address:{line1:y(t.line1),line2:y(t.line2),line3:y(t.line3),city:y(t.city),postal_code:y(t.postal_code)},...this.resolveLifecycleFields(r,a)})}resolveLifecycleFields(e,t){switch(this.getLifecycle()){case"ephemeral_only":return{ephemeral:!0};case"persistent_only":return{ephemeral:!1};case"user_choice":return{ephemeral:typeof e=="boolean"?e:void 0,expiration_date:typeof t=="string"?t:void 0}}}getLifecycle(){var e,t;return this.session.isNextAction("tokenize_card")?((t=(e=this.session.state)==null?void 0:e.data)==null?void 0:t.lifecycle)??"user_choice":"user_choice"}getSessionSchemes(){var t,r;if(!this.session.isNextAction("tokenize_card"))return;const e=(t=this.session.state)==null?void 0:t.data;if((r=e==null?void 0:e.allowed_schemes)!=null&&r.length)return J(e.allowed_schemes)}getCardDataValidationError(){if(!this.state.complete)return new Error(this.state.error??"Card data is not complete");if(!this.state.valid)return new Error(`Card data is not valid. ${this.state.error}`)}}function y(i){if(typeof i=="string")return i;if(i!=null&&i.key)return{key:i.key}}function V(i,e){return i===void 0?e:i.length===0?[]:e!=null&&e.length?e.filter(t=>i.includes(t)):i}const Q="v3.11.0";class Z{constructor(){if(Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"iframeBaseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"messageHandler",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"init",{enumerable:!0,configurable:!0,writable:!0,value:async(e,t,r)=>(window.fetchMocker={a:1},new Promise((a,n)=>{r==null||r.signal.addEventListener("abort",()=>{const l=new Error("Coordinator init aborted");l.name="AbortError",n(l),this.dispose()});const s=document.createElement("div");s.setAttribute("style","position:absolute;width:0;height:0;overflow:hidden;"),s.setAttribute("data-hg-coordinator",""),document.body.appendChild(s);const o=`${this.iframeBaseUrl}?type=coordinator&sessionId=${e}&apiBaseUrl=${t}&origin=${encodeURIComponent(location.origin)}`;if(s.innerHTML=`<iframe src="${o}" width="0" height="0" style="border:none;" tabindex="-1" aria-hidden="true"></iframe>`,this.iframe=s.querySelector("iframe"),!this.iframe){n(new Error("Failed to create coordinator iframe"));return}this.messageHandler=l=>{var d,h,u;if(l.source===((d=this.iframe)==null?void 0:d.contentWindow)){if(((h=l.data)==null?void 0:h.type)==="coordinator:ready"){a();return}if(((u=l.data)==null?void 0:u.type)==="coordinator:error"){n(l.data.error);return}}},window.addEventListener("message",this.messageHandler),this.iframe.addEventListener("error",()=>{n(new Error("Coordinator iframe failed to load"))})}))}),this.iframeBaseUrl=S(Q),!this.iframeBaseUrl)throw new Error("IFRAME_BASE_URL not found")}postMessage(e){var t,r;(r=(t=this.iframe)==null?void 0:t.contentWindow)==null||r.postMessage(e,this.iframeBaseUrl)}onMessage(e,t){window.addEventListener("message",r=>{var a,n;r.source===((a=this.iframe)==null?void 0:a.contentWindow)&&((n=r.data)==null?void 0:n.type)===e&&t(r.data)})}dispose(){var t;this.postMessage({type:"coordinator:dispose"}),this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null);const e=(t=this.iframe)==null?void 0:t.parentElement;this.iframe=null,e==null||e.remove()}}class ee{constructor(e="https://api.hellgate.io",t=new AbortController){Object.defineProperty(this,"abortCtrl",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrl=e.endsWith("/")?e.substring(0,e.length-1):e}getSession(e){return fetch(`${this.baseUrl}/sessions/${e}`,{signal:this.abortCtrl.signal}).then(t=>E(t))}completeAction(e,t){return fetch(`${this.baseUrl}/sessions/${e}/complete-action`,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:JSON.stringify(t),signal:this.abortCtrl.signal}).then(r=>E(r))}cancelAll(){this.abortCtrl.abort()}}const te=2e3;class re{constructor(e,t){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"api",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"onCloseHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pollingTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"init",{enumerable:!0,configurable:!0,writable:!0,value:async()=>new Promise((r,a)=>{const n=this.onStateChange(s=>{s.next_action!=="wait"&&(r(s),n())});this.updateSessionState().catch(s=>{s instanceof Response&&s.status===404&&a(new Error(`Session ${this.id} doesn't exist or has expired`)),a(s)})})}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:r=>(this.stateChangeHandlers.push(r),this.state&&r(this.state),()=>this.stateChangeHandlers=this.stateChangeHandlers.filter(a=>a!==r))}),Object.defineProperty(this,"onClose",{enumerable:!0,configurable:!0,writable:!0,value:r=>{var a;return((a=this.state)==null?void 0:a.next_action)===null?(r(x(this.state)),()=>{}):(this.onCloseHandlers.push(r),()=>this.onCloseHandlers=this.onCloseHandlers.filter(n=>n!==r))}}),Object.defineProperty(this,"completeAction",{enumerable:!0,configurable:!0,writable:!0,value:async r=>{const a=this.state;return new Promise((n,s)=>{const o=this.onStateChange(l=>{l.next_action!==(a==null?void 0:a.next_action)&&l.next_action===null&&(n(x(l)),o())});this.api.completeAction(this.id,r).then(l=>this.newStateHandle(l,s)).catch(async l=>s(await ie(l)))})}}),Object.defineProperty(this,"completeSession",{enumerable:!0,configurable:!0,writable:!0,value:r=>{this.onCloseHandlers.forEach(a=>a(r)),this.stop()}}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.stop(),this.api.cancelAll()}})}isNextAction(e){var t;return((t=this.state)==null?void 0:t.next_action)===e}stop(){window.clearTimeout(this.pollingTimer),this.stateChangeHandlers=[],this.onCloseHandlers=[]}async updateSessionState(e){const t=await this.api.getSession(this.id);this.newStateHandle(t,e)}newStateHandle(e,t){var r;switch(!e.next_action&&e.status&&(e.next_action=null),e.next_action){case"wait":{window.clearTimeout(this.pollingTimer),this.pollingTimer=window.setTimeout(()=>this.updateSessionState(t).catch(a=>{a instanceof Response&&a.status===404&&(t==null||t(new Error(`Session ${this.id} has expired`)))}),te);break}}e.next_action!==((r=this.state)==null?void 0:r.next_action)&&this.stateChangeHandlers.forEach(a=>a(e)),e.next_action===null&&this.completeSession(x(e)),this.state=e}}async function ie(i){return!i.ok&&i.status>=400&&i.status<=500?i.json():i}function x(i){const e={...i};return delete e.next_action,e}const ae={base_url:"https://api.hellgate.io"};class C{constructor(e,t,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"coordinator",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"paymentFlowHandlers",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.session.dispose(),this.coordinator.dispose(),Object.values(this.paymentFlowHandlers).forEach(a=>a==null?void 0:a.dispose())}}),Object.defineProperty(this,"onSessionComplete",{enumerable:!0,configurable:!0,writable:!0,value:a=>{this.session.onClose(a)}})}use(e){return this.paymentFlowHandlers[e]}static async init(e,t={}){const{session:r,coordinator:a,cardHandler:n,handler3DS:s}=await this.initHandlers(e,t);return new C(r,a,{CARD:n,"3DS":s})}static async initHandlers(e,t){const r={...ae,...t},a=new ee(r.base_url,r.abortCtrl),n=new re(e,a),s=new Z;s.onMessage("coordinator:session_state_change",d=>{d.state.next_action!=="wait"&&n.newStateHandle(d.state)}),await s.init(e,r.base_url,r.abortCtrl);const o=n.isNextAction("tokenize_card")||n.isNextAction("refresh_security_code")?await this.createCardHandler(n,s):void 0,l=this.create3DSHandler(n,t);return{session:n,coordinator:s,cardHandler:o,handler3DS:l}}static createCardHandler(e,t){return g.init(e,t)}static create3DSHandler(e,t){return new j(e,{domContainer:t.challenge_3ds_container,labelText:t.challenge_3ds_label_text})}}c.CardElement=k,c.CardExpirationDateElement=L,c.CardNumberElement=F,c.CardVerificationCodeElement=R,c.Hellgate=C,c.Hellgate3DSHandler=j,c.HellgateCardHandler=g,c.TextElement=$,c.createElement=f,c.extractCardNumberValue=P,c.extractExpiryDateValue=v,c.putCardNumberValue=N,c.putExpiryDateValue=O,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})});globalThis.HellgateSDK&&(globalThis.Hellgate=globalThis.HellgateSDK.Hellgate,delete globalThis.HellgateSDK);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@starfish-codes/hellgate",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Starfish GmbH & Co. KG",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@types/react-dom": "^18.2.22",
|
|
46
46
|
"@typescript-eslint/eslint-plugin": "^7.2.0",
|
|
47
47
|
"@typescript-eslint/parser": "^7.2.0",
|
|
48
|
-
"@vitest/browser": "^3.
|
|
48
|
+
"@vitest/browser": "^3.2.5",
|
|
49
49
|
"@vitest/coverage-istanbul": "^3.1.3",
|
|
50
50
|
"@vitest/ui": "^3.1.3",
|
|
51
51
|
"autoprefixer": "^10.4.18",
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
"husky": "^9.0.11",
|
|
57
57
|
"ky": "^1.2.2",
|
|
58
58
|
"lint-staged": "^15.2.2",
|
|
59
|
-
"lodash": "^4.
|
|
59
|
+
"lodash": "^4.18.1",
|
|
60
60
|
"mobx": "^6.12.0",
|
|
61
61
|
"mobx-react": "^9.1.0",
|
|
62
62
|
"mobx-react-viewmodel": "^0.2.0",
|
|
63
63
|
"playwright": "^1.55.1",
|
|
64
|
-
"postcss": "^8.5.
|
|
64
|
+
"postcss": "^8.5.10",
|
|
65
65
|
"postcss-nesting": "^13.0.1",
|
|
66
66
|
"prettier": "^3.2.5",
|
|
67
67
|
"react": "^18.2.0",
|
|
@@ -73,12 +73,12 @@
|
|
|
73
73
|
"tailwindcss": "^3.4.1",
|
|
74
74
|
"tailwindcss-animate": "^1.0.7",
|
|
75
75
|
"typescript": "^5.4.2",
|
|
76
|
-
"vite": "^6.4.
|
|
76
|
+
"vite": "^6.4.3",
|
|
77
77
|
"vite-plugin-checker": "^0.9.3",
|
|
78
78
|
"vite-plugin-sri3": "^1.3.0",
|
|
79
79
|
"vite-plugin-svg-icons-ng": "^1.4.0",
|
|
80
80
|
"vite-plugin-top-level-await": "^1.5.0",
|
|
81
|
-
"vitest": "^3.
|
|
81
|
+
"vitest": "^3.2.6",
|
|
82
82
|
"vitest-fetch-mock": "^0.2.2",
|
|
83
83
|
"webdriverio": "^9.12.7"
|
|
84
84
|
},
|
|
@@ -109,4 +109,4 @@
|
|
|
109
109
|
"path": "./node_modules/cz-conventional-changelog"
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
}
|
|
112
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type BTTokenizeData = Record<string, unknown>;
|