@famir/reverse-app 0.0.3
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/README.md +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/authorize/authorize.controller.d.ts +23 -0
- package/dist/modules/authorize/authorize.controller.js +331 -0
- package/dist/modules/authorize/authorize.controller.js.map +1 -0
- package/dist/modules/authorize/authorize.d.ts +32 -0
- package/dist/modules/authorize/authorize.js +3 -0
- package/dist/modules/authorize/authorize.js.map +1 -0
- package/dist/modules/authorize/authorize.schemas.d.ts +2 -0
- package/dist/modules/authorize/authorize.schemas.js +8 -0
- package/dist/modules/authorize/authorize.schemas.js.map +1 -0
- package/dist/modules/authorize/authorize.service.d.ts +17 -0
- package/dist/modules/authorize/authorize.service.js +116 -0
- package/dist/modules/authorize/authorize.service.js.map +1 -0
- package/dist/modules/authorize/index.d.ts +4 -0
- package/dist/modules/authorize/index.js +5 -0
- package/dist/modules/authorize/index.js.map +1 -0
- package/dist/modules/base/base.controller.d.ts +29 -0
- package/dist/modules/base/base.controller.js +237 -0
- package/dist/modules/base/base.controller.js.map +1 -0
- package/dist/modules/base/base.d.ts +11 -0
- package/dist/modules/base/base.js +2 -0
- package/dist/modules/base/base.js.map +1 -0
- package/dist/modules/base/index.d.ts +2 -0
- package/dist/modules/base/index.js +3 -0
- package/dist/modules/base/index.js.map +1 -0
- package/dist/modules/complete/complete.controller.d.ts +14 -0
- package/dist/modules/complete/complete.controller.js +57 -0
- package/dist/modules/complete/complete.controller.js.map +1 -0
- package/dist/modules/complete/complete.d.ts +24 -0
- package/dist/modules/complete/complete.js +3 -0
- package/dist/modules/complete/complete.js.map +1 -0
- package/dist/modules/complete/complete.service.d.ts +11 -0
- package/dist/modules/complete/complete.service.js +44 -0
- package/dist/modules/complete/complete.service.js.map +1 -0
- package/dist/modules/complete/index.d.ts +3 -0
- package/dist/modules/complete/index.js +4 -0
- package/dist/modules/complete/index.js.map +1 -0
- package/dist/modules/forward/forward.controller.d.ts +15 -0
- package/dist/modules/forward/forward.controller.js +175 -0
- package/dist/modules/forward/forward.controller.js.map +1 -0
- package/dist/modules/forward/forward.d.ts +41 -0
- package/dist/modules/forward/forward.js +3 -0
- package/dist/modules/forward/forward.js.map +1 -0
- package/dist/modules/forward/forward.service.d.ts +11 -0
- package/dist/modules/forward/forward.service.js +21 -0
- package/dist/modules/forward/forward.service.js.map +1 -0
- package/dist/modules/forward/index.d.ts +3 -0
- package/dist/modules/forward/index.js +4 -0
- package/dist/modules/forward/index.js.map +1 -0
- package/dist/modules/index.d.ts +7 -0
- package/dist/modules/index.js +8 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/setup-mirror/index.d.ts +3 -0
- package/dist/modules/setup-mirror/index.js +4 -0
- package/dist/modules/setup-mirror/index.js.map +1 -0
- package/dist/modules/setup-mirror/setup-mirror.controller.d.ts +16 -0
- package/dist/modules/setup-mirror/setup-mirror.controller.js +76 -0
- package/dist/modules/setup-mirror/setup-mirror.controller.js.map +1 -0
- package/dist/modules/setup-mirror/setup-mirror.d.ts +16 -0
- package/dist/modules/setup-mirror/setup-mirror.js +3 -0
- package/dist/modules/setup-mirror/setup-mirror.js.map +1 -0
- package/dist/modules/setup-mirror/setup-mirror.service.d.ts +12 -0
- package/dist/modules/setup-mirror/setup-mirror.service.js +54 -0
- package/dist/modules/setup-mirror/setup-mirror.service.js.map +1 -0
- package/dist/modules/transform/index.d.ts +2 -0
- package/dist/modules/transform/index.js +3 -0
- package/dist/modules/transform/index.js.map +1 -0
- package/dist/modules/transform/transform.controller.d.ts +12 -0
- package/dist/modules/transform/transform.controller.js +126 -0
- package/dist/modules/transform/transform.controller.js.map +1 -0
- package/dist/modules/transform/transform.d.ts +1 -0
- package/dist/modules/transform/transform.js +2 -0
- package/dist/modules/transform/transform.js.map +1 -0
- package/dist/modules/well-known-urls/index.d.ts +2 -0
- package/dist/modules/well-known-urls/index.js +3 -0
- package/dist/modules/well-known-urls/index.js.map +1 -0
- package/dist/modules/well-known-urls/well-known-urls.controller.d.ts +13 -0
- package/dist/modules/well-known-urls/well-known-urls.controller.js +47 -0
- package/dist/modules/well-known-urls/well-known-urls.controller.js.map +1 -0
- package/dist/modules/well-known-urls/well-known-urls.d.ts +5 -0
- package/dist/modules/well-known-urls/well-known-urls.js +2 -0
- package/dist/modules/well-known-urls/well-known-urls.js.map +1 -0
- package/dist/reverse-app.d.ts +19 -0
- package/dist/reverse-app.js +59 -0
- package/dist/reverse-app.js.map +1 -0
- package/package.json +52 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,kBAAkB,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DIContainer } from '@famir/common';
|
|
2
|
+
import { HttpServerRouter } from '@famir/http-server';
|
|
3
|
+
import { Logger } from '@famir/logger';
|
|
4
|
+
import { Templater } from '@famir/templater';
|
|
5
|
+
import { Validator } from '@famir/validator';
|
|
6
|
+
import { BaseController } from '../base/index.js';
|
|
7
|
+
import { type AuthorizeService } from './authorize.service.js';
|
|
8
|
+
export declare class AuthorizeController extends BaseController {
|
|
9
|
+
protected readonly authorizeService: AuthorizeService;
|
|
10
|
+
static register(container: DIContainer): void;
|
|
11
|
+
static resolve(container: DIContainer): AuthorizeController;
|
|
12
|
+
constructor(validator: Validator, logger: Logger, templater: Templater, router: HttpServerRouter, authorizeService: AuthorizeService);
|
|
13
|
+
use(): void;
|
|
14
|
+
private dispatchRoot;
|
|
15
|
+
private dispatchNormal;
|
|
16
|
+
private dispatchWebSocket;
|
|
17
|
+
private getSessionCookie;
|
|
18
|
+
private checkSessionCookie;
|
|
19
|
+
private persistSessionCookie;
|
|
20
|
+
private removeSessionCookie;
|
|
21
|
+
private parseUpgradeSessionParams;
|
|
22
|
+
private parseRedirectorParams;
|
|
23
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { decrypt, encrypt, randomName } from '@famir/common';
|
|
2
|
+
import { HTTP_SERVER_ROUTER } from '@famir/http-server';
|
|
3
|
+
import { LOGGER } from '@famir/logger';
|
|
4
|
+
import { TEMPLATER } from '@famir/templater';
|
|
5
|
+
import { VALIDATOR } from '@famir/validator';
|
|
6
|
+
import { BaseController } from '../base/index.js';
|
|
7
|
+
import { AUTHORIZE_CONTROLLER, AUTHORIZE_SERVICE, } from './authorize.js';
|
|
8
|
+
import { authorizeSchemas } from './authorize.schemas.js';
|
|
9
|
+
export class AuthorizeController extends BaseController {
|
|
10
|
+
authorizeService;
|
|
11
|
+
static register(container) {
|
|
12
|
+
container.registerSingleton(AUTHORIZE_CONTROLLER, (c) => new AuthorizeController(c.resolve(VALIDATOR), c.resolve(LOGGER), c.resolve(TEMPLATER), c.resolve(HTTP_SERVER_ROUTER), c.resolve(AUTHORIZE_SERVICE)));
|
|
13
|
+
}
|
|
14
|
+
static resolve(container) {
|
|
15
|
+
return container.resolve(AUTHORIZE_CONTROLLER);
|
|
16
|
+
}
|
|
17
|
+
constructor(validator, logger, templater, router, authorizeService) {
|
|
18
|
+
super(validator, logger, templater, router);
|
|
19
|
+
this.authorizeService = authorizeService;
|
|
20
|
+
this.validator.addSchemas(authorizeSchemas);
|
|
21
|
+
this.logger.debug(`AuthorizeController initialized`);
|
|
22
|
+
}
|
|
23
|
+
use() {
|
|
24
|
+
this.router.addMiddleware('authorize', async (ctx, next) => {
|
|
25
|
+
const campaign = this.getState(ctx, 'campaign');
|
|
26
|
+
const target = this.getState(ctx, 'target');
|
|
27
|
+
await this.dispatchRoot[ctx.type](ctx, campaign, target, next);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
dispatchRoot = {
|
|
31
|
+
normal: async (ctx, campaign, target, next) => {
|
|
32
|
+
await this.dispatchNormal[target.accessLevel](ctx, campaign, target, next);
|
|
33
|
+
},
|
|
34
|
+
websocket: async (ctx, campaign, target, next) => {
|
|
35
|
+
await this.dispatchWebSocket[target.accessLevel](ctx, campaign, target, next);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
dispatchNormal = {
|
|
39
|
+
transparent: async (ctx, campaign, target, next) => {
|
|
40
|
+
if (ctx.isBot) {
|
|
41
|
+
await this.sendCloakingSite(ctx, target);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
let session = null;
|
|
45
|
+
const sessionCookie = this.getSessionCookie(ctx, campaign);
|
|
46
|
+
if (sessionCookie && this.checkSessionCookie(sessionCookie)) {
|
|
47
|
+
session = await this.authorizeService.authSession({
|
|
48
|
+
campaignId: campaign.campaignId,
|
|
49
|
+
sessionId: sessionCookie,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (!session) {
|
|
53
|
+
session = await this.authorizeService.createSession({
|
|
54
|
+
campaignId: campaign.campaignId,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
this.persistSessionCookie(ctx, campaign, session);
|
|
58
|
+
const proxy = await this.authorizeService.readProxy({
|
|
59
|
+
campaignId: campaign.campaignId,
|
|
60
|
+
proxyId: session.proxyId,
|
|
61
|
+
});
|
|
62
|
+
this.setState(ctx, 'proxy', proxy);
|
|
63
|
+
this.setState(ctx, 'session', session);
|
|
64
|
+
if (ctx.state.verbose) {
|
|
65
|
+
ctx.responseHeaders.merge({
|
|
66
|
+
'X-Famir-Session-Id': session.sessionId,
|
|
67
|
+
'X-Famir-Proxy-Id': proxy.proxyId,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
await next();
|
|
71
|
+
},
|
|
72
|
+
landing: async (ctx, campaign, target, next) => {
|
|
73
|
+
if (ctx.url.isPath(campaign.upgradeSessionPath)) {
|
|
74
|
+
if (!ctx.method.is('GET')) {
|
|
75
|
+
await this.sendNotFoundPage(ctx, target);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const upgradeSessionParams = this.parseUpgradeSessionParams(ctx, campaign);
|
|
79
|
+
if (!upgradeSessionParams) {
|
|
80
|
+
await this.sendNotFoundPage(ctx, target);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (ctx.isBot) {
|
|
84
|
+
await this.sendNotFoundPage(ctx, target);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const okey = await this.authorizeService.upgradeSession({
|
|
88
|
+
campaignId: campaign.campaignId,
|
|
89
|
+
lureId: upgradeSessionParams.lure_id,
|
|
90
|
+
sessionId: upgradeSessionParams.session_id,
|
|
91
|
+
secret: upgradeSessionParams.secret,
|
|
92
|
+
});
|
|
93
|
+
if (!okey) {
|
|
94
|
+
await this.sendNotFoundPage(ctx, target);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
await this.sendRedirectTo(ctx, upgradeSessionParams.back_url);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const lure = await this.authorizeService.findLure({
|
|
101
|
+
campaignId: campaign.campaignId,
|
|
102
|
+
path: ctx.url.get('pathname'),
|
|
103
|
+
});
|
|
104
|
+
if (lure) {
|
|
105
|
+
if (!ctx.method.is(['GET', 'HEAD'])) {
|
|
106
|
+
await this.sendNotFoundPage(ctx, target);
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const redirector = await this.authorizeService.readRedirector({
|
|
110
|
+
campaignId: campaign.campaignId,
|
|
111
|
+
redirectorId: lure.redirectorId,
|
|
112
|
+
});
|
|
113
|
+
const redirectorParams = this.parseRedirectorParams(ctx, campaign, redirector);
|
|
114
|
+
if (!redirectorParams) {
|
|
115
|
+
await this.sendNotFoundPage(ctx, target);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (ctx.isBot) {
|
|
119
|
+
await this.sendRedirectorPage(ctx, target, redirector, {
|
|
120
|
+
...redirectorParams,
|
|
121
|
+
upgrade_url: null,
|
|
122
|
+
});
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const sessionCookie = this.getSessionCookie(ctx, campaign);
|
|
126
|
+
if (!sessionCookie) {
|
|
127
|
+
const session = await this.authorizeService.createSession({
|
|
128
|
+
campaignId: campaign.campaignId,
|
|
129
|
+
});
|
|
130
|
+
this.persistSessionCookie(ctx, campaign, session);
|
|
131
|
+
await this.sendOriginRedirect(ctx);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (!this.checkSessionCookie(sessionCookie)) {
|
|
135
|
+
this.removeSessionCookie(ctx, campaign);
|
|
136
|
+
await this.sendOriginRedirect(ctx);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const session = await this.authorizeService.authSession({
|
|
140
|
+
campaignId: campaign.campaignId,
|
|
141
|
+
sessionId: sessionCookie,
|
|
142
|
+
});
|
|
143
|
+
if (!session) {
|
|
144
|
+
this.removeSessionCookie(ctx, campaign);
|
|
145
|
+
await this.sendOriginRedirect(ctx);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.persistSessionCookie(ctx, campaign, session);
|
|
149
|
+
const upgradeSessionParams = {
|
|
150
|
+
lure_id: lure.lureId,
|
|
151
|
+
session_id: session.sessionId,
|
|
152
|
+
secret: session.secret,
|
|
153
|
+
back_url: redirectorParams['back_url'] ?? '/',
|
|
154
|
+
};
|
|
155
|
+
const upgrade_url = [
|
|
156
|
+
campaign.upgradeSessionPath,
|
|
157
|
+
'?',
|
|
158
|
+
randomName(),
|
|
159
|
+
'=',
|
|
160
|
+
encrypt(JSON.stringify(upgradeSessionParams), campaign.cryptSecret),
|
|
161
|
+
].join('');
|
|
162
|
+
await this.sendRedirectorPage(ctx, target, redirector, {
|
|
163
|
+
...redirectorParams,
|
|
164
|
+
upgrade_url,
|
|
165
|
+
});
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
if (ctx.isBot) {
|
|
169
|
+
await this.sendCloakingSite(ctx, target);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const sessionCookie = this.getSessionCookie(ctx, campaign);
|
|
173
|
+
if (!sessionCookie) {
|
|
174
|
+
await this.sendCloakingSite(ctx, target);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (!this.checkSessionCookie(sessionCookie)) {
|
|
178
|
+
this.removeSessionCookie(ctx, campaign);
|
|
179
|
+
await this.sendOriginRedirect(ctx);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const session = await this.authorizeService.authSession({
|
|
183
|
+
campaignId: campaign.campaignId,
|
|
184
|
+
sessionId: sessionCookie,
|
|
185
|
+
});
|
|
186
|
+
if (!session) {
|
|
187
|
+
this.removeSessionCookie(ctx, campaign);
|
|
188
|
+
await this.sendOriginRedirect(ctx);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
this.persistSessionCookie(ctx, campaign, session);
|
|
192
|
+
if (!session.isUpgraded) {
|
|
193
|
+
await this.sendCloakingSite(ctx, target);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const proxy = await this.authorizeService.readProxy({
|
|
197
|
+
campaignId: campaign.campaignId,
|
|
198
|
+
proxyId: session.proxyId,
|
|
199
|
+
});
|
|
200
|
+
this.setState(ctx, 'proxy', proxy);
|
|
201
|
+
this.setState(ctx, 'session', session);
|
|
202
|
+
if (ctx.state.verbose) {
|
|
203
|
+
ctx.responseHeaders.merge({
|
|
204
|
+
'X-Famir-Session-Id': session.sessionId,
|
|
205
|
+
'X-Famir-Proxy-Id': proxy.proxyId,
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
await next();
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
dispatchWebSocket = {
|
|
212
|
+
transparent: async (ctx, campaign, target, next) => {
|
|
213
|
+
if (ctx.isBot) {
|
|
214
|
+
ctx.close();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
let session = null;
|
|
218
|
+
const sessionCookie = this.getSessionCookie(ctx, campaign);
|
|
219
|
+
if (sessionCookie && this.checkSessionCookie(sessionCookie)) {
|
|
220
|
+
session = await this.authorizeService.authSession({
|
|
221
|
+
campaignId: campaign.campaignId,
|
|
222
|
+
sessionId: sessionCookie,
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
if (!session) {
|
|
226
|
+
session = await this.authorizeService.createSession({
|
|
227
|
+
campaignId: campaign.campaignId,
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
const proxy = await this.authorizeService.readProxy({
|
|
231
|
+
campaignId: campaign.campaignId,
|
|
232
|
+
proxyId: session.proxyId,
|
|
233
|
+
});
|
|
234
|
+
this.setState(ctx, 'proxy', proxy);
|
|
235
|
+
this.setState(ctx, 'session', session);
|
|
236
|
+
await next();
|
|
237
|
+
},
|
|
238
|
+
landing: async (ctx, campaign, target, next) => {
|
|
239
|
+
if (ctx.isBot) {
|
|
240
|
+
ctx.close();
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const sessionCookie = this.getSessionCookie(ctx, campaign);
|
|
244
|
+
if (!sessionCookie || !this.checkSessionCookie(sessionCookie)) {
|
|
245
|
+
ctx.close();
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const session = await this.authorizeService.authSession({
|
|
249
|
+
campaignId: campaign.campaignId,
|
|
250
|
+
sessionId: sessionCookie,
|
|
251
|
+
});
|
|
252
|
+
if (!session || !session.isUpgraded) {
|
|
253
|
+
ctx.close();
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const proxy = await this.authorizeService.readProxy({
|
|
257
|
+
campaignId: campaign.campaignId,
|
|
258
|
+
proxyId: session.proxyId,
|
|
259
|
+
});
|
|
260
|
+
this.setState(ctx, 'proxy', proxy);
|
|
261
|
+
this.setState(ctx, 'session', session);
|
|
262
|
+
await next();
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
getSessionCookie(ctx, campaign) {
|
|
266
|
+
const cookies = ctx.requestHeaders.getCookies();
|
|
267
|
+
return cookies ? cookies[campaign.sessionCookieName] : undefined;
|
|
268
|
+
}
|
|
269
|
+
checkSessionCookie(value) {
|
|
270
|
+
return this.validator.guardSchema('reverse-authorize-session-cookie', value);
|
|
271
|
+
}
|
|
272
|
+
persistSessionCookie(ctx, campaign, session) {
|
|
273
|
+
if (ctx.type !== 'normal') {
|
|
274
|
+
throw new Error(`Only 'normal' context type allowed`);
|
|
275
|
+
}
|
|
276
|
+
const setCookies = ctx.responseHeaders.getSetCookies() ?? {};
|
|
277
|
+
setCookies[campaign.sessionCookieName] = {
|
|
278
|
+
value: session.sessionId,
|
|
279
|
+
domain: '.' + campaign.mirrorDomain,
|
|
280
|
+
path: '/',
|
|
281
|
+
httpOnly: true,
|
|
282
|
+
maxAge: Math.round(campaign.sessionExpire / 1000),
|
|
283
|
+
};
|
|
284
|
+
ctx.responseHeaders.setSetCookies(setCookies);
|
|
285
|
+
}
|
|
286
|
+
removeSessionCookie(ctx, campaign) {
|
|
287
|
+
if (ctx.type !== 'normal') {
|
|
288
|
+
throw new Error(`Only 'normal' context type allowed`);
|
|
289
|
+
}
|
|
290
|
+
const setCookies = ctx.responseHeaders.getSetCookies() ?? {};
|
|
291
|
+
setCookies[campaign.sessionCookieName] = {
|
|
292
|
+
value: '',
|
|
293
|
+
domain: '.' + campaign.mirrorDomain,
|
|
294
|
+
path: '/',
|
|
295
|
+
httpOnly: true,
|
|
296
|
+
maxAge: 0,
|
|
297
|
+
};
|
|
298
|
+
ctx.responseHeaders.setSetCookies(setCookies);
|
|
299
|
+
}
|
|
300
|
+
parseUpgradeSessionParams(ctx, campaign) {
|
|
301
|
+
try {
|
|
302
|
+
const urlParams = ctx.url.getQueryString();
|
|
303
|
+
const value = Object.values(urlParams)[0];
|
|
304
|
+
if (!(value && typeof value === 'string')) {
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
const data = JSON.parse(decrypt(value, campaign.cryptSecret));
|
|
308
|
+
this.validator.assertSchema('reverse-authorize-upgrade-session-params', data);
|
|
309
|
+
return data;
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
return null;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
parseRedirectorParams(ctx, campaign, redirector) {
|
|
316
|
+
try {
|
|
317
|
+
const urlParams = ctx.url.getQueryString();
|
|
318
|
+
const value = Object.values(urlParams)[0];
|
|
319
|
+
if (!(value && typeof value === 'string')) {
|
|
320
|
+
return redirector.isLoose ? {} : null;
|
|
321
|
+
}
|
|
322
|
+
const data = JSON.parse(decrypt(value, campaign.cryptSecret));
|
|
323
|
+
this.validator.assertSchema('reverse-authorize-redirector-params', data);
|
|
324
|
+
return redirector.checkParams(data) ? data : null;
|
|
325
|
+
}
|
|
326
|
+
catch {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
//# sourceMappingURL=authorize.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.controller.js","sourceRoot":"","sources":["../../../src/modules/authorize/authorize.controller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAe,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AASzE,OAAO,EAAE,kBAAkB,EAAuC,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAU,MAAM,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAa,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAa,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EACL,oBAAoB,EACpB,iBAAiB,GAGlB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAQzD,MAAM,OAAO,mBAAoB,SAAQ,cAAc;IA8BhC;IA1BrB,MAAM,CAAC,QAAQ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MAAM,CAAC;YACP,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EnabledFullTargetModel, FullCampaignModel, TargetAccessLevel } from '@famir/database';
|
|
2
|
+
import { HttpServerContext, HttpServerContextType, HttpServerNextFunction } from '@famir/http-server';
|
|
3
|
+
export declare const AUTHORIZE_CONTROLLER: unique symbol;
|
|
4
|
+
export declare const AUTHORIZE_SERVICE: unique symbol;
|
|
5
|
+
export type AuthorizeHandler = (ctx: HttpServerContext, campaign: FullCampaignModel, target: EnabledFullTargetModel, next: HttpServerNextFunction) => Promise<void>;
|
|
6
|
+
export type AuthorizeDispatchContextType = Record<HttpServerContextType, AuthorizeHandler>;
|
|
7
|
+
export type AuthorizeDispatchAccessLevel = Record<TargetAccessLevel, AuthorizeHandler>;
|
|
8
|
+
export interface ReadProxyData {
|
|
9
|
+
campaignId: string;
|
|
10
|
+
proxyId: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ReadRedirectorData {
|
|
13
|
+
campaignId: string;
|
|
14
|
+
redirectorId: string;
|
|
15
|
+
}
|
|
16
|
+
export interface FindLureData {
|
|
17
|
+
campaignId: string;
|
|
18
|
+
path: string;
|
|
19
|
+
}
|
|
20
|
+
export interface CreateSessionData {
|
|
21
|
+
campaignId: string;
|
|
22
|
+
}
|
|
23
|
+
export interface AuthSessionData {
|
|
24
|
+
campaignId: string;
|
|
25
|
+
sessionId: string;
|
|
26
|
+
}
|
|
27
|
+
export interface UpgradeSessionData {
|
|
28
|
+
campaignId: string;
|
|
29
|
+
lureId: string;
|
|
30
|
+
sessionId: string;
|
|
31
|
+
secret: string;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../../src/modules/authorize/authorize.ts"],"names":[],"mappings":"AAWA,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,qBAAqB,CAAC,CAAA;AAMjE,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { redirectorParamsSchema, upgradeSessionParamsSchema } from '@famir/database';
|
|
2
|
+
import { randomIdentSchema } from '@famir/validator';
|
|
3
|
+
export const authorizeSchemas = {
|
|
4
|
+
'reverse-authorize-session-cookie': randomIdentSchema,
|
|
5
|
+
'reverse-authorize-upgrade-session-params': upgradeSessionParamsSchema,
|
|
6
|
+
'reverse-authorize-redirector-params': redirectorParamsSchema,
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=authorize.schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.schemas.js","sourceRoot":"","sources":["../../../src/modules/authorize/authorize.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAA;AACpF,OAAO,EAAoB,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAMtE,MAAM,CAAC,MAAM,gBAAgB,GAAqB;IAChD,kCAAkC,EAAE,iBAAiB;IACrD,0CAA0C,EAAE,0BAA0B;IACtE,qCAAqC,EAAE,sBAAsB;CACrD,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DIContainer } from '@famir/common';
|
|
2
|
+
import { EnabledLureModel, EnabledProxyModel, FullRedirectorModel, LureRepository, ProxyRepository, RedirectorRepository, SessionModel, SessionRepository } from '@famir/database';
|
|
3
|
+
import { AuthSessionData, CreateSessionData, FindLureData, ReadProxyData, ReadRedirectorData, UpgradeSessionData } from './authorize.js';
|
|
4
|
+
export declare class AuthorizeService {
|
|
5
|
+
protected readonly proxyRepository: ProxyRepository;
|
|
6
|
+
protected readonly redirectorRepository: RedirectorRepository;
|
|
7
|
+
protected readonly lureRepository: LureRepository;
|
|
8
|
+
protected readonly sessionRepository: SessionRepository;
|
|
9
|
+
static register(container: DIContainer): void;
|
|
10
|
+
constructor(proxyRepository: ProxyRepository, redirectorRepository: RedirectorRepository, lureRepository: LureRepository, sessionRepository: SessionRepository);
|
|
11
|
+
readProxy(data: ReadProxyData): Promise<EnabledProxyModel>;
|
|
12
|
+
readRedirector(data: ReadRedirectorData): Promise<FullRedirectorModel>;
|
|
13
|
+
findLure(data: FindLureData): Promise<EnabledLureModel | null>;
|
|
14
|
+
createSession(data: CreateSessionData): Promise<SessionModel>;
|
|
15
|
+
authSession(data: AuthSessionData): Promise<SessionModel | null>;
|
|
16
|
+
upgradeSession(data: UpgradeSessionData): Promise<boolean>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { DatabaseError, LURE_REPOSITORY, LureModel, PROXY_REPOSITORY, ProxyModel, REDIRECTOR_REPOSITORY, SESSION_REPOSITORY, } from '@famir/database';
|
|
2
|
+
import { HttpServerError } from '@famir/http-server';
|
|
3
|
+
import { AUTHORIZE_SERVICE, } from './authorize.js';
|
|
4
|
+
export class AuthorizeService {
|
|
5
|
+
proxyRepository;
|
|
6
|
+
redirectorRepository;
|
|
7
|
+
lureRepository;
|
|
8
|
+
sessionRepository;
|
|
9
|
+
static register(container) {
|
|
10
|
+
container.registerSingleton(AUTHORIZE_SERVICE, (c) => new AuthorizeService(c.resolve(PROXY_REPOSITORY), c.resolve(REDIRECTOR_REPOSITORY), c.resolve(LURE_REPOSITORY), c.resolve(SESSION_REPOSITORY)));
|
|
11
|
+
}
|
|
12
|
+
constructor(proxyRepository, redirectorRepository, lureRepository, sessionRepository) {
|
|
13
|
+
this.proxyRepository = proxyRepository;
|
|
14
|
+
this.redirectorRepository = redirectorRepository;
|
|
15
|
+
this.lureRepository = lureRepository;
|
|
16
|
+
this.sessionRepository = sessionRepository;
|
|
17
|
+
}
|
|
18
|
+
async readProxy(data) {
|
|
19
|
+
const proxy = await this.proxyRepository.read(data.campaignId, data.proxyId);
|
|
20
|
+
if (!(proxy && ProxyModel.isEnabled(proxy))) {
|
|
21
|
+
throw new HttpServerError(`Service unavailable`, {
|
|
22
|
+
context: {
|
|
23
|
+
reason: `Read proxy failed`,
|
|
24
|
+
data,
|
|
25
|
+
},
|
|
26
|
+
code: 'SERVICE_UNAVAILABLE',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return proxy;
|
|
30
|
+
}
|
|
31
|
+
async readRedirector(data) {
|
|
32
|
+
const redirector = await this.redirectorRepository.readFull(data.campaignId, data.redirectorId);
|
|
33
|
+
if (!redirector) {
|
|
34
|
+
throw new HttpServerError(`Service unavailable`, {
|
|
35
|
+
context: {
|
|
36
|
+
reason: `Read redirector failed`,
|
|
37
|
+
data,
|
|
38
|
+
},
|
|
39
|
+
code: 'SERVICE_UNAVAILABLE',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return redirector;
|
|
43
|
+
}
|
|
44
|
+
async findLure(data) {
|
|
45
|
+
const lure = await this.lureRepository.find(data.campaignId, data.path);
|
|
46
|
+
if (!(lure && LureModel.isEnabled(lure))) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
return lure;
|
|
50
|
+
}
|
|
51
|
+
async createSession(data) {
|
|
52
|
+
try {
|
|
53
|
+
return await this.sessionRepository.create(data.campaignId);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
if (error instanceof DatabaseError) {
|
|
57
|
+
if (error.code === 'NOT_FOUND') {
|
|
58
|
+
throw new HttpServerError(`Service unavailable`, {
|
|
59
|
+
cause: error,
|
|
60
|
+
context: {
|
|
61
|
+
reason: `Create session failed`,
|
|
62
|
+
},
|
|
63
|
+
code: 'SERVICE_UNAVAILABLE',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async authSession(data) {
|
|
71
|
+
try {
|
|
72
|
+
return await this.sessionRepository.auth(data.campaignId, data.sessionId);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
if (error instanceof DatabaseError) {
|
|
76
|
+
if (error.code === 'NOT_FOUND') {
|
|
77
|
+
throw new HttpServerError(`Service unavailable`, {
|
|
78
|
+
cause: error,
|
|
79
|
+
context: {
|
|
80
|
+
reason: `Auth session failed`,
|
|
81
|
+
},
|
|
82
|
+
code: `SERVICE_UNAVAILABLE`,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else if (error.code === 'FORBIDDEN') {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async upgradeSession(data) {
|
|
93
|
+
try {
|
|
94
|
+
await this.sessionRepository.upgrade(data.campaignId, data.lureId, data.sessionId, data.secret);
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (error instanceof DatabaseError) {
|
|
99
|
+
if (error.code === 'NOT_FOUND') {
|
|
100
|
+
throw new HttpServerError(`Not found`, {
|
|
101
|
+
cause: error,
|
|
102
|
+
context: {
|
|
103
|
+
reason: `Upgrade session failed`,
|
|
104
|
+
},
|
|
105
|
+
code: `NOT_FOUND`,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
else if (error.code === 'FORBIDDEN') {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=authorize.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authorize.service.js","sourceRoot":"","sources":["../../../src/modules/authorize/authorize.service.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EAIb,eAAe,EACf,SAAS,EAET,gBAAgB,EAChB,UAAU,EAEV,qBAAqB,EAErB,kBAAkB,GAGnB,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,eAAe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CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/authorize/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA;AACzC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,wBAAwB,CAAA;AACtC,cAAc,wBAAwB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EnabledFullTargetModel, FullRedirectorModel } from '@famir/database';
|
|
2
|
+
import { HttpClientError } from '@famir/http-client';
|
|
3
|
+
import { HttpServerContext, HttpServerError, HttpServerRouter } from '@famir/http-server';
|
|
4
|
+
import { Logger } from '@famir/logger';
|
|
5
|
+
import { Templater } from '@famir/templater';
|
|
6
|
+
import { Validator } from '@famir/validator';
|
|
7
|
+
import { ReverseContextState } from './base.js';
|
|
8
|
+
export declare abstract class BaseController {
|
|
9
|
+
protected readonly validator: Validator;
|
|
10
|
+
protected readonly logger: Logger;
|
|
11
|
+
protected readonly templater: Templater;
|
|
12
|
+
protected readonly router: HttpServerRouter;
|
|
13
|
+
constructor(validator: Validator, logger: Logger, templater: Templater, router: HttpServerRouter);
|
|
14
|
+
protected getState<T extends ReverseContextState, K extends keyof T>(ctx: HttpServerContext, key: K): NonNullable<T[K]>;
|
|
15
|
+
protected setState<T extends ReverseContextState, K extends keyof T>(ctx: HttpServerContext, key: K, value: T[K]): void;
|
|
16
|
+
protected sendNoContent(ctx: HttpServerContext, status?: number): Promise<void>;
|
|
17
|
+
protected sendPreflightCors(ctx: HttpServerContext, status?: number): Promise<void>;
|
|
18
|
+
protected sendRedirectTo(ctx: HttpServerContext, url: string, status?: number): Promise<void>;
|
|
19
|
+
protected sendOriginRedirect(ctx: HttpServerContext): Promise<void>;
|
|
20
|
+
protected sendMainRedirect(ctx: HttpServerContext): Promise<void>;
|
|
21
|
+
protected sendMainPage(ctx: HttpServerContext, target: EnabledFullTargetModel): Promise<void>;
|
|
22
|
+
protected sendNotFoundPage(ctx: HttpServerContext, target: EnabledFullTargetModel): Promise<void>;
|
|
23
|
+
protected sendErrorPage(ctx: HttpServerContext, error: HttpServerError | HttpClientError, isHtml: boolean): Promise<void>;
|
|
24
|
+
protected sendFaviconIco(ctx: HttpServerContext, target: EnabledFullTargetModel): Promise<void>;
|
|
25
|
+
protected sendRobotsTxt(ctx: HttpServerContext, target: EnabledFullTargetModel): Promise<void>;
|
|
26
|
+
protected sendSitemapXml(ctx: HttpServerContext, target: EnabledFullTargetModel): Promise<void>;
|
|
27
|
+
protected sendRedirectorPage(ctx: HttpServerContext, target: EnabledFullTargetModel, redirector: FullRedirectorModel, data: object): Promise<void>;
|
|
28
|
+
protected sendCloakingSite(ctx: HttpServerContext, target: EnabledFullTargetModel): Promise<void>;
|
|
29
|
+
}
|