@palbase/web 1.0.0 → 1.0.1
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/{analytics-facade-DkOwkEpi.d.ts → analytics-facade-CE_vGf1F.d.ts} +511 -9
- package/dist/{analytics-facade-t6UrFdn7.d.cts → analytics-facade-DV2uAiSg.d.cts} +511 -9
- package/dist/{chunk-JVT65V4E.js → chunk-AVEXGXRQ.js} +2 -2
- package/dist/{chunk-JVT65V4E.js.map → chunk-AVEXGXRQ.js.map} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +4 -6
- package/dist/internal.d.ts +4 -6
- package/dist/internal.js +1 -1
- package/dist/next/client.cjs +1 -1
- package/dist/next/client.cjs.map +1 -1
- package/dist/next/client.js +1 -1
- package/dist/next/index.cjs +1 -1
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +3 -5
- package/dist/next/index.d.ts +3 -5
- package/dist/next/index.js +1 -1
- package/dist/{pb-Cudze7Kb.d.cts → pb-DcknUtCh.d.cts} +1 -1
- package/dist/{pb-BmgkAe97.d.ts → pb-EMn_MF9g.d.ts} +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +3 -5
- package/dist/react/index.d.ts +3 -5
- package/dist/react/index.js +1 -1
- package/package.json +5 -7
|
@@ -1,7 +1,509 @@
|
|
|
1
|
-
import { HttpClient, TokenManager, Session } from '@palbase/core';
|
|
2
|
-
import { AuthClient } from '@palbase/auth';
|
|
3
1
|
import { S as SessionStorageAdapter } from './storage-BPaeSG8K.js';
|
|
4
|
-
import {
|
|
2
|
+
import { F } from './pooled-flags-Bwq4usn0.js';
|
|
3
|
+
|
|
4
|
+
declare class PalbaseError$1 extends Error {
|
|
5
|
+
readonly code: string;
|
|
6
|
+
readonly status: number;
|
|
7
|
+
readonly details?: unknown;
|
|
8
|
+
constructor(code: string, message: string, status: number, details?: unknown);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface PalbaseResponse$1<T> {
|
|
12
|
+
data: T | null;
|
|
13
|
+
error: PalbaseError$1 | null;
|
|
14
|
+
count?: number;
|
|
15
|
+
status: number;
|
|
16
|
+
}
|
|
17
|
+
interface HttpClientOptions$1 {
|
|
18
|
+
url?: string;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
interface RequestOptions$1 {
|
|
22
|
+
headers?: Record<string, string>;
|
|
23
|
+
body?: unknown;
|
|
24
|
+
signal?: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
interface Session$1 {
|
|
27
|
+
accessToken: string;
|
|
28
|
+
refreshToken: string;
|
|
29
|
+
expiresAt: number;
|
|
30
|
+
}
|
|
31
|
+
type AuthStateEvent$1 = 'SESSION_SET' | 'SESSION_CLEARED';
|
|
32
|
+
type AuthStateCallback$1 = (event: AuthStateEvent$1, session: Session$1 | null) => void;
|
|
33
|
+
type Unsubscribe$2 = () => void;
|
|
34
|
+
|
|
35
|
+
declare class TokenManager$1 {
|
|
36
|
+
private session;
|
|
37
|
+
private listeners;
|
|
38
|
+
private refreshPromise;
|
|
39
|
+
private refreshing;
|
|
40
|
+
refreshFunction: ((refreshToken: string) => Promise<Session$1>) | null;
|
|
41
|
+
setSession(session: Session$1): void;
|
|
42
|
+
getAccessToken(): string | null;
|
|
43
|
+
getRefreshToken(): string | null;
|
|
44
|
+
clearSession(): void;
|
|
45
|
+
isExpired(): boolean;
|
|
46
|
+
refreshSession(): Promise<void>;
|
|
47
|
+
onAuthStateChange(callback: AuthStateCallback$1): Unsubscribe$2;
|
|
48
|
+
private executeRefresh;
|
|
49
|
+
private notify;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Request interceptor. Runs before every HTTP request.
|
|
54
|
+
* Can modify headers, body, or reject the request.
|
|
55
|
+
*/
|
|
56
|
+
type RequestInterceptor$1 = (request: {
|
|
57
|
+
headers: Record<string, string>;
|
|
58
|
+
method: string;
|
|
59
|
+
path: string;
|
|
60
|
+
}) => void | Promise<void>;
|
|
61
|
+
declare class HttpClient$1 {
|
|
62
|
+
protected readonly apiKey: string;
|
|
63
|
+
protected readonly options?: HttpClientOptions$1;
|
|
64
|
+
tokenManager: TokenManager$1 | null;
|
|
65
|
+
/**
|
|
66
|
+
* Admin JWT used for platform admin endpoints (/admin/*).
|
|
67
|
+
* When set, takes precedence over tokenManager access token in the
|
|
68
|
+
* Authorization header.
|
|
69
|
+
*/
|
|
70
|
+
adminToken: string | null;
|
|
71
|
+
private readonly interceptors;
|
|
72
|
+
constructor(apiKey: string, options?: HttpClientOptions$1);
|
|
73
|
+
/** Set (or clear) the admin JWT used on admin endpoints. */
|
|
74
|
+
setAdminToken(token: string | null): void;
|
|
75
|
+
/**
|
|
76
|
+
* Create a scoped HttpClient that adds the given extra headers to every
|
|
77
|
+
* request. The returned client shares the admin token and token manager
|
|
78
|
+
* with the parent at runtime — later changes on the parent propagate to
|
|
79
|
+
* the scope and vice versa.
|
|
80
|
+
*
|
|
81
|
+
* Typical use: tagging admin calls with `x-palbase-project: <ref>` so the
|
|
82
|
+
* gateway can route them to the correct project's data plane.
|
|
83
|
+
*/
|
|
84
|
+
withHeaders(extra: Record<string, string>): HttpClient$1;
|
|
85
|
+
/** Add a request interceptor. Runs before every request. */
|
|
86
|
+
addInterceptor(interceptor: RequestInterceptor$1): void;
|
|
87
|
+
request<T>(method: string, path: string, options?: RequestOptions$1): Promise<PalbaseResponse$1<T>>;
|
|
88
|
+
private getBaseUrl;
|
|
89
|
+
private buildHeaders;
|
|
90
|
+
private executeWithRetry;
|
|
91
|
+
private delay;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare class PalbaseError extends Error {
|
|
95
|
+
readonly code: string;
|
|
96
|
+
readonly status: number;
|
|
97
|
+
readonly details?: unknown;
|
|
98
|
+
constructor(code: string, message: string, status: number, details?: unknown);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
interface PalbaseResponse<T> {
|
|
102
|
+
data: T | null;
|
|
103
|
+
error: PalbaseError | null;
|
|
104
|
+
count?: number;
|
|
105
|
+
status: number;
|
|
106
|
+
}
|
|
107
|
+
interface HttpClientOptions {
|
|
108
|
+
url?: string;
|
|
109
|
+
headers?: Record<string, string>;
|
|
110
|
+
}
|
|
111
|
+
interface RequestOptions {
|
|
112
|
+
headers?: Record<string, string>;
|
|
113
|
+
body?: unknown;
|
|
114
|
+
signal?: AbortSignal;
|
|
115
|
+
}
|
|
116
|
+
interface Session {
|
|
117
|
+
accessToken: string;
|
|
118
|
+
refreshToken: string;
|
|
119
|
+
expiresAt: number;
|
|
120
|
+
}
|
|
121
|
+
type AuthStateEvent = 'SESSION_SET' | 'SESSION_CLEARED';
|
|
122
|
+
type AuthStateCallback = (event: AuthStateEvent, session: Session | null) => void;
|
|
123
|
+
type Unsubscribe$1 = () => void;
|
|
124
|
+
|
|
125
|
+
declare class TokenManager {
|
|
126
|
+
private session;
|
|
127
|
+
private listeners;
|
|
128
|
+
private refreshPromise;
|
|
129
|
+
private refreshing;
|
|
130
|
+
refreshFunction: ((refreshToken: string) => Promise<Session>) | null;
|
|
131
|
+
setSession(session: Session): void;
|
|
132
|
+
getAccessToken(): string | null;
|
|
133
|
+
getRefreshToken(): string | null;
|
|
134
|
+
clearSession(): void;
|
|
135
|
+
isExpired(): boolean;
|
|
136
|
+
refreshSession(): Promise<void>;
|
|
137
|
+
onAuthStateChange(callback: AuthStateCallback): Unsubscribe$1;
|
|
138
|
+
private executeRefresh;
|
|
139
|
+
private notify;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Request interceptor. Runs before every HTTP request.
|
|
144
|
+
* Can modify headers, body, or reject the request.
|
|
145
|
+
*/
|
|
146
|
+
type RequestInterceptor = (request: {
|
|
147
|
+
headers: Record<string, string>;
|
|
148
|
+
method: string;
|
|
149
|
+
path: string;
|
|
150
|
+
}) => void | Promise<void>;
|
|
151
|
+
declare class HttpClient {
|
|
152
|
+
protected readonly apiKey: string;
|
|
153
|
+
protected readonly options?: HttpClientOptions;
|
|
154
|
+
tokenManager: TokenManager | null;
|
|
155
|
+
/**
|
|
156
|
+
* Admin JWT used for platform admin endpoints (/admin/*).
|
|
157
|
+
* When set, takes precedence over tokenManager access token in the
|
|
158
|
+
* Authorization header.
|
|
159
|
+
*/
|
|
160
|
+
adminToken: string | null;
|
|
161
|
+
private readonly interceptors;
|
|
162
|
+
constructor(apiKey: string, options?: HttpClientOptions);
|
|
163
|
+
/** Set (or clear) the admin JWT used on admin endpoints. */
|
|
164
|
+
setAdminToken(token: string | null): void;
|
|
165
|
+
/**
|
|
166
|
+
* Create a scoped HttpClient that adds the given extra headers to every
|
|
167
|
+
* request. The returned client shares the admin token and token manager
|
|
168
|
+
* with the parent at runtime — later changes on the parent propagate to
|
|
169
|
+
* the scope and vice versa.
|
|
170
|
+
*
|
|
171
|
+
* Typical use: tagging admin calls with `x-palbase-project: <ref>` so the
|
|
172
|
+
* gateway can route them to the correct project's data plane.
|
|
173
|
+
*/
|
|
174
|
+
withHeaders(extra: Record<string, string>): HttpClient;
|
|
175
|
+
/** Add a request interceptor. Runs before every request. */
|
|
176
|
+
addInterceptor(interceptor: RequestInterceptor): void;
|
|
177
|
+
request<T>(method: string, path: string, options?: RequestOptions): Promise<PalbaseResponse<T>>;
|
|
178
|
+
private getBaseUrl;
|
|
179
|
+
private buildHeaders;
|
|
180
|
+
private executeWithRetry;
|
|
181
|
+
private delay;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
interface User {
|
|
185
|
+
id: string;
|
|
186
|
+
email: string;
|
|
187
|
+
emailVerified: boolean;
|
|
188
|
+
createdAt: string;
|
|
189
|
+
updatedAt: string;
|
|
190
|
+
metadata?: Record<string, unknown>;
|
|
191
|
+
}
|
|
192
|
+
interface TokenResponse {
|
|
193
|
+
access_token: string;
|
|
194
|
+
refresh_token: string;
|
|
195
|
+
token_type: string;
|
|
196
|
+
expires_in: number;
|
|
197
|
+
}
|
|
198
|
+
interface AuthSession {
|
|
199
|
+
id: string;
|
|
200
|
+
ip?: string;
|
|
201
|
+
user_agent?: string;
|
|
202
|
+
acr: string;
|
|
203
|
+
amr: string[];
|
|
204
|
+
last_activity: string;
|
|
205
|
+
created_at: string;
|
|
206
|
+
current: boolean;
|
|
207
|
+
}
|
|
208
|
+
interface SignUpCredentials {
|
|
209
|
+
email: string;
|
|
210
|
+
password: string;
|
|
211
|
+
}
|
|
212
|
+
interface SignInCredentials {
|
|
213
|
+
email: string;
|
|
214
|
+
password: string;
|
|
215
|
+
}
|
|
216
|
+
interface VerifyEmailParams {
|
|
217
|
+
token?: string;
|
|
218
|
+
code?: string;
|
|
219
|
+
email?: string;
|
|
220
|
+
}
|
|
221
|
+
interface PasswordResetParams {
|
|
222
|
+
email: string;
|
|
223
|
+
}
|
|
224
|
+
interface PasswordResetConfirmParams {
|
|
225
|
+
token: string;
|
|
226
|
+
new_password: string;
|
|
227
|
+
}
|
|
228
|
+
interface PasswordChangeParams {
|
|
229
|
+
current_password: string;
|
|
230
|
+
new_password: string;
|
|
231
|
+
}
|
|
232
|
+
interface MFAEnrollParams {
|
|
233
|
+
type: 'totp' | 'email';
|
|
234
|
+
}
|
|
235
|
+
interface MFAEnrollResult {
|
|
236
|
+
enrollment_id?: string;
|
|
237
|
+
secret?: string;
|
|
238
|
+
otp_url?: string;
|
|
239
|
+
qr_code?: string;
|
|
240
|
+
recovery_codes?: string[];
|
|
241
|
+
status?: string;
|
|
242
|
+
}
|
|
243
|
+
interface MFAChallengeParams {
|
|
244
|
+
mfa_token: string;
|
|
245
|
+
type: 'totp' | 'email';
|
|
246
|
+
code: string;
|
|
247
|
+
}
|
|
248
|
+
interface MFARecoveryParams {
|
|
249
|
+
mfa_token: string;
|
|
250
|
+
code: string;
|
|
251
|
+
}
|
|
252
|
+
interface MFAFactor {
|
|
253
|
+
id: string;
|
|
254
|
+
type: string;
|
|
255
|
+
verified: boolean;
|
|
256
|
+
created_at: string;
|
|
257
|
+
}
|
|
258
|
+
interface MFAEmailChallengeParams {
|
|
259
|
+
mfa_token: string;
|
|
260
|
+
}
|
|
261
|
+
interface MFAEmailVerifyParams {
|
|
262
|
+
mfa_token: string;
|
|
263
|
+
code: string;
|
|
264
|
+
}
|
|
265
|
+
interface OAuthOptions {
|
|
266
|
+
provider: string;
|
|
267
|
+
redirectTo?: string;
|
|
268
|
+
}
|
|
269
|
+
interface Identity {
|
|
270
|
+
id: string;
|
|
271
|
+
provider: string;
|
|
272
|
+
provider_user_id: string;
|
|
273
|
+
created_at: string;
|
|
274
|
+
}
|
|
275
|
+
interface CredentialExchangeParams {
|
|
276
|
+
provider: string;
|
|
277
|
+
credential: string;
|
|
278
|
+
}
|
|
279
|
+
interface LinkIdentityParams {
|
|
280
|
+
provider: string;
|
|
281
|
+
credential: string;
|
|
282
|
+
}
|
|
283
|
+
interface MagicLinkParams {
|
|
284
|
+
email: string;
|
|
285
|
+
}
|
|
286
|
+
interface MagicLinkVerifyParams {
|
|
287
|
+
token: string;
|
|
288
|
+
fingerprint_hash?: string;
|
|
289
|
+
}
|
|
290
|
+
interface RegisterTrustedDeviceParams {
|
|
291
|
+
fingerprint_hash: string;
|
|
292
|
+
device_name?: string;
|
|
293
|
+
}
|
|
294
|
+
interface TrustedDevice {
|
|
295
|
+
id: string;
|
|
296
|
+
device_name?: string;
|
|
297
|
+
created_at: string;
|
|
298
|
+
last_used_at: string;
|
|
299
|
+
expires_at: string;
|
|
300
|
+
}
|
|
301
|
+
interface DeviceInfo {
|
|
302
|
+
id: string;
|
|
303
|
+
platform: string;
|
|
304
|
+
attestation_status: string;
|
|
305
|
+
bound: boolean;
|
|
306
|
+
created_at: string;
|
|
307
|
+
}
|
|
308
|
+
interface AttestAndroidParams {
|
|
309
|
+
verdict_token: string;
|
|
310
|
+
}
|
|
311
|
+
interface AttestAndroidResult {
|
|
312
|
+
device_id: string;
|
|
313
|
+
attestation_status: string;
|
|
314
|
+
device_integrity?: string;
|
|
315
|
+
}
|
|
316
|
+
interface AttestiOSParams {
|
|
317
|
+
attestation_object: string;
|
|
318
|
+
key_id: string;
|
|
319
|
+
challenge: string;
|
|
320
|
+
}
|
|
321
|
+
interface AttestiOSResult {
|
|
322
|
+
device_id: string;
|
|
323
|
+
attestation_status: string;
|
|
324
|
+
}
|
|
325
|
+
interface BindDeviceParams {
|
|
326
|
+
device_id: string;
|
|
327
|
+
public_key: string;
|
|
328
|
+
platform_attestation?: string;
|
|
329
|
+
}
|
|
330
|
+
interface VerifyRequestSignatureParams {
|
|
331
|
+
payload: string;
|
|
332
|
+
signature: string;
|
|
333
|
+
}
|
|
334
|
+
type AuthEvent = 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED';
|
|
335
|
+
type AuthStateChangeCallback = (event: AuthEvent, session: Session | null) => void;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Device attestation client.
|
|
339
|
+
* Handles device challenge/attestation/bind and App Check JWT cache.
|
|
340
|
+
*/
|
|
341
|
+
declare class DeviceClient {
|
|
342
|
+
private readonly httpClient;
|
|
343
|
+
private cachedToken;
|
|
344
|
+
private refreshTimer;
|
|
345
|
+
constructor(httpClient: HttpClient);
|
|
346
|
+
/** Generate a device attestation challenge. */
|
|
347
|
+
generateChallenge(): Promise<PalbaseResponse<{
|
|
348
|
+
challenge: string;
|
|
349
|
+
}>>;
|
|
350
|
+
/** Attest an Android device with a Play Integrity verdict token. */
|
|
351
|
+
attestAndroid(params: AttestAndroidParams): Promise<PalbaseResponse<AttestAndroidResult>>;
|
|
352
|
+
/** Attest an iOS device with App Attest attestation data. */
|
|
353
|
+
attestiOS(params: AttestiOSParams): Promise<PalbaseResponse<AttestiOSResult>>;
|
|
354
|
+
/** Bind a verified device with a public key for request signing. */
|
|
355
|
+
bind(params: BindDeviceParams): Promise<PalbaseResponse<{
|
|
356
|
+
success: boolean;
|
|
357
|
+
}>>;
|
|
358
|
+
/** List all devices for the current user. */
|
|
359
|
+
list(): Promise<PalbaseResponse<{
|
|
360
|
+
devices: DeviceInfo[];
|
|
361
|
+
}>>;
|
|
362
|
+
/** Delete a device by ID. */
|
|
363
|
+
delete(deviceId: string): Promise<PalbaseResponse<{
|
|
364
|
+
success: boolean;
|
|
365
|
+
}>>;
|
|
366
|
+
/**
|
|
367
|
+
* Verify a request signature from a device (server-only).
|
|
368
|
+
* Should NOT be exposed in client SDK.
|
|
369
|
+
*/
|
|
370
|
+
verifyRequestSignature(deviceId: string, params: VerifyRequestSignatureParams): Promise<PalbaseResponse<{
|
|
371
|
+
verified: boolean;
|
|
372
|
+
}>>;
|
|
373
|
+
/** Get the cached App Check token, or null if not available / expired. */
|
|
374
|
+
getToken(): string | null;
|
|
375
|
+
/** Whether App Check is active (token cached and not expired). */
|
|
376
|
+
get isActive(): boolean;
|
|
377
|
+
/** Set a cached App Check token manually (e.g. after attest flow). */
|
|
378
|
+
setCachedToken(token: string, expiresInMs: number): void;
|
|
379
|
+
/** Clean up timers and cached state. */
|
|
380
|
+
dispose(): void;
|
|
381
|
+
private scheduleRefresh;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** Reserved for future user-scope options. Admin surface is in @palbase/server. */
|
|
385
|
+
type AuthClientOptions = Record<string, never>;
|
|
386
|
+
declare class AuthClient {
|
|
387
|
+
private readonly httpClient;
|
|
388
|
+
private readonly tokenManager;
|
|
389
|
+
private readonly apiKey;
|
|
390
|
+
private readonly baseUrl;
|
|
391
|
+
private currentSession;
|
|
392
|
+
private hasSession;
|
|
393
|
+
private _mfa;
|
|
394
|
+
/** Device attestation */
|
|
395
|
+
readonly device: DeviceClient;
|
|
396
|
+
constructor(httpClient: HttpClient, tokenManager: TokenManager, apiKey?: string, baseUrl?: string, _options?: AuthClientOptions);
|
|
397
|
+
signUp(credentials: SignUpCredentials): Promise<PalbaseResponse<{
|
|
398
|
+
user: User;
|
|
399
|
+
session: Session;
|
|
400
|
+
}>>;
|
|
401
|
+
signIn(credentials: SignInCredentials): Promise<PalbaseResponse<{
|
|
402
|
+
user: User;
|
|
403
|
+
session: Session;
|
|
404
|
+
}>>;
|
|
405
|
+
signOut(): Promise<PalbaseResponse<void>>;
|
|
406
|
+
verifyEmail(params: VerifyEmailParams): Promise<PalbaseResponse<{
|
|
407
|
+
status: string;
|
|
408
|
+
}>>;
|
|
409
|
+
resendVerification(email: string): Promise<PalbaseResponse<{
|
|
410
|
+
verification_token?: string;
|
|
411
|
+
verification_code?: string;
|
|
412
|
+
}>>;
|
|
413
|
+
requestPasswordReset(params: PasswordResetParams): Promise<PalbaseResponse<{
|
|
414
|
+
success: boolean;
|
|
415
|
+
}>>;
|
|
416
|
+
confirmPasswordReset(params: PasswordResetConfirmParams): Promise<PalbaseResponse<{
|
|
417
|
+
success: boolean;
|
|
418
|
+
}>>;
|
|
419
|
+
changePassword(params: PasswordChangeParams): Promise<PalbaseResponse<{
|
|
420
|
+
success: boolean;
|
|
421
|
+
}>>;
|
|
422
|
+
refresh(): Promise<PalbaseResponse<TokenResponse>>;
|
|
423
|
+
getAccessToken(): string | null;
|
|
424
|
+
onTokenChange(callback: (tokens: {
|
|
425
|
+
accessToken: string | null;
|
|
426
|
+
refreshToken: string | null;
|
|
427
|
+
}) => void): () => void;
|
|
428
|
+
setTokens(accessToken: string, refreshToken: string, expiresIn?: number): void;
|
|
429
|
+
listSessions(): Promise<PalbaseResponse<AuthSession[]>>;
|
|
430
|
+
revokeSession(sessionId: string): Promise<PalbaseResponse<void>>;
|
|
431
|
+
revokeAllSessions(): Promise<PalbaseResponse<void>>;
|
|
432
|
+
get mfa(): {
|
|
433
|
+
enroll: (params: MFAEnrollParams) => Promise<PalbaseResponse<MFAEnrollResult>>;
|
|
434
|
+
verifyEnrollment: (code: string) => Promise<PalbaseResponse<{
|
|
435
|
+
status: string;
|
|
436
|
+
}>>;
|
|
437
|
+
challenge: (params: MFAChallengeParams) => Promise<PalbaseResponse<TokenResponse>>;
|
|
438
|
+
recovery: (params: MFARecoveryParams) => Promise<PalbaseResponse<TokenResponse>>;
|
|
439
|
+
listFactors: () => Promise<PalbaseResponse<{
|
|
440
|
+
factors: MFAFactor[];
|
|
441
|
+
}>>;
|
|
442
|
+
removeFactor: (factorId: string, currentPassword: string) => Promise<PalbaseResponse<{
|
|
443
|
+
status: string;
|
|
444
|
+
}>>;
|
|
445
|
+
regenerateRecoveryCodes: () => Promise<PalbaseResponse<{
|
|
446
|
+
recovery_codes: string[];
|
|
447
|
+
}>>;
|
|
448
|
+
emailEnroll: () => Promise<PalbaseResponse<{
|
|
449
|
+
status: string;
|
|
450
|
+
}>>;
|
|
451
|
+
emailChallenge: (params: MFAEmailChallengeParams) => Promise<PalbaseResponse<{
|
|
452
|
+
status: string;
|
|
453
|
+
}>>;
|
|
454
|
+
emailVerify: (params: MFAEmailVerifyParams) => Promise<PalbaseResponse<TokenResponse>>;
|
|
455
|
+
};
|
|
456
|
+
private buildMfa;
|
|
457
|
+
getOAuthURL(options: OAuthOptions): Promise<PalbaseResponse<{
|
|
458
|
+
url: string;
|
|
459
|
+
}>>;
|
|
460
|
+
signInWithCredential(params: CredentialExchangeParams): Promise<PalbaseResponse<{
|
|
461
|
+
user: User;
|
|
462
|
+
session: Session;
|
|
463
|
+
}>>;
|
|
464
|
+
listIdentities(): Promise<PalbaseResponse<{
|
|
465
|
+
identities: Identity[];
|
|
466
|
+
}>>;
|
|
467
|
+
linkIdentity(params: LinkIdentityParams): Promise<PalbaseResponse<{
|
|
468
|
+
success: boolean;
|
|
469
|
+
}>>;
|
|
470
|
+
unlinkIdentity(identityId: string): Promise<PalbaseResponse<{
|
|
471
|
+
success: boolean;
|
|
472
|
+
}>>;
|
|
473
|
+
requestMagicLink(params: MagicLinkParams): Promise<PalbaseResponse<{
|
|
474
|
+
success: boolean;
|
|
475
|
+
}>>;
|
|
476
|
+
verifyMagicLink(params: MagicLinkVerifyParams): Promise<PalbaseResponse<{
|
|
477
|
+
user: User;
|
|
478
|
+
session: Session;
|
|
479
|
+
}>>;
|
|
480
|
+
listTrustedDevices(): Promise<PalbaseResponse<{
|
|
481
|
+
trusted_devices: TrustedDevice[];
|
|
482
|
+
}>>;
|
|
483
|
+
registerTrustedDevice(params: RegisterTrustedDeviceParams): Promise<PalbaseResponse<{
|
|
484
|
+
trusted_device_token: string;
|
|
485
|
+
}>>;
|
|
486
|
+
revokeTrustedDevice(deviceId: string): Promise<PalbaseResponse<{
|
|
487
|
+
success: boolean;
|
|
488
|
+
}>>;
|
|
489
|
+
getSession(): {
|
|
490
|
+
data: Session | null;
|
|
491
|
+
error: null;
|
|
492
|
+
};
|
|
493
|
+
onAuthStateChange(callback: AuthStateChangeCallback): {
|
|
494
|
+
data: {
|
|
495
|
+
subscription: {
|
|
496
|
+
unsubscribe: () => void;
|
|
497
|
+
};
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
/**
|
|
501
|
+
* Verify a user's JWT token by calling GET /auth/user with their token.
|
|
502
|
+
* Server-only — should NOT be exposed in client SDK.
|
|
503
|
+
*/
|
|
504
|
+
verifyUserToken(jwt: string): Promise<PalbaseResponse<User>>;
|
|
505
|
+
private setSessionAndWireRefresh;
|
|
506
|
+
}
|
|
5
507
|
|
|
6
508
|
interface PalbeOAuthConfig {
|
|
7
509
|
google?: {
|
|
@@ -26,7 +528,7 @@ interface PalbeConfig {
|
|
|
26
528
|
}
|
|
27
529
|
|
|
28
530
|
/** Frozen view of all cached flag values (what `all()` returns / `changes()` yields). */
|
|
29
|
-
type FlagsView = Readonly<Record<string,
|
|
531
|
+
type FlagsView = Readonly<Record<string, F>>;
|
|
30
532
|
/**
|
|
31
533
|
* `pb.flags` — iOS-parity facade over `FlagsPool` (cache + delta polling +
|
|
32
534
|
* auth binding) and `FlagsClient` (stateless transport).
|
|
@@ -53,7 +555,7 @@ declare class PalbeFlags {
|
|
|
53
555
|
/** Frozen snapshot of all cached values (identity-stable until a change). */
|
|
54
556
|
all(): FlagsView;
|
|
55
557
|
/** Raw cached value for `key`, or `undefined` when not in the cache. */
|
|
56
|
-
get(key: string):
|
|
558
|
+
get(key: string): F | undefined;
|
|
57
559
|
/** `true` only when the cached value is strictly `true`; `fallback` when the key is absent. */
|
|
58
560
|
isEnabled(key: string, fallback?: boolean): boolean;
|
|
59
561
|
/** Alias of {@link isEnabled} (iOS parity). */
|
|
@@ -83,7 +585,7 @@ declare class PalbeFlags {
|
|
|
83
585
|
* (per {@link sameFlagValue} — structural compare for objects), with the
|
|
84
586
|
* new value (`undefined` = deleted). P5 React-hook substrate.
|
|
85
587
|
*/
|
|
86
|
-
subscribeKey(key: string, callback: (value:
|
|
588
|
+
subscribeKey(key: string, callback: (value: F | undefined) => void): Unsubscribe;
|
|
87
589
|
/**
|
|
88
590
|
* Async iteration over flag changes: yields the new {@link all} view on
|
|
89
591
|
* every pool change notification. The listener is detached when the
|
|
@@ -193,8 +695,8 @@ declare class PalbeRealtime {
|
|
|
193
695
|
|
|
194
696
|
interface PalbeRuntime {
|
|
195
697
|
config: PalbeConfig;
|
|
196
|
-
http: HttpClient;
|
|
197
|
-
tokenManager: TokenManager;
|
|
698
|
+
http: HttpClient$1;
|
|
699
|
+
tokenManager: TokenManager$1;
|
|
198
700
|
authClient: AuthClient;
|
|
199
701
|
auth: PalbeAuth;
|
|
200
702
|
flags: PalbeFlags;
|
|
@@ -233,7 +735,7 @@ interface AuthUser {
|
|
|
233
735
|
}
|
|
234
736
|
interface AuthSuccess {
|
|
235
737
|
user: AuthUser;
|
|
236
|
-
session: Session;
|
|
738
|
+
session: Session$1;
|
|
237
739
|
}
|
|
238
740
|
type AuthState = {
|
|
239
741
|
status: 'signedIn';
|