@brightnkhoma/bright-auth-client 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/auth-wrapper.d.ts.map +1 -1
- package/dist/context/auth-context.d.ts +2 -0
- package/dist/context/auth-context.d.ts.map +1 -1
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +35 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { TagAuthProvider } from './components/auth-wrapper.js';
|
|
1
|
+
export { TagAuthProvider as BrightAuthProvider } from './components/auth-wrapper.js';
|
|
2
2
|
export { InputOTPForm } from './components/otp.js';
|
|
3
3
|
export { LoginForm } from './components/login-form.js';
|
|
4
4
|
export { SignupForm } from './components/signup-form.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAA;AAErB,OAAO,EAAC,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAA;AAErB,OAAO,EAAC,eAAe,IAAI,kBAAkB,EAAC,MAAM,8BAA8B,CAAA;AAClF,OAAO,EAAC,YAAY,EAAC,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAC,SAAS,EAAC,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA;AACtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAC,UAAU,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,6BAA6B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -56,7 +56,11 @@ var p = (e) => {
|
|
|
56
56
|
},
|
|
57
57
|
loginWithGoogle: function(e) {
|
|
58
58
|
throw Error("Function not implemented.");
|
|
59
|
-
}
|
|
59
|
+
},
|
|
60
|
+
logout: function() {
|
|
61
|
+
throw Error("Function not implemented.");
|
|
62
|
+
},
|
|
63
|
+
isLogingOut: !1
|
|
60
64
|
}), g = ({ children: e, useRouter: t }) => {
|
|
61
65
|
let [n, r] = s(null), [i, a] = s({
|
|
62
66
|
email: "",
|
|
@@ -64,7 +68,7 @@ var p = (e) => {
|
|
|
64
68
|
password: "",
|
|
65
69
|
userName: "",
|
|
66
70
|
otp: ""
|
|
67
|
-
}), [o, c] = s(""), [u, d] = s(!1), [f, p] = s(null), [h, g] = s(!1), _ = t(), [v, y] = s(!1), [b, x] = s(!1), S = async () => {
|
|
71
|
+
}), [o, c] = s(""), [u, d] = s(!1), [f, p] = s(null), [h, g] = s(!1), _ = t(), [v, y] = s(!1), [b, x] = s(!1), [S, C] = s(!1), w = async () => {
|
|
68
72
|
try {
|
|
69
73
|
x(!0);
|
|
70
74
|
let e = new URLSearchParams({ type: "resend_otp" }), t = await (await fetch(`/api/auth?${e.toString()}`)).json();
|
|
@@ -74,12 +78,20 @@ var p = (e) => {
|
|
|
74
78
|
} finally {
|
|
75
79
|
x(!1);
|
|
76
80
|
}
|
|
77
|
-
},
|
|
81
|
+
}, T = async () => {
|
|
82
|
+
try {
|
|
83
|
+
C(!0), (await fetch("/api/auth", { method: "DELETE" })).ok && _.replace("/");
|
|
84
|
+
} catch (e) {
|
|
85
|
+
console.log(e);
|
|
86
|
+
} finally {
|
|
87
|
+
C(!1);
|
|
88
|
+
}
|
|
89
|
+
}, E = (e) => {
|
|
78
90
|
a((t) => ({
|
|
79
91
|
...t,
|
|
80
92
|
[e.target.id]: e.target.value
|
|
81
93
|
}));
|
|
82
|
-
},
|
|
94
|
+
}, D = async (e) => {
|
|
83
95
|
try {
|
|
84
96
|
if (!e) return;
|
|
85
97
|
y(!0);
|
|
@@ -88,13 +100,13 @@ var p = (e) => {
|
|
|
88
100
|
google: e
|
|
89
101
|
}), n = await (await fetch(`/api/auth?${t.toString()}`)).json();
|
|
90
102
|
if (!n.success) throw Error(n.message ?? "Login failed, please try again later");
|
|
91
|
-
g(!0), await
|
|
103
|
+
g(!0), await A(!0), _.replace("/");
|
|
92
104
|
} catch (e) {
|
|
93
105
|
console.log(e), p(e instanceof Error ? e.message : "Something went wrong. Try again.");
|
|
94
106
|
} finally {
|
|
95
107
|
y(!1);
|
|
96
108
|
}
|
|
97
|
-
},
|
|
109
|
+
}, O = async (e) => {
|
|
98
110
|
try {
|
|
99
111
|
y(!0);
|
|
100
112
|
let t = new URLSearchParams({
|
|
@@ -102,13 +114,13 @@ var p = (e) => {
|
|
|
102
114
|
type: "login"
|
|
103
115
|
}), n = await (await fetch(`/api/auth?${t.toString()}`)).json();
|
|
104
116
|
if (!n.success) throw Error(n.message ?? "Login failed, please try again later");
|
|
105
|
-
g(!0), await
|
|
117
|
+
g(!0), await A(!0), _.replace("/");
|
|
106
118
|
} catch (e) {
|
|
107
119
|
p(e instanceof Error ? e.message : "Something went wrong. Try again.");
|
|
108
120
|
} finally {
|
|
109
121
|
y(!1);
|
|
110
122
|
}
|
|
111
|
-
},
|
|
123
|
+
}, k = async (e = !1) => {
|
|
112
124
|
try {
|
|
113
125
|
let e = new URLSearchParams({ type: "me" }), t = await (await fetch(`/api/auth?${e.toString()}`)).json();
|
|
114
126
|
if (!t.success) throw Error(t.message);
|
|
@@ -119,14 +131,14 @@ var p = (e) => {
|
|
|
119
131
|
} catch (t) {
|
|
120
132
|
if (p(t instanceof Error ? t.message : "Something went wrong. Try again."), e) throw Error(t instanceof Error ? t.message : "Something went wrong. Try again.");
|
|
121
133
|
}
|
|
122
|
-
},
|
|
134
|
+
}, A = (e = !1) => k(e), ee = (e) => {
|
|
123
135
|
a((t) => ({
|
|
124
136
|
...t,
|
|
125
137
|
otp: e
|
|
126
138
|
}));
|
|
127
|
-
},
|
|
128
|
-
if (i.otp) return await
|
|
129
|
-
},
|
|
139
|
+
}, te = async () => {
|
|
140
|
+
if (i.otp) return await j(void 0, !0);
|
|
141
|
+
}, j = async (e, t) => {
|
|
130
142
|
if (e && e.preventDefault(), p(null), g(!1), !t) {
|
|
131
143
|
if (i.password.length < 8) {
|
|
132
144
|
p("Password must be at least 8 characters long.");
|
|
@@ -168,25 +180,27 @@ var p = (e) => {
|
|
|
168
180
|
confirmPassword: o,
|
|
169
181
|
error: f,
|
|
170
182
|
form: i,
|
|
171
|
-
handleChange:
|
|
183
|
+
handleChange: E,
|
|
172
184
|
loading: u,
|
|
173
|
-
onSignUp:
|
|
185
|
+
onSignUp: j,
|
|
174
186
|
setConfirmPassword: c,
|
|
175
187
|
setError: p,
|
|
176
188
|
setForm: a,
|
|
177
189
|
setLoading: d,
|
|
178
190
|
setSuccess: g,
|
|
179
191
|
success: h,
|
|
180
|
-
setOtp:
|
|
181
|
-
verififyOTP:
|
|
192
|
+
setOtp: ee,
|
|
193
|
+
verififyOTP: te,
|
|
182
194
|
isLogingIn: v,
|
|
183
|
-
login:
|
|
195
|
+
login: O,
|
|
184
196
|
setIsLoggingIn: y,
|
|
185
|
-
refresh:
|
|
197
|
+
refresh: A,
|
|
186
198
|
isResendingOtp: b,
|
|
187
199
|
user: n,
|
|
188
|
-
resendOtp:
|
|
189
|
-
loginWithGoogle:
|
|
200
|
+
resendOtp: w,
|
|
201
|
+
loginWithGoogle: D,
|
|
202
|
+
isLogingOut: S,
|
|
203
|
+
logout: T
|
|
190
204
|
},
|
|
191
205
|
children: e
|
|
192
206
|
});
|
|
@@ -5709,6 +5723,6 @@ function Ic() {
|
|
|
5709
5723
|
});
|
|
5710
5724
|
}
|
|
5711
5725
|
//#endregion
|
|
5712
|
-
export { Pc as AuthClient, Cn as InputOTPForm, Oc as LoginForm, Ac as SignupForm,
|
|
5726
|
+
export { Pc as AuthClient, g as BrightAuthProvider, Cn as InputOTPForm, Oc as LoginForm, Ac as SignupForm, p as createAppContext, h as useTagAuth };
|
|
5713
5727
|
|
|
5714
5728
|
//# sourceMappingURL=index.js.map
|