@krak-stack/auth 0.2.7 → 0.2.9

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.
@@ -89,6 +89,7 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
89
89
  readonly lastRequest: Schema.NullOr<Schema.Date>;
90
90
  readonly expiresAt: Schema.NullOr<Schema.Date>;
91
91
  readonly referrers: Schema.$Array<Schema.String>;
92
+ readonly permissions: Schema.$Record<Schema.String, Schema.$Array<Schema.String>>;
92
93
  readonly createdAt: Schema.Date;
93
94
  readonly updatedAt: Schema.Date;
94
95
  }>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.NotFound | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"deleteDomain", "DELETE", "/admin/domains/:id", Schema.toCodecStringTree<Schema.Struct<{
@@ -148,6 +149,7 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
148
149
  readonly lastRequest: Schema.NullOr<Schema.Date>;
149
150
  readonly expiresAt: Schema.NullOr<Schema.Date>;
150
151
  readonly referrers: Schema.$Array<Schema.String>;
152
+ readonly permissions: Schema.$Record<Schema.String, Schema.$Array<Schema.String>>;
151
153
  readonly createdAt: Schema.Date;
152
154
  readonly updatedAt: Schema.Date;
153
155
  }>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.NotFound | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"enableApiKeyRateLimit", "POST", "/admin/api-keys/:id/enable-rate-limit", Schema.toCodecStringTree<Schema.Struct<{
@@ -168,6 +170,7 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
168
170
  readonly lastRequest: Schema.NullOr<Schema.Date>;
169
171
  readonly expiresAt: Schema.NullOr<Schema.Date>;
170
172
  readonly referrers: Schema.$Array<Schema.String>;
173
+ readonly permissions: Schema.$Record<Schema.String, Schema.$Array<Schema.String>>;
171
174
  readonly createdAt: Schema.Date;
172
175
  readonly updatedAt: Schema.Date;
173
176
  }>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.NotFound | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"getDomainRecords", "GET", "/admin/domains/:id/records", Schema.toCodecStringTree<Schema.Struct<{
@@ -194,6 +197,7 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
194
197
  readonly lastRequest: Schema.NullOr<Schema.Date>;
195
198
  readonly expiresAt: Schema.NullOr<Schema.Date>;
196
199
  readonly referrers: Schema.$Array<Schema.String>;
200
+ readonly permissions: Schema.$Record<Schema.String, Schema.$Array<Schema.String>>;
197
201
  readonly createdAt: Schema.Date;
198
202
  readonly updatedAt: Schema.Date;
199
203
  }>>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"listDomains", "GET", "/admin/domains", never, never, never, never, Schema.toCodecJson<Schema.$Array<Schema.Struct<{
@@ -305,6 +309,7 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
305
309
  readonly lastRequest: Schema.NullOr<Schema.Date>;
306
310
  readonly expiresAt: Schema.NullOr<Schema.Date>;
307
311
  readonly referrers: Schema.$Array<Schema.String>;
312
+ readonly permissions: Schema.$Record<Schema.String, Schema.$Array<Schema.String>>;
308
313
  readonly createdAt: Schema.Date;
309
314
  readonly updatedAt: Schema.Date;
310
315
  }>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.NotFound | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"updateApiKey", "PATCH", "/admin/api-keys/:id", Schema.toCodecStringTree<Schema.Struct<{
@@ -332,6 +337,7 @@ export declare const AdminApiGroup: HttpApiGroup.HttpApiGroup<"admin", HttpApiEn
332
337
  readonly lastRequest: Schema.NullOr<Schema.Date>;
333
338
  readonly expiresAt: Schema.NullOr<Schema.Date>;
334
339
  readonly referrers: Schema.$Array<Schema.String>;
340
+ readonly permissions: Schema.$Record<Schema.String, Schema.$Array<Schema.String>>;
335
341
  readonly createdAt: Schema.Date;
336
342
  readonly updatedAt: Schema.Date;
337
343
  }>>, Schema.toCodecJson<typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.NotFound | typeof HttpApiError.InternalServerError>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"updateDomain", "PATCH", "/admin/domains/:id", Schema.toCodecStringTree<Schema.Struct<{
@@ -91,6 +91,7 @@ export declare const AdminApiKey: Schema.Struct<{
91
91
  readonly lastRequest: Schema.NullOr<Schema.Date>;
92
92
  readonly expiresAt: Schema.NullOr<Schema.Date>;
93
93
  readonly referrers: Schema.$Array<Schema.String>;
94
+ readonly permissions: Schema.$Record<Schema.String, Schema.$Array<Schema.String>>;
94
95
  readonly createdAt: Schema.Date;
95
96
  readonly updatedAt: Schema.Date;
96
97
  }>;
@@ -1,4 +1,5 @@
1
1
  import { Schema } from "effect";
2
+ import { ApiKeyPermissionGrant } from "../access.js";
2
3
  import { PaginatedResponse, Query } from "../query.js";
3
4
  import { ServerCreateDomainPayload, ServerDomain, ServerDomainIdParams, ServerDomainRecordsResponse, ServerUpdateDomainPayload, } from "../server/schema.js";
4
5
  export const AdminListQuery = Schema.Struct({
@@ -137,6 +138,7 @@ export const AdminApiKey = Schema.Struct({
137
138
  lastRequest: Schema.NullOr(Schema.Date),
138
139
  expiresAt: Schema.NullOr(Schema.Date),
139
140
  referrers: Schema.Array(Schema.String),
141
+ permissions: ApiKeyPermissionGrant,
140
142
  createdAt: Schema.Date,
141
143
  updatedAt: Schema.Date,
142
144
  }).annotate({
@@ -160,6 +162,7 @@ export const AdminApiKey = Schema.Struct({
160
162
  lastRequest: null,
161
163
  expiresAt: null,
162
164
  referrers: ["https://app.example.com"],
165
+ permissions: { "project-id": ["auth:proxy"] },
163
166
  createdAt: new Date("2026-01-01T00:00:00.000Z"),
164
167
  updatedAt: new Date("2026-01-01T00:00:00.000Z"),
165
168
  },
package/dist/api.d.ts CHANGED
@@ -1074,7 +1074,7 @@ export declare const AuthServiceApi: HttpApi.HttpApi<"AuthServiceApi", import("e
1074
1074
  readonly updatedAt: import("effect/Schema").DateFromString;
1075
1075
  }>>;
1076
1076
  readonly status: import("effect/Schema").optional<import("effect/Schema").Boolean>;
1077
- }>>, import("effect/Schema").toCodecJson<typeof import("./auth/schema.js").AuthBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"signOut", "POST", "/api/auth/sign-out", never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
1077
+ }>>, import("effect/Schema").toCodecJson<typeof import("./auth/schema.js").AuthBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"signOut", "POST", "/api/auth/sign-out", never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{}>>, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
1078
1078
  readonly success: import("effect/Schema").Boolean;
1079
1079
  }>>, import("effect/Schema").toCodecJson<typeof import("./auth/schema.js").AuthBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"twoFactorDisable", "POST", "/api/auth/two-factor/disable", never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
1080
1080
  readonly password: import("effect/Schema").optional<import("effect/Schema").String>;
@@ -2024,6 +2024,7 @@ export declare const AuthClientApi: HttpApi.HttpApi<"AuthClientApi", import("eff
2024
2024
  readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
2025
2025
  readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
2026
2026
  readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
2027
+ readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
2027
2028
  readonly createdAt: import("effect/Schema").Date;
2028
2029
  readonly updatedAt: import("effect/Schema").Date;
2029
2030
  }>>, import("effect/Schema").toCodecJson<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>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"deleteDomain", "DELETE", "/api/auth/admin/domains/:id", import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
@@ -2083,6 +2084,7 @@ export declare const AuthClientApi: HttpApi.HttpApi<"AuthClientApi", import("eff
2083
2084
  readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
2084
2085
  readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
2085
2086
  readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
2087
+ readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
2086
2088
  readonly createdAt: import("effect/Schema").Date;
2087
2089
  readonly updatedAt: import("effect/Schema").Date;
2088
2090
  }>>, import("effect/Schema").toCodecJson<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>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"enableApiKeyRateLimit", "POST", "/api/auth/admin/api-keys/:id/enable-rate-limit", import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
@@ -2103,6 +2105,7 @@ export declare const AuthClientApi: HttpApi.HttpApi<"AuthClientApi", import("eff
2103
2105
  readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
2104
2106
  readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
2105
2107
  readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
2108
+ readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
2106
2109
  readonly createdAt: import("effect/Schema").Date;
2107
2110
  readonly updatedAt: import("effect/Schema").Date;
2108
2111
  }>>, import("effect/Schema").toCodecJson<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>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getDomainRecords", "GET", "/api/auth/admin/domains/:id/records", import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
@@ -2129,6 +2132,7 @@ export declare const AuthClientApi: HttpApi.HttpApi<"AuthClientApi", import("eff
2129
2132
  readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
2130
2133
  readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
2131
2134
  readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
2135
+ readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
2132
2136
  readonly createdAt: import("effect/Schema").Date;
2133
2137
  readonly updatedAt: import("effect/Schema").Date;
2134
2138
  }>>>, import("effect/Schema").toCodecJson<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<"listDomains", "GET", "/api/auth/admin/domains", never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").$Array<import("effect/Schema").Struct<{
@@ -2240,6 +2244,7 @@ export declare const AuthClientApi: HttpApi.HttpApi<"AuthClientApi", import("eff
2240
2244
  readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
2241
2245
  readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
2242
2246
  readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
2247
+ readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
2243
2248
  readonly createdAt: import("effect/Schema").Date;
2244
2249
  readonly updatedAt: import("effect/Schema").Date;
2245
2250
  }>>, import("effect/Schema").toCodecJson<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>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"updateApiKey", "PATCH", "/api/auth/admin/api-keys/:id", import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
@@ -2267,6 +2272,7 @@ export declare const AuthClientApi: HttpApi.HttpApi<"AuthClientApi", import("eff
2267
2272
  readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
2268
2273
  readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
2269
2274
  readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
2275
+ readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
2270
2276
  readonly createdAt: import("effect/Schema").Date;
2271
2277
  readonly updatedAt: import("effect/Schema").Date;
2272
2278
  }>>, import("effect/Schema").toCodecJson<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>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"updateDomain", "PATCH", "/api/auth/admin/domains/:id", import("effect/Schema").toCodecStringTree<import("effect/Schema").Struct<{
@@ -3394,7 +3400,7 @@ export declare const AuthClientApi: HttpApi.HttpApi<"AuthClientApi", import("eff
3394
3400
  readonly updatedAt: import("effect/Schema").DateFromString;
3395
3401
  }>>;
3396
3402
  readonly status: import("effect/Schema").optional<import("effect/Schema").Boolean>;
3397
- }>>, import("effect/Schema").toCodecJson<typeof import("./auth/schema.js").AuthBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"signOut", "POST", "/api/auth/sign-out", never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
3403
+ }>>, import("effect/Schema").toCodecJson<typeof import("./auth/schema.js").AuthBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"signOut", "POST", "/api/auth/sign-out", never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{}>>, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
3398
3404
  readonly success: import("effect/Schema").Boolean;
3399
3405
  }>>, import("effect/Schema").toCodecJson<typeof import("./auth/schema.js").AuthBadRequest>, never, never> | import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"twoFactorDisable", "POST", "/api/auth/two-factor/disable", never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
3400
3406
  readonly password: import("effect/Schema").optional<import("effect/Schema").String>;
@@ -1077,7 +1077,7 @@ export declare const AuthApiGroup: HttpApiGroup.HttpApiGroup<"auth", HttpApiEndp
1077
1077
  readonly updatedAt: Schema.DateFromString;
1078
1078
  }>>;
1079
1079
  readonly status: Schema.optional<Schema.Boolean>;
1080
- }>>, Schema.toCodecJson<typeof AuthBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"signOut", "POST", "/sign-out", never, never, never, never, Schema.toCodecJson<Schema.Struct<{
1080
+ }>>, Schema.toCodecJson<typeof AuthBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"signOut", "POST", "/sign-out", never, never, Schema.toCodecJson<Schema.Struct<{}>>, never, Schema.toCodecJson<Schema.Struct<{
1081
1081
  readonly success: Schema.Boolean;
1082
1082
  }>>, Schema.toCodecJson<typeof AuthBadRequest>, never, never> | HttpApiEndpoint.HttpApiEndpoint<"twoFactorDisable", "POST", "/two-factor/disable", never, never, Schema.toCodecJson<Schema.Struct<{
1083
1083
  readonly password: Schema.optional<Schema.String>;
@@ -1,6 +1,6 @@
1
1
  import { Schema } from "effect";
2
2
  import { HttpApiEndpoint, HttpApiGroup, OpenApi, } from "effect/unstable/httpapi";
3
- import { AdminBanUserPayload, AdminUserIdPayload, AdminUserResponse, AuthBadRequest, AuthConflict, AuthExpectationFailed, AuthForbidden, AuthInternalServerError, AuthInvitation, AuthNotFound, AuthOrganization, AuthSessionResponse, AuthStatusResponse, AuthSuccessResponse, AuthTooManyRequests, AuthUnauthorized, ChangePasswordPayload, ChangePasswordResponse, CreateOrganizationPayload, DeleteApiKeyPayload, FullAuthOrganization, GetFullOrganizationQuery, GetInvitationQuery, GetInvitationResponse, GetSessionQuery, GetSessionResponse, InvitationActionResponse, InvitationIdPayload, InviteMemberPayload, LeaveOrganizationPayload, LinkedAccount, LinkSocialPayload, ListApiKeysQuery, ListApiKeysResponse, MemberResponse, OAuthConsentPayload, OAuthPublicClient, OAuthPublicClientQuery, OAuthRedirectResponse, OrganizationImpersonateUserPayload, OrganizationImpersonateUserResponse, OrganizationInvitationsQuery, OrganizationListMembersQuery, OrganizationListMembersResponse, RemoveMemberPayload, RequestPasswordResetPayload, RequestPasswordResetResponse, ResetPasswordPayload, SendVerificationOtpPayload, SetActiveOrganizationPayload, SignInEmailOtpPayload, SignInEmailPayload, SignInEmailResponse, SignInResponse, SignInSocialPayload, SocialRedirectResponse, TwoFactorBackupVerifyPayload, TwoFactorDisablePayload, TwoFactorEnablePayload, TwoFactorEnableResponse, TwoFactorSendPayload, TwoFactorVerifyPayload, UnlinkAccountPayload, UpdateMemberRolePayload, UpdateOrganizationPayload, UpdateUserPayload, UserInvitationsQuery, VerifyEmailOtpPayload, VerifyEmailOtpResponse, } from "./schema.js";
3
+ import { AdminBanUserPayload, AdminUserIdPayload, AdminUserResponse, AuthBadRequest, AuthConflict, AuthExpectationFailed, AuthForbidden, AuthInternalServerError, AuthInvitation, AuthNotFound, AuthOrganization, AuthSessionResponse, AuthStatusResponse, AuthSuccessResponse, AuthTooManyRequests, AuthUnauthorized, ChangePasswordPayload, ChangePasswordResponse, CreateOrganizationPayload, DeleteApiKeyPayload, FullAuthOrganization, GetFullOrganizationQuery, GetInvitationQuery, GetInvitationResponse, GetSessionQuery, GetSessionResponse, InvitationActionResponse, InvitationIdPayload, InviteMemberPayload, LeaveOrganizationPayload, LinkedAccount, LinkSocialPayload, ListApiKeysQuery, ListApiKeysResponse, MemberResponse, OAuthConsentPayload, OAuthPublicClient, OAuthPublicClientQuery, OAuthRedirectResponse, OrganizationImpersonateUserPayload, OrganizationImpersonateUserResponse, OrganizationInvitationsQuery, OrganizationListMembersQuery, OrganizationListMembersResponse, RemoveMemberPayload, RequestPasswordResetPayload, RequestPasswordResetResponse, ResetPasswordPayload, SendVerificationOtpPayload, SetActiveOrganizationPayload, SignInEmailOtpPayload, SignInEmailPayload, SignInEmailResponse, SignInResponse, SignInSocialPayload, SignOutPayload, SocialRedirectResponse, TwoFactorBackupVerifyPayload, TwoFactorDisablePayload, TwoFactorEnablePayload, TwoFactorEnableResponse, TwoFactorSendPayload, TwoFactorVerifyPayload, UnlinkAccountPayload, UpdateMemberRolePayload, UpdateOrganizationPayload, UpdateUserPayload, UserInvitationsQuery, VerifyEmailOtpPayload, VerifyEmailOtpResponse, } from "./schema.js";
4
4
  export * from "./schema.js";
5
5
  const errors = [
6
6
  AuthBadRequest,
@@ -20,6 +20,7 @@ export const AuthApiGroup = HttpApiGroup.make("auth")
20
20
  error: errors,
21
21
  }).annotateMerge(docs("Get session", "Returns the current browser session.")))
22
22
  .add(HttpApiEndpoint.post("signOut", "/sign-out", {
23
+ payload: SignOutPayload,
23
24
  success: AuthSuccessResponse,
24
25
  error: errors,
25
26
  }).annotateMerge(docs("Sign out", "Ends the current browser session.")))
@@ -190,6 +190,7 @@ export declare const GetSessionQuery: Schema.Struct<{
190
190
  export declare const AuthStatusResponse: Schema.Struct<{
191
191
  readonly status: Schema.Boolean;
192
192
  }>;
193
+ export declare const SignOutPayload: Schema.Struct<{}>;
193
194
  export declare const AuthSuccessResponse: Schema.Struct<{
194
195
  readonly success: Schema.Boolean;
195
196
  }>;
@@ -61,6 +61,9 @@ export const GetSessionQuery = Schema.Struct({
61
61
  export const AuthStatusResponse = Schema.Struct({
62
62
  status: Schema.Boolean,
63
63
  }).annotate({ identifier: "AuthStatusResponse", title: "Status response" });
64
+ export const SignOutPayload = Schema.Struct({}).annotate({
65
+ identifier: "SignOutPayload",
66
+ });
64
67
  export const AuthSuccessResponse = Schema.Struct({
65
68
  success: Schema.Boolean,
66
69
  }).annotate({ identifier: "AuthSuccessResponse", title: "Success response" });
@@ -95,6 +95,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined) => Effect.Ef
95
95
  readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
96
96
  readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
97
97
  readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
98
+ readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
98
99
  readonly createdAt: import("effect/Schema").Date;
99
100
  readonly updatedAt: import("effect/Schema").Date;
100
101
  }>>, import("effect/Schema").toCodecJson<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>, never, never>, never, never>;
@@ -157,6 +158,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined) => Effect.Ef
157
158
  readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
158
159
  readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
159
160
  readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
161
+ readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
160
162
  readonly createdAt: import("effect/Schema").Date;
161
163
  readonly updatedAt: import("effect/Schema").Date;
162
164
  }>>, import("effect/Schema").toCodecJson<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>, never, never>, never, never>;
@@ -178,6 +180,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined) => Effect.Ef
178
180
  readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
179
181
  readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
180
182
  readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
183
+ readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
181
184
  readonly createdAt: import("effect/Schema").Date;
182
185
  readonly updatedAt: import("effect/Schema").Date;
183
186
  }>>, import("effect/Schema").toCodecJson<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>, never, never>, never, never>;
@@ -206,6 +209,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined) => Effect.Ef
206
209
  readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
207
210
  readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
208
211
  readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
212
+ readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
209
213
  readonly createdAt: import("effect/Schema").Date;
210
214
  readonly updatedAt: import("effect/Schema").Date;
211
215
  }>>>, import("effect/Schema").toCodecJson<typeof import("effect/unstable/httpapi/HttpApiError").Unauthorized | typeof import("effect/unstable/httpapi/HttpApiError").Forbidden | typeof import("effect/unstable/httpapi/HttpApiError").InternalServerError>, never, never>, never, never>;
@@ -321,6 +325,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined) => Effect.Ef
321
325
  readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
322
326
  readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
323
327
  readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
328
+ readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
324
329
  readonly createdAt: import("effect/Schema").Date;
325
330
  readonly updatedAt: import("effect/Schema").Date;
326
331
  }>>, import("effect/Schema").toCodecJson<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>, never, never>, never, never>;
@@ -349,6 +354,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined) => Effect.Ef
349
354
  readonly lastRequest: import("effect/Schema").NullOr<import("effect/Schema").Date>;
350
355
  readonly expiresAt: import("effect/Schema").NullOr<import("effect/Schema").Date>;
351
356
  readonly referrers: import("effect/Schema").$Array<import("effect/Schema").String>;
357
+ readonly permissions: import("effect/Schema").$Record<import("effect/Schema").String, import("effect/Schema").$Array<import("effect/Schema").String>>;
352
358
  readonly createdAt: import("effect/Schema").Date;
353
359
  readonly updatedAt: import("effect/Schema").Date;
354
360
  }>>, import("effect/Schema").toCodecJson<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>, never, never>, never, never>;
@@ -1516,7 +1522,7 @@ export declare const authHttpClient: (baseUrl?: string | undefined) => Effect.Ef
1516
1522
  }>>;
1517
1523
  readonly status: import("effect/Schema").optional<import("effect/Schema").Boolean>;
1518
1524
  }>>, import("effect/Schema").toCodecJson<typeof import("../auth/schema.js").AuthBadRequest>, never, never>, never, never>;
1519
- readonly signOut: HttpApiClient.Client.Method<import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"signOut", "POST", "/api/auth/sign-out", never, never, never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
1525
+ readonly signOut: HttpApiClient.Client.Method<import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"signOut", "POST", "/api/auth/sign-out", never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{}>>, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
1520
1526
  readonly success: import("effect/Schema").Boolean;
1521
1527
  }>>, import("effect/Schema").toCodecJson<typeof import("../auth/schema.js").AuthBadRequest>, never, never>, never, never>;
1522
1528
  readonly twoFactorDisable: HttpApiClient.Client.Method<import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"twoFactorDisable", "POST", "/api/auth/two-factor/disable", never, never, import("effect/Schema").toCodecJson<import("effect/Schema").Struct<{
@@ -10,7 +10,9 @@ export declare const resolveInitialAuthMethod: ({ requestedMethod, lastLoginMeth
10
10
  emailPassword: boolean;
11
11
  emailOtp: boolean;
12
12
  }) => AuthMethod;
13
- export declare function Signin(props: AuthFormProps): import("react").JSX.Element;
13
+ export declare function Signin(props: AuthFormProps & {
14
+ otpExpiryDescription?: string | undefined;
15
+ }): import("react").JSX.Element;
14
16
  export declare function VerifyEmail(props: AuthFormProps): import("react").JSX.Element;
15
17
  export declare function ForgotPassword(props: AuthFormProps): import("react").JSX.Element;
16
18
  export declare function ResetPassword(props: AuthFormProps): import("react").JSX.Element;
@@ -421,7 +421,7 @@ export function Signin(props) {
421
421
  return;
422
422
  event.preventDefault();
423
423
  event.currentTarget.form?.requestSubmit();
424
- }, required: true })) : null, emailSubmitted && selectedAuthMethod === "password" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.password, { label: m.field_password, type: "password", autoComplete: "current-password", required: true }), _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [_jsx(Link, { className: authLinkClassName, to: "/reset-password", search: authMethodSearch(searchString, "password", formValues.email.trim()), children: m.sign_in_forgot_password }), canChangeAuthMethod ? (_jsxs(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: switchAuthMethod, children: [_jsx(Mail, {}), m.sign_in_use_email_otp] })) : null] })] })) : null, emailSubmitted && selectedAuthMethod === "emailOtp" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.otp, { label: m.sign_in_email_otp_code }), _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [otpSentTo ? (_jsx(Button, { type: "button", variant: "link", className: "h-auto px-0", disabled: emailOtpResendSeconds > 0, onClick: resendEmailOtp, children: emailOtpResendSeconds > 0
424
+ }, required: true })) : null, emailSubmitted && selectedAuthMethod === "password" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.password, { label: m.field_password, type: "password", autoComplete: "current-password", required: true }), _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [_jsx(Link, { className: authLinkClassName, to: "/reset-password", search: authMethodSearch(searchString, "password", formValues.email.trim()), children: m.sign_in_forgot_password }), canChangeAuthMethod ? (_jsxs(Button, { type: "button", variant: "link", className: "h-auto px-0", onClick: switchAuthMethod, children: [_jsx(Mail, {}), m.sign_in_use_email_otp] })) : null] })] })) : null, emailSubmitted && selectedAuthMethod === "emailOtp" ? (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(form.otp, { label: m.sign_in_email_otp_code }), props.otpExpiryDescription ? (_jsx("p", { className: "text-muted-foreground text-sm", children: props.otpExpiryDescription })) : null, _jsxs("div", { className: "flex flex-wrap gap-x-4 gap-y-2 text-sm", children: [otpSentTo ? (_jsx(Button, { type: "button", variant: "link", className: "h-auto px-0", disabled: emailOtpResendSeconds > 0, onClick: resendEmailOtp, children: emailOtpResendSeconds > 0
425
425
  ? text(m.sign_in_email_otp_resend_countdown, {
426
426
  seconds: String(emailOtpResendSeconds),
427
427
  })
@@ -1,9 +1,9 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useAtomSet, useAtomSuspense } from "@effect/atom-react";
2
+ import { useAtomRefresh, useAtomSet, useAtomSuspense, } from "@effect/atom-react";
3
3
  import { Effect, Schema } from "effect";
4
4
  import { Atom } from "effect/unstable/reactivity";
5
5
  import { Check, Loader2, Mail, ShieldAlert } from "lucide-react";
6
- import { useEffect, useState } from "react";
6
+ import { useEffect, useRef, useState } from "react";
7
7
  import { Button } from "@/components/ui/button";
8
8
  import { CopyButton } from "@krak-stack/registry/copy-button";
9
9
  import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/components/ui/card";
@@ -102,7 +102,7 @@ const accessAtom = Atom.family((baseUrl) => Atom.family((key) => {
102
102
  userId: Schema.optional(Schema.String),
103
103
  }));
104
104
  const { locale, organizationId } = Schema.decodeUnknownSync(AccessKey)(key);
105
- return Atom.keepAlive(authClientApi(baseUrl).runtime.atom((get) => Effect.gen(function* () {
105
+ return Atom.optimistic(Atom.keepAlive(authClientApi(baseUrl).runtime.atom((get) => Effect.gen(function* () {
106
106
  const client = yield* authHttpClient(baseUrl);
107
107
  const allowed = yield* client.auth
108
108
  .organizationSetActive({ payload: { organizationId } })
@@ -111,9 +111,6 @@ const accessAtom = Atom.family((baseUrl) => Atom.family((key) => {
111
111
  : Effect.fail(error)));
112
112
  if (allowed) {
113
113
  get.refresh(authSessionAtom(baseUrl));
114
- yield* get.result(authSessionAtom(baseUrl), {
115
- suspendOnWaiting: true,
116
- });
117
114
  return { allowed: true };
118
115
  }
119
116
  const profileKey = JSON.stringify({ locale, organizationId });
@@ -135,10 +132,9 @@ const accessAtom = Atom.family((baseUrl) => Atom.family((key) => {
135
132
  organization,
136
133
  invitation: invitations.find((item) => invitationMatches(item, organizationId)) ?? null,
137
134
  };
138
- })));
135
+ }))));
139
136
  }));
140
- const accessAtomKey = ({ authRefreshVersion, baseUrl, locale, organizationId, userId, }) => JSON.stringify({
141
- authRefreshVersion,
137
+ const accessAtomKey = ({ baseUrl, locale, organizationId, userId, }) => JSON.stringify({
142
138
  baseUrl,
143
139
  locale,
144
140
  organizationId,
@@ -151,25 +147,24 @@ export function MemberRequired({ organizationId, contactEmail, children, message
151
147
  const locale = auth?.locale;
152
148
  const refreshAuth = auth?.refreshAuth;
153
149
  const session = useAtomSuspense(authSessionAtom(baseUrl), {
154
- suspendOnWaiting: true,
150
+ suspendOnWaiting: false,
155
151
  }).value;
156
152
  const userId = session?.user.id;
157
153
  const currentAccessKey = accessAtomKey({
158
- authRefreshVersion,
159
154
  baseUrl,
160
155
  locale,
161
156
  organizationId,
162
157
  userId,
163
158
  });
164
- const [allowedAccessKey, setAllowedAccessKey] = useState(null);
165
- if (allowedAccessKey === currentAccessKey)
166
- return _jsx(_Fragment, { children: children });
167
- return (_jsx(MemberRequiredGate, { accessKey: currentAccessKey, baseUrl: baseUrl, contactEmail: contactEmail, locale: locale, messages: messages, onAccessAllowed: () => setAllowedAccessKey(currentAccessKey), organizationId: organizationId, refreshAuth: refreshAuth, children: children }));
159
+ return (_jsx(MemberRequiredGate, { accessKey: currentAccessKey, authRefreshVersion: authRefreshVersion, baseUrl: baseUrl, contactEmail: contactEmail, locale: locale, messages: messages, organizationId: organizationId, refreshAuth: refreshAuth, children: children }));
168
160
  }
169
- function MemberRequiredGate({ accessKey, baseUrl, contactEmail, children, locale, messages, onAccessAllowed, organizationId, refreshAuth, }) {
161
+ function MemberRequiredGate({ accessKey, authRefreshVersion, baseUrl, contactEmail, children, locale, messages, organizationId, refreshAuth, }) {
170
162
  const m = labels(locale, messages);
171
- const accessResult = useAtomSuspense(accessAtom(baseUrl)(accessKey), {
172
- suspendOnWaiting: true,
163
+ const queryAtom = accessAtom(baseUrl)(accessKey);
164
+ const refreshAccess = useAtomRefresh(queryAtom);
165
+ const lastAuthRefreshVersion = useRef(authRefreshVersion);
166
+ const accessResult = useAtomSuspense(queryAtom, {
167
+ suspendOnWaiting: false,
173
168
  });
174
169
  const acceptInvitationMutation = useAtomSet(acceptInvitationAtom(baseUrl));
175
170
  const [accepting, setAccepting] = useState(false);
@@ -177,10 +172,11 @@ function MemberRequiredGate({ accessKey, baseUrl, contactEmail, children, locale
177
172
  const access = accessResult.value;
178
173
  const invitationNow = useInvitationExpirationClock(access.allowed || !access.invitation ? [] : [access.invitation]);
179
174
  useEffect(() => {
180
- if (!access.allowed)
175
+ if (lastAuthRefreshVersion.current === authRefreshVersion)
181
176
  return;
182
- onAccessAllowed();
183
- }, [access.allowed, onAccessAllowed]);
177
+ lastAuthRefreshVersion.current = authRefreshVersion;
178
+ refreshAccess();
179
+ }, [authRefreshVersion, refreshAccess]);
184
180
  if (access.allowed)
185
181
  return _jsx(_Fragment, { children: children });
186
182
  const { invitation, organization } = access;
@@ -204,8 +200,10 @@ function MemberRequiredGate({ accessKey, baseUrl, contactEmail, children, locale
204
200
  : m.member_required_accept_error);
205
201
  },
206
202
  onSuccess: () => {
207
- refreshAuth?.();
208
- onAccessAllowed();
203
+ if (refreshAuth)
204
+ refreshAuth();
205
+ else
206
+ refreshAccess();
209
207
  setAccepting(false);
210
208
  },
211
209
  });
@@ -85,13 +85,14 @@ declare const messages: {
85
85
  readonly organization_role_owner: "Owner";
86
86
  readonly organization_role_support: "Support";
87
87
  readonly organization_slug: "Slug";
88
+ readonly organization_slug_identifier_description: "A unique, URL-friendly identifier for your organization.";
88
89
  readonly organization_slug_description: "Leave blank to generate one from the name.";
89
90
  readonly organization_switcher_empty: "You do not belong to any organizations yet.";
90
91
  readonly organization_switcher_label: "Organization";
91
92
  readonly organization_switcher_manage: "Manage organization";
92
93
  readonly organization_switcher_no_other_organizations: "No other organizations.";
93
94
  readonly organization_switcher_personal: "Personal";
94
- readonly organization_translation_description: "Localized organization details stored in metadata.";
95
+ readonly organization_translation_description: "Customize your organization’s name, logo, and icon for each language.";
95
96
  readonly organization_translation_name: "Name";
96
97
  readonly organization_update_error: "Could not update the organization.";
97
98
  readonly table_empty: "No results.";
@@ -223,13 +224,14 @@ declare const messages: {
223
224
  readonly organization_role_owner: "Propriétaire";
224
225
  readonly organization_role_support: "Support";
225
226
  readonly organization_slug: "Slug";
227
+ readonly organization_slug_identifier_description: "Un identifiant unique pour votre organisation, adapté aux URL.";
226
228
  readonly organization_slug_description: "Laissez vide pour en générer un à partir du nom.";
227
229
  readonly organization_switcher_empty: "Vous n'appartenez encore à aucune organisation.";
228
230
  readonly organization_switcher_label: "Organisation";
229
231
  readonly organization_switcher_manage: "Gérer l'organisation";
230
232
  readonly organization_switcher_no_other_organizations: "Aucune autre organisation.";
231
233
  readonly organization_switcher_personal: "Personnel";
232
- readonly organization_translation_description: "Détails localisés de l'organisation stockés dans les métadonnées.";
234
+ readonly organization_translation_description: "Personnalisez le nom, le logo et l’icône de votre organisation pour chaque langue.";
233
235
  readonly organization_translation_name: "Nom";
234
236
  readonly organization_update_error: "Impossible de mettre à jour l'organisation.";
235
237
  readonly table_empty: "Aucun résultat.";