@capgo/capacitor-supabase 8.0.4

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/README.md ADDED
@@ -0,0 +1,801 @@
1
+ # @capgo/capacitor-supabase
2
+
3
+ Native Supabase SDK integration for Capacitor - Auth, Database, and JWT access.
4
+
5
+ This plugin provides native iOS and Android Supabase SDK functionality with the ability to retrieve JWT tokens for use in JavaScript/web layers.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @capgo/capacitor-supabase
11
+ npx cap sync
12
+ ```
13
+
14
+ ## iOS Setup
15
+
16
+ No additional setup required. The plugin uses Swift Package Manager to include the Supabase Swift SDK.
17
+
18
+ ## Android Setup
19
+
20
+ The plugin requires a minimum SDK of 26 (Android 8.0). Make sure your `android/variables.gradle` has:
21
+
22
+ ```gradle
23
+ minSdkVersion = 26
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ ### Initialize the Client
29
+
30
+ ```typescript
31
+ import { CapacitorSupabase } from '@capgo/capacitor-supabase';
32
+
33
+ await CapacitorSupabase.initialize({
34
+ supabaseUrl: 'https://your-project.supabase.co',
35
+ supabaseKey: 'your-anon-key'
36
+ });
37
+ ```
38
+
39
+ ### Authentication
40
+
41
+ #### Sign In with Email/Password
42
+
43
+ ```typescript
44
+ const { session, user } = await CapacitorSupabase.signInWithPassword({
45
+ email: 'user@example.com',
46
+ password: 'password123'
47
+ });
48
+
49
+ // Access the JWT token
50
+ console.log('JWT:', session?.accessToken);
51
+ ```
52
+
53
+ #### Sign Up
54
+
55
+ ```typescript
56
+ const { session, user } = await CapacitorSupabase.signUp({
57
+ email: 'newuser@example.com',
58
+ password: 'password123',
59
+ data: { name: 'John Doe' }
60
+ });
61
+ ```
62
+
63
+ #### OAuth Sign In
64
+
65
+ ```typescript
66
+ await CapacitorSupabase.signInWithOAuth({
67
+ provider: 'google',
68
+ redirectTo: 'myapp://callback'
69
+ });
70
+ ```
71
+
72
+ #### OTP Sign In
73
+
74
+ ```typescript
75
+ // Send OTP
76
+ await CapacitorSupabase.signInWithOtp({
77
+ email: 'user@example.com'
78
+ });
79
+
80
+ // Verify OTP
81
+ const { session, user } = await CapacitorSupabase.verifyOtp({
82
+ email: 'user@example.com',
83
+ token: '123456',
84
+ type: 'email'
85
+ });
86
+ ```
87
+
88
+ #### Sign Out
89
+
90
+ ```typescript
91
+ await CapacitorSupabase.signOut();
92
+ ```
93
+
94
+ ### Session Management
95
+
96
+ #### Get Current Session
97
+
98
+ ```typescript
99
+ const { session } = await CapacitorSupabase.getSession();
100
+ if (session) {
101
+ console.log('JWT:', session.accessToken);
102
+ console.log('Refresh Token:', session.refreshToken);
103
+ console.log('Expires At:', session.expiresAt);
104
+ }
105
+ ```
106
+
107
+ #### Refresh Session
108
+
109
+ ```typescript
110
+ const { session } = await CapacitorSupabase.refreshSession();
111
+ ```
112
+
113
+ #### Get Current User
114
+
115
+ ```typescript
116
+ const { user } = await CapacitorSupabase.getUser();
117
+ if (user) {
118
+ console.log('User ID:', user.id);
119
+ console.log('Email:', user.email);
120
+ }
121
+ ```
122
+
123
+ #### Set Session Manually
124
+
125
+ ```typescript
126
+ const { session } = await CapacitorSupabase.setSession({
127
+ accessToken: 'eyJ...',
128
+ refreshToken: 'abc123'
129
+ });
130
+ ```
131
+
132
+ ### Listen to Auth State Changes
133
+
134
+ ```typescript
135
+ const listener = await CapacitorSupabase.addListener(
136
+ 'authStateChange',
137
+ ({ event, session }) => {
138
+ console.log('Auth event:', event);
139
+ // Events: INITIAL_SESSION, SIGNED_IN, SIGNED_OUT, TOKEN_REFRESHED, USER_UPDATED
140
+ if (session) {
141
+ console.log('JWT:', session.accessToken);
142
+ }
143
+ }
144
+ );
145
+
146
+ // Later, remove the listener
147
+ listener.remove();
148
+ ```
149
+
150
+ ### Using JWT with @supabase/supabase-js
151
+
152
+ The main use case is to get the JWT from native auth and use it with the JavaScript Supabase client:
153
+
154
+ ```typescript
155
+ import { createClient } from '@supabase/supabase-js';
156
+ import { CapacitorSupabase } from '@capgo/capacitor-supabase';
157
+
158
+ // Initialize native client
159
+ await CapacitorSupabase.initialize({
160
+ supabaseUrl: 'https://your-project.supabase.co',
161
+ supabaseKey: 'your-anon-key'
162
+ });
163
+
164
+ // Sign in natively
165
+ await CapacitorSupabase.signInWithPassword({
166
+ email: 'user@example.com',
167
+ password: 'password'
168
+ });
169
+
170
+ // Get session with JWT
171
+ const { session } = await CapacitorSupabase.getSession();
172
+
173
+ // Create JS client with the native session
174
+ const supabase = createClient(
175
+ 'https://your-project.supabase.co',
176
+ 'your-anon-key',
177
+ {
178
+ global: {
179
+ headers: {
180
+ Authorization: `Bearer ${session?.accessToken}`
181
+ }
182
+ }
183
+ }
184
+ );
185
+
186
+ // Now use supabase-js as normal
187
+ const { data } = await supabase.from('table').select('*');
188
+ ```
189
+
190
+ ### Database Operations (Native)
191
+
192
+ The plugin also supports native database operations:
193
+
194
+ #### Select
195
+
196
+ ```typescript
197
+ const { data, error } = await CapacitorSupabase.select({
198
+ table: 'users',
199
+ columns: 'id, name, email',
200
+ filter: { active: true },
201
+ limit: 10,
202
+ orderBy: 'created_at',
203
+ ascending: false
204
+ });
205
+ ```
206
+
207
+ #### Insert
208
+
209
+ ```typescript
210
+ const { data, error } = await CapacitorSupabase.insert({
211
+ table: 'posts',
212
+ values: { title: 'Hello', content: 'World' }
213
+ });
214
+ ```
215
+
216
+ #### Update
217
+
218
+ ```typescript
219
+ const { data, error } = await CapacitorSupabase.update({
220
+ table: 'posts',
221
+ values: { title: 'Updated Title' },
222
+ filter: { id: 1 }
223
+ });
224
+ ```
225
+
226
+ #### Delete
227
+
228
+ ```typescript
229
+ const { data, error } = await CapacitorSupabase.delete({
230
+ table: 'posts',
231
+ filter: { id: 1 }
232
+ });
233
+ ```
234
+
235
+ ## API
236
+
237
+ <docgen-index>
238
+
239
+ * [`initialize(...)`](#initialize)
240
+ * [`signInWithPassword(...)`](#signinwithpassword)
241
+ * [`signUp(...)`](#signup)
242
+ * [`signInWithOAuth(...)`](#signinwithoauth)
243
+ * [`signInWithOtp(...)`](#signinwithotp)
244
+ * [`verifyOtp(...)`](#verifyotp)
245
+ * [`signOut()`](#signout)
246
+ * [`getSession()`](#getsession)
247
+ * [`refreshSession()`](#refreshsession)
248
+ * [`getUser()`](#getuser)
249
+ * [`setSession(...)`](#setsession)
250
+ * [`addListener('authStateChange', ...)`](#addlistenerauthstatechange-)
251
+ * [`removeAllListeners()`](#removealllisteners)
252
+ * [`select(...)`](#select)
253
+ * [`insert(...)`](#insert)
254
+ * [`update(...)`](#update)
255
+ * [`delete(...)`](#delete)
256
+ * [`getPluginVersion()`](#getpluginversion)
257
+ * [Interfaces](#interfaces)
258
+ * [Type Aliases](#type-aliases)
259
+
260
+ </docgen-index>
261
+
262
+ <docgen-api>
263
+ <!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
264
+
265
+ Capacitor Supabase Plugin for native Supabase SDK integration.
266
+
267
+ This plugin provides native iOS and Android Supabase SDK functionality
268
+ with the ability to retrieve JWT tokens for use in JavaScript/web layers.
269
+
270
+ ### initialize(...)
271
+
272
+ ```typescript
273
+ initialize(options: SupabaseConfig) => Promise<void>
274
+ ```
275
+
276
+ Initialize the Supabase client with your project credentials.
277
+ Must be called before any other methods.
278
+
279
+ | Param | Type | Description |
280
+ | ------------- | --------------------------------------------------------- | ------------------------------------------------- |
281
+ | **`options`** | <code><a href="#supabaseconfig">SupabaseConfig</a></code> | - Configuration options including URL and API key |
282
+
283
+ **Since:** 0.0.1
284
+
285
+ --------------------
286
+
287
+
288
+ ### signInWithPassword(...)
289
+
290
+ ```typescript
291
+ signInWithPassword(options: SignInWithPasswordOptions) => Promise<AuthResult>
292
+ ```
293
+
294
+ Sign in with email and password.
295
+
296
+ | Param | Type | Description |
297
+ | ------------- | ------------------------------------------------------------------------------- | -------------------------------- |
298
+ | **`options`** | <code><a href="#signinwithpasswordoptions">SignInWithPasswordOptions</a></code> | - Email and password credentials |
299
+
300
+ **Returns:** <code>Promise&lt;<a href="#authresult">AuthResult</a>&gt;</code>
301
+
302
+ **Since:** 0.0.1
303
+
304
+ --------------------
305
+
306
+
307
+ ### signUp(...)
308
+
309
+ ```typescript
310
+ signUp(options: SignUpOptions) => Promise<AuthResult>
311
+ ```
312
+
313
+ Sign up a new user with email and password.
314
+
315
+ | Param | Type | Description |
316
+ | ------------- | ------------------------------------------------------- | --------------------------------------------- |
317
+ | **`options`** | <code><a href="#signupoptions">SignUpOptions</a></code> | - Email, password, and optional user metadata |
318
+
319
+ **Returns:** <code>Promise&lt;<a href="#authresult">AuthResult</a>&gt;</code>
320
+
321
+ **Since:** 0.0.1
322
+
323
+ --------------------
324
+
325
+
326
+ ### signInWithOAuth(...)
327
+
328
+ ```typescript
329
+ signInWithOAuth(options: SignInWithOAuthOptions) => Promise<void>
330
+ ```
331
+
332
+ Sign in with an OAuth provider.
333
+ Opens the provider's authentication page.
334
+
335
+ | Param | Type | Description |
336
+ | ------------- | ------------------------------------------------------------------------- | ------------------------------------------ |
337
+ | **`options`** | <code><a href="#signinwithoauthoptions">SignInWithOAuthOptions</a></code> | - OAuth provider and optional redirect URL |
338
+
339
+ **Since:** 0.0.1
340
+
341
+ --------------------
342
+
343
+
344
+ ### signInWithOtp(...)
345
+
346
+ ```typescript
347
+ signInWithOtp(options: SignInWithOtpOptions) => Promise<void>
348
+ ```
349
+
350
+ Sign in with OTP (One-Time Password) sent via email or SMS.
351
+
352
+ | Param | Type | Description |
353
+ | ------------- | --------------------------------------------------------------------- | -------------------------------------- |
354
+ | **`options`** | <code><a href="#signinwithotpoptions">SignInWithOtpOptions</a></code> | - Email or phone number to send OTP to |
355
+
356
+ **Since:** 0.0.1
357
+
358
+ --------------------
359
+
360
+
361
+ ### verifyOtp(...)
362
+
363
+ ```typescript
364
+ verifyOtp(options: VerifyOtpOptions) => Promise<AuthResult>
365
+ ```
366
+
367
+ Verify an OTP token.
368
+
369
+ | Param | Type | Description |
370
+ | ------------- | ------------------------------------------------------------- | ------------------------------------------- |
371
+ | **`options`** | <code><a href="#verifyotpoptions">VerifyOtpOptions</a></code> | - Email/phone, token, and verification type |
372
+
373
+ **Returns:** <code>Promise&lt;<a href="#authresult">AuthResult</a>&gt;</code>
374
+
375
+ **Since:** 0.0.1
376
+
377
+ --------------------
378
+
379
+
380
+ ### signOut()
381
+
382
+ ```typescript
383
+ signOut() => Promise<void>
384
+ ```
385
+
386
+ Sign out the current user.
387
+
388
+ **Since:** 0.0.1
389
+
390
+ --------------------
391
+
392
+
393
+ ### getSession()
394
+
395
+ ```typescript
396
+ getSession() => Promise<{ session: Session | null; }>
397
+ ```
398
+
399
+ Get the current session if one exists.
400
+ Returns the session with JWT access token.
401
+
402
+ **Returns:** <code>Promise&lt;{ session: <a href="#session">Session</a> | null; }&gt;</code>
403
+
404
+ **Since:** 0.0.1
405
+
406
+ --------------------
407
+
408
+
409
+ ### refreshSession()
410
+
411
+ ```typescript
412
+ refreshSession() => Promise<{ session: Session | null; }>
413
+ ```
414
+
415
+ Refresh the current session and get new tokens.
416
+
417
+ **Returns:** <code>Promise&lt;{ session: <a href="#session">Session</a> | null; }&gt;</code>
418
+
419
+ **Since:** 0.0.1
420
+
421
+ --------------------
422
+
423
+
424
+ ### getUser()
425
+
426
+ ```typescript
427
+ getUser() => Promise<{ user: User | null; }>
428
+ ```
429
+
430
+ Get the currently authenticated user.
431
+
432
+ **Returns:** <code>Promise&lt;{ user: <a href="#user">User</a> | null; }&gt;</code>
433
+
434
+ **Since:** 0.0.1
435
+
436
+ --------------------
437
+
438
+
439
+ ### setSession(...)
440
+
441
+ ```typescript
442
+ setSession(options: SetSessionOptions) => Promise<{ session: Session | null; }>
443
+ ```
444
+
445
+ Set the session manually with access and refresh tokens.
446
+ Useful for restoring a session or integrating with external auth.
447
+
448
+ | Param | Type | Description |
449
+ | ------------- | --------------------------------------------------------------- | --------------------------- |
450
+ | **`options`** | <code><a href="#setsessionoptions">SetSessionOptions</a></code> | - Access and refresh tokens |
451
+
452
+ **Returns:** <code>Promise&lt;{ session: <a href="#session">Session</a> | null; }&gt;</code>
453
+
454
+ **Since:** 0.0.1
455
+
456
+ --------------------
457
+
458
+
459
+ ### addListener('authStateChange', ...)
460
+
461
+ ```typescript
462
+ addListener(eventName: 'authStateChange', listenerFunc: (data: AuthStateChange) => void) => Promise<PluginListenerHandle>
463
+ ```
464
+
465
+ Listen to authentication state changes.
466
+
467
+ | Param | Type | Description |
468
+ | ------------------ | ------------------------------------------------------------------------------ | ------------------------------------------ |
469
+ | **`eventName`** | <code>'authStateChange'</code> | - Must be 'authStateChange' |
470
+ | **`listenerFunc`** | <code>(data: <a href="#authstatechange">AuthStateChange</a>) =&gt; void</code> | - Callback function for auth state changes |
471
+
472
+ **Returns:** <code>Promise&lt;<a href="#pluginlistenerhandle">PluginListenerHandle</a>&gt;</code>
473
+
474
+ **Since:** 0.0.1
475
+
476
+ --------------------
477
+
478
+
479
+ ### removeAllListeners()
480
+
481
+ ```typescript
482
+ removeAllListeners() => Promise<void>
483
+ ```
484
+
485
+ Remove all listeners for auth state changes.
486
+
487
+ **Since:** 0.0.1
488
+
489
+ --------------------
490
+
491
+
492
+ ### select(...)
493
+
494
+ ```typescript
495
+ select<T = unknown>(options: SelectOptions) => Promise<QueryResult<T[]>>
496
+ ```
497
+
498
+ Execute a SELECT query on a table.
499
+
500
+ | Param | Type | Description |
501
+ | ------------- | ------------------------------------------------------- | ------------------------------------------------- |
502
+ | **`options`** | <code><a href="#selectoptions">SelectOptions</a></code> | - Query options including table, columns, filters |
503
+
504
+ **Returns:** <code>Promise&lt;<a href="#queryresult">QueryResult</a>&lt;T[]&gt;&gt;</code>
505
+
506
+ **Since:** 0.0.1
507
+
508
+ --------------------
509
+
510
+
511
+ ### insert(...)
512
+
513
+ ```typescript
514
+ insert<T = unknown>(options: InsertOptions) => Promise<QueryResult<T>>
515
+ ```
516
+
517
+ Insert data into a table.
518
+
519
+ | Param | Type | Description |
520
+ | ------------- | ------------------------------------------------------- | --------------------------------- |
521
+ | **`options`** | <code><a href="#insertoptions">InsertOptions</a></code> | - Table name and values to insert |
522
+
523
+ **Returns:** <code>Promise&lt;<a href="#queryresult">QueryResult</a>&lt;T&gt;&gt;</code>
524
+
525
+ **Since:** 0.0.1
526
+
527
+ --------------------
528
+
529
+
530
+ ### update(...)
531
+
532
+ ```typescript
533
+ update<T = unknown>(options: UpdateOptions) => Promise<QueryResult<T>>
534
+ ```
535
+
536
+ Update data in a table.
537
+
538
+ | Param | Type | Description |
539
+ | ------------- | ------------------------------------------------------- | ----------------------------------------------------- |
540
+ | **`options`** | <code><a href="#updateoptions">UpdateOptions</a></code> | - Table name, values to update, and filter conditions |
541
+
542
+ **Returns:** <code>Promise&lt;<a href="#queryresult">QueryResult</a>&lt;T&gt;&gt;</code>
543
+
544
+ **Since:** 0.0.1
545
+
546
+ --------------------
547
+
548
+
549
+ ### delete(...)
550
+
551
+ ```typescript
552
+ delete<T = unknown>(options: DeleteOptions) => Promise<QueryResult<T>>
553
+ ```
554
+
555
+ Delete data from a table.
556
+
557
+ | Param | Type | Description |
558
+ | ------------- | ------------------------------------------------------- | ---------------------------------- |
559
+ | **`options`** | <code><a href="#deleteoptions">DeleteOptions</a></code> | - Table name and filter conditions |
560
+
561
+ **Returns:** <code>Promise&lt;<a href="#queryresult">QueryResult</a>&lt;T&gt;&gt;</code>
562
+
563
+ **Since:** 0.0.1
564
+
565
+ --------------------
566
+
567
+
568
+ ### getPluginVersion()
569
+
570
+ ```typescript
571
+ getPluginVersion() => Promise<{ version: string; }>
572
+ ```
573
+
574
+ Get the native Capacitor plugin version.
575
+
576
+ **Returns:** <code>Promise&lt;{ version: string; }&gt;</code>
577
+
578
+ **Since:** 0.0.1
579
+
580
+ --------------------
581
+
582
+
583
+ ### Interfaces
584
+
585
+
586
+ #### SupabaseConfig
587
+
588
+ Configuration options for initializing the Supabase client.
589
+
590
+ | Prop | Type | Description | Since |
591
+ | ----------------- | ------------------- | ---------------------------------- | ----- |
592
+ | **`supabaseUrl`** | <code>string</code> | The Supabase project URL. | 0.0.1 |
593
+ | **`supabaseKey`** | <code>string</code> | The Supabase anonymous/public key. | 0.0.1 |
594
+
595
+
596
+ #### AuthResult
597
+
598
+ Result of authentication operations that return a session.
599
+
600
+ | Prop | Type | Description | Since |
601
+ | ------------- | --------------------------------------------------- | --------------------------------------------- | ----- |
602
+ | **`session`** | <code><a href="#session">Session</a> \| null</code> | The session if authentication was successful. | 0.0.1 |
603
+ | **`user`** | <code><a href="#user">User</a> \| null</code> | The authenticated user if successful. | 0.0.1 |
604
+
605
+
606
+ #### Session
607
+
608
+ <a href="#session">Session</a> object containing authentication tokens.
609
+
610
+ | Prop | Type | Description | Since |
611
+ | ------------------ | ------------------------------------- | -------------------------------------------------------------- | ----- |
612
+ | **`accessToken`** | <code>string</code> | The JWT access token. Use this for authenticated API requests. | 0.0.1 |
613
+ | **`refreshToken`** | <code>string</code> | The refresh token for obtaining new access tokens. | 0.0.1 |
614
+ | **`tokenType`** | <code>string</code> | Token type (usually "bearer"). | 0.0.1 |
615
+ | **`expiresIn`** | <code>number</code> | Number of seconds until the access token expires. | 0.0.1 |
616
+ | **`expiresAt`** | <code>number</code> | Unix timestamp when the token expires. | 0.0.1 |
617
+ | **`user`** | <code><a href="#user">User</a></code> | The authenticated user. | 0.0.1 |
618
+
619
+
620
+ #### User
621
+
622
+ <a href="#user">User</a> object returned from authentication operations.
623
+
624
+ | Prop | Type | Description | Since |
625
+ | ------------------ | ---------------------------------------------------------------- | -------------------------------------------------- | ----- |
626
+ | **`id`** | <code>string</code> | Unique identifier for the user. | 0.0.1 |
627
+ | **`email`** | <code>string</code> | <a href="#user">User</a>'s email address. | 0.0.1 |
628
+ | **`phone`** | <code>string</code> | <a href="#user">User</a>'s phone number. | 0.0.1 |
629
+ | **`createdAt`** | <code>string</code> | Timestamp when the user was created. | 0.0.1 |
630
+ | **`lastSignInAt`** | <code>string</code> | Timestamp when the user last signed in. | 0.0.1 |
631
+ | **`userMetadata`** | <code><a href="#record">Record</a>&lt;string, unknown&gt;</code> | <a href="#user">User</a> metadata (custom fields). | 0.0.1 |
632
+ | **`appMetadata`** | <code><a href="#record">Record</a>&lt;string, unknown&gt;</code> | App metadata. | 0.0.1 |
633
+
634
+
635
+ #### SignInWithPasswordOptions
636
+
637
+ Options for email/password sign-in.
638
+
639
+ | Prop | Type | Description | Since |
640
+ | -------------- | ------------------- | ----------------------------------------- | ----- |
641
+ | **`email`** | <code>string</code> | <a href="#user">User</a>'s email address. | 0.0.1 |
642
+ | **`password`** | <code>string</code> | <a href="#user">User</a>'s password. | 0.0.1 |
643
+
644
+
645
+ #### SignUpOptions
646
+
647
+ Options for email/password sign-up.
648
+
649
+ | Prop | Type | Description | Since |
650
+ | -------------- | ---------------------------------------------------------------- | ---------------------------------------------- | ----- |
651
+ | **`email`** | <code>string</code> | <a href="#user">User</a>'s email address. | 0.0.1 |
652
+ | **`password`** | <code>string</code> | <a href="#user">User</a>'s password. | 0.0.1 |
653
+ | **`data`** | <code><a href="#record">Record</a>&lt;string, unknown&gt;</code> | Optional user metadata to store with the user. | 0.0.1 |
654
+
655
+
656
+ #### SignInWithOAuthOptions
657
+
658
+ Options for OAuth sign-in.
659
+
660
+ | Prop | Type | Description | Since |
661
+ | ---------------- | ------------------------------------------------------- | ---------------------------------------- | ----- |
662
+ | **`provider`** | <code><a href="#oauthprovider">OAuthProvider</a></code> | The OAuth provider to use. | 0.0.1 |
663
+ | **`redirectTo`** | <code>string</code> | URL to redirect to after authentication. | 0.0.1 |
664
+ | **`scopes`** | <code>string</code> | OAuth scopes to request. | 0.0.1 |
665
+
666
+
667
+ #### SignInWithOtpOptions
668
+
669
+ Options for OTP sign-in.
670
+
671
+ | Prop | Type | Description | Since |
672
+ | ----------- | ------------------- | ----------------------------------------------------------------------------- | ----- |
673
+ | **`email`** | <code>string</code> | <a href="#user">User</a>'s email address (required if phone is not provided). | 0.0.1 |
674
+ | **`phone`** | <code>string</code> | <a href="#user">User</a>'s phone number (required if email is not provided). | 0.0.1 |
675
+
676
+
677
+ #### VerifyOtpOptions
678
+
679
+ Options for verifying OTP.
680
+
681
+ | Prop | Type | Description | Since |
682
+ | ----------- | ---------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----- |
683
+ | **`email`** | <code>string</code> | <a href="#user">User</a>'s email address (required if phone is not provided). | 0.0.1 |
684
+ | **`phone`** | <code>string</code> | <a href="#user">User</a>'s phone number (required if email is not provided). | 0.0.1 |
685
+ | **`token`** | <code>string</code> | The OTP token received via email/SMS. | 0.0.1 |
686
+ | **`type`** | <code>'sms' \| 'email' \| 'magiclink' \| 'signup' \| 'recovery'</code> | The type of OTP verification. | 0.0.1 |
687
+
688
+
689
+ #### SetSessionOptions
690
+
691
+ Options for setting a session manually.
692
+
693
+ | Prop | Type | Description | Since |
694
+ | ------------------ | ------------------- | ------------------ | ----- |
695
+ | **`accessToken`** | <code>string</code> | The access token. | 0.0.1 |
696
+ | **`refreshToken`** | <code>string</code> | The refresh token. | 0.0.1 |
697
+
698
+
699
+ #### PluginListenerHandle
700
+
701
+ | Prop | Type |
702
+ | ------------ | ----------------------------------------- |
703
+ | **`remove`** | <code>() =&gt; Promise&lt;void&gt;</code> |
704
+
705
+
706
+ #### AuthStateChange
707
+
708
+ Auth state change callback data.
709
+
710
+ | Prop | Type | Description | Since |
711
+ | ------------- | ----------------------------------------------------------- | ----------------------------------------- | ----- |
712
+ | **`event`** | <code><a href="#authchangeevent">AuthChangeEvent</a></code> | The type of auth event. | 0.0.1 |
713
+ | **`session`** | <code><a href="#session">Session</a> \| null</code> | The current session (null if signed out). | 0.0.1 |
714
+
715
+
716
+ #### QueryResult
717
+
718
+ Result of database queries.
719
+
720
+ | Prop | Type | Description | Since |
721
+ | ----------- | --------------------------- | --------------------------------------------------- | ----- |
722
+ | **`data`** | <code>T \| null</code> | The query result data. | 0.0.1 |
723
+ | **`error`** | <code>string \| null</code> | Error message if the query failed. | 0.0.1 |
724
+ | **`count`** | <code>number</code> | Number of affected rows (for insert/update/delete). | 0.0.1 |
725
+
726
+
727
+ #### SelectOptions
728
+
729
+ Options for database select queries.
730
+
731
+ | Prop | Type | Description | Since |
732
+ | --------------- | ---------------------------------------------------------------- | ---------------------------------------- | ----- |
733
+ | **`table`** | <code>string</code> | The table name to query. | 0.0.1 |
734
+ | **`columns`** | <code>string</code> | Columns to select (default: "*"). | 0.0.1 |
735
+ | **`filter`** | <code><a href="#record">Record</a>&lt;string, unknown&gt;</code> | Filter conditions as key-value pairs. | 0.0.1 |
736
+ | **`limit`** | <code>number</code> | Maximum number of rows to return. | 0.0.1 |
737
+ | **`offset`** | <code>number</code> | Number of rows to skip. | 0.0.1 |
738
+ | **`orderBy`** | <code>string</code> | Column to order by. | 0.0.1 |
739
+ | **`ascending`** | <code>boolean</code> | Order direction. | 0.0.1 |
740
+ | **`single`** | <code>boolean</code> | Return a single row instead of an array. | 0.0.1 |
741
+
742
+
743
+ #### InsertOptions
744
+
745
+ Options for database insert queries.
746
+
747
+ | Prop | Type | Description | Since |
748
+ | ------------ | ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------- | ----- |
749
+ | **`table`** | <code>string</code> | The table name to insert into. | 0.0.1 |
750
+ | **`values`** | <code><a href="#record">Record</a>&lt;string, unknown&gt; \| <a href="#record">Record</a>&lt;string, unknown&gt;[]</code> | The data to insert (single object or array of objects). | 0.0.1 |
751
+
752
+
753
+ #### UpdateOptions
754
+
755
+ Options for database update queries.
756
+
757
+ | Prop | Type | Description | Since |
758
+ | ------------ | ---------------------------------------------------------------- | ------------------------------------------ | ----- |
759
+ | **`table`** | <code>string</code> | The table name to update. | 0.0.1 |
760
+ | **`values`** | <code><a href="#record">Record</a>&lt;string, unknown&gt;</code> | The data to update. | 0.0.1 |
761
+ | **`filter`** | <code><a href="#record">Record</a>&lt;string, unknown&gt;</code> | Filter conditions to match rows to update. | 0.0.1 |
762
+
763
+
764
+ #### DeleteOptions
765
+
766
+ Options for database delete queries.
767
+
768
+ | Prop | Type | Description | Since |
769
+ | ------------ | ---------------------------------------------------------------- | ------------------------------------------ | ----- |
770
+ | **`table`** | <code>string</code> | The table name to delete from. | 0.0.1 |
771
+ | **`filter`** | <code><a href="#record">Record</a>&lt;string, unknown&gt;</code> | Filter conditions to match rows to delete. | 0.0.1 |
772
+
773
+
774
+ ### Type Aliases
775
+
776
+
777
+ #### Record
778
+
779
+ Construct a type with a set of properties K of type T
780
+
781
+ <code>{
782
  [P in K]: T;
1
783
  }</code>
784
+
785
+
786
+ #### OAuthProvider
787
+
788
+ Supported OAuth providers.
789
+
790
+ <code>'apple' | 'azure' | 'bitbucket' | 'discord' | 'facebook' | 'figma' | 'github' | 'gitlab' | 'google' | 'kakao' | 'keycloak' | 'linkedin' | 'linkedin_oidc' | 'notion' | 'slack' | 'slack_oidc' | 'spotify' | 'twitch' | 'twitter' | 'workos' | 'zoom'</code>
791
+
792
+
793
+ #### AuthChangeEvent
794
+
795
+ Auth state change event types.
796
+
797
+ <code>'INITIAL_SESSION' | 'SIGNED_IN' | 'SIGNED_OUT' | 'TOKEN_REFRESHED' | 'USER_UPDATED' | 'PASSWORD_RECOVERY'</code>
798
+
799
+ </docgen-api>
800
+
801
+ ## License
802
+
803
+ MPL-2.0