@tidecloak/create-nextjs 0.0.4 → 0.0.6
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/README.md +358 -0
- package/dist/cjs/create.cjs +28 -1
- package/dist/cjs/create.js.map +1 -1
- package/dist/esm/create.js +28 -1
- package/dist/esm/create.js.map +1 -1
- package/init/.env.example +2 -1
- package/init/tcinit.sh +2 -1
- package/package.json +2 -2
- package/template-js-app/app/layout.jsx +4 -3
- package/template-js-app/package.json +1 -1
- package/template-ts-app/app/layout.tsx +8 -4
- package/template-ts-app/package.json +1 -1
- package/template-ts-app/app/provider.tsx +0 -23
package/README.md
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
# TideCloak NextJS SDK
|
|
2
|
+
|
|
3
|
+
Jump to:
|
|
4
|
+
* [Quickstart](#quickstart)
|
|
5
|
+
* [Expanding](#expanding-from-the-template)
|
|
6
|
+
* [References](#references)
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
# Quickstart
|
|
10
|
+
|
|
11
|
+
Secure your Next.js app with TideCloak: authentication, session management, data encryption, and edge-middleware integration all in minutes.
|
|
12
|
+
|
|
13
|
+
### 1. Prerequisites
|
|
14
|
+
|
|
15
|
+
Before you begin, ensure you have:
|
|
16
|
+
|
|
17
|
+
* A [running](https://github.com/tide-foundation/tidecloak-gettingstarted) TideCloak server you have admin control over. No need to set anything up - just start the server.
|
|
18
|
+
|
|
19
|
+
As well as
|
|
20
|
+
* Next.js 13.5.7 or later
|
|
21
|
+
* React 18 or later
|
|
22
|
+
* Node.js ≥18.17.0
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### 2. Initialize the template project
|
|
26
|
+
|
|
27
|
+
> [!NOTE]
|
|
28
|
+
> The initialization will prompt you to create the realm and clients on your Tidecloak server. The script will also include Tide Realm Admin creation and IGA enablement.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
sudo apt update && sudo apt install -y curl jq
|
|
32
|
+
npm init @tidecloak/nextjs@latest my-app
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
#### 2.a Project structure
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
my-app/
|
|
39
|
+
├── app
|
|
40
|
+
| └── api/
|
|
41
|
+
| │ └── protected/
|
|
42
|
+
| │ └── route.js <- A protected API on your NextJS server that verifies the user's access token
|
|
43
|
+
| ├── auth/
|
|
44
|
+
| │ └── redirect/
|
|
45
|
+
| │ └── page.jsx <- A dedicated page to redirect the user back to once authentication is complete
|
|
46
|
+
| ├── home/
|
|
47
|
+
| | └── page.jsx <- Your home page the user goes to once autenticated
|
|
48
|
+
| ├── public/
|
|
49
|
+
│ | └── silent-check-sso.html
|
|
50
|
+
| ├── layout.jsx <- Entry point of your app before the user sees any actual pages
|
|
51
|
+
| └── page.jsx <- Your login page the user is brought to when they need to authenticate
|
|
52
|
+
|
|
|
53
|
+
├── tidecloak.json <- Where your Tidecloak configuration sits
|
|
54
|
+
├── next.config.json
|
|
55
|
+
├── middleware.js <- Run on each page navigation - this is where the Tideccloak token is verified
|
|
56
|
+
└── package.json
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 3. Test your app!
|
|
60
|
+
|
|
61
|
+
```npm run dev```
|
|
62
|
+
|
|
63
|
+
Here it is - [localhost:3000](http://localhost:3000)
|
|
64
|
+
🎉
|
|
65
|
+
---
|
|
66
|
+
# Expanding from the template
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
### Implementing encryption/decryption
|
|
71
|
+
You will first need to create the required realm roles that enable each user to encrypt/decrypt their own date of births.
|
|
72
|
+
|
|
73
|
+
> [!NOTE]
|
|
74
|
+
> You have already completed the pre-requisites asked for in the documentation to set up encrypt/decrypt roles AND also set up the required client.
|
|
75
|
+
|
|
76
|
+
[Set up encrypt/decrypt roles](https://docs.tidecloak.com/docs/EncryptDecrypt/SetupED)
|
|
77
|
+
|
|
78
|
+
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).
|
|
79
|
+
|
|
80
|
+
### Syntax Overview
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
// Encrypt payloads:
|
|
84
|
+
const encryptedArray = await doEncrypt([
|
|
85
|
+
{ data: /* string */, tags: ['tag1', 'tag2'] },
|
|
86
|
+
// …
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
// Decrypt blobs:
|
|
90
|
+
const decryptedArray = await doDecrypt([
|
|
91
|
+
{ encrypted: /* string from doEncrypt */, tags: ['tag1', 'tag2'] },
|
|
92
|
+
// …
|
|
93
|
+
]);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
> **Order guarantee**: the returned array matches the input order.
|
|
97
|
+
|
|
98
|
+
* **Encryption** requires access token roles `_tide_<tag>.selfencrypt` for each tag.
|
|
99
|
+
* **Decryption** requires access token roles `_tide_<tag>.selfdecrypt` for each tag.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
# References
|
|
103
|
+
|
|
104
|
+
This bundle provides:
|
|
105
|
+
|
|
106
|
+
* `<TideCloakProvider>` - application-level context
|
|
107
|
+
* `useTideCloak()` hook - access tokens and auth actions
|
|
108
|
+
* `verifyTideCloakToken()` - server-side JWT verification
|
|
109
|
+
* `<Authenticated>` / `<Unauthenticated>` - UI guards
|
|
110
|
+
* `doEncrypt()` / `doDecrypt()` - tag-based encryption/decryption
|
|
111
|
+
* `createTideCloakMiddleware()` - Edge middleware for route protection (supports both Pages & App routers)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
### Using the `useTideCloak` Hook
|
|
115
|
+
|
|
116
|
+
Use this hook anywhere to manage auth:
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
'use client'
|
|
120
|
+
import { useTideCloak } from '@tidecloak/nextjs';
|
|
121
|
+
|
|
122
|
+
function Header() {
|
|
123
|
+
const {
|
|
124
|
+
authenticated,
|
|
125
|
+
login,
|
|
126
|
+
logout,
|
|
127
|
+
token,
|
|
128
|
+
tokenExp,
|
|
129
|
+
refreshToken,
|
|
130
|
+
getValueFromToken,
|
|
131
|
+
getValueFromIdToken,
|
|
132
|
+
hasRealmRole,
|
|
133
|
+
hasClientRole,
|
|
134
|
+
doEncrypt,
|
|
135
|
+
doDecrypt,
|
|
136
|
+
} = useTideCloak();
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<header>
|
|
140
|
+
{authenticated ? (
|
|
141
|
+
<>
|
|
142
|
+
<span>Logged in</span>
|
|
143
|
+
<button onClick={logout}>Log Out</button>
|
|
144
|
+
</>
|
|
145
|
+
) : (
|
|
146
|
+
<button onClick={login}>Log In</button>
|
|
147
|
+
)}
|
|
148
|
+
{token && (
|
|
149
|
+
<small>Expires at {new Date(tokenExp * 1000).toLocaleTimeString()}</small>
|
|
150
|
+
)}
|
|
151
|
+
</header>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
| Name | Type | Description |
|
|
157
|
+
| ------------------------------------- | -------------------------------------------- | ----------------------------------------------------------------------- |
|
|
158
|
+
| `authenticated` | `boolean` | Whether the user is logged in. |
|
|
159
|
+
| `login()` / `logout()` | `() => void` | Trigger the login or logout flows. |
|
|
160
|
+
| `token`, `tokenExp` | `string`, `number` | Access token and its expiration timestamp. |
|
|
161
|
+
| Automatic token refresh | built-in | Tokens refresh silently on expiration-no manual setup needed. |
|
|
162
|
+
| `refreshToken()` | `() => Promise<boolean>` | Force a silent token renewal. |
|
|
163
|
+
| `getValueFromToken(key)` | `(key: string) => any` | Read a custom claim from the access token. |
|
|
164
|
+
| `getValueFromIdToken(key)` | `(key: string) => any` | Read a custom claim from the ID token. |
|
|
165
|
+
| `hasRealmRole(role)` | `(role: string) => boolean` | Check a realm-level role. |
|
|
166
|
+
| `hasClientRole(role, client?)` | `(role: string, client?: string) => boolean` | Check a client-level role; defaults to your app’s client ID if omitted. |
|
|
167
|
+
| `doEncrypt(data)` / `doDecrypt(data)` | `(data: any) => Promise<any>` | Encrypt or decrypt payloads via TideCloak’s built-in service. |
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
### Guard Components
|
|
171
|
+
|
|
172
|
+
Use out-of-the-box components to show or hide content:
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
'use client'
|
|
176
|
+
import { Authenticated, Unauthenticated } from '@tidecloak/nextjs';
|
|
177
|
+
|
|
178
|
+
function Dashboard() {
|
|
179
|
+
return (
|
|
180
|
+
<>
|
|
181
|
+
<Authenticated>
|
|
182
|
+
<h1>Dashboard</h1>
|
|
183
|
+
{/* Protected widgets */}
|
|
184
|
+
</Authenticated>
|
|
185
|
+
|
|
186
|
+
<Unauthenticated>
|
|
187
|
+
<p>Please log in to access the dashboard.</p>
|
|
188
|
+
</Unauthenticated>
|
|
189
|
+
</>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
* `<Authenticated>`: renders children only when `authenticated === true`
|
|
195
|
+
* `<Unauthenticated>`: renders children only when `authenticated === false`
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
### Edge Middleware with TideCloak
|
|
199
|
+
|
|
200
|
+
TideCloak’s Edge middleware works seamlessly with both the **Pages Router** and the **App Router** in Next.js:
|
|
201
|
+
|
|
202
|
+
* **Pages Router**: Place your `middleware.ts` file at the project root alongside `pages/`. The exported middleware will apply to both page and API routes.
|
|
203
|
+
* **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.
|
|
204
|
+
|
|
205
|
+
#### Installation
|
|
206
|
+
|
|
207
|
+
No additional install-middleware is included in `@tidecloak/nextjs`.
|
|
208
|
+
|
|
209
|
+
#### Options
|
|
210
|
+
|
|
211
|
+
* **`config`** (`TidecloakConfig`): Your Keycloak adapter JSON (downloaded from your TideCloak client settings).
|
|
212
|
+
* **`publicRoutes`** (`RoutePattern[]`): Paths to bypass authentication (strings/globs/regex/functions).
|
|
213
|
+
* **`protectedRoutes`** (`ProtectedRoutesMap`): Map of path patterns to arrays of required roles.
|
|
214
|
+
* **`onRequest`**<br>`(ctx: { token: string | null }, req: NextRequest) => NextResponse | void`<br>Hook before auth logic; can short-circuit by returning a `NextResponse`.
|
|
215
|
+
* **`onSuccess`**<br>`(ctx: { payload: Record<string, any> }, req: NextRequest) => NextResponse | void`<br>Hook after successful auth & role checks; override the response by returning one.
|
|
216
|
+
* **`onFailure`**<br>`(ctx: { token: string | null }, req: NextRequest) => NextResponse | void`<br>Hook when auth or role check fails; return a `NextResponse` to override.
|
|
217
|
+
* **`onError`**<br>`(err: any, req: NextRequest) => NextResponse`<br>Hook for unexpected errors in middleware logic.
|
|
218
|
+
|
|
219
|
+
#### Example Usage
|
|
220
|
+
|
|
221
|
+
Place the following `middleware.ts` at your project root (works for both Pages and App routers) to protect both page routes and API handlers:
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import { NextResponse } from 'next/server';
|
|
225
|
+
import keycloakConfig from './tidecloak.config.json';
|
|
226
|
+
import { createTideCloakMiddleware } from '@tidecloak/nextjs/server/tidecloakMiddleware';
|
|
227
|
+
|
|
228
|
+
export default createTideCloakMiddleware({
|
|
229
|
+
config: keycloakConfig,
|
|
230
|
+
publicRoutes: ['/', '/about'],
|
|
231
|
+
protectedRoutes: {
|
|
232
|
+
'/admin/*': ['admin'],
|
|
233
|
+
'/api/private/*': ['user'],
|
|
234
|
+
},
|
|
235
|
+
onFailure: ({ token }, req) => NextResponse.redirect(new URL('/login', req.url)),
|
|
236
|
+
onError: (err, req) => NextResponse.rewrite(new URL('/error', req.url)),
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
export const config = {
|
|
240
|
+
matcher: [
|
|
241
|
+
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico)).*)',
|
|
242
|
+
'/api/(.*)',
|
|
243
|
+
],
|
|
244
|
+
runtime: 'edge',
|
|
245
|
+
};
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Flow:**
|
|
249
|
+
|
|
250
|
+
1. Bypass any `publicRoutes`
|
|
251
|
+
2. Read the `kcToken` cookie
|
|
252
|
+
3. Invoke `onRequest` hook (if provided)
|
|
253
|
+
4. Match path against `protectedRoutes` patterns
|
|
254
|
+
5. Verify signature, issuer, and roles via `verifyTideCloakToken()`
|
|
255
|
+
6. On success: `onSuccess` hook or `NextResponse.next()`
|
|
256
|
+
7. On failure: `onFailure` hook or default 403 response
|
|
257
|
+
8. On unexpected errors: `onError` hook
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
#### Server‑Side Token Verification
|
|
261
|
+
|
|
262
|
+
You can verify TideCloak-issued JWTs on your server or API routes using `verifyTideCloakToken`:
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
import { verifyTideCloakToken } from '@tidecloak/nextjs/server';
|
|
266
|
+
|
|
267
|
+
// Returns the decoded payload if valid and roles pass, otherwise null
|
|
268
|
+
const payload = await verifyTideCloakToken(
|
|
269
|
+
config, // Your TideCloak adapter JSON
|
|
270
|
+
token, // Raw access token to verify
|
|
271
|
+
['admin', 'user'] // Optional roles; user must have at least one
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
if (!payload) {
|
|
275
|
+
// Invalid token or insufficient roles
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Under the hood, it uses `jose` for cryptographic verification and key management:
|
|
280
|
+
|
|
281
|
+
```ts
|
|
282
|
+
import { jwtVerify, createLocalJWKSet, createRemoteJWKSet } from 'jose';
|
|
283
|
+
|
|
284
|
+
export async function verifyTideCloakToken(config, token, allowedRoles = []) {
|
|
285
|
+
// Implementation checks token presence, issuer, signature,
|
|
286
|
+
// authorized party (azp), and at least one allowed role.
|
|
287
|
+
}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
**Parameters:**
|
|
291
|
+
|
|
292
|
+
* `config` (`object`): Your TideCloak adapter JSON (parsed Keycloak config).
|
|
293
|
+
* `token` (`string`): Access token string to verify.
|
|
294
|
+
* `allowedRoles` (`string[]`, optional): Array of realm or client roles; user must have at least one.
|
|
295
|
+
|
|
296
|
+
**Returns:**
|
|
297
|
+
|
|
298
|
+
* `Promise<object | null>`: Decoded JWT payload if valid and role check passes; otherwise `null`.
|
|
299
|
+
|
|
300
|
+
#### Example: Protecting an API Route
|
|
301
|
+
|
|
302
|
+
Protect your server-side endpoints by verifying the JWT before proceeding.
|
|
303
|
+
|
|
304
|
+
#### Pages Router
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
// pages/api/secure.ts
|
|
308
|
+
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
309
|
+
import { verifyTideCloakToken } from '@tidecloak/nextjs/server';
|
|
310
|
+
import config from '../../tidecloakAdapter.json';
|
|
311
|
+
|
|
312
|
+
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
|
313
|
+
// Extract token from cookie or Authorization header
|
|
314
|
+
const token = req.cookies.kcToken || req.headers.authorization?.split(' ')[1] || '';
|
|
315
|
+
|
|
316
|
+
// Verify signature, issuer, and roles (e.g., 'user')
|
|
317
|
+
const payload = await verifyTideCloakToken(config, token, ['user']);
|
|
318
|
+
if (!payload) {
|
|
319
|
+
return res.status(401).json({ error: 'Unauthorized' });
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Proceed with secure logic
|
|
323
|
+
res.status(200).json({ data: 'Secure data response' });
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
#### App Router
|
|
328
|
+
|
|
329
|
+
```ts
|
|
330
|
+
// app/api/secure/route.ts
|
|
331
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
332
|
+
import { verifyTideCloakToken } from '@tidecloak/nextjs/server';
|
|
333
|
+
import config from '../../../tidecloakAdapter.json';
|
|
334
|
+
|
|
335
|
+
export async function GET(req: NextRequest) {
|
|
336
|
+
// Extract token from cookie
|
|
337
|
+
const token = req.cookies.get('kcToken')?.value || '';
|
|
338
|
+
|
|
339
|
+
// Verify signature, issuer, and roles (e.g., 'user')
|
|
340
|
+
const payload = await verifyTideCloakToken(config, token, ['user']);
|
|
341
|
+
if (!payload) {
|
|
342
|
+
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Proceed with secure logic
|
|
346
|
+
return NextResponse.json({ data: 'Secure data response' });
|
|
347
|
+
}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
### Advanced & Best Practices
|
|
351
|
+
|
|
352
|
+
* **Auto-Refresh**: built into the provider-no manual timers.
|
|
353
|
+
* **Error Handling**: use the `initError` value from `useTideCloak`.
|
|
354
|
+
* **Custom Claims**: read via `getValueFromToken()` / `getValueFromIdToken()`.
|
|
355
|
+
* **Role-Based UI**: combine hooks & guard components for fine-grained control.
|
|
356
|
+
* **Lazy Initialization**: wrap `<TideCloakProvider>` around only protected sections in large apps.
|
|
357
|
+
|
|
358
|
+
---
|
package/dist/cjs/create.cjs
CHANGED
|
@@ -64,12 +64,17 @@ async function main() {
|
|
|
64
64
|
console.log(`"${targetDir}" is ready!`);
|
|
65
65
|
console.log(`"Start developing your app here: `);
|
|
66
66
|
console.log(` cd ${targetDir} && npm install`);
|
|
67
|
+
console.log(`To run init later: cd ${targetDir} && bash init/tcinit.sh`);
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
70
|
// retry
|
|
70
71
|
missing = ['curl', 'jq'].filter(cmd => !hasCommand(cmd));
|
|
71
72
|
if (missing.length > 0) {
|
|
72
73
|
console.warn(`Still missing: ${missing.join(', ')}. Skipping initialization.`);
|
|
74
|
+
console.log(`"${targetDir}" is ready!`);
|
|
75
|
+
console.log(`"Start developing your app here: `);
|
|
76
|
+
console.log(` cd ${targetDir} && npm install`);
|
|
77
|
+
console.log(`To run init later: cd ${targetDir} && bash init/tcinit.sh`);
|
|
73
78
|
return;
|
|
74
79
|
}
|
|
75
80
|
}
|
|
@@ -116,6 +121,27 @@ async function main() {
|
|
|
116
121
|
initial: 'password',
|
|
117
122
|
validate: (input) => input.trim().length > 0 || 'Please enter a password'
|
|
118
123
|
});
|
|
124
|
+
const { subscriptionEmail } = await prompt({
|
|
125
|
+
type: 'input',
|
|
126
|
+
name: 'subscriptionEmail',
|
|
127
|
+
message: 'Enter an email to manage your license',
|
|
128
|
+
initial: '',
|
|
129
|
+
validate: (input) => input.trim().length > 0 || 'Please enter an email'
|
|
130
|
+
});
|
|
131
|
+
const { termsAccepted } = await prompt([{
|
|
132
|
+
type: 'confirm',
|
|
133
|
+
name: 'termsAccepted',
|
|
134
|
+
message: 'I agree to the Terms & Conditions (https://tide.org/legal)',
|
|
135
|
+
initial: false
|
|
136
|
+
}]);
|
|
137
|
+
if (!termsAccepted) {
|
|
138
|
+
console.log('Initialization skipped.');
|
|
139
|
+
console.log(`"${targetDir}" is ready!`);
|
|
140
|
+
console.log(`"Start developing your app here: `);
|
|
141
|
+
console.log(`cd ${targetDir} && npm install`);
|
|
142
|
+
console.log(`To run init later: cd ${targetDir} && bash init/tcinit.sh`);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
119
145
|
// 6. Run initialization script
|
|
120
146
|
const { runInit } = await prompt({
|
|
121
147
|
type: 'confirm',
|
|
@@ -136,7 +162,8 @@ async function main() {
|
|
|
136
162
|
CLIENT_NAME: clientName,
|
|
137
163
|
CLIENT_APP_URL: clientAppUrl,
|
|
138
164
|
KC_USER: kcUser,
|
|
139
|
-
KC_PASSWORD: kcPassword
|
|
165
|
+
KC_PASSWORD: kcPassword,
|
|
166
|
+
SUBSCRIPTION_EMAIL: subscriptionEmail
|
|
140
167
|
}
|
|
141
168
|
});
|
|
142
169
|
console.log('Initialization script completed successfully.');
|
package/dist/cjs/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../create.ts"],"names":[],"mappings":";;;;;;A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AAC,EAAE,CAAC;oBAC7B,YAAE,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;oBACtC,OAAO,CAAC,GAAG,CAAC,4BAA4B,SAAS,kBAAkB,CAAC,CAAA;gBACtE,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,IAAI,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAA;gBAC1D,CAAC;YACH,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,OAAO,CAAC,KAAK,CAAC,8BAA8B,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;gBAC1D,OAAO,CAAC,GAAG,CAAC,gBAAgB,SAAS,yBAAyB,CAAC,CAAA;YACjE,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,yBAAyB,SAAS,yBAAyB,CAAC,CAAA;QAC1E,CAAC;IACH,CAAC;IAED,wBAAwB;IACxB,OAAO,CAAC,GAAG,CAAC,IAAI,SAAS,aAAa,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;IACvC,OAAO,CAAC,GAAG,CAAC,MAAM,SAAS,gCAAgC,CAAC,CAAA;AAC9D,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;IAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/dist/esm/create.js
CHANGED
|
@@ -59,12 +59,17 @@ async function main() {
|
|
|
59
59
|
console.log(`"${targetDir}" is ready!`);
|
|
60
60
|
console.log(`"Start developing your app here: `);
|
|
61
61
|
console.log(` cd ${targetDir} && npm install`);
|
|
62
|
+
console.log(`To run init later: cd ${targetDir} && bash init/tcinit.sh`);
|
|
62
63
|
return;
|
|
63
64
|
}
|
|
64
65
|
// retry
|
|
65
66
|
missing = ['curl', 'jq'].filter(cmd => !hasCommand(cmd));
|
|
66
67
|
if (missing.length > 0) {
|
|
67
68
|
console.warn(`Still missing: ${missing.join(', ')}. Skipping initialization.`);
|
|
69
|
+
console.log(`"${targetDir}" is ready!`);
|
|
70
|
+
console.log(`"Start developing your app here: `);
|
|
71
|
+
console.log(` cd ${targetDir} && npm install`);
|
|
72
|
+
console.log(`To run init later: cd ${targetDir} && bash init/tcinit.sh`);
|
|
68
73
|
return;
|
|
69
74
|
}
|
|
70
75
|
}
|
|
@@ -111,6 +116,27 @@ async function main() {
|
|
|
111
116
|
initial: 'password',
|
|
112
117
|
validate: (input) => input.trim().length > 0 || 'Please enter a password'
|
|
113
118
|
});
|
|
119
|
+
const { subscriptionEmail } = await prompt({
|
|
120
|
+
type: 'input',
|
|
121
|
+
name: 'subscriptionEmail',
|
|
122
|
+
message: 'Enter an email to manage your license',
|
|
123
|
+
initial: '',
|
|
124
|
+
validate: (input) => input.trim().length > 0 || 'Please enter an email'
|
|
125
|
+
});
|
|
126
|
+
const { termsAccepted } = await prompt([{
|
|
127
|
+
type: 'confirm',
|
|
128
|
+
name: 'termsAccepted',
|
|
129
|
+
message: 'I agree to the Terms & Conditions (https://tide.org/legal)',
|
|
130
|
+
initial: false
|
|
131
|
+
}]);
|
|
132
|
+
if (!termsAccepted) {
|
|
133
|
+
console.log('Initialization skipped.');
|
|
134
|
+
console.log(`"${targetDir}" is ready!`);
|
|
135
|
+
console.log(`"Start developing your app here: `);
|
|
136
|
+
console.log(`cd ${targetDir} && npm install`);
|
|
137
|
+
console.log(`To run init later: cd ${targetDir} && bash init/tcinit.sh`);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
114
140
|
// 6. Run initialization script
|
|
115
141
|
const { runInit } = await prompt({
|
|
116
142
|
type: 'confirm',
|
|
@@ -131,7 +157,8 @@ async function main() {
|
|
|
131
157
|
CLIENT_NAME: clientName,
|
|
132
158
|
CLIENT_APP_URL: clientAppUrl,
|
|
133
159
|
KC_USER: kcUser,
|
|
134
|
-
KC_PASSWORD: kcPassword
|
|
160
|
+
KC_PASSWORD: kcPassword,
|
|
161
|
+
SUBSCRIPTION_EMAIL: subscriptionEmail
|
|
135
162
|
}
|
|
136
163
|
});
|
|
137
164
|
console.log('Initialization script completed successfully.');
|
package/dist/esm/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../create.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAA;AAE3B,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,CAAC;QACH,QAAQ,CAAC,cAAc,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;QAClD,OAAO,IAAI,CAAA;IACb,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,CAAC,EAAE,AAAD,EAAG,SAAS,CAAC,GAAG,OAAO,CAAC,IAAgB,CAAA;IAChD,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACpD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IAED,qBAAqB;IACrB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAA4C;QAC3E,IAAI,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../create.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,QAAQ,EAAE,MAA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CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,CAAA;IAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/init/.env.example
CHANGED
package/init/tcinit.sh
CHANGED
|
@@ -26,6 +26,7 @@ ADMIN_ROLE_NAME="tide-realm-admin"
|
|
|
26
26
|
KC_USER="${KC_USER:-admin}"
|
|
27
27
|
KC_PASSWORD="${KC_PASSWORD:-password}"
|
|
28
28
|
CLIENT_NAME="${CLIENT_NAME:-myclient}"
|
|
29
|
+
SUBSCRIPTION_EMAIL="${SUBSCRIPTION_EMAIL:-test@demo.org}"
|
|
29
30
|
|
|
30
31
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
31
32
|
# sed -i portability
|
|
@@ -90,7 +91,7 @@ echo "🔐 Initializing Tide realm + IGA..."
|
|
|
90
91
|
response=$(curl -i -X POST "${TIDECLOAK_LOCAL_URL}/admin/realms/${REALM_NAME}/vendorResources/setUpTideRealm" \
|
|
91
92
|
-H "Authorization: Bearer ${TOKEN}" \
|
|
92
93
|
-H "Content-Type: application/x-www-form-urlencoded" \
|
|
93
|
-
--data-urlencode "email
|
|
94
|
+
--data-urlencode "email=${SUBSCRIPTION_EMAIL}" 2>&1)
|
|
94
95
|
|
|
95
96
|
# parse status code from response
|
|
96
97
|
status=$(printf "%s" "${response}" | awk '/HTTP\/1\.[01]/ { code=$2 } END { print code }')
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tidecloak/create-nextjs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"type": "module",
|
|
5
|
-
|
|
5
|
+
"description": "Scaffold a TideCloak-ready Next.js app with optional IAM setup and working auth — start building instantly with a live example",
|
|
6
6
|
"bin": {
|
|
7
7
|
"create-nextjs": "./dist/cjs/create.cjs"
|
|
8
8
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TideCloakProvider } from "@tidecloak/nextjs";
|
|
2
|
+
import tcConfig from '../tidecloak.json';
|
|
2
3
|
|
|
3
4
|
export const metadata = {
|
|
4
5
|
title: 'My Tidecloak App',
|
|
@@ -9,9 +10,9 @@ export default function RootLayout({ children }) {
|
|
|
9
10
|
return (
|
|
10
11
|
<html lang="en">
|
|
11
12
|
<body>
|
|
12
|
-
<
|
|
13
|
+
<TideCloakProvider config={tcConfig}>
|
|
13
14
|
{children}
|
|
14
|
-
</
|
|
15
|
+
</TideCloakProvider>
|
|
15
16
|
</body>
|
|
16
17
|
</html>
|
|
17
18
|
)
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Metadata } from 'next'
|
|
2
2
|
import type { ReactNode } from 'react'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
TideCloakProvider
|
|
5
|
+
} from '@tidecloak/nextjs'
|
|
6
|
+
import tcConfig from '../tidecloak.json'
|
|
7
|
+
|
|
4
8
|
|
|
5
9
|
export const metadata: Metadata = {
|
|
6
10
|
title: 'My Tidecloak App',
|
|
@@ -11,13 +15,13 @@ interface RootLayoutProps {
|
|
|
11
15
|
children: ReactNode
|
|
12
16
|
}
|
|
13
17
|
|
|
14
|
-
export default function RootLayout({ children }: RootLayoutProps)
|
|
18
|
+
export default function RootLayout({ children }: RootLayoutProps) {
|
|
15
19
|
return (
|
|
16
20
|
<html lang="en">
|
|
17
21
|
<body>
|
|
18
|
-
<
|
|
22
|
+
<TideCloakProvider config={tcConfig}>
|
|
19
23
|
{children}
|
|
20
|
-
</
|
|
24
|
+
</TideCloakProvider>
|
|
21
25
|
</body>
|
|
22
26
|
</html>
|
|
23
27
|
)
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import React, { type ReactNode } from 'react'
|
|
4
|
-
import {
|
|
5
|
-
TideCloakProvider,
|
|
6
|
-
type TideCloakConfig,
|
|
7
|
-
} from '@tidecloak/nextjs'
|
|
8
|
-
import tcConfig from '../tidecloak.json'
|
|
9
|
-
|
|
10
|
-
interface ProviderProps {
|
|
11
|
-
children: ReactNode
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function Provider({ children }: ProviderProps): JSX.Element {
|
|
15
|
-
// If tidecloak.json isn’t already typed, you can cast it:
|
|
16
|
-
const config = tcConfig as unknown as TideCloakConfig
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<TideCloakProvider config={config}>
|
|
20
|
-
{children}
|
|
21
|
-
</TideCloakProvider>
|
|
22
|
-
)
|
|
23
|
-
}
|