taxtank-core 0.31.50 → 0.31.52
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/esm2020/lib/collections/collection.mjs +2 -3
- package/esm2020/lib/services/auth/auth.service.mjs +1 -2
- package/esm2020/lib/services/auth/jwt.service.mjs +8 -2
- package/esm2020/lib/services/http/facebook/facebook.service.mjs +3 -4
- package/esm2020/lib/services/http/google/google.service.mjs +1 -2
- package/esm2020/lib/services/http/rest/rest.service.mjs +15 -1
- package/esm2020/lib/services/http/tax-review/tax-review.service.mjs +2 -3
- package/esm2020/lib/services/http/user/user.service.mjs +8 -3
- package/esm2020/lib/services/mixpanel/mixpanel.service.mjs +7 -1
- package/fesm2015/taxtank-core.mjs +81 -55
- package/fesm2015/taxtank-core.mjs.map +1 -1
- package/fesm2020/taxtank-core.mjs +79 -53
- package/fesm2020/taxtank-core.mjs.map +1 -1
- package/lib/services/auth/jwt.service.d.ts +1 -0
- package/lib/services/http/facebook/facebook.service.d.ts +2 -2
- package/lib/services/http/rest/rest.service.d.ts +4 -0
- package/lib/services/http/tax-review/tax-review.service.d.ts +1 -1
- package/lib/services/mixpanel/mixpanel.service.d.ts +1 -0
- package/package.json +1 -1
|
@@ -32,6 +32,12 @@ export class MixpanelService {
|
|
|
32
32
|
}
|
|
33
33
|
mixpanel.track(event, properties);
|
|
34
34
|
}
|
|
35
|
+
trackPageView() {
|
|
36
|
+
if (!this.environment.enableMixpanel) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
mixpanel['track_pageview']();
|
|
40
|
+
}
|
|
35
41
|
}
|
|
36
42
|
MixpanelService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: MixpanelService, deps: [{ token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
37
43
|
MixpanelService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: MixpanelService, providedIn: 'root' });
|
|
@@ -44,4 +50,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImpor
|
|
|
44
50
|
type: Inject,
|
|
45
51
|
args: ['environment']
|
|
46
52
|
}] }]; } });
|
|
47
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
53
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWl4cGFuZWwuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL3R0LWNvcmUvc3JjL2xpYi9zZXJ2aWNlcy9taXhwYW5lbC9taXhwYW5lbC5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxNQUFNLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ25ELE9BQU8sS0FBSyxRQUFRLE1BQU0sa0JBQWtCLENBQUM7O0FBRTdDOztHQUVHO0FBSUgsTUFBTSxPQUFPLGVBQWU7SUFDMUIsWUFBMkMsV0FBZ0I7UUFBaEIsZ0JBQVcsR0FBWCxXQUFXLENBQUs7SUFDM0QsQ0FBQztJQUVELElBQUk7UUFDRixJQUFJLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxjQUFjLEVBQUU7WUFDcEMsT0FBTztTQUNSO1FBRUQsUUFBUSxDQUFDLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLGFBQWEsQ0FBQyxDQUFDO0lBQ2hELENBQUM7SUFFRCxRQUFRLENBQUMsRUFBVTtRQUNqQixJQUFJLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxjQUFjLEVBQUU7WUFDcEMsT0FBTztTQUNSO1FBRUQsUUFBUSxDQUFDLFFBQVEsQ0FBQyxFQUFFLENBQUMsQ0FBQztJQUN4QixDQU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 +1898,7 @@ class Collection {
|
|
|
1898
1898
|
return this.items.reduce((prev, current) => (get(prev, path) > get(current, path) ? prev : current));
|
|
1899
1899
|
}
|
|
1900
1900
|
reduce(callback, init = 0) {
|
|
1901
|
-
return
|
|
1901
|
+
return this.items.reduce(callback, init);
|
|
1902
1902
|
}
|
|
1903
1903
|
slice(from, to) {
|
|
1904
1904
|
this.items.slice(from, to);
|
|
@@ -10541,6 +10541,12 @@ class MixpanelService {
|
|
|
10541
10541
|
}
|
|
10542
10542
|
mixpanel.track(event, properties);
|
|
10543
10543
|
}
|
|
10544
|
+
trackPageView() {
|
|
10545
|
+
if (!this.environment.enableMixpanel) {
|
|
10546
|
+
return;
|
|
10547
|
+
}
|
|
10548
|
+
mixpanel['track_pageview']();
|
|
10549
|
+
}
|
|
10544
10550
|
}
|
|
10545
10551
|
MixpanelService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: MixpanelService, deps: [{ token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
10546
10552
|
MixpanelService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: MixpanelService, providedIn: 'root' });
|
|
@@ -10596,6 +10602,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImpor
|
|
|
10596
10602
|
const NAME_TOKEN = 'token';
|
|
10597
10603
|
const NAME_REFRESH_TOKEN = 'refreshToken';
|
|
10598
10604
|
class JwtService extends JwtHelperService {
|
|
10605
|
+
constructor() {
|
|
10606
|
+
super(...arguments);
|
|
10607
|
+
this.mpService = inject(MixpanelService);
|
|
10608
|
+
}
|
|
10599
10609
|
getToken() {
|
|
10600
10610
|
return localStorage[NAME_TOKEN];
|
|
10601
10611
|
}
|
|
@@ -10605,6 +10615,7 @@ class JwtService extends JwtHelperService {
|
|
|
10605
10615
|
saveTokens(tokens) {
|
|
10606
10616
|
localStorage[NAME_TOKEN] = tokens.token;
|
|
10607
10617
|
localStorage[NAME_REFRESH_TOKEN] = tokens.refreshToken;
|
|
10618
|
+
this.mpService.identify(this.getUser().id);
|
|
10608
10619
|
}
|
|
10609
10620
|
destroyTokens() {
|
|
10610
10621
|
localStorage.removeItem(NAME_TOKEN);
|
|
@@ -10723,6 +10734,10 @@ let RestService$1 = class RestService extends DataService {
|
|
|
10723
10734
|
*/
|
|
10724
10735
|
fetch(path = this.apiUrl) {
|
|
10725
10736
|
this.handleAccessError('get');
|
|
10737
|
+
if (!this.hasRoles()) {
|
|
10738
|
+
this.setCache([], true);
|
|
10739
|
+
return this.cacheSubject.asObservable();
|
|
10740
|
+
}
|
|
10726
10741
|
// Set cache as empty collection to avoid multiple requests before cache filled
|
|
10727
10742
|
this.setCache([]);
|
|
10728
10743
|
return this.http.get(path)
|
|
@@ -10910,6 +10925,15 @@ let RestService$1 = class RestService extends DataService {
|
|
|
10910
10925
|
});
|
|
10911
10926
|
});
|
|
10912
10927
|
}
|
|
10928
|
+
/**
|
|
10929
|
+
* check if user has subscription role to access api
|
|
10930
|
+
*/
|
|
10931
|
+
hasRoles() {
|
|
10932
|
+
if (!this.roles.length) {
|
|
10933
|
+
return true;
|
|
10934
|
+
}
|
|
10935
|
+
return !!intersection(JSON.parse(localStorage.getItem('roles')), this.roles).length;
|
|
10936
|
+
}
|
|
10913
10937
|
/**
|
|
10914
10938
|
* // @TODO Alex remove
|
|
10915
10939
|
* Method that call all listeners. Empty by default. Should be redefined by child services if required
|
|
@@ -11958,6 +11982,55 @@ var DocumentMessagesEnum;
|
|
|
11958
11982
|
DocumentMessagesEnum["DELETED"] = "Document deleted!";
|
|
11959
11983
|
})(DocumentMessagesEnum || (DocumentMessagesEnum = {}));
|
|
11960
11984
|
|
|
11985
|
+
class AuthService {
|
|
11986
|
+
constructor(http, jwtService, mpService, environment) {
|
|
11987
|
+
this.http = http;
|
|
11988
|
+
this.jwtService = jwtService;
|
|
11989
|
+
this.mpService = mpService;
|
|
11990
|
+
this.environment = environment;
|
|
11991
|
+
this.isLoggedInSubject = new BehaviorSubject(!this.jwtService.isTokenExpired());
|
|
11992
|
+
}
|
|
11993
|
+
setAuth(response) {
|
|
11994
|
+
this.jwtService.saveTokens(response);
|
|
11995
|
+
this.isLoggedInSubject.next(true);
|
|
11996
|
+
}
|
|
11997
|
+
login(username, password) {
|
|
11998
|
+
return this.http.post(`${this.environment.apiV2}/login`, { username, password }).pipe(map((response) => {
|
|
11999
|
+
this.setAuth(response);
|
|
12000
|
+
this.mpService.track('login');
|
|
12001
|
+
return response;
|
|
12002
|
+
}), catchError((error) => {
|
|
12003
|
+
this.mpService.track('loginError', { username });
|
|
12004
|
+
return throwError(error);
|
|
12005
|
+
}));
|
|
12006
|
+
}
|
|
12007
|
+
refresh(refreshToken) {
|
|
12008
|
+
return this.http.post(`${this.environment.apiV2}/token/refresh`, { refreshToken }).pipe(map((response) => {
|
|
12009
|
+
this.setAuth(response);
|
|
12010
|
+
return response;
|
|
12011
|
+
}));
|
|
12012
|
+
}
|
|
12013
|
+
logoutFront(url = '/login') {
|
|
12014
|
+
localStorage.clear();
|
|
12015
|
+
this.mpService.track('logout');
|
|
12016
|
+
this.mpService.reset();
|
|
12017
|
+
location.replace(url);
|
|
12018
|
+
}
|
|
12019
|
+
}
|
|
12020
|
+
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AuthService, deps: [{ token: i1.HttpClient }, { token: JwtService }, { token: MixpanelService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
12021
|
+
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
12022
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AuthService, decorators: [{
|
|
12023
|
+
type: Injectable,
|
|
12024
|
+
args: [{
|
|
12025
|
+
providedIn: 'root'
|
|
12026
|
+
}]
|
|
12027
|
+
}], ctorParameters: function () {
|
|
12028
|
+
return [{ type: i1.HttpClient }, { type: JwtService }, { type: MixpanelService }, { type: undefined, decorators: [{
|
|
12029
|
+
type: Inject,
|
|
12030
|
+
args: ['environment']
|
|
12031
|
+
}] }];
|
|
12032
|
+
} });
|
|
12033
|
+
|
|
11961
12034
|
const ERROR_EMAIL_PERMISSION = 'Access to email denied. Please provide access to email in facebook.';
|
|
11962
12035
|
class FacebookService {
|
|
11963
12036
|
/**
|
|
@@ -11993,7 +12066,6 @@ class FacebookService {
|
|
|
11993
12066
|
setAuth(response) {
|
|
11994
12067
|
this.jwtService.saveTokens(response);
|
|
11995
12068
|
this.isLoggedInSubject.next(true);
|
|
11996
|
-
this.mpService.identify(this.jwtService.getUser().id);
|
|
11997
12069
|
this.mpService.track('loginFB');
|
|
11998
12070
|
}
|
|
11999
12071
|
/**
|
|
@@ -12045,56 +12117,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImpor
|
|
|
12045
12117
|
}] }];
|
|
12046
12118
|
} });
|
|
12047
12119
|
|
|
12048
|
-
class AuthService {
|
|
12049
|
-
constructor(http, jwtService, mpService, environment) {
|
|
12050
|
-
this.http = http;
|
|
12051
|
-
this.jwtService = jwtService;
|
|
12052
|
-
this.mpService = mpService;
|
|
12053
|
-
this.environment = environment;
|
|
12054
|
-
this.isLoggedInSubject = new BehaviorSubject(!this.jwtService.isTokenExpired());
|
|
12055
|
-
}
|
|
12056
|
-
setAuth(response) {
|
|
12057
|
-
this.jwtService.saveTokens(response);
|
|
12058
|
-
this.isLoggedInSubject.next(true);
|
|
12059
|
-
}
|
|
12060
|
-
login(username, password) {
|
|
12061
|
-
return this.http.post(`${this.environment.apiV2}/login`, { username, password }).pipe(map((response) => {
|
|
12062
|
-
this.setAuth(response);
|
|
12063
|
-
this.mpService.identify(this.jwtService.getUser().id);
|
|
12064
|
-
this.mpService.track('login');
|
|
12065
|
-
return response;
|
|
12066
|
-
}), catchError((error) => {
|
|
12067
|
-
this.mpService.track('loginError', { username });
|
|
12068
|
-
return throwError(error);
|
|
12069
|
-
}));
|
|
12070
|
-
}
|
|
12071
|
-
refresh(refreshToken) {
|
|
12072
|
-
return this.http.post(`${this.environment.apiV2}/token/refresh`, { refreshToken }).pipe(map((response) => {
|
|
12073
|
-
this.setAuth(response);
|
|
12074
|
-
return response;
|
|
12075
|
-
}));
|
|
12076
|
-
}
|
|
12077
|
-
logoutFront(url = '/login') {
|
|
12078
|
-
localStorage.clear();
|
|
12079
|
-
this.mpService.track('logout');
|
|
12080
|
-
this.mpService.reset();
|
|
12081
|
-
location.replace(url);
|
|
12082
|
-
}
|
|
12083
|
-
}
|
|
12084
|
-
AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AuthService, deps: [{ token: i1.HttpClient }, { token: JwtService }, { token: MixpanelService }, { token: 'environment' }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
12085
|
-
AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AuthService, providedIn: 'root' });
|
|
12086
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.5", ngImport: i0, type: AuthService, decorators: [{
|
|
12087
|
-
type: Injectable,
|
|
12088
|
-
args: [{
|
|
12089
|
-
providedIn: 'root'
|
|
12090
|
-
}]
|
|
12091
|
-
}], ctorParameters: function () {
|
|
12092
|
-
return [{ type: i1.HttpClient }, { type: JwtService }, { type: MixpanelService }, { type: undefined, decorators: [{
|
|
12093
|
-
type: Inject,
|
|
12094
|
-
args: ['environment']
|
|
12095
|
-
}] }];
|
|
12096
|
-
} });
|
|
12097
|
-
|
|
12098
12120
|
/**
|
|
12099
12121
|
* Google instance
|
|
12100
12122
|
* https://developers.google.com/identity/oauth2/web/guides/overview
|
|
@@ -12139,7 +12161,6 @@ class GoogleService {
|
|
|
12139
12161
|
.subscribe((response) => {
|
|
12140
12162
|
this.jwtService.saveTokens(response);
|
|
12141
12163
|
this.isLoggedInSubject.next(true);
|
|
12142
|
-
this.mpService.identify(this.jwtService.getUser().id);
|
|
12143
12164
|
this.mpService.track('loginGoogle');
|
|
12144
12165
|
this.router.navigate([redirectUrl]);
|
|
12145
12166
|
}, (error) => {
|
|
@@ -15646,14 +15667,19 @@ class UserService extends RestService$1 {
|
|
|
15646
15667
|
}
|
|
15647
15668
|
fetch() {
|
|
15648
15669
|
return super.fetch(`${this.apiUrl}/current`).pipe(map((users) => {
|
|
15670
|
+
// @TODO vik use separated service to handle global user storage
|
|
15649
15671
|
localStorage.setItem('userId', this.getCacheFirst().id.toString());
|
|
15650
15672
|
localStorage.setItem('financialYear', this.getCacheFirst().financialYear.toString());
|
|
15651
|
-
|
|
15673
|
+
localStorage.setItem('roles', JSON.stringify(this.getCacheFirst().roles));
|
|
15652
15674
|
return users;
|
|
15653
15675
|
}));
|
|
15654
15676
|
}
|
|
15655
15677
|
register(data) {
|
|
15656
|
-
return this.http.post(`${this.apiUrl}/registration`, data)
|
|
15678
|
+
return this.http.post(`${this.apiUrl}/registration`, data)
|
|
15679
|
+
.pipe(map((user) => {
|
|
15680
|
+
this.mpService.identify(user['id']);
|
|
15681
|
+
return user;
|
|
15682
|
+
}));
|
|
15657
15683
|
}
|
|
15658
15684
|
changePassword(currentPassword, newPassword) {
|
|
15659
15685
|
return this.http.put(`${this.apiUrl}/password/change`, { currentPassword, newPassword })
|