@deverjak/tenantkit-next 0.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/LICENSE +21 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +35 -0
- package/package.json +33 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Chytré Digital
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NextResponse, type NextRequest } from 'next/server';
|
|
2
|
+
import type { CookieAdapter, CoreRuntime } from '@deverjak/tenantkit-kernel';
|
|
3
|
+
/** A writable `CookieAdapter` over `next/headers` — pass as `createSupabaseRuntime({ cookies: nextCookies })`. */
|
|
4
|
+
export declare function nextCookies(): Promise<CookieAdapter>;
|
|
5
|
+
/**
|
|
6
|
+
* The middleware (`proxy.ts`) glue: rotate the auth cookie on every request via the SessionStore port.
|
|
7
|
+
* Compose with next-intl's middleware as in the reference apps.
|
|
8
|
+
*/
|
|
9
|
+
export declare function createProxyMiddleware(runtime: CoreRuntime): (request: NextRequest) => Promise<NextResponse>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @tenantkit/next — the Next.js binding (docs/14 §5, the "second coupling axis"). The kernel speaks Web
|
|
3
|
+
* Request/Response; this package supplies the Next-specific seams: the cookie adapter (next/headers) and the
|
|
4
|
+
* session-refresh middleware. Swap this for @tenantkit/hono or @tenantkit/remix and the kernel is unchanged.
|
|
5
|
+
*/
|
|
6
|
+
import { cookies } from 'next/headers';
|
|
7
|
+
import { NextResponse } from 'next/server';
|
|
8
|
+
/** A writable `CookieAdapter` over `next/headers` — pass as `createSupabaseRuntime({ cookies: nextCookies })`. */
|
|
9
|
+
export async function nextCookies() {
|
|
10
|
+
const store = await cookies();
|
|
11
|
+
return {
|
|
12
|
+
getAll: () => store.getAll().map((c) => ({ name: c.name, value: c.value })),
|
|
13
|
+
setAll: (toSet) => {
|
|
14
|
+
for (const c of toSet) {
|
|
15
|
+
try {
|
|
16
|
+
store.set(c.name, c.value, c.options);
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
/* called from a Server Component render — ignored; the middleware below does the real refresh */
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The middleware (`proxy.ts`) glue: rotate the auth cookie on every request via the SessionStore port.
|
|
27
|
+
* Compose with next-intl's middleware as in the reference apps.
|
|
28
|
+
*/
|
|
29
|
+
export function createProxyMiddleware(runtime) {
|
|
30
|
+
return async function proxy(request) {
|
|
31
|
+
const response = NextResponse.next({ request });
|
|
32
|
+
await runtime.sessions.refresh(request, response);
|
|
33
|
+
return response;
|
|
34
|
+
};
|
|
35
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@deverjak/tenantkit-next",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Next.js binding for the @deverjak/tenantkit-kernel: the cookie adapter and the session-refresh middleware glue. The framework-specific seam.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"dist"
|
|
15
|
+
],
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public"
|
|
18
|
+
},
|
|
19
|
+
"peerDependencies": {
|
|
20
|
+
"next": ">=15",
|
|
21
|
+
"@deverjak/tenantkit-kernel": "0.2.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"typescript": "^5.9.3",
|
|
25
|
+
"next": "^16.2.9",
|
|
26
|
+
"react": "^19.2.7",
|
|
27
|
+
"@types/react": "^19.2.0"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"typecheck": "tsc --noEmit",
|
|
31
|
+
"build": "tsc -p tsconfig.json --outDir dist --declaration"
|
|
32
|
+
}
|
|
33
|
+
}
|