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/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 Directory, R as RequestEntry, h as RunningKindeTestkit, S as StartKindeTestkitOptions, T as TokenEntry, i as buildReport, j as clearCoverageDirectory, k as formatCoverageReport, m as mergeSnapshots, r as readCoverageDirectory, s as startKindeTestkit } from './server-BiODgeoB.js';
|
|
4
|
+
import { ProtectedHeaderParameters, JWTPayload } from 'jose';
|
|
5
|
+
export { K as KindeTestAuth, a as KindeTestkitHandle, k as kindeTest } from './handle-Dh0UpIzG.js';
|
|
80
6
|
|
|
81
7
|
interface CreateKindeUserOptions {
|
|
82
8
|
id?: string;
|
|
@@ -123,393 +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
|
-
declare class KindeTestkit {
|
|
160
|
-
readonly issuer: string;
|
|
161
|
-
readonly audience: string[];
|
|
162
|
-
readonly clientId: string;
|
|
163
|
-
private readonly accessTokenExpiresIn;
|
|
164
|
-
private readonly idTokenExpiresIn;
|
|
165
|
-
private readonly clock;
|
|
166
|
-
private readonly signingKey;
|
|
167
|
-
private strangerKey;
|
|
168
|
-
static create(options?: KindeTestkitOptions): Promise<KindeTestkit>;
|
|
169
|
-
private constructor();
|
|
170
|
-
get jwksUri(): string;
|
|
171
|
-
get keyId(): string;
|
|
172
|
-
get accessTokenLifetime(): number;
|
|
173
|
-
verify(token: string): Promise<JWTPayload>;
|
|
174
|
-
jwks(): {
|
|
175
|
-
keys: JWK[];
|
|
176
|
-
};
|
|
177
|
-
token(options?: KindeTokenOptions): Promise<string>;
|
|
178
|
-
m2mToken(options?: M2MTokenOptions): Promise<string>;
|
|
179
|
-
tokenFor(scenario: Scenario, overrides?: ScenarioTokenOverrides): Promise<string | null>;
|
|
180
|
-
idTokenFor(scenario: Scenario, options?: IdTokenOptions): Promise<string | null>;
|
|
181
|
-
headersFor(scenario: Scenario, overrides?: ScenarioTokenOverrides): Promise<Record<string, string>>;
|
|
182
|
-
principalFor(scenario: Scenario): KindePrincipal | null;
|
|
183
|
-
signPayload(payload: Record<string, unknown>, invalid?: "bad-signature" | "unknown-key" | "unsigned"): Promise<string>;
|
|
184
|
-
private sign;
|
|
185
|
-
private stranger;
|
|
186
|
-
}
|
|
187
|
-
declare function principalFromClaims(claims: Record<string, unknown>): KindePrincipal;
|
|
188
|
-
declare function getDefaultTestkit(): Promise<KindeTestkit>;
|
|
189
|
-
declare function createKindeToken(options?: KindeTokenOptions): Promise<string>;
|
|
190
|
-
|
|
191
|
-
interface TestkitSeed {
|
|
192
|
-
issuer?: string;
|
|
193
|
-
audience?: string | string[];
|
|
194
|
-
clientId?: string;
|
|
195
|
-
users?: Array<{
|
|
196
|
-
id: string;
|
|
197
|
-
email?: string | null;
|
|
198
|
-
emailVerified?: boolean;
|
|
199
|
-
givenName?: string | null;
|
|
200
|
-
familyName?: string | null;
|
|
201
|
-
picture?: string | null;
|
|
202
|
-
claims?: Record<string, unknown>;
|
|
203
|
-
properties?: Record<string, string | number | boolean>;
|
|
204
|
-
}>;
|
|
205
|
-
organizations?: Array<{
|
|
206
|
-
code: string;
|
|
207
|
-
name?: string;
|
|
208
|
-
metadata?: Record<string, unknown>;
|
|
209
|
-
}>;
|
|
210
|
-
memberships?: Array<{
|
|
211
|
-
user: string;
|
|
212
|
-
organization: string;
|
|
213
|
-
roles?: string[];
|
|
214
|
-
permissions?: string[];
|
|
215
|
-
}>;
|
|
216
|
-
webhooks?: Array<{
|
|
217
|
-
url: string;
|
|
218
|
-
events?: string[];
|
|
219
|
-
}>;
|
|
220
|
-
roles?: Array<{
|
|
221
|
-
key: string;
|
|
222
|
-
name?: string;
|
|
223
|
-
description?: string;
|
|
224
|
-
permissions?: string[];
|
|
225
|
-
isDefault?: boolean;
|
|
226
|
-
}>;
|
|
227
|
-
featureFlags?: Array<{
|
|
228
|
-
key: string;
|
|
229
|
-
name?: string;
|
|
230
|
-
type?: "boolean" | "string" | "integer";
|
|
231
|
-
value: boolean | string | number;
|
|
232
|
-
organizations?: Record<string, boolean | string | number>;
|
|
233
|
-
}>;
|
|
234
|
-
plans?: Array<{
|
|
235
|
-
key: string;
|
|
236
|
-
name?: string;
|
|
237
|
-
subscribers?: string[];
|
|
238
|
-
entitlements?: Array<{
|
|
239
|
-
featureKey: string;
|
|
240
|
-
featureName?: string;
|
|
241
|
-
priceName?: string;
|
|
242
|
-
fixedCharge?: number | null;
|
|
243
|
-
unitAmount?: number | null;
|
|
244
|
-
limitMax?: number | null;
|
|
245
|
-
limitMin?: number | null;
|
|
246
|
-
}>;
|
|
247
|
-
}>;
|
|
248
|
-
permissions?: Array<{
|
|
249
|
-
key: string;
|
|
250
|
-
name?: string;
|
|
251
|
-
description?: string;
|
|
252
|
-
}>;
|
|
253
|
-
applications?: Array<{
|
|
254
|
-
clientId: string;
|
|
255
|
-
clientSecret?: string;
|
|
256
|
-
name?: string;
|
|
257
|
-
organization?: string;
|
|
258
|
-
scopes?: string[];
|
|
259
|
-
permissions?: string[];
|
|
260
|
-
audience?: string | string[];
|
|
261
|
-
}>;
|
|
262
|
-
}
|
|
263
|
-
interface ResolvedSeed {
|
|
264
|
-
users: KindeUser[];
|
|
265
|
-
organizations: KindeOrganization[];
|
|
266
|
-
memberships: KindeMembership[];
|
|
267
|
-
applications: KindeApplication[];
|
|
268
|
-
webhooks: Array<{
|
|
269
|
-
url: string;
|
|
270
|
-
events?: string[];
|
|
271
|
-
}>;
|
|
272
|
-
roles: SeedRole[];
|
|
273
|
-
permissions: SeedPermission[];
|
|
274
|
-
featureFlags: SeedFeatureFlag[];
|
|
275
|
-
plans: SeedPlan[];
|
|
276
|
-
userProperties: Record<string, Record<string, string | number | boolean>>;
|
|
277
|
-
}
|
|
278
|
-
interface SeedFeatureFlag {
|
|
279
|
-
id: string;
|
|
280
|
-
key: string;
|
|
281
|
-
name: string;
|
|
282
|
-
type: "boolean" | "string" | "integer";
|
|
283
|
-
value: boolean | string | number;
|
|
284
|
-
organizations: Record<string, boolean | string | number>;
|
|
285
|
-
}
|
|
286
|
-
interface SeedPlan {
|
|
287
|
-
key: string;
|
|
288
|
-
name: string;
|
|
289
|
-
subscribers: string[];
|
|
290
|
-
subscribedOn: string;
|
|
291
|
-
entitlements: Array<{
|
|
292
|
-
id: string;
|
|
293
|
-
featureKey: string;
|
|
294
|
-
featureName: string;
|
|
295
|
-
priceName: string;
|
|
296
|
-
fixedCharge: number | null;
|
|
297
|
-
unitAmount: number | null;
|
|
298
|
-
limitMax: number | null;
|
|
299
|
-
limitMin: number | null;
|
|
300
|
-
}>;
|
|
301
|
-
}
|
|
302
|
-
interface SeedRole {
|
|
303
|
-
id: string;
|
|
304
|
-
key: string;
|
|
305
|
-
name: string;
|
|
306
|
-
description: string | null;
|
|
307
|
-
isDefault: boolean;
|
|
308
|
-
permissions: string[];
|
|
309
|
-
}
|
|
310
|
-
interface SeedPermission {
|
|
311
|
-
id: string;
|
|
312
|
-
key: string;
|
|
313
|
-
name: string;
|
|
314
|
-
description: string | null;
|
|
315
|
-
}
|
|
316
|
-
declare function resolveSeed(input: unknown): ResolvedSeed;
|
|
317
|
-
declare function seedScenario(seed: ResolvedSeed, ref: {
|
|
318
|
-
user: string;
|
|
319
|
-
organization?: string | null;
|
|
320
|
-
}): AuthenticatedScenario;
|
|
321
|
-
|
|
322
|
-
interface UserMeta {
|
|
323
|
-
providedId: string | null;
|
|
324
|
-
isSuspended: boolean;
|
|
325
|
-
isPasswordResetRequested: boolean;
|
|
326
|
-
createdOn: string;
|
|
327
|
-
totalSignIns: number;
|
|
328
|
-
lastSignedIn: string | null;
|
|
329
|
-
}
|
|
330
|
-
interface OrganizationMeta {
|
|
331
|
-
externalId: string | null;
|
|
332
|
-
handle: string;
|
|
333
|
-
createdOn: string;
|
|
334
|
-
isAllowRegistrations: boolean;
|
|
335
|
-
}
|
|
336
|
-
declare class Directory {
|
|
337
|
-
readonly seed: ResolvedSeed;
|
|
338
|
-
private readonly userMeta;
|
|
339
|
-
private readonly orgMeta;
|
|
340
|
-
private readonly snapshot;
|
|
341
|
-
constructor(seed: ResolvedSeed);
|
|
342
|
-
restore(): void;
|
|
343
|
-
user(id: string): KindeUser | undefined;
|
|
344
|
-
meta(user: KindeUser): UserMeta;
|
|
345
|
-
isSuspended(userId: string): boolean;
|
|
346
|
-
recordSignIn(user: KindeUser, organizationCode: string | null): void;
|
|
347
|
-
createUser(input: {
|
|
348
|
-
email?: string | null;
|
|
349
|
-
givenName?: string | null;
|
|
350
|
-
familyName?: string | null;
|
|
351
|
-
picture?: string | null;
|
|
352
|
-
providedId?: string | null;
|
|
353
|
-
}): KindeUser;
|
|
354
|
-
deleteUser(id: string): boolean;
|
|
355
|
-
organization(code: string): KindeOrganization | undefined;
|
|
356
|
-
orgInfo(org: KindeOrganization): OrganizationMeta;
|
|
357
|
-
createOrganization(input: {
|
|
358
|
-
name: string;
|
|
359
|
-
externalId?: string | null;
|
|
360
|
-
handle?: string | null;
|
|
361
|
-
}): KindeOrganization;
|
|
362
|
-
deleteOrganization(code: string): boolean;
|
|
363
|
-
membership(userId: string, organizationCode: string): KindeMembership | undefined;
|
|
364
|
-
addMembership(userId: string, organizationCode: string, roles?: string[], permissions?: string[]): KindeMembership;
|
|
365
|
-
removeMembership(userId: string, organizationCode: string): boolean;
|
|
366
|
-
role(idOrKey: string): SeedRole | undefined;
|
|
367
|
-
permission(idOrKey: string): SeedPermission | undefined;
|
|
368
|
-
ensureRole(key: string, extra?: Partial<Omit<SeedRole, "id" | "key">>): SeedRole;
|
|
369
|
-
ensurePermission(key: string, extra?: Partial<Omit<SeedPermission, "id" | "key">>): SeedPermission;
|
|
370
|
-
deleteRole(id: string): SeedRole | undefined;
|
|
371
|
-
deletePermission(id: string): SeedPermission | undefined;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
interface FailureRule {
|
|
375
|
-
path: string;
|
|
376
|
-
method?: string;
|
|
377
|
-
status?: number;
|
|
378
|
-
delayMs?: number;
|
|
379
|
-
hang?: boolean;
|
|
380
|
-
times?: number;
|
|
381
|
-
retryAfter?: number;
|
|
382
|
-
}
|
|
383
|
-
interface ActiveFailure {
|
|
384
|
-
id: string;
|
|
385
|
-
path: string;
|
|
386
|
-
method: string | null;
|
|
387
|
-
status: number | null;
|
|
388
|
-
delayMs: number;
|
|
389
|
-
hang: boolean;
|
|
390
|
-
remaining: number | null;
|
|
391
|
-
retryAfter: number;
|
|
392
|
-
hits: number;
|
|
393
|
-
}
|
|
394
|
-
declare class FailureInjector {
|
|
395
|
-
private rules;
|
|
396
|
-
private nextId;
|
|
397
|
-
add(rule: FailureRule): ActiveFailure;
|
|
398
|
-
remove(id: string): boolean;
|
|
399
|
-
clear(): void;
|
|
400
|
-
list(): ActiveFailure[];
|
|
401
|
-
take(method: string, path: string): ActiveFailure | null;
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
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"];
|
|
405
|
-
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"];
|
|
406
|
-
type WebhookInvalidKind = "bad-signature" | "unknown-key" | "unsigned" | "stale";
|
|
407
|
-
type WebhookSource = "admin" | "api" | "user";
|
|
408
|
-
interface WebhookEndpointInput {
|
|
409
|
-
url: string;
|
|
410
|
-
events?: string[];
|
|
411
|
-
}
|
|
412
|
-
interface WebhookEndpoint {
|
|
413
|
-
id: string;
|
|
414
|
-
url: string;
|
|
415
|
-
events: string[] | null;
|
|
416
|
-
}
|
|
417
|
-
interface SendWebhookOptions {
|
|
418
|
-
type: string;
|
|
419
|
-
data?: Record<string, unknown>;
|
|
420
|
-
user?: string;
|
|
421
|
-
organization?: string;
|
|
422
|
-
role?: string;
|
|
423
|
-
permission?: string;
|
|
424
|
-
source?: WebhookSource;
|
|
425
|
-
ipAddress?: string;
|
|
426
|
-
to?: string;
|
|
427
|
-
duplicate?: number;
|
|
428
|
-
delayMs?: number;
|
|
429
|
-
invalid?: WebhookInvalidKind;
|
|
430
|
-
}
|
|
431
|
-
interface WebhookAttempt {
|
|
432
|
-
attempt: number;
|
|
433
|
-
status: number | null;
|
|
434
|
-
error: string | null;
|
|
435
|
-
durationMs: number;
|
|
436
|
-
}
|
|
437
|
-
interface WebhookDelivery {
|
|
438
|
-
webhookId: string;
|
|
439
|
-
eventId: string;
|
|
440
|
-
type: string;
|
|
441
|
-
url: string;
|
|
442
|
-
copy: number;
|
|
443
|
-
delivered: boolean;
|
|
444
|
-
attempts: WebhookAttempt[];
|
|
445
|
-
payload: Record<string, unknown>;
|
|
446
|
-
}
|
|
447
|
-
interface WebhookOptions {
|
|
448
|
-
retryDelaysMs?: number[];
|
|
449
|
-
timeoutMs?: number;
|
|
450
|
-
}
|
|
451
|
-
declare class WebhookDispatcher {
|
|
452
|
-
private readonly testkit;
|
|
453
|
-
private readonly seed;
|
|
454
|
-
private endpoints;
|
|
455
|
-
private seededEndpoints;
|
|
456
|
-
private log;
|
|
457
|
-
private nextEndpoint;
|
|
458
|
-
private readonly retryDelaysMs;
|
|
459
|
-
private readonly timeoutMs;
|
|
460
|
-
constructor(testkit: KindeTestkit, seed: ResolvedSeed, endpoints?: WebhookEndpointInput[], options?: WebhookOptions);
|
|
461
|
-
addEndpoint(input: WebhookEndpointInput): WebhookEndpoint;
|
|
462
|
-
removeEndpoint(id: string): boolean;
|
|
463
|
-
listEndpoints(): WebhookEndpoint[];
|
|
464
|
-
deliveries(): WebhookDelivery[];
|
|
465
|
-
reset(): void;
|
|
466
|
-
buildEvent(options: SendWebhookOptions): Record<string, unknown>;
|
|
467
|
-
send(options: SendWebhookOptions): Promise<WebhookDelivery[]>;
|
|
468
|
-
private deliver;
|
|
469
|
-
private buildData;
|
|
470
|
-
emit(type: string, data: Record<string, unknown>, source?: WebhookSource): void;
|
|
471
|
-
userEventData(user: KindeUser): Record<string, unknown>;
|
|
472
|
-
emitForUser(type: "user.created" | "user.authenticated", user: KindeUser): void;
|
|
473
|
-
private userData;
|
|
474
|
-
private userPayload;
|
|
475
|
-
private organizationData;
|
|
476
|
-
private namedData;
|
|
477
|
-
private requireUser;
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
interface StartKindeTestkitOptions {
|
|
481
|
-
port?: number;
|
|
482
|
-
host?: string;
|
|
483
|
-
issuer?: string;
|
|
484
|
-
audience?: string | string[];
|
|
485
|
-
clientId?: string;
|
|
486
|
-
seed?: TestkitSeed;
|
|
487
|
-
allowPublic?: boolean;
|
|
488
|
-
webhooks?: WebhookOptions;
|
|
489
|
-
https?: boolean | {
|
|
490
|
-
certDirectory?: string;
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
interface RunningKindeTestkit {
|
|
494
|
-
url: string;
|
|
495
|
-
issuer: string;
|
|
496
|
-
discoveryUrl: string;
|
|
497
|
-
jwksUri: string;
|
|
498
|
-
testkit: KindeTestkit;
|
|
499
|
-
seed: ResolvedSeed;
|
|
500
|
-
failures: FailureInjector;
|
|
501
|
-
webhooks: WebhookDispatcher;
|
|
502
|
-
directory: Directory;
|
|
503
|
-
certificatePath: string | null;
|
|
504
|
-
reset(): void;
|
|
505
|
-
close(): Promise<void>;
|
|
506
|
-
}
|
|
507
|
-
declare function startKindeTestkit(options?: StartKindeTestkitOptions): Promise<RunningKindeTestkit>;
|
|
508
|
-
|
|
509
52
|
type TestkitErrorCode = "PUBLIC_BIND_REFUSED" | "SEED_INVALID" | "SEED_UNKNOWN_USER" | "SEED_UNKNOWN_ORGANIZATION" | "SEED_NO_MEMBERSHIP" | "INVALID_DURATION" | "INVALID_REQUEST" | "EMULATOR_UNREACHABLE";
|
|
510
53
|
declare class TestkitError extends Error {
|
|
511
54
|
readonly code: TestkitErrorCode;
|
|
512
55
|
readonly details: string[];
|
|
56
|
+
/** The message without the details list. */
|
|
57
|
+
readonly summary: string;
|
|
513
58
|
constructor(code: TestkitErrorCode, message: string, details?: string[]);
|
|
514
59
|
toString(): string;
|
|
515
60
|
}
|
|
@@ -555,4 +100,35 @@ declare function runDoctor(options: {
|
|
|
555
100
|
}): Promise<DoctorReport>;
|
|
556
101
|
declare function parseEnvFile(text: string): Record<string, string>;
|
|
557
102
|
|
|
558
|
-
|
|
103
|
+
/** Files `kinde-testkit start` looks for, in this order, when no --seed is given. */
|
|
104
|
+
declare const DEFAULT_SEED_FILES: string[];
|
|
105
|
+
declare function findSeedFile(directory?: string): string | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Reads a seed from JSON, YAML, or a JavaScript or TypeScript module.
|
|
108
|
+
* A module exports the seed as its default export or as `seed`.
|
|
109
|
+
* TypeScript files need a Node version that runs TypeScript (22.18 or later).
|
|
110
|
+
*/
|
|
111
|
+
declare function loadSeedFile(path: string): Promise<TestkitSeed>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Steps for signing in through the testkit with plain HTTP requests instead of a browser page.
|
|
115
|
+
* The Cypress commands use these. No Node APIs here, because Cypress bundles this file for the browser.
|
|
116
|
+
*/
|
|
117
|
+
interface RequestSignInOptions {
|
|
118
|
+
/** Email address or ID of the user. */
|
|
119
|
+
user: string;
|
|
120
|
+
/** Active organization, for users in more than one. */
|
|
121
|
+
org?: string;
|
|
122
|
+
}
|
|
123
|
+
/** The app's login route, with the hints the testkit sign-in page reads. */
|
|
124
|
+
declare function appLoginUrl(loginPath: string, options: RequestSignInOptions): string;
|
|
125
|
+
/** Reads the hidden request field from the testkit sign-in page. */
|
|
126
|
+
declare function readSignInRequest(html: string): string;
|
|
127
|
+
/** The form the sign-in page posts to /oauth2/auth/login. */
|
|
128
|
+
declare function signInForm(request: string, options: RequestSignInOptions): Record<string, string>;
|
|
129
|
+
/** Explains why the testkit did not redirect back to the app after the form was posted. */
|
|
130
|
+
declare function signInFailure(status: number, html: string, options: RequestSignInOptions): Error;
|
|
131
|
+
/** Resolves a Location header, which can be relative, against the URL that sent it. */
|
|
132
|
+
declare function resolveLocation(location: string, from: string): string;
|
|
133
|
+
|
|
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 };
|