@qelos/integrator-next 4.0.1 → 4.1.0
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/context.d.ts +5 -11
- package/dist/context.js +63 -43
- package/dist/context.js.map +1 -1
- package/dist/cookies.d.ts +19 -0
- package/dist/cookies.js +39 -0
- package/dist/cookies.js.map +1 -0
- package/dist/env-config.d.ts +3 -3
- package/dist/env-config.js +6 -7
- package/dist/env-config.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/me-client.d.ts +15 -0
- package/dist/me-client.js +35 -0
- package/dist/me-client.js.map +1 -0
- package/dist/middleware.d.ts +10 -34
- package/dist/middleware.js +75 -80
- package/dist/middleware.js.map +1 -1
- package/dist/pages.d.ts +5 -9
- package/dist/pages.js +61 -98
- package/dist/pages.js.map +1 -1
- package/dist/proxy-target.d.ts +17 -0
- package/dist/proxy-target.js +26 -0
- package/dist/proxy-target.js.map +1 -0
- package/dist/runtime/api-proxy.d.ts +16 -0
- package/dist/runtime/api-proxy.js +90 -0
- package/dist/runtime/api-proxy.js.map +1 -0
- package/dist/sdk-factory.d.ts +13 -16
- package/dist/sdk-factory.js +29 -79
- package/dist/sdk-factory.js.map +1 -1
- package/dist/types.d.ts +28 -16
- package/dist/types.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import { rewriteSetCookieDomain } from '../cookies';
|
|
3
|
+
import { resolveQelosProxyTarget } from '../proxy-target';
|
|
4
|
+
const HOP_BY_HOP = new Set([
|
|
5
|
+
'connection',
|
|
6
|
+
'keep-alive',
|
|
7
|
+
'proxy-authenticate',
|
|
8
|
+
'proxy-authorization',
|
|
9
|
+
'te',
|
|
10
|
+
'trailers',
|
|
11
|
+
'transfer-encoding',
|
|
12
|
+
'upgrade',
|
|
13
|
+
]);
|
|
14
|
+
function buildUpstreamHeaders(req) {
|
|
15
|
+
const out = new Headers();
|
|
16
|
+
req.headers.forEach((value, key) => {
|
|
17
|
+
const lk = key.toLowerCase();
|
|
18
|
+
if (HOP_BY_HOP.has(lk))
|
|
19
|
+
return;
|
|
20
|
+
if (lk === 'host')
|
|
21
|
+
return;
|
|
22
|
+
out.append(key, value);
|
|
23
|
+
});
|
|
24
|
+
return out;
|
|
25
|
+
}
|
|
26
|
+
async function proxyRequest(req, config) {
|
|
27
|
+
const base = resolveQelosProxyTarget(config);
|
|
28
|
+
if (!base) {
|
|
29
|
+
return NextResponse.json({
|
|
30
|
+
error: '[@qelos/integrator-next] Qelos API proxy is not configured. Set appUrl (or NEXT_QELOS_PROXY_TARGET / QELOS_IP / QELOS_API_IP in development).',
|
|
31
|
+
}, { status: 503 });
|
|
32
|
+
}
|
|
33
|
+
const pathWithSearch = req.nextUrl.pathname + req.nextUrl.search;
|
|
34
|
+
const targetUrl = `${base.replace(/\/+$/, '')}${pathWithSearch}`;
|
|
35
|
+
const originalHost = req.headers.get('host');
|
|
36
|
+
const init = {
|
|
37
|
+
method: req.method,
|
|
38
|
+
headers: buildUpstreamHeaders(req),
|
|
39
|
+
redirect: 'manual',
|
|
40
|
+
};
|
|
41
|
+
if (req.method !== 'GET' && req.method !== 'HEAD') {
|
|
42
|
+
init.body = req.body;
|
|
43
|
+
init.duplex = 'half';
|
|
44
|
+
}
|
|
45
|
+
let upstream;
|
|
46
|
+
try {
|
|
47
|
+
upstream = await fetch(targetUrl, init);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return NextResponse.json({ error: 'upstream fetch failed' }, { status: 502 });
|
|
51
|
+
}
|
|
52
|
+
const outHeaders = new Headers();
|
|
53
|
+
upstream.headers.forEach((value, key) => {
|
|
54
|
+
const lk = key.toLowerCase();
|
|
55
|
+
if (lk === 'set-cookie')
|
|
56
|
+
return;
|
|
57
|
+
if (HOP_BY_HOP.has(lk))
|
|
58
|
+
return;
|
|
59
|
+
outHeaders.append(key, value);
|
|
60
|
+
});
|
|
61
|
+
const rawCookies = upstream.headers.getSetCookie?.() ?? [];
|
|
62
|
+
for (const c of rawCookies) {
|
|
63
|
+
outHeaders.append('set-cookie', rewriteSetCookieDomain(c, originalHost ?? undefined));
|
|
64
|
+
}
|
|
65
|
+
return new Response(upstream.body, {
|
|
66
|
+
status: upstream.status,
|
|
67
|
+
statusText: upstream.statusText,
|
|
68
|
+
headers: outHeaders,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Handlers for a catch-all App Router route (e.g. `app/api/[...qelos]/route.ts`)
|
|
73
|
+
* that reverse-proxies every `/api/**` call to Qelos with `Set-Cookie` domain
|
|
74
|
+
* rewriting. Use `export const runtime = 'nodejs'`.
|
|
75
|
+
*/
|
|
76
|
+
export function createQelosApiProxyHandlers(config) {
|
|
77
|
+
async function handle(req) {
|
|
78
|
+
return proxyRequest(req, config);
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
runtime: 'nodejs',
|
|
82
|
+
GET: handle,
|
|
83
|
+
POST: handle,
|
|
84
|
+
PUT: handle,
|
|
85
|
+
PATCH: handle,
|
|
86
|
+
DELETE: handle,
|
|
87
|
+
OPTIONS: handle,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=api-proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-proxy.js","sourceRoot":"","sources":["../../src/runtime/api-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iBAAiB,CAAC;AAG1D,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,YAAY;IACZ,YAAY;IACZ,oBAAoB;IACpB,qBAAqB;IACrB,IAAI;IACJ,UAAU;IACV,m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,UAAU,2BAA2B,CAAC,MAAuB;IACjE,KAAK,UAAU,MAAM,CAAC,GAAgB;QACpC,OAAO,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACnC,CAAC;IAED,OAAO;QACL,OAAO,EAAE,QAAiB;QAC1B,GAAG,EAAE,MAAM;QACX,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,MAAM;QACX,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,MAAM;KAChB,CAAC;AACJ,CAAC"}
|
package/dist/sdk-factory.d.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { QelosNextConfig
|
|
3
|
-
export interface CreateSdkParams
|
|
1
|
+
import type QelosSDKInstance from '@qelos/sdk';
|
|
2
|
+
import type { QelosNextConfig } from './types';
|
|
3
|
+
export interface CreateSdkParams {
|
|
4
4
|
config: QelosNextConfig;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* the SDK has been used.
|
|
6
|
+
* Live header source so every SDK call forwards the current request cookies
|
|
7
|
+
* and `Authorization` (no mutable token state).
|
|
9
8
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
refreshTarget: TRefreshTarget;
|
|
18
|
-
onTokenRefresh?: TokenRefreshHook<TRefreshTarget>;
|
|
9
|
+
getHeaders: () => {
|
|
10
|
+
cookie?: string;
|
|
11
|
+
authorization?: string;
|
|
12
|
+
} | Promise<{
|
|
13
|
+
cookie?: string;
|
|
14
|
+
authorization?: string;
|
|
15
|
+
}>;
|
|
19
16
|
}
|
|
20
|
-
export declare function createRequestSdk
|
|
17
|
+
export declare function createRequestSdk({ config, getHeaders, }: CreateSdkParams): QelosSDKInstance;
|
package/dist/sdk-factory.js
CHANGED
|
@@ -1,90 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
'
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
let refreshInFlight = null;
|
|
11
|
-
const baseOptions = config.sdkOptions || {};
|
|
12
|
-
async function performRefresh() {
|
|
13
|
-
if (!tokens.refreshToken && !tokens.accessToken) {
|
|
14
|
-
throw new Error('no refresh token available');
|
|
15
|
-
}
|
|
16
|
-
const previous = {
|
|
17
|
-
accessToken: tokens.accessToken,
|
|
18
|
-
refreshToken: tokens.refreshToken,
|
|
19
|
-
};
|
|
20
|
-
let refreshed;
|
|
21
|
-
if (tokens.refreshToken) {
|
|
22
|
-
const result = await sdk.authentication.refreshToken(tokens.refreshToken);
|
|
23
|
-
refreshed = {
|
|
24
|
-
accessToken: result.payload.token,
|
|
25
|
-
refreshToken: result.payload.refreshToken,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
const result = await sdk.authentication.refreshCookieToken(tokens.accessToken);
|
|
30
|
-
refreshed = {
|
|
31
|
-
accessToken: result.payload.cookieToken,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
tokens.accessToken = refreshed.accessToken;
|
|
35
|
-
tokens.refreshToken = refreshed.refreshToken;
|
|
36
|
-
if (onTokenRefresh) {
|
|
37
|
-
await onTokenRefresh({
|
|
38
|
-
target: refreshTarget,
|
|
39
|
-
oldTokens: previous,
|
|
40
|
-
newTokens: refreshed,
|
|
41
|
-
sdk,
|
|
42
|
-
});
|
|
43
|
-
}
|
|
1
|
+
import sdkModule from '@qelos/sdk';
|
|
2
|
+
function resolveQelosSdkConstructor() {
|
|
3
|
+
const top = sdkModule;
|
|
4
|
+
if (typeof top === 'function') {
|
|
5
|
+
return top;
|
|
6
|
+
}
|
|
7
|
+
const once = top.default;
|
|
8
|
+
if (typeof once === 'function') {
|
|
9
|
+
return once;
|
|
44
10
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
refreshInFlight = null;
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return refreshInFlight;
|
|
11
|
+
const twice = once?.default;
|
|
12
|
+
if (typeof twice === 'function') {
|
|
13
|
+
return twice;
|
|
52
14
|
}
|
|
15
|
+
throw new Error('[@qelos/integrator-next] Could not resolve QelosSDK constructor from @qelos/sdk');
|
|
16
|
+
}
|
|
17
|
+
const QelosSDK = resolveQelosSdkConstructor();
|
|
18
|
+
export function createRequestSdk({ config, getHeaders, }) {
|
|
19
|
+
const baseOptions = config.sdkOptions || {};
|
|
53
20
|
const options = {
|
|
54
21
|
appUrl: config.appUrl,
|
|
55
|
-
fetch: globalThis.fetch
|
|
56
|
-
forceRefresh: !config.apiToken,
|
|
22
|
+
fetch: globalThis.fetch,
|
|
57
23
|
...baseOptions,
|
|
58
24
|
};
|
|
59
25
|
if (config.apiToken) {
|
|
60
26
|
options.apiToken = config.apiToken;
|
|
27
|
+
return new QelosSDK(options);
|
|
61
28
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
return headers;
|
|
73
|
-
}
|
|
74
|
-
if (forceRefresh && (tokens.refreshToken || tokens.accessToken)) {
|
|
75
|
-
await ensureRefresh();
|
|
76
|
-
}
|
|
77
|
-
const token = sdk?.authentication?.accessToken || tokens.accessToken;
|
|
78
|
-
if (token) {
|
|
79
|
-
headers.authorization = 'Bearer ' + token;
|
|
80
|
-
}
|
|
81
|
-
return headers;
|
|
82
|
-
};
|
|
83
|
-
options.onFailedRefreshToken = async () => {
|
|
84
|
-
await ensureRefresh();
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
sdk = new QelosSDK(options);
|
|
88
|
-
return sdk;
|
|
29
|
+
options.extraHeaders = async () => {
|
|
30
|
+
const h = await getHeaders();
|
|
31
|
+
const headers = {};
|
|
32
|
+
if (h.cookie)
|
|
33
|
+
headers.cookie = h.cookie;
|
|
34
|
+
if (h.authorization)
|
|
35
|
+
headers.authorization = h.authorization;
|
|
36
|
+
return headers;
|
|
37
|
+
};
|
|
38
|
+
return new QelosSDK(options);
|
|
89
39
|
}
|
|
90
40
|
//# sourceMappingURL=sdk-factory.js.map
|
package/dist/sdk-factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-factory.js","sourceRoot":"","sources":["../src/sdk-factory.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"sdk-factory.js","sourceRoot":"","sources":["../src/sdk-factory.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAOnC,SAAS,0BAA0B;IACjC,MAAM,GAAG,GAAG,SAAoB,CAAC;IACjC,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;QAC9B,OAAO,GAAmB,CAAC;IAC7B,CAAC;IACD,MAAM,IAAI,GAAI,GAA6B,CAAC,OAAO,CAAC;IACpD,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,OAAO,IAAoB,CAAC;IAC9B,CAAC;IACD,MAAM,KAAK,GAAI,IAA0C,EAAE,OAAO,CAAC;IACnE,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,OAAO,KAAqB,CAAC;IAC/B,CAAC;IACD,MAAM,IAAI,KAAK,CACb,iFAAiF,CAClF,CAAC;AACJ,CAAC;AAED,MAAM,QAAQ,GAAG,0BAA0B,EAAE,CAAC;AAa9C,MAAM,UAAU,gBAAgB,CAAC,EAC/B,MAAM,EACN,UAAU,GACM;IAChB,MAAM,WAAW,GAA6B,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC;IAEtE,MAAM,OAAO,GAAoB;QAC/B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,KAAK,EAAE,UAAU,CAAC,KAA6B;QAC/C,GAAG,WAAW;KACf,CAAC;IAEF,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;QACnC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,CAAC,YAAY,GAAG,KAAK,IAAI,EAAE;QAChC,MAAM,CAAC,GAAG,MAAM,UAAU,EAAE,CAAC;QAC7B,MAAM,OAAO,GAA2B,EAAE,CAAC;QAC3C,IAAI,CAAC,CAAC,MAAM;YAAE,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QACxC,IAAI,CAAC,CAAC,aAAa;YAAE,OAAO,CAAC,aAAa,GAAG,CAAC,CAAC,aAAa,CAAC;QAC7D,OAAO,OAAO,CAAC;IACjB,CAAC,CAAC;IAEF,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -2,30 +2,42 @@ import type QelosSDK from '@qelos/sdk';
|
|
|
2
2
|
import type { IUser } from '@qelos/sdk/dist/authentication';
|
|
3
3
|
import type { IWorkspace } from '@qelos/sdk/workspaces';
|
|
4
4
|
import type { QelosSDKOptions } from '@qelos/sdk/types';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export interface QelosNextConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Base URL of the Qelos backend (e.g. https://yourdomain.com).
|
|
8
|
+
*/
|
|
9
|
+
appUrl: string;
|
|
10
|
+
/**
|
|
11
|
+
* Static API token used for service-to-service calls. When provided, no
|
|
12
|
+
* cookie-based `/api/me` identification is required for anonymous access.
|
|
13
|
+
*/
|
|
14
|
+
apiToken?: string;
|
|
15
|
+
/**
|
|
16
|
+
* If true, the request is rejected (401) when the user cannot be resolved.
|
|
17
|
+
* Defaults to `false` — anonymous requests pass through with `user = null`.
|
|
18
|
+
*/
|
|
19
|
+
requireAuth?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Skip the middleware / resolver entirely for requests matching any of these
|
|
22
|
+
* path prefixes. Useful for `/_next`, `/favicon.ico`, `/health`, etc.
|
|
23
|
+
*/
|
|
24
|
+
skipPaths?: string[];
|
|
8
25
|
/**
|
|
9
26
|
* Optional extra options merged into the per-request SDK instance.
|
|
10
27
|
*/
|
|
11
28
|
sdkOptions?: Partial<QelosSDKOptions>;
|
|
12
|
-
}
|
|
13
|
-
export interface TokenRefreshContext<TRefreshTarget = unknown> {
|
|
14
29
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* routes it is the `NextApiResponse`; for `getServerSideProps` it is the
|
|
18
|
-
* raw `ServerResponse`. App Router server components / route handlers do
|
|
19
|
-
* not call this hook because cookies cannot be set after the response has
|
|
20
|
-
* started — the refreshed tokens are only mutated on the in-memory pair.
|
|
30
|
+
* When `false` (default), Edge middleware prepends `/api/` to `skipPaths` so
|
|
31
|
+
* the catch-all BFF proxy route is not shadowed by the `/api/me` probe.
|
|
21
32
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
33
|
+
disableProxy?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface QelosRequestContext {
|
|
36
|
+
user: IUser | null;
|
|
37
|
+
workspace: IWorkspace | null;
|
|
38
|
+
workspaces: IWorkspace[];
|
|
25
39
|
sdk: QelosSDK;
|
|
26
40
|
}
|
|
27
|
-
export type TokenRefreshHook<TRefreshTarget = unknown> = (ctx: TokenRefreshContext<TRefreshTarget>) => void | Promise<void>;
|
|
28
|
-
export type QelosRequestContext = QelosContext<QelosSDK, IUser, IWorkspace>;
|
|
29
41
|
/**
|
|
30
42
|
* Header name used to forward the resolved user id from edge middleware to
|
|
31
43
|
* downstream App Router handlers. Handlers that want the full user object
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AA2CA;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAAsB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qelos/integrator-next",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Qelos integrator middleware for Next.js (App Router and Pages Router): identifies the user and workspace via the Qelos SDK before the application's own handler runs.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@qelos/sdk": "4.
|
|
73
|
+
"@qelos/sdk": "4.1.0"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/node": "^22.5.4",
|