@vocollege/app 0.0.56 → 0.0.59
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/{types.d.ts → global.d.ts} +4 -0
- package/dist/{types.js → global.js} +0 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +9 -3
- package/dist/interceptor.js +41 -12
- package/dist/modules/Services/I18n/I18n.js +1 -1
- package/dist/modules/Services/I18n/strings.json +716 -21
- package/dist/modules/Services/Vapor/Vapor.js +15 -7
- package/dist/modules/VoApi/GraphClient.d.ts +3 -2
- package/dist/modules/VoApi/GraphClient.js +57 -14
- package/dist/modules/VoApi/VoApi.d.ts +4 -1
- package/dist/modules/VoApi/VoApi.js +20 -2
- package/dist/modules/VoApi/graphql.d.ts +32 -0
- package/dist/modules/VoApi/graphql.js +57 -0
- package/dist/modules/VoApi/index.d.ts +1 -21
- package/dist/modules/VoApi/index.js +7 -31
- package/dist/modules/VoApi/mutations/acl.js +5 -5
- package/dist/modules/VoApi/mutations/applications.d.ts +3 -0
- package/dist/modules/VoApi/mutations/applications.js +12 -0
- package/dist/modules/VoApi/mutations/articles.js +3 -3
- package/dist/modules/VoApi/mutations/books.d.ts +3 -0
- package/dist/modules/VoApi/mutations/books.js +12 -0
- package/dist/modules/VoApi/mutations/cards.d.ts +3 -0
- package/dist/modules/VoApi/mutations/cards.js +12 -0
- package/dist/modules/VoApi/mutations/events.d.ts +3 -0
- package/dist/modules/VoApi/mutations/events.js +12 -0
- package/dist/modules/VoApi/mutations/navigation.js +3 -3
- package/dist/modules/VoApi/mutations/pages.js +3 -3
- package/dist/modules/VoApi/mutations/queues.js +3 -3
- package/dist/modules/VoApi/mutations/sections.d.ts +3 -0
- package/dist/modules/VoApi/mutations/sections.js +12 -0
- package/dist/modules/VoApi/mutations/settings.js +1 -1
- package/dist/modules/VoApi/mutations/users.js +3 -3
- package/dist/modules/VoApi/mutations/vodocs.js +9 -9
- package/dist/modules/VoApi/mutations/vogroups.d.ts +1 -0
- package/dist/modules/VoApi/mutations/vogroups.js +10 -9
- package/dist/modules/VoApi/queries/acl.js +4 -4
- package/dist/modules/VoApi/queries/applications.d.ts +2 -0
- package/dist/modules/VoApi/queries/applications.js +11 -0
- package/dist/modules/VoApi/queries/articles.js +2 -2
- package/dist/modules/VoApi/queries/books.d.ts +4 -0
- package/dist/modules/VoApi/queries/books.js +13 -0
- package/dist/modules/VoApi/queries/cards.d.ts +2 -0
- package/dist/modules/VoApi/queries/cards.js +11 -0
- package/dist/modules/VoApi/queries/events.d.ts +2 -0
- package/dist/modules/VoApi/queries/events.js +11 -0
- package/dist/modules/VoApi/queries/help.d.ts +1 -0
- package/dist/modules/VoApi/queries/help.js +11 -0
- package/dist/modules/VoApi/queries/navigation.js +4 -4
- package/dist/modules/VoApi/queries/pages.js +2 -2
- package/dist/modules/VoApi/queries/queues.js +2 -2
- package/dist/modules/VoApi/queries/search.d.ts +2 -0
- package/dist/modules/VoApi/queries/search.js +5 -3
- package/dist/modules/VoApi/queries/sections.d.ts +2 -0
- package/dist/modules/VoApi/queries/sections.js +11 -0
- package/dist/modules/VoApi/queries/settings.js +1 -1
- package/dist/modules/VoApi/queries/users.d.ts +1 -0
- package/dist/modules/VoApi/queries/users.js +5 -4
- package/dist/modules/VoApi/queries/vodocs.js +3 -3
- package/dist/modules/VoApi/queries/vogroups.d.ts +1 -0
- package/dist/modules/VoApi/queries/vogroups.js +9 -8
- package/dist/modules/VoApp.d.ts +1 -0
- package/dist/modules/VoApp.js +17 -0
- package/dist/modules/VoAuth.d.ts +2 -1
- package/dist/modules/VoAuth.js +126 -42
- package/dist/modules/VoBase.js +2 -2
- package/dist/modules/VoConfig.js +10 -0
- package/dist/modules/VoDocs/VoDocs.d.ts +1 -2
- package/dist/modules/VoDocs/VoDocs.js +12 -44
- package/dist/modules/VoGroups.d.ts +7 -0
- package/dist/modules/VoGroups.js +39 -0
- package/dist/modules/VoHelpers.d.ts +38 -1
- package/dist/modules/VoHelpers.js +348 -51
- package/dist/modules/VoRouter.js +10 -2
- package/dist/modules/{VoUtils.d.ts → VoUtils_REMOVE.d.ts} +1 -1
- package/dist/modules/{VoUtils.js → VoUtils_REMOVE.js} +16 -12
- package/package.json +17 -8
- package/src/global.ts +44 -0
- package/src/index.ts +3 -2
- package/src/interceptor.ts +39 -8
- package/src/modules/Services/I18n/strings.json +718 -22
- package/src/modules/Services/Vapor/Vapor.ts +14 -15
- package/src/modules/VoApi/GraphClient.ts +87 -24
- package/src/modules/VoApi/VoApi.ts +23 -3
- package/src/modules/VoApi/graphql.ts +47 -0
- package/src/modules/VoApi/index.ts +1 -37
- package/src/modules/VoApi/mutations/applications.ts +27 -0
- package/src/modules/VoApi/mutations/books.ts +27 -0
- package/src/modules/VoApi/mutations/cards.ts +27 -0
- package/src/modules/VoApi/mutations/events.ts +27 -0
- package/src/modules/VoApi/mutations/queues.ts +9 -1
- package/src/modules/VoApi/mutations/sections.ts +27 -0
- package/src/modules/VoApi/mutations/settings.ts +11 -3
- package/src/modules/VoApi/mutations/users.ts +19 -9
- package/src/modules/VoApi/mutations/vodocs.ts +4 -0
- package/src/modules/VoApi/mutations/vogroups.ts +21 -7
- package/src/modules/VoApi/queries/applications.ts +71 -0
- package/src/modules/VoApi/queries/articles.ts +26 -4
- package/src/modules/VoApi/queries/books.ts +101 -0
- package/src/modules/VoApi/queries/cards.ts +87 -0
- package/src/modules/VoApi/queries/events.ts +80 -0
- package/src/modules/VoApi/queries/help.ts +12 -0
- package/src/modules/VoApi/queries/navigation.ts +3 -4
- package/src/modules/VoApi/queries/pages.ts +29 -4
- package/src/modules/VoApi/queries/queues.ts +69 -4
- package/src/modules/VoApi/queries/search.ts +105 -4
- package/src/modules/VoApi/queries/sections.ts +63 -0
- package/src/modules/VoApi/queries/settings.ts +9 -3
- package/src/modules/VoApi/queries/users.ts +93 -8
- package/src/modules/VoApi/queries/vodocs.ts +8 -4
- package/src/modules/VoApi/queries/vogroups.ts +48 -2
- package/src/modules/VoApp.ts +25 -8
- package/src/modules/VoAuth.ts +136 -37
- package/src/modules/VoConfig.ts +13 -0
- package/src/modules/VoDocs/VoDocs.ts +31 -58
- package/src/modules/VoGroups.ts +33 -0
- package/src/modules/VoHelpers.ts +283 -43
- package/src/modules/VoRouter.ts +10 -3
- package/src/modules/{VoUtils.ts → VoUtils_REMOVE.ts} +17 -13
- package/src/types.ts +0 -38
package/dist/modules/VoAuth.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { AnyMongoAbility } from "@casl/ability";
|
|
2
2
|
import VoBase from "./VoBase";
|
|
3
|
-
import { VoTokenType } from "../
|
|
3
|
+
import { VoTokenType } from "../global";
|
|
4
4
|
declare class VoAuth extends VoBase {
|
|
5
5
|
state: string;
|
|
6
6
|
verifier: string;
|
|
7
7
|
challenge: string;
|
|
8
8
|
user: any;
|
|
9
9
|
ability: AnyMongoAbility;
|
|
10
|
+
globalAbility: AnyMongoAbility;
|
|
10
11
|
constructor(key: string);
|
|
11
12
|
get getAppLoginUrl(): string;
|
|
12
13
|
auth(): Promise<unknown>;
|
package/dist/modules/VoAuth.js
CHANGED
|
@@ -7,6 +7,8 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -14,7 +16,11 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
16
|
})();
|
|
15
17
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
18
|
if (k2 === undefined) k2 = k;
|
|
17
|
-
Object.
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
18
24
|
}) : (function(o, m, k, k2) {
|
|
19
25
|
if (k2 === undefined) k2 = k;
|
|
20
26
|
o[k2] = m[k];
|
|
@@ -79,6 +85,8 @@ var VoBase_1 = __importDefault(require("./VoBase"));
|
|
|
79
85
|
var VoApi_1 = __importDefault(require("./VoApi"));
|
|
80
86
|
var VoRouter_1 = __importDefault(require("./VoRouter"));
|
|
81
87
|
var VoConfig_1 = __importDefault(require("./VoConfig"));
|
|
88
|
+
var VoGroups_1 = __importDefault(require("./VoGroups"));
|
|
89
|
+
var js_cookie_1 = __importDefault(require("js-cookie"));
|
|
82
90
|
var VoAuth = /** @class */ (function (_super) {
|
|
83
91
|
__extends(VoAuth, _super);
|
|
84
92
|
function VoAuth(key) {
|
|
@@ -88,6 +96,7 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
88
96
|
_this.verifier = "";
|
|
89
97
|
_this.challenge = "";
|
|
90
98
|
_this.ability = new ability_1.Ability();
|
|
99
|
+
_this.globalAbility = new ability_1.Ability();
|
|
91
100
|
return _this;
|
|
92
101
|
}
|
|
93
102
|
Object.defineProperty(VoAuth.prototype, "getAppLoginUrl", {
|
|
@@ -111,7 +120,7 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
111
120
|
VoAuth.prototype.auth = function () {
|
|
112
121
|
var _this = this;
|
|
113
122
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
114
|
-
var urlParams, code, state, initiatedAuth, params, url, response, state_1, verifier;
|
|
123
|
+
var urlParams, code, state, initiatedAuth, params, url, response, state_1, verifier, error_1;
|
|
115
124
|
return __generator(this, function (_a) {
|
|
116
125
|
switch (_a.label) {
|
|
117
126
|
case 0:
|
|
@@ -119,7 +128,10 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
119
128
|
code = urlParams.get("code");
|
|
120
129
|
state = urlParams.get("state");
|
|
121
130
|
initiatedAuth = this.getInitiatedAuth();
|
|
122
|
-
|
|
131
|
+
_a.label = 1;
|
|
132
|
+
case 1:
|
|
133
|
+
_a.trys.push([1, 6, , 7]);
|
|
134
|
+
if (!(code && state && state === initiatedAuth.state)) return [3 /*break*/, 4];
|
|
123
135
|
params = {
|
|
124
136
|
grant_type: "authorization_code",
|
|
125
137
|
client_id: VoConfig_1.default.get.AUTH_CLIENT_ID,
|
|
@@ -129,22 +141,35 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
129
141
|
};
|
|
130
142
|
url = this.getUrl + "/token";
|
|
131
143
|
return [4 /*yield*/, axios_1.default.post(url, params)];
|
|
132
|
-
case
|
|
144
|
+
case 2:
|
|
133
145
|
response = _a.sent();
|
|
134
146
|
state_1 = VoConfig_1.default.get.AUTH_STORAGE_STATE || "";
|
|
135
|
-
Helpers.localStorage.remove(
|
|
147
|
+
// Helpers.localStorage.remove(state);
|
|
148
|
+
js_cookie_1.default.remove(state_1, {
|
|
149
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
150
|
+
sameSite: "Lax",
|
|
151
|
+
});
|
|
136
152
|
verifier = VoConfig_1.default.get.AUTH_STORAGE_VERIFIER || "";
|
|
137
|
-
Helpers.localStorage.remove(verifier);
|
|
153
|
+
// Helpers.localStorage.remove(verifier);
|
|
154
|
+
js_cookie_1.default.remove(verifier, {
|
|
155
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
156
|
+
sameSite: "Lax",
|
|
157
|
+
});
|
|
138
158
|
this.setSession(response.data);
|
|
139
159
|
return [4 /*yield*/, this.loadUser(true)];
|
|
140
|
-
case
|
|
160
|
+
case 3:
|
|
141
161
|
_a.sent();
|
|
142
162
|
resolve(true);
|
|
143
|
-
return [3 /*break*/,
|
|
144
|
-
case
|
|
163
|
+
return [3 /*break*/, 5];
|
|
164
|
+
case 4:
|
|
145
165
|
reject("Authorization failed");
|
|
146
|
-
_a.label =
|
|
147
|
-
case
|
|
166
|
+
_a.label = 5;
|
|
167
|
+
case 5: return [3 /*break*/, 7];
|
|
168
|
+
case 6:
|
|
169
|
+
error_1 = _a.sent();
|
|
170
|
+
reject(error_1);
|
|
171
|
+
return [3 /*break*/, 7];
|
|
172
|
+
case 7: return [2 /*return*/];
|
|
148
173
|
}
|
|
149
174
|
});
|
|
150
175
|
}); });
|
|
@@ -174,34 +199,71 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
174
199
|
VoAuth.prototype.setSession = function (token) {
|
|
175
200
|
var token_type = token.token_type, access_token = token.access_token, refresh_token = token.refresh_token, expires_in = token.expires_in;
|
|
176
201
|
var refreshTokenKey = VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
177
|
-
Helpers.localStorage.set(refreshTokenKey, refresh_token);
|
|
202
|
+
// Helpers.localStorage.set(refreshTokenKey, refresh_token);
|
|
203
|
+
js_cookie_1.default.set(refreshTokenKey, refresh_token, {
|
|
204
|
+
expires: 20,
|
|
205
|
+
sameSite: "Lax",
|
|
206
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
207
|
+
});
|
|
178
208
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
179
|
-
Helpers.localStorage.set(accessTokenKey, access_token);
|
|
209
|
+
// Helpers.localStorage.set(accessTokenKey, access_token);
|
|
210
|
+
js_cookie_1.default.set(accessTokenKey, access_token, {
|
|
211
|
+
expires: 20,
|
|
212
|
+
sameSite: "Lax",
|
|
213
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
214
|
+
});
|
|
180
215
|
var tokenTypeKey = VoConfig_1.default.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
181
|
-
Helpers.localStorage.set(tokenTypeKey, token_type);
|
|
216
|
+
// Helpers.localStorage.set(tokenTypeKey, token_type);
|
|
217
|
+
js_cookie_1.default.set(tokenTypeKey, token_type, {
|
|
218
|
+
expires: 20,
|
|
219
|
+
sameSite: "Lax",
|
|
220
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
221
|
+
});
|
|
182
222
|
var expiresInKey = VoConfig_1.default.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
183
|
-
Helpers.localStorage.set(expiresInKey, expires_in);
|
|
223
|
+
// Helpers.localStorage.set(expiresInKey, expires_in);
|
|
224
|
+
js_cookie_1.default.set(expiresInKey, expires_in, {
|
|
225
|
+
expires: 20,
|
|
226
|
+
sameSite: "Lax",
|
|
227
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
228
|
+
});
|
|
184
229
|
axios_1.default.defaults.headers.common["Authorization"] =
|
|
185
230
|
token_type + " " + access_token;
|
|
231
|
+
var currentGroup = VoGroups_1.default.getCurrent(true);
|
|
232
|
+
axios_1.default.defaults.headers.common["VoGroup"] = currentGroup
|
|
233
|
+
? currentGroup.id
|
|
234
|
+
: "";
|
|
186
235
|
};
|
|
187
236
|
VoAuth.prototype.resetSession = function () {
|
|
188
237
|
var refreshTokenKey = VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
189
238
|
Helpers.localStorage.remove(refreshTokenKey);
|
|
239
|
+
js_cookie_1.default.remove(refreshTokenKey, { domain: VoConfig_1.default.get.AUTH_DOMAIN });
|
|
190
240
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
191
241
|
Helpers.localStorage.remove(accessTokenKey);
|
|
242
|
+
js_cookie_1.default.remove(accessTokenKey, {
|
|
243
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
244
|
+
sameSite: "Lax",
|
|
245
|
+
});
|
|
192
246
|
var tokenTypeKey = VoConfig_1.default.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
193
247
|
Helpers.localStorage.remove(tokenTypeKey);
|
|
248
|
+
js_cookie_1.default.remove(tokenTypeKey, {
|
|
249
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
250
|
+
sameSite: "Lax",
|
|
251
|
+
});
|
|
194
252
|
var expiresInKey = VoConfig_1.default.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
195
253
|
Helpers.localStorage.remove(expiresInKey);
|
|
254
|
+
js_cookie_1.default.remove(expiresInKey, {
|
|
255
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
256
|
+
sameSite: "Lax",
|
|
257
|
+
});
|
|
196
258
|
delete axios_1.default.defaults.headers.common["Authorization"];
|
|
197
259
|
};
|
|
198
260
|
VoAuth.prototype.refreshToken = function () {
|
|
199
261
|
return __awaiter(this, void 0, void 0, function () {
|
|
200
|
-
var token, params, url, response,
|
|
262
|
+
var token, params, url, response, error_2;
|
|
201
263
|
return __generator(this, function (_a) {
|
|
202
264
|
switch (_a.label) {
|
|
203
265
|
case 0:
|
|
204
|
-
_a.trys.push([0,
|
|
266
|
+
_a.trys.push([0, 4, , 5]);
|
|
205
267
|
token = this.getToken();
|
|
206
268
|
if (!token) return [3 /*break*/, 2];
|
|
207
269
|
params = {
|
|
@@ -219,12 +281,13 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
219
281
|
this.setSession(response.data);
|
|
220
282
|
}
|
|
221
283
|
return [2 /*return*/, this.getToken()];
|
|
222
|
-
case 2:
|
|
223
|
-
case 3:
|
|
224
|
-
|
|
284
|
+
case 2: throw new Error("Refresh token not found");
|
|
285
|
+
case 3: return [3 /*break*/, 5];
|
|
286
|
+
case 4:
|
|
287
|
+
error_2 = _a.sent();
|
|
225
288
|
this.resetSession();
|
|
226
|
-
throw
|
|
227
|
-
case
|
|
289
|
+
throw error_2;
|
|
290
|
+
case 5: return [2 /*return*/];
|
|
228
291
|
}
|
|
229
292
|
});
|
|
230
293
|
});
|
|
@@ -235,7 +298,7 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
235
298
|
if (forceLoad === void 0) { forceLoad = false; }
|
|
236
299
|
this.checkConfig();
|
|
237
300
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
238
|
-
var token,
|
|
301
|
+
var token, error_3;
|
|
239
302
|
return __generator(this, function (_a) {
|
|
240
303
|
switch (_a.label) {
|
|
241
304
|
case 0:
|
|
@@ -245,20 +308,14 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
245
308
|
case 1:
|
|
246
309
|
_a.trys.push([1, 3, , 4]);
|
|
247
310
|
this.setSession(token);
|
|
248
|
-
// const response = await VoApi.getUser();
|
|
249
|
-
// this.user = response.data.data;
|
|
250
|
-
// this.ability.update(this.user.permissions);
|
|
251
311
|
return [4 /*yield*/, this.loadUser(forceLoad)];
|
|
252
312
|
case 2:
|
|
253
|
-
// const response = await VoApi.getUser();
|
|
254
|
-
// this.user = response.data.data;
|
|
255
|
-
// this.ability.update(this.user.permissions);
|
|
256
313
|
_a.sent();
|
|
257
314
|
resolve(this.user);
|
|
258
315
|
return [3 /*break*/, 4];
|
|
259
316
|
case 3:
|
|
260
|
-
|
|
261
|
-
reject(
|
|
317
|
+
error_3 = _a.sent();
|
|
318
|
+
reject(error_3);
|
|
262
319
|
return [3 /*break*/, 4];
|
|
263
320
|
case 4: return [3 /*break*/, 6];
|
|
264
321
|
case 5:
|
|
@@ -278,7 +335,7 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
278
335
|
var _this = this;
|
|
279
336
|
if (force === void 0) { force = false; }
|
|
280
337
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
281
|
-
var response,
|
|
338
|
+
var response, error_4;
|
|
282
339
|
return __generator(this, function (_a) {
|
|
283
340
|
switch (_a.label) {
|
|
284
341
|
case 0:
|
|
@@ -289,13 +346,16 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
289
346
|
response = _a.sent();
|
|
290
347
|
this.user = response.data.data;
|
|
291
348
|
this.ability.update(this.user.permissions);
|
|
349
|
+
if (VoGroups_1.default.getCurrent(true)) {
|
|
350
|
+
this.globalAbility.update(this.user.globalPermissions);
|
|
351
|
+
}
|
|
292
352
|
_a.label = 2;
|
|
293
353
|
case 2:
|
|
294
354
|
resolve(this.user);
|
|
295
355
|
return [3 /*break*/, 4];
|
|
296
356
|
case 3:
|
|
297
|
-
|
|
298
|
-
reject(
|
|
357
|
+
error_4 = _a.sent();
|
|
358
|
+
reject(error_4);
|
|
299
359
|
return [3 /*break*/, 4];
|
|
300
360
|
case 4: return [2 /*return*/];
|
|
301
361
|
}
|
|
@@ -312,13 +372,17 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
312
372
|
VoAuth.prototype.getToken = function () {
|
|
313
373
|
try {
|
|
314
374
|
var refreshTokenKey = VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
315
|
-
|
|
375
|
+
// const refreshToken = Helpers.localStorage.get(refreshTokenKey);
|
|
376
|
+
var refreshToken = js_cookie_1.default.get(refreshTokenKey);
|
|
316
377
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
317
|
-
|
|
378
|
+
// const accessToken = Helpers.localStorage.get(accessTokenKey);
|
|
379
|
+
var accessToken = js_cookie_1.default.get(accessTokenKey);
|
|
318
380
|
var tokenTypeKey = VoConfig_1.default.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
319
|
-
|
|
381
|
+
// const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
382
|
+
var tokenType = js_cookie_1.default.get(tokenTypeKey);
|
|
320
383
|
var expiresInKey = VoConfig_1.default.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
321
|
-
|
|
384
|
+
// const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
385
|
+
var expiresIn = js_cookie_1.default.get(expiresInKey);
|
|
322
386
|
if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
323
387
|
return {
|
|
324
388
|
refresh_token: refreshToken,
|
|
@@ -341,13 +405,31 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
341
405
|
var verifier = Helpers.createRandomString(128);
|
|
342
406
|
var challenge = Helpers.base64Url(crypto_js_1.default.SHA256(verifier));
|
|
343
407
|
var stateKey = VoConfig_1.default.get.AUTH_STORAGE_STATE || "";
|
|
344
|
-
Helpers.localStorage.
|
|
408
|
+
Helpers.localStorage.remove(stateKey);
|
|
409
|
+
js_cookie_1.default.set(stateKey, state, {
|
|
410
|
+
expires: 1,
|
|
411
|
+
sameSite: "Lax",
|
|
412
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
413
|
+
});
|
|
345
414
|
var verifierKey = VoConfig_1.default.get.AUTH_STORAGE_VERIFIER || "";
|
|
346
|
-
Helpers.localStorage.
|
|
415
|
+
Helpers.localStorage.remove(verifierKey);
|
|
416
|
+
js_cookie_1.default.set(verifierKey, verifier, {
|
|
417
|
+
expires: 1,
|
|
418
|
+
sameSite: "Lax",
|
|
419
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
420
|
+
});
|
|
347
421
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
348
422
|
Helpers.localStorage.remove(accessTokenKey);
|
|
423
|
+
js_cookie_1.default.remove(accessTokenKey, {
|
|
424
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
425
|
+
sameSite: "Lax",
|
|
426
|
+
});
|
|
349
427
|
var tokenTypeKey = VoConfig_1.default.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
350
428
|
Helpers.localStorage.remove(tokenTypeKey);
|
|
429
|
+
js_cookie_1.default.remove(tokenTypeKey, {
|
|
430
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
431
|
+
sameSite: "Lax",
|
|
432
|
+
});
|
|
351
433
|
return {
|
|
352
434
|
state: state,
|
|
353
435
|
challenge: challenge,
|
|
@@ -359,9 +441,11 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
359
441
|
};
|
|
360
442
|
VoAuth.prototype.getInitiatedAuth = function () {
|
|
361
443
|
var stateKey = VoConfig_1.default.get.AUTH_STORAGE_STATE || "";
|
|
362
|
-
|
|
444
|
+
// const state = Helpers.localStorage.get(stateKey);
|
|
445
|
+
var state = js_cookie_1.default.get(stateKey);
|
|
363
446
|
var verifierKey = VoConfig_1.default.get.AUTH_STORAGE_VERIFIER || "";
|
|
364
|
-
|
|
447
|
+
// const verifier = Helpers.localStorage.get(verifierKey);
|
|
448
|
+
var verifier = js_cookie_1.default.get(verifierKey);
|
|
365
449
|
return {
|
|
366
450
|
state: state || "",
|
|
367
451
|
verifier: verifier || "",
|
package/dist/modules/VoBase.js
CHANGED
|
@@ -15,8 +15,8 @@ var VoBase = /** @class */ (function () {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(VoBase.prototype, "getUrl", {
|
|
17
17
|
get: function () {
|
|
18
|
-
var envKey = this.configKey.toUpperCase()
|
|
19
|
-
var endpointKey = this.configKey.toUpperCase()
|
|
18
|
+
var envKey = "".concat(this.configKey.toUpperCase(), "_BASE_URL");
|
|
19
|
+
var endpointKey = "".concat(this.configKey.toUpperCase(), "_ENDPOINT");
|
|
20
20
|
return VoConfig_1.default.get[envKey] + "" + VoConfig_1.default.get[endpointKey];
|
|
21
21
|
// let envKey = `REACT_APP_${this.configKey.toUpperCase()}_BASE_URL`;
|
|
22
22
|
// let endpointKey = `REACT_APP_${this.configKey.toUpperCase()}_ENDPOINT`;
|
package/dist/modules/VoConfig.js
CHANGED
|
@@ -21,15 +21,23 @@ var VoConfig = /** @class */ (function () {
|
|
|
21
21
|
// this.routes = routes;
|
|
22
22
|
// }
|
|
23
23
|
this.config = {
|
|
24
|
+
APP_VERSION: "",
|
|
24
25
|
API_BASE_URL: "",
|
|
25
26
|
API_ENDPOINT: "",
|
|
26
27
|
API_GRAPHQL: "",
|
|
28
|
+
API_SUBSCRIPTIONS_BASE_URL: "",
|
|
29
|
+
API_GRAPHQL_SUBSCRIPTIONS: "",
|
|
27
30
|
AUTH_CLIENT_ID: "",
|
|
28
31
|
AUTH_BASE_URL: "",
|
|
29
32
|
AUTH_ENDPOINT: "",
|
|
33
|
+
ADMIN_BASE_URL: "",
|
|
30
34
|
DOCS_BASE_URL: "",
|
|
31
35
|
DOCS_ENDPOINT: "",
|
|
32
36
|
DOCS_GRAPHQL: "",
|
|
37
|
+
DOCS_PUBLIC_DISKS: "",
|
|
38
|
+
DOCS_PRIVATE_DISKS: "",
|
|
39
|
+
AWS_BUCKET_VOFRONT_FILES: "",
|
|
40
|
+
AWS_BUCKET_VODOCS_FILES: "",
|
|
33
41
|
BASE_URL: "",
|
|
34
42
|
AUTH: "",
|
|
35
43
|
LOGIN: "",
|
|
@@ -41,6 +49,8 @@ var VoConfig = /** @class */ (function () {
|
|
|
41
49
|
AUTH_STORAGE_ACCESS_TOKEN: "voapp_accesstoken",
|
|
42
50
|
AUTH_STORAGE_TOKEN_TYPE: "voapp_tokentype",
|
|
43
51
|
AUTH_STORAGE_EXPIRES_IN: "voapp_expiresin",
|
|
52
|
+
AUTH_DOMAIN: ".vo-college.se",
|
|
53
|
+
CURRENT_GROUP: "vo_group",
|
|
44
54
|
};
|
|
45
55
|
}
|
|
46
56
|
VoConfig.prototype.setConfig = function (config) {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import VoBase from
|
|
1
|
+
import VoBase from "../VoBase";
|
|
2
2
|
declare class VoDocs extends VoBase {
|
|
3
3
|
graphqlClient: any;
|
|
4
4
|
init(): void;
|
|
5
5
|
get getGraphqlUrl(): string;
|
|
6
6
|
getTemporaryFileUrl(id: string): Promise<import("axios").AxiosResponse<any>>;
|
|
7
|
-
downloadFile(id: string): Promise<void>;
|
|
8
7
|
}
|
|
9
8
|
declare const _default: VoDocs;
|
|
10
9
|
export default _default;
|
|
@@ -7,6 +7,8 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -57,7 +59,9 @@ var axios_1 = __importDefault(require("axios"));
|
|
|
57
59
|
// Custom.
|
|
58
60
|
var GraphClient_1 = __importDefault(require("../VoApi/GraphClient"));
|
|
59
61
|
var VoBase_1 = __importDefault(require("../VoBase"));
|
|
62
|
+
// import VoAuth from '../VoAuth';
|
|
60
63
|
var VoConfig_1 = __importDefault(require("../VoConfig"));
|
|
64
|
+
var VoGroups_1 = __importDefault(require("../VoGroups"));
|
|
61
65
|
var VoDocs = /** @class */ (function (_super) {
|
|
62
66
|
__extends(VoDocs, _super);
|
|
63
67
|
function VoDocs() {
|
|
@@ -68,17 +72,21 @@ var VoDocs = /** @class */ (function (_super) {
|
|
|
68
72
|
};
|
|
69
73
|
Object.defineProperty(VoDocs.prototype, "getGraphqlUrl", {
|
|
70
74
|
get: function () {
|
|
71
|
-
return VoConfig_1.default.get.DOCS_BASE_URL +
|
|
75
|
+
return VoConfig_1.default.get.DOCS_BASE_URL + "" + VoConfig_1.default.get.DOCS_GRAPHQL;
|
|
72
76
|
},
|
|
73
77
|
enumerable: false,
|
|
74
78
|
configurable: true
|
|
75
79
|
});
|
|
76
80
|
VoDocs.prototype.getTemporaryFileUrl = function (id) {
|
|
77
81
|
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
-
var url;
|
|
82
|
+
var currentGroup, url;
|
|
79
83
|
return __generator(this, function (_a) {
|
|
80
84
|
try {
|
|
81
|
-
|
|
85
|
+
currentGroup = VoGroups_1.default.getCurrent(true);
|
|
86
|
+
axios_1.default.defaults.headers.common["VoGroup"] = currentGroup
|
|
87
|
+
? currentGroup.id
|
|
88
|
+
: "";
|
|
89
|
+
url = "".concat(this.getUrl, "/docs/download/").concat(id);
|
|
82
90
|
return [2 /*return*/, axios_1.default.get(url)];
|
|
83
91
|
}
|
|
84
92
|
catch (error) {
|
|
@@ -88,46 +96,6 @@ var VoDocs = /** @class */ (function (_super) {
|
|
|
88
96
|
});
|
|
89
97
|
});
|
|
90
98
|
};
|
|
91
|
-
VoDocs.prototype.downloadFile = function (id) {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
-
var elId, el, fileUrl, anchor_1, error_1;
|
|
94
|
-
return __generator(this, function (_a) {
|
|
95
|
-
switch (_a.label) {
|
|
96
|
-
case 0:
|
|
97
|
-
_a.trys.push([0, 2, , 3]);
|
|
98
|
-
elId = "file-" + id;
|
|
99
|
-
el = document.getElementById(elId);
|
|
100
|
-
if (el !== null && el.parentNode) {
|
|
101
|
-
el.parentNode.removeChild(el);
|
|
102
|
-
}
|
|
103
|
-
return [4 /*yield*/, this.getTemporaryFileUrl(id)];
|
|
104
|
-
case 1:
|
|
105
|
-
fileUrl = _a.sent();
|
|
106
|
-
if (fileUrl.data) {
|
|
107
|
-
anchor_1 = document.createElement('a');
|
|
108
|
-
anchor_1.id = elId;
|
|
109
|
-
anchor_1.href = fileUrl.data;
|
|
110
|
-
anchor_1.download = fileUrl.data;
|
|
111
|
-
document.body.appendChild(anchor_1);
|
|
112
|
-
anchor_1.click();
|
|
113
|
-
setTimeout(function () {
|
|
114
|
-
if (anchor_1.parentNode) {
|
|
115
|
-
anchor_1.parentNode.removeChild(anchor_1);
|
|
116
|
-
}
|
|
117
|
-
}, 500);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
throw "No file was found";
|
|
121
|
-
}
|
|
122
|
-
return [3 /*break*/, 3];
|
|
123
|
-
case 2:
|
|
124
|
-
error_1 = _a.sent();
|
|
125
|
-
throw error_1;
|
|
126
|
-
case 3: return [2 /*return*/];
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
99
|
return VoDocs;
|
|
132
100
|
}(VoBase_1.default));
|
|
133
|
-
exports.default = new VoDocs(
|
|
101
|
+
exports.default = new VoDocs("docs");
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var VoHelpers_1 = require("./VoHelpers");
|
|
7
|
+
var VoConfig_1 = __importDefault(require("./VoConfig"));
|
|
8
|
+
var VoGroups = /** @class */ (function () {
|
|
9
|
+
function VoGroups() {
|
|
10
|
+
}
|
|
11
|
+
VoGroups.prototype.getCurrent = function (getFromDomain) {
|
|
12
|
+
if (getFromDomain === void 0) { getFromDomain = false; }
|
|
13
|
+
var group = VoHelpers_1.localStorage.get(VoConfig_1.default.get.CURRENT_GROUP);
|
|
14
|
+
if (group) {
|
|
15
|
+
return JSON.parse(group);
|
|
16
|
+
}
|
|
17
|
+
if (getFromDomain) {
|
|
18
|
+
var groupName = this.getGroupNameFromDomain(window.location.host);
|
|
19
|
+
if (groupName && groupName !== "") {
|
|
20
|
+
return { id: groupName };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
};
|
|
25
|
+
VoGroups.prototype.getGroupNameFromDomain = function (host) {
|
|
26
|
+
var subdomain = host === null || host === void 0 ? void 0 : host.split(".")[0];
|
|
27
|
+
var localIndex = subdomain === null || subdomain === void 0 ? void 0 : subdomain.indexOf("local");
|
|
28
|
+
if (localIndex !== undefined && localIndex > -1) {
|
|
29
|
+
var hyphenIndex = (subdomain === null || subdomain === void 0 ? void 0 : subdomain.indexOf("-")) || 0;
|
|
30
|
+
subdomain = subdomain === null || subdomain === void 0 ? void 0 : subdomain.substring(hyphenIndex + 1);
|
|
31
|
+
}
|
|
32
|
+
if (subdomain === "admin") {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return subdomain;
|
|
36
|
+
};
|
|
37
|
+
return VoGroups;
|
|
38
|
+
}());
|
|
39
|
+
exports.default = new VoGroups();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import crypto from "crypto-js";
|
|
2
|
+
import { GeneralObject } from "../global";
|
|
2
3
|
export declare const base64Url: (string: crypto.lib.WordArray | String) => string;
|
|
3
4
|
export declare const createRandomString: (num: number) => string;
|
|
4
5
|
export declare const localStorage: {
|
|
@@ -16,11 +17,13 @@ export declare const regexPatterns: {
|
|
|
16
17
|
stringNonDigit: RegExp;
|
|
17
18
|
password: RegExp;
|
|
18
19
|
cleanName: RegExp;
|
|
20
|
+
personalNumber: RegExp;
|
|
21
|
+
orgnr: RegExp;
|
|
19
22
|
};
|
|
20
23
|
declare type errorObjectType = {
|
|
21
24
|
message: string;
|
|
22
25
|
fields?: {
|
|
23
|
-
[key: string]:
|
|
26
|
+
[key: string]: any;
|
|
24
27
|
};
|
|
25
28
|
};
|
|
26
29
|
export declare const getError: (error: any) => errorObjectType;
|
|
@@ -29,4 +32,38 @@ export declare const createSlug2: (value: string) => string;
|
|
|
29
32
|
export declare const wrapPromise: (promise: any) => {
|
|
30
33
|
read: () => any;
|
|
31
34
|
};
|
|
35
|
+
export declare const downloadFile: (url: string) => void;
|
|
36
|
+
export declare const orderByPosition: (a: any, b: any) => 1 | -1 | 0;
|
|
37
|
+
export declare const orderByField: (a: any, b: any, field: string) => 1 | -1 | 0;
|
|
38
|
+
export declare const shortenText: (str: string, limit?: number, stripHtml?: boolean, addEllipsis?: boolean) => string;
|
|
39
|
+
export declare const getImageContact: (item: any, width?: number, height?: number) => string;
|
|
40
|
+
export declare const getImage: (item: any, width: number, height: number, field?: string) => string;
|
|
41
|
+
export declare const getImageDescription: (item: any, field?: string) => any;
|
|
42
|
+
export declare const getContactName: (item?: GeneralObject | undefined) => string;
|
|
43
|
+
export declare const getUserString: (item?: GeneralObject | undefined) => string;
|
|
44
|
+
export declare const parseState: (state: any, initialState: any) => GeneralObject;
|
|
45
|
+
export declare const changeObj: (obj: any, is: any, value: any) => {};
|
|
46
|
+
export declare const reducer: (state: any, action: any) => any;
|
|
47
|
+
export declare const getGroupLogotype: (group: GeneralObject, logo?: string, output?: GeneralObject[]) => any;
|
|
48
|
+
export declare const getObjValue: (obj: any, ...props: string[]) => any;
|
|
49
|
+
/**
|
|
50
|
+
* Convert an SVG into an image.
|
|
51
|
+
* @param url
|
|
52
|
+
* @param width
|
|
53
|
+
* @param height
|
|
54
|
+
* @param format
|
|
55
|
+
* @param quality
|
|
56
|
+
* @returns Promise
|
|
57
|
+
*
|
|
58
|
+
* @note Convert logic inpired by
|
|
59
|
+
* https://levelup.gitconnected.com/draw-an-svg-to-canvas-and-download-it-as-image-in-javascript-f7f7713cf81f
|
|
60
|
+
* https://medium.com/@benjamin.black/using-blob-from-svg-text-as-image-source-2a8947af7a8e
|
|
61
|
+
*
|
|
62
|
+
* In this method we could actually assign "url" directly to "image.src" and then
|
|
63
|
+
* extract an image with canvas, but Firefox doesn't support drawing an SVG into
|
|
64
|
+
* canvas if it misses width/height attributes. Read more here:
|
|
65
|
+
* https://stackoverflow.com/questions/28690643/firefox-error-rendering-an-svg-image-to-html5-canvas-with-drawimage
|
|
66
|
+
* https://bugzilla.mozilla.org/show_bug.cgi?id=700533
|
|
67
|
+
*/
|
|
68
|
+
export declare const convertSvgToImage: (url: string, width?: null | number, height?: null | number, format?: string, quality?: number) => Promise<unknown>;
|
|
32
69
|
export {};
|