@loomcore/api 0.2.45 → 0.2.46
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.
|
@@ -24,6 +24,7 @@ declare function setupTestUsers(): Promise<{
|
|
|
24
24
|
declare function deleteTestUser(): Promise<void>;
|
|
25
25
|
declare function simulateloginWithTestUser(): Promise<string>;
|
|
26
26
|
declare function getAuthToken(): string;
|
|
27
|
+
declare function getExpiredAuthToken(): string;
|
|
27
28
|
declare function verifyToken(token: string): any;
|
|
28
29
|
export declare class CategoryService extends GenericApiService<ICategory> {
|
|
29
30
|
constructor(database: IDatabase);
|
|
@@ -65,6 +66,7 @@ declare const testUtils: {
|
|
|
65
66
|
deleteMetaOrg: typeof deleteMetaOrg;
|
|
66
67
|
deleteTestUser: typeof deleteTestUser;
|
|
67
68
|
getAuthToken: typeof getAuthToken;
|
|
69
|
+
getExpiredAuthToken: typeof getExpiredAuthToken;
|
|
68
70
|
getTestMetaOrgRefererUrl: typeof testObjectsModule.getTestMetaOrgRefererUrl;
|
|
69
71
|
initialize: typeof initialize;
|
|
70
72
|
setupTestConfig: typeof setupTestConfig;
|
|
@@ -208,6 +208,11 @@ function getAuthToken() {
|
|
|
208
208
|
const token = jwt.sign(userContext, JWT_SECRET, { expiresIn: 3600 });
|
|
209
209
|
return `Bearer ${token}`;
|
|
210
210
|
}
|
|
211
|
+
function getExpiredAuthToken() {
|
|
212
|
+
const userContext = getTestMetaOrgUserContext();
|
|
213
|
+
const token = jwt.sign(userContext, JWT_SECRET, { expiresIn: -1 });
|
|
214
|
+
return `Bearer ${token}`;
|
|
215
|
+
}
|
|
211
216
|
function verifyToken(token) {
|
|
212
217
|
return jwt.verify(token, JWT_SECRET);
|
|
213
218
|
}
|
|
@@ -402,6 +407,7 @@ const testUtils = {
|
|
|
402
407
|
deleteMetaOrg,
|
|
403
408
|
deleteTestUser,
|
|
404
409
|
getAuthToken,
|
|
410
|
+
getExpiredAuthToken,
|
|
405
411
|
getTestMetaOrgRefererUrl,
|
|
406
412
|
initialize,
|
|
407
413
|
setupTestConfig,
|
|
@@ -16,6 +16,12 @@ export function authenticateRequest(req) {
|
|
|
16
16
|
throw new UnauthenticatedError();
|
|
17
17
|
}
|
|
18
18
|
const authConfig = getAuthConfig();
|
|
19
|
-
|
|
19
|
+
let rawPayload;
|
|
20
|
+
try {
|
|
21
|
+
rawPayload = jwt.verify(token, authConfig.clientSecret);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
throw new UnauthenticatedError();
|
|
25
|
+
}
|
|
20
26
|
return getAuthUserContextSpec().decode(rawPayload);
|
|
21
27
|
}
|