@tidecloak/nextjs 0.9.11

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 ADDED
@@ -0,0 +1,334 @@
1
+ Tide Community Open Code License
2
+
3
+ Preamble:
4
+ The Tide Community Open Code License is a copyright License for
5
+ software and other kinds of works designed to encourage the adoption
6
+ of the Tide Protocol. The aim of the Tide Protocol is to be the technological
7
+ infrastructure of a true zero-trust paradigm, addressing the data-breach
8
+ protection needs of platform vendors and their customers, the
9
+ self-sovereign authority needs of online users, and replace the reliance
10
+ on blind trust with proofs.
11
+
12
+ To that end, the Tide Community Open Code License gives you the
13
+ freedom to modify and distribute copies of software and other works
14
+ for free, or for a fee, as long as you do so in accordance with these
15
+ terms and the software adopts the Tide Protocol in full.
16
+
17
+ License Terms
18
+ Version: 2
19
+ Date of last revision: 1 December 2022
20
+
21
+ 1 Acceptance of these terms
22
+ (a) These terms are between the copyright holder (“we”, “us” and
23
+ “our”) identified in the notice embedded in or provided with
24
+ the source code, technical documentation or other material
25
+ relating to the Tide Foundation Limited’s (ACN 630 011 371)
26
+ (“Tide”) data decryption and key management platform
27
+ known as the “Tide Protocol” (“Tide Protocol”) and with which
28
+ these terms are packaged (“Materials”) and the person or
29
+ entity (“you” and “your”) accessing and/or using the Materials.
30
+ (b) By using, modifying or publishing the Materials or any Modified
31
+ Materials (as defined in clause 2(c) below), you agree to be
32
+ bound by these terms. If you are doing any of the foregoing in
33
+ the context of your employment with your employer or on behalf
34
+ of another entity, you are agreeing to be bound by these terms
35
+ on behalf of that employer or other entity and you represent
36
+ and warrant that you have the authority of that employer or
37
+ other entity to enter into these terms on their behalf. In such
38
+ circumstances, each reference in these terms “you” or “your”
39
+ includes that employer or other entity.
40
+ (c) These terms will remain in effect until terminated under
41
+ clause 9.
42
+
43
+ 2 Intellectual property rights
44
+ (a) In these terms, “Intellectual Property Rights” means all
45
+ intellectual property rights of whatever nature throughout the
46
+ world, including all rights conferred under statute, common
47
+ law or equity, whether existing now or at any time in the
48
+ future, including all rights in and to any patents, patent
49
+ applications, business names, trade names, domain names, trade
50
+ marks, copyright, trade secrets, circuit layout rights,
51
+ designs, confidential information, know-how, technical
52
+ information, data or developments. All of our Intellectual
53
+ Property Rights are protected by the laws in force in
54
+ Australia from time to time.
55
+ (b) You acknowledge and agree that we (or our licensors) retain all
56
+ right, title, and interest (including all Intellectual Property
57
+ Rights) in and to the Materials, and nothing you do with or in
58
+ relation to the Materials will transfer any right, title or
59
+ interest (including Intellectual Property Rights) to you or
60
+ License or otherwise permit you to exercise any Intellectual
61
+ Property Rights except as expressly granted under these terms.
62
+ (c) In these terms, “Modified Materials” means any work based on
63
+ one or more of the Materials, including a revision,
64
+ modification, adaptation, subset, addition, enhancement,
65
+ improvement, combination, translation, abridgment,
66
+ condensation, expansion, collection, compilation or any other
67
+ form in which such Materials may be recast, transformed or
68
+ adapted or any other new material derived from the Materials.
69
+
70
+ 3 Your License to the Materials
71
+ (a) Subject to paragraph (c) below and your compliance with these
72
+ terms, we grant you a limited, non-exclusive,
73
+ non-sub-licensable, revocable, worldwide, royalty free License
74
+ for the term of these terms to access, use, copy, modify,
75
+ adapt, distribute, publish and exploit the Materials, provided
76
+ that such License is exercised:
77
+ (i) solely in connection with the adoption and use of the
78
+ Tide Protocol;
79
+ (ii) solely in a manner which requires any payment or
80
+ exchange of value to be made via Tide Tokens (as
81
+ defined in paragraph (c) below); and
82
+ (iii) in accordance with clause 6 and on these terms in
83
+ respect of the right to distribute and publish the
84
+ Materials and Modified Materials.
85
+ The foregoing rights to distribute, publish and exploit the
86
+ Materials include the right to do so for a fee and applies
87
+ in respect of the Materials and the Modified Materials.
88
+ (b) Any access, use, copy, modification, adaptation, distribution,
89
+ publication or exploitation of any of the Materials for use
90
+ with applications that do not fully use, adopt and implement
91
+ the Tide Protocol is prohibited. This prohibition includes any
92
+ use or adaptation of the Materials for the purposes of any
93
+ protocol, system or platform competing with the Tide Protocol
94
+ or which facilitates any form of payment or exchange of value
95
+ other than through use of Tide Tokens (as defined in paragraph
96
+ (c) below).
97
+ (c) Without limiting paragraph (b), the License granted under
98
+ paragraph (a) does not permit you to, and in exercising the
99
+ rights granted to you under paragraph (a) you must not, under
100
+ any circumstances:
101
+ (i) remove, omit or in any way modify any component of the
102
+ Materials, including source code components, which
103
+ requires payment or exchange of value to be made via
104
+ Tide cryptographic tokens designed for settling
105
+ transactions entered into via the Tide Protocol (“Tide
106
+ Tokens”);
107
+ (ii) use the Materials which are source code or object code:
108
+ (A) in combination with any other code, script or
109
+ software (whether in source or object code form),
110
+ or otherwise in any manner, which would in any way
111
+ circumvent the requirement for any payment or
112
+ exchange of value to be made via Tide Tokens; or
113
+ (B) in any other way which does not properly use, adopt
114
+ and implement the Tide Protocol in its entirety,
115
+ including for the purposes of both data decryption
116
+ and key management;
117
+ (iii) violate any applicable laws or any rights of any person,
118
+ or use or permit or facilitate the use of the Materials
119
+ in any manner or for any purpose that is unlawful or is
120
+ in breach of any laws of jurisdiction anywhere in the
121
+ world;
122
+ (iv) distribute viruses, spyware, corrupted files, or any
123
+ other similar software or programs that may damage the
124
+ operation of any computer hardware or software, or the
125
+ Tide Protocol; or
126
+ (v) engage in any other conduct that is improper or brings
127
+ or is likely to bring us, the Materials, the Tide
128
+ Protocol or Tide Tokens into disrepute,
129
+ and you must ensure that where any third party is being engaged
130
+ to make modifications to the Materials on your behalf, their
131
+ rights to do so are subject to terms which incorporate the
132
+ restrictions in this clause 3.
133
+ (d) You must take your own precautions to ensure that the processes
134
+ which you employ for accessing and using the Materials do not
135
+ expose you to the risk of viruses, malicious computer code or
136
+ other forms of interference which may damage your computer
137
+ systems. We recommend that you install and use up-to-date
138
+ anti-virus, anti-spyware and firewall software on your computer
139
+ systems.
140
+
141
+ 4 Data security and privacy
142
+ You are fully responsible for ensuring:
143
+ (a) any use, adoption or implementation of the Materials, any
144
+ Modified Materials and/or the Tide Protocol appropriately
145
+ protects, encrypts and stores data; and
146
+ (b) all aspects of compliance with privacy and data protection laws.
147
+ We disclaim all warranties and liability regarding the same.
148
+
149
+ 5 Modification of Tide Protocol and Materials
150
+ You acknowledge that Tide may at any time without notice to you change
151
+ or update the whole or any part of the Tide Protocol and/or any of the
152
+ Materials, including in a manner which may result in applications or
153
+ processes you may have developed or implemented no longer being
154
+ compatible or otherwise working in the same manner with the Tide
155
+ Protocol or any Material, including any software development kit. We
156
+ may also withdraw or remove any part of the Materials or the Tide
157
+ Protocol at any stage without notice to you.
158
+
159
+ 6 Distribution
160
+ (a) Without limiting clause 3, in exercising the rights granted to
161
+ you under clause 3(a) to distribute or publish one or more
162
+ copies of any Materials verbatim as you receive the Materials,
163
+ you may do so in any medium, provided that:
164
+ (i) you provide all recipients of the Materials with a copy of
165
+ these terms along with the Materials:
166
+ (ii) you keep intact and do not remove, omit, or in any way
167
+ modify any of the following:
168
+ (A) any notices stating that these License terms apply;
169
+ (B) any hyperlink to these License terms; and
170
+ (C) any notices of the absence of any warranty;
171
+ (b) You may charge any price or no price for each copy of the
172
+ Materials or Modified Materials that you distribute or publish,
173
+ and you may offer support or warranty protection for a fee.
174
+ (c) Without limiting clause 3, in exercising the rights granted to
175
+ you under clause 3(a) to distribute or publish one or more
176
+ copies of any Modified Materials you create or cause to be
177
+ created, you may do so in any medium, provided that:
178
+ (i) you provide all recipients of the Modified Materials with
179
+ a copy of these terms along with the Modified Materials;
180
+ (ii) you keep intact and do not remove, omit, or in any way
181
+ modify any of the following:
182
+ (A) any notices stating that these License terms apply to
183
+ the unmodified Materials;
184
+ (B) any hyperlink to these License terms; and
185
+ (C) any notices of the absence of any warranty in respect
186
+ of the unmodified Materials; and
187
+ (iii) the whole of any Modified Materials must be licensed under
188
+ these terms (although this does not limit the operation of
189
+ paragraph (d)), but you may impose further restrictions
190
+ that do not conflict with or override these terms.
191
+ (d) Where you compile any source code Materials or Modified
192
+ Materials in an aggregate with any proprietary program, the
193
+ Materials remain governed by these License terms. For the
194
+ purposes of the foregoing, a compilation of any Materials with
195
+ other separate and independent works, which are not by their
196
+ nature extensions of the Materials, and which are not combined
197
+ with the Materials such as to form a larger program, in or on
198
+ a volume of a storage or distribution medium, is an “aggregate”
199
+ if the compilation and its resulting copyright are not used to
200
+ limit the access or legal rights of the compilation's users
201
+ beyond what the individual Materials permit. Inclusion of any
202
+ Materials in an aggregate does not cause these terms to apply
203
+ to the other parts of the aggregate.
204
+ (e) You may not initiate any proceedings or claims in respect of
205
+ infringement of any patent rights in respect of the access,
206
+ use, copy, modification, adaptation, distribution, publication
207
+ or exploitation of any of the Materials or Modified Materials
208
+ in accordance with these terms.
209
+
210
+ 7 Liability
211
+ (a) All express or implied guarantees, warranties, representations,
212
+ statements, terms or conditions relating to these terms or the
213
+ Materials that are not contained in these terms, are excluded
214
+ to the maximum extent permitted by law. Without limiting the
215
+ foregoing:
216
+ (i) the Materials are provided ‘as-is’ and neither we nor Tide
217
+ warrant or represent that they will work in any way, that
218
+ they are fit for any particular purpose, that your
219
+ requirements will be met, that your use of the Materials
220
+ will be uninterrupted or error free or that the Materials
221
+ are free of viruses or other harmful components; and
222
+ (ii) we and Tide are not responsible for any loss, corruption or
223
+ interception of data which occurs in connection with your
224
+ use or misuse of the Materials.
225
+ (b) Nothing in these terms excludes, restricts or modifies any
226
+ guarantee, term, condition, warranty, or any right or remedy,
227
+ implied or imposed by any law which cannot lawfully be excluded
228
+ or limited. (a “Non-Excludable Provision”). If any guarantee,
229
+ term, condition or warranty is implied into these terms under a
230
+ Non-Excludable Provision and we or Tide can limit your remedy
231
+ for a breach of the Non-Excludable Provision, then our and
232
+ Tide’s liability for breach of the Non-Excludable Provision is
233
+ limited to one or more of the following at our option:
234
+ (i) in the case of goods, the replacement of the goods or the
235
+ supply of equivalent goods, the repair of the goods, the
236
+ payment of the cost of replacing the goods or of acquiring
237
+ equivalent goods, or the payment of the cost of having the
238
+ goods repaired; or
239
+ (ii) in the case of services, the supplying of the services
240
+ again, or the payment of the cost of having the services
241
+ supplied again.
242
+ (c) To the maximum extent permitted by law but despite any other
243
+ clause in these terms, your use of the Materials is at your own
244
+ risk and neither we nor Tide are liable to you for any loss or
245
+ damage you (or any of your representatives or sub-licensees)
246
+ suffer, sustain or incur in connection with these terms,
247
+ exercise of any rights granted under these terms or otherwise
248
+ in connection with any access or use of the Materials, including
249
+ in respect of any loss, corruption or interception of data or
250
+ breach of privacy or security.
251
+ (d) Without limiting paragraph (c), to the maximum extent permitted
252
+ by law, neither we nor Tide are not liable to you for and no
253
+ measure of damages will under any circumstances include:
254
+ (i) special, indirect, consequential, incidental or punitive
255
+ damages; or
256
+ (ii) damages for loss of profits, revenue, goodwill,
257
+ opportunity, anticipated savings or loss or corruption of
258
+ data.
259
+ (e) The exclusions and limitations of liability in this clause 8
260
+ apply regardless of the basis on which such liability arises,
261
+ whether in contract, breach of warranty, tort (including
262
+ negligence), in equity, under statute, under an indemnity or
263
+ on any other basis.
264
+ (f) You will indemnify us and hold us, Tide and each of our
265
+ directors, officers, employees and contractors harmless from
266
+ and against any loss suffered or incurred by us or any of
267
+ those indemnified, arising out of or in connection with:
268
+ (i) your or any of your sub-licensee’s access or use of any of
269
+ the Materials or any other exercise of any of the rights
270
+ granted to you under these terms in connection with any of
271
+ the Materials;
272
+ (ii) your negligence or breach of these terms;
273
+ (iii) your violation of any applicable law or infringement of any
274
+ rights (including Intellectual Property Rights) of a third
275
+ party; or
276
+ (iv) any claim made by any third party arising out of or in
277
+ connection with any Modified Materials, including any
278
+ application developed using any of the Materials, and
279
+ including in respect of infringement of any person’s
280
+ Intellectual Property Rights.
281
+ 8 Termination
282
+ (a) Your License to use the Materials under clause 3(a) immediately
283
+ and automatically terminates without the need for us to give
284
+ notice to you if you breach these terms.
285
+ (b) You may terminate these terms at any time by ceasing all use
286
+ and removing all implementations of the Materials and the Tide
287
+ Protocol.
288
+ (c) Upon termination of these terms, all rights and Licenses
289
+ granted to you under these terms will also terminate and you
290
+ must immediately cease using the Materials and remove all
291
+ implementations of the Materials.
292
+ 9 General
293
+ (a) You remain fully responsible and liable for the acts and
294
+ omissions of any third party to whom you subcontract the
295
+ exercise or performance any of your rights or obligations under
296
+ these terms, as if such acts and omissions were your acts and
297
+ omissions.
298
+ (b) If any part of these terms is held to be unenforceable, the
299
+ unenforceable part is to be given effect to the greatest extent
300
+ possible and the remainder will remain in full force and effect.
301
+ (c) No waiver, delay or failure by us to take any action shall
302
+ constitute or be construed as a waiver of that or any other term,
303
+ condition, option, privilege or right we may have.
304
+ (d) The word “including” when used in these terms is not a term of
305
+ limitation.
306
+
307
+ ====================
308
+ End of License terms
309
+ ====================
310
+
311
+ If you develop a Modified Material and want to assert your copyright,
312
+ attach the following notices to the Modified Material. It is best to
313
+ attach them to the start of each source file to most effectively state
314
+ the exclusion of warranty and each file should have at least the
315
+ “copyright” line and a pointer to where the full notice is found.
316
+
317
+ <INSERT PROGRAM NAME and PURPOSE.>
318
+
319
+ Copyright (c) <year> <name of author>
320
+
321
+ This program is free software and is subject to the terms of the Tide
322
+ Community Open Code License as published by the Tide Foundation
323
+ Limited. You may modify it and redistribute it in accordance with
324
+ and subject to the terms of that License.
325
+
326
+ This program is distributed WITHOUT WARRANTY of any kind, including
327
+ without any implied warranty of MERCHANTABILITY or FITNESS FOR A
328
+ PARTICULAR PURPOSE. See the Tide Community Open Code License for
329
+ more details.
330
+
331
+ You should have received a copy of the Tide Community Open Code
332
+ License along with this program.
333
+
334
+ If not, see https://tide.org/licenses_tcoc2-0-0-en
package/README.md ADDED
@@ -0,0 +1,345 @@
1
+ # TideCloak NextJS SDK
2
+
3
+ Secure your Next.js app with TideCloak: authentication, session management, data encryption, and edge-middleware integration-all in minutes.
4
+
5
+ ---
6
+
7
+ ## 1. Prerequisites
8
+
9
+ Before you begin, ensure you have:
10
+
11
+ * Next.js 13.5.7 or later
12
+ * React 18 or later
13
+ * Node.js ≥18.17.0
14
+ * A running TideCloak server
15
+ * A registered client in your realm
16
+
17
+ ---
18
+
19
+ ## 2. Install the SDK
20
+
21
+ Add the NextJS bundle to your project:
22
+
23
+ ```bash
24
+ npm install @tidecloak/nextjs
25
+ # or
26
+ yarn add @tidecloak/nextjs
27
+ ```
28
+
29
+ This bundle provides:
30
+
31
+ * `<TideCloakProvider>` - application-level context
32
+ * `useTideCloak()` hook - access tokens and auth actions
33
+ * `verifyTideCloakToken()` - server-side JWT verification
34
+ * `<Authenticated>` / `<Unauthenticated>` - UI guards
35
+ * `doEncrypt()` / `doDecrypt()` - tag-based encryption/decryption
36
+ * `createTideCloakMiddleware()` - Edge middleware for route protection (supports both Pages & App routers)
37
+
38
+ ---
39
+
40
+ ## 3. Initialize the Provider
41
+
42
+ Wrap your root component in `<TideCloakProvider>` to load adapter settings and bootstrap auth:
43
+
44
+ ```tsx
45
+ 'use client'
46
+ import React from 'react';
47
+ import { TideCloakProvider } from '@tidecloak/nextjs';
48
+ import adapter from '../tidecloakAdapter.json';
49
+
50
+ export default function App() {
51
+ return (
52
+ <TideCloakProvider config={adapter}>
53
+ <YourApp />
54
+ </TideCloakProvider>
55
+ );
56
+ }
57
+ ```
58
+
59
+ **What it does:**
60
+
61
+ * **Loads** your adapter JSON
62
+ * **Initializes** internal auth flows and listeners
63
+ * **Provides** auth state & methods via React Context
64
+
65
+ ---
66
+
67
+ ## 4. Using the `useTideCloak` Hook
68
+
69
+ Use this hook anywhere to manage auth:
70
+
71
+ ```tsx
72
+ 'use client'
73
+ import { useTideCloak } from '@tidecloak/nextjs';
74
+
75
+ function Header() {
76
+ const {
77
+ authenticated,
78
+ login,
79
+ logout,
80
+ token,
81
+ tokenExp,
82
+ refreshToken,
83
+ getValueFromToken,
84
+ getValueFromIdToken,
85
+ hasRealmRole,
86
+ hasClientRole,
87
+ doEncrypt,
88
+ doDecrypt,
89
+ } = useTideCloak();
90
+
91
+ return (
92
+ <header>
93
+ {authenticated ? (
94
+ <>
95
+ <span>Logged in</span>
96
+ <button onClick={logout}>Log Out</button>
97
+ </>
98
+ ) : (
99
+ <button onClick={login}>Log In</button>
100
+ )}
101
+ {token && (
102
+ <small>Expires at {new Date(tokenExp * 1000).toLocaleTimeString()}</small>
103
+ )}
104
+ </header>
105
+ );
106
+ }
107
+ ```
108
+
109
+ | Name | Type | Description |
110
+ | ------------------------------------- | -------------------------------------------- | ----------------------------------------------------------------------- |
111
+ | `authenticated` | `boolean` | Whether the user is logged in. |
112
+ | `login()` / `logout()` | `() => void` | Trigger the login or logout flows. |
113
+ | `token`, `tokenExp` | `string`, `number` | Access token and its expiration timestamp. |
114
+ | Automatic token refresh | built-in | Tokens refresh silently on expiration-no manual setup needed. |
115
+ | `refreshToken()` | `() => Promise<boolean>` | Force a silent token renewal. |
116
+ | `getValueFromToken(key)` | `(key: string) => any` | Read a custom claim from the access token. |
117
+ | `getValueFromIdToken(key)` | `(key: string) => any` | Read a custom claim from the ID token. |
118
+ | `hasRealmRole(role)` | `(role: string) => boolean` | Check a realm-level role. |
119
+ | `hasClientRole(role, client?)` | `(role: string, client?: string) => boolean` | Check a client-level role; defaults to your app’s client ID if omitted. |
120
+ | `doEncrypt(data)` / `doDecrypt(data)` | `(data: any) => Promise<any>` | Encrypt or decrypt payloads via TideCloak’s built-in service. |
121
+
122
+ ---
123
+
124
+ ## 5. Guard Components
125
+
126
+ Use out-of-the-box components to show or hide content:
127
+
128
+ ```tsx
129
+ 'use client'
130
+ import { Authenticated, Unauthenticated } from '@tidecloak/nextjs';
131
+
132
+ function Dashboard() {
133
+ return (
134
+ <>
135
+ <Authenticated>
136
+ <h1>Dashboard</h1>
137
+ {/* Protected widgets */}
138
+ </Authenticated>
139
+
140
+ <Unauthenticated>
141
+ <p>Please log in to access the dashboard.</p>
142
+ </Unauthenticated>
143
+ </>
144
+ );
145
+ }
146
+ ```
147
+
148
+ * `<Authenticated>`: renders children only when `authenticated === true`
149
+ * `<Unauthenticated>`: renders children only when `authenticated === false`
150
+
151
+ ---
152
+
153
+ ## 6. Encrypting & Decrypting Data
154
+
155
+ TideCloak lets you protect sensitive fields with **tag-based** encryption. Pass in an array of `{ data, tags }` objects and receive encrypted strings (or vice versa).
156
+
157
+ ### Syntax Overview
158
+
159
+ ```ts
160
+ // Encrypt payloads:
161
+ const encryptedArray = await doEncrypt([
162
+ { data: /* any JSON-serializable value */, tags: ['tag1', 'tag2'] },
163
+ // …
164
+ ]);
165
+
166
+ // Decrypt blobs:
167
+ const decryptedArray = await doDecrypt([
168
+ { encrypted: /* string from encrypt() */, tags: ['tag1', 'tag2'] },
169
+ // …
170
+ ]);
171
+ ```
172
+
173
+ > **Order guarantee**: the returned array matches the input order.
174
+
175
+ ### Permissions
176
+
177
+ * **Encryption** requires roles `tide_<tag>.selfencrypt` for each tag.
178
+ * **Decryption** requires roles `tide_<tag>.selfdecrypt` for each tag.
179
+
180
+ ---
181
+
182
+ ## 7. Edge Middleware with TideCloak
183
+
184
+ TideCloak’s Edge middleware works seamlessly with both the **Pages Router** and the **App Router** in Next.js:
185
+
186
+ * **Pages Router**: Place your `middleware.ts` file at the project root alongside `pages/`. The exported middleware will apply to both page and API routes.
187
+ * **App Router**: Put `middleware.ts` at the project root (or inside `src/`). It integrates with `/app` routes and layouts, protecting both server components and route handlers.
188
+
189
+ ### 7.1 Installation
190
+
191
+ No additional install-middleware is included in `@tidecloak/nextjs`.
192
+
193
+ ### 7.2 Options
194
+
195
+ * **`config`** (`TidecloakConfig`): Your Keycloak adapter JSON (downloaded from your TideCloak client settings).
196
+ * **`publicRoutes`** (`RoutePattern[]`): Paths to bypass authentication (strings/globs/regex/functions).
197
+ * **`protectedRoutes`** (`ProtectedRoutesMap`): Map of path patterns to arrays of required roles.
198
+ * **`onRequest`**<br>`(ctx: { token: string | null }, req: NextRequest) => NextResponse | void`<br>Hook before auth logic; can short-circuit by returning a `NextResponse`.
199
+ * **`onSuccess`**<br>`(ctx: { payload: Record<string, any> }, req: NextRequest) => NextResponse | void`<br>Hook after successful auth & role checks; override the response by returning one.
200
+ * **`onFailure`**<br>`(ctx: { token: string | null }, req: NextRequest) => NextResponse | void`<br>Hook when auth or role check fails; return a `NextResponse` to override.
201
+ * **`onError`**<br>`(err: any, req: NextRequest) => NextResponse`<br>Hook for unexpected errors in middleware logic.
202
+
203
+ ### 7.3 Example Usage
204
+
205
+ Place the following `middleware.ts` at your project root (works for both Pages and App routers) to protect both page routes and API handlers:
206
+
207
+ ```ts
208
+ import { NextResponse } from 'next/server';
209
+ import keycloakConfig from './tidecloak.config.json';
210
+ import { createTideCloakMiddleware } from '@tidecloak/nextjs/server/tidecloakMiddleware';
211
+
212
+ export default createTideCloakMiddleware({
213
+ config: keycloakConfig,
214
+ publicRoutes: ['/', '/about'],
215
+ protectedRoutes: {
216
+ '/admin/*': ['admin'],
217
+ '/api/private/*': ['user'],
218
+ },
219
+ onFailure: ({ token }, req) => NextResponse.redirect(new URL('/login', req.url)),
220
+ onError: (err, req) => NextResponse.rewrite(new URL('/error', req.url)),
221
+ });
222
+
223
+ export const config = {
224
+ matcher: [
225
+ '/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico)).*)',
226
+ '/api/(.*)',
227
+ ],
228
+ runtime: 'edge',
229
+ };
230
+ ```
231
+
232
+ **Flow:**
233
+
234
+ 1. Bypass any `publicRoutes`
235
+ 2. Read the `kcToken` cookie
236
+ 3. Invoke `onRequest` hook (if provided)
237
+ 4. Match path against `protectedRoutes` patterns
238
+ 5. Verify signature, issuer, and roles via `verifyTideCloakToken()`
239
+ 6. On success: `onSuccess` hook or `NextResponse.next()`
240
+ 7. On failure: `onFailure` hook or default 403 response
241
+ 8. On unexpected errors: `onError` hook
242
+
243
+ ---
244
+
245
+ ### 7.4. Server‑Side Token Verification
246
+
247
+ You can verify TideCloak-issued JWTs on your server or API routes using `verifyTideCloakToken`:
248
+
249
+ ```ts
250
+ import { verifyTideCloakToken } from '@tidecloak/nextjs/server';
251
+
252
+ // Returns the decoded payload if valid and roles pass, otherwise null
253
+ const payload = await verifyTideCloakToken(
254
+ config, // Your TideCloak adapter JSON
255
+ token, // Raw access token to verify
256
+ ['admin', 'user'] // Optional roles; user must have at least one
257
+ );
258
+
259
+ if (!payload) {
260
+ // Invalid token or insufficient roles
261
+ }
262
+ ```
263
+
264
+ Under the hood, it uses `jose` for cryptographic verification and key management:
265
+
266
+ ```ts
267
+ import { jwtVerify, createLocalJWKSet, createRemoteJWKSet } from 'jose';
268
+
269
+ export async function verifyTideCloakToken(config, token, allowedRoles = []) {
270
+ // Implementation checks token presence, issuer, signature,
271
+ // authorized party (azp), and at least one allowed role.
272
+ }
273
+ ```
274
+
275
+ **Parameters:**
276
+
277
+ * `config` (`object`): Your TideCloak adapter JSON (parsed Keycloak config).
278
+ * `token` (`string`): Access token string to verify.
279
+ * `allowedRoles` (`string[]`, optional): Array of realm or client roles; user must have at least one.
280
+
281
+ **Returns:**
282
+
283
+ * `Promise<object | null>`: Decoded JWT payload if valid and role check passes; otherwise `null`.
284
+
285
+ ### Example: Protecting an API Route
286
+
287
+ Protect your server-side endpoints by verifying the JWT before proceeding.
288
+
289
+ #### Pages Router
290
+
291
+ ```ts
292
+ // pages/api/secure.ts
293
+ import type { NextApiRequest, NextApiResponse } from 'next';
294
+ import { verifyTideCloakToken } from '@tidecloak/nextjs/server';
295
+ import config from '../../tidecloakAdapter.json';
296
+
297
+ export default async function handler(req: NextApiRequest, res: NextApiResponse) {
298
+ // Extract token from cookie or Authorization header
299
+ const token = req.cookies.kcToken || req.headers.authorization?.split(' ')[1] || '';
300
+
301
+ // Verify signature, issuer, and roles (e.g., 'user')
302
+ const payload = await verifyTideCloakToken(config, token, ['user']);
303
+ if (!payload) {
304
+ return res.status(401).json({ error: 'Unauthorized' });
305
+ }
306
+
307
+ // Proceed with secure logic
308
+ res.status(200).json({ data: 'Secure data response' });
309
+ }
310
+ ```
311
+
312
+ #### App Router
313
+
314
+ ```ts
315
+ // app/api/secure/route.ts
316
+ import { NextRequest, NextResponse } from 'next/server';
317
+ import { verifyTideCloakToken } from '@tidecloak/nextjs/server';
318
+ import config from '../../../tidecloakAdapter.json';
319
+
320
+ export async function GET(req: NextRequest) {
321
+ // Extract token from cookie
322
+ const token = req.cookies.get('kcToken')?.value || '';
323
+
324
+ // Verify signature, issuer, and roles (e.g., 'user')
325
+ const payload = await verifyTideCloakToken(config, token, ['user']);
326
+ if (!payload) {
327
+ return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
328
+ }
329
+
330
+ // Proceed with secure logic
331
+ return NextResponse.json({ data: 'Secure data response' });
332
+ }
333
+ ```
334
+
335
+ ---
336
+
337
+ ## 8. Advanced & Best Practices
338
+
339
+ * **Auto-Refresh**: built into the provider-no manual timers.
340
+ * **Error Handling**: use the `initError` value from `useTideCloak`.
341
+ * **Custom Claims**: read via `getValueFromToken()` / `getValueFromIdToken()`.
342
+ * **Role-Based UI**: combine hooks & guard components for fine-grained control.
343
+ * **Lazy Initialization**: wrap `<TideCloakProvider>` around only protected sections in large apps.
344
+
345
+ ---
@@ -0,0 +1 @@
1
+ export * from '@tidecloak/react';
@@ -0,0 +1,2 @@
1
+ export { createTideCloakMiddleware } from './tidecloakMiddleware';
2
+ export { verifyTideCloakToken } from '@tidecloak/verify';
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Convert a single RoutePattern into a test function
3
+ */
4
+ export function normalizePattern(pattern) {
5
+ if (typeof pattern === 'function')
6
+ return pattern;
7
+ if (pattern instanceof RegExp)
8
+ return (path) => pattern.test(path);
9
+ if (pattern === 'OPTIONS')
10
+ return (_path, req) => req.method === 'OPTIONS';
11
+ if (typeof pattern === 'string' && pattern.includes('*')) {
12
+ // Escape regex chars, then replace '*' with '.*'
13
+ const escaped = pattern
14
+ .replace(/[-/\\^$+?.()|[\]{}]/g, '\\$&')
15
+ .replace(/\\\*/g, '.*');
16
+ const regex = new RegExp(`^${escaped}$`);
17
+ return (path) => regex.test(path);
18
+ }
19
+ // Simple prefix match
20
+ return (path) => path.startsWith(pattern);
21
+ }
22
+ /**
23
+ * Convert a ProtectedRoutesMap into an array of { test, roles }
24
+ */
25
+ export function normalizeProtectedRoutes(map = {}) {
26
+ return Object.entries(map).map(([pattern, roles]) => ({
27
+ test: normalizePattern(pattern),
28
+ roles,
29
+ }));
30
+ }
@@ -0,0 +1,92 @@
1
+ import { NextResponse } from 'next/server';
2
+ import { verifyTideCloakToken } from '@tidecloak/verify';
3
+ import { normalizePattern, normalizeProtectedRoutes } from './routerMatcher';
4
+ const DEFAULTS = {
5
+ protectedRoutes: {},
6
+ onRequest: undefined,
7
+ onSuccess: undefined,
8
+ };
9
+ /**
10
+ * Returns a Next.js Edge Middleware function enforcing TideCloak auth.
11
+ *
12
+ * Example usage in your `middleware.ts`:
13
+ *
14
+ * ```ts
15
+ * import keycloakConfig from './tidecloak.config.json'
16
+ * import { createTideMiddleware } from 'tidecloak-nextjs/server/tidecloakMiddleware'
17
+ *
18
+ * export default createTideMiddleware({
19
+ * config: keycloakConfig,
20
+ * publicRoutes: ['/', '/about'],
21
+ * protectedRoutes: {
22
+ * '/admin/*': ['admin'],
23
+ * '/api/private/*': ['user']
24
+ * }
25
+ * })
26
+ *
27
+ * export const config = {
28
+ * matcher: [
29
+ * '/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico)).*)',
30
+ * '/(api|trpc)(.*)'
31
+ * ],
32
+ * runtime: 'edge'
33
+ * }
34
+ * ```
35
+ */
36
+ export function createTideCloakMiddleware(opts) {
37
+ var _a;
38
+ const settings = { ...DEFAULTS, ...opts };
39
+ // Prepare arrays of test functions for public and protected routes
40
+ const publicTests = ((_a = settings.publicRoutes) !== null && _a !== void 0 ? _a : []).map(normalizePattern);
41
+ const protectedTests = normalizeProtectedRoutes(settings.protectedRoutes);
42
+ return async function middleware(req) {
43
+ var _a;
44
+ const path = req.nextUrl.pathname;
45
+ try {
46
+ // Bypass auth entirely for configured public routes
47
+ if (publicTests.some(test => test(path, req))) {
48
+ return NextResponse.next();
49
+ }
50
+ // Extract the raw JWT from the specified cookie
51
+ const token = ((_a = req.cookies.get("kcToken")) === null || _a === void 0 ? void 0 : _a.value) || null;
52
+ // Allow custom logic before auth checks
53
+ if (settings.onRequest) {
54
+ const result = settings.onRequest({ token }, req);
55
+ if (result)
56
+ return result;
57
+ }
58
+ // Iterate protected routes; the first match enforces a role check
59
+ for (const { test, roles } of protectedTests) {
60
+ if (test(path, req)) {
61
+ // Verify signature, issuer, and presence of at least one allowed role
62
+ const payload = await verifyTideCloakToken(settings.config, token, roles);
63
+ if (!payload) {
64
+ // Custom onFailure hook or default redirect
65
+ const result = settings.onFailure({ token }, req);
66
+ if (result)
67
+ return result;
68
+ return NextResponse.json({ error: '[TideCloak Middleware] Access forbidden: invalid token' }, { status: 403 });
69
+ }
70
+ // Custom onSuccess hook if provided
71
+ if (settings.onSuccess) {
72
+ const result = settings.onSuccess({ payload }, req);
73
+ if (result)
74
+ return result;
75
+ }
76
+ // Token valid and role check passed
77
+ return NextResponse.next();
78
+ }
79
+ }
80
+ // No protected route matched; continue
81
+ return NextResponse.next();
82
+ }
83
+ catch (err) {
84
+ // Handle unexpected errors
85
+ if (settings.onError) {
86
+ return settings.onError(err, req);
87
+ }
88
+ console.error("[TideCloak Middleware] ", err);
89
+ throw err;
90
+ }
91
+ };
92
+ }
@@ -0,0 +1 @@
1
+ export * from '@tidecloak/react';
@@ -0,0 +1,2 @@
1
+ export { createTideCloakMiddleware } from './tidecloakMiddleware';
2
+ export { verifyTideCloakToken } from '@tidecloak/verify';
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Convert a single RoutePattern into a test function
3
+ */
4
+ export function normalizePattern(pattern) {
5
+ if (typeof pattern === 'function')
6
+ return pattern;
7
+ if (pattern instanceof RegExp)
8
+ return (path) => pattern.test(path);
9
+ if (pattern === 'OPTIONS')
10
+ return (_path, req) => req.method === 'OPTIONS';
11
+ if (typeof pattern === 'string' && pattern.includes('*')) {
12
+ // Escape regex chars, then replace '*' with '.*'
13
+ const escaped = pattern
14
+ .replace(/[-/\\^$+?.()|[\]{}]/g, '\\$&')
15
+ .replace(/\\\*/g, '.*');
16
+ const regex = new RegExp(`^${escaped}$`);
17
+ return (path) => regex.test(path);
18
+ }
19
+ // Simple prefix match
20
+ return (path) => path.startsWith(pattern);
21
+ }
22
+ /**
23
+ * Convert a ProtectedRoutesMap into an array of { test, roles }
24
+ */
25
+ export function normalizeProtectedRoutes(map = {}) {
26
+ return Object.entries(map).map(([pattern, roles]) => ({
27
+ test: normalizePattern(pattern),
28
+ roles,
29
+ }));
30
+ }
@@ -0,0 +1,92 @@
1
+ import { NextResponse } from 'next/server';
2
+ import { verifyTideCloakToken } from '@tidecloak/verify';
3
+ import { normalizePattern, normalizeProtectedRoutes } from './routerMatcher';
4
+ const DEFAULTS = {
5
+ protectedRoutes: {},
6
+ onRequest: undefined,
7
+ onSuccess: undefined,
8
+ };
9
+ /**
10
+ * Returns a Next.js Edge Middleware function enforcing TideCloak auth.
11
+ *
12
+ * Example usage in your `middleware.ts`:
13
+ *
14
+ * ```ts
15
+ * import keycloakConfig from './tidecloak.config.json'
16
+ * import { createTideMiddleware } from 'tidecloak-nextjs/server/tidecloakMiddleware'
17
+ *
18
+ * export default createTideMiddleware({
19
+ * config: keycloakConfig,
20
+ * publicRoutes: ['/', '/about'],
21
+ * protectedRoutes: {
22
+ * '/admin/*': ['admin'],
23
+ * '/api/private/*': ['user']
24
+ * }
25
+ * })
26
+ *
27
+ * export const config = {
28
+ * matcher: [
29
+ * '/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico)).*)',
30
+ * '/(api|trpc)(.*)'
31
+ * ],
32
+ * runtime: 'edge'
33
+ * }
34
+ * ```
35
+ */
36
+ export function createTideCloakMiddleware(opts) {
37
+ var _a;
38
+ const settings = { ...DEFAULTS, ...opts };
39
+ // Prepare arrays of test functions for public and protected routes
40
+ const publicTests = ((_a = settings.publicRoutes) !== null && _a !== void 0 ? _a : []).map(normalizePattern);
41
+ const protectedTests = normalizeProtectedRoutes(settings.protectedRoutes);
42
+ return async function middleware(req) {
43
+ var _a;
44
+ const path = req.nextUrl.pathname;
45
+ try {
46
+ // Bypass auth entirely for configured public routes
47
+ if (publicTests.some(test => test(path, req))) {
48
+ return NextResponse.next();
49
+ }
50
+ // Extract the raw JWT from the specified cookie
51
+ const token = ((_a = req.cookies.get("kcToken")) === null || _a === void 0 ? void 0 : _a.value) || null;
52
+ // Allow custom logic before auth checks
53
+ if (settings.onRequest) {
54
+ const result = settings.onRequest({ token }, req);
55
+ if (result)
56
+ return result;
57
+ }
58
+ // Iterate protected routes; the first match enforces a role check
59
+ for (const { test, roles } of protectedTests) {
60
+ if (test(path, req)) {
61
+ // Verify signature, issuer, and presence of at least one allowed role
62
+ const payload = await verifyTideCloakToken(settings.config, token, roles);
63
+ if (!payload) {
64
+ // Custom onFailure hook or default redirect
65
+ const result = settings.onFailure({ token }, req);
66
+ if (result)
67
+ return result;
68
+ return NextResponse.json({ error: '[TideCloak Middleware] Access forbidden: invalid token' }, { status: 403 });
69
+ }
70
+ // Custom onSuccess hook if provided
71
+ if (settings.onSuccess) {
72
+ const result = settings.onSuccess({ payload }, req);
73
+ if (result)
74
+ return result;
75
+ }
76
+ // Token valid and role check passed
77
+ return NextResponse.next();
78
+ }
79
+ }
80
+ // No protected route matched; continue
81
+ return NextResponse.next();
82
+ }
83
+ catch (err) {
84
+ // Handle unexpected errors
85
+ if (settings.onError) {
86
+ return settings.onError(err, req);
87
+ }
88
+ console.error("[TideCloak Middleware] ", err);
89
+ throw err;
90
+ }
91
+ };
92
+ }
@@ -0,0 +1,2 @@
1
+ export * from '@tidecloak/react';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { createTideCloakMiddleware } from './tidecloakMiddleware';
2
+ export { verifyTideCloakToken } from '@tidecloak/verify';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,21 @@
1
+ import { NextRequest } from 'next/server';
2
+ /**
3
+ * A route matcher: prefix string, glob string, RegExp, or custom function
4
+ */
5
+ export type RoutePattern = string | RegExp | ((pathname: string, req: NextRequest) => boolean);
6
+ /**
7
+ * Map of protected routes: key = path pattern, value = allowed roles
8
+ */
9
+ export type ProtectedRoutesMap = Record<string, string[]>;
10
+ /**
11
+ * Convert a single RoutePattern into a test function
12
+ */
13
+ export declare function normalizePattern(pattern: RoutePattern): (pathname: string, req: NextRequest) => boolean;
14
+ /**
15
+ * Convert a ProtectedRoutesMap into an array of { test, roles }
16
+ */
17
+ export declare function normalizeProtectedRoutes(map?: ProtectedRoutesMap): Array<{
18
+ test: (pathname: string, req: NextRequest) => boolean;
19
+ roles: string[];
20
+ }>;
21
+ //# sourceMappingURL=routerMatcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routerMatcher.d.ts","sourceRoot":"","sources":["../../../src/server/routerMatcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEzC;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,MAAM,GACN,CAAC,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,CAAA;AAErD;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAEzD;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,GACpB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAcjD;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,GAAE,kBAAuB,GAC3B,KAAK,CAAC;IACP,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC;IACtD,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC,CAKD"}
@@ -0,0 +1,82 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+ import { RoutePattern, ProtectedRoutesMap } from './routerMatcher';
3
+ interface JWK {
4
+ kid: string;
5
+ kty: string;
6
+ alg: string;
7
+ use: string;
8
+ crv: string;
9
+ x: string;
10
+ }
11
+ export interface TidecloakConfig {
12
+ realm: string;
13
+ "auth-server-url": string;
14
+ "ssl-required": string;
15
+ resource: string;
16
+ "public-client": boolean;
17
+ "confidential-port": number;
18
+ jwk: {
19
+ keys: JWK[];
20
+ };
21
+ [key: string]: unknown;
22
+ }
23
+ /**
24
+ * Configuration options for TideCloak middleware.
25
+ *
26
+ * - `config`: Your Keycloak client adapter JSON.
27
+ * - `publicRoutes`: Optional array of paths to exclude from auth, using globs, regex, or functions.
28
+ * - `protectedRoutes`: Map of path patterns to arrays of required roles.
29
+ * - `onRequest`, `onSuccess`, `onFailure`, `onError`: Lifecycle hooks for custom logic.
30
+ */
31
+ export interface TideMiddlewareOptions {
32
+ /** Keycloak client adapter JSON (downloaded from your Keycloak realm settings) */
33
+ config: TidecloakConfig;
34
+ /** Routes that always bypass authentication */
35
+ publicRoutes?: RoutePattern[];
36
+ /** Routes requiring a verified token and specific roles */
37
+ protectedRoutes?: ProtectedRoutesMap;
38
+ /** Called before any auth logic; return a Response to short‑circuit */
39
+ onRequest?: (ctx: {
40
+ token: string | null;
41
+ }, req: NextRequest) => NextResponse | void;
42
+ /** Called after successful auth and role checks; return a Response to override */
43
+ onSuccess?: (ctx: {
44
+ payload: Record<string, any>;
45
+ }, req: NextRequest) => NextResponse | void;
46
+ /** Called when auth or role check fails; return a Response to override */
47
+ onFailure?: (ctx: {
48
+ token: string | null;
49
+ }, req: NextRequest) => NextResponse | void;
50
+ /** Fallback for unhandled errors in middleware logic */
51
+ onError?: (err: any, req: NextRequest) => NextResponse;
52
+ }
53
+ /**
54
+ * Returns a Next.js Edge Middleware function enforcing TideCloak auth.
55
+ *
56
+ * Example usage in your `middleware.ts`:
57
+ *
58
+ * ```ts
59
+ * import keycloakConfig from './tidecloak.config.json'
60
+ * import { createTideMiddleware } from 'tidecloak-nextjs/server/tidecloakMiddleware'
61
+ *
62
+ * export default createTideMiddleware({
63
+ * config: keycloakConfig,
64
+ * publicRoutes: ['/', '/about'],
65
+ * protectedRoutes: {
66
+ * '/admin/*': ['admin'],
67
+ * '/api/private/*': ['user']
68
+ * }
69
+ * })
70
+ *
71
+ * export const config = {
72
+ * matcher: [
73
+ * '/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico)).*)',
74
+ * '/(api|trpc)(.*)'
75
+ * ],
76
+ * runtime: 'edge'
77
+ * }
78
+ * ```
79
+ */
80
+ export declare function createTideCloakMiddleware(opts: TideMiddlewareOptions): (req: NextRequest) => Promise<NextResponse<unknown>>;
81
+ export {};
82
+ //# sourceMappingURL=tidecloakMiddleware.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tidecloakMiddleware.d.ts","sourceRoot":"","sources":["../../../src/server/tidecloakMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAEvD,OAAO,EAGL,YAAY,EACZ,kBAAkB,EACnB,MAAM,iBAAiB,CAAA;AAExB,UAAU,GAAG;IACT,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,EAAE,OAAO,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,GAAG,EAAE;QACH,IAAI,EAAE,GAAG,EAAE,CAAC;KACb,CAAC;IAEF,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB;IACpC,kFAAkF;IAClF,MAAM,EAAE,eAAe,CAAA;IACvB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,YAAY,EAAE,CAAA;IAC7B,2DAA2D;IAC3D,eAAe,CAAC,EAAE,kBAAkB,CAAA;IACpC,uEAAuE;IACvE,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,GAAG,EAAE,WAAW,KAAK,YAAY,GAAG,IAAI,CAAA;IACpF,kFAAkF;IAClF,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,EAAE,GAAG,EAAE,WAAW,KAAK,YAAY,GAAG,IAAI,CAAA;IAC5F,0EAA0E;IAC1E,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE;QAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,EAAE,GAAG,EAAE,WAAW,KAAK,YAAY,GAAG,IAAI,CAAA;IACpF,wDAAwD;IACxD,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,KAAK,YAAY,CAAA;CACvD;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,qBAAqB,IAOlC,KAAK,WAAW,oCAyDlD"}
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@tidecloak/nextjs",
3
+ "version": "0.9.11",
4
+ "description": "TideCloak nextjs SDK",
5
+ "exports": {
6
+ ".": {
7
+ "import": "./dist/esm/index.js",
8
+ "types": "./dist/types/index.d.ts",
9
+ "require": "./dist/cjs/index.js"
10
+ },
11
+ "./server": {
12
+ "import": "./dist/esm/server/index.js",
13
+ "types": "./dist/types/server/index.d.ts",
14
+ "require": "./dist/cjs/server/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/tide-foundation/tidecloak-js.git"
26
+ },
27
+ "author": "Tide",
28
+ "license": "https://tide.org/licenses_tcoc2-0-0-en",
29
+ "keywords": [
30
+ "security",
31
+ "tidecloak",
32
+ "tide",
33
+ "authentication",
34
+ "oidc",
35
+ "oauth2",
36
+ "authorization",
37
+ "react"
38
+ ],
39
+ "peerDependencies": {
40
+ "next": ">=13",
41
+ "react": ">=18.0.0"
42
+ },
43
+ "scripts": {
44
+ "build:cjs": "tsc -p tsconfig.cjs.json",
45
+ "build:esm": "tsc -p tsconfig.esm.json",
46
+ "build": "npm run build:cjs && npm run build:esm",
47
+ "prepare": "npm run build"
48
+ },
49
+ "dependencies": {
50
+ "@tidecloak/react": "^0.9.11",
51
+ "@tidecloak/verify": "^0.9.12"
52
+ },
53
+ "devDependencies": {
54
+ "@types/react": "^19.1.8",
55
+ "@types/react-dom": "^19.1.6"
56
+ }
57
+ }