kinde-testkit 0.4.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/dist/index.d.cts CHANGED
@@ -200,6 +200,7 @@ interface TestkitSeed {
200
200
  familyName?: string | null;
201
201
  picture?: string | null;
202
202
  claims?: Record<string, unknown>;
203
+ properties?: Record<string, string | number | boolean>;
203
204
  }>;
204
205
  organizations?: Array<{
205
206
  code: string;
@@ -216,6 +217,39 @@ interface TestkitSeed {
216
217
  url: string;
217
218
  events?: string[];
218
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
+ }>;
219
253
  applications?: Array<{
220
254
  clientId: string;
221
255
  clientSecret?: string;
@@ -235,6 +269,49 @@ interface ResolvedSeed {
235
269
  url: string;
236
270
  events?: string[];
237
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;
238
315
  }
239
316
  declare function resolveSeed(input: unknown): ResolvedSeed;
240
317
  declare function seedScenario(seed: ResolvedSeed, ref: {
@@ -242,6 +319,58 @@ declare function seedScenario(seed: ResolvedSeed, ref: {
242
319
  organization?: string | null;
243
320
  }): AuthenticatedScenario;
244
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
+
245
374
  interface FailureRule {
246
375
  path: string;
247
376
  method?: string;
@@ -338,6 +467,8 @@ declare class WebhookDispatcher {
338
467
  send(options: SendWebhookOptions): Promise<WebhookDelivery[]>;
339
468
  private deliver;
340
469
  private buildData;
470
+ emit(type: string, data: Record<string, unknown>, source?: WebhookSource): void;
471
+ userEventData(user: KindeUser): Record<string, unknown>;
341
472
  emitForUser(type: "user.created" | "user.authenticated", user: KindeUser): void;
342
473
  private userData;
343
474
  private userPayload;
@@ -355,6 +486,9 @@ interface StartKindeTestkitOptions {
355
486
  seed?: TestkitSeed;
356
487
  allowPublic?: boolean;
357
488
  webhooks?: WebhookOptions;
489
+ https?: boolean | {
490
+ certDirectory?: string;
491
+ };
358
492
  }
359
493
  interface RunningKindeTestkit {
360
494
  url: string;
@@ -365,6 +499,8 @@ interface RunningKindeTestkit {
365
499
  seed: ResolvedSeed;
366
500
  failures: FailureInjector;
367
501
  webhooks: WebhookDispatcher;
502
+ directory: Directory;
503
+ certificatePath: string | null;
368
504
  reset(): void;
369
505
  close(): Promise<void>;
370
506
  }
@@ -378,6 +514,19 @@ declare class TestkitError extends Error {
378
514
  toString(): string;
379
515
  }
380
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
+
381
530
  type CheckStatus = "pass" | "warn" | "fail";
382
531
  interface Check {
383
532
  name: string;
@@ -406,4 +555,4 @@ declare function runDoctor(options: {
406
555
  }): Promise<DoctorReport>;
407
556
  declare function parseEnvFile(text: string): Record<string, string>;
408
557
 
409
- 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, 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 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, 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
@@ -200,6 +200,7 @@ interface TestkitSeed {
200
200
  familyName?: string | null;
201
201
  picture?: string | null;
202
202
  claims?: Record<string, unknown>;
203
+ properties?: Record<string, string | number | boolean>;
203
204
  }>;
204
205
  organizations?: Array<{
205
206
  code: string;
@@ -216,6 +217,39 @@ interface TestkitSeed {
216
217
  url: string;
217
218
  events?: string[];
218
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
+ }>;
219
253
  applications?: Array<{
220
254
  clientId: string;
221
255
  clientSecret?: string;
@@ -235,6 +269,49 @@ interface ResolvedSeed {
235
269
  url: string;
236
270
  events?: string[];
237
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;
238
315
  }
239
316
  declare function resolveSeed(input: unknown): ResolvedSeed;
240
317
  declare function seedScenario(seed: ResolvedSeed, ref: {
@@ -242,6 +319,58 @@ declare function seedScenario(seed: ResolvedSeed, ref: {
242
319
  organization?: string | null;
243
320
  }): AuthenticatedScenario;
244
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
+
245
374
  interface FailureRule {
246
375
  path: string;
247
376
  method?: string;
@@ -338,6 +467,8 @@ declare class WebhookDispatcher {
338
467
  send(options: SendWebhookOptions): Promise<WebhookDelivery[]>;
339
468
  private deliver;
340
469
  private buildData;
470
+ emit(type: string, data: Record<string, unknown>, source?: WebhookSource): void;
471
+ userEventData(user: KindeUser): Record<string, unknown>;
341
472
  emitForUser(type: "user.created" | "user.authenticated", user: KindeUser): void;
342
473
  private userData;
343
474
  private userPayload;
@@ -355,6 +486,9 @@ interface StartKindeTestkitOptions {
355
486
  seed?: TestkitSeed;
356
487
  allowPublic?: boolean;
357
488
  webhooks?: WebhookOptions;
489
+ https?: boolean | {
490
+ certDirectory?: string;
491
+ };
358
492
  }
359
493
  interface RunningKindeTestkit {
360
494
  url: string;
@@ -365,6 +499,8 @@ interface RunningKindeTestkit {
365
499
  seed: ResolvedSeed;
366
500
  failures: FailureInjector;
367
501
  webhooks: WebhookDispatcher;
502
+ directory: Directory;
503
+ certificatePath: string | null;
368
504
  reset(): void;
369
505
  close(): Promise<void>;
370
506
  }
@@ -378,6 +514,19 @@ declare class TestkitError extends Error {
378
514
  toString(): string;
379
515
  }
380
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
+
381
530
  type CheckStatus = "pass" | "warn" | "fail";
382
531
  interface Check {
383
532
  name: string;
@@ -406,4 +555,4 @@ declare function runDoctor(options: {
406
555
  }): Promise<DoctorReport>;
407
556
  declare function parseEnvFile(text: string): Record<string, string>;
408
557
 
409
- 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, 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 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, 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 };