@supabase/auth-js 2.100.0 → 2.101.0-canary.0

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.
Files changed (37) hide show
  1. package/dist/main/GoTrueAdminApi.d.ts +449 -0
  2. package/dist/main/GoTrueAdminApi.d.ts.map +1 -1
  3. package/dist/main/GoTrueAdminApi.js +449 -0
  4. package/dist/main/GoTrueAdminApi.js.map +1 -1
  5. package/dist/main/GoTrueClient.d.ts +1668 -63
  6. package/dist/main/GoTrueClient.d.ts.map +1 -1
  7. package/dist/main/GoTrueClient.js +1889 -70
  8. package/dist/main/GoTrueClient.js.map +1 -1
  9. package/dist/main/lib/types.d.ts +409 -0
  10. package/dist/main/lib/types.d.ts.map +1 -1
  11. package/dist/main/lib/types.js.map +1 -1
  12. package/dist/main/lib/version.d.ts +1 -1
  13. package/dist/main/lib/version.d.ts.map +1 -1
  14. package/dist/main/lib/version.js +1 -1
  15. package/dist/main/lib/version.js.map +1 -1
  16. package/dist/module/GoTrueAdminApi.d.ts +449 -0
  17. package/dist/module/GoTrueAdminApi.d.ts.map +1 -1
  18. package/dist/module/GoTrueAdminApi.js +449 -0
  19. package/dist/module/GoTrueAdminApi.js.map +1 -1
  20. package/dist/module/GoTrueClient.d.ts +1668 -63
  21. package/dist/module/GoTrueClient.d.ts.map +1 -1
  22. package/dist/module/GoTrueClient.js +1889 -70
  23. package/dist/module/GoTrueClient.js.map +1 -1
  24. package/dist/module/lib/types.d.ts +409 -0
  25. package/dist/module/lib/types.d.ts.map +1 -1
  26. package/dist/module/lib/types.js.map +1 -1
  27. package/dist/module/lib/version.d.ts +1 -1
  28. package/dist/module/lib/version.d.ts.map +1 -1
  29. package/dist/module/lib/version.js +1 -1
  30. package/dist/module/lib/version.js.map +1 -1
  31. package/dist/tsconfig.module.tsbuildinfo +1 -1
  32. package/dist/tsconfig.tsbuildinfo +1 -1
  33. package/package.json +1 -1
  34. package/src/GoTrueAdminApi.ts +449 -0
  35. package/src/GoTrueClient.ts +1889 -70
  36. package/src/lib/types.ts +409 -0
  37. package/src/lib/version.ts +1 -1
@@ -237,6 +237,8 @@ class GoTrueClient {
237
237
  * Initializes the client session either from the url or from storage.
238
238
  * This method is automatically called when instantiating the client, but should also be called
239
239
  * manually when checking for an error from an auth redirect (oauth, magiclink, password recovery, etc).
240
+ *
241
+ * @category Auth
240
242
  */
241
243
  async initialize() {
242
244
  if (this.initializePromise) {
@@ -325,6 +327,74 @@ class GoTrueClient {
325
327
  * Creates a new anonymous user.
326
328
  *
327
329
  * @returns A session where the is_anonymous claim in the access token JWT set to true
330
+ *
331
+ * @category Auth
332
+ *
333
+ * @remarks
334
+ * - Returns an anonymous user
335
+ * - It is recommended to set up captcha for anonymous sign-ins to prevent abuse. You can pass in the captcha token in the `options` param.
336
+ *
337
+ * @example Create an anonymous user
338
+ * ```js
339
+ * const { data, error } = await supabase.auth.signInAnonymously({
340
+ * options: {
341
+ * captchaToken
342
+ * }
343
+ * });
344
+ * ```
345
+ *
346
+ * @exampleResponse Create an anonymous user
347
+ * ```json
348
+ * {
349
+ * "data": {
350
+ * "user": {
351
+ * "id": "11111111-1111-1111-1111-111111111111",
352
+ * "aud": "authenticated",
353
+ * "role": "authenticated",
354
+ * "email": "",
355
+ * "phone": "",
356
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
357
+ * "app_metadata": {},
358
+ * "user_metadata": {},
359
+ * "identities": [],
360
+ * "created_at": "2024-01-01T00:00:00Z",
361
+ * "updated_at": "2024-01-01T00:00:00Z",
362
+ * "is_anonymous": true
363
+ * },
364
+ * "session": {
365
+ * "access_token": "<ACCESS_TOKEN>",
366
+ * "token_type": "bearer",
367
+ * "expires_in": 3600,
368
+ * "expires_at": 1700000000,
369
+ * "refresh_token": "<REFRESH_TOKEN>",
370
+ * "user": {
371
+ * "id": "11111111-1111-1111-1111-111111111111",
372
+ * "aud": "authenticated",
373
+ * "role": "authenticated",
374
+ * "email": "",
375
+ * "phone": "",
376
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
377
+ * "app_metadata": {},
378
+ * "user_metadata": {},
379
+ * "identities": [],
380
+ * "created_at": "2024-01-01T00:00:00Z",
381
+ * "updated_at": "2024-01-01T00:00:00Z",
382
+ * "is_anonymous": true
383
+ * }
384
+ * }
385
+ * },
386
+ * "error": null
387
+ * }
388
+ * ```
389
+ *
390
+ * @example Create an anonymous user with custom user metadata
391
+ * ```js
392
+ * const { data, error } = await supabase.auth.signInAnonymously({
393
+ * options: {
394
+ * data
395
+ * }
396
+ * })
397
+ * ```
328
398
  */
329
399
  async signInAnonymously(credentials) {
330
400
  var _a, _b, _c;
@@ -604,6 +674,115 @@ class GoTrueClient {
604
674
  * between the cases where the account does not exist or that the
605
675
  * email/phone and password combination is wrong or that the account can only
606
676
  * be accessed via social login.
677
+ *
678
+ * @category Auth
679
+ *
680
+ * @remarks
681
+ * - Requires either an email and password or a phone number and password.
682
+ *
683
+ * @example Sign in with email and password
684
+ * ```js
685
+ * const { data, error } = await supabase.auth.signInWithPassword({
686
+ * email: 'example@email.com',
687
+ * password: 'example-password',
688
+ * })
689
+ * ```
690
+ *
691
+ * @exampleResponse Sign in with email and password
692
+ * ```json
693
+ * {
694
+ * "data": {
695
+ * "user": {
696
+ * "id": "11111111-1111-1111-1111-111111111111",
697
+ * "aud": "authenticated",
698
+ * "role": "authenticated",
699
+ * "email": "example@email.com",
700
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
701
+ * "phone": "",
702
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
703
+ * "app_metadata": {
704
+ * "provider": "email",
705
+ * "providers": [
706
+ * "email"
707
+ * ]
708
+ * },
709
+ * "user_metadata": {},
710
+ * "identities": [
711
+ * {
712
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
713
+ * "id": "11111111-1111-1111-1111-111111111111",
714
+ * "user_id": "11111111-1111-1111-1111-111111111111",
715
+ * "identity_data": {
716
+ * "email": "example@email.com",
717
+ * "email_verified": false,
718
+ * "phone_verified": false,
719
+ * "sub": "11111111-1111-1111-1111-111111111111"
720
+ * },
721
+ * "provider": "email",
722
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
723
+ * "created_at": "2024-01-01T00:00:00Z",
724
+ * "updated_at": "2024-01-01T00:00:00Z",
725
+ * "email": "example@email.com"
726
+ * }
727
+ * ],
728
+ * "created_at": "2024-01-01T00:00:00Z",
729
+ * "updated_at": "2024-01-01T00:00:00Z"
730
+ * },
731
+ * "session": {
732
+ * "access_token": "<ACCESS_TOKEN>",
733
+ * "token_type": "bearer",
734
+ * "expires_in": 3600,
735
+ * "expires_at": 1700000000,
736
+ * "refresh_token": "<REFRESH_TOKEN>",
737
+ * "user": {
738
+ * "id": "11111111-1111-1111-1111-111111111111",
739
+ * "aud": "authenticated",
740
+ * "role": "authenticated",
741
+ * "email": "example@email.com",
742
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
743
+ * "phone": "",
744
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
745
+ * "app_metadata": {
746
+ * "provider": "email",
747
+ * "providers": [
748
+ * "email"
749
+ * ]
750
+ * },
751
+ * "user_metadata": {},
752
+ * "identities": [
753
+ * {
754
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
755
+ * "id": "11111111-1111-1111-1111-111111111111",
756
+ * "user_id": "11111111-1111-1111-1111-111111111111",
757
+ * "identity_data": {
758
+ * "email": "example@email.com",
759
+ * "email_verified": false,
760
+ * "phone_verified": false,
761
+ * "sub": "11111111-1111-1111-1111-111111111111"
762
+ * },
763
+ * "provider": "email",
764
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
765
+ * "created_at": "2024-01-01T00:00:00Z",
766
+ * "updated_at": "2024-01-01T00:00:00Z",
767
+ * "email": "example@email.com"
768
+ * }
769
+ * ],
770
+ * "created_at": "2024-01-01T00:00:00Z",
771
+ * "updated_at": "2024-01-01T00:00:00Z"
772
+ * }
773
+ * }
774
+ * },
775
+ * "error": null
776
+ * }
777
+ * ```
778
+ *
779
+ * @example Sign in with phone and password
780
+ * ```js
781
+ * const { data, error } = await supabase.auth.signInWithPassword({
782
+ * phone: '+13334445555',
783
+ * password: 'some-password',
784
+ * })
785
+ * ```
607
786
  */
608
787
  async signInWithPassword(credentials) {
609
788
  try {
@@ -662,6 +841,81 @@ class GoTrueClient {
662
841
  /**
663
842
  * Log in an existing user via a third-party provider.
664
843
  * This method supports the PKCE flow.
844
+ *
845
+ * @category Auth
846
+ *
847
+ * @remarks
848
+ * - This method is used for signing in using [Social Login (OAuth) providers](/docs/guides/auth#configure-third-party-providers).
849
+ * - It works by redirecting your application to the provider's authorization screen, before bringing back the user to your app.
850
+ *
851
+ * @example Sign in using a third-party provider
852
+ * ```js
853
+ * const { data, error } = await supabase.auth.signInWithOAuth({
854
+ * provider: 'github'
855
+ * })
856
+ * ```
857
+ *
858
+ * @exampleResponse Sign in using a third-party provider
859
+ * ```json
860
+ * {
861
+ * data: {
862
+ * provider: 'github',
863
+ * url: <PROVIDER_URL_TO_REDIRECT_TO>
864
+ * },
865
+ * error: null
866
+ * }
867
+ * ```
868
+ *
869
+ * @exampleDescription Sign in using a third-party provider with redirect
870
+ * - When the OAuth provider successfully authenticates the user, they are redirected to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls). It does not redirect the user immediately after invoking this method.
871
+ * - See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project.
872
+ *
873
+ * @example Sign in using a third-party provider with redirect
874
+ * ```js
875
+ * const { data, error } = await supabase.auth.signInWithOAuth({
876
+ * provider: 'github',
877
+ * options: {
878
+ * redirectTo: 'https://example.com/welcome'
879
+ * }
880
+ * })
881
+ * ```
882
+ *
883
+ * @exampleDescription Sign in with scopes and access provider tokens
884
+ * If you need additional access from an OAuth provider, in order to access provider specific APIs in the name of the user, you can do this by passing in the scopes the user should authorize for your application. Note that the `scopes` option takes in **a space-separated list** of scopes.
885
+ *
886
+ * Because OAuth sign-in often includes redirects, you should register an `onAuthStateChange` callback immediately after you create the Supabase client. This callback will listen for the presence of `provider_token` and `provider_refresh_token` properties on the `session` object and store them in local storage. The client library will emit these values **only once** immediately after the user signs in. You can then access them by looking them up in local storage, or send them to your backend servers for further processing.
887
+ *
888
+ * Finally, make sure you remove them from local storage on the `SIGNED_OUT` event. If the OAuth provider supports token revocation, make sure you call those APIs either from the frontend or schedule them to be called on the backend.
889
+ *
890
+ * @example Sign in with scopes and access provider tokens
891
+ * ```js
892
+ * // Register this immediately after calling createClient!
893
+ * // Because signInWithOAuth causes a redirect, you need to fetch the
894
+ * // provider tokens from the callback.
895
+ * supabase.auth.onAuthStateChange((event, session) => {
896
+ * if (session && session.provider_token) {
897
+ * window.localStorage.setItem('oauth_provider_token', session.provider_token)
898
+ * }
899
+ *
900
+ * if (session && session.provider_refresh_token) {
901
+ * window.localStorage.setItem('oauth_provider_refresh_token', session.provider_refresh_token)
902
+ * }
903
+ *
904
+ * if (event === 'SIGNED_OUT') {
905
+ * window.localStorage.removeItem('oauth_provider_token')
906
+ * window.localStorage.removeItem('oauth_provider_refresh_token')
907
+ * }
908
+ * })
909
+ *
910
+ * // Call this on your Sign in with GitHub button to initiate OAuth
911
+ * // with GitHub with the requested elevated scopes.
912
+ * await supabase.auth.signInWithOAuth({
913
+ * provider: 'github',
914
+ * options: {
915
+ * scopes: 'repo gist notifications'
916
+ * }
917
+ * })
918
+ * ```
665
919
  */
666
920
  async signInWithOAuth(credentials) {
667
921
  var _a, _b, _c, _d;
@@ -674,73 +928,321 @@ class GoTrueClient {
674
928
  }
675
929
  /**
676
930
  * Log in an existing user by exchanging an Auth Code issued during the PKCE flow.
677
- */
678
- async exchangeCodeForSession(authCode) {
679
- await this.initializePromise;
680
- return this._acquireLock(this.lockAcquireTimeout, async () => {
681
- return this._exchangeCodeForSession(authCode);
682
- });
683
- }
684
- /**
685
- * Signs in a user by verifying a message signed by the user's private key.
686
- * Supports Ethereum (via Sign-In-With-Ethereum) & Solana (Sign-In-With-Solana) standards,
687
- * both of which derive from the EIP-4361 standard
688
- * With slight variation on Solana's side.
689
- * @reference https://eips.ethereum.org/EIPS/eip-4361
690
- */
691
- async signInWithWeb3(credentials) {
692
- const { chain } = credentials;
693
- switch (chain) {
694
- case 'ethereum':
695
- return await this.signInWithEthereum(credentials);
696
- case 'solana':
697
- return await this.signInWithSolana(credentials);
698
- default:
699
- throw new Error(`@supabase/auth-js: Unsupported chain "${chain}"`);
700
- }
701
- }
702
- async signInWithEthereum(credentials) {
703
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
704
- // TODO: flatten type
705
- let message;
706
- let signature;
707
- if ('message' in credentials) {
708
- message = credentials.message;
709
- signature = credentials.signature;
710
- }
711
- else {
712
- const { chain, wallet, statement, options } = credentials;
713
- let resolvedWallet;
714
- if (!isBrowser()) {
715
- if (typeof wallet !== 'object' || !(options === null || options === void 0 ? void 0 : options.url)) {
716
- throw new Error('@supabase/auth-js: Both wallet and url must be specified in non-browser environments.');
717
- }
718
- resolvedWallet = wallet;
719
- }
720
- else if (typeof wallet === 'object') {
721
- resolvedWallet = wallet;
722
- }
723
- else {
724
- const windowAny = window;
725
- if ('ethereum' in windowAny &&
726
- typeof windowAny.ethereum === 'object' &&
727
- 'request' in windowAny.ethereum &&
728
- typeof windowAny.ethereum.request === 'function') {
729
- resolvedWallet = windowAny.ethereum;
730
- }
731
- else {
732
- throw new Error(`@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.`);
733
- }
734
- }
735
- const url = new URL((_a = options === null || options === void 0 ? void 0 : options.url) !== null && _a !== void 0 ? _a : window.location.href);
736
- const accounts = await resolvedWallet
737
- .request({
738
- method: 'eth_requestAccounts',
739
- })
740
- .then((accs) => accs)
741
- .catch(() => {
742
- throw new Error(`@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid`);
743
- });
931
+ *
932
+ * @category Auth
933
+ *
934
+ * @remarks
935
+ * - Used when `flowType` is set to `pkce` in client options.
936
+ *
937
+ * @example Exchange Auth Code
938
+ * ```js
939
+ * supabase.auth.exchangeCodeForSession('34e770dd-9ff9-416c-87fa-43b31d7ef225')
940
+ * ```
941
+ *
942
+ * @exampleResponse Exchange Auth Code
943
+ * ```json
944
+ * {
945
+ * "data": {
946
+ * session: {
947
+ * access_token: '<ACCESS_TOKEN>',
948
+ * token_type: 'bearer',
949
+ * expires_in: 3600,
950
+ * expires_at: 1700000000,
951
+ * refresh_token: '<REFRESH_TOKEN>',
952
+ * user: {
953
+ * id: '11111111-1111-1111-1111-111111111111',
954
+ * aud: 'authenticated',
955
+ * role: 'authenticated',
956
+ * email: 'example@email.com'
957
+ * email_confirmed_at: '2024-01-01T00:00:00Z',
958
+ * phone: '',
959
+ * confirmation_sent_at: '2024-01-01T00:00:00Z',
960
+ * confirmed_at: '2024-01-01T00:00:00Z',
961
+ * last_sign_in_at: '2024-01-01T00:00:00Z',
962
+ * app_metadata: {
963
+ * "provider": "email",
964
+ * "providers": [
965
+ * "email",
966
+ * "<OTHER_PROVIDER>"
967
+ * ]
968
+ * },
969
+ * user_metadata: {
970
+ * email: 'email@email.com',
971
+ * email_verified: true,
972
+ * full_name: 'User Name',
973
+ * iss: '<ISS>',
974
+ * name: 'User Name',
975
+ * phone_verified: false,
976
+ * provider_id: '<PROVIDER_ID>',
977
+ * sub: '<SUB>'
978
+ * },
979
+ * identities: [
980
+ * {
981
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
982
+ * "id": "11111111-1111-1111-1111-111111111111",
983
+ * "user_id": "11111111-1111-1111-1111-111111111111",
984
+ * "identity_data": {
985
+ * "email": "example@email.com",
986
+ * "email_verified": false,
987
+ * "phone_verified": false,
988
+ * "sub": "11111111-1111-1111-1111-111111111111"
989
+ * },
990
+ * "provider": "email",
991
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
992
+ * "created_at": "2024-01-01T00:00:00Z",
993
+ * "updated_at": "2024-01-01T00:00:00Z",
994
+ * "email": "email@example.com"
995
+ * },
996
+ * {
997
+ * "identity_id": "33333333-3333-3333-3333-333333333333",
998
+ * "id": "<ID>",
999
+ * "user_id": "<USER_ID>",
1000
+ * "identity_data": {
1001
+ * "email": "example@email.com",
1002
+ * "email_verified": true,
1003
+ * "full_name": "User Name",
1004
+ * "iss": "<ISS>",
1005
+ * "name": "User Name",
1006
+ * "phone_verified": false,
1007
+ * "provider_id": "<PROVIDER_ID>",
1008
+ * "sub": "<SUB>"
1009
+ * },
1010
+ * "provider": "<PROVIDER>",
1011
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
1012
+ * "created_at": "2024-01-01T00:00:00Z",
1013
+ * "updated_at": "2024-01-01T00:00:00Z",
1014
+ * "email": "example@email.com"
1015
+ * }
1016
+ * ],
1017
+ * created_at: '2024-01-01T00:00:00Z',
1018
+ * updated_at: '2024-01-01T00:00:00Z',
1019
+ * is_anonymous: false
1020
+ * },
1021
+ * provider_token: '<PROVIDER_TOKEN>',
1022
+ * provider_refresh_token: '<PROVIDER_REFRESH_TOKEN>'
1023
+ * },
1024
+ * user: {
1025
+ * id: '11111111-1111-1111-1111-111111111111',
1026
+ * aud: 'authenticated',
1027
+ * role: 'authenticated',
1028
+ * email: 'example@email.com',
1029
+ * email_confirmed_at: '2024-01-01T00:00:00Z',
1030
+ * phone: '',
1031
+ * confirmation_sent_at: '2024-01-01T00:00:00Z',
1032
+ * confirmed_at: '2024-01-01T00:00:00Z',
1033
+ * last_sign_in_at: '2024-01-01T00:00:00Z',
1034
+ * app_metadata: {
1035
+ * provider: 'email',
1036
+ * providers: [
1037
+ * "email",
1038
+ * "<OTHER_PROVIDER>"
1039
+ * ]
1040
+ * },
1041
+ * user_metadata: {
1042
+ * email: 'email@email.com',
1043
+ * email_verified: true,
1044
+ * full_name: 'User Name',
1045
+ * iss: '<ISS>',
1046
+ * name: 'User Name',
1047
+ * phone_verified: false,
1048
+ * provider_id: '<PROVIDER_ID>',
1049
+ * sub: '<SUB>'
1050
+ * },
1051
+ * identities: [
1052
+ * {
1053
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
1054
+ * "id": "11111111-1111-1111-1111-111111111111",
1055
+ * "user_id": "11111111-1111-1111-1111-111111111111",
1056
+ * "identity_data": {
1057
+ * "email": "example@email.com",
1058
+ * "email_verified": false,
1059
+ * "phone_verified": false,
1060
+ * "sub": "11111111-1111-1111-1111-111111111111"
1061
+ * },
1062
+ * "provider": "email",
1063
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
1064
+ * "created_at": "2024-01-01T00:00:00Z",
1065
+ * "updated_at": "2024-01-01T00:00:00Z",
1066
+ * "email": "email@example.com"
1067
+ * },
1068
+ * {
1069
+ * "identity_id": "33333333-3333-3333-3333-333333333333",
1070
+ * "id": "<ID>",
1071
+ * "user_id": "<USER_ID>",
1072
+ * "identity_data": {
1073
+ * "email": "example@email.com",
1074
+ * "email_verified": true,
1075
+ * "full_name": "User Name",
1076
+ * "iss": "<ISS>",
1077
+ * "name": "User Name",
1078
+ * "phone_verified": false,
1079
+ * "provider_id": "<PROVIDER_ID>",
1080
+ * "sub": "<SUB>"
1081
+ * },
1082
+ * "provider": "<PROVIDER>",
1083
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
1084
+ * "created_at": "2024-01-01T00:00:00Z",
1085
+ * "updated_at": "2024-01-01T00:00:00Z",
1086
+ * "email": "example@email.com"
1087
+ * }
1088
+ * ],
1089
+ * created_at: '2024-01-01T00:00:00Z',
1090
+ * updated_at: '2024-01-01T00:00:00Z',
1091
+ * is_anonymous: false
1092
+ * },
1093
+ * redirectType: null
1094
+ * },
1095
+ * "error": null
1096
+ * }
1097
+ * ```
1098
+ */
1099
+ async exchangeCodeForSession(authCode) {
1100
+ await this.initializePromise;
1101
+ return this._acquireLock(this.lockAcquireTimeout, async () => {
1102
+ return this._exchangeCodeForSession(authCode);
1103
+ });
1104
+ }
1105
+ /**
1106
+ * Signs in a user by verifying a message signed by the user's private key.
1107
+ * Supports Ethereum (via Sign-In-With-Ethereum) & Solana (Sign-In-With-Solana) standards,
1108
+ * both of which derive from the EIP-4361 standard
1109
+ * With slight variation on Solana's side.
1110
+ * @reference https://eips.ethereum.org/EIPS/eip-4361
1111
+ *
1112
+ * @category Auth
1113
+ *
1114
+ * @remarks
1115
+ * - Uses a Web3 (Ethereum, Solana) wallet to sign a user in.
1116
+ * - Read up on the [potential for abuse](/docs/guides/auth/auth-web3#potential-for-abuse) before using it.
1117
+ *
1118
+ * @example Sign in with Solana or Ethereum (Window API)
1119
+ * ```js
1120
+ * // uses window.ethereum for the wallet
1121
+ * const { data, error } = await supabase.auth.signInWithWeb3({
1122
+ * chain: 'ethereum',
1123
+ * statement: 'I accept the Terms of Service at https://example.com/tos'
1124
+ * })
1125
+ *
1126
+ * // uses window.solana for the wallet
1127
+ * const { data, error } = await supabase.auth.signInWithWeb3({
1128
+ * chain: 'solana',
1129
+ * statement: 'I accept the Terms of Service at https://example.com/tos'
1130
+ * })
1131
+ * ```
1132
+ *
1133
+ * @example Sign in with Ethereum (Message and Signature)
1134
+ * ```js
1135
+ * const { data, error } = await supabase.auth.signInWithWeb3({
1136
+ * chain: 'ethereum',
1137
+ * message: '<sign in with ethereum message>',
1138
+ * signature: '<hex of the ethereum signature over the message>',
1139
+ * })
1140
+ * ```
1141
+ *
1142
+ * @example Sign in with Solana (Brave)
1143
+ * ```js
1144
+ * const { data, error } = await supabase.auth.signInWithWeb3({
1145
+ * chain: 'solana',
1146
+ * statement: 'I accept the Terms of Service at https://example.com/tos',
1147
+ * wallet: window.braveSolana
1148
+ * })
1149
+ * ```
1150
+ *
1151
+ * @example Sign in with Solana (Wallet Adapter)
1152
+ * ```jsx
1153
+ * function SignInButton() {
1154
+ * const wallet = useWallet()
1155
+ *
1156
+ * return (
1157
+ * <>
1158
+ * {wallet.connected ? (
1159
+ * <button
1160
+ * onClick={() => {
1161
+ * supabase.auth.signInWithWeb3({
1162
+ * chain: 'solana',
1163
+ * statement: 'I accept the Terms of Service at https://example.com/tos',
1164
+ * wallet,
1165
+ * })
1166
+ * }}
1167
+ * >
1168
+ * Sign in with Solana
1169
+ * </button>
1170
+ * ) : (
1171
+ * <WalletMultiButton />
1172
+ * )}
1173
+ * </>
1174
+ * )
1175
+ * }
1176
+ *
1177
+ * function App() {
1178
+ * const endpoint = clusterApiUrl('devnet')
1179
+ * const wallets = useMemo(() => [], [])
1180
+ *
1181
+ * return (
1182
+ * <ConnectionProvider endpoint={endpoint}>
1183
+ * <WalletProvider wallets={wallets}>
1184
+ * <WalletModalProvider>
1185
+ * <SignInButton />
1186
+ * </WalletModalProvider>
1187
+ * </WalletProvider>
1188
+ * </ConnectionProvider>
1189
+ * )
1190
+ * }
1191
+ * ```
1192
+ */
1193
+ async signInWithWeb3(credentials) {
1194
+ const { chain } = credentials;
1195
+ switch (chain) {
1196
+ case 'ethereum':
1197
+ return await this.signInWithEthereum(credentials);
1198
+ case 'solana':
1199
+ return await this.signInWithSolana(credentials);
1200
+ default:
1201
+ throw new Error(`@supabase/auth-js: Unsupported chain "${chain}"`);
1202
+ }
1203
+ }
1204
+ async signInWithEthereum(credentials) {
1205
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
1206
+ // TODO: flatten type
1207
+ let message;
1208
+ let signature;
1209
+ if ('message' in credentials) {
1210
+ message = credentials.message;
1211
+ signature = credentials.signature;
1212
+ }
1213
+ else {
1214
+ const { chain, wallet, statement, options } = credentials;
1215
+ let resolvedWallet;
1216
+ if (!isBrowser()) {
1217
+ if (typeof wallet !== 'object' || !(options === null || options === void 0 ? void 0 : options.url)) {
1218
+ throw new Error('@supabase/auth-js: Both wallet and url must be specified in non-browser environments.');
1219
+ }
1220
+ resolvedWallet = wallet;
1221
+ }
1222
+ else if (typeof wallet === 'object') {
1223
+ resolvedWallet = wallet;
1224
+ }
1225
+ else {
1226
+ const windowAny = window;
1227
+ if ('ethereum' in windowAny &&
1228
+ typeof windowAny.ethereum === 'object' &&
1229
+ 'request' in windowAny.ethereum &&
1230
+ typeof windowAny.ethereum.request === 'function') {
1231
+ resolvedWallet = windowAny.ethereum;
1232
+ }
1233
+ else {
1234
+ throw new Error(`@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.`);
1235
+ }
1236
+ }
1237
+ const url = new URL((_a = options === null || options === void 0 ? void 0 : options.url) !== null && _a !== void 0 ? _a : window.location.href);
1238
+ const accounts = await resolvedWallet
1239
+ .request({
1240
+ method: 'eth_requestAccounts',
1241
+ })
1242
+ .then((accs) => accs)
1243
+ .catch(() => {
1244
+ throw new Error(`@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid`);
1245
+ });
744
1246
  if (!accounts || accounts.length === 0) {
745
1247
  throw new Error(`@supabase/auth-js: No accounts available. Please ensure the wallet is connected.`);
746
1248
  }
@@ -986,6 +1488,77 @@ class GoTrueClient {
986
1488
  /**
987
1489
  * Allows signing in with an OIDC ID token. The authentication provider used
988
1490
  * should be enabled and configured.
1491
+ *
1492
+ * @category Auth
1493
+ *
1494
+ * @remarks
1495
+ * - Use an ID token to sign in.
1496
+ * - Especially useful when implementing sign in using native platform dialogs in mobile or desktop apps using Sign in with Apple or Sign in with Google on iOS and Android.
1497
+ * - You can also use Google's [One Tap](https://developers.google.com/identity/gsi/web/guides/display-google-one-tap) and [Automatic sign-in](https://developers.google.com/identity/gsi/web/guides/automatic-sign-in-sign-out) via this API.
1498
+ *
1499
+ * @example Sign In using ID Token
1500
+ * ```js
1501
+ * const { data, error } = await supabase.auth.signInWithIdToken({
1502
+ * provider: 'google',
1503
+ * token: 'your-id-token'
1504
+ * })
1505
+ * ```
1506
+ *
1507
+ * @exampleResponse Sign In using ID Token
1508
+ * ```json
1509
+ * {
1510
+ * "data": {
1511
+ * "user": {
1512
+ * "id": "11111111-1111-1111-1111-111111111111",
1513
+ * "aud": "authenticated",
1514
+ * "role": "authenticated",
1515
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
1516
+ * "app_metadata": {
1517
+ * ...
1518
+ * },
1519
+ * "user_metadata": {
1520
+ * ...
1521
+ * },
1522
+ * "identities": [
1523
+ * {
1524
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
1525
+ * "provider": "google",
1526
+ * }
1527
+ * ],
1528
+ * "created_at": "2024-01-01T00:00:00Z",
1529
+ * "updated_at": "2024-01-01T00:00:00Z",
1530
+ * },
1531
+ * "session": {
1532
+ * "access_token": "<ACCESS_TOKEN>",
1533
+ * "token_type": "bearer",
1534
+ * "expires_in": 3600,
1535
+ * "expires_at": 1700000000,
1536
+ * "refresh_token": "<REFRESH_TOKEN>",
1537
+ * "user": {
1538
+ * "id": "11111111-1111-1111-1111-111111111111",
1539
+ * "aud": "authenticated",
1540
+ * "role": "authenticated",
1541
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
1542
+ * "app_metadata": {
1543
+ * ...
1544
+ * },
1545
+ * "user_metadata": {
1546
+ * ...
1547
+ * },
1548
+ * "identities": [
1549
+ * {
1550
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
1551
+ * "provider": "google",
1552
+ * }
1553
+ * ],
1554
+ * "created_at": "2024-01-01T00:00:00Z",
1555
+ * "updated_at": "2024-01-01T00:00:00Z",
1556
+ * }
1557
+ * }
1558
+ * },
1559
+ * "error": null
1560
+ * }
1561
+ * ```
989
1562
  */
990
1563
  async signInWithIdToken(credentials) {
991
1564
  try {
@@ -1038,6 +1611,66 @@ class GoTrueClient {
1038
1611
  * channel is not supported on other providers
1039
1612
  * at this time.
1040
1613
  * This method supports PKCE when an email is passed.
1614
+ *
1615
+ * @category Auth
1616
+ *
1617
+ * @remarks
1618
+ * - Requires either an email or phone number.
1619
+ * - This method is used for passwordless sign-ins where a OTP is sent to the user's email or phone number.
1620
+ * - If the user doesn't exist, `signInWithOtp()` will signup the user instead. To restrict this behavior, you can set `shouldCreateUser` in `SignInWithPasswordlessCredentials.options` to `false`.
1621
+ * - If you're using an email, you can configure whether you want the user to receive a magiclink or a OTP.
1622
+ * - If you're using phone, you can configure whether you want the user to receive a OTP.
1623
+ * - The magic link's destination URL is determined by the [`SITE_URL`](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls).
1624
+ * - See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project.
1625
+ * - Magic links and OTPs share the same implementation. To send users a one-time code instead of a magic link, [modify the magic link email template](/dashboard/project/_/auth/templates) to include `{{ .Token }}` instead of `{{ .ConfirmationURL }}`.
1626
+ * - See our [Twilio Phone Auth Guide](/docs/guides/auth/phone-login?showSMSProvider=Twilio) for details about configuring WhatsApp sign in.
1627
+ *
1628
+ * @exampleDescription Sign in with email
1629
+ * The user will be sent an email which contains either a magiclink or a OTP or both. By default, a given user can only request a OTP once every 60 seconds.
1630
+ *
1631
+ * @example Sign in with email
1632
+ * ```js
1633
+ * const { data, error } = await supabase.auth.signInWithOtp({
1634
+ * email: 'example@email.com',
1635
+ * options: {
1636
+ * emailRedirectTo: 'https://example.com/welcome'
1637
+ * }
1638
+ * })
1639
+ * ```
1640
+ *
1641
+ * @exampleResponse Sign in with email
1642
+ * ```json
1643
+ * {
1644
+ * "data": {
1645
+ * "user": null,
1646
+ * "session": null
1647
+ * },
1648
+ * "error": null
1649
+ * }
1650
+ * ```
1651
+ *
1652
+ * @exampleDescription Sign in with SMS OTP
1653
+ * The user will be sent a SMS which contains a OTP. By default, a given user can only request a OTP once every 60 seconds.
1654
+ *
1655
+ * @example Sign in with SMS OTP
1656
+ * ```js
1657
+ * const { data, error } = await supabase.auth.signInWithOtp({
1658
+ * phone: '+13334445555',
1659
+ * })
1660
+ * ```
1661
+ *
1662
+ * @exampleDescription Sign in with WhatsApp OTP
1663
+ * The user will be sent a WhatsApp message which contains a OTP. By default, a given user can only request a OTP once every 60 seconds. Note that a user will need to have a valid WhatsApp account that is linked to Twilio in order to use this feature.
1664
+ *
1665
+ * @example Sign in with WhatsApp OTP
1666
+ * ```js
1667
+ * const { data, error } = await supabase.auth.signInWithOtp({
1668
+ * phone: '+13334445555',
1669
+ * options: {
1670
+ * channel:'whatsapp',
1671
+ * }
1672
+ * })
1673
+ * ```
1041
1674
  */
1042
1675
  async signInWithOtp(credentials) {
1043
1676
  var _a, _b, _c, _d, _e;
@@ -1093,9 +1726,143 @@ class GoTrueClient {
1093
1726
  }
1094
1727
  /**
1095
1728
  * Log in a user given a User supplied OTP or TokenHash received through mobile or email.
1096
- */
1097
- async verifyOtp(params) {
1098
- var _a, _b;
1729
+ *
1730
+ * @category Auth
1731
+ *
1732
+ * @remarks
1733
+ * - The `verifyOtp` method takes in different verification types.
1734
+ * - If a phone number is used, the type can either be:
1735
+ * 1. `sms` – Used when verifying a one-time password (OTP) sent via SMS during sign-up or sign-in.
1736
+ * 2. `phone_change` – Used when verifying an OTP sent to a new phone number during a phone number update process.
1737
+ * - If an email address is used, the type can be one of the following (note: `signup` and `magiclink` types are deprecated):
1738
+ * 1. `email` – Used when verifying an OTP sent to the user's email during sign-up or sign-in.
1739
+ * 2. `recovery` – Used when verifying an OTP sent for account recovery, typically after a password reset request.
1740
+ * 3. `invite` – Used when verifying an OTP sent as part of an invitation to join a project or organization.
1741
+ * 4. `email_change` – Used when verifying an OTP sent to a new email address during an email update process.
1742
+ * - The verification type used should be determined based on the corresponding auth method called before `verifyOtp` to sign up / sign-in a user.
1743
+ * - The `TokenHash` is contained in the [email templates](/docs/guides/auth/auth-email-templates) and can be used to sign in. You may wish to use the hash for the PKCE flow for Server Side Auth. Read [the Password-based Auth guide](/docs/guides/auth/passwords) for more details.
1744
+ *
1745
+ * @example Verify Signup One-Time Password (OTP)
1746
+ * ```js
1747
+ * const { data, error } = await supabase.auth.verifyOtp({ email, token, type: 'email'})
1748
+ * ```
1749
+ *
1750
+ * @exampleResponse Verify Signup One-Time Password (OTP)
1751
+ * ```json
1752
+ * {
1753
+ * "data": {
1754
+ * "user": {
1755
+ * "id": "11111111-1111-1111-1111-111111111111",
1756
+ * "aud": "authenticated",
1757
+ * "role": "authenticated",
1758
+ * "email": "example@email.com",
1759
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
1760
+ * "phone": "",
1761
+ * "confirmed_at": "2024-01-01T00:00:00Z",
1762
+ * "recovery_sent_at": "2024-01-01T00:00:00Z",
1763
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
1764
+ * "app_metadata": {
1765
+ * "provider": "email",
1766
+ * "providers": [
1767
+ * "email"
1768
+ * ]
1769
+ * },
1770
+ * "user_metadata": {
1771
+ * "email": "example@email.com",
1772
+ * "email_verified": false,
1773
+ * "phone_verified": false,
1774
+ * "sub": "11111111-1111-1111-1111-111111111111"
1775
+ * },
1776
+ * "identities": [
1777
+ * {
1778
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
1779
+ * "id": "11111111-1111-1111-1111-111111111111",
1780
+ * "user_id": "11111111-1111-1111-1111-111111111111",
1781
+ * "identity_data": {
1782
+ * "email": "example@email.com",
1783
+ * "email_verified": false,
1784
+ * "phone_verified": false,
1785
+ * "sub": "11111111-1111-1111-1111-111111111111"
1786
+ * },
1787
+ * "provider": "email",
1788
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
1789
+ * "created_at": "2024-01-01T00:00:00Z",
1790
+ * "updated_at": "2024-01-01T00:00:00Z",
1791
+ * "email": "example@email.com"
1792
+ * }
1793
+ * ],
1794
+ * "created_at": "2024-01-01T00:00:00Z",
1795
+ * "updated_at": "2024-01-01T00:00:00Z",
1796
+ * "is_anonymous": false
1797
+ * },
1798
+ * "session": {
1799
+ * "access_token": "<ACCESS_TOKEN>",
1800
+ * "token_type": "bearer",
1801
+ * "expires_in": 3600,
1802
+ * "expires_at": 1700000000,
1803
+ * "refresh_token": "<REFRESH_TOKEN>",
1804
+ * "user": {
1805
+ * "id": "11111111-1111-1111-1111-111111111111",
1806
+ * "aud": "authenticated",
1807
+ * "role": "authenticated",
1808
+ * "email": "example@email.com",
1809
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
1810
+ * "phone": "",
1811
+ * "confirmed_at": "2024-01-01T00:00:00Z",
1812
+ * "recovery_sent_at": "2024-01-01T00:00:00Z",
1813
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
1814
+ * "app_metadata": {
1815
+ * "provider": "email",
1816
+ * "providers": [
1817
+ * "email"
1818
+ * ]
1819
+ * },
1820
+ * "user_metadata": {
1821
+ * "email": "example@email.com",
1822
+ * "email_verified": false,
1823
+ * "phone_verified": false,
1824
+ * "sub": "11111111-1111-1111-1111-111111111111"
1825
+ * },
1826
+ * "identities": [
1827
+ * {
1828
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
1829
+ * "id": "11111111-1111-1111-1111-111111111111",
1830
+ * "user_id": "11111111-1111-1111-1111-111111111111",
1831
+ * "identity_data": {
1832
+ * "email": "example@email.com",
1833
+ * "email_verified": false,
1834
+ * "phone_verified": false,
1835
+ * "sub": "11111111-1111-1111-1111-111111111111"
1836
+ * },
1837
+ * "provider": "email",
1838
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
1839
+ * "created_at": "2024-01-01T00:00:00Z",
1840
+ * "updated_at": "2024-01-01T00:00:00Z",
1841
+ * "email": "example@email.com"
1842
+ * }
1843
+ * ],
1844
+ * "created_at": "2024-01-01T00:00:00Z",
1845
+ * "updated_at": "2024-01-01T00:00:00Z",
1846
+ * "is_anonymous": false
1847
+ * }
1848
+ * }
1849
+ * },
1850
+ * "error": null
1851
+ * }
1852
+ * ```
1853
+ *
1854
+ * @example Verify SMS One-Time Password (OTP)
1855
+ * ```js
1856
+ * const { data, error } = await supabase.auth.verifyOtp({ phone, token, type: 'sms'})
1857
+ * ```
1858
+ *
1859
+ * @example Verify Email Auth (Token Hash)
1860
+ * ```js
1861
+ * const { data, error } = await supabase.auth.verifyOtp({ token_hash: tokenHash, type: 'email'})
1862
+ * ```
1863
+ */
1864
+ async verifyOtp(params) {
1865
+ var _a, _b;
1099
1866
  try {
1100
1867
  let redirectTo = undefined;
1101
1868
  let captchaToken = undefined;
@@ -1144,6 +1911,45 @@ class GoTrueClient {
1144
1911
  *
1145
1912
  * If you have built an organization-specific login page, you can use the
1146
1913
  * organization's SSO Identity Provider UUID directly instead.
1914
+ *
1915
+ * @category Auth
1916
+ *
1917
+ * @remarks
1918
+ * - Before you can call this method you need to [establish a connection](/docs/guides/auth/sso/auth-sso-saml#managing-saml-20-connections) to an identity provider. Use the [CLI commands](/docs/reference/cli/supabase-sso) to do this.
1919
+ * - If you've associated an email domain to the identity provider, you can use the `domain` property to start a sign-in flow.
1920
+ * - In case you need to use a different way to start the authentication flow with an identity provider, you can use the `providerId` property. For example:
1921
+ * - Mapping specific user email addresses with an identity provider.
1922
+ * - Using different hints to identity the identity provider to be used by the user, like a company-specific page, IP address or other tracking information.
1923
+ *
1924
+ * @example Sign in with email domain
1925
+ * ```js
1926
+ * // You can extract the user's email domain and use it to trigger the
1927
+ * // authentication flow with the correct identity provider.
1928
+ *
1929
+ * const { data, error } = await supabase.auth.signInWithSSO({
1930
+ * domain: 'company.com'
1931
+ * })
1932
+ *
1933
+ * if (data?.url) {
1934
+ * // redirect the user to the identity provider's authentication flow
1935
+ * window.location.href = data.url
1936
+ * }
1937
+ * ```
1938
+ *
1939
+ * @example Sign in with provider UUID
1940
+ * ```js
1941
+ * // Useful when you need to map a user's sign in request according
1942
+ * // to different rules that can't use email domains.
1943
+ *
1944
+ * const { data, error } = await supabase.auth.signInWithSSO({
1945
+ * providerId: '21648a9d-8d5a-4555-a9d1-d6375dc14e92'
1946
+ * })
1947
+ *
1948
+ * if (data?.url) {
1949
+ * // redirect the user to the identity provider's authentication flow
1950
+ * window.location.href = data.url
1951
+ * }
1952
+ * ```
1147
1953
  */
1148
1954
  async signInWithSSO(params) {
1149
1955
  var _a, _b, _c, _d, _e;
@@ -1178,6 +1984,23 @@ class GoTrueClient {
1178
1984
  /**
1179
1985
  * Sends a reauthentication OTP to the user's email or phone number.
1180
1986
  * Requires the user to be signed-in.
1987
+ *
1988
+ * @category Auth
1989
+ *
1990
+ * @remarks
1991
+ * - This method is used together with `updateUser()` when a user's password needs to be updated.
1992
+ * - If you require your user to reauthenticate before updating their password, you need to enable the **Secure password change** option in your [project's email provider settings](/dashboard/project/_/auth/providers).
1993
+ * - A user is only require to reauthenticate before updating their password if **Secure password change** is enabled and the user **hasn't recently signed in**. A user is deemed recently signed in if the session was created in the last 24 hours.
1994
+ * - This method will send a nonce to the user's email. If the user doesn't have a confirmed email address, the method will send the nonce to the user's confirmed phone number instead.
1995
+ * - After receiving the OTP, include it as the `nonce` in your `updateUser()` call to finalize the password change.
1996
+ *
1997
+ * @exampleDescription Send reauthentication nonce
1998
+ * Sends a reauthentication nonce to the user's email or phone number.
1999
+ *
2000
+ * @example Send reauthentication nonce
2001
+ * ```js
2002
+ * const { error } = await supabase.auth.reauthenticate()
2003
+ * ```
1181
2004
  */
1182
2005
  async reauthenticate() {
1183
2006
  await this.initializePromise;
@@ -1209,6 +2032,62 @@ class GoTrueClient {
1209
2032
  }
1210
2033
  /**
1211
2034
  * Resends an existing signup confirmation email, email change email, SMS OTP or phone change OTP.
2035
+ *
2036
+ * @category Auth
2037
+ *
2038
+ * @remarks
2039
+ * - Resends a signup confirmation, email change or phone change email to the user.
2040
+ * - Passwordless sign-ins can be resent by calling the `signInWithOtp()` method again.
2041
+ * - Password recovery emails can be resent by calling the `resetPasswordForEmail()` method again.
2042
+ * - This method will only resend an email or phone OTP to the user if there was an initial signup, email change or phone change request being made(note: For existing users signing in with OTP, you should use `signInWithOtp()` again to resend the OTP).
2043
+ * - You can specify a redirect url when you resend an email link using the `emailRedirectTo` option.
2044
+ *
2045
+ * @exampleDescription Resend an email signup confirmation
2046
+ * Resends the email signup confirmation to the user
2047
+ *
2048
+ * @example Resend an email signup confirmation
2049
+ * ```js
2050
+ * const { error } = await supabase.auth.resend({
2051
+ * type: 'signup',
2052
+ * email: 'email@example.com',
2053
+ * options: {
2054
+ * emailRedirectTo: 'https://example.com/welcome'
2055
+ * }
2056
+ * })
2057
+ * ```
2058
+ *
2059
+ * @exampleDescription Resend a phone signup confirmation
2060
+ * Resends the phone signup confirmation email to the user
2061
+ *
2062
+ * @example Resend a phone signup confirmation
2063
+ * ```js
2064
+ * const { error } = await supabase.auth.resend({
2065
+ * type: 'sms',
2066
+ * phone: '1234567890'
2067
+ * })
2068
+ * ```
2069
+ *
2070
+ * @exampleDescription Resend email change email
2071
+ * Resends the email change email to the user
2072
+ *
2073
+ * @example Resend email change email
2074
+ * ```js
2075
+ * const { error } = await supabase.auth.resend({
2076
+ * type: 'email_change',
2077
+ * email: 'email@example.com'
2078
+ * })
2079
+ * ```
2080
+ *
2081
+ * @exampleDescription Resend phone change OTP
2082
+ * Resends the phone change OTP to the user
2083
+ *
2084
+ * @example Resend phone change OTP
2085
+ * ```js
2086
+ * const { error } = await supabase.auth.resend({
2087
+ * type: 'phone_change',
2088
+ * phone: '1234567890'
2089
+ * })
2090
+ * ```
1212
2091
  */
1213
2092
  async resend(credentials) {
1214
2093
  try {
@@ -1260,6 +2139,80 @@ class GoTrueClient {
1260
2139
  * the values in it may not be authentic and therefore it's strongly advised
1261
2140
  * against using this method and its results in such circumstances. A warning
1262
2141
  * will be emitted if this is detected. Use {@link #getUser()} instead.
2142
+ *
2143
+ * @category Auth
2144
+ *
2145
+ * @remarks
2146
+ * - Since the introduction of [asymmetric JWT signing keys](/docs/guides/auth/signing-keys), this method is considered low-level and we encourage you to use `getClaims()` or `getUser()` instead.
2147
+ * - Retrieves the current [user session](/docs/guides/auth/sessions) from the storage medium (local storage, cookies).
2148
+ * - The session contains an access token (signed JWT), a refresh token and the user object.
2149
+ * - If the session's access token is expired or is about to expire, this method will use the refresh token to refresh the session.
2150
+ * - When using in a browser, or you've called `startAutoRefresh()` in your environment (React Native, etc.) this function always returns a valid access token without refreshing the session itself, as this is done in the background. This function returns very fast.
2151
+ * - **IMPORTANT SECURITY NOTICE:** If using an insecure storage medium, such as cookies or request headers, the user object returned by this function **must not be trusted**. Always verify the JWT using `getClaims()` or your own JWT verification library to securely establish the user's identity and access. You can also use `getUser()` to fetch the user object directly from the Auth server for this purpose.
2152
+ * - When using in a browser, this function is synchronized across all tabs using the [LockManager](https://developer.mozilla.org/en-US/docs/Web/API/LockManager) API. In other environments make sure you've defined a proper `lock` property, if necessary, to make sure there are no race conditions while the session is being refreshed.
2153
+ *
2154
+ * @example Get the session data
2155
+ * ```js
2156
+ * const { data, error } = await supabase.auth.getSession()
2157
+ * ```
2158
+ *
2159
+ * @exampleResponse Get the session data
2160
+ * ```json
2161
+ * {
2162
+ * "data": {
2163
+ * "session": {
2164
+ * "access_token": "<ACCESS_TOKEN>",
2165
+ * "token_type": "bearer",
2166
+ * "expires_in": 3600,
2167
+ * "expires_at": 1700000000,
2168
+ * "refresh_token": "<REFRESH_TOKEN>",
2169
+ * "user": {
2170
+ * "id": "11111111-1111-1111-1111-111111111111",
2171
+ * "aud": "authenticated",
2172
+ * "role": "authenticated",
2173
+ * "email": "example@email.com",
2174
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
2175
+ * "phone": "",
2176
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2177
+ * "app_metadata": {
2178
+ * "provider": "email",
2179
+ * "providers": [
2180
+ * "email"
2181
+ * ]
2182
+ * },
2183
+ * "user_metadata": {
2184
+ * "email": "example@email.com",
2185
+ * "email_verified": false,
2186
+ * "phone_verified": false,
2187
+ * "sub": "11111111-1111-1111-1111-111111111111"
2188
+ * },
2189
+ * "identities": [
2190
+ * {
2191
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
2192
+ * "id": "11111111-1111-1111-1111-111111111111",
2193
+ * "user_id": "11111111-1111-1111-1111-111111111111",
2194
+ * "identity_data": {
2195
+ * "email": "example@email.com",
2196
+ * "email_verified": false,
2197
+ * "phone_verified": false,
2198
+ * "sub": "11111111-1111-1111-1111-111111111111"
2199
+ * },
2200
+ * "provider": "email",
2201
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2202
+ * "created_at": "2024-01-01T00:00:00Z",
2203
+ * "updated_at": "2024-01-01T00:00:00Z",
2204
+ * "email": "example@email.com"
2205
+ * }
2206
+ * ],
2207
+ * "created_at": "2024-01-01T00:00:00Z",
2208
+ * "updated_at": "2024-01-01T00:00:00Z",
2209
+ * "is_anonymous": false
2210
+ * }
2211
+ * }
2212
+ * },
2213
+ * "error": null
2214
+ * }
2215
+ * ```
1263
2216
  */
1264
2217
  async getSession() {
1265
2218
  await this.initializePromise;
@@ -1418,6 +2371,75 @@ class GoTrueClient {
1418
2371
  * value is authentic and can be used to base authorization rules on.
1419
2372
  *
1420
2373
  * @param jwt Takes in an optional access token JWT. If no JWT is provided, the JWT from the current session is used.
2374
+ *
2375
+ * @category Auth
2376
+ *
2377
+ * @remarks
2378
+ * - This method fetches the user object from the database instead of local session.
2379
+ * - This method is useful for checking if the user is authorized because it validates the user's access token JWT on the server.
2380
+ * - Should always be used when checking for user authorization on the server. On the client, you can instead use `getSession().session.user` for faster results. `getSession` is insecure on the server.
2381
+ *
2382
+ * @example Get the logged in user with the current existing session
2383
+ * ```js
2384
+ * const { data: { user } } = await supabase.auth.getUser()
2385
+ * ```
2386
+ *
2387
+ * @exampleResponse Get the logged in user with the current existing session
2388
+ * ```json
2389
+ * {
2390
+ * "data": {
2391
+ * "user": {
2392
+ * "id": "11111111-1111-1111-1111-111111111111",
2393
+ * "aud": "authenticated",
2394
+ * "role": "authenticated",
2395
+ * "email": "example@email.com",
2396
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
2397
+ * "phone": "",
2398
+ * "confirmed_at": "2024-01-01T00:00:00Z",
2399
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2400
+ * "app_metadata": {
2401
+ * "provider": "email",
2402
+ * "providers": [
2403
+ * "email"
2404
+ * ]
2405
+ * },
2406
+ * "user_metadata": {
2407
+ * "email": "example@email.com",
2408
+ * "email_verified": false,
2409
+ * "phone_verified": false,
2410
+ * "sub": "11111111-1111-1111-1111-111111111111"
2411
+ * },
2412
+ * "identities": [
2413
+ * {
2414
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
2415
+ * "id": "11111111-1111-1111-1111-111111111111",
2416
+ * "user_id": "11111111-1111-1111-1111-111111111111",
2417
+ * "identity_data": {
2418
+ * "email": "example@email.com",
2419
+ * "email_verified": false,
2420
+ * "phone_verified": false,
2421
+ * "sub": "11111111-1111-1111-1111-111111111111"
2422
+ * },
2423
+ * "provider": "email",
2424
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2425
+ * "created_at": "2024-01-01T00:00:00Z",
2426
+ * "updated_at": "2024-01-01T00:00:00Z",
2427
+ * "email": "example@email.com"
2428
+ * }
2429
+ * ],
2430
+ * "created_at": "2024-01-01T00:00:00Z",
2431
+ * "updated_at": "2024-01-01T00:00:00Z",
2432
+ * "is_anonymous": false
2433
+ * }
2434
+ * },
2435
+ * "error": null
2436
+ * }
2437
+ * ```
2438
+ *
2439
+ * @example Get the logged in user with a custom access token jwt
2440
+ * ```js
2441
+ * const { data: { user } } = await supabase.auth.getUser(jwt)
2442
+ * ```
1421
2443
  */
1422
2444
  async getUser(jwt) {
1423
2445
  if (jwt) {
@@ -1473,6 +2495,117 @@ class GoTrueClient {
1473
2495
  }
1474
2496
  /**
1475
2497
  * Updates user data for a logged in user.
2498
+ *
2499
+ * @category Auth
2500
+ *
2501
+ * @remarks
2502
+ * - In order to use the `updateUser()` method, the user needs to be signed in first.
2503
+ * - By default, email updates sends a confirmation link to both the user's current and new email.
2504
+ * To only send a confirmation link to the user's new email, disable **Secure email change** in your project's [email auth provider settings](/dashboard/project/_/auth/providers).
2505
+ *
2506
+ * @exampleDescription Update the email for an authenticated user
2507
+ * Sends a "Confirm Email Change" email to the new address. If **Secure Email Change** is enabled (default), confirmation is also required from the **old email** before the change is applied. To skip dual confirmation and apply the change after only the new email is verified, disable **Secure Email Change** in the [Email Auth Provider settings](/dashboard/project/_/auth/providers?provider=Email).
2508
+ *
2509
+ * @example Update the email for an authenticated user
2510
+ * ```js
2511
+ * const { data, error } = await supabase.auth.updateUser({
2512
+ * email: 'new@email.com'
2513
+ * })
2514
+ * ```
2515
+ *
2516
+ * @exampleResponse Update the email for an authenticated user
2517
+ * ```json
2518
+ * {
2519
+ * "data": {
2520
+ * "user": {
2521
+ * "id": "11111111-1111-1111-1111-111111111111",
2522
+ * "aud": "authenticated",
2523
+ * "role": "authenticated",
2524
+ * "email": "example@email.com",
2525
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
2526
+ * "phone": "",
2527
+ * "confirmed_at": "2024-01-01T00:00:00Z",
2528
+ * "new_email": "new@email.com",
2529
+ * "email_change_sent_at": "2024-01-01T00:00:00Z",
2530
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2531
+ * "app_metadata": {
2532
+ * "provider": "email",
2533
+ * "providers": [
2534
+ * "email"
2535
+ * ]
2536
+ * },
2537
+ * "user_metadata": {
2538
+ * "email": "example@email.com",
2539
+ * "email_verified": false,
2540
+ * "phone_verified": false,
2541
+ * "sub": "11111111-1111-1111-1111-111111111111"
2542
+ * },
2543
+ * "identities": [
2544
+ * {
2545
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
2546
+ * "id": "11111111-1111-1111-1111-111111111111",
2547
+ * "user_id": "11111111-1111-1111-1111-111111111111",
2548
+ * "identity_data": {
2549
+ * "email": "example@email.com",
2550
+ * "email_verified": false,
2551
+ * "phone_verified": false,
2552
+ * "sub": "11111111-1111-1111-1111-111111111111"
2553
+ * },
2554
+ * "provider": "email",
2555
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2556
+ * "created_at": "2024-01-01T00:00:00Z",
2557
+ * "updated_at": "2024-01-01T00:00:00Z",
2558
+ * "email": "example@email.com"
2559
+ * }
2560
+ * ],
2561
+ * "created_at": "2024-01-01T00:00:00Z",
2562
+ * "updated_at": "2024-01-01T00:00:00Z",
2563
+ * "is_anonymous": false
2564
+ * }
2565
+ * },
2566
+ * "error": null
2567
+ * }
2568
+ * ```
2569
+ *
2570
+ * @exampleDescription Update the phone number for an authenticated user
2571
+ * Sends a one-time password (OTP) to the new phone number.
2572
+ *
2573
+ * @example Update the phone number for an authenticated user
2574
+ * ```js
2575
+ * const { data, error } = await supabase.auth.updateUser({
2576
+ * phone: '123456789'
2577
+ * })
2578
+ * ```
2579
+ *
2580
+ * @example Update the password for an authenticated user
2581
+ * ```js
2582
+ * const { data, error } = await supabase.auth.updateUser({
2583
+ * password: 'new password'
2584
+ * })
2585
+ * ```
2586
+ *
2587
+ * @exampleDescription Update the user's metadata
2588
+ * Updates the user's custom metadata.
2589
+ *
2590
+ * **Note**: The `data` field maps to the `auth.users.raw_user_meta_data` column in your Supabase database. When calling `getUser()`, the data will be available as `user.user_metadata`.
2591
+ *
2592
+ * @example Update the user's metadata
2593
+ * ```js
2594
+ * const { data, error } = await supabase.auth.updateUser({
2595
+ * data: { hello: 'world' }
2596
+ * })
2597
+ * ```
2598
+ *
2599
+ * @exampleDescription Update the user's password with a nonce
2600
+ * If **Secure password change** is enabled in your [project's email provider settings](/dashboard/project/_/auth/providers), updating the user's password would require a nonce if the user **hasn't recently signed in**. The nonce is sent to the user's email or phone number. A user is deemed recently signed in if the session was created in the last 24 hours.
2601
+ *
2602
+ * @example Update the user's password with a nonce
2603
+ * ```js
2604
+ * const { data, error } = await supabase.auth.updateUser({
2605
+ * password: 'new password',
2606
+ * nonce: '123456'
2607
+ * })
2608
+ * ```
1476
2609
  */
1477
2610
  async updateUser(attributes, options = {}) {
1478
2611
  await this.initializePromise;
@@ -1525,6 +2658,125 @@ class GoTrueClient {
1525
2658
  * Sets the session data from the current session. If the current session is expired, setSession will take care of refreshing it to obtain a new session.
1526
2659
  * If the refresh token or access token in the current session is invalid, an error will be thrown.
1527
2660
  * @param currentSession The current session that minimally contains an access token and refresh token.
2661
+ *
2662
+ * @category Auth
2663
+ *
2664
+ * @remarks
2665
+ * - This method sets the session using an `access_token` and `refresh_token`.
2666
+ * - If successful, a `SIGNED_IN` event is emitted.
2667
+ *
2668
+ * @exampleDescription Set the session
2669
+ * Sets the session data from an access_token and refresh_token, then returns an auth response or error.
2670
+ *
2671
+ * @example Set the session
2672
+ * ```js
2673
+ * const { data, error } = await supabase.auth.setSession({
2674
+ * access_token,
2675
+ * refresh_token
2676
+ * })
2677
+ * ```
2678
+ *
2679
+ * @exampleResponse Set the session
2680
+ * ```json
2681
+ * {
2682
+ * "data": {
2683
+ * "user": {
2684
+ * "id": "11111111-1111-1111-1111-111111111111",
2685
+ * "aud": "authenticated",
2686
+ * "role": "authenticated",
2687
+ * "email": "example@email.com",
2688
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
2689
+ * "phone": "",
2690
+ * "confirmed_at": "2024-01-01T00:00:00Z",
2691
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2692
+ * "app_metadata": {
2693
+ * "provider": "email",
2694
+ * "providers": [
2695
+ * "email"
2696
+ * ]
2697
+ * },
2698
+ * "user_metadata": {
2699
+ * "email": "example@email.com",
2700
+ * "email_verified": false,
2701
+ * "phone_verified": false,
2702
+ * "sub": "11111111-1111-1111-1111-111111111111"
2703
+ * },
2704
+ * "identities": [
2705
+ * {
2706
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
2707
+ * "id": "11111111-1111-1111-1111-111111111111",
2708
+ * "user_id": "11111111-1111-1111-1111-111111111111",
2709
+ * "identity_data": {
2710
+ * "email": "example@email.com",
2711
+ * "email_verified": false,
2712
+ * "phone_verified": false,
2713
+ * "sub": "11111111-1111-1111-1111-111111111111"
2714
+ * },
2715
+ * "provider": "email",
2716
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2717
+ * "created_at": "2024-01-01T00:00:00Z",
2718
+ * "updated_at": "2024-01-01T00:00:00Z",
2719
+ * "email": "example@email.com"
2720
+ * }
2721
+ * ],
2722
+ * "created_at": "2024-01-01T00:00:00Z",
2723
+ * "updated_at": "2024-01-01T00:00:00Z",
2724
+ * "is_anonymous": false
2725
+ * },
2726
+ * "session": {
2727
+ * "access_token": "<ACCESS_TOKEN>",
2728
+ * "refresh_token": "<REFRESH_TOKEN>",
2729
+ * "user": {
2730
+ * "id": "11111111-1111-1111-1111-111111111111",
2731
+ * "aud": "authenticated",
2732
+ * "role": "authenticated",
2733
+ * "email": "example@email.com",
2734
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
2735
+ * "phone": "",
2736
+ * "confirmed_at": "2024-01-01T00:00:00Z",
2737
+ * "last_sign_in_at": "11111111-1111-1111-1111-111111111111",
2738
+ * "app_metadata": {
2739
+ * "provider": "email",
2740
+ * "providers": [
2741
+ * "email"
2742
+ * ]
2743
+ * },
2744
+ * "user_metadata": {
2745
+ * "email": "example@email.com",
2746
+ * "email_verified": false,
2747
+ * "phone_verified": false,
2748
+ * "sub": "11111111-1111-1111-1111-111111111111"
2749
+ * },
2750
+ * "identities": [
2751
+ * {
2752
+ * "identity_id": "2024-01-01T00:00:00Z",
2753
+ * "id": "11111111-1111-1111-1111-111111111111",
2754
+ * "user_id": "11111111-1111-1111-1111-111111111111",
2755
+ * "identity_data": {
2756
+ * "email": "example@email.com",
2757
+ * "email_verified": false,
2758
+ * "phone_verified": false,
2759
+ * "sub": "11111111-1111-1111-1111-111111111111"
2760
+ * },
2761
+ * "provider": "email",
2762
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2763
+ * "created_at": "2024-01-01T00:00:00Z",
2764
+ * "updated_at": "2024-01-01T00:00:00Z",
2765
+ * "email": "example@email.com"
2766
+ * }
2767
+ * ],
2768
+ * "created_at": "2024-01-01T00:00:00Z",
2769
+ * "updated_at": "2024-01-01T00:00:00Z",
2770
+ * "is_anonymous": false
2771
+ * },
2772
+ * "token_type": "bearer",
2773
+ * "expires_in": 3500,
2774
+ * "expires_at": 1700000000
2775
+ * }
2776
+ * },
2777
+ * "error": null
2778
+ * }
2779
+ * ```
1528
2780
  */
1529
2781
  async setSession(currentSession) {
1530
2782
  await this.initializePromise;
@@ -1586,6 +2838,125 @@ class GoTrueClient {
1586
2838
  * Takes in an optional current session. If not passed in, then refreshSession() will attempt to retrieve it from getSession().
1587
2839
  * If the current session's refresh token is invalid, an error will be thrown.
1588
2840
  * @param currentSession The current session. If passed in, it must contain a refresh token.
2841
+ *
2842
+ * @category Auth
2843
+ *
2844
+ * @remarks
2845
+ * - This method will refresh and return a new session whether the current one is expired or not.
2846
+ *
2847
+ * @example Refresh session using the current session
2848
+ * ```js
2849
+ * const { data, error } = await supabase.auth.refreshSession()
2850
+ * const { session, user } = data
2851
+ * ```
2852
+ *
2853
+ * @exampleResponse Refresh session using the current session
2854
+ * ```json
2855
+ * {
2856
+ * "data": {
2857
+ * "user": {
2858
+ * "id": "11111111-1111-1111-1111-111111111111",
2859
+ * "aud": "authenticated",
2860
+ * "role": "authenticated",
2861
+ * "email": "example@email.com",
2862
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
2863
+ * "phone": "",
2864
+ * "confirmed_at": "2024-01-01T00:00:00Z",
2865
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2866
+ * "app_metadata": {
2867
+ * "provider": "email",
2868
+ * "providers": [
2869
+ * "email"
2870
+ * ]
2871
+ * },
2872
+ * "user_metadata": {
2873
+ * "email": "example@email.com",
2874
+ * "email_verified": false,
2875
+ * "phone_verified": false,
2876
+ * "sub": "11111111-1111-1111-1111-111111111111"
2877
+ * },
2878
+ * "identities": [
2879
+ * {
2880
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
2881
+ * "id": "11111111-1111-1111-1111-111111111111",
2882
+ * "user_id": "11111111-1111-1111-1111-111111111111",
2883
+ * "identity_data": {
2884
+ * "email": "example@email.com",
2885
+ * "email_verified": false,
2886
+ * "phone_verified": false,
2887
+ * "sub": "11111111-1111-1111-1111-111111111111"
2888
+ * },
2889
+ * "provider": "email",
2890
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2891
+ * "created_at": "2024-01-01T00:00:00Z",
2892
+ * "updated_at": "2024-01-01T00:00:00Z",
2893
+ * "email": "example@email.com"
2894
+ * }
2895
+ * ],
2896
+ * "created_at": "2024-01-01T00:00:00Z",
2897
+ * "updated_at": "2024-01-01T00:00:00Z",
2898
+ * "is_anonymous": false
2899
+ * },
2900
+ * "session": {
2901
+ * "access_token": "<ACCESS_TOKEN>",
2902
+ * "token_type": "bearer",
2903
+ * "expires_in": 3600,
2904
+ * "expires_at": 1700000000,
2905
+ * "refresh_token": "<REFRESH_TOKEN>",
2906
+ * "user": {
2907
+ * "id": "11111111-1111-1111-1111-111111111111",
2908
+ * "aud": "authenticated",
2909
+ * "role": "authenticated",
2910
+ * "email": "example@email.com",
2911
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
2912
+ * "phone": "",
2913
+ * "confirmed_at": "2024-01-01T00:00:00Z",
2914
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2915
+ * "app_metadata": {
2916
+ * "provider": "email",
2917
+ * "providers": [
2918
+ * "email"
2919
+ * ]
2920
+ * },
2921
+ * "user_metadata": {
2922
+ * "email": "example@email.com",
2923
+ * "email_verified": false,
2924
+ * "phone_verified": false,
2925
+ * "sub": "11111111-1111-1111-1111-111111111111"
2926
+ * },
2927
+ * "identities": [
2928
+ * {
2929
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
2930
+ * "id": "11111111-1111-1111-1111-111111111111",
2931
+ * "user_id": "11111111-1111-1111-1111-111111111111",
2932
+ * "identity_data": {
2933
+ * "email": "example@email.com",
2934
+ * "email_verified": false,
2935
+ * "phone_verified": false,
2936
+ * "sub": "11111111-1111-1111-1111-111111111111"
2937
+ * },
2938
+ * "provider": "email",
2939
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
2940
+ * "created_at": "2024-01-01T00:00:00Z",
2941
+ * "updated_at": "2024-01-01T00:00:00Z",
2942
+ * "email": "example@email.com"
2943
+ * }
2944
+ * ],
2945
+ * "created_at": "2024-01-01T00:00:00Z",
2946
+ * "updated_at": "2024-01-01T00:00:00Z",
2947
+ * "is_anonymous": false
2948
+ * }
2949
+ * }
2950
+ * },
2951
+ * "error": null
2952
+ * }
2953
+ * ```
2954
+ *
2955
+ * @example Refresh session using a refresh token
2956
+ * ```js
2957
+ * const { data, error } = await supabase.auth.refreshSession({ refresh_token })
2958
+ * const { session, user } = data
2959
+ * ```
1589
2960
  */
1590
2961
  async refreshSession(currentSession) {
1591
2962
  await this.initializePromise;
@@ -1741,6 +3112,28 @@ class GoTrueClient {
1741
3112
  * There is no way to revoke a user's access token jwt until it expires. It is recommended to set a shorter expiry on the jwt for this reason.
1742
3113
  *
1743
3114
  * If using `others` scope, no `SIGNED_OUT` event is fired!
3115
+ *
3116
+ * @category Auth
3117
+ *
3118
+ * @remarks
3119
+ * - In order to use the `signOut()` method, the user needs to be signed in first.
3120
+ * - By default, `signOut()` uses the global scope, which signs out all other sessions that the user is logged into as well. Customize this behavior by passing a scope parameter.
3121
+ * - Since Supabase Auth uses JWTs for authentication, the access token JWT will be valid until it's expired. When the user signs out, Supabase revokes the refresh token and deletes the JWT from the client-side. This does not revoke the JWT and it will still be valid until it expires.
3122
+ *
3123
+ * @example Sign out (all sessions)
3124
+ * ```js
3125
+ * const { error } = await supabase.auth.signOut()
3126
+ * ```
3127
+ *
3128
+ * @example Sign out (current session)
3129
+ * ```js
3130
+ * const { error } = await supabase.auth.signOut({ scope: 'local' })
3131
+ * ```
3132
+ *
3133
+ * @example Sign out (other sessions)
3134
+ * ```js
3135
+ * const { error } = await supabase.auth.signOut({ scope: 'others' })
3136
+ * ```
1744
3137
  */
1745
3138
  async signOut(options = { scope: 'global' }) {
1746
3139
  await this.initializePromise;
@@ -1775,6 +3168,193 @@ class GoTrueClient {
1775
3168
  return this._returnResult({ error: null });
1776
3169
  });
1777
3170
  }
3171
+ /** *
3172
+ * @category Auth
3173
+ *
3174
+ * @remarks
3175
+ * - Subscribes to important events occurring on the user's session.
3176
+ * - Use on the frontend/client. It is less useful on the server.
3177
+ * - Events are emitted across tabs to keep your application's UI up-to-date. Some events can fire very frequently, based on the number of tabs open. Use a quick and efficient callback function, and defer or debounce as many operations as you can to be performed outside of the callback.
3178
+ * - **Important:** A callback can be an `async` function and it runs synchronously during the processing of the changes causing the event. You can easily create a dead-lock by using `await` on a call to another method of the Supabase library.
3179
+ * - Avoid using `async` functions as callbacks.
3180
+ * - Limit the number of `await` calls in `async` callbacks.
3181
+ * - Do not use other Supabase functions in the callback function. If you must, dispatch the functions once the callback has finished executing. Use this as a quick way to achieve this:
3182
+ * ```js
3183
+ * supabase.auth.onAuthStateChange((event, session) => {
3184
+ * setTimeout(async () => {
3185
+ * // await on other Supabase function here
3186
+ * // this runs right after the callback has finished
3187
+ * }, 0)
3188
+ * })
3189
+ * ```
3190
+ * - Emitted events:
3191
+ * - `INITIAL_SESSION`
3192
+ * - Emitted right after the Supabase client is constructed and the initial session from storage is loaded.
3193
+ * - `SIGNED_IN`
3194
+ * - Emitted each time a user session is confirmed or re-established, including on user sign in and when refocusing a tab.
3195
+ * - Avoid making assumptions as to when this event is fired, this may occur even when the user is already signed in. Instead, check the user object attached to the event to see if a new user has signed in and update your application's UI.
3196
+ * - This event can fire very frequently depending on the number of tabs open in your application.
3197
+ * - `SIGNED_OUT`
3198
+ * - Emitted when the user signs out. This can be after:
3199
+ * - A call to `supabase.auth.signOut()`.
3200
+ * - After the user's session has expired for any reason:
3201
+ * - User has signed out on another device.
3202
+ * - The session has reached its timebox limit or inactivity timeout.
3203
+ * - User has signed in on another device with single session per user enabled.
3204
+ * - Check the [User Sessions](/docs/guides/auth/sessions) docs for more information.
3205
+ * - Use this to clean up any local storage your application has associated with the user.
3206
+ * - `TOKEN_REFRESHED`
3207
+ * - Emitted each time a new access and refresh token are fetched for the signed in user.
3208
+ * - It's best practice and highly recommended to extract the access token (JWT) and store it in memory for further use in your application.
3209
+ * - Avoid frequent calls to `supabase.auth.getSession()` for the same purpose.
3210
+ * - There is a background process that keeps track of when the session should be refreshed so you will always receive valid tokens by listening to this event.
3211
+ * - The frequency of this event is related to the JWT expiry limit configured on your project.
3212
+ * - `USER_UPDATED`
3213
+ * - Emitted each time the `supabase.auth.updateUser()` method finishes successfully. Listen to it to update your application's UI based on new profile information.
3214
+ * - `PASSWORD_RECOVERY`
3215
+ * - Emitted instead of the `SIGNED_IN` event when the user lands on a page that includes a password recovery link in the URL.
3216
+ * - Use it to show a UI to the user where they can [reset their password](/docs/guides/auth/passwords#resetting-a-users-password-forgot-password).
3217
+ *
3218
+ * @example Listen to auth changes
3219
+ * ```js
3220
+ * const { data } = supabase.auth.onAuthStateChange((event, session) => {
3221
+ * console.log(event, session)
3222
+ *
3223
+ * if (event === 'INITIAL_SESSION') {
3224
+ * // handle initial session
3225
+ * } else if (event === 'SIGNED_IN') {
3226
+ * // handle sign in event
3227
+ * } else if (event === 'SIGNED_OUT') {
3228
+ * // handle sign out event
3229
+ * } else if (event === 'PASSWORD_RECOVERY') {
3230
+ * // handle password recovery event
3231
+ * } else if (event === 'TOKEN_REFRESHED') {
3232
+ * // handle token refreshed event
3233
+ * } else if (event === 'USER_UPDATED') {
3234
+ * // handle user updated event
3235
+ * }
3236
+ * })
3237
+ *
3238
+ * // call unsubscribe to remove the callback
3239
+ * data.subscription.unsubscribe()
3240
+ * ```
3241
+ *
3242
+ * @exampleDescription Listen to sign out
3243
+ * Make sure you clear out any local data, such as local and session storage, after the client library has detected the user's sign out.
3244
+ *
3245
+ * @example Listen to sign out
3246
+ * ```js
3247
+ * supabase.auth.onAuthStateChange((event, session) => {
3248
+ * if (event === 'SIGNED_OUT') {
3249
+ * console.log('SIGNED_OUT', session)
3250
+ *
3251
+ * // clear local and session storage
3252
+ * [
3253
+ * window.localStorage,
3254
+ * window.sessionStorage,
3255
+ * ].forEach((storage) => {
3256
+ * Object.entries(storage)
3257
+ * .forEach(([key]) => {
3258
+ * storage.removeItem(key)
3259
+ * })
3260
+ * })
3261
+ * }
3262
+ * })
3263
+ * ```
3264
+ *
3265
+ * @exampleDescription Store OAuth provider tokens on sign in
3266
+ * When using [OAuth (Social Login)](/docs/guides/auth/social-login) you sometimes wish to get access to the provider's access token and refresh token, in order to call provider APIs in the name of the user.
3267
+ *
3268
+ * For example, if you are using [Sign in with Google](/docs/guides/auth/social-login/auth-google) you may want to use the provider token to call Google APIs on behalf of the user. Supabase Auth does not keep track of the provider access and refresh token, but does return them for you once, immediately after sign in. You can use the `onAuthStateChange` method to listen for the presence of the provider tokens and store them in local storage. You can further send them to your server's APIs for use on the backend.
3269
+ *
3270
+ * Finally, make sure you remove them from local storage on the `SIGNED_OUT` event. If the OAuth provider supports token revocation, make sure you call those APIs either from the frontend or schedule them to be called on the backend.
3271
+ *
3272
+ * @example Store OAuth provider tokens on sign in
3273
+ * ```js
3274
+ * // Register this immediately after calling createClient!
3275
+ * // Because signInWithOAuth causes a redirect, you need to fetch the
3276
+ * // provider tokens from the callback.
3277
+ * supabase.auth.onAuthStateChange((event, session) => {
3278
+ * if (session && session.provider_token) {
3279
+ * window.localStorage.setItem('oauth_provider_token', session.provider_token)
3280
+ * }
3281
+ *
3282
+ * if (session && session.provider_refresh_token) {
3283
+ * window.localStorage.setItem('oauth_provider_refresh_token', session.provider_refresh_token)
3284
+ * }
3285
+ *
3286
+ * if (event === 'SIGNED_OUT') {
3287
+ * window.localStorage.removeItem('oauth_provider_token')
3288
+ * window.localStorage.removeItem('oauth_provider_refresh_token')
3289
+ * }
3290
+ * })
3291
+ * ```
3292
+ *
3293
+ * @exampleDescription Use React Context for the User's session
3294
+ * Instead of relying on `supabase.auth.getSession()` within your React components, you can use a [React Context](https://react.dev/reference/react/createContext) to store the latest session information from the `onAuthStateChange` callback and access it that way.
3295
+ *
3296
+ * @example Use React Context for the User's session
3297
+ * ```js
3298
+ * const SessionContext = React.createContext(null)
3299
+ *
3300
+ * function main() {
3301
+ * const [session, setSession] = React.useState(null)
3302
+ *
3303
+ * React.useEffect(() => {
3304
+ * const {data: { subscription }} = supabase.auth.onAuthStateChange(
3305
+ * (event, session) => {
3306
+ * if (event === 'SIGNED_OUT') {
3307
+ * setSession(null)
3308
+ * } else if (session) {
3309
+ * setSession(session)
3310
+ * }
3311
+ * })
3312
+ *
3313
+ * return () => {
3314
+ * subscription.unsubscribe()
3315
+ * }
3316
+ * }, [])
3317
+ *
3318
+ * return (
3319
+ * <SessionContext.Provider value={session}>
3320
+ * <App />
3321
+ * </SessionContext.Provider>
3322
+ * )
3323
+ * }
3324
+ * ```
3325
+ *
3326
+ * @example Listen to password recovery events
3327
+ * ```js
3328
+ * supabase.auth.onAuthStateChange((event, session) => {
3329
+ * if (event === 'PASSWORD_RECOVERY') {
3330
+ * console.log('PASSWORD_RECOVERY', session)
3331
+ * // show screen to update user's password
3332
+ * showPasswordResetScreen(true)
3333
+ * }
3334
+ * })
3335
+ * ```
3336
+ *
3337
+ * @example Listen to sign in
3338
+ * ```js
3339
+ * supabase.auth.onAuthStateChange((event, session) => {
3340
+ * if (event === 'SIGNED_IN') console.log('SIGNED_IN', session)
3341
+ * })
3342
+ * ```
3343
+ *
3344
+ * @example Listen to token refresh
3345
+ * ```js
3346
+ * supabase.auth.onAuthStateChange((event, session) => {
3347
+ * if (event === 'TOKEN_REFRESHED') console.log('TOKEN_REFRESHED', session)
3348
+ * })
3349
+ * ```
3350
+ *
3351
+ * @example Listen to user updates
3352
+ * ```js
3353
+ * supabase.auth.onAuthStateChange((event, session) => {
3354
+ * if (event === 'USER_UPDATED') console.log('USER_UPDATED', session)
3355
+ * })
3356
+ * ```
3357
+ */
1778
3358
  onAuthStateChange(callback) {
1779
3359
  const id = generateCallbackId();
1780
3360
  const subscription = {
@@ -1818,6 +3398,66 @@ class GoTrueClient {
1818
3398
  * @param email The email address of the user.
1819
3399
  * @param options.redirectTo The URL to send the user to after they click the password reset link.
1820
3400
  * @param options.captchaToken Verification token received when the user completes the captcha on the site.
3401
+ *
3402
+ * @category Auth
3403
+ *
3404
+ * @remarks
3405
+ * - The password reset flow consist of 2 broad steps: (i) Allow the user to login via the password reset link; (ii) Update the user's password.
3406
+ * - The `resetPasswordForEmail()` only sends a password reset link to the user's email.
3407
+ * To update the user's password, see [`updateUser()`](/docs/reference/javascript/auth-updateuser).
3408
+ * - A `PASSWORD_RECOVERY` event will be emitted when the password recovery link is clicked.
3409
+ * You can use [`onAuthStateChange()`](/docs/reference/javascript/auth-onauthstatechange) to listen and invoke a callback function on these events.
3410
+ * - When the user clicks the reset link in the email they are redirected back to your application.
3411
+ * You can configure the URL that the user is redirected to with the `redirectTo` parameter.
3412
+ * See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project.
3413
+ * - After the user has been redirected successfully, prompt them for a new password and call `updateUser()`:
3414
+ * ```js
3415
+ * const { data, error } = await supabase.auth.updateUser({
3416
+ * password: new_password
3417
+ * })
3418
+ * ```
3419
+ *
3420
+ * @example Reset password
3421
+ * ```js
3422
+ * const { data, error } = await supabase.auth.resetPasswordForEmail(email, {
3423
+ * redirectTo: 'https://example.com/update-password',
3424
+ * })
3425
+ * ```
3426
+ *
3427
+ * @exampleResponse Reset password
3428
+ * ```json
3429
+ * {
3430
+ * data: {}
3431
+ * error: null
3432
+ * }
3433
+ * ```
3434
+ *
3435
+ * @example Reset password (React)
3436
+ * ```js
3437
+ * /**
3438
+ * * Step 1: Send the user an email to get a password reset token.
3439
+ * * This email contains a link which sends the user back to your application.
3440
+ * *\/
3441
+ * const { data, error } = await supabase.auth
3442
+ * .resetPasswordForEmail('user@email.com')
3443
+ *
3444
+ * /**
3445
+ * * Step 2: Once the user is redirected back to your application,
3446
+ * * ask the user to reset their password.
3447
+ * *\/
3448
+ * useEffect(() => {
3449
+ * supabase.auth.onAuthStateChange(async (event, session) => {
3450
+ * if (event == "PASSWORD_RECOVERY") {
3451
+ * const newPassword = prompt("What would you like your new password to be?");
3452
+ * const { data, error } = await supabase.auth
3453
+ * .updateUser({ password: newPassword })
3454
+ *
3455
+ * if (data) alert("Password updated successfully!")
3456
+ * if (error) alert("There was an error updating your password.")
3457
+ * }
3458
+ * })
3459
+ * }, [])
3460
+ * ```
1821
3461
  */
1822
3462
  async resetPasswordForEmail(email, options = {}) {
1823
3463
  let codeChallenge = null;
@@ -1849,6 +3489,43 @@ class GoTrueClient {
1849
3489
  }
1850
3490
  /**
1851
3491
  * Gets all the identities linked to a user.
3492
+ *
3493
+ * @category Auth
3494
+ *
3495
+ * @remarks
3496
+ * - The user needs to be signed in to call `getUserIdentities()`.
3497
+ *
3498
+ * @example Returns a list of identities linked to the user
3499
+ * ```js
3500
+ * const { data, error } = await supabase.auth.getUserIdentities()
3501
+ * ```
3502
+ *
3503
+ * @exampleResponse Returns a list of identities linked to the user
3504
+ * ```json
3505
+ * {
3506
+ * "data": {
3507
+ * "identities": [
3508
+ * {
3509
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
3510
+ * "id": "2024-01-01T00:00:00Z",
3511
+ * "user_id": "2024-01-01T00:00:00Z",
3512
+ * "identity_data": {
3513
+ * "email": "example@email.com",
3514
+ * "email_verified": false,
3515
+ * "phone_verified": false,
3516
+ * "sub": "11111111-1111-1111-1111-111111111111"
3517
+ * },
3518
+ * "provider": "email",
3519
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
3520
+ * "created_at": "2024-01-01T00:00:00Z",
3521
+ * "updated_at": "2024-01-01T00:00:00Z",
3522
+ * "email": "example@email.com"
3523
+ * }
3524
+ * ]
3525
+ * },
3526
+ * "error": null
3527
+ * }
3528
+ * ```
1852
3529
  */
1853
3530
  async getUserIdentities() {
1854
3531
  var _a;
@@ -1865,6 +3542,33 @@ class GoTrueClient {
1865
3542
  throw error;
1866
3543
  }
1867
3544
  }
3545
+ /** *
3546
+ * @category Auth
3547
+ *
3548
+ * @remarks
3549
+ * - The **Enable Manual Linking** option must be enabled from your [project's authentication settings](/dashboard/project/_/auth/providers).
3550
+ * - The user needs to be signed in to call `linkIdentity()`.
3551
+ * - If the candidate identity is already linked to the existing user or another user, `linkIdentity()` will fail.
3552
+ * - If `linkIdentity` is run in the browser, the user is automatically redirected to the returned URL. On the server, you should handle the redirect.
3553
+ *
3554
+ * @example Link an identity to a user
3555
+ * ```js
3556
+ * const { data, error } = await supabase.auth.linkIdentity({
3557
+ * provider: 'github'
3558
+ * })
3559
+ * ```
3560
+ *
3561
+ * @exampleResponse Link an identity to a user
3562
+ * ```json
3563
+ * {
3564
+ * data: {
3565
+ * provider: 'github',
3566
+ * url: <PROVIDER_URL_TO_REDIRECT_TO>
3567
+ * },
3568
+ * error: null
3569
+ * }
3570
+ * ```
3571
+ */
1868
3572
  async linkIdentity(credentials) {
1869
3573
  if ('token' in credentials) {
1870
3574
  return this.linkIdentityIdToken(credentials);
@@ -1955,6 +3659,28 @@ class GoTrueClient {
1955
3659
  }
1956
3660
  /**
1957
3661
  * Unlinks an identity from a user by deleting it. The user will no longer be able to sign in with that identity once it's unlinked.
3662
+ *
3663
+ * @category Auth
3664
+ *
3665
+ * @remarks
3666
+ * - The **Enable Manual Linking** option must be enabled from your [project's authentication settings](/dashboard/project/_/auth/providers).
3667
+ * - The user needs to be signed in to call `unlinkIdentity()`.
3668
+ * - The user must have at least 2 identities in order to unlink an identity.
3669
+ * - The identity to be unlinked must belong to the user.
3670
+ *
3671
+ * @example Unlink an identity
3672
+ * ```js
3673
+ * // retrieve all identities linked to a user
3674
+ * const identities = await supabase.auth.getUserIdentities()
3675
+ *
3676
+ * // find the google identity
3677
+ * const googleIdentity = identities.find(
3678
+ * identity => identity.provider === 'google'
3679
+ * )
3680
+ *
3681
+ * // unlink the google identity
3682
+ * const { error } = await supabase.auth.unlinkIdentity(googleIdentity)
3683
+ * ```
1958
3684
  */
1959
3685
  async unlinkIdentity(identity) {
1960
3686
  try {
@@ -2353,6 +4079,28 @@ class GoTrueClient {
2353
4079
  * appropriately to conserve resources.
2354
4080
  *
2355
4081
  * {@see #stopAutoRefresh}
4082
+ *
4083
+ * @category Auth
4084
+ *
4085
+ * @remarks
4086
+ * - Only useful in non-browser environments such as React Native or Electron.
4087
+ * - The Supabase Auth library automatically starts and stops proactively refreshing the session when a tab is focused or not.
4088
+ * - On non-browser platforms, such as mobile or desktop apps built with web technologies, the library is not able to effectively determine whether the application is _focused_ or not.
4089
+ * - To give this hint to the application, you should be calling this method when the app is in focus and calling `supabase.auth.stopAutoRefresh()` when it's out of focus.
4090
+ *
4091
+ * @example Start and stop auto refresh in React Native
4092
+ * ```js
4093
+ * import { AppState } from 'react-native'
4094
+ *
4095
+ * // make sure you register this only once!
4096
+ * AppState.addEventListener('change', (state) => {
4097
+ * if (state === 'active') {
4098
+ * supabase.auth.startAutoRefresh()
4099
+ * } else {
4100
+ * supabase.auth.stopAutoRefresh()
4101
+ * }
4102
+ * })
4103
+ * ```
2356
4104
  */
2357
4105
  async startAutoRefresh() {
2358
4106
  this._removeVisibilityChangedCallback();
@@ -2365,6 +4113,28 @@ class GoTrueClient {
2365
4113
  * removed and you must manage visibility changes on your own.
2366
4114
  *
2367
4115
  * See {@link #startAutoRefresh} for more details.
4116
+ *
4117
+ * @category Auth
4118
+ *
4119
+ * @remarks
4120
+ * - Only useful in non-browser environments such as React Native or Electron.
4121
+ * - The Supabase Auth library automatically starts and stops proactively refreshing the session when a tab is focused or not.
4122
+ * - On non-browser platforms, such as mobile or desktop apps built with web technologies, the library is not able to effectively determine whether the application is _focused_ or not.
4123
+ * - When your application goes in the background or out of focus, call this method to stop the proactive refreshing of the session.
4124
+ *
4125
+ * @example Start and stop auto refresh in React Native
4126
+ * ```js
4127
+ * import { AppState } from 'react-native'
4128
+ *
4129
+ * // make sure you register this only once!
4130
+ * AppState.addEventListener('change', (state) => {
4131
+ * if (state === 'active') {
4132
+ * supabase.auth.startAutoRefresh()
4133
+ * } else {
4134
+ * supabase.auth.stopAutoRefresh()
4135
+ * }
4136
+ * })
4137
+ * ```
2368
4138
  */
2369
4139
  async stopAutoRefresh() {
2370
4140
  this._removeVisibilityChangedCallback();
@@ -2955,6 +4725,55 @@ class GoTrueClient {
2955
4725
  * can obtain from {@link #getSession}.
2956
4726
  * @param options Various additional options that allow you to customize the
2957
4727
  * behavior of this method.
4728
+ *
4729
+ * @category Auth
4730
+ *
4731
+ * @remarks
4732
+ * - Parses the user's [access token](/docs/guides/auth/sessions#access-token-jwt-claims) as a [JSON Web Token (JWT)](/docs/guides/auth/jwts) and returns its components if valid and not expired.
4733
+ * - If your project is using asymmetric JWT signing keys, then the verification is done locally usually without a network request using the [WebCrypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API).
4734
+ * - A network request is sent to your project's JWT signing key discovery endpoint `https://project-id.supabase.co/auth/v1/.well-known/jwks.json`, which is cached locally. If your environment is ephemeral, such as a Lambda function that is destroyed after every request, a network request will be sent for each new invocation. Supabase provides a network-edge cache providing fast responses for these situations.
4735
+ * - If the user's access token is about to expire when calling this function, the user's session will first be refreshed before validating the JWT.
4736
+ * - If your project is using a symmetric secret to sign the JWT, it always sends a request similar to `getUser()` to validate the JWT at the server before returning the decoded token. This is also used if the WebCrypto API is not available in the environment. Make sure you polyfill it in such situations.
4737
+ * - The returned claims can be customized per project using the [Custom Access Token Hook](/docs/guides/auth/auth-hooks/custom-access-token-hook).
4738
+ *
4739
+ * @example Get JWT claims, header and signature
4740
+ * ```js
4741
+ * const { data, error } = await supabase.auth.getClaims()
4742
+ * ```
4743
+ *
4744
+ * @exampleResponse Get JWT claims, header and signature
4745
+ * ```json
4746
+ * {
4747
+ * "data": {
4748
+ * "claims": {
4749
+ * "aal": "aal1",
4750
+ * "amr": [{
4751
+ * "method": "email",
4752
+ * "timestamp": 1715766000
4753
+ * }],
4754
+ * "app_metadata": {},
4755
+ * "aud": "authenticated",
4756
+ * "email": "example@email.com",
4757
+ * "exp": 1715769600,
4758
+ * "iat": 1715766000,
4759
+ * "is_anonymous": false,
4760
+ * "iss": "https://project-id.supabase.co/auth/v1",
4761
+ * "phone": "+13334445555",
4762
+ * "role": "authenticated",
4763
+ * "session_id": "11111111-1111-1111-1111-111111111111",
4764
+ * "sub": "11111111-1111-1111-1111-111111111111",
4765
+ * "user_metadata": {}
4766
+ * },
4767
+ * "header": {
4768
+ * "alg": "RS256",
4769
+ * "typ": "JWT",
4770
+ * "kid": "11111111-1111-1111-1111-111111111111"
4771
+ * },
4772
+ * "signature": [/** Uint8Array *\/],
4773
+ * },
4774
+ * "error": null
4775
+ * }
4776
+ * ```
2958
4777
  */
2959
4778
  async getClaims(jwt, options = {}) {
2960
4779
  try {