@krak-stack/auth 0.1.61 → 0.1.62

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.
@@ -4,7 +4,7 @@ export { OrganizationSwitcher } from "./organization-switcher";
4
4
  export { MemberRequired } from "./member-required";
5
5
  export { HasPermission, useHasPermission } from "./has-permission";
6
6
  export { ProjectAccessMatrix } from "./project-access-matrix";
7
- export { ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, } from "./auth-forms";
7
+ export { ForgotPassword, ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, } from "./auth-forms";
8
8
  export { UserButton } from "./user-button";
9
9
  export { AdminOrganizationsTable } from "./admin-organizations";
10
10
  export { AdminOrganizationForm } from "./admin-organization-form";
@@ -4,7 +4,7 @@ export { OrganizationSwitcher } from "./organization-switcher";
4
4
  export { MemberRequired } from "./member-required";
5
5
  export { HasPermission, useHasPermission } from "./has-permission";
6
6
  export { ProjectAccessMatrix } from "./project-access-matrix";
7
- export { ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, } from "./auth-forms";
7
+ export { ForgotPassword, ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, } from "./auth-forms";
8
8
  export { UserButton } from "./user-button";
9
9
  export { AdminOrganizationsTable } from "./admin-organizations";
10
10
  export { AdminOrganizationForm } from "./admin-organization-form";
@@ -4,7 +4,6 @@ export type ProjectAccessMatrixAccess<Action extends string = string> = {
4
4
  readonly apiKeys: {
5
5
  readonly user: ReadonlyArray<Action>;
6
6
  readonly organization: ReadonlyArray<Action>;
7
- readonly service: ReadonlyArray<Action>;
8
7
  };
9
8
  readonly project: string;
10
9
  readonly roles: Readonly<Record<string, ReadonlyArray<Action> | undefined>>;
@@ -17,7 +16,6 @@ export type ProjectAccessMatrixMessages = {
17
16
  organizationKey: string;
18
17
  resource: string;
19
18
  rolePermissions: string;
20
- serviceKey: string;
21
19
  userKey: string;
22
20
  };
23
21
  export declare const ProjectAccessMatrix: <Action extends string, Role extends string>({ access, labels, locale, messages: messageOverrides, }: {
@@ -9,7 +9,6 @@ const messages = {
9
9
  organizationKey: "Organization key",
10
10
  resource: "Resource",
11
11
  rolePermissions: "Role grants",
12
- serviceKey: "Service key",
13
12
  userKey: "User key",
14
13
  },
15
14
  fr: {
@@ -20,7 +19,6 @@ const messages = {
20
19
  organizationKey: "Clé d’organisation",
21
20
  resource: "Ressource",
22
21
  rolePermissions: "Droits des rôles",
23
- serviceKey: "Clé de service",
24
22
  userKey: "Clé utilisateur",
25
23
  },
26
24
  };
@@ -47,11 +45,6 @@ export const ProjectAccessMatrix = ({ access, labels, locale = "en", messages: m
47
45
  label: text.organizationKey,
48
46
  permissions: access.apiKeys.organization,
49
47
  },
50
- {
51
- id: "service",
52
- label: text.serviceKey,
53
- permissions: access.apiKeys.service,
54
- },
55
48
  ];
56
49
  return (_jsxs("div", { className: "space-y-8", children: [_jsx(PermissionTable, { access: access, columns: roleColumns, labels: labels, text: text, title: text.rolePermissions }), _jsx(PermissionTable, { access: access, columns: keyColumns, labels: labels, text: text, title: text.apiKeyPermissions })] }));
57
50
  };
package/dist/index.d.ts CHANGED
@@ -5,7 +5,7 @@ export { AuthClientApi, AuthServiceApi } from "./api";
5
5
  export { AuthService, type AuthServiceLayerOptions } from "./service";
6
6
  export { AuthClientConfig } from "./config";
7
7
  export { proxyAuthRequest } from "./server/proxy";
8
- export { OrganizationSwitcher, MemberRequired, ProjectAccessMatrix, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, type AuthUiClient, type MemberRequiredMessages, type MemberRequiredProps, type ProjectAccessMatrixAccess, type ProjectAccessMatrixMessages, type ProjectAccessLabels, type ProjectAccessLabelCatalog, type KrakstackAuthContextValue, type KrakstackAuthLocale, type KrakstackAuthProviderProps, type OrganizationSwitcherDialog, type OrganizationSwitcherFeatures, type OrganizationSwitcherProps, type UserButtonDialog, useAuthClient, useAdminUsersTotal, } from "./components";
8
+ export { OrganizationSwitcher, MemberRequired, ProjectAccessMatrix, KrakstackAuthProvider, ForgotPassword, ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, type AuthUiClient, type MemberRequiredMessages, type MemberRequiredProps, type ProjectAccessMatrixAccess, type ProjectAccessMatrixMessages, type ProjectAccessLabels, type ProjectAccessLabelCatalog, type KrakstackAuthContextValue, type KrakstackAuthLocale, type KrakstackAuthProviderProps, type OrganizationSwitcherDialog, type OrganizationSwitcherFeatures, type OrganizationSwitcherProps, type UserButtonDialog, useAuthClient, useAdminUsersTotal, } from "./components";
9
9
  export * as BetterAuth from "./better-auth/api.group";
10
10
  export * as Extra from "./extra/api.group";
11
11
  export * as Server from "./server";
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ export { AuthClientApi, AuthServiceApi } from "./api";
5
5
  export { AuthService } from "./service";
6
6
  export { AuthClientConfig } from "./config";
7
7
  export { proxyAuthRequest } from "./server/proxy";
8
- export { OrganizationSwitcher, MemberRequired, ProjectAccessMatrix, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, useAuthClient, useAdminUsersTotal, } from "./components";
8
+ export { OrganizationSwitcher, MemberRequired, ProjectAccessMatrix, KrakstackAuthProvider, ForgotPassword, ResetPassword, Signin, Signup, TwoFactor, VerifyEmail, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, useAuthClient, useAdminUsersTotal, } from "./components";
9
9
  export * as BetterAuth from "./better-auth/api.group";
10
10
  export * as Extra from "./extra/api.group";
11
11
  export * as Server from "./server";
@@ -52,23 +52,13 @@ declare const OrganizationApiKeyActorRequired_base: HttpApiMiddleware.ServiceCla
52
52
  }, HttpApiMiddleware.HttpApiMiddleware<CurrentActor, readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden], AuthService>>;
53
53
  declare class OrganizationApiKeyActorRequired extends OrganizationApiKeyActorRequired_base {
54
54
  }
55
- declare const ServiceApiKeyActorRequired_base: HttpApiMiddleware.ServiceClass<ServiceApiKeyActorRequired, "@krak-stack/auth/ActorRequired/ApiKey/Service", {
56
- requires: AuthService;
57
- provides: CurrentActor;
58
- error: readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden];
59
- clientError: never;
60
- requiredForClient: false;
61
- security: never;
62
- }, HttpApiMiddleware.HttpApiMiddleware<CurrentActor, readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden], AuthService>>;
63
- declare class ServiceApiKeyActorRequired extends ServiceApiKeyActorRequired_base {
64
- }
65
55
  export type ActorConstraint = {
66
56
  readonly type: "user";
67
57
  } | {
68
58
  readonly type: "apiKey";
69
- readonly ownerType?: "user" | "organization" | "service" | undefined;
59
+ readonly ownerType?: "user" | "organization" | undefined;
70
60
  };
71
- declare const actorRequiredLayer: <Project extends string, Action extends string>(access: ProjectAccessDefinition<Project, Action>) => Layer.Layer<AnyActorRequired | ApiKeyActorRequired | OrganizationApiKeyActorRequired | ServiceApiKeyActorRequired | UserActorRequired | UserApiKeyActorRequired, never, never>;
61
+ declare const actorRequiredLayer: <Project extends string, Action extends string>(access: ProjectAccessDefinition<Project, Action>) => Layer.Layer<AnyActorRequired | ApiKeyActorRequired | OrganizationApiKeyActorRequired | UserActorRequired | UserApiKeyActorRequired, never, never>;
72
62
  type ActorRequiredFactory = {
73
63
  (): typeof AnyActorRequired;
74
64
  (constraint: {
@@ -82,10 +72,6 @@ type ActorRequiredFactory = {
82
72
  readonly type: "apiKey";
83
73
  readonly ownerType: "organization";
84
74
  }): typeof OrganizationApiKeyActorRequired;
85
- (constraint: {
86
- readonly type: "apiKey";
87
- readonly ownerType: "service";
88
- }): typeof ServiceApiKeyActorRequired;
89
75
  (constraint: {
90
76
  readonly type: "apiKey";
91
77
  }): typeof ApiKeyActorRequired;
@@ -16,13 +16,6 @@ const resolveCurrentActor = (access) => Effect.gen(function* () {
16
16
  if (session.authMethod.type === "apiKey") {
17
17
  const apiKey = session.authMethod.apiKey;
18
18
  const grant = yield* Schema.decodeUnknownEffect(ApiKeyPermissionGrant)(apiKey.permissions ?? {}).pipe(Effect.mapError(() => new HttpApiError.Unauthorized({})));
19
- if (apiKey.configId === "service") {
20
- return access.actorForApiKey({
21
- apiKeyId: apiKey.id,
22
- owner: { type: "service", serviceId: apiKey.referenceId },
23
- grant,
24
- });
25
- }
26
19
  const organizationId = session.session.activeOrganizationId;
27
20
  if (!organizationId)
28
21
  return yield* new HttpApiError.Unauthorized({});
@@ -86,10 +79,6 @@ class OrganizationApiKeyActorRequired extends HttpApiMiddleware.Service()("@krak
86
79
  error: [HttpApiError.Unauthorized, HttpApiError.Forbidden],
87
80
  }) {
88
81
  }
89
- class ServiceApiKeyActorRequired extends HttpApiMiddleware.Service()("@krak-stack/auth/ActorRequired/ApiKey/Service", {
90
- error: [HttpApiError.Unauthorized, HttpApiError.Forbidden],
91
- }) {
92
- }
93
82
  const matchesConstraint = (actor, constraint) => {
94
83
  if (!constraint)
95
84
  return true;
@@ -111,16 +100,11 @@ const actorRequired = (constraint) => {
111
100
  if (constraint.ownerType === "organization") {
112
101
  return OrganizationApiKeyActorRequired;
113
102
  }
114
- if (constraint.ownerType === "service")
115
- return ServiceApiKeyActorRequired;
116
103
  return ApiKeyActorRequired;
117
104
  };
118
105
  const actorRequiredLayer = (access) => Layer.mergeAll(Layer.succeed(AnyActorRequired, (httpEffect) => requiredActor(access).pipe(Effect.flatMap((actor) => httpEffect.pipe(Effect.provideService(CurrentActor, actor))))), Layer.succeed(UserActorRequired, (httpEffect) => requiredActor(access, { type: "user" }).pipe(Effect.flatMap((actor) => httpEffect.pipe(Effect.provideService(CurrentActor, actor))))), Layer.succeed(ApiKeyActorRequired, (httpEffect) => requiredActor(access, { type: "apiKey" }).pipe(Effect.flatMap((actor) => httpEffect.pipe(Effect.provideService(CurrentActor, actor))))), Layer.succeed(UserApiKeyActorRequired, (httpEffect) => requiredActor(access, { type: "apiKey", ownerType: "user" }).pipe(Effect.flatMap((actor) => httpEffect.pipe(Effect.provideService(CurrentActor, actor))))), Layer.succeed(OrganizationApiKeyActorRequired, (httpEffect) => requiredActor(access, {
119
106
  type: "apiKey",
120
107
  ownerType: "organization",
121
- }).pipe(Effect.flatMap((actor) => httpEffect.pipe(Effect.provideService(CurrentActor, actor))))), Layer.succeed(ServiceApiKeyActorRequired, (httpEffect) => requiredActor(access, {
122
- type: "apiKey",
123
- ownerType: "service",
124
108
  }).pipe(Effect.flatMap((actor) => httpEffect.pipe(Effect.provideService(CurrentActor, actor))))));
125
109
  export const ActorRequired = Object.assign(actorRequired, {
126
110
  layer: actorRequiredLayer,
@@ -41,11 +41,11 @@ export const makeAuthenticationLive = (options = {}) => {
41
41
  return yield* new HttpApiError.Forbidden({});
42
42
  }
43
43
  }
44
- return yield* httpEffect.pipe(Effect.provideService(AuthService, auth));
44
+ return auth;
45
45
  }).pipe(Effect.mapError((error) => error instanceof HttpApiError.Unauthorized ||
46
46
  error instanceof HttpApiError.Forbidden
47
47
  ? error
48
- : new HttpApiError.Unauthorized({}))),
48
+ : new HttpApiError.Unauthorized({})), Effect.flatMap((auth) => httpEffect.pipe(Effect.provideService(AuthService, auth)))),
49
49
  };
50
50
  }));
51
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/auth",
3
- "version": "0.1.61",
3
+ "version": "0.1.62",
4
4
  "description": "Effect HttpApi clients and schemas for KrakStack Auth.",
5
5
  "license": "MIT",
6
6
  "files": [