@supabase/auth-js 2.100.0 → 2.100.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/main/GoTrueAdminApi.d.ts +449 -0
- package/dist/main/GoTrueAdminApi.d.ts.map +1 -1
- package/dist/main/GoTrueAdminApi.js +449 -0
- package/dist/main/GoTrueAdminApi.js.map +1 -1
- package/dist/main/GoTrueClient.d.ts +1668 -63
- package/dist/main/GoTrueClient.d.ts.map +1 -1
- package/dist/main/GoTrueClient.js +1889 -70
- package/dist/main/GoTrueClient.js.map +1 -1
- package/dist/main/lib/types.d.ts +409 -0
- package/dist/main/lib/types.d.ts.map +1 -1
- package/dist/main/lib/types.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/module/GoTrueAdminApi.d.ts +449 -0
- package/dist/module/GoTrueAdminApi.d.ts.map +1 -1
- package/dist/module/GoTrueAdminApi.js +449 -0
- package/dist/module/GoTrueAdminApi.js.map +1 -1
- package/dist/module/GoTrueClient.d.ts +1668 -63
- package/dist/module/GoTrueClient.d.ts.map +1 -1
- package/dist/module/GoTrueClient.js +1889 -70
- package/dist/module/GoTrueClient.js.map +1 -1
- package/dist/module/lib/types.d.ts +409 -0
- package/dist/module/lib/types.d.ts.map +1 -1
- package/dist/module/lib/types.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/tsconfig.module.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/GoTrueAdminApi.ts +449 -0
- package/src/GoTrueClient.ts +1889 -70
- package/src/lib/types.ts +409 -0
- package/src/lib/version.ts +1 -1
package/src/GoTrueAdminApi.ts
CHANGED
|
@@ -106,6 +106,8 @@ export default class GoTrueAdminApi {
|
|
|
106
106
|
* Removes a logged-in session.
|
|
107
107
|
* @param jwt A valid, logged-in JWT.
|
|
108
108
|
* @param scope The logout sope.
|
|
109
|
+
*
|
|
110
|
+
* @category Auth
|
|
109
111
|
*/
|
|
110
112
|
async signOut(
|
|
111
113
|
jwt: string,
|
|
@@ -137,6 +139,64 @@ export default class GoTrueAdminApi {
|
|
|
137
139
|
* Sends an invite link to an email address.
|
|
138
140
|
* @param email The email address of the user.
|
|
139
141
|
* @param options Additional options to be included when inviting.
|
|
142
|
+
*
|
|
143
|
+
* @category Auth
|
|
144
|
+
*
|
|
145
|
+
* @remarks
|
|
146
|
+
* - Sends an invite link to the user's email address.
|
|
147
|
+
* - The `inviteUserByEmail()` method is typically used by administrators to invite users to join the application.
|
|
148
|
+
* - Note that PKCE is not supported when using `inviteUserByEmail`. This is because the browser initiating the invite is often different from the browser accepting the invite which makes it difficult to provide the security guarantees required of the PKCE flow.
|
|
149
|
+
*
|
|
150
|
+
* @example Invite a user
|
|
151
|
+
* ```js
|
|
152
|
+
* const { data, error } = await supabase.auth.admin.inviteUserByEmail('email@example.com')
|
|
153
|
+
* ```
|
|
154
|
+
*
|
|
155
|
+
* @exampleResponse Invite a user
|
|
156
|
+
* ```json
|
|
157
|
+
* {
|
|
158
|
+
* "data": {
|
|
159
|
+
* "user": {
|
|
160
|
+
* "id": "11111111-1111-1111-1111-111111111111",
|
|
161
|
+
* "aud": "authenticated",
|
|
162
|
+
* "role": "authenticated",
|
|
163
|
+
* "email": "example@email.com",
|
|
164
|
+
* "invited_at": "2024-01-01T00:00:00Z",
|
|
165
|
+
* "phone": "",
|
|
166
|
+
* "confirmation_sent_at": "2024-01-01T00:00:00Z",
|
|
167
|
+
* "app_metadata": {
|
|
168
|
+
* "provider": "email",
|
|
169
|
+
* "providers": [
|
|
170
|
+
* "email"
|
|
171
|
+
* ]
|
|
172
|
+
* },
|
|
173
|
+
* "user_metadata": {},
|
|
174
|
+
* "identities": [
|
|
175
|
+
* {
|
|
176
|
+
* "identity_id": "22222222-2222-2222-2222-222222222222",
|
|
177
|
+
* "id": "11111111-1111-1111-1111-111111111111",
|
|
178
|
+
* "user_id": "11111111-1111-1111-1111-111111111111",
|
|
179
|
+
* "identity_data": {
|
|
180
|
+
* "email": "example@email.com",
|
|
181
|
+
* "email_verified": false,
|
|
182
|
+
* "phone_verified": false,
|
|
183
|
+
* "sub": "11111111-1111-1111-1111-111111111111"
|
|
184
|
+
* },
|
|
185
|
+
* "provider": "email",
|
|
186
|
+
* "last_sign_in_at": "2024-01-01T00:00:00Z",
|
|
187
|
+
* "created_at": "2024-01-01T00:00:00Z",
|
|
188
|
+
* "updated_at": "2024-01-01T00:00:00Z",
|
|
189
|
+
* "email": "example@email.com"
|
|
190
|
+
* }
|
|
191
|
+
* ],
|
|
192
|
+
* "created_at": "2024-01-01T00:00:00Z",
|
|
193
|
+
* "updated_at": "2024-01-01T00:00:00Z",
|
|
194
|
+
* "is_anonymous": false
|
|
195
|
+
* }
|
|
196
|
+
* },
|
|
197
|
+
* "error": null
|
|
198
|
+
* }
|
|
199
|
+
* ```
|
|
140
200
|
*/
|
|
141
201
|
async inviteUserByEmail(
|
|
142
202
|
email: string,
|
|
@@ -170,6 +230,115 @@ export default class GoTrueAdminApi {
|
|
|
170
230
|
* @param options.password User password. For signup only.
|
|
171
231
|
* @param options.data Optional user metadata. For signup only.
|
|
172
232
|
* @param options.redirectTo The redirect url which should be appended to the generated link
|
|
233
|
+
*
|
|
234
|
+
* @category Auth
|
|
235
|
+
*
|
|
236
|
+
* @remarks
|
|
237
|
+
* - The following types can be passed into `generateLink()`: `signup`, `magiclink`, `invite`, `recovery`, `email_change_current`, `email_change_new`, `phone_change`.
|
|
238
|
+
* - `generateLink()` only generates the email link for `email_change_email` if the **Secure email change** is enabled in your project's [email auth provider settings](/dashboard/project/_/auth/providers).
|
|
239
|
+
* - `generateLink()` handles the creation of the user for `signup`, `invite` and `magiclink`.
|
|
240
|
+
*
|
|
241
|
+
* @example Generate a signup link
|
|
242
|
+
* ```js
|
|
243
|
+
* const { data, error } = await supabase.auth.admin.generateLink({
|
|
244
|
+
* type: 'signup',
|
|
245
|
+
* email: 'email@example.com',
|
|
246
|
+
* password: 'secret'
|
|
247
|
+
* })
|
|
248
|
+
* ```
|
|
249
|
+
*
|
|
250
|
+
* @exampleResponse Generate a signup link
|
|
251
|
+
* ```json
|
|
252
|
+
* {
|
|
253
|
+
* "data": {
|
|
254
|
+
* "properties": {
|
|
255
|
+
* "action_link": "<LINK_TO_SEND_TO_USER>",
|
|
256
|
+
* "email_otp": "999999",
|
|
257
|
+
* "hashed_token": "<HASHED_TOKEN",
|
|
258
|
+
* "redirect_to": "<REDIRECT_URL>",
|
|
259
|
+
* "verification_type": "signup"
|
|
260
|
+
* },
|
|
261
|
+
* "user": {
|
|
262
|
+
* "id": "11111111-1111-1111-1111-111111111111",
|
|
263
|
+
* "aud": "authenticated",
|
|
264
|
+
* "role": "authenticated",
|
|
265
|
+
* "email": "email@example.com",
|
|
266
|
+
* "phone": "",
|
|
267
|
+
* "confirmation_sent_at": "2024-01-01T00:00:00Z",
|
|
268
|
+
* "app_metadata": {
|
|
269
|
+
* "provider": "email",
|
|
270
|
+
* "providers": [
|
|
271
|
+
* "email"
|
|
272
|
+
* ]
|
|
273
|
+
* },
|
|
274
|
+
* "user_metadata": {},
|
|
275
|
+
* "identities": [
|
|
276
|
+
* {
|
|
277
|
+
* "identity_id": "22222222-2222-2222-2222-222222222222",
|
|
278
|
+
* "id": "11111111-1111-1111-1111-111111111111",
|
|
279
|
+
* "user_id": "11111111-1111-1111-1111-111111111111",
|
|
280
|
+
* "identity_data": {
|
|
281
|
+
* "email": "email@example.com",
|
|
282
|
+
* "email_verified": false,
|
|
283
|
+
* "phone_verified": false,
|
|
284
|
+
* "sub": "11111111-1111-1111-1111-111111111111"
|
|
285
|
+
* },
|
|
286
|
+
* "provider": "email",
|
|
287
|
+
* "last_sign_in_at": "2024-01-01T00:00:00Z",
|
|
288
|
+
* "created_at": "2024-01-01T00:00:00Z",
|
|
289
|
+
* "updated_at": "2024-01-01T00:00:00Z",
|
|
290
|
+
* "email": "email@example.com"
|
|
291
|
+
* }
|
|
292
|
+
* ],
|
|
293
|
+
* "created_at": "2024-01-01T00:00:00Z",
|
|
294
|
+
* "updated_at": "2024-01-01T00:00:00Z",
|
|
295
|
+
* "is_anonymous": false
|
|
296
|
+
* }
|
|
297
|
+
* },
|
|
298
|
+
* "error": null
|
|
299
|
+
* }
|
|
300
|
+
* ```
|
|
301
|
+
*
|
|
302
|
+
* @example Generate an invite link
|
|
303
|
+
* ```js
|
|
304
|
+
* const { data, error } = await supabase.auth.admin.generateLink({
|
|
305
|
+
* type: 'invite',
|
|
306
|
+
* email: 'email@example.com'
|
|
307
|
+
* })
|
|
308
|
+
* ```
|
|
309
|
+
*
|
|
310
|
+
* @example Generate a magic link
|
|
311
|
+
* ```js
|
|
312
|
+
* const { data, error } = await supabase.auth.admin.generateLink({
|
|
313
|
+
* type: 'magiclink',
|
|
314
|
+
* email: 'email@example.com'
|
|
315
|
+
* })
|
|
316
|
+
* ```
|
|
317
|
+
*
|
|
318
|
+
* @example Generate a recovery link
|
|
319
|
+
* ```js
|
|
320
|
+
* const { data, error } = await supabase.auth.admin.generateLink({
|
|
321
|
+
* type: 'recovery',
|
|
322
|
+
* email: 'email@example.com'
|
|
323
|
+
* })
|
|
324
|
+
* ```
|
|
325
|
+
*
|
|
326
|
+
* @example Generate links to change current email address
|
|
327
|
+
* ```js
|
|
328
|
+
* // generate an email change link to be sent to the current email address
|
|
329
|
+
* const { data, error } = await supabase.auth.admin.generateLink({
|
|
330
|
+
* type: 'email_change_current',
|
|
331
|
+
* email: 'current.email@example.com',
|
|
332
|
+
* newEmail: 'new.email@example.com'
|
|
333
|
+
* })
|
|
334
|
+
*
|
|
335
|
+
* // generate an email change link to be sent to the new email address
|
|
336
|
+
* const { data, error } = await supabase.auth.admin.generateLink({
|
|
337
|
+
* type: 'email_change_new',
|
|
338
|
+
* email: 'current.email@example.com',
|
|
339
|
+
* newEmail: 'new.email@example.com'
|
|
340
|
+
* })
|
|
341
|
+
* ```
|
|
173
342
|
*/
|
|
174
343
|
async generateLink(params: GenerateLinkParams): Promise<GenerateLinkResponse> {
|
|
175
344
|
try {
|
|
@@ -204,6 +373,81 @@ export default class GoTrueAdminApi {
|
|
|
204
373
|
/**
|
|
205
374
|
* Creates a new user.
|
|
206
375
|
* This function should only be called on a server. Never expose your `service_role` key in the browser.
|
|
376
|
+
*
|
|
377
|
+
* @category Auth
|
|
378
|
+
*
|
|
379
|
+
* @remarks
|
|
380
|
+
* - To confirm the user's email address or phone number, set `email_confirm` or `phone_confirm` to true. Both arguments default to false.
|
|
381
|
+
* - `createUser()` will not send a confirmation email to the user. You can use [`inviteUserByEmail()`](/docs/reference/javascript/auth-admin-inviteuserbyemail) if you want to send them an email invite instead.
|
|
382
|
+
* - If you are sure that the created user's email or phone number is legitimate and verified, you can set the `email_confirm` or `phone_confirm` param to `true`.
|
|
383
|
+
*
|
|
384
|
+
* @example With custom user metadata
|
|
385
|
+
* ```js
|
|
386
|
+
* const { data, error } = await supabase.auth.admin.createUser({
|
|
387
|
+
* email: 'user@email.com',
|
|
388
|
+
* password: 'password',
|
|
389
|
+
* user_metadata: { name: 'Yoda' }
|
|
390
|
+
* })
|
|
391
|
+
* ```
|
|
392
|
+
*
|
|
393
|
+
* @exampleResponse With custom user metadata
|
|
394
|
+
* ```json
|
|
395
|
+
* {
|
|
396
|
+
* data: {
|
|
397
|
+
* user: {
|
|
398
|
+
* id: '1',
|
|
399
|
+
* aud: 'authenticated',
|
|
400
|
+
* role: 'authenticated',
|
|
401
|
+
* email: 'example@email.com',
|
|
402
|
+
* email_confirmed_at: '2024-01-01T00:00:00Z',
|
|
403
|
+
* phone: '',
|
|
404
|
+
* confirmation_sent_at: '2024-01-01T00:00:00Z',
|
|
405
|
+
* confirmed_at: '2024-01-01T00:00:00Z',
|
|
406
|
+
* last_sign_in_at: '2024-01-01T00:00:00Z',
|
|
407
|
+
* app_metadata: {},
|
|
408
|
+
* user_metadata: {},
|
|
409
|
+
* identities: [
|
|
410
|
+
* {
|
|
411
|
+
* "identity_id": "22222222-2222-2222-2222-222222222222",
|
|
412
|
+
* "id": "1",
|
|
413
|
+
* "user_id": "1",
|
|
414
|
+
* "identity_data": {
|
|
415
|
+
* "email": "example@email.com",
|
|
416
|
+
* "email_verified": true,
|
|
417
|
+
* "phone_verified": false,
|
|
418
|
+
* "sub": "1"
|
|
419
|
+
* },
|
|
420
|
+
* "provider": "email",
|
|
421
|
+
* "last_sign_in_at": "2024-01-01T00:00:00Z",
|
|
422
|
+
* "created_at": "2024-01-01T00:00:00Z",
|
|
423
|
+
* "updated_at": "2024-01-01T00:00:00Z",
|
|
424
|
+
* "email": "email@example.com"
|
|
425
|
+
* },
|
|
426
|
+
* ],
|
|
427
|
+
* created_at: '2024-01-01T00:00:00Z',
|
|
428
|
+
* updated_at: '2024-01-01T00:00:00Z',
|
|
429
|
+
* is_anonymous: false,
|
|
430
|
+
* }
|
|
431
|
+
* }
|
|
432
|
+
* error: null
|
|
433
|
+
* }
|
|
434
|
+
* ```
|
|
435
|
+
*
|
|
436
|
+
* @example Auto-confirm the user's email
|
|
437
|
+
* ```js
|
|
438
|
+
* const { data, error } = await supabase.auth.admin.createUser({
|
|
439
|
+
* email: 'user@email.com',
|
|
440
|
+
* email_confirm: true
|
|
441
|
+
* })
|
|
442
|
+
* ```
|
|
443
|
+
*
|
|
444
|
+
* @example Auto-confirm the user's phone number
|
|
445
|
+
* ```js
|
|
446
|
+
* const { data, error } = await supabase.auth.admin.createUser({
|
|
447
|
+
* phone: '1234567890',
|
|
448
|
+
* phone_confirm: true
|
|
449
|
+
* })
|
|
450
|
+
* ```
|
|
207
451
|
*/
|
|
208
452
|
async createUser(attributes: AdminUserAttributes): Promise<UserResponse> {
|
|
209
453
|
try {
|
|
@@ -226,6 +470,24 @@ export default class GoTrueAdminApi {
|
|
|
226
470
|
*
|
|
227
471
|
* This function should only be called on a server. Never expose your `service_role` key in the browser.
|
|
228
472
|
* @param params An object which supports `page` and `perPage` as numbers, to alter the paginated results.
|
|
473
|
+
*
|
|
474
|
+
* @category Auth
|
|
475
|
+
*
|
|
476
|
+
* @remarks
|
|
477
|
+
* - Defaults to return 50 users per page.
|
|
478
|
+
*
|
|
479
|
+
* @example Get a page of users
|
|
480
|
+
* ```js
|
|
481
|
+
* const { data: { users }, error } = await supabase.auth.admin.listUsers()
|
|
482
|
+
* ```
|
|
483
|
+
*
|
|
484
|
+
* @example Paginated list of users
|
|
485
|
+
* ```js
|
|
486
|
+
* const { data: { users }, error } = await supabase.auth.admin.listUsers({
|
|
487
|
+
* page: 1,
|
|
488
|
+
* perPage: 1000
|
|
489
|
+
* })
|
|
490
|
+
* ```
|
|
229
491
|
*/
|
|
230
492
|
async listUsers(
|
|
231
493
|
params?: PageParams
|
|
@@ -273,6 +535,60 @@ export default class GoTrueAdminApi {
|
|
|
273
535
|
* @param uid The user's unique identifier
|
|
274
536
|
*
|
|
275
537
|
* This function should only be called on a server. Never expose your `service_role` key in the browser.
|
|
538
|
+
*
|
|
539
|
+
* @category Auth
|
|
540
|
+
*
|
|
541
|
+
* @remarks
|
|
542
|
+
* - Fetches the user object from the database based on the user's id.
|
|
543
|
+
* - The `getUserById()` method requires the user's id which maps to the `auth.users.id` column.
|
|
544
|
+
*
|
|
545
|
+
* @example Fetch the user object using the access_token jwt
|
|
546
|
+
* ```js
|
|
547
|
+
* const { data, error } = await supabase.auth.admin.getUserById(1)
|
|
548
|
+
* ```
|
|
549
|
+
*
|
|
550
|
+
* @exampleResponse Fetch the user object using the access_token jwt
|
|
551
|
+
* ```json
|
|
552
|
+
* {
|
|
553
|
+
* data: {
|
|
554
|
+
* user: {
|
|
555
|
+
* id: '1',
|
|
556
|
+
* aud: 'authenticated',
|
|
557
|
+
* role: 'authenticated',
|
|
558
|
+
* email: 'example@email.com',
|
|
559
|
+
* email_confirmed_at: '2024-01-01T00:00:00Z',
|
|
560
|
+
* phone: '',
|
|
561
|
+
* confirmation_sent_at: '2024-01-01T00:00:00Z',
|
|
562
|
+
* confirmed_at: '2024-01-01T00:00:00Z',
|
|
563
|
+
* last_sign_in_at: '2024-01-01T00:00:00Z',
|
|
564
|
+
* app_metadata: {},
|
|
565
|
+
* user_metadata: {},
|
|
566
|
+
* identities: [
|
|
567
|
+
* {
|
|
568
|
+
* "identity_id": "22222222-2222-2222-2222-222222222222",
|
|
569
|
+
* "id": "1",
|
|
570
|
+
* "user_id": "1",
|
|
571
|
+
* "identity_data": {
|
|
572
|
+
* "email": "example@email.com",
|
|
573
|
+
* "email_verified": true,
|
|
574
|
+
* "phone_verified": false,
|
|
575
|
+
* "sub": "1"
|
|
576
|
+
* },
|
|
577
|
+
* "provider": "email",
|
|
578
|
+
* "last_sign_in_at": "2024-01-01T00:00:00Z",
|
|
579
|
+
* "created_at": "2024-01-01T00:00:00Z",
|
|
580
|
+
* "updated_at": "2024-01-01T00:00:00Z",
|
|
581
|
+
* "email": "email@example.com"
|
|
582
|
+
* },
|
|
583
|
+
* ],
|
|
584
|
+
* created_at: '2024-01-01T00:00:00Z',
|
|
585
|
+
* updated_at: '2024-01-01T00:00:00Z',
|
|
586
|
+
* is_anonymous: false,
|
|
587
|
+
* }
|
|
588
|
+
* }
|
|
589
|
+
* error: null
|
|
590
|
+
* }
|
|
591
|
+
* ```
|
|
276
592
|
*/
|
|
277
593
|
async getUserById(uid: string): Promise<UserResponse> {
|
|
278
594
|
validateUUID(uid)
|
|
@@ -322,6 +638,117 @@ export default class GoTrueAdminApi {
|
|
|
322
638
|
*
|
|
323
639
|
* @see {@link GoTrueClient.refreshSession} for syncing admin changes to the client
|
|
324
640
|
* @see {@link GoTrueClient.updateUser} for client-side user updates (triggers listeners automatically)
|
|
641
|
+
*
|
|
642
|
+
* @category Auth
|
|
643
|
+
*
|
|
644
|
+
* @example Updates a user's email
|
|
645
|
+
* ```js
|
|
646
|
+
* const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
647
|
+
* '11111111-1111-1111-1111-111111111111',
|
|
648
|
+
* { email: 'new@email.com' }
|
|
649
|
+
* )
|
|
650
|
+
* ```
|
|
651
|
+
*
|
|
652
|
+
* @exampleResponse Updates a user's email
|
|
653
|
+
* ```json
|
|
654
|
+
* {
|
|
655
|
+
* "data": {
|
|
656
|
+
* "user": {
|
|
657
|
+
* "id": "11111111-1111-1111-1111-111111111111",
|
|
658
|
+
* "aud": "authenticated",
|
|
659
|
+
* "role": "authenticated",
|
|
660
|
+
* "email": "new@email.com",
|
|
661
|
+
* "email_confirmed_at": "2024-01-01T00:00:00Z",
|
|
662
|
+
* "phone": "",
|
|
663
|
+
* "confirmed_at": "2024-01-01T00:00:00Z",
|
|
664
|
+
* "recovery_sent_at": "2024-01-01T00:00:00Z",
|
|
665
|
+
* "last_sign_in_at": "2024-01-01T00:00:00Z",
|
|
666
|
+
* "app_metadata": {
|
|
667
|
+
* "provider": "email",
|
|
668
|
+
* "providers": [
|
|
669
|
+
* "email"
|
|
670
|
+
* ]
|
|
671
|
+
* },
|
|
672
|
+
* "user_metadata": {
|
|
673
|
+
* "email": "example@email.com",
|
|
674
|
+
* "email_verified": false,
|
|
675
|
+
* "phone_verified": false,
|
|
676
|
+
* "sub": "11111111-1111-1111-1111-111111111111"
|
|
677
|
+
* },
|
|
678
|
+
* "identities": [
|
|
679
|
+
* {
|
|
680
|
+
* "identity_id": "22222222-2222-2222-2222-222222222222",
|
|
681
|
+
* "id": "11111111-1111-1111-1111-111111111111",
|
|
682
|
+
* "user_id": "11111111-1111-1111-1111-111111111111",
|
|
683
|
+
* "identity_data": {
|
|
684
|
+
* "email": "example@email.com",
|
|
685
|
+
* "email_verified": false,
|
|
686
|
+
* "phone_verified": false,
|
|
687
|
+
* "sub": "11111111-1111-1111-1111-111111111111"
|
|
688
|
+
* },
|
|
689
|
+
* "provider": "email",
|
|
690
|
+
* "last_sign_in_at": "2024-01-01T00:00:00Z",
|
|
691
|
+
* "created_at": "2024-01-01T00:00:00Z",
|
|
692
|
+
* "updated_at": "2024-01-01T00:00:00Z",
|
|
693
|
+
* "email": "example@email.com"
|
|
694
|
+
* }
|
|
695
|
+
* ],
|
|
696
|
+
* "created_at": "2024-01-01T00:00:00Z",
|
|
697
|
+
* "updated_at": "2024-01-01T00:00:00Z",
|
|
698
|
+
* "is_anonymous": false
|
|
699
|
+
* }
|
|
700
|
+
* },
|
|
701
|
+
* "error": null
|
|
702
|
+
* }
|
|
703
|
+
* ```
|
|
704
|
+
*
|
|
705
|
+
* @example Updates a user's password
|
|
706
|
+
* ```js
|
|
707
|
+
* const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
708
|
+
* '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
|
|
709
|
+
* { password: 'new_password' }
|
|
710
|
+
* )
|
|
711
|
+
* ```
|
|
712
|
+
*
|
|
713
|
+
* @example Updates a user's metadata
|
|
714
|
+
* ```js
|
|
715
|
+
* const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
716
|
+
* '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
|
|
717
|
+
* { user_metadata: { hello: 'world' } }
|
|
718
|
+
* )
|
|
719
|
+
* ```
|
|
720
|
+
*
|
|
721
|
+
* @example Updates a user's app_metadata
|
|
722
|
+
* ```js
|
|
723
|
+
* const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
724
|
+
* '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
|
|
725
|
+
* { app_metadata: { plan: 'trial' } }
|
|
726
|
+
* )
|
|
727
|
+
* ```
|
|
728
|
+
*
|
|
729
|
+
* @example Confirms a user's email address
|
|
730
|
+
* ```js
|
|
731
|
+
* const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
732
|
+
* '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
|
|
733
|
+
* { email_confirm: true }
|
|
734
|
+
* )
|
|
735
|
+
* ```
|
|
736
|
+
*
|
|
737
|
+
* @example Confirms a user's phone number
|
|
738
|
+
* ```js
|
|
739
|
+
* const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
740
|
+
* '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
|
|
741
|
+
* { phone_confirm: true }
|
|
742
|
+
* )
|
|
743
|
+
* ```
|
|
744
|
+
*
|
|
745
|
+
* @example Ban a user for 100 years
|
|
746
|
+
* ```js
|
|
747
|
+
* const { data: user, error } = await supabase.auth.admin.updateUserById(
|
|
748
|
+
* '6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
|
|
749
|
+
* { ban_duration: '876000h' }
|
|
750
|
+
* )
|
|
751
|
+
* ```
|
|
325
752
|
*/
|
|
326
753
|
async updateUserById(uid: string, attributes: AdminUserAttributes): Promise<UserResponse> {
|
|
327
754
|
validateUUID(uid)
|
|
@@ -349,6 +776,28 @@ export default class GoTrueAdminApi {
|
|
|
349
776
|
* Defaults to false for backward compatibility.
|
|
350
777
|
*
|
|
351
778
|
* This function should only be called on a server. Never expose your `service_role` key in the browser.
|
|
779
|
+
*
|
|
780
|
+
* @category Auth
|
|
781
|
+
*
|
|
782
|
+
* @remarks
|
|
783
|
+
* - The `deleteUser()` method requires the user's ID, which maps to the `auth.users.id` column.
|
|
784
|
+
*
|
|
785
|
+
* @example Removes a user
|
|
786
|
+
* ```js
|
|
787
|
+
* const { data, error } = await supabase.auth.admin.deleteUser(
|
|
788
|
+
* '715ed5db-f090-4b8c-a067-640ecee36aa0'
|
|
789
|
+
* )
|
|
790
|
+
* ```
|
|
791
|
+
*
|
|
792
|
+
* @exampleResponse Removes a user
|
|
793
|
+
* ```json
|
|
794
|
+
* {
|
|
795
|
+
* "data": {
|
|
796
|
+
* "user": {}
|
|
797
|
+
* },
|
|
798
|
+
* "error": null
|
|
799
|
+
* }
|
|
800
|
+
* ```
|
|
352
801
|
*/
|
|
353
802
|
async deleteUser(id: string, shouldSoftDelete = false): Promise<UserResponse> {
|
|
354
803
|
validateUUID(id)
|