@cripty2001/utils 0.0.71 → 0.0.73
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.
|
@@ -17,7 +17,7 @@ export declare class Client {
|
|
|
17
17
|
private url;
|
|
18
18
|
private authToken;
|
|
19
19
|
private setAuthToken;
|
|
20
|
-
|
|
20
|
+
user: Dispatcher<string | null, AppserverData | null>;
|
|
21
21
|
private constructor();
|
|
22
22
|
static create(url: string): Client;
|
|
23
23
|
login(token: string): Promise<boolean>;
|
package/dist/Appserver/client.js
CHANGED
|
@@ -32,15 +32,21 @@ class Client {
|
|
|
32
32
|
url;
|
|
33
33
|
authToken;
|
|
34
34
|
setAuthToken;
|
|
35
|
-
|
|
35
|
+
user;
|
|
36
36
|
constructor(url) {
|
|
37
37
|
this.url = url;
|
|
38
|
-
[
|
|
39
|
-
this.
|
|
38
|
+
const [_authToken, _setAuthToken] = whispr_1.Whispr.create(null);
|
|
39
|
+
this.authToken = _authToken;
|
|
40
|
+
this.setAuthToken = (t) => {
|
|
41
|
+
if (t === this.authToken.value)
|
|
42
|
+
return true;
|
|
43
|
+
return _setAuthToken(t);
|
|
44
|
+
};
|
|
45
|
+
this.user = new Dispatcher_1.Dispatcher(this.authToken, async (token) => {
|
|
40
46
|
if (token === null)
|
|
41
|
-
return
|
|
47
|
+
return null;
|
|
42
48
|
const { user } = await this.unsafeExec('auth/whoami', {});
|
|
43
|
-
return user
|
|
49
|
+
return user;
|
|
44
50
|
}, 0); // Sync execution
|
|
45
51
|
}
|
|
46
52
|
static create(url) {
|
|
@@ -48,7 +54,11 @@ class Client {
|
|
|
48
54
|
}
|
|
49
55
|
async login(token) {
|
|
50
56
|
this.setAuthToken(token);
|
|
51
|
-
return await this.
|
|
57
|
+
return await this.user.data.wait(data => {
|
|
58
|
+
if (data.loading)
|
|
59
|
+
return;
|
|
60
|
+
return data.ok;
|
|
61
|
+
});
|
|
52
62
|
}
|
|
53
63
|
async exec(action, input) {
|
|
54
64
|
return this.unsafeExec(`/exec/${action}`, input);
|
package/package.json
CHANGED