@gbozee/ultimate 0.0.2-135 → 0.0.2-137

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/dist/index.cjs CHANGED
@@ -51557,6 +51557,14 @@ class AppDatabase {
51557
51557
  });
51558
51558
  return user[0];
51559
51559
  }
51560
+ async verifyUserPassword(password) {
51561
+ const user = await this.getUserByEmail();
51562
+ if (user) {
51563
+ const userPassword = decryptObject(user.settings.password, this.salt);
51564
+ return userPassword === password;
51565
+ }
51566
+ return false;
51567
+ }
51560
51568
  async generateUserPassword() {
51561
51569
  const user = await this.getUserByEmail();
51562
51570
  if (user) {
@@ -51638,6 +51646,30 @@ class AppDatabase {
51638
51646
  }
51639
51647
  return false;
51640
51648
  }
51649
+ async verifyAdminPassword(password) {
51650
+ if (!this.email) {
51651
+ const instance = await this.pb.collection("_superusers").getOne(this.pb.authStore.record.id);
51652
+ if (instance) {
51653
+ const userPassword = decryptObject(instance.settings.password, instance.settings.salt);
51654
+ return userPassword === password;
51655
+ }
51656
+ }
51657
+ return false;
51658
+ }
51659
+ async setAdminPassword(payload) {
51660
+ const { password, salt } = payload;
51661
+ if (!this.email) {
51662
+ const encrypted = encryptObject(password, salt);
51663
+ await this.pb.collection("_superusers").update(this.pb.authStore.record.id, {
51664
+ settings: {
51665
+ password: encrypted,
51666
+ salt
51667
+ }
51668
+ });
51669
+ return true;
51670
+ }
51671
+ return false;
51672
+ }
51641
51673
  async addNewCredential(params) {
51642
51674
  const { password, payload } = params;
51643
51675
  let credentials = await this.getCredentials({ password });
package/dist/index.d.ts CHANGED
@@ -547,6 +547,7 @@ export declare class AppDatabase {
547
547
  salt?: string;
548
548
  });
549
549
  getUserByEmail(): Promise<import("pocketbase").RecordModel>;
550
+ verifyUserPassword(password: string): Promise<boolean>;
550
551
  generateUserPassword(): Promise<void>;
551
552
  getUserCredentials(): Promise<any>;
552
553
  getCredentials(payload: {
@@ -559,6 +560,11 @@ export declare class AppDatabase {
559
560
  changeUserPassword(payload: {
560
561
  password: string;
561
562
  }): Promise<boolean>;
563
+ verifyAdminPassword(password: string): Promise<boolean>;
564
+ setAdminPassword(payload: {
565
+ password: string;
566
+ salt: string;
567
+ }): Promise<boolean>;
562
568
  addNewCredential(params: {
563
569
  password?: string;
564
570
  payload: {
package/dist/index.js CHANGED
@@ -51505,6 +51505,14 @@ class AppDatabase {
51505
51505
  });
51506
51506
  return user[0];
51507
51507
  }
51508
+ async verifyUserPassword(password) {
51509
+ const user = await this.getUserByEmail();
51510
+ if (user) {
51511
+ const userPassword = decryptObject(user.settings.password, this.salt);
51512
+ return userPassword === password;
51513
+ }
51514
+ return false;
51515
+ }
51508
51516
  async generateUserPassword() {
51509
51517
  const user = await this.getUserByEmail();
51510
51518
  if (user) {
@@ -51586,6 +51594,30 @@ class AppDatabase {
51586
51594
  }
51587
51595
  return false;
51588
51596
  }
51597
+ async verifyAdminPassword(password) {
51598
+ if (!this.email) {
51599
+ const instance = await this.pb.collection("_superusers").getOne(this.pb.authStore.record.id);
51600
+ if (instance) {
51601
+ const userPassword = decryptObject(instance.settings.password, instance.settings.salt);
51602
+ return userPassword === password;
51603
+ }
51604
+ }
51605
+ return false;
51606
+ }
51607
+ async setAdminPassword(payload) {
51608
+ const { password, salt } = payload;
51609
+ if (!this.email) {
51610
+ const encrypted = encryptObject(password, salt);
51611
+ await this.pb.collection("_superusers").update(this.pb.authStore.record.id, {
51612
+ settings: {
51613
+ password: encrypted,
51614
+ salt
51615
+ }
51616
+ });
51617
+ return true;
51618
+ }
51619
+ return false;
51620
+ }
51589
51621
  async addNewCredential(params) {
51590
51622
  const { password, payload } = params;
51591
51623
  let credentials = await this.getCredentials({ password });
@@ -58259,6 +58259,14 @@ class AppDatabase {
58259
58259
  });
58260
58260
  return user[0];
58261
58261
  }
58262
+ async verifyUserPassword(password) {
58263
+ const user = await this.getUserByEmail();
58264
+ if (user) {
58265
+ const userPassword = decryptObject(user.settings.password, this.salt);
58266
+ return userPassword === password;
58267
+ }
58268
+ return false;
58269
+ }
58262
58270
  async generateUserPassword() {
58263
58271
  const user = await this.getUserByEmail();
58264
58272
  if (user) {
@@ -58340,6 +58348,30 @@ class AppDatabase {
58340
58348
  }
58341
58349
  return false;
58342
58350
  }
58351
+ async verifyAdminPassword(password) {
58352
+ if (!this.email) {
58353
+ const instance = await this.pb.collection("_superusers").getOne(this.pb.authStore.record.id);
58354
+ if (instance) {
58355
+ const userPassword = decryptObject(instance.settings.password, instance.settings.salt);
58356
+ return userPassword === password;
58357
+ }
58358
+ }
58359
+ return false;
58360
+ }
58361
+ async setAdminPassword(payload) {
58362
+ const { password, salt } = payload;
58363
+ if (!this.email) {
58364
+ const encrypted = encryptObject(password, salt);
58365
+ await this.pb.collection("_superusers").update(this.pb.authStore.record.id, {
58366
+ settings: {
58367
+ password: encrypted,
58368
+ salt
58369
+ }
58370
+ });
58371
+ return true;
58372
+ }
58373
+ return false;
58374
+ }
58343
58375
  async addNewCredential(params) {
58344
58376
  const { password, payload } = params;
58345
58377
  let credentials = await this.getCredentials({ password });
@@ -58236,6 +58236,14 @@ class AppDatabase {
58236
58236
  });
58237
58237
  return user[0];
58238
58238
  }
58239
+ async verifyUserPassword(password) {
58240
+ const user = await this.getUserByEmail();
58241
+ if (user) {
58242
+ const userPassword = decryptObject(user.settings.password, this.salt);
58243
+ return userPassword === password;
58244
+ }
58245
+ return false;
58246
+ }
58239
58247
  async generateUserPassword() {
58240
58248
  const user = await this.getUserByEmail();
58241
58249
  if (user) {
@@ -58317,6 +58325,30 @@ class AppDatabase {
58317
58325
  }
58318
58326
  return false;
58319
58327
  }
58328
+ async verifyAdminPassword(password) {
58329
+ if (!this.email) {
58330
+ const instance = await this.pb.collection("_superusers").getOne(this.pb.authStore.record.id);
58331
+ if (instance) {
58332
+ const userPassword = decryptObject(instance.settings.password, instance.settings.salt);
58333
+ return userPassword === password;
58334
+ }
58335
+ }
58336
+ return false;
58337
+ }
58338
+ async setAdminPassword(payload) {
58339
+ const { password, salt } = payload;
58340
+ if (!this.email) {
58341
+ const encrypted = encryptObject(password, salt);
58342
+ await this.pb.collection("_superusers").update(this.pb.authStore.record.id, {
58343
+ settings: {
58344
+ password: encrypted,
58345
+ salt
58346
+ }
58347
+ });
58348
+ return true;
58349
+ }
58350
+ return false;
58351
+ }
58320
58352
  async addNewCredential(params) {
58321
58353
  const { password, payload } = params;
58322
58354
  let credentials = await this.getCredentials({ password });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gbozee/ultimate",
3
3
  "type": "module",
4
- "version": "0.0.2-135",
4
+ "version": "0.0.2-137",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",