@leancodepl/kratos 10.0.2 → 10.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +134 -42
- package/dist/index.js +1260 -1249
- package/dist/index.umd.cjs +1 -1
- package/dist/lib/factories/mkKratos.d.ts +14 -9
- package/dist/lib/factories/mkKratos.d.ts.map +1 -1
- package/dist/lib/flows/login/chooseMethodForm/ChooseMethodFormWrapper.d.ts +13 -22
- package/dist/lib/flows/login/chooseMethodForm/ChooseMethodFormWrapper.d.ts.map +1 -1
- package/dist/lib/flows/login/loginFlow.d.ts +5 -3
- package/dist/lib/flows/login/loginFlow.d.ts.map +1 -1
- package/dist/lib/flows/registration/registrationFlow.d.ts +5 -4
- package/dist/lib/flows/registration/registrationFlow.d.ts.map +1 -1
- package/dist/lib/flows/registration/traitsForm/TraitsFormWrapper.d.ts +7 -14
- package/dist/lib/flows/registration/traitsForm/TraitsFormWrapper.d.ts.map +1 -1
- package/dist/lib/flows/settings/oidcForm/OidcFormWrapper.d.ts +7 -11
- package/dist/lib/flows/settings/oidcForm/OidcFormWrapper.d.ts.map +1 -1
- package/dist/lib/flows/settings/oidcForm/providers.d.ts +1 -2
- package/dist/lib/flows/settings/oidcForm/providers.d.ts.map +1 -1
- package/dist/lib/flows/settings/settingsFlow.d.ts +7 -5
- package/dist/lib/flows/settings/settingsFlow.d.ts.map +1 -1
- package/dist/lib/utils/flow.d.ts +12 -8
- package/dist/lib/utils/flow.d.ts.map +1 -1
- package/dist/lib/utils/index.d.ts +1 -0
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/oidcProviders.d.ts +18 -0
- package/dist/lib/utils/oidcProviders.d.ts.map +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,52 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See
|
|
4
4
|
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [10.1.1](https://github.com/leancodepl/js_corelibrary/compare/v10.1.0...v10.1.1) (2026-02-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @leancodepl/kratos
|
|
9
|
+
|
|
10
|
+
# Change Log
|
|
11
|
+
|
|
12
|
+
All notable changes to this project will be documented in this file. See
|
|
13
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
14
|
+
|
|
15
|
+
# [10.1.0](https://github.com/leancodepl/js_corelibrary/compare/v10.0.2...v10.1.0) (2026-02-16)
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- Add OIDC providers config to example app and fix type issues
|
|
20
|
+
([6c7f13b](https://github.com/leancodepl/js_corelibrary/commit/6c7f13b63498314ccdd742b2656767d3f4dd62b3))
|
|
21
|
+
- Address code review feedback
|
|
22
|
+
([7830178](https://github.com/leancodepl/js_corelibrary/commit/7830178cba6147cd533bc6cbd7cd25e3c2d26fb1))
|
|
23
|
+
- Properly type OidcProviderUiNode attributes to avoid 'any'
|
|
24
|
+
([27acdce](https://github.com/leancodepl/js_corelibrary/commit/27acdce9a874dfbe8e30566fc19f9b51aa6314d9))
|
|
25
|
+
- Remove unused imports and variables from OIDC provider implementation
|
|
26
|
+
([2590a39](https://github.com/leancodepl/js_corelibrary/commit/2590a392e63181d0a6ea1ce4dc10ddf9b392c0d7))
|
|
27
|
+
- Resolve build failures in kratos package
|
|
28
|
+
([c356f93](https://github.com/leancodepl/js_corelibrary/commit/c356f9366fbf623d32829e58d53afd58e374ca7d))
|
|
29
|
+
- Resolve linter errors and warnings
|
|
30
|
+
([a900e5c](https://github.com/leancodepl/js_corelibrary/commit/a900e5c80664d4914114b0d2ca9f45fdb2c86854))
|
|
31
|
+
- Update documentation to show correct provider capitalization
|
|
32
|
+
([980b62b](https://github.com/leancodepl/js_corelibrary/commit/980b62b707ac63f61c864d37ddd580b7225f94d6))
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
- Add support for custom OIDC providers
|
|
37
|
+
([a1ae459](https://github.com/leancodepl/js_corelibrary/commit/a1ae459ebb1a2d14bd9def97af7ec4dfec2e15da))
|
|
38
|
+
- Add type-safe OIDC provider support
|
|
39
|
+
([b52ab23](https://github.com/leancodepl/js_corelibrary/commit/b52ab233096eeb91fae6850e7c30e5b0cb0a5b15))
|
|
40
|
+
- Make OidcFormProps generic with OidcProvidersConfig type
|
|
41
|
+
([7957ff8](https://github.com/leancodepl/js_corelibrary/commit/7957ff84fb634b859a8a5f6bc114d2dc2ba3ec1d))
|
|
42
|
+
- remove label from oidc provider type amd spread oidc components
|
|
43
|
+
([aa25a5f](https://github.com/leancodepl/js_corelibrary/commit/aa25a5f7ff0bb6b1cd2e36d23b3c61dd3621d77e))
|
|
44
|
+
- unify oidcProviderComponents implementations
|
|
45
|
+
([74f7ad3](https://github.com/leancodepl/js_corelibrary/commit/74f7ad38211ff88826ffb21b9c73580854e27f3a))
|
|
46
|
+
|
|
47
|
+
# Change Log
|
|
48
|
+
|
|
49
|
+
All notable changes to this project will be documented in this file. See
|
|
50
|
+
[Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
51
|
+
|
|
6
52
|
## [10.0.2](https://github.com/leancodepl/js_corelibrary/compare/v10.0.1...v10.0.2) (2026-02-13)
|
|
7
53
|
|
|
8
54
|
**Note:** Version bump only for package @leancodepl/kratos
|
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ yarn add @leancodepl/kratos
|
|
|
12
12
|
|
|
13
13
|
## API
|
|
14
14
|
|
|
15
|
-
### `mkKratos(queryClient, basePath, traits, SessionManager)`
|
|
15
|
+
### `mkKratos(queryClient, basePath, traits, SessionManager, oidcProviders)`
|
|
16
16
|
|
|
17
17
|
Creates a Kratos client factory with authentication flows, session management, and React providers.
|
|
18
18
|
|
|
@@ -23,6 +23,8 @@ Creates a Kratos client factory with authentication flows, session management, a
|
|
|
23
23
|
- `traits?: TTraitsConfig` - Optional traits configuration object for user schema validation
|
|
24
24
|
- `SessionManager?: new (props: BaseSessionManagerContructorProps) => TSessionManager` - Optional session manager
|
|
25
25
|
constructor, defaults to BaseSessionManager
|
|
26
|
+
- `oidcProviders?: readonly OidcProviderConfig[]` - Optional array of custom OIDC provider configurations. Each provider
|
|
27
|
+
should have an `id` (matching Kratos provider ID)
|
|
26
28
|
|
|
27
29
|
**Returns:** Object with the following structure:
|
|
28
30
|
|
|
@@ -201,6 +203,98 @@ const {
|
|
|
201
203
|
})
|
|
202
204
|
```
|
|
203
205
|
|
|
206
|
+
### Custom OIDC Providers
|
|
207
|
+
|
|
208
|
+
You can configure custom OIDC providers (like Microsoft, GitHub, etc.) in addition to the default providers (Apple, Google, Facebook):
|
|
209
|
+
|
|
210
|
+
```typescript
|
|
211
|
+
// kratosService.ts
|
|
212
|
+
|
|
213
|
+
import { mkKratos } from "@leancodepl/kratos"
|
|
214
|
+
import { environment } from "./environments"
|
|
215
|
+
import { queryClient } from "./queryService"
|
|
216
|
+
import { traitsConfig } from "./traits"
|
|
217
|
+
|
|
218
|
+
const {
|
|
219
|
+
session: { sessionManager },
|
|
220
|
+
providers: { KratosProviders },
|
|
221
|
+
flows: { LoginFlow, RegistrationFlow, SettingsFlow },
|
|
222
|
+
} = mkKratos({
|
|
223
|
+
queryClient,
|
|
224
|
+
basePath: environment.authUrl,
|
|
225
|
+
traits: traitsConfig,
|
|
226
|
+
oidcProviders: [
|
|
227
|
+
{ id: "microsoft" },
|
|
228
|
+
{ id: "github" },
|
|
229
|
+
{ id: "reddit" },
|
|
230
|
+
],
|
|
231
|
+
})
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
The OIDC providers are automatically made available in the flow forms as capitalized component properties. For example, a provider with `id: "microsoft"` will be available as `oidcProviders.Microsoft`.
|
|
235
|
+
|
|
236
|
+
With TypeScript, the library generates type-safe provider types from your configuration, ensuring you can only access providers you've configured:
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
// kratosService.ts
|
|
240
|
+
|
|
241
|
+
const oidcProvidersConfig = [
|
|
242
|
+
{ id: "microsoft" },
|
|
243
|
+
{ id: "github" },
|
|
244
|
+
{ id: "reddit" },
|
|
245
|
+
] as const
|
|
246
|
+
|
|
247
|
+
const {
|
|
248
|
+
session: { sessionManager },
|
|
249
|
+
providers: { KratosProviders },
|
|
250
|
+
flows: { LoginFlow, RegistrationFlow, SettingsFlow },
|
|
251
|
+
} = mkKratos({
|
|
252
|
+
queryClient,
|
|
253
|
+
basePath: environment.authUrl,
|
|
254
|
+
traits: traitsConfig,
|
|
255
|
+
oidcProviders: oidcProvidersConfig,
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
export type OidcProvidersConfig = typeof oidcProvidersConfig
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
```tsx
|
|
262
|
+
// loginPage.tsx
|
|
263
|
+
|
|
264
|
+
import { loginFlow } from "@leancodepl/kratos"
|
|
265
|
+
import type { OidcProvidersConfig } from "./kratosService"
|
|
266
|
+
|
|
267
|
+
// Note: Provider IDs are capitalized (first letter only) in the component names.
|
|
268
|
+
// For example, "github" becomes "Github", "microsoft" becomes "Microsoft".
|
|
269
|
+
function ChooseMethodForm(props: loginFlow.ChooseMethodFormProps<OidcProvidersConfig>) {
|
|
270
|
+
const { oidcProviders: { Microsoft, Github, Reddit }, isSubmitting, isValidating } = props
|
|
271
|
+
|
|
272
|
+
return (
|
|
273
|
+
<div>
|
|
274
|
+
{Microsoft && (
|
|
275
|
+
<Microsoft>
|
|
276
|
+
<button disabled={isSubmitting || isValidating}>Sign in with Microsoft</button>
|
|
277
|
+
</Microsoft>
|
|
278
|
+
)}
|
|
279
|
+
|
|
280
|
+
{Github && (
|
|
281
|
+
<Github>
|
|
282
|
+
<button disabled={isSubmitting || isValidating}>Sign in with GitHub</button>
|
|
283
|
+
</Github>
|
|
284
|
+
)}
|
|
285
|
+
|
|
286
|
+
{Reddit && (
|
|
287
|
+
<Reddit>
|
|
288
|
+
<button disabled={isSubmitting || isValidating}>Sign in with Reddit</button>
|
|
289
|
+
</Reddit>
|
|
290
|
+
)}
|
|
291
|
+
</div>
|
|
292
|
+
)
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
The same pattern applies to registration and settings flows. Only providers configured in your Kratos instance will be available in the `oidcProviders` object, and TypeScript will provide autocomplete and type checking for the available providers.
|
|
297
|
+
|
|
204
298
|
### Session Management
|
|
205
299
|
|
|
206
300
|
```tsx
|
|
@@ -435,6 +529,7 @@ export const Input = ({ errors, ...props }: InputProps) => (
|
|
|
435
529
|
import { loginFlow } from "@leancodepl/kratos"
|
|
436
530
|
import { LoginFlow, getErrorMessage } from "./kratosService"
|
|
437
531
|
import type { AuthTraitsConfig } from "./traits"
|
|
532
|
+
import type { OidcProvidersConfig } from "./kratosService"
|
|
438
533
|
|
|
439
534
|
function LoginPage() {
|
|
440
535
|
return (
|
|
@@ -445,11 +540,11 @@ function LoginPage() {
|
|
|
445
540
|
)
|
|
446
541
|
}
|
|
447
542
|
|
|
448
|
-
function ChooseMethodForm(props: loginFlow.ChooseMethodFormProps) {
|
|
449
|
-
const { errors, isSubmitting, isValidating } = props
|
|
543
|
+
function ChooseMethodForm(props: loginFlow.ChooseMethodFormProps<OidcProvidersConfig>) {
|
|
544
|
+
const { errors, isSubmitting, isValidating, oidcProviders: { Google, Apple, Facebook } } = props
|
|
450
545
|
|
|
451
546
|
if (props.isRefresh) {
|
|
452
|
-
const { passwordFields,
|
|
547
|
+
const { passwordFields, Passkey, identifier } = props
|
|
453
548
|
|
|
454
549
|
return (
|
|
455
550
|
<div>
|
|
@@ -508,10 +603,7 @@ function ChooseMethodForm(props: loginFlow.ChooseMethodFormProps) {
|
|
|
508
603
|
|
|
509
604
|
const {
|
|
510
605
|
passwordFields: { Identifier, Password, Submit },
|
|
511
|
-
Google,
|
|
512
606
|
Passkey,
|
|
513
|
-
Apple,
|
|
514
|
-
Facebook,
|
|
515
607
|
} = props
|
|
516
608
|
|
|
517
609
|
return (
|
|
@@ -528,17 +620,23 @@ function ChooseMethodForm(props: loginFlow.ChooseMethodFormProps) {
|
|
|
528
620
|
<button>Login</button>
|
|
529
621
|
</Submit>
|
|
530
622
|
|
|
531
|
-
|
|
532
|
-
<
|
|
533
|
-
|
|
623
|
+
{Google && (
|
|
624
|
+
<Google>
|
|
625
|
+
<button>Sign in with Google</button>
|
|
626
|
+
</Google>
|
|
627
|
+
)}
|
|
534
628
|
|
|
535
|
-
|
|
536
|
-
<
|
|
537
|
-
|
|
629
|
+
{Apple && (
|
|
630
|
+
<Apple>
|
|
631
|
+
<button>Sign in with Apple</button>
|
|
632
|
+
</Apple>
|
|
633
|
+
)}
|
|
538
634
|
|
|
539
|
-
|
|
540
|
-
<
|
|
541
|
-
|
|
635
|
+
{Facebook && (
|
|
636
|
+
<Facebook>
|
|
637
|
+
<button>Sign in with Facebook</button>
|
|
638
|
+
</Facebook>
|
|
639
|
+
)}
|
|
542
640
|
|
|
543
641
|
<Passkey>
|
|
544
642
|
<button>Sign in with Passkey</button>
|
|
@@ -561,7 +659,7 @@ function ChooseMethodForm(props: loginFlow.ChooseMethodFormProps) {
|
|
|
561
659
|
```tsx
|
|
562
660
|
import { registrationFlow } from "@leancodepl/kratos"
|
|
563
661
|
import { RegistrationFlow, getErrorMessage } from "./kratosService"
|
|
564
|
-
import type { AuthTraitsConfig } from "./
|
|
662
|
+
import type { AuthTraitsConfig, OidcProvidersConfig } from "./kratosService"
|
|
565
663
|
|
|
566
664
|
function RegisterPage() {
|
|
567
665
|
return (
|
|
@@ -575,36 +673,30 @@ function RegisterPage() {
|
|
|
575
673
|
|
|
576
674
|
function TraitsForm({
|
|
577
675
|
errors,
|
|
578
|
-
|
|
579
|
-
RegulationsAccepted,
|
|
580
|
-
GivenName,
|
|
581
|
-
Google,
|
|
582
|
-
Apple,
|
|
583
|
-
Facebook,
|
|
676
|
+
oidcProviders: { Google, Apple, Facebook },
|
|
677
|
+
traitFields: { Email, GivenName, RegulationsAccepted, Submit },
|
|
584
678
|
isSubmitting,
|
|
585
679
|
isValidating,
|
|
586
|
-
}: registrationFlow.TraitsFormProps<AuthTraitsConfig>) {
|
|
680
|
+
}: registrationFlow.TraitsFormProps<AuthTraitsConfig, OidcProvidersConfig>) {
|
|
587
681
|
return (
|
|
588
682
|
<div>
|
|
589
|
-
|
|
590
|
-
<Email
|
|
591
|
-
|
|
592
|
-
</Email>
|
|
593
|
-
)}
|
|
594
|
-
{GivenName && (
|
|
595
|
-
<GivenName>
|
|
596
|
-
<input placeholder="First name" />
|
|
597
|
-
</GivenName>
|
|
598
|
-
)}
|
|
599
|
-
{RegulationsAccepted && (
|
|
600
|
-
<RegulationsAccepted>
|
|
601
|
-
<input placeholder="Regulations accepted" type="checkbox">
|
|
602
|
-
I accept the regulations
|
|
603
|
-
</input>
|
|
604
|
-
</RegulationsAccepted>
|
|
605
|
-
)}
|
|
683
|
+
<Email>
|
|
684
|
+
<input placeholder="Email" />
|
|
685
|
+
</Email>
|
|
606
686
|
|
|
607
|
-
<
|
|
687
|
+
<GivenName>
|
|
688
|
+
<input placeholder="First name" />
|
|
689
|
+
</GivenName>
|
|
690
|
+
|
|
691
|
+
<RegulationsAccepted>
|
|
692
|
+
<input placeholder="Regulations accepted" type="checkbox">
|
|
693
|
+
I accept the regulations
|
|
694
|
+
</input>
|
|
695
|
+
</RegulationsAccepted>
|
|
696
|
+
|
|
697
|
+
<Submit>
|
|
698
|
+
<button>Register</button>
|
|
699
|
+
</Submit>
|
|
608
700
|
|
|
609
701
|
{Google && (
|
|
610
702
|
<Google>
|