kinde-testkit 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +189 -11
- package/dist/cli.js +957 -117
- package/dist/cypress-support.d.ts +98 -0
- package/dist/cypress-support.js +119 -0
- package/dist/cypress-support.js.map +1 -0
- package/dist/cypress.cjs +4249 -0
- package/dist/cypress.cjs.map +1 -0
- package/dist/cypress.d.cts +118 -0
- package/dist/cypress.d.ts +118 -0
- package/dist/cypress.js +3324 -0
- package/dist/cypress.js.map +1 -0
- package/dist/index.cjs +2042 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +178 -3
- package/dist/index.d.ts +178 -3
- package/dist/index.js +846 -52
- package/dist/index.js.map +1 -1
- package/dist/jest.cjs +4318 -0
- package/dist/jest.cjs.map +1 -0
- package/dist/jest.d.cts +567 -0
- package/dist/jest.d.ts +567 -0
- package/dist/jest.js +3392 -0
- package/dist/jest.js.map +1 -0
- package/dist/vitest.d.ts +154 -1
- package/dist/vitest.js +757 -57
- package/dist/vitest.js.map +1 -1
- package/package.json +34 -3
package/dist/index.d.cts
CHANGED
|
@@ -156,7 +156,17 @@ interface IdTokenOptions {
|
|
|
156
156
|
clientId?: string;
|
|
157
157
|
nonce?: string;
|
|
158
158
|
}
|
|
159
|
+
/** Receives every token the testkit signs, for coverage and the dashboard. */
|
|
160
|
+
interface TokenObserver {
|
|
161
|
+
accessToken?(payload: Record<string, unknown>, invalid: InvalidTokenKind | undefined, token: string): void;
|
|
162
|
+
idToken?(payload: Record<string, unknown>, token: string): void;
|
|
163
|
+
anonymous?(): void;
|
|
164
|
+
}
|
|
159
165
|
declare class KindeTestkit {
|
|
166
|
+
private observers;
|
|
167
|
+
/** Calls the observer for every token signed from now on. Returns a function that stops it. */
|
|
168
|
+
observe(observer: TokenObserver): () => void;
|
|
169
|
+
private signAccess;
|
|
160
170
|
readonly issuer: string;
|
|
161
171
|
readonly audience: string[];
|
|
162
172
|
readonly clientId: string;
|
|
@@ -337,9 +347,11 @@ declare class Directory {
|
|
|
337
347
|
readonly seed: ResolvedSeed;
|
|
338
348
|
private readonly userMeta;
|
|
339
349
|
private readonly orgMeta;
|
|
340
|
-
private
|
|
350
|
+
private snapshot;
|
|
341
351
|
constructor(seed: ResolvedSeed);
|
|
342
352
|
restore(): void;
|
|
353
|
+
/** Replaces the whole seed with another resolved seed, and makes it the state reset() returns to. */
|
|
354
|
+
load(next: ResolvedSeed): void;
|
|
343
355
|
user(id: string): KindeUser | undefined;
|
|
344
356
|
meta(user: KindeUser): UserMeta;
|
|
345
357
|
isSuspended(userId: string): boolean;
|
|
@@ -457,8 +469,12 @@ declare class WebhookDispatcher {
|
|
|
457
469
|
private nextEndpoint;
|
|
458
470
|
private readonly retryDelaysMs;
|
|
459
471
|
private readonly timeoutMs;
|
|
472
|
+
/** Set by the server to record coverage. */
|
|
473
|
+
observe: (id: string) => void;
|
|
460
474
|
constructor(testkit: KindeTestkit, seed: ResolvedSeed, endpoints?: WebhookEndpointInput[], options?: WebhookOptions);
|
|
461
475
|
addEndpoint(input: WebhookEndpointInput): WebhookEndpoint;
|
|
476
|
+
/** Replaces the endpoints that came from the seed, as when a new seed is loaded. */
|
|
477
|
+
replaceSeededEndpoints(endpoints: WebhookEndpointInput[]): void;
|
|
462
478
|
removeEndpoint(id: string): boolean;
|
|
463
479
|
listEndpoints(): WebhookEndpoint[];
|
|
464
480
|
deliveries(): WebhookDelivery[];
|
|
@@ -477,14 +493,109 @@ declare class WebhookDispatcher {
|
|
|
477
493
|
private requireUser;
|
|
478
494
|
}
|
|
479
495
|
|
|
496
|
+
interface RequestEntry {
|
|
497
|
+
at: string;
|
|
498
|
+
method: string;
|
|
499
|
+
path: string;
|
|
500
|
+
status: number;
|
|
501
|
+
durationMs: number;
|
|
502
|
+
injected: boolean;
|
|
503
|
+
}
|
|
504
|
+
interface TokenEntry {
|
|
505
|
+
at: string;
|
|
506
|
+
kind: "access" | "m2m" | "id";
|
|
507
|
+
subject: string | null;
|
|
508
|
+
organization: string | null;
|
|
509
|
+
permissions: string[];
|
|
510
|
+
roles: string[];
|
|
511
|
+
invalid: InvalidTokenKind | null;
|
|
512
|
+
expiresAt: string | null;
|
|
513
|
+
claims: Record<string, unknown>;
|
|
514
|
+
token: string;
|
|
515
|
+
}
|
|
516
|
+
/** Keeps the latest requests and tokens for the dashboard and `kinde-testkit inspect --requests`. */
|
|
517
|
+
declare class ActivityLog {
|
|
518
|
+
private requestLog;
|
|
519
|
+
private tokenLog;
|
|
520
|
+
request(entry: Omit<RequestEntry, "at" | "path"> & {
|
|
521
|
+
path: string;
|
|
522
|
+
query: URLSearchParams;
|
|
523
|
+
}): void;
|
|
524
|
+
token(kind: TokenEntry["kind"], claims: Record<string, unknown>, invalid: InvalidTokenKind | undefined, token: string): void;
|
|
525
|
+
requests(): RequestEntry[];
|
|
526
|
+
tokens(): TokenEntry[];
|
|
527
|
+
reset(): void;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
interface CoverageItem {
|
|
531
|
+
id: string;
|
|
532
|
+
label: string;
|
|
533
|
+
hint: string;
|
|
534
|
+
}
|
|
535
|
+
interface CoverageGroup {
|
|
536
|
+
name: string;
|
|
537
|
+
items: CoverageItem[];
|
|
538
|
+
}
|
|
539
|
+
declare const COVERAGE_GROUPS: CoverageGroup[];
|
|
540
|
+
interface CoverageGroupResult {
|
|
541
|
+
name: string;
|
|
542
|
+
covered: number;
|
|
543
|
+
total: number;
|
|
544
|
+
items: Array<CoverageItem & {
|
|
545
|
+
covered: boolean;
|
|
546
|
+
count: number;
|
|
547
|
+
}>;
|
|
548
|
+
}
|
|
549
|
+
interface CoverageReport {
|
|
550
|
+
covered: number;
|
|
551
|
+
total: number;
|
|
552
|
+
groups: CoverageGroupResult[];
|
|
553
|
+
}
|
|
554
|
+
interface CoverageSnapshot {
|
|
555
|
+
version: 1;
|
|
556
|
+
hits: Record<string, number>;
|
|
557
|
+
}
|
|
558
|
+
/** Records which authentication scenarios the testkit produced during a test run. */
|
|
559
|
+
declare class CoverageRecorder {
|
|
560
|
+
private hits;
|
|
561
|
+
private userOrganizations;
|
|
562
|
+
private organizationUsers;
|
|
563
|
+
private organizationPermissionSets;
|
|
564
|
+
hit(id: string): void;
|
|
565
|
+
/** Called for every access token the testkit signs. */
|
|
566
|
+
observeAccessToken(payload: Record<string, unknown>, invalid: InvalidTokenKind | undefined): void;
|
|
567
|
+
report(): CoverageReport;
|
|
568
|
+
snapshot(): CoverageSnapshot;
|
|
569
|
+
reset(): void;
|
|
570
|
+
/** Writes this run's snapshot to the coverage folder, so separate test files can be merged. */
|
|
571
|
+
write(directory?: string): string;
|
|
572
|
+
}
|
|
573
|
+
declare const DEFAULT_COVERAGE_DIRECTORY: string;
|
|
574
|
+
declare function buildReport(hits: Record<string, number>): CoverageReport;
|
|
575
|
+
declare function mergeSnapshots(snapshots: CoverageSnapshot[]): Record<string, number>;
|
|
576
|
+
/** Reads and merges every snapshot in the coverage folder. */
|
|
577
|
+
declare function readCoverageDirectory(directory?: string): {
|
|
578
|
+
files: number;
|
|
579
|
+
report: CoverageReport;
|
|
580
|
+
};
|
|
581
|
+
declare function clearCoverageDirectory(directory?: string): void;
|
|
582
|
+
declare function formatCoverageReport(report: CoverageReport, options?: {
|
|
583
|
+
missing?: boolean;
|
|
584
|
+
}): string;
|
|
585
|
+
|
|
480
586
|
interface StartKindeTestkitOptions {
|
|
481
587
|
port?: number;
|
|
482
588
|
host?: string;
|
|
483
589
|
issuer?: string;
|
|
484
590
|
audience?: string | string[];
|
|
485
591
|
clientId?: string;
|
|
486
|
-
seed
|
|
592
|
+
/** A seed object, or the path of a JSON, YAML, JavaScript or TypeScript seed file. */
|
|
593
|
+
seed?: TestkitSeed | string;
|
|
487
594
|
allowPublic?: boolean;
|
|
595
|
+
/** Write this run's authentication coverage to a folder when the testkit closes. */
|
|
596
|
+
coverage?: boolean | {
|
|
597
|
+
directory?: string;
|
|
598
|
+
};
|
|
488
599
|
webhooks?: WebhookOptions;
|
|
489
600
|
https?: boolean | {
|
|
490
601
|
certDirectory?: string;
|
|
@@ -501,6 +612,10 @@ interface RunningKindeTestkit {
|
|
|
501
612
|
webhooks: WebhookDispatcher;
|
|
502
613
|
directory: Directory;
|
|
503
614
|
certificatePath: string | null;
|
|
615
|
+
coverage: CoverageRecorder;
|
|
616
|
+
activity: ActivityLog;
|
|
617
|
+
/** Replaces the seed while the issuer runs. reset() returns to the new seed. */
|
|
618
|
+
loadSeed(seed: TestkitSeed): void;
|
|
504
619
|
reset(): void;
|
|
505
620
|
close(): Promise<void>;
|
|
506
621
|
}
|
|
@@ -555,4 +670,64 @@ declare function runDoctor(options: {
|
|
|
555
670
|
}): Promise<DoctorReport>;
|
|
556
671
|
declare function parseEnvFile(text: string): Record<string, string>;
|
|
557
672
|
|
|
558
|
-
|
|
673
|
+
interface KindeTestAuth {
|
|
674
|
+
token: string | null;
|
|
675
|
+
headers: Record<string, string>;
|
|
676
|
+
principal: KindePrincipal | null;
|
|
677
|
+
request: {
|
|
678
|
+
headers: Record<string, string>;
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
declare function kindeTest(options: {
|
|
682
|
+
scenario: Scenario;
|
|
683
|
+
testkit?: KindeTestkit;
|
|
684
|
+
token?: ScenarioTokenOverrides;
|
|
685
|
+
}): Promise<KindeTestAuth>;
|
|
686
|
+
interface KindeTestkitHandle {
|
|
687
|
+
readonly url: string;
|
|
688
|
+
readonly issuer: string;
|
|
689
|
+
readonly jwksUri: string;
|
|
690
|
+
readonly testkit: KindeTestkit;
|
|
691
|
+
readonly failures: FailureInjector;
|
|
692
|
+
readonly webhooks: WebhookDispatcher;
|
|
693
|
+
readonly directory: Directory;
|
|
694
|
+
readonly coverage: CoverageRecorder;
|
|
695
|
+
readonly activity: ActivityLog;
|
|
696
|
+
readonly certificatePath: string | null;
|
|
697
|
+
auth(scenario: Scenario, token?: ScenarioTokenOverrides): Promise<KindeTestAuth>;
|
|
698
|
+
loadSeed(seed: TestkitSeed): void;
|
|
699
|
+
reset(): void;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/** Files `kinde-testkit start` looks for, in this order, when no --seed is given. */
|
|
703
|
+
declare const DEFAULT_SEED_FILES: string[];
|
|
704
|
+
declare function findSeedFile(directory?: string): string | undefined;
|
|
705
|
+
/**
|
|
706
|
+
* Reads a seed from JSON, YAML, or a JavaScript or TypeScript module.
|
|
707
|
+
* A module exports the seed as its default export or as `seed`.
|
|
708
|
+
* TypeScript files need a Node version that runs TypeScript (22.18 or later).
|
|
709
|
+
*/
|
|
710
|
+
declare function loadSeedFile(path: string): Promise<TestkitSeed>;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Steps for signing in through the testkit with plain HTTP requests instead of a browser page.
|
|
714
|
+
* The Cypress commands use these. No Node APIs here, because Cypress bundles this file for the browser.
|
|
715
|
+
*/
|
|
716
|
+
interface RequestSignInOptions {
|
|
717
|
+
/** Email address or ID of the user. */
|
|
718
|
+
user: string;
|
|
719
|
+
/** Active organization, for users in more than one. */
|
|
720
|
+
org?: string;
|
|
721
|
+
}
|
|
722
|
+
/** The app's login route, with the hints the testkit sign-in page reads. */
|
|
723
|
+
declare function appLoginUrl(loginPath: string, options: RequestSignInOptions): string;
|
|
724
|
+
/** Reads the hidden request field from the testkit sign-in page. */
|
|
725
|
+
declare function readSignInRequest(html: string): string;
|
|
726
|
+
/** The form the sign-in page posts to /oauth2/auth/login. */
|
|
727
|
+
declare function signInForm(request: string, options: RequestSignInOptions): Record<string, string>;
|
|
728
|
+
/** Explains why the testkit did not redirect back to the app after the form was posted. */
|
|
729
|
+
declare function signInFailure(status: number, html: string, options: RequestSignInOptions): Error;
|
|
730
|
+
/** Resolves a Location header, which can be relative, against the URL that sent it. */
|
|
731
|
+
declare function resolveLocation(location: string, from: string): string;
|
|
732
|
+
|
|
733
|
+
export { type ActiveFailure, ActivityLog, type AuthenticatedScenario, BILLING_EVENT_TYPES, COVERAGE_GROUPS, type Check, type CheckStatus, type CoverageGroup, type CoverageGroupResult, type CoverageItem, CoverageRecorder, type CoverageReport, type CoverageSnapshot, type CreateKindeOrganizationOptions, type CreateKindeUserOptions, type CreateMembershipOptions, DEFAULT_AUTH_METHODS, DEFAULT_CLIENT_ID, DEFAULT_COVERAGE_DIRECTORY, DEFAULT_ISSUER, DEFAULT_M2M_CLIENT_ID, DEFAULT_SCOPES, DEFAULT_SEED_FILES, Directory, type DoctorReport, type Duration, FailureInjector, type FailureRule, INVALID_TOKEN_KINDS, type IdTokenOptions, type InvalidTokenKind, type KindeApplication, type KindeMembership, type KindeOrganization, type KindePrincipal, type KindeRole, type KindeTestAuth, KindeTestkit, type KindeTestkitHandle, type KindeTestkitOptions, type KindeTokenOptions, type KindeUser, type LocalCertificate, type M2MTokenOptions, type RequestEntry, type RequestSignInOptions, type ResolvedSeed, type RunningKindeTestkit, type Scenario, ScenarioBuilder, type ScenarioTokenOverrides, type SendWebhookOptions, type StartKindeTestkitOptions, TestkitError, type TestkitErrorCode, type TestkitSeed, type TokenEntry, type TokenInspection, type TokenObserver, type UnauthenticatedScenario, WEBHOOK_EVENT_TYPES, type WebhookAttempt, type WebhookDelivery, WebhookDispatcher, type WebhookEndpoint, type WebhookEndpointInput, type WebhookInvalidKind, type WebhookOptions, type WebhookSource, appLoginUrl, buildReport, clearCoverageDirectory, createKindeOrganization, createKindeToken, createKindeUser, createLocalCertificate, createMembership, ensureLocalCertificate, findSeedFile, formatCoverageReport, getDefaultTestkit, inspectToken, isAuthenticated, kindeTest, loadSeedFile, mergeSnapshots, parseEnvFile, principalFromClaims, readCoverageDirectory, readSignInRequest, resetFactories, resolveLocation, resolveSeed, runDoctor, scenario, seedScenario, signInFailure, signInForm, startKindeTestkit, toKindeRole };
|
package/dist/index.d.ts
CHANGED
|
@@ -156,7 +156,17 @@ interface IdTokenOptions {
|
|
|
156
156
|
clientId?: string;
|
|
157
157
|
nonce?: string;
|
|
158
158
|
}
|
|
159
|
+
/** Receives every token the testkit signs, for coverage and the dashboard. */
|
|
160
|
+
interface TokenObserver {
|
|
161
|
+
accessToken?(payload: Record<string, unknown>, invalid: InvalidTokenKind | undefined, token: string): void;
|
|
162
|
+
idToken?(payload: Record<string, unknown>, token: string): void;
|
|
163
|
+
anonymous?(): void;
|
|
164
|
+
}
|
|
159
165
|
declare class KindeTestkit {
|
|
166
|
+
private observers;
|
|
167
|
+
/** Calls the observer for every token signed from now on. Returns a function that stops it. */
|
|
168
|
+
observe(observer: TokenObserver): () => void;
|
|
169
|
+
private signAccess;
|
|
160
170
|
readonly issuer: string;
|
|
161
171
|
readonly audience: string[];
|
|
162
172
|
readonly clientId: string;
|
|
@@ -337,9 +347,11 @@ declare class Directory {
|
|
|
337
347
|
readonly seed: ResolvedSeed;
|
|
338
348
|
private readonly userMeta;
|
|
339
349
|
private readonly orgMeta;
|
|
340
|
-
private
|
|
350
|
+
private snapshot;
|
|
341
351
|
constructor(seed: ResolvedSeed);
|
|
342
352
|
restore(): void;
|
|
353
|
+
/** Replaces the whole seed with another resolved seed, and makes it the state reset() returns to. */
|
|
354
|
+
load(next: ResolvedSeed): void;
|
|
343
355
|
user(id: string): KindeUser | undefined;
|
|
344
356
|
meta(user: KindeUser): UserMeta;
|
|
345
357
|
isSuspended(userId: string): boolean;
|
|
@@ -457,8 +469,12 @@ declare class WebhookDispatcher {
|
|
|
457
469
|
private nextEndpoint;
|
|
458
470
|
private readonly retryDelaysMs;
|
|
459
471
|
private readonly timeoutMs;
|
|
472
|
+
/** Set by the server to record coverage. */
|
|
473
|
+
observe: (id: string) => void;
|
|
460
474
|
constructor(testkit: KindeTestkit, seed: ResolvedSeed, endpoints?: WebhookEndpointInput[], options?: WebhookOptions);
|
|
461
475
|
addEndpoint(input: WebhookEndpointInput): WebhookEndpoint;
|
|
476
|
+
/** Replaces the endpoints that came from the seed, as when a new seed is loaded. */
|
|
477
|
+
replaceSeededEndpoints(endpoints: WebhookEndpointInput[]): void;
|
|
462
478
|
removeEndpoint(id: string): boolean;
|
|
463
479
|
listEndpoints(): WebhookEndpoint[];
|
|
464
480
|
deliveries(): WebhookDelivery[];
|
|
@@ -477,14 +493,109 @@ declare class WebhookDispatcher {
|
|
|
477
493
|
private requireUser;
|
|
478
494
|
}
|
|
479
495
|
|
|
496
|
+
interface RequestEntry {
|
|
497
|
+
at: string;
|
|
498
|
+
method: string;
|
|
499
|
+
path: string;
|
|
500
|
+
status: number;
|
|
501
|
+
durationMs: number;
|
|
502
|
+
injected: boolean;
|
|
503
|
+
}
|
|
504
|
+
interface TokenEntry {
|
|
505
|
+
at: string;
|
|
506
|
+
kind: "access" | "m2m" | "id";
|
|
507
|
+
subject: string | null;
|
|
508
|
+
organization: string | null;
|
|
509
|
+
permissions: string[];
|
|
510
|
+
roles: string[];
|
|
511
|
+
invalid: InvalidTokenKind | null;
|
|
512
|
+
expiresAt: string | null;
|
|
513
|
+
claims: Record<string, unknown>;
|
|
514
|
+
token: string;
|
|
515
|
+
}
|
|
516
|
+
/** Keeps the latest requests and tokens for the dashboard and `kinde-testkit inspect --requests`. */
|
|
517
|
+
declare class ActivityLog {
|
|
518
|
+
private requestLog;
|
|
519
|
+
private tokenLog;
|
|
520
|
+
request(entry: Omit<RequestEntry, "at" | "path"> & {
|
|
521
|
+
path: string;
|
|
522
|
+
query: URLSearchParams;
|
|
523
|
+
}): void;
|
|
524
|
+
token(kind: TokenEntry["kind"], claims: Record<string, unknown>, invalid: InvalidTokenKind | undefined, token: string): void;
|
|
525
|
+
requests(): RequestEntry[];
|
|
526
|
+
tokens(): TokenEntry[];
|
|
527
|
+
reset(): void;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
interface CoverageItem {
|
|
531
|
+
id: string;
|
|
532
|
+
label: string;
|
|
533
|
+
hint: string;
|
|
534
|
+
}
|
|
535
|
+
interface CoverageGroup {
|
|
536
|
+
name: string;
|
|
537
|
+
items: CoverageItem[];
|
|
538
|
+
}
|
|
539
|
+
declare const COVERAGE_GROUPS: CoverageGroup[];
|
|
540
|
+
interface CoverageGroupResult {
|
|
541
|
+
name: string;
|
|
542
|
+
covered: number;
|
|
543
|
+
total: number;
|
|
544
|
+
items: Array<CoverageItem & {
|
|
545
|
+
covered: boolean;
|
|
546
|
+
count: number;
|
|
547
|
+
}>;
|
|
548
|
+
}
|
|
549
|
+
interface CoverageReport {
|
|
550
|
+
covered: number;
|
|
551
|
+
total: number;
|
|
552
|
+
groups: CoverageGroupResult[];
|
|
553
|
+
}
|
|
554
|
+
interface CoverageSnapshot {
|
|
555
|
+
version: 1;
|
|
556
|
+
hits: Record<string, number>;
|
|
557
|
+
}
|
|
558
|
+
/** Records which authentication scenarios the testkit produced during a test run. */
|
|
559
|
+
declare class CoverageRecorder {
|
|
560
|
+
private hits;
|
|
561
|
+
private userOrganizations;
|
|
562
|
+
private organizationUsers;
|
|
563
|
+
private organizationPermissionSets;
|
|
564
|
+
hit(id: string): void;
|
|
565
|
+
/** Called for every access token the testkit signs. */
|
|
566
|
+
observeAccessToken(payload: Record<string, unknown>, invalid: InvalidTokenKind | undefined): void;
|
|
567
|
+
report(): CoverageReport;
|
|
568
|
+
snapshot(): CoverageSnapshot;
|
|
569
|
+
reset(): void;
|
|
570
|
+
/** Writes this run's snapshot to the coverage folder, so separate test files can be merged. */
|
|
571
|
+
write(directory?: string): string;
|
|
572
|
+
}
|
|
573
|
+
declare const DEFAULT_COVERAGE_DIRECTORY: string;
|
|
574
|
+
declare function buildReport(hits: Record<string, number>): CoverageReport;
|
|
575
|
+
declare function mergeSnapshots(snapshots: CoverageSnapshot[]): Record<string, number>;
|
|
576
|
+
/** Reads and merges every snapshot in the coverage folder. */
|
|
577
|
+
declare function readCoverageDirectory(directory?: string): {
|
|
578
|
+
files: number;
|
|
579
|
+
report: CoverageReport;
|
|
580
|
+
};
|
|
581
|
+
declare function clearCoverageDirectory(directory?: string): void;
|
|
582
|
+
declare function formatCoverageReport(report: CoverageReport, options?: {
|
|
583
|
+
missing?: boolean;
|
|
584
|
+
}): string;
|
|
585
|
+
|
|
480
586
|
interface StartKindeTestkitOptions {
|
|
481
587
|
port?: number;
|
|
482
588
|
host?: string;
|
|
483
589
|
issuer?: string;
|
|
484
590
|
audience?: string | string[];
|
|
485
591
|
clientId?: string;
|
|
486
|
-
seed
|
|
592
|
+
/** A seed object, or the path of a JSON, YAML, JavaScript or TypeScript seed file. */
|
|
593
|
+
seed?: TestkitSeed | string;
|
|
487
594
|
allowPublic?: boolean;
|
|
595
|
+
/** Write this run's authentication coverage to a folder when the testkit closes. */
|
|
596
|
+
coverage?: boolean | {
|
|
597
|
+
directory?: string;
|
|
598
|
+
};
|
|
488
599
|
webhooks?: WebhookOptions;
|
|
489
600
|
https?: boolean | {
|
|
490
601
|
certDirectory?: string;
|
|
@@ -501,6 +612,10 @@ interface RunningKindeTestkit {
|
|
|
501
612
|
webhooks: WebhookDispatcher;
|
|
502
613
|
directory: Directory;
|
|
503
614
|
certificatePath: string | null;
|
|
615
|
+
coverage: CoverageRecorder;
|
|
616
|
+
activity: ActivityLog;
|
|
617
|
+
/** Replaces the seed while the issuer runs. reset() returns to the new seed. */
|
|
618
|
+
loadSeed(seed: TestkitSeed): void;
|
|
504
619
|
reset(): void;
|
|
505
620
|
close(): Promise<void>;
|
|
506
621
|
}
|
|
@@ -555,4 +670,64 @@ declare function runDoctor(options: {
|
|
|
555
670
|
}): Promise<DoctorReport>;
|
|
556
671
|
declare function parseEnvFile(text: string): Record<string, string>;
|
|
557
672
|
|
|
558
|
-
|
|
673
|
+
interface KindeTestAuth {
|
|
674
|
+
token: string | null;
|
|
675
|
+
headers: Record<string, string>;
|
|
676
|
+
principal: KindePrincipal | null;
|
|
677
|
+
request: {
|
|
678
|
+
headers: Record<string, string>;
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
declare function kindeTest(options: {
|
|
682
|
+
scenario: Scenario;
|
|
683
|
+
testkit?: KindeTestkit;
|
|
684
|
+
token?: ScenarioTokenOverrides;
|
|
685
|
+
}): Promise<KindeTestAuth>;
|
|
686
|
+
interface KindeTestkitHandle {
|
|
687
|
+
readonly url: string;
|
|
688
|
+
readonly issuer: string;
|
|
689
|
+
readonly jwksUri: string;
|
|
690
|
+
readonly testkit: KindeTestkit;
|
|
691
|
+
readonly failures: FailureInjector;
|
|
692
|
+
readonly webhooks: WebhookDispatcher;
|
|
693
|
+
readonly directory: Directory;
|
|
694
|
+
readonly coverage: CoverageRecorder;
|
|
695
|
+
readonly activity: ActivityLog;
|
|
696
|
+
readonly certificatePath: string | null;
|
|
697
|
+
auth(scenario: Scenario, token?: ScenarioTokenOverrides): Promise<KindeTestAuth>;
|
|
698
|
+
loadSeed(seed: TestkitSeed): void;
|
|
699
|
+
reset(): void;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
/** Files `kinde-testkit start` looks for, in this order, when no --seed is given. */
|
|
703
|
+
declare const DEFAULT_SEED_FILES: string[];
|
|
704
|
+
declare function findSeedFile(directory?: string): string | undefined;
|
|
705
|
+
/**
|
|
706
|
+
* Reads a seed from JSON, YAML, or a JavaScript or TypeScript module.
|
|
707
|
+
* A module exports the seed as its default export or as `seed`.
|
|
708
|
+
* TypeScript files need a Node version that runs TypeScript (22.18 or later).
|
|
709
|
+
*/
|
|
710
|
+
declare function loadSeedFile(path: string): Promise<TestkitSeed>;
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Steps for signing in through the testkit with plain HTTP requests instead of a browser page.
|
|
714
|
+
* The Cypress commands use these. No Node APIs here, because Cypress bundles this file for the browser.
|
|
715
|
+
*/
|
|
716
|
+
interface RequestSignInOptions {
|
|
717
|
+
/** Email address or ID of the user. */
|
|
718
|
+
user: string;
|
|
719
|
+
/** Active organization, for users in more than one. */
|
|
720
|
+
org?: string;
|
|
721
|
+
}
|
|
722
|
+
/** The app's login route, with the hints the testkit sign-in page reads. */
|
|
723
|
+
declare function appLoginUrl(loginPath: string, options: RequestSignInOptions): string;
|
|
724
|
+
/** Reads the hidden request field from the testkit sign-in page. */
|
|
725
|
+
declare function readSignInRequest(html: string): string;
|
|
726
|
+
/** The form the sign-in page posts to /oauth2/auth/login. */
|
|
727
|
+
declare function signInForm(request: string, options: RequestSignInOptions): Record<string, string>;
|
|
728
|
+
/** Explains why the testkit did not redirect back to the app after the form was posted. */
|
|
729
|
+
declare function signInFailure(status: number, html: string, options: RequestSignInOptions): Error;
|
|
730
|
+
/** Resolves a Location header, which can be relative, against the URL that sent it. */
|
|
731
|
+
declare function resolveLocation(location: string, from: string): string;
|
|
732
|
+
|
|
733
|
+
export { type ActiveFailure, ActivityLog, type AuthenticatedScenario, BILLING_EVENT_TYPES, COVERAGE_GROUPS, type Check, type CheckStatus, type CoverageGroup, type CoverageGroupResult, type CoverageItem, CoverageRecorder, type CoverageReport, type CoverageSnapshot, type CreateKindeOrganizationOptions, type CreateKindeUserOptions, type CreateMembershipOptions, DEFAULT_AUTH_METHODS, DEFAULT_CLIENT_ID, DEFAULT_COVERAGE_DIRECTORY, DEFAULT_ISSUER, DEFAULT_M2M_CLIENT_ID, DEFAULT_SCOPES, DEFAULT_SEED_FILES, Directory, type DoctorReport, type Duration, FailureInjector, type FailureRule, INVALID_TOKEN_KINDS, type IdTokenOptions, type InvalidTokenKind, type KindeApplication, type KindeMembership, type KindeOrganization, type KindePrincipal, type KindeRole, type KindeTestAuth, KindeTestkit, type KindeTestkitHandle, type KindeTestkitOptions, type KindeTokenOptions, type KindeUser, type LocalCertificate, type M2MTokenOptions, type RequestEntry, type RequestSignInOptions, type ResolvedSeed, type RunningKindeTestkit, type Scenario, ScenarioBuilder, type ScenarioTokenOverrides, type SendWebhookOptions, type StartKindeTestkitOptions, TestkitError, type TestkitErrorCode, type TestkitSeed, type TokenEntry, type TokenInspection, type TokenObserver, type UnauthenticatedScenario, WEBHOOK_EVENT_TYPES, type WebhookAttempt, type WebhookDelivery, WebhookDispatcher, type WebhookEndpoint, type WebhookEndpointInput, type WebhookInvalidKind, type WebhookOptions, type WebhookSource, appLoginUrl, buildReport, clearCoverageDirectory, createKindeOrganization, createKindeToken, createKindeUser, createLocalCertificate, createMembership, ensureLocalCertificate, findSeedFile, formatCoverageReport, getDefaultTestkit, inspectToken, isAuthenticated, kindeTest, loadSeedFile, mergeSnapshots, parseEnvFile, principalFromClaims, readCoverageDirectory, readSignInRequest, resetFactories, resolveLocation, resolveSeed, runDoctor, scenario, seedScenario, signInFailure, signInForm, startKindeTestkit, toKindeRole };
|