@quatrain/auth-supabase 1.0.2 → 1.0.3

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.
@@ -1,4 +1,4 @@
1
- import { User } from '@quatrain/core';
1
+ import { User } from '@quatrain/backend';
2
2
  import { AbstractAuthAdapter, AuthParameters } from '@quatrain/auth';
3
3
  export declare class SupabaseAuthAdapter extends AbstractAuthAdapter {
4
4
  protected _client: any;
@@ -16,7 +16,12 @@ const supabase_js_1 = require("@supabase/supabase-js");
16
16
  class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
17
17
  constructor(params = {}) {
18
18
  super(params);
19
- this._client = (0, supabase_js_1.createClient)(params.config.supabaseUrl, params.config.supabaseKey);
19
+ this._client = (0, supabase_js_1.createClient)(params.config.supabaseUrl, params.config.supabaseKey, {
20
+ auth: {
21
+ autoRefreshToken: false,
22
+ persistSession: false,
23
+ },
24
+ });
20
25
  }
21
26
  /**
22
27
  * Register new user in authentication
@@ -26,13 +31,16 @@ class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
26
31
  register(user) {
27
32
  return __awaiter(this, void 0, void 0, function* () {
28
33
  try {
29
- const { name: displayName, email, phone: phoneNumber, password, disabled = false, } = user._;
34
+ const { name: displayName, email, phone: phoneNumber, password,
35
+ //disabled = false,
36
+ } = user._;
30
37
  auth_1.Auth.log(`[SAA] Adding user '${displayName}'`);
31
- const { data, error } = yield this._client.auth.signUp({
38
+ const { data, error } = yield this._client.auth.admin.createUser({
32
39
  email,
33
40
  password,
34
41
  });
35
42
  if (error) {
43
+ console.log(error);
36
44
  throw new Error(error);
37
45
  }
38
46
  return data.user;
@@ -64,7 +72,10 @@ class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
64
72
  try {
65
73
  if (Object.keys(updatable).length > 0) {
66
74
  auth_1.Auth.log(`Updating ${updatable.displayName} Auth record`);
67
- // await getAuth().updateUser(user.uid, updatable)
75
+ const { data, error } = yield this._client.auth.admin.updateUserById(user.uid, updatable);
76
+ if (error !== null) {
77
+ auth_1.Auth.log(error);
78
+ }
68
79
  }
69
80
  }
70
81
  catch (e) { }
@@ -77,7 +88,7 @@ class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
77
88
  }
78
89
  setCustomUserClaims(id, claims) {
79
90
  return __awaiter(this, void 0, void 0, function* () {
80
- const { data, error } = yield this._client.auth.updateUserById(id, claims);
91
+ const { data, error } = yield this._client.auth.admin.updateUserById(id, claims);
81
92
  if (error) {
82
93
  throw new Error(error);
83
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/auth-supabase",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",