pangea-server 3.3.44 → 3.3.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.
|
@@ -7,5 +7,5 @@ export type AuthUsers<AM extends AuthMap> = {
|
|
|
7
7
|
[K in keyof AM]: InstanceType<AM[K]> | null;
|
|
8
8
|
};
|
|
9
9
|
export interface AuthCtor<AM extends AuthMap, AU extends AuthUsers<AM>, BA extends BaseAuth<AM>> {
|
|
10
|
-
new (authUsers: AU, initRes:
|
|
10
|
+
new (authUsers: AU, initRes: any): BA;
|
|
11
11
|
}
|
|
@@ -28,7 +28,8 @@ function callController(controller, validate, appVersion, authConfig) {
|
|
|
28
28
|
let result;
|
|
29
29
|
try {
|
|
30
30
|
const authUsers = await (0, auth_1.getUsersFromToken)(headers.authorization, db, accessToken, authMap);
|
|
31
|
-
const
|
|
31
|
+
const initRes = initAuthCtor ? await initAuthCtor(db, headers) : undefined;
|
|
32
|
+
const auth = new authCtor(authUsers, initRes);
|
|
32
33
|
(0, helpers_1.printInfo)(reqId, 'auth resolved');
|
|
33
34
|
result = await controller(ctx, db, auth);
|
|
34
35
|
(0, helpers_1.printInfo)(reqId, 'controller executed');
|
|
@@ -10,7 +10,7 @@ export type SetRouteArgs<V extends RouteValidator, AM extends AuthMap, BA extend
|
|
|
10
10
|
export type AuthConfig<AM extends AuthMap, AU extends AuthUsers<AM>, BA extends BaseAuth<AM>> = {
|
|
11
11
|
authMap: AM;
|
|
12
12
|
authCtor: AuthCtor<AM, AU, BA>;
|
|
13
|
-
initAuthCtor?: (headers: ReqHeaders) => Promise<unknown>;
|
|
13
|
+
initAuthCtor?: (db: Db, headers: ReqHeaders) => Promise<unknown>;
|
|
14
14
|
accessToken: AccessToken;
|
|
15
15
|
};
|
|
16
16
|
export type SetRoutes = (app: App) => void;
|