@worldcoin/idkit 1.4.2 → 2.0.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.
@@ -31,6 +31,7 @@ var useIDKitStore = createWithEqualityFn()(
31
31
  action_description: "",
32
32
  bridge_url: "",
33
33
  verification_level: DEFAULT_VERIFICATION_LEVEL,
34
+ partner: false,
34
35
  open: false,
35
36
  result: null,
36
37
  errorTitle: "",
@@ -72,6 +73,7 @@ var useIDKitStore = createWithEqualityFn()(
72
73
  signal,
73
74
  action,
74
75
  app_id,
76
+ partner,
75
77
  onError,
76
78
  verification_level,
77
79
  action_description,
@@ -86,7 +88,8 @@ var useIDKitStore = createWithEqualityFn()(
86
88
  action_description,
87
89
  autoClose: autoClose ?? true,
88
90
  app_id: advanced?.self_hosted ? SELF_HOSTED_APP_ID : app_id,
89
- verification_level: verification_level ?? DEFAULT_VERIFICATION_LEVEL
91
+ verification_level: verification_level ?? DEFAULT_VERIFICATION_LEVEL,
92
+ partner
90
93
  });
91
94
  get().addSuccessCallback(onSuccess, source);
92
95
  if (onError) get().addErrorCallback(onError, source);
@@ -36,6 +36,10 @@ type WidgetProps = Config & {
36
36
  children?: ({ open }: {
37
37
  open: () => void;
38
38
  }) => JSX.Element;
39
+ show_modal?: boolean;
40
+ /** Whether to disable the default modal behavior. Defaults to `false`. */
41
+ disable_default_modal_behavior?: boolean;
42
+ container_id?: string;
39
43
  };
40
44
 
41
45
  export { type Config as C, IDKITStage as I, type WidgetProps as W, ConfigSource as a, type CallbackFn as b };
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { C as Config, W as WidgetProps } from './config-Cp9MWjvm.js';
1
+ import { C as Config, W as WidgetProps } from './config-BRFx4nLT.js';
2
2
  import * as react from 'react';
3
3
  export { IErrorState, ISuccessResult, VerificationLevel } from '@worldcoin/idkit-core';
4
4
  export { solidityEncode } from '@worldcoin/idkit-core/hashing';
package/build/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  QRCode_default,
3
3
  __,
4
4
  idkit_default
5
- } from "./chunk-YN64HCS2.js";
5
+ } from "./chunk-5OWPJUHG.js";
6
6
 
7
7
  // src/hooks/useIDKit.ts
8
8
  import { useEffect } from "react";
@@ -23,7 +23,7 @@ var useIDKit = ({ handleVerify, onSuccess } = {}) => {
23
23
  var useIDKit_default = useIDKit;
24
24
 
25
25
  // src/components/IDKitWidget/index.tsx
26
- import { memo as memo2 } from "react";
26
+ import { memo } from "react";
27
27
 
28
28
  // src/components/IDKitWidget/BaseWidget.tsx
29
29
  import root from "react-shadow";
@@ -31,7 +31,13 @@ import root from "react-shadow";
31
31
  // src/hooks/useMedia.ts
32
32
  import { useEffect as useEffect2, useState } from "react";
33
33
  var useMedia = () => {
34
- const [media, setMedia] = useState("desktop");
34
+ const getInitialState = () => {
35
+ if (typeof window !== "undefined") {
36
+ return window.matchMedia("(max-width: 768px)").matches ? "mobile" : "desktop";
37
+ }
38
+ return "desktop";
39
+ };
40
+ const [media, setMedia] = useState(getInitialState());
35
41
  useEffect2(() => {
36
42
  const mql = window.matchMedia("(max-width: 768px)");
37
43
  const handleChange = (mql2) => setMedia(mql2.matches ? "mobile" : "desktop");
@@ -45,6 +51,9 @@ var useMedia = () => {
45
51
  };
46
52
  var useMedia_default = useMedia;
47
53
 
54
+ // src/components/IDKitWidget/BaseWidget.tsx
55
+ import { createPortal } from "react-dom";
56
+
48
57
  // src/styles/styles.css
49
58
  var styles_default = `/* TODO: Use an alternative to avoid the extra request to Google (e.g. hosting ourselves, or local file) */
50
59
  @import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;600;700&family=Sora:wght@600&display=swap');
@@ -651,6 +660,39 @@ select{
651
660
  --tw-contain-paint: ;
652
661
  --tw-contain-style: ;
653
662
  }
663
+ .container{
664
+ width: 100%;
665
+ }
666
+ @media (min-width: 414px){
667
+ .container{
668
+ max-width: 414px;
669
+ }
670
+ }
671
+ @media (min-width: 640px){
672
+ .container{
673
+ max-width: 640px;
674
+ }
675
+ }
676
+ @media (min-width: 768px){
677
+ .container{
678
+ max-width: 768px;
679
+ }
680
+ }
681
+ @media (min-width: 1024px){
682
+ .container{
683
+ max-width: 1024px;
684
+ }
685
+ }
686
+ @media (min-width: 1280px){
687
+ .container{
688
+ max-width: 1280px;
689
+ }
690
+ }
691
+ @media (min-width: 1536px){
692
+ .container{
693
+ max-width: 1536px;
694
+ }
695
+ }
654
696
  .visible{
655
697
  visibility: visible;
656
698
  }
@@ -666,12 +708,12 @@ select{
666
708
  .inset-0{
667
709
  inset: 0;
668
710
  }
669
- .z-10{
670
- z-index: 10;
671
- }
672
711
  .z-50{
673
712
  z-index: 50;
674
713
  }
714
+ .z-\\[9999\\]{
715
+ z-index: 9999;
716
+ }
675
717
  .mx-6{
676
718
  margin-left: 24px;
677
719
  margin-right: 24px;
@@ -716,6 +758,9 @@ select{
716
758
  .mt-4{
717
759
  margin-top: 16px;
718
760
  }
761
+ .inline{
762
+ display: inline;
763
+ }
719
764
  .flex{
720
765
  display: flex;
721
766
  }
@@ -725,6 +770,14 @@ select{
725
770
  .hidden{
726
771
  display: none;
727
772
  }
773
+ .size-11{
774
+ width: 44px;
775
+ height: 44px;
776
+ }
777
+ .size-24{
778
+ width: 96px;
779
+ height: 96px;
780
+ }
728
781
  .size-5{
729
782
  width: 20px;
730
783
  height: 20px;
@@ -740,12 +793,6 @@ select{
740
793
  .h-10{
741
794
  height: 40px;
742
795
  }
743
- .h-24{
744
- height: 96px;
745
- }
746
- .h-5{
747
- height: 20px;
748
- }
749
796
  .min-h-full{
750
797
  min-height: 100%;
751
798
  }
@@ -755,12 +802,6 @@ select{
755
802
  .w-24{
756
803
  width: 96px;
757
804
  }
758
- .w-4{
759
- width: 16px;
760
- }
761
- .w-5{
762
- width: 20px;
763
- }
764
805
  .w-full{
765
806
  width: 100%;
766
807
  }
@@ -804,9 +845,6 @@ select{
804
845
  .justify-between{
805
846
  justify-content: space-between;
806
847
  }
807
- .gap-1{
808
- gap: 4px;
809
- }
810
848
  .space-x-2 > :not([hidden]) ~ :not([hidden]){
811
849
  --tw-space-x-reverse: 0;
812
850
  margin-right: calc(8px * var(--tw-space-x-reverse));
@@ -987,6 +1025,10 @@ select{
987
1025
  --tw-text-opacity: 1;
988
1026
  color: rgb(17 24 39 / var(--tw-text-opacity));
989
1027
  }
1028
+ .text-red-500{
1029
+ --tw-text-opacity: 1;
1030
+ color: rgb(239 68 68 / var(--tw-text-opacity));
1031
+ }
990
1032
  .text-white{
991
1033
  --tw-text-opacity: 1;
992
1034
  color: rgb(255 255 255 / var(--tw-text-opacity));
@@ -1162,6 +1204,22 @@ var XMarkIcon = (props) => /* @__PURE__ */ jsx2("svg", { ...props, xmlns: "http:
1162
1204
  ) });
1163
1205
  var XMarkIcon_default = XMarkIcon;
1164
1206
 
1207
+ // ../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
1208
+ function r(e) {
1209
+ var t, f, n = "";
1210
+ if ("string" == typeof e || "number" == typeof e) n += e;
1211
+ else if ("object" == typeof e) if (Array.isArray(e)) {
1212
+ var o = e.length;
1213
+ for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
1214
+ } else for (f in e) e[f] && (n && (n += " "), n += f);
1215
+ return n;
1216
+ }
1217
+ function clsx() {
1218
+ for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
1219
+ return n;
1220
+ }
1221
+ var clsx_default = clsx;
1222
+
1165
1223
  // src/components/Icons/ErrorIcon.tsx
1166
1224
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
1167
1225
  var ErrorIcon = (props) => /* @__PURE__ */ jsxs("svg", { ...props, xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 100 100", children: [
@@ -1312,7 +1370,7 @@ var ERROR_MESSAGES = {
1312
1370
  "There was a problem with this request. Please try again or contact the app owner."
1313
1371
  ),
1314
1372
  [AppErrorCodes.InvalidNetwork]: __(
1315
- "Invalid network. If you are the app owner, visit docs.worldcoin.org/test for details."
1373
+ "Invalid network. If you are the app owner, visit docs.world.org/test for details."
1316
1374
  ),
1317
1375
  [AppErrorCodes.InclusionProofFailed]: __("There was an issue fetching your credential. Please try again."),
1318
1376
  [AppErrorCodes.InclusionProofPending]: __(
@@ -1322,10 +1380,11 @@ var ERROR_MESSAGES = {
1322
1380
  [AppErrorCodes.UnexpectedResponse]: __("Unexpected response from your wallet. Please try again."),
1323
1381
  [AppErrorCodes.FailedByHostApp]: __("Verification failed by the app. Please contact the app owner for details.")
1324
1382
  };
1325
- var ErrorState = () => {
1383
+ var ErrorState = (props) => {
1326
1384
  const { retryFlow, errorState } = idkit_default(getParams);
1385
+ const { show_modal } = props;
1327
1386
  return /* @__PURE__ */ jsxs3("div", { className: "space-y-8", children: [
1328
- /* @__PURE__ */ jsx6("div", { className: "-mt-5 flex items-center justify-center", children: errorState?.code == AppErrorCodes.VerificationRejected ? /* @__PURE__ */ jsx6(WarningIcon_default, { className: "w-24" }) : /* @__PURE__ */ jsx6(ErrorIcon_default, { className: "w-24" }) }),
1387
+ /* @__PURE__ */ jsx6("div", { className: clsx_default("flex items-center justify-center", show_modal ? "-mt-5" : ""), children: errorState?.code == AppErrorCodes.VerificationRejected ? /* @__PURE__ */ jsx6(WarningIcon_default, { className: "w-24" }) : /* @__PURE__ */ jsx6(ErrorIcon_default, { className: "w-24" }) }),
1329
1388
  /* @__PURE__ */ jsxs3("div", { children: [
1330
1389
  /* @__PURE__ */ jsx6("p", { className: "text-center text-2xl font-semibold text-gray-900 dark:text-white", children: (errorState?.code && ERROR_TITLES[errorState.code]) ?? ERROR_TITLES[AppErrorCodes.GenericError] }),
1331
1390
  /* @__PURE__ */ jsx6("p", { className: "mx-auto mt-2 max-w-[224px] text-center text-657080", children: errorState?.message ?? ERROR_MESSAGES[errorState?.code ?? AppErrorCodes.GenericError] })
@@ -1337,7 +1396,7 @@ var ErrorState = () => {
1337
1396
  onClick: retryFlow,
1338
1397
  className: "inline-flex items-center rounded-lg border border-ebecef bg-transparent px-8 py-3 font-medium text-3c424b shadow-sm transition duration-300 hover:shadow focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-40",
1339
1398
  children: [
1340
- /* @__PURE__ */ jsx6(ReloadIcon_default, { className: "mr-1.5 h-5 w-5" }),
1399
+ /* @__PURE__ */ jsx6(ReloadIcon_default, { className: "mr-1.5 size-5" }),
1341
1400
  __("Try Again")
1342
1401
  ]
1343
1402
  }
@@ -1414,9 +1473,9 @@ var CheckIcon_default = CheckIcon;
1414
1473
 
1415
1474
  // src/components/IDKitWidget/States/SuccessState.tsx
1416
1475
  import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
1417
- var SuccessState = () => {
1476
+ var SuccessState = (props) => {
1418
1477
  return /* @__PURE__ */ jsxs5("div", { className: "space-y-6", children: [
1419
- /* @__PURE__ */ jsx8("div", { className: "-mt-5 flex items-center justify-center", children: /* @__PURE__ */ jsx8(CheckIcon_default, { className: "w-24 text-white" }) }),
1478
+ /* @__PURE__ */ jsx8("div", { className: clsx_default("flex items-center justify-center", props.show_modal ? "-mt-5" : ""), children: /* @__PURE__ */ jsx8(CheckIcon_default, { className: "w-24 text-white" }) }),
1420
1479
  /* @__PURE__ */ jsxs5("div", { children: [
1421
1480
  /* @__PURE__ */ jsx8("p", { className: "text-center text-2xl font-semibold text-gray-900 dark:text-white", children: __("Successfully verified") }),
1422
1481
  /* @__PURE__ */ jsx8("p", { className: "mx-auto mt-2 max-w-[224px] text-center text-lg text-657080", children: __("Your World ID verification was successful") })
@@ -1425,22 +1484,6 @@ var SuccessState = () => {
1425
1484
  };
1426
1485
  var SuccessState_default = SuccessState;
1427
1486
 
1428
- // ../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
1429
- function r(e) {
1430
- var t, f, n = "";
1431
- if ("string" == typeof e || "number" == typeof e) n += e;
1432
- else if ("object" == typeof e) if (Array.isArray(e)) {
1433
- var o = e.length;
1434
- for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
1435
- } else for (f in e) e[f] && (n && (n += " "), n += f);
1436
- return n;
1437
- }
1438
- function clsx() {
1439
- for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
1440
- return n;
1441
- }
1442
- var clsx_default = clsx;
1443
-
1444
1487
  // src/components/IDKitWidget/States/WorldID/QRState.tsx
1445
1488
  import copy from "copy-to-clipboard";
1446
1489
  import { useCallback, useState as useState2 } from "react";
@@ -1678,7 +1721,7 @@ import { useEffect as useEffect4, useState as useState3 } from "react";
1678
1721
  // src/services/wld-bridge.ts
1679
1722
  import { useEffect as useEffect3, useRef } from "react";
1680
1723
  import { useWorldBridgeStore } from "@worldcoin/idkit-core";
1681
- var useWorldBridge = (app_id, action, signal, bridge_url, verification_level, action_description) => {
1724
+ var useWorldBridge = (app_id, action, signal, bridge_url, verification_level, action_description, partner) => {
1682
1725
  const ref_verification_level = useRef(verification_level);
1683
1726
  const { reset, result, connectorURI, createClient, pollForUpdates, verificationState, errorCode } = useWorldBridgeStore();
1684
1727
  useEffect3(() => {
@@ -1689,10 +1732,21 @@ var useWorldBridge = (app_id, action, signal, bridge_url, verification_level, ac
1689
1732
  signal,
1690
1733
  bridge_url,
1691
1734
  action_description,
1692
- verification_level: ref_verification_level.current
1735
+ verification_level: ref_verification_level.current,
1736
+ partner
1693
1737
  });
1694
1738
  }
1695
- }, [app_id, action, signal, action_description, createClient, ref_verification_level, bridge_url, connectorURI]);
1739
+ }, [
1740
+ app_id,
1741
+ action,
1742
+ signal,
1743
+ action_description,
1744
+ createClient,
1745
+ ref_verification_level,
1746
+ bridge_url,
1747
+ connectorURI,
1748
+ partner
1749
+ ]);
1696
1750
  useEffect3(() => {
1697
1751
  if (!connectorURI || result || errorCode) return;
1698
1752
  const interval = setInterval(() => void pollForUpdates(), 3e3);
@@ -1737,9 +1791,11 @@ var getOptions = (store) => ({
1737
1791
  handleVerify: store.handleVerify,
1738
1792
  setErrorState: store.setErrorState,
1739
1793
  verification_level: store.verification_level,
1740
- action_description: store.action_description
1794
+ action_description: store.action_description,
1795
+ partner: store.partner
1741
1796
  });
1742
- var WorldIDState = () => {
1797
+ var WorldIDState = (props) => {
1798
+ const media = useMedia_default();
1743
1799
  const [showQR, setShowQR] = useState3(false);
1744
1800
  const {
1745
1801
  app_id,
@@ -1750,7 +1806,8 @@ var WorldIDState = () => {
1750
1806
  bridge_url,
1751
1807
  action_description,
1752
1808
  verification_level,
1753
- setErrorState
1809
+ setErrorState,
1810
+ partner
1754
1811
  } = idkit_default(getOptions, shallow);
1755
1812
  const { connectorURI, reset, errorCode, result, verificationState } = useWorldBridge(
1756
1813
  app_id,
@@ -1758,7 +1815,8 @@ var WorldIDState = () => {
1758
1815
  signal,
1759
1816
  bridge_url,
1760
1817
  verification_level,
1761
- action_description
1818
+ action_description,
1819
+ partner
1762
1820
  );
1763
1821
  useEffect4(() => reset, [reset]);
1764
1822
  useEffect4(() => {
@@ -1767,10 +1825,8 @@ var WorldIDState = () => {
1767
1825
  setErrorState({ code: errorCode ?? AppErrorCodes2.GenericError });
1768
1826
  }
1769
1827
  if (result) {
1770
- if (verification_level == VerificationLevel.Orb && result.verification_level == VerificationLevel.Device) {
1771
- console.error(
1772
- "Credential type received from wallet does not match configured credential_types. This should only happen when manually selecting disallowed credentials in the Worldcoin Simulator."
1773
- );
1828
+ if (verification_level === VerificationLevel.Orb && result.verification_level === VerificationLevel.Device) {
1829
+ console.error("Credential type received from wallet does not match configured credential_types.");
1774
1830
  setStage("ERROR" /* ERROR */);
1775
1831
  setErrorState({ code: AppErrorCodes2.CredentialUnavailable });
1776
1832
  return;
@@ -1778,29 +1834,43 @@ var WorldIDState = () => {
1778
1834
  return handleVerify(result);
1779
1835
  }
1780
1836
  }, [result, handleVerify, verificationState, setStage, errorCode, setErrorState, verification_level]);
1781
- return /* @__PURE__ */ jsxs9("div", { className: clsx_default("-mt-6 space-y-5", { "space-y-10": !showQR }), children: [
1782
- /* @__PURE__ */ jsxs9("div", { children: [
1783
- /* @__PURE__ */ jsx13("div", { className: "mb-4 flex items-center justify-center", children: /* @__PURE__ */ jsx13(WorldcoinIcon_default, { className: "h-10 text-0d151d dark:text-white" }) }),
1784
- /* @__PURE__ */ jsx13("p", { className: "text-center font-sora text-2xl font-semibold text-gray-900 dark:text-white", children: __("Verify with World ID") }),
1785
- /* @__PURE__ */ jsx13("p", { className: "mt-3 text-center text-657080 dark:text-9eafc0 md:mt-2", children: "Please use your World App to scan the QR code" })
1786
- ] }),
1787
- /* @__PURE__ */ jsxs9("div", { className: "relative", children: [
1788
- verificationState == VerificationState.WaitingForApp && /* @__PURE__ */ jsxs9("div", { className: "absolute inset-0 flex flex-col items-center justify-center space-y-6", children: [
1789
- /* @__PURE__ */ jsx13(LoadingIcon_default, { className: "size-6" }),
1790
- /* @__PURE__ */ jsxs9("div", { children: [
1791
- /* @__PURE__ */ jsx13("p", { className: "font-bold text-657080", children: "Verifying" }),
1792
- /* @__PURE__ */ jsx13("p", { className: "text-sm text-657080", children: "Please continue in app" })
1837
+ const { show_modal } = props;
1838
+ return /* @__PURE__ */ jsxs9(
1839
+ "div",
1840
+ {
1841
+ className: clsx_default(
1842
+ "flex flex-col items-center text-center",
1843
+ show_modal ? showQR ? "-mt-6 space-y-5 " : "-mt-6 space-y-10 " : ""
1844
+ ),
1845
+ children: [
1846
+ /* @__PURE__ */ jsxs9("div", { className: clsx_default(!show_modal ? "hidden" : ""), children: [
1847
+ /* @__PURE__ */ jsx13("div", { className: "mb-4 flex items-center justify-center", children: /* @__PURE__ */ jsx13(WorldcoinIcon_default, { className: "h-10 text-0d151d dark:text-white" }) }),
1848
+ /* @__PURE__ */ jsx13("p", { className: "font-sora text-2xl font-semibold text-gray-900 dark:text-white", children: __("Verify with World ID") }),
1849
+ /* @__PURE__ */ jsx13("p", { className: clsx_default("mt-3 text-657080 dark:text-9eafc0 md:mt-2", { hidden: media === "mobile" }), children: "Please use your World App to scan the QR code" })
1850
+ ] }),
1851
+ /* @__PURE__ */ jsxs9("div", { className: "relative w-full", children: [
1852
+ verificationState === VerificationState.WaitingForApp && /* @__PURE__ */ jsxs9("div", { className: "absolute inset-0 flex flex-col items-center justify-center space-y-6", children: [
1853
+ /* @__PURE__ */ jsx13(LoadingIcon_default, { className: "size-6" }),
1854
+ /* @__PURE__ */ jsxs9("div", { children: [
1855
+ /* @__PURE__ */ jsx13("p", { className: "font-bold text-657080", children: "Verifying" }),
1856
+ /* @__PURE__ */ jsx13("p", { className: "text-sm text-657080", children: "Please continue in app" }),
1857
+ /* @__PURE__ */ jsx13("p", { className: clsx_default(show_modal ? "" : "hidden", "mt-2 text-sm font-bold text-red-500"), children: "Don't close this window" })
1858
+ ] })
1859
+ ] }),
1860
+ /* @__PURE__ */ jsx13(
1861
+ "div",
1862
+ {
1863
+ className: clsx_default(
1864
+ "transition duration-500 ease-in-out",
1865
+ verificationState === VerificationState.WaitingForApp && "opacity-40 blur-lg"
1866
+ ),
1867
+ children: /* @__PURE__ */ jsx13("div", { className: "mx-auto", children: /* @__PURE__ */ jsx13(QRState_default, { showQR, setShowQR, qrData: connectorURI }) })
1868
+ }
1869
+ )
1793
1870
  ] })
1794
- ] }),
1795
- /* @__PURE__ */ jsx13(
1796
- "div",
1797
- {
1798
- className: verificationState === VerificationState.WaitingForApp ? "opacity-40 blur-lg transition duration-500 ease-in-out" : "transition duration-500 ease-in-out",
1799
- children: /* @__PURE__ */ jsx13(QRState_default, { showQR, setShowQR, qrData: connectorURI })
1800
- }
1801
- )
1802
- ] })
1803
- ] });
1871
+ ]
1872
+ }
1873
+ );
1804
1874
  };
1805
1875
  var WorldIDState_default = WorldIDState;
1806
1876
 
@@ -1810,15 +1880,14 @@ import { Fragment as Fragment2, useEffect as useEffect5, useMemo } from "react";
1810
1880
  import { AnimatePresence as AnimatePresence2, motion as motion2 } from "framer-motion";
1811
1881
 
1812
1882
  // src/components/IDKitWidget/States/HostAppVerificationState.tsx
1813
- import { memo } from "react";
1814
1883
  import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
1815
1884
  var HostAppVerificationState = () => {
1816
1885
  return /* @__PURE__ */ jsxs10("div", { className: "space-y-6", children: [
1817
- /* @__PURE__ */ jsx14("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx14(LoadingIcon_default, { className: "h-24 w-24" }) }),
1886
+ /* @__PURE__ */ jsx14("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx14(LoadingIcon_default, { className: "size-24" }) }),
1818
1887
  /* @__PURE__ */ jsx14("div", { className: "mt-4 text-70868f", children: __("Transmitting verification to host app. Please wait...") })
1819
1888
  ] });
1820
1889
  };
1821
- var HostAppVerificationState_default = memo(HostAppVerificationState);
1890
+ var HostAppVerificationState_default = HostAppVerificationState;
1822
1891
 
1823
1892
  // src/components/IDKitWidget/BaseWidget.tsx
1824
1893
  import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
@@ -1830,7 +1899,13 @@ var getParams2 = ({ open, processing, onOpenChange, stage, setStage, setOptions
1830
1899
  isOpen: open,
1831
1900
  onOpenChange
1832
1901
  });
1833
- var IDKitWidget = ({ children, ...config }) => {
1902
+ var IDKitWidget = ({
1903
+ children,
1904
+ show_modal = true,
1905
+ container_id,
1906
+ disable_default_modal_behavior = false,
1907
+ ...config
1908
+ }) => {
1834
1909
  const media = useMedia_default();
1835
1910
  const { isOpen, onOpenChange, stage, setOptions } = idkit_default(getParams2, shallow2);
1836
1911
  useEffect5(() => {
@@ -1842,22 +1917,48 @@ var IDKitWidget = ({ children, ...config }) => {
1842
1917
  const StageContent = useMemo(() => {
1843
1918
  switch (stage) {
1844
1919
  case "WORLD_ID" /* WORLD_ID */:
1845
- return WorldIDState_default;
1920
+ return /* @__PURE__ */ jsx15(WorldIDState_default, { show_modal });
1846
1921
  case "SUCCESS" /* SUCCESS */:
1847
- return SuccessState_default;
1922
+ return /* @__PURE__ */ jsx15(SuccessState_default, {});
1848
1923
  case "ERROR" /* ERROR */:
1849
- return ErrorState_default;
1924
+ return /* @__PURE__ */ jsx15(ErrorState_default, {});
1850
1925
  case "HOST_APP_VERIFICATION" /* HOST_APP_VERIFICATION */:
1851
- return HostAppVerificationState_default;
1926
+ return /* @__PURE__ */ jsx15(HostAppVerificationState_default, {});
1852
1927
  default:
1853
1928
  throw new Error(__("Invalid IDKitStage :stage.", { stage }));
1854
1929
  }
1855
- }, [stage]);
1930
+ }, [stage, show_modal]);
1931
+ const widgetContent = /* @__PURE__ */ jsxs11(root.div, { mode: "open", id: "idkit-widget", children: [
1932
+ /* @__PURE__ */ jsx15(Styles_default, {}),
1933
+ /* @__PURE__ */ jsxs11(Toast.Provider, { children: [
1934
+ /* @__PURE__ */ jsx15(Toast.Viewport, { className: "flex justify-center" }),
1935
+ /* @__PURE__ */ jsx15(
1936
+ "div",
1937
+ {
1938
+ id: "widget-content-inline",
1939
+ className: "relative flex flex-col bg-white p-4 focus:outline-none dark:bg-0d151d",
1940
+ children: StageContent
1941
+ }
1942
+ )
1943
+ ] })
1944
+ ] });
1945
+ if (!show_modal && container_id) {
1946
+ const containerElement = document.getElementById(container_id);
1947
+ if (containerElement) {
1948
+ return createPortal(widgetContent, containerElement);
1949
+ }
1950
+ console.warn(`Container element with id "${container_id}" not found. Rendering widget inline.`);
1951
+ }
1952
+ const avoidDefaultDomBehavior = (e) => {
1953
+ if (disable_default_modal_behavior) {
1954
+ e.preventDefault();
1955
+ }
1956
+ };
1856
1957
  return /* @__PURE__ */ jsxs11(Dialog.Root, { open: isOpen, onOpenChange, children: [
1857
1958
  children?.({ open: () => onOpenChange(true) }),
1858
1959
  /* @__PURE__ */ jsx15(Dialog.Portal, { forceMount: true, children: /* @__PURE__ */ jsx15(Fragment2, { children: /* @__PURE__ */ jsx15(AnimatePresence2, { children: isOpen && /* @__PURE__ */ jsxs11(root.div, { mode: "open", id: "idkit-widget", children: [
1859
1960
  /* @__PURE__ */ jsx15(Styles_default, {}),
1860
- /* @__PURE__ */ jsxs11("div", { id: "modal", className: "fixed z-10 font-sans", children: [
1961
+ /* @__PURE__ */ jsxs11("div", { id: "modal", className: "fixed z-[9999] font-sans", children: [
1861
1962
  /* @__PURE__ */ jsx15(Dialog.Overlay, { asChild: true, children: /* @__PURE__ */ jsx15(
1862
1963
  motion2.div,
1863
1964
  {
@@ -1867,53 +1968,46 @@ var IDKitWidget = ({ children, ...config }) => {
1867
1968
  className: "fixed inset-0 bg-black/50 backdrop-blur-lg"
1868
1969
  }
1869
1970
  ) }),
1870
- /* @__PURE__ */ jsx15("div", { className: "fixed inset-0 z-10 overflow-y-hidden md:overflow-y-auto", children: /* @__PURE__ */ jsx15("div", { className: "flex min-h-full items-end justify-center text-center md:items-center md:p-4", children: /* @__PURE__ */ jsx15(Dialog.Content, { asChild: true, children: /* @__PURE__ */ jsx15(
1871
- motion2.div,
1971
+ /* @__PURE__ */ jsx15("div", { className: "fixed inset-0 z-[9999] overflow-y-hidden md:overflow-y-auto", children: /* @__PURE__ */ jsx15("div", { className: "flex min-h-full items-end justify-center text-center md:items-center md:p-4", children: /* @__PURE__ */ jsx15(
1972
+ Dialog.Content,
1872
1973
  {
1873
- layout: media == "mobile" ? "position" : true,
1874
- exit: media == "mobile" ? "initMob" : "init",
1875
- initial: media == "mobile" ? "initMob" : "init",
1876
- animate: media == "mobile" ? "animateMob" : "animate",
1877
- variants: {
1878
- init: { opacity: 0, scale: 0.9 },
1879
- initMob: { translateY: "100%" },
1880
- animate: { opacity: 1, scale: 1 },
1881
- animateMob: { translateY: 0 }
1882
- },
1883
- transition: { layout: { duration: 0.15 } },
1884
- className: "relative z-50 flex min-h-screen w-full flex-col bg-white pt-6 shadow focus:outline-none focus-visible:ring focus-visible:ring-purple-500/75 dark:bg-0d151d md:min-h-[35rem] md:max-w-md md:rounded-2xl",
1885
- children: /* @__PURE__ */ jsxs11(Toast.Provider, { children: [
1886
- /* @__PURE__ */ jsx15(Toast.Viewport, { className: "flex justify-center" }),
1887
- /* @__PURE__ */ jsx15("div", { className: "mx-6 mb-12 flex items-center justify-between", children: /* @__PURE__ */ jsx15(Dialog.Close, { className: "flex items-center justify-center rounded-full text-black dark:text-white", children: /* @__PURE__ */ jsx15(XMarkIcon_default, { className: "size-5" }) }) }),
1888
- /* @__PURE__ */ jsx15("div", { className: "relative mx-6 mb-6 flex flex-1 flex-col items-center justify-center", children: /* @__PURE__ */ jsx15(StageContent, {}) }),
1889
- /* @__PURE__ */ jsxs11("div", { className: "flex items-center justify-between border-t border-f5f5f7 p-7 md:rounded-b-2xl", children: [
1890
- /* @__PURE__ */ jsxs11(
1891
- "a",
1892
- {
1893
- href: "https://worldcoin.org/world-id",
1894
- target: "_blank",
1895
- rel: "noreferrer",
1896
- className: "flex items-center gap-1 text-sm text-9eafc0",
1897
- children: [
1898
- /* @__PURE__ */ jsx15(WorldcoinIcon_default, { className: "w-4 text-9eafc0 dark:text-white" }),
1899
- /* @__PURE__ */ jsx15("span", { children: __("Powered by Worldcoin") })
1900
- ]
1901
- }
1902
- ),
1903
- /* @__PURE__ */ jsx15(
1904
- "a",
1905
- {
1906
- href: "https://developer.worldcoin.org/privacy-statement",
1907
- target: "_blank",
1908
- rel: "noreferrer",
1909
- className: "text-sm text-9eafc0 hover:underline",
1910
- children: __("Terms & Privacy")
1911
- }
1912
- )
1913
- ] })
1914
- ] })
1974
+ asChild: true,
1975
+ onPointerDownOutside: avoidDefaultDomBehavior,
1976
+ onInteractOutside: avoidDefaultDomBehavior,
1977
+ children: /* @__PURE__ */ jsx15(
1978
+ motion2.div,
1979
+ {
1980
+ layout: media == "mobile" ? "position" : true,
1981
+ exit: media == "mobile" ? "initMob" : "init",
1982
+ initial: media == "mobile" ? "initMob" : "init",
1983
+ animate: media == "mobile" ? "animateMob" : "animate",
1984
+ variants: {
1985
+ init: { opacity: 0, scale: 0.9 },
1986
+ initMob: { translateY: "100%" },
1987
+ animate: { opacity: 1, scale: 1 },
1988
+ animateMob: { translateY: 0 }
1989
+ },
1990
+ transition: { layout: { duration: 0.15 } },
1991
+ className: "relative z-50 flex min-h-screen w-full flex-col bg-white pt-6 shadow focus:outline-none focus-visible:ring focus-visible:ring-purple-500/75 dark:bg-0d151d md:min-h-[35rem] md:max-w-md md:rounded-2xl",
1992
+ children: /* @__PURE__ */ jsxs11(Toast.Provider, { children: [
1993
+ /* @__PURE__ */ jsx15(Toast.Viewport, { className: "flex justify-center" }),
1994
+ /* @__PURE__ */ jsx15("div", { className: "mx-6 mb-12 flex items-center justify-between", children: /* @__PURE__ */ jsx15(Dialog.Close, { className: "flex size-11 items-center justify-center rounded-full text-black dark:text-white", children: /* @__PURE__ */ jsx15(XMarkIcon_default, { className: "size-5" }) }) }),
1995
+ /* @__PURE__ */ jsx15("div", { className: "relative mx-6 mb-6 flex flex-1 flex-col items-center justify-center", children: StageContent }),
1996
+ /* @__PURE__ */ jsx15("div", { className: "flex items-center justify-center border-t border-f5f5f7 p-7 md:rounded-b-2xl", children: /* @__PURE__ */ jsx15(
1997
+ "a",
1998
+ {
1999
+ href: "https://developer.worldcoin.org/privacy-statement",
2000
+ target: "_blank",
2001
+ rel: "noreferrer",
2002
+ className: "text-sm text-657080 hover:underline",
2003
+ children: __("Terms & Privacy")
2004
+ }
2005
+ ) })
2006
+ ] })
2007
+ }
2008
+ )
1915
2009
  }
1916
- ) }) }) })
2010
+ ) }) })
1917
2011
  ] })
1918
2012
  ] }) }) }) })
1919
2013
  ] });
@@ -1921,7 +2015,7 @@ var IDKitWidget = ({ children, ...config }) => {
1921
2015
  var BaseWidget_default = IDKitWidget;
1922
2016
 
1923
2017
  // src/components/IDKitWidget/index.tsx
1924
- var IDKitWidget_default = memo2(BaseWidget_default);
2018
+ var IDKitWidget_default = memo(BaseWidget_default);
1925
2019
 
1926
2020
  // src/index.ts
1927
2021
  import { VerificationLevel as VerificationLevel2 } from "@worldcoin/idkit-core";
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import * as zustand_traditional from 'zustand/traditional';
3
3
  import * as zustand_vanilla from 'zustand/vanilla';
4
- import { I as IDKITStage, a as ConfigSource, b as CallbackFn, C as Config } from './config-Cp9MWjvm.js';
4
+ import { I as IDKITStage, a as ConfigSource, b as CallbackFn, C as Config } from './config-BRFx4nLT.js';
5
5
  import { IDKitConfig, ISuccessResult, IErrorState } from '@worldcoin/idkit-core';
6
6
 
7
7
  type CleanWord<T> = T extends `${string}${' ' | ',' | '!' | '?' | '.' | '`'}${string}` ? never : T extends '' ? never : T;
@@ -27,6 +27,7 @@ type IDKitStore = {
27
27
  bridge_url?: IDKitConfig['bridge_url'];
28
28
  action_description?: IDKitConfig['action_description'];
29
29
  verification_level: NonNullable<IDKitConfig['verification_level']>;
30
+ partner?: IDKitConfig['partner'];
30
31
  open: boolean;
31
32
  stage: IDKITStage;
32
33
  autoClose: boolean;
package/build/internal.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  QRCode_default,
4
4
  __,
5
5
  idkit_default
6
- } from "./chunk-YN64HCS2.js";
6
+ } from "./chunk-5OWPJUHG.js";
7
7
  export {
8
8
  ConfigSource,
9
9
  QRCode_default as QRCode,
package/package.json CHANGED
@@ -1,60 +1,4 @@
1
1
  {
2
- "name": "@worldcoin/idkit",
3
- "version": "1.4.2",
4
- "homepage": "https://docs.worldcoin.org/id/idkit",
5
- "license": "MIT",
6
- "private": false,
7
- "description": "The identity SDK. Privacy-preserving identity and proof of personhood with World ID.",
8
- "repository": {
9
- "type": "git",
10
- "url": "git+https://github.com/worldcoin/idkit-js",
11
- "directory": "packages/react"
12
- },
13
- "type": "module",
14
- "exports": {
15
- ".": {
16
- "import": "./build/index.js",
17
- "types": "./build/index.d.ts"
18
- },
19
- "./internal": {
20
- "import": "./build/internal.js",
21
- "types": "./build/internal.d.ts"
22
- }
23
- },
24
- "publishConfig": {
25
- "access": "public"
26
- },
27
- "typesVersions": {
28
- "*": {
29
- "internal": [
30
- "./build/internal.d.ts"
31
- ],
32
- "*": [
33
- "./build/*/index.d.ts",
34
- "./build/index.d.ts"
35
- ]
36
- }
37
- },
38
- "main": "src/index.ts",
39
- "types": "src/index.ts",
40
- "engines": {
41
- "node": ">=12.4"
42
- },
43
- "files": [
44
- "build",
45
- "README.md"
46
- ],
47
- "keywords": [
48
- "identity",
49
- "ID",
50
- "web3",
51
- "proof-of-personhood",
52
- "sybil resistance"
53
- ],
54
- "peerDependencies": {
55
- "react": ">18.0.0",
56
- "react-dom": ">18.0.0"
57
- },
58
2
  "dependencies": {
59
3
  "@radix-ui/react-dialog": "^1.1.1",
60
4
  "@radix-ui/react-toast": "^1.2.1",
@@ -64,8 +8,9 @@
64
8
  "qrcode": "^1.5.3",
65
9
  "react-shadow": "^19.1.0",
66
10
  "zustand": "^4.5.4",
67
- "@worldcoin/idkit-core": "1.4.2"
11
+ "@worldcoin/idkit-core": "2.0.0"
68
12
  },
13
+ "description": "The identity SDK. Privacy-preserving identity and proof of personhood with World ID.",
69
14
  "devDependencies": {
70
15
  "@types/node": "18.11.9",
71
16
  "@types/qrcode": "^1.5.5",
@@ -93,10 +38,65 @@
93
38
  "tsup": "^8.1.0",
94
39
  "typescript": "^5.5.3"
95
40
  },
41
+ "engines": {
42
+ "node": ">=12.4"
43
+ },
44
+ "exports": {
45
+ ".": {
46
+ "import": "./build/index.js",
47
+ "types": "./build/index.d.ts"
48
+ },
49
+ "./internal": {
50
+ "import": "./build/internal.js",
51
+ "types": "./build/internal.d.ts"
52
+ }
53
+ },
54
+ "files": [
55
+ "build",
56
+ "README.md"
57
+ ],
58
+ "homepage": "https://docs.worldcoin.org/id/idkit",
59
+ "keywords": [
60
+ "identity",
61
+ "ID",
62
+ "web3",
63
+ "proof-of-personhood",
64
+ "sybil resistance"
65
+ ],
66
+ "license": "MIT",
67
+ "main": "src/index.ts",
68
+ "name": "@worldcoin/idkit",
69
+ "peerDependencies": {
70
+ "react": ">18.0.0",
71
+ "react-dom": ">18.0.0"
72
+ },
73
+ "private": false,
74
+ "publishConfig": {
75
+ "access": "public"
76
+ },
77
+ "repository": {
78
+ "directory": "packages/react",
79
+ "type": "git",
80
+ "url": "git+https://github.com/worldcoin/idkit-js"
81
+ },
82
+ "type": "module",
83
+ "types": "src/index.ts",
84
+ "typesVersions": {
85
+ "*": {
86
+ "*": [
87
+ "./build/*/index.d.ts",
88
+ "./build/index.d.ts"
89
+ ],
90
+ "internal": [
91
+ "./build/internal.d.ts"
92
+ ]
93
+ }
94
+ },
95
+ "version": "2.0.0",
96
96
  "scripts": {
97
- "dev": "tsup --watch",
98
- "lint": "eslint src --ext .ts",
99
97
  "build": "npm run build:css && tsup",
100
- "build:css": "npx tailwindcss -i ./src/styles/styles.css -o ./build/index.css --minify"
98
+ "build:css": "npx tailwindcss -i ./src/styles/styles.css -o ./build/index.css --minify",
99
+ "dev": "tsup --watch",
100
+ "lint": "eslint src --ext .ts"
101
101
  }
102
102
  }