@krak-stack/auth 0.1.70 → 0.2.0
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/README.md +4 -3
- package/dist/access.d.ts +4 -4
- package/dist/access.js +10 -4
- package/dist/admin/api.group.d.ts +17 -17
- package/dist/admin/api.group.js +2 -2
- package/dist/admin/schema.d.ts +18 -18
- package/dist/admin/schema.js +3 -3
- package/dist/api.d.ts +2093 -631
- package/dist/api.js +7 -7
- package/dist/auth/api.group.d.ts +793 -0
- package/dist/auth/api.group.js +241 -0
- package/dist/auth/schema.d.ts +800 -0
- package/dist/auth/schema.js +625 -0
- package/dist/components/admin-organization-form.d.ts +1 -1
- package/dist/components/admin-organization-form.js +16 -18
- package/dist/components/admin-organizations.js +52 -46
- package/dist/components/admin-users.js +115 -138
- package/dist/components/api-key-edit-form.d.ts +4 -3
- package/dist/components/api-key-edit-form.js +32 -27
- package/dist/components/api-key-permissions.d.ts +1 -1
- package/dist/components/api-key-rate-limit.d.ts +1 -1
- package/dist/components/api-key-referrers.d.ts +3 -2
- package/dist/components/api-key-referrers.js +2 -3
- package/dist/components/api-key.d.ts +0 -9
- package/dist/components/api-key.js +0 -39
- package/dist/components/auth-atoms.d.ts +178 -0
- package/dist/components/auth-atoms.js +46 -0
- package/dist/components/auth-client-api.d.ts +2474 -142
- package/dist/components/auth-client-api.js +14 -10
- package/dist/components/auth-forms.d.ts +1 -3
- package/dist/components/auth-forms.js +168 -195
- package/dist/components/auth-provider.d.ts +3 -7
- package/dist/components/auth-provider.js +56 -30
- package/dist/components/has-permission.js +1 -1
- package/dist/components/index.d.ts +19 -20
- package/dist/components/index.js +13 -13
- package/dist/components/member-required.d.ts +1 -3
- package/dist/components/member-required.js +102 -78
- package/dist/components/organization-switcher.d.ts +4 -6
- package/dist/components/organization-switcher.js +469 -324
- package/dist/components/project-access-matrix.d.ts +1 -1
- package/dist/components/project-access-matrix.js +9 -13
- package/dist/components/user-button.d.ts +5 -3
- package/dist/components/user-button.js +265 -316
- package/dist/components/utils.d.ts +3 -1
- package/dist/components/utils.js +4 -11
- package/dist/extra/api.group.d.ts +3 -3
- package/dist/extra/api.group.js +6 -6
- package/dist/extra/schema.js +1 -1
- package/dist/index.d.ts +11 -12
- package/dist/index.js +11 -12
- package/dist/query.d.ts +2 -2
- package/dist/roles.d.ts +5 -4
- package/dist/roles.js +11 -7
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +26 -19
- package/dist/server/actor.d.ts +30 -32
- package/dist/server/actor.js +39 -22
- package/dist/server/api.group.js +2 -2
- package/dist/server/index.d.ts +14 -14
- package/dist/server/index.js +8 -8
- package/dist/server/middleware.d.ts +3 -3
- package/dist/server/middleware.js +10 -5
- package/dist/server/schema.js +1 -1
- package/dist/service.d.ts +2053 -201
- package/dist/service.js +32 -21
- package/package.json +10 -9
- package/dist/better-auth/api.group.d.ts +0 -62
- package/dist/better-auth/api.group.js +0 -39
- package/dist/better-auth/schema.d.ts +0 -72
- package/dist/better-auth/schema.js +0 -110
- package/dist/components/auth-client.d.ts +0 -50
- package/dist/components/auth-client.js +0 -46
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { Cause, Effect, Layer, Redacted } from "effect";
|
|
2
2
|
import { HttpServerRequest } from "effect/unstable/http";
|
|
3
3
|
import { HttpApiError, HttpApiMiddleware, HttpApiSecurity, } from "effect/unstable/httpapi";
|
|
4
|
-
import { AuthService } from "../service";
|
|
4
|
+
import { AuthService } from "../service.js";
|
|
5
5
|
export const ApiKeySecurity = HttpApiSecurity.apiKey({
|
|
6
6
|
key: "x-api-key",
|
|
7
7
|
in: "header",
|
|
8
8
|
});
|
|
9
9
|
export class AuthMiddleware extends HttpApiMiddleware.Service()("@krak-stack/auth/AuthMiddleware", {
|
|
10
|
-
error: [
|
|
10
|
+
error: [
|
|
11
|
+
HttpApiError.Unauthorized,
|
|
12
|
+
HttpApiError.Forbidden,
|
|
13
|
+
HttpApiError.ServiceUnavailable,
|
|
14
|
+
],
|
|
11
15
|
security: {
|
|
12
16
|
apiKey: ApiKeySecurity,
|
|
13
17
|
},
|
|
@@ -32,7 +36,7 @@ export const makeAuthenticationLive = (options = {}) => {
|
|
|
32
36
|
AuthService.layer({
|
|
33
37
|
...authOptions,
|
|
34
38
|
headers,
|
|
35
|
-
})), Effect.tapCause((cause) => Effect.logError("Authentication rejected: auth client initialization failed", Cause.pretty(cause))), Effect.mapError(() => new HttpApiError.
|
|
39
|
+
})), Effect.tapCause((cause) => Effect.logError("Authentication rejected: auth client initialization failed", Cause.pretty(cause))), Effect.mapError(() => new HttpApiError.ServiceUnavailable({})));
|
|
36
40
|
if (!isAllowedRoute(allowedOrganizationImpersonationRoutes, request)) {
|
|
37
41
|
const session = yield* auth
|
|
38
42
|
.getSession()
|
|
@@ -43,9 +47,10 @@ export const makeAuthenticationLive = (options = {}) => {
|
|
|
43
47
|
}
|
|
44
48
|
return auth;
|
|
45
49
|
}).pipe(Effect.mapError((error) => error instanceof HttpApiError.Unauthorized ||
|
|
46
|
-
error instanceof HttpApiError.Forbidden
|
|
50
|
+
error instanceof HttpApiError.Forbidden ||
|
|
51
|
+
error instanceof HttpApiError.ServiceUnavailable
|
|
47
52
|
? error
|
|
48
|
-
: new HttpApiError.
|
|
53
|
+
: new HttpApiError.ServiceUnavailable({})), Effect.flatMap((auth) => httpEffect.pipe(Effect.provideService(AuthService, auth)))),
|
|
49
54
|
};
|
|
50
55
|
}));
|
|
51
56
|
};
|
package/dist/server/schema.js
CHANGED