@krak-stack/auth 0.1.59 → 0.1.61

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 (35) hide show
  1. package/dist/access.d.ts +53 -28
  2. package/dist/access.js +34 -19
  3. package/dist/api.d.ts +10 -6
  4. package/dist/components/api-key-edit-form.d.ts +6 -3
  5. package/dist/components/api-key-edit-form.js +44 -11
  6. package/dist/components/api-key-permissions.d.ts +10 -0
  7. package/dist/components/api-key-permissions.js +45 -0
  8. package/dist/components/api-key.d.ts +6 -1
  9. package/dist/components/api-key.js +21 -1
  10. package/dist/components/auth-client-api.d.ts +5 -3
  11. package/dist/components/auth-provider.d.ts +4 -2
  12. package/dist/components/auth-provider.js +3 -1
  13. package/dist/components/has-permission.d.ts +6 -0
  14. package/dist/components/has-permission.js +4 -0
  15. package/dist/components/index.d.ts +5 -2
  16. package/dist/components/index.js +3 -1
  17. package/dist/components/organization-switcher.d.ts +2 -2
  18. package/dist/components/organization-switcher.js +13 -11
  19. package/dist/components/project-access-matrix.d.ts +28 -0
  20. package/dist/components/project-access-matrix.js +92 -0
  21. package/dist/components/user-button.d.ts +2 -2
  22. package/dist/components/user-button.js +9 -8
  23. package/dist/extra/api.group.d.ts +5 -3
  24. package/dist/extra/api.group.js +10 -7
  25. package/dist/extra/schema.d.ts +6 -4
  26. package/dist/extra/schema.js +12 -8
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +1 -1
  29. package/dist/server/actor.d.ts +95 -0
  30. package/dist/server/actor.js +127 -0
  31. package/dist/server/index.d.ts +4 -2
  32. package/dist/server/index.js +2 -1
  33. package/dist/service.d.ts +21 -17
  34. package/dist/service.js +5 -2
  35. package/package.json +5 -1
@@ -0,0 +1,95 @@
1
+ import { Layer } from "effect";
2
+ import { HttpApiError, HttpApiMiddleware } from "effect/unstable/httpapi";
3
+ import { CurrentActor, type ProjectAccessDefinition } from "../access";
4
+ import { AuthService } from "../service";
5
+ declare const AnyActorRequired_base: HttpApiMiddleware.ServiceClass<AnyActorRequired, "@krak-stack/auth/ActorRequired", {
6
+ requires: AuthService;
7
+ provides: CurrentActor;
8
+ error: readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden];
9
+ clientError: never;
10
+ requiredForClient: false;
11
+ security: never;
12
+ }, HttpApiMiddleware.HttpApiMiddleware<CurrentActor, readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden], AuthService>>;
13
+ declare class AnyActorRequired extends AnyActorRequired_base {
14
+ }
15
+ declare const UserActorRequired_base: HttpApiMiddleware.ServiceClass<UserActorRequired, "@krak-stack/auth/ActorRequired/User", {
16
+ requires: AuthService;
17
+ provides: CurrentActor;
18
+ error: readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden];
19
+ clientError: never;
20
+ requiredForClient: false;
21
+ security: never;
22
+ }, HttpApiMiddleware.HttpApiMiddleware<CurrentActor, readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden], AuthService>>;
23
+ declare class UserActorRequired extends UserActorRequired_base {
24
+ }
25
+ declare const ApiKeyActorRequired_base: HttpApiMiddleware.ServiceClass<ApiKeyActorRequired, "@krak-stack/auth/ActorRequired/ApiKey", {
26
+ requires: AuthService;
27
+ provides: CurrentActor;
28
+ error: readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden];
29
+ clientError: never;
30
+ requiredForClient: false;
31
+ security: never;
32
+ }, HttpApiMiddleware.HttpApiMiddleware<CurrentActor, readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden], AuthService>>;
33
+ declare class ApiKeyActorRequired extends ApiKeyActorRequired_base {
34
+ }
35
+ declare const UserApiKeyActorRequired_base: HttpApiMiddleware.ServiceClass<UserApiKeyActorRequired, "@krak-stack/auth/ActorRequired/ApiKey/User", {
36
+ requires: AuthService;
37
+ provides: CurrentActor;
38
+ error: readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden];
39
+ clientError: never;
40
+ requiredForClient: false;
41
+ security: never;
42
+ }, HttpApiMiddleware.HttpApiMiddleware<CurrentActor, readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden], AuthService>>;
43
+ declare class UserApiKeyActorRequired extends UserApiKeyActorRequired_base {
44
+ }
45
+ declare const OrganizationApiKeyActorRequired_base: HttpApiMiddleware.ServiceClass<OrganizationApiKeyActorRequired, "@krak-stack/auth/ActorRequired/ApiKey/Organization", {
46
+ requires: AuthService;
47
+ provides: CurrentActor;
48
+ error: readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden];
49
+ clientError: never;
50
+ requiredForClient: false;
51
+ security: never;
52
+ }, HttpApiMiddleware.HttpApiMiddleware<CurrentActor, readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden], AuthService>>;
53
+ declare class OrganizationApiKeyActorRequired extends OrganizationApiKeyActorRequired_base {
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
+ export type ActorConstraint = {
66
+ readonly type: "user";
67
+ } | {
68
+ readonly type: "apiKey";
69
+ readonly ownerType?: "user" | "organization" | "service" | undefined;
70
+ };
71
+ declare const actorRequiredLayer: <Project extends string, Action extends string>(access: ProjectAccessDefinition<Project, Action>) => Layer.Layer<AnyActorRequired | ApiKeyActorRequired | OrganizationApiKeyActorRequired | ServiceApiKeyActorRequired | UserActorRequired | UserApiKeyActorRequired, never, never>;
72
+ type ActorRequiredFactory = {
73
+ (): typeof AnyActorRequired;
74
+ (constraint: {
75
+ readonly type: "user";
76
+ }): typeof UserActorRequired;
77
+ (constraint: {
78
+ readonly type: "apiKey";
79
+ readonly ownerType: "user";
80
+ }): typeof UserApiKeyActorRequired;
81
+ (constraint: {
82
+ readonly type: "apiKey";
83
+ readonly ownerType: "organization";
84
+ }): typeof OrganizationApiKeyActorRequired;
85
+ (constraint: {
86
+ readonly type: "apiKey";
87
+ readonly ownerType: "service";
88
+ }): typeof ServiceApiKeyActorRequired;
89
+ (constraint: {
90
+ readonly type: "apiKey";
91
+ }): typeof ApiKeyActorRequired;
92
+ readonly layer: typeof actorRequiredLayer;
93
+ };
94
+ export declare const ActorRequired: ActorRequiredFactory;
95
+ export {};
@@ -0,0 +1,127 @@
1
+ import { Effect, Layer, Schema } from "effect";
2
+ import { HttpApiError, HttpApiMiddleware } from "effect/unstable/httpapi";
3
+ import { ApiKeyPermissionGrant, CurrentActor, } from "../access";
4
+ import { parseRoleList } from "../roles";
5
+ import { AuthService } from "../service";
6
+ const activeMemberRoles = ({ organizationId, userId, }) => Effect.gen(function* () {
7
+ const auth = yield* AuthService;
8
+ const member = yield* auth.organizations
9
+ .getActiveMember({ params: { organizationId, userId } })
10
+ .pipe(Effect.mapError(() => new HttpApiError.Forbidden({})));
11
+ return parseRoleList(member.role);
12
+ });
13
+ const resolveCurrentActor = (access) => Effect.gen(function* () {
14
+ const auth = yield* AuthService;
15
+ const session = yield* auth.requireSession();
16
+ if (session.authMethod.type === "apiKey") {
17
+ const apiKey = session.authMethod.apiKey;
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
+ const organizationId = session.session.activeOrganizationId;
27
+ if (!organizationId)
28
+ return yield* new HttpApiError.Unauthorized({});
29
+ if (apiKey.configId === "organization") {
30
+ return access.actorForApiKey({
31
+ apiKeyId: apiKey.id,
32
+ owner: { type: "organization", organizationId },
33
+ grant,
34
+ });
35
+ }
36
+ if (apiKey.configId === "user" && session.user) {
37
+ const roles = yield* activeMemberRoles({
38
+ organizationId,
39
+ userId: session.user.id,
40
+ });
41
+ return access.actorForApiKey({
42
+ apiKeyId: apiKey.id,
43
+ owner: {
44
+ type: "user",
45
+ userId: session.user.id,
46
+ organizationId,
47
+ roles,
48
+ },
49
+ grant,
50
+ });
51
+ }
52
+ return yield* new HttpApiError.Unauthorized({});
53
+ }
54
+ if (!session.user)
55
+ return yield* new HttpApiError.Unauthorized({});
56
+ const organizationId = session.session.activeOrganizationId;
57
+ if (!organizationId)
58
+ return yield* new HttpApiError.Unauthorized({});
59
+ const roles = yield* activeMemberRoles({
60
+ organizationId,
61
+ userId: session.user.id,
62
+ });
63
+ return access.actorForUser({
64
+ userId: session.user.id,
65
+ organizationId,
66
+ roles,
67
+ });
68
+ });
69
+ class AnyActorRequired extends HttpApiMiddleware.Service()("@krak-stack/auth/ActorRequired", {
70
+ error: [HttpApiError.Unauthorized, HttpApiError.Forbidden],
71
+ }) {
72
+ }
73
+ class UserActorRequired extends HttpApiMiddleware.Service()("@krak-stack/auth/ActorRequired/User", {
74
+ error: [HttpApiError.Unauthorized, HttpApiError.Forbidden],
75
+ }) {
76
+ }
77
+ class ApiKeyActorRequired extends HttpApiMiddleware.Service()("@krak-stack/auth/ActorRequired/ApiKey", {
78
+ error: [HttpApiError.Unauthorized, HttpApiError.Forbidden],
79
+ }) {
80
+ }
81
+ class UserApiKeyActorRequired extends HttpApiMiddleware.Service()("@krak-stack/auth/ActorRequired/ApiKey/User", {
82
+ error: [HttpApiError.Unauthorized, HttpApiError.Forbidden],
83
+ }) {
84
+ }
85
+ class OrganizationApiKeyActorRequired extends HttpApiMiddleware.Service()("@krak-stack/auth/ActorRequired/ApiKey/Organization", {
86
+ error: [HttpApiError.Unauthorized, HttpApiError.Forbidden],
87
+ }) {
88
+ }
89
+ class ServiceApiKeyActorRequired extends HttpApiMiddleware.Service()("@krak-stack/auth/ActorRequired/ApiKey/Service", {
90
+ error: [HttpApiError.Unauthorized, HttpApiError.Forbidden],
91
+ }) {
92
+ }
93
+ const matchesConstraint = (actor, constraint) => {
94
+ if (!constraint)
95
+ return true;
96
+ if (constraint.type === "user")
97
+ return actor.actor.type === "user";
98
+ return (actor.actor.type === "apiKey" &&
99
+ (!constraint.ownerType || actor.actor.owner.type === constraint.ownerType));
100
+ };
101
+ const requiredActor = (access, constraint) => resolveCurrentActor(access).pipe(Effect.flatMap((actor) => matchesConstraint(actor, constraint)
102
+ ? Effect.succeed(actor)
103
+ : Effect.fail(new HttpApiError.Forbidden({}))));
104
+ const actorRequired = (constraint) => {
105
+ if (!constraint)
106
+ return AnyActorRequired;
107
+ if (constraint.type === "user")
108
+ return UserActorRequired;
109
+ if (constraint.ownerType === "user")
110
+ return UserApiKeyActorRequired;
111
+ if (constraint.ownerType === "organization") {
112
+ return OrganizationApiKeyActorRequired;
113
+ }
114
+ if (constraint.ownerType === "service")
115
+ return ServiceApiKeyActorRequired;
116
+ return ApiKeyActorRequired;
117
+ };
118
+ 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
+ type: "apiKey",
120
+ 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
+ }).pipe(Effect.flatMap((actor) => httpEffect.pipe(Effect.provideService(CurrentActor, actor))))));
125
+ export const ActorRequired = Object.assign(actorRequired, {
126
+ layer: actorRequiredLayer,
127
+ });
@@ -3,9 +3,11 @@ export type { AuthSession, AuthSessionWithOrganization, AuthSessionWithUser, Aut
3
3
  export { AuthClientConfig } from "../config";
4
4
  export { ServerDomainsApiGroup, ServerOrganizationsApiGroup, ServerUsersApiGroup, } from "./api.group";
5
5
  export { proxyAuthRequest } from "./proxy";
6
+ export { ActorRequired } from "./actor";
7
+ export type { ActorConstraint } from "./actor";
6
8
  export { ApiKeySecurity, AuthMiddleware, makeAuthenticationLive, } from "./middleware";
7
9
  export type { AuthenticationLiveOptions } from "./middleware";
8
10
  export { ServerActiveOrganization, ServerCreateDomainPayload, ServerDomain, ServerDomainHostParams, ServerDomainIdParams, ServerDomainRecordsResponse, ServerMembersResponse, ServerOrganizationChildrenResponse, ServerOrganizationsResponse, ServerUpdateDomainPayload, ServerUsersResponse, } from "./schema";
9
11
  export type { Member, Organization, OrganizationMetadata, User, } from "../schema";
10
- export { ApiKeyPermissionGrant, CurrentPrincipal, Forbidden, all, any, defineProjectAccess, permission, policy, withPolicy, } from "../access";
11
- export type { ApiKeyOwner, ApiKeyPrincipal, Policy, Principal, ProjectAccessConfig, ProjectAccessCatalog, ProjectAccessDefinition, UserPrincipal, } from "../access";
12
+ export { ApiKeyPermissionGrant, CurrentActor, Forbidden, all, actorUserId, any, defineProjectAccess, permission, policy, withPolicy, } from "../access";
13
+ export type { ApiKeyOwner, ApiKeyActor, Actor, Policy, ProjectAccessConfig, ProjectAccessCatalog, ProjectAccessDefinition, UserActor, } from "../access";
@@ -2,6 +2,7 @@ export { AuthService } from "../service";
2
2
  export { AuthClientConfig } from "../config";
3
3
  export { ServerDomainsApiGroup, ServerOrganizationsApiGroup, ServerUsersApiGroup, } from "./api.group";
4
4
  export { proxyAuthRequest } from "./proxy";
5
+ export { ActorRequired } from "./actor";
5
6
  export { ApiKeySecurity, AuthMiddleware, makeAuthenticationLive, } from "./middleware";
6
7
  export { ServerActiveOrganization, ServerCreateDomainPayload, ServerDomain, ServerDomainHostParams, ServerDomainIdParams, ServerDomainRecordsResponse, ServerMembersResponse, ServerOrganizationChildrenResponse, ServerOrganizationsResponse, ServerUpdateDomainPayload, ServerUsersResponse, } from "./schema";
7
- export { ApiKeyPermissionGrant, CurrentPrincipal, Forbidden, all, any, defineProjectAccess, permission, policy, withPolicy, } from "../access";
8
+ export { ApiKeyPermissionGrant, CurrentActor, Forbidden, all, actorUserId, any, defineProjectAccess, permission, policy, withPolicy, } from "../access";
package/dist/service.d.ts CHANGED
@@ -28,7 +28,7 @@ export type AuthSessionWithUser = AuthSession & {
28
28
  export type AuthSessionWithUserAndOrganization = AuthSessionWithUser & AuthSessionWithOrganization;
29
29
  export type AuthServiceLayerOptions = Partial<ClientConfig> & {
30
30
  readonly headers?: Record<string, string>;
31
- readonly apiKeyConfigId?: "user" | "organization";
31
+ readonly apiKeyConfigId?: "user" | "organization" | "service";
32
32
  };
33
33
  declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/auth/AuthService", {
34
34
  getSession: () => Effect.Effect<AuthSession | null, HttpApiError.Unauthorized, never>;
@@ -206,14 +206,19 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
206
206
  }) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
207
207
  readonly ok: import("effect/Schema").Boolean;
208
208
  }, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra/schema").ExtraBadRequest | HttpApiError.Forbidden | HttpApiError.InternalServerError | import("effect/Schema").SchemaError | HttpApiError.Unauthorized), [Mode] extends ["response-only"] ? never : never>;
209
- readonly updateApiKeyPermissions: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
209
+ readonly updateApiKey: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
210
210
  readonly params: import("effect/Schema").Struct.ReadonlySide<{
211
211
  readonly keyId: import("effect/Schema").NonEmptyString;
212
212
  }, "Type">;
213
- readonly payload: import("effect/Schema").Struct.ReadonlySide<{
214
- readonly configId: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>;
215
- readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
216
- }, "Type">;
213
+ readonly payload: {
214
+ readonly configId: "organization" | "service" | "user";
215
+ readonly name: string;
216
+ readonly enabled: boolean;
217
+ readonly permissions?: {
218
+ readonly [x: string]: readonly string[];
219
+ } | undefined;
220
+ readonly referrers?: readonly string[] | undefined;
221
+ };
217
222
  readonly responseMode?: Mode;
218
223
  }) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
219
224
  readonly ok: import("effect/Schema").Boolean;
@@ -228,9 +233,6 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
228
233
  readonly payload: {
229
234
  readonly key: string;
230
235
  readonly configId?: "organization" | "service" | "user" | undefined;
231
- readonly permissions?: {
232
- readonly [x: string]: readonly string[];
233
- } | undefined;
234
236
  };
235
237
  readonly responseMode?: Mode;
236
238
  }) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
@@ -836,14 +838,19 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
836
838
  }) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
837
839
  readonly ok: import("effect/Schema").Boolean;
838
840
  }, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra/schema").ExtraBadRequest | HttpApiError.Forbidden | HttpApiError.InternalServerError | import("effect/Schema").SchemaError | HttpApiError.Unauthorized), [Mode] extends ["response-only"] ? never : never>;
839
- readonly updateApiKeyPermissions: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
841
+ readonly updateApiKey: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
840
842
  readonly params: import("effect/Schema").Struct.ReadonlySide<{
841
843
  readonly keyId: import("effect/Schema").NonEmptyString;
842
844
  }, "Type">;
843
- readonly payload: import("effect/Schema").Struct.ReadonlySide<{
844
- readonly configId: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>;
845
- readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
846
- }, "Type">;
845
+ readonly payload: {
846
+ readonly configId: "organization" | "service" | "user";
847
+ readonly name: string;
848
+ readonly enabled: boolean;
849
+ readonly permissions?: {
850
+ readonly [x: string]: readonly string[];
851
+ } | undefined;
852
+ readonly referrers?: readonly string[] | undefined;
853
+ };
847
854
  readonly responseMode?: Mode;
848
855
  }) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
849
856
  readonly ok: import("effect/Schema").Boolean;
@@ -858,9 +865,6 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
858
865
  readonly payload: {
859
866
  readonly key: string;
860
867
  readonly configId?: "organization" | "service" | "user" | undefined;
861
- readonly permissions?: {
862
- readonly [x: string]: readonly string[];
863
- } | undefined;
864
868
  };
865
869
  readonly responseMode?: Mode;
866
870
  }) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
package/dist/service.js CHANGED
@@ -59,7 +59,7 @@ const sessionCache = Effect.runSync(Cache.makeWith(() => Effect.gen(function* ()
59
59
  export class AuthService extends Context.Service()("@krak-stack/auth/AuthService", {
60
60
  make: (options = {}) => Effect.gen(function* () {
61
61
  const headers = options.headers ?? {};
62
- const apiKeyConfigId = options.apiKeyConfigId ?? "user";
62
+ const apiKeyConfigId = options.apiKeyConfigId;
63
63
  const config = yield* AuthClientConfig;
64
64
  const http = yield* HttpClient.HttpClient;
65
65
  const httpClient = HttpClient.mapRequest(http, (request) => isBetterAuthSessionRequest(request)
@@ -101,7 +101,10 @@ export class AuthService extends Context.Service()("@krak-stack/auth/AuthService
101
101
  const getApiKeySession = (key) => Effect.gen(function* () {
102
102
  const verified = yield* api.authExtra
103
103
  .verifyApiKey({
104
- payload: { key, configId: apiKeyConfigId },
104
+ payload: {
105
+ key,
106
+ ...(apiKeyConfigId ? { configId: apiKeyConfigId } : {}),
107
+ },
105
108
  })
106
109
  .pipe(Effect.mapError(unauthorized));
107
110
  if (!verified.valid || !verified.key) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/auth",
3
- "version": "0.1.59",
3
+ "version": "0.1.61",
4
4
  "description": "Effect HttpApi clients and schemas for KrakStack Auth.",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -38,6 +38,10 @@
38
38
  "types": "./dist/access.d.ts",
39
39
  "default": "./dist/access.js"
40
40
  },
41
+ "./access/matrix": {
42
+ "types": "./dist/components/project-access-matrix.d.ts",
43
+ "default": "./dist/components/project-access-matrix.js"
44
+ },
41
45
  "./components": {
42
46
  "types": "./dist/components/index.d.ts",
43
47
  "default": "./dist/components/index.js"