@quatrain/auth-supabase 1.0.0-beta4 → 1.0.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.
@@ -1,4 +1,5 @@
1
- import { AbstractAuthAdapter, User, AuthParameters } from '@quatrain/core';
1
+ import { User } from '@quatrain/core';
2
+ import { AbstractAuthAdapter, AuthParameters } from '@quatrain/auth';
2
3
  export declare class SupabaseAuthAdapter extends AbstractAuthAdapter {
3
4
  protected _client: any;
4
5
  constructor(params?: AuthParameters);
@@ -13,4 +14,5 @@ export declare class SupabaseAuthAdapter extends AbstractAuthAdapter {
13
14
  signout(user: User): Promise<any>;
14
15
  update(user: User, updatable: any): Promise<any>;
15
16
  delete(user: User): Promise<any>;
17
+ setCustomUserClaims(id: string, claims: any): Promise<any>;
16
18
  }
@@ -10,10 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SupabaseAuthAdapter = void 0;
13
- const core_1 = require("@quatrain/core");
13
+ const auth_1 = require("@quatrain/auth");
14
14
  const supabase_js_1 = require("@supabase/supabase-js");
15
15
  // Create a single supabase client for interacting with your database
16
- class SupabaseAuthAdapter extends core_1.AbstractAuthAdapter {
16
+ class SupabaseAuthAdapter extends auth_1.AbstractAuthAdapter {
17
17
  constructor(params = {}) {
18
18
  super(params);
19
19
  this._client = (0, supabase_js_1.createClient)(params.config.supabaseUrl, params.config.supabaseKey);
@@ -27,7 +27,7 @@ class SupabaseAuthAdapter extends core_1.AbstractAuthAdapter {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
28
  try {
29
29
  const { name: displayName, email, phone: phoneNumber, password, disabled = false, } = user._;
30
- core_1.Core.log(`[SAA] Adding user '${displayName}'`);
30
+ auth_1.Auth.log(`[SAA] Adding user '${displayName}'`);
31
31
  const { data, error } = yield this._client.auth.signUp({
32
32
  email,
33
33
  password,
@@ -39,7 +39,7 @@ class SupabaseAuthAdapter extends core_1.AbstractAuthAdapter {
39
39
  }
40
40
  catch (err) {
41
41
  console.log(err);
42
- throw new core_1.AuthenticationError(err.message);
42
+ throw new auth_1.AuthenticationError(err.message);
43
43
  }
44
44
  });
45
45
  }
@@ -60,10 +60,10 @@ class SupabaseAuthAdapter extends core_1.AbstractAuthAdapter {
60
60
  }
61
61
  update(user, updatable) {
62
62
  return __awaiter(this, void 0, void 0, function* () {
63
- console.log('auth data to update', JSON.stringify(updatable));
63
+ auth_1.Auth.log('auth data to update', JSON.stringify(updatable));
64
64
  try {
65
65
  if (Object.keys(updatable).length > 0) {
66
- console.log(`Updating ${updatable.displayName} Auth record`);
66
+ auth_1.Auth.log(`Updating ${updatable.displayName} Auth record`);
67
67
  // await getAuth().updateUser(user.uid, updatable)
68
68
  }
69
69
  }
@@ -75,5 +75,16 @@ class SupabaseAuthAdapter extends core_1.AbstractAuthAdapter {
75
75
  // return await getAuth().deleteUser(user.uid)
76
76
  });
77
77
  }
78
+ setCustomUserClaims(id, claims) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ const { data, error } = yield this._client.auth.updateUserById(id, claims);
81
+ if (error) {
82
+ throw new Error(error);
83
+ }
84
+ else {
85
+ return data;
86
+ }
87
+ });
88
+ }
78
89
  }
79
90
  exports.SupabaseAuthAdapter = SupabaseAuthAdapter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/auth-supabase",
3
- "version": "1.0.0-beta4",
3
+ "version": "1.0.1",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -13,6 +13,7 @@
13
13
  "@quatrain/core": "^1.0.0-beta2"
14
14
  },
15
15
  "dependencies": {
16
+ "@quatrain/auth": "^1.0.0",
16
17
  "@supabase/supabase-js": "^2.42.4"
17
18
  },
18
19
  "devDependencies": {