supaapps-auth 1.0.5 → 1.0.6

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.
@@ -8,7 +8,7 @@ export declare class AuthManager {
8
8
  static getInstance<T>(): AuthManager;
9
9
  private toBase64Url;
10
10
  private generatePKCEPair;
11
- mustBeLoggedIn(): Promise<void>;
11
+ mustBeLoggedIn(): Promise<boolean>;
12
12
  getLoginWithGoogleUri(): string;
13
13
  isLoggedIn(): Promise<boolean>;
14
14
  getAccessToken(): Promise<string>;
@@ -49,9 +49,15 @@ class AuthManager {
49
49
  }
50
50
  mustBeLoggedIn() {
51
51
  return __awaiter(this, void 0, void 0, function* () {
52
- if (!(yield this.isLoggedIn())) {
53
- this.loginCallback();
54
- }
52
+ return new Promise((resolve, reject) => {
53
+ this.isLoggedIn().then((isLoggedIn) => {
54
+ if (!isLoggedIn) {
55
+ this.loginCallback();
56
+ return resolve(false);
57
+ }
58
+ return resolve(true);
59
+ });
60
+ });
55
61
  });
56
62
  }
57
63
  getLoginWithGoogleUri() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supaapps-auth",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -50,11 +50,18 @@ export class AuthManager {
50
50
  return { newCodeVerifier, newCodeChallenge };
51
51
  };
52
52
 
53
- public async mustBeLoggedIn(): Promise<void> {
54
- if (!await this.isLoggedIn()) {
55
- this.loginCallback();
56
- }
53
+ public async mustBeLoggedIn(): Promise<boolean> {
54
+ return new Promise((resolve, reject) => {
55
+ this.isLoggedIn().then((isLoggedIn) => {
56
+ if (!isLoggedIn) {
57
+ this.loginCallback();
58
+ return resolve(false);
59
+ }
60
+ return resolve(true);
61
+ });
62
+ });
57
63
  }
64
+
58
65
  public getLoginWithGoogleUri(): string {
59
66
  // get or create codeVerifier and codeChallenge from localstorage
60
67
  const { newCodeVerifier, newCodeChallenge } = this.generatePKCEPair();