clefbase 2.0.1 → 2.0.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/app.d.ts CHANGED
@@ -44,10 +44,10 @@ export declare class ClefbaseApp {
44
44
  *
45
45
  * @example
46
46
  * const app = initClefbase({
47
- * serverUrl: "https://api.cleforyx.com",
48
- * projectId: "my_project_abc",
49
- * apiKey: "cfx_...",
50
- * adminSecret: "", // only needed for hosting
47
+ * serverUrl: "https://api.cleforyx.com",
48
+ * projectId: "swoove-md3",
49
+ * apiKey: "cfx_...",
50
+ * // gatewayUrl defaults to "https://auth.cleforyx.com"
51
51
  * });
52
52
  */
53
53
  export declare function initClefbase(config: ClefbaseConfig, name?: string): ClefbaseApp;
@@ -67,7 +67,7 @@ export declare function getHosting(app?: ClefbaseApp): ClefbaseHosting;
67
67
  * @example
68
68
  * import { initClefbase, getFunctions, httpsCallable } from "clefbase";
69
69
  *
70
- * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
70
+ * const app = initClefbase({ serverUrl, projectId, apiKey });
71
71
  * const fns = getFunctions(app);
72
72
  *
73
73
  * const greet = httpsCallable<{ name: string }, { message: string }>(fns, "greetUser");
@@ -80,33 +80,13 @@ export declare function getFunctions(app?: ClefbaseApp): ClefbaseFunctions;
80
80
  * @example
81
81
  * import { initClefbase, getAI } from "clefbase";
82
82
  *
83
- * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
83
+ * const app = initClefbase({ serverUrl, projectId, apiKey });
84
84
  * const ai = getAI(app);
85
85
  *
86
- * // Text generation
87
86
  * const { content } = await ai.text({
88
87
  * model: "claude-sonnet-4-5",
89
88
  * prompt: "Explain closures in JavaScript",
90
89
  * });
91
- *
92
- * // Image generation — saved to project Storage automatically
93
- * const { files } = await ai.image({
94
- * model: "imagen-3.0-generate-002",
95
- * prompt: "A futuristic cityscape at sunset",
96
- * });
97
- *
98
- * // Video generation
99
- * const { status, files: videoFiles } = await ai.video({
100
- * model: "veo-2.0-generate-001",
101
- * prompt: "A dog running on a beach",
102
- * durationSeconds: 5,
103
- * });
104
- *
105
- * // Embeddings
106
- * const { embeddings } = await ai.embedding({
107
- * model: "text-embedding-004",
108
- * input: ["Hello", "World"],
109
- * });
110
90
  */
111
91
  export declare function getAI(app?: ClefbaseApp): ClefbaseAI;
112
92
  //# sourceMappingURL=app.d.ts.map
package/dist/app.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C;;;GAGG;AACH,qBAAa,WAAW;IACtB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAEhC,gBAAgB,CAAC,QAAQ,CAAC,OAAO,EAAS,UAAU,CAAC;IACrD,gBAAgB,CAAC,QAAQ,CAAC,SAAS,EAAO,UAAU,CAAC;IACrD,gBAAgB,CAAC,QAAQ,CAAC,YAAY,EAAI,UAAU,CAAC;IACrD,gBAAgB,CAAC,QAAQ,CAAC,YAAY,EAAI,UAAU,CAAC;IACrD,gBAAgB,CAAC,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC;IACrD,gBAAgB,CAAC,QAAQ,CAAC,OAAO,EAAS,UAAU,CAAC;IAErD,OAAO,CAAC,GAAG,CAAuC;IAClD,OAAO,CAAC,KA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;IAMlC,gBAAgB;IAChB,MAAM,IAAI,UAAU;CAKrB;AAOD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,cAAc,EACtB,IAAI,GAAE,MAAgB,GACrB,WAAW,CAKb;AAED,wEAAwE;AACxE,wBAAgB,MAAM,CAAC,IAAI,GAAE,MAAgB,GAAG,WAAW,CAQ1D;AAID,gCAAgC;AAChC,wBAAgB,WAAW,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,QAAQ,CAEvD;AAED,4BAA4B;AAC5B,wBAAgB,OAAO,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,IAAI,CAE/C;AAED,+BAA+B;AAC/B,wBAAgB,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,eAAe,CAE7D;AAED,iEAAiE;AACjE,wBAAgB,UAAU,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,eAAe,CAE7D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,iBAAiB,CAEjE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,KAAK,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,UAAU,CAEnD"}
package/dist/app.js CHANGED
@@ -17,6 +17,7 @@ const hosting_1 = require("./hosting");
17
17
  const functions_1 = require("./functions");
18
18
  const ai_1 = require("./ai");
19
19
  // ─── App ──────────────────────────────────────────────────────────────────────
20
+ const DEFAULT_GATEWAY_URL = "https://auth.cleforyx.com";
20
21
  /**
21
22
  * A Clefbase application instance.
22
23
  * Created by `initClefbase()` — pass it to `getDatabase()`, `getAuth()`, etc.
@@ -41,8 +42,9 @@ class ClefbaseApp {
41
42
  }
42
43
  /** @internal */
43
44
  _getAuth() {
44
- if (!this._auth)
45
- this._auth = new auth_1.Auth(this._authHttp);
45
+ if (!this._auth) {
46
+ this._auth = new auth_1.Auth(this._authHttp, DEFAULT_GATEWAY_URL, this.config.projectId);
47
+ }
46
48
  return this._auth;
47
49
  }
48
50
  /** @internal */
@@ -80,10 +82,10 @@ const registry = new Map();
80
82
  *
81
83
  * @example
82
84
  * const app = initClefbase({
83
- * serverUrl: "https://api.cleforyx.com",
84
- * projectId: "my_project_abc",
85
- * apiKey: "cfx_...",
86
- * adminSecret: "", // only needed for hosting
85
+ * serverUrl: "https://api.cleforyx.com",
86
+ * projectId: "swoove-md3",
87
+ * apiKey: "cfx_...",
88
+ * // gatewayUrl defaults to "https://auth.cleforyx.com"
87
89
  * });
88
90
  */
89
91
  function initClefbase(config, name = DEFAULT) {
@@ -124,7 +126,7 @@ function getHosting(app) {
124
126
  * @example
125
127
  * import { initClefbase, getFunctions, httpsCallable } from "clefbase";
126
128
  *
127
- * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
129
+ * const app = initClefbase({ serverUrl, projectId, apiKey });
128
130
  * const fns = getFunctions(app);
129
131
  *
130
132
  * const greet = httpsCallable<{ name: string }, { message: string }>(fns, "greetUser");
@@ -139,33 +141,13 @@ function getFunctions(app) {
139
141
  * @example
140
142
  * import { initClefbase, getAI } from "clefbase";
141
143
  *
142
- * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
144
+ * const app = initClefbase({ serverUrl, projectId, apiKey });
143
145
  * const ai = getAI(app);
144
146
  *
145
- * // Text generation
146
147
  * const { content } = await ai.text({
147
148
  * model: "claude-sonnet-4-5",
148
149
  * prompt: "Explain closures in JavaScript",
149
150
  * });
150
- *
151
- * // Image generation — saved to project Storage automatically
152
- * const { files } = await ai.image({
153
- * model: "imagen-3.0-generate-002",
154
- * prompt: "A futuristic cityscape at sunset",
155
- * });
156
- *
157
- * // Video generation
158
- * const { status, files: videoFiles } = await ai.video({
159
- * model: "veo-2.0-generate-001",
160
- * prompt: "A dog running on a beach",
161
- * durationSeconds: 5,
162
- * });
163
- *
164
- * // Embeddings
165
- * const { embeddings } = await ai.embedding({
166
- * model: "text-embedding-004",
167
- * input: ["Hello", "World"],
168
- * });
169
151
  */
170
152
  function getAI(app) {
171
153
  return (app ?? getApp())._getAI();
package/dist/app.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;AA2GA,oCAQC;AAGD,wBAQC;AAKD,kCAEC;AAGD,0BAEC;AAGD,gCAEC;AAGD,gCAEC;AAcD,oCAEC;AAoCD,sBAEC;AA1MD,iCAAoC;AACpC,6BAAgC;AAChC,iCAA8B;AAC9B,uCAA4C;AAC5C,uCAA4C;AAC5C,2CAAgD;AAChD,6BAAkC;AAGlC,iFAAiF;AAEjF;;;GAGG;AACH,MAAa,WAAW;IAiBtB,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,MAAM,IAAI,GAAK,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACpD,MAAM,MAAM,GAAG,EAAE,WAAW,EAAO,MAAM,CAAC,MAAM,EAAE,CAAC;QAEnD,IAAI,CAAC,OAAO,GAAU,IAAI,iBAAU,CAAC,GAAG,IAAI,KAAK,EAAW,MAAM,CAAC,CAAC;QACpE,IAAI,CAAC,SAAS,GAAQ,IAAI,iBAAU,CAAC,GAAG,IAAI,OAAO,EAAS,MAAM,CAAC,CAAC;QACpE,IAAI,CAAC,YAAY,GAAK,IAAI,iBAAU,CAAC,GAAG,IAAI,UAAU,EAAM,MAAM,CAAC,CAAC;QACpE,IAAI,CAAC,YAAY,GAAK,IAAI,iBAAU,CAAC,GAAG,IAAI,UAAU,EAAM,MAAM,CAAC,CAAC;QACpE,IAAI,CAAC,cAAc,GAAG,IAAI,iBAAU,CAAC,GAAG,IAAI,YAAY,EAAI,MAAM,CAAC,CAAC;QACpE,IAAI,CAAC,OAAO,GAAU,IAAI,iBAAU,CAAC,GAAG,IAAI,KAAK,EAAW,MAAM,CAAC,CAAC;IACtE,CAAC;IAED,gBAAgB;IAChB,MAAM;QACJ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AAQ,EAAE,CAAC;AACtC,CAAC;AAED,+BAA+B;AAC/B,SAAgB,UAAU,CAAC,GAAiB;IAC1C,OAAO,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACzC,CAAC;AAED,iEAAiE;AACjE,SAAgB,UAAU,CAAC,GAAiB;IAC1C,OAAO,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AACzC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,YAAY,CAAC,GAAiB;IAC5C,OAAO,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC,aAAa,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,KAAK,CAAC,GAAiB;IACrC,OAAO,CAAC,GAAG,IAAI,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC;AACpC,CAAC"}
@@ -1,59 +1,15 @@
1
1
  import { HttpClient } from "../http";
2
2
  import type { AuthUser, AuthResult } from "../types";
3
- interface GisNotification {
4
- isNotDisplayed(): boolean;
5
- isSkippedMoment(): boolean;
6
- isDismissedMoment(): boolean;
7
- getNotDisplayedReason(): string;
8
- getSkippedReason(): string;
9
- getDismissedReason(): string;
10
- }
11
- interface GoogleAccountsId {
12
- initialize(config: {
13
- client_id: string;
14
- callback: (response: {
15
- credential: string;
16
- }) => void;
17
- auto_select?: boolean;
18
- cancel_on_tap_outside?: boolean;
19
- }): void;
20
- prompt(momentListener?: (n: GisNotification) => void): void;
21
- renderButton(parent: HTMLElement, options: {
22
- type?: "standard" | "icon";
23
- theme?: "outline" | "filled_blue" | "filled_black";
24
- size?: "large" | "medium" | "small";
25
- text?: "signin_with" | "signup_with" | "continue_with" | "signin";
26
- shape?: "rectangular" | "pill" | "circle" | "square";
27
- logo_alignment?: "left" | "center";
28
- width?: number;
29
- locale?: string;
30
- }): void;
31
- disableAutoSelect(): void;
32
- revoke(hint: string, done: () => void): void;
33
- }
34
- declare global {
35
- interface Window {
36
- google?: {
37
- accounts: {
38
- id: GoogleAccountsId;
39
- };
40
- };
41
- }
42
- }
43
3
  /**
44
- * Options for rendering a Google-branded sign-in button.
45
- * Pass to `auth.signInWithGoogle()` to show a button instead of One Tap.
4
+ * Options for `auth.signInWithGateway()`.
46
5
  */
47
- export interface GoogleButtonOptions {
48
- /** The DOM element to render the button into. */
49
- container: HTMLElement;
50
- theme?: "outline" | "filled_blue" | "filled_black";
51
- size?: "large" | "medium" | "small";
52
- text?: "signin_with" | "signup_with" | "continue_with" | "signin";
53
- shape?: "rectangular" | "pill";
54
- /** Pixel width of the button (min 200, max 400). */
55
- width?: number;
56
- locale?: string;
6
+ export interface GatewaySignInOptions {
7
+ /**
8
+ * The URL the gateway should redirect back to after authentication.
9
+ * Defaults to `window.location.origin` (your app's root).
10
+ * Must be registered as an allowed redirect for your project in the gateway.
11
+ */
12
+ redirectUrl?: string;
57
13
  }
58
14
  type AuthStateCallback = (user: AuthUser | null) => void;
59
15
  /**
@@ -61,20 +17,28 @@ type AuthStateCallback = (user: AuthUser | null) => void;
61
17
  *
62
18
  * @example
63
19
  * const auth = getAuth(app);
20
+ *
21
+ * // Email / password
64
22
  * const { user } = await auth.signIn("alice@example.com", "pass");
65
- * const unsub = auth.onAuthStateChanged(u => console.log(u));
66
- * unsub();
23
+ *
24
+ * // Google — redirect to gateway, come back signed in
25
+ * await auth.signInWithGateway("google");
26
+ *
27
+ * // On every page load, handle the gateway callback:
28
+ * const result = await auth.handleGatewayCallback();
29
+ * if (result) console.log("Signed in via gateway:", result.user.email);
67
30
  */
68
31
  export declare class Auth {
69
32
  private readonly http;
70
33
  private readonly store;
71
34
  private listeners;
72
- /** Cached Google Client ID. `null` = confirmed not configured. `undefined` = not yet fetched. */
73
- private _googleClientId;
74
- constructor(http: HttpClient);
35
+ /** The base URL of the Cleforyx auth gateway (e.g. https://auth.cleforyx.com) */
36
+ private readonly gatewayUrl;
37
+ /** The project ID — used as the `?project=` param when redirecting to the gateway */
38
+ private readonly projectId;
39
+ constructor(http: HttpClient, gatewayUrl: string, projectId: string);
75
40
  private notify;
76
41
  private handleResult;
77
- private resolveGoogleClientId;
78
42
  /** @internal — used by Storage to attach the bearer token to upload requests */
79
43
  getAuthHeaders(): Record<string, string>;
80
44
  /** The currently signed-in user, or null. */
@@ -82,7 +46,7 @@ export declare class Auth {
82
46
  /** The raw bearer token for the active session, or null. */
83
47
  get currentToken(): string | null;
84
48
  /**
85
- * Create a new account.
49
+ * Create a new account with email + password.
86
50
  *
87
51
  * @example
88
52
  * const { user } = await auth.signUp("alice@example.com", "pass123", {
@@ -103,75 +67,60 @@ export declare class Auth {
103
67
  */
104
68
  signIn(email: string, password: string): Promise<AuthResult>;
105
69
  /**
106
- * Sign in with Google using the Google Identity Services popup or One Tap.
107
- *
108
- * Browser-only. The GIS script (`accounts.google.com/gsi/client`) is loaded
109
- * automatically — no manual `<script>` tag needed.
70
+ * Redirect the user to the Cleforyx auth gateway to sign in with an
71
+ * OAuth provider (currently `"google"`).
110
72
  *
111
- * Without `buttonOptions`, the Google One Tap prompt is shown.
112
- * Pass `{ container }` to render a fully styled Google button instead —
113
- * which is more reliable since One Tap can be suppressed by the browser.
73
+ * The gateway handles the OAuth flow and redirects back to your app with
74
+ * `?cfx_token=<token>&cfx_project=<projectId>` in the URL.
75
+ * Call `auth.handleGatewayCallback()` on page load to complete sign-in.
114
76
  *
115
- * Automatically handles new sign-ups: if the Google account has never been
116
- * seen before, a new user record is created server-side.
117
- *
118
- * @throws `ClefbaseError` with code `GOOGLE_NOT_CONFIGURED` if no Client ID
119
- * has been set in the project's auth settings.
120
- * @throws `ClefbaseError` with code `GOOGLE_PROMPT_SUPPRESSED` if One Tap
121
- * could not be displayed (switch to button mode in that case).
122
- * @throws `ClefbaseError` with code `GOOGLE_SIGN_IN_CANCELLED` if the user
123
- * dismissed the popup.
77
+ * **This method never returns** it calls `window.location.href`.
124
78
  *
125
79
  * @example
126
- * // One Tap prompt
127
- * const { user } = await auth.signInWithGoogle();
80
+ * // On button click:
81
+ * await auth.signInWithGateway("google");
128
82
  *
129
- * // Branded Google button
130
- * const { user } = await auth.signInWithGoogle({
131
- * container: document.getElementById("google-btn")!,
132
- * theme: "filled_blue",
133
- * size: "large",
134
- * text: "continue_with",
83
+ * // With a custom return URL:
84
+ * await auth.signInWithGateway("google", {
85
+ * redirectUrl: "https://myapp.cleforyx.com/dashboard",
135
86
  * });
136
- *
137
- * // React example
138
- * const btnRef = useRef<HTMLDivElement>(null);
139
- * await auth.signInWithGoogle({ container: btnRef.current! });
140
87
  */
141
- signInWithGoogle(buttonOptions?: GoogleButtonOptions): Promise<AuthResult>;
88
+ signInWithGateway(provider: "google", options?: GatewaySignInOptions): Promise<never>;
142
89
  /**
143
- * Sign in with Google using a raw ID token string.
144
- *
145
- * Use this when you already have a `credential` from Google's callback —
146
- * for example with a custom button implementation, React Native Google
147
- * Sign-In, or any other flow that gives you an ID token directly.
148
- *
149
- * Works in both browser and Node.js environments.
90
+ * Check if the current URL contains a gateway callback (`?cfx_token=`).
91
+ * Useful for rendering a "Finishing sign-in…" loading state before calling
92
+ * `handleGatewayCallback()`.
150
93
  *
151
94
  * @example
152
- * // Inside a GIS callback
153
- * google.accounts.id.initialize({
154
- * client_id: "...",
155
- * callback: async ({ credential }) => {
156
- * const { user } = await auth.signInWithGoogleToken(credential);
157
- * },
158
- * });
159
- *
160
- * // React Native
161
- * const { idToken } = await GoogleSignin.signIn();
162
- * const { user } = await auth.signInWithGoogleToken(idToken);
95
+ * if (auth.isGatewayCallbackPending()) {
96
+ * showLoadingSpinner();
97
+ * }
163
98
  */
164
- signInWithGoogleToken(idToken: string): Promise<AuthResult>;
99
+ isGatewayCallbackPending(): boolean;
165
100
  /**
166
- * Returns `true` if Google Sign-In is configured for this project.
167
- * Useful for conditionally rendering a "Sign in with Google" button.
101
+ * Call this on every page load (ideally before rendering your app).
102
+ * If the URL contains `?cfx_token=`, the token is validated against
103
+ * the server, the session is saved, and the signed-in `AuthResult` is
104
+ * returned. The query params are cleaned from the URL automatically.
105
+ *
106
+ * Returns `null` if there is no pending callback.
168
107
  *
169
108
  * @example
170
- * if (await auth.isGoogleSignInEnabled()) {
171
- * showGoogleButton();
172
- * }
109
+ * // In your app's root component or entry point:
110
+ * useEffect(() => {
111
+ * auth.handleGatewayCallback().then(result => {
112
+ * if (result) {
113
+ * console.log("Signed in:", result.user.email);
114
+ * navigate("/dashboard");
115
+ * }
116
+ * });
117
+ * }, []);
118
+ *
119
+ * // Or outside React:
120
+ * const result = await auth.handleGatewayCallback();
121
+ * if (result) showDashboard(result.user);
173
122
  */
174
- isGoogleSignInEnabled(): Promise<boolean>;
123
+ handleGatewayCallback(): Promise<AuthResult | null>;
175
124
  /** Sign out and clear the local session. */
176
125
  signOut(): Promise<void>;
177
126
  /** Re-fetch the current user's profile from the server and update the cache. */
@@ -199,7 +148,7 @@ export declare class Auth {
199
148
  verifyEmail(code: string): Promise<AuthUser>;
200
149
  /**
201
150
  * Subscribe to auth state changes.
202
- * Fires immediately with the current user, then on every change.
151
+ * Fires immediately with the current user, then on every sign-in or sign-out.
203
152
  * Returns an unsubscribe function.
204
153
  *
205
154
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAmDrD,UAAU,eAAe;IACvB,cAAc,IAAI,OAAO,CAAC;IAC1B,eAAe,IAAI,OAAO,CAAC;IAC3B,iBAAiB,IAAI,OAAO,CAAC;IAC7B,qBAAqB,IAAI,MAAM,CAAC;IAChC,gBAAgB,IAAI,MAAM,CAAC;IAC3B,kBAAkB,IAAI,MAAM,CAAC;CAC9B;AAED,UAAU,gBAAgB;IACxB,UAAU,CAAC,MAAM,EAAE;QACjB,SAAS,EAA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AC,QAAQ,EAAE,iBAAiB,GAAG,MAAM,IAAI;CAO5D"}
@@ -47,60 +47,29 @@ 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
50
  /**
89
51
  * Authentication service. Obtain via `getAuth(app)`.
90
52
  *
91
53
  * @example
92
54
  * const auth = getAuth(app);
55
+ *
56
+ * // Email / password
93
57
  * const { user } = await auth.signIn("alice@example.com", "pass");
94
- * const unsub = auth.onAuthStateChanged(u => console.log(u));
95
- * unsub();
58
+ *
59
+ * // Google — redirect to gateway, come back signed in
60
+ * await auth.signInWithGateway("google");
61
+ *
62
+ * // On every page load, handle the gateway callback:
63
+ * const result = await auth.handleGatewayCallback();
64
+ * if (result) console.log("Signed in via gateway:", result.user.email);
96
65
  */
97
66
  class Auth {
98
- constructor(http) {
67
+ constructor(http, gatewayUrl, projectId) {
99
68
  this.http = http;
100
69
  this.store = new SessionStore();
101
70
  this.listeners = [];
102
- /** Cached Google Client ID. `null` = confirmed not configured. `undefined` = not yet fetched. */
103
- this._googleClientId = undefined;
71
+ this.gatewayUrl = gatewayUrl.replace(/\/+$/, "");
72
+ this.projectId = projectId;
104
73
  this.store.load();
105
74
  }
106
75
  // ── Internals ─────────────────────────────────────────────────────────────
@@ -121,23 +90,6 @@ class Auth {
121
90
  this.notify(result.user);
122
91
  return result;
123
92
  }
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
93
  /** @internal — used by Storage to attach the bearer token to upload requests */
142
94
  getAuthHeaders() {
143
95
  const s = this.store.load();
@@ -148,8 +100,9 @@ class Auth {
148
100
  get currentUser() { return this.store.load()?.user ?? null; }
149
101
  /** The raw bearer token for the active session, or null. */
150
102
  get currentToken() { return this.store.load()?.token ?? null; }
103
+ // ── Email / password ──────────────────────────────────────────────────────
151
104
  /**
152
- * Create a new account.
105
+ * Create a new account with email + password.
153
106
  *
154
107
  * @example
155
108
  * const { user } = await auth.signUp("alice@example.com", "pass123", {
@@ -158,9 +111,7 @@ class Auth {
158
111
  * });
159
112
  */
160
113
  async signUp(email, password, profile) {
161
- const result = await this.http.post("/signup", {
162
- email, password, ...profile,
163
- });
114
+ const result = await this.http.post("/signup", { email, password, ...profile });
164
115
  return this.handleResult(result);
165
116
  }
166
117
  /**
@@ -173,133 +124,110 @@ class Auth {
173
124
  const result = await this.http.post("/signin", { email, password });
174
125
  return this.handleResult(result);
175
126
  }
127
+ // ── Gateway OAuth (redirect flow) ─────────────────────────────────────────
176
128
  /**
177
- * Sign in with Google using the Google Identity Services popup or One Tap.
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.
129
+ * Redirect the user to the Cleforyx auth gateway to sign in with an
130
+ * OAuth provider (currently `"google"`).
185
131
  *
186
- * Automatically handles new sign-ups: if the Google account has never been
187
- * seen before, a new user record is created server-side.
132
+ * The gateway handles the OAuth flow and redirects back to your app with
133
+ * `?cfx_token=<token>&cfx_project=<projectId>` in the URL.
134
+ * Call `auth.handleGatewayCallback()` on page load to complete sign-in.
188
135
  *
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.
136
+ * **This method never returns** it calls `window.location.href`.
195
137
  *
196
138
  * @example
197
- * // One Tap prompt
198
- * const { user } = await auth.signInWithGoogle();
139
+ * // On button click:
140
+ * await auth.signInWithGateway("google");
199
141
  *
200
- * // Branded Google button
201
- * const { user } = await auth.signInWithGoogle({
202
- * container: document.getElementById("google-btn")!,
203
- * theme: "filled_blue",
204
- * size: "large",
205
- * text: "continue_with",
142
+ * // With a custom return URL:
143
+ * await auth.signInWithGateway("google", {
144
+ * redirectUrl: "https://myapp.cleforyx.com/dashboard",
206
145
  * });
207
- *
208
- * // React example
209
- * const btnRef = useRef<HTMLDivElement>(null);
210
- * await auth.signInWithGoogle({ container: btnRef.current! });
211
146
  */
212
- async signInWithGoogle(buttonOptions) {
213
- const clientId = await this.resolveGoogleClientId();
214
- await loadGisScript();
215
- const gis = window.google.accounts.id;
216
- return new Promise((resolve, reject) => {
217
- gis.initialize({
218
- client_id: clientId,
219
- auto_select: false,
220
- cancel_on_tap_outside: true,
221
- callback: async ({ credential }) => {
222
- try {
223
- resolve(await this.signInWithGoogleToken(credential));
224
- }
225
- catch (err) {
226
- reject(err);
227
- }
228
- },
229
- });
230
- if (buttonOptions?.container) {
231
- const { container, theme, size, text, shape, width, locale } = buttonOptions;
232
- gis.renderButton(container, {
233
- type: "standard",
234
- theme: theme ?? "outline",
235
- size: size ?? "large",
236
- text: text ?? "signin_with",
237
- shape: shape ?? "rectangular",
238
- logo_alignment: "left",
239
- width,
240
- locale,
241
- });
242
- }
243
- else {
244
- gis.prompt((n) => {
245
- if (n.isNotDisplayed()) {
246
- reject(new types_1.ClefbaseError(`Google One Tap could not be displayed (${n.getNotDisplayedReason()}). ` +
247
- "Pass a { container } element to render a sign-in button instead.", "GOOGLE_PROMPT_SUPPRESSED"));
248
- }
249
- else if (n.isSkippedMoment() || n.isDismissedMoment()) {
250
- reject(new types_1.ClefbaseError("Google Sign-In was cancelled by the user.", "GOOGLE_SIGN_IN_CANCELLED"));
251
- }
252
- });
253
- }
147
+ async signInWithGateway(provider, options) {
148
+ if (typeof window === "undefined") {
149
+ throw new types_1.ClefbaseError("signInWithGateway() requires a browser environment.", "UNSUPPORTED_ENVIRONMENT");
150
+ }
151
+ const redirectUrl = options?.redirectUrl ?? window.location.origin;
152
+ const params = new URLSearchParams({
153
+ project: this.projectId,
154
+ redirect: redirectUrl,
254
155
  });
156
+ window.location.href = `${this.gatewayUrl}/${provider}?${params.toString()}`;
157
+ // This line is unreachable but TypeScript needs it for `never` return type
158
+ return new Promise(() => { });
255
159
  }
256
160
  /**
257
- * Sign in with Google using a raw ID token string.
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.
161
+ * Check if the current URL contains a gateway callback (`?cfx_token=`).
162
+ * Useful for rendering a "Finishing sign-in…" loading state before calling
163
+ * `handleGatewayCallback()`.
264
164
  *
265
165
  * @example
266
- * // Inside a GIS callback
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);
166
+ * if (auth.isGatewayCallbackPending()) {
167
+ * showLoadingSpinner();
168
+ * }
277
169
  */
278
- async signInWithGoogleToken(idToken) {
279
- if (!idToken || typeof idToken !== "string") {
280
- throw new types_1.ClefbaseError("idToken must be a non-empty string.", "INVALID_ARGUMENT");
281
- }
282
- const result = await this.http.post("/google", { idToken });
283
- return this.handleResult(result);
170
+ isGatewayCallbackPending() {
171
+ if (typeof window === "undefined")
172
+ return false;
173
+ return new URLSearchParams(window.location.search).has("cfx_token");
284
174
  }
285
175
  /**
286
- * Returns `true` if Google Sign-In is configured for this project.
287
- * Useful for conditionally rendering a "Sign in with Google" button.
176
+ * Call this on every page load (ideally before rendering your app).
177
+ * If the URL contains `?cfx_token=`, the token is validated against
178
+ * the server, the session is saved, and the signed-in `AuthResult` is
179
+ * returned. The query params are cleaned from the URL automatically.
180
+ *
181
+ * Returns `null` if there is no pending callback.
288
182
  *
289
183
  * @example
290
- * if (await auth.isGoogleSignInEnabled()) {
291
- * showGoogleButton();
292
- * }
184
+ * // In your app's root component or entry point:
185
+ * useEffect(() => {
186
+ * auth.handleGatewayCallback().then(result => {
187
+ * if (result) {
188
+ * console.log("Signed in:", result.user.email);
189
+ * navigate("/dashboard");
190
+ * }
191
+ * });
192
+ * }, []);
193
+ *
194
+ * // Or outside React:
195
+ * const result = await auth.handleGatewayCallback();
196
+ * if (result) showDashboard(result.user);
293
197
  */
294
- async isGoogleSignInEnabled() {
198
+ async handleGatewayCallback() {
199
+ if (typeof window === "undefined")
200
+ return null;
201
+ const params = new URLSearchParams(window.location.search);
202
+ const token = params.get("cfx_token");
203
+ if (!token)
204
+ return null;
205
+ // Clean the token + project params from the URL immediately so they
206
+ // aren't reprocessed on refresh or shared in links
207
+ params.delete("cfx_token");
208
+ params.delete("cfx_project");
209
+ const cleanSearch = params.toString();
210
+ const cleanUrl = window.location.pathname + (cleanSearch ? `?${cleanSearch}` : "");
211
+ window.history.replaceState({}, "", cleanUrl);
212
+ // Validate the token against the server and fetch the full user object
295
213
  try {
296
- const cfg = await this.http.get("/google/config");
297
- return cfg.enabled && Boolean(cfg.clientId);
214
+ const user = await this.http.get("/me", { Authorization: `Bearer ${token}` });
215
+ // We don't have an expiresAt from the URL — fetch it from /me is enough
216
+ // for the session; use a generous 30-day default matching server config
217
+ const expiresAt = new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString();
218
+ const result = {
219
+ user,
220
+ token,
221
+ session: { token, expiresAt },
222
+ };
223
+ return this.handleResult(result);
298
224
  }
299
- catch {
300
- return false;
225
+ catch (err) {
226
+ // Token was invalid or expired — don't sign in
227
+ throw new types_1.ClefbaseError(`Gateway callback failed: ${err.message}`, "GATEWAY_CALLBACK_ERROR");
301
228
  }
302
229
  }
230
+ // ── Session management ────────────────────────────────────────────────────
303
231
  /** Sign out and clear the local session. */
304
232
  async signOut() {
305
233
  const token = this.currentToken;
@@ -311,13 +239,6 @@ class Auth {
311
239
  }
312
240
  this.store.clear();
313
241
  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
242
  }
322
243
  /** Re-fetch the current user's profile from the server and update the cache. */
323
244
  async refreshCurrentUser() {
@@ -383,7 +304,7 @@ class Auth {
383
304
  }
384
305
  /**
385
306
  * Subscribe to auth state changes.
386
- * Fires immediately with the current user, then on every change.
307
+ * Fires immediately with the current user, then on every sign-in or sign-out.
387
308
  * Returns an unsubscribe function.
388
309
  *
389
310
  * @example
@@ -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,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;QAAC,CAAC;QACzE,MAAM,CAAC;YAAC,OAAO,IAAI,CAAC;QAAC,CAAC;IACxB,CAAC;IAED,IAAI,CAAC,CAAmB;QACtB,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC;QACjB,IAAI,CAAC;YAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAAC,CAAC;QACtD,MAAM,CAAC,CAAC,0BAA0B,CAAC,CAAC;IACtC,CAAC;IAED,IAAI;QACF,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtC,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACvC,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,MAAM,GAAG,IAAI,CAAC,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(cfg) {
764
764
  ` *`,
765
765
  ` * Usage:`,
766
766
  ...(database ? [` * import { db } from "@lib/clefBase";`] : []),
767
- ...(auth ? [` * import { auth } from "@lib/clefBase";`] : []),
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();
package/dist/cli.js CHANGED
@@ -34575,7 +34575,18 @@ function buildLibTs(cfg) {
34575
34575
  ` *`,
34576
34576
  ` * Usage:`,
34577
34577
  ...database ? [` * import { db } from "@lib/clefBase";`] : [],
34578
- ...auth ? [` * import { auth } from "@lib/clefBase";`] : [],
34578
+ ...auth ? [
34579
+ ` * import { auth } from "@lib/clefBase";`,
34580
+ ` *`,
34581
+ ` * // Email / password`,
34582
+ ` * const { user } = await auth.signIn("alice@example.com", "pass");`,
34583
+ ` *`,
34584
+ ` * // Google sign-in \u2014 add this to your root component / entry point:`,
34585
+ ` * await auth.handleGatewayCallback(); // handles ?cfx_token= on return`,
34586
+ ` *`,
34587
+ ` * // On sign-in button click:`,
34588
+ ` * await auth.signInWithGateway("google");`
34589
+ ] : [],
34579
34590
  ...storage ? [` * import { storage } from "@lib/clefBase";`] : [],
34580
34591
  ...fns ? [
34581
34592
  ` * import { fns, httpsCallable } from "@lib/clefBase";`,
@@ -34612,6 +34623,20 @@ function buildLibTs(cfg) {
34612
34623
  lines.push(`/** Clefbase Auth \u2014 sign up, sign in, manage sessions. */`);
34613
34624
  lines.push(`export const auth: Auth = getAuth(app);`);
34614
34625
  lines.push("");
34626
+ lines.push(`/**`);
34627
+ lines.push(` * Call this once on every page load (before rendering your UI).`);
34628
+ lines.push(` * Detects the ?cfx_token= param the gateway appends after OAuth,`);
34629
+ lines.push(` * saves the session, and cleans the URL.`);
34630
+ lines.push(` *`);
34631
+ lines.push(` * @example`);
34632
+ lines.push(` * // React / Next.js \u2014 in your root layout or _app.tsx:`);
34633
+ lines.push(` * useEffect(() => { auth.handleGatewayCallback(); }, []);`);
34634
+ lines.push(` *`);
34635
+ lines.push(` * // Vanilla JS \u2014 at the top of your entry point:`);
34636
+ lines.push(` * await auth.handleGatewayCallback();`);
34637
+ lines.push(` */`);
34638
+ lines.push(`export { auth };`);
34639
+ lines.push("");
34615
34640
  }
34616
34641
  if (storage) {
34617
34642
  lines.push(`/** Clefbase Storage \u2014 upload and manage files. */`);
@@ -34744,6 +34769,8 @@ function printUsageHint(cfg) {
34744
34769
  if (cfg.services.auth) {
34745
34770
  console.log();
34746
34771
  console.log(source_default.cyan(` const { user } = await auth.signIn("email", "pass");`));
34772
+ console.log(source_default.cyan(` await auth.signInWithGateway("google"); // redirects to auth.cleforyx.com`));
34773
+ console.log(source_default.cyan(` await auth.handleGatewayCallback(); // call on every page load`));
34747
34774
  }
34748
34775
  if (cfg.services.storage) {
34749
34776
  console.log();
@@ -35522,7 +35549,7 @@ async function promptRequired(message) {
35522
35549
  }
35523
35550
 
35524
35551
  // package.json
35525
- var version = "2.0.1";
35552
+ var version = "2.0.2";
35526
35553
 
35527
35554
  // src/cli/index.ts
35528
35555
  var program2 = new Command();
package/dist/index.d.ts CHANGED
@@ -10,12 +10,21 @@
10
10
  * setAuthToken, FunctionsError, AIError, FieldValue,
11
11
  * } from "clefbase";
12
12
  *
13
- * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
13
+ * const app = initClefbase({ serverUrl, projectId, apiKey });
14
14
  *
15
- * // ── Auth ──────────────────────────────────────────────────────────────────
15
+ * // ── Auth — email / password ───────────────────────────────────────────────
16
16
  * const auth = getAuth(app);
17
17
  * const { token } = await auth.signIn("alice@example.com", "password123");
18
18
  *
19
+ * // ── Auth — Google via gateway (redirect flow) ─────────────────────────────
20
+ * // 1. On sign-in button click:
21
+ * await auth.signInWithGateway("google");
22
+ * // ^ redirects to auth.cleforyx.com, then back to your app with ?cfx_token=
23
+ *
24
+ * // 2. On every page load (before rendering):
25
+ * const result = await auth.handleGatewayCallback();
26
+ * if (result) console.log("Signed in:", result.user.email);
27
+ *
19
28
  * // ── Database ──────────────────────────────────────────────────────────────
20
29
  * const db = getDatabase(app);
21
30
  * await db.collection("posts").doc("p1").update({
@@ -32,69 +41,14 @@
32
41
  * const greet = httpsCallable<{ name: string }, { message: string }>(fns, "greetUser");
33
42
  * const { data } = await greet({ name: "Alice" });
34
43
  *
35
- * // ── AI — text / code ──────────────────────────────────────────────────────
44
+ * // ── AI ────────────────────────────────────────────────────────────────────
36
45
  * const ai = getAI(app);
37
- *
38
- * const { content } = await ai.text({
39
- * model: "claude-sonnet-4-5",
40
- * prompt: "Explain async/await in JavaScript",
41
- * });
42
- *
43
- * // Multi-turn chat
44
- * const reply = await ai.text({
45
- * model: "gemini-2.5-flash",
46
- * prompt: "Give me a harder example",
47
- * systemPrompt: "You are a JavaScript tutor.",
48
- * history: [{ role: "user", content: "Explain closures" }, { role: "assistant", content: "..." }],
49
- * });
50
- *
51
- * // ── AI — image generation (auto-saved to Storage) ─────────────────────────
52
- * const { files } = await ai.image({
53
- * model: "imagen-4.0-generate-001",
54
- * prompt: "A serene mountain lake at dawn, photorealistic",
55
- * aspectRatio: "16:9",
56
- * numberOfImages: 2,
57
- * outputFolder: "landscapes",
58
- * });
59
- * // files[].fullPath → path in project Storage
60
- * // files[].storageFileId → use with storage.ref() to get the download URL
61
- *
62
- * // ── AI — video generation (auto-saved to Storage) ─────────────────────────
63
- * const { status, files: clips } = await ai.video({
64
- * model: "veo-3.1-generate-preview",
65
- * prompt: "A slow-motion waterfall in a rainforest",
66
- * durationSeconds: 8,
67
- * aspectRatio: "16:9",
68
- * });
69
- *
70
- * // ── AI — embeddings ───────────────────────────────────────────────────────
71
- * const { embeddings } = await ai.embedding({
72
- * model: "gemini-embedding-001",
73
- * input: ["Hello world", "Semantic search"],
74
- * });
75
- *
76
- * // ── AI — browse models ────────────────────────────────────────────────────
77
- * const imageModels = await ai.listModels({ category: "image" });
78
- * const allModels = await ai.listModels();
79
- *
80
- * // ── AI — usage stats ──────────────────────────────────────────────────────
81
- * const stats = await ai.getStats();
82
- * const history = await ai.getUsage({ limit: 20 });
83
- *
84
- * // ── AI — convenience top-level functions ──────────────────────────────────
85
- * const { content: code } = await generateText(ai, {
86
- * model: "claude-sonnet-4-5",
87
- * prompt: "Write a merge sort in TypeScript",
88
- * });
89
- * const { files: imgs } = await generateImage(ai, {
90
- * model: "imagen-4.0-fast-generate-001",
91
- * prompt: "A cute cartoon robot",
92
- * });
46
+ * const { content } = await ai.text({ model: "claude-sonnet-4-5", prompt: "Hi" });
93
47
  */
94
48
  export { ClefbaseApp, initClefbase, getApp, getDatabase, getAuth, getStorage, getHosting, getFunctions, getAI, } from "./app";
95
49
  export { Database, CollectionReference, CollectionGroup, DocumentReference, Query, WriteBatch, Transaction, runTransaction, } from "./db";
96
50
  export { Auth } from "./auth";
97
- export type { GoogleButtonOptions } from "./auth";
51
+ export type { GatewaySignInOptions } from "./auth";
98
52
  export { ClefbaseStorage, StorageReference, BucketReference } from "./storage";
99
53
  export type { StorageFile } from "./storage";
100
54
  export type { StorageImageStatus } from "./react/StorageImage";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AAGH,OAAO,EACL,WAAW,EACX,YAAY,EACZ,MAAM,EACN,WAAW,EACX,OAAO,EACP,UAAU,EACV,UAAU,EACV,YAAY,EACZ,KAAK,GACN,MAAM,OAAO,CAAC;AAGf,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,iBAAiB,EACjB,KAAK,EACL,UAAU,EACV,WAAW,EACX,cAAc,GACf,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGlD,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,eAAe,EAAE,MA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AqB,EACrB,mBAAmB,GACpB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,UAAU,EACV,OAAO,EACP,YAAY,EACZ,aAAa,EACb,aAAa,EACb,iBAAiB,GAClB,MAAM,MAAM,CAAC;AAEd,YAAY,EACV,OAAO,EACP,UAAU,EACV,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,aAAa,EACb,YAAY,GACb,MAAM,MAAM,CAAC;AAGd,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC/D,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,cAAc,EACd,WAAW,EACX,UAAU,EACV,QAAQ,EACR,WAAW,EACX,UAAU,GACX,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -11,12 +11,21 @@
11
11
  * setAuthToken, FunctionsError, AIError, FieldValue,
12
12
  * } from "clefbase";
13
13
  *
14
- * const app = initClefbase({ serverUrl, projectId, apiKey, adminSecret: "" });
14
+ * const app = initClefbase({ serverUrl, projectId, apiKey });
15
15
  *
16
- * // ── Auth ──────────────────────────────────────────────────────────────────
16
+ * // ── Auth — email / password ───────────────────────────────────────────────
17
17
  * const auth = getAuth(app);
18
18
  * const { token } = await auth.signIn("alice@example.com", "password123");
19
19
  *
20
+ * // ── Auth — Google via gateway (redirect flow) ─────────────────────────────
21
+ * // 1. On sign-in button click:
22
+ * await auth.signInWithGateway("google");
23
+ * // ^ redirects to auth.cleforyx.com, then back to your app with ?cfx_token=
24
+ *
25
+ * // 2. On every page load (before rendering):
26
+ * const result = await auth.handleGatewayCallback();
27
+ * if (result) console.log("Signed in:", result.user.email);
28
+ *
20
29
  * // ── Database ──────────────────────────────────────────────────────────────
21
30
  * const db = getDatabase(app);
22
31
  * await db.collection("posts").doc("p1").update({
@@ -33,64 +42,9 @@
33
42
  * const greet = httpsCallable<{ name: string }, { message: string }>(fns, "greetUser");
34
43
  * const { data } = await greet({ name: "Alice" });
35
44
  *
36
- * // ── AI — text / code ──────────────────────────────────────────────────────
45
+ * // ── AI ────────────────────────────────────────────────────────────────────
37
46
  * const ai = getAI(app);
38
- *
39
- * const { content } = await ai.text({
40
- * model: "claude-sonnet-4-5",
41
- * prompt: "Explain async/await in JavaScript",
42
- * });
43
- *
44
- * // Multi-turn chat
45
- * const reply = await ai.text({
46
- * model: "gemini-2.5-flash",
47
- * prompt: "Give me a harder example",
48
- * systemPrompt: "You are a JavaScript tutor.",
49
- * history: [{ role: "user", content: "Explain closures" }, { role: "assistant", content: "..." }],
50
- * });
51
- *
52
- * // ── AI — image generation (auto-saved to Storage) ─────────────────────────
53
- * const { files } = await ai.image({
54
- * model: "imagen-4.0-generate-001",
55
- * prompt: "A serene mountain lake at dawn, photorealistic",
56
- * aspectRatio: "16:9",
57
- * numberOfImages: 2,
58
- * outputFolder: "landscapes",
59
- * });
60
- * // files[].fullPath → path in project Storage
61
- * // files[].storageFileId → use with storage.ref() to get the download URL
62
- *
63
- * // ── AI — video generation (auto-saved to Storage) ─────────────────────────
64
- * const { status, files: clips } = await ai.video({
65
- * model: "veo-3.1-generate-preview",
66
- * prompt: "A slow-motion waterfall in a rainforest",
67
- * durationSeconds: 8,
68
- * aspectRatio: "16:9",
69
- * });
70
- *
71
- * // ── AI — embeddings ───────────────────────────────────────────────────────
72
- * const { embeddings } = await ai.embedding({
73
- * model: "gemini-embedding-001",
74
- * input: ["Hello world", "Semantic search"],
75
- * });
76
- *
77
- * // ── AI — browse models ────────────────────────────────────────────────────
78
- * const imageModels = await ai.listModels({ category: "image" });
79
- * const allModels = await ai.listModels();
80
- *
81
- * // ── AI — usage stats ──────────────────────────────────────────────────────
82
- * const stats = await ai.getStats();
83
- * const history = await ai.getUsage({ limit: 20 });
84
- *
85
- * // ── AI — convenience top-level functions ──────────────────────────────────
86
- * const { content: code } = await generateText(ai, {
87
- * model: "claude-sonnet-4-5",
88
- * prompt: "Write a merge sort in TypeScript",
89
- * });
90
- * const { files: imgs } = await generateImage(ai, {
91
- * model: "imagen-4.0-fast-generate-001",
92
- * prompt: "A cute cartoon robot",
93
- * });
47
+ * const { content } = await ai.text({ model: "claude-sonnet-4-5", prompt: "Hi" });
94
48
  */
95
49
  Object.defineProperty(exports, "__esModule", { value: true });
96
50
  exports.ClefbaseError = exports.FieldValueSentinel = exports.FieldValue = exports.generateEmbedding = exports.generateVideo = exports.generateImage = exports.generateText = exports.AIError = exports.ClefbaseAI = exports.deployFromFile = exports.setAuthToken = exports.getFunctionExecutions = exports.listFunctions = exports.deleteFunction = exports.deployFunction = exports.callFunction = exports.httpsCallable = exports.FunctionsError = exports.ClefbaseFunctions = exports.SiteReference = exports.ClefbaseHosting = exports.EmailVerificationCard = exports.BucketReference = exports.StorageReference = exports.ClefbaseStorage = exports.Auth = exports.runTransaction = exports.Transaction = exports.WriteBatch = exports.Query = exports.DocumentReference = exports.CollectionGroup = exports.CollectionReference = exports.Database = exports.getAI = exports.getFunctions = exports.getHosting = exports.getStorage = exports.getAuth = exports.getDatabase = exports.getApp = exports.initClefbase = exports.ClefbaseApp = void 0;
@@ -132,11 +86,8 @@ Object.defineProperty(exports, "ClefbaseHosting", { enumerable: true, get: funct
132
86
  Object.defineProperty(exports, "SiteReference", { enumerable: true, get: function () { return hosting_1.SiteReference; } });
133
87
  // ─── Functions ────────────────────────────────────────────────────────────────
134
88
  var functions_1 = require("./functions");
135
- // Class
136
89
  Object.defineProperty(exports, "ClefbaseFunctions", { enumerable: true, get: function () { return functions_1.ClefbaseFunctions; } });
137
- // Error
138
90
  Object.defineProperty(exports, "FunctionsError", { enumerable: true, get: function () { return functions_1.FunctionsError; } });
139
- // Top-level factory / convenience
140
91
  Object.defineProperty(exports, "httpsCallable", { enumerable: true, get: function () { return functions_1.httpsCallable; } });
141
92
  Object.defineProperty(exports, "callFunction", { enumerable: true, get: function () { return functions_1.callFunction; } });
142
93
  Object.defineProperty(exports, "deployFunction", { enumerable: true, get: function () { return functions_1.deployFunction; } });
@@ -147,11 +98,8 @@ Object.defineProperty(exports, "setAuthToken", { enumerable: true, get: function
147
98
  Object.defineProperty(exports, "deployFromFile", { enumerable: true, get: function () { return functions_1.deployFromFile; } });
148
99
  // ─── AI ───────────────────────────────────────────────────────────────────────
149
100
  var ai_1 = require("./ai");
150
- // Class
151
101
  Object.defineProperty(exports, "ClefbaseAI", { enumerable: true, get: function () { return ai_1.ClefbaseAI; } });
152
- // Error
153
102
  Object.defineProperty(exports, "AIError", { enumerable: true, get: function () { return ai_1.AIError; } });
154
- // Top-level convenience functions
155
103
  Object.defineProperty(exports, "generateText", { enumerable: true, get: function () { return ai_1.generateText; } });
156
104
  Object.defineProperty(exports, "generateImage", { enumerable: true, get: function () { return ai_1.generateImage; } });
157
105
  Object.defineProperty(exports, "generateVideo", { enumerable: true, get: function () { return ai_1.generateVideo; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;;;AAEH,iFAAiF;AACjF,6BAUe;AATb,kGAAA,WAAW,OAAA;AACX,mGAAA,YAAY,OAAA;AACZ,6FAAA,MAAM,OAAA;AACN,kGAAA,WAAW,OAAA;AACX,8FAAA,OAAO,OAAA;AACP,iGAAA,UAAU,OAAA;AACV,iGAAA,UAAU,OAAA;AACV,mGAAA,YAAY,OAAA;AACZ,4FAAA,KAAK,OAAA;AAGP,iFAAiF;AACjF,2BASc;AARZ,8FAAA,QAAQ,OAAA;AACR,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ACb,mGAAA,aAAa,OAAA;AACb,uGAAA,iBAAiB,OAAA;AAoBnB,iFAAiF;AACjF,6CAA+D;AAAtD,yGAAA,UAAU,OAAA;AAAE,iHAAA,kBAAkB,OAAA;AAiBvC,iCAAwC;AAA/B,sGAAA,aAAa,OAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clefbase",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Firebase-style SDK and CLI for Clefbase — database, auth, storage, hosting, and functions",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",