@krak-stack/auth 0.1.27 → 0.1.29

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.
@@ -0,0 +1,252 @@
1
+ import { AtomHttpApi } from "effect/unstable/reactivity";
2
+ export declare const authApiClient: (baseUrl?: string | undefined) => AtomHttpApi.AtomHttpApiClient<object, `AuthApi:${string}`, import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"auth", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getSession", "GET", "/api/auth/get-session", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").NullOr<import("effect/Schema").Struct<{
3
+ readonly session: import("effect/Schema").Struct<{
4
+ readonly id: import("effect/Schema").String;
5
+ readonly expiresAt: import("effect/Schema").Date;
6
+ readonly token: import("effect/Schema").String;
7
+ readonly createdAt: import("effect/Schema").Date;
8
+ readonly updatedAt: import("effect/Schema").Date;
9
+ readonly ipAddress: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
10
+ readonly userAgent: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
11
+ readonly userId: import("effect/Schema").String;
12
+ readonly impersonatedBy: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
13
+ readonly activeOrganizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
14
+ }>;
15
+ readonly user: import("effect/Schema").Struct<{
16
+ readonly id: import("effect/Schema").String;
17
+ readonly name: import("effect/Schema").String;
18
+ readonly email: import("effect/Schema").String;
19
+ readonly emailVerified: import("effect/Schema").Boolean;
20
+ readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
21
+ readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
22
+ readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
23
+ readonly createdAt: import("effect/Schema").Date;
24
+ readonly updatedAt: import("effect/Schema").Date;
25
+ }>;
26
+ }>>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").BadRequest | typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError | typeof import("../better-auth").TooManyRequests>, never, never>, false> | import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"authExtra", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"createApiKey", "POST", "/api/auth/create-api-key", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
27
+ readonly configId: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>;
28
+ readonly name: import("effect/Schema").optional<import("effect/Schema").NonEmptyString>;
29
+ readonly organizationId: import("effect/Schema").optional<import("effect/Schema").String>;
30
+ readonly permissions: import("effect/Schema").optional<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
31
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
32
+ readonly id: import("effect/Schema").String;
33
+ readonly key: import("effect/Schema").String;
34
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"presign", "POST", "/api/organizations/logo/presign", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
35
+ readonly fileName: import("effect/Schema").NonEmptyString;
36
+ readonly contentType: import("effect/Schema").NonEmptyString;
37
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
38
+ readonly uploadUrl: import("effect/Schema").String;
39
+ readonly url: import("effect/Schema").String;
40
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").BadRequest | typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"presignUserImageUpload", "POST", "/api/auth/image/presign", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
41
+ readonly fileName: import("effect/Schema").NonEmptyString;
42
+ readonly contentType: import("effect/Schema").NonEmptyString;
43
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
44
+ readonly uploadUrl: import("effect/Schema").String;
45
+ readonly url: import("effect/Schema").String;
46
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError | typeof import("../extra").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"setPassword", "POST", "/api/auth/set-password", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
47
+ readonly newPassword: import("effect/Schema").NonEmptyString;
48
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
49
+ readonly ok: import("effect/Schema").Boolean;
50
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"verifyApiKey", "POST", "/api/auth/verify-api-key", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
51
+ readonly key: import("effect/Schema").NonEmptyString;
52
+ readonly configId: import("effect/Schema").optional<import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"user">, import("effect/Schema").Literal<"organization">, import("effect/Schema").Literal<"service">]>>;
53
+ readonly permissions: import("effect/Schema").optional<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
54
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
55
+ readonly valid: import("effect/Schema").Boolean;
56
+ readonly error: import("effect/Schema").NullOr<import("effect/Schema").Struct<{
57
+ readonly message: import("effect/Schema").String;
58
+ readonly code: import("effect/Schema").String;
59
+ }>>;
60
+ readonly key: import("effect/Schema").NullOr<import("effect/Schema").Struct<{
61
+ readonly id: import("effect/Schema").String;
62
+ readonly configId: import("effect/Schema").String;
63
+ readonly name: import("effect/Schema").NullOr<import("effect/Schema").String>;
64
+ readonly start: import("effect/Schema").NullOr<import("effect/Schema").String>;
65
+ readonly prefix: import("effect/Schema").NullOr<import("effect/Schema").String>;
66
+ readonly referenceId: import("effect/Schema").String;
67
+ readonly enabled: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
68
+ readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
69
+ readonly createdAt: import("effect/Schema").Date;
70
+ readonly updatedAt: import("effect/Schema").Date;
71
+ readonly permissions: import("effect/Schema").NullOr<import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>>;
72
+ readonly metadata: import("effect/Schema").NullOr<import("effect/Schema").Unknown>;
73
+ }>>;
74
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra").ExtraBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"verifyPassword", "POST", "/api/auth/verify-password", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
75
+ readonly password: import("effect/Schema").NonEmptyString;
76
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
77
+ readonly ok: import("effect/Schema").Boolean;
78
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("../extra").ExtraBadRequest>, never, never>, false> | import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"domains", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"createDomain", "POST", "/api/domains", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
79
+ readonly hostname: import("effect/Schema").NonEmptyString;
80
+ readonly rootHostname: import("effect/Schema").NonEmptyString;
81
+ readonly projectId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
82
+ readonly organizationId: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
83
+ readonly managed: import("effect/Schema").Boolean;
84
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
85
+ readonly id: import("effect/Schema").String;
86
+ readonly hostname: import("effect/Schema").String;
87
+ readonly rootHostname: import("effect/Schema").String;
88
+ readonly projectId: import("effect/Schema").NullOr<import("effect/Schema").String>;
89
+ readonly organizationId: import("effect/Schema").NullOr<import("effect/Schema").String>;
90
+ readonly hostnameId: import("effect/Schema").String;
91
+ readonly managed: import("effect/Schema").Boolean;
92
+ readonly active: import("effect/Schema").Boolean;
93
+ readonly createdAt: import("effect/Schema").Date;
94
+ readonly updatedAt: import("effect/Schema").Date;
95
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").BadRequest | typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"deleteDomain", "DELETE", "/api/domains/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
96
+ readonly id: import("effect/Schema").NonEmptyString;
97
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
98
+ readonly id: import("effect/Schema").String;
99
+ readonly hostname: import("effect/Schema").String;
100
+ readonly rootHostname: import("effect/Schema").String;
101
+ readonly projectId: import("effect/Schema").NullOr<import("effect/Schema").String>;
102
+ readonly organizationId: import("effect/Schema").NullOr<import("effect/Schema").String>;
103
+ readonly hostnameId: import("effect/Schema").String;
104
+ readonly managed: import("effect/Schema").Boolean;
105
+ readonly active: import("effect/Schema").Boolean;
106
+ readonly createdAt: import("effect/Schema").Date;
107
+ readonly updatedAt: import("effect/Schema").Date;
108
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getDomain", "GET", "/api/domains/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
109
+ readonly id: import("effect/Schema").NonEmptyString;
110
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
111
+ readonly id: import("effect/Schema").String;
112
+ readonly hostname: import("effect/Schema").String;
113
+ readonly rootHostname: import("effect/Schema").String;
114
+ readonly projectId: import("effect/Schema").NullOr<import("effect/Schema").String>;
115
+ readonly organizationId: import("effect/Schema").NullOr<import("effect/Schema").String>;
116
+ readonly hostnameId: import("effect/Schema").String;
117
+ readonly managed: import("effect/Schema").Boolean;
118
+ readonly active: import("effect/Schema").Boolean;
119
+ readonly createdAt: import("effect/Schema").Date;
120
+ readonly updatedAt: import("effect/Schema").Date;
121
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getDomainByHost", "GET", "/api/domains/by-host/:hostname", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
122
+ readonly hostname: import("effect/Schema").NonEmptyString;
123
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
124
+ readonly id: import("effect/Schema").String;
125
+ readonly hostname: import("effect/Schema").String;
126
+ readonly rootHostname: import("effect/Schema").String;
127
+ readonly projectId: import("effect/Schema").NullOr<import("effect/Schema").String>;
128
+ readonly organizationId: import("effect/Schema").NullOr<import("effect/Schema").String>;
129
+ readonly hostnameId: import("effect/Schema").String;
130
+ readonly managed: import("effect/Schema").Boolean;
131
+ readonly active: import("effect/Schema").Boolean;
132
+ readonly createdAt: import("effect/Schema").Date;
133
+ readonly updatedAt: import("effect/Schema").Date;
134
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getDomainRecords", "GET", "/api/domains/:id/records", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
135
+ readonly id: import("effect/Schema").NonEmptyString;
136
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").$Array<import("effect/Schema").Struct<{
137
+ readonly required: import("effect/Schema").Boolean;
138
+ readonly status: import("effect/Schema").String;
139
+ readonly type: import("effect/Schema").String;
140
+ readonly name: import("effect/Schema").String;
141
+ readonly value: import("effect/Schema").String;
142
+ }>>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never>, false> | import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"organizations", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getActiveMember", "GET", "/api/organizations/:organizationId/members/:userId", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
143
+ readonly organizationId: import("effect/Schema").NonEmptyString;
144
+ readonly userId: import("effect/Schema").NonEmptyString;
145
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
146
+ readonly id: import("effect/Schema").String;
147
+ readonly organizationId: import("effect/Schema").String;
148
+ readonly userId: import("effect/Schema").String;
149
+ readonly role: import("effect/Schema").String;
150
+ readonly createdAt: import("effect/Schema").Date;
151
+ readonly user: import("effect/Schema").Struct<{
152
+ readonly id: import("effect/Schema").String;
153
+ readonly name: import("effect/Schema").String;
154
+ readonly email: import("effect/Schema").String;
155
+ readonly emailVerified: import("effect/Schema").Boolean;
156
+ readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
157
+ readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
158
+ readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
159
+ readonly createdAt: import("effect/Schema").Date;
160
+ readonly updatedAt: import("effect/Schema").Date;
161
+ }>;
162
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getOrganization", "GET", "/api/organizations/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
163
+ readonly id: import("effect/Schema").NonEmptyString;
164
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
165
+ readonly id: import("effect/Schema").String;
166
+ readonly name: import("effect/Schema").String;
167
+ readonly slug: import("effect/Schema").String;
168
+ readonly logo: import("effect/Schema").NullOr<import("effect/Schema").String>;
169
+ readonly metadata: import("effect/Schema").NullOr<import("effect/Schema").Struct<{
170
+ readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
171
+ readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
172
+ readonly name: import("effect/Schema").String;
173
+ readonly logo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
174
+ readonly icon: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
175
+ readonly contactEmail: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
176
+ readonly location: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
177
+ }>>;
178
+ }>>;
179
+ readonly createdAt: import("effect/Schema").Date;
180
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"listOrganizationMembers", "GET", "/api/organizations/:organizationId/members", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
181
+ readonly organizationId: import("effect/Schema").NonEmptyString;
182
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").$Array<import("effect/Schema").Struct<{
183
+ readonly id: import("effect/Schema").String;
184
+ readonly organizationId: import("effect/Schema").String;
185
+ readonly userId: import("effect/Schema").String;
186
+ readonly role: import("effect/Schema").String;
187
+ readonly createdAt: import("effect/Schema").Date;
188
+ readonly user: import("effect/Schema").Struct<{
189
+ readonly id: import("effect/Schema").String;
190
+ readonly name: import("effect/Schema").String;
191
+ readonly email: import("effect/Schema").String;
192
+ readonly emailVerified: import("effect/Schema").Boolean;
193
+ readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
194
+ readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
195
+ readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
196
+ readonly createdAt: import("effect/Schema").Date;
197
+ readonly updatedAt: import("effect/Schema").Date;
198
+ }>;
199
+ }>>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"listOrganizations", "GET", "/api/organizations", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
200
+ readonly ids: import("effect/Schema").optional<import("effect/Schema").NonEmptyString>;
201
+ readonly userId: import("effect/Schema").optional<import("effect/Schema").NonEmptyString>;
202
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
203
+ readonly data: import("effect/Schema").$Array<import("effect/Schema").Struct<{
204
+ readonly id: import("effect/Schema").String;
205
+ readonly name: import("effect/Schema").String;
206
+ readonly slug: import("effect/Schema").String;
207
+ readonly logo: import("effect/Schema").NullOr<import("effect/Schema").String>;
208
+ readonly metadata: import("effect/Schema").NullOr<import("effect/Schema").Struct<{
209
+ readonly translations: import("effect/Schema").$Array<import("effect/Schema").Struct<{
210
+ readonly locale: import("effect/Schema").Union<readonly [import("effect/Schema").Literal<"en">, import("effect/Schema").Literal<"fr">]>;
211
+ readonly name: import("effect/Schema").String;
212
+ readonly logo: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
213
+ readonly icon: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
214
+ readonly contactEmail: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
215
+ readonly location: import("effect/Schema").optional<import("effect/Schema").NullOr<import("effect/Schema").String>>;
216
+ }>>;
217
+ }>>;
218
+ readonly createdAt: import("effect/Schema").Date;
219
+ }>>;
220
+ readonly missingIds: import("effect/Schema").$Array<import("effect/Schema").String>;
221
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").BadRequest | typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never>, false> | import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"users", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getUser", "GET", "/api/users/:id", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
222
+ readonly id: import("effect/Schema").NonEmptyString;
223
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
224
+ readonly id: import("effect/Schema").String;
225
+ readonly name: import("effect/Schema").String;
226
+ readonly email: import("effect/Schema").String;
227
+ readonly emailVerified: import("effect/Schema").Boolean;
228
+ readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
229
+ readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
230
+ readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
231
+ readonly createdAt: import("effect/Schema").Date;
232
+ readonly updatedAt: import("effect/Schema").Date;
233
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").NotFound | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getUserActiveOrganization", "GET", "/api/organizations/user/:userId/active", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
234
+ readonly userId: import("effect/Schema").NonEmptyString;
235
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
236
+ readonly id: import("effect/Schema").NullOr<import("effect/Schema").String>;
237
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"listUsersByIds", "GET", "/api/users", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<import("effect/Schema").Struct<{
238
+ readonly ids: import("effect/Schema").NonEmptyString;
239
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").Struct<{
240
+ readonly data: import("effect/Schema").$Array<import("effect/Schema").Struct<{
241
+ readonly id: import("effect/Schema").String;
242
+ readonly name: import("effect/Schema").String;
243
+ readonly email: import("effect/Schema").String;
244
+ readonly emailVerified: import("effect/Schema").Boolean;
245
+ readonly image: import("effect/Schema").NullOr<import("effect/Schema").String>;
246
+ readonly role: import("effect/Schema").NullOr<import("effect/Schema").String>;
247
+ readonly banned: import("effect/Schema").NullOr<import("effect/Schema").Boolean>;
248
+ readonly createdAt: import("effect/Schema").Date;
249
+ readonly updatedAt: import("effect/Schema").Date;
250
+ }>>;
251
+ readonly missingIds: import("effect/Schema").$Array<import("effect/Schema").String>;
252
+ }>>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never>, false>>;
@@ -0,0 +1,29 @@
1
+ import { Effect } from "effect";
2
+ import { FetchHttpClient, HttpClient } from "effect/unstable/http";
3
+ import { AtomHttpApi } from "effect/unstable/reactivity";
4
+ import { AuthApi } from "../api";
5
+ const authApiUrl = (baseUrl) => {
6
+ const url = baseUrl?.trim() ||
7
+ (typeof window === "undefined"
8
+ ? "http://localhost:3000"
9
+ : window.location.origin);
10
+ return url.replace(/\/$/, "");
11
+ };
12
+ const createAuthApiClient = (key) => AtomHttpApi.Service()(`AuthApi:${key}`, {
13
+ api: AuthApi,
14
+ baseUrl: key,
15
+ httpClient: FetchHttpClient.layer,
16
+ transformClient: (client) => HttpClient.makeWith((request) => client.postprocess(request).pipe(Effect.provideService(FetchHttpClient.RequestInit, {
17
+ credentials: "include",
18
+ })), client.preprocess),
19
+ });
20
+ const authApiClients = new Map();
21
+ export const authApiClient = (baseUrl) => {
22
+ const key = authApiUrl(baseUrl);
23
+ const existing = authApiClients.get(key);
24
+ if (existing)
25
+ return existing;
26
+ const client = createAuthApiClient(key);
27
+ authApiClients.set(key, client);
28
+ return client;
29
+ };
@@ -2,9 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
2
2
  import { useAtomSet } from "@effect/atom-react";
3
3
  import { useStore } from "@tanstack/react-form";
4
4
  import {} from "@tanstack/react-table";
5
- import { Layer, Schema } from "effect";
6
- import { FetchHttpClient } from "effect/unstable/http";
7
- import { AtomHttpApi } from "effect/unstable/reactivity";
5
+ import { Schema } from "effect";
8
6
  import { Building2, Check, ChevronsUpDown, Copy, KeyRound, Mail, PencilIcon, Plus, Trash2, UserIcon, UserPlus, Users, X, } from "lucide-react";
9
7
  import { createContext, useContext, useEffect, useEffectEvent, useState, } from "react";
10
8
  import { DataTable } from "@/components/ui/data-table";
@@ -19,9 +17,10 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "
19
17
  import { Separator } from "@/components/ui/separator";
20
18
  import { cn } from "@/lib/utils";
21
19
  import { OrganizationMetadata, } from "@krak-stack/auth/schema";
20
+ import { authApiClient } from "./auth-api-client";
22
21
  import { createApiKey } from "./api-key";
23
- import { AuthApi } from "../api";
24
- import { assetPath, assetUrl, isRecord } from "./utils";
22
+ import { ExtraPresignedUpload } from "../extra/schema";
23
+ import { assetPath, assetUrl } from "./utils";
25
24
  const messages = {
26
25
  en: {
27
26
  api_key_rate_limit_notice: "API keys are subject to the same rate limits as your account.",
@@ -207,49 +206,24 @@ const slugify = (value) => value
207
206
  .replace(/[^a-z0-9]+/g, "-")
208
207
  .replace(/^-+|-+$/g, "");
209
208
  const isOrganizationSlugConflict = (error) => {
210
- if (!isRecord(error))
209
+ if (typeof error !== "object" || error === null)
211
210
  return false;
212
- const code = typeof error.code === "string" ? error.code : "";
213
- const message = typeof error.message === "string" ? error.message : "";
211
+ const code = Reflect.get(error, "code");
212
+ const message = Reflect.get(error, "message");
214
213
  return [code, message].some((value) => {
214
+ if (typeof value !== "string")
215
+ return false;
215
216
  const normalized = value.toLowerCase().replaceAll("_", " ");
216
217
  return normalized.includes("organization already exists");
217
218
  });
218
219
  };
219
220
  const nullableString = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
220
- const parsePresignedUpload = (value, m) => {
221
- if (!isRecord(value) ||
222
- typeof value.uploadUrl !== "string" ||
223
- typeof value.url !== "string") {
224
- throw new Error(m.organization_logo_upload_error());
225
- }
226
- return { uploadUrl: value.uploadUrl, url: value.url };
227
- };
228
- const credentialedFetchLayer = Layer.provide(FetchHttpClient.layer, Layer.succeed(FetchHttpClient.RequestInit, { credentials: "include" }));
229
- const createAuthApiClient = (key) => AtomHttpApi.Service()(`OrganizationSwitcherAuthApi:${key}`, {
230
- api: AuthApi,
231
- baseUrl: key,
232
- httpClient: credentialedFetchLayer,
233
- });
234
- const authApiClients = new Map();
235
- const authApiClient = (baseUrl) => {
236
- const url = baseUrl?.trim() ||
237
- (typeof window === "undefined"
238
- ? "http://localhost:3000"
239
- : window.location.origin);
240
- const key = url.replace(/\/$/, "");
241
- const existing = authApiClients.get(key);
242
- if (existing)
243
- return existing;
244
- const client = createAuthApiClient(key);
245
- authApiClients.set(key, client);
246
- return client;
247
- };
221
+ const decodePresignedUpload = Schema.decodeUnknownPromise(ExtraPresignedUpload);
248
222
  const uploadOrganizationLogo = async (file, m, presignOrganizationLogo) => {
249
223
  const contentType = file.type || "image/png";
250
- const presigned = parsePresignedUpload(await presignOrganizationLogo({
224
+ const presigned = await decodePresignedUpload(await presignOrganizationLogo({
251
225
  payload: { fileName: file.name, contentType },
252
- }), m);
226
+ }));
253
227
  const uploadResponse = await fetch(presigned.uploadUrl, {
254
228
  method: "PUT",
255
229
  headers: { "Content-Type": contentType },
@@ -1,6 +1,8 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useAtomSet } from "@effect/atom-react";
2
3
  import {} from "@tanstack/react-table";
3
4
  import { useNavigate, useRouterState, } from "@tanstack/react-router";
5
+ import { Schema } from "effect";
4
6
  import { Check, Copy, KeyRound, LogOutIcon, ShieldCheck, Trash2, UserCircleIcon, UserIcon, } from "lucide-react";
5
7
  import { QRCode } from "react-qr-code";
6
8
  import { createContext, useContext, useEffect, useEffectEvent, useState, } from "react";
@@ -14,8 +16,10 @@ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, }
14
16
  import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel, FieldLegend, FieldSet, } from "@/components/ui/field";
15
17
  import { DropdownMenu, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu";
16
18
  import { Separator } from "@/components/ui/separator";
19
+ import { authApiClient } from "./auth-api-client";
17
20
  import { createApiKey } from "./api-key";
18
- import { assetPath, assetUrl, isRecord } from "./utils";
21
+ import { ExtraPresignedUpload } from "../extra/schema";
22
+ import { assetPath, assetUrl } from "./utils";
19
23
  const messages = {
20
24
  en: {
21
25
  api_key_rate_limit_notice: "API keys are subject to the same rate limits as your account.",
@@ -200,21 +204,12 @@ const userButtonMessageFns = (labels) => new Proxy({}, {
200
204
  const UserButtonMessagesContext = createContext(userButtonMessageFns(userButtonMessages()));
201
205
  const useUserButtonMessages = () => useContext(UserButtonMessagesContext);
202
206
  const isFile = (value) => value instanceof File;
203
- const presignUserImageUpload = async (authClient, file, m) => {
207
+ const decodePresignedUpload = Schema.decodeUnknownPromise(ExtraPresignedUpload);
208
+ const presignUserImageUpload = async (file, m, presignUserImage) => {
204
209
  const contentType = file.type || "image/png";
205
- const result = await authClient.$fetch("/image/presign", {
206
- method: "POST",
207
- body: { fileName: file.name, contentType },
208
- });
209
- if (result.error || !isRecord(result.data)) {
210
- throw new Error(m.user_profile_image_upload_error());
211
- }
212
- const uploadUrl = Reflect.get(result.data, "uploadUrl");
213
- const url = Reflect.get(result.data, "url");
214
- if (typeof uploadUrl !== "string" || typeof url !== "string") {
215
- throw new Error(m.user_profile_image_upload_error());
216
- }
217
- return { uploadUrl, url };
210
+ return await decodePresignedUpload(await presignUserImage({
211
+ payload: { fileName: file.name, contentType },
212
+ }));
218
213
  };
219
214
  export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side = "bottom", defaultDialog = null, hideTrigger = false, renderUnauthenticated, apiKeyPermissions, messages, dialog: controlledDialog, onDialogChange, }) => {
220
215
  const labels = userButtonMessages(messages);
@@ -227,6 +222,7 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
227
222
  const [uncontrolledDialog, setUncontrolledDialog] = useState(defaultDialog);
228
223
  const settingsDialog = controlledDialog !== undefined ? controlledDialog : uncontrolledDialog;
229
224
  const [formError, setFormError] = useState(null);
225
+ const presignUserImage = useAtomSet(authApiClient(baseUrl).mutation("authExtra", "presignUserImageUpload"), { mode: "promise" });
230
226
  const setSettingsDialog = (next) => {
231
227
  const nextDialog = typeof next === "function" ? next(settingsDialog) : next;
232
228
  if (nextDialog === settingsDialog)
@@ -253,7 +249,7 @@ export const UserButton = ({ authClient, baseUrl, signOutRedirect = "/", side =
253
249
  const imageFile = isFile(values.image) ? values.image : null;
254
250
  const image = imageFile
255
251
  ? await (async () => {
256
- const presigned = await presignUserImageUpload(authClient, imageFile, m);
252
+ const presigned = await presignUserImageUpload(imageFile, m, presignUserImage);
257
253
  const uploadResponse = await fetch(presigned.uploadUrl, {
258
254
  method: "PUT",
259
255
  headers: { "Content-Type": imageFile.type || "image/png" },
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@krak-stack/auth",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "Effect HttpApi clients and schemas for KrakStack Auth.",
5
5
  "license": "MIT",
6
6
  "files": [
7
- "dist"
7
+ "dist",
8
+ "tailwind.css"
8
9
  ],
9
10
  "type": "module",
10
11
  "sideEffects": false,
@@ -29,6 +30,7 @@
29
30
  "types": "./dist/components/index.d.ts",
30
31
  "default": "./dist/components/index.js"
31
32
  },
33
+ "./tailwind.css": "./tailwind.css",
32
34
  "./better-auth": {
33
35
  "types": "./dist/better-auth/index.d.ts",
34
36
  "default": "./dist/better-auth/index.js"
package/tailwind.css ADDED
@@ -0,0 +1 @@
1
+ @source "./dist";