@monocloud/auth-node-core 0.1.5 → 0.1.6

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 DELETED
@@ -1,1565 +0,0 @@
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";
2
- import { SerializeOptions } from "cookie";
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
873
- //#region src/types/internal.d.ts
874
- type CookieOptions = SerializeOptions;
875
- interface IMonoCloudCookieRequest {
876
- getCookie(name: string): Promise<string | undefined>;
877
- getAllCookies(): Promise<Map<string, string>>;
878
- }
879
- interface MonoCloudRequest extends IMonoCloudCookieRequest {
880
- getQuery(parameter: string): string | string[] | undefined;
881
- getRawRequest(): Promise<{
882
- method: string;
883
- url: string;
884
- body: Record<string, string> | string;
885
- }>;
886
- }
887
- interface IMonoCloudCookieResponse {
888
- setCookie(cookieName: string, value: string, options: CookieOptions): Promise<void>;
889
- }
890
- interface MonoCloudResponse extends IMonoCloudCookieResponse {
891
- redirect(url: string, statusCode?: number): void;
892
- sendJson(data: any, statusCode?: number): void;
893
- notFound(): void;
894
- noContent(): void;
895
- internalServerError(): void;
896
- methodNotAllowed(): void;
897
- setNoCache(): void;
898
- done(): any;
899
- }
900
- //#endregion
901
- //#region src/types/index.d.ts
902
- /**
903
- * Possible values for the SameSite attribute in cookies.
904
- */
905
- type SameSiteValues = 'strict' | 'lax' | 'none';
906
- /**
907
- * Possible values for the Security Algorithms.
908
- */
909
- type SecurityAlgorithms = 'RS256' | 'RS384' | 'RS512' | 'PS256' | 'PS384' | 'PS512' | 'ES256' | 'ES384' | 'ES512';
910
- /**
911
- * Represents the lifetime information of a session, including the creation time (c),
912
- * the last updated time (u), and optionally the expiration time (e).
913
- */
914
- interface SessionLifetime {
915
- /**
916
- * The time at which the session was created (in epoch).
917
- */
918
- c: number;
919
- /**
920
- * The time at which the session was last updated (in epoch).
921
- */
922
- u: number;
923
- /**
924
- * Optional. The expiration time of the session (in epoch).
925
- */
926
- e?: number;
927
- }
928
- /**
929
- * Represents a session store interface for managing session data.
930
- */
931
- interface MonoCloudSessionStore {
932
- /**
933
- * Retrieves a session from the store based on the provided key.
934
- * @param key - The key used to identify the session.
935
- * @returns A Promise that resolves with the session data, or undefined / null if not found.
936
- */
937
- get(key: string): Promise<MonoCloudSession$1 | undefined | null>;
938
- /**
939
- * Stores a session in the store with the specified key.
940
- * @param key - The key used to identify the session.
941
- * @param data - The session data to be stored.
942
- * @param lifetime - The lifetime information of the session.
943
- * @returns A Promise that resolves when the session is successfully stored.
944
- */
945
- set(key: string, data: MonoCloudSession$1, lifetime: SessionLifetime): Promise<void>;
946
- /**
947
- * Deletes a session from the store based on the provided key.
948
- * @param key - The key used to identify the session to be deleted.
949
- * @returns A Promise that resolves when the session is successfully deleted.
950
- */
951
- delete(key: string): Promise<void>;
952
- }
953
- /**
954
- * Options for cookies.
955
- */
956
- interface MonoCloudCookieOptions {
957
- /**
958
- * The name of the cookie.
959
- * For session cookies, the default value is 'session'.
960
- * For state cookies, the default value is 'state'.
961
- */
962
- name: string;
963
- /**
964
- * The path for which the cookie is valid.
965
- * @defaultValue '/'
966
- */
967
- path: string;
968
- /**
969
- * Optional: The domain for which the cookie is valid.
970
- */
971
- domain?: string;
972
- /**
973
- * Determines whether the cookie is accessible only through HTTP requests.
974
- * This setting will be ignored for the state cookie and will always be true.
975
- * @defaultValue true
976
- */
977
- httpOnly: boolean;
978
- /**
979
- * Determines whether the cookie should only be sent over HTTPS connections.
980
- * If not provided, this settings will be auto-detected basis the scheme of the application url.
981
- */
982
- secure: boolean;
983
- /**
984
- * The SameSite attribute value for the cookie, ensuring cross-site request forgery protection.
985
- * @defaultValue 'lax'
986
- */
987
- sameSite: SameSiteValues;
988
- /**
989
- * Determines whether the cookie should persist beyond the current session.
990
- * For session cookies, the default value is true.
991
- * For state cookies, the default value is false.
992
- */
993
- persistent: boolean;
994
- }
995
- /**
996
- * Options for the authentication sessions.
997
- */
998
- interface MonoCloudSessionOptionsBase {
999
- /**
1000
- * Configuration options for the authentication session cookie.
1001
- */
1002
- cookie: MonoCloudCookieOptions;
1003
- /**
1004
- * Determines whether the session should use sliding expiration.
1005
- * @defaultValue false
1006
- */
1007
- sliding: boolean;
1008
- /**
1009
- * The duration of the session in seconds.
1010
- * @defaultValue 86400 (1 Day)
1011
- */
1012
- duration: number;
1013
- /**
1014
- * The maximum duration for the session in seconds.
1015
- * Will only be used when the session is set to 'sliding'.
1016
- * @defaultValue 604800 (1 Week)
1017
- */
1018
- maximumDuration: number;
1019
- /**
1020
- * Optional: The session store to use for storing session data.
1021
- */
1022
- store?: MonoCloudSessionStore;
1023
- }
1024
- /**
1025
- * Options for the authentication state.
1026
- */
1027
- interface MonoCloudStateOptions {
1028
- /**
1029
- * Configuration options for the authentication state cookie.
1030
- */
1031
- cookie: MonoCloudCookieOptions;
1032
- }
1033
- /**
1034
- * Options for the MonoCloud Authentication route handlers.
1035
- */
1036
- interface MonoCloudRoutes {
1037
- /**
1038
- * The URL of the callback handler
1039
- * @defaultValue '/api/auth/callback'
1040
- */
1041
- callback: string;
1042
- /**
1043
- * The URL of the back-channel logout handler
1044
- * @defaultValue '/api/auth/backchannel-logout'
1045
- */
1046
- backChannelLogout: string;
1047
- /**
1048
- * The URL of the sign-in handler
1049
- * @defaultValue '/api/auth/signin'
1050
- */
1051
- signIn: string;
1052
- /**
1053
- * The URL of the sign-out handler
1054
- * @defaultValue '/api/auth/signout'
1055
- */
1056
- signOut: string;
1057
- /**
1058
- * The URL of the userinfo handler
1059
- * @defaultValue '/api/auth/userinfo'
1060
- */
1061
- userInfo: string;
1062
- }
1063
- /**
1064
- * Represents an indicator for additional resources that can be requested.
1065
- */
1066
- interface Indicator {
1067
- /**
1068
- * Space separated list of resources to scope the access token to
1069
- */
1070
- resource: string;
1071
- /**
1072
- * Optional: Space separated list of scopes to request
1073
- */
1074
- scopes?: string;
1075
- }
1076
- /**
1077
- * Options for configuration MonoCloud Authentication.
1078
- */
1079
- interface MonoCloudOptionsBase {
1080
- /**
1081
- * The client ID of the authenticating application.
1082
- */
1083
- clientId: string;
1084
- /**
1085
- * Optional: The client secret of the authenticating application.
1086
- */
1087
- clientSecret?: string;
1088
- /**
1089
- * MonoCloud tenant domain.
1090
- */
1091
- tenantDomain: string;
1092
- /**
1093
- * A secret key that will be used for encrypting cookies.
1094
- */
1095
- cookieSecret: string;
1096
- /**
1097
- * The URL of the application.
1098
- */
1099
- appUrl: string;
1100
- /**
1101
- * Configuration options for the route handler URLs.
1102
- */
1103
- routes: MonoCloudRoutes;
1104
- /**
1105
- * The maximum allowed clock skew (in seconds) for token validation.
1106
- * @defaultValue 60 (seconds)
1107
- */
1108
- clockSkew: number;
1109
- /**
1110
- * The timeout (in milliseconds) for receiving responses from the authentication service.
1111
- * @defaultValue 10000 (10 seconds)
1112
- */
1113
- responseTimeout: number;
1114
- /**
1115
- * Determines whether to use PAR (Pushed Authorization Requests) for authorization requests.
1116
- * @defaultValue false
1117
- */
1118
- usePar: boolean;
1119
- /**
1120
- * Optional: The URI to redirect to after the user logs out.
1121
- */
1122
- postLogoutRedirectUri?: string;
1123
- /**
1124
- * Determines whether the user will be logged out of the authentication service.
1125
- * @defaultValue true
1126
- */
1127
- federatedSignOut: boolean;
1128
- /**
1129
- * Determines whether to fetch the user information from the 'userinfo' endpoint during authentication.
1130
- * @defaultValue true
1131
- */
1132
- userInfo: boolean;
1133
- /**
1134
- * Determines whether to refetch the user information from the authentication service on each request to the
1135
- * application's userinfo endpoint.
1136
- * @defaultValue false
1137
- */
1138
- refetchUserInfo: boolean;
1139
- /**
1140
- * Default authorization parameters to include in authentication requests.
1141
- * @defaultValue {
1142
- * scope: 'openid email profile',
1143
- * response_type: 'code'
1144
- * }
1145
- */
1146
- defaultAuthParams: AuthorizationParams$1;
1147
- /**
1148
- * Optional: Additional resources that can be requested in `getTokens()`.
1149
- *
1150
- */
1151
- resources?: Indicator[];
1152
- /**
1153
- * Configuration options for the user session.
1154
- */
1155
- session: MonoCloudSessionOptionsBase;
1156
- /**
1157
- * Configuration options for state management during authentication.
1158
- */
1159
- state: MonoCloudStateOptions;
1160
- /**
1161
- * The signing algorithm that is expected to be used for signing ID tokens.
1162
- * @defaultValue 'RS256'
1163
- */
1164
- idTokenSigningAlg: SecurityAlgorithms;
1165
- /**
1166
- * Array of strings representing the filtered ID token claims.
1167
- */
1168
- filteredIdTokenClaims: string[];
1169
- /**
1170
- * The name of the debugger instance.
1171
- */
1172
- debugger: string;
1173
- /**
1174
- * The name of the user agent.
1175
- */
1176
- userAgent: string;
1177
- /**
1178
- * Jwks Cache Duration
1179
- *
1180
- * Time in seconds to cache the JWKS document after it is fetched
1181
- *
1182
- * @default 60 (seconds)
1183
- *
1184
- * */
1185
- jwksCacheDuration?: number;
1186
- /**
1187
- * Metadata Cache Duration
1188
- *
1189
- * Time in seconds to cache the metadata document after it is fetched.
1190
- *
1191
- * @default 60 (seconds)
1192
- * */
1193
- metadataCacheDuration?: number;
1194
- /**
1195
- * Determines whether authorization parameters should be dynamically extracted
1196
- * from query.
1197
- *
1198
- * When set to `true`, parameters such as `scope`, `resource`, `prompt` etc
1199
- * from the query parameters will be merged into the authentication request.
1200
- *
1201
- * @example
1202
- *
1203
- * // The SDK will automatically use prompt='login' and the login_hint.
1204
- * https://example.com/api/auth/signin?prompt=login&login_hint=user@example.com
1205
- *
1206
- * @default false
1207
- */
1208
- allowQueryParamOverrides?: boolean;
1209
- /**
1210
- * Optional: A callback function invoked when a back-channel logout event is received.
1211
- */
1212
- onBackChannelLogout?: OnBackChannelLogout;
1213
- /**
1214
- * Optional: A callback function invoked when an authentication state is being set (before sign-in).
1215
- */
1216
- onSetApplicationState?: OnSetApplicationState;
1217
- /**
1218
- * Optional: A callback function invoked before creating or updating the user session.
1219
- */
1220
- onSessionCreating?: OnSessionCreating;
1221
- }
1222
- /**
1223
- * Options for the authentication sessions.
1224
- */
1225
- type MonoCloudSessionOptions = Except<PartialDeep<MonoCloudSessionOptionsBase>, 'store'> & {
1226
- /**
1227
- * Optional: The session store to use for storing session data.
1228
- */
1229
- store?: MonoCloudSessionStore;
1230
- };
1231
- /**
1232
- * Options for configuration MonoCloud Authentication.
1233
- */
1234
- type MonoCloudOptions = Except<PartialDeep<MonoCloudOptionsBase>, 'defaultAuthParams' | 'session'> & {
1235
- /**
1236
- * Default authorization parameters to include in authentication requests.
1237
- * @defaultValue {
1238
- * scope: 'openid email profile',
1239
- * response_type: 'code'
1240
- * }
1241
- */
1242
- defaultAuthParams?: Partial<AuthorizationParams$1>;
1243
- /**
1244
- * Configuration options for the user session.
1245
- */
1246
- session?: MonoCloudSessionOptions;
1247
- };
1248
- /**
1249
- * Defines a callback function to be invoked when a back-channel logout event is received.
1250
- * This function receives an optional subject identifier (sub) of the user and an optional session identifier (sid).
1251
- *
1252
- * @param sub - Optional. The subject identifier (sub) of the user.
1253
- * @param sid - Optional. The session identifier (sid) associated with the user's session.
1254
- * @returns A Promise that resolves when the operation is completed, or void.
1255
- */
1256
- type OnBackChannelLogout = (
1257
- /**
1258
- * Optional. The subject identifier (sub) of the user.
1259
- */
1260
-
1261
- sub?: string,
1262
- /**
1263
- * Optional. The session identifier (sid) associated with the user's session.
1264
- */
1265
-
1266
- sid?: string) => Promise<void> | void;
1267
- /**
1268
- * The custom application state.
1269
- */
1270
- type ApplicationState = Record<string, any>;
1271
- /**
1272
- * Defines a callback function to be executed when a new session is being created or updated.
1273
- * This function receives parameters related to the session being created,
1274
- * including the session object itself, optional ID token and user information claims,
1275
- * and the application state.
1276
- *
1277
- * @param session - The Session object being created.
1278
- * @param idToken - Optional. Claims from the ID token received during authentication.
1279
- * @param userInfo - Optional. Claims from the user information received during authentication.
1280
- * @param state - Optional. The application state associated with the session.
1281
- * @returns A Promise that resolves when the operation is completed, or void.
1282
- */
1283
- type OnSessionCreating = (
1284
- /**
1285
- * The Session object being created.
1286
- */
1287
-
1288
- session: MonoCloudSession$1,
1289
- /**
1290
- * Optional. Claims from the ID token received during authentication.
1291
- */
1292
-
1293
- idToken?: Partial<IdTokenClaims$1>,
1294
- /**
1295
- * Optional. Claims from the user information received during authentication.
1296
- */
1297
-
1298
- userInfo?: UserinfoResponse$1,
1299
- /**
1300
- * Optional. The application state associated with the session.
1301
- */
1302
-
1303
- state?: ApplicationState) => Promise<void> | void;
1304
- /**
1305
- * Defines a callback function to be executed when an authentication state is being set.
1306
- * This function receives the incoming request and should return or resolve with an ApplicationState object.
1307
- *
1308
- * @param req - The incoming request.
1309
- * @returns A Promise that resolves with the ApplicationState object when the operation is completed, or the ApplicationState object directly.
1310
- */
1311
- type OnSetApplicationState = (
1312
- /**
1313
- * The incoming request.
1314
- */
1315
-
1316
- req: MonoCloudRequest) => Promise<ApplicationState> | ApplicationState;
1317
- /**
1318
- * Represents the tokens obtained during authentication that are available in the session.
1319
- */
1320
- interface MonoCloudTokens extends AccessToken$1 {
1321
- /**
1322
- * The ID token obtained during authentication.
1323
- */
1324
- idToken?: string;
1325
- /**
1326
- * The refresh token obtained during authentication.
1327
- */
1328
- refreshToken?: string;
1329
- /**
1330
- * Specifies if the access token has expired.
1331
- */
1332
- isExpired: boolean;
1333
- }
1334
- /**
1335
- * A function used to handle errors that occur during the signin, callback, signout and userinfo endpoint execution.
1336
- *
1337
- * @param error - Error occured during execution of the endpoint.
1338
- */
1339
- type OnError = (error: Error) => Promise<any> | any;
1340
- /**
1341
- * Represents options for the sign-in handler.
1342
- */
1343
- interface SignInOptions {
1344
- /**
1345
- * The application URL to which the user should be redirected after successful authentication.
1346
- * Must be a relative Url.
1347
- * Defaults to the appUrl.
1348
- */
1349
- returnUrl?: string;
1350
- /**
1351
- * Specifies whether to initiate a user registration process.
1352
- */
1353
- register?: boolean;
1354
- /**
1355
- * Additional authorization parameters to include in the authentication request.
1356
- */
1357
- authParams?: AuthorizationParams$1;
1358
- /**
1359
- * A custom function to handle unexpected errors while signing in.
1360
- */
1361
- onError?: OnError;
1362
- }
1363
- /**
1364
- * Represents options for the callback handler.
1365
- */
1366
- interface CallbackOptions {
1367
- /**
1368
- * Determines whether to fetch the user information from the 'userinfo' endpoint after processing the callback.
1369
- */
1370
- userInfo?: boolean;
1371
- /**
1372
- * Url to be sent to the token endpoint.
1373
- */
1374
- redirectUri?: string;
1375
- /**
1376
- * A custom function to handle unexpected errors while processing callback from MonoCloud.
1377
- */
1378
- onError?: OnError;
1379
- }
1380
- /**
1381
- * Represents options for the userinfo handler.
1382
- */
1383
- interface UserInfoOptions {
1384
- /**
1385
- * Determines whether to refetch the user information from the authentication service.
1386
- */
1387
- refresh?: boolean;
1388
- /**
1389
- * A custom function to handle unexpected errors while fetching userinfo.
1390
- */
1391
- onError?: OnError;
1392
- }
1393
- /**
1394
- * Represents options for the sign-out handler.
1395
- */
1396
- type SignOutOptions = {
1397
- /**
1398
- * Determines whether the user will be logged out of the authentication service.
1399
- */
1400
- federatedSignOut?: boolean;
1401
- /**
1402
- * A custom function to handle unexpected errors while signing out.
1403
- */
1404
- onError?: OnError;
1405
- } & EndSessionParameters$1;
1406
- /**
1407
- * Represents options for the GetTokens handler.
1408
- */
1409
- interface GetTokensOptions extends RefreshGrantOptions$1 {
1410
- /**
1411
- * Specifies whether to force the refresh of the access token.
1412
- */
1413
- forceRefresh?: boolean;
1414
- /**
1415
- * Determines whether to refetch the user information.
1416
- */
1417
- refetchUserInfo?: boolean;
1418
- }
1419
- //#endregion
1420
- //#region src/monocloud-node-core-client.d.ts
1421
- declare class MonoCloudCoreClient {
1422
- readonly oidcClient: MonoCloudOidcClient$1;
1423
- private readonly options;
1424
- private readonly stateService;
1425
- private readonly sessionService;
1426
- private readonly debug;
1427
- private optionsValidated;
1428
- constructor(partialOptions?: MonoCloudOptions);
1429
- /**
1430
- * Initiates the sign-in flow by redirecting the user to the MonoCloud authorization endpoint.
1431
- *
1432
- * This method handles scope and resource merging, state generation (nonce, state, PKCE),
1433
- * and Constructing the final authorization URL.
1434
- *
1435
- * @param request - MonoCloud request object.
1436
- * @param response - MonoCloud response object.
1437
- * @param signInOptions - Configuration to customize the sign-in behavior.
1438
- * @returns A promise that resolves when the callback processing and redirection are complete.
1439
- *
1440
- * @throws {@link MonoCloudValidationError} When validation of parameters or state fails.
1441
- */
1442
- signIn(request: MonoCloudRequest, response: MonoCloudResponse, signInOptions?: SignInOptions): Promise<any>;
1443
- /**
1444
- * Handles the OpenID callback after the user authenticates with MonoCloud.
1445
- *
1446
- * Processes the authorization code, validates the state and nonce, exchanges the code for tokens,
1447
- * initializes the user session, and performs the final redirect to the application's return URL.
1448
- *
1449
- * @param request - MonoCloud request object.
1450
- * @param response - MonoCloud response object.
1451
- * @param callbackOptions - Optional configuration for the callback handler.
1452
- * @returns A promise that resolves when the callback processing and redirection are complete.
1453
- *
1454
- * @throws {@link MonoCloudValidationError} If the state is mismatched or tokens are invalid.
1455
- */
1456
- callback(request: MonoCloudRequest, response: MonoCloudResponse, callbackOptions?: CallbackOptions): Promise<any>;
1457
- /**
1458
- * Retrieves user information, optionally refetching fresh data from the UserInfo endpoint.
1459
- *
1460
- * @param request - MonoCloud request object.
1461
- * @param response - MonoCloud response object.
1462
- * @param userinfoOptions - Configuration to control refetching and error handling.
1463
- * @returns A promise that resolves with the user information sent as a JSON response.
1464
- *
1465
- * @remarks
1466
- * If `refresh` is true, the session is updated with fresh claims from the identity provider.
1467
- */
1468
- userInfo(request: MonoCloudRequest, response: MonoCloudResponse, userinfoOptions?: UserInfoOptions): Promise<any>;
1469
- /**
1470
- * Initiates the sign-out flow, destroying the local session and optionally performing federated sign-out.
1471
- *
1472
- * @param request - MonoCloud request object.
1473
- * @param response - MonoCloud response object.
1474
- * @param signOutOptions - Configuration for post-logout behavior and federated sign-out.
1475
- *
1476
- * @returns A promise that resolves when the sign-out redirection is initiated.
1477
- */
1478
- signOut(request: MonoCloudRequest, response: MonoCloudResponse, signOutOptions?: SignOutOptions): Promise<any>;
1479
- /**
1480
- * Handles Back-Channel Logout notifications from the identity provider.
1481
- *
1482
- * Validates the Logout Token and triggers the `onBackChannelLogout` callback defined in options.
1483
- *
1484
- * @param request - MonoCloud request object.
1485
- * @param response - MonoCloud response object.
1486
- *
1487
- * @returns A promise that resolves when the logout notification has been processed.
1488
- *
1489
- * @throws {@link MonoCloudValidationError} If the logout token is missing or invalid.
1490
- */
1491
- backChannelLogout(request: MonoCloudRequest, response: MonoCloudResponse): Promise<any>;
1492
- /**
1493
- * Checks if the current request has an active and authenticated session.
1494
- *
1495
- * @param request - MonoCloud cookie request object.
1496
- * @param response - MonoCloud cookie response object.
1497
- *
1498
- * @returns `true` if a valid session with user data exists, `false` otherwise.
1499
- *
1500
- */
1501
- isAuthenticated(request: IMonoCloudCookieRequest, response: IMonoCloudCookieResponse): Promise<boolean>;
1502
- /**
1503
- * Checks if the current session user belongs to the specified groups.
1504
- *
1505
- * @param request - MonoCloud cookie request object.
1506
- * @param response - MonoCloud cookie response object.
1507
- * @param groups - List of group names or IDs to check.
1508
- * @param groupsClaim - Optional claim name that holds groups. Defaults to "groups".
1509
- * @param matchAll - If `true`, requires membership in all groups; otherwise any one group is sufficient.
1510
- *
1511
- * @returns `true` if the user satisfies the group condition, `false` otherwise.
1512
- */
1513
- isUserInGroup(request: IMonoCloudCookieRequest, response: IMonoCloudCookieResponse, groups: string[], groupsClaim?: string, matchAll?: boolean): Promise<boolean>;
1514
- /**
1515
- * Retrieves the current user's session data.
1516
- *
1517
- * @param request - MonoCloud cookie request object.
1518
- * @param response - MonoCloud cookie response object.
1519
- *
1520
- * @returns Session or `undefined`.
1521
- */
1522
- getSession(request: IMonoCloudCookieRequest, response: IMonoCloudCookieResponse): Promise<MonoCloudSession$1 | undefined>;
1523
- /**
1524
- * Updates the current user's session with new data.
1525
- *
1526
- * @param request - MonoCloud cookie request object.
1527
- * @param response - MonoCloud cookie response object.
1528
- * @param session - The updated session object to persist.
1529
- */
1530
- updateSession(request: IMonoCloudCookieRequest, response: IMonoCloudCookieResponse, session: MonoCloudSession$1): Promise<void>;
1531
- /**
1532
- * Returns a copy of the current client configuration options.
1533
- *
1534
- * @returns A copy of the initialized configuration.
1535
- */
1536
- getOptions(): MonoCloudOptionsBase;
1537
- /**
1538
- * Destroys the local user session.
1539
- *
1540
- * @param request - MonoCloud cookie request object.
1541
- * @param response - MonoCloud cookie response object.
1542
- *
1543
- * @remarks
1544
- * This does not perform federated sign-out. For identity provider sign-out, use `signOut` handler.
1545
- */
1546
- destroySession(request: IMonoCloudCookieRequest, response: IMonoCloudCookieResponse): Promise<void>;
1547
- /**
1548
- * Retrieves active tokens (Access, ID, Refresh), performing a refresh if they are expired or missing.
1549
- *
1550
- * @param request - MonoCloud cookie request object.
1551
- * @param response - MonoCloud cookie response object.
1552
- * @param options - Configuration for token retrieval (force refresh, specific scopes/resources).
1553
- *
1554
- * @returns Fetched tokens
1555
- *
1556
- * @throws {@link MonoCloudValidationError} If the session does not exist or tokens cannot be found/refreshed.
1557
- */
1558
- getTokens(request: IMonoCloudCookieRequest, response: IMonoCloudCookieResponse, options?: GetTokensOptions): Promise<MonoCloudTokens>;
1559
- private verifyLogoutToken;
1560
- private handleCatchAll;
1561
- private validateOptions;
1562
- }
1563
- //#endregion
1564
- export { type AccessToken, type ApplicationState, type AuthState, type AuthenticateOptions, type Authenticators, type AuthorizationParams, type CallbackOptions, type CallbackParams, type ClientAuthMethod, type CodeChallengeMethod, type CookieOptions, type DisplayOptions, type EndSessionParameters, type GetTokensOptions, type Group, type IMonoCloudCookieRequest, type IMonoCloudCookieResponse, type IdTokenClaims, type Indicator, type IssuerMetadata, type JWSAlgorithm, type Jwk, type Jwks, type JwsHeaderParameters, MonoCloudAuthBaseError, type MonoCloudClientOptions, type MonoCloudCookieOptions, MonoCloudCoreClient, MonoCloudHttpError, MonoCloudOPError, MonoCloudOidcClient, type MonoCloudOptions, type MonoCloudOptionsBase, type MonoCloudRequest, type MonoCloudResponse, type MonoCloudRoutes, type MonoCloudSession, type MonoCloudSessionOptions, type MonoCloudSessionOptionsBase, type MonoCloudSessionStore, type MonoCloudStateOptions, MonoCloudTokenError, type MonoCloudTokens, type MonoCloudUser, MonoCloudValidationError, type OnBackChannelLogout, type OnError, type OnSessionCreating, type OnSetApplicationState, type ParResponse, type Prompt, type PushedAuthorizationParams, type RefetchUserInfoOptions, type RefreshGrantOptions, type RefreshSessionOptions, type ResponseModes, type ResponseTypes, type SameSiteValues, type SecurityAlgorithms, type SessionLifetime, type SignInOptions, type SignOutOptions, type Tokens, type UserInfoOptions, type UserinfoResponse };
1565
- //# sourceMappingURL=index.d.cts.map