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/vitest.d.ts
CHANGED
|
@@ -1,406 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as KindeTestkitHandle } from './handle-Dh0UpIzG.js';
|
|
2
|
+
export { K as KindeTestAuth, k as kindeTest } from './handle-Dh0UpIzG.js';
|
|
3
|
+
import { S as StartKindeTestkitOptions } from './server-BiODgeoB.js';
|
|
4
|
+
import './webhooks-DJyCsbdF.js';
|
|
5
|
+
import 'jose';
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
id: string;
|
|
5
|
-
email: string | null;
|
|
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
|
-
}
|
|
80
|
-
|
|
81
|
-
interface KindeTestkitOptions {
|
|
82
|
-
issuer?: string;
|
|
83
|
-
audience?: string | string[];
|
|
84
|
-
clientId?: string;
|
|
85
|
-
accessTokenExpiresIn?: Duration;
|
|
86
|
-
idTokenExpiresIn?: Duration;
|
|
87
|
-
now?: () => number;
|
|
88
|
-
}
|
|
89
|
-
type ScenarioTokenOverrides = Pick<KindeTokenOptions, "expiresIn" | "invalid" | "scopes" | "featureFlags" | "claims" | "authMethods" | "authTime" | "clientId" | "audience">;
|
|
90
|
-
interface M2MTokenOptions {
|
|
91
|
-
clientId?: string;
|
|
92
|
-
organizationCode?: string | null;
|
|
93
|
-
scopes?: string[];
|
|
94
|
-
grantedScopes?: string[];
|
|
95
|
-
audience?: string[];
|
|
96
|
-
permissions?: string[];
|
|
97
|
-
claims?: Record<string, unknown>;
|
|
98
|
-
expiresIn?: Duration;
|
|
99
|
-
invalid?: InvalidTokenKind;
|
|
100
|
-
}
|
|
101
|
-
interface IdTokenOptions {
|
|
102
|
-
expiresIn?: Duration;
|
|
103
|
-
authMethods?: string[];
|
|
104
|
-
authTime?: number;
|
|
105
|
-
clientId?: string;
|
|
106
|
-
nonce?: string;
|
|
107
|
-
}
|
|
108
|
-
declare class KindeTestkit {
|
|
109
|
-
readonly issuer: string;
|
|
110
|
-
readonly audience: string[];
|
|
111
|
-
readonly clientId: string;
|
|
112
|
-
private readonly accessTokenExpiresIn;
|
|
113
|
-
private readonly idTokenExpiresIn;
|
|
114
|
-
private readonly clock;
|
|
115
|
-
private readonly signingKey;
|
|
116
|
-
private strangerKey;
|
|
117
|
-
static create(options?: KindeTestkitOptions): Promise<KindeTestkit>;
|
|
118
|
-
private constructor();
|
|
119
|
-
get jwksUri(): string;
|
|
120
|
-
get keyId(): string;
|
|
121
|
-
get accessTokenLifetime(): number;
|
|
122
|
-
verify(token: string): Promise<JWTPayload>;
|
|
123
|
-
jwks(): {
|
|
124
|
-
keys: JWK[];
|
|
125
|
-
};
|
|
126
|
-
token(options?: KindeTokenOptions): Promise<string>;
|
|
127
|
-
m2mToken(options?: M2MTokenOptions): Promise<string>;
|
|
128
|
-
tokenFor(scenario: Scenario, overrides?: ScenarioTokenOverrides): Promise<string | null>;
|
|
129
|
-
idTokenFor(scenario: Scenario, options?: IdTokenOptions): Promise<string | null>;
|
|
130
|
-
headersFor(scenario: Scenario, overrides?: ScenarioTokenOverrides): Promise<Record<string, string>>;
|
|
131
|
-
principalFor(scenario: Scenario): KindePrincipal | null;
|
|
132
|
-
signPayload(payload: Record<string, unknown>, invalid?: "bad-signature" | "unknown-key" | "unsigned"): Promise<string>;
|
|
133
|
-
private sign;
|
|
134
|
-
private stranger;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
interface TestkitSeed {
|
|
138
|
-
issuer?: string;
|
|
139
|
-
audience?: string | string[];
|
|
140
|
-
clientId?: string;
|
|
141
|
-
users?: Array<{
|
|
142
|
-
id: string;
|
|
143
|
-
email?: string | null;
|
|
144
|
-
emailVerified?: boolean;
|
|
145
|
-
givenName?: string | null;
|
|
146
|
-
familyName?: string | null;
|
|
147
|
-
picture?: string | null;
|
|
148
|
-
claims?: Record<string, unknown>;
|
|
149
|
-
properties?: Record<string, string | number | boolean>;
|
|
150
|
-
}>;
|
|
151
|
-
organizations?: Array<{
|
|
152
|
-
code: string;
|
|
153
|
-
name?: string;
|
|
154
|
-
metadata?: Record<string, unknown>;
|
|
155
|
-
}>;
|
|
156
|
-
memberships?: Array<{
|
|
157
|
-
user: string;
|
|
158
|
-
organization: string;
|
|
159
|
-
roles?: string[];
|
|
160
|
-
permissions?: string[];
|
|
161
|
-
}>;
|
|
162
|
-
webhooks?: Array<{
|
|
163
|
-
url: string;
|
|
164
|
-
events?: string[];
|
|
165
|
-
}>;
|
|
166
|
-
roles?: Array<{
|
|
167
|
-
key: string;
|
|
168
|
-
name?: string;
|
|
169
|
-
description?: string;
|
|
170
|
-
permissions?: string[];
|
|
171
|
-
isDefault?: boolean;
|
|
172
|
-
}>;
|
|
173
|
-
featureFlags?: Array<{
|
|
174
|
-
key: string;
|
|
175
|
-
name?: string;
|
|
176
|
-
type?: "boolean" | "string" | "integer";
|
|
177
|
-
value: boolean | string | number;
|
|
178
|
-
organizations?: Record<string, boolean | string | number>;
|
|
179
|
-
}>;
|
|
180
|
-
plans?: Array<{
|
|
181
|
-
key: string;
|
|
182
|
-
name?: string;
|
|
183
|
-
subscribers?: string[];
|
|
184
|
-
entitlements?: Array<{
|
|
185
|
-
featureKey: string;
|
|
186
|
-
featureName?: string;
|
|
187
|
-
priceName?: string;
|
|
188
|
-
fixedCharge?: number | null;
|
|
189
|
-
unitAmount?: number | null;
|
|
190
|
-
limitMax?: number | null;
|
|
191
|
-
limitMin?: number | null;
|
|
192
|
-
}>;
|
|
193
|
-
}>;
|
|
194
|
-
permissions?: Array<{
|
|
195
|
-
key: string;
|
|
196
|
-
name?: string;
|
|
197
|
-
description?: string;
|
|
198
|
-
}>;
|
|
199
|
-
applications?: Array<{
|
|
200
|
-
clientId: string;
|
|
201
|
-
clientSecret?: string;
|
|
202
|
-
name?: string;
|
|
203
|
-
organization?: string;
|
|
204
|
-
scopes?: string[];
|
|
205
|
-
permissions?: string[];
|
|
206
|
-
audience?: string | string[];
|
|
207
|
-
}>;
|
|
208
|
-
}
|
|
209
|
-
interface ResolvedSeed {
|
|
210
|
-
users: KindeUser[];
|
|
211
|
-
organizations: KindeOrganization[];
|
|
212
|
-
memberships: KindeMembership[];
|
|
213
|
-
applications: KindeApplication[];
|
|
214
|
-
webhooks: Array<{
|
|
215
|
-
url: string;
|
|
216
|
-
events?: string[];
|
|
217
|
-
}>;
|
|
218
|
-
roles: SeedRole[];
|
|
219
|
-
permissions: SeedPermission[];
|
|
220
|
-
featureFlags: SeedFeatureFlag[];
|
|
221
|
-
plans: SeedPlan[];
|
|
222
|
-
userProperties: Record<string, Record<string, string | number | boolean>>;
|
|
223
|
-
}
|
|
224
|
-
interface SeedFeatureFlag {
|
|
225
|
-
id: string;
|
|
226
|
-
key: string;
|
|
227
|
-
name: string;
|
|
228
|
-
type: "boolean" | "string" | "integer";
|
|
229
|
-
value: boolean | string | number;
|
|
230
|
-
organizations: Record<string, boolean | string | number>;
|
|
231
|
-
}
|
|
232
|
-
interface SeedPlan {
|
|
233
|
-
key: string;
|
|
234
|
-
name: string;
|
|
235
|
-
subscribers: string[];
|
|
236
|
-
subscribedOn: string;
|
|
237
|
-
entitlements: Array<{
|
|
238
|
-
id: string;
|
|
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
|
-
interface SeedRole {
|
|
249
|
-
id: string;
|
|
250
|
-
key: string;
|
|
251
|
-
name: string;
|
|
252
|
-
description: string | null;
|
|
253
|
-
isDefault: boolean;
|
|
254
|
-
permissions: string[];
|
|
255
|
-
}
|
|
256
|
-
interface SeedPermission {
|
|
257
|
-
id: string;
|
|
258
|
-
key: string;
|
|
259
|
-
name: string;
|
|
260
|
-
description: string | null;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
interface FailureRule {
|
|
264
|
-
path: string;
|
|
265
|
-
method?: string;
|
|
266
|
-
status?: number;
|
|
267
|
-
delayMs?: number;
|
|
268
|
-
hang?: boolean;
|
|
269
|
-
times?: number;
|
|
270
|
-
retryAfter?: number;
|
|
271
|
-
}
|
|
272
|
-
interface ActiveFailure {
|
|
273
|
-
id: string;
|
|
274
|
-
path: string;
|
|
275
|
-
method: string | null;
|
|
276
|
-
status: number | null;
|
|
277
|
-
delayMs: number;
|
|
278
|
-
hang: boolean;
|
|
279
|
-
remaining: number | null;
|
|
280
|
-
retryAfter: number;
|
|
281
|
-
hits: number;
|
|
282
|
-
}
|
|
283
|
-
declare class FailureInjector {
|
|
284
|
-
private rules;
|
|
285
|
-
private nextId;
|
|
286
|
-
add(rule: FailureRule): ActiveFailure;
|
|
287
|
-
remove(id: string): boolean;
|
|
288
|
-
clear(): void;
|
|
289
|
-
list(): ActiveFailure[];
|
|
290
|
-
take(method: string, path: string): ActiveFailure | null;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
type WebhookInvalidKind = "bad-signature" | "unknown-key" | "unsigned" | "stale";
|
|
294
|
-
type WebhookSource = "admin" | "api" | "user";
|
|
295
|
-
interface WebhookEndpointInput {
|
|
296
|
-
url: string;
|
|
297
|
-
events?: string[];
|
|
298
|
-
}
|
|
299
|
-
interface WebhookEndpoint {
|
|
300
|
-
id: string;
|
|
301
|
-
url: string;
|
|
302
|
-
events: string[] | null;
|
|
303
|
-
}
|
|
304
|
-
interface SendWebhookOptions {
|
|
305
|
-
type: string;
|
|
306
|
-
data?: Record<string, unknown>;
|
|
307
|
-
user?: string;
|
|
308
|
-
organization?: string;
|
|
309
|
-
role?: string;
|
|
310
|
-
permission?: string;
|
|
311
|
-
source?: WebhookSource;
|
|
312
|
-
ipAddress?: string;
|
|
313
|
-
to?: string;
|
|
314
|
-
duplicate?: number;
|
|
315
|
-
delayMs?: number;
|
|
316
|
-
invalid?: WebhookInvalidKind;
|
|
317
|
-
}
|
|
318
|
-
interface WebhookAttempt {
|
|
319
|
-
attempt: number;
|
|
320
|
-
status: number | null;
|
|
321
|
-
error: string | null;
|
|
322
|
-
durationMs: number;
|
|
323
|
-
}
|
|
324
|
-
interface WebhookDelivery {
|
|
325
|
-
webhookId: string;
|
|
326
|
-
eventId: string;
|
|
327
|
-
type: string;
|
|
328
|
-
url: string;
|
|
329
|
-
copy: number;
|
|
330
|
-
delivered: boolean;
|
|
331
|
-
attempts: WebhookAttempt[];
|
|
332
|
-
payload: Record<string, unknown>;
|
|
333
|
-
}
|
|
334
|
-
interface WebhookOptions {
|
|
335
|
-
retryDelaysMs?: number[];
|
|
336
|
-
timeoutMs?: number;
|
|
337
|
-
}
|
|
338
|
-
declare class WebhookDispatcher {
|
|
339
|
-
private readonly testkit;
|
|
340
|
-
private readonly seed;
|
|
341
|
-
private endpoints;
|
|
342
|
-
private seededEndpoints;
|
|
343
|
-
private log;
|
|
344
|
-
private nextEndpoint;
|
|
345
|
-
private readonly retryDelaysMs;
|
|
346
|
-
private readonly timeoutMs;
|
|
347
|
-
constructor(testkit: KindeTestkit, seed: ResolvedSeed, endpoints?: WebhookEndpointInput[], options?: WebhookOptions);
|
|
348
|
-
addEndpoint(input: WebhookEndpointInput): WebhookEndpoint;
|
|
349
|
-
removeEndpoint(id: string): boolean;
|
|
350
|
-
listEndpoints(): WebhookEndpoint[];
|
|
351
|
-
deliveries(): WebhookDelivery[];
|
|
352
|
-
reset(): void;
|
|
353
|
-
buildEvent(options: SendWebhookOptions): Record<string, unknown>;
|
|
354
|
-
send(options: SendWebhookOptions): Promise<WebhookDelivery[]>;
|
|
355
|
-
private deliver;
|
|
356
|
-
private buildData;
|
|
357
|
-
emit(type: string, data: Record<string, unknown>, source?: WebhookSource): void;
|
|
358
|
-
userEventData(user: KindeUser): Record<string, unknown>;
|
|
359
|
-
emitForUser(type: "user.created" | "user.authenticated", user: KindeUser): void;
|
|
360
|
-
private userData;
|
|
361
|
-
private userPayload;
|
|
362
|
-
private organizationData;
|
|
363
|
-
private namedData;
|
|
364
|
-
private requireUser;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
interface StartKindeTestkitOptions {
|
|
368
|
-
port?: number;
|
|
369
|
-
host?: string;
|
|
370
|
-
issuer?: string;
|
|
371
|
-
audience?: string | string[];
|
|
372
|
-
clientId?: string;
|
|
373
|
-
seed?: TestkitSeed;
|
|
374
|
-
allowPublic?: boolean;
|
|
375
|
-
webhooks?: WebhookOptions;
|
|
376
|
-
https?: boolean | {
|
|
377
|
-
certDirectory?: string;
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
interface KindeTestAuth {
|
|
382
|
-
token: string | null;
|
|
383
|
-
headers: Record<string, string>;
|
|
384
|
-
principal: KindePrincipal | null;
|
|
385
|
-
request: {
|
|
386
|
-
headers: Record<string, string>;
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
declare function kindeTest(options: {
|
|
390
|
-
scenario: Scenario;
|
|
391
|
-
testkit?: KindeTestkit;
|
|
392
|
-
token?: ScenarioTokenOverrides;
|
|
393
|
-
}): Promise<KindeTestAuth>;
|
|
394
|
-
interface KindeTestkitHandle {
|
|
395
|
-
readonly url: string;
|
|
396
|
-
readonly issuer: string;
|
|
397
|
-
readonly jwksUri: string;
|
|
398
|
-
readonly testkit: KindeTestkit;
|
|
399
|
-
readonly failures: FailureInjector;
|
|
400
|
-
readonly webhooks: WebhookDispatcher;
|
|
401
|
-
auth(scenario: Scenario, token?: ScenarioTokenOverrides): Promise<KindeTestAuth>;
|
|
402
|
-
reset(): void;
|
|
403
|
-
}
|
|
7
|
+
/** Starts a testkit for the test file. Use the handle inside tests and hooks. */
|
|
404
8
|
declare function useKindeTestkit(options?: StartKindeTestkitOptions): KindeTestkitHandle;
|
|
405
9
|
|
|
406
|
-
export {
|
|
10
|
+
export { KindeTestkitHandle, useKindeTestkit };
|