@worldcoin/idkit 4.0.0-dev.ae2c0a6 → 4.0.1-dev.a1a85c4

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.cjs CHANGED
@@ -202,36 +202,6 @@ function useIDKitRequest(config) {
202
202
  config
203
203
  );
204
204
  }
205
- function assertSessionId(sessionId) {
206
- if (sessionId === void 0) {
207
- return void 0;
208
- }
209
- if (sessionId.trim().length === 0) {
210
- throw idkitCore.IDKitErrorCodes.MalformedRequest;
211
- }
212
- return sessionId;
213
- }
214
- function useIDKitSession(config) {
215
- return useIDKitFlow(() => {
216
- const existingSessionId = assertSessionId(config.existing_session_id);
217
- const builder = existingSessionId ? idkitCore.IDKit.proveSession(existingSessionId, {
218
- app_id: config.app_id,
219
- rp_context: config.rp_context,
220
- action_description: config.action_description,
221
- bridge_url: config.bridge_url,
222
- override_connect_base_url: config.override_connect_base_url,
223
- environment: config.environment
224
- }) : idkitCore.IDKit.createSession({
225
- app_id: config.app_id,
226
- rp_context: config.rp_context,
227
- action_description: config.action_description,
228
- bridge_url: config.bridge_url,
229
- override_connect_base_url: config.override_connect_base_url,
230
- environment: config.environment
231
- });
232
- return builder.preset(config.preset);
233
- }, config);
234
- }
235
205
 
236
206
  // src/styles/widgetStyles.ts
237
207
  var WIDGET_STYLES = `
@@ -528,6 +498,22 @@ var WIDGET_STYLES = `
528
498
  color: var(--idkit-text-secondary);
529
499
  }
530
500
 
501
+ /* Simulator callout (staging only) */
502
+ .idkit-simulator-callout {
503
+ margin: 12px 0 0;
504
+ font-size: 14px;
505
+ color: var(--idkit-text-secondary);
506
+ text-align: center;
507
+ }
508
+ .idkit-simulator-callout a {
509
+ color: var(--idkit-text-muted);
510
+ text-decoration: underline;
511
+ text-underline-offset: 2px;
512
+ }
513
+ .idkit-simulator-callout a:hover {
514
+ color: var(--idkit-text);
515
+ }
516
+
531
517
  /* Mobile deep-link button */
532
518
  .idkit-deeplink-btn {
533
519
  display: flex;
@@ -1186,7 +1172,10 @@ function QRPlaceholderIcon(props) {
1186
1172
  }
1187
1173
  );
1188
1174
  }
1189
- function QRState({ qrData }) {
1175
+ function QRState({
1176
+ qrData,
1177
+ showSimulatorCallout
1178
+ }) {
1190
1179
  const media = useMedia();
1191
1180
  const [copiedLink, setCopiedLink] = react.useState(false);
1192
1181
  const copyLink = react.useCallback(() => {
@@ -1225,13 +1214,27 @@ function QRState({ qrData }) {
1225
1214
  style: { cursor: "pointer" },
1226
1215
  children: /* @__PURE__ */ jsxRuntime.jsx(QRCode, { data: qrData, size: media === "mobile" ? 160 : 200 })
1227
1216
  }
1228
- ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "idkit-qr-placeholder", children: /* @__PURE__ */ jsxRuntime.jsx(QRPlaceholderIcon, {}) }) }) })
1217
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "idkit-qr-placeholder", children: /* @__PURE__ */ jsxRuntime.jsx(QRPlaceholderIcon, {}) }) }) }),
1218
+ showSimulatorCallout && qrData && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "idkit-simulator-callout", children: [
1219
+ "Testing in staging?",
1220
+ " ",
1221
+ /* @__PURE__ */ jsxRuntime.jsx(
1222
+ "a",
1223
+ {
1224
+ href: `https://simulator.worldcoin.org?connect_url=${encodeURIComponent(qrData)}`,
1225
+ target: "_blank",
1226
+ rel: "noopener noreferrer",
1227
+ children: "Use the simulator"
1228
+ }
1229
+ )
1230
+ ] })
1229
1231
  ] })
1230
1232
  ] });
1231
1233
  }
1232
1234
  function WorldIDState({
1233
1235
  connectorURI,
1234
- isAwaitingUserConfirmation
1236
+ isAwaitingUserConfirmation,
1237
+ showSimulatorCallout
1235
1238
  }) {
1236
1239
  const media = useMedia();
1237
1240
  return /* @__PURE__ */ jsxRuntime.jsxs(
@@ -1261,7 +1264,13 @@ function WorldIDState({
1261
1264
  "div",
1262
1265
  {
1263
1266
  className: `idkit-qr-blur ${isAwaitingUserConfirmation ? "blurred" : ""}`,
1264
- children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(QRState, { qrData: connectorURI }) })
1267
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(
1268
+ QRState,
1269
+ {
1270
+ qrData: connectorURI,
1271
+ showSimulatorCallout
1272
+ }
1273
+ ) })
1265
1274
  }
1266
1275
  )
1267
1276
  ] })
@@ -1622,90 +1631,14 @@ function IDKitRequestWidget({
1622
1631
  }
1623
1632
  }, [flow.isSuccess, autoClose, onOpenChange]);
1624
1633
  const stage = getVisualStage(flow.isSuccess, flow.isError);
1634
+ const showSimulatorCallout = config.environment === "staging";
1625
1635
  return /* @__PURE__ */ jsxRuntime.jsxs(IDKitModal, { open, onOpenChange, children: [
1626
1636
  stage === "worldid" && /* @__PURE__ */ jsxRuntime.jsx(
1627
1637
  WorldIDState,
1628
1638
  {
1629
1639
  connectorURI: flow.connectorURI,
1630
- isAwaitingUserConfirmation: flow.isAwaitingUserConfirmation
1631
- }
1632
- ),
1633
- stage === "success" && /* @__PURE__ */ jsxRuntime.jsx(SuccessState, {}),
1634
- stage === "error" && /* @__PURE__ */ jsxRuntime.jsx(
1635
- ErrorState,
1636
- {
1637
- errorCode: flow.errorCode,
1638
- onRetry: () => {
1639
- resetFlow();
1640
- openFlow();
1641
- }
1642
- }
1643
- )
1644
- ] });
1645
- }
1646
- function getVisualStage2(isSuccess, isError) {
1647
- if (isSuccess) {
1648
- return "success";
1649
- }
1650
- if (isError) {
1651
- return "error";
1652
- }
1653
- return "worldid";
1654
- }
1655
- function IDKitSessionWidget({
1656
- open,
1657
- onOpenChange,
1658
- onSuccess,
1659
- onError,
1660
- autoClose = true,
1661
- language,
1662
- ...config
1663
- }) {
1664
- const flow = useIDKitSession(config);
1665
- const { open: openFlow, reset: resetFlow } = flow;
1666
- const lastResultRef = react.useRef(null);
1667
- const lastErrorCodeRef = react.useRef(null);
1668
- react.useEffect(() => {
1669
- if (language) {
1670
- setLocalizationConfig({ language });
1671
- }
1672
- }, [language]);
1673
- react.useEffect(() => {
1674
- if (open) {
1675
- openFlow();
1676
- return;
1677
- }
1678
- resetFlow();
1679
- }, [open, openFlow, resetFlow]);
1680
- react.useEffect(() => {
1681
- if (!flow.result || flow.result === lastResultRef.current) {
1682
- return;
1683
- }
1684
- lastResultRef.current = flow.result;
1685
- void Promise.resolve(onSuccess?.(flow.result)).catch(() => {
1686
- });
1687
- }, [onSuccess, flow.result]);
1688
- react.useEffect(() => {
1689
- if (!flow.errorCode || flow.errorCode === lastErrorCodeRef.current) {
1690
- return;
1691
- }
1692
- lastErrorCodeRef.current = flow.errorCode;
1693
- void Promise.resolve(onError?.(flow.errorCode)).catch(() => {
1694
- });
1695
- }, [flow.errorCode, onError]);
1696
- react.useEffect(() => {
1697
- if (flow.isSuccess && autoClose) {
1698
- const timer = setTimeout(() => onOpenChange(false), 2500);
1699
- return () => clearTimeout(timer);
1700
- }
1701
- }, [flow.isSuccess, autoClose, onOpenChange]);
1702
- const stage = getVisualStage2(flow.isSuccess, flow.isError);
1703
- return /* @__PURE__ */ jsxRuntime.jsxs(IDKitModal, { open, onOpenChange, children: [
1704
- stage === "worldid" && /* @__PURE__ */ jsxRuntime.jsx(
1705
- WorldIDState,
1706
- {
1707
- connectorURI: flow.connectorURI,
1708
- isAwaitingUserConfirmation: flow.isAwaitingUserConfirmation
1640
+ isAwaitingUserConfirmation: flow.isAwaitingUserConfirmation,
1641
+ showSimulatorCallout
1709
1642
  }
1710
1643
  ),
1711
1644
  stage === "success" && /* @__PURE__ */ jsxRuntime.jsx(SuccessState, {}),
@@ -1722,10 +1655,6 @@ function IDKitSessionWidget({
1722
1655
  ] });
1723
1656
  }
1724
1657
 
1725
- Object.defineProperty(exports, "CredentialRequest", {
1726
- enumerable: true,
1727
- get: function () { return idkitCore.CredentialRequest; }
1728
- });
1729
1658
  Object.defineProperty(exports, "IDKit", {
1730
1659
  enumerable: true,
1731
1660
  get: function () { return idkitCore.IDKit; }
@@ -1734,14 +1663,6 @@ Object.defineProperty(exports, "IDKitErrorCodes", {
1734
1663
  enumerable: true,
1735
1664
  get: function () { return idkitCore.IDKitErrorCodes; }
1736
1665
  });
1737
- Object.defineProperty(exports, "all", {
1738
- enumerable: true,
1739
- get: function () { return idkitCore.all; }
1740
- });
1741
- Object.defineProperty(exports, "any", {
1742
- enumerable: true,
1743
- get: function () { return idkitCore.any; }
1744
- });
1745
1666
  Object.defineProperty(exports, "documentLegacy", {
1746
1667
  enumerable: true,
1747
1668
  get: function () { return idkitCore.documentLegacy; }
@@ -1759,8 +1680,6 @@ Object.defineProperty(exports, "signRequest", {
1759
1680
  get: function () { return idkitCore.signRequest; }
1760
1681
  });
1761
1682
  exports.IDKitRequestWidget = IDKitRequestWidget;
1762
- exports.IDKitSessionWidget = IDKitSessionWidget;
1763
1683
  exports.useIDKitRequest = useIDKitRequest;
1764
- exports.useIDKitSession = useIDKitSession;
1765
1684
  //# sourceMappingURL=index.cjs.map
1766
1685
  //# sourceMappingURL=index.cjs.map