@auth-strategy-manager/rest 1.0.3 → 1.2.0
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/README.md +23 -15
- package/dist/index.d.ts +1 -1
- package/dist/rest-strategy.d.ts +9 -7
- package/dist/rest-strategy.js +56 -24
- package/dist/rest-strategy.js.map +1 -1
- package/dist/types.d.ts +14 -3
- package/package.json +4 -4
- package/dist/core/src/auth-strategy-manager.d.ts +0 -14
- package/dist/core/src/auth-strategy-manager.js +0 -93
- package/dist/core/src/auth-strategy-manager.js.map +0 -1
- package/dist/core/src/constants.d.ts +0 -3
- package/dist/core/src/constants.js +0 -7
- package/dist/core/src/constants.js.map +0 -1
- package/dist/core/src/errors.d.ts +0 -20
- package/dist/core/src/errors.js +0 -41
- package/dist/core/src/errors.js.map +0 -1
- package/dist/core/src/helpers/index.d.ts +0 -1
- package/dist/core/src/helpers/index.js +0 -18
- package/dist/core/src/helpers/index.js.map +0 -1
- package/dist/core/src/helpers/strategy-helper.d.ts +0 -10
- package/dist/core/src/helpers/strategy-helper.js +0 -47
- package/dist/core/src/helpers/strategy-helper.js.map +0 -1
- package/dist/core/src/index.d.ts +0 -5
- package/dist/core/src/index.js +0 -22
- package/dist/core/src/index.js.map +0 -1
- package/dist/core/src/strategies/empty-strategy.d.ts +0 -11
- package/dist/core/src/strategies/empty-strategy.js +0 -37
- package/dist/core/src/strategies/empty-strategy.js.map +0 -1
- package/dist/core/src/strategies/index.d.ts +0 -1
- package/dist/core/src/strategies/index.js +0 -18
- package/dist/core/src/strategies/index.js.map +0 -1
- package/dist/core/src/types.d.ts +0 -23
- package/dist/core/src/types.js +0 -3
- package/dist/core/src/types.js.map +0 -1
- package/dist/rest/src/index.d.ts +0 -2
- package/dist/rest/src/index.js +0 -6
- package/dist/rest/src/index.js.map +0 -1
- package/dist/rest/src/rest-strategy.d.ts +0 -27
- package/dist/rest/src/rest-strategy.js +0 -161
- package/dist/rest/src/rest-strategy.js.map +0 -1
- package/dist/rest/src/types.d.ts +0 -14
- package/dist/rest/src/types.js +0 -3
- package/dist/rest/src/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -29,19 +29,18 @@ const axiosInstance = axios.create({
|
|
|
29
29
|
// Create REST strategy
|
|
30
30
|
const restStrategy = new RestStrategy({
|
|
31
31
|
name: 'my-rest',
|
|
32
|
-
tokenKey: 'access_token',
|
|
33
32
|
signInUrl: 'https://myapp.com/sign-in',
|
|
34
33
|
axiosInstance,
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
accessToken: {
|
|
35
|
+
key: 'access_token',
|
|
36
|
+
storage: 'sessionStorage',
|
|
37
|
+
getToken: (response: unknown) => (response as any).data?.access_token || (response as any).access_token,
|
|
38
|
+
},
|
|
37
39
|
checkAuth: { url: '/auth/check-auth', method: 'GET' },
|
|
38
40
|
signIn: { url: '/auth/sign-in', method: 'POST' },
|
|
39
41
|
signUp: { url: '/auth/sign-up', method: 'POST' },
|
|
40
42
|
signOut: { url: '/auth/sign-out', method: 'POST' },
|
|
41
43
|
refresh: { url: '/auth/refresh', method: 'POST' },
|
|
42
|
-
|
|
43
|
-
// Custom token extraction function
|
|
44
|
-
getToken: (response: unknown) => (response as any).data?.access_token || (response as any).access_token
|
|
45
44
|
});
|
|
46
45
|
|
|
47
46
|
// Use with strategy manager
|
|
@@ -61,7 +60,7 @@ const isAuthenticated = await restStrategy.checkAuth();
|
|
|
61
60
|
// Sign out
|
|
62
61
|
await restStrategy.signOut();
|
|
63
62
|
|
|
64
|
-
//
|
|
63
|
+
// Clear state
|
|
65
64
|
restStrategy.clear();
|
|
66
65
|
```
|
|
67
66
|
|
|
@@ -77,16 +76,25 @@ type RestConfig = {
|
|
|
77
76
|
signOut: UrlConfig;
|
|
78
77
|
refresh: UrlConfig;
|
|
79
78
|
name?: string;
|
|
80
|
-
|
|
79
|
+
accessToken: AccessTokenConfig;
|
|
80
|
+
refreshToken?: RefreshTokenConfig;
|
|
81
81
|
signInUrl?: string;
|
|
82
82
|
axiosInstance?: AxiosInstance;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
type AccessTokenConfig = {
|
|
86
|
+
key: string;
|
|
87
|
+
storage: 'sessionStorage' | 'localStorage';
|
|
83
88
|
getToken?: (response: unknown, url?: string) => string;
|
|
84
89
|
};
|
|
85
90
|
|
|
86
|
-
type
|
|
87
|
-
|
|
88
|
-
|
|
91
|
+
type RefreshTokenConfig = {
|
|
92
|
+
key: string;
|
|
93
|
+
storage: 'sessionStorage' | 'localStorage';
|
|
94
|
+
getToken?: (response: unknown, url?: string) => string;
|
|
89
95
|
};
|
|
96
|
+
|
|
97
|
+
type UrlConfig = { url: string; method?: string };
|
|
90
98
|
```
|
|
91
99
|
|
|
92
100
|
### Parameters
|
|
@@ -97,10 +105,10 @@ type UrlConfig = {
|
|
|
97
105
|
- `signOut` - Endpoint for user sign out
|
|
98
106
|
- `refresh` - Endpoint for token refresh
|
|
99
107
|
- `name` - Strategy name (default: 'rest')
|
|
100
|
-
- `
|
|
108
|
+
- `accessToken` - Access token storage and extraction (required)
|
|
109
|
+
- `refreshToken` - Optional: refresh token storage and extraction (e.g. access in sessionStorage, refresh in localStorage)
|
|
101
110
|
- `signInUrl` - URL for redirect after logout
|
|
102
111
|
- `axiosInstance` - Custom axios instance
|
|
103
|
-
- `getToken` - Custom function for extracting token from response
|
|
104
112
|
|
|
105
113
|
## API
|
|
106
114
|
|
|
@@ -128,9 +136,9 @@ constructor(config: RestConfig)
|
|
|
128
136
|
- `token?: string` - Current token
|
|
129
137
|
- `isAuthenticated: boolean` - Authentication status
|
|
130
138
|
|
|
131
|
-
## Token
|
|
139
|
+
## Token storage
|
|
132
140
|
|
|
133
|
-
|
|
141
|
+
Access token (and optionally refresh token) are stored using the configured `accessToken` and `refreshToken` configs. Each can use `sessionStorage` or `localStorage` independently.
|
|
134
142
|
|
|
135
143
|
## License
|
|
136
144
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { RestStrategy } from './rest-strategy';
|
|
2
|
-
export type { Config as RestConfig, UrlConfig } from './types';
|
|
2
|
+
export type { AccessTokenConfig, Config as RestConfig, RefreshTokenConfig, StorageType, TokenConfig, UrlConfig, } from './types';
|
package/dist/rest-strategy.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
2
|
import { Strategy } from '@auth-strategy-manager/core';
|
|
3
3
|
import { Config, UrlName } from './types';
|
|
4
4
|
export declare class RestStrategy implements Strategy {
|
|
@@ -6,22 +6,24 @@ export declare class RestStrategy implements Strategy {
|
|
|
6
6
|
readonly axiosInstance: AxiosInstance;
|
|
7
7
|
readonly urls: Partial<Record<UrlName, any>>;
|
|
8
8
|
signInUrl?: string;
|
|
9
|
-
private readonly
|
|
10
|
-
private readonly
|
|
9
|
+
private readonly accessToken;
|
|
10
|
+
private readonly refreshTokenConfig?;
|
|
11
11
|
private readonly helper;
|
|
12
12
|
private currentRefresh;
|
|
13
13
|
constructor(config: Config);
|
|
14
|
+
private getStorage;
|
|
14
15
|
get startUrl(): string | undefined;
|
|
15
16
|
set startUrl(url: string);
|
|
16
17
|
get token(): string | undefined;
|
|
17
18
|
set token(token: string);
|
|
18
19
|
get isAuthenticated(): boolean;
|
|
19
|
-
|
|
20
|
-
signIn: <
|
|
21
|
-
signUp: <
|
|
20
|
+
checkAuth: () => Promise<boolean>;
|
|
21
|
+
signIn: <T = unknown, D = undefined>(config?: D | undefined) => Promise<T>;
|
|
22
|
+
signUp: <T = unknown, D = undefined>(config?: D | undefined) => Promise<T>;
|
|
22
23
|
signOut: () => Promise<void>;
|
|
23
24
|
refreshToken: () => Promise<void>;
|
|
25
|
+
clear: () => void;
|
|
24
26
|
private extractToken;
|
|
27
|
+
private extractRefreshToken;
|
|
25
28
|
private setAuthParams;
|
|
26
|
-
private clearAuthData;
|
|
27
29
|
}
|
package/dist/rest-strategy.js
CHANGED
|
@@ -27,25 +27,26 @@ exports.RestStrategy = void 0;
|
|
|
27
27
|
const axios_1 = __importDefault(require("axios"));
|
|
28
28
|
const core_1 = require("@auth-strategy-manager/core");
|
|
29
29
|
const DEFAULT_NAME = 'rest';
|
|
30
|
-
const
|
|
30
|
+
const DEFAULT_ACCESS_KEY = 'access';
|
|
31
|
+
const DEFAULT_ACCESS_STORAGE = 'sessionStorage';
|
|
31
32
|
class RestStrategy {
|
|
32
33
|
constructor(config) {
|
|
33
34
|
var _a;
|
|
34
35
|
this.currentRefresh = null;
|
|
35
|
-
this.
|
|
36
|
+
this.checkAuth = () => __awaiter(this, void 0, void 0, function* () {
|
|
36
37
|
if (!this.token) {
|
|
37
38
|
return false;
|
|
38
39
|
}
|
|
39
|
-
if (!this.urls.
|
|
40
|
+
if (!this.urls.checkAuth) {
|
|
40
41
|
throw new Error('Check URL is not defined');
|
|
41
42
|
}
|
|
42
|
-
const { url, method } = this.urls.
|
|
43
|
+
const { url, method } = this.urls.checkAuth;
|
|
43
44
|
const response = yield this.axiosInstance(url, { method });
|
|
44
45
|
const token = this.extractToken(response, url);
|
|
45
46
|
const isAuthenticated = Boolean(token);
|
|
46
47
|
if (isAuthenticated) {
|
|
47
48
|
this.helper.activeStrategyName = this.name;
|
|
48
|
-
this.setAuthParams(token);
|
|
49
|
+
this.setAuthParams(token, this.extractRefreshToken(response, url));
|
|
49
50
|
}
|
|
50
51
|
return isAuthenticated;
|
|
51
52
|
});
|
|
@@ -54,10 +55,14 @@ class RestStrategy {
|
|
|
54
55
|
throw new Error('Sign in URL is not defined');
|
|
55
56
|
}
|
|
56
57
|
const { url, method } = this.urls.signIn;
|
|
57
|
-
|
|
58
|
+
let axiosConfig = {};
|
|
59
|
+
if (config && typeof config === 'object') {
|
|
60
|
+
axiosConfig = config;
|
|
61
|
+
}
|
|
62
|
+
const response = yield this.axiosInstance(url, Object.assign(Object.assign({}, axiosConfig), { method }));
|
|
58
63
|
const token = this.extractToken(response, url);
|
|
59
64
|
if (token) {
|
|
60
|
-
this.setAuthParams(token);
|
|
65
|
+
this.setAuthParams(token, this.extractRefreshToken(response, url));
|
|
61
66
|
}
|
|
62
67
|
return response;
|
|
63
68
|
});
|
|
@@ -66,10 +71,14 @@ class RestStrategy {
|
|
|
66
71
|
throw new Error('Sign up URL is not defined');
|
|
67
72
|
}
|
|
68
73
|
const { url, method } = this.urls.signUp;
|
|
69
|
-
|
|
74
|
+
let axiosConfig = {};
|
|
75
|
+
if (config && typeof config === 'object') {
|
|
76
|
+
axiosConfig = config;
|
|
77
|
+
}
|
|
78
|
+
const response = yield this.axiosInstance(url, Object.assign(Object.assign({}, axiosConfig), { method }));
|
|
70
79
|
const token = this.extractToken(response, url);
|
|
71
80
|
if (token) {
|
|
72
|
-
this.setAuthParams(token);
|
|
81
|
+
this.setAuthParams(token, this.extractRefreshToken(response, url));
|
|
73
82
|
}
|
|
74
83
|
return response;
|
|
75
84
|
});
|
|
@@ -79,11 +88,11 @@ class RestStrategy {
|
|
|
79
88
|
}
|
|
80
89
|
const { url, method } = this.urls.signOut;
|
|
81
90
|
if (!url) {
|
|
82
|
-
this.
|
|
91
|
+
this.clear();
|
|
83
92
|
return;
|
|
84
93
|
}
|
|
85
94
|
yield this.axiosInstance(url, { method });
|
|
86
|
-
this.
|
|
95
|
+
this.clear();
|
|
87
96
|
});
|
|
88
97
|
this.refreshToken = () => __awaiter(this, void 0, void 0, function* () {
|
|
89
98
|
if (!this.urls.refresh) {
|
|
@@ -103,35 +112,58 @@ class RestStrategy {
|
|
|
103
112
|
const response = yield this.axiosInstance(url, { method });
|
|
104
113
|
const token = this.extractToken(response, url);
|
|
105
114
|
if (token) {
|
|
106
|
-
this.setAuthParams(token);
|
|
115
|
+
this.setAuthParams(token, this.extractRefreshToken(response, url));
|
|
107
116
|
}
|
|
108
117
|
resolver();
|
|
109
118
|
this.currentRefresh = null;
|
|
110
119
|
});
|
|
120
|
+
this.clear = () => {
|
|
121
|
+
this.getStorage(this.accessToken.storage).removeItem(this.accessToken.key);
|
|
122
|
+
if (this.refreshTokenConfig) {
|
|
123
|
+
this.getStorage(this.refreshTokenConfig.storage).removeItem(this.refreshTokenConfig.key);
|
|
124
|
+
}
|
|
125
|
+
this.helper.reset();
|
|
126
|
+
};
|
|
111
127
|
this.extractToken = (response, url) => {
|
|
112
128
|
if (typeof response === 'string') {
|
|
113
129
|
return response;
|
|
114
130
|
}
|
|
115
|
-
|
|
131
|
+
const getter = this.accessToken.getToken;
|
|
132
|
+
return getter ? getter(response, url) : '';
|
|
133
|
+
};
|
|
134
|
+
this.extractRefreshToken = (response, url) => {
|
|
135
|
+
var _a;
|
|
136
|
+
const getter = (_a = this.refreshTokenConfig) === null || _a === void 0 ? void 0 : _a.getToken;
|
|
137
|
+
if (!getter)
|
|
138
|
+
return undefined;
|
|
139
|
+
const value = getter(response, url);
|
|
140
|
+
return value || undefined;
|
|
116
141
|
};
|
|
117
|
-
this.setAuthParams = (token) => {
|
|
118
|
-
|
|
142
|
+
this.setAuthParams = (token, refreshTokenValue) => {
|
|
143
|
+
const accessStorage = this.getStorage(this.accessToken.storage);
|
|
144
|
+
accessStorage.setItem(this.accessToken.key, token);
|
|
145
|
+
if (this.refreshTokenConfig && refreshTokenValue) {
|
|
146
|
+
const refreshStorage = this.getStorage(this.refreshTokenConfig.storage);
|
|
147
|
+
refreshStorage.setItem(this.refreshTokenConfig.key, refreshTokenValue);
|
|
148
|
+
}
|
|
119
149
|
this.helper.activeStrategyName = this.name;
|
|
120
150
|
this.helper.isAuthenticated = true;
|
|
121
151
|
};
|
|
122
|
-
|
|
123
|
-
window.sessionStorage.clear();
|
|
124
|
-
this.helper.reset();
|
|
125
|
-
};
|
|
126
|
-
const { name, tokenKey, getToken, signInUrl: loginUrl } = config, urls = __rest(config, ["name", "tokenKey", "getToken", "signInUrl"]);
|
|
152
|
+
const { name, accessToken, refreshToken, signInUrl: loginUrl } = config, urls = __rest(config, ["name", "accessToken", "refreshToken", "signInUrl"]);
|
|
127
153
|
this.helper = new core_1.StrategyHelper();
|
|
128
154
|
this.name = name || DEFAULT_NAME;
|
|
129
|
-
this.
|
|
130
|
-
|
|
155
|
+
this.accessToken = accessToken !== null && accessToken !== void 0 ? accessToken : {
|
|
156
|
+
key: DEFAULT_ACCESS_KEY,
|
|
157
|
+
storage: DEFAULT_ACCESS_STORAGE,
|
|
158
|
+
};
|
|
159
|
+
this.refreshTokenConfig = refreshToken;
|
|
131
160
|
this.signInUrl = loginUrl;
|
|
132
161
|
this.urls = urls;
|
|
133
162
|
this.axiosInstance = (_a = config.axiosInstance) !== null && _a !== void 0 ? _a : axios_1.default.create();
|
|
134
163
|
}
|
|
164
|
+
getStorage(type) {
|
|
165
|
+
return window[type];
|
|
166
|
+
}
|
|
135
167
|
get startUrl() {
|
|
136
168
|
return this.helper.startUrl;
|
|
137
169
|
}
|
|
@@ -140,10 +172,10 @@ class RestStrategy {
|
|
|
140
172
|
}
|
|
141
173
|
get token() {
|
|
142
174
|
var _a;
|
|
143
|
-
return (_a =
|
|
175
|
+
return (_a = this.getStorage(this.accessToken.storage).getItem(this.accessToken.key)) !== null && _a !== void 0 ? _a : undefined;
|
|
144
176
|
}
|
|
145
177
|
set token(token) {
|
|
146
|
-
|
|
178
|
+
this.getStorage(this.accessToken.storage).setItem(this.accessToken.key, token);
|
|
147
179
|
}
|
|
148
180
|
get isAuthenticated() {
|
|
149
181
|
return this.helper.isAuthenticated;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-strategy.js","sourceRoot":"","sources":["../src/rest-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAiE;AACjE,sDAAuE;AAGvE,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,MAAM,
|
|
1
|
+
{"version":3,"file":"rest-strategy.js","sourceRoot":"","sources":["../src/rest-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAiE;AACjE,s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CAAC,IAAI,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,IAAI,QAAQ,CAAC,GAAW;QACtB,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC;IAC7B,CAAC;IAED,IAAI,KAAK;;QACP,OAAO,MAAA,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,mCAAI,SAAS,CAAC;IAC9F,CAAC;IAED,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACjF,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;IACrC,CAAC;CA0IF;AA3LD,oCA2LC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,12 +3,23 @@ export type UrlConfig = {
|
|
|
3
3
|
url: string;
|
|
4
4
|
method?: AxiosRequestConfig['method'];
|
|
5
5
|
};
|
|
6
|
-
export type UrlName = '
|
|
6
|
+
export type UrlName = 'checkAuth' | 'signIn' | 'signUp' | 'signOut' | 'refresh';
|
|
7
|
+
export type StorageType = 'sessionStorage' | 'localStorage';
|
|
8
|
+
export type TokenConfig = {
|
|
9
|
+
key: string;
|
|
10
|
+
storage: StorageType;
|
|
11
|
+
/** Extract access / refresh token from API response */
|
|
12
|
+
getToken?: (response: unknown, url?: string) => string;
|
|
13
|
+
};
|
|
14
|
+
export type AccessTokenConfig = TokenConfig;
|
|
15
|
+
export type RefreshTokenConfig = TokenConfig;
|
|
7
16
|
export type Config = Record<UrlName, UrlConfig> & {
|
|
8
17
|
name?: string;
|
|
9
|
-
|
|
18
|
+
/** Where and how to store the access token. Default: { key: 'access', storage: 'sessionStorage' } */
|
|
19
|
+
accessToken?: AccessTokenConfig;
|
|
20
|
+
/** Optional: where and how to store the refresh token (e.g. access in sessionStorage, refresh in localStorage) */
|
|
21
|
+
refreshToken?: RefreshTokenConfig;
|
|
10
22
|
/** URL for redirecting to the authorization page */
|
|
11
23
|
signInUrl?: string;
|
|
12
24
|
axiosInstance?: any;
|
|
13
|
-
getToken?: (response: unknown, url?: string) => string;
|
|
14
25
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auth-strategy-manager/rest",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "REST API strategy for auth-strategy-manager",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
"README.md"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@auth-strategy-manager/core": "^1.0.
|
|
18
|
-
"axios": "
|
|
17
|
+
"@auth-strategy-manager/core": "^1.0.6",
|
|
18
|
+
"axios": "1.11.0"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"axios": "
|
|
21
|
+
"axios": "1.11.0"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|
|
24
24
|
"authentication",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AuthStrategyManagerInterface, Strategy } from './types';
|
|
2
|
-
export declare class AuthStrategyManager implements AuthStrategyManagerInterface {
|
|
3
|
-
strategiesCount: number;
|
|
4
|
-
private strategies;
|
|
5
|
-
private readonly helper;
|
|
6
|
-
constructor(strategies?: Strategy[]);
|
|
7
|
-
get strategy(): Strategy;
|
|
8
|
-
get startUrl(): string | undefined;
|
|
9
|
-
set startUrl(url: string);
|
|
10
|
-
checkAuth: () => Promise<boolean>;
|
|
11
|
-
setStrategies: (strategies: Strategy[]) => Promise<void>;
|
|
12
|
-
use: (strategyName: string) => void;
|
|
13
|
-
clear: () => void;
|
|
14
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.AuthStrategyManager = void 0;
|
|
13
|
-
const errors_1 = require("./errors");
|
|
14
|
-
const constants_1 = require("./constants");
|
|
15
|
-
const helpers_1 = require("./helpers");
|
|
16
|
-
const strategies_1 = require("./strategies");
|
|
17
|
-
const emptyStrategy = new strategies_1.EmptyStrategy();
|
|
18
|
-
const protocol = window.location.protocol;
|
|
19
|
-
const [baseUrl] = window.location.href.replace(`${protocol}//`, '').split('/');
|
|
20
|
-
const startUrl = `${protocol}//${baseUrl}`;
|
|
21
|
-
class AuthStrategyManager {
|
|
22
|
-
constructor(strategies) {
|
|
23
|
-
var _a, _b;
|
|
24
|
-
this.checkAuth = () => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
var _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
26
|
-
const strategyNames = Object.keys(this.strategies);
|
|
27
|
-
const strategyName = strategyNames[0];
|
|
28
|
-
if (strategyNames.length === 1) {
|
|
29
|
-
return yield this.strategies[strategyName].checkAuth();
|
|
30
|
-
}
|
|
31
|
-
const actives = yield Promise.allSettled(strategyNames.map((strategyName) => this.strategies[strategyName].checkAuth()));
|
|
32
|
-
let isAuthenticated = false;
|
|
33
|
-
for (let index = 0; index < actives.length; index++) {
|
|
34
|
-
const active = actives[index];
|
|
35
|
-
if (active.status === 'fulfilled' && active.value === true) {
|
|
36
|
-
this.helper.activeStrategyName = strategyNames[index];
|
|
37
|
-
isAuthenticated = true;
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
if (active.status === 'rejected' &&
|
|
41
|
-
((_d = (_c = active.reason) === null || _c === void 0 ? void 0 : _c.code) !== null && _d !== void 0 ? _d : (_e = active === null || active === void 0 ? void 0 : active.reason) === null || _e === void 0 ? void 0 : _e.message) === constants_1.NETWORK_ERROR_CODE) {
|
|
42
|
-
throw new errors_1.NetworkError((_f = active === null || active === void 0 ? void 0 : active.reason) === null || _f === void 0 ? void 0 : _f.message);
|
|
43
|
-
}
|
|
44
|
-
if (active.status === 'rejected' &&
|
|
45
|
-
((_h = (_g = active.reason) === null || _g === void 0 ? void 0 : _g.code) !== null && _h !== void 0 ? _h : (_j = active === null || active === void 0 ? void 0 : active.reason) === null || _j === void 0 ? void 0 : _j.message) === constants_1.TIMEOUT_3RD_PARTY_ERROR_CODE) {
|
|
46
|
-
throw new errors_1.Timeout3rdPartyError((_k = active === null || active === void 0 ? void 0 : active.reason) === null || _k === void 0 ? void 0 : _k.message);
|
|
47
|
-
}
|
|
48
|
-
if (active.status === 'rejected' && ((_l = active.reason) === null || _l === void 0 ? void 0 : _l.code) === constants_1.CERT_ERROR_CODE) {
|
|
49
|
-
throw new errors_1.CertError();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return isAuthenticated;
|
|
53
|
-
});
|
|
54
|
-
this.setStrategies = (strategies) => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
this.strategiesCount = strategies.length;
|
|
56
|
-
this.strategies = strategies.reduce((acc, strategy) => {
|
|
57
|
-
acc[strategy.name] = strategy;
|
|
58
|
-
return acc;
|
|
59
|
-
}, {});
|
|
60
|
-
});
|
|
61
|
-
this.use = (strategyName) => {
|
|
62
|
-
this.helper.activeStrategyName = strategyName;
|
|
63
|
-
};
|
|
64
|
-
this.clear = () => {
|
|
65
|
-
var _a, _b;
|
|
66
|
-
(_b = (_a = this.strategy).clear) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
67
|
-
this.helper.activeStrategyName = emptyStrategy.name;
|
|
68
|
-
this.startUrl = startUrl;
|
|
69
|
-
};
|
|
70
|
-
this.helper = helpers_1.strategyHelper;
|
|
71
|
-
this.strategiesCount = (_a = strategies === null || strategies === void 0 ? void 0 : strategies.length) !== null && _a !== void 0 ? _a : 0;
|
|
72
|
-
this.strategies =
|
|
73
|
-
(_b = strategies === null || strategies === void 0 ? void 0 : strategies.reduce((acc, strategy) => {
|
|
74
|
-
acc[strategy.name] = strategy;
|
|
75
|
-
return acc;
|
|
76
|
-
}, {})) !== null && _b !== void 0 ? _b : {};
|
|
77
|
-
}
|
|
78
|
-
get strategy() {
|
|
79
|
-
var _a;
|
|
80
|
-
if (!this.helper.activeStrategyName || !this.strategies) {
|
|
81
|
-
return emptyStrategy;
|
|
82
|
-
}
|
|
83
|
-
return (_a = this.strategies[this.helper.activeStrategyName]) !== null && _a !== void 0 ? _a : emptyStrategy;
|
|
84
|
-
}
|
|
85
|
-
get startUrl() {
|
|
86
|
-
return this.helper.startUrl;
|
|
87
|
-
}
|
|
88
|
-
set startUrl(url) {
|
|
89
|
-
this.helper.startUrl = url;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
exports.AuthStrategyManager = AuthStrategyManager;
|
|
93
|
-
//# sourceMappingURL=auth-strategy-manager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-strategy-manager.js","sourceRoot":"","sources":["../../../../core/src/auth-strategy-manager.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAyE;AACzE,2CAAgG;AAChG,uCAA2D;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
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TIMEOUT_3RD_PARTY_ERROR_CODE = exports.NETWORK_ERROR_CODE = exports.CERT_ERROR_CODE = void 0;
|
|
4
|
-
exports.CERT_ERROR_CODE = 'ERR_CERT_AUTHORITY_INVALID';
|
|
5
|
-
exports.NETWORK_ERROR_CODE = 'ERR_NETWORK';
|
|
6
|
-
exports.TIMEOUT_3RD_PARTY_ERROR_CODE = 'Timeout when waiting for 3rd party check iframe message.';
|
|
7
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../core/src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,4BAA4B,CAAC;AAC/C,QAAA,kBAAkB,GAAG,aAAa,CAAC;AACnC,QAAA,4BAA4B,GACvC,0DAA0D,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
type ResponseErrorData = {
|
|
2
|
-
status: number;
|
|
3
|
-
message: string;
|
|
4
|
-
};
|
|
5
|
-
export declare class ResponseError {
|
|
6
|
-
readonly status: number;
|
|
7
|
-
readonly message: string;
|
|
8
|
-
constructor(data: ResponseErrorData);
|
|
9
|
-
toString: () => string;
|
|
10
|
-
}
|
|
11
|
-
export declare class CertError extends ResponseError {
|
|
12
|
-
constructor();
|
|
13
|
-
}
|
|
14
|
-
export declare class NetworkError extends ResponseError {
|
|
15
|
-
constructor(message?: string);
|
|
16
|
-
}
|
|
17
|
-
export declare class Timeout3rdPartyError extends ResponseError {
|
|
18
|
-
constructor(message?: string);
|
|
19
|
-
}
|
|
20
|
-
export {};
|
package/dist/core/src/errors.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Timeout3rdPartyError = exports.NetworkError = exports.CertError = exports.ResponseError = void 0;
|
|
4
|
-
class ResponseError {
|
|
5
|
-
constructor(data) {
|
|
6
|
-
this.toString = () => {
|
|
7
|
-
return `${this.status ? `Status ${this.status}: ` : ''}${this.message}`;
|
|
8
|
-
};
|
|
9
|
-
this.status = data.status;
|
|
10
|
-
this.message = data.message;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.ResponseError = ResponseError;
|
|
14
|
-
class CertError extends ResponseError {
|
|
15
|
-
constructor() {
|
|
16
|
-
super({
|
|
17
|
-
status: 0,
|
|
18
|
-
message: 'ERR_CERT_AUTHORITY_INVALID',
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.CertError = CertError;
|
|
23
|
-
class NetworkError extends ResponseError {
|
|
24
|
-
constructor(message) {
|
|
25
|
-
super({
|
|
26
|
-
status: 0,
|
|
27
|
-
message: message !== null && message !== void 0 ? message : 'NETWORK ERROR',
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.NetworkError = NetworkError;
|
|
32
|
-
class Timeout3rdPartyError extends ResponseError {
|
|
33
|
-
constructor(message) {
|
|
34
|
-
super({
|
|
35
|
-
status: 0,
|
|
36
|
-
message: message !== null && message !== void 0 ? message : 'Timeout when waiting for 3rd party check iframe message.',
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.Timeout3rdPartyError = Timeout3rdPartyError;
|
|
41
|
-
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../core/src/errors.ts"],"names":[],"mappings":";;;AAKA,MAAa,aAAa;IAIxB,YAAY,IAAuB;QAKnC,aAAQ,GAAG,GAAG,EAAE;YACd,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC1E,CAAC,CAAC;QANA,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAC9B,CAAC;CAKF;AAZD,sCAYC;AAED,MAAa,SAAU,SAAQ,aAAa;IAC1C;QACE,KAAK,CAAC;YACJ,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,4BAA4B;SACtC,CAAC,CAAC;IACL,CAAC;CACF;AAPD,8BAOC;AAED,MAAa,YAAa,SAAQ,aAAa;IAC7C,YAAY,OAAgB;QAC1B,KAAK,CAAC;YACJ,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,eAAe;SACpC,CAAC,CAAC;IACL,CAAC;CACF;AAPD,oCAOC;AAED,MAAa,oBAAqB,SAAQ,aAAa;IACrD,YAAY,OAAgB;QAC1B,KAAK,CAAC;YACJ,MAAM,EAAE,CAAC;YACT,OAAO,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,0DAA0D;SAC/E,CAAC,CAAC;IACL,CAAC;CACF;AAPD,oDAOC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './strategy-helper';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./strategy-helper"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../core/src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare class StrategyHelper {
|
|
2
|
-
isAuthenticated: boolean;
|
|
3
|
-
get activeStrategyName(): string;
|
|
4
|
-
set activeStrategyName(name: string);
|
|
5
|
-
get startUrl(): string | undefined;
|
|
6
|
-
set startUrl(url: string | undefined);
|
|
7
|
-
clearStorage: () => void;
|
|
8
|
-
reset: () => void;
|
|
9
|
-
}
|
|
10
|
-
export declare const strategyHelper: StrategyHelper;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.strategyHelper = exports.StrategyHelper = void 0;
|
|
4
|
-
const TYPE_KEY = 'authStrategyName';
|
|
5
|
-
const START_URL_KEY = 'startUrl';
|
|
6
|
-
const protocol = window.location.protocol;
|
|
7
|
-
const [baseUrl] = window.location.href.replace(`${protocol}//`, '').split('/');
|
|
8
|
-
const startUrl = `${protocol}//${baseUrl}`;
|
|
9
|
-
class StrategyHelper {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.isAuthenticated = false;
|
|
12
|
-
this.clearStorage = () => {
|
|
13
|
-
localStorage.removeItem(TYPE_KEY);
|
|
14
|
-
};
|
|
15
|
-
this.reset = () => {
|
|
16
|
-
this.clearStorage();
|
|
17
|
-
this.isAuthenticated = false;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
get activeStrategyName() {
|
|
21
|
-
var _a;
|
|
22
|
-
return (_a = localStorage.getItem(TYPE_KEY)) !== null && _a !== void 0 ? _a : '';
|
|
23
|
-
}
|
|
24
|
-
set activeStrategyName(name) {
|
|
25
|
-
if (!name) {
|
|
26
|
-
localStorage.removeItem(TYPE_KEY);
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
localStorage.setItem(TYPE_KEY, name);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
get startUrl() {
|
|
33
|
-
var _a;
|
|
34
|
-
return (_a = localStorage.getItem(START_URL_KEY)) !== null && _a !== void 0 ? _a : startUrl;
|
|
35
|
-
}
|
|
36
|
-
set startUrl(url) {
|
|
37
|
-
if (url) {
|
|
38
|
-
localStorage.setItem(START_URL_KEY, url);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
localStorage.removeItem(START_URL_KEY);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.StrategyHelper = StrategyHelper;
|
|
46
|
-
exports.strategyHelper = new StrategyHelper();
|
|
47
|
-
//# sourceMappingURL=strategy-helper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"strategy-helper.js","sourceRoot":"","sources":["../../../../../core/src/helpers/strategy-helper.ts"],"names":[],"mappings":";;;AAAA,MAAM,QAAQ,GAAG,kBAAkB,CAAC;AACpC,MAAM,aAAa,GAAG,UAAU,CAAC;AAEjC,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;AAC1C,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,QAAQ,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAE/E,MAAM,QAAQ,GAAG,GAAG,QAAQ,KAAK,OAAO,EAAE,CAAC;AAE3C,MAAa,cAAc;IAA3B;QACE,oBAAe,GAAG,KAAK,CAAC;QA0BjB,iBAAY,GAAG,GAAS,EAAE;YAC/B,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACpC,CAAC,CAAC;QAEK,UAAK,GAAG,GAAG,EAAE;YAClB,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,CAAC,eAAe,GAAG,KAAK,CAAC;QAC/B,CAAC,CAAC;IACJ,CAAC;IAhCC,IAAI,kBAAkB;;QACpB,OAAO,MAAA,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,mCAAI,EAAE,CAAC;IAC9C,CAAC;IAED,IAAI,kBAAkB,CAAC,IAAY;QACjC,IAAI,CAAC,IAAI,EAAE;YACT,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;SACnC;aAAM;YACL,YAAY,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;SACtC;IACH,CAAC;IAED,IAAI,QAAQ;;QACV,OAAO,MAAA,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,mCAAI,QAAQ,CAAC;IACzD,CAAC;IAED,IAAI,QAAQ,CAAC,GAAuB;QAClC,IAAI,GAAG,EAAE;YACP,YAAY,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;SAC1C;aAAM;YACL,YAAY,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;SACxC;IACH,CAAC;CAUF;AAnCD,wCAmCC;AAEY,QAAA,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
package/dist/core/src/index.d.ts
DELETED
package/dist/core/src/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./auth-strategy-manager"), exports);
|
|
18
|
-
__exportStar(require("./strategies"), exports);
|
|
19
|
-
__exportStar(require("./types"), exports);
|
|
20
|
-
__exportStar(require("./errors"), exports);
|
|
21
|
-
__exportStar(require("./helpers"), exports);
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../core/src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC;AACxC,+CAA6B;AAC7B,0CAAwB;AACxB,2CAAyB;AACzB,4CAA0B"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { StrategyHelper } from '../helpers';
|
|
2
|
-
import { Strategy } from '../types';
|
|
3
|
-
export declare class EmptyStrategy extends StrategyHelper implements Strategy {
|
|
4
|
-
readonly name = "empty";
|
|
5
|
-
checkAuth: () => Promise<boolean>;
|
|
6
|
-
signIn: <T>() => Promise<T>;
|
|
7
|
-
signUp: <T>() => Promise<T>;
|
|
8
|
-
signOut: () => Promise<void>;
|
|
9
|
-
refreshToken: () => Promise<void>;
|
|
10
|
-
getUserProfile: <T>() => Promise<T>;
|
|
11
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EmptyStrategy = void 0;
|
|
13
|
-
const helpers_1 = require("../helpers");
|
|
14
|
-
class EmptyStrategy extends helpers_1.StrategyHelper {
|
|
15
|
-
constructor() {
|
|
16
|
-
super(...arguments);
|
|
17
|
-
this.name = 'empty';
|
|
18
|
-
this.checkAuth = () => __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
return false;
|
|
20
|
-
});
|
|
21
|
-
this.signIn = () => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
return false;
|
|
23
|
-
});
|
|
24
|
-
this.signUp = () => __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
return false;
|
|
26
|
-
});
|
|
27
|
-
this.signOut = () => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
this.clearStorage();
|
|
29
|
-
});
|
|
30
|
-
this.refreshToken = () => __awaiter(this, void 0, void 0, function* () { });
|
|
31
|
-
this.getUserProfile = () => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
return undefined;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
exports.EmptyStrategy = EmptyStrategy;
|
|
37
|
-
//# sourceMappingURL=empty-strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"empty-strategy.js","sourceRoot":"","sources":["../../../../../core/src/strategies/empty-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAA4C;AAG5C,MAAa,aAAc,SAAQ,wBAAc;IAAjD;;QACW,SAAI,GAAG,OAAO,CAAC;QAExB,cAAS,GAAG,GAA2B,EAAE;YACvC,OAAO,KAAK,CAAC;QACf,CAAC,CAAA,CAAC;QAEF,WAAM,GAAG,GAAwB,EAAE;YACjC,OAAO,KAAU,CAAC;QACpB,CAAC,CAAA,CAAC;QAEF,WAAM,GAAG,GAAwB,EAAE;YACjC,OAAO,KAAU,CAAC;QACpB,CAAC,CAAA,CAAC;QAEF,YAAO,GAAG,GAAwB,EAAE;YAClC,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,CAAC,CAAA,CAAC;QAEF,iBAAY,GAAG,GAAwB,EAAE,gDAAE,CAAC,CAAA,CAAC;QAE7C,mBAAc,GAAG,GAAwB,EAAE;YACzC,OAAO,SAAc,CAAC;QACxB,CAAC,CAAA,CAAC;IACJ,CAAC;CAAA;AAxBD,sCAwBC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './empty-strategy';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./empty-strategy"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../core/src/strategies/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAiC"}
|
package/dist/core/src/types.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export type AuthStrategyManagerStrategies = Record<string, Strategy>;
|
|
2
|
-
export type Strategy = {
|
|
3
|
-
name: string;
|
|
4
|
-
token?: string;
|
|
5
|
-
isAuthenticated?: boolean;
|
|
6
|
-
startUrl?: string;
|
|
7
|
-
signInUrl?: string;
|
|
8
|
-
checkAuth: () => Promise<boolean>;
|
|
9
|
-
signIn: <T = unknown, D = undefined>(config?: D) => Promise<T>;
|
|
10
|
-
signUp: <T = unknown, D = undefined>(config?: D) => Promise<T>;
|
|
11
|
-
signOut: () => Promise<void>;
|
|
12
|
-
refreshToken: <T>(args?: T) => Promise<void>;
|
|
13
|
-
clear?: () => void;
|
|
14
|
-
};
|
|
15
|
-
export type AuthStrategyManagerInterface = {
|
|
16
|
-
strategiesCount: number;
|
|
17
|
-
strategy: Strategy;
|
|
18
|
-
startUrl: string | undefined;
|
|
19
|
-
checkAuth: () => Promise<boolean>;
|
|
20
|
-
setStrategies: (strategies: Strategy[]) => Promise<void>;
|
|
21
|
-
use: (strategyName: string) => void;
|
|
22
|
-
clear: () => void;
|
|
23
|
-
};
|
package/dist/core/src/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../core/src/types.ts"],"names":[],"mappings":""}
|
package/dist/rest/src/index.d.ts
DELETED
package/dist/rest/src/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RestStrategy = void 0;
|
|
4
|
-
var rest_strategy_1 = require("./rest-strategy");
|
|
5
|
-
Object.defineProperty(exports, "RestStrategy", { enumerable: true, get: function () { return rest_strategy_1.RestStrategy; } });
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAAtC,6GAAA,YAAY,OAAA"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { AxiosInstance } from 'axios';
|
|
2
|
-
import { Strategy } from '@auth-strategy-manager/core';
|
|
3
|
-
import { Config, UrlName } from './types';
|
|
4
|
-
export declare class RestStrategy implements Strategy {
|
|
5
|
-
readonly name: string;
|
|
6
|
-
readonly axiosInstance: AxiosInstance;
|
|
7
|
-
readonly urls: Partial<Record<UrlName, any>>;
|
|
8
|
-
signInUrl?: string;
|
|
9
|
-
private readonly tokenKey;
|
|
10
|
-
private readonly getToken?;
|
|
11
|
-
private readonly helper;
|
|
12
|
-
private currentRefresh;
|
|
13
|
-
constructor(config: Config);
|
|
14
|
-
get startUrl(): string | undefined;
|
|
15
|
-
set startUrl(url: string);
|
|
16
|
-
get token(): string | undefined;
|
|
17
|
-
set token(token: string);
|
|
18
|
-
get isAuthenticated(): boolean;
|
|
19
|
-
checkAuth: () => Promise<boolean>;
|
|
20
|
-
signIn: <T = unknown, D = undefined>(config?: D | undefined) => Promise<T>;
|
|
21
|
-
signUp: <T = unknown, D = undefined>(config?: D | undefined) => Promise<T>;
|
|
22
|
-
signOut: () => Promise<void>;
|
|
23
|
-
refreshToken: () => Promise<void>;
|
|
24
|
-
clear: () => void;
|
|
25
|
-
private extractToken;
|
|
26
|
-
private setAuthParams;
|
|
27
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.RestStrategy = void 0;
|
|
27
|
-
const axios_1 = __importDefault(require("axios"));
|
|
28
|
-
const core_1 = require("@auth-strategy-manager/core");
|
|
29
|
-
const DEFAULT_NAME = 'rest';
|
|
30
|
-
const DEFAULT_TOKEN_KEY = 'access';
|
|
31
|
-
class RestStrategy {
|
|
32
|
-
constructor(config) {
|
|
33
|
-
var _a;
|
|
34
|
-
this.currentRefresh = null;
|
|
35
|
-
this.checkAuth = () => __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
if (!this.token) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
if (!this.urls.checkAuth) {
|
|
40
|
-
throw new Error('Check URL is not defined');
|
|
41
|
-
}
|
|
42
|
-
const { url, method } = this.urls.checkAuth;
|
|
43
|
-
const response = yield this.axiosInstance(url, { method });
|
|
44
|
-
const token = this.extractToken(response, url);
|
|
45
|
-
const isAuthenticated = Boolean(token);
|
|
46
|
-
if (isAuthenticated) {
|
|
47
|
-
this.helper.activeStrategyName = this.name;
|
|
48
|
-
this.setAuthParams(token);
|
|
49
|
-
}
|
|
50
|
-
return isAuthenticated;
|
|
51
|
-
});
|
|
52
|
-
this.signIn = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
if (!this.urls.signIn) {
|
|
54
|
-
throw new Error('Sign in URL is not defined');
|
|
55
|
-
}
|
|
56
|
-
const { url, method } = this.urls.signIn;
|
|
57
|
-
let axiosConfig = {};
|
|
58
|
-
if (config && typeof config === 'object') {
|
|
59
|
-
axiosConfig = config;
|
|
60
|
-
}
|
|
61
|
-
const response = yield this.axiosInstance(url, Object.assign(Object.assign({}, axiosConfig), { method }));
|
|
62
|
-
const token = this.extractToken(response, url);
|
|
63
|
-
if (token) {
|
|
64
|
-
this.setAuthParams(token);
|
|
65
|
-
}
|
|
66
|
-
return response;
|
|
67
|
-
});
|
|
68
|
-
this.signUp = (config) => __awaiter(this, void 0, void 0, function* () {
|
|
69
|
-
if (!this.urls.signUp) {
|
|
70
|
-
throw new Error('Sign up URL is not defined');
|
|
71
|
-
}
|
|
72
|
-
const { url, method } = this.urls.signUp;
|
|
73
|
-
let axiosConfig = {};
|
|
74
|
-
if (config && typeof config === 'object') {
|
|
75
|
-
axiosConfig = config;
|
|
76
|
-
}
|
|
77
|
-
const response = yield this.axiosInstance(url, Object.assign(Object.assign({}, axiosConfig), { method }));
|
|
78
|
-
const token = this.extractToken(response, url);
|
|
79
|
-
if (token) {
|
|
80
|
-
this.setAuthParams(token);
|
|
81
|
-
}
|
|
82
|
-
return response;
|
|
83
|
-
});
|
|
84
|
-
this.signOut = () => __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
if (!this.urls.signOut) {
|
|
86
|
-
throw new Error('Sign out URL is not defined');
|
|
87
|
-
}
|
|
88
|
-
const { url, method } = this.urls.signOut;
|
|
89
|
-
if (!url) {
|
|
90
|
-
this.clear();
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
yield this.axiosInstance(url, { method });
|
|
94
|
-
this.clear();
|
|
95
|
-
});
|
|
96
|
-
this.refreshToken = () => __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
if (!this.urls.refresh) {
|
|
98
|
-
throw new Error('Refresh token URL is not defined');
|
|
99
|
-
}
|
|
100
|
-
const { url, method } = this.urls.refresh;
|
|
101
|
-
if (!url) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
if (this.currentRefresh) {
|
|
105
|
-
return yield this.currentRefresh;
|
|
106
|
-
}
|
|
107
|
-
let resolver = () => { };
|
|
108
|
-
this.currentRefresh = new Promise((resolve) => {
|
|
109
|
-
resolver = resolve;
|
|
110
|
-
});
|
|
111
|
-
const response = yield this.axiosInstance(url, { method });
|
|
112
|
-
const token = this.extractToken(response, url);
|
|
113
|
-
if (token) {
|
|
114
|
-
this.setAuthParams(token);
|
|
115
|
-
}
|
|
116
|
-
resolver();
|
|
117
|
-
this.currentRefresh = null;
|
|
118
|
-
});
|
|
119
|
-
this.clear = () => {
|
|
120
|
-
window.sessionStorage.clear();
|
|
121
|
-
this.helper.reset();
|
|
122
|
-
};
|
|
123
|
-
this.extractToken = (response, url) => {
|
|
124
|
-
if (typeof response === 'string') {
|
|
125
|
-
return response;
|
|
126
|
-
}
|
|
127
|
-
return this.getToken ? this.getToken(response, url) : '';
|
|
128
|
-
};
|
|
129
|
-
this.setAuthParams = (token) => {
|
|
130
|
-
window.sessionStorage.setItem(this.tokenKey, token);
|
|
131
|
-
this.helper.activeStrategyName = this.name;
|
|
132
|
-
this.helper.isAuthenticated = true;
|
|
133
|
-
};
|
|
134
|
-
const { name, tokenKey, getToken, signInUrl: loginUrl } = config, urls = __rest(config, ["name", "tokenKey", "getToken", "signInUrl"]);
|
|
135
|
-
this.helper = new core_1.StrategyHelper();
|
|
136
|
-
this.name = name || DEFAULT_NAME;
|
|
137
|
-
this.tokenKey = tokenKey || DEFAULT_TOKEN_KEY;
|
|
138
|
-
this.getToken = getToken;
|
|
139
|
-
this.signInUrl = loginUrl;
|
|
140
|
-
this.urls = urls;
|
|
141
|
-
this.axiosInstance = (_a = config.axiosInstance) !== null && _a !== void 0 ? _a : axios_1.default.create();
|
|
142
|
-
}
|
|
143
|
-
get startUrl() {
|
|
144
|
-
return this.helper.startUrl;
|
|
145
|
-
}
|
|
146
|
-
set startUrl(url) {
|
|
147
|
-
this.helper.startUrl = url;
|
|
148
|
-
}
|
|
149
|
-
get token() {
|
|
150
|
-
var _a;
|
|
151
|
-
return (_a = window.sessionStorage.getItem(this.tokenKey)) !== null && _a !== void 0 ? _a : undefined;
|
|
152
|
-
}
|
|
153
|
-
set token(token) {
|
|
154
|
-
window.sessionStorage.setItem(this.tokenKey, token);
|
|
155
|
-
}
|
|
156
|
-
get isAuthenticated() {
|
|
157
|
-
return this.helper.isAuthenticated;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
exports.RestStrategy = RestStrategy;
|
|
161
|
-
//# sourceMappingURL=rest-strategy.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"rest-strategy.js","sourceRoot":"","sources":["../../../src/rest-strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAAiE;AACjE,sDAAuE;AAGvE,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AAEnC,MAAa,YAAY;IAWvB,YAAY,MAAc;;QAFlB,mBAAc,G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c,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,mCAAI,SAAS,CAAC;IACnE,CAAC;IAED,IAAI,KAAK,CAAC,KAAa;QACrB,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;IACrC,CAAC;CA0HF;AApKD,oCAoKC"}
|
package/dist/rest/src/types.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { AxiosRequestConfig } from 'axios';
|
|
2
|
-
export type UrlConfig = {
|
|
3
|
-
url: string;
|
|
4
|
-
method?: AxiosRequestConfig['method'];
|
|
5
|
-
};
|
|
6
|
-
export type UrlName = 'checkAuth' | 'signIn' | 'signUp' | 'signOut' | 'refresh';
|
|
7
|
-
export type Config = Record<UrlName, UrlConfig> & {
|
|
8
|
-
name?: string;
|
|
9
|
-
tokenKey?: string;
|
|
10
|
-
/** URL for redirecting to the authorization page */
|
|
11
|
-
signInUrl?: string;
|
|
12
|
-
axiosInstance?: any;
|
|
13
|
-
getToken?: (response: unknown, url?: string) => string;
|
|
14
|
-
};
|
package/dist/rest/src/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":""}
|