@krak-stack/auth 0.1.44 → 0.1.46
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 +10 -2
- package/dist/api.d.ts +99 -10
- package/dist/api.js +1 -1
- package/dist/better-auth/api.group.d.ts +33 -1
- package/dist/better-auth/api.group.js +16 -1
- package/dist/better-auth/schema.d.ts +36 -0
- package/dist/better-auth/schema.js +56 -0
- package/dist/components/admin-users.js +60 -4
- package/dist/components/auth-client-api.d.ts +62 -5
- package/dist/components/auth-client.js +3 -1
- package/dist/components/auth-provider.d.ts +2 -0
- package/dist/components/auth-provider.js +16 -2
- package/dist/components/index.d.ts +1 -1
- package/dist/components/organization-switcher.d.ts +5 -2
- package/dist/components/organization-switcher.js +64 -35
- package/dist/components/user-button.d.ts +2 -0
- package/dist/components/user-button.js +8 -3
- package/dist/extra/api.group.d.ts +4 -4
- package/dist/extra/api.group.js +19 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/roles.d.ts +10 -0
- package/dist/roles.js +31 -0
- package/dist/schema.d.ts +1 -0
- package/dist/schema.js +2 -0
- package/dist/server/middleware.d.ts +9 -3
- package/dist/server/middleware.js +25 -2
- package/dist/service.d.ts +80 -8
- package/package.json +5 -1
package/dist/extra/api.group.js
CHANGED
|
@@ -15,7 +15,12 @@ export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
|
15
15
|
.add(HttpApiEndpoint.post("setPassword", "/auth/set-password", {
|
|
16
16
|
payload: ExtraSetPasswordPayload,
|
|
17
17
|
success: ExtraOkResponse,
|
|
18
|
-
error:
|
|
18
|
+
error: [
|
|
19
|
+
ExtraBadRequest,
|
|
20
|
+
HttpApiError.Unauthorized,
|
|
21
|
+
HttpApiError.Forbidden,
|
|
22
|
+
HttpApiError.InternalServerError,
|
|
23
|
+
],
|
|
19
24
|
}).annotateMerge(OpenApi.annotations({
|
|
20
25
|
title: "Set password",
|
|
21
26
|
summary: "Set password for the current user",
|
|
@@ -24,7 +29,12 @@ export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
|
24
29
|
.add(HttpApiEndpoint.post("verifyPassword", "/auth/verify-password", {
|
|
25
30
|
payload: ExtraVerifyPasswordPayload,
|
|
26
31
|
success: ExtraOkResponse,
|
|
27
|
-
error:
|
|
32
|
+
error: [
|
|
33
|
+
ExtraBadRequest,
|
|
34
|
+
HttpApiError.Unauthorized,
|
|
35
|
+
HttpApiError.Forbidden,
|
|
36
|
+
HttpApiError.InternalServerError,
|
|
37
|
+
],
|
|
28
38
|
}).annotateMerge(OpenApi.annotations({
|
|
29
39
|
title: "Verify password",
|
|
30
40
|
summary: "Verify current user password",
|
|
@@ -33,7 +43,12 @@ export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
|
33
43
|
.add(HttpApiEndpoint.post("createApiKey", "/auth/create-api-key", {
|
|
34
44
|
payload: ExtraCreateApiKeyPayload,
|
|
35
45
|
success: ExtraCreateApiKeyResponse,
|
|
36
|
-
error:
|
|
46
|
+
error: [
|
|
47
|
+
ExtraBadRequest,
|
|
48
|
+
HttpApiError.Unauthorized,
|
|
49
|
+
HttpApiError.Forbidden,
|
|
50
|
+
HttpApiError.InternalServerError,
|
|
51
|
+
],
|
|
37
52
|
}).annotateMerge(OpenApi.annotations({
|
|
38
53
|
title: "Create API key",
|
|
39
54
|
summary: "Create an API key with optional permissions",
|
|
@@ -54,6 +69,7 @@ export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
|
54
69
|
error: [
|
|
55
70
|
ExtraBadRequest,
|
|
56
71
|
HttpApiError.Unauthorized,
|
|
72
|
+
HttpApiError.Forbidden,
|
|
57
73
|
HttpApiError.InternalServerError,
|
|
58
74
|
],
|
|
59
75
|
}).annotateMerge(OpenApi.annotations({
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
export * from "./schema";
|
|
2
2
|
export * as Query from "./query";
|
|
3
|
+
export * as Roles from "./roles";
|
|
3
4
|
export { AuthClientApi, AuthServiceApi } from "./api";
|
|
4
5
|
export { AuthService, type AuthServiceLayerOptions } from "./service";
|
|
5
6
|
export { AuthClientConfig } from "./config";
|
|
6
7
|
export { proxyAuthRequest } from "./server/proxy";
|
|
7
|
-
export { OrganizationSwitcher, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, type AuthUiClient, type KrakstackAuthContextValue, type KrakstackAuthLocale, type KrakstackAuthProviderProps, type OrganizationSwitcherDialog, type UserButtonDialog, useAuthClient, useAdminUsersTotal, } from "./components";
|
|
8
|
+
export { OrganizationSwitcher, KrakstackAuthProvider, ResetPassword, Signin, Signup, TwoFactor, AdminOrganizationForm, AdminOrganizationsTable, AdminUsersTable, UserButton, assetUrl, createAuthUiClient, type AuthUiClient, type KrakstackAuthContextValue, type KrakstackAuthLocale, type KrakstackAuthProviderProps, type OrganizationSwitcherDialog, type OrganizationSwitcherProps, type UserButtonDialog, useAuthClient, useAdminUsersTotal, } from "./components";
|
|
8
9
|
export * as BetterAuth from "./better-auth/api.group";
|
|
9
10
|
export * as Extra from "./extra/api.group";
|
|
10
11
|
export * as Server from "./server";
|
package/dist/index.js
CHANGED
package/dist/roles.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const organizationRoles: readonly ["owner", "admin", "support", "member"];
|
|
2
|
+
export type OrganizationRole = (typeof organizationRoles)[number];
|
|
3
|
+
export declare const organizationImpersonationRoles: readonly ["owner", "admin", "support"];
|
|
4
|
+
export declare const globalAdminRoles: readonly ["admin"];
|
|
5
|
+
export type GlobalAdminRole = (typeof globalAdminRoles)[number];
|
|
6
|
+
export declare const parseRoleList: (role: unknown) => string[];
|
|
7
|
+
export declare const hasAnyRole: (role: unknown, roles: readonly string[]) => boolean;
|
|
8
|
+
export declare const isOrganizationRole: (role: string) => role is OrganizationRole;
|
|
9
|
+
export declare const normalizeOrganizationRole: (role: unknown) => OrganizationRole;
|
|
10
|
+
export declare const normalizeOrganizationRoles: (role: unknown) => OrganizationRole[];
|
package/dist/roles.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const organizationRoles = [
|
|
2
|
+
"owner",
|
|
3
|
+
"admin",
|
|
4
|
+
"support",
|
|
5
|
+
"member",
|
|
6
|
+
];
|
|
7
|
+
export const organizationImpersonationRoles = [
|
|
8
|
+
"owner",
|
|
9
|
+
"admin",
|
|
10
|
+
"support",
|
|
11
|
+
];
|
|
12
|
+
export const globalAdminRoles = ["admin"];
|
|
13
|
+
export const parseRoleList = (role) => typeof role === "string"
|
|
14
|
+
? role
|
|
15
|
+
.split(",")
|
|
16
|
+
.map((item) => item.trim())
|
|
17
|
+
.filter(Boolean)
|
|
18
|
+
: [];
|
|
19
|
+
export const hasAnyRole = (role, roles) => {
|
|
20
|
+
const allowed = new Set(roles);
|
|
21
|
+
return parseRoleList(role).some((item) => allowed.has(item));
|
|
22
|
+
};
|
|
23
|
+
export const isOrganizationRole = (role) => organizationRoles.includes(role);
|
|
24
|
+
export const normalizeOrganizationRole = (role) => {
|
|
25
|
+
const [firstRole] = parseRoleList(role).filter(isOrganizationRole);
|
|
26
|
+
return firstRole ?? "member";
|
|
27
|
+
};
|
|
28
|
+
export const normalizeOrganizationRoles = (role) => {
|
|
29
|
+
const roles = parseRoleList(role).filter(isOrganizationRole);
|
|
30
|
+
return roles.length > 0 ? Array.from(new Set(roles)) : ["member"];
|
|
31
|
+
};
|
package/dist/schema.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export declare const Session: Schema.Struct<{
|
|
|
21
21
|
readonly userAgent: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
22
22
|
readonly userId: Schema.String;
|
|
23
23
|
readonly impersonatedBy: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
24
|
+
readonly impersonatedByOrganizationId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
24
25
|
readonly activeOrganizationId: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
25
26
|
}>;
|
|
26
27
|
export declare const OrganizationLocale: Schema.Union<readonly [Schema.Literal<"en">, Schema.Literal<"fr">]>;
|
package/dist/schema.js
CHANGED
|
@@ -39,6 +39,7 @@ export const Session = Schema.Struct({
|
|
|
39
39
|
userAgent: Schema.optional(Schema.NullOr(Schema.String)),
|
|
40
40
|
userId: Schema.String,
|
|
41
41
|
impersonatedBy: Schema.optional(Schema.NullOr(Schema.String)),
|
|
42
|
+
impersonatedByOrganizationId: Schema.optional(Schema.NullOr(Schema.String)),
|
|
42
43
|
activeOrganizationId: Schema.optional(Schema.NullOr(Schema.String)),
|
|
43
44
|
}).annotate({
|
|
44
45
|
identifier: "Session",
|
|
@@ -55,6 +56,7 @@ export const Session = Schema.Struct({
|
|
|
55
56
|
userAgent: "Mozilla/5.0",
|
|
56
57
|
userId: "user_1",
|
|
57
58
|
impersonatedBy: null,
|
|
59
|
+
impersonatedByOrganizationId: null,
|
|
58
60
|
activeOrganizationId: "org_1",
|
|
59
61
|
},
|
|
60
62
|
],
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
+
import { HttpServerRequest } from "effect/unstable/http";
|
|
2
3
|
import { HttpApiError, HttpApiMiddleware, HttpApiSecurity } from "effect/unstable/httpapi";
|
|
3
4
|
import { AuthService, type AuthServiceLayerOptions } from "../service";
|
|
4
5
|
export declare const ApiKeySecurity: HttpApiSecurity.ApiKey;
|
|
5
6
|
declare const AuthMiddleware_base: HttpApiMiddleware.ServiceClass<AuthMiddleware, "@krak-stack/auth/AuthMiddleware", {
|
|
6
7
|
requires: never;
|
|
7
8
|
provides: AuthService;
|
|
8
|
-
error: typeof HttpApiError.Unauthorized;
|
|
9
|
+
error: readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden];
|
|
9
10
|
clientError: never;
|
|
10
11
|
requiredForClient: false;
|
|
11
12
|
security: {
|
|
@@ -13,11 +14,16 @@ declare const AuthMiddleware_base: HttpApiMiddleware.ServiceClass<AuthMiddleware
|
|
|
13
14
|
};
|
|
14
15
|
}, HttpApiMiddleware.HttpApiMiddlewareSecurity<{
|
|
15
16
|
readonly apiKey: HttpApiSecurity.ApiKey;
|
|
16
|
-
}, AuthService, typeof HttpApiError.Unauthorized, never>>;
|
|
17
|
+
}, AuthService, readonly [typeof HttpApiError.Unauthorized, typeof HttpApiError.Forbidden], never>>;
|
|
17
18
|
export declare class AuthMiddleware extends AuthMiddleware_base {
|
|
19
|
+
static readonly layer: (options?: AuthenticationLiveOptions | Layer.Layer<AuthService, unknown>) => Layer.Layer<AuthMiddleware, never, never>;
|
|
18
20
|
}
|
|
19
21
|
export type AuthenticationLiveOptions = AuthServiceLayerOptions & {
|
|
20
|
-
readonly
|
|
22
|
+
readonly allowedOrganizationImpersonationRoutes?: readonly {
|
|
23
|
+
readonly method: string;
|
|
24
|
+
readonly path: string;
|
|
25
|
+
}[];
|
|
26
|
+
readonly authLayer?: Layer.Layer<AuthService, unknown, HttpServerRequest.HttpServerRequest>;
|
|
21
27
|
};
|
|
22
28
|
export declare const makeAuthenticationLive: (options?: AuthenticationLiveOptions | Layer.Layer<AuthService, unknown>) => Layer.Layer<AuthMiddleware, never, never>;
|
|
23
29
|
export {};
|
|
@@ -7,17 +7,19 @@ export const ApiKeySecurity = HttpApiSecurity.apiKey({
|
|
|
7
7
|
in: "header",
|
|
8
8
|
});
|
|
9
9
|
export class AuthMiddleware extends HttpApiMiddleware.Service()("@krak-stack/auth/AuthMiddleware", {
|
|
10
|
-
error: HttpApiError.Unauthorized,
|
|
10
|
+
error: [HttpApiError.Unauthorized, HttpApiError.Forbidden],
|
|
11
11
|
security: {
|
|
12
12
|
apiKey: ApiKeySecurity,
|
|
13
13
|
},
|
|
14
14
|
}) {
|
|
15
|
+
static layer = (options = {}) => makeAuthenticationLive(options);
|
|
15
16
|
}
|
|
16
17
|
const isAuthServiceLayer = (value) => Layer.isLayer(value);
|
|
17
18
|
export const makeAuthenticationLive = (options = {}) => {
|
|
18
19
|
const legacyLayer = isAuthServiceLayer(options) ? options : undefined;
|
|
19
20
|
const authOptions = isAuthServiceLayer(options) ? {} : options;
|
|
20
21
|
const authLayer = legacyLayer ?? authOptions.authLayer;
|
|
22
|
+
const allowedOrganizationImpersonationRoutes = authOptions.allowedOrganizationImpersonationRoutes ?? [];
|
|
21
23
|
return Layer.effect(AuthMiddleware, Effect.gen(function* () {
|
|
22
24
|
return {
|
|
23
25
|
apiKey: (httpEffect, { credential }) => Effect.gen(function* () {
|
|
@@ -31,10 +33,31 @@ export const makeAuthenticationLive = (options = {}) => {
|
|
|
31
33
|
...authOptions,
|
|
32
34
|
headers,
|
|
33
35
|
})), Effect.tapCause((cause) => Effect.logError("Authentication rejected: auth client initialization failed", Cause.pretty(cause))), Effect.mapError(() => new HttpApiError.Unauthorized({})));
|
|
36
|
+
if (!isAllowedRoute(allowedOrganizationImpersonationRoutes, request)) {
|
|
37
|
+
const session = yield* auth
|
|
38
|
+
.getSession()
|
|
39
|
+
.pipe(Effect.catchTag("Unauthorized", () => Effect.succeed(null)));
|
|
40
|
+
if (session?.session.impersonatedByOrganizationId) {
|
|
41
|
+
return yield* new HttpApiError.Forbidden({});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
34
44
|
return yield* httpEffect.pipe(Effect.provideService(AuthService, auth));
|
|
35
|
-
}).pipe(Effect.mapError((error) => error instanceof HttpApiError.Unauthorized
|
|
45
|
+
}).pipe(Effect.mapError((error) => error instanceof HttpApiError.Unauthorized ||
|
|
46
|
+
error instanceof HttpApiError.Forbidden
|
|
36
47
|
? error
|
|
37
48
|
: new HttpApiError.Unauthorized({}))),
|
|
38
49
|
};
|
|
39
50
|
}));
|
|
40
51
|
};
|
|
52
|
+
const pathnameFromUrl = (url) => new URL(url, "http://localhost").pathname;
|
|
53
|
+
const isAllowedRoute = (routes, request) => routes.some(({ method, path }) => method.toUpperCase() === request.method.toUpperCase() &&
|
|
54
|
+
routePathMatches(path, pathnameFromUrl(request.url)));
|
|
55
|
+
const routePathMatches = (allowedPath, requestPath) => {
|
|
56
|
+
if (allowedPath === requestPath)
|
|
57
|
+
return true;
|
|
58
|
+
const allowedSegments = allowedPath.split("/").filter(Boolean);
|
|
59
|
+
const requestSegments = requestPath.split("/").filter(Boolean);
|
|
60
|
+
if (allowedSegments.length !== requestSegments.length)
|
|
61
|
+
return false;
|
|
62
|
+
return allowedSegments.every((segment, index) => segment.startsWith(":") || segment === requestSegments[index]);
|
|
63
|
+
};
|
package/dist/service.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
50
50
|
readonly userAgent: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
51
51
|
readonly userId: import("effect/Schema").String;
|
|
52
52
|
readonly impersonatedBy: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
53
|
+
readonly impersonatedByOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
53
54
|
readonly activeOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
54
55
|
}>;
|
|
55
56
|
readonly user: import("effect/Schema").Struct<{
|
|
@@ -65,6 +66,41 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
65
66
|
readonly updatedAt: import("effect/Schema").Date;
|
|
66
67
|
}>;
|
|
67
68
|
}, "Type"> | null, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : HttpApiError.BadRequest | HttpApiError.Forbidden | HttpApiError.InternalServerError | HttpApiError.NotFound | import("effect/Schema").SchemaError | import("./better-auth/schema").TooManyRequests | HttpApiError.Unauthorized), [Mode] extends ["response-only"] ? never : never>;
|
|
69
|
+
readonly organizationImpersonateUser: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
70
|
+
readonly payload: {
|
|
71
|
+
readonly organizationId: string;
|
|
72
|
+
readonly actorUserId: string;
|
|
73
|
+
readonly targetUserId: string;
|
|
74
|
+
readonly expiresInSeconds?: number | undefined;
|
|
75
|
+
};
|
|
76
|
+
readonly responseMode?: Mode;
|
|
77
|
+
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
78
|
+
readonly session: import("effect/Schema").Struct<{
|
|
79
|
+
readonly id: import("effect/Schema").String;
|
|
80
|
+
readonly expiresAt: import("effect/Schema").Date;
|
|
81
|
+
readonly token: import("effect/Schema").String;
|
|
82
|
+
readonly createdAt: import("effect/Schema").Date;
|
|
83
|
+
readonly updatedAt: import("effect/Schema").Date;
|
|
84
|
+
readonly ipAddress: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
85
|
+
readonly userAgent: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
86
|
+
readonly userId: import("effect/Schema").String;
|
|
87
|
+
readonly impersonatedBy: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
88
|
+
readonly impersonatedByOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
89
|
+
readonly activeOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
90
|
+
}>;
|
|
91
|
+
readonly user: import("effect/Schema").Struct<{
|
|
92
|
+
readonly id: import("effect/Schema").String;
|
|
93
|
+
readonly name: import("effect/Schema").String;
|
|
94
|
+
readonly email: import("effect/Schema").String;
|
|
95
|
+
readonly emailVerified: import("effect/Schema").Boolean;
|
|
96
|
+
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
97
|
+
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
98
|
+
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
99
|
+
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
100
|
+
readonly createdAt: import("effect/Schema").Date;
|
|
101
|
+
readonly updatedAt: import("effect/Schema").Date;
|
|
102
|
+
}>;
|
|
103
|
+
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : HttpApiError.BadRequest | HttpApiError.Forbidden | HttpApiError.InternalServerError | HttpApiError.NotFound | import("effect/Schema").SchemaError | HttpApiError.Unauthorized), [Mode] extends ["response-only"] ? never : never>;
|
|
68
104
|
};
|
|
69
105
|
authExtra: {
|
|
70
106
|
readonly createApiKey: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
@@ -80,7 +116,7 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
80
116
|
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
81
117
|
readonly id: import("effect/Schema").String;
|
|
82
118
|
readonly key: import("effect/Schema").String;
|
|
83
|
-
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra/schema").ExtraBadRequest | import("effect/Schema").SchemaError), [Mode] extends ["response-only"] ? never : never>;
|
|
119
|
+
}, "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>;
|
|
84
120
|
readonly getProjectPublicConfig: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
85
121
|
readonly query: {
|
|
86
122
|
readonly projectId?: string | undefined;
|
|
@@ -111,13 +147,13 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
111
147
|
readonly responseMode?: Mode;
|
|
112
148
|
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
113
149
|
readonly ok: import("effect/Schema").Boolean;
|
|
114
|
-
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra/schema").ExtraBadRequest | import("effect/Schema").SchemaError), [Mode] extends ["response-only"] ? never : never>;
|
|
150
|
+
}, "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>;
|
|
115
151
|
readonly uploadUserImage: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
116
152
|
readonly payload: FormData;
|
|
117
153
|
readonly responseMode?: Mode;
|
|
118
154
|
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
119
155
|
readonly url: import("effect/Schema").String;
|
|
120
|
-
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra/schema").ExtraBadRequest | HttpApiError.InternalServerError | import("effect/Schema").SchemaError | HttpApiError.Unauthorized), [Mode] extends ["response-only"] ? never : never>;
|
|
156
|
+
}, "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>;
|
|
121
157
|
readonly verifyApiKey: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
122
158
|
readonly payload: {
|
|
123
159
|
readonly key: string;
|
|
@@ -155,7 +191,7 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
155
191
|
readonly responseMode?: Mode;
|
|
156
192
|
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
157
193
|
readonly ok: import("effect/Schema").Boolean;
|
|
158
|
-
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra/schema").ExtraBadRequest | import("effect/Schema").SchemaError), [Mode] extends ["response-only"] ? never : never>;
|
|
194
|
+
}, "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>;
|
|
159
195
|
};
|
|
160
196
|
domains: {
|
|
161
197
|
readonly createDomain: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
@@ -426,6 +462,7 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
426
462
|
readonly userAgent: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
427
463
|
readonly userId: import("effect/Schema").String;
|
|
428
464
|
readonly impersonatedBy: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
465
|
+
readonly impersonatedByOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
429
466
|
readonly activeOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
430
467
|
}>;
|
|
431
468
|
readonly user: import("effect/Schema").Struct<{
|
|
@@ -441,6 +478,41 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
441
478
|
readonly updatedAt: import("effect/Schema").Date;
|
|
442
479
|
}>;
|
|
443
480
|
}, "Type"> | null, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : HttpApiError.BadRequest | HttpApiError.Forbidden | HttpApiError.InternalServerError | HttpApiError.NotFound | import("effect/Schema").SchemaError | import("./better-auth/schema").TooManyRequests | HttpApiError.Unauthorized), [Mode] extends ["response-only"] ? never : never>;
|
|
481
|
+
readonly organizationImpersonateUser: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
482
|
+
readonly payload: {
|
|
483
|
+
readonly organizationId: string;
|
|
484
|
+
readonly actorUserId: string;
|
|
485
|
+
readonly targetUserId: string;
|
|
486
|
+
readonly expiresInSeconds?: number | undefined;
|
|
487
|
+
};
|
|
488
|
+
readonly responseMode?: Mode;
|
|
489
|
+
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
490
|
+
readonly session: import("effect/Schema").Struct<{
|
|
491
|
+
readonly id: import("effect/Schema").String;
|
|
492
|
+
readonly expiresAt: import("effect/Schema").Date;
|
|
493
|
+
readonly token: import("effect/Schema").String;
|
|
494
|
+
readonly createdAt: import("effect/Schema").Date;
|
|
495
|
+
readonly updatedAt: import("effect/Schema").Date;
|
|
496
|
+
readonly ipAddress: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
497
|
+
readonly userAgent: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
498
|
+
readonly userId: import("effect/Schema").String;
|
|
499
|
+
readonly impersonatedBy: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
500
|
+
readonly impersonatedByOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
501
|
+
readonly activeOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
502
|
+
}>;
|
|
503
|
+
readonly user: import("effect/Schema").Struct<{
|
|
504
|
+
readonly id: import("effect/Schema").String;
|
|
505
|
+
readonly name: import("effect/Schema").String;
|
|
506
|
+
readonly email: import("effect/Schema").String;
|
|
507
|
+
readonly emailVerified: import("effect/Schema").Boolean;
|
|
508
|
+
readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
509
|
+
readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
|
|
510
|
+
readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
|
|
511
|
+
readonly lastLoginMethod: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
|
|
512
|
+
readonly createdAt: import("effect/Schema").Date;
|
|
513
|
+
readonly updatedAt: import("effect/Schema").Date;
|
|
514
|
+
}>;
|
|
515
|
+
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : HttpApiError.BadRequest | HttpApiError.Forbidden | HttpApiError.InternalServerError | HttpApiError.NotFound | import("effect/Schema").SchemaError | HttpApiError.Unauthorized), [Mode] extends ["response-only"] ? never : never>;
|
|
444
516
|
};
|
|
445
517
|
authExtra: {
|
|
446
518
|
readonly createApiKey: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
@@ -456,7 +528,7 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
456
528
|
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
457
529
|
readonly id: import("effect/Schema").String;
|
|
458
530
|
readonly key: import("effect/Schema").String;
|
|
459
|
-
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra/schema").ExtraBadRequest | import("effect/Schema").SchemaError), [Mode] extends ["response-only"] ? never : never>;
|
|
531
|
+
}, "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>;
|
|
460
532
|
readonly getProjectPublicConfig: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
461
533
|
readonly query: {
|
|
462
534
|
readonly projectId?: string | undefined;
|
|
@@ -487,13 +559,13 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
487
559
|
readonly responseMode?: Mode;
|
|
488
560
|
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
489
561
|
readonly ok: import("effect/Schema").Boolean;
|
|
490
|
-
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra/schema").ExtraBadRequest | import("effect/Schema").SchemaError), [Mode] extends ["response-only"] ? never : never>;
|
|
562
|
+
}, "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>;
|
|
491
563
|
readonly uploadUserImage: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
492
564
|
readonly payload: FormData;
|
|
493
565
|
readonly responseMode?: Mode;
|
|
494
566
|
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
495
567
|
readonly url: import("effect/Schema").String;
|
|
496
|
-
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra/schema").ExtraBadRequest | HttpApiError.InternalServerError | import("effect/Schema").SchemaError | HttpApiError.Unauthorized), [Mode] extends ["response-only"] ? never : never>;
|
|
568
|
+
}, "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>;
|
|
497
569
|
readonly verifyApiKey: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
498
570
|
readonly payload: {
|
|
499
571
|
readonly key: string;
|
|
@@ -531,7 +603,7 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
531
603
|
readonly responseMode?: Mode;
|
|
532
604
|
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
533
605
|
readonly ok: import("effect/Schema").Boolean;
|
|
534
|
-
}, "Type">, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("./extra/schema").ExtraBadRequest | import("effect/Schema").SchemaError), [Mode] extends ["response-only"] ? never : never>;
|
|
606
|
+
}, "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>;
|
|
535
607
|
};
|
|
536
608
|
domains: {
|
|
537
609
|
readonly createDomain: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.46",
|
|
4
4
|
"description": "Effect HttpApi clients and schemas for KrakStack Auth.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"types": "./dist/query.d.ts",
|
|
31
31
|
"default": "./dist/query.js"
|
|
32
32
|
},
|
|
33
|
+
"./roles": {
|
|
34
|
+
"types": "./dist/roles.d.ts",
|
|
35
|
+
"default": "./dist/roles.js"
|
|
36
|
+
},
|
|
33
37
|
"./components": {
|
|
34
38
|
"types": "./dist/components/index.d.ts",
|
|
35
39
|
"default": "./dist/components/index.js"
|