@depup/supabase__auth-js 2.99.2-depup.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 (195) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +25 -0
  3. package/changes.json +5 -0
  4. package/dist/main/AuthAdminApi.d.ts +4 -0
  5. package/dist/main/AuthAdminApi.d.ts.map +1 -0
  6. package/dist/main/AuthAdminApi.js +7 -0
  7. package/dist/main/AuthAdminApi.js.map +1 -0
  8. package/dist/main/AuthClient.d.ts +4 -0
  9. package/dist/main/AuthClient.d.ts.map +1 -0
  10. package/dist/main/AuthClient.js +7 -0
  11. package/dist/main/AuthClient.js.map +1 -0
  12. package/dist/main/GoTrueAdminApi.d.ts +227 -0
  13. package/dist/main/GoTrueAdminApi.d.ts.map +1 -0
  14. package/dist/main/GoTrueAdminApi.js +596 -0
  15. package/dist/main/GoTrueAdminApi.js.map +1 -0
  16. package/dist/main/GoTrueClient.d.ts +783 -0
  17. package/dist/main/GoTrueClient.d.ts.map +1 -0
  18. package/dist/main/GoTrueClient.js +3029 -0
  19. package/dist/main/GoTrueClient.js.map +1 -0
  20. package/dist/main/index.d.ts +9 -0
  21. package/dist/main/index.d.ts.map +1 -0
  22. package/dist/main/index.js +20 -0
  23. package/dist/main/index.js.map +1 -0
  24. package/dist/main/lib/base64url.d.ts +76 -0
  25. package/dist/main/lib/base64url.d.ts.map +1 -0
  26. package/dist/main/lib/base64url.js +269 -0
  27. package/dist/main/lib/base64url.js.map +1 -0
  28. package/dist/main/lib/constants.d.ts +26 -0
  29. package/dist/main/lib/constants.d.ts.map +1 -0
  30. package/dist/main/lib/constants.js +31 -0
  31. package/dist/main/lib/constants.js.map +1 -0
  32. package/dist/main/lib/error-codes.d.ts +7 -0
  33. package/dist/main/lib/error-codes.d.ts.map +1 -0
  34. package/dist/main/lib/error-codes.js +3 -0
  35. package/dist/main/lib/error-codes.js.map +1 -0
  36. package/dist/main/lib/errors.d.ts +243 -0
  37. package/dist/main/lib/errors.d.ts.map +1 -0
  38. package/dist/main/lib/errors.js +289 -0
  39. package/dist/main/lib/errors.js.map +1 -0
  40. package/dist/main/lib/fetch.d.ts +34 -0
  41. package/dist/main/lib/fetch.d.ts.map +1 -0
  42. package/dist/main/lib/fetch.js +184 -0
  43. package/dist/main/lib/fetch.js.map +1 -0
  44. package/dist/main/lib/helpers.d.ts +91 -0
  45. package/dist/main/lib/helpers.d.ts.map +1 -0
  46. package/dist/main/lib/helpers.js +395 -0
  47. package/dist/main/lib/helpers.js.map +1 -0
  48. package/dist/main/lib/local-storage.d.ts +9 -0
  49. package/dist/main/lib/local-storage.d.ts.map +1 -0
  50. package/dist/main/lib/local-storage.js +21 -0
  51. package/dist/main/lib/local-storage.js.map +1 -0
  52. package/dist/main/lib/locks.d.ts +107 -0
  53. package/dist/main/lib/locks.d.ts.map +1 -0
  54. package/dist/main/lib/locks.js +314 -0
  55. package/dist/main/lib/locks.js.map +1 -0
  56. package/dist/main/lib/polyfills.d.ts +5 -0
  57. package/dist/main/lib/polyfills.d.ts.map +1 -0
  58. package/dist/main/lib/polyfills.js +29 -0
  59. package/dist/main/lib/polyfills.js.map +1 -0
  60. package/dist/main/lib/types.d.ts +1861 -0
  61. package/dist/main/lib/types.d.ts.map +1 -0
  62. package/dist/main/lib/types.js +23 -0
  63. package/dist/main/lib/types.js.map +1 -0
  64. package/dist/main/lib/version.d.ts +2 -0
  65. package/dist/main/lib/version.d.ts.map +1 -0
  66. package/dist/main/lib/version.js +11 -0
  67. package/dist/main/lib/version.js.map +1 -0
  68. package/dist/main/lib/web3/ethereum.d.ts +96 -0
  69. package/dist/main/lib/web3/ethereum.d.ts.map +1 -0
  70. package/dist/main/lib/web3/ethereum.js +66 -0
  71. package/dist/main/lib/web3/ethereum.js.map +1 -0
  72. package/dist/main/lib/web3/solana.d.ts +160 -0
  73. package/dist/main/lib/web3/solana.d.ts.map +1 -0
  74. package/dist/main/lib/web3/solana.js +4 -0
  75. package/dist/main/lib/web3/solana.js.map +1 -0
  76. package/dist/main/lib/webauthn.d.ts +276 -0
  77. package/dist/main/lib/webauthn.d.ts.map +1 -0
  78. package/dist/main/lib/webauthn.dom.d.ts +583 -0
  79. package/dist/main/lib/webauthn.dom.d.ts.map +1 -0
  80. package/dist/main/lib/webauthn.dom.js +4 -0
  81. package/dist/main/lib/webauthn.dom.js.map +1 -0
  82. package/dist/main/lib/webauthn.errors.d.ts +80 -0
  83. package/dist/main/lib/webauthn.errors.d.ts.map +1 -0
  84. package/dist/main/lib/webauthn.errors.js +265 -0
  85. package/dist/main/lib/webauthn.errors.js.map +1 -0
  86. package/dist/main/lib/webauthn.js +706 -0
  87. package/dist/main/lib/webauthn.js.map +1 -0
  88. package/dist/module/AuthAdminApi.d.ts +4 -0
  89. package/dist/module/AuthAdminApi.d.ts.map +1 -0
  90. package/dist/module/AuthAdminApi.js +4 -0
  91. package/dist/module/AuthAdminApi.js.map +1 -0
  92. package/dist/module/AuthClient.d.ts +4 -0
  93. package/dist/module/AuthClient.d.ts.map +1 -0
  94. package/dist/module/AuthClient.js +4 -0
  95. package/dist/module/AuthClient.js.map +1 -0
  96. package/dist/module/GoTrueAdminApi.d.ts +227 -0
  97. package/dist/module/GoTrueAdminApi.d.ts.map +1 -0
  98. package/dist/module/GoTrueAdminApi.js +593 -0
  99. package/dist/module/GoTrueAdminApi.js.map +1 -0
  100. package/dist/module/GoTrueClient.d.ts +783 -0
  101. package/dist/module/GoTrueClient.d.ts.map +1 -0
  102. package/dist/module/GoTrueClient.js +3026 -0
  103. package/dist/module/GoTrueClient.js.map +1 -0
  104. package/dist/module/index.d.ts +9 -0
  105. package/dist/module/index.d.ts.map +1 -0
  106. package/dist/module/index.js +9 -0
  107. package/dist/module/index.js.map +1 -0
  108. package/dist/module/lib/base64url.d.ts +76 -0
  109. package/dist/module/lib/base64url.d.ts.map +1 -0
  110. package/dist/module/lib/base64url.js +257 -0
  111. package/dist/module/lib/base64url.js.map +1 -0
  112. package/dist/module/lib/constants.d.ts +26 -0
  113. package/dist/module/lib/constants.d.ts.map +1 -0
  114. package/dist/module/lib/constants.js +28 -0
  115. package/dist/module/lib/constants.js.map +1 -0
  116. package/dist/module/lib/error-codes.d.ts +7 -0
  117. package/dist/module/lib/error-codes.d.ts.map +1 -0
  118. package/dist/module/lib/error-codes.js +2 -0
  119. package/dist/module/lib/error-codes.js.map +1 -0
  120. package/dist/module/lib/errors.d.ts +243 -0
  121. package/dist/module/lib/errors.d.ts.map +1 -0
  122. package/dist/module/lib/errors.js +266 -0
  123. package/dist/module/lib/errors.js.map +1 -0
  124. package/dist/module/lib/fetch.d.ts +34 -0
  125. package/dist/module/lib/fetch.d.ts.map +1 -0
  126. package/dist/module/lib/fetch.js +174 -0
  127. package/dist/module/lib/fetch.js.map +1 -0
  128. package/dist/module/lib/helpers.d.ts +91 -0
  129. package/dist/module/lib/helpers.d.ts.map +1 -0
  130. package/dist/module/lib/helpers.js +368 -0
  131. package/dist/module/lib/helpers.js.map +1 -0
  132. package/dist/module/lib/local-storage.d.ts +9 -0
  133. package/dist/module/lib/local-storage.d.ts.map +1 -0
  134. package/dist/module/lib/local-storage.js +18 -0
  135. package/dist/module/lib/local-storage.js.map +1 -0
  136. package/dist/module/lib/locks.d.ts +107 -0
  137. package/dist/module/lib/locks.d.ts.map +1 -0
  138. package/dist/module/lib/locks.js +306 -0
  139. package/dist/module/lib/locks.js.map +1 -0
  140. package/dist/module/lib/polyfills.d.ts +5 -0
  141. package/dist/module/lib/polyfills.d.ts.map +1 -0
  142. package/dist/module/lib/polyfills.js +26 -0
  143. package/dist/module/lib/polyfills.js.map +1 -0
  144. package/dist/module/lib/types.d.ts +1861 -0
  145. package/dist/module/lib/types.d.ts.map +1 -0
  146. package/dist/module/lib/types.js +20 -0
  147. package/dist/module/lib/types.js.map +1 -0
  148. package/dist/module/lib/version.d.ts +2 -0
  149. package/dist/module/lib/version.d.ts.map +1 -0
  150. package/dist/module/lib/version.js +8 -0
  151. package/dist/module/lib/version.js.map +1 -0
  152. package/dist/module/lib/web3/ethereum.d.ts +96 -0
  153. package/dist/module/lib/web3/ethereum.d.ts.map +1 -0
  154. package/dist/module/lib/web3/ethereum.js +60 -0
  155. package/dist/module/lib/web3/ethereum.js.map +1 -0
  156. package/dist/module/lib/web3/solana.d.ts +160 -0
  157. package/dist/module/lib/web3/solana.d.ts.map +1 -0
  158. package/dist/module/lib/web3/solana.js +3 -0
  159. package/dist/module/lib/web3/solana.js.map +1 -0
  160. package/dist/module/lib/webauthn.d.ts +276 -0
  161. package/dist/module/lib/webauthn.d.ts.map +1 -0
  162. package/dist/module/lib/webauthn.dom.d.ts +583 -0
  163. package/dist/module/lib/webauthn.dom.d.ts.map +1 -0
  164. package/dist/module/lib/webauthn.dom.js +3 -0
  165. package/dist/module/lib/webauthn.dom.js.map +1 -0
  166. package/dist/module/lib/webauthn.errors.d.ts +80 -0
  167. package/dist/module/lib/webauthn.errors.d.ts.map +1 -0
  168. package/dist/module/lib/webauthn.errors.js +257 -0
  169. package/dist/module/lib/webauthn.errors.js.map +1 -0
  170. package/dist/module/lib/webauthn.js +689 -0
  171. package/dist/module/lib/webauthn.js.map +1 -0
  172. package/dist/tsconfig.module.tsbuildinfo +1 -0
  173. package/dist/tsconfig.tsbuildinfo +1 -0
  174. package/package.json +56 -0
  175. package/src/AuthAdminApi.ts +5 -0
  176. package/src/AuthClient.ts +5 -0
  177. package/src/GoTrueAdminApi.ts +723 -0
  178. package/src/GoTrueClient.ts +4078 -0
  179. package/src/index.ts +13 -0
  180. package/src/lib/base64url.ts +308 -0
  181. package/src/lib/constants.ts +34 -0
  182. package/src/lib/error-codes.ts +90 -0
  183. package/src/lib/errors.ts +324 -0
  184. package/src/lib/fetch.ts +283 -0
  185. package/src/lib/helpers.ts +463 -0
  186. package/src/lib/local-storage.ts +21 -0
  187. package/src/lib/locks.ts +375 -0
  188. package/src/lib/polyfills.ts +23 -0
  189. package/src/lib/types.ts +2229 -0
  190. package/src/lib/version.ts +7 -0
  191. package/src/lib/web3/ethereum.ts +184 -0
  192. package/src/lib/web3/solana.ts +186 -0
  193. package/src/lib/webauthn.dom.ts +636 -0
  194. package/src/lib/webauthn.errors.ts +317 -0
  195. package/src/lib/webauthn.ts +946 -0
@@ -0,0 +1,783 @@
1
+ import GoTrueAdminApi from './GoTrueAdminApi';
2
+ import { AuthError } from './lib/errors';
3
+ import { Fetch } from './lib/fetch';
4
+ import { Deferred } from './lib/helpers';
5
+ import type { AuthChangeEvent, AuthFlowType, AuthOtpResponse, AuthResponse, AuthTokenResponse, AuthTokenResponsePassword, CallRefreshTokenResult, GoTrueClientOptions, GoTrueMFAApi, InitializeResult, JWK, JwtHeader, JwtPayload, LockFunc, OAuthResponse, AuthOAuthServerApi, ResendParams, Session, SignInAnonymouslyCredentials, SignInWithIdTokenCredentials, SignInWithOAuthCredentials, SignInWithPasswordCredentials, SignInWithPasswordlessCredentials, SignInWithSSO, SignOut, SignUpWithPasswordCredentials, SSOResponse, Subscription, SupportedStorage, User, UserAttributes, UserIdentity, UserResponse, VerifyOtpParams, Web3Credentials } from './lib/types';
6
+ export default class GoTrueClient {
7
+ private static nextInstanceID;
8
+ private instanceID;
9
+ /**
10
+ * Namespace for the GoTrue admin methods.
11
+ * These methods should only be used in a trusted server-side environment.
12
+ */
13
+ admin: GoTrueAdminApi;
14
+ /**
15
+ * Namespace for the MFA methods.
16
+ */
17
+ mfa: GoTrueMFAApi;
18
+ /**
19
+ * Namespace for the OAuth 2.1 authorization server methods.
20
+ * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
21
+ * Used to implement the authorization code flow on the consent page.
22
+ */
23
+ oauth: AuthOAuthServerApi;
24
+ /**
25
+ * The storage key used to identify the values saved in localStorage
26
+ */
27
+ protected storageKey: string;
28
+ protected flowType: AuthFlowType;
29
+ /**
30
+ * The JWKS used for verifying asymmetric JWTs
31
+ */
32
+ protected get jwks(): {
33
+ keys: JWK[];
34
+ };
35
+ protected set jwks(value: {
36
+ keys: JWK[];
37
+ });
38
+ protected get jwks_cached_at(): number;
39
+ protected set jwks_cached_at(value: number);
40
+ protected autoRefreshToken: boolean;
41
+ protected persistSession: boolean;
42
+ protected storage: SupportedStorage;
43
+ /**
44
+ * @experimental
45
+ */
46
+ protected userStorage: SupportedStorage | null;
47
+ protected memoryStorage: {
48
+ [key: string]: string;
49
+ } | null;
50
+ protected stateChangeEmitters: Map<string | symbol, Subscription>;
51
+ protected autoRefreshTicker: ReturnType<typeof setInterval> | null;
52
+ protected autoRefreshTickTimeout: ReturnType<typeof setTimeout> | null;
53
+ protected visibilityChangedCallback: (() => Promise<any>) | null;
54
+ protected refreshingDeferred: Deferred<CallRefreshTokenResult> | null;
55
+ /**
56
+ * Keeps track of the async client initialization.
57
+ * When null or not yet resolved the auth state is `unknown`
58
+ * Once resolved the auth state is known and it's safe to call any further client methods.
59
+ * Keep extra care to never reject or throw uncaught errors
60
+ */
61
+ protected initializePromise: Promise<InitializeResult> | null;
62
+ protected detectSessionInUrl: boolean | ((url: URL, params: {
63
+ [parameter: string]: string;
64
+ }) => boolean);
65
+ protected url: string;
66
+ protected headers: {
67
+ [key: string]: string;
68
+ };
69
+ protected hasCustomAuthorizationHeader: boolean;
70
+ protected suppressGetSessionWarning: boolean;
71
+ protected fetch: Fetch;
72
+ protected lock: LockFunc;
73
+ protected lockAcquired: boolean;
74
+ protected pendingInLock: Promise<any>[];
75
+ protected throwOnError: boolean;
76
+ protected lockAcquireTimeout: number;
77
+ /**
78
+ * Used to broadcast state change events to other tabs listening.
79
+ */
80
+ protected broadcastChannel: BroadcastChannel | null;
81
+ protected logDebugMessages: boolean;
82
+ protected logger: (message: string, ...args: any[]) => void;
83
+ /**
84
+ * Create a new client for use in the browser.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * import { GoTrueClient } from '@supabase/auth-js'
89
+ *
90
+ * const auth = new GoTrueClient({
91
+ * url: 'https://xyzcompany.supabase.co/auth/v1',
92
+ * headers: { apikey: 'public-anon-key' },
93
+ * storageKey: 'supabase-auth',
94
+ * })
95
+ * ```
96
+ */
97
+ constructor(options: GoTrueClientOptions);
98
+ /**
99
+ * Returns whether error throwing mode is enabled for this client.
100
+ */
101
+ isThrowOnErrorEnabled(): boolean;
102
+ /**
103
+ * Centralizes return handling with optional error throwing. When `throwOnError` is enabled
104
+ * and the provided result contains a non-nullish error, the error is thrown instead of
105
+ * being returned. This ensures consistent behavior across all public API methods.
106
+ */
107
+ private _returnResult;
108
+ private _logPrefix;
109
+ private _debug;
110
+ /**
111
+ * Initializes the client session either from the url or from storage.
112
+ * This method is automatically called when instantiating the client, but should also be called
113
+ * manually when checking for an error from an auth redirect (oauth, magiclink, password recovery, etc).
114
+ */
115
+ initialize(): Promise<InitializeResult>;
116
+ /**
117
+ * IMPORTANT:
118
+ * 1. Never throw in this method, as it is called from the constructor
119
+ * 2. Never return a session from this method as it would be cached over
120
+ * the whole lifetime of the client
121
+ */
122
+ private _initialize;
123
+ /**
124
+ * Creates a new anonymous user.
125
+ *
126
+ * @returns A session where the is_anonymous claim in the access token JWT set to true
127
+ */
128
+ signInAnonymously(credentials?: SignInAnonymouslyCredentials): Promise<AuthResponse>;
129
+ /**
130
+ * Creates a new user.
131
+ *
132
+ * Be aware that if a user account exists in the system you may get back an
133
+ * error message that attempts to hide this information from the user.
134
+ * This method has support for PKCE via email signups. The PKCE flow cannot be used when autoconfirm is enabled.
135
+ *
136
+ * @returns A logged-in session if the server has "autoconfirm" ON
137
+ * @returns A user if the server has "autoconfirm" OFF
138
+ *
139
+ * @category Auth
140
+ *
141
+ * @remarks
142
+ * - By default, the user needs to verify their email address before logging in. To turn this off, disable **Confirm email** in [your project](/dashboard/project/_/auth/providers).
143
+ * - **Confirm email** determines if users need to confirm their email address after signing up.
144
+ * - If **Confirm email** is enabled, a `user` is returned but `session` is null.
145
+ * - If **Confirm email** is disabled, both a `user` and a `session` are returned.
146
+ * - When the user confirms their email address, they are redirected to the [`SITE_URL`](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) by default. You can modify your `SITE_URL` or add additional redirect URLs in [your project](/dashboard/project/_/auth/url-configuration).
147
+ * - If signUp() is called for an existing confirmed user:
148
+ * - When both **Confirm email** and **Confirm phone** (even when phone provider is disabled) are enabled in [your project](/dashboard/project/_/auth/providers), an obfuscated/fake user object is returned.
149
+ * - When either **Confirm email** or **Confirm phone** (even when phone provider is disabled) is disabled, the error message, `User already registered` is returned.
150
+ * - To fetch the currently logged-in user, refer to [`getUser()`](/docs/reference/javascript/auth-getuser).
151
+ *
152
+ * @example Sign up with an email and password
153
+ * ```js
154
+ * const { data, error } = await supabase.auth.signUp({
155
+ * email: 'example@email.com',
156
+ * password: 'example-password',
157
+ * })
158
+ * ```
159
+ *
160
+ * @exampleResponse Sign up with an email and password
161
+ * ```json
162
+ * // Some fields may be null if "confirm email" is enabled.
163
+ * {
164
+ * "data": {
165
+ * "user": {
166
+ * "id": "11111111-1111-1111-1111-111111111111",
167
+ * "aud": "authenticated",
168
+ * "role": "authenticated",
169
+ * "email": "example@email.com",
170
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
171
+ * "phone": "",
172
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
173
+ * "app_metadata": {
174
+ * "provider": "email",
175
+ * "providers": [
176
+ * "email"
177
+ * ]
178
+ * },
179
+ * "user_metadata": {},
180
+ * "identities": [
181
+ * {
182
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
183
+ * "id": "11111111-1111-1111-1111-111111111111",
184
+ * "user_id": "11111111-1111-1111-1111-111111111111",
185
+ * "identity_data": {
186
+ * "email": "example@email.com",
187
+ * "email_verified": false,
188
+ * "phone_verified": false,
189
+ * "sub": "11111111-1111-1111-1111-111111111111"
190
+ * },
191
+ * "provider": "email",
192
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
193
+ * "created_at": "2024-01-01T00:00:00Z",
194
+ * "updated_at": "2024-01-01T00:00:00Z",
195
+ * "email": "example@email.com"
196
+ * }
197
+ * ],
198
+ * "created_at": "2024-01-01T00:00:00Z",
199
+ * "updated_at": "2024-01-01T00:00:00Z"
200
+ * },
201
+ * "session": {
202
+ * "access_token": "<ACCESS_TOKEN>",
203
+ * "token_type": "bearer",
204
+ * "expires_in": 3600,
205
+ * "expires_at": 1700000000,
206
+ * "refresh_token": "<REFRESH_TOKEN>",
207
+ * "user": {
208
+ * "id": "11111111-1111-1111-1111-111111111111",
209
+ * "aud": "authenticated",
210
+ * "role": "authenticated",
211
+ * "email": "example@email.com",
212
+ * "email_confirmed_at": "2024-01-01T00:00:00Z",
213
+ * "phone": "",
214
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
215
+ * "app_metadata": {
216
+ * "provider": "email",
217
+ * "providers": [
218
+ * "email"
219
+ * ]
220
+ * },
221
+ * "user_metadata": {},
222
+ * "identities": [
223
+ * {
224
+ * "identity_id": "22222222-2222-2222-2222-222222222222",
225
+ * "id": "11111111-1111-1111-1111-111111111111",
226
+ * "user_id": "11111111-1111-1111-1111-111111111111",
227
+ * "identity_data": {
228
+ * "email": "example@email.com",
229
+ * "email_verified": false,
230
+ * "phone_verified": false,
231
+ * "sub": "11111111-1111-1111-1111-111111111111"
232
+ * },
233
+ * "provider": "email",
234
+ * "last_sign_in_at": "2024-01-01T00:00:00Z",
235
+ * "created_at": "2024-01-01T00:00:00Z",
236
+ * "updated_at": "2024-01-01T00:00:00Z",
237
+ * "email": "example@email.com"
238
+ * }
239
+ * ],
240
+ * "created_at": "2024-01-01T00:00:00Z",
241
+ * "updated_at": "2024-01-01T00:00:00Z"
242
+ * }
243
+ * }
244
+ * },
245
+ * "error": null
246
+ * }
247
+ * ```
248
+ *
249
+ * @example Sign up with a phone number and password (SMS)
250
+ * ```js
251
+ * const { data, error } = await supabase.auth.signUp({
252
+ * phone: '123456789',
253
+ * password: 'example-password',
254
+ * options: {
255
+ * channel: 'sms'
256
+ * }
257
+ * })
258
+ * ```
259
+ *
260
+ * @exampleDescription Sign up with a phone number and password (whatsapp)
261
+ * 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.
262
+ *
263
+ * @example Sign up with a phone number and password (whatsapp)
264
+ * ```js
265
+ * const { data, error } = await supabase.auth.signUp({
266
+ * phone: '123456789',
267
+ * password: 'example-password',
268
+ * options: {
269
+ * channel: 'whatsapp'
270
+ * }
271
+ * })
272
+ * ```
273
+ *
274
+ * @example Sign up with additional user metadata
275
+ * ```js
276
+ * const { data, error } = await supabase.auth.signUp(
277
+ * {
278
+ * email: 'example@email.com',
279
+ * password: 'example-password',
280
+ * options: {
281
+ * data: {
282
+ * first_name: 'John',
283
+ * age: 27,
284
+ * }
285
+ * }
286
+ * }
287
+ * )
288
+ * ```
289
+ *
290
+ * @exampleDescription Sign up with a redirect URL
291
+ * - See [redirect URLs and wildcards](/docs/guides/auth/redirect-urls#use-wildcards-in-redirect-urls) to add additional redirect URLs to your project.
292
+ *
293
+ * @example Sign up with a redirect URL
294
+ * ```js
295
+ * const { data, error } = await supabase.auth.signUp(
296
+ * {
297
+ * email: 'example@email.com',
298
+ * password: 'example-password',
299
+ * options: {
300
+ * emailRedirectTo: 'https://example.com/welcome'
301
+ * }
302
+ * }
303
+ * )
304
+ * ```
305
+ */
306
+ signUp(credentials: SignUpWithPasswordCredentials): Promise<AuthResponse>;
307
+ /**
308
+ * Log in an existing user with an email and password or phone and password.
309
+ *
310
+ * Be aware that you may get back an error message that will not distinguish
311
+ * between the cases where the account does not exist or that the
312
+ * email/phone and password combination is wrong or that the account can only
313
+ * be accessed via social login.
314
+ */
315
+ signInWithPassword(credentials: SignInWithPasswordCredentials): Promise<AuthTokenResponsePassword>;
316
+ /**
317
+ * Log in an existing user via a third-party provider.
318
+ * This method supports the PKCE flow.
319
+ */
320
+ signInWithOAuth(credentials: SignInWithOAuthCredentials): Promise<OAuthResponse>;
321
+ /**
322
+ * Log in an existing user by exchanging an Auth Code issued during the PKCE flow.
323
+ */
324
+ exchangeCodeForSession(authCode: string): Promise<AuthTokenResponse>;
325
+ /**
326
+ * Signs in a user by verifying a message signed by the user's private key.
327
+ * Supports Ethereum (via Sign-In-With-Ethereum) & Solana (Sign-In-With-Solana) standards,
328
+ * both of which derive from the EIP-4361 standard
329
+ * With slight variation on Solana's side.
330
+ * @reference https://eips.ethereum.org/EIPS/eip-4361
331
+ */
332
+ signInWithWeb3(credentials: Web3Credentials): Promise<{
333
+ data: {
334
+ session: Session;
335
+ user: User;
336
+ };
337
+ error: null;
338
+ } | {
339
+ data: {
340
+ session: null;
341
+ user: null;
342
+ };
343
+ error: AuthError;
344
+ }>;
345
+ private signInWithEthereum;
346
+ private signInWithSolana;
347
+ private _exchangeCodeForSession;
348
+ /**
349
+ * Allows signing in with an OIDC ID token. The authentication provider used
350
+ * should be enabled and configured.
351
+ */
352
+ signInWithIdToken(credentials: SignInWithIdTokenCredentials): Promise<AuthTokenResponse>;
353
+ /**
354
+ * Log in a user using magiclink or a one-time password (OTP).
355
+ *
356
+ * If the `{{ .ConfirmationURL }}` variable is specified in the email template, a magiclink will be sent.
357
+ * If the `{{ .Token }}` variable is specified in the email template, an OTP will be sent.
358
+ * If you're using phone sign-ins, only an OTP will be sent. You won't be able to send a magiclink for phone sign-ins.
359
+ *
360
+ * Be aware that you may get back an error message that will not distinguish
361
+ * between the cases where the account does not exist or, that the account
362
+ * can only be accessed via social login.
363
+ *
364
+ * Do note that you will need to configure a Whatsapp sender on Twilio
365
+ * if you are using phone sign in with the 'whatsapp' channel. The whatsapp
366
+ * channel is not supported on other providers
367
+ * at this time.
368
+ * This method supports PKCE when an email is passed.
369
+ */
370
+ signInWithOtp(credentials: SignInWithPasswordlessCredentials): Promise<AuthOtpResponse>;
371
+ /**
372
+ * Log in a user given a User supplied OTP or TokenHash received through mobile or email.
373
+ */
374
+ verifyOtp(params: VerifyOtpParams): Promise<AuthResponse>;
375
+ /**
376
+ * Attempts a single-sign on using an enterprise Identity Provider. A
377
+ * successful SSO attempt will redirect the current page to the identity
378
+ * provider authorization page. The redirect URL is implementation and SSO
379
+ * protocol specific.
380
+ *
381
+ * You can use it by providing a SSO domain. Typically you can extract this
382
+ * domain by asking users for their email address. If this domain is
383
+ * registered on the Auth instance the redirect will use that organization's
384
+ * currently active SSO Identity Provider for the login.
385
+ *
386
+ * If you have built an organization-specific login page, you can use the
387
+ * organization's SSO Identity Provider UUID directly instead.
388
+ */
389
+ signInWithSSO(params: SignInWithSSO): Promise<SSOResponse>;
390
+ /**
391
+ * Sends a reauthentication OTP to the user's email or phone number.
392
+ * Requires the user to be signed-in.
393
+ */
394
+ reauthenticate(): Promise<AuthResponse>;
395
+ private _reauthenticate;
396
+ /**
397
+ * Resends an existing signup confirmation email, email change email, SMS OTP or phone change OTP.
398
+ */
399
+ resend(credentials: ResendParams): Promise<AuthOtpResponse>;
400
+ /**
401
+ * Returns the session, refreshing it if necessary.
402
+ *
403
+ * The session returned can be null if the session is not detected which can happen in the event a user is not signed-in or has logged out.
404
+ *
405
+ * **IMPORTANT:** This method loads values directly from the storage attached
406
+ * to the client. If that storage is based on request cookies for example,
407
+ * the values in it may not be authentic and therefore it's strongly advised
408
+ * against using this method and its results in such circumstances. A warning
409
+ * will be emitted if this is detected. Use {@link #getUser()} instead.
410
+ */
411
+ getSession(): Promise<{
412
+ data: {
413
+ session: Session;
414
+ };
415
+ error: null;
416
+ } | {
417
+ data: {
418
+ session: null;
419
+ };
420
+ error: AuthError;
421
+ } | {
422
+ data: {
423
+ session: null;
424
+ };
425
+ error: null;
426
+ }>;
427
+ /**
428
+ * Acquires a global lock based on the storage key.
429
+ */
430
+ private _acquireLock;
431
+ /**
432
+ * Use instead of {@link #getSession} inside the library. It is
433
+ * semantically usually what you want, as getting a session involves some
434
+ * processing afterwards that requires only one client operating on the
435
+ * session at once across multiple tabs or processes.
436
+ */
437
+ private _useSession;
438
+ /**
439
+ * NEVER USE DIRECTLY!
440
+ *
441
+ * Always use {@link #_useSession}.
442
+ */
443
+ private __loadSession;
444
+ /**
445
+ * Gets the current user details if there is an existing session. This method
446
+ * performs a network request to the Supabase Auth server, so the returned
447
+ * value is authentic and can be used to base authorization rules on.
448
+ *
449
+ * @param jwt Takes in an optional access token JWT. If no JWT is provided, the JWT from the current session is used.
450
+ */
451
+ getUser(jwt?: string): Promise<UserResponse>;
452
+ private _getUser;
453
+ /**
454
+ * Updates user data for a logged in user.
455
+ */
456
+ updateUser(attributes: UserAttributes, options?: {
457
+ emailRedirectTo?: string | undefined;
458
+ }): Promise<UserResponse>;
459
+ protected _updateUser(attributes: UserAttributes, options?: {
460
+ emailRedirectTo?: string | undefined;
461
+ }): Promise<UserResponse>;
462
+ /**
463
+ * 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.
464
+ * If the refresh token or access token in the current session is invalid, an error will be thrown.
465
+ * @param currentSession The current session that minimally contains an access token and refresh token.
466
+ */
467
+ setSession(currentSession: {
468
+ access_token: string;
469
+ refresh_token: string;
470
+ }): Promise<AuthResponse>;
471
+ protected _setSession(currentSession: {
472
+ access_token: string;
473
+ refresh_token: string;
474
+ }): Promise<AuthResponse>;
475
+ /**
476
+ * Returns a new session, regardless of expiry status.
477
+ * Takes in an optional current session. If not passed in, then refreshSession() will attempt to retrieve it from getSession().
478
+ * If the current session's refresh token is invalid, an error will be thrown.
479
+ * @param currentSession The current session. If passed in, it must contain a refresh token.
480
+ */
481
+ refreshSession(currentSession?: {
482
+ refresh_token: string;
483
+ }): Promise<AuthResponse>;
484
+ protected _refreshSession(currentSession?: {
485
+ refresh_token: string;
486
+ }): Promise<AuthResponse>;
487
+ /**
488
+ * Gets the session data from a URL string
489
+ */
490
+ private _getSessionFromURL;
491
+ /**
492
+ * Checks if the current URL contains parameters given by an implicit oauth grant flow (https://www.rfc-editor.org/rfc/rfc6749.html#section-4.2)
493
+ *
494
+ * If `detectSessionInUrl` is a function, it will be called with the URL and params to determine
495
+ * if the URL should be processed as a Supabase auth callback. This allows users to exclude
496
+ * URLs from other OAuth providers (e.g., Facebook Login) that also return access_token in the fragment.
497
+ */
498
+ private _isImplicitGrantCallback;
499
+ /**
500
+ * Checks if the current URL and backing storage contain parameters given by a PKCE flow
501
+ */
502
+ private _isPKCECallback;
503
+ /**
504
+ * Inside a browser context, `signOut()` will remove the logged in user from the browser session and log them out - removing all items from localstorage and then trigger a `"SIGNED_OUT"` event.
505
+ *
506
+ * For server-side management, you can revoke all refresh tokens for a user by passing a user's JWT through to `auth.api.signOut(JWT: string)`.
507
+ * 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.
508
+ *
509
+ * If using `others` scope, no `SIGNED_OUT` event is fired!
510
+ */
511
+ signOut(options?: SignOut): Promise<{
512
+ error: AuthError | null;
513
+ }>;
514
+ protected _signOut({ scope }?: SignOut): Promise<{
515
+ error: AuthError | null;
516
+ }>;
517
+ /**
518
+ * Receive a notification every time an auth event happens.
519
+ * Safe to use without an async function as callback.
520
+ *
521
+ * @param callback A callback function to be invoked when an auth event happens.
522
+ */
523
+ onAuthStateChange(callback: (event: AuthChangeEvent, session: Session | null) => void): {
524
+ data: {
525
+ subscription: Subscription;
526
+ };
527
+ };
528
+ /**
529
+ * Avoid using an async function inside `onAuthStateChange` as you might end
530
+ * up with a deadlock. The callback function runs inside an exclusive lock,
531
+ * so calling other Supabase Client APIs that also try to acquire the
532
+ * exclusive lock, might cause a deadlock. This behavior is observable across
533
+ * tabs. In the next major library version, this behavior will not be supported.
534
+ *
535
+ * Receive a notification every time an auth event happens.
536
+ *
537
+ * @param callback A callback function to be invoked when an auth event happens.
538
+ * @deprecated Due to the possibility of deadlocks with async functions as callbacks, use the version without an async function.
539
+ */
540
+ onAuthStateChange(callback: (event: AuthChangeEvent, session: Session | null) => Promise<void>): {
541
+ data: {
542
+ subscription: Subscription;
543
+ };
544
+ };
545
+ private _emitInitialSession;
546
+ /**
547
+ * Sends a password reset request to an email address. This method supports the PKCE flow.
548
+ *
549
+ * @param email The email address of the user.
550
+ * @param options.redirectTo The URL to send the user to after they click the password reset link.
551
+ * @param options.captchaToken Verification token received when the user completes the captcha on the site.
552
+ */
553
+ resetPasswordForEmail(email: string, options?: {
554
+ redirectTo?: string;
555
+ captchaToken?: string;
556
+ }): Promise<{
557
+ data: {};
558
+ error: null;
559
+ } | {
560
+ data: null;
561
+ error: AuthError;
562
+ }>;
563
+ /**
564
+ * Gets all the identities linked to a user.
565
+ */
566
+ getUserIdentities(): Promise<{
567
+ data: {
568
+ identities: UserIdentity[];
569
+ };
570
+ error: null;
571
+ } | {
572
+ data: null;
573
+ error: AuthError;
574
+ }>;
575
+ /**
576
+ * Links an oauth identity to an existing user.
577
+ * This method supports the PKCE flow.
578
+ */
579
+ linkIdentity(credentials: SignInWithOAuthCredentials): Promise<OAuthResponse>;
580
+ /**
581
+ * Links an OIDC identity to an existing user.
582
+ */
583
+ linkIdentity(credentials: SignInWithIdTokenCredentials): Promise<AuthTokenResponse>;
584
+ private linkIdentityOAuth;
585
+ private linkIdentityIdToken;
586
+ /**
587
+ * 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.
588
+ */
589
+ unlinkIdentity(identity: UserIdentity): Promise<{
590
+ data: {};
591
+ error: null;
592
+ } | {
593
+ data: null;
594
+ error: AuthError;
595
+ }>;
596
+ /**
597
+ * Generates a new JWT.
598
+ * @param refreshToken A valid refresh token that was returned on login.
599
+ */
600
+ private _refreshAccessToken;
601
+ private _isValidSession;
602
+ private _handleProviderSignIn;
603
+ /**
604
+ * Recovers the session from LocalStorage and refreshes the token
605
+ * Note: this method is async to accommodate for AsyncStorage e.g. in React native.
606
+ */
607
+ private _recoverAndRefresh;
608
+ private _callRefreshToken;
609
+ private _notifyAllSubscribers;
610
+ /**
611
+ * set currentSession and currentUser
612
+ * process to _startAutoRefreshToken if possible
613
+ */
614
+ private _saveSession;
615
+ private _removeSession;
616
+ /**
617
+ * Removes any registered visibilitychange callback.
618
+ *
619
+ * {@see #startAutoRefresh}
620
+ * {@see #stopAutoRefresh}
621
+ */
622
+ private _removeVisibilityChangedCallback;
623
+ /**
624
+ * This is the private implementation of {@link #startAutoRefresh}. Use this
625
+ * within the library.
626
+ */
627
+ private _startAutoRefresh;
628
+ /**
629
+ * This is the private implementation of {@link #stopAutoRefresh}. Use this
630
+ * within the library.
631
+ */
632
+ private _stopAutoRefresh;
633
+ /**
634
+ * Starts an auto-refresh process in the background. The session is checked
635
+ * every few seconds. Close to the time of expiration a process is started to
636
+ * refresh the session. If refreshing fails it will be retried for as long as
637
+ * necessary.
638
+ *
639
+ * If you set the {@link GoTrueClientOptions#autoRefreshToken} you don't need
640
+ * to call this function, it will be called for you.
641
+ *
642
+ * On browsers the refresh process works only when the tab/window is in the
643
+ * foreground to conserve resources as well as prevent race conditions and
644
+ * flooding auth with requests. If you call this method any managed
645
+ * visibility change callback will be removed and you must manage visibility
646
+ * changes on your own.
647
+ *
648
+ * On non-browser platforms the refresh process works *continuously* in the
649
+ * background, which may not be desirable. You should hook into your
650
+ * platform's foreground indication mechanism and call these methods
651
+ * appropriately to conserve resources.
652
+ *
653
+ * {@see #stopAutoRefresh}
654
+ */
655
+ startAutoRefresh(): Promise<void>;
656
+ /**
657
+ * Stops an active auto refresh process running in the background (if any).
658
+ *
659
+ * If you call this method any managed visibility change callback will be
660
+ * removed and you must manage visibility changes on your own.
661
+ *
662
+ * See {@link #startAutoRefresh} for more details.
663
+ */
664
+ stopAutoRefresh(): Promise<void>;
665
+ /**
666
+ * Runs the auto refresh token tick.
667
+ */
668
+ private _autoRefreshTokenTick;
669
+ /**
670
+ * Registers callbacks on the browser / platform, which in-turn run
671
+ * algorithms when the browser window/tab are in foreground. On non-browser
672
+ * platforms it assumes always foreground.
673
+ */
674
+ private _handleVisibilityChange;
675
+ /**
676
+ * Callback registered with `window.addEventListener('visibilitychange')`.
677
+ */
678
+ private _onVisibilityChanged;
679
+ /**
680
+ * Generates the relevant login URL for a third-party provider.
681
+ * @param options.redirectTo A URL or mobile address to send the user to after they are confirmed.
682
+ * @param options.scopes A space-separated list of scopes granted to the OAuth application.
683
+ * @param options.queryParams An object of key-value pairs containing query parameters granted to the OAuth application.
684
+ */
685
+ private _getUrlForProvider;
686
+ private _unenroll;
687
+ /**
688
+ * {@see GoTrueMFAApi#enroll}
689
+ */
690
+ private _enroll;
691
+ /**
692
+ * {@see GoTrueMFAApi#verify}
693
+ */
694
+ private _verify;
695
+ /**
696
+ * {@see GoTrueMFAApi#challenge}
697
+ */
698
+ private _challenge;
699
+ /**
700
+ * {@see GoTrueMFAApi#challengeAndVerify}
701
+ */
702
+ private _challengeAndVerify;
703
+ /**
704
+ * {@see GoTrueMFAApi#listFactors}
705
+ */
706
+ private _listFactors;
707
+ /**
708
+ * {@see GoTrueMFAApi#getAuthenticatorAssuranceLevel}
709
+ */
710
+ private _getAuthenticatorAssuranceLevel;
711
+ /**
712
+ * Retrieves details about an OAuth authorization request.
713
+ * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
714
+ *
715
+ * Returns authorization details including client info, scopes, and user information.
716
+ * If the response includes only a redirect_url field, it means consent was already given - the caller
717
+ * should handle the redirect manually if needed.
718
+ */
719
+ private _getAuthorizationDetails;
720
+ /**
721
+ * Approves an OAuth authorization request.
722
+ * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
723
+ */
724
+ private _approveAuthorization;
725
+ /**
726
+ * Denies an OAuth authorization request.
727
+ * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
728
+ */
729
+ private _denyAuthorization;
730
+ /**
731
+ * Lists all OAuth grants that the authenticated user has authorized.
732
+ * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
733
+ */
734
+ private _listOAuthGrants;
735
+ /**
736
+ * Revokes a user's OAuth grant for a specific client.
737
+ * Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
738
+ */
739
+ private _revokeOAuthGrant;
740
+ private fetchJwk;
741
+ /**
742
+ * Extracts the JWT claims present in the access token by first verifying the
743
+ * JWT against the server's JSON Web Key Set endpoint
744
+ * `/.well-known/jwks.json` which is often cached, resulting in significantly
745
+ * faster responses. Prefer this method over {@link #getUser} which always
746
+ * sends a request to the Auth server for each JWT.
747
+ *
748
+ * If the project is not using an asymmetric JWT signing key (like ECC or
749
+ * RSA) it always sends a request to the Auth server (similar to {@link
750
+ * #getUser}) to verify the JWT.
751
+ *
752
+ * @param jwt An optional specific JWT you wish to verify, not the one you
753
+ * can obtain from {@link #getSession}.
754
+ * @param options Various additional options that allow you to customize the
755
+ * behavior of this method.
756
+ */
757
+ getClaims(jwt?: string, options?: {
758
+ /**
759
+ * @deprecated Please use options.jwks instead.
760
+ */
761
+ keys?: JWK[];
762
+ /** If set to `true` the `exp` claim will not be validated against the current time. */
763
+ allowExpired?: boolean;
764
+ /** If set, this JSON Web Key Set is going to have precedence over the cached value available on the server. */
765
+ jwks?: {
766
+ keys: JWK[];
767
+ };
768
+ }): Promise<{
769
+ data: {
770
+ claims: JwtPayload;
771
+ header: JwtHeader;
772
+ signature: Uint8Array;
773
+ };
774
+ error: null;
775
+ } | {
776
+ data: null;
777
+ error: AuthError;
778
+ } | {
779
+ data: null;
780
+ error: null;
781
+ }>;
782
+ }
783
+ //# sourceMappingURL=GoTrueClient.d.ts.map