@monocloud/auth-node-core 0.1.4 → 0.1.5

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
@@ -1,7 +1,875 @@
1
- import { Except, PartialDeep } from "type-fest";
2
1
  import { AccessToken, AccessToken as AccessToken$1, AuthState, AuthenticateOptions, Authenticators, AuthorizationParams, AuthorizationParams as AuthorizationParams$1, CallbackParams, ClientAuthMethod, CodeChallengeMethod, DisplayOptions, EndSessionParameters, EndSessionParameters as EndSessionParameters$1, Group, IdTokenClaims, IdTokenClaims as IdTokenClaims$1, IssuerMetadata, JWSAlgorithm, Jwk, Jwks, JwsHeaderParameters, MonoCloudAuthBaseError, MonoCloudClientOptions, MonoCloudHttpError, MonoCloudOPError, MonoCloudOidcClient, MonoCloudOidcClient as MonoCloudOidcClient$1, MonoCloudSession, MonoCloudSession as MonoCloudSession$1, MonoCloudTokenError, MonoCloudUser, MonoCloudValidationError, ParResponse, Prompt, PushedAuthorizationParams, RefetchUserInfoOptions, RefreshGrantOptions, RefreshGrantOptions as RefreshGrantOptions$1, RefreshSessionOptions, ResponseModes, ResponseTypes, Tokens, UserinfoResponse, UserinfoResponse as UserinfoResponse$1 } from "@monocloud/auth-core";
3
2
  import { SerializeOptions } from "cookie";
4
3
 
4
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/primitive.d.ts
5
+ /**
6
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
7
+
8
+ @category Type
9
+ */
10
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
11
+ //#endregion
12
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/is-any.d.ts
13
+ /**
14
+ Returns a boolean for whether the given type is `any`.
15
+
16
+ @link https://stackoverflow.com/a/49928360/1490091
17
+
18
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
19
+
20
+ @example
21
+ ```
22
+ import type {IsAny} from 'type-fest';
23
+
24
+ const typedObject = {a: 1, b: 2} as const;
25
+ const anyObject: any = {a: 1, b: 2};
26
+
27
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
28
+ return object[key];
29
+ }
30
+
31
+ const typedA = get(typedObject, 'a');
32
+ //=> 1
33
+
34
+ const anyA = get(anyObject, 'a');
35
+ //=> any
36
+ ```
37
+
38
+ @category Type Guard
39
+ @category Utilities
40
+ */
41
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
42
+ //#endregion
43
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/is-optional-key-of.d.ts
44
+ /**
45
+ Returns a boolean for whether the given key is an optional key of type.
46
+
47
+ This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
48
+
49
+ @example
50
+ ```
51
+ import type {IsOptionalKeyOf} from 'type-fest';
52
+
53
+ type User = {
54
+ name: string;
55
+ surname: string;
56
+
57
+ luckyNumber?: number;
58
+ };
59
+
60
+ type Admin = {
61
+ name: string;
62
+ surname?: string;
63
+ };
64
+
65
+ type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
66
+ //=> true
67
+
68
+ type T2 = IsOptionalKeyOf<User, 'name'>;
69
+ //=> false
70
+
71
+ type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
72
+ //=> boolean
73
+
74
+ type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
75
+ //=> false
76
+
77
+ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
78
+ //=> boolean
79
+ ```
80
+
81
+ @category Type Guard
82
+ @category Utilities
83
+ */
84
+ type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
85
+ //#endregion
86
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/optional-keys-of.d.ts
87
+ /**
88
+ Extract all optional keys from the given type.
89
+
90
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
91
+
92
+ @example
93
+ ```
94
+ import type {OptionalKeysOf, Except} from 'type-fest';
95
+
96
+ type User = {
97
+ name: string;
98
+ surname: string;
99
+
100
+ luckyNumber?: number;
101
+ };
102
+
103
+ const REMOVE_FIELD = Symbol('remove field symbol');
104
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
105
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
106
+ };
107
+
108
+ const update1: UpdateOperation<User> = {
109
+ name: 'Alice',
110
+ };
111
+
112
+ const update2: UpdateOperation<User> = {
113
+ name: 'Bob',
114
+ luckyNumber: REMOVE_FIELD,
115
+ };
116
+ ```
117
+
118
+ @category Utilities
119
+ */
120
+ type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
121
+ ? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
122
+ : never;
123
+ //#endregion
124
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/required-keys-of.d.ts
125
+ /**
126
+ Extract all required keys from the given type.
127
+
128
+ This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
129
+
130
+ @example
131
+ ```
132
+ import type {RequiredKeysOf} from 'type-fest';
133
+
134
+ declare function createValidation<
135
+ Entity extends object,
136
+ Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
137
+ >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
138
+
139
+ type User = {
140
+ name: string;
141
+ surname: string;
142
+ luckyNumber?: number;
143
+ };
144
+
145
+ const validator1 = createValidation<User>('name', value => value.length < 25);
146
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
147
+
148
+ // @ts-expect-error
149
+ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
150
+ // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
151
+ ```
152
+
153
+ @category Utilities
154
+ */
155
+ type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
156
+ ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
157
+ //#endregion
158
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/is-never.d.ts
159
+ /**
160
+ Returns a boolean for whether the given type is `never`.
161
+
162
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
163
+ @link https://stackoverflow.com/a/53984913/10292952
164
+ @link https://www.zhenghao.io/posts/ts-never
165
+
166
+ Useful in type utilities, such as checking if something does not occur.
167
+
168
+ @example
169
+ ```
170
+ import type {IsNever, And} from 'type-fest';
171
+
172
+ type A = IsNever<never>;
173
+ //=> true
174
+
175
+ type B = IsNever<any>;
176
+ //=> false
177
+
178
+ type C = IsNever<unknown>;
179
+ //=> false
180
+
181
+ type D = IsNever<never[]>;
182
+ //=> false
183
+
184
+ type E = IsNever<object>;
185
+ //=> false
186
+
187
+ type F = IsNever<string>;
188
+ //=> false
189
+ ```
190
+
191
+ @example
192
+ ```
193
+ import type {IsNever} from 'type-fest';
194
+
195
+ type IsTrue<T> = T extends true ? true : false;
196
+
197
+ // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
198
+ type A = IsTrue<never>;
199
+ //=> never
200
+
201
+ // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
202
+ type IsTrueFixed<T> =
203
+ IsNever<T> extends true ? false : T extends true ? true : false;
204
+
205
+ type B = IsTrueFixed<never>;
206
+ //=> false
207
+ ```
208
+
209
+ @category Type Guard
210
+ @category Utilities
211
+ */
212
+ type IsNever<T> = [T] extends [never] ? true : false;
213
+ //#endregion
214
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/if.d.ts
215
+ /**
216
+ An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
217
+
218
+ Use-cases:
219
+ - You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
220
+
221
+ Note:
222
+ - Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
223
+ - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
224
+
225
+ @example
226
+ ```
227
+ import type {If} from 'type-fest';
228
+
229
+ type A = If<true, 'yes', 'no'>;
230
+ //=> 'yes'
231
+
232
+ type B = If<false, 'yes', 'no'>;
233
+ //=> 'no'
234
+
235
+ type C = If<boolean, 'yes', 'no'>;
236
+ //=> 'yes' | 'no'
237
+
238
+ type D = If<any, 'yes', 'no'>;
239
+ //=> 'yes' | 'no'
240
+
241
+ type E = If<never, 'yes', 'no'>;
242
+ //=> 'no'
243
+ ```
244
+
245
+ @example
246
+ ```
247
+ import type {If, IsAny, IsNever} from 'type-fest';
248
+
249
+ type A = If<IsAny<unknown>, 'is any', 'not any'>;
250
+ //=> 'not any'
251
+
252
+ type B = If<IsNever<never>, 'is never', 'not never'>;
253
+ //=> 'is never'
254
+ ```
255
+
256
+ @example
257
+ ```
258
+ import type {If, IsEqual} from 'type-fest';
259
+
260
+ type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
261
+
262
+ type A = IfEqual<string, string, 'equal', 'not equal'>;
263
+ //=> 'equal'
264
+
265
+ type B = IfEqual<string, number, 'equal', 'not equal'>;
266
+ //=> 'not equal'
267
+ ```
268
+
269
+ Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
270
+
271
+ @example
272
+ ```
273
+ import type {If, IsEqual, StringRepeat} from 'type-fest';
274
+
275
+ type HundredZeroes = StringRepeat<'0', 100>;
276
+
277
+ // The following implementation is not tail recursive
278
+ type Includes<S extends string, Char extends string> =
279
+ S extends `${infer First}${infer Rest}`
280
+ ? If<IsEqual<First, Char>,
281
+ 'found',
282
+ Includes<Rest, Char>>
283
+ : 'not found';
284
+
285
+ // Hence, instantiations with long strings will fail
286
+ // @ts-expect-error
287
+ type Fails = Includes<HundredZeroes, '1'>;
288
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
289
+ // Error: Type instantiation is excessively deep and possibly infinite.
290
+
291
+ // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
292
+ type IncludesWithoutIf<S extends string, Char extends string> =
293
+ S extends `${infer First}${infer Rest}`
294
+ ? IsEqual<First, Char> extends true
295
+ ? 'found'
296
+ : IncludesWithoutIf<Rest, Char>
297
+ : 'not found';
298
+
299
+ // Now, instantiations with long strings will work
300
+ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
301
+ //=> 'not found'
302
+ ```
303
+
304
+ @category Type Guard
305
+ @category Utilities
306
+ */
307
+ type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
308
+ //#endregion
309
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/internal/type.d.ts
310
+ /**
311
+ Matches any primitive, `void`, `Date`, or `RegExp` value.
312
+ */
313
+ type BuiltIns = Primitive | void | Date | RegExp;
314
+ /**
315
+ Test if the given function has multiple call signatures.
316
+
317
+ Needed to handle the case of a single call signature with properties.
318
+
319
+ Multiple call signatures cannot currently be supported due to a TypeScript limitation.
320
+ @see https://github.com/microsoft/TypeScript/issues/29732
321
+ */
322
+ type HasMultipleCallSignatures<T extends (...arguments_: any[]) => unknown> = T extends {
323
+ (...arguments_: infer A): unknown;
324
+ (...arguments_: infer B): unknown;
325
+ } ? B extends A ? A extends B ? false : true : true : false;
326
+ //#endregion
327
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/simplify.d.ts
328
+ /**
329
+ Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
330
+
331
+ @example
332
+ ```
333
+ import type {Simplify} from 'type-fest';
334
+
335
+ type PositionProps = {
336
+ top: number;
337
+ left: number;
338
+ };
339
+
340
+ type SizeProps = {
341
+ width: number;
342
+ height: number;
343
+ };
344
+
345
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
346
+ type Props = Simplify<PositionProps & SizeProps>;
347
+ ```
348
+
349
+ Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
350
+
351
+ If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
352
+
353
+ @example
354
+ ```
355
+ import type {Simplify} from 'type-fest';
356
+
357
+ interface SomeInterface {
358
+ foo: number;
359
+ bar?: string;
360
+ baz: number | undefined;
361
+ }
362
+
363
+ type SomeType = {
364
+ foo: number;
365
+ bar?: string;
366
+ baz: number | undefined;
367
+ };
368
+
369
+ const literal = {foo: 123, bar: 'hello', baz: 456};
370
+ const someType: SomeType = literal;
371
+ const someInterface: SomeInterface = literal;
372
+
373
+ declare function fn(object: Record<string, unknown>): void;
374
+
375
+ fn(literal); // Good: literal object type is sealed
376
+ fn(someType); // Good: type is sealed
377
+ // @ts-expect-error
378
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
379
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
380
+ ```
381
+
382
+ @link https://github.com/microsoft/TypeScript/issues/15300
383
+ @see {@link SimplifyDeep}
384
+ @category Object
385
+ */
386
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
387
+ //#endregion
388
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/is-equal.d.ts
389
+ /**
390
+ Returns a boolean for whether the two given types are equal.
391
+
392
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
393
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
394
+
395
+ Use-cases:
396
+ - If you want to make a conditional branch based on the result of a comparison of two types.
397
+
398
+ @example
399
+ ```
400
+ import type {IsEqual} from 'type-fest';
401
+
402
+ // This type returns a boolean for whether the given array includes the given item.
403
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
404
+ type Includes<Value extends readonly any[], Item> =
405
+ Value extends readonly [Value[0], ...infer rest]
406
+ ? IsEqual<Value[0], Item> extends true
407
+ ? true
408
+ : Includes<rest, Item>
409
+ : false;
410
+ ```
411
+
412
+ @category Type Guard
413
+ @category Utilities
414
+ */
415
+ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
416
+ // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
417
+ type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
418
+ //#endregion
419
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/omit-index-signature.d.ts
420
+ /**
421
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
422
+
423
+ This is the counterpart of `PickIndexSignature`.
424
+
425
+ Use-cases:
426
+ - Remove overly permissive signatures from third-party types.
427
+
428
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
429
+
430
+ It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
431
+
432
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
433
+
434
+ ```
435
+ const indexed: Record<string, unknown> = {}; // Allowed
436
+
437
+ // @ts-expect-error
438
+ const keyed: Record<'foo', unknown> = {}; // Error
439
+ // TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
440
+ ```
441
+
442
+ Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
443
+
444
+ ```
445
+ type Indexed = {} extends Record<string, unknown>
446
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
447
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
448
+
449
+ type IndexedResult = Indexed;
450
+ //=> '✅ `{}` is assignable to `Record<string, unknown>`'
451
+
452
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
453
+ ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
454
+ : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
455
+
456
+ type KeyedResult = Keyed;
457
+ //=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
458
+ ```
459
+
460
+ Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
461
+
462
+ ```
463
+ type OmitIndexSignature<ObjectType> = {
464
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
465
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
466
+ };
467
+ ```
468
+
469
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
470
+
471
+ ```
472
+ type OmitIndexSignature<ObjectType> = {
473
+ [KeyType in keyof ObjectType
474
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
475
+ as {} extends Record<KeyType, unknown>
476
+ ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
477
+ : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
478
+ ]: ObjectType[KeyType];
479
+ };
480
+ ```
481
+
482
+ If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
483
+
484
+ @example
485
+ ```
486
+ import type {OmitIndexSignature} from 'type-fest';
487
+
488
+ type Example = {
489
+ // These index signatures will be removed.
490
+ [x: string]: any;
491
+ [x: number]: any;
492
+ [x: symbol]: any;
493
+ [x: `head-${string}`]: string;
494
+ [x: `${string}-tail`]: string;
495
+ [x: `head-${string}-tail`]: string;
496
+ [x: `${bigint}`]: string;
497
+ [x: `embedded-${number}`]: string;
498
+
499
+ // These explicitly defined keys will remain.
500
+ foo: 'bar';
501
+ qux?: 'baz';
502
+ };
503
+
504
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
505
+ //=> {foo: 'bar'; qux?: 'baz'}
506
+ ```
507
+
508
+ @see {@link PickIndexSignature}
509
+ @category Object
510
+ */
511
+ type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
512
+ //#endregion
513
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/pick-index-signature.d.ts
514
+ /**
515
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
516
+
517
+ This is the counterpart of `OmitIndexSignature`.
518
+
519
+ @example
520
+ ```
521
+ import type {PickIndexSignature} from 'type-fest';
522
+
523
+ declare const symbolKey: unique symbol;
524
+
525
+ type Example = {
526
+ // These index signatures will remain.
527
+ [x: string]: unknown;
528
+ [x: number]: unknown;
529
+ [x: symbol]: unknown;
530
+ [x: `head-${string}`]: string;
531
+ [x: `${string}-tail`]: string;
532
+ [x: `head-${string}-tail`]: string;
533
+ [x: `${bigint}`]: string;
534
+ [x: `embedded-${number}`]: string;
535
+
536
+ // These explicitly defined keys will be removed.
537
+ ['kebab-case-key']: string;
538
+ [symbolKey]: string;
539
+ foo: 'bar';
540
+ qux?: 'baz';
541
+ };
542
+
543
+ type ExampleIndexSignature = PickIndexSignature<Example>;
544
+ // {
545
+ // [x: string]: unknown;
546
+ // [x: number]: unknown;
547
+ // [x: symbol]: unknown;
548
+ // [x: `head-${string}`]: string;
549
+ // [x: `${string}-tail`]: string;
550
+ // [x: `head-${string}-tail`]: string;
551
+ // [x: `${bigint}`]: string;
552
+ // [x: `embedded-${number}`]: string;
553
+ // }
554
+ ```
555
+
556
+ @see {@link OmitIndexSignature}
557
+ @category Object
558
+ */
559
+ type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
560
+ //#endregion
561
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/merge.d.ts
562
+ // Merges two objects without worrying about index signatures.
563
+ type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
564
+ /**
565
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
566
+
567
+ @example
568
+ ```
569
+ import type {Merge} from 'type-fest';
570
+
571
+ type Foo = {
572
+ [x: string]: unknown;
573
+ [x: number]: unknown;
574
+ foo: string;
575
+ bar: symbol;
576
+ };
577
+
578
+ type Bar = {
579
+ [x: number]: number;
580
+ [x: symbol]: unknown;
581
+ bar: Date;
582
+ baz: boolean;
583
+ };
584
+
585
+ export type FooBar = Merge<Foo, Bar>;
586
+ //=> {
587
+ // [x: string]: unknown;
588
+ // [x: number]: number;
589
+ // [x: symbol]: unknown;
590
+ // foo: string;
591
+ // bar: Date;
592
+ // baz: boolean;
593
+ // }
594
+ ```
595
+
596
+ Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type.
597
+
598
+ @see {@link ObjectMerge}
599
+ @category Object
600
+ */
601
+ type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
602
+ ? Source extends unknown // For distributing `Source`
603
+ ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
604
+ : never;
605
+ // Should never happen
606
+ type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
607
+ //#endregion
608
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/internal/object.d.ts
609
+ /**
610
+ Merges user specified options with default options.
611
+
612
+ @example
613
+ ```
614
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
615
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
616
+ type SpecifiedOptions = {leavesOnly: true};
617
+
618
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
619
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
620
+ ```
621
+
622
+ @example
623
+ ```
624
+ // Complains if default values are not provided for optional options
625
+
626
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
627
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
628
+ type SpecifiedOptions = {};
629
+
630
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
631
+ // ~~~~~~~~~~~~~~~~~~~
632
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
633
+ ```
634
+
635
+ @example
636
+ ```
637
+ // Complains if an option's default type does not conform to the expected type
638
+
639
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
640
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
641
+ type SpecifiedOptions = {};
642
+
643
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
644
+ // ~~~~~~~~~~~~~~~~~~~
645
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
646
+ ```
647
+
648
+ @example
649
+ ```
650
+ // Complains if an option's specified type does not conform to the expected type
651
+
652
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
653
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
654
+ type SpecifiedOptions = {leavesOnly: 'yes'};
655
+
656
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
657
+ // ~~~~~~~~~~~~~~~~
658
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
659
+ ```
660
+ */
661
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
662
+ //#endregion
663
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/except.d.ts
664
+ /**
665
+ Filter out keys from an object.
666
+
667
+ Returns `never` if `Exclude` is strictly equal to `Key`.
668
+ Returns `never` if `Key` extends `Exclude`.
669
+ Returns `Key` otherwise.
670
+
671
+ @example
672
+ ```
673
+ type Filtered = Filter<'foo', 'foo'>;
674
+ //=> never
675
+ ```
676
+
677
+ @example
678
+ ```
679
+ type Filtered = Filter<'bar', string>;
680
+ //=> never
681
+ ```
682
+
683
+ @example
684
+ ```
685
+ type Filtered = Filter<'bar', 'foo'>;
686
+ //=> 'bar'
687
+ ```
688
+
689
+ @see {Except}
690
+ */
691
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
692
+ type ExceptOptions = {
693
+ /**
694
+ Disallow assigning non-specified properties.
695
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
696
+ @default false
697
+ */
698
+ requireExactProps?: boolean;
699
+ };
700
+ type DefaultExceptOptions = {
701
+ requireExactProps: false;
702
+ };
703
+ /**
704
+ Create a type from an object type without certain keys.
705
+
706
+ We recommend setting the `requireExactProps` option to `true`.
707
+
708
+ This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
709
+
710
+ This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
711
+
712
+ @example
713
+ ```
714
+ import type {Except} from 'type-fest';
715
+
716
+ type Foo = {
717
+ a: number;
718
+ b: string;
719
+ };
720
+
721
+ type FooWithoutA = Except<Foo, 'a'>;
722
+ //=> {b: string}
723
+
724
+ // @ts-expect-error
725
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
726
+ // errors: 'a' does not exist in type '{ b: string; }'
727
+
728
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
729
+ //=> {a: number} & Partial<Record<'b', never>>
730
+
731
+ // @ts-expect-error
732
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
733
+ // errors at 'b': Type 'string' is not assignable to type 'undefined'.
734
+
735
+ // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
736
+
737
+ // Consider the following example:
738
+
739
+ type UserData = {
740
+ [metadata: string]: string;
741
+ email: string;
742
+ name: string;
743
+ role: 'admin' | 'user';
744
+ };
745
+
746
+ // `Omit` clearly doesn't behave as expected in this case:
747
+ type PostPayload = Omit<UserData, 'email'>;
748
+ //=> {[x: string]: string; [x: number]: string}
749
+
750
+ // In situations like this, `Except` works better.
751
+ // It simply removes the `email` key while preserving all the other keys.
752
+ type PostPayloadFixed = Except<UserData, 'email'>;
753
+ //=> {[x: string]: string; name: string; role: 'admin' | 'user'}
754
+ ```
755
+
756
+ @category Object
757
+ */
758
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
759
+ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
760
+ //#endregion
761
+ //#region ../../node_modules/.pnpm/type-fest@5.4.4/node_modules/type-fest/source/partial-deep.d.ts
762
+ /**
763
+ @see {@link PartialDeep}
764
+ */
765
+ type PartialDeepOptions = {
766
+ /**
767
+ Whether to affect the individual elements of arrays and tuples.
768
+ @default false
769
+ */
770
+ readonly recurseIntoArrays?: boolean;
771
+ /**
772
+ Allows `undefined` values in non-tuple arrays.
773
+ - When set to `true`, elements of non-tuple arrays can be `undefined`.
774
+ - When set to `false`, only explicitly defined elements are allowed in non-tuple arrays, ensuring stricter type checking.
775
+ @default false
776
+ @example
777
+ You can allow `undefined` values in non-tuple arrays by passing `{recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}` as the second type argument:
778
+ ```
779
+ import type {PartialDeep} from 'type-fest';
780
+ type Settings = {
781
+ languages: string[];
782
+ };
783
+ declare const partialSettings: PartialDeep<Settings, {recurseIntoArrays: true; allowUndefinedInNonTupleArrays: true}>;
784
+ partialSettings.languages = [undefined]; // OK
785
+ ```
786
+ */
787
+ readonly allowUndefinedInNonTupleArrays?: boolean;
788
+ };
789
+ type DefaultPartialDeepOptions = {
790
+ recurseIntoArrays: false;
791
+ allowUndefinedInNonTupleArrays: false;
792
+ };
793
+ /**
794
+ Create a type from another type with all keys and nested keys set to optional.
795
+
796
+ Use-cases:
797
+ - Merging a default settings/config object with another object, the second object would be a deep partial of the default object.
798
+ - Mocking and testing complex entities, where populating an entire object with its keys would be redundant in terms of the mock or test.
799
+
800
+ @example
801
+ ```
802
+ import type {PartialDeep} from 'type-fest';
803
+
804
+ let settings = {
805
+ textEditor: {
806
+ fontSize: 14,
807
+ fontColor: '#000000',
808
+ fontWeight: 400,
809
+ },
810
+ autocomplete: false,
811
+ autosave: true,
812
+ };
813
+
814
+ const applySavedSettings = (savedSettings: PartialDeep<typeof settings>) => (
815
+ {...settings, ...savedSettings, textEditor: {...settings.textEditor, ...savedSettings.textEditor}}
816
+ );
817
+
818
+ settings = applySavedSettings({textEditor: {fontWeight: 500}});
819
+ ```
820
+
821
+ By default, this does not affect elements in array and tuple types. You can change this by passing `{recurseIntoArrays: true}` as the second type argument:
822
+
823
+ ```
824
+ import type {PartialDeep} from 'type-fest';
825
+
826
+ type Shape = {
827
+ dimensions: [number, number];
828
+ };
829
+
830
+ const partialShape: PartialDeep<Shape, {recurseIntoArrays: true}> = {
831
+ dimensions: [], // OK
832
+ };
833
+
834
+ partialShape.dimensions = [15]; // OK
835
+ ```
836
+
837
+ @see {@link PartialDeepOptions}
838
+
839
+ @category Object
840
+ @category Array
841
+ @category Set
842
+ @category Map
843
+ */
844
+ type PartialDeep<T, Options extends PartialDeepOptions = {}> = _PartialDeep<T, ApplyDefaultOptions<PartialDeepOptions, DefaultPartialDeepOptions, Options>>;
845
+ type _PartialDeep<T, Options extends Required<PartialDeepOptions>> = T extends BuiltIns | ((new (...arguments_: any[]) => unknown)) ? T : T extends Map<infer KeyType, infer ValueType> ? PartialMapDeep<KeyType, ValueType, Options> : T extends Set<infer ItemType> ? PartialSetDeep<ItemType, Options> : T extends ReadonlyMap<infer KeyType, infer ValueType> ? PartialReadonlyMapDeep<KeyType, ValueType, Options> : T extends ReadonlySet<infer ItemType> ? PartialReadonlySetDeep<ItemType, Options> : T extends ((...arguments_: any[]) => unknown) ? IsNever<keyof T> extends true ? T // For functions with no properties
846
+ : HasMultipleCallSignatures<T> extends true ? T : ((...arguments_: Parameters<T>) => ReturnType<T>) & PartialObjectDeep<T, Options> : T extends object ? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
847
+ ? Options['recurseIntoArrays'] extends true ? ItemType[] extends T // Test for arrays (non-tuples) specifically
848
+ ? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
849
+ ? ReadonlyArray<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>> : Array<_PartialDeep<Options['allowUndefinedInNonTupleArrays'] extends false ? ItemType : ItemType | undefined, Options>> : PartialObjectDeep<T, Options> // Tuples behave properly
850
+ : T // If they don't opt into array testing, just use the original type
851
+ : PartialObjectDeep<T, Options> : unknown;
852
+ /**
853
+ Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.
854
+ */
855
+ type PartialMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & Map<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
856
+ /**
857
+ Same as `PartialDeep`, but accepts only `Set`s as inputs. Internal helper for `PartialDeep`.
858
+ */
859
+ type PartialSetDeep<T, Options extends Required<PartialDeepOptions>> = {} & Set<_PartialDeep<T, Options>>;
860
+ /**
861
+ Same as `PartialDeep`, but accepts only `ReadonlyMap`s as inputs. Internal helper for `PartialDeep`.
862
+ */
863
+ type PartialReadonlyMapDeep<KeyType, ValueType, Options extends Required<PartialDeepOptions>> = {} & ReadonlyMap<_PartialDeep<KeyType, Options>, _PartialDeep<ValueType, Options>>;
864
+ /**
865
+ Same as `PartialDeep`, but accepts only `ReadonlySet`s as inputs. Internal helper for `PartialDeep`.
866
+ */
867
+ type PartialReadonlySetDeep<T, Options extends Required<PartialDeepOptions>> = {} & ReadonlySet<_PartialDeep<T, Options>>;
868
+ /**
869
+ Same as `PartialDeep`, but accepts only `object`s as inputs. Internal helper for `PartialDeep`.
870
+ */
871
+ type PartialObjectDeep<ObjectType extends object, Options extends Required<PartialDeepOptions>> = { [KeyType in keyof ObjectType]?: _PartialDeep<ObjectType[KeyType], Options> };
872
+ //#endregion
5
873
  //#region src/types/internal.d.ts
6
874
  type CookieOptions = SerializeOptions;
7
875
  interface IMonoCloudCookieRequest {
@@ -389,10 +1257,12 @@ type OnBackChannelLogout = (
389
1257
  /**
390
1258
  * Optional. The subject identifier (sub) of the user.
391
1259
  */
1260
+
392
1261
  sub?: string,
393
1262
  /**
394
1263
  * Optional. The session identifier (sid) associated with the user's session.
395
1264
  */
1265
+
396
1266
  sid?: string) => Promise<void> | void;
397
1267
  /**
398
1268
  * The custom application state.
@@ -414,18 +1284,22 @@ type OnSessionCreating = (
414
1284
  /**
415
1285
  * The Session object being created.
416
1286
  */
1287
+
417
1288
  session: MonoCloudSession$1,
418
1289
  /**
419
1290
  * Optional. Claims from the ID token received during authentication.
420
1291
  */
1292
+
421
1293
  idToken?: Partial<IdTokenClaims$1>,
422
1294
  /**
423
1295
  * Optional. Claims from the user information received during authentication.
424
1296
  */
1297
+
425
1298
  userInfo?: UserinfoResponse$1,
426
1299
  /**
427
1300
  * Optional. The application state associated with the session.
428
1301
  */
1302
+
429
1303
  state?: ApplicationState) => Promise<void> | void;
430
1304
  /**
431
1305
  * Defines a callback function to be executed when an authentication state is being set.
@@ -438,6 +1312,7 @@ type OnSetApplicationState = (
438
1312
  /**
439
1313
  * The incoming request.
440
1314
  */
1315
+
441
1316
  req: MonoCloudRequest) => Promise<ApplicationState> | ApplicationState;
442
1317
  /**
443
1318
  * Represents the tokens obtained during authentication that are available in the session.