@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,28 @@
1
+ import { version } from './version';
2
+ /** Current session will be checked for refresh at this interval. */
3
+ export const AUTO_REFRESH_TICK_DURATION_MS = 30 * 1000;
4
+ /**
5
+ * A token refresh will be attempted this many ticks before the current session expires. */
6
+ export const AUTO_REFRESH_TICK_THRESHOLD = 3;
7
+ /*
8
+ * Earliest time before an access token expires that the session should be refreshed.
9
+ */
10
+ export const EXPIRY_MARGIN_MS = AUTO_REFRESH_TICK_THRESHOLD * AUTO_REFRESH_TICK_DURATION_MS;
11
+ export const GOTRUE_URL = 'http://localhost:9999';
12
+ export const STORAGE_KEY = 'supabase.auth.token';
13
+ export const AUDIENCE = '';
14
+ export const DEFAULT_HEADERS = { 'X-Client-Info': `gotrue-js/${version}` };
15
+ export const NETWORK_FAILURE = {
16
+ MAX_RETRIES: 10,
17
+ RETRY_INTERVAL: 2, // in deciseconds
18
+ };
19
+ export const API_VERSION_HEADER_NAME = 'X-Supabase-Api-Version';
20
+ export const API_VERSIONS = {
21
+ '2024-01-01': {
22
+ timestamp: Date.parse('2024-01-01T00:00:00.0Z'),
23
+ name: '2024-01-01',
24
+ },
25
+ };
26
+ export const BASE64URL_REGEX = /^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i;
27
+ export const JWKS_TTL = 10 * 60 * 1000; // 10 minutes
28
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,oEAAoE;AACpE,MAAM,CAAC,MAAM,6BAA6B,GAAG,EAAE,GAAG,IAAI,CAAA;AAEtD;2FAC2F;AAC3F,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAA;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,GAAG,6BAA6B,CAAA;AAE3F,MAAM,CAAC,MAAM,UAAU,GAAG,uBAAuB,CAAA;AACjD,MAAM,CAAC,MAAM,WAAW,GAAG,qBAAqB,CAAA;AAChD,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,CAAA;AAC1B,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,eAAe,EAAE,aAAa,OAAO,EAAE,EAAE,CAAA;AAC1E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,WAAW,EAAE,EAAE;IACf,cAAc,EAAE,CAAC,EAAE,iBAAiB;CACrC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAA;AAC/D,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,YAAY,EAAE;QACZ,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,wBAAwB,CAAC;QAC/C,IAAI,EAAE,YAAY;KACnB;CACF,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,sDAAsD,CAAA;AAErF,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAA,CAAC,aAAa"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Known error codes. Note that the server may also return other error codes
3
+ * not included in this list (if the SDK is older than the version
4
+ * on the server).
5
+ */
6
+ export type ErrorCode = 'unexpected_failure' | 'validation_failed' | 'bad_json' | 'email_exists' | 'phone_exists' | 'bad_jwt' | 'not_admin' | 'no_authorization' | 'user_not_found' | 'session_not_found' | 'session_expired' | 'refresh_token_not_found' | 'refresh_token_already_used' | 'flow_state_not_found' | 'flow_state_expired' | 'signup_disabled' | 'user_banned' | 'provider_email_needs_verification' | 'invite_not_found' | 'bad_oauth_state' | 'bad_oauth_callback' | 'oauth_provider_not_supported' | 'unexpected_audience' | 'single_identity_not_deletable' | 'email_conflict_identity_not_deletable' | 'identity_already_exists' | 'email_provider_disabled' | 'phone_provider_disabled' | 'too_many_enrolled_mfa_factors' | 'mfa_factor_name_conflict' | 'mfa_factor_not_found' | 'mfa_ip_address_mismatch' | 'mfa_challenge_expired' | 'mfa_verification_failed' | 'mfa_verification_rejected' | 'insufficient_aal' | 'captcha_failed' | 'saml_provider_disabled' | 'manual_linking_disabled' | 'sms_send_failed' | 'email_not_confirmed' | 'phone_not_confirmed' | 'reauth_nonce_missing' | 'saml_relay_state_not_found' | 'saml_relay_state_expired' | 'saml_idp_not_found' | 'saml_assertion_no_user_id' | 'saml_assertion_no_email' | 'user_already_exists' | 'sso_provider_not_found' | 'saml_metadata_fetch_failed' | 'saml_idp_already_exists' | 'sso_domain_already_exists' | 'saml_entity_id_mismatch' | 'conflict' | 'provider_disabled' | 'user_sso_managed' | 'reauthentication_needed' | 'same_password' | 'reauthentication_not_valid' | 'otp_expired' | 'otp_disabled' | 'identity_not_found' | 'weak_password' | 'over_request_rate_limit' | 'over_email_send_rate_limit' | 'over_sms_send_rate_limit' | 'bad_code_verifier' | 'anonymous_provider_disabled' | 'hook_timeout' | 'hook_timeout_after_retry' | 'hook_payload_over_size_limit' | 'hook_payload_invalid_content_type' | 'request_timeout' | 'mfa_phone_enroll_not_enabled' | 'mfa_phone_verify_not_enabled' | 'mfa_totp_enroll_not_enabled' | 'mfa_totp_verify_not_enabled' | 'mfa_webauthn_enroll_not_enabled' | 'mfa_webauthn_verify_not_enabled' | 'mfa_verified_factor_exists' | 'invalid_credentials' | 'email_address_not_authorized' | 'email_address_invalid';
7
+ //# sourceMappingURL=error-codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../../src/lib/error-codes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,SAAS,GACjB,oBAAoB,GACpB,mBAAmB,GACnB,UAAU,GACV,cA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1
+ {"version":3,"file":"error-codes.js","sourceRoot":"","sources":["../../../src/lib/error-codes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,243 @@
1
+ import { WeakPasswordReasons } from './types';
2
+ import { ErrorCode } from './error-codes';
3
+ /**
4
+ * Base error thrown by Supabase Auth helpers.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { AuthError } from '@supabase/auth-js'
9
+ *
10
+ * throw new AuthError('Unexpected auth error', 500, 'unexpected')
11
+ * ```
12
+ */
13
+ export declare class AuthError extends Error {
14
+ /**
15
+ * Error code associated with the error. Most errors coming from
16
+ * HTTP responses will have a code, though some errors that occur
17
+ * before a response is received will not have one present. In that
18
+ * case {@link #status} will also be undefined.
19
+ */
20
+ code: ErrorCode | (string & {}) | undefined;
21
+ /** HTTP status code that caused the error. */
22
+ status: number | undefined;
23
+ protected __isAuthError: boolean;
24
+ constructor(message: string, status?: number, code?: string);
25
+ }
26
+ export declare function isAuthError(error: unknown): error is AuthError;
27
+ /**
28
+ * Error returned directly from the GoTrue REST API.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * import { AuthApiError } from '@supabase/auth-js'
33
+ *
34
+ * throw new AuthApiError('Invalid credentials', 400, 'invalid_credentials')
35
+ * ```
36
+ */
37
+ export declare class AuthApiError extends AuthError {
38
+ status: number;
39
+ constructor(message: string, status: number, code: string | undefined);
40
+ }
41
+ export declare function isAuthApiError(error: unknown): error is AuthApiError;
42
+ /**
43
+ * Wraps non-standard errors so callers can inspect the root cause.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { AuthUnknownError } from '@supabase/auth-js'
48
+ *
49
+ * try {
50
+ * await someAuthCall()
51
+ * } catch (err) {
52
+ * throw new AuthUnknownError('Auth failed', err)
53
+ * }
54
+ * ```
55
+ */
56
+ export declare class AuthUnknownError extends AuthError {
57
+ originalError: unknown;
58
+ constructor(message: string, originalError: unknown);
59
+ }
60
+ /**
61
+ * Flexible error class used to create named auth errors at runtime.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { CustomAuthError } from '@supabase/auth-js'
66
+ *
67
+ * throw new CustomAuthError('My custom auth error', 'MyAuthError', 400, 'custom_code')
68
+ * ```
69
+ */
70
+ export declare class CustomAuthError extends AuthError {
71
+ name: string;
72
+ status: number;
73
+ constructor(message: string, name: string, status: number, code: string | undefined);
74
+ }
75
+ /**
76
+ * Error thrown when an operation requires a session but none is present.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * import { AuthSessionMissingError } from '@supabase/auth-js'
81
+ *
82
+ * throw new AuthSessionMissingError()
83
+ * ```
84
+ */
85
+ export declare class AuthSessionMissingError extends CustomAuthError {
86
+ constructor();
87
+ }
88
+ export declare function isAuthSessionMissingError(error: any): error is AuthSessionMissingError;
89
+ /**
90
+ * Error thrown when the token response is malformed.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * import { AuthInvalidTokenResponseError } from '@supabase/auth-js'
95
+ *
96
+ * throw new AuthInvalidTokenResponseError()
97
+ * ```
98
+ */
99
+ export declare class AuthInvalidTokenResponseError extends CustomAuthError {
100
+ constructor();
101
+ }
102
+ /**
103
+ * Error thrown when email/password credentials are invalid.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * import { AuthInvalidCredentialsError } from '@supabase/auth-js'
108
+ *
109
+ * throw new AuthInvalidCredentialsError('Email or password is incorrect')
110
+ * ```
111
+ */
112
+ export declare class AuthInvalidCredentialsError extends CustomAuthError {
113
+ constructor(message: string);
114
+ }
115
+ /**
116
+ * Error thrown when implicit grant redirects contain an error.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * import { AuthImplicitGrantRedirectError } from '@supabase/auth-js'
121
+ *
122
+ * throw new AuthImplicitGrantRedirectError('OAuth redirect failed', {
123
+ * error: 'access_denied',
124
+ * code: 'oauth_error',
125
+ * })
126
+ * ```
127
+ */
128
+ export declare class AuthImplicitGrantRedirectError extends CustomAuthError {
129
+ details: {
130
+ error: string;
131
+ code: string;
132
+ } | null;
133
+ constructor(message: string, details?: {
134
+ error: string;
135
+ code: string;
136
+ } | null);
137
+ toJSON(): {
138
+ name: string;
139
+ message: string;
140
+ status: number;
141
+ details: {
142
+ error: string;
143
+ code: string;
144
+ } | null;
145
+ };
146
+ }
147
+ export declare function isAuthImplicitGrantRedirectError(error: any): error is AuthImplicitGrantRedirectError;
148
+ /**
149
+ * Error thrown during PKCE code exchanges.
150
+ *
151
+ * @example
152
+ * ```ts
153
+ * import { AuthPKCEGrantCodeExchangeError } from '@supabase/auth-js'
154
+ *
155
+ * throw new AuthPKCEGrantCodeExchangeError('PKCE exchange failed')
156
+ * ```
157
+ */
158
+ export declare class AuthPKCEGrantCodeExchangeError extends CustomAuthError {
159
+ details: {
160
+ error: string;
161
+ code: string;
162
+ } | null;
163
+ constructor(message: string, details?: {
164
+ error: string;
165
+ code: string;
166
+ } | null);
167
+ toJSON(): {
168
+ name: string;
169
+ message: string;
170
+ status: number;
171
+ details: {
172
+ error: string;
173
+ code: string;
174
+ } | null;
175
+ };
176
+ }
177
+ /**
178
+ * Error thrown when the PKCE code verifier is not found in storage.
179
+ * This typically happens when the auth flow was initiated in a different
180
+ * browser, device, or the storage was cleared.
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * import { AuthPKCECodeVerifierMissingError } from '@supabase/auth-js'
185
+ *
186
+ * throw new AuthPKCECodeVerifierMissingError()
187
+ * ```
188
+ */
189
+ export declare class AuthPKCECodeVerifierMissingError extends CustomAuthError {
190
+ constructor();
191
+ }
192
+ export declare function isAuthPKCECodeVerifierMissingError(error: unknown): error is AuthPKCECodeVerifierMissingError;
193
+ /**
194
+ * Error thrown when a transient fetch issue occurs.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * import { AuthRetryableFetchError } from '@supabase/auth-js'
199
+ *
200
+ * throw new AuthRetryableFetchError('Service temporarily unavailable', 503)
201
+ * ```
202
+ */
203
+ export declare class AuthRetryableFetchError extends CustomAuthError {
204
+ constructor(message: string, status: number);
205
+ }
206
+ export declare function isAuthRetryableFetchError(error: unknown): error is AuthRetryableFetchError;
207
+ /**
208
+ * This error is thrown on certain methods when the password used is deemed
209
+ * weak. Inspect the reasons to identify what password strength rules are
210
+ * inadequate.
211
+ */
212
+ /**
213
+ * Error thrown when a supplied password is considered weak.
214
+ *
215
+ * @example
216
+ * ```ts
217
+ * import { AuthWeakPasswordError } from '@supabase/auth-js'
218
+ *
219
+ * throw new AuthWeakPasswordError('Password too short', 400, ['min_length'])
220
+ * ```
221
+ */
222
+ export declare class AuthWeakPasswordError extends CustomAuthError {
223
+ /**
224
+ * Reasons why the password is deemed weak.
225
+ */
226
+ reasons: WeakPasswordReasons[];
227
+ constructor(message: string, status: number, reasons: WeakPasswordReasons[]);
228
+ }
229
+ export declare function isAuthWeakPasswordError(error: unknown): error is AuthWeakPasswordError;
230
+ /**
231
+ * Error thrown when a JWT cannot be verified or parsed.
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * import { AuthInvalidJwtError } from '@supabase/auth-js'
236
+ *
237
+ * throw new AuthInvalidJwtError('Token signature is invalid')
238
+ * ```
239
+ */
240
+ export declare class AuthInvalidJwtError extends CustomAuthError {
241
+ constructor(message: string);
242
+ }
243
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/lib/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC;;;;;;;;;GASG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC;;;;;OAKG;IACH,IAAI,EAAE,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,SAAS,CAAA;IAE3C,8CAA8C;IAC9C,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAE1B,SAAS,CAAC,aAAa,UAAO;gBAElB,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE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M;CAG5B"}
@@ -0,0 +1,266 @@
1
+ /**
2
+ * Base error thrown by Supabase Auth helpers.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * import { AuthError } from '@supabase/auth-js'
7
+ *
8
+ * throw new AuthError('Unexpected auth error', 500, 'unexpected')
9
+ * ```
10
+ */
11
+ export class AuthError extends Error {
12
+ constructor(message, status, code) {
13
+ super(message);
14
+ this.__isAuthError = true;
15
+ this.name = 'AuthError';
16
+ this.status = status;
17
+ this.code = code;
18
+ }
19
+ }
20
+ export function isAuthError(error) {
21
+ return typeof error === 'object' && error !== null && '__isAuthError' in error;
22
+ }
23
+ /**
24
+ * Error returned directly from the GoTrue REST API.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { AuthApiError } from '@supabase/auth-js'
29
+ *
30
+ * throw new AuthApiError('Invalid credentials', 400, 'invalid_credentials')
31
+ * ```
32
+ */
33
+ export class AuthApiError extends AuthError {
34
+ constructor(message, status, code) {
35
+ super(message, status, code);
36
+ this.name = 'AuthApiError';
37
+ this.status = status;
38
+ this.code = code;
39
+ }
40
+ }
41
+ export function isAuthApiError(error) {
42
+ return isAuthError(error) && error.name === 'AuthApiError';
43
+ }
44
+ /**
45
+ * Wraps non-standard errors so callers can inspect the root cause.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { AuthUnknownError } from '@supabase/auth-js'
50
+ *
51
+ * try {
52
+ * await someAuthCall()
53
+ * } catch (err) {
54
+ * throw new AuthUnknownError('Auth failed', err)
55
+ * }
56
+ * ```
57
+ */
58
+ export class AuthUnknownError extends AuthError {
59
+ constructor(message, originalError) {
60
+ super(message);
61
+ this.name = 'AuthUnknownError';
62
+ this.originalError = originalError;
63
+ }
64
+ }
65
+ /**
66
+ * Flexible error class used to create named auth errors at runtime.
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * import { CustomAuthError } from '@supabase/auth-js'
71
+ *
72
+ * throw new CustomAuthError('My custom auth error', 'MyAuthError', 400, 'custom_code')
73
+ * ```
74
+ */
75
+ export class CustomAuthError extends AuthError {
76
+ constructor(message, name, status, code) {
77
+ super(message, status, code);
78
+ this.name = name;
79
+ this.status = status;
80
+ }
81
+ }
82
+ /**
83
+ * Error thrown when an operation requires a session but none is present.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * import { AuthSessionMissingError } from '@supabase/auth-js'
88
+ *
89
+ * throw new AuthSessionMissingError()
90
+ * ```
91
+ */
92
+ export class AuthSessionMissingError extends CustomAuthError {
93
+ constructor() {
94
+ super('Auth session missing!', 'AuthSessionMissingError', 400, undefined);
95
+ }
96
+ }
97
+ export function isAuthSessionMissingError(error) {
98
+ return isAuthError(error) && error.name === 'AuthSessionMissingError';
99
+ }
100
+ /**
101
+ * Error thrown when the token response is malformed.
102
+ *
103
+ * @example
104
+ * ```ts
105
+ * import { AuthInvalidTokenResponseError } from '@supabase/auth-js'
106
+ *
107
+ * throw new AuthInvalidTokenResponseError()
108
+ * ```
109
+ */
110
+ export class AuthInvalidTokenResponseError extends CustomAuthError {
111
+ constructor() {
112
+ super('Auth session or user missing', 'AuthInvalidTokenResponseError', 500, undefined);
113
+ }
114
+ }
115
+ /**
116
+ * Error thrown when email/password credentials are invalid.
117
+ *
118
+ * @example
119
+ * ```ts
120
+ * import { AuthInvalidCredentialsError } from '@supabase/auth-js'
121
+ *
122
+ * throw new AuthInvalidCredentialsError('Email or password is incorrect')
123
+ * ```
124
+ */
125
+ export class AuthInvalidCredentialsError extends CustomAuthError {
126
+ constructor(message) {
127
+ super(message, 'AuthInvalidCredentialsError', 400, undefined);
128
+ }
129
+ }
130
+ /**
131
+ * Error thrown when implicit grant redirects contain an error.
132
+ *
133
+ * @example
134
+ * ```ts
135
+ * import { AuthImplicitGrantRedirectError } from '@supabase/auth-js'
136
+ *
137
+ * throw new AuthImplicitGrantRedirectError('OAuth redirect failed', {
138
+ * error: 'access_denied',
139
+ * code: 'oauth_error',
140
+ * })
141
+ * ```
142
+ */
143
+ export class AuthImplicitGrantRedirectError extends CustomAuthError {
144
+ constructor(message, details = null) {
145
+ super(message, 'AuthImplicitGrantRedirectError', 500, undefined);
146
+ this.details = null;
147
+ this.details = details;
148
+ }
149
+ toJSON() {
150
+ return {
151
+ name: this.name,
152
+ message: this.message,
153
+ status: this.status,
154
+ details: this.details,
155
+ };
156
+ }
157
+ }
158
+ export function isAuthImplicitGrantRedirectError(error) {
159
+ return isAuthError(error) && error.name === 'AuthImplicitGrantRedirectError';
160
+ }
161
+ /**
162
+ * Error thrown during PKCE code exchanges.
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * import { AuthPKCEGrantCodeExchangeError } from '@supabase/auth-js'
167
+ *
168
+ * throw new AuthPKCEGrantCodeExchangeError('PKCE exchange failed')
169
+ * ```
170
+ */
171
+ export class AuthPKCEGrantCodeExchangeError extends CustomAuthError {
172
+ constructor(message, details = null) {
173
+ super(message, 'AuthPKCEGrantCodeExchangeError', 500, undefined);
174
+ this.details = null;
175
+ this.details = details;
176
+ }
177
+ toJSON() {
178
+ return {
179
+ name: this.name,
180
+ message: this.message,
181
+ status: this.status,
182
+ details: this.details,
183
+ };
184
+ }
185
+ }
186
+ /**
187
+ * Error thrown when the PKCE code verifier is not found in storage.
188
+ * This typically happens when the auth flow was initiated in a different
189
+ * browser, device, or the storage was cleared.
190
+ *
191
+ * @example
192
+ * ```ts
193
+ * import { AuthPKCECodeVerifierMissingError } from '@supabase/auth-js'
194
+ *
195
+ * throw new AuthPKCECodeVerifierMissingError()
196
+ * ```
197
+ */
198
+ export class AuthPKCECodeVerifierMissingError extends CustomAuthError {
199
+ constructor() {
200
+ super('PKCE code verifier not found in storage. ' +
201
+ 'This can happen if the auth flow was initiated in a different browser or device, ' +
202
+ 'or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), ' +
203
+ 'use @supabase/ssr on both the server and client to store the code verifier in cookies.', 'AuthPKCECodeVerifierMissingError', 400, 'pkce_code_verifier_not_found');
204
+ }
205
+ }
206
+ export function isAuthPKCECodeVerifierMissingError(error) {
207
+ return isAuthError(error) && error.name === 'AuthPKCECodeVerifierMissingError';
208
+ }
209
+ /**
210
+ * Error thrown when a transient fetch issue occurs.
211
+ *
212
+ * @example
213
+ * ```ts
214
+ * import { AuthRetryableFetchError } from '@supabase/auth-js'
215
+ *
216
+ * throw new AuthRetryableFetchError('Service temporarily unavailable', 503)
217
+ * ```
218
+ */
219
+ export class AuthRetryableFetchError extends CustomAuthError {
220
+ constructor(message, status) {
221
+ super(message, 'AuthRetryableFetchError', status, undefined);
222
+ }
223
+ }
224
+ export function isAuthRetryableFetchError(error) {
225
+ return isAuthError(error) && error.name === 'AuthRetryableFetchError';
226
+ }
227
+ /**
228
+ * This error is thrown on certain methods when the password used is deemed
229
+ * weak. Inspect the reasons to identify what password strength rules are
230
+ * inadequate.
231
+ */
232
+ /**
233
+ * Error thrown when a supplied password is considered weak.
234
+ *
235
+ * @example
236
+ * ```ts
237
+ * import { AuthWeakPasswordError } from '@supabase/auth-js'
238
+ *
239
+ * throw new AuthWeakPasswordError('Password too short', 400, ['min_length'])
240
+ * ```
241
+ */
242
+ export class AuthWeakPasswordError extends CustomAuthError {
243
+ constructor(message, status, reasons) {
244
+ super(message, 'AuthWeakPasswordError', status, 'weak_password');
245
+ this.reasons = reasons;
246
+ }
247
+ }
248
+ export function isAuthWeakPasswordError(error) {
249
+ return isAuthError(error) && error.name === 'AuthWeakPasswordError';
250
+ }
251
+ /**
252
+ * Error thrown when a JWT cannot be verified or parsed.
253
+ *
254
+ * @example
255
+ * ```ts
256
+ * import { AuthInvalidJwtError } from '@supabase/auth-js'
257
+ *
258
+ * throw new AuthInvalidJwtError('Token signature is invalid')
259
+ * ```
260
+ */
261
+ export class AuthInvalidJwtError extends CustomAuthError {
262
+ constructor(message) {
263
+ super(message, 'AuthInvalidJwtError', 400, 'invalid_jwt');
264
+ }
265
+ }
266
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/lib/err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CAAA;AACvE,CAAC;AAED;;;;GAIG;AACH;;;;;;;;;GASG;AACH,MAAM,OAAO,qBAAsB,SAAQ,eAAe;IAMxD,YAAY,OAAe,EAAE,MAAc,EAAE,OAA8B;QACzE,KAAK,CAAC,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,eAAe,CAAC,CAAA;QAEhE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CACF;AAED,MAAM,UAAU,uBAAuB,CAAC,KAAc;IACpD,OAAO,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,uBAAuB,CAAA;AACrE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,mBAAoB,SAAQ,eAAe;IACtD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,qBAAqB,EAAE,GAAG,EAAE,aAAa,CAAC,CAAA;IAC3D,CAAC;CACF"}
@@ -0,0 +1,34 @@
1
+ import { AuthResponse, AuthResponsePassword, SSOResponse, GenerateLinkResponse, UserResponse } from './types';
2
+ export type Fetch = typeof fetch;
3
+ export interface FetchOptions {
4
+ headers?: {
5
+ [key: string]: string;
6
+ };
7
+ noResolveJson?: boolean;
8
+ }
9
+ export interface FetchParameters {
10
+ signal?: AbortSignal;
11
+ }
12
+ export type RequestMethodType = 'GET' | 'POST' | 'PUT' | 'DELETE';
13
+ export declare function handleError(error: unknown): Promise<void>;
14
+ interface GotrueRequestOptions extends FetchOptions {
15
+ jwt?: string;
16
+ redirectTo?: string;
17
+ body?: object;
18
+ query?: {
19
+ [key: string]: string;
20
+ };
21
+ /**
22
+ * Function that transforms api response from gotrue into a desirable / standardised format
23
+ */
24
+ xform?: (data: any) => any;
25
+ }
26
+ export declare function _request(fetcher: Fetch, method: RequestMethodType, url: string, options?: GotrueRequestOptions): Promise<any>;
27
+ export declare function _sessionResponse(data: any): AuthResponse;
28
+ export declare function _sessionResponsePassword(data: any): AuthResponsePassword;
29
+ export declare function _userResponse(data: any): UserResponse;
30
+ export declare function _ssoResponse(data: any): SSOResponse;
31
+ export declare function _generateLinkResponse(data: any): GenerateLinkResponse;
32
+ export declare function _noResolveJsonResponse(data: any): Response;
33
+ export {};
34
+ //# sourceMappingURL=fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/lib/fetch.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,WAAW,EAEX,oBAAoB,EAEpB,YAAY,EACb,MAAM,SAAS,CAAA;AAShB,MAAM,MAAM,KAAK,GAAG,OAAO,KAAK,CAAA;AAEhC,MAAM,WAAW,YAAY;IAC3B,OAAO,CAAC,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAA;IACD,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAA;AAOjE,wBAAsB,WAAW,CAAC,KAAK,EAAE,OAAO,iBA+D/C;AAmBD,UAAU,oBAAqB,SAAQ,YAAY;IACjD,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IACjC;;OAEG;IACH,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,GAAG,CAAA;CAC3B;AAED,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,KAAK,EACd,MAAM,EAAE,iBAAiB,EACzB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,oBAAoB,gBAgC/B;AAwCD,wBAAgB,gBAAgB,CAAC,IAA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