kinde-testkit 0.5.0 → 0.6.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/CHANGELOG.md +18 -0
- package/README.md +242 -12
- package/dist/chunk-33AHOLUN.js +183 -0
- package/dist/chunk-33AHOLUN.js.map +1 -0
- package/dist/chunk-GCOZVCZY.js +3430 -0
- package/dist/chunk-GCOZVCZY.js.map +1 -0
- package/dist/chunk-U2D47SCY.js +72 -0
- package/dist/chunk-U2D47SCY.js.map +1 -0
- package/dist/cli.js +178 -2849
- package/dist/cli.js.map +1 -0
- package/dist/cypress-support.js +119 -0
- package/dist/cypress-support.js.map +1 -0
- package/dist/cypress.cjs +4251 -0
- package/dist/cypress.d.cts +24 -0
- package/dist/cypress.d.ts +25 -0
- package/dist/cypress.js +23 -0
- package/dist/cypress.js.map +1 -0
- package/dist/handle-BERQZCyH.d.cts +32 -0
- package/dist/handle-Dh0UpIzG.d.ts +33 -0
- package/dist/index.cjs +2046 -101
- package/dist/index.d.cts +38 -463
- package/dist/index.d.ts +39 -463
- package/dist/index.js +90 -2822
- package/dist/index.js.map +1 -1
- package/dist/jest.cjs +4320 -0
- package/dist/jest.d.cts +17 -0
- package/dist/jest.d.ts +18 -0
- package/dist/jest.js +23 -0
- package/dist/jest.js.map +1 -0
- package/dist/playwright.d.ts +2 -54
- package/dist/server-BiODgeoB.d.ts +185 -0
- package/dist/server-ciWIscoQ.d.cts +579 -0
- package/dist/vitest.d.ts +7 -403
- package/dist/vitest.js +6 -2677
- package/dist/vitest.js.map +1 -1
- package/dist/webhooks-DJyCsbdF.d.ts +397 -0
- package/package.json +36 -4
- package/dist/index.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
- Cut the package from 923 kB to 321 kB. The ESM entry points now share one copy of the issuer instead of each bundling its own.
|
|
6
|
+
- With `--json`, CLI errors are one JSON object with `code`, `message` and `details`, so scripts and coding agents can read why a command failed. Error details no longer print twice.
|
|
7
|
+
- Add contract tests that compare discovery, JWKS, M2M token claims and Management API responses with a real Kinde business. Run them with `npm run test:contract`.
|
|
8
|
+
- Add a contents list and a section for coding agents to the README.
|
|
9
|
+
- Fix the Next.js example's Cypress outage test, which failed because the first visit landed on the testkit.
|
|
10
|
+
|
|
11
|
+
## 0.6.0
|
|
12
|
+
|
|
13
|
+
- Add `kinde-testkit/jest` with the same `useKindeTestkit()` and `kindeTest()` as the Vitest helper, for CommonJS and ESM test files.
|
|
14
|
+
- Add Cypress support: `setupKindeTestkit()` starts the testkit from `setupNodeEvents`, and `kinde-testkit/cypress/support` adds `cy.kindeSignIn()`, `cy.kindeSignOut()`, `cy.kindeToken()`, `cy.kindeInjectFailure()`, `cy.kindeClearFailures()`, `cy.kindeSendWebhook()` and `cy.kindeReset()`.
|
|
15
|
+
- Load seed files in YAML, JavaScript and TypeScript as well as JSON, and replace a running issuer's seed with `kinde-testkit seed <file>`.
|
|
16
|
+
- Add a dashboard at `/dashboard` with the seed, recent tokens, requests, webhook deliveries, failure rules and coverage, plus reset and send forms.
|
|
17
|
+
- Add an authentication coverage report: the testkit records which identity, organization, permission, token, session, M2M, API, webhook and outage cases a run produced. Read it with `kinde-testkit coverage`, and fail CI below a number with `--min`.
|
|
18
|
+
- Add a Dockerfile that runs the issuer as a non-root user with a health check, plus Docker Compose instructions.
|
|
19
|
+
- The Next.js example adds Cypress tests.
|
|
20
|
+
|
|
3
21
|
## 0.5.0
|
|
4
22
|
|
|
5
23
|
- Add the Management API at `/api/v1`: users, organizations, organization members, member roles and permissions, roles and permissions. It needs an M2M token for `<issuer>/api`, checks the scopes of seeded applications, and writes every change into the testkit's data. Changes send the matching webhooks. Unimplemented routes answer 404 `ROUTE_NOT_FOUND`.
|
package/README.md
CHANGED
|
@@ -7,9 +7,36 @@ Test apps that use Kinde without a live Kinde environment. kinde-testkit runs a
|
|
|
7
7
|
There are two ways to use it:
|
|
8
8
|
|
|
9
9
|
- **API and unit tests:** mint a token for any user, organization and permission set, including expired, tampered and unsigned tokens, and send it to your API.
|
|
10
|
-
- **Browser tests:** point your app at the testkit, and Playwright signs in as any seeded user through your app's own login route.
|
|
11
|
-
|
|
12
|
-
It also issues machine-to-machine tokens, answers the Management API and Account API calls your app makes, sends signed webhooks, makes Kinde's endpoints fail or slow down on demand
|
|
10
|
+
- **Browser tests:** point your app at the testkit, and Playwright or Cypress signs in as any seeded user through your app's own login route.
|
|
11
|
+
|
|
12
|
+
It also issues machine-to-machine tokens, answers the Management API and Account API calls your app makes, sends signed webhooks, and makes Kinde's endpoints fail or slow down on demand. A local dashboard shows what the testkit issued and answered, a coverage report shows which authentication cases your tests reached, and a `doctor` command checks your app's Kinde settings before a test run. It runs with Vitest, Jest, Playwright and Cypress, from the command line, or in Docker.
|
|
13
|
+
|
|
14
|
+
## Contents
|
|
15
|
+
|
|
16
|
+
- [Why it exists](#why-it-exists)
|
|
17
|
+
- [How it works](#how-it-works)
|
|
18
|
+
- [Install](#install)
|
|
19
|
+
- [Quick start with Vitest](#quick-start-with-vitest)
|
|
20
|
+
- [Browser tests with Playwright](#browser-tests-with-playwright)
|
|
21
|
+
- [Browser tests with Cypress](#browser-tests-with-cypress)
|
|
22
|
+
- [Machine-to-machine tokens](#machine-to-machine-tokens)
|
|
23
|
+
- [Webhooks](#webhooks)
|
|
24
|
+
- [Management API and Account API](#management-api-and-account-api)
|
|
25
|
+
- [Testing outages](#testing-outages)
|
|
26
|
+
- [Check your setup](#check-your-setup)
|
|
27
|
+
- [With Kinde's SDKs](#with-kindes-sdks)
|
|
28
|
+
- [Use with a coding agent](#use-with-a-coding-agent)
|
|
29
|
+
- [Checked against real Kinde](#checked-against-real-kinde)
|
|
30
|
+
- [Run the issuer from the command line](#run-the-issuer-from-the-command-line)
|
|
31
|
+
- [Dashboard](#dashboard)
|
|
32
|
+
- [Authentication coverage](#authentication-coverage)
|
|
33
|
+
- [Docker](#docker)
|
|
34
|
+
- [Invalid tokens](#invalid-tokens)
|
|
35
|
+
- [API](#api)
|
|
36
|
+
- [Endpoints](#endpoints)
|
|
37
|
+
- [Token shape](#token-shape)
|
|
38
|
+
- [What this release covers](#what-this-release-covers)
|
|
39
|
+
- [Safety](#safety)
|
|
13
40
|
|
|
14
41
|
## Why it exists
|
|
15
42
|
|
|
@@ -85,6 +112,25 @@ describe("projects API", () => {
|
|
|
85
112
|
|
|
86
113
|
`useKindeTestkit()` starts the issuer on a free port before the tests and stops it after. Point your app's issuer setting at `kinde.issuer` for the test run, so its middleware fetches keys from the testkit instead of Kinde.
|
|
87
114
|
|
|
115
|
+
### Jest
|
|
116
|
+
|
|
117
|
+
`kinde-testkit/jest` has the same `useKindeTestkit()` and `kindeTest()`. It works with CommonJS and ESM test files:
|
|
118
|
+
|
|
119
|
+
```js
|
|
120
|
+
const { scenario } = require("kinde-testkit");
|
|
121
|
+
const { useKindeTestkit } = require("kinde-testkit/jest");
|
|
122
|
+
|
|
123
|
+
const kinde = useKindeTestkit({ seed: "kinde-testkit.yaml" });
|
|
124
|
+
|
|
125
|
+
test("a viewer cannot delete a project", async () => {
|
|
126
|
+
const { headers } = await kinde.auth(scenario().user({ email: "viewer@example.test" }).organization("org_acme").authenticated());
|
|
127
|
+
const res = await request(app).delete("/projects/p1").set(headers);
|
|
128
|
+
expect(res.status).toBe(403);
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
It uses Jest's global `beforeAll` and `afterAll`. If you turn off `injectGlobals`, pass them from `@jest/globals`: `useKindeTestkit(options, { beforeAll, afterAll })`.
|
|
133
|
+
|
|
88
134
|
## Browser tests with Playwright
|
|
89
135
|
|
|
90
136
|
Start the testkit and your app from `playwright.config.ts`, with the app's Kinde settings pointed at the testkit:
|
|
@@ -155,6 +201,52 @@ A user with more than one organization needs `{ org }`, otherwise the fixture st
|
|
|
155
201
|
|
|
156
202
|
[`examples/nextjs`](examples/nextjs) is a working Next.js app on `@kinde-oss/kinde-auth-nextjs` with these tests.
|
|
157
203
|
|
|
204
|
+
## Browser tests with Cypress
|
|
205
|
+
|
|
206
|
+
Start the testkit from `setupNodeEvents`, and import the commands in your support file:
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
// cypress.config.ts
|
|
210
|
+
import { defineConfig } from "cypress";
|
|
211
|
+
import { setupKindeTestkit } from "kinde-testkit/cypress";
|
|
212
|
+
|
|
213
|
+
export default defineConfig({
|
|
214
|
+
e2e: {
|
|
215
|
+
baseUrl: "http://localhost:3000",
|
|
216
|
+
setupNodeEvents(on, config) {
|
|
217
|
+
return setupKindeTestkit(on, config, { start: { seed: "kinde-testkit.json" } });
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
// cypress/support/e2e.ts
|
|
225
|
+
import "kinde-testkit/cypress/support";
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
This starts the testkit on port 4400 for the run, so start your app with `KINDE_ISSUER_URL=http://localhost:4400`. If you already run `kinde-testkit start`, leave out `start`, and the commands use `KINDE_ISSUER_URL` or `http://localhost:4400`.
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
it("a viewer cannot delete projects", () => {
|
|
232
|
+
cy.kindeSignIn("viewer@example.test");
|
|
233
|
+
cy.visit("/projects");
|
|
234
|
+
cy.contains("button", /Delete/).should("not.exist");
|
|
235
|
+
});
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
| Command | What it does |
|
|
239
|
+
| --- | --- |
|
|
240
|
+
| `cy.kindeSignIn(email, { org, loginPath })` | Signs in through your app's login route with requests, then opens the app's callback. Fast, and needs no `cy.origin()` |
|
|
241
|
+
| `cy.kindeSignOut({ logoutPath })` | Opens your app's logout route |
|
|
242
|
+
| `cy.kindeToken(options)` | Yields an access token, with the same options as `POST /testkit/token` |
|
|
243
|
+
| `cy.kindeInjectFailure(rule)` | Makes a testkit endpoint fail, slow down or hang. Removed when the test ends |
|
|
244
|
+
| `cy.kindeClearFailures()` | Removes the failures this test added |
|
|
245
|
+
| `cy.kindeSendWebhook(event)` | Sends a signed webhook and yields the delivery results |
|
|
246
|
+
| `cy.kindeReset()` | Clears sessions, failure rules, deliveries and Management API changes |
|
|
247
|
+
|
|
248
|
+
`cy.kindeSignIn()` skips the sign-in page but runs everything else your app does: its login route, its state cookie and its callback, where the app exchanges the code for tokens. To test the sign-in page itself, visit your login route and use `cy.origin("http://localhost:4400", ...)`. The example app's `cypress/e2e/auth.cy.ts` does both.
|
|
249
|
+
|
|
158
250
|
### The sign-in page
|
|
159
251
|
|
|
160
252
|
The page at `/oauth2/auth` lists the seeded users. You can also type any email address: a user that is not in the seed file signs in without an organization. A user with more than one organization picks one on the next screen, unless the app sent `org_code`.
|
|
@@ -359,6 +451,31 @@ KINDE_ISSUER_URL=http://localhost:4400
|
|
|
359
451
|
|
|
360
452
|
The SDK accepts a plain `http://localhost` issuer. Its login, callback, refresh, logout and session-ending routes all work against the testkit. Its `validateToken` accepts kinde-testkit tokens and rejects the wrong-issuer, tampered, unknown-key and unsigned kinds. It does not reject expired tokens, because the SDK handles expiry by refreshing the session.
|
|
361
453
|
|
|
454
|
+
## Use with a coding agent
|
|
455
|
+
|
|
456
|
+
Every command takes `--json` and exits with code 1 when something fails. With `--json`, errors are one JSON object, `{ "error": { "code", "message", "details" } }`, so an agent can read the result and the reason without parsing text. A typical loop:
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
npx kinde-testkit start --json & # prints the issuer URL and seed counts as JSON
|
|
460
|
+
npx kinde-testkit doctor --json # checks the app's .env against the issuer
|
|
461
|
+
npx kinde-testkit token --user admin@example.test --json
|
|
462
|
+
npx kinde-testkit inspect "$TOKEN" --json # explains why a token was rejected
|
|
463
|
+
npx kinde-testkit coverage --url http://localhost:4400 --json # lists the auth cases not tested yet
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
Point the agent at three facts: the app's `KINDE_ISSUER_URL` must be the testkit's URL during tests, users and organizations come from `kinde-testkit.json` or `kinde-testkit.yaml`, and `kinde-testkit coverage` names the missing cases with the one-line change that tests each of them.
|
|
467
|
+
|
|
468
|
+
## Checked against real Kinde
|
|
469
|
+
|
|
470
|
+
`test/contract` sends the same requests to a real Kinde business and to the testkit and fails on any field Kinde returns that the testkit does not: discovery endpoints, JWKS keys, M2M token claims, the Management API's error for a missing token, and the fields of users, organizations, roles and permissions. It only reads. Run it with an M2M app that has the `read:users`, `read:organizations`, `read:roles` and `read:permissions` scopes in a test business:
|
|
471
|
+
|
|
472
|
+
```bash
|
|
473
|
+
KINDE_CONTRACT_DOMAIN=https://<your-business>.kinde.com \
|
|
474
|
+
KINDE_CONTRACT_CLIENT_ID=<client ID> \
|
|
475
|
+
KINDE_CONTRACT_CLIENT_SECRET=<client secret> \
|
|
476
|
+
npm run test:contract
|
|
477
|
+
```
|
|
478
|
+
|
|
362
479
|
## Run the issuer from the command line
|
|
363
480
|
|
|
364
481
|
```bash
|
|
@@ -374,6 +491,7 @@ Issuer: http://localhost:4400
|
|
|
374
491
|
Discovery: http://localhost:4400/.well-known/openid-configuration
|
|
375
492
|
JWKS: http://localhost:4400/.well-known/jwks
|
|
376
493
|
Token: POST http://localhost:4400/testkit/token
|
|
494
|
+
Dashboard: http://localhost:4400/dashboard
|
|
377
495
|
```
|
|
378
496
|
|
|
379
497
|
Then mint a token from another terminal:
|
|
@@ -385,7 +503,23 @@ curl -H "Authorization: Bearer $(npx kinde-testkit token --user admin@example.te
|
|
|
385
503
|
|
|
386
504
|
### Seed file
|
|
387
505
|
|
|
388
|
-
|
|
506
|
+
`start` loads the first of `kinde-testkit.json`, `.yaml`, `.yml`, `.ts`, `.mts`, `.js` and `.mjs` in the current folder. Pass `--seed <file>` to use another path. In code, `seed` takes an object or a file path. The same seed in YAML:
|
|
507
|
+
|
|
508
|
+
```yaml
|
|
509
|
+
users:
|
|
510
|
+
- id: kp_admin
|
|
511
|
+
email: admin@example.test
|
|
512
|
+
organizations:
|
|
513
|
+
- code: org_acme
|
|
514
|
+
name: Acme Inc.
|
|
515
|
+
memberships:
|
|
516
|
+
- user: kp_admin
|
|
517
|
+
organization: org_acme
|
|
518
|
+
roles: [admin]
|
|
519
|
+
permissions: [projects:read, projects:delete]
|
|
520
|
+
```
|
|
521
|
+
|
|
522
|
+
A JavaScript or TypeScript seed exports the object as its default export or as `seed`. TypeScript seeds need Node 22.18 or later, which runs TypeScript files directly. The JSON version, with every section:
|
|
389
523
|
|
|
390
524
|
```json
|
|
391
525
|
{
|
|
@@ -414,20 +548,100 @@ When `kinde-testkit.json` exists in the current folder, `start` loads it. Pass `
|
|
|
414
548
|
|
|
415
549
|
A token for a seeded user takes its roles and permissions from the membership in the active organization. A user with two memberships must name the organization. The issuer refuses a token for an organization the user does not belong to, because Kinde would not issue one. The issuer checks the whole seed when it starts and lists every problem at once.
|
|
416
550
|
|
|
551
|
+
`kinde-testkit seed <file>` replaces the seed of a running issuer, and `reset` returns to that seed after that. The issuer, audience and signing key stay the same, so apps that cached the keys keep working. `kinde-testkit stop` stops a running issuer.
|
|
552
|
+
|
|
553
|
+
## Dashboard
|
|
554
|
+
|
|
555
|
+
Open `http://localhost:4400/dashboard` while the testkit runs. It shows:
|
|
556
|
+
|
|
557
|
+
- users, organizations and memberships, with the permissions each member's token gets
|
|
558
|
+
- the latest tokens the testkit issued, with their claims
|
|
559
|
+
- the latest requests to Kinde's endpoints, with status and time taken. Codes, secrets and refresh tokens are hidden
|
|
560
|
+
- webhook deliveries, and a form to send an event
|
|
561
|
+
- failure rules, and a form to add one
|
|
562
|
+
- the coverage report
|
|
563
|
+
|
|
564
|
+
It has buttons to reset the testkit and to clear coverage. **Live updates** reloads the page every 3 seconds. The dashboard only adds a view: everything on it is also in the CLI and the HTTP endpoints. It only accepts actions from its own page, so another site you have open cannot reset or change the testkit.
|
|
565
|
+
|
|
566
|
+
## Authentication coverage
|
|
567
|
+
|
|
568
|
+
Most suites test that a user can sign in. Authorization bugs hide in the other cases: a token from another organization, an expired token, a user with no permissions. The testkit records which of these cases it produced during a run, grouped the way the bugs happen:
|
|
569
|
+
|
|
570
|
+
```bash
|
|
571
|
+
npx kinde-testkit coverage
|
|
572
|
+
```
|
|
573
|
+
|
|
574
|
+
```
|
|
575
|
+
Kinde authentication coverage
|
|
576
|
+
|
|
577
|
+
Identity 6/6
|
|
578
|
+
Organizations 4/5
|
|
579
|
+
Permissions 5/5
|
|
580
|
+
Token validation 3/8
|
|
581
|
+
Sessions 4/5
|
|
582
|
+
Machine-to-machine 0/4
|
|
583
|
+
Kinde APIs 2/4
|
|
584
|
+
Webhooks 5/5
|
|
585
|
+
Outages 2/4
|
|
586
|
+
|
|
587
|
+
Overall: 31/46
|
|
588
|
+
|
|
589
|
+
Not covered:
|
|
590
|
+
Organizations: Organization claim missing. Mint a token with invalid: "missing-organization".
|
|
591
|
+
Token validation: Wrong issuer. Mint a token with invalid: "wrong-issuer".
|
|
592
|
+
...
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
Turn it on with `useKindeTestkit({ coverage: true })` in Vitest or Jest, `setupKindeTestkit(on, config, { start: { coverage: true } })` in Cypress, or `kinde-testkit start --coverage`. Each test file writes its result to `.kinde-testkit/coverage/` when it ends, and `kinde-testkit coverage` adds them up. Clear the folder before a run with `kinde-testkit coverage --clear`, and fail CI below a number with `--min 30`. For a running issuer, `kinde-testkit coverage --url http://localhost:4400` reads it directly, and the dashboard shows the same report.
|
|
596
|
+
|
|
597
|
+
Coverage counts what the testkit produced, such as an expired token or a 503 from the token endpoint. It does not know what your test checked after that. A covered item means your suite sent that case to your app. Your assertions decide whether the app handled it.
|
|
598
|
+
|
|
599
|
+
## Docker
|
|
600
|
+
|
|
601
|
+
The repository has a Dockerfile. Build it straight from GitHub, then mount the folder with your seed file:
|
|
602
|
+
|
|
603
|
+
```bash
|
|
604
|
+
docker build -t kinde-testkit https://github.com/sholajegede/kinde-testkit.git
|
|
605
|
+
docker run --rm -p 4400:4400 -v "$PWD:/work" kinde-testkit
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
The container runs `kinde-testkit start` as a non-root user, loads the seed file from `/work`, and has a health check on `/testkit/health`. Its issuer is `http://localhost:4400`, which is right when your app and browser run on the host. In Docker Compose, where the app reaches the testkit by service name, set the issuer to the address your app uses:
|
|
609
|
+
|
|
610
|
+
```yaml
|
|
611
|
+
services:
|
|
612
|
+
kinde:
|
|
613
|
+
build: https://github.com/sholajegede/kinde-testkit.git
|
|
614
|
+
command: ["start", "--host", "0.0.0.0", "--port", "4400", "--allow-public", "--issuer", "http://kinde:4400"]
|
|
615
|
+
volumes: ["./:/work"]
|
|
616
|
+
app:
|
|
617
|
+
build: .
|
|
618
|
+
environment:
|
|
619
|
+
KINDE_ISSUER_URL: http://kinde:4400
|
|
620
|
+
depends_on:
|
|
621
|
+
kinde:
|
|
622
|
+
condition: service_healthy
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
The browser must reach the same issuer address as the app, because the issuer in the token has to match. Run browser tests on the host with the `localhost` setup, or run the browser in the same Compose network.
|
|
626
|
+
|
|
417
627
|
### Commands
|
|
418
628
|
|
|
419
629
|
| Command | What it does |
|
|
420
630
|
| --- | --- |
|
|
421
|
-
| `kinde-testkit start` | Start the issuer. Options: `--port`, `--host`, `--issuer`, `--audience`, `--client-id`, `--seed`, `--webhook`, `--https`, `--cert-dir`, `--allow-public`, `--json` |
|
|
631
|
+
| `kinde-testkit start` | Start the issuer. Options: `--port`, `--host`, `--issuer`, `--audience`, `--client-id`, `--seed`, `--webhook`, `--https`, `--cert-dir`, `--coverage`, `--allow-public`, `--json` |
|
|
632
|
+
| `kinde-testkit stop` | Stop a running issuer. Options: `--url` |
|
|
633
|
+
| `kinde-testkit seed <file>` | Replace a running issuer's seed with a JSON, YAML, JavaScript or TypeScript file. Options: `--url`, `--json` |
|
|
422
634
|
| `kinde-testkit cert` | Write the local HTTPS certificate and print the `NODE_EXTRA_CA_CERTS` line. Options: `--dir` |
|
|
423
635
|
| `kinde-testkit token` | Print a signed access token. Options: `--user`, `--org`, `--sub`, `--permissions`, `--roles`, `--expires-in`, `--invalid`, `--url`, `--json` |
|
|
424
636
|
| `kinde-testkit users` | List seeded users |
|
|
425
637
|
| `kinde-testkit organizations` | List seeded organizations |
|
|
426
638
|
| `kinde-testkit token --m2m` | Print a machine-to-machine token. Options: `--client-id`, `--scope`, `--org`, `--permissions`, `--expires-in`, `--invalid` |
|
|
427
639
|
| `kinde-testkit inspect [token]` | Decode a token and check it. Reads stdin when no token is given. Options: `--url`, `--json` |
|
|
640
|
+
| `kinde-testkit inspect --requests` | List the latest requests the issuer answered. `--tokens` lists the latest tokens it issued |
|
|
641
|
+
| `kinde-testkit coverage` | Show which authentication cases your tests covered. Options: `--url`, `--dir`, `--min`, `--clear`, `--json` |
|
|
428
642
|
| `kinde-testkit doctor` | Check your app's Kinde settings against the issuer. Options: `--url`, `--env-file`, `--json` |
|
|
429
643
|
| `kinde-testkit fail <path>` | Add a failure rule. Options: `--status`, `--delay`, `--hang`, `--times`, `--method`, `--list`, `--clear` |
|
|
430
|
-
| `kinde-testkit reset` | Clear sign-in sessions, failure rules, webhook deliveries
|
|
644
|
+
| `kinde-testkit reset` | Clear sign-in sessions, failure rules, webhook deliveries, endpoints added at runtime and Management API changes |
|
|
431
645
|
| `kinde-testkit webhook <type>` | Send a signed webhook. Options: `--user`, `--org`, `--role`, `--permission`, `--data`, `--to`, `--duplicate`, `--invalid`, `--types`, `--deliveries` |
|
|
432
646
|
|
|
433
647
|
Every command takes `--json` for CI scripts and coding agents.
|
|
@@ -469,12 +683,16 @@ import {
|
|
|
469
683
|
- `scenario()` builds a caller: `.user()`, `.organization()`, `.withoutOrganization()`, `.role()`, `.permissions()`, `.claims()`, then `.authenticated()` or `.unauthenticated()`. The result is plain JSON, so you can keep scenarios in a shared file and import them anywhere.
|
|
470
684
|
- `createKindeUser()` gives a user a stable id derived from the email, so the same email always maps to the same `kp_` id. `createKindeOrganization()` and `createMembership()` cover organizations and per-organization roles.
|
|
471
685
|
- `KindeTestkit.create({ issuer, audience, clientId, accessTokenExpiresIn, idTokenExpiresIn })` holds a signing key. Access tokens last 24 hours and ID tokens 1 hour by default, the same as Kinde's defaults. Use `token()`, `tokenFor(scenario)`, `idTokenFor(scenario)`, `m2mToken()`, `headersFor(scenario)`, `principalFor(scenario)`, `signPayload()` and `jwks()`.
|
|
472
|
-
- `startKindeTestkit({ port, seed, audience })` runs the issuer in-process and returns `{ url, issuer, jwksUri, testkit, failures, webhooks, reset(), close() }`. Pass `webhooks: { retryDelaysMs, timeoutMs }` to change webhook retries.
|
|
686
|
+
- `startKindeTestkit({ port, seed, audience, https, coverage })` runs the issuer in-process and returns `{ url, issuer, jwksUri, testkit, failures, webhooks, directory, coverage, activity, loadSeed(), reset(), close() }`. `seed` is an object or a file path. Pass `webhooks: { retryDelaysMs, timeoutMs }` to change webhook retries.
|
|
687
|
+
- `loadSeedFile(path)` reads a JSON, YAML, JavaScript or TypeScript seed. `readCoverageDirectory()`, `formatCoverageReport()` and `CoverageRecorder` are the functions behind `kinde-testkit coverage`.
|
|
688
|
+
- `appLoginUrl()`, `readSignInRequest()`, `signInForm()` and `resolveLocation()` are the steps `cy.kindeSignIn()` takes, for signing in with requests from another test runner.
|
|
473
689
|
- `inspectToken(token, { issuerUrl })` and `runDoctor({ url, env })` are the functions behind `inspect` and `doctor`. Both return a list of checks with `pass`, `warn` or `fail`.
|
|
474
690
|
- `createKindeToken(options)` signs with a shared default testkit whose issuer is `http://localhost:4400`, or `KINDE_TESTKIT_ISSUER` when set.
|
|
475
691
|
- `principalFromClaims(claims)` turns verified claims into `{ type, subject, issuer, organization, roles, permissions }`. `type` is `"user"`, or `"machine"` for M2M tokens.
|
|
476
692
|
|
|
477
|
-
From `kinde-testkit/vitest`: `useKindeTestkit()`, which also exposes `failures`, `webhooks` and `reset()`, and `kindeTest()`.
|
|
693
|
+
From `kinde-testkit/vitest` and `kinde-testkit/jest`: `useKindeTestkit()`, which also exposes `failures`, `webhooks`, `directory`, `coverage`, `activity`, `loadSeed()` and `reset()`, and `kindeTest()`.
|
|
694
|
+
|
|
695
|
+
From `kinde-testkit/cypress`: `setupKindeTestkit(on, config, { start, url })`. From `kinde-testkit/cypress/support`: the `cy.kinde*` commands and their types.
|
|
478
696
|
|
|
479
697
|
From `kinde-testkit/playwright`: `test` and `expect` with the `kinde` fixture, the `KindeTestOptions` type for your config, and `createKindeFixture(page, options)` for building the fixture into your own `test.extend()`.
|
|
480
698
|
|
|
@@ -497,7 +715,12 @@ From `kinde-testkit/playwright`: `test` and `expect` with the `kinde` fixture, t
|
|
|
497
715
|
| `POST /testkit/webhooks` | Send a webhook and return the deliveries |
|
|
498
716
|
| `GET /testkit/webhooks/deliveries`, `/testkit/webhooks/types` | Delivery log and the event types with built-in payloads |
|
|
499
717
|
| `GET`, `POST /testkit/webhooks/endpoints`, `DELETE /testkit/webhooks/endpoints/<id>` | List, add and remove webhook endpoints |
|
|
500
|
-
| `POST /testkit/reset` | Clear sign-in state, failure rules
|
|
718
|
+
| `POST /testkit/reset` | Clear sign-in state, failure rules, webhook deliveries and Management API changes |
|
|
719
|
+
| `POST /testkit/seed` | Replace the seed with the JSON body |
|
|
720
|
+
| `POST /testkit/stop` | Stop the issuer |
|
|
721
|
+
| `GET`, `DELETE /testkit/coverage` | Read or clear the coverage report |
|
|
722
|
+
| `GET /testkit/requests`, `/testkit/tokens` | The latest requests answered and tokens issued |
|
|
723
|
+
| `GET /dashboard` | The dashboard |
|
|
501
724
|
|
|
502
725
|
## Token shape
|
|
503
726
|
|
|
@@ -538,20 +761,27 @@ ID tokens carry `amr`, `aud` (the client ID), `auth_time`, `email`, `email_verif
|
|
|
538
761
|
| Switching the active organization | Implemented through `org_code` or the organization picker |
|
|
539
762
|
| Authorization code flow with sign-in page, PKCE and `state` | Implemented |
|
|
540
763
|
| Refresh tokens with rotation, revocation, logout and user profile | Implemented |
|
|
541
|
-
| Vitest
|
|
764
|
+
| Vitest and Jest helpers, Playwright fixture, Cypress commands | Implemented. Jest runs in the test suite. Cypress's sign-in steps are tested against the Next.js SDK |
|
|
542
765
|
| Accepted by `@kinde/jwt-validator` and the Next.js SDK's `validateToken` | Tested |
|
|
543
766
|
| Sign-in, organization switching and sign-out through `@kinde-oss/kinde-auth-nextjs` | Tested in Chrome with Playwright |
|
|
544
767
|
| Client credentials grant with Kinde's M2M token shape, seeded and org-scoped apps | Implemented |
|
|
545
768
|
| Failure injection: error status, delay, hang, by path, method and count | Implemented, tested through the Next.js SDK |
|
|
546
769
|
| `doctor`, `inspect` and `reset` commands | Implemented |
|
|
547
|
-
| Management API and
|
|
770
|
+
| Management API: users, organizations, members, roles and permissions | Implemented, tested with `@kinde/management-api-js` |
|
|
771
|
+
| Account API: permissions, roles, feature flags, properties and entitlements | Implemented, tested with `@kinde/js-utils` |
|
|
772
|
+
| Seed files in JSON, YAML, JavaScript and TypeScript, replaced at runtime | Implemented |
|
|
773
|
+
| Dashboard, request and token log | Implemented |
|
|
774
|
+
| Authentication coverage report | Implemented |
|
|
775
|
+
| Docker image | Dockerfile in the repository |
|
|
776
|
+
| Passwords, MFA, social sign-in and SAML | Not emulated. The sign-in page signs in any seeded user or email directly |
|
|
777
|
+
| Kinde's hosted pages, such as the self-serve portal | Not emulated. `portal_link` returns a placeholder page |
|
|
548
778
|
| Signed webhooks for the 16 event types in `@kinde/webhooks`, billing events with your data, retries, duplicates, forged and stale events | Implemented, tested with `@kinde/webhooks` and a Next.js route |
|
|
549
779
|
|
|
550
780
|
## Safety
|
|
551
781
|
|
|
552
782
|
kinde-testkit signs a token for any identity you ask for, so it keeps to localhost:
|
|
553
783
|
|
|
554
|
-
- The issuer binds to `127.0.0.1` and refuses any other interface unless you pass `--allow-public`.
|
|
784
|
+
- The issuer binds to `127.0.0.1` and refuses any other interface unless you pass `--allow-public`. The Docker image passes it, because the container's own network is where it listens. Publish the port to your machine only, as `-p 4400:4400` does.
|
|
555
785
|
- It makes a new signing key every time it starts. Two running issuers never share a key.
|
|
556
786
|
- It accepts any client ID, client secret and redirect URI, so it never needs your real app settings. That is only safe because it stays on localhost.
|
|
557
787
|
- Codes, refresh tokens and users who sign in with an unseeded email live in memory and are gone when it stops.
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// src/inspect.ts
|
|
2
|
+
import { createRemoteJWKSet, decodeJwt, decodeProtectedHeader, jwtVerify } from "jose";
|
|
3
|
+
async function inspectToken(token, options = {}) {
|
|
4
|
+
const checks = [];
|
|
5
|
+
const trimmed = token.trim();
|
|
6
|
+
let header = null;
|
|
7
|
+
let payload = null;
|
|
8
|
+
if (trimmed.split(".").length !== 3) {
|
|
9
|
+
checks.push({ name: "Format", status: "fail", detail: "A JWT has three parts separated by dots." });
|
|
10
|
+
return { kind: "unknown", header, payload, checks };
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
header = decodeProtectedHeader(trimmed);
|
|
14
|
+
payload = decodeJwt(trimmed);
|
|
15
|
+
} catch {
|
|
16
|
+
checks.push({ name: "Format", status: "fail", detail: "The header or payload is not valid base64url JSON." });
|
|
17
|
+
return { kind: "unknown", header, payload, checks };
|
|
18
|
+
}
|
|
19
|
+
checks.push({ name: "Format", status: "pass", detail: "Three base64url parts with JSON header and payload." });
|
|
20
|
+
checks.push(
|
|
21
|
+
header.alg === "RS256" ? { name: "Algorithm", status: "pass", detail: "RS256, the algorithm Kinde signs with." } : { name: "Algorithm", status: "fail", detail: `${String(header.alg)} is not RS256. Kinde tokens are always RS256.` }
|
|
22
|
+
);
|
|
23
|
+
const signer = typeof header.kid === "string" && header.kid.startsWith("kinde-testkit") ? "kinde-testkit" : "another issuer";
|
|
24
|
+
checks.push({ name: "Key", status: "pass", detail: `kid ${String(header.kid ?? "missing")} (${signer}).` });
|
|
25
|
+
const now = options.now ?? Math.floor(Date.now() / 1e3);
|
|
26
|
+
if (typeof payload.exp !== "number") {
|
|
27
|
+
checks.push({ name: "Expiry", status: "fail", detail: "No exp claim." });
|
|
28
|
+
} else if (payload.exp <= now) {
|
|
29
|
+
checks.push({ name: "Expiry", status: "fail", detail: `Expired ${formatSpan(now - payload.exp)} ago.` });
|
|
30
|
+
} else {
|
|
31
|
+
checks.push({ name: "Expiry", status: "pass", detail: `Expires in ${formatSpan(payload.exp - now)}.` });
|
|
32
|
+
}
|
|
33
|
+
if (typeof payload.iat === "number" && payload.iat > now + 60) {
|
|
34
|
+
checks.push({ name: "Issued at", status: "fail", detail: `iat is ${formatSpan(payload.iat - now)} in the future.` });
|
|
35
|
+
}
|
|
36
|
+
if (options.issuerUrl) {
|
|
37
|
+
const issuer = options.issuerUrl.replace(/\/+$/, "");
|
|
38
|
+
if (payload.iss !== issuer) {
|
|
39
|
+
checks.push({ name: "Issuer", status: "fail", detail: `iss is ${String(payload.iss)}, not ${issuer}.` });
|
|
40
|
+
} else {
|
|
41
|
+
checks.push({ name: "Issuer", status: "pass", detail: `Issued by ${issuer}.` });
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
await jwtVerify(trimmed, createRemoteJWKSet(new URL(`${issuer}/.well-known/jwks.json`)), { algorithms: ["RS256"] });
|
|
45
|
+
checks.push({ name: "Signature", status: "pass", detail: `Verified against ${issuer}/.well-known/jwks.json.` });
|
|
46
|
+
} catch (error) {
|
|
47
|
+
const code = error.code ?? "";
|
|
48
|
+
if (code === "ERR_JWT_EXPIRED" || code === "ERR_JWT_CLAIM_VALIDATION_FAILED") {
|
|
49
|
+
checks.push({ name: "Signature", status: "pass", detail: `Verified against ${issuer}/.well-known/jwks.json.` });
|
|
50
|
+
} else {
|
|
51
|
+
checks.push({ name: "Signature", status: "fail", detail: describeVerifyError(code, issuer) });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
} else {
|
|
55
|
+
checks.push({ name: "Signature", status: "warn", detail: "Not checked. Pass --url to verify against a running issuer." });
|
|
56
|
+
}
|
|
57
|
+
return { kind: kindOf(payload), header, payload, checks };
|
|
58
|
+
}
|
|
59
|
+
function kindOf(payload) {
|
|
60
|
+
if (Array.isArray(payload.gty) && payload.gty.includes("client_credentials")) return "m2m";
|
|
61
|
+
if ("email" in payload || "org_codes" in payload || "at_hash" in payload || "nonce" in payload) return "id";
|
|
62
|
+
if ("scp" in payload || "permissions" in payload || "org_code" in payload) return "access";
|
|
63
|
+
return "unknown";
|
|
64
|
+
}
|
|
65
|
+
function describeVerifyError(code, issuer) {
|
|
66
|
+
if (code === "ERR_JWKS_NO_MATCHING_KEY") return `No key in ${issuer}'s JWKS matches this token's kid.`;
|
|
67
|
+
if (code === "ERR_JWS_SIGNATURE_VERIFICATION_FAILED") return "The signature does not match the token. It was changed after signing.";
|
|
68
|
+
if (code === "ERR_JOSE_ALG_NOT_ALLOWED" || code === "ERR_JOSE_NOT_SUPPORTED") return "The token is not signed with RS256.";
|
|
69
|
+
if (code === "ERR_JWKS_TIMEOUT" || code === "ERR_JOSE_GENERIC") return `Could not fetch keys from ${issuer}.`;
|
|
70
|
+
return `Verification failed (${code || "unknown error"}).`;
|
|
71
|
+
}
|
|
72
|
+
function formatSpan(seconds) {
|
|
73
|
+
const s = Math.max(0, Math.round(seconds));
|
|
74
|
+
if (s < 60) return `${s}s`;
|
|
75
|
+
if (s < 3600) return `${Math.floor(s / 60)}m ${s % 60}s`;
|
|
76
|
+
if (s < 86400) return `${Math.floor(s / 3600)}h ${Math.floor(s % 3600 / 60)}m`;
|
|
77
|
+
return `${Math.floor(s / 86400)}d ${Math.floor(s % 86400 / 3600)}h`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// src/doctor.ts
|
|
81
|
+
var SECRET_FORMAT = /^[a-zA-Z0-9]{40,60}$/;
|
|
82
|
+
async function runDoctor(options) {
|
|
83
|
+
const url = options.url.replace(/\/+$/, "");
|
|
84
|
+
const checks = [];
|
|
85
|
+
let issuer = null;
|
|
86
|
+
try {
|
|
87
|
+
const health = await (await fetch(`${url}/testkit/health`)).json();
|
|
88
|
+
issuer = health.issuer ?? null;
|
|
89
|
+
checks.push({ name: "Issuer running", status: "pass", detail: `${url} answers, issuer ${issuer}.` });
|
|
90
|
+
} catch {
|
|
91
|
+
checks.push({ name: "Issuer running", status: "fail", detail: `Nothing answers at ${url}. Start it with "kinde-testkit start".` });
|
|
92
|
+
}
|
|
93
|
+
if (issuer) {
|
|
94
|
+
try {
|
|
95
|
+
const discovery = await (await fetch(`${url}/.well-known/openid-configuration`)).json();
|
|
96
|
+
checks.push(
|
|
97
|
+
discovery.issuer === issuer ? { name: "Discovery", status: "pass", detail: "The discovery document names the same issuer." } : { name: "Discovery", status: "fail", detail: `Discovery says ${String(discovery.issuer)}, health says ${issuer}.` }
|
|
98
|
+
);
|
|
99
|
+
} catch {
|
|
100
|
+
checks.push({ name: "Discovery", status: "fail", detail: "Could not read /.well-known/openid-configuration." });
|
|
101
|
+
}
|
|
102
|
+
try {
|
|
103
|
+
const jwks = await (await fetch(`${url}/.well-known/jwks.json`)).json();
|
|
104
|
+
const usable = (jwks.keys ?? []).filter((key) => key.kty === "RSA" && key.use === "sig");
|
|
105
|
+
checks.push(
|
|
106
|
+
usable.length > 0 ? { name: "JWKS", status: "pass", detail: `${usable.length} RS256 signing key at /.well-known/jwks.json.` } : { name: "JWKS", status: "fail", detail: "No RSA signing key at /.well-known/jwks.json." }
|
|
107
|
+
);
|
|
108
|
+
} catch {
|
|
109
|
+
checks.push({ name: "JWKS", status: "fail", detail: "Could not read /.well-known/jwks.json." });
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
const users = await (await fetch(`${url}/testkit/users`)).json();
|
|
113
|
+
checks.push(
|
|
114
|
+
users.length > 0 ? { name: "Seed", status: "pass", detail: `${users.length} seeded ${users.length === 1 ? "user" : "users"}.` } : { name: "Seed", status: "warn", detail: "No seeded users. The sign-in page still accepts any email, but those users have no organization." }
|
|
115
|
+
);
|
|
116
|
+
} catch {
|
|
117
|
+
checks.push({ name: "Seed", status: "warn", detail: "Could not read /testkit/users." });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
const env = options.env;
|
|
121
|
+
const configured = env.KINDE_ISSUER_URL?.trim().replace(/\/+$/, "");
|
|
122
|
+
if (!configured) {
|
|
123
|
+
checks.push({ name: "KINDE_ISSUER_URL", status: "fail", detail: "Not set. Set it to the testkit's issuer for test runs." });
|
|
124
|
+
} else if (/\.kinde\.com$/i.test(new URL(configured, "http://x").hostname)) {
|
|
125
|
+
checks.push({ name: "KINDE_ISSUER_URL", status: "fail", detail: `${configured} is a real Kinde domain. Tests would sign in against Kinde, not the testkit.` });
|
|
126
|
+
} else if (issuer && configured !== issuer) {
|
|
127
|
+
checks.push({ name: "KINDE_ISSUER_URL", status: "fail", detail: `${configured} does not match the testkit issuer ${issuer}. Token checks compare iss exactly.` });
|
|
128
|
+
} else {
|
|
129
|
+
checks.push({ name: "KINDE_ISSUER_URL", status: "pass", detail: `${configured}.` });
|
|
130
|
+
}
|
|
131
|
+
checks.push(
|
|
132
|
+
env.KINDE_CLIENT_ID ? { name: "KINDE_CLIENT_ID", status: "pass", detail: "Set. The testkit accepts any client ID." } : { name: "KINDE_CLIENT_ID", status: "fail", detail: "Not set. Kinde's SDKs refuse to start without it." }
|
|
133
|
+
);
|
|
134
|
+
const secret = env.KINDE_CLIENT_SECRET;
|
|
135
|
+
if (!secret) {
|
|
136
|
+
checks.push({ name: "KINDE_CLIENT_SECRET", status: "warn", detail: "Not set. Server-side SDKs, such as the Next.js SDK, need it." });
|
|
137
|
+
} else if (!SECRET_FORMAT.test(secret)) {
|
|
138
|
+
checks.push({ name: "KINDE_CLIENT_SECRET", status: "fail", detail: "The Next.js SDK only accepts 40 to 60 letters and digits." });
|
|
139
|
+
} else {
|
|
140
|
+
checks.push({ name: "KINDE_CLIENT_SECRET", status: "pass", detail: "Set, in the format Kinde's SDKs accept." });
|
|
141
|
+
}
|
|
142
|
+
if (issuer?.startsWith("https://")) {
|
|
143
|
+
checks.push(
|
|
144
|
+
env.NODE_EXTRA_CA_CERTS ? { name: "NODE_EXTRA_CA_CERTS", status: "pass", detail: `${env.NODE_EXTRA_CA_CERTS}.` } : {
|
|
145
|
+
name: "NODE_EXTRA_CA_CERTS",
|
|
146
|
+
status: "warn",
|
|
147
|
+
detail: "The testkit serves HTTPS with a local certificate. Start your app with NODE_EXTRA_CA_CERTS set to it, or Node will refuse the connection."
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
const site = env.KINDE_SITE_URL;
|
|
152
|
+
if (!site) {
|
|
153
|
+
checks.push({ name: "KINDE_SITE_URL", status: "warn", detail: "Not set. The Next.js SDK builds its callback URL from it." });
|
|
154
|
+
} else if (!/^https?:\/\//.test(site)) {
|
|
155
|
+
checks.push({ name: "KINDE_SITE_URL", status: "fail", detail: `${site} is not an http or https URL.` });
|
|
156
|
+
} else {
|
|
157
|
+
checks.push({ name: "KINDE_SITE_URL", status: "pass", detail: `${site}.` });
|
|
158
|
+
}
|
|
159
|
+
return { url, checks, ok: checks.every((check) => check.status !== "fail") };
|
|
160
|
+
}
|
|
161
|
+
function parseEnvFile(text) {
|
|
162
|
+
const values = {};
|
|
163
|
+
for (const line of text.split(/\r?\n/)) {
|
|
164
|
+
const match = /^\s*(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)\s*$/.exec(line);
|
|
165
|
+
if (!match) continue;
|
|
166
|
+
let value = match[2];
|
|
167
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
168
|
+
value = value.slice(1, -1);
|
|
169
|
+
} else {
|
|
170
|
+
value = value.replace(/\s+#.*$/, "");
|
|
171
|
+
}
|
|
172
|
+
values[match[1]] = value;
|
|
173
|
+
}
|
|
174
|
+
return values;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export {
|
|
178
|
+
inspectToken,
|
|
179
|
+
formatSpan,
|
|
180
|
+
runDoctor,
|
|
181
|
+
parseEnvFile
|
|
182
|
+
};
|
|
183
|
+
//# sourceMappingURL=chunk-33AHOLUN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/inspect.ts","../src/doctor.ts"],"sourcesContent":["import { createRemoteJWKSet, decodeJwt, decodeProtectedHeader, jwtVerify, type JWTPayload, type ProtectedHeaderParameters } from \"jose\";\n\nexport type CheckStatus = \"pass\" | \"warn\" | \"fail\";\n\nexport interface Check {\n name: string;\n status: CheckStatus;\n detail: string;\n}\n\nexport interface TokenInspection {\n kind: \"access\" | \"id\" | \"m2m\" | \"unknown\";\n header: ProtectedHeaderParameters | null;\n payload: JWTPayload | null;\n checks: Check[];\n}\n\nexport async function inspectToken(\n token: string,\n options: { issuerUrl?: string; now?: number } = {},\n): Promise<TokenInspection> {\n const checks: Check[] = [];\n const trimmed = token.trim();\n let header: ProtectedHeaderParameters | null = null;\n let payload: JWTPayload | null = null;\n\n if (trimmed.split(\".\").length !== 3) {\n checks.push({ name: \"Format\", status: \"fail\", detail: \"A JWT has three parts separated by dots.\" });\n return { kind: \"unknown\", header, payload, checks };\n }\n try {\n header = decodeProtectedHeader(trimmed);\n payload = decodeJwt(trimmed);\n } catch {\n checks.push({ name: \"Format\", status: \"fail\", detail: \"The header or payload is not valid base64url JSON.\" });\n return { kind: \"unknown\", header, payload, checks };\n }\n checks.push({ name: \"Format\", status: \"pass\", detail: \"Three base64url parts with JSON header and payload.\" });\n\n checks.push(\n header.alg === \"RS256\"\n ? { name: \"Algorithm\", status: \"pass\", detail: \"RS256, the algorithm Kinde signs with.\" }\n : { name: \"Algorithm\", status: \"fail\", detail: `${String(header.alg)} is not RS256. Kinde tokens are always RS256.` },\n );\n\n const signer = typeof header.kid === \"string\" && header.kid.startsWith(\"kinde-testkit\") ? \"kinde-testkit\" : \"another issuer\";\n checks.push({ name: \"Key\", status: \"pass\", detail: `kid ${String(header.kid ?? \"missing\")} (${signer}).` });\n\n const now = options.now ?? Math.floor(Date.now() / 1000);\n if (typeof payload.exp !== \"number\") {\n checks.push({ name: \"Expiry\", status: \"fail\", detail: \"No exp claim.\" });\n } else if (payload.exp <= now) {\n checks.push({ name: \"Expiry\", status: \"fail\", detail: `Expired ${formatSpan(now - payload.exp)} ago.` });\n } else {\n checks.push({ name: \"Expiry\", status: \"pass\", detail: `Expires in ${formatSpan(payload.exp - now)}.` });\n }\n if (typeof payload.iat === \"number\" && payload.iat > now + 60) {\n checks.push({ name: \"Issued at\", status: \"fail\", detail: `iat is ${formatSpan(payload.iat - now)} in the future.` });\n }\n\n if (options.issuerUrl) {\n const issuer = options.issuerUrl.replace(/\\/+$/, \"\");\n if (payload.iss !== issuer) {\n checks.push({ name: \"Issuer\", status: \"fail\", detail: `iss is ${String(payload.iss)}, not ${issuer}.` });\n } else {\n checks.push({ name: \"Issuer\", status: \"pass\", detail: `Issued by ${issuer}.` });\n }\n try {\n await jwtVerify(trimmed, createRemoteJWKSet(new URL(`${issuer}/.well-known/jwks.json`)), { algorithms: [\"RS256\"] });\n checks.push({ name: \"Signature\", status: \"pass\", detail: `Verified against ${issuer}/.well-known/jwks.json.` });\n } catch (error) {\n const code = (error as { code?: string }).code ?? \"\";\n if (code === \"ERR_JWT_EXPIRED\" || code === \"ERR_JWT_CLAIM_VALIDATION_FAILED\") {\n checks.push({ name: \"Signature\", status: \"pass\", detail: `Verified against ${issuer}/.well-known/jwks.json.` });\n } else {\n checks.push({ name: \"Signature\", status: \"fail\", detail: describeVerifyError(code, issuer) });\n }\n }\n } else {\n checks.push({ name: \"Signature\", status: \"warn\", detail: \"Not checked. Pass --url to verify against a running issuer.\" });\n }\n\n return { kind: kindOf(payload), header, payload, checks };\n}\n\nfunction kindOf(payload: JWTPayload): TokenInspection[\"kind\"] {\n if (Array.isArray(payload.gty) && payload.gty.includes(\"client_credentials\")) return \"m2m\";\n if (\"email\" in payload || \"org_codes\" in payload || \"at_hash\" in payload || \"nonce\" in payload) return \"id\";\n if (\"scp\" in payload || \"permissions\" in payload || \"org_code\" in payload) return \"access\";\n return \"unknown\";\n}\n\nfunction describeVerifyError(code: string, issuer: string): string {\n if (code === \"ERR_JWKS_NO_MATCHING_KEY\") return `No key in ${issuer}'s JWKS matches this token's kid.`;\n if (code === \"ERR_JWS_SIGNATURE_VERIFICATION_FAILED\") return \"The signature does not match the token. It was changed after signing.\";\n if (code === \"ERR_JOSE_ALG_NOT_ALLOWED\" || code === \"ERR_JOSE_NOT_SUPPORTED\") return \"The token is not signed with RS256.\";\n if (code === \"ERR_JWKS_TIMEOUT\" || code === \"ERR_JOSE_GENERIC\") return `Could not fetch keys from ${issuer}.`;\n return `Verification failed (${code || \"unknown error\"}).`;\n}\n\nexport function formatSpan(seconds: number): string {\n const s = Math.max(0, Math.round(seconds));\n if (s < 60) return `${s}s`;\n if (s < 3600) return `${Math.floor(s / 60)}m ${s % 60}s`;\n if (s < 86400) return `${Math.floor(s / 3600)}h ${Math.floor((s % 3600) / 60)}m`;\n return `${Math.floor(s / 86400)}d ${Math.floor((s % 86400) / 3600)}h`;\n}\n","import type { Check } from \"./inspect.js\";\n\nconst SECRET_FORMAT = /^[a-zA-Z0-9]{40,60}$/;\n\nexport interface DoctorReport {\n url: string;\n checks: Check[];\n ok: boolean;\n}\n\nexport async function runDoctor(options: { url: string; env: Record<string, string | undefined> }): Promise<DoctorReport> {\n const url = options.url.replace(/\\/+$/, \"\");\n const checks: Check[] = [];\n let issuer: string | null = null;\n\n try {\n const health = (await (await fetch(`${url}/testkit/health`)).json()) as { issuer?: string };\n issuer = health.issuer ?? null;\n checks.push({ name: \"Issuer running\", status: \"pass\", detail: `${url} answers, issuer ${issuer}.` });\n } catch {\n checks.push({ name: \"Issuer running\", status: \"fail\", detail: `Nothing answers at ${url}. Start it with \"kinde-testkit start\".` });\n }\n\n if (issuer) {\n try {\n const discovery = (await (await fetch(`${url}/.well-known/openid-configuration`)).json()) as { issuer?: string };\n checks.push(\n discovery.issuer === issuer\n ? { name: \"Discovery\", status: \"pass\", detail: \"The discovery document names the same issuer.\" }\n : { name: \"Discovery\", status: \"fail\", detail: `Discovery says ${String(discovery.issuer)}, health says ${issuer}.` },\n );\n } catch {\n checks.push({ name: \"Discovery\", status: \"fail\", detail: \"Could not read /.well-known/openid-configuration.\" });\n }\n try {\n const jwks = (await (await fetch(`${url}/.well-known/jwks.json`)).json()) as { keys?: Array<{ kty?: string; use?: string }> };\n const usable = (jwks.keys ?? []).filter((key) => key.kty === \"RSA\" && key.use === \"sig\");\n checks.push(\n usable.length > 0\n ? { name: \"JWKS\", status: \"pass\", detail: `${usable.length} RS256 signing key at /.well-known/jwks.json.` }\n : { name: \"JWKS\", status: \"fail\", detail: \"No RSA signing key at /.well-known/jwks.json.\" },\n );\n } catch {\n checks.push({ name: \"JWKS\", status: \"fail\", detail: \"Could not read /.well-known/jwks.json.\" });\n }\n try {\n const users = (await (await fetch(`${url}/testkit/users`)).json()) as unknown[];\n checks.push(\n users.length > 0\n ? { name: \"Seed\", status: \"pass\", detail: `${users.length} seeded ${users.length === 1 ? \"user\" : \"users\"}.` }\n : { name: \"Seed\", status: \"warn\", detail: \"No seeded users. The sign-in page still accepts any email, but those users have no organization.\" },\n );\n } catch {\n checks.push({ name: \"Seed\", status: \"warn\", detail: \"Could not read /testkit/users.\" });\n }\n }\n\n const env = options.env;\n const configured = env.KINDE_ISSUER_URL?.trim().replace(/\\/+$/, \"\");\n if (!configured) {\n checks.push({ name: \"KINDE_ISSUER_URL\", status: \"fail\", detail: \"Not set. Set it to the testkit's issuer for test runs.\" });\n } else if (/\\.kinde\\.com$/i.test(new URL(configured, \"http://x\").hostname)) {\n checks.push({ name: \"KINDE_ISSUER_URL\", status: \"fail\", detail: `${configured} is a real Kinde domain. Tests would sign in against Kinde, not the testkit.` });\n } else if (issuer && configured !== issuer) {\n checks.push({ name: \"KINDE_ISSUER_URL\", status: \"fail\", detail: `${configured} does not match the testkit issuer ${issuer}. Token checks compare iss exactly.` });\n } else {\n checks.push({ name: \"KINDE_ISSUER_URL\", status: \"pass\", detail: `${configured}.` });\n }\n\n checks.push(\n env.KINDE_CLIENT_ID\n ? { name: \"KINDE_CLIENT_ID\", status: \"pass\", detail: \"Set. The testkit accepts any client ID.\" }\n : { name: \"KINDE_CLIENT_ID\", status: \"fail\", detail: \"Not set. Kinde's SDKs refuse to start without it.\" },\n );\n\n const secret = env.KINDE_CLIENT_SECRET;\n if (!secret) {\n checks.push({ name: \"KINDE_CLIENT_SECRET\", status: \"warn\", detail: \"Not set. Server-side SDKs, such as the Next.js SDK, need it.\" });\n } else if (!SECRET_FORMAT.test(secret)) {\n checks.push({ name: \"KINDE_CLIENT_SECRET\", status: \"fail\", detail: \"The Next.js SDK only accepts 40 to 60 letters and digits.\" });\n } else {\n checks.push({ name: \"KINDE_CLIENT_SECRET\", status: \"pass\", detail: \"Set, in the format Kinde's SDKs accept.\" });\n }\n\n if (issuer?.startsWith(\"https://\")) {\n checks.push(\n env.NODE_EXTRA_CA_CERTS\n ? { name: \"NODE_EXTRA_CA_CERTS\", status: \"pass\", detail: `${env.NODE_EXTRA_CA_CERTS}.` }\n : {\n name: \"NODE_EXTRA_CA_CERTS\",\n status: \"warn\",\n detail: \"The testkit serves HTTPS with a local certificate. Start your app with NODE_EXTRA_CA_CERTS set to it, or Node will refuse the connection.\",\n },\n );\n }\n\n const site = env.KINDE_SITE_URL;\n if (!site) {\n checks.push({ name: \"KINDE_SITE_URL\", status: \"warn\", detail: \"Not set. The Next.js SDK builds its callback URL from it.\" });\n } else if (!/^https?:\\/\\//.test(site)) {\n checks.push({ name: \"KINDE_SITE_URL\", status: \"fail\", detail: `${site} is not an http or https URL.` });\n } else {\n checks.push({ name: \"KINDE_SITE_URL\", status: \"pass\", detail: `${site}.` });\n }\n\n return { url, checks, ok: checks.every((check) => check.status !== \"fail\") };\n}\n\nexport function parseEnvFile(text: string): Record<string, string> {\n const values: Record<string, string> = {};\n for (const line of text.split(/\\r?\\n/)) {\n const match = /^\\s*(?:export\\s+)?([A-Za-z_][A-Za-z0-9_]*)\\s*=\\s*(.*)\\s*$/.exec(line);\n if (!match) continue;\n let value = match[2]!;\n if ((value.startsWith('\"') && value.endsWith('\"')) || (value.startsWith(\"'\") && value.endsWith(\"'\"))) {\n value = value.slice(1, -1);\n } else {\n value = value.replace(/\\s+#.*$/, \"\");\n }\n values[match[1]!] = value;\n }\n return values;\n}\n"],"mappings":";AAAA,SAAS,oBAAoB,WAAW,uBAAuB,iBAAkE;AAiBjI,eAAsB,aACpB,OACA,UAAgD,CAAC,GACvB;AAC1B,QAAM,SAAkB,CAAC;AACzB,QAAM,UAAU,MAAM,KAAK;AAC3B,MAAI,SAA2C;AAC/C,MAAI,UAA6B;AAEjC,MAAI,QAAQ,MAAM,GAAG,EAAE,WAAW,GAAG;AACnC,WAAO,KAAK,EAAE,MAAM,UAAU,QAAQ,QAAQ,QAAQ,2CAA2C,CAAC;AAClG,WAAO,EAAE,MAAM,WAAW,QAAQ,SAAS,OAAO;AAAA,EACpD;AACA,MAAI;AACF,aAAS,sBAAsB,OAAO;AACtC,cAAU,UAAU,OAAO;AAAA,EAC7B,QAAQ;AACN,WAAO,KAAK,EAAE,MAAM,UAAU,QAAQ,QAAQ,QAAQ,qDAAqD,CAAC;AAC5G,WAAO,EAAE,MAAM,WAAW,QAAQ,SAAS,OAAO;AAAA,EACpD;AACA,SAAO,KAAK,EAAE,MAAM,UAAU,QAAQ,QAAQ,QAAQ,sDAAsD,CAAC;AAE7G,SAAO;AAAA,IACL,OAAO,QAAQ,UACX,EAAE,MAAM,aAAa,QAAQ,QAAQ,QAAQ,yCAAyC,IACtF,EAAE,MAAM,aAAa,QAAQ,QAAQ,QAAQ,GAAG,OAAO,OAAO,GAAG,CAAC,gDAAgD;AAAA,EACxH;AAEA,QAAM,SAAS,OAAO,OAAO,QAAQ,YAAY,OAAO,IAAI,WAAW,eAAe,IAAI,kBAAkB;AAC5G,SAAO,KAAK,EAAE,MAAM,OAAO,QAAQ,QAAQ,QAAQ,OAAO,OAAO,OAAO,OAAO,SAAS,CAAC,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