@supabase/gotrue-js 2.2.4 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/main/GoTrueAdminApi.d.ts.map +1 -1
  2. package/dist/main/GoTrueAdminApi.js.map +1 -1
  3. package/dist/main/GoTrueClient.d.ts +21 -1
  4. package/dist/main/GoTrueClient.d.ts.map +1 -1
  5. package/dist/main/GoTrueClient.js +47 -2
  6. package/dist/main/GoTrueClient.js.map +1 -1
  7. package/dist/main/lib/errors.d.ts +1 -0
  8. package/dist/main/lib/errors.d.ts.map +1 -1
  9. package/dist/main/lib/errors.js +5 -1
  10. package/dist/main/lib/errors.js.map +1 -1
  11. package/dist/main/lib/fetch.d.ts +2 -1
  12. package/dist/main/lib/fetch.d.ts.map +1 -1
  13. package/dist/main/lib/fetch.js +8 -4
  14. package/dist/main/lib/fetch.js.map +1 -1
  15. package/dist/main/lib/types.d.ts +24 -0
  16. package/dist/main/lib/types.d.ts.map +1 -1
  17. package/dist/main/lib/version.d.ts +1 -1
  18. package/dist/main/lib/version.js +1 -1
  19. package/dist/module/GoTrueAdminApi.d.ts.map +1 -1
  20. package/dist/module/GoTrueAdminApi.js.map +1 -1
  21. package/dist/module/GoTrueClient.d.ts +21 -1
  22. package/dist/module/GoTrueClient.d.ts.map +1 -1
  23. package/dist/module/GoTrueClient.js +49 -4
  24. package/dist/module/GoTrueClient.js.map +1 -1
  25. package/dist/module/lib/errors.d.ts +1 -0
  26. package/dist/module/lib/errors.d.ts.map +1 -1
  27. package/dist/module/lib/errors.js +3 -0
  28. package/dist/module/lib/errors.js.map +1 -1
  29. package/dist/module/lib/fetch.d.ts +2 -1
  30. package/dist/module/lib/fetch.d.ts.map +1 -1
  31. package/dist/module/lib/fetch.js +6 -3
  32. package/dist/module/lib/fetch.js.map +1 -1
  33. package/dist/module/lib/types.d.ts +24 -0
  34. package/dist/module/lib/types.d.ts.map +1 -1
  35. package/dist/module/lib/version.d.ts +1 -1
  36. package/dist/module/lib/version.js +1 -1
  37. package/package.json +1 -1
  38. package/src/GoTrueAdminApi.ts +0 -1
  39. package/src/GoTrueClient.ts +55 -2
  40. package/src/lib/errors.ts +4 -0
  41. package/src/lib/fetch.ts +6 -1
  42. package/src/lib/types.ts +31 -0
  43. package/src/lib/version.ts +1 -1
package/src/lib/fetch.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { expiresAt, looksLikeFetchResponse } from './helpers'
2
2
  import {
3
3
  AuthResponse,
4
+ SSOResponse,
4
5
  GenerateLinkProperties,
5
6
  GenerateLinkResponse,
6
7
  User,
@@ -81,7 +82,7 @@ export async function _request(
81
82
  url: string,
82
83
  options?: GotrueRequestOptions
83
84
  ) {
84
- const headers = options?.headers ?? {}
85
+ const headers = { ...options?.headers }
85
86
  if (options?.jwt) {
86
87
  headers['Authorization'] = `Bearer ${options.jwt}`
87
88
  }
@@ -136,6 +137,10 @@ export function _userResponse(data: any): UserResponse {
136
137
  return { data: { user }, error: null }
137
138
  }
138
139
 
140
+ export function _ssoResponse(data: any): SSOResponse {
141
+ return { data, error: null }
142
+ }
143
+
139
144
  export function _generateLinkResponse(data: any): GenerateLinkResponse {
140
145
  const { action_link, email_otp, hashed_token, redirect_to, verification_type, ...rest } = data
141
146
 
package/src/lib/types.ts CHANGED
@@ -85,6 +85,19 @@ export type OAuthResponse =
85
85
  error: AuthError
86
86
  }
87
87
 
88
+ export type SSOResponse =
89
+ | {
90
+ data: {
91
+ /** URL to take the user to (in a browser) to complete SSO. */
92
+ url: string
93
+ }
94
+ error: null
95
+ }
96
+ | {
97
+ data: null
98
+ error: AuthError
99
+ }
100
+
88
101
  export type UserResponse =
89
102
  | {
90
103
  data: {
@@ -466,6 +479,24 @@ export interface VerifyEmailOtpParams {
466
479
  export type MobileOtpType = 'sms' | 'phone_change'
467
480
  export type EmailOtpType = 'signup' | 'invite' | 'magiclink' | 'recovery' | 'email_change'
468
481
 
482
+ export type SignInWithSSO = {
483
+ options?: {
484
+ /** A URL to send the user to after they have signed-in. */
485
+ redirectTo?: string
486
+ /** Verification token received when the user completes the captcha on the site. */
487
+ captchaToken?: string
488
+ }
489
+ } & (
490
+ | {
491
+ /** UUID of the SSO provider to invoke single-sign on to. */
492
+ providerId: string
493
+ }
494
+ | {
495
+ /** Domain name of the organization for which to invoke single-sign on. */
496
+ domain: string
497
+ }
498
+ )
499
+
469
500
  export type GenerateSignupLinkParams = {
470
501
  type: 'signup'
471
502
  email: string
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '2.2.4'
2
+ export const version = '2.3.1'