kinde-testkit 0.6.0 → 0.7.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 +19 -0
- package/README.md +89 -3
- package/dist/chunk-2QJ7DTNL.js +72 -0
- package/dist/chunk-2QJ7DTNL.js.map +1 -0
- package/dist/chunk-33AHOLUN.js +183 -0
- package/dist/chunk-33AHOLUN.js.map +1 -0
- package/dist/chunk-JTAB2S44.js +3697 -0
- package/dist/chunk-JTAB2S44.js.map +1 -0
- package/dist/cli.js +50 -3561
- package/dist/cli.js.map +1 -0
- package/dist/cypress.cjs +286 -17
- package/dist/cypress.d.cts +2 -96
- package/dist/cypress.d.ts +3 -96
- package/dist/cypress.js +2 -3303
- package/dist/cypress.js.map +1 -1
- package/dist/handle-E_BhdHx8.d.ts +33 -0
- package/dist/handle-estfqypp.d.cts +32 -0
- package/dist/index.cjs +286 -17
- package/dist/index.d.cts +7 -607
- package/dist/index.d.ts +8 -607
- package/dist/index.js +51 -3577
- package/dist/index.js.map +1 -1
- package/dist/jest.cjs +286 -17
- package/dist/jest.d.cts +5 -555
- package/dist/jest.d.ts +6 -555
- package/dist/jest.js +4 -3373
- package/dist/jest.js.map +1 -1
- package/dist/playwright.d.ts +2 -54
- package/dist/server-B9fBcnyQ.d.ts +194 -0
- package/dist/server-CTBJXMac.d.cts +588 -0
- package/dist/vitest.d.ts +6 -555
- package/dist/vitest.js +5 -3376
- package/dist/vitest.js.map +1 -1
- package/dist/webhooks-DJyCsbdF.d.ts +397 -0
- package/package.json +3 -2
- package/dist/cypress-support.d.ts +0 -98
- package/dist/cypress.cjs.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/jest.cjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,82 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
emailVerified: boolean;
|
|
7
|
-
givenName: string | null;
|
|
8
|
-
familyName: string | null;
|
|
9
|
-
picture: string | null;
|
|
10
|
-
claims: Record<string, unknown>;
|
|
11
|
-
}
|
|
12
|
-
interface KindeOrganization {
|
|
13
|
-
code: string;
|
|
14
|
-
name: string;
|
|
15
|
-
metadata: Record<string, unknown>;
|
|
16
|
-
}
|
|
17
|
-
interface KindeRole {
|
|
18
|
-
id: string;
|
|
19
|
-
key: string;
|
|
20
|
-
name: string;
|
|
21
|
-
}
|
|
22
|
-
interface KindeApplication {
|
|
23
|
-
clientId: string;
|
|
24
|
-
clientSecret: string | null;
|
|
25
|
-
name: string;
|
|
26
|
-
organizationCode: string | null;
|
|
27
|
-
scopes: string[] | null;
|
|
28
|
-
permissions: string[] | null;
|
|
29
|
-
audience: string[] | null;
|
|
30
|
-
}
|
|
31
|
-
interface KindeMembership {
|
|
32
|
-
userId: string;
|
|
33
|
-
organizationCode: string;
|
|
34
|
-
roles: string[];
|
|
35
|
-
permissions: string[];
|
|
36
|
-
}
|
|
37
|
-
interface AuthenticatedScenario {
|
|
38
|
-
kind: "authenticated";
|
|
39
|
-
user: KindeUser;
|
|
40
|
-
organization: KindeOrganization | null;
|
|
41
|
-
roles: string[];
|
|
42
|
-
permissions: string[];
|
|
43
|
-
claims: Record<string, unknown>;
|
|
44
|
-
}
|
|
45
|
-
interface UnauthenticatedScenario {
|
|
46
|
-
kind: "unauthenticated";
|
|
47
|
-
}
|
|
48
|
-
type Scenario = AuthenticatedScenario | UnauthenticatedScenario;
|
|
49
|
-
interface KindePrincipal {
|
|
50
|
-
type: "user" | "machine";
|
|
51
|
-
subject: string;
|
|
52
|
-
issuer: string;
|
|
53
|
-
organization: {
|
|
54
|
-
code: string;
|
|
55
|
-
} | null;
|
|
56
|
-
roles: string[];
|
|
57
|
-
permissions: string[];
|
|
58
|
-
claims: Record<string, unknown>;
|
|
59
|
-
}
|
|
60
|
-
type InvalidTokenKind = "expired" | "wrong-issuer" | "wrong-audience" | "missing-subject" | "missing-organization" | "missing-permissions" | "future-iat" | "bad-signature" | "unknown-key" | "unsigned";
|
|
61
|
-
type Duration = number | `${number}${"s" | "m" | "h" | "d"}`;
|
|
62
|
-
interface KindeTokenOptions {
|
|
63
|
-
subject?: string;
|
|
64
|
-
organizationCode?: string | null;
|
|
65
|
-
permissions?: string[];
|
|
66
|
-
roles?: Array<string | KindeRole>;
|
|
67
|
-
scopes?: string[];
|
|
68
|
-
featureFlags?: Record<string, {
|
|
69
|
-
t: "b" | "s" | "i";
|
|
70
|
-
v: boolean | string | number;
|
|
71
|
-
}>;
|
|
72
|
-
claims?: Record<string, unknown>;
|
|
73
|
-
authMethods?: string[];
|
|
74
|
-
authTime?: number;
|
|
75
|
-
clientId?: string;
|
|
76
|
-
audience?: string[];
|
|
77
|
-
expiresIn?: Duration;
|
|
78
|
-
invalid?: InvalidTokenKind;
|
|
79
|
-
}
|
|
1
|
+
import { K as KindeOrganization, a as KindeUser, b as KindeMembership, c as KindeRole, A as AuthenticatedScenario, U as UnauthenticatedScenario, S as Scenario, T as TestkitSeed } from './webhooks-DJyCsbdF.js';
|
|
2
|
+
export { d as ActiveFailure, B as BILLING_EVENT_TYPES, D as DEFAULT_AUTH_METHODS, e as DEFAULT_CLIENT_ID, f as DEFAULT_ISSUER, g as DEFAULT_M2M_CLIENT_ID, h as DEFAULT_SCOPES, i as Duration, F as FailureInjector, j as FailureRule, I as INVALID_TOKEN_KINDS, k as IdTokenOptions, l as InvalidTokenKind, m as KindeApplication, n as KindePrincipal, o as KindeTestkit, p as KindeTestkitOptions, q as KindeTokenOptions, M as M2MTokenOptions, R as ResolvedSeed, r as ScenarioTokenOverrides, s as SendWebhookOptions, t as TokenObserver, W as WEBHOOK_EVENT_TYPES, u as WebhookAttempt, v as WebhookDelivery, w as WebhookDispatcher, x as WebhookEndpoint, y as WebhookEndpointInput, z as WebhookInvalidKind, C as WebhookOptions, E as WebhookSource, G as createKindeToken, H as getDefaultTestkit, J as principalFromClaims, L as resolveSeed, N as seedScenario } from './webhooks-DJyCsbdF.js';
|
|
3
|
+
export { A as ActivityLog, C as COVERAGE_GROUPS, a as CoverageGroup, b as CoverageGroupResult, c as CoverageItem, d as CoverageRecorder, e as CoverageReport, f as CoverageSnapshot, D as DEFAULT_COVERAGE_DIRECTORY, g as DeviceFlowOptions, h as Directory, R as RequestEntry, i as RunningKindeTestkit, S as StartKindeTestkitOptions, T as TokenEntry, j as buildReport, k as clearCoverageDirectory, l as formatCoverageReport, m as mergeSnapshots, r as readCoverageDirectory, s as startKindeTestkit } from './server-B9fBcnyQ.js';
|
|
4
|
+
import { ProtectedHeaderParameters, JWTPayload } from 'jose';
|
|
5
|
+
export { K as KindeTestAuth, a as KindeTestkitHandle, k as kindeTest } from './handle-E_BhdHx8.js';
|
|
80
6
|
|
|
81
7
|
interface CreateKindeUserOptions {
|
|
82
8
|
id?: string;
|
|
@@ -123,508 +49,12 @@ declare class ScenarioBuilder {
|
|
|
123
49
|
declare function scenario(): ScenarioBuilder;
|
|
124
50
|
declare function isAuthenticated(value: Scenario): value is AuthenticatedScenario;
|
|
125
51
|
|
|
126
|
-
declare const DEFAULT_ISSUER = "http://localhost:4400";
|
|
127
|
-
declare const DEFAULT_CLIENT_ID = "kinde_testkit_client";
|
|
128
|
-
declare const DEFAULT_M2M_CLIENT_ID = "kinde_testkit_m2m";
|
|
129
|
-
declare const DEFAULT_SCOPES: string[];
|
|
130
|
-
declare const DEFAULT_AUTH_METHODS: string[];
|
|
131
|
-
declare const INVALID_TOKEN_KINDS: readonly InvalidTokenKind[];
|
|
132
|
-
interface KindeTestkitOptions {
|
|
133
|
-
issuer?: string;
|
|
134
|
-
audience?: string | string[];
|
|
135
|
-
clientId?: string;
|
|
136
|
-
accessTokenExpiresIn?: Duration;
|
|
137
|
-
idTokenExpiresIn?: Duration;
|
|
138
|
-
now?: () => number;
|
|
139
|
-
}
|
|
140
|
-
type ScenarioTokenOverrides = Pick<KindeTokenOptions, "expiresIn" | "invalid" | "scopes" | "featureFlags" | "claims" | "authMethods" | "authTime" | "clientId" | "audience">;
|
|
141
|
-
interface M2MTokenOptions {
|
|
142
|
-
clientId?: string;
|
|
143
|
-
organizationCode?: string | null;
|
|
144
|
-
scopes?: string[];
|
|
145
|
-
grantedScopes?: string[];
|
|
146
|
-
audience?: string[];
|
|
147
|
-
permissions?: string[];
|
|
148
|
-
claims?: Record<string, unknown>;
|
|
149
|
-
expiresIn?: Duration;
|
|
150
|
-
invalid?: InvalidTokenKind;
|
|
151
|
-
}
|
|
152
|
-
interface IdTokenOptions {
|
|
153
|
-
expiresIn?: Duration;
|
|
154
|
-
authMethods?: string[];
|
|
155
|
-
authTime?: number;
|
|
156
|
-
clientId?: string;
|
|
157
|
-
nonce?: string;
|
|
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
|
-
}
|
|
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;
|
|
170
|
-
readonly issuer: string;
|
|
171
|
-
readonly audience: string[];
|
|
172
|
-
readonly clientId: string;
|
|
173
|
-
private readonly accessTokenExpiresIn;
|
|
174
|
-
private readonly idTokenExpiresIn;
|
|
175
|
-
private readonly clock;
|
|
176
|
-
private readonly signingKey;
|
|
177
|
-
private strangerKey;
|
|
178
|
-
static create(options?: KindeTestkitOptions): Promise<KindeTestkit>;
|
|
179
|
-
private constructor();
|
|
180
|
-
get jwksUri(): string;
|
|
181
|
-
get keyId(): string;
|
|
182
|
-
get accessTokenLifetime(): number;
|
|
183
|
-
verify(token: string): Promise<JWTPayload>;
|
|
184
|
-
jwks(): {
|
|
185
|
-
keys: JWK[];
|
|
186
|
-
};
|
|
187
|
-
token(options?: KindeTokenOptions): Promise<string>;
|
|
188
|
-
m2mToken(options?: M2MTokenOptions): Promise<string>;
|
|
189
|
-
tokenFor(scenario: Scenario, overrides?: ScenarioTokenOverrides): Promise<string | null>;
|
|
190
|
-
idTokenFor(scenario: Scenario, options?: IdTokenOptions): Promise<string | null>;
|
|
191
|
-
headersFor(scenario: Scenario, overrides?: ScenarioTokenOverrides): Promise<Record<string, string>>;
|
|
192
|
-
principalFor(scenario: Scenario): KindePrincipal | null;
|
|
193
|
-
signPayload(payload: Record<string, unknown>, invalid?: "bad-signature" | "unknown-key" | "unsigned"): Promise<string>;
|
|
194
|
-
private sign;
|
|
195
|
-
private stranger;
|
|
196
|
-
}
|
|
197
|
-
declare function principalFromClaims(claims: Record<string, unknown>): KindePrincipal;
|
|
198
|
-
declare function getDefaultTestkit(): Promise<KindeTestkit>;
|
|
199
|
-
declare function createKindeToken(options?: KindeTokenOptions): Promise<string>;
|
|
200
|
-
|
|
201
|
-
interface TestkitSeed {
|
|
202
|
-
issuer?: string;
|
|
203
|
-
audience?: string | string[];
|
|
204
|
-
clientId?: string;
|
|
205
|
-
users?: Array<{
|
|
206
|
-
id: string;
|
|
207
|
-
email?: string | null;
|
|
208
|
-
emailVerified?: boolean;
|
|
209
|
-
givenName?: string | null;
|
|
210
|
-
familyName?: string | null;
|
|
211
|
-
picture?: string | null;
|
|
212
|
-
claims?: Record<string, unknown>;
|
|
213
|
-
properties?: Record<string, string | number | boolean>;
|
|
214
|
-
}>;
|
|
215
|
-
organizations?: Array<{
|
|
216
|
-
code: string;
|
|
217
|
-
name?: string;
|
|
218
|
-
metadata?: Record<string, unknown>;
|
|
219
|
-
}>;
|
|
220
|
-
memberships?: Array<{
|
|
221
|
-
user: string;
|
|
222
|
-
organization: string;
|
|
223
|
-
roles?: string[];
|
|
224
|
-
permissions?: string[];
|
|
225
|
-
}>;
|
|
226
|
-
webhooks?: Array<{
|
|
227
|
-
url: string;
|
|
228
|
-
events?: string[];
|
|
229
|
-
}>;
|
|
230
|
-
roles?: Array<{
|
|
231
|
-
key: string;
|
|
232
|
-
name?: string;
|
|
233
|
-
description?: string;
|
|
234
|
-
permissions?: string[];
|
|
235
|
-
isDefault?: boolean;
|
|
236
|
-
}>;
|
|
237
|
-
featureFlags?: Array<{
|
|
238
|
-
key: string;
|
|
239
|
-
name?: string;
|
|
240
|
-
type?: "boolean" | "string" | "integer";
|
|
241
|
-
value: boolean | string | number;
|
|
242
|
-
organizations?: Record<string, boolean | string | number>;
|
|
243
|
-
}>;
|
|
244
|
-
plans?: Array<{
|
|
245
|
-
key: string;
|
|
246
|
-
name?: string;
|
|
247
|
-
subscribers?: string[];
|
|
248
|
-
entitlements?: Array<{
|
|
249
|
-
featureKey: string;
|
|
250
|
-
featureName?: string;
|
|
251
|
-
priceName?: string;
|
|
252
|
-
fixedCharge?: number | null;
|
|
253
|
-
unitAmount?: number | null;
|
|
254
|
-
limitMax?: number | null;
|
|
255
|
-
limitMin?: number | null;
|
|
256
|
-
}>;
|
|
257
|
-
}>;
|
|
258
|
-
permissions?: Array<{
|
|
259
|
-
key: string;
|
|
260
|
-
name?: string;
|
|
261
|
-
description?: string;
|
|
262
|
-
}>;
|
|
263
|
-
applications?: Array<{
|
|
264
|
-
clientId: string;
|
|
265
|
-
clientSecret?: string;
|
|
266
|
-
name?: string;
|
|
267
|
-
organization?: string;
|
|
268
|
-
scopes?: string[];
|
|
269
|
-
permissions?: string[];
|
|
270
|
-
audience?: string | string[];
|
|
271
|
-
}>;
|
|
272
|
-
}
|
|
273
|
-
interface ResolvedSeed {
|
|
274
|
-
users: KindeUser[];
|
|
275
|
-
organizations: KindeOrganization[];
|
|
276
|
-
memberships: KindeMembership[];
|
|
277
|
-
applications: KindeApplication[];
|
|
278
|
-
webhooks: Array<{
|
|
279
|
-
url: string;
|
|
280
|
-
events?: string[];
|
|
281
|
-
}>;
|
|
282
|
-
roles: SeedRole[];
|
|
283
|
-
permissions: SeedPermission[];
|
|
284
|
-
featureFlags: SeedFeatureFlag[];
|
|
285
|
-
plans: SeedPlan[];
|
|
286
|
-
userProperties: Record<string, Record<string, string | number | boolean>>;
|
|
287
|
-
}
|
|
288
|
-
interface SeedFeatureFlag {
|
|
289
|
-
id: string;
|
|
290
|
-
key: string;
|
|
291
|
-
name: string;
|
|
292
|
-
type: "boolean" | "string" | "integer";
|
|
293
|
-
value: boolean | string | number;
|
|
294
|
-
organizations: Record<string, boolean | string | number>;
|
|
295
|
-
}
|
|
296
|
-
interface SeedPlan {
|
|
297
|
-
key: string;
|
|
298
|
-
name: string;
|
|
299
|
-
subscribers: string[];
|
|
300
|
-
subscribedOn: string;
|
|
301
|
-
entitlements: Array<{
|
|
302
|
-
id: string;
|
|
303
|
-
featureKey: string;
|
|
304
|
-
featureName: string;
|
|
305
|
-
priceName: string;
|
|
306
|
-
fixedCharge: number | null;
|
|
307
|
-
unitAmount: number | null;
|
|
308
|
-
limitMax: number | null;
|
|
309
|
-
limitMin: number | null;
|
|
310
|
-
}>;
|
|
311
|
-
}
|
|
312
|
-
interface SeedRole {
|
|
313
|
-
id: string;
|
|
314
|
-
key: string;
|
|
315
|
-
name: string;
|
|
316
|
-
description: string | null;
|
|
317
|
-
isDefault: boolean;
|
|
318
|
-
permissions: string[];
|
|
319
|
-
}
|
|
320
|
-
interface SeedPermission {
|
|
321
|
-
id: string;
|
|
322
|
-
key: string;
|
|
323
|
-
name: string;
|
|
324
|
-
description: string | null;
|
|
325
|
-
}
|
|
326
|
-
declare function resolveSeed(input: unknown): ResolvedSeed;
|
|
327
|
-
declare function seedScenario(seed: ResolvedSeed, ref: {
|
|
328
|
-
user: string;
|
|
329
|
-
organization?: string | null;
|
|
330
|
-
}): AuthenticatedScenario;
|
|
331
|
-
|
|
332
|
-
interface UserMeta {
|
|
333
|
-
providedId: string | null;
|
|
334
|
-
isSuspended: boolean;
|
|
335
|
-
isPasswordResetRequested: boolean;
|
|
336
|
-
createdOn: string;
|
|
337
|
-
totalSignIns: number;
|
|
338
|
-
lastSignedIn: string | null;
|
|
339
|
-
}
|
|
340
|
-
interface OrganizationMeta {
|
|
341
|
-
externalId: string | null;
|
|
342
|
-
handle: string;
|
|
343
|
-
createdOn: string;
|
|
344
|
-
isAllowRegistrations: boolean;
|
|
345
|
-
}
|
|
346
|
-
declare class Directory {
|
|
347
|
-
readonly seed: ResolvedSeed;
|
|
348
|
-
private readonly userMeta;
|
|
349
|
-
private readonly orgMeta;
|
|
350
|
-
private snapshot;
|
|
351
|
-
constructor(seed: ResolvedSeed);
|
|
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;
|
|
355
|
-
user(id: string): KindeUser | undefined;
|
|
356
|
-
meta(user: KindeUser): UserMeta;
|
|
357
|
-
isSuspended(userId: string): boolean;
|
|
358
|
-
recordSignIn(user: KindeUser, organizationCode: string | null): void;
|
|
359
|
-
createUser(input: {
|
|
360
|
-
email?: string | null;
|
|
361
|
-
givenName?: string | null;
|
|
362
|
-
familyName?: string | null;
|
|
363
|
-
picture?: string | null;
|
|
364
|
-
providedId?: string | null;
|
|
365
|
-
}): KindeUser;
|
|
366
|
-
deleteUser(id: string): boolean;
|
|
367
|
-
organization(code: string): KindeOrganization | undefined;
|
|
368
|
-
orgInfo(org: KindeOrganization): OrganizationMeta;
|
|
369
|
-
createOrganization(input: {
|
|
370
|
-
name: string;
|
|
371
|
-
externalId?: string | null;
|
|
372
|
-
handle?: string | null;
|
|
373
|
-
}): KindeOrganization;
|
|
374
|
-
deleteOrganization(code: string): boolean;
|
|
375
|
-
membership(userId: string, organizationCode: string): KindeMembership | undefined;
|
|
376
|
-
addMembership(userId: string, organizationCode: string, roles?: string[], permissions?: string[]): KindeMembership;
|
|
377
|
-
removeMembership(userId: string, organizationCode: string): boolean;
|
|
378
|
-
role(idOrKey: string): SeedRole | undefined;
|
|
379
|
-
permission(idOrKey: string): SeedPermission | undefined;
|
|
380
|
-
ensureRole(key: string, extra?: Partial<Omit<SeedRole, "id" | "key">>): SeedRole;
|
|
381
|
-
ensurePermission(key: string, extra?: Partial<Omit<SeedPermission, "id" | "key">>): SeedPermission;
|
|
382
|
-
deleteRole(id: string): SeedRole | undefined;
|
|
383
|
-
deletePermission(id: string): SeedPermission | undefined;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
interface FailureRule {
|
|
387
|
-
path: string;
|
|
388
|
-
method?: string;
|
|
389
|
-
status?: number;
|
|
390
|
-
delayMs?: number;
|
|
391
|
-
hang?: boolean;
|
|
392
|
-
times?: number;
|
|
393
|
-
retryAfter?: number;
|
|
394
|
-
}
|
|
395
|
-
interface ActiveFailure {
|
|
396
|
-
id: string;
|
|
397
|
-
path: string;
|
|
398
|
-
method: string | null;
|
|
399
|
-
status: number | null;
|
|
400
|
-
delayMs: number;
|
|
401
|
-
hang: boolean;
|
|
402
|
-
remaining: number | null;
|
|
403
|
-
retryAfter: number;
|
|
404
|
-
hits: number;
|
|
405
|
-
}
|
|
406
|
-
declare class FailureInjector {
|
|
407
|
-
private rules;
|
|
408
|
-
private nextId;
|
|
409
|
-
add(rule: FailureRule): ActiveFailure;
|
|
410
|
-
remove(id: string): boolean;
|
|
411
|
-
clear(): void;
|
|
412
|
-
list(): ActiveFailure[];
|
|
413
|
-
take(method: string, path: string): ActiveFailure | null;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
declare const WEBHOOK_EVENT_TYPES: readonly ["user.created", "user.updated", "user.deleted", "user.authenticated", "user.authentication_failed", "organization.created", "organization.updated", "organization.deleted", "role.created", "role.updated", "role.deleted", "permission.created", "permission.updated", "permission.deleted", "subscriber.created", "access_request.created"];
|
|
417
|
-
declare const BILLING_EVENT_TYPES: readonly ["customer.agreement_cancelled", "customer.agreement_created", "customer.invoice_overdue", "customer.meter_usage_updated", "customer.payment_failed", "customer.payment_succeeded", "customer.plan_assigned", "customer.plan_changed"];
|
|
418
|
-
type WebhookInvalidKind = "bad-signature" | "unknown-key" | "unsigned" | "stale";
|
|
419
|
-
type WebhookSource = "admin" | "api" | "user";
|
|
420
|
-
interface WebhookEndpointInput {
|
|
421
|
-
url: string;
|
|
422
|
-
events?: string[];
|
|
423
|
-
}
|
|
424
|
-
interface WebhookEndpoint {
|
|
425
|
-
id: string;
|
|
426
|
-
url: string;
|
|
427
|
-
events: string[] | null;
|
|
428
|
-
}
|
|
429
|
-
interface SendWebhookOptions {
|
|
430
|
-
type: string;
|
|
431
|
-
data?: Record<string, unknown>;
|
|
432
|
-
user?: string;
|
|
433
|
-
organization?: string;
|
|
434
|
-
role?: string;
|
|
435
|
-
permission?: string;
|
|
436
|
-
source?: WebhookSource;
|
|
437
|
-
ipAddress?: string;
|
|
438
|
-
to?: string;
|
|
439
|
-
duplicate?: number;
|
|
440
|
-
delayMs?: number;
|
|
441
|
-
invalid?: WebhookInvalidKind;
|
|
442
|
-
}
|
|
443
|
-
interface WebhookAttempt {
|
|
444
|
-
attempt: number;
|
|
445
|
-
status: number | null;
|
|
446
|
-
error: string | null;
|
|
447
|
-
durationMs: number;
|
|
448
|
-
}
|
|
449
|
-
interface WebhookDelivery {
|
|
450
|
-
webhookId: string;
|
|
451
|
-
eventId: string;
|
|
452
|
-
type: string;
|
|
453
|
-
url: string;
|
|
454
|
-
copy: number;
|
|
455
|
-
delivered: boolean;
|
|
456
|
-
attempts: WebhookAttempt[];
|
|
457
|
-
payload: Record<string, unknown>;
|
|
458
|
-
}
|
|
459
|
-
interface WebhookOptions {
|
|
460
|
-
retryDelaysMs?: number[];
|
|
461
|
-
timeoutMs?: number;
|
|
462
|
-
}
|
|
463
|
-
declare class WebhookDispatcher {
|
|
464
|
-
private readonly testkit;
|
|
465
|
-
private readonly seed;
|
|
466
|
-
private endpoints;
|
|
467
|
-
private seededEndpoints;
|
|
468
|
-
private log;
|
|
469
|
-
private nextEndpoint;
|
|
470
|
-
private readonly retryDelaysMs;
|
|
471
|
-
private readonly timeoutMs;
|
|
472
|
-
/** Set by the server to record coverage. */
|
|
473
|
-
observe: (id: string) => void;
|
|
474
|
-
constructor(testkit: KindeTestkit, seed: ResolvedSeed, endpoints?: WebhookEndpointInput[], options?: WebhookOptions);
|
|
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;
|
|
478
|
-
removeEndpoint(id: string): boolean;
|
|
479
|
-
listEndpoints(): WebhookEndpoint[];
|
|
480
|
-
deliveries(): WebhookDelivery[];
|
|
481
|
-
reset(): void;
|
|
482
|
-
buildEvent(options: SendWebhookOptions): Record<string, unknown>;
|
|
483
|
-
send(options: SendWebhookOptions): Promise<WebhookDelivery[]>;
|
|
484
|
-
private deliver;
|
|
485
|
-
private buildData;
|
|
486
|
-
emit(type: string, data: Record<string, unknown>, source?: WebhookSource): void;
|
|
487
|
-
userEventData(user: KindeUser): Record<string, unknown>;
|
|
488
|
-
emitForUser(type: "user.created" | "user.authenticated", user: KindeUser): void;
|
|
489
|
-
private userData;
|
|
490
|
-
private userPayload;
|
|
491
|
-
private organizationData;
|
|
492
|
-
private namedData;
|
|
493
|
-
private requireUser;
|
|
494
|
-
}
|
|
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
|
-
|
|
586
|
-
interface StartKindeTestkitOptions {
|
|
587
|
-
port?: number;
|
|
588
|
-
host?: string;
|
|
589
|
-
issuer?: string;
|
|
590
|
-
audience?: string | string[];
|
|
591
|
-
clientId?: string;
|
|
592
|
-
/** A seed object, or the path of a JSON, YAML, JavaScript or TypeScript seed file. */
|
|
593
|
-
seed?: TestkitSeed | string;
|
|
594
|
-
allowPublic?: boolean;
|
|
595
|
-
/** Write this run's authentication coverage to a folder when the testkit closes. */
|
|
596
|
-
coverage?: boolean | {
|
|
597
|
-
directory?: string;
|
|
598
|
-
};
|
|
599
|
-
webhooks?: WebhookOptions;
|
|
600
|
-
https?: boolean | {
|
|
601
|
-
certDirectory?: string;
|
|
602
|
-
};
|
|
603
|
-
}
|
|
604
|
-
interface RunningKindeTestkit {
|
|
605
|
-
url: string;
|
|
606
|
-
issuer: string;
|
|
607
|
-
discoveryUrl: string;
|
|
608
|
-
jwksUri: string;
|
|
609
|
-
testkit: KindeTestkit;
|
|
610
|
-
seed: ResolvedSeed;
|
|
611
|
-
failures: FailureInjector;
|
|
612
|
-
webhooks: WebhookDispatcher;
|
|
613
|
-
directory: Directory;
|
|
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;
|
|
619
|
-
reset(): void;
|
|
620
|
-
close(): Promise<void>;
|
|
621
|
-
}
|
|
622
|
-
declare function startKindeTestkit(options?: StartKindeTestkitOptions): Promise<RunningKindeTestkit>;
|
|
623
|
-
|
|
624
52
|
type TestkitErrorCode = "PUBLIC_BIND_REFUSED" | "SEED_INVALID" | "SEED_UNKNOWN_USER" | "SEED_UNKNOWN_ORGANIZATION" | "SEED_NO_MEMBERSHIP" | "INVALID_DURATION" | "INVALID_REQUEST" | "EMULATOR_UNREACHABLE";
|
|
625
53
|
declare class TestkitError extends Error {
|
|
626
54
|
readonly code: TestkitErrorCode;
|
|
627
55
|
readonly details: string[];
|
|
56
|
+
/** The message without the details list. */
|
|
57
|
+
readonly summary: string;
|
|
628
58
|
constructor(code: TestkitErrorCode, message: string, details?: string[]);
|
|
629
59
|
toString(): string;
|
|
630
60
|
}
|
|
@@ -670,35 +100,6 @@ declare function runDoctor(options: {
|
|
|
670
100
|
}): Promise<DoctorReport>;
|
|
671
101
|
declare function parseEnvFile(text: string): Record<string, string>;
|
|
672
102
|
|
|
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
103
|
/** Files `kinde-testkit start` looks for, in this order, when no --seed is given. */
|
|
703
104
|
declare const DEFAULT_SEED_FILES: string[];
|
|
704
105
|
declare function findSeedFile(directory?: string): string | undefined;
|
|
@@ -730,4 +131,4 @@ declare function signInFailure(status: number, html: string, options: RequestSig
|
|
|
730
131
|
/** Resolves a Location header, which can be relative, against the URL that sent it. */
|
|
731
132
|
declare function resolveLocation(location: string, from: string): string;
|
|
732
133
|
|
|
733
|
-
export {
|
|
134
|
+
export { AuthenticatedScenario, type Check, type CheckStatus, type CreateKindeOrganizationOptions, type CreateKindeUserOptions, type CreateMembershipOptions, DEFAULT_SEED_FILES, type DoctorReport, KindeMembership, KindeOrganization, KindeRole, KindeUser, type LocalCertificate, type RequestSignInOptions, Scenario, ScenarioBuilder, TestkitError, type TestkitErrorCode, TestkitSeed, type TokenInspection, UnauthenticatedScenario, appLoginUrl, createKindeOrganization, createKindeUser, createLocalCertificate, createMembership, ensureLocalCertificate, findSeedFile, inspectToken, isAuthenticated, loadSeedFile, parseEnvFile, readSignInRequest, resetFactories, resolveLocation, runDoctor, scenario, signInFailure, signInForm, toKindeRole };
|