@supabase/gotrue-js 1.17.0 → 1.20.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 (75) hide show
  1. package/README.md +16 -4
  2. package/dist/main/GoTrueApi.d.ts +39 -22
  3. package/dist/main/GoTrueApi.d.ts.map +1 -1
  4. package/dist/main/GoTrueApi.js +84 -75
  5. package/dist/main/GoTrueApi.js.map +1 -1
  6. package/dist/main/GoTrueClient.d.ts +26 -13
  7. package/dist/main/GoTrueClient.d.ts.map +1 -1
  8. package/dist/main/GoTrueClient.js +57 -59
  9. package/dist/main/GoTrueClient.js.map +1 -1
  10. package/dist/main/lib/constants.d.ts +3 -1
  11. package/dist/main/lib/constants.d.ts.map +1 -1
  12. package/dist/main/lib/constants.js +2 -1
  13. package/dist/main/lib/constants.js.map +1 -1
  14. package/dist/main/lib/cookies.d.ts.map +1 -1
  15. package/dist/main/lib/cookies.js +1 -0
  16. package/dist/main/lib/cookies.js.map +1 -1
  17. package/dist/main/lib/fetch.d.ts +5 -4
  18. package/dist/main/lib/fetch.d.ts.map +1 -1
  19. package/dist/main/lib/fetch.js +10 -10
  20. package/dist/main/lib/fetch.js.map +1 -1
  21. package/dist/main/lib/helpers.d.ts +0 -11
  22. package/dist/main/lib/helpers.d.ts.map +1 -1
  23. package/dist/main/lib/helpers.js +6 -25
  24. package/dist/main/lib/helpers.js.map +1 -1
  25. package/dist/main/lib/polyfills.d.ts.map +1 -1
  26. package/dist/main/lib/polyfills.js +3 -1
  27. package/dist/main/lib/polyfills.js.map +1 -1
  28. package/dist/main/lib/types.d.ts +1 -1
  29. package/dist/main/lib/types.d.ts.map +1 -1
  30. package/dist/main/lib/version.d.ts +2 -0
  31. package/dist/main/lib/version.d.ts.map +1 -0
  32. package/dist/main/lib/version.js +6 -0
  33. package/dist/main/lib/version.js.map +1 -0
  34. package/dist/module/GoTrueApi.d.ts +39 -22
  35. package/dist/module/GoTrueApi.d.ts.map +1 -1
  36. package/dist/module/GoTrueApi.js +77 -68
  37. package/dist/module/GoTrueApi.js.map +1 -1
  38. package/dist/module/GoTrueClient.d.ts +26 -13
  39. package/dist/module/GoTrueClient.d.ts.map +1 -1
  40. package/dist/module/GoTrueClient.js +43 -45
  41. package/dist/module/GoTrueClient.js.map +1 -1
  42. package/dist/module/lib/constants.d.ts +3 -1
  43. package/dist/module/lib/constants.d.ts.map +1 -1
  44. package/dist/module/lib/constants.js +2 -1
  45. package/dist/module/lib/constants.js.map +1 -1
  46. package/dist/module/lib/cookies.d.ts.map +1 -1
  47. package/dist/module/lib/cookies.js +1 -0
  48. package/dist/module/lib/cookies.js.map +1 -1
  49. package/dist/module/lib/fetch.d.ts +5 -4
  50. package/dist/module/lib/fetch.d.ts.map +1 -1
  51. package/dist/module/lib/fetch.js +11 -11
  52. package/dist/module/lib/fetch.js.map +1 -1
  53. package/dist/module/lib/helpers.d.ts +0 -11
  54. package/dist/module/lib/helpers.d.ts.map +1 -1
  55. package/dist/module/lib/helpers.js +3 -22
  56. package/dist/module/lib/helpers.js.map +1 -1
  57. package/dist/module/lib/polyfills.d.ts.map +1 -1
  58. package/dist/module/lib/polyfills.js +3 -1
  59. package/dist/module/lib/polyfills.js.map +1 -1
  60. package/dist/module/lib/types.d.ts +1 -1
  61. package/dist/module/lib/types.d.ts.map +1 -1
  62. package/dist/module/lib/version.d.ts +2 -0
  63. package/dist/module/lib/version.d.ts.map +1 -0
  64. package/dist/module/lib/version.js +3 -0
  65. package/dist/module/lib/version.js.map +1 -0
  66. package/package.json +18 -7
  67. package/src/GoTrueApi.ts +142 -80
  68. package/src/GoTrueClient.ts +74 -59
  69. package/src/lib/constants.ts +2 -1
  70. package/src/lib/cookies.ts +1 -0
  71. package/src/lib/fetch.ts +32 -10
  72. package/src/lib/helpers.ts +3 -26
  73. package/src/lib/polyfills.ts +3 -2
  74. package/src/lib/types.ts +2 -0
  75. package/src/lib/version.ts +2 -0
package/README.md CHANGED
@@ -25,9 +25,21 @@ const GOTRUE_URL = 'http://localhost:9999'
25
25
  const auth = new GoTrueClient({ url: GOTRUE_URL })
26
26
  ```
27
27
 
28
- - `signUp()`: https://supabase.io/docs/gotrue/client/signup
29
- - `signIn()`: https://supabase.io/docs/gotrue/client/signin
30
- - `signOut()`: https://supabase.io/docs/gotrue/client/signout
28
+ - `signUp()`: https://supabase.io/docs/reference/javascript/auth-signup
29
+ - `signIn()`: https://supabase.io/docs/reference/javascript/auth-signin
30
+ - `signOut()`: https://supabase.io/docs/reference/javascript/auth-signout
31
+
32
+ ### Custom `fetch` implementation
33
+
34
+ `gotrue-js` uses the [`cross-fetch`](https://www.npmjs.com/package/cross-fetch) library to make HTTP requests, but an alternative `fetch` implementation can be provided as an option. This is most useful in environments where `cross-fetch` is not compatible, for instance Cloudflare Workers:
35
+
36
+ ```js
37
+ import { GoTrueClient } from '@supabase/gotrue-js'
38
+
39
+ const GOTRUE_URL = 'http://localhost:9999'
40
+
41
+ const auth = new GoTrueClient({ url: GOTRUE_URL, fetch: fetch })
42
+ ```
31
43
 
32
44
  ## Sponsors
33
45
 
@@ -35,4 +47,4 @@ We are building the features of Firebase using enterprise-grade, open source pro
35
47
 
36
48
  [![New Sponsor](https://user-images.githubusercontent.com/10214025/90518111-e74bbb00-e198-11ea-8f88-c9e3c1aa4b5b.png)](https://github.com/sponsors/supabase)
37
49
 
38
- ![Watch this repo](https://gitcdn.xyz/repo/supabase/monorepo/master/web/static/watch-repo.gif "Watch this repo")
50
+ ![Watch this repo](https://gitcdn.xyz/repo/supabase/monorepo/master/web/static/watch-repo.gif 'Watch this repo')
@@ -1,31 +1,40 @@
1
+ import { Fetch } from './lib/fetch';
1
2
  import { Session, Provider, UserAttributes, CookieOptions, User } from './lib/types';
3
+ export interface ApiError {
4
+ message: string;
5
+ status: number;
6
+ }
2
7
  export default class GoTrueApi {
3
8
  protected url: string;
4
9
  protected headers: {
5
10
  [key: string]: string;
6
11
  };
7
12
  protected cookieOptions: CookieOptions;
8
- constructor({ url, headers, cookieOptions, }: {
13
+ protected fetch?: Fetch;
14
+ constructor({ url, headers, cookieOptions, fetch, }: {
9
15
  url: string;
10
16
  headers?: {
11
17
  [key: string]: string;
12
18
  };
13
19
  cookieOptions?: CookieOptions;
20
+ fetch?: Fetch;
14
21
  });
15
22
  /**
16
23
  * Creates a new user using their email address.
17
24
  * @param email The email address of the user.
18
25
  * @param password The password of the user.
19
26
  * @param redirectTo A URL or mobile address to send the user to after they are confirmed.
27
+ * @param data Optional user metadata.
20
28
  *
21
29
  * @returns A logged-in session if the server has "autoconfirm" ON
22
30
  * @returns A user if the server has "autoconfirm" OFF
23
31
  */
24
32
  signUpWithEmail(email: string, password: string, options?: {
25
33
  redirectTo?: string;
34
+ data?: object;
26
35
  }): Promise<{
27
36
  data: Session | User | null;
28
- error: Error | null;
37
+ error: ApiError | null;
29
38
  }>;
30
39
  /**
31
40
  * Logs in an existing user using their email address.
@@ -37,25 +46,28 @@ export default class GoTrueApi {
37
46
  redirectTo?: string;
38
47
  }): Promise<{
39
48
  data: Session | null;
40
- error: Error | null;
49
+ error: ApiError | null;
41
50
  }>;
42
51
  /**
43
52
  * Signs up a new user using their phone number and a password.
44
- * @param phone The email address of the user.
53
+ * @param phone The phone number of the user.
45
54
  * @param password The password of the user.
55
+ * @param data Optional user metadata.
46
56
  */
47
- signUpWithPhone(phone: string, password: string): Promise<{
57
+ signUpWithPhone(phone: string, password: string, options?: {
58
+ data?: object;
59
+ }): Promise<{
48
60
  data: Session | User | null;
49
- error: Error | null;
61
+ error: ApiError | null;
50
62
  }>;
51
63
  /**
52
64
  * Logs in an existing user using their phone number and password.
53
- * @param phone The email address of the user.
65
+ * @param phone The phone number of the user.
54
66
  * @param password The password of the user.
55
67
  */
56
68
  signInWithPhone(phone: string, password: string): Promise<{
57
69
  data: Session | null;
58
- error: Error | null;
70
+ error: ApiError | null;
59
71
  }>;
60
72
  /**
61
73
  * Sends a magic login link to an email address.
@@ -66,7 +78,7 @@ export default class GoTrueApi {
66
78
  redirectTo?: string;
67
79
  }): Promise<{
68
80
  data: {} | null;
69
- error: Error | null;
81
+ error: ApiError | null;
70
82
  }>;
71
83
  /**
72
84
  * Sends a mobile OTP via SMS. Will register the account if it doesn't already exist
@@ -74,7 +86,7 @@ export default class GoTrueApi {
74
86
  */
75
87
  sendMobileOTP(phone: string): Promise<{
76
88
  data: {} | null;
77
- error: Error | null;
89
+ error: ApiError | null;
78
90
  }>;
79
91
  /**
80
92
  * Send User supplied Mobile OTP to be verified
@@ -86,18 +98,20 @@ export default class GoTrueApi {
86
98
  redirectTo?: string;
87
99
  }): Promise<{
88
100
  data: Session | User | null;
89
- error: Error | null;
101
+ error: ApiError | null;
90
102
  }>;
91
103
  /**
92
104
  * Sends an invite link to an email address.
93
105
  * @param email The email address of the user.
94
106
  * @param redirectTo A URL or mobile address to send the user to after they are confirmed.
107
+ * @param data Optional user metadata
95
108
  */
96
109
  inviteUserByEmail(email: string, options?: {
97
110
  redirectTo?: string;
111
+ data?: object;
98
112
  }): Promise<{
99
113
  data: User | null;
100
- error: Error | null;
114
+ error: ApiError | null;
101
115
  }>;
102
116
  /**
103
117
  * Sends a reset request to an email address.
@@ -108,7 +122,7 @@ export default class GoTrueApi {
108
122
  redirectTo?: string;
109
123
  }): Promise<{
110
124
  data: {} | null;
111
- error: Error | null;
125
+ error: ApiError | null;
112
126
  }>;
113
127
  /**
114
128
  * Create a temporary object with all configured headers and
@@ -121,7 +135,7 @@ export default class GoTrueApi {
121
135
  * @param jwt A valid, logged-in JWT.
122
136
  */
123
137
  signOut(jwt: string): Promise<{
124
- error: Error | null;
138
+ error: ApiError | null;
125
139
  }>;
126
140
  /**
127
141
  * Generates the relevant login URL for a third-party provider.
@@ -140,7 +154,7 @@ export default class GoTrueApi {
140
154
  getUser(jwt: string): Promise<{
141
155
  user: User | null;
142
156
  data: User | null;
143
- error: Error | null;
157
+ error: ApiError | null;
144
158
  }>;
145
159
  /**
146
160
  * Updates the user data.
@@ -150,17 +164,20 @@ export default class GoTrueApi {
150
164
  updateUser(jwt: string, attributes: UserAttributes): Promise<{
151
165
  user: User | null;
152
166
  data: User | null;
153
- error: Error | null;
167
+ error: ApiError | null;
154
168
  }>;
155
169
  /**
156
- * Delete an user.
170
+ * Delete a user. Requires a `service_role` key.
171
+ *
172
+ * This function should only be called on a server. Never expose your `service_role` key in the browser.
173
+ *
157
174
  * @param uid The user uid you want to remove.
158
175
  * @param jwt A valid JWT. Must be a full-access API key (e.g. service_role key).
159
176
  */
160
177
  deleteUser(uid: string, jwt: string): Promise<{
161
178
  user: User | null;
162
179
  data: User | null;
163
- error: Error | null;
180
+ error: ApiError | null;
164
181
  }>;
165
182
  /**
166
183
  * Generates a new JWT.
@@ -168,7 +185,7 @@ export default class GoTrueApi {
168
185
  */
169
186
  refreshAccessToken(refreshToken: string): Promise<{
170
187
  data: Session | null;
171
- error: Error | null;
188
+ error: ApiError | null;
172
189
  }>;
173
190
  /**
174
191
  * Set/delete the auth cookie based on the AuthChangeEvent.
@@ -182,7 +199,7 @@ export default class GoTrueApi {
182
199
  getUserByCookie(req: any): Promise<{
183
200
  user: User | null;
184
201
  data: User | null;
185
- error: Error | null;
202
+ error: ApiError | null;
186
203
  }>;
187
204
  /**
188
205
  * Generates links to be sent via email or other.
@@ -194,11 +211,11 @@ export default class GoTrueApi {
194
211
  */
195
212
  generateLink(type: 'signup' | 'magiclink' | 'recovery' | 'invite', email: string, options?: {
196
213
  password?: string;
197
- data?: any;
214
+ data?: object;
198
215
  redirectTo?: string;
199
216
  }): Promise<{
200
217
  data: Session | User | null;
201
- error: Error | null;
218
+ error: ApiError | null;
202
219
  }>;
203
220
  }
204
221
  //# sourceMappingURL=GoTrueApi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GoTrueApi.d.ts","sourceRoot":"","sources":["../../src/GoTrueApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,aA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A;KAAE,CAAC;IAgB5E;;;;;;;OAOG;IACG,YAAY,CAChB,IAAI,EAAE,QAAQ,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,EACpD,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;QACP,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,UAAU,CAAC,EAAE,MAAM,CAAA;KACf,GACL,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC;QAAC,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;KAAE,CAAC;CAmBpE"}
@@ -14,16 +14,18 @@ const constants_1 = require("./lib/constants");
14
14
  const cookies_1 = require("./lib/cookies");
15
15
  const helpers_1 = require("./lib/helpers");
16
16
  class GoTrueApi {
17
- constructor({ url = '', headers = {}, cookieOptions, }) {
17
+ constructor({ url = '', headers = {}, cookieOptions, fetch, }) {
18
18
  this.url = url;
19
19
  this.headers = headers;
20
20
  this.cookieOptions = Object.assign(Object.assign({}, constants_1.COOKIE_OPTIONS), cookieOptions);
21
+ this.fetch = fetch;
21
22
  }
22
23
  /**
23
24
  * Creates a new user using their email address.
24
25
  * @param email The email address of the user.
25
26
  * @param password The password of the user.
26
27
  * @param redirectTo A URL or mobile address to send the user to after they are confirmed.
28
+ * @param data Optional user metadata.
27
29
  *
28
30
  * @returns A logged-in session if the server has "autoconfirm" ON
29
31
  * @returns A user if the server has "autoconfirm" OFF
@@ -31,19 +33,19 @@ class GoTrueApi {
31
33
  signUpWithEmail(email, password, options = {}) {
32
34
  return __awaiter(this, void 0, void 0, function* () {
33
35
  try {
34
- let headers = Object.assign({}, this.headers);
36
+ const headers = Object.assign({}, this.headers);
35
37
  let queryString = '';
36
38
  if (options.redirectTo) {
37
39
  queryString = '?redirect_to=' + encodeURIComponent(options.redirectTo);
38
40
  }
39
- const data = yield fetch_1.post(`${this.url}/signup${queryString}`, { email, password }, { headers });
40
- let session = Object.assign({}, data);
41
+ const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/signup${queryString}`, { email, password, data: options.data }, { headers });
42
+ const session = Object.assign({}, data);
41
43
  if (session.expires_in)
42
- session.expires_at = helpers_1.expiresAt(data.expires_in);
44
+ session.expires_at = (0, helpers_1.expiresAt)(data.expires_in);
43
45
  return { data: session, error: null };
44
46
  }
45
- catch (error) {
46
- return { data: null, error };
47
+ catch (e) {
48
+ return { data: null, error: e };
47
49
  }
48
50
  });
49
51
  }
@@ -56,60 +58,61 @@ class GoTrueApi {
56
58
  signInWithEmail(email, password, options = {}) {
57
59
  return __awaiter(this, void 0, void 0, function* () {
58
60
  try {
59
- let headers = Object.assign({}, this.headers);
61
+ const headers = Object.assign({}, this.headers);
60
62
  let queryString = '?grant_type=password';
61
63
  if (options.redirectTo) {
62
64
  queryString += '&redirect_to=' + encodeURIComponent(options.redirectTo);
63
65
  }
64
- const data = yield fetch_1.post(`${this.url}/token${queryString}`, { email, password }, { headers });
65
- let session = Object.assign({}, data);
66
+ const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/token${queryString}`, { email, password }, { headers });
67
+ const session = Object.assign({}, data);
66
68
  if (session.expires_in)
67
- session.expires_at = helpers_1.expiresAt(data.expires_in);
69
+ session.expires_at = (0, helpers_1.expiresAt)(data.expires_in);
68
70
  return { data: session, error: null };
69
71
  }
70
- catch (error) {
71
- return { data: null, error };
72
+ catch (e) {
73
+ return { data: null, error: e };
72
74
  }
73
75
  });
74
76
  }
75
77
  /**
76
78
  * Signs up a new user using their phone number and a password.
77
- * @param phone The email address of the user.
79
+ * @param phone The phone number of the user.
78
80
  * @param password The password of the user.
81
+ * @param data Optional user metadata.
79
82
  */
80
- signUpWithPhone(phone, password) {
83
+ signUpWithPhone(phone, password, options = {}) {
81
84
  return __awaiter(this, void 0, void 0, function* () {
82
85
  try {
83
- let headers = Object.assign({}, this.headers);
84
- const data = yield fetch_1.post(`${this.url}/signup`, { phone, password }, { headers });
85
- let session = Object.assign({}, data);
86
+ const headers = Object.assign({}, this.headers);
87
+ const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/signup`, { phone, password, data: options.data }, { headers });
88
+ const session = Object.assign({}, data);
86
89
  if (session.expires_in)
87
- session.expires_at = helpers_1.expiresAt(data.expires_in);
90
+ session.expires_at = (0, helpers_1.expiresAt)(data.expires_in);
88
91
  return { data: session, error: null };
89
92
  }
90
- catch (error) {
91
- return { data: null, error };
93
+ catch (e) {
94
+ return { data: null, error: e };
92
95
  }
93
96
  });
94
97
  }
95
98
  /**
96
99
  * Logs in an existing user using their phone number and password.
97
- * @param phone The email address of the user.
100
+ * @param phone The phone number of the user.
98
101
  * @param password The password of the user.
99
102
  */
100
103
  signInWithPhone(phone, password) {
101
104
  return __awaiter(this, void 0, void 0, function* () {
102
105
  try {
103
- let headers = Object.assign({}, this.headers);
104
- let queryString = '?grant_type=password';
105
- const data = yield fetch_1.post(`${this.url}/token${queryString}`, { phone, password }, { headers });
106
- let session = Object.assign({}, data);
106
+ const headers = Object.assign({}, this.headers);
107
+ const queryString = '?grant_type=password';
108
+ const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/token${queryString}`, { phone, password }, { headers });
109
+ const session = Object.assign({}, data);
107
110
  if (session.expires_in)
108
- session.expires_at = helpers_1.expiresAt(data.expires_in);
111
+ session.expires_at = (0, helpers_1.expiresAt)(data.expires_in);
109
112
  return { data: session, error: null };
110
113
  }
111
- catch (error) {
112
- return { data: null, error };
114
+ catch (e) {
115
+ return { data: null, error: e };
113
116
  }
114
117
  });
115
118
  }
@@ -121,16 +124,16 @@ class GoTrueApi {
121
124
  sendMagicLinkEmail(email, options = {}) {
122
125
  return __awaiter(this, void 0, void 0, function* () {
123
126
  try {
124
- let headers = Object.assign({}, this.headers);
127
+ const headers = Object.assign({}, this.headers);
125
128
  let queryString = '';
126
129
  if (options.redirectTo) {
127
130
  queryString += '?redirect_to=' + encodeURIComponent(options.redirectTo);
128
131
  }
129
- const data = yield fetch_1.post(`${this.url}/magiclink${queryString}`, { email }, { headers });
132
+ const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/magiclink${queryString}`, { email }, { headers });
130
133
  return { data, error: null };
131
134
  }
132
- catch (error) {
133
- return { data: null, error };
135
+ catch (e) {
136
+ return { data: null, error: e };
134
137
  }
135
138
  });
136
139
  }
@@ -141,12 +144,12 @@ class GoTrueApi {
141
144
  sendMobileOTP(phone) {
142
145
  return __awaiter(this, void 0, void 0, function* () {
143
146
  try {
144
- let headers = Object.assign({}, this.headers);
145
- const data = yield fetch_1.post(`${this.url}/otp`, { phone }, { headers });
147
+ const headers = Object.assign({}, this.headers);
148
+ const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/otp`, { phone }, { headers });
146
149
  return { data, error: null };
147
150
  }
148
- catch (error) {
149
- return { data: null, error };
151
+ catch (e) {
152
+ return { data: null, error: e };
150
153
  }
151
154
  });
152
155
  }
@@ -159,12 +162,12 @@ class GoTrueApi {
159
162
  verifyMobileOTP(phone, token, options = {}) {
160
163
  return __awaiter(this, void 0, void 0, function* () {
161
164
  try {
162
- let headers = Object.assign({}, this.headers);
163
- const data = yield fetch_1.post(`${this.url}/verify`, { phone, token, type: 'sms', redirect_to: options.redirectTo }, { headers });
165
+ const headers = Object.assign({}, this.headers);
166
+ const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/verify`, { phone, token, type: 'sms', redirect_to: options.redirectTo }, { headers });
164
167
  return { data, error: null };
165
168
  }
166
- catch (error) {
167
- return { data: null, error };
169
+ catch (e) {
170
+ return { data: null, error: e };
168
171
  }
169
172
  });
170
173
  }
@@ -172,20 +175,21 @@ class GoTrueApi {
172
175
  * Sends an invite link to an email address.
173
176
  * @param email The email address of the user.
174
177
  * @param redirectTo A URL or mobile address to send the user to after they are confirmed.
178
+ * @param data Optional user metadata
175
179
  */
176
180
  inviteUserByEmail(email, options = {}) {
177
181
  return __awaiter(this, void 0, void 0, function* () {
178
182
  try {
179
- let headers = Object.assign({}, this.headers);
183
+ const headers = Object.assign({}, this.headers);
180
184
  let queryString = '';
181
185
  if (options.redirectTo) {
182
186
  queryString += '?redirect_to=' + encodeURIComponent(options.redirectTo);
183
187
  }
184
- const data = yield fetch_1.post(`${this.url}/invite${queryString}`, { email }, { headers });
188
+ const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/invite${queryString}`, { email, data: options.data }, { headers });
185
189
  return { data, error: null };
186
190
  }
187
- catch (error) {
188
- return { data: null, error };
191
+ catch (e) {
192
+ return { data: null, error: e };
189
193
  }
190
194
  });
191
195
  }
@@ -197,16 +201,16 @@ class GoTrueApi {
197
201
  resetPasswordForEmail(email, options = {}) {
198
202
  return __awaiter(this, void 0, void 0, function* () {
199
203
  try {
200
- let headers = Object.assign({}, this.headers);
204
+ const headers = Object.assign({}, this.headers);
201
205
  let queryString = '';
202
206
  if (options.redirectTo) {
203
207
  queryString += '?redirect_to=' + encodeURIComponent(options.redirectTo);
204
208
  }
205
- const data = yield fetch_1.post(`${this.url}/recover${queryString}`, { email }, { headers });
209
+ const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/recover${queryString}`, { email }, { headers });
206
210
  return { data, error: null };
207
211
  }
208
- catch (error) {
209
- return { data: null, error };
212
+ catch (e) {
213
+ return { data: null, error: e };
210
214
  }
211
215
  });
212
216
  }
@@ -227,11 +231,11 @@ class GoTrueApi {
227
231
  signOut(jwt) {
228
232
  return __awaiter(this, void 0, void 0, function* () {
229
233
  try {
230
- yield fetch_1.post(`${this.url}/logout`, {}, { headers: this._createRequestHeaders(jwt), noResolveJson: true });
234
+ yield (0, fetch_1.post)(this.fetch, `${this.url}/logout`, {}, { headers: this._createRequestHeaders(jwt), noResolveJson: true });
231
235
  return { error: null };
232
236
  }
233
- catch (error) {
234
- return { error };
237
+ catch (e) {
238
+ return { error: e };
235
239
  }
236
240
  });
237
241
  }
@@ -242,7 +246,7 @@ class GoTrueApi {
242
246
  * @param scopes A space-separated list of scopes granted to the OAuth application.
243
247
  */
244
248
  getUrlForProvider(provider, options) {
245
- let urlParams = [`provider=${encodeURIComponent(provider)}`];
249
+ const urlParams = [`provider=${encodeURIComponent(provider)}`];
246
250
  if (options === null || options === void 0 ? void 0 : options.redirectTo) {
247
251
  urlParams.push(`redirect_to=${encodeURIComponent(options.redirectTo)}`);
248
252
  }
@@ -258,11 +262,13 @@ class GoTrueApi {
258
262
  getUser(jwt) {
259
263
  return __awaiter(this, void 0, void 0, function* () {
260
264
  try {
261
- const data = yield fetch_1.get(`${this.url}/user`, { headers: this._createRequestHeaders(jwt) });
265
+ const data = yield (0, fetch_1.get)(this.fetch, `${this.url}/user`, {
266
+ headers: this._createRequestHeaders(jwt),
267
+ });
262
268
  return { user: data, data, error: null };
263
269
  }
264
- catch (error) {
265
- return { user: null, data: null, error };
270
+ catch (e) {
271
+ return { user: null, data: null, error: e };
266
272
  }
267
273
  });
268
274
  }
@@ -274,31 +280,34 @@ class GoTrueApi {
274
280
  updateUser(jwt, attributes) {
275
281
  return __awaiter(this, void 0, void 0, function* () {
276
282
  try {
277
- const data = yield fetch_1.put(`${this.url}/user`, attributes, {
283
+ const data = yield (0, fetch_1.put)(this.fetch, `${this.url}/user`, attributes, {
278
284
  headers: this._createRequestHeaders(jwt),
279
285
  });
280
286
  return { user: data, data, error: null };
281
287
  }
282
- catch (error) {
283
- return { user: null, data: null, error };
288
+ catch (e) {
289
+ return { user: null, data: null, error: e };
284
290
  }
285
291
  });
286
292
  }
287
293
  /**
288
- * Delete an user.
294
+ * Delete a user. Requires a `service_role` key.
295
+ *
296
+ * This function should only be called on a server. Never expose your `service_role` key in the browser.
297
+ *
289
298
  * @param uid The user uid you want to remove.
290
299
  * @param jwt A valid JWT. Must be a full-access API key (e.g. service_role key).
291
300
  */
292
301
  deleteUser(uid, jwt) {
293
302
  return __awaiter(this, void 0, void 0, function* () {
294
303
  try {
295
- const data = yield fetch_1.remove(`${this.url}/admin/users/${uid}`, {}, {
304
+ const data = yield (0, fetch_1.remove)(this.fetch, `${this.url}/admin/users/${uid}`, {}, {
296
305
  headers: this._createRequestHeaders(jwt),
297
306
  });
298
307
  return { user: data, data, error: null };
299
308
  }
300
- catch (error) {
301
- return { user: null, data: null, error };
309
+ catch (e) {
310
+ return { user: null, data: null, error: e };
302
311
  }
303
312
  });
304
313
  }
@@ -309,14 +318,14 @@ class GoTrueApi {
309
318
  refreshAccessToken(refreshToken) {
310
319
  return __awaiter(this, void 0, void 0, function* () {
311
320
  try {
312
- const data = yield fetch_1.post(`${this.url}/token?grant_type=refresh_token`, { refresh_token: refreshToken }, { headers: this.headers });
313
- let session = Object.assign({}, data);
321
+ const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/token?grant_type=refresh_token`, { refresh_token: refreshToken }, { headers: this.headers });
322
+ const session = Object.assign({}, data);
314
323
  if (session.expires_in)
315
- session.expires_at = helpers_1.expiresAt(data.expires_in);
324
+ session.expires_at = (0, helpers_1.expiresAt)(data.expires_in);
316
325
  return { data: session, error: null };
317
326
  }
318
- catch (error) {
319
- return { data: null, error };
327
+ catch (e) {
328
+ return { data: null, error: e };
320
329
  }
321
330
  });
322
331
  }
@@ -335,7 +344,7 @@ class GoTrueApi {
335
344
  if (event === 'SIGNED_IN') {
336
345
  if (!session)
337
346
  throw new Error('Auth session missing!');
338
- cookies_1.setCookie(req, res, {
347
+ (0, cookies_1.setCookie)(req, res, {
339
348
  name: this.cookieOptions.name,
340
349
  value: session.access_token,
341
350
  domain: this.cookieOptions.domain,
@@ -345,7 +354,7 @@ class GoTrueApi {
345
354
  });
346
355
  }
347
356
  if (event === 'SIGNED_OUT')
348
- cookies_1.deleteCookie(req, res, this.cookieOptions.name);
357
+ (0, cookies_1.deleteCookie)(req, res, this.cookieOptions.name);
349
358
  res.status(200).json({});
350
359
  }
351
360
  /**
@@ -365,8 +374,8 @@ class GoTrueApi {
365
374
  throw error;
366
375
  return { user, data: user, error: null };
367
376
  }
368
- catch (error) {
369
- return { user: null, data: null, error };
377
+ catch (e) {
378
+ return { user: null, data: null, error: e };
370
379
  }
371
380
  });
372
381
  }
@@ -381,7 +390,7 @@ class GoTrueApi {
381
390
  generateLink(type, email, options = {}) {
382
391
  return __awaiter(this, void 0, void 0, function* () {
383
392
  try {
384
- const data = yield fetch_1.post(`${this.url}/admin/generate_link`, {
393
+ const data = yield (0, fetch_1.post)(this.fetch, `${this.url}/admin/generate_link`, {
385
394
  type,
386
395
  email,
387
396
  password: options.password,
@@ -390,8 +399,8 @@ class GoTrueApi {
390
399
  }, { headers: this.headers });
391
400
  return { data, error: null };
392
401
  }
393
- catch (error) {
394
- return { data: null, error };
402
+ catch (e) {
403
+ return { data: null, error: e };
395
404
  }
396
405
  });
397
406
  }