@supabase/gotrue-js 2.119.0-canary.0 → 2.119.0-canary.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supabase/gotrue-js",
3
- "version": "2.119.0-canary.0",
3
+ "version": "2.119.0-canary.2",
4
4
  "private": false,
5
5
  "description": "Official SDK for Supabase Auth",
6
6
  "keywords": [
@@ -801,6 +801,8 @@ export default class GoTrueAdminApi {
801
801
 
802
802
  /**
803
803
  * Delete a user. Requires a `service_role` key.
804
+ * Returns the user that was deleted. In cases of concurrent updates, the user object returned
805
+ * might not accurately reflect the user information at the time of deletion.
804
806
  *
805
807
  * @param id The user id you want to remove.
806
808
  * @param shouldSoftDelete If true, then the user will be soft-deleted from the auth schema. Soft deletion allows user identification from the hashed user ID but is not reversible.
@@ -825,7 +827,14 @@ export default class GoTrueAdminApi {
825
827
  * ```json
826
828
  * {
827
829
  * "data": {
828
- * "user": {}
830
+ * "user": {
831
+ * "id": "715ed5db-f090-4b8c-a067-640ecee36aa0",
832
+ * "aud": "authenticated",
833
+ * "role": "authenticated",
834
+ * "email": "example@email.com",
835
+ * "created_at": "2024-01-01T00:00:00Z",
836
+ * "updated_at": "2024-01-01T00:00:00Z"
837
+ * }
829
838
  * },
830
839
  * "error": null
831
840
  * }
@@ -835,13 +844,24 @@ export default class GoTrueAdminApi {
835
844
  validateUUID(id)
836
845
 
837
846
  try {
838
- return await _request(this.fetch, 'DELETE', `${this.url}/admin/users/${id}`, {
847
+ // The Auth server answers the DELETE with an empty object. However, this is
848
+ // a breaking change in the JS API, so until `v3` is released, we polyfill the
849
+ // result by fetching the user information before it gets deleted.
850
+ // See https://github.com/supabase/supabase-js/issues/2751
851
+ const { data, error } = await this.getUserById(id)
852
+ if (error) {
853
+ return { data: { user: null }, error }
854
+ }
855
+
856
+ await _request(this.fetch, 'DELETE', `${this.url}/admin/users/${id}`, {
839
857
  headers: this.headers,
840
858
  body: {
841
859
  should_soft_delete: shouldSoftDelete,
842
860
  },
843
- xform: _userResponse,
861
+ noResolveJson: true,
844
862
  })
863
+
864
+ return { data, error: null }
845
865
  } catch (error) {
846
866
  if (isAuthError(error)) {
847
867
  return { data: { user: null }, error }
@@ -4,4 +4,4 @@
4
4
  // - Debugging and support (identifying which version is running)
5
5
  // - Telemetry and logging (version reporting in errors/analytics)
6
6
  // - Ensuring build artifacts match the published package version
7
- export const version = '2.119.0-canary.0'
7
+ export const version = '2.119.0-canary.2'