kinde-testkit 0.3.0 → 0.5.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 +18 -0
- package/README.md +113 -8
- package/dist/cli.js +1580 -118
- package/dist/index.cjs +1428 -104
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +235 -1
- package/dist/index.d.ts +235 -1
- package/dist/index.js +1421 -103
- package/dist/index.js.map +1 -1
- package/dist/playwright.d.ts +34 -0
- package/dist/playwright.js +4 -0
- package/dist/playwright.js.map +1 -1
- package/dist/vitest.d.ts +186 -0
- package/dist/vitest.js +1409 -103
- package/dist/vitest.js.map +1 -1
- package/package.json +4 -1
package/dist/index.d.cts
CHANGED
|
@@ -180,6 +180,7 @@ declare class KindeTestkit {
|
|
|
180
180
|
idTokenFor(scenario: Scenario, options?: IdTokenOptions): Promise<string | null>;
|
|
181
181
|
headersFor(scenario: Scenario, overrides?: ScenarioTokenOverrides): Promise<Record<string, string>>;
|
|
182
182
|
principalFor(scenario: Scenario): KindePrincipal | null;
|
|
183
|
+
signPayload(payload: Record<string, unknown>, invalid?: "bad-signature" | "unknown-key" | "unsigned"): Promise<string>;
|
|
183
184
|
private sign;
|
|
184
185
|
private stranger;
|
|
185
186
|
}
|
|
@@ -199,6 +200,7 @@ interface TestkitSeed {
|
|
|
199
200
|
familyName?: string | null;
|
|
200
201
|
picture?: string | null;
|
|
201
202
|
claims?: Record<string, unknown>;
|
|
203
|
+
properties?: Record<string, string | number | boolean>;
|
|
202
204
|
}>;
|
|
203
205
|
organizations?: Array<{
|
|
204
206
|
code: string;
|
|
@@ -211,6 +213,43 @@ interface TestkitSeed {
|
|
|
211
213
|
roles?: string[];
|
|
212
214
|
permissions?: string[];
|
|
213
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
|
+
}>;
|
|
214
253
|
applications?: Array<{
|
|
215
254
|
clientId: string;
|
|
216
255
|
clientSecret?: string;
|
|
@@ -226,6 +265,53 @@ interface ResolvedSeed {
|
|
|
226
265
|
organizations: KindeOrganization[];
|
|
227
266
|
memberships: KindeMembership[];
|
|
228
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;
|
|
229
315
|
}
|
|
230
316
|
declare function resolveSeed(input: unknown): ResolvedSeed;
|
|
231
317
|
declare function seedScenario(seed: ResolvedSeed, ref: {
|
|
@@ -233,6 +319,58 @@ declare function seedScenario(seed: ResolvedSeed, ref: {
|
|
|
233
319
|
organization?: string | null;
|
|
234
320
|
}): AuthenticatedScenario;
|
|
235
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
|
+
|
|
236
374
|
interface FailureRule {
|
|
237
375
|
path: string;
|
|
238
376
|
method?: string;
|
|
@@ -263,6 +401,82 @@ declare class FailureInjector {
|
|
|
263
401
|
take(method: string, path: string): ActiveFailure | null;
|
|
264
402
|
}
|
|
265
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
|
+
|
|
266
480
|
interface StartKindeTestkitOptions {
|
|
267
481
|
port?: number;
|
|
268
482
|
host?: string;
|
|
@@ -271,6 +485,10 @@ interface StartKindeTestkitOptions {
|
|
|
271
485
|
clientId?: string;
|
|
272
486
|
seed?: TestkitSeed;
|
|
273
487
|
allowPublic?: boolean;
|
|
488
|
+
webhooks?: WebhookOptions;
|
|
489
|
+
https?: boolean | {
|
|
490
|
+
certDirectory?: string;
|
|
491
|
+
};
|
|
274
492
|
}
|
|
275
493
|
interface RunningKindeTestkit {
|
|
276
494
|
url: string;
|
|
@@ -280,6 +498,9 @@ interface RunningKindeTestkit {
|
|
|
280
498
|
testkit: KindeTestkit;
|
|
281
499
|
seed: ResolvedSeed;
|
|
282
500
|
failures: FailureInjector;
|
|
501
|
+
webhooks: WebhookDispatcher;
|
|
502
|
+
directory: Directory;
|
|
503
|
+
certificatePath: string | null;
|
|
283
504
|
reset(): void;
|
|
284
505
|
close(): Promise<void>;
|
|
285
506
|
}
|
|
@@ -293,6 +514,19 @@ declare class TestkitError extends Error {
|
|
|
293
514
|
toString(): string;
|
|
294
515
|
}
|
|
295
516
|
|
|
517
|
+
interface LocalCertificate {
|
|
518
|
+
cert: string;
|
|
519
|
+
key: string;
|
|
520
|
+
certPath: string;
|
|
521
|
+
keyPath: string;
|
|
522
|
+
created: boolean;
|
|
523
|
+
}
|
|
524
|
+
declare function ensureLocalCertificate(directory?: string): LocalCertificate;
|
|
525
|
+
declare function createLocalCertificate(): {
|
|
526
|
+
cert: string;
|
|
527
|
+
key: string;
|
|
528
|
+
};
|
|
529
|
+
|
|
296
530
|
type CheckStatus = "pass" | "warn" | "fail";
|
|
297
531
|
interface Check {
|
|
298
532
|
name: string;
|
|
@@ -321,4 +555,4 @@ declare function runDoctor(options: {
|
|
|
321
555
|
}): Promise<DoctorReport>;
|
|
322
556
|
declare function parseEnvFile(text: string): Record<string, string>;
|
|
323
557
|
|
|
324
|
-
export { type ActiveFailure, type AuthenticatedScenario, type Check, type CheckStatus, type CreateKindeOrganizationOptions, type CreateKindeUserOptions, type CreateMembershipOptions, DEFAULT_AUTH_METHODS, DEFAULT_CLIENT_ID, DEFAULT_ISSUER, DEFAULT_M2M_CLIENT_ID, DEFAULT_SCOPES, type DoctorReport, type Duration, FailureInjector, type FailureRule, INVALID_TOKEN_KINDS, type IdTokenOptions, type InvalidTokenKind, type KindeApplication, type KindeMembership, type KindeOrganization, type KindePrincipal, type KindeRole, KindeTestkit, type KindeTestkitOptions, type KindeTokenOptions, type KindeUser, type M2MTokenOptions, type ResolvedSeed, type RunningKindeTestkit, type Scenario, ScenarioBuilder, type ScenarioTokenOverrides, type StartKindeTestkitOptions, TestkitError, type TestkitErrorCode, type TestkitSeed, type TokenInspection, type UnauthenticatedScenario, createKindeOrganization, createKindeToken, createKindeUser, createMembership, getDefaultTestkit, inspectToken, isAuthenticated, parseEnvFile, principalFromClaims, resetFactories, resolveSeed, runDoctor, scenario, seedScenario, startKindeTestkit, toKindeRole };
|
|
558
|
+
export { type ActiveFailure, type AuthenticatedScenario, BILLING_EVENT_TYPES, type Check, type CheckStatus, type CreateKindeOrganizationOptions, type CreateKindeUserOptions, type CreateMembershipOptions, DEFAULT_AUTH_METHODS, DEFAULT_CLIENT_ID, DEFAULT_ISSUER, DEFAULT_M2M_CLIENT_ID, DEFAULT_SCOPES, 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, KindeTestkit, type KindeTestkitOptions, type KindeTokenOptions, type KindeUser, type LocalCertificate, type M2MTokenOptions, type ResolvedSeed, type RunningKindeTestkit, type Scenario, ScenarioBuilder, type ScenarioTokenOverrides, type SendWebhookOptions, type StartKindeTestkitOptions, TestkitError, type TestkitErrorCode, type TestkitSeed, type TokenInspection, type UnauthenticatedScenario, WEBHOOK_EVENT_TYPES, type WebhookAttempt, type WebhookDelivery, WebhookDispatcher, type WebhookEndpoint, type WebhookEndpointInput, type WebhookInvalidKind, type WebhookOptions, type WebhookSource, createKindeOrganization, createKindeToken, createKindeUser, createLocalCertificate, createMembership, ensureLocalCertificate, getDefaultTestkit, inspectToken, isAuthenticated, parseEnvFile, principalFromClaims, resetFactories, resolveSeed, runDoctor, scenario, seedScenario, startKindeTestkit, toKindeRole };
|
package/dist/index.d.ts
CHANGED
|
@@ -180,6 +180,7 @@ declare class KindeTestkit {
|
|
|
180
180
|
idTokenFor(scenario: Scenario, options?: IdTokenOptions): Promise<string | null>;
|
|
181
181
|
headersFor(scenario: Scenario, overrides?: ScenarioTokenOverrides): Promise<Record<string, string>>;
|
|
182
182
|
principalFor(scenario: Scenario): KindePrincipal | null;
|
|
183
|
+
signPayload(payload: Record<string, unknown>, invalid?: "bad-signature" | "unknown-key" | "unsigned"): Promise<string>;
|
|
183
184
|
private sign;
|
|
184
185
|
private stranger;
|
|
185
186
|
}
|
|
@@ -199,6 +200,7 @@ interface TestkitSeed {
|
|
|
199
200
|
familyName?: string | null;
|
|
200
201
|
picture?: string | null;
|
|
201
202
|
claims?: Record<string, unknown>;
|
|
203
|
+
properties?: Record<string, string | number | boolean>;
|
|
202
204
|
}>;
|
|
203
205
|
organizations?: Array<{
|
|
204
206
|
code: string;
|
|
@@ -211,6 +213,43 @@ interface TestkitSeed {
|
|
|
211
213
|
roles?: string[];
|
|
212
214
|
permissions?: string[];
|
|
213
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
|
+
}>;
|
|
214
253
|
applications?: Array<{
|
|
215
254
|
clientId: string;
|
|
216
255
|
clientSecret?: string;
|
|
@@ -226,6 +265,53 @@ interface ResolvedSeed {
|
|
|
226
265
|
organizations: KindeOrganization[];
|
|
227
266
|
memberships: KindeMembership[];
|
|
228
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;
|
|
229
315
|
}
|
|
230
316
|
declare function resolveSeed(input: unknown): ResolvedSeed;
|
|
231
317
|
declare function seedScenario(seed: ResolvedSeed, ref: {
|
|
@@ -233,6 +319,58 @@ declare function seedScenario(seed: ResolvedSeed, ref: {
|
|
|
233
319
|
organization?: string | null;
|
|
234
320
|
}): AuthenticatedScenario;
|
|
235
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
|
+
|
|
236
374
|
interface FailureRule {
|
|
237
375
|
path: string;
|
|
238
376
|
method?: string;
|
|
@@ -263,6 +401,82 @@ declare class FailureInjector {
|
|
|
263
401
|
take(method: string, path: string): ActiveFailure | null;
|
|
264
402
|
}
|
|
265
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
|
+
|
|
266
480
|
interface StartKindeTestkitOptions {
|
|
267
481
|
port?: number;
|
|
268
482
|
host?: string;
|
|
@@ -271,6 +485,10 @@ interface StartKindeTestkitOptions {
|
|
|
271
485
|
clientId?: string;
|
|
272
486
|
seed?: TestkitSeed;
|
|
273
487
|
allowPublic?: boolean;
|
|
488
|
+
webhooks?: WebhookOptions;
|
|
489
|
+
https?: boolean | {
|
|
490
|
+
certDirectory?: string;
|
|
491
|
+
};
|
|
274
492
|
}
|
|
275
493
|
interface RunningKindeTestkit {
|
|
276
494
|
url: string;
|
|
@@ -280,6 +498,9 @@ interface RunningKindeTestkit {
|
|
|
280
498
|
testkit: KindeTestkit;
|
|
281
499
|
seed: ResolvedSeed;
|
|
282
500
|
failures: FailureInjector;
|
|
501
|
+
webhooks: WebhookDispatcher;
|
|
502
|
+
directory: Directory;
|
|
503
|
+
certificatePath: string | null;
|
|
283
504
|
reset(): void;
|
|
284
505
|
close(): Promise<void>;
|
|
285
506
|
}
|
|
@@ -293,6 +514,19 @@ declare class TestkitError extends Error {
|
|
|
293
514
|
toString(): string;
|
|
294
515
|
}
|
|
295
516
|
|
|
517
|
+
interface LocalCertificate {
|
|
518
|
+
cert: string;
|
|
519
|
+
key: string;
|
|
520
|
+
certPath: string;
|
|
521
|
+
keyPath: string;
|
|
522
|
+
created: boolean;
|
|
523
|
+
}
|
|
524
|
+
declare function ensureLocalCertificate(directory?: string): LocalCertificate;
|
|
525
|
+
declare function createLocalCertificate(): {
|
|
526
|
+
cert: string;
|
|
527
|
+
key: string;
|
|
528
|
+
};
|
|
529
|
+
|
|
296
530
|
type CheckStatus = "pass" | "warn" | "fail";
|
|
297
531
|
interface Check {
|
|
298
532
|
name: string;
|
|
@@ -321,4 +555,4 @@ declare function runDoctor(options: {
|
|
|
321
555
|
}): Promise<DoctorReport>;
|
|
322
556
|
declare function parseEnvFile(text: string): Record<string, string>;
|
|
323
557
|
|
|
324
|
-
export { type ActiveFailure, type AuthenticatedScenario, type Check, type CheckStatus, type CreateKindeOrganizationOptions, type CreateKindeUserOptions, type CreateMembershipOptions, DEFAULT_AUTH_METHODS, DEFAULT_CLIENT_ID, DEFAULT_ISSUER, DEFAULT_M2M_CLIENT_ID, DEFAULT_SCOPES, type DoctorReport, type Duration, FailureInjector, type FailureRule, INVALID_TOKEN_KINDS, type IdTokenOptions, type InvalidTokenKind, type KindeApplication, type KindeMembership, type KindeOrganization, type KindePrincipal, type KindeRole, KindeTestkit, type KindeTestkitOptions, type KindeTokenOptions, type KindeUser, type M2MTokenOptions, type ResolvedSeed, type RunningKindeTestkit, type Scenario, ScenarioBuilder, type ScenarioTokenOverrides, type StartKindeTestkitOptions, TestkitError, type TestkitErrorCode, type TestkitSeed, type TokenInspection, type UnauthenticatedScenario, createKindeOrganization, createKindeToken, createKindeUser, createMembership, getDefaultTestkit, inspectToken, isAuthenticated, parseEnvFile, principalFromClaims, resetFactories, resolveSeed, runDoctor, scenario, seedScenario, startKindeTestkit, toKindeRole };
|
|
558
|
+
export { type ActiveFailure, type AuthenticatedScenario, BILLING_EVENT_TYPES, type Check, type CheckStatus, type CreateKindeOrganizationOptions, type CreateKindeUserOptions, type CreateMembershipOptions, DEFAULT_AUTH_METHODS, DEFAULT_CLIENT_ID, DEFAULT_ISSUER, DEFAULT_M2M_CLIENT_ID, DEFAULT_SCOPES, 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, KindeTestkit, type KindeTestkitOptions, type KindeTokenOptions, type KindeUser, type LocalCertificate, type M2MTokenOptions, type ResolvedSeed, type RunningKindeTestkit, type Scenario, ScenarioBuilder, type ScenarioTokenOverrides, type SendWebhookOptions, type StartKindeTestkitOptions, TestkitError, type TestkitErrorCode, type TestkitSeed, type TokenInspection, type UnauthenticatedScenario, WEBHOOK_EVENT_TYPES, type WebhookAttempt, type WebhookDelivery, WebhookDispatcher, type WebhookEndpoint, type WebhookEndpointInput, type WebhookInvalidKind, type WebhookOptions, type WebhookSource, createKindeOrganization, createKindeToken, createKindeUser, createLocalCertificate, createMembership, ensureLocalCertificate, getDefaultTestkit, inspectToken, isAuthenticated, parseEnvFile, principalFromClaims, resetFactories, resolveSeed, runDoctor, scenario, seedScenario, startKindeTestkit, toKindeRole };
|