@worldcoin/idkit 4.0.0-dev.fe98789 → 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/README.md +10 -0
- package/dist/hashing.cjs +12 -0
- package/dist/hashing.cjs.map +1 -0
- package/dist/hashing.d.cts +2 -0
- package/dist/hashing.d.ts +2 -0
- package/dist/hashing.js +3 -0
- package/dist/hashing.js.map +1 -0
- package/dist/index.cjs +50 -129
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -14
- package/dist/index.d.ts +3 -14
- package/dist/index.js +48 -117
- package/dist/index.js.map +1 -1
- package/dist/signing.cjs +12 -0
- package/dist/signing.cjs.map +1 -0
- package/dist/signing.d.cts +1 -0
- package/dist/signing.d.ts +1 -0
- package/dist/signing.js +3 -0
- package/dist/signing.js.map +1 -0
- package/package.json +12 -2
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ React SDK for World ID built on top of `@worldcoin/idkit-core`.
|
|
|
7
7
|
- Headless hooks for custom UI
|
|
8
8
|
- Built-in controlled widgets with shadow DOM isolation
|
|
9
9
|
- Separate request and session APIs
|
|
10
|
+
- Pure JS `/signing` and `/hashing` subpath exports for server-side use
|
|
10
11
|
|
|
11
12
|
## Installation
|
|
12
13
|
|
|
@@ -49,3 +50,12 @@ const config: IDKitRequestHookConfig = {
|
|
|
49
50
|
preset: { type: "OrbLegacy" },
|
|
50
51
|
};
|
|
51
52
|
```
|
|
53
|
+
|
|
54
|
+
## Subpath Exports
|
|
55
|
+
|
|
56
|
+
Pure JS subpath exports for server-side use (no WASM or React required):
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
import { signRequest } from "@worldcoin/idkit/signing";
|
|
60
|
+
import { hashSignal } from "@worldcoin/idkit/hashing";
|
|
61
|
+
```
|
package/dist/hashing.cjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var hashing = require('@worldcoin/idkit-core/hashing');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "hashSignal", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return hashing.hashSignal; }
|
|
10
|
+
});
|
|
11
|
+
//# sourceMappingURL=hashing.cjs.map
|
|
12
|
+
//# sourceMappingURL=hashing.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"hashing.cjs","sourcesContent":[]}
|
package/dist/hashing.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"hashing.js","sourcesContent":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -113,8 +113,6 @@ function useIDKitFlow(createFlowHandle, config) {
|
|
|
113
113
|
};
|
|
114
114
|
void (async () => {
|
|
115
115
|
try {
|
|
116
|
-
await idkitCore.IDKit.init();
|
|
117
|
-
ensureNotAborted(controller.signal);
|
|
118
116
|
const request = await createFlowHandleRef.current();
|
|
119
117
|
ensureNotAborted(controller.signal);
|
|
120
118
|
setState((prev) => {
|
|
@@ -204,36 +202,6 @@ function useIDKitRequest(config) {
|
|
|
204
202
|
config
|
|
205
203
|
);
|
|
206
204
|
}
|
|
207
|
-
function assertSessionId(sessionId) {
|
|
208
|
-
if (sessionId === void 0) {
|
|
209
|
-
return void 0;
|
|
210
|
-
}
|
|
211
|
-
if (sessionId.trim().length === 0) {
|
|
212
|
-
throw idkitCore.IDKitErrorCodes.MalformedRequest;
|
|
213
|
-
}
|
|
214
|
-
return sessionId;
|
|
215
|
-
}
|
|
216
|
-
function useIDKitSession(config) {
|
|
217
|
-
return useIDKitFlow(() => {
|
|
218
|
-
const existingSessionId = assertSessionId(config.existing_session_id);
|
|
219
|
-
const builder = existingSessionId ? idkitCore.IDKit.proveSession(existingSessionId, {
|
|
220
|
-
app_id: config.app_id,
|
|
221
|
-
rp_context: config.rp_context,
|
|
222
|
-
action_description: config.action_description,
|
|
223
|
-
bridge_url: config.bridge_url,
|
|
224
|
-
override_connect_base_url: config.override_connect_base_url,
|
|
225
|
-
environment: config.environment
|
|
226
|
-
}) : idkitCore.IDKit.createSession({
|
|
227
|
-
app_id: config.app_id,
|
|
228
|
-
rp_context: config.rp_context,
|
|
229
|
-
action_description: config.action_description,
|
|
230
|
-
bridge_url: config.bridge_url,
|
|
231
|
-
override_connect_base_url: config.override_connect_base_url,
|
|
232
|
-
environment: config.environment
|
|
233
|
-
});
|
|
234
|
-
return builder.preset(config.preset);
|
|
235
|
-
}, config);
|
|
236
|
-
}
|
|
237
205
|
|
|
238
206
|
// src/styles/widgetStyles.ts
|
|
239
207
|
var WIDGET_STYLES = `
|
|
@@ -530,6 +498,22 @@ var WIDGET_STYLES = `
|
|
|
530
498
|
color: var(--idkit-text-secondary);
|
|
531
499
|
}
|
|
532
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
|
+
|
|
533
517
|
/* Mobile deep-link button */
|
|
534
518
|
.idkit-deeplink-btn {
|
|
535
519
|
display: flex;
|
|
@@ -1188,7 +1172,10 @@ function QRPlaceholderIcon(props) {
|
|
|
1188
1172
|
}
|
|
1189
1173
|
);
|
|
1190
1174
|
}
|
|
1191
|
-
function QRState({
|
|
1175
|
+
function QRState({
|
|
1176
|
+
qrData,
|
|
1177
|
+
showSimulatorCallout
|
|
1178
|
+
}) {
|
|
1192
1179
|
const media = useMedia();
|
|
1193
1180
|
const [copiedLink, setCopiedLink] = react.useState(false);
|
|
1194
1181
|
const copyLink = react.useCallback(() => {
|
|
@@ -1227,13 +1214,27 @@ function QRState({ qrData }) {
|
|
|
1227
1214
|
style: { cursor: "pointer" },
|
|
1228
1215
|
children: /* @__PURE__ */ jsxRuntime.jsx(QRCode, { data: qrData, size: media === "mobile" ? 160 : 200 })
|
|
1229
1216
|
}
|
|
1230
|
-
) : /* @__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
|
+
] })
|
|
1231
1231
|
] })
|
|
1232
1232
|
] });
|
|
1233
1233
|
}
|
|
1234
1234
|
function WorldIDState({
|
|
1235
1235
|
connectorURI,
|
|
1236
|
-
isAwaitingUserConfirmation
|
|
1236
|
+
isAwaitingUserConfirmation,
|
|
1237
|
+
showSimulatorCallout
|
|
1237
1238
|
}) {
|
|
1238
1239
|
const media = useMedia();
|
|
1239
1240
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -1263,7 +1264,13 @@ function WorldIDState({
|
|
|
1263
1264
|
"div",
|
|
1264
1265
|
{
|
|
1265
1266
|
className: `idkit-qr-blur ${isAwaitingUserConfirmation ? "blurred" : ""}`,
|
|
1266
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", justifyContent: "center" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
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
|
+
) })
|
|
1267
1274
|
}
|
|
1268
1275
|
)
|
|
1269
1276
|
] })
|
|
@@ -1624,90 +1631,14 @@ function IDKitRequestWidget({
|
|
|
1624
1631
|
}
|
|
1625
1632
|
}, [flow.isSuccess, autoClose, onOpenChange]);
|
|
1626
1633
|
const stage = getVisualStage(flow.isSuccess, flow.isError);
|
|
1634
|
+
const showSimulatorCallout = config.environment === "staging";
|
|
1627
1635
|
return /* @__PURE__ */ jsxRuntime.jsxs(IDKitModal, { open, onOpenChange, children: [
|
|
1628
1636
|
stage === "worldid" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1629
1637
|
WorldIDState,
|
|
1630
1638
|
{
|
|
1631
1639
|
connectorURI: flow.connectorURI,
|
|
1632
|
-
isAwaitingUserConfirmation: flow.isAwaitingUserConfirmation
|
|
1633
|
-
|
|
1634
|
-
),
|
|
1635
|
-
stage === "success" && /* @__PURE__ */ jsxRuntime.jsx(SuccessState, {}),
|
|
1636
|
-
stage === "error" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1637
|
-
ErrorState,
|
|
1638
|
-
{
|
|
1639
|
-
errorCode: flow.errorCode,
|
|
1640
|
-
onRetry: () => {
|
|
1641
|
-
resetFlow();
|
|
1642
|
-
openFlow();
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
)
|
|
1646
|
-
] });
|
|
1647
|
-
}
|
|
1648
|
-
function getVisualStage2(isSuccess, isError) {
|
|
1649
|
-
if (isSuccess) {
|
|
1650
|
-
return "success";
|
|
1651
|
-
}
|
|
1652
|
-
if (isError) {
|
|
1653
|
-
return "error";
|
|
1654
|
-
}
|
|
1655
|
-
return "worldid";
|
|
1656
|
-
}
|
|
1657
|
-
function IDKitSessionWidget({
|
|
1658
|
-
open,
|
|
1659
|
-
onOpenChange,
|
|
1660
|
-
onSuccess,
|
|
1661
|
-
onError,
|
|
1662
|
-
autoClose = true,
|
|
1663
|
-
language,
|
|
1664
|
-
...config
|
|
1665
|
-
}) {
|
|
1666
|
-
const flow = useIDKitSession(config);
|
|
1667
|
-
const { open: openFlow, reset: resetFlow } = flow;
|
|
1668
|
-
const lastResultRef = react.useRef(null);
|
|
1669
|
-
const lastErrorCodeRef = react.useRef(null);
|
|
1670
|
-
react.useEffect(() => {
|
|
1671
|
-
if (language) {
|
|
1672
|
-
setLocalizationConfig({ language });
|
|
1673
|
-
}
|
|
1674
|
-
}, [language]);
|
|
1675
|
-
react.useEffect(() => {
|
|
1676
|
-
if (open) {
|
|
1677
|
-
openFlow();
|
|
1678
|
-
return;
|
|
1679
|
-
}
|
|
1680
|
-
resetFlow();
|
|
1681
|
-
}, [open, openFlow, resetFlow]);
|
|
1682
|
-
react.useEffect(() => {
|
|
1683
|
-
if (!flow.result || flow.result === lastResultRef.current) {
|
|
1684
|
-
return;
|
|
1685
|
-
}
|
|
1686
|
-
lastResultRef.current = flow.result;
|
|
1687
|
-
void Promise.resolve(onSuccess?.(flow.result)).catch(() => {
|
|
1688
|
-
});
|
|
1689
|
-
}, [onSuccess, flow.result]);
|
|
1690
|
-
react.useEffect(() => {
|
|
1691
|
-
if (!flow.errorCode || flow.errorCode === lastErrorCodeRef.current) {
|
|
1692
|
-
return;
|
|
1693
|
-
}
|
|
1694
|
-
lastErrorCodeRef.current = flow.errorCode;
|
|
1695
|
-
void Promise.resolve(onError?.(flow.errorCode)).catch(() => {
|
|
1696
|
-
});
|
|
1697
|
-
}, [flow.errorCode, onError]);
|
|
1698
|
-
react.useEffect(() => {
|
|
1699
|
-
if (flow.isSuccess && autoClose) {
|
|
1700
|
-
const timer = setTimeout(() => onOpenChange(false), 2500);
|
|
1701
|
-
return () => clearTimeout(timer);
|
|
1702
|
-
}
|
|
1703
|
-
}, [flow.isSuccess, autoClose, onOpenChange]);
|
|
1704
|
-
const stage = getVisualStage2(flow.isSuccess, flow.isError);
|
|
1705
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(IDKitModal, { open, onOpenChange, children: [
|
|
1706
|
-
stage === "worldid" && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1707
|
-
WorldIDState,
|
|
1708
|
-
{
|
|
1709
|
-
connectorURI: flow.connectorURI,
|
|
1710
|
-
isAwaitingUserConfirmation: flow.isAwaitingUserConfirmation
|
|
1640
|
+
isAwaitingUserConfirmation: flow.isAwaitingUserConfirmation,
|
|
1641
|
+
showSimulatorCallout
|
|
1711
1642
|
}
|
|
1712
1643
|
),
|
|
1713
1644
|
stage === "success" && /* @__PURE__ */ jsxRuntime.jsx(SuccessState, {}),
|
|
@@ -1724,10 +1655,6 @@ function IDKitSessionWidget({
|
|
|
1724
1655
|
] });
|
|
1725
1656
|
}
|
|
1726
1657
|
|
|
1727
|
-
Object.defineProperty(exports, "CredentialRequest", {
|
|
1728
|
-
enumerable: true,
|
|
1729
|
-
get: function () { return idkitCore.CredentialRequest; }
|
|
1730
|
-
});
|
|
1731
1658
|
Object.defineProperty(exports, "IDKit", {
|
|
1732
1659
|
enumerable: true,
|
|
1733
1660
|
get: function () { return idkitCore.IDKit; }
|
|
@@ -1736,14 +1663,6 @@ Object.defineProperty(exports, "IDKitErrorCodes", {
|
|
|
1736
1663
|
enumerable: true,
|
|
1737
1664
|
get: function () { return idkitCore.IDKitErrorCodes; }
|
|
1738
1665
|
});
|
|
1739
|
-
Object.defineProperty(exports, "all", {
|
|
1740
|
-
enumerable: true,
|
|
1741
|
-
get: function () { return idkitCore.all; }
|
|
1742
|
-
});
|
|
1743
|
-
Object.defineProperty(exports, "any", {
|
|
1744
|
-
enumerable: true,
|
|
1745
|
-
get: function () { return idkitCore.any; }
|
|
1746
|
-
});
|
|
1747
1666
|
Object.defineProperty(exports, "documentLegacy", {
|
|
1748
1667
|
enumerable: true,
|
|
1749
1668
|
get: function () { return idkitCore.documentLegacy; }
|
|
@@ -1756,9 +1675,11 @@ Object.defineProperty(exports, "secureDocumentLegacy", {
|
|
|
1756
1675
|
enumerable: true,
|
|
1757
1676
|
get: function () { return idkitCore.secureDocumentLegacy; }
|
|
1758
1677
|
});
|
|
1678
|
+
Object.defineProperty(exports, "signRequest", {
|
|
1679
|
+
enumerable: true,
|
|
1680
|
+
get: function () { return idkitCore.signRequest; }
|
|
1681
|
+
});
|
|
1759
1682
|
exports.IDKitRequestWidget = IDKitRequestWidget;
|
|
1760
|
-
exports.IDKitSessionWidget = IDKitSessionWidget;
|
|
1761
1683
|
exports.useIDKitRequest = useIDKitRequest;
|
|
1762
|
-
exports.useIDKitSession = useIDKitSession;
|
|
1763
1684
|
//# sourceMappingURL=index.cjs.map
|
|
1764
1685
|
//# sourceMappingURL=index.cjs.map
|