clefbase 2.0.1 → 2.0.3
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/app.d.ts +6 -26
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +10 -28
- package/dist/app.js.map +1 -1
- package/dist/auth/index.d.ts +48 -164
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +178 -227
- package/dist/auth/index.js.map +1 -1
- package/dist/cli-src/cli/commands/init.js +28 -1
- package/dist/cli.js +29 -2
- package/dist/index.d.ts +14 -60
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -65
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/auth/index.js
CHANGED
|
@@ -47,60 +47,14 @@ class SessionStore {
|
|
|
47
47
|
catch { /* ignore */ }
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
// ─── GIS script loader ────────────────────────────────────────────────────────
|
|
51
|
-
const GIS_SCRIPT_URL = "https://accounts.google.com/gsi/client";
|
|
52
|
-
let _gisLoading = null;
|
|
53
|
-
function loadGisScript() {
|
|
54
|
-
if (typeof window === "undefined") {
|
|
55
|
-
return Promise.reject(new types_1.ClefbaseError("signInWithGoogle() requires a browser environment. " +
|
|
56
|
-
"Use signInWithGoogleToken(idToken) for server/Node.js contexts.", "UNSUPPORTED_ENVIRONMENT"));
|
|
57
|
-
}
|
|
58
|
-
if (window.google?.accounts?.id)
|
|
59
|
-
return Promise.resolve();
|
|
60
|
-
if (_gisLoading)
|
|
61
|
-
return _gisLoading;
|
|
62
|
-
_gisLoading = new Promise((resolve, reject) => {
|
|
63
|
-
if (window.google?.accounts?.id) {
|
|
64
|
-
resolve();
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const existing = document.querySelector(`script[src="${GIS_SCRIPT_URL}"]`);
|
|
68
|
-
const onLoad = () => resolve();
|
|
69
|
-
const onError = () => {
|
|
70
|
-
_gisLoading = null;
|
|
71
|
-
reject(new types_1.ClefbaseError("Failed to load the Google Identity Services script. Check your internet connection and Content Security Policy.", "GOOGLE_SCRIPT_LOAD_ERROR"));
|
|
72
|
-
};
|
|
73
|
-
if (existing) {
|
|
74
|
-
existing.addEventListener("load", onLoad, { once: true });
|
|
75
|
-
existing.addEventListener("error", onError, { once: true });
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const script = document.createElement("script");
|
|
79
|
-
script.src = GIS_SCRIPT_URL;
|
|
80
|
-
script.async = true;
|
|
81
|
-
script.defer = true;
|
|
82
|
-
script.addEventListener("load", onLoad, { once: true });
|
|
83
|
-
script.addEventListener("error", onError, { once: true });
|
|
84
|
-
document.head.appendChild(script);
|
|
85
|
-
});
|
|
86
|
-
return _gisLoading;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Authentication service. Obtain via `getAuth(app)`.
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* const auth = getAuth(app);
|
|
93
|
-
* const { user } = await auth.signIn("alice@example.com", "pass");
|
|
94
|
-
* const unsub = auth.onAuthStateChanged(u => console.log(u));
|
|
95
|
-
* unsub();
|
|
96
|
-
*/
|
|
97
50
|
class Auth {
|
|
98
|
-
constructor(http) {
|
|
51
|
+
constructor(http, gatewayUrl, projectId) {
|
|
99
52
|
this.http = http;
|
|
100
53
|
this.store = new SessionStore();
|
|
101
54
|
this.listeners = [];
|
|
102
|
-
|
|
103
|
-
this.
|
|
55
|
+
this._modalCleanup = null;
|
|
56
|
+
this.gatewayUrl = gatewayUrl.replace(/\/+$/, "");
|
|
57
|
+
this.projectId = projectId;
|
|
104
58
|
this.store.load();
|
|
105
59
|
}
|
|
106
60
|
// ── Internals ─────────────────────────────────────────────────────────────
|
|
@@ -121,186 +75,218 @@ class Auth {
|
|
|
121
75
|
this.notify(result.user);
|
|
122
76
|
return result;
|
|
123
77
|
}
|
|
124
|
-
async resolveGoogleClientId() {
|
|
125
|
-
if (this._googleClientId !== undefined) {
|
|
126
|
-
if (!this._googleClientId) {
|
|
127
|
-
throw new types_1.ClefbaseError("Google Sign-In is not enabled for this project. " +
|
|
128
|
-
"Add a Google Client ID in your Clefbase auth settings.", "GOOGLE_NOT_CONFIGURED");
|
|
129
|
-
}
|
|
130
|
-
return this._googleClientId;
|
|
131
|
-
}
|
|
132
|
-
const cfg = await this.http.get("/google/config");
|
|
133
|
-
if (!cfg.enabled || !cfg.clientId) {
|
|
134
|
-
this._googleClientId = null;
|
|
135
|
-
throw new types_1.ClefbaseError("Google Sign-In is not enabled for this project. " +
|
|
136
|
-
"Add a Google Client ID in your Clefbase auth settings.", "GOOGLE_NOT_CONFIGURED");
|
|
137
|
-
}
|
|
138
|
-
this._googleClientId = cfg.clientId;
|
|
139
|
-
return this._googleClientId;
|
|
140
|
-
}
|
|
141
78
|
/** @internal — used by Storage to attach the bearer token to upload requests */
|
|
142
79
|
getAuthHeaders() {
|
|
143
80
|
const s = this.store.load();
|
|
144
81
|
return s ? { Authorization: `Bearer ${s.token}` } : {};
|
|
145
82
|
}
|
|
146
83
|
// ── Public API ────────────────────────────────────────────────────────────
|
|
147
|
-
/** The currently signed-in user, or null. */
|
|
148
84
|
get currentUser() { return this.store.load()?.user ?? null; }
|
|
149
|
-
/** The raw bearer token for the active session, or null. */
|
|
150
85
|
get currentToken() { return this.store.load()?.token ?? null; }
|
|
151
|
-
|
|
152
|
-
* Create a new account.
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* const { user } = await auth.signUp("alice@example.com", "pass123", {
|
|
156
|
-
* displayName: "Alice",
|
|
157
|
-
* metadata: { role: "admin" },
|
|
158
|
-
* });
|
|
159
|
-
*/
|
|
86
|
+
// ── Email / password ──────────────────────────────────────────────────────
|
|
160
87
|
async signUp(email, password, profile) {
|
|
161
|
-
const result = await this.http.post("/signup", {
|
|
162
|
-
email, password, ...profile,
|
|
163
|
-
});
|
|
88
|
+
const result = await this.http.post("/signup", { email, password, ...profile });
|
|
164
89
|
return this.handleResult(result);
|
|
165
90
|
}
|
|
166
|
-
/**
|
|
167
|
-
* Sign in with email + password.
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* const { user, token } = await auth.signIn("alice@example.com", "pass");
|
|
171
|
-
*/
|
|
172
91
|
async signIn(email, password) {
|
|
173
92
|
const result = await this.http.post("/signin", { email, password });
|
|
174
93
|
return this.handleResult(result);
|
|
175
94
|
}
|
|
95
|
+
// ── Auth UI modal ─────────────────────────────────────────────────────────
|
|
176
96
|
/**
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* Browser-only. The GIS script (`accounts.google.com/gsi/client`) is loaded
|
|
180
|
-
* automatically — no manual `<script>` tag needed.
|
|
181
|
-
*
|
|
182
|
-
* Without `buttonOptions`, the Google One Tap prompt is shown.
|
|
183
|
-
* Pass `{ container }` to render a fully styled Google button instead —
|
|
184
|
-
* which is more reliable since One Tap can be suppressed by the browser.
|
|
97
|
+
* Open the Cleforyx hosted auth UI as a modal overlay on top of your page.
|
|
98
|
+
* Handles sign-in via email/password, Google, and magic link seamlessly.
|
|
185
99
|
*
|
|
186
|
-
*
|
|
187
|
-
* seen before, a new user record is created server-side.
|
|
188
|
-
*
|
|
189
|
-
* @throws `ClefbaseError` with code `GOOGLE_NOT_CONFIGURED` if no Client ID
|
|
190
|
-
* has been set in the project's auth settings.
|
|
191
|
-
* @throws `ClefbaseError` with code `GOOGLE_PROMPT_SUPPRESSED` if One Tap
|
|
192
|
-
* could not be displayed (switch to button mode in that case).
|
|
193
|
-
* @throws `ClefbaseError` with code `GOOGLE_SIGN_IN_CANCELLED` if the user
|
|
194
|
-
* dismissed the popup.
|
|
100
|
+
* The modal closes automatically on successful sign-in and fires `onSuccess`.
|
|
195
101
|
*
|
|
196
102
|
* @example
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*
|
|
202
|
-
* container: document.getElementById("google-btn")!,
|
|
203
|
-
* theme: "filled_blue",
|
|
204
|
-
* size: "large",
|
|
205
|
-
* text: "continue_with",
|
|
103
|
+
* auth.openAuthUI({
|
|
104
|
+
* onSuccess: (result) => {
|
|
105
|
+
* console.log("Signed in:", result.user.email);
|
|
106
|
+
* navigate("/dashboard");
|
|
107
|
+
* },
|
|
206
108
|
* });
|
|
207
|
-
*
|
|
208
|
-
* // React example
|
|
209
|
-
* const btnRef = useRef<HTMLDivElement>(null);
|
|
210
|
-
* await auth.signInWithGoogle({ container: btnRef.current! });
|
|
211
109
|
*/
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
110
|
+
openAuthUI(options = {}) {
|
|
111
|
+
if (typeof window === "undefined") {
|
|
112
|
+
throw new types_1.ClefbaseError("openAuthUI() requires a browser environment.", "UNSUPPORTED_ENVIRONMENT");
|
|
113
|
+
}
|
|
114
|
+
const { mode = "modal", onSuccess, onDismiss, redirectUrl } = options;
|
|
115
|
+
const currentUrl = window.location.href;
|
|
116
|
+
const returnUrl = redirectUrl ?? currentUrl;
|
|
117
|
+
const params = new URLSearchParams({
|
|
118
|
+
project: this.projectId,
|
|
119
|
+
redirect: returnUrl,
|
|
120
|
+
embed: "popup",
|
|
121
|
+
});
|
|
122
|
+
const authUrl = `${this.gatewayUrl}/login?${params}`;
|
|
123
|
+
if (mode === "redirect") {
|
|
124
|
+
window.location.href = authUrl;
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
// ── Modal mode ──────────────────────────────────────────────────────────
|
|
128
|
+
// Inject styles once
|
|
129
|
+
if (!document.getElementById("cfx-modal-styles")) {
|
|
130
|
+
const style = document.createElement("style");
|
|
131
|
+
style.id = "cfx-modal-styles";
|
|
132
|
+
style.textContent = `
|
|
133
|
+
@keyframes cfxFadeIn { from { opacity: 0 } to { opacity: 1 } }
|
|
134
|
+
@keyframes cfxSlideUp { from { transform: translateY(20px); opacity: 0 } to { transform: none; opacity: 1 } }
|
|
135
|
+
#cfx-auth-overlay {
|
|
136
|
+
position: fixed; inset: 0; z-index: 999999;
|
|
137
|
+
background: rgba(15,23,42,0.6); backdrop-filter: blur(4px);
|
|
138
|
+
display: flex; align-items: center; justify-content: center;
|
|
139
|
+
animation: cfxFadeIn 0.18s ease;
|
|
140
|
+
padding: 16px; box-sizing: border-box;
|
|
141
|
+
}
|
|
142
|
+
#cfx-auth-card {
|
|
143
|
+
background: white; border-radius: 20px;
|
|
144
|
+
box-shadow: 0 24px 64px rgba(0,0,0,0.2);
|
|
145
|
+
overflow: hidden; width: 100%; max-width: 460px;
|
|
146
|
+
animation: cfxSlideUp 0.22s ease; position: relative;
|
|
147
|
+
}
|
|
148
|
+
#cfx-auth-frame {
|
|
149
|
+
width: 100%; height: 560px; border: none; display: block;
|
|
150
|
+
}
|
|
151
|
+
#cfx-auth-close {
|
|
152
|
+
position: absolute; top: 14px; right: 16px;
|
|
153
|
+
background: rgba(0,0,0,0.06); border: none;
|
|
154
|
+
width: 28px; height: 28px; border-radius: 50%;
|
|
155
|
+
font-size: 16px; line-height: 1; cursor: pointer;
|
|
156
|
+
display: flex; align-items: center; justify-content: center;
|
|
157
|
+
color: #64748b; z-index: 1; transition: background 0.15s;
|
|
158
|
+
}
|
|
159
|
+
#cfx-auth-close:hover { background: rgba(0,0,0,0.12); }
|
|
160
|
+
`;
|
|
161
|
+
document.head.appendChild(style);
|
|
162
|
+
}
|
|
163
|
+
// Create overlay
|
|
164
|
+
const overlay = document.createElement("div");
|
|
165
|
+
overlay.id = "cfx-auth-overlay";
|
|
166
|
+
const card = document.createElement("div");
|
|
167
|
+
card.id = "cfx-auth-card";
|
|
168
|
+
const closeBtn = document.createElement("button");
|
|
169
|
+
closeBtn.id = "cfx-auth-close";
|
|
170
|
+
closeBtn.innerHTML = "✕";
|
|
171
|
+
closeBtn.setAttribute("aria-label", "Close");
|
|
172
|
+
const iframe = document.createElement("iframe");
|
|
173
|
+
iframe.id = "cfx-auth-frame";
|
|
174
|
+
iframe.src = authUrl;
|
|
175
|
+
iframe.setAttribute("allow", "identity-credentials-get");
|
|
176
|
+
card.appendChild(closeBtn);
|
|
177
|
+
card.appendChild(iframe);
|
|
178
|
+
overlay.appendChild(card);
|
|
179
|
+
document.body.appendChild(overlay);
|
|
180
|
+
// Prevent body scroll
|
|
181
|
+
const prevOverflow = document.body.style.overflow;
|
|
182
|
+
document.body.style.overflow = "hidden";
|
|
183
|
+
const cleanup = () => {
|
|
184
|
+
overlay.remove();
|
|
185
|
+
document.body.style.overflow = prevOverflow;
|
|
186
|
+
window.removeEventListener("message", messageHandler);
|
|
187
|
+
this._modalCleanup = null;
|
|
188
|
+
};
|
|
189
|
+
const messageHandler = async (e) => {
|
|
190
|
+
if (e.data?.source !== "cleforyx-auth" || e.data?.type !== "auth_success")
|
|
191
|
+
return;
|
|
192
|
+
const { token, user: rawUser } = e.data;
|
|
193
|
+
if (!token)
|
|
194
|
+
return;
|
|
195
|
+
cleanup();
|
|
196
|
+
// Build a full AuthResult — fetch fresh user data to get expiresAt
|
|
197
|
+
// Use the public /me endpoint (no API key needed, just dbId + bearer)
|
|
198
|
+
try {
|
|
199
|
+
const serverUrl = this.http.getBaseUrl().replace(/\/auth$/, "");
|
|
200
|
+
const res = await fetch(`${serverUrl}/auth/public/me?dbId=${encodeURIComponent(this.projectId)}`, {
|
|
201
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
241
202
|
});
|
|
203
|
+
const user = res.ok ? await res.json() : rawUser;
|
|
204
|
+
const expiresAt = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString();
|
|
205
|
+
const result = { user, token, session: { token, expiresAt } };
|
|
206
|
+
this.handleResult(result);
|
|
207
|
+
onSuccess?.(result);
|
|
242
208
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
209
|
+
catch {
|
|
210
|
+
// Fallback: use the user data from postMessage directly
|
|
211
|
+
const expiresAt = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString();
|
|
212
|
+
const result = { user: rawUser, token, session: { token, expiresAt } };
|
|
213
|
+
this.handleResult(result);
|
|
214
|
+
onSuccess?.(result);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
closeBtn.onclick = () => { cleanup(); onDismiss?.(); };
|
|
218
|
+
overlay.addEventListener("click", (e) => {
|
|
219
|
+
if (e.target === overlay) {
|
|
220
|
+
cleanup();
|
|
221
|
+
onDismiss?.();
|
|
253
222
|
}
|
|
254
223
|
});
|
|
224
|
+
window.addEventListener("message", messageHandler);
|
|
225
|
+
this._modalCleanup = cleanup;
|
|
226
|
+
}
|
|
227
|
+
/** Close the auth modal programmatically if open. */
|
|
228
|
+
closeAuthUI() {
|
|
229
|
+
this._modalCleanup?.();
|
|
255
230
|
}
|
|
231
|
+
// ── Gateway redirect flow ─────────────────────────────────────────────────
|
|
256
232
|
/**
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* Use this when you already have a `credential` from Google's callback —
|
|
260
|
-
* for example with a custom button implementation, React Native Google
|
|
261
|
-
* Sign-In, or any other flow that gives you an ID token directly.
|
|
262
|
-
*
|
|
263
|
-
* Works in both browser and Node.js environments.
|
|
233
|
+
* Redirect to the Cleforyx auth gateway for OAuth sign-in.
|
|
234
|
+
* Use `openAuthUI()` for a modal experience instead.
|
|
264
235
|
*
|
|
265
236
|
* @example
|
|
266
|
-
*
|
|
267
|
-
* google.accounts.id.initialize({
|
|
268
|
-
* client_id: "...",
|
|
269
|
-
* callback: async ({ credential }) => {
|
|
270
|
-
* const { user } = await auth.signInWithGoogleToken(credential);
|
|
271
|
-
* },
|
|
272
|
-
* });
|
|
273
|
-
*
|
|
274
|
-
* // React Native
|
|
275
|
-
* const { idToken } = await GoogleSignin.signIn();
|
|
276
|
-
* const { user } = await auth.signInWithGoogleToken(idToken);
|
|
237
|
+
* await auth.signInWithGateway("google");
|
|
277
238
|
*/
|
|
278
|
-
async
|
|
279
|
-
if (
|
|
280
|
-
throw new types_1.ClefbaseError("
|
|
239
|
+
async signInWithGateway(provider, options) {
|
|
240
|
+
if (typeof window === "undefined") {
|
|
241
|
+
throw new types_1.ClefbaseError("signInWithGateway() requires a browser environment.", "UNSUPPORTED_ENVIRONMENT");
|
|
281
242
|
}
|
|
282
|
-
const
|
|
283
|
-
|
|
243
|
+
const redirectUrl = options?.redirectUrl ?? window.location.href;
|
|
244
|
+
const params = new URLSearchParams({ project: this.projectId, redirect: redirectUrl });
|
|
245
|
+
window.location.href = `${this.gatewayUrl}/google?${params}`;
|
|
246
|
+
return new Promise(() => { });
|
|
247
|
+
}
|
|
248
|
+
isGatewayCallbackPending() {
|
|
249
|
+
if (typeof window === "undefined")
|
|
250
|
+
return false;
|
|
251
|
+
return new URLSearchParams(window.location.search).has("cfx_token");
|
|
284
252
|
}
|
|
285
253
|
/**
|
|
286
|
-
*
|
|
287
|
-
*
|
|
254
|
+
* Call on every page load to handle the gateway redirect callback.
|
|
255
|
+
* Detects `?cfx_token=` in the URL, validates it, and returns the signed-in user.
|
|
288
256
|
*
|
|
289
257
|
* @example
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
258
|
+
* useEffect(() => {
|
|
259
|
+
* auth.handleGatewayCallback().then(result => {
|
|
260
|
+
* if (result) navigate("/dashboard");
|
|
261
|
+
* });
|
|
262
|
+
* }, []);
|
|
293
263
|
*/
|
|
294
|
-
async
|
|
264
|
+
async handleGatewayCallback() {
|
|
265
|
+
if (typeof window === "undefined")
|
|
266
|
+
return null;
|
|
267
|
+
const params = new URLSearchParams(window.location.search);
|
|
268
|
+
const token = params.get("cfx_token");
|
|
269
|
+
if (!token)
|
|
270
|
+
return null;
|
|
271
|
+
// Clean URL
|
|
272
|
+
params.delete("cfx_token");
|
|
273
|
+
params.delete("cfx_project");
|
|
274
|
+
window.history.replaceState({}, "", window.location.pathname + (params.toString() ? `?${params}` : ""));
|
|
275
|
+
// Use /auth/public/me — no API key needed, just dbId + bearer
|
|
276
|
+
const serverUrl = this.http.getBaseUrl().replace(/\/auth$/, "");
|
|
295
277
|
try {
|
|
296
|
-
const
|
|
297
|
-
|
|
278
|
+
const res = await fetch(`${serverUrl}/auth/public/me?dbId=${encodeURIComponent(this.projectId)}`, { headers: { Authorization: `Bearer ${token}` } });
|
|
279
|
+
if (!res.ok)
|
|
280
|
+
throw new Error(`${res.status} ${res.statusText}`);
|
|
281
|
+
const user = await res.json();
|
|
282
|
+
const expiresAt = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString();
|
|
283
|
+
return this.handleResult({ user, token, session: { token, expiresAt } });
|
|
298
284
|
}
|
|
299
|
-
catch {
|
|
300
|
-
|
|
285
|
+
catch (err) {
|
|
286
|
+
throw new types_1.ClefbaseError(`Gateway callback failed: ${err.message}`, "GATEWAY_CALLBACK_ERROR");
|
|
301
287
|
}
|
|
302
288
|
}
|
|
303
|
-
|
|
289
|
+
// ── Session management ────────────────────────────────────────────────────
|
|
304
290
|
async signOut() {
|
|
305
291
|
const token = this.currentToken;
|
|
306
292
|
if (token) {
|
|
@@ -311,15 +297,7 @@ class Auth {
|
|
|
311
297
|
}
|
|
312
298
|
this.store.clear();
|
|
313
299
|
this.notify(null);
|
|
314
|
-
// Tell GIS to disable auto-select so the user isn't silently re-signed in
|
|
315
|
-
if (typeof window !== "undefined" && window.google?.accounts?.id) {
|
|
316
|
-
try {
|
|
317
|
-
window.google.accounts.id.disableAutoSelect();
|
|
318
|
-
}
|
|
319
|
-
catch { /* ignore */ }
|
|
320
|
-
}
|
|
321
300
|
}
|
|
322
|
-
/** Re-fetch the current user's profile from the server and update the cache. */
|
|
323
301
|
async refreshCurrentUser() {
|
|
324
302
|
const token = this.currentToken;
|
|
325
303
|
if (!token)
|
|
@@ -336,72 +314,45 @@ class Auth {
|
|
|
336
314
|
return null;
|
|
337
315
|
}
|
|
338
316
|
}
|
|
339
|
-
/**
|
|
340
|
-
* Update the signed-in user's profile.
|
|
341
|
-
*
|
|
342
|
-
* @example
|
|
343
|
-
* await auth.updateProfile({ displayName: "Bob", metadata: { theme: "dark" } });
|
|
344
|
-
*/
|
|
345
317
|
async updateProfile(updates) {
|
|
346
318
|
const token = this.currentToken;
|
|
347
319
|
if (!token)
|
|
348
320
|
throw new Error("No user is currently signed in.");
|
|
349
|
-
const user = await this.http.patch("/me", updates, {
|
|
350
|
-
Authorization: `Bearer ${token}`,
|
|
351
|
-
});
|
|
321
|
+
const user = await this.http.patch("/me", updates, { Authorization: `Bearer ${token}` });
|
|
352
322
|
const session = this.store.load();
|
|
353
323
|
if (session)
|
|
354
324
|
this.store.save({ ...session, user });
|
|
355
325
|
this.notify(user);
|
|
356
326
|
return user;
|
|
357
327
|
}
|
|
358
|
-
/** Change password. All other sessions are invalidated server-side. */
|
|
359
328
|
async changePassword(currentPassword, newPassword) {
|
|
360
329
|
const token = this.currentToken;
|
|
361
330
|
if (!token)
|
|
362
331
|
throw new Error("No user is currently signed in.");
|
|
363
332
|
await this.http.post("/change-password", { currentPassword, newPassword }, { Authorization: `Bearer ${token}` });
|
|
364
333
|
}
|
|
365
|
-
/** Request a password-reset email. Safe to call even for unregistered addresses. */
|
|
366
334
|
async sendPasswordResetEmail(email) {
|
|
367
335
|
await this.http.post("/forgot-password", { email });
|
|
368
336
|
}
|
|
369
|
-
/** Complete a password reset with the token from the reset email. */
|
|
370
337
|
async confirmPasswordReset(resetToken, newPassword) {
|
|
371
338
|
await this.http.post("/reset-password", { token: resetToken, newPassword });
|
|
372
339
|
}
|
|
373
|
-
/** Send an email verification code to the currently signed-in user. */
|
|
374
340
|
async sendEmailVerification() {
|
|
375
341
|
const token = this.currentToken;
|
|
376
342
|
if (!token)
|
|
377
343
|
throw new Error("No user is currently signed in.");
|
|
378
344
|
await this.http.post("/send-verification", undefined, { Authorization: `Bearer ${token}` });
|
|
379
345
|
}
|
|
380
|
-
/** Verify email with the code the user received. */
|
|
381
346
|
async verifyEmail(code) {
|
|
382
347
|
return this.http.post("/verify-email", { code });
|
|
383
348
|
}
|
|
384
|
-
/**
|
|
385
|
-
* Subscribe to auth state changes.
|
|
386
|
-
* Fires immediately with the current user, then on every change.
|
|
387
|
-
* Returns an unsubscribe function.
|
|
388
|
-
*
|
|
389
|
-
* @example
|
|
390
|
-
* const unsubscribe = auth.onAuthStateChanged(user => {
|
|
391
|
-
* if (user) console.log("signed in:", user.email);
|
|
392
|
-
* else console.log("signed out");
|
|
393
|
-
* });
|
|
394
|
-
* unsubscribe();
|
|
395
|
-
*/
|
|
396
349
|
onAuthStateChanged(callback) {
|
|
397
350
|
this.listeners.push(callback);
|
|
398
351
|
try {
|
|
399
352
|
callback(this.currentUser);
|
|
400
353
|
}
|
|
401
354
|
catch { /* ignore */ }
|
|
402
|
-
return () => {
|
|
403
|
-
this.listeners = this.listeners.filter(cb => cb !== callback);
|
|
404
|
-
};
|
|
355
|
+
return () => { this.listeners = this.listeners.filter(cb => cb !== callback); };
|
|
405
356
|
}
|
|
406
357
|
}
|
|
407
358
|
exports.Auth = Auth;
|
package/dist/auth/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;AAEA,oCAAyC;AAUzC,MAAM,YAAY;IAAlB;QACU,YAAO,GAA4B,IAAI,CAAC;QAC/B,QAAG,GAAG,aAAa,CAAC;IAiCvC,CAAC;IA/BC,IAAY,EAAE;QACZ,IAAI,CAAC;YAAC,OAAO,OAAO,YA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GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC;CACF;AAnWD,oBAmWC"}
|
|
@@ -764,7 +764,18 @@ function buildLibTs(cfg) {
|
|
|
764
764
|
` *`,
|
|
765
765
|
` * Usage:`,
|
|
766
766
|
...(database ? [` * import { db } from "@lib/clefBase";`] : []),
|
|
767
|
-
...(auth ? [
|
|
767
|
+
...(auth ? [
|
|
768
|
+
` * import { auth } from "@lib/clefBase";`,
|
|
769
|
+
` *`,
|
|
770
|
+
` * // Email / password`,
|
|
771
|
+
` * const { user } = await auth.signIn("alice@example.com", "pass");`,
|
|
772
|
+
` *`,
|
|
773
|
+
` * // Google sign-in — add this to your root component / entry point:`,
|
|
774
|
+
` * await auth.handleGatewayCallback(); // handles ?cfx_token= on return`,
|
|
775
|
+
` *`,
|
|
776
|
+
` * // On sign-in button click:`,
|
|
777
|
+
` * await auth.signInWithGateway("google");`,
|
|
778
|
+
] : []),
|
|
768
779
|
...(storage ? [` * import { storage } from "@lib/clefBase";`] : []),
|
|
769
780
|
...(fns ? [
|
|
770
781
|
` * import { fns, httpsCallable } from "@lib/clefBase";`,
|
|
@@ -804,6 +815,20 @@ function buildLibTs(cfg) {
|
|
|
804
815
|
lines.push(`/** Clefbase Auth — sign up, sign in, manage sessions. */`);
|
|
805
816
|
lines.push(`export const auth: Auth = getAuth(app);`);
|
|
806
817
|
lines.push("");
|
|
818
|
+
lines.push(`/**`);
|
|
819
|
+
lines.push(` * Call this once on every page load (before rendering your UI).`);
|
|
820
|
+
lines.push(` * Detects the ?cfx_token= param the gateway appends after OAuth,`);
|
|
821
|
+
lines.push(` * saves the session, and cleans the URL.`);
|
|
822
|
+
lines.push(` *`);
|
|
823
|
+
lines.push(` * @example`);
|
|
824
|
+
lines.push(` * // React / Next.js — in your root layout or _app.tsx:`);
|
|
825
|
+
lines.push(` * useEffect(() => { auth.handleGatewayCallback(); }, []);`);
|
|
826
|
+
lines.push(` *`);
|
|
827
|
+
lines.push(` * // Vanilla JS — at the top of your entry point:`);
|
|
828
|
+
lines.push(` * await auth.handleGatewayCallback();`);
|
|
829
|
+
lines.push(` */`);
|
|
830
|
+
lines.push(`export { auth };`);
|
|
831
|
+
lines.push("");
|
|
807
832
|
}
|
|
808
833
|
if (storage) {
|
|
809
834
|
lines.push(`/** Clefbase Storage — upload and manage files. */`);
|
|
@@ -941,6 +966,8 @@ function printUsageHint(cfg) {
|
|
|
941
966
|
if (cfg.services.auth) {
|
|
942
967
|
console.log();
|
|
943
968
|
console.log(chalk_1.default.cyan(` const { user } = await auth.signIn("email", "pass");`));
|
|
969
|
+
console.log(chalk_1.default.cyan(` await auth.signInWithGateway("google"); // redirects to auth.cleforyx.com`));
|
|
970
|
+
console.log(chalk_1.default.cyan(` await auth.handleGatewayCallback(); // call on every page load`));
|
|
944
971
|
}
|
|
945
972
|
if (cfg.services.storage) {
|
|
946
973
|
console.log();
|