@pubflow/react 0.4.7 → 0.4.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/dist/index.cjs +22 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +7 -4
- package/dist/index.esm.js +22 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/types/hooks/useTwoFactor.d.ts +8 -5
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -10142,6 +10142,27 @@ function useTwoFactor(instanceId) {
|
|
|
10142
10142
|
setIsLoading(false);
|
|
10143
10143
|
}
|
|
10144
10144
|
}, [instance, refresh]);
|
|
10145
|
+
const confirmSetup = React.useCallback(async (methodId, method, code) => {
|
|
10146
|
+
if (!instance)
|
|
10147
|
+
return { success: false, verified: false, error: 'Pubflow not initialized' };
|
|
10148
|
+
setIsLoading(true);
|
|
10149
|
+
setError(null);
|
|
10150
|
+
try {
|
|
10151
|
+
// action='setup' activates a pending_setup method in the DB
|
|
10152
|
+
const result = await instance.twoFactorService.verify(methodId, code, 'setup');
|
|
10153
|
+
if (result.verified)
|
|
10154
|
+
await refresh();
|
|
10155
|
+
return result;
|
|
10156
|
+
}
|
|
10157
|
+
catch (e) {
|
|
10158
|
+
const msg = (e === null || e === void 0 ? void 0 : e.message) || 'Confirmation failed';
|
|
10159
|
+
setError(msg);
|
|
10160
|
+
return { success: false, verified: false, error: msg };
|
|
10161
|
+
}
|
|
10162
|
+
finally {
|
|
10163
|
+
setIsLoading(false);
|
|
10164
|
+
}
|
|
10165
|
+
}, [instance, refresh]);
|
|
10145
10166
|
return {
|
|
10146
10167
|
systemEnabled,
|
|
10147
10168
|
availableMethods,
|
|
@@ -10150,6 +10171,7 @@ function useTwoFactor(instanceId) {
|
|
|
10150
10171
|
error,
|
|
10151
10172
|
refresh,
|
|
10152
10173
|
setup,
|
|
10174
|
+
confirmSetup,
|
|
10153
10175
|
toggle,
|
|
10154
10176
|
removeMethod,
|
|
10155
10177
|
};
|