@saxenapackages/auth-sdk 1.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.
- package/README.md +195 -0
- package/dist/api/authApi.d.ts +19 -0
- package/dist/api/axios.d.ts +5 -0
- package/dist/auth-sdk.css +1 -0
- package/dist/components/alert/Alert.d.ts +9 -0
- package/dist/components/authWidget/index.d.ts +7 -0
- package/dist/components/forgotPassword/index.d.ts +8 -0
- package/dist/components/googleLogin/index.d.ts +7 -0
- package/dist/components/login/index.d.ts +9 -0
- package/dist/components/otp/index.d.ts +12 -0
- package/dist/components/resetPassword/index.d.ts +8 -0
- package/dist/components/signup/index.d.ts +8 -0
- package/dist/components/updateUser/index.d.ts +9 -0
- package/dist/hooks/useAuth.d.ts +3 -0
- package/dist/hooks/useLogin.d.ts +8 -0
- package/dist/hooks/useOtp.d.ts +9 -0
- package/dist/hooks/useResetPassword.d.ts +8 -0
- package/dist/hooks/useSignup.d.ts +8 -0
- package/dist/hooks/useUpdateUser.d.ts +8 -0
- package/dist/hooks/useVerifyIdentity.d.ts +8 -0
- package/dist/index.cjs +23 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +2248 -0
- package/dist/index.js.map +1 -0
- package/dist/provider/AuthContext.d.ts +24 -0
- package/dist/provider/AuthProvider.d.ts +8 -0
- package/dist/services/event.service.d.ts +9 -0
- package/dist/services/storage.service.d.ts +10 -0
- package/dist/services/token.service.d.ts +10 -0
- package/dist/setupTests.d.ts +0 -0
- package/dist/theme/defaultTheme.d.ts +3 -0
- package/dist/types/api.d.ts +10 -0
- package/dist/types/auth.d.ts +28 -0
- package/dist/types/config.d.ts +139 -0
- package/dist/utils/errors.d.ts +7 -0
- package/dist/utils/helpers.d.ts +8 -0
- package/dist/validation/index.d.ts +6 -0
- package/dist/validation/login.d.ts +28 -0
- package/dist/validation/otp.d.ts +8 -0
- package/dist/validation/resetPassword.d.ts +17 -0
- package/dist/validation/signup.d.ts +27 -0
- package/dist/validation/updateUser.d.ts +38 -0
- package/dist/validation/verifyIdentity.d.ts +8 -0
- package/package.json +49 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,2248 @@
|
|
|
1
|
+
var kt = Object.defineProperty;
|
|
2
|
+
var Nt = (s, e, o) => e in s ? kt(s, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : s[e] = o;
|
|
3
|
+
var ze = (s, e, o) => Nt(s, typeof e != "symbol" ? e + "" : e, o);
|
|
4
|
+
import Tt, { createContext as _t, useState as S, useMemo as rt, useEffect as st, useContext as Pt } from "react";
|
|
5
|
+
import gt from "axios";
|
|
6
|
+
import { z as I } from "zod";
|
|
7
|
+
var ct = { exports: {} }, at = {};
|
|
8
|
+
/**
|
|
9
|
+
* @license React
|
|
10
|
+
* react-jsx-runtime.production.js
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the MIT license found in the
|
|
15
|
+
* LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/
|
|
17
|
+
var yt;
|
|
18
|
+
function St() {
|
|
19
|
+
if (yt) return at;
|
|
20
|
+
yt = 1;
|
|
21
|
+
var s = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
22
|
+
function o(n, i, d) {
|
|
23
|
+
var g = null;
|
|
24
|
+
if (d !== void 0 && (g = "" + d), i.key !== void 0 && (g = "" + i.key), "key" in i) {
|
|
25
|
+
d = {};
|
|
26
|
+
for (var l in i)
|
|
27
|
+
l !== "key" && (d[l] = i[l]);
|
|
28
|
+
} else d = i;
|
|
29
|
+
return i = d.ref, {
|
|
30
|
+
$$typeof: s,
|
|
31
|
+
type: n,
|
|
32
|
+
key: g,
|
|
33
|
+
ref: i !== void 0 ? i : null,
|
|
34
|
+
props: d
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return at.Fragment = e, at.jsx = o, at.jsxs = o, at;
|
|
38
|
+
}
|
|
39
|
+
var ot = {};
|
|
40
|
+
/**
|
|
41
|
+
* @license React
|
|
42
|
+
* react-jsx-runtime.development.js
|
|
43
|
+
*
|
|
44
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
45
|
+
*
|
|
46
|
+
* This source code is licensed under the MIT license found in the
|
|
47
|
+
* LICENSE file in the root directory of this source tree.
|
|
48
|
+
*/
|
|
49
|
+
var xt;
|
|
50
|
+
function It() {
|
|
51
|
+
return xt || (xt = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
52
|
+
function s(a) {
|
|
53
|
+
if (a == null) return null;
|
|
54
|
+
if (typeof a == "function")
|
|
55
|
+
return a.$$typeof === re ? null : a.displayName || a.name || null;
|
|
56
|
+
if (typeof a == "string") return a;
|
|
57
|
+
switch (a) {
|
|
58
|
+
case L:
|
|
59
|
+
return "Fragment";
|
|
60
|
+
case P:
|
|
61
|
+
return "Profiler";
|
|
62
|
+
case V:
|
|
63
|
+
return "StrictMode";
|
|
64
|
+
case Q:
|
|
65
|
+
return "Suspense";
|
|
66
|
+
case le:
|
|
67
|
+
return "SuspenseList";
|
|
68
|
+
case ee:
|
|
69
|
+
return "Activity";
|
|
70
|
+
}
|
|
71
|
+
if (typeof a == "object")
|
|
72
|
+
switch (typeof a.tag == "number" && console.error(
|
|
73
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
74
|
+
), a.$$typeof) {
|
|
75
|
+
case O:
|
|
76
|
+
return "Portal";
|
|
77
|
+
case T:
|
|
78
|
+
return a.displayName || "Context";
|
|
79
|
+
case G:
|
|
80
|
+
return (a._context.displayName || "Context") + ".Consumer";
|
|
81
|
+
case A:
|
|
82
|
+
var u = a.render;
|
|
83
|
+
return a = a.displayName, a || (a = u.displayName || u.name || "", a = a !== "" ? "ForwardRef(" + a + ")" : "ForwardRef"), a;
|
|
84
|
+
case se:
|
|
85
|
+
return u = a.displayName || null, u !== null ? u : s(a.type) || "Memo";
|
|
86
|
+
case F:
|
|
87
|
+
u = a._payload, a = a._init;
|
|
88
|
+
try {
|
|
89
|
+
return s(a(u));
|
|
90
|
+
} catch {
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
function e(a) {
|
|
96
|
+
return "" + a;
|
|
97
|
+
}
|
|
98
|
+
function o(a) {
|
|
99
|
+
try {
|
|
100
|
+
e(a);
|
|
101
|
+
var u = !1;
|
|
102
|
+
} catch {
|
|
103
|
+
u = !0;
|
|
104
|
+
}
|
|
105
|
+
if (u) {
|
|
106
|
+
u = console;
|
|
107
|
+
var j = u.error, N = typeof Symbol == "function" && Symbol.toStringTag && a[Symbol.toStringTag] || a.constructor.name || "Object";
|
|
108
|
+
return j.call(
|
|
109
|
+
u,
|
|
110
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
111
|
+
N
|
|
112
|
+
), e(a);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
function n(a) {
|
|
116
|
+
if (a === L) return "<>";
|
|
117
|
+
if (typeof a == "object" && a !== null && a.$$typeof === F)
|
|
118
|
+
return "<...>";
|
|
119
|
+
try {
|
|
120
|
+
var u = s(a);
|
|
121
|
+
return u ? "<" + u + ">" : "<...>";
|
|
122
|
+
} catch {
|
|
123
|
+
return "<...>";
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function i() {
|
|
127
|
+
var a = J.A;
|
|
128
|
+
return a === null ? null : a.getOwner();
|
|
129
|
+
}
|
|
130
|
+
function d() {
|
|
131
|
+
return Error("react-stack-top-frame");
|
|
132
|
+
}
|
|
133
|
+
function g(a) {
|
|
134
|
+
if (M.call(a, "key")) {
|
|
135
|
+
var u = Object.getOwnPropertyDescriptor(a, "key").get;
|
|
136
|
+
if (u && u.isReactWarning) return !1;
|
|
137
|
+
}
|
|
138
|
+
return a.key !== void 0;
|
|
139
|
+
}
|
|
140
|
+
function l(a, u) {
|
|
141
|
+
function j() {
|
|
142
|
+
h || (h = !0, console.error(
|
|
143
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
144
|
+
u
|
|
145
|
+
));
|
|
146
|
+
}
|
|
147
|
+
j.isReactWarning = !0, Object.defineProperty(a, "key", {
|
|
148
|
+
get: j,
|
|
149
|
+
configurable: !0
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function m() {
|
|
153
|
+
var a = s(this.type);
|
|
154
|
+
return p[a] || (p[a] = !0, console.error(
|
|
155
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
156
|
+
)), a = this.props.ref, a !== void 0 ? a : null;
|
|
157
|
+
}
|
|
158
|
+
function E(a, u, j, N, U, q) {
|
|
159
|
+
var R = j.ref;
|
|
160
|
+
return a = {
|
|
161
|
+
$$typeof: v,
|
|
162
|
+
type: a,
|
|
163
|
+
key: u,
|
|
164
|
+
props: j,
|
|
165
|
+
_owner: N
|
|
166
|
+
}, (R !== void 0 ? R : null) !== null ? Object.defineProperty(a, "ref", {
|
|
167
|
+
enumerable: !1,
|
|
168
|
+
get: m
|
|
169
|
+
}) : Object.defineProperty(a, "ref", { enumerable: !1, value: null }), a._store = {}, Object.defineProperty(a._store, "validated", {
|
|
170
|
+
configurable: !1,
|
|
171
|
+
enumerable: !1,
|
|
172
|
+
writable: !0,
|
|
173
|
+
value: 0
|
|
174
|
+
}), Object.defineProperty(a, "_debugInfo", {
|
|
175
|
+
configurable: !1,
|
|
176
|
+
enumerable: !1,
|
|
177
|
+
writable: !0,
|
|
178
|
+
value: null
|
|
179
|
+
}), Object.defineProperty(a, "_debugStack", {
|
|
180
|
+
configurable: !1,
|
|
181
|
+
enumerable: !1,
|
|
182
|
+
writable: !0,
|
|
183
|
+
value: U
|
|
184
|
+
}), Object.defineProperty(a, "_debugTask", {
|
|
185
|
+
configurable: !1,
|
|
186
|
+
enumerable: !1,
|
|
187
|
+
writable: !0,
|
|
188
|
+
value: q
|
|
189
|
+
}), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
|
|
190
|
+
}
|
|
191
|
+
function k(a, u, j, N, U, q) {
|
|
192
|
+
var R = u.children;
|
|
193
|
+
if (R !== void 0)
|
|
194
|
+
if (N)
|
|
195
|
+
if (D(R)) {
|
|
196
|
+
for (N = 0; N < R.length; N++)
|
|
197
|
+
b(R[N]);
|
|
198
|
+
Object.freeze && Object.freeze(R);
|
|
199
|
+
} else
|
|
200
|
+
console.error(
|
|
201
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
202
|
+
);
|
|
203
|
+
else b(R);
|
|
204
|
+
if (M.call(u, "key")) {
|
|
205
|
+
R = s(a);
|
|
206
|
+
var W = Object.keys(u).filter(function(C) {
|
|
207
|
+
return C !== "key";
|
|
208
|
+
});
|
|
209
|
+
N = 0 < W.length ? "{key: someKey, " + W.join(": ..., ") + ": ...}" : "{key: someKey}", w[R + N] || (W = 0 < W.length ? "{" + W.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
210
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
211
|
+
let props = %s;
|
|
212
|
+
<%s {...props} />
|
|
213
|
+
React keys must be passed directly to JSX without using spread:
|
|
214
|
+
let props = %s;
|
|
215
|
+
<%s key={someKey} {...props} />`,
|
|
216
|
+
N,
|
|
217
|
+
R,
|
|
218
|
+
W,
|
|
219
|
+
R
|
|
220
|
+
), w[R + N] = !0);
|
|
221
|
+
}
|
|
222
|
+
if (R = null, j !== void 0 && (o(j), R = "" + j), g(u) && (o(u.key), R = "" + u.key), "key" in u) {
|
|
223
|
+
j = {};
|
|
224
|
+
for (var K in u)
|
|
225
|
+
K !== "key" && (j[K] = u[K]);
|
|
226
|
+
} else j = u;
|
|
227
|
+
return R && l(
|
|
228
|
+
j,
|
|
229
|
+
typeof a == "function" ? a.displayName || a.name || "Unknown" : a
|
|
230
|
+
), E(
|
|
231
|
+
a,
|
|
232
|
+
R,
|
|
233
|
+
j,
|
|
234
|
+
i(),
|
|
235
|
+
U,
|
|
236
|
+
q
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
function b(a) {
|
|
240
|
+
x(a) ? a._store && (a._store.validated = 1) : typeof a == "object" && a !== null && a.$$typeof === F && (a._payload.status === "fulfilled" ? x(a._payload.value) && a._payload.value._store && (a._payload.value._store.validated = 1) : a._store && (a._store.validated = 1));
|
|
241
|
+
}
|
|
242
|
+
function x(a) {
|
|
243
|
+
return typeof a == "object" && a !== null && a.$$typeof === v;
|
|
244
|
+
}
|
|
245
|
+
var _ = Tt, v = Symbol.for("react.transitional.element"), O = Symbol.for("react.portal"), L = Symbol.for("react.fragment"), V = Symbol.for("react.strict_mode"), P = Symbol.for("react.profiler"), G = Symbol.for("react.consumer"), T = Symbol.for("react.context"), A = Symbol.for("react.forward_ref"), Q = Symbol.for("react.suspense"), le = Symbol.for("react.suspense_list"), se = Symbol.for("react.memo"), F = Symbol.for("react.lazy"), ee = Symbol.for("react.activity"), re = Symbol.for("react.client.reference"), J = _.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, M = Object.prototype.hasOwnProperty, D = Array.isArray, c = console.createTask ? console.createTask : function() {
|
|
246
|
+
return null;
|
|
247
|
+
};
|
|
248
|
+
_ = {
|
|
249
|
+
react_stack_bottom_frame: function(a) {
|
|
250
|
+
return a();
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
var h, p = {}, f = _.react_stack_bottom_frame.bind(
|
|
254
|
+
_,
|
|
255
|
+
d
|
|
256
|
+
)(), y = c(n(d)), w = {};
|
|
257
|
+
ot.Fragment = L, ot.jsx = function(a, u, j) {
|
|
258
|
+
var N = 1e4 > J.recentlyCreatedOwnerStacks++;
|
|
259
|
+
return k(
|
|
260
|
+
a,
|
|
261
|
+
u,
|
|
262
|
+
j,
|
|
263
|
+
!1,
|
|
264
|
+
N ? Error("react-stack-top-frame") : f,
|
|
265
|
+
N ? c(n(a)) : y
|
|
266
|
+
);
|
|
267
|
+
}, ot.jsxs = function(a, u, j) {
|
|
268
|
+
var N = 1e4 > J.recentlyCreatedOwnerStacks++;
|
|
269
|
+
return k(
|
|
270
|
+
a,
|
|
271
|
+
u,
|
|
272
|
+
j,
|
|
273
|
+
!0,
|
|
274
|
+
N ? Error("react-stack-top-frame") : f,
|
|
275
|
+
N ? c(n(a)) : y
|
|
276
|
+
);
|
|
277
|
+
};
|
|
278
|
+
})()), ot;
|
|
279
|
+
}
|
|
280
|
+
var wt;
|
|
281
|
+
function Rt() {
|
|
282
|
+
return wt || (wt = 1, process.env.NODE_ENV === "production" ? ct.exports = St() : ct.exports = It()), ct.exports;
|
|
283
|
+
}
|
|
284
|
+
var t = Rt();
|
|
285
|
+
const bt = _t(void 0);
|
|
286
|
+
class mt {
|
|
287
|
+
constructor() {
|
|
288
|
+
ze(this, "store", {});
|
|
289
|
+
}
|
|
290
|
+
getItem(e) {
|
|
291
|
+
return this.store[e] || null;
|
|
292
|
+
}
|
|
293
|
+
setItem(e, o) {
|
|
294
|
+
this.store[e] = o;
|
|
295
|
+
}
|
|
296
|
+
removeItem(e) {
|
|
297
|
+
delete this.store[e];
|
|
298
|
+
}
|
|
299
|
+
clear() {
|
|
300
|
+
this.store = {};
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
class Ct {
|
|
304
|
+
constructor(e) {
|
|
305
|
+
ze(this, "adapter");
|
|
306
|
+
this.adapter = this.resolveAdapter(e);
|
|
307
|
+
}
|
|
308
|
+
resolveAdapter(e) {
|
|
309
|
+
return !e || e === "localStorage" ? typeof window < "u" ? window.localStorage : new mt() : e === "sessionStorage" ? typeof window < "u" ? window.sessionStorage : new mt() : e === "memory" ? new mt() : e;
|
|
310
|
+
}
|
|
311
|
+
async getItem(e) {
|
|
312
|
+
try {
|
|
313
|
+
return await this.adapter.getItem(e);
|
|
314
|
+
} catch (o) {
|
|
315
|
+
return console.error("StorageService: failed to get item", o), null;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
async setItem(e, o) {
|
|
319
|
+
try {
|
|
320
|
+
await this.adapter.setItem(e, o);
|
|
321
|
+
} catch (n) {
|
|
322
|
+
console.error("StorageService: failed to set item", n);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
async removeItem(e) {
|
|
326
|
+
try {
|
|
327
|
+
await this.adapter.removeItem(e);
|
|
328
|
+
} catch (o) {
|
|
329
|
+
console.error("StorageService: failed to remove item", o);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
async clear() {
|
|
333
|
+
try {
|
|
334
|
+
await this.adapter.clear();
|
|
335
|
+
} catch (e) {
|
|
336
|
+
console.error("StorageService: failed to clear", e);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
function it(s) {
|
|
341
|
+
try {
|
|
342
|
+
const e = s.split(".");
|
|
343
|
+
if (e.length !== 3) return null;
|
|
344
|
+
const n = e[1].replace(/-/g, "+").replace(/_/g, "/"), i = decodeURIComponent(
|
|
345
|
+
atob(n).split("").map((d) => "%" + ("00" + d.charCodeAt(0).toString(16)).slice(-2)).join("")
|
|
346
|
+
);
|
|
347
|
+
return JSON.parse(i);
|
|
348
|
+
} catch {
|
|
349
|
+
return null;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
function Lt(s) {
|
|
353
|
+
if (!s) return !0;
|
|
354
|
+
const e = it(s);
|
|
355
|
+
return !e || !e.exp ? !1 : e.exp * 1e3 - 1e4 < Date.now();
|
|
356
|
+
}
|
|
357
|
+
function ie(s, e) {
|
|
358
|
+
if (!(!s || !e))
|
|
359
|
+
return e.split(".").reduce((o, n) => o ? o[n] : void 0, s);
|
|
360
|
+
}
|
|
361
|
+
function nt(s, e) {
|
|
362
|
+
if (!e) return s;
|
|
363
|
+
const o = {};
|
|
364
|
+
return Object.keys(s).forEach((n) => {
|
|
365
|
+
const i = e[n] || n;
|
|
366
|
+
o[i] = s[n];
|
|
367
|
+
}), o;
|
|
368
|
+
}
|
|
369
|
+
function Qe(s, e) {
|
|
370
|
+
return e ? ie(s, e) : ie(s, "accessToken") || ie(s, "Token") || ie(s, "token") || ie(s, "data.accessToken") || ie(s, "data.Token") || ie(s, "data.token") || null;
|
|
371
|
+
}
|
|
372
|
+
function tt(s, e) {
|
|
373
|
+
return e ? ie(s, e) : ie(s, "refreshToken") || ie(s, "refresh_token") || ie(s, "RefreshToken") || ie(s, "data.refreshToken") || ie(s, "data.refresh_token") || ie(s, "data.RefreshToken") || null;
|
|
374
|
+
}
|
|
375
|
+
function dt(s, e) {
|
|
376
|
+
return e ? ie(s, e) : ie(s, "user") || ie(s, "data.user") || // Try returning the payload itself if it has userId/id to treat the response structure as a flat user profile representation
|
|
377
|
+
(s && (s.userId || s.id || s.email) ? s : null);
|
|
378
|
+
}
|
|
379
|
+
class Ot {
|
|
380
|
+
constructor(e) {
|
|
381
|
+
ze(this, "storageService");
|
|
382
|
+
this.storageService = e;
|
|
383
|
+
}
|
|
384
|
+
async saveToken(e, o) {
|
|
385
|
+
await this.storageService.setItem(e, o);
|
|
386
|
+
}
|
|
387
|
+
async getToken(e) {
|
|
388
|
+
return this.storageService.getItem(e);
|
|
389
|
+
}
|
|
390
|
+
async removeToken(e) {
|
|
391
|
+
await this.storageService.removeItem(e);
|
|
392
|
+
}
|
|
393
|
+
decodeJWT(e) {
|
|
394
|
+
return it(e);
|
|
395
|
+
}
|
|
396
|
+
isExpired(e) {
|
|
397
|
+
return Lt(e);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
class zt {
|
|
401
|
+
constructor() {
|
|
402
|
+
ze(this, "listeners", /* @__PURE__ */ new Map());
|
|
403
|
+
}
|
|
404
|
+
on(e, o) {
|
|
405
|
+
this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(o);
|
|
406
|
+
}
|
|
407
|
+
off(e, o) {
|
|
408
|
+
const n = this.listeners.get(e);
|
|
409
|
+
n && n.delete(o);
|
|
410
|
+
}
|
|
411
|
+
emit(e, o) {
|
|
412
|
+
const n = this.listeners.get(e);
|
|
413
|
+
n && n.forEach((i) => {
|
|
414
|
+
try {
|
|
415
|
+
i(o);
|
|
416
|
+
} catch (d) {
|
|
417
|
+
console.error(`Error in event listener for ${e}:`, d);
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
const ne = new zt();
|
|
423
|
+
let et = !1, ht = [];
|
|
424
|
+
const vt = (s, e = null) => {
|
|
425
|
+
ht.forEach((o) => {
|
|
426
|
+
s ? o.reject(s) : o.resolve(e);
|
|
427
|
+
}), ht = [];
|
|
428
|
+
};
|
|
429
|
+
function At(s, e, o, n) {
|
|
430
|
+
const i = gt.create({
|
|
431
|
+
baseURL: s.apiBaseUrl,
|
|
432
|
+
withCredentials: !0
|
|
433
|
+
});
|
|
434
|
+
return i.interceptors.request.use(
|
|
435
|
+
async (d) => {
|
|
436
|
+
s.headers && Object.entries(s.headers).forEach(([m, E]) => {
|
|
437
|
+
d.headers.set(m, E);
|
|
438
|
+
});
|
|
439
|
+
const g = s.tokenKey || "Token", l = await e.getToken(g);
|
|
440
|
+
return l && !d.headers.Authorization && (d.headers.Authorization = `Bearer ${l}`), d;
|
|
441
|
+
},
|
|
442
|
+
(d) => Promise.reject(d)
|
|
443
|
+
), i.interceptors.response.use(
|
|
444
|
+
(d) => d,
|
|
445
|
+
async (d) => {
|
|
446
|
+
var l, m, E, k, b;
|
|
447
|
+
const g = d.config;
|
|
448
|
+
if (d.response && d.response.status === 401 && !g._retry && s.enableRefreshToken !== !1) {
|
|
449
|
+
const x = ((l = s.endpoints) == null ? void 0 : l.refreshToken) || "/refresh";
|
|
450
|
+
if ((m = g.url) != null && m.includes(x))
|
|
451
|
+
return et = !1, n(), ne.emit("TOKEN_EXPIRED"), Promise.reject(d);
|
|
452
|
+
if (et)
|
|
453
|
+
return new Promise((L, V) => {
|
|
454
|
+
ht.push({
|
|
455
|
+
resolve: (P) => {
|
|
456
|
+
g.headers.Authorization = `Bearer ${P}`, L(i(g));
|
|
457
|
+
},
|
|
458
|
+
reject: (P) => {
|
|
459
|
+
V(P);
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
});
|
|
463
|
+
g._retry = !0, et = !0;
|
|
464
|
+
const _ = s.tokenKey || "Token", v = s.refreshTokenKey || "refreshToken", O = await e.getToken(v);
|
|
465
|
+
if (!O)
|
|
466
|
+
return et = !1, n(), ne.emit("TOKEN_EXPIRED"), Promise.reject(d);
|
|
467
|
+
try {
|
|
468
|
+
const L = ((E = s.endpoints) == null ? void 0 : E.refreshToken) || "/identity/access-token", V = L.includes("/identity/access-token"), P = {
|
|
469
|
+
...s.headers,
|
|
470
|
+
...V ? { refreshToken: O } : {}
|
|
471
|
+
}, G = await gt.post(
|
|
472
|
+
`${s.apiBaseUrl}${L}`,
|
|
473
|
+
V ? null : { refreshToken: O },
|
|
474
|
+
{
|
|
475
|
+
headers: P,
|
|
476
|
+
withCredentials: !0
|
|
477
|
+
}
|
|
478
|
+
), T = Qe(G.data, (k = s.responseMapping) == null ? void 0 : k.token), A = tt(G.data, (b = s.responseMapping) == null ? void 0 : b.refreshToken) || O;
|
|
479
|
+
if (T)
|
|
480
|
+
return await e.saveToken(_, T), A && await e.saveToken(v, A), o(T, A), vt(null, T), g.headers.Authorization = `Bearer ${T}`, et = !1, i(g);
|
|
481
|
+
throw new Error("Auth SDK: Token not returned in refresh response payload.");
|
|
482
|
+
} catch (L) {
|
|
483
|
+
return et = !1, vt(L, null), n(), ne.emit("TOKEN_EXPIRED"), Promise.reject(L);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
return Promise.reject(d);
|
|
487
|
+
}
|
|
488
|
+
), i;
|
|
489
|
+
}
|
|
490
|
+
class Ae extends Error {
|
|
491
|
+
constructor(o, n, i) {
|
|
492
|
+
super(o);
|
|
493
|
+
ze(this, "code");
|
|
494
|
+
ze(this, "originalError");
|
|
495
|
+
this.name = "AuthSdkError", this.code = n, this.originalError = i;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
function Ie(s) {
|
|
499
|
+
var e, o;
|
|
500
|
+
if (s instanceof Ae) return s;
|
|
501
|
+
if (s != null && s.response) {
|
|
502
|
+
const n = s.response.status;
|
|
503
|
+
let i = ((e = s.response.data) == null ? void 0 : e.message) || ((o = s.response.data) == null ? void 0 : o.error) || s.message || "";
|
|
504
|
+
Array.isArray(i) ? i = i.join(". ") : typeof i == "object" && i !== null && (i = JSON.stringify(i));
|
|
505
|
+
const d = typeof i == "string" ? i.toLowerCase() : "";
|
|
506
|
+
return n === 401 ? d.includes("otp") ? new Ae(i || "OTP verification expired or invalid.", "OTP_EXPIRED", s) : new Ae(i || "Invalid credentials provided.", "INVALID_CREDENTIALS", s) : n === 403 ? new Ae(i || "Access token has expired or is invalid.", "TOKEN_EXPIRED", s) : n === 404 ? new Ae(i || "User or endpoint not found.", "USER_NOT_FOUND", s) : n >= 500 ? new Ae(i || "Internal server error occurred.", "SERVER_ERROR", s) : new Ae(i || "API request failed.", "UNKNOWN_ERROR", s);
|
|
507
|
+
}
|
|
508
|
+
return s != null && s.request ? new Ae("Network connection issue. Please check your connection.", "NETWORK_ERROR", s) : new Ae((s == null ? void 0 : s.message) || "An unknown error occurred.", "UNKNOWN_ERROR", s);
|
|
509
|
+
}
|
|
510
|
+
class Ut {
|
|
511
|
+
constructor(e, o) {
|
|
512
|
+
ze(this, "axiosInstance");
|
|
513
|
+
ze(this, "config");
|
|
514
|
+
this.axiosInstance = e, this.config = o;
|
|
515
|
+
}
|
|
516
|
+
getEndpoint(e, o) {
|
|
517
|
+
var n;
|
|
518
|
+
return ((n = this.config.endpoints) == null ? void 0 : n[e]) || o;
|
|
519
|
+
}
|
|
520
|
+
resolveUrl(e, o) {
|
|
521
|
+
if (!o) return e;
|
|
522
|
+
let n = e;
|
|
523
|
+
return Object.entries(o).forEach(([i, d]) => {
|
|
524
|
+
n = n.replace(`:${i}`, String(d));
|
|
525
|
+
}), n;
|
|
526
|
+
}
|
|
527
|
+
async login(e) {
|
|
528
|
+
var o;
|
|
529
|
+
try {
|
|
530
|
+
const n = { email: "email", password: "password", otp: "otp" }, i = ((o = this.config.requestMapping) == null ? void 0 : o.login) || n, d = nt({ site: this.config.site, ...e }, i);
|
|
531
|
+
if (d.otp !== void 0 && d.otp !== null) {
|
|
532
|
+
const m = Number(d.otp);
|
|
533
|
+
isNaN(m) || (d.otp = m);
|
|
534
|
+
}
|
|
535
|
+
const g = this.getEndpoint("login", "/identity/signin");
|
|
536
|
+
return (await this.axiosInstance.post(g, d)).data;
|
|
537
|
+
} catch (n) {
|
|
538
|
+
throw Ie(n);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
async signup(e) {
|
|
542
|
+
var o;
|
|
543
|
+
try {
|
|
544
|
+
const n = { name: "fullName", email: "email", password: "password" }, i = ((o = this.config.requestMapping) == null ? void 0 : o.signup) || n, d = nt({ site: this.config.site, ...e }, i), g = this.getEndpoint("signup", "/identity/signup");
|
|
545
|
+
return (await this.axiosInstance.post(g, d)).data;
|
|
546
|
+
} catch (n) {
|
|
547
|
+
throw Ie(n);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
async verifyIdentity(e, o) {
|
|
551
|
+
var n;
|
|
552
|
+
try {
|
|
553
|
+
const i = { email: "email" }, d = ((n = this.config.requestMapping) == null ? void 0 : n.verifyIdentity) || i, g = nt(e, d), l = this.getEndpoint("verifyIdentity", "/identity/verify"), m = this.resolveUrl(l, o);
|
|
554
|
+
if (m.includes("/identity/verify")) {
|
|
555
|
+
const k = this.config.site || sessionStorage.getItem("auth_registration_site") || "", b = g.email || g.Email;
|
|
556
|
+
return (await this.axiosInstance.post(m, null, {
|
|
557
|
+
params: { site: k, email: b }
|
|
558
|
+
})).data;
|
|
559
|
+
} else
|
|
560
|
+
return (await this.axiosInstance.post(m, g)).data;
|
|
561
|
+
} catch (i) {
|
|
562
|
+
throw Ie(i);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
async verifyOtp(e, o) {
|
|
566
|
+
var n;
|
|
567
|
+
try {
|
|
568
|
+
const i = this.getEndpoint("verifyOtp", "/identity/otp/validate"), d = this.resolveUrl(i, o);
|
|
569
|
+
if (e.ResendOtp) {
|
|
570
|
+
const l = this.getEndpoint("verifyIdentity", "/identity/verify"), m = e.Email || e.email || sessionStorage.getItem("auth_registration_email") || "", E = this.config.site || sessionStorage.getItem("auth_registration_site") || "";
|
|
571
|
+
return (await this.axiosInstance.post(l, null, {
|
|
572
|
+
params: { site: E, email: m }
|
|
573
|
+
})).data;
|
|
574
|
+
}
|
|
575
|
+
if (d.includes("/identity/otp/validate")) {
|
|
576
|
+
const l = e.Otp || e.otp, m = e.id || e.Id || sessionStorage.getItem("auth_registration_id") || "", k = {
|
|
577
|
+
site: e.site || e.Site || this.config.site || sessionStorage.getItem("auth_registration_site") || "",
|
|
578
|
+
id: m,
|
|
579
|
+
otp: typeof l == "string" ? parseInt(l, 10) : l
|
|
580
|
+
};
|
|
581
|
+
return (await this.axiosInstance.post(d, k)).data;
|
|
582
|
+
} else {
|
|
583
|
+
const l = nt(e, (n = this.config.requestMapping) == null ? void 0 : n.verifyOtp);
|
|
584
|
+
return (await this.axiosInstance.post(d, l)).data;
|
|
585
|
+
}
|
|
586
|
+
} catch (i) {
|
|
587
|
+
throw Ie(i);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
async resetPassword(e, o) {
|
|
591
|
+
var n;
|
|
592
|
+
try {
|
|
593
|
+
const i = { password: "password" }, d = ((n = this.config.requestMapping) == null ? void 0 : n.resetPassword) || i, g = nt(e, d), l = this.getEndpoint("resetPassword", "/identity/update"), m = this.resolveUrl(l, o);
|
|
594
|
+
if (m.includes("/identity/update")) {
|
|
595
|
+
const E = (o == null ? void 0 : o.site) || this.config.site || sessionStorage.getItem("auth_registration_site") || "", k = (o == null ? void 0 : o.id) || sessionStorage.getItem("auth_registration_id") || "", b = o == null ? void 0 : o.token;
|
|
596
|
+
return (await this.axiosInstance.put(m, g, {
|
|
597
|
+
params: { site: E, id: k },
|
|
598
|
+
headers: b ? { Authorization: `Bearer ${b}` } : void 0
|
|
599
|
+
})).data;
|
|
600
|
+
} else {
|
|
601
|
+
const E = o == null ? void 0 : o.token;
|
|
602
|
+
return (await this.axiosInstance.post(m, g, {
|
|
603
|
+
headers: E ? { Authorization: `Bearer ${E}` } : void 0
|
|
604
|
+
})).data;
|
|
605
|
+
}
|
|
606
|
+
} catch (i) {
|
|
607
|
+
throw Ie(i);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
async googleLogin(e) {
|
|
611
|
+
try {
|
|
612
|
+
const o = this.getEndpoint("googleLogin", "/identity/auth/google"), n = this.resolveUrl(o, { userId: e });
|
|
613
|
+
return (await this.axiosInstance.get(n)).data;
|
|
614
|
+
} catch (o) {
|
|
615
|
+
throw Ie(o);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
async logout() {
|
|
619
|
+
try {
|
|
620
|
+
const e = this.getEndpoint("logout", "/logout");
|
|
621
|
+
return (await this.axiosInstance.get(e)).data;
|
|
622
|
+
} catch (e) {
|
|
623
|
+
throw Ie(e);
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
async getUserProfile(e, o) {
|
|
627
|
+
try {
|
|
628
|
+
const n = this.getEndpoint("getUser", "/identity");
|
|
629
|
+
return (await this.axiosInstance.get(n, {
|
|
630
|
+
params: { site: e, id: o }
|
|
631
|
+
})).data;
|
|
632
|
+
} catch (n) {
|
|
633
|
+
throw Ie(n);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
async updateUser(e, o, n) {
|
|
637
|
+
try {
|
|
638
|
+
const i = this.getEndpoint("updateUser", "/identity/update");
|
|
639
|
+
return (await this.axiosInstance.put(i, e, {
|
|
640
|
+
params: { site: o, id: n }
|
|
641
|
+
})).data;
|
|
642
|
+
} catch (i) {
|
|
643
|
+
throw Ie(i);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
async deleteUser(e, o) {
|
|
647
|
+
try {
|
|
648
|
+
const n = this.getEndpoint("deleteUser", "/identity");
|
|
649
|
+
return (await this.axiosInstance.delete(n, {
|
|
650
|
+
params: { site: e, id: o }
|
|
651
|
+
})).data;
|
|
652
|
+
} catch (n) {
|
|
653
|
+
throw Ie(n);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const Is = ({ children: s, config: e }) => {
|
|
658
|
+
const [o, n] = S(null), [i, d] = S(null), [g, l] = S(null), [m, E] = S(!0), k = rt(() => new Ct(e.storage), [e.storage]), b = rt(() => new Ot(k), [k]), x = e.tokenKey || "Token", _ = e.refreshTokenKey || "refreshToken", v = async (c, h = null, p = null) => {
|
|
659
|
+
if (n(c), c) {
|
|
660
|
+
await b.saveToken(x, c);
|
|
661
|
+
const f = p || it(c) || null;
|
|
662
|
+
l(f);
|
|
663
|
+
} else
|
|
664
|
+
await b.removeToken(x), l(null);
|
|
665
|
+
h ? (d(h), await b.saveToken(_, h)) : c === null && (d(null), await b.removeToken(_));
|
|
666
|
+
}, { axiosInstance: O, authApi: L } = rt(() => {
|
|
667
|
+
const c = At(
|
|
668
|
+
e,
|
|
669
|
+
b,
|
|
670
|
+
(p, f) => {
|
|
671
|
+
n(p), f && d(f);
|
|
672
|
+
},
|
|
673
|
+
() => {
|
|
674
|
+
n(null), d(null), l(null);
|
|
675
|
+
}
|
|
676
|
+
), h = new Ut(c, e);
|
|
677
|
+
return { axiosInstance: c, authApi: h };
|
|
678
|
+
}, [e, b]);
|
|
679
|
+
st(() => {
|
|
680
|
+
(async () => {
|
|
681
|
+
var h, p, f;
|
|
682
|
+
try {
|
|
683
|
+
const y = await b.getToken(x), w = await b.getToken(_);
|
|
684
|
+
if (y)
|
|
685
|
+
if (b.isExpired(y))
|
|
686
|
+
if (e.autoRefresh !== !1 && w)
|
|
687
|
+
try {
|
|
688
|
+
let a;
|
|
689
|
+
if (e.isExternalApiCall && e.onRefresh)
|
|
690
|
+
a = await e.onRefresh(w);
|
|
691
|
+
else {
|
|
692
|
+
const N = ((h = e.endpoints) == null ? void 0 : h.refreshToken) || "/identity/access-token", U = N.includes("/identity/access-token");
|
|
693
|
+
a = (await O.post(
|
|
694
|
+
N,
|
|
695
|
+
U ? null : { refreshToken: w },
|
|
696
|
+
{
|
|
697
|
+
headers: U ? { refreshToken: w } : {}
|
|
698
|
+
}
|
|
699
|
+
)).data;
|
|
700
|
+
}
|
|
701
|
+
const u = Qe(a, (p = e.responseMapping) == null ? void 0 : p.token), j = tt(a, (f = e.responseMapping) == null ? void 0 : f.refreshToken) || w;
|
|
702
|
+
u ? await v(u, j) : await v(null);
|
|
703
|
+
} catch {
|
|
704
|
+
await v(null);
|
|
705
|
+
}
|
|
706
|
+
else
|
|
707
|
+
await v(null);
|
|
708
|
+
else
|
|
709
|
+
await v(y, w);
|
|
710
|
+
} catch (y) {
|
|
711
|
+
console.error("Auth SDK Provider: session recovery failed.", y);
|
|
712
|
+
} finally {
|
|
713
|
+
E(!1);
|
|
714
|
+
}
|
|
715
|
+
})();
|
|
716
|
+
}, []);
|
|
717
|
+
const V = () => o ? it(o) : null, P = async (c) => {
|
|
718
|
+
var h, p, f, y, w, a;
|
|
719
|
+
try {
|
|
720
|
+
const u = e.isExternalApiCall && e.onLogin ? await e.onLogin(c) : await L.login(c);
|
|
721
|
+
if (u && (u.error || u.success === !1))
|
|
722
|
+
throw new Error(u.error || u.message || "Login failed.");
|
|
723
|
+
const j = Qe(u, (h = e.responseMapping) == null ? void 0 : h.token), N = tt(u, (p = e.responseMapping) == null ? void 0 : p.refreshToken), U = dt(u, (f = e.responseMapping) == null ? void 0 : f.user);
|
|
724
|
+
return j ? (await v(j, N, U), ne.emit("LOGIN_SUCCESS", { user: U || it(j), token: j })) : l(U || null), u;
|
|
725
|
+
} catch (u) {
|
|
726
|
+
if (u && (u.message === "Email not verified" || ((a = (w = (y = u.originalError) == null ? void 0 : y.response) == null ? void 0 : w.data) == null ? void 0 : a.message) === "Email not verified")) {
|
|
727
|
+
const N = c.email || c.Email;
|
|
728
|
+
if (N) {
|
|
729
|
+
sessionStorage.setItem("auth_registration_email", N);
|
|
730
|
+
try {
|
|
731
|
+
await A({ email: N });
|
|
732
|
+
} catch (U) {
|
|
733
|
+
console.error("Failed to trigger OTP email dispatch:", U);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
ne.emit("OTP_SENT", { email: N });
|
|
737
|
+
}
|
|
738
|
+
throw ne.emit("LOGIN_FAILED", u), u;
|
|
739
|
+
}
|
|
740
|
+
}, G = async (c) => {
|
|
741
|
+
var h, p, f;
|
|
742
|
+
try {
|
|
743
|
+
const y = e.isExternalApiCall && e.onSignup ? await e.onSignup(c) : await L.signup(c);
|
|
744
|
+
if (y && (y.error || y.success === !1))
|
|
745
|
+
throw new Error(y.error || y.message || "Registration failed.");
|
|
746
|
+
if (y && y.id) {
|
|
747
|
+
sessionStorage.setItem("auth_registration_id", y.id), sessionStorage.setItem("auth_registration_site", y.site || e.site || "");
|
|
748
|
+
const j = c.Email || c.email;
|
|
749
|
+
j && sessionStorage.setItem("auth_registration_email", j);
|
|
750
|
+
}
|
|
751
|
+
y && y.isOtpSent && y.isVerified === !1 && ne.emit("OTP_SENT", y);
|
|
752
|
+
const w = Qe(y, (h = e.responseMapping) == null ? void 0 : h.token), a = tt(y, (p = e.responseMapping) == null ? void 0 : p.refreshToken), u = dt(y, (f = e.responseMapping) == null ? void 0 : f.user);
|
|
753
|
+
return w ? await v(w, a, u) : l(u || null), y;
|
|
754
|
+
} catch (y) {
|
|
755
|
+
throw y;
|
|
756
|
+
}
|
|
757
|
+
}, T = async (c, h) => {
|
|
758
|
+
var p, f, y;
|
|
759
|
+
try {
|
|
760
|
+
const w = e.isExternalApiCall && e.onVerifyOtp ? await e.onVerifyOtp(c, h) : await L.verifyOtp(c, h);
|
|
761
|
+
if (w && (w.error || w.success === !1))
|
|
762
|
+
throw new Error(w.error || w.message || "OTP verification failed.");
|
|
763
|
+
const a = Qe(w, (p = e.responseMapping) == null ? void 0 : p.token), u = tt(w, (f = e.responseMapping) == null ? void 0 : f.refreshToken), j = dt(w, (y = e.responseMapping) == null ? void 0 : y.user), N = c.isResetPassword === !0 || sessionStorage.getItem("auth_reset_flow") === "true";
|
|
764
|
+
return a && !N && await v(a, u, j), c.ResendOtp || ne.emit("OTP_VERIFIED", w), w;
|
|
765
|
+
} catch (w) {
|
|
766
|
+
throw w;
|
|
767
|
+
}
|
|
768
|
+
}, A = async (c, h) => {
|
|
769
|
+
try {
|
|
770
|
+
const p = e.isExternalApiCall && e.onVerifyIdentity ? await e.onVerifyIdentity(c, h) : await L.verifyIdentity(c, h);
|
|
771
|
+
if (p && (p.error || p.success === !1))
|
|
772
|
+
throw new Error(p.error || p.message || "Identity verification request failed.");
|
|
773
|
+
if (sessionStorage.setItem("auth_reset_flow", "true"), p && p.id) {
|
|
774
|
+
sessionStorage.setItem("auth_registration_id", p.id), sessionStorage.setItem("auth_registration_site", p.site || e.site || "");
|
|
775
|
+
const f = c.Email || c.email;
|
|
776
|
+
f && sessionStorage.setItem("auth_registration_email", f);
|
|
777
|
+
}
|
|
778
|
+
return p;
|
|
779
|
+
} catch (p) {
|
|
780
|
+
throw p;
|
|
781
|
+
}
|
|
782
|
+
}, Q = async (c, h) => {
|
|
783
|
+
var p, f, y;
|
|
784
|
+
try {
|
|
785
|
+
const w = e.isExternalApiCall && e.onResetPassword ? await e.onResetPassword(c, h) : await L.resetPassword(c, h);
|
|
786
|
+
if (w && (w.error || w.success === !1))
|
|
787
|
+
throw new Error(w.error || w.message || "Password reset failed.");
|
|
788
|
+
const a = Qe(w, (p = e.responseMapping) == null ? void 0 : p.token), u = tt(w, (f = e.responseMapping) == null ? void 0 : f.refreshToken), j = dt(w, (y = e.responseMapping) == null ? void 0 : y.user);
|
|
789
|
+
return a && await v(a, u, j), sessionStorage.removeItem("auth_reset_flow"), ne.emit("PASSWORD_RESET", w), w;
|
|
790
|
+
} catch (w) {
|
|
791
|
+
throw w;
|
|
792
|
+
}
|
|
793
|
+
}, le = async () => {
|
|
794
|
+
var f, y;
|
|
795
|
+
const c = await b.getToken(_);
|
|
796
|
+
if (!c) throw new Error("Auth SDK: No refresh token is cached.");
|
|
797
|
+
let h;
|
|
798
|
+
if (e.isExternalApiCall && e.onRefresh)
|
|
799
|
+
h = await e.onRefresh(c);
|
|
800
|
+
else {
|
|
801
|
+
const w = ((f = e.endpoints) == null ? void 0 : f.refreshToken) || "/identity/access-token", a = w.includes("/identity/access-token");
|
|
802
|
+
h = (await O.post(
|
|
803
|
+
w,
|
|
804
|
+
a ? null : { refreshToken: c },
|
|
805
|
+
{
|
|
806
|
+
headers: a ? { refreshToken: c } : {}
|
|
807
|
+
}
|
|
808
|
+
)).data;
|
|
809
|
+
}
|
|
810
|
+
const p = Qe(h, (y = e.responseMapping) == null ? void 0 : y.token);
|
|
811
|
+
return p ? (await v(p), p) : null;
|
|
812
|
+
}, se = async (c, h) => {
|
|
813
|
+
try {
|
|
814
|
+
const p = V(), f = c || (p == null ? void 0 : p.site) || e.site || "", y = h || (p == null ? void 0 : p.userId) || "";
|
|
815
|
+
return e.isExternalApiCall && e.onGetUser ? await e.onGetUser(f, y) : await L.getUserProfile(f, y);
|
|
816
|
+
} catch (p) {
|
|
817
|
+
throw p;
|
|
818
|
+
}
|
|
819
|
+
}, F = async (c, h, p) => {
|
|
820
|
+
try {
|
|
821
|
+
const f = V(), y = h || (f == null ? void 0 : f.site) || e.site || "", w = p || (f == null ? void 0 : f.userId) || "", a = e.isExternalApiCall && e.onUpdateUser ? await e.onUpdateUser(c, y, w) : await L.updateUser(c, y, w);
|
|
822
|
+
if (a && (a.error || a.success === !1))
|
|
823
|
+
throw new Error(a.error || a.message || "Profile update failed.");
|
|
824
|
+
return a && l((u) => ({ ...u, ...a })), a;
|
|
825
|
+
} catch (f) {
|
|
826
|
+
throw f;
|
|
827
|
+
}
|
|
828
|
+
}, ee = async (c, h) => {
|
|
829
|
+
try {
|
|
830
|
+
const p = V(), f = c || (p == null ? void 0 : p.site) || e.site || "", y = h || (p == null ? void 0 : p.userId) || "", w = e.isExternalApiCall && e.onDeleteUser ? await e.onDeleteUser(f, y) : await L.deleteUser(f, y);
|
|
831
|
+
return await v(null), ne.emit("LOGOUT"), w;
|
|
832
|
+
} catch (p) {
|
|
833
|
+
throw p;
|
|
834
|
+
}
|
|
835
|
+
}, re = async () => {
|
|
836
|
+
try {
|
|
837
|
+
e.isExternalApiCall && e.onLogout ? await e.onLogout() : await L.logout();
|
|
838
|
+
} catch {
|
|
839
|
+
} finally {
|
|
840
|
+
await v(null), ne.emit("LOGOUT");
|
|
841
|
+
}
|
|
842
|
+
}, J = !!o, M = rt(() => {
|
|
843
|
+
var te, H;
|
|
844
|
+
const c = {}, h = e.theme;
|
|
845
|
+
let p = "#3f51b5", f = "#303f9f", y = "#ff4081", w = "#f4f6f8", a = "#ffffff", u = "#1a1f36", j = "#5c7080", N = "#e1e8ed", U = "#d32f2f", q = "#2e7d32", R = "8px", W = "8px", K = "8px", C = "8px", B = "16px", $ = "system-ui, -apple-system, sans-serif", X = "system-ui, -apple-system, sans-serif", Y = "linear-gradient(135deg, #e0e8f5 0%, #f4f6f8 100%)";
|
|
846
|
+
if (h === "dark")
|
|
847
|
+
p = "#6366f1", f = "#4f46e5", y = "#ec4899", w = "#0f172a", a = "#1e293b", u = "#f8fafc", j = "#94a3b8", N = "#334155", U = "#f87171", q = "#4ade80", R = "8px", W = "16px", K = "8px", C = "8px", Y = "linear-gradient(135deg, #090d16 0%, #0f172a 100%)";
|
|
848
|
+
else if (h && typeof h == "object") {
|
|
849
|
+
const z = h.colors || {};
|
|
850
|
+
z.primary && (p = z.primary), z.primaryHover && (f = z.primaryHover), z.secondary && (y = z.secondary), z.background && (w = z.background), z.surface && (a = z.surface), z.text && (u = z.text), z.textMuted && (j = z.textMuted), z.border && (N = z.border), z.error && (U = z.error), z.success && (q = z.success), (te = h.fonts) != null && te.body && ($ = h.fonts.body), (H = h.fonts) != null && H.heading && (X = h.fonts.heading), h.borderRadius && (R = h.borderRadius, W = h.borderRadius, K = h.borderRadius, C = h.borderRadius), h.borderRadiusCard && (W = h.borderRadiusCard), h.borderRadiusButton && (K = h.borderRadiusButton), h.borderRadiusInput && (C = h.borderRadiusInput), h.spacing && (B = h.spacing), h.background && (Y = h.background);
|
|
851
|
+
}
|
|
852
|
+
return c["--auth-color-primary"] = p, c["--auth-color-primary-hover"] = f, c["--auth-color-secondary"] = y, c["--auth-color-background"] = w, c["--auth-color-surface"] = a, c["--auth-color-text"] = u, c["--auth-color-text-muted"] = j, c["--auth-color-border"] = N, c["--auth-color-error"] = U, c["--auth-color-success"] = q, c["--auth-font-body"] = $, c["--auth-font-heading"] = X, c["--auth-border-radius"] = R, c["--auth-border-radius-card"] = W, c["--auth-border-radius-button"] = K, c["--auth-border-radius-input"] = C, c["--auth-spacing"] = B, c["--auth-bg-style"] = Y, c;
|
|
853
|
+
}, [e.theme]), D = rt(() => ({
|
|
854
|
+
user: g,
|
|
855
|
+
token: o,
|
|
856
|
+
refreshToken: i,
|
|
857
|
+
isAuthenticated: J,
|
|
858
|
+
loading: m,
|
|
859
|
+
login: P,
|
|
860
|
+
logout: re,
|
|
861
|
+
signup: G,
|
|
862
|
+
verifyOtp: T,
|
|
863
|
+
verifyIdentity: A,
|
|
864
|
+
resetPassword: Q,
|
|
865
|
+
refresh: le,
|
|
866
|
+
getUserProfile: se,
|
|
867
|
+
updateUser: F,
|
|
868
|
+
deleteUser: ee,
|
|
869
|
+
config: e,
|
|
870
|
+
authApi: L
|
|
871
|
+
}), [g, o, i, J, m, e, L]);
|
|
872
|
+
return /* @__PURE__ */ t.jsx(bt.Provider, { value: D, children: /* @__PURE__ */ t.jsx("div", { style: M, className: "auth-sdk-provider-container", children: s }) });
|
|
873
|
+
};
|
|
874
|
+
function he() {
|
|
875
|
+
const s = Pt(bt);
|
|
876
|
+
if (!s)
|
|
877
|
+
throw new Error("useAuth must be used within an AuthProvider");
|
|
878
|
+
return s;
|
|
879
|
+
}
|
|
880
|
+
function Ft() {
|
|
881
|
+
const { login: s } = he(), [e, o] = S(!1), [n, i] = S(null), [d, g] = S(!1);
|
|
882
|
+
return { loading: e, error: n, success: d, execute: async (E) => {
|
|
883
|
+
o(!0), i(null), g(!1);
|
|
884
|
+
try {
|
|
885
|
+
const k = await s(E);
|
|
886
|
+
return g(!0), k;
|
|
887
|
+
} catch (k) {
|
|
888
|
+
throw i((k == null ? void 0 : k.message) || "Login failed."), k;
|
|
889
|
+
} finally {
|
|
890
|
+
o(!1);
|
|
891
|
+
}
|
|
892
|
+
}, reset: () => {
|
|
893
|
+
i(null), g(!1);
|
|
894
|
+
} };
|
|
895
|
+
}
|
|
896
|
+
function Mt() {
|
|
897
|
+
const { signup: s } = he(), [e, o] = S(!1), [n, i] = S(null), [d, g] = S(!1);
|
|
898
|
+
return { loading: e, error: n, success: d, execute: async (E) => {
|
|
899
|
+
o(!0), i(null), g(!1);
|
|
900
|
+
try {
|
|
901
|
+
const k = await s(E);
|
|
902
|
+
return g(!0), k;
|
|
903
|
+
} catch (k) {
|
|
904
|
+
throw i((k == null ? void 0 : k.message) || "Registration failed."), k;
|
|
905
|
+
} finally {
|
|
906
|
+
o(!1);
|
|
907
|
+
}
|
|
908
|
+
}, reset: () => {
|
|
909
|
+
i(null), g(!1);
|
|
910
|
+
} };
|
|
911
|
+
}
|
|
912
|
+
function $t() {
|
|
913
|
+
const { verifyIdentity: s } = he(), [e, o] = S(!1), [n, i] = S(null), [d, g] = S(!1);
|
|
914
|
+
return { loading: e, error: n, success: d, execute: async (E, k) => {
|
|
915
|
+
o(!0), i(null), g(!1);
|
|
916
|
+
try {
|
|
917
|
+
const b = await s(E, k);
|
|
918
|
+
return g(!0), b;
|
|
919
|
+
} catch (b) {
|
|
920
|
+
throw i((b == null ? void 0 : b.message) || "Failed to submit identity verification request."), b;
|
|
921
|
+
} finally {
|
|
922
|
+
o(!1);
|
|
923
|
+
}
|
|
924
|
+
}, reset: () => {
|
|
925
|
+
i(null), g(!1);
|
|
926
|
+
} };
|
|
927
|
+
}
|
|
928
|
+
function Dt() {
|
|
929
|
+
const { verifyOtp: s } = he(), [e, o] = S(!1), [n, i] = S(null), [d, g] = S(!1);
|
|
930
|
+
return { loading: e, error: n, success: d, execute: async (k, b) => {
|
|
931
|
+
o(!0), i(null), g(!1);
|
|
932
|
+
try {
|
|
933
|
+
const x = await s(k, b);
|
|
934
|
+
return g(!0), x;
|
|
935
|
+
} catch (x) {
|
|
936
|
+
throw i((x == null ? void 0 : x.message) || "OTP verification failed."), x;
|
|
937
|
+
} finally {
|
|
938
|
+
o(!1);
|
|
939
|
+
}
|
|
940
|
+
}, resend: async (k, b) => {
|
|
941
|
+
o(!0), i(null);
|
|
942
|
+
try {
|
|
943
|
+
return await s(k, b);
|
|
944
|
+
} catch (x) {
|
|
945
|
+
throw i((x == null ? void 0 : x.message) || "Failed to resend OTP."), x;
|
|
946
|
+
} finally {
|
|
947
|
+
o(!1);
|
|
948
|
+
}
|
|
949
|
+
}, reset: () => {
|
|
950
|
+
i(null), g(!1);
|
|
951
|
+
} };
|
|
952
|
+
}
|
|
953
|
+
function Bt() {
|
|
954
|
+
const { resetPassword: s } = he(), [e, o] = S(!1), [n, i] = S(null), [d, g] = S(!1);
|
|
955
|
+
return { loading: e, error: n, success: d, execute: async (E, k) => {
|
|
956
|
+
o(!0), i(null), g(!1);
|
|
957
|
+
try {
|
|
958
|
+
const b = await s(E, k);
|
|
959
|
+
return g(!0), b;
|
|
960
|
+
} catch (b) {
|
|
961
|
+
throw i((b == null ? void 0 : b.message) || "Password reset failed."), b;
|
|
962
|
+
} finally {
|
|
963
|
+
o(!1);
|
|
964
|
+
}
|
|
965
|
+
}, reset: () => {
|
|
966
|
+
i(null), g(!1);
|
|
967
|
+
} };
|
|
968
|
+
}
|
|
969
|
+
function qt() {
|
|
970
|
+
const { updateUser: s } = he(), [e, o] = S(!1), [n, i] = S(null), [d, g] = S(!1);
|
|
971
|
+
return { loading: e, error: n, success: d, execute: async (E, k, b) => {
|
|
972
|
+
o(!0), i(null), g(!1);
|
|
973
|
+
try {
|
|
974
|
+
const x = await s(E, k, b);
|
|
975
|
+
return g(!0), x;
|
|
976
|
+
} catch (x) {
|
|
977
|
+
throw i((x == null ? void 0 : x.message) || "Profile update failed."), x;
|
|
978
|
+
} finally {
|
|
979
|
+
o(!1);
|
|
980
|
+
}
|
|
981
|
+
}, reset: () => {
|
|
982
|
+
i(null), g(!1);
|
|
983
|
+
} };
|
|
984
|
+
}
|
|
985
|
+
const Wt = "_card_1gys8_2", Vt = "_heading_1gys8_18", Gt = "_subtext_1gys8_30", Kt = "_form_1gys8_39", Ht = "_formGroup_1gys8_45", Yt = "_label_1gys8_52", Jt = "_inputWrapper_1gys8_59", Xt = "_input_1gys8_59", Zt = "_inputError_1gys8_89", Qt = "_inputIcon_1gys8_98", es = "_eyeIcon_1gys8_116", ts = "_errorText_1gys8_121", ss = "_button_1gys8_131", rs = "_link_1gys8_160", as = "_footerText_1gys8_177", os = "_divider_1gys8_185", ns = "_googleButton_1gys8_211", is = "_googleIcon_1gys8_233", ls = "_apiErrorBlock_1gys8_267", cs = "_apiErrorIcon_1gys8_285", ds = "_apiSuccessBlock_1gys8_294", us = "_apiSuccessIcon_1gys8_312", r = {
|
|
986
|
+
card: Wt,
|
|
987
|
+
heading: Vt,
|
|
988
|
+
subtext: Gt,
|
|
989
|
+
form: Kt,
|
|
990
|
+
formGroup: Ht,
|
|
991
|
+
label: Yt,
|
|
992
|
+
inputWrapper: Jt,
|
|
993
|
+
input: Xt,
|
|
994
|
+
inputError: Zt,
|
|
995
|
+
inputIcon: Qt,
|
|
996
|
+
eyeIcon: es,
|
|
997
|
+
errorText: ts,
|
|
998
|
+
button: ss,
|
|
999
|
+
link: rs,
|
|
1000
|
+
footerText: as,
|
|
1001
|
+
divider: os,
|
|
1002
|
+
googleButton: ns,
|
|
1003
|
+
googleIcon: is,
|
|
1004
|
+
apiErrorBlock: ls,
|
|
1005
|
+
apiErrorIcon: cs,
|
|
1006
|
+
apiSuccessBlock: ds,
|
|
1007
|
+
apiSuccessIcon: us
|
|
1008
|
+
}, jt = ({ buttonText: s, className: e }) => {
|
|
1009
|
+
var d, g;
|
|
1010
|
+
const { config: o } = he(), n = () => {
|
|
1011
|
+
var E;
|
|
1012
|
+
const l = ((E = o.endpoints) == null ? void 0 : E.googleLogin) || "/auth/google", m = l.startsWith("http") ? l : `${o.apiBaseUrl}${l}`;
|
|
1013
|
+
window.open(m, "_self");
|
|
1014
|
+
}, i = s || ((g = (d = o.customization) == null ? void 0 : d.buttonText) == null ? void 0 : g.google) || "Sign in with Google";
|
|
1015
|
+
return /* @__PURE__ */ t.jsxs(
|
|
1016
|
+
"button",
|
|
1017
|
+
{
|
|
1018
|
+
type: "button",
|
|
1019
|
+
onClick: n,
|
|
1020
|
+
className: `${r.googleButton} ${e || ""}`,
|
|
1021
|
+
"aria-label": i,
|
|
1022
|
+
children: [
|
|
1023
|
+
/* @__PURE__ */ t.jsxs("svg", { className: r.googleIcon, viewBox: "0 0 24 24", "aria-hidden": "true", children: [
|
|
1024
|
+
/* @__PURE__ */ t.jsx(
|
|
1025
|
+
"path",
|
|
1026
|
+
{
|
|
1027
|
+
fill: "#4285F4",
|
|
1028
|
+
d: "M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"
|
|
1029
|
+
}
|
|
1030
|
+
),
|
|
1031
|
+
/* @__PURE__ */ t.jsx(
|
|
1032
|
+
"path",
|
|
1033
|
+
{
|
|
1034
|
+
fill: "#34A853",
|
|
1035
|
+
d: "M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"
|
|
1036
|
+
}
|
|
1037
|
+
),
|
|
1038
|
+
/* @__PURE__ */ t.jsx(
|
|
1039
|
+
"path",
|
|
1040
|
+
{
|
|
1041
|
+
fill: "#FBBC05",
|
|
1042
|
+
d: "M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.06H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.94l2.85-2.22.81-.63z"
|
|
1043
|
+
}
|
|
1044
|
+
),
|
|
1045
|
+
/* @__PURE__ */ t.jsx(
|
|
1046
|
+
"path",
|
|
1047
|
+
{
|
|
1048
|
+
fill: "#EA4335",
|
|
1049
|
+
d: "M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.06l3.66 2.84c.87-2.6 3.3-4.52 6.16-4.52z"
|
|
1050
|
+
}
|
|
1051
|
+
)
|
|
1052
|
+
] }),
|
|
1053
|
+
/* @__PURE__ */ t.jsx("span", { children: i })
|
|
1054
|
+
]
|
|
1055
|
+
}
|
|
1056
|
+
);
|
|
1057
|
+
}, Ue = ({ message: s, type: e, style: o, onDismiss: n }) => {
|
|
1058
|
+
const [i, d] = S(s);
|
|
1059
|
+
return st(() => {
|
|
1060
|
+
d(s);
|
|
1061
|
+
}, [s]), st(() => {
|
|
1062
|
+
if (i) {
|
|
1063
|
+
const g = setTimeout(() => {
|
|
1064
|
+
d(null), n && n();
|
|
1065
|
+
}, 3e3);
|
|
1066
|
+
return () => clearTimeout(g);
|
|
1067
|
+
}
|
|
1068
|
+
}, [i, n]), i ? e === "success" ? /* @__PURE__ */ t.jsxs("div", { className: r.apiSuccessBlock, style: o, role: "status", children: [
|
|
1069
|
+
/* @__PURE__ */ t.jsx("svg", { className: r.apiSuccessIcon, viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ t.jsx("path", { fillRule: "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z", clipRule: "evenodd" }) }),
|
|
1070
|
+
/* @__PURE__ */ t.jsx("span", { children: i })
|
|
1071
|
+
] }) : /* @__PURE__ */ t.jsxs("div", { className: r.apiErrorBlock, style: o, role: "alert", children: [
|
|
1072
|
+
/* @__PURE__ */ t.jsx("svg", { className: r.apiErrorIcon, viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ t.jsx("path", { fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z", clipRule: "evenodd" }) }),
|
|
1073
|
+
/* @__PURE__ */ t.jsx("span", { children: i })
|
|
1074
|
+
] }) : null;
|
|
1075
|
+
}, ps = I.object({
|
|
1076
|
+
email: I.string().email("Please enter a valid email address"),
|
|
1077
|
+
password: I.string().min(1, "Password is required")
|
|
1078
|
+
}), ms = I.object({
|
|
1079
|
+
email: I.string().email("Please enter a valid email address")
|
|
1080
|
+
}), hs = I.object({
|
|
1081
|
+
email: I.string().email("Please enter a valid email address"),
|
|
1082
|
+
otp: I.string().min(1, "OTP is required")
|
|
1083
|
+
}), fs = I.object({
|
|
1084
|
+
name: I.string().min(1, "Name is required"),
|
|
1085
|
+
email: I.string().email("Please enter a valid email address"),
|
|
1086
|
+
password: I.string().min(6, "Password must be at least 6 characters long"),
|
|
1087
|
+
verifyPassword: I.string().min(1, "Please confirm your password")
|
|
1088
|
+
}).refine((s) => s.password === s.verifyPassword, {
|
|
1089
|
+
message: "Passwords do not match",
|
|
1090
|
+
path: ["verifyPassword"]
|
|
1091
|
+
}), gs = I.object({
|
|
1092
|
+
email: I.string().email("Please enter a valid email address")
|
|
1093
|
+
}), ys = I.object({
|
|
1094
|
+
otp: I.string().min(4, "OTP must be at least 4 digits").max(8, "OTP is too long")
|
|
1095
|
+
}), xs = I.object({
|
|
1096
|
+
password: I.string().min(6, "Password must be at least 6 characters long"),
|
|
1097
|
+
verifyPassword: I.string().min(1, "Please confirm your password")
|
|
1098
|
+
}).refine((s) => s.password === s.verifyPassword, {
|
|
1099
|
+
message: "Passwords do not match",
|
|
1100
|
+
path: ["verifyPassword"]
|
|
1101
|
+
}), ws = I.object({
|
|
1102
|
+
fullName: I.string().min(1, "Full name is required").optional().or(I.literal("")),
|
|
1103
|
+
email: I.string().email("Please enter a valid email address").optional().or(I.literal("")),
|
|
1104
|
+
username: I.string().optional(),
|
|
1105
|
+
phoneNumber: I.string().optional(),
|
|
1106
|
+
password: I.string().min(6, "Password must be at least 6 characters long").optional().or(I.literal("")),
|
|
1107
|
+
profileUrl: I.string().url("Please enter a valid URL").optional().or(I.literal("")),
|
|
1108
|
+
city: I.string().optional(),
|
|
1109
|
+
state: I.string().optional(),
|
|
1110
|
+
country: I.string().optional(),
|
|
1111
|
+
postalcode: I.string().optional(),
|
|
1112
|
+
timezone: I.string().optional()
|
|
1113
|
+
}), vs = ({
|
|
1114
|
+
components: s,
|
|
1115
|
+
labels: e,
|
|
1116
|
+
buttonText: o,
|
|
1117
|
+
placeholders: n,
|
|
1118
|
+
validationSchema: i,
|
|
1119
|
+
onSuccess: d,
|
|
1120
|
+
onForgotPasswordClick: g,
|
|
1121
|
+
onSignupClick: l
|
|
1122
|
+
}) => {
|
|
1123
|
+
var Y, te, H, z, ce, fe, pe, ae, je, ge, Te, we, _e, ye, xe, me, ve, Pe, Fe, Me, $e, De, Be, qe, We, Ve, Ge, Ke, He, Ye, Je, Xe, Re, Ce, Ee, ue, ke, Le, de, Se, lt, Ze;
|
|
1124
|
+
const { config: m, verifyIdentity: E } = he(), { loading: k, error: b, execute: x, reset: _ } = Ft(), [v, O] = S({}), [L, V] = S(!0), [P, G] = S(null), [T, A] = S("password"), [Q, le] = S(""), [se, F] = S(""), [ee, re] = S(!1), [J, M] = S(!1), [D, c] = S(null), h = i || ((te = (Y = m.customization) == null ? void 0 : Y.validationSchema) == null ? void 0 : te.login) || ps, p = async (oe) => {
|
|
1125
|
+
oe.preventDefault(), O({}), c(null), G(null);
|
|
1126
|
+
try {
|
|
1127
|
+
ms.parse({ email: Q });
|
|
1128
|
+
} catch (Z) {
|
|
1129
|
+
if (Z instanceof I.ZodError) {
|
|
1130
|
+
O({ [C]: Z.errors[0].message });
|
|
1131
|
+
return;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
M(!0);
|
|
1135
|
+
try {
|
|
1136
|
+
await E({ [C]: Q }), re(!0), c("OTP has been sent to your e-mail.");
|
|
1137
|
+
} catch (Z) {
|
|
1138
|
+
G(Z.message || "Failed to send OTP.");
|
|
1139
|
+
} finally {
|
|
1140
|
+
M(!1);
|
|
1141
|
+
}
|
|
1142
|
+
}, f = async (oe) => {
|
|
1143
|
+
if (oe.preventDefault(), O({}), c(null), G(null), T === "otp") {
|
|
1144
|
+
if (!ee)
|
|
1145
|
+
return;
|
|
1146
|
+
try {
|
|
1147
|
+
hs.parse({ email: Q, otp: se });
|
|
1148
|
+
} catch (Z) {
|
|
1149
|
+
if (Z instanceof I.ZodError) {
|
|
1150
|
+
const be = {};
|
|
1151
|
+
Z.errors.forEach((Oe) => {
|
|
1152
|
+
if (Oe.path[0]) {
|
|
1153
|
+
const Ne = Oe.path[0].toString() === "email" ? C : Oe.path[0].toString() === "otp" ? $ : Oe.path[0].toString();
|
|
1154
|
+
be[Ne] = Oe.message;
|
|
1155
|
+
}
|
|
1156
|
+
}), O(be);
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
try {
|
|
1161
|
+
const Z = await x({ [C]: Q, [$]: se });
|
|
1162
|
+
d && d(Z);
|
|
1163
|
+
} catch (Z) {
|
|
1164
|
+
G((Z == null ? void 0 : Z.message) || "Verification failed.");
|
|
1165
|
+
}
|
|
1166
|
+
} else {
|
|
1167
|
+
const Z = new FormData(oe.currentTarget), be = Object.fromEntries(Z.entries()), Oe = {
|
|
1168
|
+
email: be[C],
|
|
1169
|
+
password: be[B]
|
|
1170
|
+
};
|
|
1171
|
+
try {
|
|
1172
|
+
h.parse(Oe);
|
|
1173
|
+
} catch (Ne) {
|
|
1174
|
+
if (Ne instanceof I.ZodError) {
|
|
1175
|
+
const ft = {};
|
|
1176
|
+
Ne.errors.forEach((ut) => {
|
|
1177
|
+
if (ut.path[0]) {
|
|
1178
|
+
const pt = ut.path[0].toString(), Et = pt === "email" ? C : pt === "password" ? B : pt;
|
|
1179
|
+
ft[Et] = ut.message;
|
|
1180
|
+
}
|
|
1181
|
+
}), O(ft);
|
|
1182
|
+
return;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
try {
|
|
1186
|
+
const Ne = await x(be);
|
|
1187
|
+
d && d(Ne);
|
|
1188
|
+
} catch (Ne) {
|
|
1189
|
+
G((Ne == null ? void 0 : Ne.message) || "Login failed."), console.error("[SDK Login Component] Error caught during form submit:", Ne);
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
}, y = (s == null ? void 0 : s.Card) || "div", w = (s == null ? void 0 : s.Button) || "button", a = s == null ? void 0 : s.Input, u = ((z = (H = m.customization) == null ? void 0 : H.labels) == null ? void 0 : z.loginTitle) || "Log In", j = (e == null ? void 0 : e.email) || ((fe = (ce = m.customization) == null ? void 0 : ce.labels) == null ? void 0 : fe.loginEmail) || ((ae = (pe = m.customization) == null ? void 0 : pe.labels) == null ? void 0 : ae.email) || "E-mail", N = (e == null ? void 0 : e.password) || ((ge = (je = m.customization) == null ? void 0 : je.labels) == null ? void 0 : ge.loginPassword) || ((we = (Te = m.customization) == null ? void 0 : Te.labels) == null ? void 0 : we.password) || "Password", U = o || ((ye = (_e = m.customization) == null ? void 0 : _e.buttonText) == null ? void 0 : ye.login) || "Login", q = (n == null ? void 0 : n.email) || ((me = (xe = m.customization) == null ? void 0 : xe.placeholders) == null ? void 0 : me.loginEmail) || ((Pe = (ve = m.customization) == null ? void 0 : ve.placeholders) == null ? void 0 : Pe.email) || "E-mail", R = (n == null ? void 0 : n.password) || ((Me = (Fe = m.customization) == null ? void 0 : Fe.placeholders) == null ? void 0 : Me.loginPassword) || ((De = ($e = m.customization) == null ? void 0 : $e.placeholders) == null ? void 0 : De.password) || "Password", W = ((qe = (Be = m.customization) == null ? void 0 : Be.labels) == null ? void 0 : qe.otpLabel) || "OTP Code", K = ((Ve = (We = m.customization) == null ? void 0 : We.placeholders) == null ? void 0 : Ve.otpPlaceholder) || "123456", C = ((Ke = (Ge = m.requestMapping) == null ? void 0 : Ge.login) == null ? void 0 : Ke.email) || "email", B = ((Ye = (He = m.requestMapping) == null ? void 0 : He.login) == null ? void 0 : Ye.password) || "password", $ = ((Xe = (Je = m.requestMapping) == null ? void 0 : Je.login) == null ? void 0 : Xe.otp) || ((Ce = (Re = m.requestMapping) == null ? void 0 : Re.otp) == null ? void 0 : Ce.otp) || "otp", X = k || J;
|
|
1193
|
+
return /* @__PURE__ */ t.jsxs(y, { className: r.card, children: [
|
|
1194
|
+
/* @__PURE__ */ t.jsx("h1", { className: r.heading, children: u }),
|
|
1195
|
+
/* @__PURE__ */ t.jsxs("form", { onSubmit: f, className: r.form, noValidate: !0, children: [
|
|
1196
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
1197
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: C, className: r.label, children: j }),
|
|
1198
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: a ? /* @__PURE__ */ t.jsx(
|
|
1199
|
+
a,
|
|
1200
|
+
{
|
|
1201
|
+
type: "email",
|
|
1202
|
+
id: C,
|
|
1203
|
+
name: C,
|
|
1204
|
+
value: Q,
|
|
1205
|
+
onChange: (oe) => le(oe.target.value),
|
|
1206
|
+
placeholder: q,
|
|
1207
|
+
error: v[C],
|
|
1208
|
+
disabled: ee && T === "otp"
|
|
1209
|
+
}
|
|
1210
|
+
) : /* @__PURE__ */ t.jsx(
|
|
1211
|
+
"input",
|
|
1212
|
+
{
|
|
1213
|
+
type: "email",
|
|
1214
|
+
id: C,
|
|
1215
|
+
name: C,
|
|
1216
|
+
value: Q,
|
|
1217
|
+
onChange: (oe) => le(oe.target.value),
|
|
1218
|
+
placeholder: q,
|
|
1219
|
+
className: `${r.input} ${v[C] ? r.inputError : ""}`,
|
|
1220
|
+
required: !0,
|
|
1221
|
+
disabled: ee && T === "otp",
|
|
1222
|
+
"aria-invalid": !!v[C],
|
|
1223
|
+
"aria-describedby": v[C] ? `${C}-error` : void 0
|
|
1224
|
+
}
|
|
1225
|
+
) }),
|
|
1226
|
+
v[C] && /* @__PURE__ */ t.jsx("span", { id: `${C}-error`, className: r.errorText, role: "alert", children: v[C] })
|
|
1227
|
+
] }),
|
|
1228
|
+
T === "otp" ? ee && /* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
1229
|
+
/* @__PURE__ */ t.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
1230
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: $, className: r.label, children: W }),
|
|
1231
|
+
/* @__PURE__ */ t.jsx("button", { type: "button", onClick: p, className: r.link, style: { fontSize: "0.75rem", background: "none", border: "none", padding: 0 }, children: "Resend OTP" })
|
|
1232
|
+
] }),
|
|
1233
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: a ? /* @__PURE__ */ t.jsx(
|
|
1234
|
+
a,
|
|
1235
|
+
{
|
|
1236
|
+
type: "text",
|
|
1237
|
+
id: $,
|
|
1238
|
+
name: $,
|
|
1239
|
+
value: se,
|
|
1240
|
+
onChange: (oe) => F(oe.target.value),
|
|
1241
|
+
placeholder: K,
|
|
1242
|
+
error: v[$]
|
|
1243
|
+
}
|
|
1244
|
+
) : /* @__PURE__ */ t.jsx(
|
|
1245
|
+
"input",
|
|
1246
|
+
{
|
|
1247
|
+
type: "text",
|
|
1248
|
+
id: $,
|
|
1249
|
+
name: $,
|
|
1250
|
+
value: se,
|
|
1251
|
+
onChange: (oe) => F(oe.target.value),
|
|
1252
|
+
placeholder: K,
|
|
1253
|
+
className: `${r.input} ${v[$] ? r.inputError : ""}`,
|
|
1254
|
+
required: !0,
|
|
1255
|
+
"aria-invalid": !!v[$],
|
|
1256
|
+
"aria-describedby": v[$] ? `${$}-error` : void 0
|
|
1257
|
+
}
|
|
1258
|
+
) }),
|
|
1259
|
+
v[$] && /* @__PURE__ */ t.jsx("span", { id: `${$}-error`, className: r.errorText, role: "alert", children: v[$] })
|
|
1260
|
+
] }) : /* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
1261
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: B, className: r.label, children: N }),
|
|
1262
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: a ? /* @__PURE__ */ t.jsx(
|
|
1263
|
+
a,
|
|
1264
|
+
{
|
|
1265
|
+
type: L ? "password" : "text",
|
|
1266
|
+
id: B,
|
|
1267
|
+
name: B,
|
|
1268
|
+
placeholder: R,
|
|
1269
|
+
error: v[B]
|
|
1270
|
+
}
|
|
1271
|
+
) : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
1272
|
+
/* @__PURE__ */ t.jsx(
|
|
1273
|
+
"input",
|
|
1274
|
+
{
|
|
1275
|
+
type: L ? "password" : "text",
|
|
1276
|
+
id: B,
|
|
1277
|
+
name: B,
|
|
1278
|
+
placeholder: R,
|
|
1279
|
+
className: `${r.input} ${v[B] ? r.inputError : ""}`,
|
|
1280
|
+
required: !0,
|
|
1281
|
+
"aria-invalid": !!v[B],
|
|
1282
|
+
"aria-describedby": v[B] ? `${B}-error` : void 0
|
|
1283
|
+
}
|
|
1284
|
+
),
|
|
1285
|
+
/* @__PURE__ */ t.jsx(
|
|
1286
|
+
"button",
|
|
1287
|
+
{
|
|
1288
|
+
type: "button",
|
|
1289
|
+
onClick: () => V(!L),
|
|
1290
|
+
className: r.inputIcon,
|
|
1291
|
+
"aria-label": L ? "Show password" : "Hide password",
|
|
1292
|
+
children: L ? /* @__PURE__ */ t.jsxs("svg", { className: r.eyeIcon, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1293
|
+
/* @__PURE__ */ t.jsx("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
1294
|
+
/* @__PURE__ */ t.jsx("circle", { cx: "12", cy: "12", r: "3" })
|
|
1295
|
+
] }) : /* @__PURE__ */ t.jsxs("svg", { className: r.eyeIcon, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1296
|
+
/* @__PURE__ */ t.jsx("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
|
|
1297
|
+
/* @__PURE__ */ t.jsx("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1298
|
+
] })
|
|
1299
|
+
}
|
|
1300
|
+
)
|
|
1301
|
+
] }) }),
|
|
1302
|
+
v[B] && /* @__PURE__ */ t.jsx("span", { id: `${B}-error`, className: r.errorText, role: "alert", children: v[B] })
|
|
1303
|
+
] }),
|
|
1304
|
+
/* @__PURE__ */ t.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", marginTop: "-4px" }, children: [
|
|
1305
|
+
m.enableOtpLogin && /* @__PURE__ */ t.jsx(
|
|
1306
|
+
"button",
|
|
1307
|
+
{
|
|
1308
|
+
type: "button",
|
|
1309
|
+
onClick: () => {
|
|
1310
|
+
A(T === "password" ? "otp" : "password"), O({}), c(null), G(null), _();
|
|
1311
|
+
},
|
|
1312
|
+
className: r.link,
|
|
1313
|
+
style: { background: "none", border: "none", padding: 0 },
|
|
1314
|
+
children: T === "password" ? "Login with OTP" : "Login with Password"
|
|
1315
|
+
}
|
|
1316
|
+
),
|
|
1317
|
+
T === "password" && g && /* @__PURE__ */ t.jsx(
|
|
1318
|
+
"button",
|
|
1319
|
+
{
|
|
1320
|
+
type: "button",
|
|
1321
|
+
onClick: g,
|
|
1322
|
+
className: r.link,
|
|
1323
|
+
children: ((ue = (Ee = m.customization) == null ? void 0 : Ee.labels) == null ? void 0 : ue.loginForgotPasswordLink) || "Forgot password?"
|
|
1324
|
+
}
|
|
1325
|
+
)
|
|
1326
|
+
] }),
|
|
1327
|
+
/* @__PURE__ */ t.jsx(Ue, { message: D, type: "success", style: { marginTop: "8px", marginBottom: "8px" }, onDismiss: () => c(null) }),
|
|
1328
|
+
/* @__PURE__ */ t.jsx(Ue, { message: P || b, type: "error", style: { marginTop: "8px", marginBottom: "8px" }, onDismiss: () => {
|
|
1329
|
+
G(null), _();
|
|
1330
|
+
} }),
|
|
1331
|
+
T === "otp" && !ee ? /* @__PURE__ */ t.jsx(w, { type: "button", onClick: p, disabled: X, className: r.button, children: X ? "Sending OTP..." : "Send OTP" }) : /* @__PURE__ */ t.jsx(w, { type: "submit", disabled: X, className: r.button, children: X ? s != null && s.Loader ? /* @__PURE__ */ t.jsx(s.Loader, {}) : "Loading..." : U }),
|
|
1332
|
+
l && /* @__PURE__ */ t.jsxs("div", { className: r.footerText, children: [
|
|
1333
|
+
((Le = (ke = m.customization) == null ? void 0 : ke.labels) == null ? void 0 : Le.loginDontHaveAccountText) || "Don't have an account? ",
|
|
1334
|
+
" ",
|
|
1335
|
+
/* @__PURE__ */ t.jsx(
|
|
1336
|
+
"button",
|
|
1337
|
+
{
|
|
1338
|
+
type: "button",
|
|
1339
|
+
onClick: l,
|
|
1340
|
+
className: r.link,
|
|
1341
|
+
style: { background: "none", border: "none", padding: 0 },
|
|
1342
|
+
children: ((Se = (de = m.customization) == null ? void 0 : de.labels) == null ? void 0 : Se.loginSignupLink) || "SignUp"
|
|
1343
|
+
}
|
|
1344
|
+
)
|
|
1345
|
+
] }),
|
|
1346
|
+
m.enableGoogleLogin !== !1 && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
1347
|
+
/* @__PURE__ */ t.jsx("div", { className: r.divider, children: ((Ze = (lt = m.customization) == null ? void 0 : lt.labels) == null ? void 0 : Ze.loginDividerText) || "or" }),
|
|
1348
|
+
/* @__PURE__ */ t.jsx(jt, {})
|
|
1349
|
+
] })
|
|
1350
|
+
] })
|
|
1351
|
+
] });
|
|
1352
|
+
}, bs = ({
|
|
1353
|
+
components: s,
|
|
1354
|
+
labels: e,
|
|
1355
|
+
buttonText: o,
|
|
1356
|
+
placeholders: n,
|
|
1357
|
+
validationSchema: i,
|
|
1358
|
+
onSuccess: d,
|
|
1359
|
+
onLoginClick: g
|
|
1360
|
+
}) => {
|
|
1361
|
+
var y, w, a, u, j, N, U, q, R, W, K, C, B, $, X, Y, te, H, z, ce, fe, pe, ae, je, ge, Te, we, _e, ye, xe, me, ve, Pe, Fe, Me, $e, De, Be, qe, We, Ve, Ge, Ke, He, Ye, Je, Xe, Re, Ce, Ee, ue, ke;
|
|
1362
|
+
const { config: l } = he(), { loading: m, error: E, execute: k, reset: b } = Mt(), [x, _] = S({}), [v, O] = S({ pass: !0, verify: !0 }), L = i || ((w = (y = l.customization) == null ? void 0 : y.validationSchema) == null ? void 0 : w.signup) || fs, V = async (Le) => {
|
|
1363
|
+
Le.preventDefault(), _({});
|
|
1364
|
+
const de = new FormData(Le.currentTarget), Se = Object.fromEntries(de.entries()), lt = {
|
|
1365
|
+
name: Se[c],
|
|
1366
|
+
email: Se[h],
|
|
1367
|
+
password: Se[p],
|
|
1368
|
+
verifyPassword: Se[f]
|
|
1369
|
+
};
|
|
1370
|
+
try {
|
|
1371
|
+
L.parse(lt);
|
|
1372
|
+
} catch (Ze) {
|
|
1373
|
+
if (Ze instanceof I.ZodError) {
|
|
1374
|
+
const oe = {};
|
|
1375
|
+
Ze.errors.forEach((Z) => {
|
|
1376
|
+
if (Z.path[0]) {
|
|
1377
|
+
const be = Z.path[0].toString(), Oe = be === "name" ? c : be === "email" ? h : be === "password" ? p : be === "verifyPassword" ? f : be;
|
|
1378
|
+
oe[Oe] = Z.message;
|
|
1379
|
+
}
|
|
1380
|
+
}), _(oe);
|
|
1381
|
+
return;
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
try {
|
|
1385
|
+
const { [f]: Ze, ...oe } = Se, Z = await k(oe);
|
|
1386
|
+
d && d(Z);
|
|
1387
|
+
} catch {
|
|
1388
|
+
}
|
|
1389
|
+
}, P = (s == null ? void 0 : s.Card) || "div", G = (s == null ? void 0 : s.Button) || "button", T = s == null ? void 0 : s.Input, A = ((u = (a = l.customization) == null ? void 0 : a.labels) == null ? void 0 : u.signupTitle) || "Sign Up", Q = (e == null ? void 0 : e.name) || ((N = (j = l.customization) == null ? void 0 : j.labels) == null ? void 0 : N.signupName) || ((q = (U = l.customization) == null ? void 0 : U.labels) == null ? void 0 : q.name) || "Name", le = (e == null ? void 0 : e.email) || ((W = (R = l.customization) == null ? void 0 : R.labels) == null ? void 0 : W.signupEmail) || ((C = (K = l.customization) == null ? void 0 : K.labels) == null ? void 0 : C.email) || "E-mail", se = (e == null ? void 0 : e.password) || (($ = (B = l.customization) == null ? void 0 : B.labels) == null ? void 0 : $.signupPassword) || ((Y = (X = l.customization) == null ? void 0 : X.labels) == null ? void 0 : Y.password) || "Password", F = (e == null ? void 0 : e.verifyPassword) || ((H = (te = l.customization) == null ? void 0 : te.labels) == null ? void 0 : H.signupVerifyPassword) || ((ce = (z = l.customization) == null ? void 0 : z.labels) == null ? void 0 : ce.verifyPassword) || "Verify Password", ee = o || ((pe = (fe = l.customization) == null ? void 0 : fe.buttonText) == null ? void 0 : pe.signup) || "Register", re = (n == null ? void 0 : n.name) || ((je = (ae = l.customization) == null ? void 0 : ae.placeholders) == null ? void 0 : je.signupName) || ((Te = (ge = l.customization) == null ? void 0 : ge.placeholders) == null ? void 0 : Te.name) || "Name", J = (n == null ? void 0 : n.email) || ((_e = (we = l.customization) == null ? void 0 : we.placeholders) == null ? void 0 : _e.signupEmail) || ((xe = (ye = l.customization) == null ? void 0 : ye.placeholders) == null ? void 0 : xe.email) || "E-mail", M = (n == null ? void 0 : n.password) || ((ve = (me = l.customization) == null ? void 0 : me.placeholders) == null ? void 0 : ve.signupPassword) || ((Fe = (Pe = l.customization) == null ? void 0 : Pe.placeholders) == null ? void 0 : Fe.password) || "Password", D = (n == null ? void 0 : n.verifyPassword) || (($e = (Me = l.customization) == null ? void 0 : Me.placeholders) == null ? void 0 : $e.signupVerifyPassword) || ((Be = (De = l.customization) == null ? void 0 : De.placeholders) == null ? void 0 : Be.verifyPassword) || "Verify Password", c = ((We = (qe = l.requestMapping) == null ? void 0 : qe.signup) == null ? void 0 : We.name) || "name", h = ((Ge = (Ve = l.requestMapping) == null ? void 0 : Ve.signup) == null ? void 0 : Ge.email) || "email", p = ((He = (Ke = l.requestMapping) == null ? void 0 : Ke.signup) == null ? void 0 : He.password) || "password", f = ((Je = (Ye = l.requestMapping) == null ? void 0 : Ye.signup) == null ? void 0 : Je.verifyPassword) || "verifyPassword";
|
|
1390
|
+
return /* @__PURE__ */ t.jsxs(P, { className: r.card, children: [
|
|
1391
|
+
/* @__PURE__ */ t.jsx("h1", { className: r.heading, children: A }),
|
|
1392
|
+
/* @__PURE__ */ t.jsxs("form", { onSubmit: V, className: r.form, noValidate: !0, children: [
|
|
1393
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
1394
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: c, className: r.label, children: Q }),
|
|
1395
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: T ? /* @__PURE__ */ t.jsx(
|
|
1396
|
+
T,
|
|
1397
|
+
{
|
|
1398
|
+
type: "text",
|
|
1399
|
+
id: c,
|
|
1400
|
+
name: c,
|
|
1401
|
+
placeholder: re,
|
|
1402
|
+
error: x[c]
|
|
1403
|
+
}
|
|
1404
|
+
) : /* @__PURE__ */ t.jsx(
|
|
1405
|
+
"input",
|
|
1406
|
+
{
|
|
1407
|
+
type: "text",
|
|
1408
|
+
id: c,
|
|
1409
|
+
name: c,
|
|
1410
|
+
placeholder: re,
|
|
1411
|
+
className: `${r.input} ${x[c] ? r.inputError : ""}`,
|
|
1412
|
+
required: !0,
|
|
1413
|
+
"aria-invalid": !!x[c],
|
|
1414
|
+
"aria-describedby": x[c] ? `${c}-error` : void 0
|
|
1415
|
+
}
|
|
1416
|
+
) }),
|
|
1417
|
+
x[c] && /* @__PURE__ */ t.jsx("span", { id: `${c}-error`, className: r.errorText, role: "alert", children: x[c] })
|
|
1418
|
+
] }),
|
|
1419
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
1420
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: h, className: r.label, children: le }),
|
|
1421
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: T ? /* @__PURE__ */ t.jsx(
|
|
1422
|
+
T,
|
|
1423
|
+
{
|
|
1424
|
+
type: "email",
|
|
1425
|
+
id: h,
|
|
1426
|
+
name: h,
|
|
1427
|
+
placeholder: J,
|
|
1428
|
+
error: x[h]
|
|
1429
|
+
}
|
|
1430
|
+
) : /* @__PURE__ */ t.jsx(
|
|
1431
|
+
"input",
|
|
1432
|
+
{
|
|
1433
|
+
type: "email",
|
|
1434
|
+
id: h,
|
|
1435
|
+
name: h,
|
|
1436
|
+
placeholder: J,
|
|
1437
|
+
className: `${r.input} ${x[h] ? r.inputError : ""}`,
|
|
1438
|
+
required: !0,
|
|
1439
|
+
"aria-invalid": !!x[h],
|
|
1440
|
+
"aria-describedby": x[h] ? `${h}-error` : void 0
|
|
1441
|
+
}
|
|
1442
|
+
) }),
|
|
1443
|
+
x[h] && /* @__PURE__ */ t.jsx("span", { id: `${h}-error`, className: r.errorText, role: "alert", children: x[h] })
|
|
1444
|
+
] }),
|
|
1445
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
1446
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: p, className: r.label, children: se }),
|
|
1447
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: T ? /* @__PURE__ */ t.jsx(
|
|
1448
|
+
T,
|
|
1449
|
+
{
|
|
1450
|
+
type: v.pass ? "password" : "text",
|
|
1451
|
+
id: p,
|
|
1452
|
+
name: p,
|
|
1453
|
+
placeholder: M,
|
|
1454
|
+
error: x[p]
|
|
1455
|
+
}
|
|
1456
|
+
) : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
1457
|
+
/* @__PURE__ */ t.jsx(
|
|
1458
|
+
"input",
|
|
1459
|
+
{
|
|
1460
|
+
type: v.pass ? "password" : "text",
|
|
1461
|
+
id: p,
|
|
1462
|
+
name: p,
|
|
1463
|
+
placeholder: M,
|
|
1464
|
+
className: `${r.input} ${x[p] ? r.inputError : ""}`,
|
|
1465
|
+
required: !0,
|
|
1466
|
+
"aria-invalid": !!x[p],
|
|
1467
|
+
"aria-describedby": x[p] ? `${p}-error` : void 0
|
|
1468
|
+
}
|
|
1469
|
+
),
|
|
1470
|
+
/* @__PURE__ */ t.jsx(
|
|
1471
|
+
"button",
|
|
1472
|
+
{
|
|
1473
|
+
type: "button",
|
|
1474
|
+
onClick: () => O({ ...v, pass: !v.pass }),
|
|
1475
|
+
className: r.inputIcon,
|
|
1476
|
+
"aria-label": v.pass ? "Show password" : "Hide password",
|
|
1477
|
+
children: v.pass ? /* @__PURE__ */ t.jsxs("svg", { className: r.eyeIcon, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1478
|
+
/* @__PURE__ */ t.jsx("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
1479
|
+
/* @__PURE__ */ t.jsx("circle", { cx: "12", cy: "12", r: "3" })
|
|
1480
|
+
] }) : /* @__PURE__ */ t.jsxs("svg", { className: r.eyeIcon, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1481
|
+
/* @__PURE__ */ t.jsx("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
|
|
1482
|
+
/* @__PURE__ */ t.jsx("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1483
|
+
] })
|
|
1484
|
+
}
|
|
1485
|
+
)
|
|
1486
|
+
] }) }),
|
|
1487
|
+
x[p] && /* @__PURE__ */ t.jsx("span", { id: `${p}-error`, className: r.errorText, role: "alert", children: x[p] })
|
|
1488
|
+
] }),
|
|
1489
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
1490
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: f, className: r.label, children: F }),
|
|
1491
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: T ? /* @__PURE__ */ t.jsx(
|
|
1492
|
+
T,
|
|
1493
|
+
{
|
|
1494
|
+
type: v.verify ? "password" : "text",
|
|
1495
|
+
id: f,
|
|
1496
|
+
name: f,
|
|
1497
|
+
placeholder: D,
|
|
1498
|
+
error: x[f]
|
|
1499
|
+
}
|
|
1500
|
+
) : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
1501
|
+
/* @__PURE__ */ t.jsx(
|
|
1502
|
+
"input",
|
|
1503
|
+
{
|
|
1504
|
+
type: v.verify ? "password" : "text",
|
|
1505
|
+
id: f,
|
|
1506
|
+
name: f,
|
|
1507
|
+
placeholder: D,
|
|
1508
|
+
className: `${r.input} ${x[f] ? r.inputError : ""}`,
|
|
1509
|
+
required: !0,
|
|
1510
|
+
"aria-invalid": !!x[f],
|
|
1511
|
+
"aria-describedby": x[f] ? `${f}-error` : void 0
|
|
1512
|
+
}
|
|
1513
|
+
),
|
|
1514
|
+
/* @__PURE__ */ t.jsx(
|
|
1515
|
+
"button",
|
|
1516
|
+
{
|
|
1517
|
+
type: "button",
|
|
1518
|
+
onClick: () => O({ ...v, verify: !v.verify }),
|
|
1519
|
+
className: r.inputIcon,
|
|
1520
|
+
"aria-label": v.verify ? "Show password" : "Hide password",
|
|
1521
|
+
children: v.verify ? /* @__PURE__ */ t.jsxs("svg", { className: r.eyeIcon, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1522
|
+
/* @__PURE__ */ t.jsx("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
1523
|
+
/* @__PURE__ */ t.jsx("circle", { cx: "12", cy: "12", r: "3" })
|
|
1524
|
+
] }) : /* @__PURE__ */ t.jsxs("svg", { className: r.eyeIcon, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1525
|
+
/* @__PURE__ */ t.jsx("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
|
|
1526
|
+
/* @__PURE__ */ t.jsx("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1527
|
+
] })
|
|
1528
|
+
}
|
|
1529
|
+
)
|
|
1530
|
+
] }) }),
|
|
1531
|
+
x[f] && /* @__PURE__ */ t.jsx("span", { id: `${f}-error`, className: r.errorText, role: "alert", children: x[f] })
|
|
1532
|
+
] }),
|
|
1533
|
+
/* @__PURE__ */ t.jsx(Ue, { message: E, type: "error", style: { marginTop: "8px", marginBottom: "8px" }, onDismiss: b }),
|
|
1534
|
+
/* @__PURE__ */ t.jsx(G, { type: "submit", disabled: m, className: r.button, children: m ? s != null && s.Loader ? /* @__PURE__ */ t.jsx(s.Loader, {}) : "Loading..." : ee }),
|
|
1535
|
+
g && /* @__PURE__ */ t.jsxs("div", { className: r.footerText, children: [
|
|
1536
|
+
((Re = (Xe = l.customization) == null ? void 0 : Xe.labels) == null ? void 0 : Re.signupAlreadyHaveAccountText) || "Already have an account? ",
|
|
1537
|
+
" ",
|
|
1538
|
+
/* @__PURE__ */ t.jsx(
|
|
1539
|
+
"button",
|
|
1540
|
+
{
|
|
1541
|
+
type: "button",
|
|
1542
|
+
onClick: g,
|
|
1543
|
+
className: r.link,
|
|
1544
|
+
style: { background: "none", border: "none", padding: 0 },
|
|
1545
|
+
children: ((Ee = (Ce = l.customization) == null ? void 0 : Ce.labels) == null ? void 0 : Ee.signupLoginLink) || "Login"
|
|
1546
|
+
}
|
|
1547
|
+
)
|
|
1548
|
+
] }),
|
|
1549
|
+
l.enableGoogleLogin !== !1 && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
1550
|
+
/* @__PURE__ */ t.jsx("div", { className: r.divider, children: ((ke = (ue = l.customization) == null ? void 0 : ue.labels) == null ? void 0 : ke.signupDividerText) || "or" }),
|
|
1551
|
+
/* @__PURE__ */ t.jsx(jt, {})
|
|
1552
|
+
] })
|
|
1553
|
+
] })
|
|
1554
|
+
] });
|
|
1555
|
+
}, js = ({
|
|
1556
|
+
components: s,
|
|
1557
|
+
labels: e,
|
|
1558
|
+
buttonText: o,
|
|
1559
|
+
placeholders: n,
|
|
1560
|
+
validationSchema: i,
|
|
1561
|
+
onSuccess: d,
|
|
1562
|
+
onBackToLoginClick: g
|
|
1563
|
+
}) => {
|
|
1564
|
+
var ee, re, J, M, D, c, h, p, f, y, w, a, u, j, N, U, q, R, W, K;
|
|
1565
|
+
const { config: l } = he(), { loading: m, error: E, success: k, execute: b, reset: x } = $t(), [_, v] = S({}), O = i || ((re = (ee = l.customization) == null ? void 0 : ee.validationSchema) == null ? void 0 : re.verifyIdentity) || gs, L = async (C) => {
|
|
1566
|
+
C.preventDefault(), v({});
|
|
1567
|
+
const B = new FormData(C.currentTarget), $ = Object.fromEntries(B.entries()), X = {
|
|
1568
|
+
email: $[F]
|
|
1569
|
+
};
|
|
1570
|
+
try {
|
|
1571
|
+
O.parse(X);
|
|
1572
|
+
} catch (Y) {
|
|
1573
|
+
if (Y instanceof I.ZodError) {
|
|
1574
|
+
const te = {};
|
|
1575
|
+
Y.errors.forEach((H) => {
|
|
1576
|
+
if (H.path[0]) {
|
|
1577
|
+
const z = H.path[0].toString(), ce = z === "email" ? F : z;
|
|
1578
|
+
te[ce] = H.message;
|
|
1579
|
+
}
|
|
1580
|
+
}), v(te);
|
|
1581
|
+
return;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
try {
|
|
1585
|
+
const Y = await b($);
|
|
1586
|
+
d && d(Y);
|
|
1587
|
+
} catch {
|
|
1588
|
+
}
|
|
1589
|
+
}, V = (s == null ? void 0 : s.Card) || "div", P = (s == null ? void 0 : s.Button) || "button", G = s == null ? void 0 : s.Input, T = ((M = (J = l.customization) == null ? void 0 : J.labels) == null ? void 0 : M.forgotPasswordTitle) || "Forgot Password", A = ((c = (D = l.customization) == null ? void 0 : D.labels) == null ? void 0 : c.forgotPasswordSubtitle) || "Enter your registered e-mail here, and we will send an OTP.", Q = (e == null ? void 0 : e.email) || ((p = (h = l.customization) == null ? void 0 : h.labels) == null ? void 0 : p.forgotPasswordEmail) || ((y = (f = l.customization) == null ? void 0 : f.labels) == null ? void 0 : y.email) || "E-mail", le = o || ((a = (w = l.customization) == null ? void 0 : w.buttonText) == null ? void 0 : a.forgotPassword) || "Submit", se = (n == null ? void 0 : n.email) || ((j = (u = l.customization) == null ? void 0 : u.placeholders) == null ? void 0 : j.forgotPasswordEmail) || ((U = (N = l.customization) == null ? void 0 : N.placeholders) == null ? void 0 : U.email) || "E-mail", F = ((R = (q = l.requestMapping) == null ? void 0 : q.forgotPassword) == null ? void 0 : R.email) || "email";
|
|
1590
|
+
return /* @__PURE__ */ t.jsxs(V, { className: r.card, children: [
|
|
1591
|
+
/* @__PURE__ */ t.jsxs("div", { style: { textAlign: "center", marginBottom: "20px" }, children: [
|
|
1592
|
+
/* @__PURE__ */ t.jsx(
|
|
1593
|
+
"img",
|
|
1594
|
+
{
|
|
1595
|
+
src: "/img/confusion.png",
|
|
1596
|
+
alt: "",
|
|
1597
|
+
style: { width: "64px", height: "64px", marginBottom: "10px" },
|
|
1598
|
+
onError: (C) => {
|
|
1599
|
+
C.currentTarget.style.display = "none";
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
),
|
|
1603
|
+
/* @__PURE__ */ t.jsx("h1", { className: r.heading, children: T }),
|
|
1604
|
+
/* @__PURE__ */ t.jsx("p", { className: r.subtext, children: k ? "OTP has been dispatched to your email address." : A })
|
|
1605
|
+
] }),
|
|
1606
|
+
/* @__PURE__ */ t.jsxs("form", { onSubmit: L, className: r.form, noValidate: !0, children: [
|
|
1607
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
1608
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: F, className: r.label, children: Q }),
|
|
1609
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: G ? /* @__PURE__ */ t.jsx(
|
|
1610
|
+
G,
|
|
1611
|
+
{
|
|
1612
|
+
type: "email",
|
|
1613
|
+
id: F,
|
|
1614
|
+
name: F,
|
|
1615
|
+
placeholder: se,
|
|
1616
|
+
error: _[F]
|
|
1617
|
+
}
|
|
1618
|
+
) : /* @__PURE__ */ t.jsx(
|
|
1619
|
+
"input",
|
|
1620
|
+
{
|
|
1621
|
+
type: "email",
|
|
1622
|
+
id: F,
|
|
1623
|
+
name: F,
|
|
1624
|
+
placeholder: se,
|
|
1625
|
+
className: `${r.input} ${_[F] ? r.inputError : ""}`,
|
|
1626
|
+
required: !0,
|
|
1627
|
+
"aria-invalid": !!_[F],
|
|
1628
|
+
"aria-describedby": _[F] ? `${F}-error` : void 0
|
|
1629
|
+
}
|
|
1630
|
+
) }),
|
|
1631
|
+
_[F] && /* @__PURE__ */ t.jsx("span", { id: `${F}-error`, className: r.errorText, role: "alert", children: _[F] })
|
|
1632
|
+
] }),
|
|
1633
|
+
/* @__PURE__ */ t.jsx(Ue, { message: E, type: "error", style: { marginTop: "8px", marginBottom: "8px" }, onDismiss: x }),
|
|
1634
|
+
/* @__PURE__ */ t.jsx(P, { type: "submit", disabled: m, className: r.button, children: m ? s != null && s.Loader ? /* @__PURE__ */ t.jsx(s.Loader, {}) : "Loading..." : le }),
|
|
1635
|
+
g && /* @__PURE__ */ t.jsx("div", { className: r.footerText, children: /* @__PURE__ */ t.jsx(
|
|
1636
|
+
"button",
|
|
1637
|
+
{
|
|
1638
|
+
type: "button",
|
|
1639
|
+
onClick: g,
|
|
1640
|
+
className: r.link,
|
|
1641
|
+
style: { background: "none", border: "none", padding: 0 },
|
|
1642
|
+
children: ((K = (W = l.customization) == null ? void 0 : W.labels) == null ? void 0 : K.forgotPasswordBackToLoginLink) || "Back to Login"
|
|
1643
|
+
}
|
|
1644
|
+
) })
|
|
1645
|
+
] })
|
|
1646
|
+
] });
|
|
1647
|
+
}, Es = ({
|
|
1648
|
+
components: s,
|
|
1649
|
+
labels: e,
|
|
1650
|
+
buttonText: o,
|
|
1651
|
+
placeholders: n,
|
|
1652
|
+
validationSchema: i,
|
|
1653
|
+
email: d,
|
|
1654
|
+
name: g,
|
|
1655
|
+
token: l,
|
|
1656
|
+
urlParams: m,
|
|
1657
|
+
onSuccess: E,
|
|
1658
|
+
onResendSuccess: k
|
|
1659
|
+
}) => {
|
|
1660
|
+
var h, p, f, y, w, a, u, j, N, U, q, R, W, K, C, B, $, X, Y, te;
|
|
1661
|
+
const { config: b } = he(), { loading: x, error: _, execute: v, resend: O, reset: L } = Dt(), [V, P] = S({}), [G, T] = S(null), A = ((p = (h = b.requestMapping) == null ? void 0 : h.otp) == null ? void 0 : p.otp) || ((y = (f = b.requestMapping) == null ? void 0 : f.login) == null ? void 0 : y.otp) || "otp", Q = i || ((a = (w = b.customization) == null ? void 0 : w.validationSchema) == null ? void 0 : a.otp) || ys, le = async (H) => {
|
|
1662
|
+
var pe;
|
|
1663
|
+
H.preventDefault(), P({}), T(null);
|
|
1664
|
+
const ce = ((pe = new FormData(H.currentTarget).get(A)) == null ? void 0 : pe.toString()) || "";
|
|
1665
|
+
try {
|
|
1666
|
+
Q.parse({ otp: ce });
|
|
1667
|
+
} catch (ae) {
|
|
1668
|
+
if (ae instanceof I.ZodError) {
|
|
1669
|
+
P({ [A]: ae.errors[0].message });
|
|
1670
|
+
return;
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
const fe = {
|
|
1674
|
+
[A]: ce,
|
|
1675
|
+
email: d || "",
|
|
1676
|
+
token: l || localStorage.getItem("Token") || ""
|
|
1677
|
+
};
|
|
1678
|
+
try {
|
|
1679
|
+
const ae = await v(fe, m);
|
|
1680
|
+
E && E(ae);
|
|
1681
|
+
} catch {
|
|
1682
|
+
}
|
|
1683
|
+
}, se = async () => {
|
|
1684
|
+
P({}), T(null);
|
|
1685
|
+
const H = {
|
|
1686
|
+
Name: g || "",
|
|
1687
|
+
Email: d || "",
|
|
1688
|
+
ResendOtp: "Resend Otp",
|
|
1689
|
+
Token: l || localStorage.getItem("Token") || ""
|
|
1690
|
+
};
|
|
1691
|
+
try {
|
|
1692
|
+
const z = await O(H, m);
|
|
1693
|
+
T("A new OTP has been sent."), k && k(z);
|
|
1694
|
+
} catch {
|
|
1695
|
+
}
|
|
1696
|
+
}, F = (s == null ? void 0 : s.Card) || "div", ee = (s == null ? void 0 : s.Button) || "button", re = s == null ? void 0 : s.Input, J = ((j = (u = b.customization) == null ? void 0 : u.labels) == null ? void 0 : j.otpTitle) || "E-mail Verification", M = (e == null ? void 0 : e.otp) || ((U = (N = b.customization) == null ? void 0 : N.labels) == null ? void 0 : U.otpLabel) || ((R = (q = b.customization) == null ? void 0 : q.labels) == null ? void 0 : R.otp) || "OTP", D = o || ((K = (W = b.customization) == null ? void 0 : W.buttonText) == null ? void 0 : K.otp) || "Submit", c = (n == null ? void 0 : n.otp) || ((B = (C = b.customization) == null ? void 0 : C.placeholders) == null ? void 0 : B.otpPlaceholder) || ((X = ($ = b.customization) == null ? void 0 : $.placeholders) == null ? void 0 : X.otp) || "OTP Code";
|
|
1697
|
+
return /* @__PURE__ */ t.jsxs(F, { className: r.card, children: [
|
|
1698
|
+
/* @__PURE__ */ t.jsxs("div", { style: { textAlign: "center", marginBottom: "20px" }, children: [
|
|
1699
|
+
/* @__PURE__ */ t.jsx(
|
|
1700
|
+
"img",
|
|
1701
|
+
{
|
|
1702
|
+
src: "/img/otp-email-authentication-and-verification-method-vector-47553539.jpg",
|
|
1703
|
+
alt: "",
|
|
1704
|
+
style: { width: "80px", height: "80px", borderRadius: "50%", marginBottom: "10px", objectFit: "cover" },
|
|
1705
|
+
onError: (H) => {
|
|
1706
|
+
H.currentTarget.style.display = "none";
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
),
|
|
1710
|
+
/* @__PURE__ */ t.jsx("h1", { className: r.heading, children: J }),
|
|
1711
|
+
d && /* @__PURE__ */ t.jsxs("p", { className: r.subtext, children: [
|
|
1712
|
+
"Verifying code sent to ",
|
|
1713
|
+
d
|
|
1714
|
+
] })
|
|
1715
|
+
] }),
|
|
1716
|
+
/* @__PURE__ */ t.jsxs("form", { onSubmit: le, className: r.form, noValidate: !0, children: [
|
|
1717
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
1718
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: A, className: r.label, children: M }),
|
|
1719
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: re ? /* @__PURE__ */ t.jsx(
|
|
1720
|
+
re,
|
|
1721
|
+
{
|
|
1722
|
+
type: "text",
|
|
1723
|
+
id: A,
|
|
1724
|
+
name: A,
|
|
1725
|
+
placeholder: c,
|
|
1726
|
+
error: V[A]
|
|
1727
|
+
}
|
|
1728
|
+
) : /* @__PURE__ */ t.jsx(
|
|
1729
|
+
"input",
|
|
1730
|
+
{
|
|
1731
|
+
type: "text",
|
|
1732
|
+
id: A,
|
|
1733
|
+
name: A,
|
|
1734
|
+
placeholder: c,
|
|
1735
|
+
className: `${r.input} ${V[A] ? r.inputError : ""}`,
|
|
1736
|
+
required: !0,
|
|
1737
|
+
inputMode: "numeric",
|
|
1738
|
+
pattern: "[0-9]*",
|
|
1739
|
+
"aria-invalid": !!V[A],
|
|
1740
|
+
"aria-describedby": V[A] ? `${A}-error` : void 0
|
|
1741
|
+
}
|
|
1742
|
+
) }),
|
|
1743
|
+
V[A] && /* @__PURE__ */ t.jsx("span", { id: `${A}-error`, className: r.errorText, role: "alert", children: V[A] })
|
|
1744
|
+
] }),
|
|
1745
|
+
/* @__PURE__ */ t.jsx("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: /* @__PURE__ */ t.jsx(
|
|
1746
|
+
"button",
|
|
1747
|
+
{
|
|
1748
|
+
type: "button",
|
|
1749
|
+
onClick: se,
|
|
1750
|
+
className: r.link,
|
|
1751
|
+
style: { background: "none", border: "none", padding: 0 },
|
|
1752
|
+
children: ((te = (Y = b.customization) == null ? void 0 : Y.labels) == null ? void 0 : te.otpResendLink) || "Resend OTP"
|
|
1753
|
+
}
|
|
1754
|
+
) }),
|
|
1755
|
+
/* @__PURE__ */ t.jsx(Ue, { message: G, type: "success", style: { marginTop: "8px", marginBottom: "8px" }, onDismiss: () => T(null) }),
|
|
1756
|
+
/* @__PURE__ */ t.jsx(Ue, { message: _, type: "error", style: { marginTop: "8px", marginBottom: "8px" }, onDismiss: L }),
|
|
1757
|
+
/* @__PURE__ */ t.jsx(ee, { type: "submit", disabled: x, className: r.button, children: x ? s != null && s.Loader ? /* @__PURE__ */ t.jsx(s.Loader, {}) : "Loading..." : D })
|
|
1758
|
+
] })
|
|
1759
|
+
] });
|
|
1760
|
+
}, ks = ({
|
|
1761
|
+
components: s,
|
|
1762
|
+
labels: e,
|
|
1763
|
+
buttonText: o,
|
|
1764
|
+
placeholders: n,
|
|
1765
|
+
validationSchema: i,
|
|
1766
|
+
urlParams: d,
|
|
1767
|
+
onSuccess: g
|
|
1768
|
+
}) => {
|
|
1769
|
+
var c, h, p, f, y, w, a, u, j, N, U, q, R, W, K, C, B, $, X, Y, te, H, z, ce, fe, pe, ae, je;
|
|
1770
|
+
const { config: l } = he(), { loading: m, error: E, success: k, execute: b, reset: x } = Bt(), [_, v] = S({}), [O, L] = S({ pass: !0, verify: !0 }), V = i || ((h = (c = l.customization) == null ? void 0 : c.validationSchema) == null ? void 0 : h.resetPassword) || xs, P = async (ge) => {
|
|
1771
|
+
ge.preventDefault(), v({});
|
|
1772
|
+
const Te = new FormData(ge.currentTarget), we = Object.fromEntries(Te.entries()), _e = {
|
|
1773
|
+
password: we[M],
|
|
1774
|
+
verifyPassword: we[D]
|
|
1775
|
+
};
|
|
1776
|
+
try {
|
|
1777
|
+
V.parse(_e);
|
|
1778
|
+
} catch (ye) {
|
|
1779
|
+
if (ye instanceof I.ZodError) {
|
|
1780
|
+
const xe = {};
|
|
1781
|
+
ye.errors.forEach((me) => {
|
|
1782
|
+
if (me.path[0]) {
|
|
1783
|
+
const ve = me.path[0].toString(), Pe = ve === "password" ? M : ve === "verifyPassword" ? D : ve;
|
|
1784
|
+
xe[Pe] = me.message;
|
|
1785
|
+
}
|
|
1786
|
+
}), v(xe);
|
|
1787
|
+
return;
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1790
|
+
try {
|
|
1791
|
+
const { [D]: ye, ...xe } = we, me = await b(xe, d);
|
|
1792
|
+
g && g(me);
|
|
1793
|
+
} catch {
|
|
1794
|
+
}
|
|
1795
|
+
}, G = (s == null ? void 0 : s.Card) || "div", T = (s == null ? void 0 : s.Button) || "button", A = s == null ? void 0 : s.Input, Q = ((f = (p = l.customization) == null ? void 0 : p.labels) == null ? void 0 : f.resetPasswordTitle) || "Forget Password", le = ((w = (y = l.customization) == null ? void 0 : y.labels) == null ? void 0 : w.resetPasswordSubtitle) || "Enter your registered e-mail here we'll send OTP in your email", se = (e == null ? void 0 : e.password) || ((u = (a = l.customization) == null ? void 0 : a.labels) == null ? void 0 : u.resetPasswordPassword) || ((N = (j = l.customization) == null ? void 0 : j.labels) == null ? void 0 : N.password) || "Password", F = (e == null ? void 0 : e.verifyPassword) || ((q = (U = l.customization) == null ? void 0 : U.labels) == null ? void 0 : q.resetPasswordVerifyPassword) || ((W = (R = l.customization) == null ? void 0 : R.labels) == null ? void 0 : W.verifyPassword) || "Verify Password", ee = o || ((C = (K = l.customization) == null ? void 0 : K.buttonText) == null ? void 0 : C.resetPassword) || "Submit", re = (n == null ? void 0 : n.password) || (($ = (B = l.customization) == null ? void 0 : B.placeholders) == null ? void 0 : $.resetPasswordPassword) || ((Y = (X = l.customization) == null ? void 0 : X.placeholders) == null ? void 0 : Y.password) || "Password", J = (n == null ? void 0 : n.verifyPassword) || ((H = (te = l.customization) == null ? void 0 : te.placeholders) == null ? void 0 : H.resetPasswordVerifyPassword) || ((ce = (z = l.customization) == null ? void 0 : z.placeholders) == null ? void 0 : ce.verifyPassword) || "Verify Password", M = ((pe = (fe = l.requestMapping) == null ? void 0 : fe.resetPassword) == null ? void 0 : pe.password) || "password", D = ((je = (ae = l.requestMapping) == null ? void 0 : ae.resetPassword) == null ? void 0 : je.verifyPassword) || "verifyPassword";
|
|
1796
|
+
return /* @__PURE__ */ t.jsxs(G, { className: r.card, children: [
|
|
1797
|
+
/* @__PURE__ */ t.jsxs("div", { style: { textAlign: "center", marginBottom: "20px" }, children: [
|
|
1798
|
+
/* @__PURE__ */ t.jsx(
|
|
1799
|
+
"img",
|
|
1800
|
+
{
|
|
1801
|
+
src: "/img/confusion.png",
|
|
1802
|
+
alt: "",
|
|
1803
|
+
style: { width: "64px", height: "64px", marginBottom: "10px" },
|
|
1804
|
+
onError: (ge) => {
|
|
1805
|
+
ge.currentTarget.style.display = "none";
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
),
|
|
1809
|
+
/* @__PURE__ */ t.jsx("h1", { className: r.heading, children: Q }),
|
|
1810
|
+
/* @__PURE__ */ t.jsx("p", { className: r.subtext, children: k ? "Your password has been successfully updated." : d != null && d.id ? "Enter your new credentials below." : le })
|
|
1811
|
+
] }),
|
|
1812
|
+
/* @__PURE__ */ t.jsxs("form", { onSubmit: P, className: r.form, noValidate: !0, children: [
|
|
1813
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
1814
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: M, className: r.label, children: se }),
|
|
1815
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: A ? /* @__PURE__ */ t.jsx(
|
|
1816
|
+
A,
|
|
1817
|
+
{
|
|
1818
|
+
type: O.pass ? "password" : "text",
|
|
1819
|
+
id: M,
|
|
1820
|
+
name: M,
|
|
1821
|
+
placeholder: re,
|
|
1822
|
+
error: _[M]
|
|
1823
|
+
}
|
|
1824
|
+
) : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
1825
|
+
/* @__PURE__ */ t.jsx(
|
|
1826
|
+
"input",
|
|
1827
|
+
{
|
|
1828
|
+
type: O.pass ? "password" : "text",
|
|
1829
|
+
id: M,
|
|
1830
|
+
name: M,
|
|
1831
|
+
placeholder: re,
|
|
1832
|
+
className: `${r.input} ${_[M] ? r.inputError : ""}`,
|
|
1833
|
+
required: !0,
|
|
1834
|
+
"aria-invalid": !!_[M],
|
|
1835
|
+
"aria-describedby": _[M] ? `${M}-error` : void 0
|
|
1836
|
+
}
|
|
1837
|
+
),
|
|
1838
|
+
/* @__PURE__ */ t.jsx(
|
|
1839
|
+
"button",
|
|
1840
|
+
{
|
|
1841
|
+
type: "button",
|
|
1842
|
+
onClick: () => L({ ...O, pass: !O.pass }),
|
|
1843
|
+
className: r.inputIcon,
|
|
1844
|
+
"aria-label": O.pass ? "Show password" : "Hide password",
|
|
1845
|
+
children: O.pass ? /* @__PURE__ */ t.jsxs("svg", { className: r.eyeIcon, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1846
|
+
/* @__PURE__ */ t.jsx("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
1847
|
+
/* @__PURE__ */ t.jsx("circle", { cx: "12", cy: "12", r: "3" })
|
|
1848
|
+
] }) : /* @__PURE__ */ t.jsxs("svg", { className: r.eyeIcon, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1849
|
+
/* @__PURE__ */ t.jsx("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
|
|
1850
|
+
/* @__PURE__ */ t.jsx("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1851
|
+
] })
|
|
1852
|
+
}
|
|
1853
|
+
)
|
|
1854
|
+
] }) }),
|
|
1855
|
+
_[M] && /* @__PURE__ */ t.jsx("span", { id: `${M}-error`, className: r.errorText, role: "alert", children: _[M] })
|
|
1856
|
+
] }),
|
|
1857
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
1858
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: D, className: r.label, children: F }),
|
|
1859
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: A ? /* @__PURE__ */ t.jsx(
|
|
1860
|
+
A,
|
|
1861
|
+
{
|
|
1862
|
+
type: O.verify ? "password" : "text",
|
|
1863
|
+
id: D,
|
|
1864
|
+
name: D,
|
|
1865
|
+
placeholder: J,
|
|
1866
|
+
error: _[D]
|
|
1867
|
+
}
|
|
1868
|
+
) : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
1869
|
+
/* @__PURE__ */ t.jsx(
|
|
1870
|
+
"input",
|
|
1871
|
+
{
|
|
1872
|
+
type: O.verify ? "password" : "text",
|
|
1873
|
+
id: D,
|
|
1874
|
+
name: D,
|
|
1875
|
+
placeholder: J,
|
|
1876
|
+
className: `${r.input} ${_[D] ? r.inputError : ""}`,
|
|
1877
|
+
required: !0,
|
|
1878
|
+
"aria-invalid": !!_[D],
|
|
1879
|
+
"aria-describedby": _[D] ? `${D}-error` : void 0
|
|
1880
|
+
}
|
|
1881
|
+
),
|
|
1882
|
+
/* @__PURE__ */ t.jsx(
|
|
1883
|
+
"button",
|
|
1884
|
+
{
|
|
1885
|
+
type: "button",
|
|
1886
|
+
onClick: () => L({ ...O, verify: !O.verify }),
|
|
1887
|
+
className: r.inputIcon,
|
|
1888
|
+
"aria-label": O.verify ? "Show password" : "Hide password",
|
|
1889
|
+
children: O.verify ? /* @__PURE__ */ t.jsxs("svg", { className: r.eyeIcon, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1890
|
+
/* @__PURE__ */ t.jsx("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
1891
|
+
/* @__PURE__ */ t.jsx("circle", { cx: "12", cy: "12", r: "3" })
|
|
1892
|
+
] }) : /* @__PURE__ */ t.jsxs("svg", { className: r.eyeIcon, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1893
|
+
/* @__PURE__ */ t.jsx("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
|
|
1894
|
+
/* @__PURE__ */ t.jsx("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
1895
|
+
] })
|
|
1896
|
+
}
|
|
1897
|
+
)
|
|
1898
|
+
] }) }),
|
|
1899
|
+
_[D] && /* @__PURE__ */ t.jsx("span", { id: `${D}-error`, className: r.errorText, role: "alert", children: _[D] })
|
|
1900
|
+
] }),
|
|
1901
|
+
/* @__PURE__ */ t.jsx(Ue, { message: E, type: "error", style: { marginTop: "8px", marginBottom: "8px" }, onDismiss: x }),
|
|
1902
|
+
/* @__PURE__ */ t.jsx(T, { type: "submit", disabled: m, className: r.button, children: m ? s != null && s.Loader ? /* @__PURE__ */ t.jsx(s.Loader, {}) : "Loading..." : ee })
|
|
1903
|
+
] })
|
|
1904
|
+
] });
|
|
1905
|
+
}, Ns = ({
|
|
1906
|
+
components: s,
|
|
1907
|
+
labels: e,
|
|
1908
|
+
buttonText: o,
|
|
1909
|
+
validationSchema: n,
|
|
1910
|
+
onSuccess: i,
|
|
1911
|
+
site: d,
|
|
1912
|
+
id: g
|
|
1913
|
+
}) => {
|
|
1914
|
+
var W, K, C, B, $, X, Y, te, H, z, ce, fe, pe, ae, je, ge, Te, we, _e, ye, xe, me, ve, Pe, Fe, Me, $e, De, Be, qe, We, Ve, Ge, Ke, He, Ye, Je, Xe;
|
|
1915
|
+
const { user: l, config: m } = he(), { loading: E, error: k, success: b, execute: x, reset: _ } = qt(), [v, O] = S({}), [L, V] = S(!0), [P, G] = S({
|
|
1916
|
+
fullName: "",
|
|
1917
|
+
email: "",
|
|
1918
|
+
username: "",
|
|
1919
|
+
phoneNumber: "",
|
|
1920
|
+
password: "",
|
|
1921
|
+
profileUrl: "",
|
|
1922
|
+
city: "",
|
|
1923
|
+
state: "",
|
|
1924
|
+
country: "",
|
|
1925
|
+
postalcode: "",
|
|
1926
|
+
timezone: ""
|
|
1927
|
+
});
|
|
1928
|
+
st(() => {
|
|
1929
|
+
l && G({
|
|
1930
|
+
fullName: l.fullName || l.name || "",
|
|
1931
|
+
email: l.email || "",
|
|
1932
|
+
username: l.username || "",
|
|
1933
|
+
phoneNumber: l.phoneNumber || "",
|
|
1934
|
+
password: "",
|
|
1935
|
+
profileUrl: l.profileUrl || "",
|
|
1936
|
+
city: l.city || "",
|
|
1937
|
+
state: l.state || "",
|
|
1938
|
+
country: l.country || "",
|
|
1939
|
+
postalcode: l.postalcode || "",
|
|
1940
|
+
timezone: l.timezone || ""
|
|
1941
|
+
});
|
|
1942
|
+
}, [l]);
|
|
1943
|
+
const T = (Re) => {
|
|
1944
|
+
const { name: Ce, value: Ee } = Re.target;
|
|
1945
|
+
G((ue) => ({ ...ue, [Ce]: Ee }));
|
|
1946
|
+
}, A = n || ((K = (W = m.customization) == null ? void 0 : W.validationSchema) == null ? void 0 : K.updateUser) || ws, Q = async (Re) => {
|
|
1947
|
+
Re.preventDefault(), O({});
|
|
1948
|
+
const Ce = {
|
|
1949
|
+
fullName: P.fullName,
|
|
1950
|
+
email: P.email,
|
|
1951
|
+
username: P.username,
|
|
1952
|
+
phoneNumber: P.phoneNumber,
|
|
1953
|
+
password: P.password,
|
|
1954
|
+
profileUrl: P.profileUrl,
|
|
1955
|
+
city: P.city,
|
|
1956
|
+
state: P.state,
|
|
1957
|
+
country: P.country,
|
|
1958
|
+
postalcode: P.postalcode,
|
|
1959
|
+
timezone: P.timezone
|
|
1960
|
+
}, Ee = {};
|
|
1961
|
+
Object.entries(Ce).forEach(([ue, ke]) => {
|
|
1962
|
+
ke !== "" && (Ee[ue] = ke);
|
|
1963
|
+
});
|
|
1964
|
+
try {
|
|
1965
|
+
A.parse(Ee);
|
|
1966
|
+
} catch (ue) {
|
|
1967
|
+
if (ue instanceof I.ZodError) {
|
|
1968
|
+
const ke = {};
|
|
1969
|
+
ue.errors.forEach((Le) => {
|
|
1970
|
+
if (Le.path[0]) {
|
|
1971
|
+
const de = Le.path[0].toString(), Se = de === "fullName" ? f : de === "email" ? y : de === "username" ? w : de === "phoneNumber" ? a : de === "profileUrl" ? u : de === "password" ? j : de === "city" ? N : de === "state" ? U : de === "country" ? q : de === "postalcode" ? R : de;
|
|
1972
|
+
ke[Se] = Le.message;
|
|
1973
|
+
}
|
|
1974
|
+
}), O(ke);
|
|
1975
|
+
return;
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
try {
|
|
1979
|
+
const ue = await x(Ee, d, g);
|
|
1980
|
+
i && i(ue);
|
|
1981
|
+
} catch {
|
|
1982
|
+
}
|
|
1983
|
+
}, le = (s == null ? void 0 : s.Card) || "div", se = (s == null ? void 0 : s.Button) || "button", F = s == null ? void 0 : s.Input, ee = ((B = (C = m.customization) == null ? void 0 : C.labels) == null ? void 0 : B.updateUserTitle) || "Update Profile", re = (e == null ? void 0 : e.fullName) || ((X = ($ = m.customization) == null ? void 0 : $.labels) == null ? void 0 : X.updateUserFullName) || "Full Name", J = (e == null ? void 0 : e.email) || ((te = (Y = m.customization) == null ? void 0 : Y.labels) == null ? void 0 : te.updateUserEmail) || "Email", M = (e == null ? void 0 : e.username) || ((z = (H = m.customization) == null ? void 0 : H.labels) == null ? void 0 : z.updateUserUsername) || "Username", D = (e == null ? void 0 : e.phoneNumber) || ((fe = (ce = m.customization) == null ? void 0 : ce.labels) == null ? void 0 : fe.updateUserPhone) || "Phone Number", c = (e == null ? void 0 : e.password) || ((ae = (pe = m.customization) == null ? void 0 : pe.labels) == null ? void 0 : ae.updateUserPassword) || "New Password", h = (e == null ? void 0 : e.profileUrl) || ((ge = (je = m.customization) == null ? void 0 : je.labels) == null ? void 0 : ge.updateUserProfileUrl) || "Profile URL", p = o || ((we = (Te = m.customization) == null ? void 0 : Te.buttonText) == null ? void 0 : we.updateUser) || "Update Info", f = ((ye = (_e = m.requestMapping) == null ? void 0 : _e.updateUser) == null ? void 0 : ye.fullName) || "fullName", y = ((me = (xe = m.requestMapping) == null ? void 0 : xe.updateUser) == null ? void 0 : me.email) || "email", w = ((Pe = (ve = m.requestMapping) == null ? void 0 : ve.updateUser) == null ? void 0 : Pe.username) || "username", a = ((Me = (Fe = m.requestMapping) == null ? void 0 : Fe.updateUser) == null ? void 0 : Me.phoneNumber) || "phoneNumber", u = ((De = ($e = m.requestMapping) == null ? void 0 : $e.updateUser) == null ? void 0 : De.profileUrl) || "profileUrl", j = ((qe = (Be = m.requestMapping) == null ? void 0 : Be.updateUser) == null ? void 0 : qe.password) || "password", N = ((Ve = (We = m.requestMapping) == null ? void 0 : We.updateUser) == null ? void 0 : Ve.city) || "city", U = ((Ke = (Ge = m.requestMapping) == null ? void 0 : Ge.updateUser) == null ? void 0 : Ke.state) || "state", q = ((Ye = (He = m.requestMapping) == null ? void 0 : He.updateUser) == null ? void 0 : Ye.country) || "country", R = ((Xe = (Je = m.requestMapping) == null ? void 0 : Je.updateUser) == null ? void 0 : Xe.postalcode) || "postalcode";
|
|
1984
|
+
return /* @__PURE__ */ t.jsxs(le, { className: r.card, style: { maxWidth: "520px" }, children: [
|
|
1985
|
+
/* @__PURE__ */ t.jsx("h1", { className: r.heading, children: ee }),
|
|
1986
|
+
/* @__PURE__ */ t.jsxs("form", { onSubmit: Q, className: r.form, noValidate: !0, children: [
|
|
1987
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
1988
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: f, className: r.label, children: re }),
|
|
1989
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: F ? /* @__PURE__ */ t.jsx(
|
|
1990
|
+
F,
|
|
1991
|
+
{
|
|
1992
|
+
type: "text",
|
|
1993
|
+
id: f,
|
|
1994
|
+
name: f,
|
|
1995
|
+
value: P.fullName,
|
|
1996
|
+
onChange: T,
|
|
1997
|
+
placeholder: "John Doe",
|
|
1998
|
+
error: v[f]
|
|
1999
|
+
}
|
|
2000
|
+
) : /* @__PURE__ */ t.jsx(
|
|
2001
|
+
"input",
|
|
2002
|
+
{
|
|
2003
|
+
type: "text",
|
|
2004
|
+
id: f,
|
|
2005
|
+
name: f,
|
|
2006
|
+
value: P.fullName,
|
|
2007
|
+
onChange: T,
|
|
2008
|
+
placeholder: "John Doe",
|
|
2009
|
+
className: `${r.input} ${v[f] ? r.inputError : ""}`
|
|
2010
|
+
}
|
|
2011
|
+
) }),
|
|
2012
|
+
v[f] && /* @__PURE__ */ t.jsx("span", { className: r.errorText, children: v[f] })
|
|
2013
|
+
] }),
|
|
2014
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
2015
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: y, className: r.label, children: J }),
|
|
2016
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: F ? /* @__PURE__ */ t.jsx(
|
|
2017
|
+
F,
|
|
2018
|
+
{
|
|
2019
|
+
type: "email",
|
|
2020
|
+
id: y,
|
|
2021
|
+
name: y,
|
|
2022
|
+
value: P.email,
|
|
2023
|
+
onChange: T,
|
|
2024
|
+
placeholder: "email@example.com",
|
|
2025
|
+
error: v[y]
|
|
2026
|
+
}
|
|
2027
|
+
) : /* @__PURE__ */ t.jsx(
|
|
2028
|
+
"input",
|
|
2029
|
+
{
|
|
2030
|
+
type: "email",
|
|
2031
|
+
id: y,
|
|
2032
|
+
name: y,
|
|
2033
|
+
value: P.email,
|
|
2034
|
+
onChange: T,
|
|
2035
|
+
placeholder: "email@example.com",
|
|
2036
|
+
className: `${r.input} ${v[y] ? r.inputError : ""}`
|
|
2037
|
+
}
|
|
2038
|
+
) }),
|
|
2039
|
+
v[y] && /* @__PURE__ */ t.jsx("span", { className: r.errorText, children: v[y] })
|
|
2040
|
+
] }),
|
|
2041
|
+
/* @__PURE__ */ t.jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: "12px" }, children: [
|
|
2042
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
2043
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: w, className: r.label, children: M }),
|
|
2044
|
+
/* @__PURE__ */ t.jsx(
|
|
2045
|
+
"input",
|
|
2046
|
+
{
|
|
2047
|
+
type: "text",
|
|
2048
|
+
id: w,
|
|
2049
|
+
name: w,
|
|
2050
|
+
value: P.username,
|
|
2051
|
+
onChange: T,
|
|
2052
|
+
placeholder: "username",
|
|
2053
|
+
className: r.input
|
|
2054
|
+
}
|
|
2055
|
+
)
|
|
2056
|
+
] }),
|
|
2057
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
2058
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: a, className: r.label, children: D }),
|
|
2059
|
+
/* @__PURE__ */ t.jsx(
|
|
2060
|
+
"input",
|
|
2061
|
+
{
|
|
2062
|
+
type: "text",
|
|
2063
|
+
id: a,
|
|
2064
|
+
name: a,
|
|
2065
|
+
value: P.phoneNumber,
|
|
2066
|
+
onChange: T,
|
|
2067
|
+
placeholder: "+123456789",
|
|
2068
|
+
className: r.input
|
|
2069
|
+
}
|
|
2070
|
+
)
|
|
2071
|
+
] })
|
|
2072
|
+
] }),
|
|
2073
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
2074
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: u, className: r.label, children: h }),
|
|
2075
|
+
/* @__PURE__ */ t.jsx("div", { className: r.inputWrapper, children: /* @__PURE__ */ t.jsx(
|
|
2076
|
+
"input",
|
|
2077
|
+
{
|
|
2078
|
+
type: "text",
|
|
2079
|
+
id: u,
|
|
2080
|
+
name: u,
|
|
2081
|
+
value: P.profileUrl,
|
|
2082
|
+
onChange: T,
|
|
2083
|
+
placeholder: "https://example.com/avatar.png",
|
|
2084
|
+
className: `${r.input} ${v[u] ? r.inputError : ""}`
|
|
2085
|
+
}
|
|
2086
|
+
) }),
|
|
2087
|
+
v[u] && /* @__PURE__ */ t.jsx("span", { className: r.errorText, children: v[u] })
|
|
2088
|
+
] }),
|
|
2089
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
2090
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: j, className: r.label, children: c }),
|
|
2091
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.inputWrapper, children: [
|
|
2092
|
+
/* @__PURE__ */ t.jsx(
|
|
2093
|
+
"input",
|
|
2094
|
+
{
|
|
2095
|
+
type: L ? "password" : "text",
|
|
2096
|
+
id: j,
|
|
2097
|
+
name: j,
|
|
2098
|
+
value: P.password,
|
|
2099
|
+
onChange: T,
|
|
2100
|
+
placeholder: "•••••••• (leave empty to keep current)",
|
|
2101
|
+
className: `${r.input} ${v[j] ? r.inputError : ""}`
|
|
2102
|
+
}
|
|
2103
|
+
),
|
|
2104
|
+
/* @__PURE__ */ t.jsx(
|
|
2105
|
+
"button",
|
|
2106
|
+
{
|
|
2107
|
+
type: "button",
|
|
2108
|
+
onClick: () => V(!L),
|
|
2109
|
+
className: r.inputIcon,
|
|
2110
|
+
children: L ? /* @__PURE__ */ t.jsxs("svg", { className: r.eyeIcon, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2111
|
+
/* @__PURE__ */ t.jsx("path", { d: "M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" }),
|
|
2112
|
+
/* @__PURE__ */ t.jsx("circle", { cx: "12", cy: "12", r: "3" })
|
|
2113
|
+
] }) : /* @__PURE__ */ t.jsxs("svg", { className: r.eyeIcon, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2114
|
+
/* @__PURE__ */ t.jsx("path", { d: "M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24" }),
|
|
2115
|
+
/* @__PURE__ */ t.jsx("line", { x1: "1", y1: "1", x2: "23", y2: "23" })
|
|
2116
|
+
] })
|
|
2117
|
+
}
|
|
2118
|
+
)
|
|
2119
|
+
] }),
|
|
2120
|
+
v[j] && /* @__PURE__ */ t.jsx("span", { className: r.errorText, children: v[j] })
|
|
2121
|
+
] }),
|
|
2122
|
+
/* @__PURE__ */ t.jsxs("div", { style: { marginTop: "4px", borderTop: "1px solid var(--auth-color-border, #e2e8f0)", paddingTop: "12px" }, children: [
|
|
2123
|
+
/* @__PURE__ */ t.jsx("h3", { style: { margin: "0 0 10px 0", fontSize: "0.9rem", fontWeight: 600 }, children: "Location Details" }),
|
|
2124
|
+
/* @__PURE__ */ t.jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: "12px" }, children: [
|
|
2125
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
2126
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: N, className: r.label, children: "City" }),
|
|
2127
|
+
/* @__PURE__ */ t.jsx("input", { type: "text", id: N, name: N, value: P.city, onChange: T, placeholder: "City", className: r.input })
|
|
2128
|
+
] }),
|
|
2129
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
2130
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: U, className: r.label, children: "State" }),
|
|
2131
|
+
/* @__PURE__ */ t.jsx("input", { type: "text", id: U, name: U, value: P.state, onChange: T, placeholder: "State", className: r.input })
|
|
2132
|
+
] })
|
|
2133
|
+
] }),
|
|
2134
|
+
/* @__PURE__ */ t.jsxs("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: "12px", marginTop: "10px" }, children: [
|
|
2135
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
2136
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: q, className: r.label, children: "Country" }),
|
|
2137
|
+
/* @__PURE__ */ t.jsx("input", { type: "text", id: q, name: q, value: P.country, onChange: T, placeholder: "Country", className: r.input })
|
|
2138
|
+
] }),
|
|
2139
|
+
/* @__PURE__ */ t.jsxs("div", { className: r.formGroup, children: [
|
|
2140
|
+
/* @__PURE__ */ t.jsx("label", { htmlFor: R, className: r.label, children: "Postal Code" }),
|
|
2141
|
+
/* @__PURE__ */ t.jsx("input", { type: "text", id: R, name: R, value: P.postalcode, onChange: T, placeholder: "Postal Code", className: r.input })
|
|
2142
|
+
] })
|
|
2143
|
+
] })
|
|
2144
|
+
] }),
|
|
2145
|
+
/* @__PURE__ */ t.jsx(Ue, { message: b ? "Profile updated successfully." : null, type: "success", style: { marginTop: "12px", marginBottom: "8px" }, onDismiss: _ }),
|
|
2146
|
+
/* @__PURE__ */ t.jsx(Ue, { message: k, type: "error", style: { marginTop: "12px", marginBottom: "8px" }, onDismiss: _ }),
|
|
2147
|
+
/* @__PURE__ */ t.jsx(se, { type: "submit", disabled: E, className: r.button, style: { marginTop: "10px" }, children: E ? s != null && s.Loader ? /* @__PURE__ */ t.jsx(s.Loader, {}) : "Updating..." : p })
|
|
2148
|
+
] })
|
|
2149
|
+
] });
|
|
2150
|
+
}, Rs = ({ view: s = "login", onSuccess: e }) => {
|
|
2151
|
+
const [o, n] = S(s), [i, d] = S(""), [g, l] = S(null), { isAuthenticated: m } = he();
|
|
2152
|
+
return st(() => {
|
|
2153
|
+
n(s);
|
|
2154
|
+
}, [s]), st(() => {
|
|
2155
|
+
const E = (x) => {
|
|
2156
|
+
if (x && x.email)
|
|
2157
|
+
d(x.email);
|
|
2158
|
+
else {
|
|
2159
|
+
const _ = sessionStorage.getItem("auth_registration_email");
|
|
2160
|
+
_ && d(_);
|
|
2161
|
+
}
|
|
2162
|
+
n("otp");
|
|
2163
|
+
}, k = (x) => {
|
|
2164
|
+
e && e("login", x);
|
|
2165
|
+
}, b = (x) => {
|
|
2166
|
+
n("login"), e && e("resetPassword", x);
|
|
2167
|
+
};
|
|
2168
|
+
return ne.on("OTP_SENT", E), ne.on("LOGIN_SUCCESS", k), ne.on("PASSWORD_RESET", b), () => {
|
|
2169
|
+
ne.off("OTP_SENT", E), ne.off("LOGIN_SUCCESS", k), ne.off("PASSWORD_RESET", b);
|
|
2170
|
+
};
|
|
2171
|
+
}, [e]), m && o !== "updateUser" && o !== "resetPassword" ? null : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
2172
|
+
o === "login" && /* @__PURE__ */ t.jsx(
|
|
2173
|
+
vs,
|
|
2174
|
+
{
|
|
2175
|
+
onForgotPasswordClick: () => n("forgotPassword"),
|
|
2176
|
+
onSignupClick: () => n("signup")
|
|
2177
|
+
}
|
|
2178
|
+
),
|
|
2179
|
+
o === "signup" && /* @__PURE__ */ t.jsx(
|
|
2180
|
+
bs,
|
|
2181
|
+
{
|
|
2182
|
+
onLoginClick: () => n("login")
|
|
2183
|
+
}
|
|
2184
|
+
),
|
|
2185
|
+
o === "forgotPassword" && /* @__PURE__ */ t.jsx(
|
|
2186
|
+
js,
|
|
2187
|
+
{
|
|
2188
|
+
onBackToLoginClick: () => n("login"),
|
|
2189
|
+
onSuccess: (E) => {
|
|
2190
|
+
E && E.email && d(E.email), n("otp");
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
),
|
|
2194
|
+
o === "otp" && /* @__PURE__ */ t.jsx(
|
|
2195
|
+
Es,
|
|
2196
|
+
{
|
|
2197
|
+
email: i,
|
|
2198
|
+
onSuccess: (E) => {
|
|
2199
|
+
const k = (E == null ? void 0 : E.accessToken) || (E == null ? void 0 : E.token);
|
|
2200
|
+
k && (l(k), n("resetPassword")), e && e("otp", E);
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
),
|
|
2204
|
+
o === "resetPassword" && /* @__PURE__ */ t.jsx(ks, { urlParams: g ? { token: g } : void 0 }),
|
|
2205
|
+
o === "updateUser" && /* @__PURE__ */ t.jsx(
|
|
2206
|
+
Ns,
|
|
2207
|
+
{
|
|
2208
|
+
onSuccess: (E) => {
|
|
2209
|
+
e && e("updateUser", E);
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
)
|
|
2213
|
+
] });
|
|
2214
|
+
};
|
|
2215
|
+
export {
|
|
2216
|
+
Ue as Alert,
|
|
2217
|
+
bt as AuthContext,
|
|
2218
|
+
Is as AuthProvider,
|
|
2219
|
+
Ae as AuthSdkError,
|
|
2220
|
+
Rs as AuthWidget,
|
|
2221
|
+
js as ForgotPassword,
|
|
2222
|
+
jt as GoogleLogin,
|
|
2223
|
+
vs as Login,
|
|
2224
|
+
Es as OTP,
|
|
2225
|
+
ks as ResetPassword,
|
|
2226
|
+
bs as Signup,
|
|
2227
|
+
Ns as UpdateUser,
|
|
2228
|
+
it as decodeJWT,
|
|
2229
|
+
ne as eventService,
|
|
2230
|
+
Lt as isTokenExpired,
|
|
2231
|
+
ps as loginSchema,
|
|
2232
|
+
Ie as normalizeError,
|
|
2233
|
+
ms as otpEmailSchema,
|
|
2234
|
+
ys as otpSchema,
|
|
2235
|
+
hs as otpSubmitSchema,
|
|
2236
|
+
xs as resetPasswordSchema,
|
|
2237
|
+
fs as signupSchema,
|
|
2238
|
+
ws as updateUserSchema,
|
|
2239
|
+
he as useAuth,
|
|
2240
|
+
Ft as useLogin,
|
|
2241
|
+
Dt as useOtp,
|
|
2242
|
+
Bt as useResetPassword,
|
|
2243
|
+
Mt as useSignup,
|
|
2244
|
+
qt as useUpdateUser,
|
|
2245
|
+
$t as useVerifyIdentity,
|
|
2246
|
+
gs as verifyIdentitySchema
|
|
2247
|
+
};
|
|
2248
|
+
//# sourceMappingURL=index.js.map
|