@reclaimprotocol/js-sdk 5.5.0 → 5.6.0-dev.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/index.d.ts CHANGED
@@ -603,10 +603,9 @@ type ReclaimFlowInitOptions = {
603
603
  * that automatically launches the verification flow after they install the app, ensuring
604
604
  * a seamless continuation of the verification process.
605
605
  *
606
- * **Platform Support:** Currently Android only
607
- *
608
- * **Default Behavior:** Opt-in during rollout phase. Will default to `true` for all apps
609
- * once fully released. See: https://blog.reclaimprotocol.org/posts/moving-beyond-google-play-instant
606
+ * **Default Behavior:** Enabled by default for Android. Opt-in during rollout phase for iOS.
607
+ * Will default to `true` for all apps once fully released.
608
+ * See: https://blog.reclaimprotocol.org/posts/moving-beyond-google-play-instant
610
609
  */
611
610
  canUseDeferredDeepLinksFlow?: boolean;
612
611
  /**
@@ -621,6 +620,17 @@ type ReclaimFlowInitOptions = {
621
620
  * @default 'portal'
622
621
  */
623
622
  verificationMode?: 'app' | 'portal';
623
+ /**
624
+ * The deeplink to ios mobile application.
625
+ * Defaults to `reclaimverifier://org.reclaimprotocol.app`.
626
+ */
627
+ iosDeepLinkBaseUrl?: string;
628
+ /**
629
+ * The link to ios app store page.
630
+ * Defaults to Reclaim Verifier's iOS App store page
631
+ * `itms-apps://apps.apple.com/in/app/reclaim-verifier/id6503247508`
632
+ */
633
+ iosAppDownloadUrl?: string;
624
634
  };
625
635
  type ReclaimFlowLaunchOptions = ReclaimFlowInitOptions & {
626
636
  /**
@@ -1469,6 +1479,7 @@ declare class ReclaimProofRequest {
1469
1479
  private showQRCodeModal;
1470
1480
  private redirectToInstantApp;
1471
1481
  private redirectToAppClip;
1482
+ private redirectToiOSApp;
1472
1483
  /**
1473
1484
  * Returns the provider id and exact version of the provider that was used in the verification session of this request.
1474
1485
  *
package/dist/index.js CHANGED
@@ -84,7 +84,7 @@ var require_package = __commonJS({
84
84
  "package.json"(exports2, module2) {
85
85
  module2.exports = {
86
86
  name: "@reclaimprotocol/js-sdk",
87
- version: "5.5.0",
87
+ version: "5.6.0-dev.0",
88
88
  description: "Designed to request proofs from the Reclaim protocol and manage the flow of claims and witness interactions.",
89
89
  main: "dist/index.js",
90
90
  types: "dist/index.d.ts",
@@ -3242,8 +3242,8 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3242
3242
  template = replaceAll(template, ")", "%29");
3243
3243
  return template;
3244
3244
  }
3245
- buildSharePageUrl(template) {
3246
- return `${this.appSharePageUrl}/?template=${template}`;
3245
+ buildSharePageUrl(template, url) {
3246
+ return `${url != null ? url : this.appSharePageUrl}/?template=${template}`;
3247
3247
  }
3248
3248
  openPortalTab(templateData, preOpenedTab) {
3249
3249
  return __async(this, null, function* () {
@@ -3549,11 +3549,11 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3549
3549
  }
3550
3550
  } else if (deviceType === "mobile" /* MOBILE */) {
3551
3551
  if (mode === "app") {
3552
- if (((_d = this.options) == null ? void 0 : _d.useAppClip) && getMobileDeviceType() === "ios" /* IOS */) {
3553
- logger11.info("Redirecting to iOS app clip");
3554
- this.redirectToAppClip();
3552
+ if ((((_d = this.options) == null ? void 0 : _d.useAppClip) || options.canUseDeferredDeepLinksFlow) && getMobileDeviceType() === "ios" /* IOS */) {
3553
+ logger11.info("Redirecting for iOS");
3554
+ yield this.redirectToiOSApp(options);
3555
3555
  } else {
3556
- logger11.info("Redirecting to share page");
3556
+ logger11.info("Redirecting for android");
3557
3557
  yield this.redirectToInstantApp(options);
3558
3558
  }
3559
3559
  } else {
@@ -3652,7 +3652,7 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3652
3652
  const template = this.encodeTemplateData(this.templateData);
3653
3653
  let instantAppUrl = this.buildSharePageUrl(template);
3654
3654
  logger11.info("Redirecting to Android instant app: " + instantAppUrl);
3655
- const isDeferredDeeplinksFlowEnabled = (_a = options.canUseDeferredDeepLinksFlow) != null ? _a : false;
3655
+ const isDeferredDeeplinksFlowEnabled = (_a = options.canUseDeferredDeepLinksFlow) != null ? _a : true;
3656
3656
  if (isDeferredDeeplinksFlowEnabled) {
3657
3657
  instantAppUrl = instantAppUrl.replace("/verifier", "/link");
3658
3658
  const deepLink = `intent://details?id=org.reclaimprotocol.app&url=${encodeURIComponent(
@@ -3721,6 +3721,69 @@ var ReclaimProofRequest = class _ReclaimProofRequest {
3721
3721
  throw error;
3722
3722
  }
3723
3723
  }
3724
+ redirectToiOSApp(options) {
3725
+ return __async(this, null, function* () {
3726
+ var _a;
3727
+ try {
3728
+ logger11.info("Preparing to launch for iOS app: ", options);
3729
+ const isDeferredDeeplinksFlowEnabled = (_a = options.canUseDeferredDeepLinksFlow) != null ? _a : false;
3730
+ if (!isDeferredDeeplinksFlowEnabled) {
3731
+ return this.redirectToAppClip();
3732
+ }
3733
+ const template = this.encodeTemplateData(this.templateData);
3734
+ const defaultiOSDeepLinkUrlBase = "reclaimverifier://org.reclaimprotocol.app";
3735
+ const deepLink = this.buildSharePageUrl(
3736
+ template,
3737
+ options.iosDeepLinkBaseUrl || defaultiOSDeepLinkUrlBase
3738
+ );
3739
+ const iosAppInstallUrl = options.iosAppDownloadUrl || "itms-apps://apps.apple.com/in/app/reclaim-verifier/id6503247508";
3740
+ logger11.info("Redirecting to iOS app: " + deepLink, "or store: ", iosAppInstallUrl);
3741
+ try {
3742
+ window.navigator.clipboard.writeText(deepLink).catch(() => {
3743
+ console.error("We can't access the clipboard. Please copy this link and open Reclaim Verifier app.");
3744
+ });
3745
+ let appInstalled = false;
3746
+ let timeoutId;
3747
+ const iframe = document.createElement("iframe");
3748
+ iframe.style.display = "none";
3749
+ iframe.style.width = "1px";
3750
+ iframe.style.height = "1px";
3751
+ document.body.appendChild(iframe);
3752
+ const cleanup = () => {
3753
+ if (iframe.parentNode) {
3754
+ document.body.removeChild(iframe);
3755
+ }
3756
+ if (timeoutId) {
3757
+ clearTimeout(timeoutId);
3758
+ }
3759
+ };
3760
+ const onVisibilityChange = () => {
3761
+ if (document.hidden) {
3762
+ logger11.info("App maybe installed, document hidden");
3763
+ appInstalled = true;
3764
+ cleanup();
3765
+ window.location.href = deepLink;
3766
+ }
3767
+ };
3768
+ document.addEventListener("visibilitychange", onVisibilityChange, { once: true });
3769
+ iframe.src = deepLink;
3770
+ timeoutId = setTimeout(() => {
3771
+ document.removeEventListener("visibilitychange", onVisibilityChange);
3772
+ cleanup();
3773
+ if (!appInstalled) {
3774
+ window.location.href = iosAppInstallUrl;
3775
+ }
3776
+ }, 1500);
3777
+ } catch (e) {
3778
+ console.error("something went wrong during launch, opening store", e);
3779
+ window.location.href = iosAppInstallUrl;
3780
+ }
3781
+ } catch (error) {
3782
+ logger11.info("Error redirecting to instant app:", error);
3783
+ throw error;
3784
+ }
3785
+ });
3786
+ }
3724
3787
  /**
3725
3788
  * Returns the provider id and exact version of the provider that was used in the verification session of this request.
3726
3789
  *