zavadil-ts-common 1.2.44 → 1.2.46
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.d.ts +4 -2
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/oauth/OAuthTokenManager.d.ts +1 -1
- package/dist/oauth/RestClientWithOAuth.d.ts +1 -0
- package/dist/oauth/tokenprovider/IdTokenProviderDefault.d.ts +1 -0
- package/dist/oauth/tokenprovider/IdTokenProviderLogin.d.ts +1 -3
- package/dist/oauth/tokenprovider/IdTokenProviderStorage.d.ts +1 -0
- package/dist/oauth/tokenprovider/IdTokenProviderUrl.d.ts +3 -1
- package/dist/oauth/tokenprovider/OAuthIdTokenProvider.d.ts +1 -0
- package/dist/type/Entity.d.ts +1 -1
- package/package.json +1 -1
- package/src/oauth/OAuthTokenManager.ts +2 -1
- package/src/oauth/RestClientWithOAuth.ts +5 -3
- package/src/oauth/tokenprovider/IdTokenProviderDefault.ts +6 -1
- package/src/oauth/tokenprovider/IdTokenProviderLogin.ts +3 -3
- package/src/oauth/tokenprovider/IdTokenProviderStorage.ts +5 -1
- package/src/oauth/tokenprovider/IdTokenProviderUrl.ts +9 -1
- package/src/oauth/tokenprovider/OAuthIdTokenProvider.ts +1 -0
- package/src/type/Entity.ts +1 -1
@@ -6,9 +6,7 @@ export declare class IdTokenProviderLogin extends RedirectionProvider implements
|
|
6
6
|
client: RestClientWithOAuth;
|
7
7
|
tokenQueryName: string;
|
8
8
|
constructor(client: RestClientWithOAuth, tokenQueryName?: string);
|
9
|
-
/**
|
10
|
-
* Attempt to get ID token from URL or storage, redirect to login page when not successful
|
11
|
-
*/
|
12
9
|
redirectToLogin(): Promise<any>;
|
13
10
|
getIdToken(): Promise<IdTokenPayload>;
|
11
|
+
reset(): Promise<any>;
|
14
12
|
}
|
@@ -6,4 +6,5 @@ export declare class IdTokenProviderStorage implements OAuthIdTokenProvider {
|
|
6
6
|
saveIdTokenToLocalStorage(token: IdTokenPayload | null): void;
|
7
7
|
getIdTokenFromLocalStorage(): IdTokenPayload | null | undefined;
|
8
8
|
getIdToken(): Promise<IdTokenPayload>;
|
9
|
+
reset(): Promise<any>;
|
9
10
|
}
|
@@ -1,10 +1,12 @@
|
|
1
1
|
import { OAuthIdTokenProvider } from "./OAuthIdTokenProvider";
|
2
2
|
import { IdTokenPayload } from "../OAuthRestClient";
|
3
3
|
import { RestClientWithOAuth } from "../RestClientWithOAuth";
|
4
|
-
|
4
|
+
import { RedirectionProvider } from "./RedirectionProvider";
|
5
|
+
export declare class IdTokenProviderUrl extends RedirectionProvider implements OAuthIdTokenProvider {
|
5
6
|
client: RestClientWithOAuth;
|
6
7
|
tokenQueryName: string;
|
7
8
|
constructor(client: RestClientWithOAuth, tokenQueryName?: string);
|
8
9
|
getIdTokenFromUrl(): string | null;
|
9
10
|
getIdToken(): Promise<IdTokenPayload>;
|
11
|
+
reset(): Promise<any>;
|
10
12
|
}
|
package/dist/type/Entity.d.ts
CHANGED
package/package.json
CHANGED
@@ -32,9 +32,10 @@ export class OAuthTokenManager implements OAuthIdTokenProvider {
|
|
32
32
|
return OAuthUtil.isValidToken(this.accessTokens.get(privilege));
|
33
33
|
}
|
34
34
|
|
35
|
-
reset() {
|
35
|
+
reset(): Promise<any> {
|
36
36
|
this.idToken = undefined;
|
37
37
|
this.accessTokens.clear();
|
38
|
+
return this.freshIdTokenProvider.reset();
|
38
39
|
}
|
39
40
|
|
40
41
|
/**
|
@@ -49,9 +49,11 @@ export class RestClientWithOAuth extends RestClient implements OAuthIdTokenProvi
|
|
49
49
|
}
|
50
50
|
|
51
51
|
logout(): Promise<any> {
|
52
|
-
return this.
|
53
|
-
|
54
|
-
|
52
|
+
return this.reset().then(() => this.initialize());
|
53
|
+
}
|
54
|
+
|
55
|
+
reset(): Promise<any> {
|
56
|
+
return this.getTokenManager().then((m) => m.reset());
|
55
57
|
}
|
56
58
|
|
57
59
|
/**
|
@@ -37,10 +37,15 @@ export class IdTokenProviderDefault implements OAuthIdTokenProvider {
|
|
37
37
|
)
|
38
38
|
.then(
|
39
39
|
(t) => {
|
40
|
+
console.log("Token in URL, saving to storage and redirecting");
|
40
41
|
this.storage.saveIdTokenToLocalStorage(t);
|
41
|
-
return
|
42
|
+
return this.url.reset();
|
42
43
|
}
|
43
44
|
);
|
44
45
|
}
|
45
46
|
|
47
|
+
reset(): Promise<any> {
|
48
|
+
return this.storage.reset().then(() => this.url.reset());
|
49
|
+
}
|
50
|
+
|
46
51
|
}
|
@@ -16,9 +16,6 @@ export class IdTokenProviderLogin extends RedirectionProvider implements OAuthId
|
|
16
16
|
this.tokenQueryName = tokenQueryName || 'token';
|
17
17
|
}
|
18
18
|
|
19
|
-
/**
|
20
|
-
* Attempt to get ID token from URL or storage, redirect to login page when not successful
|
21
|
-
*/
|
22
19
|
redirectToLogin(): Promise<any> {
|
23
20
|
return this.client.getServerInfo().then(
|
24
21
|
(si) => {
|
@@ -36,4 +33,7 @@ export class IdTokenProviderLogin extends RedirectionProvider implements OAuthId
|
|
36
33
|
return this.redirectToLogin();
|
37
34
|
}
|
38
35
|
|
36
|
+
reset(): Promise<any> {
|
37
|
+
return Promise.resolve();
|
38
|
+
}
|
39
39
|
}
|
@@ -8,7 +8,7 @@ export class IdTokenProviderStorage implements OAuthIdTokenProvider {
|
|
8
8
|
key: string;
|
9
9
|
|
10
10
|
constructor(storageKey?: string) {
|
11
|
-
this.key = storageKey || '';
|
11
|
+
this.key = storageKey || 'id-token';
|
12
12
|
}
|
13
13
|
|
14
14
|
saveIdTokenToLocalStorage(token: IdTokenPayload | null) {
|
@@ -30,4 +30,8 @@ export class IdTokenProviderStorage implements OAuthIdTokenProvider {
|
|
30
30
|
return Promise.reject("No valid token found in storage!");
|
31
31
|
}
|
32
32
|
|
33
|
+
reset(): Promise<any> {
|
34
|
+
this.saveIdTokenToLocalStorage(null);
|
35
|
+
return Promise.resolve();
|
36
|
+
}
|
33
37
|
}
|
@@ -3,14 +3,16 @@ import {IdTokenPayload} from "../OAuthRestClient";
|
|
3
3
|
import {RestClientWithOAuth} from "../RestClientWithOAuth";
|
4
4
|
import {StringUtil} from "../../util";
|
5
5
|
import UrlUtil from "../../util/UrlUtil";
|
6
|
+
import {RedirectionProvider} from "./RedirectionProvider";
|
6
7
|
|
7
|
-
export class IdTokenProviderUrl implements OAuthIdTokenProvider {
|
8
|
+
export class IdTokenProviderUrl extends RedirectionProvider implements OAuthIdTokenProvider {
|
8
9
|
|
9
10
|
client: RestClientWithOAuth;
|
10
11
|
|
11
12
|
tokenQueryName: string;
|
12
13
|
|
13
14
|
constructor(client: RestClientWithOAuth, tokenQueryName?: string) {
|
15
|
+
super();
|
14
16
|
this.client = client;
|
15
17
|
this.tokenQueryName = tokenQueryName || 'token';
|
16
18
|
}
|
@@ -27,4 +29,10 @@ export class IdTokenProviderUrl implements OAuthIdTokenProvider {
|
|
27
29
|
.then(m => m.verifyIdToken(raw));
|
28
30
|
}
|
29
31
|
|
32
|
+
reset(): Promise<any> {
|
33
|
+
const raw = this.getIdTokenFromUrl();
|
34
|
+
if (raw === null || StringUtil.isBlank(raw)) return Promise.resolve();
|
35
|
+
const thisUrl = UrlUtil.deleteParamFromUrl(document.location.toString(), this.tokenQueryName);
|
36
|
+
return this.redirectTo(thisUrl);
|
37
|
+
}
|
30
38
|
}
|
package/src/type/Entity.ts
CHANGED