@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.
Files changed (73) hide show
  1. package/README.md +4 -3
  2. package/dist/access.d.ts +4 -4
  3. package/dist/access.js +10 -4
  4. package/dist/admin/api.group.d.ts +17 -17
  5. package/dist/admin/api.group.js +2 -2
  6. package/dist/admin/schema.d.ts +18 -18
  7. package/dist/admin/schema.js +3 -3
  8. package/dist/api.d.ts +2093 -631
  9. package/dist/api.js +7 -7
  10. package/dist/auth/api.group.d.ts +793 -0
  11. package/dist/auth/api.group.js +241 -0
  12. package/dist/auth/schema.d.ts +800 -0
  13. package/dist/auth/schema.js +625 -0
  14. package/dist/components/admin-organization-form.d.ts +1 -1
  15. package/dist/components/admin-organization-form.js +16 -18
  16. package/dist/components/admin-organizations.js +52 -46
  17. package/dist/components/admin-users.js +115 -138
  18. package/dist/components/api-key-edit-form.d.ts +4 -3
  19. package/dist/components/api-key-edit-form.js +32 -27
  20. package/dist/components/api-key-permissions.d.ts +1 -1
  21. package/dist/components/api-key-rate-limit.d.ts +1 -1
  22. package/dist/components/api-key-referrers.d.ts +3 -2
  23. package/dist/components/api-key-referrers.js +2 -3
  24. package/dist/components/api-key.d.ts +0 -9
  25. package/dist/components/api-key.js +0 -39
  26. package/dist/components/auth-atoms.d.ts +178 -0
  27. package/dist/components/auth-atoms.js +46 -0
  28. package/dist/components/auth-client-api.d.ts +2474 -142
  29. package/dist/components/auth-client-api.js +14 -10
  30. package/dist/components/auth-forms.d.ts +1 -3
  31. package/dist/components/auth-forms.js +168 -195
  32. package/dist/components/auth-provider.d.ts +3 -7
  33. package/dist/components/auth-provider.js +56 -30
  34. package/dist/components/has-permission.js +1 -1
  35. package/dist/components/index.d.ts +19 -20
  36. package/dist/components/index.js +13 -13
  37. package/dist/components/member-required.d.ts +1 -3
  38. package/dist/components/member-required.js +102 -78
  39. package/dist/components/organization-switcher.d.ts +4 -6
  40. package/dist/components/organization-switcher.js +469 -324
  41. package/dist/components/project-access-matrix.d.ts +1 -1
  42. package/dist/components/project-access-matrix.js +9 -13
  43. package/dist/components/user-button.d.ts +5 -3
  44. package/dist/components/user-button.js +265 -316
  45. package/dist/components/utils.d.ts +3 -1
  46. package/dist/components/utils.js +4 -11
  47. package/dist/extra/api.group.d.ts +3 -3
  48. package/dist/extra/api.group.js +6 -6
  49. package/dist/extra/schema.js +1 -1
  50. package/dist/index.d.ts +11 -12
  51. package/dist/index.js +11 -12
  52. package/dist/query.d.ts +2 -2
  53. package/dist/roles.d.ts +5 -4
  54. package/dist/roles.js +11 -7
  55. package/dist/schema.d.ts +1 -1
  56. package/dist/schema.js +26 -19
  57. package/dist/server/actor.d.ts +30 -32
  58. package/dist/server/actor.js +39 -22
  59. package/dist/server/api.group.js +2 -2
  60. package/dist/server/index.d.ts +14 -14
  61. package/dist/server/index.js +8 -8
  62. package/dist/server/middleware.d.ts +3 -3
  63. package/dist/server/middleware.js +10 -5
  64. package/dist/server/schema.js +1 -1
  65. package/dist/service.d.ts +2053 -201
  66. package/dist/service.js +32 -21
  67. package/package.json +10 -9
  68. package/dist/better-auth/api.group.d.ts +0 -62
  69. package/dist/better-auth/api.group.js +0 -39
  70. package/dist/better-auth/schema.d.ts +0 -72
  71. package/dist/better-auth/schema.js +0 -110
  72. package/dist/components/auth-client.d.ts +0 -50
  73. 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: [HttpApiError.Unauthorized, HttpApiError.Forbidden],
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.Unauthorized({})));
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.Unauthorized({})), Effect.flatMap((auth) => httpEffect.pipe(Effect.provideService(AuthService, auth)))),
53
+ : new HttpApiError.ServiceUnavailable({})), Effect.flatMap((auth) => httpEffect.pipe(Effect.provideService(AuthService, auth)))),
49
54
  };
50
55
  }));
51
56
  };
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- import { Member, Organization, User } from "../schema";
2
+ import { Member, Organization, User } from "../schema.js";
3
3
  export const ServerIdsQuery = Schema.Struct({
4
4
  ids: Schema.NonEmptyString,
5
5
  }).annotate({