@worldcoin/idkit 4.0.7 → 4.0.9
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 +2 -1
- package/dist/index.cjs +18 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ npm install @worldcoin/idkit
|
|
|
21
21
|
import {
|
|
22
22
|
useIDKitRequest,
|
|
23
23
|
orbLegacy,
|
|
24
|
+
deviceLegacy,
|
|
24
25
|
selfieCheckLegacy,
|
|
25
26
|
} from "@worldcoin/idkit";
|
|
26
27
|
|
|
@@ -43,7 +44,7 @@ function Example() {
|
|
|
43
44
|
}
|
|
44
45
|
```
|
|
45
46
|
|
|
46
|
-
Use `selfieCheckLegacy({ signal })` for selfie-check preset requests.
|
|
47
|
+
Use `deviceLegacy({ signal })` for orb-or-device legacy requests and `selfieCheckLegacy({ signal })` for selfie-check preset requests.
|
|
47
48
|
|
|
48
49
|
```tsx
|
|
49
50
|
import type { IDKitRequestHookConfig } from "@worldcoin/idkit";
|
package/dist/index.cjs
CHANGED
|
@@ -65,10 +65,12 @@ function toErrorCode(error) {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// src/hooks/useIDKitFlow.ts
|
|
68
|
+
var isDebug = () => typeof window !== "undefined" && window.IDKIT_DEBUG;
|
|
68
69
|
function useIDKitFlow(createFlowHandle, config) {
|
|
69
70
|
const [state, setState] = react.useState(
|
|
70
71
|
createInitialHookState
|
|
71
72
|
);
|
|
73
|
+
const [runId, setRunId] = react.useState(0);
|
|
72
74
|
const abortRef = react.useRef(null);
|
|
73
75
|
const createFlowHandleRef = react.useRef(createFlowHandle);
|
|
74
76
|
const configRef = react.useRef(config);
|
|
@@ -78,6 +80,7 @@ function useIDKitFlow(createFlowHandle, config) {
|
|
|
78
80
|
abortRef.current?.abort();
|
|
79
81
|
abortRef.current = null;
|
|
80
82
|
setState(createInitialHookState);
|
|
83
|
+
setRunId((id) => id + 1);
|
|
81
84
|
}, []);
|
|
82
85
|
const open = react.useCallback(() => {
|
|
83
86
|
setState((prev) => {
|
|
@@ -113,8 +116,14 @@ function useIDKitFlow(createFlowHandle, config) {
|
|
|
113
116
|
};
|
|
114
117
|
void (async () => {
|
|
115
118
|
try {
|
|
119
|
+
if (isDebug()) console.debug("[IDKit] Creating flow handle\u2026");
|
|
116
120
|
const request = await createFlowHandleRef.current();
|
|
117
121
|
ensureNotAborted(controller.signal);
|
|
122
|
+
if (isDebug())
|
|
123
|
+
console.debug("[IDKit] Flow created", {
|
|
124
|
+
connectorURI: request.connectorURI,
|
|
125
|
+
requestId: request.requestId
|
|
126
|
+
});
|
|
118
127
|
setState((prev) => {
|
|
119
128
|
if (prev.connectorURI === request.connectorURI) {
|
|
120
129
|
return prev;
|
|
@@ -147,6 +156,8 @@ function useIDKitFlow(createFlowHandle, config) {
|
|
|
147
156
|
return;
|
|
148
157
|
}
|
|
149
158
|
if (nextStatus.type === "failed") {
|
|
159
|
+
if (isDebug())
|
|
160
|
+
console.warn("[IDKit] Poll returned failed", nextStatus);
|
|
150
161
|
setFailed(nextStatus.error ?? idkitCore.IDKitErrorCodes.GenericError);
|
|
151
162
|
return;
|
|
152
163
|
}
|
|
@@ -160,8 +171,10 @@ function useIDKitFlow(createFlowHandle, config) {
|
|
|
160
171
|
}
|
|
161
172
|
} catch (error) {
|
|
162
173
|
if (controller.signal.aborted) {
|
|
174
|
+
if (isDebug()) console.debug("[IDKit] Flow aborted");
|
|
163
175
|
return;
|
|
164
176
|
}
|
|
177
|
+
if (isDebug()) console.error("[IDKit] Flow error:", error);
|
|
165
178
|
setFailed(toErrorCode(error));
|
|
166
179
|
}
|
|
167
180
|
})();
|
|
@@ -171,7 +184,7 @@ function useIDKitFlow(createFlowHandle, config) {
|
|
|
171
184
|
abortRef.current = null;
|
|
172
185
|
}
|
|
173
186
|
};
|
|
174
|
-
}, [state.isOpen]);
|
|
187
|
+
}, [state.isOpen, runId]);
|
|
175
188
|
return {
|
|
176
189
|
open,
|
|
177
190
|
reset,
|
|
@@ -1731,6 +1744,10 @@ Object.defineProperty(exports, "IDKitErrorCodes", {
|
|
|
1731
1744
|
enumerable: true,
|
|
1732
1745
|
get: function () { return idkitCore.IDKitErrorCodes; }
|
|
1733
1746
|
});
|
|
1747
|
+
Object.defineProperty(exports, "deviceLegacy", {
|
|
1748
|
+
enumerable: true,
|
|
1749
|
+
get: function () { return idkitCore.deviceLegacy; }
|
|
1750
|
+
});
|
|
1734
1751
|
Object.defineProperty(exports, "documentLegacy", {
|
|
1735
1752
|
enumerable: true,
|
|
1736
1753
|
get: function () { return idkitCore.documentLegacy; }
|