@paypay/mini-app-js-sdk 2.38.0 → 2.40.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/client/clientFunctions/index.d.ts +2 -0
- package/dist/client/clientFunctions/storageFunctions.d.ts +22 -0
- package/dist/client/clientFunctions/urlFunctions.d.ts +1 -0
- package/dist/client/clientUtils.d.ts +1 -4
- package/dist/client/index.d.ts +3 -0
- package/dist/client/supportedFunctionsList.d.ts +1 -1
- package/dist/core/coreUtils.d.ts +8 -0
- package/dist/environment-variables.d.ts +1 -0
- package/dist/mini-app-api.d.ts +1 -2
- package/dist/mini-app-js-sdk.browser.js +1 -1
- package/dist/mini-app-js-sdk.es.js +285 -655
- package/dist/resources/images.d.ts +1 -0
- package/dist/resources/locales/topup/index.d.ts +48 -0
- package/dist/resources/locales/topup/ja.d.ts +24 -0
- package/dist/types.d.ts +0 -10
- package/dist/utils/fetch.d.ts +2 -2
- package/dist/utils/helper.d.ts +2 -0
- package/dist/utils/minimumAppVersion.d.ts +0 -1
- package/dist/utils/minimumJSSDKVersion.d.ts +2 -0
- package/package.json +1 -1
- package/dist/model/bridge/logAppsFlyerEvent.d.ts +0 -2
- package/dist/utils/remoteString.d.ts +0 -6
|
@@ -274,7 +274,6 @@ const miniAppSupportedFunctions = [
|
|
|
274
274
|
"getKycPassportInfo",
|
|
275
275
|
"shortcutExists",
|
|
276
276
|
"addShortcut",
|
|
277
|
-
"logAppsFlyerEvent",
|
|
278
277
|
"getAllUserAddresses",
|
|
279
278
|
"getUserPaymentFeatureSettings",
|
|
280
279
|
"getPaymentSettings",
|
|
@@ -346,372 +345,12 @@ function v4(options, buf, offset) {
|
|
|
346
345
|
}
|
|
347
346
|
return stringify(rnds);
|
|
348
347
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const expression = /(^\s*(((\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5])\.){3}(\d|[1-9]\d|1\d{2}|2[0-4]\d|25[0-5]))\s*$)/;
|
|
354
|
-
return expression.test(hostName);
|
|
355
|
-
}
|
|
356
|
-
function isIPv6(hostName) {
|
|
357
|
-
const expression = /(^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$)/;
|
|
358
|
-
return expression.test(hostName);
|
|
359
|
-
}
|
|
360
|
-
const secondaryList = [
|
|
361
|
-
"ab.ca",
|
|
362
|
-
"ac.ac",
|
|
363
|
-
"ac.ae",
|
|
364
|
-
"ac.at",
|
|
365
|
-
"ac.be",
|
|
366
|
-
"ac.cn",
|
|
367
|
-
"ac.il",
|
|
368
|
-
"ac.in",
|
|
369
|
-
"ac.jp",
|
|
370
|
-
"ac.kr",
|
|
371
|
-
"ac.th",
|
|
372
|
-
"ac.uk",
|
|
373
|
-
"ac.sg",
|
|
374
|
-
"ad.jp",
|
|
375
|
-
"adm.br",
|
|
376
|
-
"adv.br",
|
|
377
|
-
"ah.cn",
|
|
378
|
-
"am.br",
|
|
379
|
-
"arq.br",
|
|
380
|
-
"art.br",
|
|
381
|
-
"arts.ro",
|
|
382
|
-
"asn.au",
|
|
383
|
-
"asso.fr",
|
|
384
|
-
"asso.mc",
|
|
385
|
-
"bc.ca",
|
|
386
|
-
"bio.br",
|
|
387
|
-
"biz.pl",
|
|
388
|
-
"biz.tr",
|
|
389
|
-
"bj.cn",
|
|
390
|
-
"bel.tr",
|
|
391
|
-
"br.com",
|
|
392
|
-
"cn.com",
|
|
393
|
-
"cng.br",
|
|
394
|
-
"cnt.br",
|
|
395
|
-
"co.ac",
|
|
396
|
-
"co.at",
|
|
397
|
-
"co.de",
|
|
398
|
-
"co.gl",
|
|
399
|
-
"co.hk",
|
|
400
|
-
"co.id",
|
|
401
|
-
"co.il",
|
|
402
|
-
"co.in",
|
|
403
|
-
"co.jp",
|
|
404
|
-
"co.kr",
|
|
405
|
-
"co.mg",
|
|
406
|
-
"co.ms",
|
|
407
|
-
"co.nz",
|
|
408
|
-
"co.th",
|
|
409
|
-
"cp.tz",
|
|
410
|
-
"co.uk",
|
|
411
|
-
"co.ve",
|
|
412
|
-
"co.vi",
|
|
413
|
-
"co.za",
|
|
414
|
-
"com.ag",
|
|
415
|
-
"com.ai",
|
|
416
|
-
"com.ar",
|
|
417
|
-
"com.au",
|
|
418
|
-
"com.br",
|
|
419
|
-
"com.co",
|
|
420
|
-
"com.cn",
|
|
421
|
-
"com.cy",
|
|
422
|
-
"com.de",
|
|
423
|
-
"com.do",
|
|
424
|
-
"com.ec",
|
|
425
|
-
"com.es",
|
|
426
|
-
"com.fj",
|
|
427
|
-
"com.fr",
|
|
428
|
-
"com.gl",
|
|
429
|
-
"com.gt",
|
|
430
|
-
"com.hk",
|
|
431
|
-
"com.hr",
|
|
432
|
-
"com.hu",
|
|
433
|
-
"com.kg",
|
|
434
|
-
"com.ki",
|
|
435
|
-
"com.lc",
|
|
436
|
-
"com.mg",
|
|
437
|
-
"com.mm",
|
|
438
|
-
"com.ms",
|
|
439
|
-
"com.mt",
|
|
440
|
-
"com.mu",
|
|
441
|
-
"com.mx",
|
|
442
|
-
"com.my",
|
|
443
|
-
"com.na",
|
|
444
|
-
"com.nf",
|
|
445
|
-
"com.ng",
|
|
446
|
-
"com.ni",
|
|
447
|
-
"com.pa",
|
|
448
|
-
"com.ph",
|
|
449
|
-
"com.pl",
|
|
450
|
-
"com.pt",
|
|
451
|
-
"com.qa",
|
|
452
|
-
"com.ro",
|
|
453
|
-
"com.ru",
|
|
454
|
-
"com.sb",
|
|
455
|
-
"com.sc",
|
|
456
|
-
"com.sg",
|
|
457
|
-
"com.sv",
|
|
458
|
-
"com.tr",
|
|
459
|
-
"com.tw",
|
|
460
|
-
"com.ua",
|
|
461
|
-
"com.uy",
|
|
462
|
-
"com.ve",
|
|
463
|
-
"com.vn",
|
|
464
|
-
"cq.cn",
|
|
465
|
-
"de.com",
|
|
466
|
-
"de.org",
|
|
467
|
-
"ecn.br",
|
|
468
|
-
"ed.jp",
|
|
469
|
-
"edu.au",
|
|
470
|
-
"edu.cn",
|
|
471
|
-
"edu.hk",
|
|
472
|
-
"edu.mm",
|
|
473
|
-
"edu.my",
|
|
474
|
-
"edu.pl",
|
|
475
|
-
"edu.pt",
|
|
476
|
-
"edu.qa",
|
|
477
|
-
"edu.sg",
|
|
478
|
-
"edu.tr",
|
|
479
|
-
"edu.tw",
|
|
480
|
-
"eng.br",
|
|
481
|
-
"ernet.in",
|
|
482
|
-
"esp.br",
|
|
483
|
-
"etc.br",
|
|
484
|
-
"eti.br",
|
|
485
|
-
"eu.com",
|
|
486
|
-
"eu.int",
|
|
487
|
-
"eu.lv",
|
|
488
|
-
"firm.in",
|
|
489
|
-
"firm.ro",
|
|
490
|
-
"fm.br",
|
|
491
|
-
"fot.br",
|
|
492
|
-
"fst.br",
|
|
493
|
-
"g12.br",
|
|
494
|
-
"gb.com",
|
|
495
|
-
"gb.net",
|
|
496
|
-
"gd.cn",
|
|
497
|
-
"gen.in",
|
|
498
|
-
"go.jp",
|
|
499
|
-
"go.kr",
|
|
500
|
-
"go.th",
|
|
501
|
-
"gov.au",
|
|
502
|
-
"gov.az",
|
|
503
|
-
"gov.br",
|
|
504
|
-
"gov.cn",
|
|
505
|
-
"gov.il",
|
|
506
|
-
"gov.in",
|
|
507
|
-
"gov.mm",
|
|
508
|
-
"gov.my",
|
|
509
|
-
"gov.qa",
|
|
510
|
-
"gov.sg",
|
|
511
|
-
"gov.tr",
|
|
512
|
-
"gov.tw",
|
|
513
|
-
"gov.uk",
|
|
514
|
-
"govt.nz",
|
|
515
|
-
"gr.jp",
|
|
516
|
-
"gs.cn",
|
|
517
|
-
"gv.ac",
|
|
518
|
-
"gv.at",
|
|
519
|
-
"gx.cn",
|
|
520
|
-
"gz.cn",
|
|
521
|
-
"he.cn",
|
|
522
|
-
"hi.cn",
|
|
523
|
-
"hk.cn",
|
|
524
|
-
"hl.cn",
|
|
525
|
-
"hu.com",
|
|
526
|
-
"id.au",
|
|
527
|
-
"idv.tw",
|
|
528
|
-
"in.ua",
|
|
529
|
-
"in.th",
|
|
530
|
-
"ind.br",
|
|
531
|
-
"ind.in",
|
|
532
|
-
"inf.br",
|
|
533
|
-
"info.pl",
|
|
534
|
-
"info.ro",
|
|
535
|
-
"info.tr",
|
|
536
|
-
"info.ve",
|
|
537
|
-
"iwi.nz",
|
|
538
|
-
"jl.cn",
|
|
539
|
-
"jor.br",
|
|
540
|
-
"js.cn",
|
|
541
|
-
"jus.br",
|
|
542
|
-
"k12.il",
|
|
543
|
-
"k12.tr",
|
|
544
|
-
"kr.com",
|
|
545
|
-
"lel.br",
|
|
546
|
-
"lg.jp",
|
|
547
|
-
"ln.cn",
|
|
548
|
-
"ltd.uk",
|
|
549
|
-
"mb.ca",
|
|
550
|
-
"me.uk",
|
|
551
|
-
"med.br",
|
|
552
|
-
"mi.th",
|
|
553
|
-
"mil.br",
|
|
554
|
-
"mil.uk",
|
|
555
|
-
"mo.cn",
|
|
556
|
-
"mod.uk",
|
|
557
|
-
"muni.il",
|
|
558
|
-
"nb.ca",
|
|
559
|
-
"ne.jp",
|
|
560
|
-
"ne.kr",
|
|
561
|
-
"net.ag",
|
|
562
|
-
"net.ai",
|
|
563
|
-
"net.au",
|
|
564
|
-
"net.br",
|
|
565
|
-
"net.cn",
|
|
566
|
-
"net.do",
|
|
567
|
-
"net.gl",
|
|
568
|
-
"net.hk",
|
|
569
|
-
"net.il",
|
|
570
|
-
"net.in",
|
|
571
|
-
"net.kg",
|
|
572
|
-
"net.ki",
|
|
573
|
-
"net.lc",
|
|
574
|
-
"net.mg",
|
|
575
|
-
"net.mm",
|
|
576
|
-
"net.mu",
|
|
577
|
-
"net.ni",
|
|
578
|
-
"net.nz",
|
|
579
|
-
"net.pl",
|
|
580
|
-
"net.ru",
|
|
581
|
-
"net.sb",
|
|
582
|
-
"net.sc",
|
|
583
|
-
"net.sg",
|
|
584
|
-
"net.th",
|
|
585
|
-
"net.tr",
|
|
586
|
-
"net.tw",
|
|
587
|
-
"net.uk",
|
|
588
|
-
"net.ve",
|
|
589
|
-
"nf.ca",
|
|
590
|
-
"nhs.uk",
|
|
591
|
-
"nm.cn",
|
|
592
|
-
"nm.kr",
|
|
593
|
-
"no.com",
|
|
594
|
-
"nom.br",
|
|
595
|
-
"nom.ni",
|
|
596
|
-
"nom.ro",
|
|
597
|
-
"ns.ca",
|
|
598
|
-
"nt.ca",
|
|
599
|
-
"nt.ro",
|
|
600
|
-
"ntr.br",
|
|
601
|
-
"nx.cn",
|
|
602
|
-
"odo.br",
|
|
603
|
-
"off.ai",
|
|
604
|
-
"on.ca",
|
|
605
|
-
"or.ac",
|
|
606
|
-
"or.at",
|
|
607
|
-
"or.jp",
|
|
608
|
-
"or.kr",
|
|
609
|
-
"or.th",
|
|
610
|
-
"org.ag",
|
|
611
|
-
"org.ai",
|
|
612
|
-
"org.au",
|
|
613
|
-
"org.br",
|
|
614
|
-
"org.cn",
|
|
615
|
-
"org.do",
|
|
616
|
-
"org.es",
|
|
617
|
-
"org.gl",
|
|
618
|
-
"org.hk",
|
|
619
|
-
"org.in",
|
|
620
|
-
"org.kg",
|
|
621
|
-
"org.ki",
|
|
622
|
-
"org.lc",
|
|
623
|
-
"org.mg",
|
|
624
|
-
"org.mm",
|
|
625
|
-
"org.ms",
|
|
626
|
-
"org.nf",
|
|
627
|
-
"org.ng",
|
|
628
|
-
"org.ni",
|
|
629
|
-
"org.nz",
|
|
630
|
-
"org.pl",
|
|
631
|
-
"org.ro",
|
|
632
|
-
"org.ru",
|
|
633
|
-
"org.sb",
|
|
634
|
-
"org.sc",
|
|
635
|
-
"org.sg",
|
|
636
|
-
"org.tr",
|
|
637
|
-
"org.tw",
|
|
638
|
-
"org.uk",
|
|
639
|
-
"org.ve",
|
|
640
|
-
"pe.ca",
|
|
641
|
-
"plc.uk",
|
|
642
|
-
"ppg.br",
|
|
643
|
-
"pro.br",
|
|
644
|
-
"psc.br",
|
|
645
|
-
"psi.br",
|
|
646
|
-
"qc.ca",
|
|
647
|
-
"qc.com",
|
|
648
|
-
"qh.cn",
|
|
649
|
-
"rec.br",
|
|
650
|
-
"rec.ro",
|
|
651
|
-
"res.in",
|
|
652
|
-
"sa.com",
|
|
653
|
-
"sc.cn",
|
|
654
|
-
"sch.uk",
|
|
655
|
-
"se.com",
|
|
656
|
-
"se.net",
|
|
657
|
-
"sh.cn",
|
|
658
|
-
"sk.ca",
|
|
659
|
-
"slg.br",
|
|
660
|
-
"sn.cn",
|
|
661
|
-
"store.ro",
|
|
662
|
-
"tj.cn",
|
|
663
|
-
"tm.fr",
|
|
664
|
-
"tm.mc",
|
|
665
|
-
"tm.ro",
|
|
666
|
-
"tmp.br",
|
|
667
|
-
"tur.br",
|
|
668
|
-
"tv.br",
|
|
669
|
-
"tv.tr",
|
|
670
|
-
"tw.cn",
|
|
671
|
-
"uk.com",
|
|
672
|
-
"uk.net",
|
|
673
|
-
"us.com",
|
|
674
|
-
"uy.com",
|
|
675
|
-
"vet.br",
|
|
676
|
-
"waw.pl",
|
|
677
|
-
"web.ve",
|
|
678
|
-
"www.ro",
|
|
679
|
-
"xj.cn",
|
|
680
|
-
"xz.cn",
|
|
681
|
-
"yk.ca",
|
|
682
|
-
"yn.cn",
|
|
683
|
-
"zj.cn",
|
|
684
|
-
"zlg.br"
|
|
685
|
-
];
|
|
686
|
-
function parseDomain(domain) {
|
|
687
|
-
const splitStr = domain.split(".");
|
|
688
|
-
if (isIP(domain) || splitStr.length <= 2) {
|
|
689
|
-
return domain;
|
|
690
|
-
}
|
|
691
|
-
const secondary = splitStr.slice(splitStr.length - 2).join(".");
|
|
692
|
-
if (secondaryList.includes(secondary) && splitStr.length >= 3) {
|
|
693
|
-
return splitStr.slice(splitStr.length - 3).join(".");
|
|
348
|
+
class PPError extends Error {
|
|
349
|
+
constructor(message, errorCode) {
|
|
350
|
+
super(message);
|
|
351
|
+
this.errorCode = errorCode;
|
|
694
352
|
}
|
|
695
|
-
return splitStr.slice(splitStr.length - 2).join(".");
|
|
696
353
|
}
|
|
697
|
-
function getDomain(subdomainCookieSharing, hostname) {
|
|
698
|
-
return subdomainCookieSharing ? parseDomain(hostname) : hostname;
|
|
699
|
-
}
|
|
700
|
-
const JS_SDK_VERSION = "2.38.0";
|
|
701
|
-
const REVISION = "55465a6";
|
|
702
|
-
const coreBaseUrl = new URL("https://mini-app-sdk-core.paypay.ne.jp/");
|
|
703
|
-
const CORE_IFRAME_ORIGIN = coreBaseUrl.origin;
|
|
704
|
-
const CORE_IFRAME_URL = new URL(
|
|
705
|
-
`./iframe.html?v=${JS_SDK_VERSION}&rev=${REVISION}`,
|
|
706
|
-
coreBaseUrl
|
|
707
|
-
).href;
|
|
708
|
-
const COUPON_IFRAME_URL = new URL(
|
|
709
|
-
`./coupon/iframe.html?v=${JS_SDK_VERSION}`,
|
|
710
|
-
coreBaseUrl
|
|
711
|
-
).href;
|
|
712
|
-
const SENTRY_DSN = "https://377b45f154b1fb17d8e98a6ffb67030a@o4505819519320064.ingest.sentry.io/4506579323453440";
|
|
713
|
-
const GA_API_SECRET = "fgPKRkdQQvq7XbV4qw3MOQ";
|
|
714
|
-
const GA_MEASUREMENT_ID = "G-M64Q2828RR";
|
|
715
354
|
var MiniAppErrorType = /* @__PURE__ */ ((MiniAppErrorType2) => {
|
|
716
355
|
MiniAppErrorType2["success"] = "SUCCESS";
|
|
717
356
|
MiniAppErrorType2["invalidUrl"] = "INVALID_URL";
|
|
@@ -784,6 +423,21 @@ var MiniAppErrorType = /* @__PURE__ */ ((MiniAppErrorType2) => {
|
|
|
784
423
|
MiniAppErrorType2["sdkUpgradeRequired"] = "SDK_UPGRADE_REQUIRED";
|
|
785
424
|
return MiniAppErrorType2;
|
|
786
425
|
})(MiniAppErrorType || {});
|
|
426
|
+
const JS_SDK_VERSION = "2.40.0";
|
|
427
|
+
const REVISION = "e045550";
|
|
428
|
+
const coreBaseUrl = new URL("https://mini-app-sdk-core.paypay.ne.jp/");
|
|
429
|
+
const CORE_IFRAME_ORIGIN = coreBaseUrl.origin;
|
|
430
|
+
const CORE_IFRAME_URL = new URL(
|
|
431
|
+
`./iframe.html?v=${JS_SDK_VERSION}&rev=${REVISION}`,
|
|
432
|
+
coreBaseUrl
|
|
433
|
+
).href;
|
|
434
|
+
const COUPON_IFRAME_URL = new URL(
|
|
435
|
+
`./coupon/iframe.html?v=${JS_SDK_VERSION}`,
|
|
436
|
+
coreBaseUrl
|
|
437
|
+
).href;
|
|
438
|
+
const SENTRY_DSN = "https://377b45f154b1fb17d8e98a6ffb67030a@o4505819519320064.ingest.sentry.io/4506579323453440";
|
|
439
|
+
const GA_API_SECRET = "fgPKRkdQQvq7XbV4qw3MOQ";
|
|
440
|
+
const GA_MEASUREMENT_ID = "G-M64Q2828RR";
|
|
787
441
|
const objectToString = Object.prototype.toString;
|
|
788
442
|
function isBuiltin(wat, className) {
|
|
789
443
|
return objectToString.call(wat) === `[object ${className}]`;
|
|
@@ -2095,7 +1749,7 @@ const errorsToIgnore = [
|
|
|
2095
1749
|
function sendWindowBridgeErrorToSentry(functionName, message, error) {
|
|
2096
1750
|
if (!errorsToIgnore.includes(error) && SENTRY_DSN) {
|
|
2097
1751
|
captureMessage(
|
|
2098
|
-
`windowBridge.${functionName} failed.
|
|
1752
|
+
`windowBridge.${functionName} failed. error: ${error}, message: ${message}`,
|
|
2099
1753
|
"log"
|
|
2100
1754
|
);
|
|
2101
1755
|
}
|
|
@@ -2105,6 +1759,224 @@ function addBreadcrumbToSentry(breadcrumb) {
|
|
|
2105
1759
|
addBreadcrumb(breadcrumb);
|
|
2106
1760
|
}
|
|
2107
1761
|
}
|
|
1762
|
+
class WindowBridge {
|
|
1763
|
+
constructor(functions, allowedOrigins) {
|
|
1764
|
+
this.deferredCallbacks = {};
|
|
1765
|
+
this.functions = functions;
|
|
1766
|
+
this.allowedOrigins = allowedOrigins;
|
|
1767
|
+
this.messageEventHandler = this.messageEventHandler.bind(this);
|
|
1768
|
+
this.subscribeToMessageEvent();
|
|
1769
|
+
}
|
|
1770
|
+
/**
|
|
1771
|
+
* Subscribe to message event to handle incoming messages.
|
|
1772
|
+
* These messages can be of two types
|
|
1773
|
+
* 1. A function call from another window
|
|
1774
|
+
* 2. Response of a function call made from this window to another window
|
|
1775
|
+
*/
|
|
1776
|
+
subscribeToMessageEvent() {
|
|
1777
|
+
window.addEventListener("message", this.messageEventHandler);
|
|
1778
|
+
}
|
|
1779
|
+
/**
|
|
1780
|
+
* Unsubscribe to message event.
|
|
1781
|
+
*/
|
|
1782
|
+
unsubscribeToMessageEvent() {
|
|
1783
|
+
window.removeEventListener("message", this.messageEventHandler);
|
|
1784
|
+
}
|
|
1785
|
+
messageEventHandler(receivedMessageEvent) {
|
|
1786
|
+
var _a;
|
|
1787
|
+
if (!((_a = receivedMessageEvent.data) == null ? void 0 : _a.forWindowBridge)) {
|
|
1788
|
+
return;
|
|
1789
|
+
}
|
|
1790
|
+
if (this.allowedOrigins && !this.allowedOrigins.includes(receivedMessageEvent.origin)) {
|
|
1791
|
+
return this.sendErrorResponse(
|
|
1792
|
+
receivedMessageEvent,
|
|
1793
|
+
`${receivedMessageEvent.origin} is not allowed to make requests`,
|
|
1794
|
+
MiniAppErrorType.originNotAllowed
|
|
1795
|
+
);
|
|
1796
|
+
}
|
|
1797
|
+
if (receivedMessageEvent.data.type === "request") {
|
|
1798
|
+
void this.handleRequest(
|
|
1799
|
+
receivedMessageEvent
|
|
1800
|
+
);
|
|
1801
|
+
} else if (receivedMessageEvent.data.type === "response") {
|
|
1802
|
+
this.handleResponse(
|
|
1803
|
+
receivedMessageEvent
|
|
1804
|
+
);
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
handleRequest(receivedMessageEvent) {
|
|
1808
|
+
return __async(this, null, function* () {
|
|
1809
|
+
const functionName = receivedMessageEvent.data.functionName;
|
|
1810
|
+
const functionToInvoke = this.functions[functionName];
|
|
1811
|
+
if (!functionToInvoke) {
|
|
1812
|
+
this.sendErrorResponse(
|
|
1813
|
+
receivedMessageEvent,
|
|
1814
|
+
`Function '${functionName}' does not exists on the target window`,
|
|
1815
|
+
MiniAppErrorType.functionNotFound
|
|
1816
|
+
);
|
|
1817
|
+
}
|
|
1818
|
+
try {
|
|
1819
|
+
this.sendSuccessResponse(
|
|
1820
|
+
receivedMessageEvent,
|
|
1821
|
+
yield functionToInvoke(...receivedMessageEvent.data.params)
|
|
1822
|
+
);
|
|
1823
|
+
} catch (error) {
|
|
1824
|
+
let message = "Some error ocurred while processing the request";
|
|
1825
|
+
let errorCode = MiniAppErrorType.unknown;
|
|
1826
|
+
if (error instanceof PPError) {
|
|
1827
|
+
message = error.message;
|
|
1828
|
+
errorCode = error.errorCode;
|
|
1829
|
+
}
|
|
1830
|
+
this.sendErrorResponse(receivedMessageEvent, message, errorCode);
|
|
1831
|
+
}
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
handleResponse(receivedMessageEvent) {
|
|
1835
|
+
if (!this.deferredCallbacks[receivedMessageEvent.data.key]) {
|
|
1836
|
+
console.warn(
|
|
1837
|
+
`Callback for ${receivedMessageEvent.data.functionName} not found`
|
|
1838
|
+
);
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1841
|
+
const [resolve, reject] = this.deferredCallbacks[receivedMessageEvent.data.key];
|
|
1842
|
+
delete this.deferredCallbacks[receivedMessageEvent.data.key];
|
|
1843
|
+
if (receivedMessageEvent.data.status === "success") {
|
|
1844
|
+
resolve(receivedMessageEvent.data.result);
|
|
1845
|
+
} else {
|
|
1846
|
+
reject(
|
|
1847
|
+
new PPError(
|
|
1848
|
+
receivedMessageEvent.data.message,
|
|
1849
|
+
receivedMessageEvent.data.errorCode
|
|
1850
|
+
)
|
|
1851
|
+
);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
sendErrorResponse(receivedMessageEvent, message, errorCode) {
|
|
1855
|
+
sendWindowBridgeErrorToSentry(
|
|
1856
|
+
receivedMessageEvent.data.functionName,
|
|
1857
|
+
message,
|
|
1858
|
+
errorCode
|
|
1859
|
+
);
|
|
1860
|
+
this.sendResponse(receivedMessageEvent, {
|
|
1861
|
+
status: "failure",
|
|
1862
|
+
message,
|
|
1863
|
+
errorCode
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
sendSuccessResponse(receivedMessageEvent, result) {
|
|
1867
|
+
this.sendResponse(receivedMessageEvent, {
|
|
1868
|
+
status: "success",
|
|
1869
|
+
result
|
|
1870
|
+
});
|
|
1871
|
+
}
|
|
1872
|
+
sendResponse(receivedMessageEvent, data) {
|
|
1873
|
+
var _a;
|
|
1874
|
+
(_a = receivedMessageEvent.source) == null ? void 0 : _a.postMessage(
|
|
1875
|
+
__spreadValues({
|
|
1876
|
+
forWindowBridge: true,
|
|
1877
|
+
type: "response",
|
|
1878
|
+
key: receivedMessageEvent.data.key,
|
|
1879
|
+
functionName: receivedMessageEvent.data.functionName
|
|
1880
|
+
}, data),
|
|
1881
|
+
// Just a hack to overcome weird function overload mismatch
|
|
1882
|
+
receivedMessageEvent.origin
|
|
1883
|
+
);
|
|
1884
|
+
}
|
|
1885
|
+
/**
|
|
1886
|
+
* A static method to create a new `WindowBridge` instance and enforce singleton pattern
|
|
1887
|
+
* @param functions an objection of functions that can be invoked on the current window
|
|
1888
|
+
* @param allowedOrigins a list of allowed origins from where request can be accepted
|
|
1889
|
+
* @returns `WindowBridge` instance
|
|
1890
|
+
*/
|
|
1891
|
+
static init(functions, allowedOrigins) {
|
|
1892
|
+
if (this._instance) {
|
|
1893
|
+
throw new Error(
|
|
1894
|
+
"WindowBridge already initialized, you can't call WindowBridge.init more than once"
|
|
1895
|
+
);
|
|
1896
|
+
}
|
|
1897
|
+
this._instance = new this(functions, allowedOrigins);
|
|
1898
|
+
return this._instance;
|
|
1899
|
+
}
|
|
1900
|
+
/**
|
|
1901
|
+
* Destroy current WindowBridge instance, being used for testing
|
|
1902
|
+
*/
|
|
1903
|
+
static destroy() {
|
|
1904
|
+
if (this._instance) {
|
|
1905
|
+
this._instance.unsubscribeToMessageEvent();
|
|
1906
|
+
this._instance = void 0;
|
|
1907
|
+
}
|
|
1908
|
+
}
|
|
1909
|
+
/**
|
|
1910
|
+
* A static method to get an existing `WindowBridge` instance
|
|
1911
|
+
* @returns `WindowBridge` instance
|
|
1912
|
+
*/
|
|
1913
|
+
static getBridge() {
|
|
1914
|
+
if (!this._instance) {
|
|
1915
|
+
throw new Error(
|
|
1916
|
+
"WindowBridge not initialized, please call WindowBridge.init before calling WindowBridge.getBridge"
|
|
1917
|
+
);
|
|
1918
|
+
}
|
|
1919
|
+
return this._instance;
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* A static function that returns a proxy object to invoke functions on a target window.
|
|
1923
|
+
* We can call it multiple times to invoke functions on different windows
|
|
1924
|
+
* @param getTargetWindow a function that returns the target window where we want to invoke functions
|
|
1925
|
+
* @param targetWindowOrigin origin of the target window
|
|
1926
|
+
* @returns a proxy object to call functions from target window as an asynchronous function
|
|
1927
|
+
*/
|
|
1928
|
+
static getTargetWindowFunctionProxy(getTargetWindow, targetWindowOrigin) {
|
|
1929
|
+
return WindowBridge.getBridge().getTargetWindowFunctionProxy(
|
|
1930
|
+
getTargetWindow,
|
|
1931
|
+
targetWindowOrigin
|
|
1932
|
+
);
|
|
1933
|
+
}
|
|
1934
|
+
/**
|
|
1935
|
+
* It returns a proxy object to invoke functions on a target window.
|
|
1936
|
+
* We can call it multiple times to invoke functions on different windows
|
|
1937
|
+
* @param getTargetWindow a function that returns the target window where we want to invoke functions
|
|
1938
|
+
* @param targetWindowOrigin origin of the target window
|
|
1939
|
+
* @returns a proxy object to call functions from target window as an asynchronous function
|
|
1940
|
+
*/
|
|
1941
|
+
getTargetWindowFunctionProxy(getTargetWindow, targetWindowOrigin) {
|
|
1942
|
+
return new Proxy(this, {
|
|
1943
|
+
get(windowBridgeInstance, functionName) {
|
|
1944
|
+
return (...params) => (
|
|
1945
|
+
// eslint-disable-next-line no-async-promise-executor, @typescript-eslint/no-misused-promises
|
|
1946
|
+
new Promise((resolve, reject) => __async(this, null, function* () {
|
|
1947
|
+
const functionNameString = functionName.toString();
|
|
1948
|
+
const key = `${functionNameString}--${getRandomString()}`;
|
|
1949
|
+
try {
|
|
1950
|
+
const targetWindow = yield getTargetWindow();
|
|
1951
|
+
if (!targetWindow) {
|
|
1952
|
+
throw new Error("Target window is undefined");
|
|
1953
|
+
}
|
|
1954
|
+
windowBridgeInstance.deferredCallbacks[key] = [resolve, reject];
|
|
1955
|
+
targetWindow.postMessage(
|
|
1956
|
+
{
|
|
1957
|
+
forWindowBridge: true,
|
|
1958
|
+
type: "request",
|
|
1959
|
+
functionName: functionNameString,
|
|
1960
|
+
key,
|
|
1961
|
+
params: JSON.parse(JSON.stringify(params))
|
|
1962
|
+
},
|
|
1963
|
+
targetWindowOrigin
|
|
1964
|
+
);
|
|
1965
|
+
} catch (error) {
|
|
1966
|
+
delete windowBridgeInstance.deferredCallbacks[key];
|
|
1967
|
+
reject(
|
|
1968
|
+
new PPError(
|
|
1969
|
+
error.message,
|
|
1970
|
+
MiniAppErrorType.messageSendingFailed
|
|
1971
|
+
)
|
|
1972
|
+
);
|
|
1973
|
+
}
|
|
1974
|
+
}))
|
|
1975
|
+
);
|
|
1976
|
+
}
|
|
1977
|
+
});
|
|
1978
|
+
}
|
|
1979
|
+
}
|
|
2108
1980
|
let clientId = "";
|
|
2109
1981
|
function getCurrentClientId() {
|
|
2110
1982
|
return clientId;
|
|
@@ -2172,12 +2044,12 @@ function getKeyWithClientId(baseKey, clientId2) {
|
|
|
2172
2044
|
return `${baseKey}.${clientId2 != null ? clientId2 : getCurrentClientId()}`;
|
|
2173
2045
|
}
|
|
2174
2046
|
function saveLocalStorage(key, value) {
|
|
2175
|
-
removeLocalStorage(key);
|
|
2047
|
+
removeLocalStorage$1(key);
|
|
2176
2048
|
if (value) {
|
|
2177
2049
|
return storage.setItem(key, value);
|
|
2178
2050
|
}
|
|
2179
2051
|
}
|
|
2180
|
-
function removeLocalStorage(key) {
|
|
2052
|
+
function removeLocalStorage$1(key) {
|
|
2181
2053
|
storage.removeItem(key);
|
|
2182
2054
|
}
|
|
2183
2055
|
function saveClientUUID(uuid) {
|
|
@@ -2285,38 +2157,14 @@ function getIconUrl(theme) {
|
|
|
2285
2157
|
function convertToString(str) {
|
|
2286
2158
|
return str ? String(str) : "";
|
|
2287
2159
|
}
|
|
2288
|
-
function removeCookie(key, domain) {
|
|
2289
|
-
api.remove(key);
|
|
2290
|
-
api.remove(key, { domain });
|
|
2291
|
-
}
|
|
2292
|
-
function saveRefreshToken(refreshToken, domain, isSecure, clientId2) {
|
|
2293
|
-
let refreshTokenKey = PpLocalStorageKey.refreshToken;
|
|
2294
|
-
if (clientId2) {
|
|
2295
|
-
refreshTokenKey = `${refreshTokenKey}.${clientId2}`;
|
|
2296
|
-
}
|
|
2297
|
-
removeCookie(refreshTokenKey, domain);
|
|
2298
|
-
return api.set(refreshTokenKey, refreshToken, {
|
|
2299
|
-
domain,
|
|
2300
|
-
expires: 90,
|
|
2301
|
-
secure: isSecure
|
|
2302
|
-
});
|
|
2303
|
-
}
|
|
2304
|
-
function saveCodeVerifier(codeVerifier, domain, isSecure, expires) {
|
|
2305
|
-
removeCookie(PpLocalStorageKey.codeVerifier, domain);
|
|
2306
|
-
return api.set(PpLocalStorageKey.codeVerifier, codeVerifier, {
|
|
2307
|
-
domain,
|
|
2308
|
-
secure: isSecure,
|
|
2309
|
-
expires
|
|
2310
|
-
});
|
|
2311
|
-
}
|
|
2312
2160
|
function getRefreshToken(clientId2) {
|
|
2313
2161
|
const refreshTokenWithClientId = api.get(
|
|
2314
2162
|
`${PpLocalStorageKey.refreshToken}.${clientId2}`
|
|
2315
2163
|
);
|
|
2316
2164
|
return refreshTokenWithClientId || api.get(PpLocalStorageKey.refreshToken) || "";
|
|
2317
2165
|
}
|
|
2318
|
-
function getCodeVerifier() {
|
|
2319
|
-
return api.get(PpLocalStorageKey.codeVerifier) || "";
|
|
2166
|
+
function getCodeVerifier(clientId2) {
|
|
2167
|
+
return api.get(`${PpLocalStorageKey.codeVerifier}.${clientId2}`) || api.get(PpLocalStorageKey.codeVerifier) || "";
|
|
2320
2168
|
}
|
|
2321
2169
|
function exposeClientJsBridge(jsBridge) {
|
|
2322
2170
|
if (window.hasOwnProperty(jsBridgeNamespace) && window[jsBridgeNamespace] === jsBridge) {
|
|
@@ -2390,230 +2238,6 @@ var MiniAppStatusType = /* @__PURE__ */ ((MiniAppStatusType2) => {
|
|
|
2390
2238
|
MiniAppStatusType2["connected"] = "CONNECTED";
|
|
2391
2239
|
return MiniAppStatusType2;
|
|
2392
2240
|
})(MiniAppStatusType || {});
|
|
2393
|
-
class PPError extends Error {
|
|
2394
|
-
constructor(message, errorCode) {
|
|
2395
|
-
super(message);
|
|
2396
|
-
this.errorCode = errorCode;
|
|
2397
|
-
}
|
|
2398
|
-
}
|
|
2399
|
-
class WindowBridge {
|
|
2400
|
-
constructor(functions, allowedOrigins) {
|
|
2401
|
-
this.deferredCallbacks = {};
|
|
2402
|
-
this.functions = functions;
|
|
2403
|
-
this.allowedOrigins = allowedOrigins;
|
|
2404
|
-
this.messageEventHandler = this.messageEventHandler.bind(this);
|
|
2405
|
-
this.subscribeToMessageEvent();
|
|
2406
|
-
}
|
|
2407
|
-
/**
|
|
2408
|
-
* Subscribe to message event to handle incoming messages.
|
|
2409
|
-
* These messages can be of two types
|
|
2410
|
-
* 1. A function call from another window
|
|
2411
|
-
* 2. Response of a function call made from this window to another window
|
|
2412
|
-
*/
|
|
2413
|
-
subscribeToMessageEvent() {
|
|
2414
|
-
window.addEventListener("message", this.messageEventHandler);
|
|
2415
|
-
}
|
|
2416
|
-
/**
|
|
2417
|
-
* Unsubscribe to message event.
|
|
2418
|
-
*/
|
|
2419
|
-
unsubscribeToMessageEvent() {
|
|
2420
|
-
window.removeEventListener("message", this.messageEventHandler);
|
|
2421
|
-
}
|
|
2422
|
-
messageEventHandler(receivedMessageEvent) {
|
|
2423
|
-
var _a;
|
|
2424
|
-
if (!((_a = receivedMessageEvent.data) == null ? void 0 : _a.forWindowBridge)) {
|
|
2425
|
-
return;
|
|
2426
|
-
}
|
|
2427
|
-
if (this.allowedOrigins && !this.allowedOrigins.includes(receivedMessageEvent.origin)) {
|
|
2428
|
-
return this.sendErrorResponse(
|
|
2429
|
-
receivedMessageEvent,
|
|
2430
|
-
`${receivedMessageEvent.origin} is not allowed to make requests`,
|
|
2431
|
-
MiniAppErrorType.originNotAllowed
|
|
2432
|
-
);
|
|
2433
|
-
}
|
|
2434
|
-
if (receivedMessageEvent.data.type === "request") {
|
|
2435
|
-
void this.handleRequest(
|
|
2436
|
-
receivedMessageEvent
|
|
2437
|
-
);
|
|
2438
|
-
} else if (receivedMessageEvent.data.type === "response") {
|
|
2439
|
-
this.handleResponse(
|
|
2440
|
-
receivedMessageEvent
|
|
2441
|
-
);
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2444
|
-
handleRequest(receivedMessageEvent) {
|
|
2445
|
-
return __async(this, null, function* () {
|
|
2446
|
-
const functionName = receivedMessageEvent.data.functionName;
|
|
2447
|
-
const functionToInvoke = this.functions[functionName];
|
|
2448
|
-
if (!functionToInvoke) {
|
|
2449
|
-
this.sendErrorResponse(
|
|
2450
|
-
receivedMessageEvent,
|
|
2451
|
-
`Function '${functionName}' does not exists on the target window`,
|
|
2452
|
-
MiniAppErrorType.functionNotFound
|
|
2453
|
-
);
|
|
2454
|
-
}
|
|
2455
|
-
try {
|
|
2456
|
-
this.sendSuccessResponse(
|
|
2457
|
-
receivedMessageEvent,
|
|
2458
|
-
yield functionToInvoke(...receivedMessageEvent.data.params)
|
|
2459
|
-
);
|
|
2460
|
-
} catch (error) {
|
|
2461
|
-
let message = "Some error ocurred while processing the request";
|
|
2462
|
-
let errorCode = MiniAppErrorType.unknown;
|
|
2463
|
-
if (error instanceof PPError) {
|
|
2464
|
-
message = error.message;
|
|
2465
|
-
errorCode = error.errorCode;
|
|
2466
|
-
}
|
|
2467
|
-
this.sendErrorResponse(receivedMessageEvent, message, errorCode);
|
|
2468
|
-
}
|
|
2469
|
-
});
|
|
2470
|
-
}
|
|
2471
|
-
handleResponse(receivedMessageEvent) {
|
|
2472
|
-
if (!this.deferredCallbacks[receivedMessageEvent.data.key]) {
|
|
2473
|
-
console.warn(
|
|
2474
|
-
`Callback for ${receivedMessageEvent.data.functionName} not found`
|
|
2475
|
-
);
|
|
2476
|
-
return;
|
|
2477
|
-
}
|
|
2478
|
-
const [resolve, reject] = this.deferredCallbacks[receivedMessageEvent.data.key];
|
|
2479
|
-
delete this.deferredCallbacks[receivedMessageEvent.data.key];
|
|
2480
|
-
if (receivedMessageEvent.data.status === "success") {
|
|
2481
|
-
resolve(receivedMessageEvent.data.result);
|
|
2482
|
-
} else {
|
|
2483
|
-
reject(
|
|
2484
|
-
new PPError(
|
|
2485
|
-
receivedMessageEvent.data.message,
|
|
2486
|
-
receivedMessageEvent.data.errorCode
|
|
2487
|
-
)
|
|
2488
|
-
);
|
|
2489
|
-
}
|
|
2490
|
-
}
|
|
2491
|
-
sendErrorResponse(receivedMessageEvent, message, errorCode) {
|
|
2492
|
-
sendWindowBridgeErrorToSentry(
|
|
2493
|
-
receivedMessageEvent.data.functionName,
|
|
2494
|
-
message,
|
|
2495
|
-
errorCode
|
|
2496
|
-
);
|
|
2497
|
-
this.sendResponse(receivedMessageEvent, {
|
|
2498
|
-
status: "failure",
|
|
2499
|
-
message,
|
|
2500
|
-
errorCode
|
|
2501
|
-
});
|
|
2502
|
-
}
|
|
2503
|
-
sendSuccessResponse(receivedMessageEvent, result) {
|
|
2504
|
-
this.sendResponse(receivedMessageEvent, {
|
|
2505
|
-
status: "success",
|
|
2506
|
-
result
|
|
2507
|
-
});
|
|
2508
|
-
}
|
|
2509
|
-
sendResponse(receivedMessageEvent, data) {
|
|
2510
|
-
var _a;
|
|
2511
|
-
(_a = receivedMessageEvent.source) == null ? void 0 : _a.postMessage(
|
|
2512
|
-
__spreadValues({
|
|
2513
|
-
forWindowBridge: true,
|
|
2514
|
-
type: "response",
|
|
2515
|
-
key: receivedMessageEvent.data.key,
|
|
2516
|
-
functionName: receivedMessageEvent.data.functionName
|
|
2517
|
-
}, data),
|
|
2518
|
-
// Just a hack to overcome weird function overload mismatch
|
|
2519
|
-
receivedMessageEvent.origin
|
|
2520
|
-
);
|
|
2521
|
-
}
|
|
2522
|
-
/**
|
|
2523
|
-
* A static method to create a new `WindowBridge` instance and enforce singleton pattern
|
|
2524
|
-
* @param functions an objection of functions that can be invoked on the current window
|
|
2525
|
-
* @param allowedOrigins a list of allowed origins from where request can be accepted
|
|
2526
|
-
* @returns `WindowBridge` instance
|
|
2527
|
-
*/
|
|
2528
|
-
static init(functions, allowedOrigins) {
|
|
2529
|
-
if (this._instance) {
|
|
2530
|
-
throw new Error(
|
|
2531
|
-
"WindowBridge already initialized, you can't call WindowBridge.init more than once"
|
|
2532
|
-
);
|
|
2533
|
-
}
|
|
2534
|
-
this._instance = new this(functions, allowedOrigins);
|
|
2535
|
-
return this._instance;
|
|
2536
|
-
}
|
|
2537
|
-
/**
|
|
2538
|
-
* Destroy current WindowBridge instance, being used for testing
|
|
2539
|
-
*/
|
|
2540
|
-
static destroy() {
|
|
2541
|
-
if (this._instance) {
|
|
2542
|
-
this._instance.unsubscribeToMessageEvent();
|
|
2543
|
-
this._instance = void 0;
|
|
2544
|
-
}
|
|
2545
|
-
}
|
|
2546
|
-
/**
|
|
2547
|
-
* A static method to get an existing `WindowBridge` instance
|
|
2548
|
-
* @returns `WindowBridge` instance
|
|
2549
|
-
*/
|
|
2550
|
-
static getBridge() {
|
|
2551
|
-
if (!this._instance) {
|
|
2552
|
-
throw new Error(
|
|
2553
|
-
"WindowBridge not initialized, please call WindowBridge.init before calling WindowBridge.getBridge"
|
|
2554
|
-
);
|
|
2555
|
-
}
|
|
2556
|
-
return this._instance;
|
|
2557
|
-
}
|
|
2558
|
-
/**
|
|
2559
|
-
* A static function that returns a proxy object to invoke functions on a target window.
|
|
2560
|
-
* We can call it multiple times to invoke functions on different windows
|
|
2561
|
-
* @param getTargetWindow a function that returns the target window where we want to invoke functions
|
|
2562
|
-
* @param targetWindowOrigin origin of the target window
|
|
2563
|
-
* @returns a proxy object to call functions from target window as an asynchronous function
|
|
2564
|
-
*/
|
|
2565
|
-
static getTargetWindowFunctionProxy(getTargetWindow, targetWindowOrigin) {
|
|
2566
|
-
return WindowBridge.getBridge().getTargetWindowFunctionProxy(
|
|
2567
|
-
getTargetWindow,
|
|
2568
|
-
targetWindowOrigin
|
|
2569
|
-
);
|
|
2570
|
-
}
|
|
2571
|
-
/**
|
|
2572
|
-
* It returns a proxy object to invoke functions on a target window.
|
|
2573
|
-
* We can call it multiple times to invoke functions on different windows
|
|
2574
|
-
* @param getTargetWindow a function that returns the target window where we want to invoke functions
|
|
2575
|
-
* @param targetWindowOrigin origin of the target window
|
|
2576
|
-
* @returns a proxy object to call functions from target window as an asynchronous function
|
|
2577
|
-
*/
|
|
2578
|
-
getTargetWindowFunctionProxy(getTargetWindow, targetWindowOrigin) {
|
|
2579
|
-
return new Proxy(this, {
|
|
2580
|
-
get(windowBridgeInstance, functionName) {
|
|
2581
|
-
return (...params) => (
|
|
2582
|
-
// eslint-disable-next-line no-async-promise-executor, @typescript-eslint/no-misused-promises
|
|
2583
|
-
new Promise((resolve, reject) => __async(this, null, function* () {
|
|
2584
|
-
const functionNameString = functionName.toString();
|
|
2585
|
-
const key = `${functionNameString}--${getRandomString()}`;
|
|
2586
|
-
try {
|
|
2587
|
-
const targetWindow = yield getTargetWindow();
|
|
2588
|
-
if (!targetWindow) {
|
|
2589
|
-
throw new Error("Target window is undefined");
|
|
2590
|
-
}
|
|
2591
|
-
windowBridgeInstance.deferredCallbacks[key] = [resolve, reject];
|
|
2592
|
-
targetWindow.postMessage(
|
|
2593
|
-
{
|
|
2594
|
-
forWindowBridge: true,
|
|
2595
|
-
type: "request",
|
|
2596
|
-
functionName: functionNameString,
|
|
2597
|
-
key,
|
|
2598
|
-
params: JSON.parse(JSON.stringify(params))
|
|
2599
|
-
},
|
|
2600
|
-
targetWindowOrigin
|
|
2601
|
-
);
|
|
2602
|
-
} catch (error) {
|
|
2603
|
-
delete windowBridgeInstance.deferredCallbacks[key];
|
|
2604
|
-
reject(
|
|
2605
|
-
new PPError(
|
|
2606
|
-
error.message,
|
|
2607
|
-
MiniAppErrorType.messageSendingFailed
|
|
2608
|
-
)
|
|
2609
|
-
);
|
|
2610
|
-
}
|
|
2611
|
-
}))
|
|
2612
|
-
);
|
|
2613
|
-
}
|
|
2614
|
-
});
|
|
2615
|
-
}
|
|
2616
|
-
}
|
|
2617
2241
|
const style = "";
|
|
2618
2242
|
const MinVersion = {
|
|
2619
2243
|
PRE_TRANSACTION_AUTO_CHARGE: "3.43.0",
|
|
@@ -2621,10 +2245,46 @@ const MinVersion = {
|
|
|
2621
2245
|
OS_HOME_SCREEN_ICON: "3.71.0",
|
|
2622
2246
|
START_MULTIFACTOR_AUTH_ANDROID_FIX: "3.67.0",
|
|
2623
2247
|
KYC_PASSPORT: "3.72.0",
|
|
2624
|
-
LOG_APP_FLYER_EVENT: "3.78.0",
|
|
2625
2248
|
PERFORMANCE_MEASUREMENT: "4.47.0",
|
|
2626
2249
|
START_MULTIFACTOR_AUTH_PIN_FALLBACK: "4.63.0"
|
|
2627
2250
|
};
|
|
2251
|
+
function setCookie({ name, value, options }) {
|
|
2252
|
+
return api.set(name, value, options);
|
|
2253
|
+
}
|
|
2254
|
+
function getCookie({ name }) {
|
|
2255
|
+
return api.get(name);
|
|
2256
|
+
}
|
|
2257
|
+
function removeCookie({ name, options }) {
|
|
2258
|
+
return api.remove(name, options);
|
|
2259
|
+
}
|
|
2260
|
+
function setLocalStorage({
|
|
2261
|
+
name,
|
|
2262
|
+
value
|
|
2263
|
+
}) {
|
|
2264
|
+
return localStorage.setItem(name, value);
|
|
2265
|
+
}
|
|
2266
|
+
function getLocalStorage({ name }) {
|
|
2267
|
+
return localStorage.getItem(name);
|
|
2268
|
+
}
|
|
2269
|
+
function removeLocalStorage({ name }) {
|
|
2270
|
+
return localStorage.removeItem(name);
|
|
2271
|
+
}
|
|
2272
|
+
function removeQueryParametersFromUrl(removeParams) {
|
|
2273
|
+
const url2 = new URL(window.location.href);
|
|
2274
|
+
removeParams.forEach((param) => url2.searchParams.delete(param));
|
|
2275
|
+
const newURL = `${url2.pathname}${url2.search}`;
|
|
2276
|
+
history.replaceState(null, "", newURL);
|
|
2277
|
+
}
|
|
2278
|
+
const clientWindowBridgeFunctions = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2279
|
+
__proto__: null,
|
|
2280
|
+
getCookie,
|
|
2281
|
+
getLocalStorage,
|
|
2282
|
+
removeCookie,
|
|
2283
|
+
removeLocalStorage,
|
|
2284
|
+
removeQueryParametersFromUrl,
|
|
2285
|
+
setCookie,
|
|
2286
|
+
setLocalStorage
|
|
2287
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
2628
2288
|
const IFRAME_NAME = "ppmna-iframe";
|
|
2629
2289
|
const IFRAME_CONTAINER_NAME = "ppsdk-container";
|
|
2630
2290
|
let iframeContainer;
|
|
@@ -2705,7 +2365,7 @@ function createIframe() {
|
|
|
2705
2365
|
let useAllFunctions = false;
|
|
2706
2366
|
let clientSdkType;
|
|
2707
2367
|
let initDonePromise;
|
|
2708
|
-
WindowBridge.init(
|
|
2368
|
+
WindowBridge.init(clientWindowBridgeFunctions, [CORE_IFRAME_ORIGIN]);
|
|
2709
2369
|
void getCoreIframe();
|
|
2710
2370
|
function clearInternalInitSyncState() {
|
|
2711
2371
|
initDonePromise = Promise.resolve(false);
|
|
@@ -2741,14 +2401,6 @@ const commonMessageHandler = (e) => {
|
|
|
2741
2401
|
window.location.href = linkOption.url;
|
|
2742
2402
|
}
|
|
2743
2403
|
}
|
|
2744
|
-
if (e.data.name === PPUtilFunctionName.saveRefreshToken) {
|
|
2745
|
-
const { refreshToken, domain, isSecure, clientId: clientId2 } = e.data.data;
|
|
2746
|
-
saveRefreshToken(refreshToken, domain, isSecure, clientId2);
|
|
2747
|
-
}
|
|
2748
|
-
if (e.data.name === PPUtilFunctionName.saveCodeVerifier) {
|
|
2749
|
-
const { codeVerifier, domain, isSecure, expires } = e.data.data;
|
|
2750
|
-
saveCodeVerifier(codeVerifier, domain, isSecure, expires);
|
|
2751
|
-
}
|
|
2752
2404
|
if (e.data.name === PPUtilFunctionName.consoleDebugInfo) {
|
|
2753
2405
|
const { params } = e.data.data;
|
|
2754
2406
|
consoleDebugInfo(params);
|
|
@@ -2765,29 +2417,20 @@ addEventListener("popstate", () => {
|
|
|
2765
2417
|
}).catch((error) => console.warn(error));
|
|
2766
2418
|
});
|
|
2767
2419
|
function init(params) {
|
|
2768
|
-
const url2 = new URL(window.location.href);
|
|
2769
|
-
const token = url2.searchParams.get("token");
|
|
2770
|
-
const ott = url2.searchParams.get("one_time_token");
|
|
2771
2420
|
const refreshToken = getRefreshToken(params.clientId);
|
|
2772
|
-
const codeVerifier = getCodeVerifier();
|
|
2773
|
-
const clientVersion = "2.
|
|
2421
|
+
const codeVerifier = getCodeVerifier(params.clientId);
|
|
2422
|
+
const clientVersion = "2.40.0";
|
|
2774
2423
|
useAllFunctions = !!params.useAllFunctions;
|
|
2775
|
-
if (token || ott) {
|
|
2776
|
-
removeTokenFromUrl(url2);
|
|
2777
|
-
}
|
|
2778
2424
|
const initParams = {
|
|
2779
2425
|
env: params.env,
|
|
2780
2426
|
mode: params.mode,
|
|
2781
2427
|
debugMode: params.debugMode,
|
|
2782
2428
|
clientId: params.clientId,
|
|
2783
|
-
token,
|
|
2784
|
-
ott,
|
|
2785
2429
|
refreshToken,
|
|
2786
2430
|
clientVersion,
|
|
2787
2431
|
codeVerifier,
|
|
2788
2432
|
clientSdkType,
|
|
2789
2433
|
clientUrl: window.location.href
|
|
2790
|
-
// OTT already removed
|
|
2791
2434
|
};
|
|
2792
2435
|
let initDonePromiseResolve;
|
|
2793
2436
|
const nextInitDonePromise = new Promise(
|
|
@@ -3006,13 +2649,7 @@ const logout = promiseToCallback(
|
|
|
3006
2649
|
"logout",
|
|
3007
2650
|
() => __async(void 0, null, function* () {
|
|
3008
2651
|
try {
|
|
3009
|
-
|
|
3010
|
-
const clientDomain = getDomain(
|
|
3011
|
-
subdomainCookieSharing,
|
|
3012
|
-
window.location.hostname
|
|
3013
|
-
);
|
|
3014
|
-
removeCookie(PpLocalStorageKey.refreshToken, clientDomain);
|
|
3015
|
-
removeCookie(PpLocalStorageKey.codeVerifier, clientDomain);
|
|
2652
|
+
yield core.logout();
|
|
3016
2653
|
return { statusCode: MiniAppStatusType.loggedOut };
|
|
3017
2654
|
} catch (error) {
|
|
3018
2655
|
throw new PPError(
|
|
@@ -3079,13 +2716,6 @@ function postMessageToCore(messageData) {
|
|
|
3079
2716
|
);
|
|
3080
2717
|
});
|
|
3081
2718
|
}
|
|
3082
|
-
function removeTokenFromUrl(url2) {
|
|
3083
|
-
url2.searchParams.delete("token");
|
|
3084
|
-
url2.searchParams.delete("one_time_token");
|
|
3085
|
-
url2.search = url2.searchParams.toString();
|
|
3086
|
-
const newURL = url2.toString().replace(url2.origin, "");
|
|
3087
|
-
history.replaceState(null, "", newURL);
|
|
3088
|
-
}
|
|
3089
2719
|
function triggerPostMessageToCore(type, showIframeFlag, params, postMessageParams) {
|
|
3090
2720
|
const messageId = functionStart();
|
|
3091
2721
|
if (showIframeFlag) {
|
|
@@ -3245,8 +2875,8 @@ function executePendingFunctionCalls(client2) {
|
|
|
3245
2875
|
}
|
|
3246
2876
|
}
|
|
3247
2877
|
const clientProperties = {
|
|
3248
|
-
version: "2.
|
|
3249
|
-
revision: "
|
|
2878
|
+
version: "2.40.0",
|
|
2879
|
+
revision: "e045550"
|
|
3250
2880
|
};
|
|
3251
2881
|
function getClient({ sdkType }) {
|
|
3252
2882
|
clientSdkType = sdkType;
|