@qelos/integrator-next 4.0.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/LICENSE +20 -0
- package/README.md +256 -0
- package/dist/context.d.ts +55 -0
- package/dist/context.js +131 -0
- package/dist/context.js.map +1 -0
- package/dist/env-config.d.ts +28 -0
- package/dist/env-config.js +59 -0
- package/dist/env-config.js.map +1 -0
- package/dist/forward-headers.d.ts +7 -0
- package/dist/forward-headers.js +16 -0
- package/dist/forward-headers.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware.d.ts +68 -0
- package/dist/middleware.js +140 -0
- package/dist/middleware.js.map +1 -0
- package/dist/pages.d.ts +54 -0
- package/dist/pages.js +190 -0
- package/dist/pages.js.map +1 -0
- package/dist/route.d.ts +15 -0
- package/dist/route.js +21 -0
- package/dist/route.js.map +1 -0
- package/dist/sdk-factory.d.ts +20 -0
- package/dist/sdk-factory.js +90 -0
- package/dist/sdk-factory.js.map +1 -0
- package/dist/social-auth.d.ts +12 -0
- package/dist/social-auth.js +14 -0
- package/dist/social-auth.js.map +1 -0
- package/dist/types.d.ts +39 -0
- package/dist/types.js +12 -0
- package/dist/types.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { applySocialAuthCookiesToServerResponse } from '@qelos/sdk';
|
|
2
|
+
/**
|
|
3
|
+
* Runs {@link QelosSDK.authentication.socialCallback} for `requestUrl` and
|
|
4
|
+
* forwards session `Set-Cookie` headers to `res` (Next.js Pages `NextApiResponse`,
|
|
5
|
+
* App Route handlers using `NextResponse` should set cookies via the Response API
|
|
6
|
+
* instead — use the SDK helpers from `@qelos/sdk` directly there).
|
|
7
|
+
*/
|
|
8
|
+
export async function completeSocialAuthCallback(sdk, requestUrl, res) {
|
|
9
|
+
const result = await sdk.authentication.socialCallback(requestUrl);
|
|
10
|
+
applySocialAuthCookiesToServerResponse(res, result);
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
export { applySocialAuthCookiesToServerResponse, getSocialAuthSetCookieParts, parseSocialCallbackRefreshToken, } from '@qelos/sdk';
|
|
14
|
+
//# sourceMappingURL=social-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"social-auth.js","sourceRoot":"","sources":["../src/social-auth.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sCAAsC,EAAE,MAAM,YAAY,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,GAAa,EACb,UAAkB,EAClB,GAAgE;IAEhE,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;IACnE,sCAAsC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,OAAO,EACL,sCAAsC,EACtC,2BAA2B,EAC3B,+BAA+B,GAGhC,MAAM,YAAY,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type QelosSDK from '@qelos/sdk';
|
|
2
|
+
import type { IUser } from '@qelos/sdk/dist/authentication';
|
|
3
|
+
import type { IWorkspace } from '@qelos/sdk/workspaces';
|
|
4
|
+
import type { QelosSDKOptions } from '@qelos/sdk/types';
|
|
5
|
+
import type { QelosConfig, QelosContext, QelosTokenPair, ResolvedTokens } from '@qelos/global-types';
|
|
6
|
+
export type { QelosTokenPair, ResolvedTokens } from '@qelos/global-types';
|
|
7
|
+
export interface QelosNextConfig extends QelosConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Optional extra options merged into the per-request SDK instance.
|
|
10
|
+
*/
|
|
11
|
+
sdkOptions?: Partial<QelosSDKOptions>;
|
|
12
|
+
}
|
|
13
|
+
export interface TokenRefreshContext<TRefreshTarget = unknown> {
|
|
14
|
+
/**
|
|
15
|
+
* The transport-specific carrier for the refresh hook. For App Router edge
|
|
16
|
+
* middleware this is the outbound `NextResponse`; for Pages Router API
|
|
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.
|
|
21
|
+
*/
|
|
22
|
+
target: TRefreshTarget;
|
|
23
|
+
oldTokens: QelosTokenPair;
|
|
24
|
+
newTokens: ResolvedTokens;
|
|
25
|
+
sdk: QelosSDK;
|
|
26
|
+
}
|
|
27
|
+
export type TokenRefreshHook<TRefreshTarget = unknown> = (ctx: TokenRefreshContext<TRefreshTarget>) => void | Promise<void>;
|
|
28
|
+
export type QelosRequestContext = QelosContext<QelosSDK, IUser, IWorkspace>;
|
|
29
|
+
/**
|
|
30
|
+
* Header name used to forward the resolved user id from edge middleware to
|
|
31
|
+
* downstream App Router handlers. Handlers that want the full user object
|
|
32
|
+
* should call `getQelosContext()` from `@qelos/integrator-next/context`.
|
|
33
|
+
*/
|
|
34
|
+
export declare const QELOS_USER_HEADER = "x-qelos-user-id";
|
|
35
|
+
/**
|
|
36
|
+
* Header name used to forward the resolved workspace id from edge middleware
|
|
37
|
+
* to downstream App Router handlers.
|
|
38
|
+
*/
|
|
39
|
+
export declare const QELOS_WORKSPACE_HEADER = "x-qelos-workspace-id";
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Header name used to forward the resolved user id from edge middleware to
|
|
3
|
+
* downstream App Router handlers. Handlers that want the full user object
|
|
4
|
+
* should call `getQelosContext()` from `@qelos/integrator-next/context`.
|
|
5
|
+
*/
|
|
6
|
+
export const QELOS_USER_HEADER = 'x-qelos-user-id';
|
|
7
|
+
/**
|
|
8
|
+
* Header name used to forward the resolved workspace id from edge middleware
|
|
9
|
+
* to downstream App Router handlers.
|
|
10
|
+
*/
|
|
11
|
+
export const QELOS_WORKSPACE_HEADER = 'x-qelos-workspace-id';
|
|
12
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAyCA;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC;AAEnD;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,sBAAsB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qelos/integrator-next",
|
|
3
|
+
"version": "4.0.0",
|
|
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
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./middleware": {
|
|
16
|
+
"types": "./dist/middleware.d.ts",
|
|
17
|
+
"import": "./dist/middleware.js",
|
|
18
|
+
"require": "./dist/middleware.js",
|
|
19
|
+
"default": "./dist/middleware.js"
|
|
20
|
+
},
|
|
21
|
+
"./sdk-factory": {
|
|
22
|
+
"types": "./dist/sdk-factory.d.ts",
|
|
23
|
+
"import": "./dist/sdk-factory.js",
|
|
24
|
+
"require": "./dist/sdk-factory.js",
|
|
25
|
+
"default": "./dist/sdk-factory.js"
|
|
26
|
+
},
|
|
27
|
+
"./context": {
|
|
28
|
+
"types": "./dist/context.d.ts",
|
|
29
|
+
"import": "./dist/context.js",
|
|
30
|
+
"require": "./dist/context.js",
|
|
31
|
+
"default": "./dist/context.js"
|
|
32
|
+
},
|
|
33
|
+
"./pages": {
|
|
34
|
+
"types": "./dist/pages.d.ts",
|
|
35
|
+
"import": "./dist/pages.js",
|
|
36
|
+
"require": "./dist/pages.js",
|
|
37
|
+
"default": "./dist/pages.js"
|
|
38
|
+
},
|
|
39
|
+
"./route": {
|
|
40
|
+
"types": "./dist/route.d.ts",
|
|
41
|
+
"import": "./dist/route.js",
|
|
42
|
+
"require": "./dist/route.js",
|
|
43
|
+
"default": "./dist/route.js"
|
|
44
|
+
},
|
|
45
|
+
"./types": {
|
|
46
|
+
"types": "./dist/types.d.ts",
|
|
47
|
+
"import": "./dist/types.js",
|
|
48
|
+
"require": "./dist/types.js",
|
|
49
|
+
"default": "./dist/types.js"
|
|
50
|
+
},
|
|
51
|
+
"./package.json": "./package.json"
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist",
|
|
55
|
+
"README.md"
|
|
56
|
+
],
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"next": ">=13.4.0",
|
|
59
|
+
"react": ">=18.2.0"
|
|
60
|
+
},
|
|
61
|
+
"peerDependenciesMeta": {
|
|
62
|
+
"react": {
|
|
63
|
+
"optional": true
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"@qelos/global-types": "^4.0.0",
|
|
68
|
+
"@qelos/sdk": "^4.0.0"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@types/node": "^22.5.4",
|
|
72
|
+
"next": "^14.2.5",
|
|
73
|
+
"react": "^18.3.1",
|
|
74
|
+
"tsx": "^4.21.0",
|
|
75
|
+
"typescript": "^5.4.5"
|
|
76
|
+
},
|
|
77
|
+
"author": "David Meir-Levy <davidmeirlevy@gmail.com>",
|
|
78
|
+
"license": "MIT",
|
|
79
|
+
"publishConfig": {
|
|
80
|
+
"access": "public"
|
|
81
|
+
},
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": ">=18"
|
|
84
|
+
},
|
|
85
|
+
"scripts": {
|
|
86
|
+
"type-check": "tsc --noEmit",
|
|
87
|
+
"build": "tsc",
|
|
88
|
+
"pre-build": "tsc",
|
|
89
|
+
"test": "node --import tsx --test \"src/**/*.test.ts\""
|
|
90
|
+
}
|
|
91
|
+
}
|