@qelos/integrator-nest 4.0.1 → 4.1.1
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/cookies.d.ts +19 -0
- package/dist/cookies.js +43 -0
- package/dist/cookies.js.map +1 -0
- package/dist/cookies.test.d.ts +1 -0
- package/dist/cookies.test.js +76 -0
- package/dist/cookies.test.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/middleware.js +71 -31
- package/dist/middleware.js.map +1 -1
- package/dist/module-options.d.ts +3 -0
- package/dist/module-options.js +21 -2
- package/dist/module-options.js.map +1 -1
- package/dist/module.d.ts +6 -3
- package/dist/module.js +38 -4
- package/dist/module.js.map +1 -1
- package/dist/proxy-target.d.ts +17 -0
- package/dist/proxy-target.js +29 -0
- package/dist/proxy-target.js.map +1 -0
- package/dist/proxy-target.test.d.ts +1 -0
- package/dist/proxy-target.test.js +86 -0
- package/dist/proxy-target.test.js.map +1 -0
- package/dist/proxy.middleware.d.ts +7 -0
- package/dist/proxy.middleware.js +197 -0
- package/dist/proxy.middleware.js.map +1 -0
- package/dist/request-utils.d.ts +2 -6
- package/dist/request-utils.js +1 -86
- package/dist/request-utils.js.map +1 -1
- package/dist/sdk-factory.d.ts +2 -10
- package/dist/sdk-factory.js +19 -77
- package/dist/sdk-factory.js.map +1 -1
- package/dist/types.d.ts +13 -41
- package/package.json +2 -2
package/dist/types.d.ts
CHANGED
|
@@ -2,14 +2,6 @@ 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
|
-
export interface QelosTokenPair {
|
|
6
|
-
accessToken?: string;
|
|
7
|
-
refreshToken?: string;
|
|
8
|
-
}
|
|
9
|
-
export interface ResolvedTokens {
|
|
10
|
-
accessToken: string;
|
|
11
|
-
refreshToken?: string;
|
|
12
|
-
}
|
|
13
5
|
/**
|
|
14
6
|
* A request-like object. NestJS can run on either Express or Fastify, so we
|
|
15
7
|
* type the bits we touch generically and feature-detect at runtime.
|
|
@@ -17,8 +9,8 @@ export interface ResolvedTokens {
|
|
|
17
9
|
export interface AnyRequest {
|
|
18
10
|
url?: string;
|
|
19
11
|
path?: string;
|
|
12
|
+
method?: string;
|
|
20
13
|
headers: Record<string, string | string[] | undefined>;
|
|
21
|
-
cookies?: Record<string, string | undefined>;
|
|
22
14
|
qelos?: QelosRequestContext;
|
|
23
15
|
[key: string]: unknown;
|
|
24
16
|
}
|
|
@@ -26,8 +18,6 @@ export interface AnyRequest {
|
|
|
26
18
|
* A response-like object (Express `Response` or Fastify `FastifyReply`).
|
|
27
19
|
*/
|
|
28
20
|
export interface AnyResponse {
|
|
29
|
-
cookie?: (name: string, value: string, options?: Record<string, unknown>) => unknown;
|
|
30
|
-
setCookie?: (name: string, value: string, options?: Record<string, unknown>) => unknown;
|
|
31
21
|
setHeader?: (name: string, value: string | string[]) => unknown;
|
|
32
22
|
header?: (name: string, value: string | string[]) => unknown;
|
|
33
23
|
getHeader?: (name: string) => string | string[] | number | undefined;
|
|
@@ -40,17 +30,9 @@ export interface QelosNestConfig {
|
|
|
40
30
|
appUrl: string;
|
|
41
31
|
/**
|
|
42
32
|
* Static API token used for service-to-service calls. When provided, no
|
|
43
|
-
* cookie
|
|
33
|
+
* cookie-based authentication is performed.
|
|
44
34
|
*/
|
|
45
35
|
apiToken?: string;
|
|
46
|
-
/**
|
|
47
|
-
* Cookie name carrying the Qelos access token. Defaults to `q_access_token`.
|
|
48
|
-
*/
|
|
49
|
-
accessTokenCookie?: string;
|
|
50
|
-
/**
|
|
51
|
-
* Cookie name carrying the Qelos refresh token. Defaults to `q_refresh_token`.
|
|
52
|
-
*/
|
|
53
|
-
refreshTokenCookie?: string;
|
|
54
36
|
/**
|
|
55
37
|
* If true, the middleware short-circuits with 401 when the user cannot be
|
|
56
38
|
* resolved. Defaults to `false` — anonymous requests pass through with
|
|
@@ -65,6 +47,11 @@ export interface QelosNestConfig {
|
|
|
65
47
|
* these prefixes. Useful for `/health`, `/api/_auth`, etc.
|
|
66
48
|
*/
|
|
67
49
|
skipPaths?: string[];
|
|
50
|
+
/**
|
|
51
|
+
* If true, the catch-all `/api/**` proxy middleware is not registered.
|
|
52
|
+
* Defaults to `false`.
|
|
53
|
+
*/
|
|
54
|
+
disableProxy?: boolean;
|
|
68
55
|
/**
|
|
69
56
|
* Optional extra options merged into the per-request SDK instance.
|
|
70
57
|
*/
|
|
@@ -75,14 +62,6 @@ export type WorkspaceResolver = (params: {
|
|
|
75
62
|
user: IUser;
|
|
76
63
|
workspaces: IWorkspace[];
|
|
77
64
|
}) => IWorkspace | null | Promise<IWorkspace | null>;
|
|
78
|
-
export interface TokenRefreshContext {
|
|
79
|
-
request: AnyRequest;
|
|
80
|
-
response: AnyResponse;
|
|
81
|
-
oldTokens: QelosTokenPair;
|
|
82
|
-
newTokens: ResolvedTokens;
|
|
83
|
-
sdk: QelosSDK;
|
|
84
|
-
}
|
|
85
|
-
export type TokenRefreshHook = (ctx: TokenRefreshContext) => void | Promise<void>;
|
|
86
65
|
export interface QelosRequestContext {
|
|
87
66
|
/**
|
|
88
67
|
* The authenticated user, or `null` when anonymous.
|
|
@@ -98,25 +77,18 @@ export interface QelosRequestContext {
|
|
|
98
77
|
*/
|
|
99
78
|
workspaces: IWorkspace[];
|
|
100
79
|
/**
|
|
101
|
-
* SDK instance bound to the current request's
|
|
80
|
+
* SDK instance bound to the current request's cookies. `extraHeaders`
|
|
81
|
+
* re-reads cookies live on each call, so cookie rotations applied by the
|
|
82
|
+
* middleware are picked up automatically.
|
|
102
83
|
*/
|
|
103
84
|
sdk: QelosSDK;
|
|
104
|
-
/**
|
|
105
|
-
* Tokens read from the request. Mutated in place when a refresh occurs so
|
|
106
|
-
* later code can read the current pair.
|
|
107
|
-
*/
|
|
108
|
-
tokens: QelosTokenPair;
|
|
109
85
|
}
|
|
110
86
|
export interface QelosModuleOptions {
|
|
111
87
|
config: QelosNestConfig;
|
|
112
88
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
|
|
116
|
-
onTokenRefresh?: TokenRefreshHook;
|
|
117
|
-
/**
|
|
118
|
-
* Resolve the active workspace for a request. Defaults to picking the first
|
|
119
|
-
* workspace returned from `sdk.workspaces.getList()`.
|
|
89
|
+
* Resolve the active workspace for a request. Defaults to whatever
|
|
90
|
+
* `/api/me` reports on `user.workspace` (the user's currently activated
|
|
91
|
+
* workspace, or `null` when none is active).
|
|
120
92
|
*/
|
|
121
93
|
resolveWorkspace?: WorkspaceResolver;
|
|
122
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qelos/integrator-nest",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "NestJS module that identifies the Qelos user and active workspace before your route handlers run",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@qelos/sdk": "4.
|
|
64
|
+
"@qelos/sdk": "4.1.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@nestjs/common": "^10.4.5",
|