@lydianpay/sdk-web 3.13.0 → 3.14.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/README.md +49 -12
- package/dist/chunks/browser-BFd9Zasn.js +33 -0
- package/dist/chunks/connect-multichain-W5NFpeTb.js +9971 -0
- package/dist/chunks/index-B2KlqxZz.js +5944 -0
- package/dist/chunks/index-B8vFbue_.js +114 -0
- package/dist/chunks/{index-DJbuCqvB.js → index-ChcFlkGu.js} +927 -1293
- package/dist/chunks/{index-DrpAyUns.js → index-DDKaYwMc.js} +101 -83
- package/dist/chunks/index-DhuuCvX-.js +4716 -0
- package/dist/chunks/index-FAg0du7P.js +595 -0
- package/dist/chunks/index-SMHjRBlL.js +314 -0
- package/dist/chunks/mm-install-modal_2.entry-Dhx9nDM_.js +1365 -0
- package/dist/chunks/{mountEngine-DoxKiMjy.js → mountEngine-0u7my-Xz.js} +5715 -5589
- package/dist/chunks/utils-Ca8X9WUu.js +264 -0
- package/dist/lydian.js +1 -1
- package/dist/types/.tsbuildinfo +1 -1
- package/dist/types/types.d.ts +7 -0
- package/dist/types/ui/initConfig.d.ts +3 -0
- package/package.json +8 -4
- package/dist/chunks/metamask-sdk-C2ev3Ki6.js +0 -15037
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const g = ["USD", "TRY", "PHP"];
|
|
2
|
-
function
|
|
2
|
+
function A(e) {
|
|
3
3
|
return typeof e == "string" && g.includes(e);
|
|
4
4
|
}
|
|
5
5
|
function c(e) {
|
|
@@ -42,7 +42,7 @@ class y {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
const l = "transaction";
|
|
45
|
-
class
|
|
45
|
+
class S extends y {
|
|
46
46
|
async getCryptoTransaction(t) {
|
|
47
47
|
return await this.request(`/${l}/${t}`);
|
|
48
48
|
}
|
|
@@ -75,7 +75,7 @@ class A extends y {
|
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function I(e, t) {
|
|
79
79
|
t.forEach((a) => {
|
|
80
80
|
Object.getOwnPropertyNames(a.prototype).forEach((n) => {
|
|
81
81
|
const o = Object.getOwnPropertyDescriptor(a.prototype, n);
|
|
@@ -84,7 +84,7 @@ function S(e, t) {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
const w = "customer/otp";
|
|
87
|
-
class
|
|
87
|
+
class L extends y {
|
|
88
88
|
// PATCH /customer/otp -> text/plain "OTP sent" (no JSON body).
|
|
89
89
|
async sendCustomerOTP(t) {
|
|
90
90
|
return await this.requestText(`/${w}`, {
|
|
@@ -101,7 +101,7 @@ class I extends y {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
const d = "session";
|
|
104
|
-
class
|
|
104
|
+
class U extends y {
|
|
105
105
|
async createSession(t) {
|
|
106
106
|
return await this.request(`/${d}`, {
|
|
107
107
|
method: "POST",
|
|
@@ -131,10 +131,10 @@ class L extends y {
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
class
|
|
134
|
+
class b extends y {
|
|
135
135
|
}
|
|
136
|
-
|
|
137
|
-
const R =
|
|
136
|
+
I(b, [S, L, U]);
|
|
137
|
+
const R = b;
|
|
138
138
|
var u = {
|
|
139
139
|
COMPLIANCE_PENDING: -10,
|
|
140
140
|
API_CANCELLED: -9,
|
|
@@ -152,7 +152,7 @@ var u = {
|
|
|
152
152
|
FRAUD: -1,
|
|
153
153
|
PENDING: 0,
|
|
154
154
|
SUCCESS: 1
|
|
155
|
-
},
|
|
155
|
+
}, V = {
|
|
156
156
|
PARTIALLY_PAID: 1,
|
|
157
157
|
OVERPAID: 3
|
|
158
158
|
}, O = {
|
|
@@ -164,9 +164,9 @@ var u = {
|
|
|
164
164
|
prod: "https://api.lydian.com"
|
|
165
165
|
};
|
|
166
166
|
function F(e) {
|
|
167
|
-
return e.dev ? p.dev : e.sandbox ? p.sandbox : p.prod;
|
|
167
|
+
return e.gatewayUrl ? new URL(e.gatewayUrl).origin : e.dev ? p.dev : e.sandbox ? p.sandbox : p.prod;
|
|
168
168
|
}
|
|
169
|
-
function
|
|
169
|
+
function C({
|
|
170
170
|
options: e,
|
|
171
171
|
unsupportedKeys: t,
|
|
172
172
|
entryPoint: a
|
|
@@ -178,35 +178,47 @@ function P(e) {
|
|
|
178
178
|
var t;
|
|
179
179
|
return (t = e.flow) != null && t.walletConnect && !e.walletConnectProjectId ? "walletConnectProjectId is required when flow.walletConnect is on" : null;
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function k(e) {
|
|
182
|
+
return e.gatewayUrl === void 0 || W(e.gatewayUrl) ? null : `gatewayUrl must be an http(s) origin such as http://localhost:8000, with no path, got ${JSON.stringify(e.gatewayUrl)}`;
|
|
183
|
+
}
|
|
184
|
+
function W(e) {
|
|
185
|
+
let t;
|
|
186
|
+
try {
|
|
187
|
+
t = new URL(e);
|
|
188
|
+
} catch {
|
|
189
|
+
return !1;
|
|
190
|
+
}
|
|
191
|
+
return (t.protocol === "http:" || t.protocol === "https:") && t.pathname === "/" && t.search === "" && t.hash === "";
|
|
192
|
+
}
|
|
193
|
+
function ee(e) {
|
|
182
194
|
return e !== null && !c(e) && !!e.publishableKey;
|
|
183
195
|
}
|
|
184
|
-
function
|
|
196
|
+
function te(e) {
|
|
185
197
|
return e !== null && !c(e);
|
|
186
198
|
}
|
|
187
|
-
function
|
|
199
|
+
function ae({
|
|
188
200
|
options: e,
|
|
189
201
|
session: t,
|
|
190
202
|
settled: a
|
|
191
203
|
}) {
|
|
192
204
|
return !a && t !== null && e !== null && c(e);
|
|
193
205
|
}
|
|
194
|
-
function
|
|
206
|
+
function T(e, t, a) {
|
|
195
207
|
try {
|
|
196
208
|
e == null || e(t, a);
|
|
197
209
|
} catch (n) {
|
|
198
210
|
console.error(`onEvent("${t}") threw:`, n);
|
|
199
211
|
}
|
|
200
212
|
}
|
|
201
|
-
async function
|
|
213
|
+
async function x({
|
|
202
214
|
api: e,
|
|
203
215
|
options: t,
|
|
204
216
|
emit: a
|
|
205
217
|
}) {
|
|
206
218
|
try {
|
|
207
|
-
const n = await
|
|
208
|
-
a("session.loaded",
|
|
209
|
-
const s = await
|
|
219
|
+
const n = await M({ api: e, options: t }), { session: o, sessionPromoted: r } = await Y({ api: e, sessionID: n });
|
|
220
|
+
a("session.loaded", $(o));
|
|
221
|
+
const s = await B({
|
|
210
222
|
api: e,
|
|
211
223
|
transactionID: o.transactionID
|
|
212
224
|
});
|
|
@@ -215,7 +227,7 @@ async function U({
|
|
|
215
227
|
return { ok: !1 };
|
|
216
228
|
}
|
|
217
229
|
}
|
|
218
|
-
async function
|
|
230
|
+
async function M({
|
|
219
231
|
api: e,
|
|
220
232
|
options: t
|
|
221
233
|
}) {
|
|
@@ -226,24 +238,24 @@ async function W({
|
|
|
226
238
|
referenceNumber: t.transaction.referenceNumber
|
|
227
239
|
})).sessionID;
|
|
228
240
|
}
|
|
229
|
-
async function
|
|
241
|
+
async function Y({
|
|
230
242
|
api: e,
|
|
231
243
|
sessionID: t
|
|
232
244
|
}) {
|
|
233
245
|
const a = await e.getSession(t);
|
|
234
|
-
return { session: a, sessionPromoted:
|
|
246
|
+
return { session: a, sessionPromoted: E(a) };
|
|
235
247
|
}
|
|
236
|
-
function
|
|
248
|
+
function $(e) {
|
|
237
249
|
return {
|
|
238
250
|
sessionID: e.sessionID,
|
|
239
251
|
merchantName: e.merchantName,
|
|
240
|
-
alreadyPromoted:
|
|
252
|
+
alreadyPromoted: E(e)
|
|
241
253
|
};
|
|
242
254
|
}
|
|
243
|
-
function
|
|
255
|
+
function E(e) {
|
|
244
256
|
return !!e.transactionID;
|
|
245
257
|
}
|
|
246
|
-
async function
|
|
258
|
+
async function B({
|
|
247
259
|
api: e,
|
|
248
260
|
transactionID: t
|
|
249
261
|
}) {
|
|
@@ -255,7 +267,7 @@ async function Y({
|
|
|
255
267
|
return console.error("Failed to resolve the session transaction:", a), null;
|
|
256
268
|
}
|
|
257
269
|
}
|
|
258
|
-
function
|
|
270
|
+
function h(e) {
|
|
259
271
|
if (!e)
|
|
260
272
|
return;
|
|
261
273
|
let t;
|
|
@@ -266,7 +278,7 @@ function m(e) {
|
|
|
266
278
|
}
|
|
267
279
|
return t.protocol === "https:" || t.protocol === "http:" ? e : void 0;
|
|
268
280
|
}
|
|
269
|
-
function
|
|
281
|
+
function _({
|
|
270
282
|
message: e,
|
|
271
283
|
reason: t,
|
|
272
284
|
shouldEndCheckout: a,
|
|
@@ -282,11 +294,11 @@ function $({
|
|
|
282
294
|
// Only a failure that ends the checkout carries a redirect. A retryable one
|
|
283
295
|
// leaves the customer mid-flow with something still to do, and a host that
|
|
284
296
|
// navigated on it would eject them on a hiccup.
|
|
285
|
-
redirectURL: a ?
|
|
297
|
+
redirectURL: a ? h(o == null ? void 0 : o.failureURL) : void 0
|
|
286
298
|
}
|
|
287
299
|
};
|
|
288
300
|
}
|
|
289
|
-
const
|
|
301
|
+
const G = {
|
|
290
302
|
"common.cancelTransaction": "Cancel Transaction",
|
|
291
303
|
"common.cancel": "Cancel",
|
|
292
304
|
"common.back": "Back",
|
|
@@ -507,40 +519,40 @@ const B = {
|
|
|
507
519
|
"validation.customerDetailsMissing": "Customer details are missing.",
|
|
508
520
|
"validation.invalidOtp": "Please enter a valid 6-digit code.",
|
|
509
521
|
"terms.notice": 'By continuing, you agree to Lydian <a href="https://lydian.com/privacy" target="_blank" rel="noopener noreferrer">Terms and Conditions</a> and understand your data will be processed according to the <a href="https://lydian.com/privacy" target="_blank" rel="noopener noreferrer">Privacy Notice</a>.'
|
|
510
|
-
}, f = { en:
|
|
511
|
-
let D =
|
|
512
|
-
function
|
|
522
|
+
}, f = { en: G }, v = "en";
|
|
523
|
+
let D = v;
|
|
524
|
+
function ne() {
|
|
513
525
|
return D;
|
|
514
526
|
}
|
|
515
|
-
function
|
|
527
|
+
function N(e, t) {
|
|
516
528
|
var n;
|
|
517
|
-
const a = ((n = f[D]) == null ? void 0 : n[e]) ?? f[
|
|
529
|
+
const a = ((n = f[D]) == null ? void 0 : n[e]) ?? f[v][e] ?? e;
|
|
518
530
|
return t ? a.replace(
|
|
519
531
|
/\{(\w+)\}/g,
|
|
520
532
|
(o, r) => t[r] != null ? String(t[r]) : `{${r}}`
|
|
521
533
|
) : a;
|
|
522
534
|
}
|
|
523
|
-
function
|
|
535
|
+
function q(e) {
|
|
524
536
|
return e === u.SUCCESS ? "succeeded" : e < u.PENDING && e !== u.KYC_VERIFICATION_PENDING && e !== u.COMPLIANCE_PENDING ? "failed" : "active";
|
|
525
537
|
}
|
|
526
|
-
function
|
|
538
|
+
function H({
|
|
527
539
|
transaction: e,
|
|
528
540
|
session: t
|
|
529
541
|
}) {
|
|
530
542
|
var o, r, s;
|
|
531
|
-
const a =
|
|
543
|
+
const a = q(e.status);
|
|
532
544
|
if (a === "active")
|
|
533
545
|
return null;
|
|
534
546
|
if (a === "failed")
|
|
535
547
|
return {
|
|
536
548
|
outcome: a,
|
|
537
|
-
message:
|
|
549
|
+
message: N("errors.paymentCouldNotComplete"),
|
|
538
550
|
failure: {
|
|
539
551
|
shouldEndCheckout: !0,
|
|
540
552
|
// Negative (non-KYC) status — cancelled / fraud / timeout.
|
|
541
553
|
reason: "blocked",
|
|
542
554
|
transactionID: e.transactionID,
|
|
543
|
-
redirectURL:
|
|
555
|
+
redirectURL: h(t == null ? void 0 : t.failureURL)
|
|
544
556
|
}
|
|
545
557
|
};
|
|
546
558
|
const n = (o = e.payments) == null ? void 0 : o.find(
|
|
@@ -560,7 +572,7 @@ function q({
|
|
|
560
572
|
asset: n == null ? void 0 : n.cryptoAsset,
|
|
561
573
|
network: n == null ? void 0 : n.cryptoNetwork,
|
|
562
574
|
completedAt: n == null ? void 0 : n.completedAt,
|
|
563
|
-
redirectURL:
|
|
575
|
+
redirectURL: h(t == null ? void 0 : t.successURL)
|
|
564
576
|
}
|
|
565
577
|
};
|
|
566
578
|
}
|
|
@@ -570,7 +582,7 @@ function K() {
|
|
|
570
582
|
setOptions: (t) => {
|
|
571
583
|
e = t;
|
|
572
584
|
},
|
|
573
|
-
emit: (t, a) =>
|
|
585
|
+
emit: (t, a) => T(e == null ? void 0 : e.onEvent, t, a),
|
|
574
586
|
paymentFailed: (t, a) => {
|
|
575
587
|
var n;
|
|
576
588
|
return (n = e == null ? void 0 : e.paymentFailedListener) == null ? void 0 : n.call(e, t, a);
|
|
@@ -585,7 +597,7 @@ function K() {
|
|
|
585
597
|
}
|
|
586
598
|
};
|
|
587
599
|
}
|
|
588
|
-
class
|
|
600
|
+
class j extends HTMLElement {
|
|
589
601
|
constructor() {
|
|
590
602
|
super(), this.engine = null, this.engineLoadPromise = null, this.isTornDown = !1, this.shadow = this.attachShadow({ mode: "open" });
|
|
591
603
|
}
|
|
@@ -595,7 +607,7 @@ class G extends HTMLElement {
|
|
|
595
607
|
this.isTornDown = !1;
|
|
596
608
|
}
|
|
597
609
|
async initialize(t) {
|
|
598
|
-
const a =
|
|
610
|
+
const a = z(t), n = J({ api: a, options: t }), o = await this.loadEngine(t, n);
|
|
599
611
|
!o || this.isTornDown || (this.engine = o, await o.initialize(t, { api: a, sessionLoad: n }));
|
|
600
612
|
}
|
|
601
613
|
async loadEngine(t, a) {
|
|
@@ -623,7 +635,7 @@ class G extends HTMLElement {
|
|
|
623
635
|
// Not started in the constructor: a page can carry the tag and never check out.
|
|
624
636
|
// Overlapping initialize() calls share one download.
|
|
625
637
|
getOrLoadEngine() {
|
|
626
|
-
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-
|
|
638
|
+
return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-0u7my-Xz.js").then((t) => t.m).then((t) => {
|
|
627
639
|
const a = t.mountCheckoutEngine({
|
|
628
640
|
host: this,
|
|
629
641
|
shadowRoot: this.shadow
|
|
@@ -658,7 +670,7 @@ class G extends HTMLElement {
|
|
|
658
670
|
return;
|
|
659
671
|
const o = K();
|
|
660
672
|
o.setOptions(t);
|
|
661
|
-
const r = n.ok && n.linkedTransaction ?
|
|
673
|
+
const r = n.ok && n.linkedTransaction ? H({
|
|
662
674
|
transaction: n.linkedTransaction,
|
|
663
675
|
session: n.session
|
|
664
676
|
}) : null;
|
|
@@ -674,7 +686,7 @@ class G extends HTMLElement {
|
|
|
674
686
|
}), o.paymentFailed(r.message, r.failure);
|
|
675
687
|
return;
|
|
676
688
|
}
|
|
677
|
-
const s =
|
|
689
|
+
const s = N("errors.checkoutUnavailable"), i = _({
|
|
678
690
|
message: s,
|
|
679
691
|
reason: "error",
|
|
680
692
|
shouldEndCheckout: !0,
|
|
@@ -688,82 +700,88 @@ class G extends HTMLElement {
|
|
|
688
700
|
t == null || t.teardown(), t == null || t.unmount(), this.engine = null, this.engineLoadPromise = null;
|
|
689
701
|
}
|
|
690
702
|
}
|
|
691
|
-
function
|
|
703
|
+
function z(e) {
|
|
692
704
|
return new R(
|
|
693
705
|
F(e),
|
|
694
706
|
c(e) ? void 0 : e.publishableKey
|
|
695
707
|
);
|
|
696
708
|
}
|
|
697
|
-
function
|
|
709
|
+
function J({
|
|
698
710
|
api: e,
|
|
699
711
|
options: t
|
|
700
712
|
}) {
|
|
701
|
-
return
|
|
713
|
+
return x({
|
|
702
714
|
api: e,
|
|
703
715
|
options: t,
|
|
704
|
-
emit: (a, n) =>
|
|
716
|
+
emit: (a, n) => T(t.onEvent, a, n)
|
|
705
717
|
});
|
|
706
718
|
}
|
|
707
|
-
customElements.get("lydian-checkout") || customElements.define("lydian-checkout",
|
|
708
|
-
function
|
|
719
|
+
customElements.get("lydian-checkout") || customElements.define("lydian-checkout", j);
|
|
720
|
+
function m() {
|
|
709
721
|
return document.querySelector("lydian-checkout");
|
|
710
722
|
}
|
|
711
|
-
async function
|
|
723
|
+
async function Q(e) {
|
|
712
724
|
if (!e.publishableKey || !e.transaction.amount || !e.transaction.currency)
|
|
713
725
|
throw new Error("SDK initialization requires publishableKey and a transaction");
|
|
714
726
|
const t = P(e);
|
|
715
727
|
if (t)
|
|
716
728
|
throw new Error(t);
|
|
717
|
-
|
|
729
|
+
const a = k(e);
|
|
730
|
+
if (a)
|
|
731
|
+
throw new Error(a);
|
|
732
|
+
if (!A(e.transaction.currency))
|
|
718
733
|
throw new Error("Invalid value for currency, valid values are: " + g.join(", "));
|
|
719
|
-
const
|
|
734
|
+
const n = C({
|
|
720
735
|
options: e,
|
|
721
736
|
unsupportedKeys: ["sessionID"],
|
|
722
737
|
entryPoint: "init"
|
|
723
738
|
});
|
|
724
|
-
if (
|
|
725
|
-
throw new Error(
|
|
726
|
-
await
|
|
739
|
+
if (n)
|
|
740
|
+
throw new Error(n);
|
|
741
|
+
await m().initialize(e);
|
|
727
742
|
}
|
|
728
|
-
async function
|
|
743
|
+
async function Z(e) {
|
|
729
744
|
if (!e.sessionID)
|
|
730
745
|
throw new Error("initExistingSession requires a sessionID");
|
|
731
746
|
const t = P(e);
|
|
732
747
|
if (t)
|
|
733
748
|
throw new Error(t);
|
|
734
|
-
const a =
|
|
749
|
+
const a = k(e);
|
|
750
|
+
if (a)
|
|
751
|
+
throw new Error(a);
|
|
752
|
+
const n = C({
|
|
735
753
|
options: e,
|
|
736
754
|
unsupportedKeys: ["publishableKey", "transaction"],
|
|
737
755
|
entryPoint: "initExistingSession"
|
|
738
756
|
});
|
|
739
|
-
if (
|
|
740
|
-
throw new Error(
|
|
741
|
-
await
|
|
757
|
+
if (n)
|
|
758
|
+
throw new Error(n);
|
|
759
|
+
await m().initialize(e);
|
|
742
760
|
}
|
|
743
|
-
async function
|
|
744
|
-
await
|
|
761
|
+
async function X(e) {
|
|
762
|
+
await m().updateTransaction(e);
|
|
745
763
|
}
|
|
746
|
-
window.Lydian = { init:
|
|
764
|
+
window.Lydian = { init: Q, initExistingSession: Z, updateTransaction: X };
|
|
747
765
|
export {
|
|
748
766
|
O as P,
|
|
749
767
|
u as T,
|
|
750
|
-
|
|
751
|
-
|
|
768
|
+
V as a,
|
|
769
|
+
te as b,
|
|
752
770
|
g as c,
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
771
|
+
Y as d,
|
|
772
|
+
$ as e,
|
|
773
|
+
B as f,
|
|
774
|
+
ne as g,
|
|
757
775
|
c as h,
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
776
|
+
A as i,
|
|
777
|
+
q as j,
|
|
778
|
+
H as k,
|
|
779
|
+
E as l,
|
|
780
|
+
ae as m,
|
|
781
|
+
_ as n,
|
|
782
|
+
ee as o,
|
|
765
783
|
K as p,
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
784
|
+
M as r,
|
|
785
|
+
h as s,
|
|
786
|
+
N as t
|
|
769
787
|
};
|