@krak-stack/auth 0.1.56 → 0.1.58
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/dist/access.d.ts +93 -0
- package/dist/access.js +97 -0
- package/dist/admin/api.group.d.ts +7 -0
- package/dist/admin/api.group.js +1 -1
- package/dist/admin/schema.d.ts +2 -0
- package/dist/admin/schema.js +4 -0
- package/dist/api.d.ts +23 -0
- package/dist/components/api-key-edit-form.d.ts +20 -0
- package/dist/components/api-key-edit-form.js +50 -0
- package/dist/components/api-key-rate-limit.d.ts +18 -0
- package/dist/components/api-key-rate-limit.js +29 -0
- package/dist/components/api-key-referrers.d.ts +8 -0
- package/dist/components/api-key-referrers.js +24 -0
- package/dist/components/api-key.d.ts +1 -0
- package/dist/components/api-key.js +20 -1
- package/dist/components/auth-client-api.d.ts +15 -0
- package/dist/components/auth-provider.d.ts +11 -1
- package/dist/components/auth-provider.js +29 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.js +2 -1
- package/dist/components/organization-switcher.d.ts +58 -3
- package/dist/components/organization-switcher.js +253 -70
- package/dist/components/user-button.d.ts +41 -3
- package/dist/components/user-button.js +134 -33
- package/dist/extra/api.group.d.ts +112 -103
- package/dist/extra/api.group.js +20 -1
- package/dist/extra/schema.d.ts +7 -0
- package/dist/extra/schema.js +18 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/server/index.js +1 -0
- package/dist/service.d.ts +26 -0
- package/package.json +5 -1
package/dist/extra/api.group.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
1
2
|
import { OpenApi } from "effect/unstable/httpapi";
|
|
2
3
|
import { HttpApiEndpoint, HttpApiError, HttpApiGroup, } from "effect/unstable/httpapi";
|
|
3
|
-
import { ExtraBadRequest, ExtraCreateApiKeyPayload, ExtraCreateApiKeyResponse, ExtraImageUploadMultipartPayload, ExtraOkResponse, ExtraOrganizationPublicProfile, ExtraOrganizationPublicProfileQuery, ExtraProjectPublicConfig, ExtraProjectPublicConfigQuery, ExtraSetPasswordPayload, ExtraUploadedAsset, ExtraVerifyApiKeyPayload, ExtraVerifyApiKeyResponse, ExtraVerifyPasswordPayload, } from "./schema";
|
|
4
|
+
import { ExtraBadRequest, ExtraCreateApiKeyPayload, ExtraCreateApiKeyResponse, ExtraImageUploadMultipartPayload, ExtraOkResponse, ExtraOrganizationPublicProfile, ExtraOrganizationPublicProfileQuery, ExtraProjectPublicConfig, ExtraProjectPublicConfigQuery, ExtraSetPasswordPayload, ExtraUpdateApiKeyPermissionsPayload, ExtraUploadedAsset, ExtraVerifyApiKeyPayload, ExtraVerifyApiKeyResponse, ExtraVerifyPasswordPayload, } from "./schema";
|
|
4
5
|
export * from "./schema";
|
|
5
6
|
export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
6
7
|
.add(HttpApiEndpoint.get("getProjectPublicConfig", "/auth/project-config", {
|
|
@@ -11,6 +12,24 @@ export const ExtraApiGroup = HttpApiGroup.make("authExtra")
|
|
|
11
12
|
title: "Get project public config",
|
|
12
13
|
summary: "Get host-aware project white-label config",
|
|
13
14
|
description: "Returns resolved public branding and authentication options through the proxied auth API.",
|
|
15
|
+
})))
|
|
16
|
+
.add(HttpApiEndpoint.patch("updateApiKeyPermissions", "/auth/api-key/:keyId/permissions", {
|
|
17
|
+
params: Schema.Struct({ keyId: Schema.NonEmptyString }),
|
|
18
|
+
payload: Schema.Struct({
|
|
19
|
+
configId: ExtraUpdateApiKeyPermissionsPayload.fields.configId,
|
|
20
|
+
permissions: ExtraUpdateApiKeyPermissionsPayload.fields.permissions,
|
|
21
|
+
}),
|
|
22
|
+
success: ExtraOkResponse,
|
|
23
|
+
error: [
|
|
24
|
+
ExtraBadRequest,
|
|
25
|
+
HttpApiError.Unauthorized,
|
|
26
|
+
HttpApiError.Forbidden,
|
|
27
|
+
HttpApiError.InternalServerError,
|
|
28
|
+
],
|
|
29
|
+
}).annotateMerge(OpenApi.annotations({
|
|
30
|
+
title: "Update API key permissions",
|
|
31
|
+
summary: "Replace an API key's permissions",
|
|
32
|
+
description: "Updates server-only API key permissions after Better Auth verifies user ownership or organization key-management access.",
|
|
14
33
|
})))
|
|
15
34
|
.add(HttpApiEndpoint.get("getOrganizationPublicProfile", "/auth/organization-profile", {
|
|
16
35
|
query: ExtraOrganizationPublicProfileQuery,
|
package/dist/extra/schema.d.ts
CHANGED
|
@@ -20,11 +20,17 @@ export declare const ExtraCreateApiKeyPayload: Schema.Struct<{
|
|
|
20
20
|
readonly name: Schema.optional<Schema.NonEmptyString>;
|
|
21
21
|
readonly organizationId: Schema.optional<Schema.String>;
|
|
22
22
|
readonly permissions: Schema.optional<Schema.$Record<Schema.String, Schema.$Array<Schema.String>>>;
|
|
23
|
+
readonly referrers: Schema.optional<Schema.$Array<Schema.String>>;
|
|
23
24
|
}>;
|
|
24
25
|
export declare const ExtraCreateApiKeyResponse: Schema.Struct<{
|
|
25
26
|
readonly id: Schema.String;
|
|
26
27
|
readonly key: Schema.String;
|
|
27
28
|
}>;
|
|
29
|
+
export declare const ExtraUpdateApiKeyPermissionsPayload: Schema.Struct<{
|
|
30
|
+
readonly configId: Schema.Union<readonly [Schema.Literal<"user">, Schema.Literal<"organization">, Schema.Literal<"service">]>;
|
|
31
|
+
readonly keyId: Schema.NonEmptyString;
|
|
32
|
+
readonly permissions: Schema.$Record<Schema.String, Schema.$Array<Schema.String>>;
|
|
33
|
+
}>;
|
|
28
34
|
export declare const ExtraVerifyApiKeyPayload: Schema.Struct<{
|
|
29
35
|
readonly key: Schema.NonEmptyString;
|
|
30
36
|
readonly configId: Schema.optional<Schema.Union<readonly [Schema.Literal<"user">, Schema.Literal<"organization">, Schema.Literal<"service">]>>;
|
|
@@ -170,6 +176,7 @@ export type ExtraSetPasswordPayload = typeof ExtraSetPasswordPayload.Type;
|
|
|
170
176
|
export type ExtraVerifyPasswordPayload = typeof ExtraVerifyPasswordPayload.Type;
|
|
171
177
|
export type ExtraCreateApiKeyPayload = typeof ExtraCreateApiKeyPayload.Type;
|
|
172
178
|
export type ExtraCreateApiKeyResponse = typeof ExtraCreateApiKeyResponse.Type;
|
|
179
|
+
export type ExtraUpdateApiKeyPermissionsPayload = typeof ExtraUpdateApiKeyPermissionsPayload.Type;
|
|
173
180
|
export type ExtraVerifyApiKeyPayload = typeof ExtraVerifyApiKeyPayload.Type;
|
|
174
181
|
export type ExtraVerifyApiKeyResponse = typeof ExtraVerifyApiKeyResponse.Type;
|
|
175
182
|
export type ExtraProjectPublicConfigQuery = typeof ExtraProjectPublicConfigQuery.Type;
|
package/dist/extra/schema.js
CHANGED
|
@@ -47,6 +47,7 @@ export const ExtraCreateApiKeyPayload = Schema.Struct({
|
|
|
47
47
|
name: Schema.optional(Schema.NonEmptyString),
|
|
48
48
|
organizationId: Schema.optional(Schema.String),
|
|
49
49
|
permissions: Schema.optional(ExtraApiKeyPermissions),
|
|
50
|
+
referrers: Schema.optional(Schema.Array(Schema.String)),
|
|
50
51
|
}).annotate({
|
|
51
52
|
identifier: "ExtraCreateApiKeyPayload",
|
|
52
53
|
title: "Extra create API key payload",
|
|
@@ -56,6 +57,7 @@ export const ExtraCreateApiKeyPayload = Schema.Struct({
|
|
|
56
57
|
configId: "user",
|
|
57
58
|
name: "Production key",
|
|
58
59
|
permissions: { projects: ["read"] },
|
|
60
|
+
referrers: ["https://app.example.com"],
|
|
59
61
|
},
|
|
60
62
|
],
|
|
61
63
|
});
|
|
@@ -68,6 +70,22 @@ export const ExtraCreateApiKeyResponse = Schema.Struct({
|
|
|
68
70
|
description: "Response returned after creating an API key. The secret key is only returned once.",
|
|
69
71
|
examples: [{ id: "api-key-id", key: "user_1234567890" }],
|
|
70
72
|
});
|
|
73
|
+
export const ExtraUpdateApiKeyPermissionsPayload = Schema.Struct({
|
|
74
|
+
configId: ExtraApiKeyConfigId,
|
|
75
|
+
keyId: Schema.NonEmptyString,
|
|
76
|
+
permissions: ExtraApiKeyPermissions,
|
|
77
|
+
}).annotate({
|
|
78
|
+
identifier: "ExtraUpdateApiKeyPermissionsPayload",
|
|
79
|
+
title: "Extra update API key permissions payload",
|
|
80
|
+
description: "Server-authorized replacement permissions for an existing API key.",
|
|
81
|
+
examples: [
|
|
82
|
+
{
|
|
83
|
+
configId: "organization",
|
|
84
|
+
keyId: "api-key-id",
|
|
85
|
+
permissions: { "211-search": ["search:execute"] },
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
});
|
|
71
89
|
export const ExtraVerifyApiKeyPayload = Schema.Struct({
|
|
72
90
|
key: Schema.NonEmptyString,
|
|
73
91
|
configId: Schema.optional(ExtraApiKeyConfigId),
|
package/dist/server/index.d.ts
CHANGED
|
@@ -7,3 +7,5 @@ export { ApiKeySecurity, AuthMiddleware, makeAuthenticationLive, } from "./middl
|
|
|
7
7
|
export type { AuthenticationLiveOptions } from "./middleware";
|
|
8
8
|
export { ServerActiveOrganization, ServerCreateDomainPayload, ServerDomain, ServerDomainHostParams, ServerDomainIdParams, ServerDomainRecordsResponse, ServerMembersResponse, ServerOrganizationChildrenResponse, ServerOrganizationsResponse, ServerUpdateDomainPayload, ServerUsersResponse, } from "./schema";
|
|
9
9
|
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";
|
package/dist/server/index.js
CHANGED
|
@@ -4,3 +4,4 @@ export { ServerDomainsApiGroup, ServerOrganizationsApiGroup, ServerUsersApiGroup
|
|
|
4
4
|
export { proxyAuthRequest } from "./proxy";
|
|
5
5
|
export { ApiKeySecurity, AuthMiddleware, makeAuthenticationLive, } from "./middleware";
|
|
6
6
|
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";
|
package/dist/service.d.ts
CHANGED
|
@@ -111,6 +111,7 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
111
111
|
readonly permissions?: {
|
|
112
112
|
readonly [x: string]: readonly string[];
|
|
113
113
|
} | undefined;
|
|
114
|
+
readonly referrers?: readonly string[] | undefined;
|
|
114
115
|
};
|
|
115
116
|
readonly responseMode?: Mode;
|
|
116
117
|
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
@@ -205,6 +206,18 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
205
206
|
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
206
207
|
readonly ok: import("effect/Schema").Boolean;
|
|
207
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: {
|
|
210
|
+
readonly params: import("effect/Schema").Struct.ReadonlySide<{
|
|
211
|
+
readonly keyId: import("effect/Schema").NonEmptyString;
|
|
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">;
|
|
217
|
+
readonly responseMode?: Mode;
|
|
218
|
+
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
219
|
+
readonly ok: import("effect/Schema").Boolean;
|
|
220
|
+
}, "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>;
|
|
208
221
|
readonly uploadUserImage: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
209
222
|
readonly payload: FormData;
|
|
210
223
|
readonly responseMode?: Mode;
|
|
@@ -728,6 +741,7 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
728
741
|
readonly permissions?: {
|
|
729
742
|
readonly [x: string]: readonly string[];
|
|
730
743
|
} | undefined;
|
|
744
|
+
readonly referrers?: readonly string[] | undefined;
|
|
731
745
|
};
|
|
732
746
|
readonly responseMode?: Mode;
|
|
733
747
|
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
@@ -822,6 +836,18 @@ declare const AuthService_base: Context.ServiceClass<AuthService, "@krak-stack/a
|
|
|
822
836
|
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
823
837
|
readonly ok: import("effect/Schema").Boolean;
|
|
824
838
|
}, "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: {
|
|
840
|
+
readonly params: import("effect/Schema").Struct.ReadonlySide<{
|
|
841
|
+
readonly keyId: import("effect/Schema").NonEmptyString;
|
|
842
|
+
}, "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">;
|
|
847
|
+
readonly responseMode?: Mode;
|
|
848
|
+
}) => Effect.Effect<HttpApiClient.Client.Response<import("effect/Schema").Struct.ReadonlySide<{
|
|
849
|
+
readonly ok: import("effect/Schema").Boolean;
|
|
850
|
+
}, "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>;
|
|
825
851
|
readonly uploadUserImage: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
826
852
|
readonly payload: FormData;
|
|
827
853
|
readonly responseMode?: Mode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/auth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.58",
|
|
4
4
|
"description": "Effect HttpApi clients and schemas for KrakStack Auth.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -34,6 +34,10 @@
|
|
|
34
34
|
"types": "./dist/roles.d.ts",
|
|
35
35
|
"default": "./dist/roles.js"
|
|
36
36
|
},
|
|
37
|
+
"./access": {
|
|
38
|
+
"types": "./dist/access.d.ts",
|
|
39
|
+
"default": "./dist/access.js"
|
|
40
|
+
},
|
|
37
41
|
"./components": {
|
|
38
42
|
"types": "./dist/components/index.d.ts",
|
|
39
43
|
"default": "./dist/components/index.js"
|