@vocollege/app 0.0.58 → 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 +14 -9
- package/dist/modules/Services/I18n/I18n.js +1 -1
- package/dist/modules/Services/I18n/strings.json +506 -25
- package/dist/modules/Services/Vapor/Vapor.js +3 -1
- package/dist/modules/VoApi/GraphClient.d.ts +3 -2
- package/dist/modules/VoApi/GraphClient.js +51 -13
- package/dist/modules/VoApi/VoApi.d.ts +4 -1
- package/dist/modules/VoApi/VoApi.js +18 -2
- package/dist/modules/VoApi/graphql.d.ts +5 -0
- package/dist/modules/VoApi/graphql.js +12 -3
- package/dist/modules/VoApi/index.js +5 -1
- 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.js +3 -3
- package/dist/modules/VoApi/mutations/events.js +3 -3
- 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.js +3 -3
- 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.js +2 -2
- package/dist/modules/VoApi/queries/events.js +2 -2
- 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.js +2 -2
- 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.js +7 -7
- 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 +119 -38
- package/dist/modules/VoBase.js +2 -2
- package/dist/modules/VoConfig.js +9 -0
- package/dist/modules/VoDocs/VoDocs.js +7 -2
- package/dist/modules/VoGroups.d.ts +7 -0
- package/dist/modules/VoGroups.js +39 -0
- package/dist/modules/VoHelpers.d.ts +36 -1
- package/dist/modules/VoHelpers.js +320 -48
- package/dist/modules/VoRouter.js +10 -2
- package/dist/modules/VoUtils_REMOVE.js +9 -5
- package/package.json +17 -9
- package/src/global.ts +44 -0
- package/src/index.ts +3 -2
- package/src/interceptor.ts +15 -8
- package/src/modules/Services/I18n/strings.json +505 -24
- package/src/modules/Services/Vapor/Vapor.ts +2 -1
- package/src/modules/VoApi/GraphClient.ts +66 -8
- package/src/modules/VoApi/VoApi.ts +23 -3
- package/src/modules/VoApi/graphql.ts +5 -0
- package/src/modules/VoApi/mutations/applications.ts +27 -0
- package/src/modules/VoApi/mutations/books.ts +27 -0
- package/src/modules/VoApi/mutations/users.ts +5 -0
- package/src/modules/VoApi/mutations/vodocs.ts +2 -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 +1 -1
- package/src/modules/VoApi/queries/books.ts +101 -0
- package/src/modules/VoApi/queries/cards.ts +14 -1
- package/src/modules/VoApi/queries/events.ts +1 -1
- 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 +1 -1
- package/src/modules/VoApi/queries/queues.ts +18 -1
- package/src/modules/VoApi/queries/search.ts +98 -1
- package/src/modules/VoApi/queries/sections.ts +1 -1
- package/src/modules/VoApi/queries/users.ts +74 -8
- package/src/modules/VoApi/queries/vodocs.ts +8 -4
- package/src/modules/VoApi/queries/vogroups.ts +40 -11
- package/src/modules/VoApp.ts +25 -8
- package/src/modules/VoAuth.ts +134 -37
- package/src/modules/VoConfig.ts +11 -0
- package/src/modules/VoDocs/VoDocs.ts +5 -0
- package/src/modules/VoGroups.ts +33 -0
- package/src/modules/VoHelpers.ts +254 -42
- package/src/modules/VoRouter.ts +10 -3
- package/src/types.ts +0 -38
package/dist/modules/VoAuth.js
CHANGED
|
@@ -16,7 +16,11 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
16
16
|
})();
|
|
17
17
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
18
|
if (k2 === undefined) k2 = k;
|
|
19
|
-
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);
|
|
20
24
|
}) : (function(o, m, k, k2) {
|
|
21
25
|
if (k2 === undefined) k2 = k;
|
|
22
26
|
o[k2] = m[k];
|
|
@@ -81,6 +85,8 @@ var VoBase_1 = __importDefault(require("./VoBase"));
|
|
|
81
85
|
var VoApi_1 = __importDefault(require("./VoApi"));
|
|
82
86
|
var VoRouter_1 = __importDefault(require("./VoRouter"));
|
|
83
87
|
var VoConfig_1 = __importDefault(require("./VoConfig"));
|
|
88
|
+
var VoGroups_1 = __importDefault(require("./VoGroups"));
|
|
89
|
+
var js_cookie_1 = __importDefault(require("js-cookie"));
|
|
84
90
|
var VoAuth = /** @class */ (function (_super) {
|
|
85
91
|
__extends(VoAuth, _super);
|
|
86
92
|
function VoAuth(key) {
|
|
@@ -90,6 +96,7 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
90
96
|
_this.verifier = "";
|
|
91
97
|
_this.challenge = "";
|
|
92
98
|
_this.ability = new ability_1.Ability();
|
|
99
|
+
_this.globalAbility = new ability_1.Ability();
|
|
93
100
|
return _this;
|
|
94
101
|
}
|
|
95
102
|
Object.defineProperty(VoAuth.prototype, "getAppLoginUrl", {
|
|
@@ -113,7 +120,7 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
113
120
|
VoAuth.prototype.auth = function () {
|
|
114
121
|
var _this = this;
|
|
115
122
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
116
|
-
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;
|
|
117
124
|
return __generator(this, function (_a) {
|
|
118
125
|
switch (_a.label) {
|
|
119
126
|
case 0:
|
|
@@ -121,7 +128,10 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
121
128
|
code = urlParams.get("code");
|
|
122
129
|
state = urlParams.get("state");
|
|
123
130
|
initiatedAuth = this.getInitiatedAuth();
|
|
124
|
-
|
|
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];
|
|
125
135
|
params = {
|
|
126
136
|
grant_type: "authorization_code",
|
|
127
137
|
client_id: VoConfig_1.default.get.AUTH_CLIENT_ID,
|
|
@@ -131,22 +141,35 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
131
141
|
};
|
|
132
142
|
url = this.getUrl + "/token";
|
|
133
143
|
return [4 /*yield*/, axios_1.default.post(url, params)];
|
|
134
|
-
case
|
|
144
|
+
case 2:
|
|
135
145
|
response = _a.sent();
|
|
136
146
|
state_1 = VoConfig_1.default.get.AUTH_STORAGE_STATE || "";
|
|
137
|
-
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
|
+
});
|
|
138
152
|
verifier = VoConfig_1.default.get.AUTH_STORAGE_VERIFIER || "";
|
|
139
|
-
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
|
+
});
|
|
140
158
|
this.setSession(response.data);
|
|
141
159
|
return [4 /*yield*/, this.loadUser(true)];
|
|
142
|
-
case
|
|
160
|
+
case 3:
|
|
143
161
|
_a.sent();
|
|
144
162
|
resolve(true);
|
|
145
|
-
return [3 /*break*/,
|
|
146
|
-
case
|
|
163
|
+
return [3 /*break*/, 5];
|
|
164
|
+
case 4:
|
|
147
165
|
reject("Authorization failed");
|
|
148
|
-
_a.label =
|
|
149
|
-
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*/];
|
|
150
173
|
}
|
|
151
174
|
});
|
|
152
175
|
}); });
|
|
@@ -176,30 +199,67 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
176
199
|
VoAuth.prototype.setSession = function (token) {
|
|
177
200
|
var token_type = token.token_type, access_token = token.access_token, refresh_token = token.refresh_token, expires_in = token.expires_in;
|
|
178
201
|
var refreshTokenKey = VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
179
|
-
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
|
+
});
|
|
180
208
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
181
|
-
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
|
+
});
|
|
182
215
|
var tokenTypeKey = VoConfig_1.default.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
183
|
-
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
|
+
});
|
|
184
222
|
var expiresInKey = VoConfig_1.default.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
185
|
-
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
|
+
});
|
|
186
229
|
axios_1.default.defaults.headers.common["Authorization"] =
|
|
187
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
|
+
: "";
|
|
188
235
|
};
|
|
189
236
|
VoAuth.prototype.resetSession = function () {
|
|
190
237
|
var refreshTokenKey = VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
191
238
|
Helpers.localStorage.remove(refreshTokenKey);
|
|
239
|
+
js_cookie_1.default.remove(refreshTokenKey, { domain: VoConfig_1.default.get.AUTH_DOMAIN });
|
|
192
240
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
193
241
|
Helpers.localStorage.remove(accessTokenKey);
|
|
242
|
+
js_cookie_1.default.remove(accessTokenKey, {
|
|
243
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
244
|
+
sameSite: "Lax",
|
|
245
|
+
});
|
|
194
246
|
var tokenTypeKey = VoConfig_1.default.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
195
247
|
Helpers.localStorage.remove(tokenTypeKey);
|
|
248
|
+
js_cookie_1.default.remove(tokenTypeKey, {
|
|
249
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
250
|
+
sameSite: "Lax",
|
|
251
|
+
});
|
|
196
252
|
var expiresInKey = VoConfig_1.default.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
197
253
|
Helpers.localStorage.remove(expiresInKey);
|
|
254
|
+
js_cookie_1.default.remove(expiresInKey, {
|
|
255
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
256
|
+
sameSite: "Lax",
|
|
257
|
+
});
|
|
198
258
|
delete axios_1.default.defaults.headers.common["Authorization"];
|
|
199
259
|
};
|
|
200
260
|
VoAuth.prototype.refreshToken = function () {
|
|
201
261
|
return __awaiter(this, void 0, void 0, function () {
|
|
202
|
-
var token, params, url, response,
|
|
262
|
+
var token, params, url, response, error_2;
|
|
203
263
|
return __generator(this, function (_a) {
|
|
204
264
|
switch (_a.label) {
|
|
205
265
|
case 0:
|
|
@@ -224,9 +284,9 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
224
284
|
case 2: throw new Error("Refresh token not found");
|
|
225
285
|
case 3: return [3 /*break*/, 5];
|
|
226
286
|
case 4:
|
|
227
|
-
|
|
287
|
+
error_2 = _a.sent();
|
|
228
288
|
this.resetSession();
|
|
229
|
-
throw
|
|
289
|
+
throw error_2;
|
|
230
290
|
case 5: return [2 /*return*/];
|
|
231
291
|
}
|
|
232
292
|
});
|
|
@@ -238,7 +298,7 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
238
298
|
if (forceLoad === void 0) { forceLoad = false; }
|
|
239
299
|
this.checkConfig();
|
|
240
300
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
241
|
-
var token,
|
|
301
|
+
var token, error_3;
|
|
242
302
|
return __generator(this, function (_a) {
|
|
243
303
|
switch (_a.label) {
|
|
244
304
|
case 0:
|
|
@@ -248,20 +308,14 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
248
308
|
case 1:
|
|
249
309
|
_a.trys.push([1, 3, , 4]);
|
|
250
310
|
this.setSession(token);
|
|
251
|
-
// const response = await VoApi.getUser();
|
|
252
|
-
// this.user = response.data.data;
|
|
253
|
-
// this.ability.update(this.user.permissions);
|
|
254
311
|
return [4 /*yield*/, this.loadUser(forceLoad)];
|
|
255
312
|
case 2:
|
|
256
|
-
// const response = await VoApi.getUser();
|
|
257
|
-
// this.user = response.data.data;
|
|
258
|
-
// this.ability.update(this.user.permissions);
|
|
259
313
|
_a.sent();
|
|
260
314
|
resolve(this.user);
|
|
261
315
|
return [3 /*break*/, 4];
|
|
262
316
|
case 3:
|
|
263
|
-
|
|
264
|
-
reject(
|
|
317
|
+
error_3 = _a.sent();
|
|
318
|
+
reject(error_3);
|
|
265
319
|
return [3 /*break*/, 4];
|
|
266
320
|
case 4: return [3 /*break*/, 6];
|
|
267
321
|
case 5:
|
|
@@ -281,7 +335,7 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
281
335
|
var _this = this;
|
|
282
336
|
if (force === void 0) { force = false; }
|
|
283
337
|
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
284
|
-
var response,
|
|
338
|
+
var response, error_4;
|
|
285
339
|
return __generator(this, function (_a) {
|
|
286
340
|
switch (_a.label) {
|
|
287
341
|
case 0:
|
|
@@ -292,13 +346,16 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
292
346
|
response = _a.sent();
|
|
293
347
|
this.user = response.data.data;
|
|
294
348
|
this.ability.update(this.user.permissions);
|
|
349
|
+
if (VoGroups_1.default.getCurrent(true)) {
|
|
350
|
+
this.globalAbility.update(this.user.globalPermissions);
|
|
351
|
+
}
|
|
295
352
|
_a.label = 2;
|
|
296
353
|
case 2:
|
|
297
354
|
resolve(this.user);
|
|
298
355
|
return [3 /*break*/, 4];
|
|
299
356
|
case 3:
|
|
300
|
-
|
|
301
|
-
reject(
|
|
357
|
+
error_4 = _a.sent();
|
|
358
|
+
reject(error_4);
|
|
302
359
|
return [3 /*break*/, 4];
|
|
303
360
|
case 4: return [2 /*return*/];
|
|
304
361
|
}
|
|
@@ -315,13 +372,17 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
315
372
|
VoAuth.prototype.getToken = function () {
|
|
316
373
|
try {
|
|
317
374
|
var refreshTokenKey = VoConfig_1.default.get.AUTH_STORAGE_REFRESH_TOKEN || "";
|
|
318
|
-
|
|
375
|
+
// const refreshToken = Helpers.localStorage.get(refreshTokenKey);
|
|
376
|
+
var refreshToken = js_cookie_1.default.get(refreshTokenKey);
|
|
319
377
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
320
|
-
|
|
378
|
+
// const accessToken = Helpers.localStorage.get(accessTokenKey);
|
|
379
|
+
var accessToken = js_cookie_1.default.get(accessTokenKey);
|
|
321
380
|
var tokenTypeKey = VoConfig_1.default.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
322
|
-
|
|
381
|
+
// const tokenType = Helpers.localStorage.get(tokenTypeKey);
|
|
382
|
+
var tokenType = js_cookie_1.default.get(tokenTypeKey);
|
|
323
383
|
var expiresInKey = VoConfig_1.default.get.AUTH_STORAGE_EXPIRES_IN || "";
|
|
324
|
-
|
|
384
|
+
// const expiresIn = Helpers.localStorage.get(expiresInKey);
|
|
385
|
+
var expiresIn = js_cookie_1.default.get(expiresInKey);
|
|
325
386
|
if (refreshToken && accessToken && tokenType && expiresIn) {
|
|
326
387
|
return {
|
|
327
388
|
refresh_token: refreshToken,
|
|
@@ -344,13 +405,31 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
344
405
|
var verifier = Helpers.createRandomString(128);
|
|
345
406
|
var challenge = Helpers.base64Url(crypto_js_1.default.SHA256(verifier));
|
|
346
407
|
var stateKey = VoConfig_1.default.get.AUTH_STORAGE_STATE || "";
|
|
347
|
-
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
|
+
});
|
|
348
414
|
var verifierKey = VoConfig_1.default.get.AUTH_STORAGE_VERIFIER || "";
|
|
349
|
-
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
|
+
});
|
|
350
421
|
var accessTokenKey = VoConfig_1.default.get.AUTH_STORAGE_ACCESS_TOKEN || "";
|
|
351
422
|
Helpers.localStorage.remove(accessTokenKey);
|
|
423
|
+
js_cookie_1.default.remove(accessTokenKey, {
|
|
424
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
425
|
+
sameSite: "Lax",
|
|
426
|
+
});
|
|
352
427
|
var tokenTypeKey = VoConfig_1.default.get.AUTH_STORAGE_TOKEN_TYPE || "";
|
|
353
428
|
Helpers.localStorage.remove(tokenTypeKey);
|
|
429
|
+
js_cookie_1.default.remove(tokenTypeKey, {
|
|
430
|
+
domain: VoConfig_1.default.get.AUTH_DOMAIN,
|
|
431
|
+
sameSite: "Lax",
|
|
432
|
+
});
|
|
354
433
|
return {
|
|
355
434
|
state: state,
|
|
356
435
|
challenge: challenge,
|
|
@@ -362,9 +441,11 @@ var VoAuth = /** @class */ (function (_super) {
|
|
|
362
441
|
};
|
|
363
442
|
VoAuth.prototype.getInitiatedAuth = function () {
|
|
364
443
|
var stateKey = VoConfig_1.default.get.AUTH_STORAGE_STATE || "";
|
|
365
|
-
|
|
444
|
+
// const state = Helpers.localStorage.get(stateKey);
|
|
445
|
+
var state = js_cookie_1.default.get(stateKey);
|
|
366
446
|
var verifierKey = VoConfig_1.default.get.AUTH_STORAGE_VERIFIER || "";
|
|
367
|
-
|
|
447
|
+
// const verifier = Helpers.localStorage.get(verifierKey);
|
|
448
|
+
var verifier = js_cookie_1.default.get(verifierKey);
|
|
368
449
|
return {
|
|
369
450
|
state: state || "",
|
|
370
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,9 +21,12 @@ 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: "",
|
|
@@ -31,6 +34,10 @@ var VoConfig = /** @class */ (function () {
|
|
|
31
34
|
DOCS_BASE_URL: "",
|
|
32
35
|
DOCS_ENDPOINT: "",
|
|
33
36
|
DOCS_GRAPHQL: "",
|
|
37
|
+
DOCS_PUBLIC_DISKS: "",
|
|
38
|
+
DOCS_PRIVATE_DISKS: "",
|
|
39
|
+
AWS_BUCKET_VOFRONT_FILES: "",
|
|
40
|
+
AWS_BUCKET_VODOCS_FILES: "",
|
|
34
41
|
BASE_URL: "",
|
|
35
42
|
AUTH: "",
|
|
36
43
|
LOGIN: "",
|
|
@@ -42,6 +49,8 @@ var VoConfig = /** @class */ (function () {
|
|
|
42
49
|
AUTH_STORAGE_ACCESS_TOKEN: "voapp_accesstoken",
|
|
43
50
|
AUTH_STORAGE_TOKEN_TYPE: "voapp_tokentype",
|
|
44
51
|
AUTH_STORAGE_EXPIRES_IN: "voapp_expiresin",
|
|
52
|
+
AUTH_DOMAIN: ".vo-college.se",
|
|
53
|
+
CURRENT_GROUP: "vo_group",
|
|
45
54
|
};
|
|
46
55
|
}
|
|
47
56
|
VoConfig.prototype.setConfig = function (config) {
|
|
@@ -61,6 +61,7 @@ var GraphClient_1 = __importDefault(require("../VoApi/GraphClient"));
|
|
|
61
61
|
var VoBase_1 = __importDefault(require("../VoBase"));
|
|
62
62
|
// import VoAuth from '../VoAuth';
|
|
63
63
|
var VoConfig_1 = __importDefault(require("../VoConfig"));
|
|
64
|
+
var VoGroups_1 = __importDefault(require("../VoGroups"));
|
|
64
65
|
var VoDocs = /** @class */ (function (_super) {
|
|
65
66
|
__extends(VoDocs, _super);
|
|
66
67
|
function VoDocs() {
|
|
@@ -78,10 +79,14 @@ var VoDocs = /** @class */ (function (_super) {
|
|
|
78
79
|
});
|
|
79
80
|
VoDocs.prototype.getTemporaryFileUrl = function (id) {
|
|
80
81
|
return __awaiter(this, void 0, void 0, function () {
|
|
81
|
-
var url;
|
|
82
|
+
var currentGroup, url;
|
|
82
83
|
return __generator(this, function (_a) {
|
|
83
84
|
try {
|
|
84
|
-
|
|
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);
|
|
85
90
|
return [2 /*return*/, axios_1.default.get(url)];
|
|
86
91
|
}
|
|
87
92
|
catch (error) {
|
|
@@ -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: {
|
|
@@ -17,11 +18,12 @@ export declare const regexPatterns: {
|
|
|
17
18
|
password: RegExp;
|
|
18
19
|
cleanName: RegExp;
|
|
19
20
|
personalNumber: RegExp;
|
|
21
|
+
orgnr: RegExp;
|
|
20
22
|
};
|
|
21
23
|
declare type errorObjectType = {
|
|
22
24
|
message: string;
|
|
23
25
|
fields?: {
|
|
24
|
-
[key: string]:
|
|
26
|
+
[key: string]: any;
|
|
25
27
|
};
|
|
26
28
|
};
|
|
27
29
|
export declare const getError: (error: any) => errorObjectType;
|
|
@@ -31,4 +33,37 @@ export declare const wrapPromise: (promise: any) => {
|
|
|
31
33
|
read: () => any;
|
|
32
34
|
};
|
|
33
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>;
|
|
34
69
|
export {};
|