@auth-strategy-manager/rest 1.0.3 → 1.0.4
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/rest-strategy.d.ts +5 -5
- package/dist/rest-strategy.js +19 -11
- package/dist/rest-strategy.js.map +1 -1
- package/dist/types.d.ts +1 -1
- 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/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 {
|
|
@@ -16,12 +16,12 @@ export declare class RestStrategy implements Strategy {
|
|
|
16
16
|
get token(): string | undefined;
|
|
17
17
|
set token(token: string);
|
|
18
18
|
get isAuthenticated(): boolean;
|
|
19
|
-
|
|
20
|
-
signIn: <
|
|
21
|
-
signUp: <
|
|
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
22
|
signOut: () => Promise<void>;
|
|
23
23
|
refreshToken: () => Promise<void>;
|
|
24
|
+
clear: () => void;
|
|
24
25
|
private extractToken;
|
|
25
26
|
private setAuthParams;
|
|
26
|
-
private clearAuthData;
|
|
27
27
|
}
|
package/dist/rest-strategy.js
CHANGED
|
@@ -32,14 +32,14 @@ class RestStrategy {
|
|
|
32
32
|
constructor(config) {
|
|
33
33
|
var _a;
|
|
34
34
|
this.currentRefresh = null;
|
|
35
|
-
this.
|
|
35
|
+
this.checkAuth = () => __awaiter(this, void 0, void 0, function* () {
|
|
36
36
|
if (!this.token) {
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
|
-
if (!this.urls.
|
|
39
|
+
if (!this.urls.checkAuth) {
|
|
40
40
|
throw new Error('Check URL is not defined');
|
|
41
41
|
}
|
|
42
|
-
const { url, method } = this.urls.
|
|
42
|
+
const { url, method } = this.urls.checkAuth;
|
|
43
43
|
const response = yield this.axiosInstance(url, { method });
|
|
44
44
|
const token = this.extractToken(response, url);
|
|
45
45
|
const isAuthenticated = Boolean(token);
|
|
@@ -54,7 +54,11 @@ class RestStrategy {
|
|
|
54
54
|
throw new Error('Sign in URL is not defined');
|
|
55
55
|
}
|
|
56
56
|
const { url, method } = this.urls.signIn;
|
|
57
|
-
|
|
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 }));
|
|
58
62
|
const token = this.extractToken(response, url);
|
|
59
63
|
if (token) {
|
|
60
64
|
this.setAuthParams(token);
|
|
@@ -66,7 +70,11 @@ class RestStrategy {
|
|
|
66
70
|
throw new Error('Sign up URL is not defined');
|
|
67
71
|
}
|
|
68
72
|
const { url, method } = this.urls.signUp;
|
|
69
|
-
|
|
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 }));
|
|
70
78
|
const token = this.extractToken(response, url);
|
|
71
79
|
if (token) {
|
|
72
80
|
this.setAuthParams(token);
|
|
@@ -79,11 +87,11 @@ class RestStrategy {
|
|
|
79
87
|
}
|
|
80
88
|
const { url, method } = this.urls.signOut;
|
|
81
89
|
if (!url) {
|
|
82
|
-
this.
|
|
90
|
+
this.clear();
|
|
83
91
|
return;
|
|
84
92
|
}
|
|
85
93
|
yield this.axiosInstance(url, { method });
|
|
86
|
-
this.
|
|
94
|
+
this.clear();
|
|
87
95
|
});
|
|
88
96
|
this.refreshToken = () => __awaiter(this, void 0, void 0, function* () {
|
|
89
97
|
if (!this.urls.refresh) {
|
|
@@ -108,6 +116,10 @@ class RestStrategy {
|
|
|
108
116
|
resolver();
|
|
109
117
|
this.currentRefresh = null;
|
|
110
118
|
});
|
|
119
|
+
this.clear = () => {
|
|
120
|
+
window.sessionStorage.clear();
|
|
121
|
+
this.helper.reset();
|
|
122
|
+
};
|
|
111
123
|
this.extractToken = (response, url) => {
|
|
112
124
|
if (typeof response === 'string') {
|
|
113
125
|
return response;
|
|
@@ -119,10 +131,6 @@ class RestStrategy {
|
|
|
119
131
|
this.helper.activeStrategyName = this.name;
|
|
120
132
|
this.helper.isAuthenticated = true;
|
|
121
133
|
};
|
|
122
|
-
this.clearAuthData = () => {
|
|
123
|
-
window.sessionStorage.clear();
|
|
124
|
-
this.helper.reset();
|
|
125
|
-
};
|
|
126
134
|
const { name, tokenKey, getToken, signInUrl: loginUrl } = config, urls = __rest(config, ["name", "tokenKey", "getToken", "signInUrl"]);
|
|
127
135
|
this.helper = new core_1.StrategyHelper();
|
|
128
136
|
this.name = name || DEFAULT_NAME;
|
|
@@ -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,iBAAiB,GAAG,QAAQ,CAAC;AAEnC,MAAa,YAAY;IAWvB,YAAY,MAAc;;QAFlB,mBAAc,GAAyB,IAAI,CAAC;
|
|
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,GAAyB,IAAI,CAAC;QAmC7C,cAAS,GAAG,GAA2B,EAAE;YAC9C,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;gBACf,OAAO,KAAK,CAAC;aACd;YAED,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAA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AAK,CAAC,CAAC;IACtD,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;IACrC,CAAC;CA0HF;AApKD,oCAoKC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ 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
7
|
export type Config = Record<UrlName, UrlConfig> & {
|
|
8
8
|
name?: string;
|
|
9
9
|
tokenKey?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auth-strategy-manager/rest",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
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.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,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC;IAC7B,CAAC;CAmEF;AAlGD,kDAkGC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
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,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,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,GAAG,CAAC;IAC7B,CAAC;IAED,IAAI,KAAK;;QACP,OAAO,MAAA,MAAM,CAAC,cAAc,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":""}
|