@ztimson/momentum 1.5.2 → 1.5.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.
- package/dist/auth.d.ts +12 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.mjs +11 -7
- package/package.json +1 -1
package/dist/auth.d.ts
CHANGED
|
@@ -28,7 +28,16 @@ export declare class Auth extends PathEventEmitter {
|
|
|
28
28
|
/** Update user info without changing the session */
|
|
29
29
|
set user(user: User | null | undefined);
|
|
30
30
|
constructor(momentum: Momentum);
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Handle login flow automatically:
|
|
33
|
+
* 1. Check for URL token and use if provided
|
|
34
|
+
* 2. Check server for session (retrieve cookie)
|
|
35
|
+
* 3. Open SSO login
|
|
36
|
+
* 4. Handle redirects/events
|
|
37
|
+
* @param {boolean | string} reload - Perform redirect (string) or reload (true) on success
|
|
38
|
+
*/
|
|
39
|
+
handleLogin(redirect: string): Promise<SessionData | null>;
|
|
40
|
+
handleLogin(reload?: boolean): Promise<SessionData | null>;
|
|
32
41
|
/**
|
|
33
42
|
* Check if origin is recognized & whitelisted
|
|
34
43
|
* @param {string} host Origin to check
|
|
@@ -58,7 +67,9 @@ export declare class Auth extends PathEventEmitter {
|
|
|
58
67
|
loginRedirect(host?: string): Promise<string>;
|
|
59
68
|
/**
|
|
60
69
|
* Logout current user
|
|
70
|
+
* @param {boolean | string} reload - Perform redirect (string) or reload (true) on logout
|
|
61
71
|
*/
|
|
72
|
+
logout(redirect: string): Promise<void>;
|
|
62
73
|
logout(reload?: boolean): Promise<void>;
|
|
63
74
|
/**
|
|
64
75
|
* Create a new user with login
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAM,MAAM,QAAQ,CAA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
|
|
2875
2875
|
s = await this.loginRedirect();
|
|
2876
|
-
if (!!s && reload)
|
|
2876
|
+
if (!!s && reload) {
|
|
2877
|
+
if (typeof reload == "string") location.href = reload;
|
|
2878
|
+
location.reload();
|
|
2879
|
+
}
|
|
2877
2880
|
}
|
|
2878
|
-
return this.session;
|
|
2881
|
+
return this.session || null;
|
|
2879
2882
|
}
|
|
2880
2883
|
/**
|
|
2881
2884
|
* Check if origin is recognized & whitelisted
|
|
@@ -2940,15 +2943,16 @@
|
|
|
2940
2943
|
}
|
|
2941
2944
|
});
|
|
2942
2945
|
}
|
|
2943
|
-
/**
|
|
2944
|
-
* Logout current user
|
|
2945
|
-
*/
|
|
2946
2946
|
async logout(reload = this.momentum.opts?.expiredStrategy == "reload") {
|
|
2947
2947
|
await this.momentum.api.request({
|
|
2948
2948
|
url: "api/auth/logout",
|
|
2949
2949
|
method: "DELETE"
|
|
2950
2950
|
});
|
|
2951
|
-
if (reload)
|
|
2951
|
+
if (reload) {
|
|
2952
|
+
if (typeof reload == "string") location.href = reload;
|
|
2953
|
+
location.reload();
|
|
2954
|
+
return;
|
|
2955
|
+
}
|
|
2952
2956
|
this.momentum.api.token = this.session = this.user = null;
|
|
2953
2957
|
await this.readSession();
|
|
2954
2958
|
}
|
|
@@ -4889,7 +4893,7 @@ ${Object.entries(t).map(([name, value]) => `--theme-${kebabCase(name)}: ${value}
|
|
|
4889
4893
|
};
|
|
4890
4894
|
//#endregion
|
|
4891
4895
|
//#region package.json
|
|
4892
|
-
var version = "1.5.
|
|
4896
|
+
var version = "1.5.3";
|
|
4893
4897
|
//#endregion
|
|
4894
4898
|
//#region src/webRtc.ts
|
|
4895
4899
|
var WebRtc = class extends PathEventEmitter {
|
package/dist/index.mjs
CHANGED
|
@@ -2869,9 +2869,12 @@ var Auth = class extends PathEventEmitter {
|
|
|
2869
2869
|
}
|
|
2870
2870
|
if (!s?.user) {
|
|
2871
2871
|
s = await this.loginRedirect();
|
|
2872
|
-
if (!!s && reload)
|
|
2872
|
+
if (!!s && reload) {
|
|
2873
|
+
if (typeof reload == "string") location.href = reload;
|
|
2874
|
+
location.reload();
|
|
2875
|
+
}
|
|
2873
2876
|
}
|
|
2874
|
-
return this.session;
|
|
2877
|
+
return this.session || null;
|
|
2875
2878
|
}
|
|
2876
2879
|
/**
|
|
2877
2880
|
* Check if origin is recognized & whitelisted
|
|
@@ -2936,15 +2939,16 @@ var Auth = class extends PathEventEmitter {
|
|
|
2936
2939
|
}
|
|
2937
2940
|
});
|
|
2938
2941
|
}
|
|
2939
|
-
/**
|
|
2940
|
-
* Logout current user
|
|
2941
|
-
*/
|
|
2942
2942
|
async logout(reload = this.momentum.opts?.expiredStrategy == "reload") {
|
|
2943
2943
|
await this.momentum.api.request({
|
|
2944
2944
|
url: "api/auth/logout",
|
|
2945
2945
|
method: "DELETE"
|
|
2946
2946
|
});
|
|
2947
|
-
if (reload)
|
|
2947
|
+
if (reload) {
|
|
2948
|
+
if (typeof reload == "string") location.href = reload;
|
|
2949
|
+
location.reload();
|
|
2950
|
+
return;
|
|
2951
|
+
}
|
|
2948
2952
|
this.momentum.api.token = this.session = this.user = null;
|
|
2949
2953
|
await this.readSession();
|
|
2950
2954
|
}
|
|
@@ -4885,7 +4889,7 @@ var Static = class extends Storage {
|
|
|
4885
4889
|
};
|
|
4886
4890
|
//#endregion
|
|
4887
4891
|
//#region package.json
|
|
4888
|
-
var version = "1.5.
|
|
4892
|
+
var version = "1.5.3";
|
|
4889
4893
|
//#endregion
|
|
4890
4894
|
//#region src/webRtc.ts
|
|
4891
4895
|
var WebRtc = class extends PathEventEmitter {
|