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/app.d.ts
CHANGED
|
@@ -44,10 +44,10 @@ export declare class ClefbaseApp {
|
|
|
44
44
|
*
|
|
45
45
|
* @example
|
|
46
46
|
* const app = initClefbase({
|
|
47
|
-
* serverUrl:
|
|
48
|
-
* projectId:
|
|
49
|
-
* apiKey:
|
|
50
|
-
*
|
|
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
|
|
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
|
|
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,EA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AAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,UAAU,CAAgC;IAClD,OAAO,CAAC,GAAG,CAAuC;gBAEtC,MAAM,EAAE,cAAc;IAalC,gBAAgB;IAChB,MAAM,IAAI,QAAQ;IAKlB,gBAAgB;IAChB,QAAQ,IAAI,IAAI;IAWhB,gBAAgB;IAChB,WAAW,IAAI,eAAe;IAU9B,gBAAgB;IAChB,WAAW,IAAI,eAAe;IAM9B,gBAAgB;IAChB,aAAa,IAAI,iBAAiB;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:
|
|
84
|
-
* projectId:
|
|
85
|
-
* apiKey:
|
|
86
|
-
*
|
|
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
|
|
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
|
|
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":";;;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../src/app.ts"],"names":[],"mappings":";;;AAmHA,oCAQC;AAGD,wBAQC;AAKD,kCAEC;AAGD,0BAEC;AAGD,gCAEC;AAGD,gCAEC;AAcD,oCAEC;AAgBD,sBAEC;AA9LD,iCAAoC;AACpC,6BAAgC;AAChC,iCAA8B;AAC9B,uCAA4C;AAC5C,uCAA4C;AAC5C,2CAA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AM,EAAE,CAAC;AACpC,CAAC"}
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,214 +1,98 @@
|
|
|
1
1
|
import { HttpClient } from "../http";
|
|
2
2
|
import type { AuthUser, AuthResult } from "../types";
|
|
3
|
-
interface
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
}
|
|
3
|
+
export interface GatewaySignInOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Where the gateway should redirect after sign-in.
|
|
6
|
+
* Defaults to `window.location.origin`.
|
|
7
|
+
* Must be registered as an allowed redirect for your project.
|
|
8
|
+
*/
|
|
9
|
+
redirectUrl?: string;
|
|
42
10
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
locale?: string;
|
|
11
|
+
export interface OpenAuthUIOptions {
|
|
12
|
+
/**
|
|
13
|
+
* How to display the auth UI.
|
|
14
|
+
* - `"modal"` (default) — overlay on top of the current page
|
|
15
|
+
* - `"redirect"` — full-page redirect to auth.cleforyx.com
|
|
16
|
+
*/
|
|
17
|
+
mode?: "modal" | "redirect";
|
|
18
|
+
/** Called when the user successfully signs in. */
|
|
19
|
+
onSuccess?: (result: AuthResult) => void;
|
|
20
|
+
/** Called when the modal is dismissed without signing in. */
|
|
21
|
+
onDismiss?: () => void;
|
|
22
|
+
/** Where to redirect after sign-in (redirect mode only). Defaults to current page. */
|
|
23
|
+
redirectUrl?: string;
|
|
57
24
|
}
|
|
58
25
|
type AuthStateCallback = (user: AuthUser | null) => void;
|
|
59
|
-
/**
|
|
60
|
-
* Authentication service. Obtain via `getAuth(app)`.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* const auth = getAuth(app);
|
|
64
|
-
* const { user } = await auth.signIn("alice@example.com", "pass");
|
|
65
|
-
* const unsub = auth.onAuthStateChanged(u => console.log(u));
|
|
66
|
-
* unsub();
|
|
67
|
-
*/
|
|
68
26
|
export declare class Auth {
|
|
69
27
|
private readonly http;
|
|
70
28
|
private readonly store;
|
|
71
29
|
private listeners;
|
|
72
|
-
|
|
73
|
-
private
|
|
74
|
-
|
|
30
|
+
private readonly gatewayUrl;
|
|
31
|
+
private readonly projectId;
|
|
32
|
+
private _modalCleanup;
|
|
33
|
+
constructor(http: HttpClient, gatewayUrl: string, projectId: string);
|
|
75
34
|
private notify;
|
|
76
35
|
private handleResult;
|
|
77
|
-
private resolveGoogleClientId;
|
|
78
36
|
/** @internal — used by Storage to attach the bearer token to upload requests */
|
|
79
37
|
getAuthHeaders(): Record<string, string>;
|
|
80
|
-
/** The currently signed-in user, or null. */
|
|
81
38
|
get currentUser(): AuthUser | null;
|
|
82
|
-
/** The raw bearer token for the active session, or null. */
|
|
83
39
|
get currentToken(): string | null;
|
|
84
|
-
/**
|
|
85
|
-
* Create a new account.
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* const { user } = await auth.signUp("alice@example.com", "pass123", {
|
|
89
|
-
* displayName: "Alice",
|
|
90
|
-
* metadata: { role: "admin" },
|
|
91
|
-
* });
|
|
92
|
-
*/
|
|
93
40
|
signUp(email: string, password: string, profile?: {
|
|
94
41
|
displayName?: string;
|
|
95
42
|
photoUrl?: string;
|
|
96
43
|
metadata?: Record<string, unknown>;
|
|
97
44
|
}): Promise<AuthResult>;
|
|
98
|
-
/**
|
|
99
|
-
* Sign in with email + password.
|
|
100
|
-
*
|
|
101
|
-
* @example
|
|
102
|
-
* const { user, token } = await auth.signIn("alice@example.com", "pass");
|
|
103
|
-
*/
|
|
104
45
|
signIn(email: string, password: string): Promise<AuthResult>;
|
|
105
46
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
* Browser-only. The GIS script (`accounts.google.com/gsi/client`) is loaded
|
|
109
|
-
* automatically — no manual `<script>` tag needed.
|
|
110
|
-
*
|
|
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.
|
|
114
|
-
*
|
|
115
|
-
* Automatically handles new sign-ups: if the Google account has never been
|
|
116
|
-
* seen before, a new user record is created server-side.
|
|
47
|
+
* Open the Cleforyx hosted auth UI as a modal overlay on top of your page.
|
|
48
|
+
* Handles sign-in via email/password, Google, and magic link seamlessly.
|
|
117
49
|
*
|
|
118
|
-
*
|
|
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.
|
|
50
|
+
* The modal closes automatically on successful sign-in and fires `onSuccess`.
|
|
124
51
|
*
|
|
125
52
|
* @example
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
* container: document.getElementById("google-btn")!,
|
|
132
|
-
* theme: "filled_blue",
|
|
133
|
-
* size: "large",
|
|
134
|
-
* text: "continue_with",
|
|
53
|
+
* auth.openAuthUI({
|
|
54
|
+
* onSuccess: (result) => {
|
|
55
|
+
* console.log("Signed in:", result.user.email);
|
|
56
|
+
* navigate("/dashboard");
|
|
57
|
+
* },
|
|
135
58
|
* });
|
|
136
|
-
*
|
|
137
|
-
* // React example
|
|
138
|
-
* const btnRef = useRef<HTMLDivElement>(null);
|
|
139
|
-
* await auth.signInWithGoogle({ container: btnRef.current! });
|
|
140
59
|
*/
|
|
141
|
-
|
|
60
|
+
openAuthUI(options?: OpenAuthUIOptions): void;
|
|
61
|
+
/** Close the auth modal programmatically if open. */
|
|
62
|
+
closeAuthUI(): void;
|
|
142
63
|
/**
|
|
143
|
-
*
|
|
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.
|
|
64
|
+
* Redirect to the Cleforyx auth gateway for OAuth sign-in.
|
|
65
|
+
* Use `openAuthUI()` for a modal experience instead.
|
|
150
66
|
*
|
|
151
67
|
* @example
|
|
152
|
-
*
|
|
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);
|
|
68
|
+
* await auth.signInWithGateway("google");
|
|
163
69
|
*/
|
|
164
|
-
|
|
70
|
+
signInWithGateway(provider: "google", options?: GatewaySignInOptions): Promise<never>;
|
|
71
|
+
isGatewayCallbackPending(): boolean;
|
|
165
72
|
/**
|
|
166
|
-
*
|
|
167
|
-
*
|
|
73
|
+
* Call on every page load to handle the gateway redirect callback.
|
|
74
|
+
* Detects `?cfx_token=` in the URL, validates it, and returns the signed-in user.
|
|
168
75
|
*
|
|
169
76
|
* @example
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
77
|
+
* useEffect(() => {
|
|
78
|
+
* auth.handleGatewayCallback().then(result => {
|
|
79
|
+
* if (result) navigate("/dashboard");
|
|
80
|
+
* });
|
|
81
|
+
* }, []);
|
|
173
82
|
*/
|
|
174
|
-
|
|
175
|
-
/** Sign out and clear the local session. */
|
|
83
|
+
handleGatewayCallback(): Promise<AuthResult | null>;
|
|
176
84
|
signOut(): Promise<void>;
|
|
177
|
-
/** Re-fetch the current user's profile from the server and update the cache. */
|
|
178
85
|
refreshCurrentUser(): Promise<AuthUser | null>;
|
|
179
|
-
/**
|
|
180
|
-
* Update the signed-in user's profile.
|
|
181
|
-
*
|
|
182
|
-
* @example
|
|
183
|
-
* await auth.updateProfile({ displayName: "Bob", metadata: { theme: "dark" } });
|
|
184
|
-
*/
|
|
185
86
|
updateProfile(updates: {
|
|
186
87
|
displayName?: string;
|
|
187
88
|
photoUrl?: string;
|
|
188
89
|
metadata?: Record<string, unknown>;
|
|
189
90
|
}): Promise<AuthUser>;
|
|
190
|
-
/** Change password. All other sessions are invalidated server-side. */
|
|
191
91
|
changePassword(currentPassword: string, newPassword: string): Promise<void>;
|
|
192
|
-
/** Request a password-reset email. Safe to call even for unregistered addresses. */
|
|
193
92
|
sendPasswordResetEmail(email: string): Promise<void>;
|
|
194
|
-
/** Complete a password reset with the token from the reset email. */
|
|
195
93
|
confirmPasswordReset(resetToken: string, newPassword: string): Promise<void>;
|
|
196
|
-
/** Send an email verification code to the currently signed-in user. */
|
|
197
94
|
sendEmailVerification(): Promise<void>;
|
|
198
|
-
/** Verify email with the code the user received. */
|
|
199
95
|
verifyEmail(code: string): Promise<AuthUser>;
|
|
200
|
-
/**
|
|
201
|
-
* Subscribe to auth state changes.
|
|
202
|
-
* Fires immediately with the current user, then on every change.
|
|
203
|
-
* Returns an unsubscribe function.
|
|
204
|
-
*
|
|
205
|
-
* @example
|
|
206
|
-
* const unsubscribe = auth.onAuthStateChanged(user => {
|
|
207
|
-
* if (user) console.log("signed in:", user.email);
|
|
208
|
-
* else console.log("signed out");
|
|
209
|
-
* });
|
|
210
|
-
* unsubscribe();
|
|
211
|
-
*/
|
|
212
96
|
onAuthStateChanged(callback: AuthStateCallback): () => void;
|
|
213
97
|
}
|
|
214
98
|
export {};
|
package/dist/auth/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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;AAkDrD,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;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