@krak-stack/auth 0.2.22 → 0.2.24
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 +20 -0
- package/README.md +54 -0
- package/dist/api.d.ts +1364 -1364
- package/dist/components/admin-organizations.js +8 -3
- package/dist/components/admin-users.js +15 -5
- package/dist/components/auth-forms.js +144 -61
- package/dist/components/email-otp-state.d.ts +11 -0
- package/dist/components/email-otp-state.js +25 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/organization-switcher.js +6 -4
- package/dist/components/password-field.d.ts +15 -0
- package/dist/components/password-field.js +12 -0
- package/dist/components/password-reset-flow.d.ts +25 -0
- package/dist/components/password-reset-flow.js +51 -0
- package/dist/components/password-reset.d.ts +34 -0
- package/dist/components/password-reset.js +41 -0
- package/dist/components/user-button.d.ts +18 -0
- package/dist/components/user-button.js +147 -69
- package/dist/server/actor.js +1 -13
- package/dist/server/attribution.d.ts +3 -0
- package/dist/server/attribution.js +26 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/middleware.d.ts +7 -1
- package/dist/server/middleware.js +60 -28
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @krak-stack/auth
|
|
2
2
|
|
|
3
|
+
## 0.2.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Improve the sign-in flow by moving email-code/password switching into the alternative options below the primary action. Replace the inline email-change link with a Back control so users can return to the initial screen and choose Google. Persist successful code-send timestamps in local storage to preserve the resend cooldown across method switches and reloads, and reuse unexpired codes instead of sending duplicate emails when switching back to email code.
|
|
8
|
+
|
|
9
|
+
## 0.2.23
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Add a reusable Effect Form `PasswordField` with optional recovery for existing-password prompts. Password sign-in sends recovery email for the entered address before opening the confirmation page, while account revocation, password changes, and two-factor settings send recovery email inline. Share request state, resend cooldowns, and confirmation controls across public recovery and account settings without adding router dependencies to the shared flow.
|
|
14
|
+
|
|
15
|
+
Preserve recovery confirmation across refreshes without resending email, accept plain and JSON-quoted confirmation timestamps, retain OAuth and return-destination context, and clear browser session cookies after a successful password reset. Include English and French recovery messages and regression coverage for OTP-only accounts, token reuse, and session revocation.
|
|
16
|
+
|
|
17
|
+
Use link-style Back controls above nested account-security and API-key dialog headings. Keep the active security page visible through the closing animation and reset nested state only after the dialog finishes closing, preventing the default page from flashing.
|
|
18
|
+
|
|
19
|
+
Use the registry's built-in list columns for organization and project memberships and user, organization, and admin API-key permissions, replacing custom list-summary cell renderers.
|
|
20
|
+
|
|
21
|
+
Show the account's sign-in email as its default, read-only primary contact email. Preserve it when saving contact details and exclude duplicate copies from the editable contact-email list.
|
|
22
|
+
|
|
3
23
|
## 0.2.22
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -57,6 +57,34 @@ const program = Effect.gen(function* () {
|
|
|
57
57
|
|
|
58
58
|
Use `AuthMiddleware.layer()` to provide request headers and configuration in an Effect HttpApi application. See the [middleware guide](https://auth.krakstack.net/en/docs/middleware).
|
|
59
59
|
|
|
60
|
+
`AuthMiddleware` also annotates request logs and spans with verified user,
|
|
61
|
+
organization, and actor IDs using its existing session lookup. Missing sessions
|
|
62
|
+
are anonymous; auth service failures are not silently treated as anonymous.
|
|
63
|
+
`ActorRequired` remains responsible for project authorization and `CurrentActor`.
|
|
64
|
+
|
|
65
|
+
For plain `HttpRouter` routes, use the same authentication through
|
|
66
|
+
`AuthMiddleware.routerLayer()`. For example, browser Events ingestion can inherit
|
|
67
|
+
verified identity without an `Events.layer({ identity })` callback:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { AuthMiddleware } from "@krak-stack/auth/server";
|
|
71
|
+
import { HttpApiOtlp } from "@krak-stack/registry/opentelemetry/api";
|
|
72
|
+
import { Events } from "@krak-stack/registry/events";
|
|
73
|
+
import { Layer } from "effect";
|
|
74
|
+
|
|
75
|
+
const telemetry = HttpApiOtlp.layer.pipe(
|
|
76
|
+
Layer.provide(AuthMiddleware.routerLayer({ paths: ["/api/otel/v1/logs"] })),
|
|
77
|
+
Layer.provide(Events.processorLayer),
|
|
78
|
+
Layer.provide(eventsLayer),
|
|
79
|
+
);
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Here `eventsLayer` is the configured Events layer, with SQL provided when
|
|
83
|
+
persistence is needed. `paths` limits auth lookup to the listed URL pathnames;
|
|
84
|
+
without it, the middleware covers every route it is provided to. The router
|
|
85
|
+
adapter uses the same auth configuration and organization-impersonation policy
|
|
86
|
+
as `AuthMiddleware.layer()`. It does not grant permissions or provide `CurrentActor`.
|
|
87
|
+
|
|
60
88
|
## React Components
|
|
61
89
|
|
|
62
90
|
The component bundle uses the optional peer dependencies declared in `package.json` and Krakstack/shadcn UI primitives from `@krak-stack/registry`. Install the component peers used by your application; server-only consumers only need `effect`.
|
|
@@ -92,4 +120,30 @@ See [React components and CSS](https://auth.krakstack.net/en/docs/components) fo
|
|
|
92
120
|
|
|
93
121
|
Define project permissions with `defineProjectAccess`, resolve actors with `ActorRequired`, and enforce backend policies with `withPolicy`. Frontend permission helpers control presentation only.
|
|
94
122
|
|
|
123
|
+
`AuthMiddleware` annotates the current span, child spans and handler logs with verified attribution:
|
|
124
|
+
|
|
125
|
+
| Attribute | User session | User-owned API key | Organization-owned API key |
|
|
126
|
+
| ---------------------- | ---------------------- | ---------------------- | -------------------------- |
|
|
127
|
+
| `app.actor.type` | `user` | `api_key` | `api_key` |
|
|
128
|
+
| `app.actor.id` | User ID | API-key ID | API-key ID |
|
|
129
|
+
| `app.actor.owner.type` | Omitted | `user` | `organization` |
|
|
130
|
+
| `app.actor.owner.id` | Omitted | Owner user ID | Owner organization ID |
|
|
131
|
+
| `user.id` | User ID | Owner user ID | Omitted |
|
|
132
|
+
| `organization.id` | Active organization ID | Active organization ID | Owner organization ID |
|
|
133
|
+
|
|
134
|
+
The `app.actor.*` fields and existing `organization.id` are application conventions, not standard OTel actor attributes. The public actor model still uses `type: "apiKey"`; `api_key` is its telemetry representation. Only identifiers are emitted, never API-key values or session tokens. Consumers such as transactional audit recording can inherit these log annotations without depending on the auth SDK. MCP and AI execution context belongs to the respective integration layers and does not replace the authenticated actor.
|
|
135
|
+
|
|
136
|
+
Auth-owned user, organization and actor annotations replace the inherited set,
|
|
137
|
+
preventing stale user/API-key owner attribution. Unrelated request, MCP and agent
|
|
138
|
+
context is preserved, and scoped log/child-span context is restored afterward.
|
|
139
|
+
Stale fields on an already-created current span are cleared to empty strings
|
|
140
|
+
because the tracer interface has no attribute-removal method; handler logs and
|
|
141
|
+
new child spans omit those fields entirely.
|
|
142
|
+
|
|
143
|
+
`ActorRequired` does not construct or rewrite attribution. It resolves the project
|
|
144
|
+
actor, enforces actor constraints, and provides `CurrentActor`, preserving the
|
|
145
|
+
annotations established by `AuthMiddleware`. When supplying `AuthService` directly
|
|
146
|
+
without `AuthMiddleware`, authorization still works, but no auth attribution is
|
|
147
|
+
added automatically.
|
|
148
|
+
|
|
95
149
|
See the [RBAC guide](https://auth.krakstack.net/en/docs/rbac).
|