better-auth 1.6.22 → 1.6.24
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/adapters/index.d.mts +1 -6
- package/dist/api/dispatch.d.mts +0 -1
- package/dist/api/index.d.mts +476 -478
- package/dist/api/middlewares/authorization.d.mts +12 -8
- package/dist/api/middlewares/authorization.mjs +2 -1
- package/dist/api/middlewares/index.d.mts +2 -1
- package/dist/api/middlewares/origin-check.d.mts +3 -5
- package/dist/api/routes/account.d.mts +10 -13
- package/dist/api/routes/account.mjs +35 -7
- package/dist/api/routes/callback.d.mts +1 -3
- package/dist/api/routes/callback.mjs +4 -0
- package/dist/api/routes/email-verification.d.mts +4 -8
- package/dist/api/routes/email-verification.mjs +15 -2
- package/dist/api/routes/error.d.mts +1 -3
- package/dist/api/routes/index.d.mts +2 -1
- package/dist/api/routes/ok.d.mts +1 -3
- package/dist/api/routes/password.d.mts +7 -9
- package/dist/api/routes/password.mjs +14 -1
- package/dist/api/routes/session.d.mts +22 -24
- package/dist/api/routes/session.mjs +5 -1
- package/dist/api/routes/sign-in.d.mts +3 -5
- package/dist/api/routes/sign-in.mjs +84 -2
- package/dist/api/routes/sign-out.d.mts +1 -3
- package/dist/api/routes/sign-up.d.mts +3 -4
- package/dist/api/routes/sign-up.mjs +3 -2
- package/dist/api/routes/update-session.d.mts +3 -4
- package/dist/api/routes/update-user.d.mts +13 -14
- package/dist/api/routes/update-user.mjs +26 -1
- package/dist/auth/full.d.mts +1 -1
- package/dist/auth/minimal.d.mts +1 -1
- package/dist/client/config.d.mts +12 -14
- package/dist/client/config.mjs +2 -2
- package/dist/client/equality.d.mts +0 -1
- package/dist/client/index.d.mts +6 -5
- package/dist/client/lynx/index.d.mts +4 -5
- package/dist/client/lynx/lynx-store.d.mts +1 -2
- package/dist/client/parser.d.mts +7 -3
- package/dist/client/path-to-object.d.mts +3 -4
- package/dist/client/plugins/index.d.mts +2 -1
- package/dist/client/plugins/infer-plugin.d.mts +0 -1
- package/dist/client/query.d.mts +0 -1
- package/dist/client/query.mjs +38 -20
- package/dist/client/react/index.d.mts +4 -5
- package/dist/client/react/react-store.d.mts +1 -2
- package/dist/client/session-refresh.d.mts +0 -1
- package/dist/client/solid/index.d.mts +5 -6
- package/dist/client/svelte/index.d.mts +5 -6
- package/dist/client/types.d.mts +2 -2
- package/dist/client/vanilla.d.mts +2 -3
- package/dist/client/vue/index.d.mts +5 -6
- package/dist/context/create-context.mjs +3 -3
- package/dist/context/helpers.mjs +2 -2
- package/dist/cookies/cookie-utils.d.mts +1 -1
- package/dist/cookies/index.d.mts +6 -7
- package/dist/cookies/index.mjs +4 -0
- package/dist/cookies/session-store.d.mts +1 -0
- package/dist/cookies/session-store.mjs +6 -1
- package/dist/crypto/index.d.mts +2 -9
- package/dist/crypto/jwt.d.mts +0 -1
- package/dist/crypto/password.d.mts +1 -5
- package/dist/db/adapter-base.d.mts +0 -1
- package/dist/db/adapter-kysely.d.mts +0 -1
- package/dist/db/field-converter.d.mts +0 -1
- package/dist/db/field.d.mts +9 -10
- package/dist/db/get-migration.d.mts +0 -1
- package/dist/db/get-migration.mjs +8 -4
- package/dist/db/get-schema.d.mts +0 -1
- package/dist/db/internal-adapter.d.mts +0 -1
- package/dist/db/internal-adapter.mjs +61 -1
- package/dist/db/revoke-unproven-account-access.d.mts +0 -1
- package/dist/db/schema.d.mts +2 -2
- package/dist/db/to-zod.d.mts +3 -7
- package/dist/db/with-hooks.d.mts +0 -1
- package/dist/index.d.mts +4 -3
- package/dist/integrations/next-js.d.mts +4 -7
- package/dist/integrations/node.d.mts +2 -3
- package/dist/integrations/svelte-kit.d.mts +2 -9
- package/dist/integrations/tanstack-start-solid.d.mts +2 -5
- package/dist/integrations/tanstack-start.d.mts +2 -5
- package/dist/oauth2/link-account.d.mts +1 -1
- package/dist/oauth2/state.d.mts +0 -1
- package/dist/oauth2/utils.d.mts +0 -1
- package/dist/package.mjs +1 -1
- package/dist/plugins/access/access.d.mts +0 -1
- package/dist/plugins/access/types.d.mts +4 -5
- package/dist/plugins/additional-fields/client.d.mts +0 -1
- package/dist/plugins/admin/access/statement.d.mts +1 -0
- package/dist/plugins/admin/admin.d.mts +120 -125
- package/dist/plugins/admin/client.d.mts +30 -30
- package/dist/plugins/admin/client.mjs +1 -1
- package/dist/plugins/admin/error-codes.d.mts +23 -25
- package/dist/plugins/admin/index.d.mts +1 -1
- package/dist/plugins/admin/routes.mjs +9 -0
- package/dist/plugins/admin/schema.d.mts +1 -1
- package/dist/plugins/admin/types.d.mts +3 -2
- package/dist/plugins/anonymous/client.d.mts +9 -11
- package/dist/plugins/anonymous/client.mjs +1 -1
- package/dist/plugins/anonymous/error-codes.d.mts +8 -10
- package/dist/plugins/anonymous/index.d.mts +14 -18
- package/dist/plugins/anonymous/types.d.mts +1 -1
- package/dist/plugins/bearer/index.d.mts +4 -7
- package/dist/plugins/captcha/index.d.mts +5 -8
- package/dist/plugins/captcha/types.d.mts +0 -1
- package/dist/plugins/custom-session/client.d.mts +0 -1
- package/dist/plugins/custom-session/index.d.mts +7 -12
- package/dist/plugins/device-authorization/client.d.mts +0 -1
- package/dist/plugins/device-authorization/index.d.mts +19 -22
- package/dist/plugins/email-otp/client.d.mts +4 -6
- package/dist/plugins/email-otp/client.mjs +1 -1
- package/dist/plugins/email-otp/error-codes.d.mts +3 -5
- package/dist/plugins/email-otp/index.d.mts +67 -73
- package/dist/plugins/email-otp/routes.mjs +2 -0
- package/dist/plugins/email-otp/types.d.mts +0 -1
- package/dist/plugins/generic-oauth/client.d.mts +11 -11
- package/dist/plugins/generic-oauth/client.mjs +1 -1
- package/dist/plugins/generic-oauth/error-codes.d.mts +8 -10
- package/dist/plugins/generic-oauth/index.d.mts +41 -44
- package/dist/plugins/generic-oauth/index.mjs +2 -1
- package/dist/plugins/generic-oauth/providers/auth0.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/gumroad.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/hubspot.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/index.d.mts +3 -1
- package/dist/plugins/generic-oauth/providers/keycloak.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/line.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/microsoft-entra-id.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/okta.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/patreon.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/slack.d.mts +0 -1
- package/dist/plugins/generic-oauth/providers/yandex.d.mts +28 -0
- package/dist/plugins/generic-oauth/providers/yandex.mjs +60 -0
- package/dist/plugins/generic-oauth/routes.mjs +14 -0
- package/dist/plugins/generic-oauth/types.d.mts +1 -2
- package/dist/plugins/haveibeenpwned/index.d.mts +3 -6
- package/dist/plugins/index.d.mts +5 -1
- package/dist/plugins/index.mjs +2 -1
- package/dist/plugins/jwt/client.d.mts +2 -4
- package/dist/plugins/jwt/index.d.mts +8 -11
- package/dist/plugins/jwt/sign.d.mts +2 -2
- package/dist/plugins/jwt/types.d.mts +1 -1
- package/dist/plugins/jwt/utils.d.mts +2 -4
- package/dist/plugins/jwt/verify.d.mts +0 -1
- package/dist/plugins/last-login-method/client.mjs +13 -0
- package/dist/plugins/last-login-method/index.d.mts +11 -5
- package/dist/plugins/last-login-method/index.mjs +8 -0
- package/dist/plugins/magic-link/client.d.mts +0 -1
- package/dist/plugins/magic-link/index.d.mts +4 -5
- package/dist/plugins/magic-link/index.mjs +32 -1
- package/dist/plugins/mcp/authorize.mjs +12 -0
- package/dist/plugins/mcp/client/adapters.d.mts +0 -1
- package/dist/plugins/mcp/client/index.d.mts +2 -0
- package/dist/plugins/mcp/client/index.mjs +36 -11
- package/dist/plugins/mcp/index.d.mts +10 -11
- package/dist/plugins/multi-session/client.d.mts +2 -4
- package/dist/plugins/multi-session/client.mjs +1 -1
- package/dist/plugins/multi-session/error-codes.d.mts +1 -3
- package/dist/plugins/multi-session/index.d.mts +7 -11
- package/dist/plugins/multi-session/index.mjs +45 -0
- package/dist/plugins/oauth-popup/client.d.mts +6 -12
- package/dist/plugins/oauth-popup/client.mjs +5 -3
- package/dist/plugins/oauth-popup/error-codes.d.mts +4 -6
- package/dist/plugins/oauth-popup/index.d.mts +8 -12
- package/dist/plugins/oauth-popup/index.mjs +1 -1
- package/dist/plugins/oauth-popup/types.d.mts +1 -2
- package/dist/plugins/oauth-proxy/index.d.mts +6 -9
- package/dist/plugins/oauth-proxy/index.mjs +2 -2
- package/dist/plugins/oidc-provider/authorize.mjs +9 -0
- package/dist/plugins/oidc-provider/client.d.mts +1 -2
- package/dist/plugins/oidc-provider/index.d.mts +15 -17
- package/dist/plugins/oidc-provider/index.mjs +26 -2
- package/dist/plugins/oidc-provider/schema.d.mts +0 -1
- package/dist/plugins/oidc-provider/schema.mjs +37 -0
- package/dist/plugins/oidc-provider/types.d.mts +1 -1
- package/dist/plugins/one-tap/client.d.mts +3 -6
- package/dist/plugins/one-tap/client.mjs +3 -0
- package/dist/plugins/one-tap/index.d.mts +1 -3
- package/dist/plugins/one-tap/index.mjs +5 -0
- package/dist/plugins/one-time-token/client.d.mts +1 -2
- package/dist/plugins/one-time-token/index.d.mts +5 -6
- package/dist/plugins/one-time-token/index.mjs +30 -0
- package/dist/plugins/open-api/generator.d.mts +0 -1
- package/dist/plugins/open-api/generator.mjs +81 -5
- package/dist/plugins/open-api/index.d.mts +3 -5
- package/dist/plugins/organization/access/statement.d.mts +1 -0
- package/dist/plugins/organization/adapter.d.mts +56 -82
- package/dist/plugins/organization/adapter.mjs +17 -3
- package/dist/plugins/organization/client.d.mts +106 -105
- package/dist/plugins/organization/client.mjs +7 -4
- package/dist/plugins/organization/error-codes.d.mts +59 -61
- package/dist/plugins/organization/has-permission.d.mts +0 -1
- package/dist/plugins/organization/has-permission.mjs +1 -1
- package/dist/plugins/organization/index.d.mts +1 -1
- package/dist/plugins/organization/organization.d.mts +7 -7
- package/dist/plugins/organization/organization.mjs +434 -1
- package/dist/plugins/organization/permission.d.mts +2 -2
- package/dist/plugins/organization/routes/crud-access-control.d.mts +17 -17
- package/dist/plugins/organization/routes/crud-invites.d.mts +53 -54
- package/dist/plugins/organization/routes/crud-invites.mjs +1 -1
- package/dist/plugins/organization/routes/crud-members.d.mts +44 -46
- package/dist/plugins/organization/routes/crud-members.mjs +4 -1
- package/dist/plugins/organization/routes/crud-org.d.mts +47 -48
- package/dist/plugins/organization/routes/crud-org.mjs +2 -2
- package/dist/plugins/organization/routes/crud-team.d.mts +50 -51
- package/dist/plugins/organization/schema.d.mts +4 -4
- package/dist/plugins/organization/schema.mjs +1 -1
- package/dist/plugins/organization/types.d.mts +16 -16
- package/dist/plugins/phone-number/client.d.mts +13 -15
- package/dist/plugins/phone-number/client.mjs +1 -1
- package/dist/plugins/phone-number/error-codes.d.mts +12 -14
- package/dist/plugins/phone-number/index.d.mts +41 -47
- package/dist/plugins/phone-number/routes.mjs +15 -0
- package/dist/plugins/phone-number/types.d.mts +1 -1
- package/dist/plugins/siwe/client.d.mts +0 -1
- package/dist/plugins/siwe/index.d.mts +4 -5
- package/dist/plugins/test-utils/index.d.mts +2 -4
- package/dist/plugins/test-utils/types.d.mts +1 -0
- package/dist/plugins/two-factor/backup-codes/index.d.mts +4 -6
- package/dist/plugins/two-factor/backup-codes/index.mjs +52 -1
- package/dist/plugins/two-factor/client.d.mts +12 -15
- package/dist/plugins/two-factor/client.mjs +1 -1
- package/dist/plugins/two-factor/error-code.d.mts +10 -12
- package/dist/plugins/two-factor/index.d.mts +27 -31
- package/dist/plugins/two-factor/index.mjs +30 -0
- package/dist/plugins/two-factor/otp/index.d.mts +2 -4
- package/dist/plugins/two-factor/otp/index.mjs +42 -1
- package/dist/plugins/two-factor/totp/index.d.mts +4 -6
- package/dist/plugins/two-factor/totp/index.mjs +47 -0
- package/dist/plugins/two-factor/types.d.mts +1 -1
- package/dist/plugins/username/client.d.mts +9 -11
- package/dist/plugins/username/client.mjs +1 -1
- package/dist/plugins/username/error-codes.d.mts +8 -10
- package/dist/plugins/username/index.d.mts +17 -22
- package/dist/plugins/username/schema.d.mts +3 -5
- package/dist/state.d.mts +0 -1
- package/dist/state.mjs +4 -0
- package/dist/test-utils/test-instance.d.mts +5 -3
- package/dist/test-utils/test-instance.mjs +4 -1
- package/dist/types/adapter.d.mts +1 -1
- package/dist/types/api.d.mts +1 -2
- package/dist/types/auth.d.mts +0 -1
- package/dist/types/helper.d.mts +5 -5
- package/dist/types/index.d.mts +2 -2
- package/dist/types/models.d.mts +0 -1
- package/dist/types/plugins.d.mts +2 -3
- package/dist/utils/index.d.mts +2 -1
- package/dist/utils/request.mjs +23 -0
- package/dist/utils/url.d.mts +0 -1
- package/package.json +10 -10
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { FieldAttributeToObject, InferAdditionalFieldsFromPluginOptions, RemoveFieldsWithReturnedFalse } from "../../db/field.mjs";
|
|
2
|
-
import { User
|
|
2
|
+
import { User } from "../../types/models.mjs";
|
|
3
|
+
import "../../types/index.mjs";
|
|
4
|
+
import "../../db/index.mjs";
|
|
3
5
|
import { OrganizationOptions } from "./types.mjs";
|
|
4
6
|
import { InferInvitation, InferMember, InferOrganization, InferOrganizationRolesFromOption, InferTeam, InvitationStatus, MemberInput, OrganizationInput, TeamInput, TeamMember } from "./schema.mjs";
|
|
5
7
|
import { AuthContext, GenericEndpointContext } from "@better-auth/core";
|
|
6
|
-
import * as _better_auth_core_db0 from "@better-auth/core/db";
|
|
7
8
|
import { WhereOperator } from "@better-auth/core/db/adapter";
|
|
8
|
-
|
|
9
9
|
//#region src/plugins/organization/adapter.d.ts
|
|
10
10
|
declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContext, options?: O | undefined) => {
|
|
11
11
|
findOrganizationBySlug: (slug: string) => Promise<InferOrganization<O> | null>;
|
|
@@ -44,9 +44,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
44
44
|
};
|
|
45
45
|
}) & (O["schema"] extends {
|
|
46
46
|
member?: {
|
|
47
|
-
additionalFields: infer Field extends Record<string,
|
|
47
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
48
48
|
} | undefined;
|
|
49
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) & {
|
|
49
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) & {
|
|
50
50
|
user: {
|
|
51
51
|
id: string;
|
|
52
52
|
name: string;
|
|
@@ -95,9 +95,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
95
95
|
};
|
|
96
96
|
}) & (O["schema"] extends {
|
|
97
97
|
member?: {
|
|
98
|
-
additionalFields: infer Field extends Record<string,
|
|
98
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
99
99
|
} | undefined;
|
|
100
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) & {
|
|
100
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) & {
|
|
101
101
|
user: {
|
|
102
102
|
id: string;
|
|
103
103
|
name: string;
|
|
@@ -139,10 +139,10 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
139
139
|
};
|
|
140
140
|
}) & (O["schema"] extends {
|
|
141
141
|
member?: {
|
|
142
|
-
additionalFields: infer Field extends Record<string,
|
|
142
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
143
143
|
} | undefined;
|
|
144
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) & {
|
|
145
|
-
user: User
|
|
144
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) & {
|
|
145
|
+
user: User;
|
|
146
146
|
}, "user"> & {
|
|
147
147
|
user: {
|
|
148
148
|
id: string;
|
|
@@ -180,9 +180,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
180
180
|
};
|
|
181
181
|
}) & (O["schema"] extends {
|
|
182
182
|
member?: {
|
|
183
|
-
additionalFields: infer Field extends Record<string,
|
|
183
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
184
184
|
} | undefined;
|
|
185
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) & {
|
|
185
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) & {
|
|
186
186
|
user: {
|
|
187
187
|
id: string;
|
|
188
188
|
name: string;
|
|
@@ -226,14 +226,10 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
226
226
|
};
|
|
227
227
|
}) & (O["schema"] extends {
|
|
228
228
|
member?: {
|
|
229
|
-
additionalFields: infer Field extends Record<string,
|
|
229
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
230
230
|
} | undefined;
|
|
231
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) | null>;
|
|
232
|
-
deleteMember: ({
|
|
233
|
-
memberId,
|
|
234
|
-
organizationId,
|
|
235
|
-
userId: _userId
|
|
236
|
-
}: {
|
|
231
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) | null>;
|
|
232
|
+
deleteMember: ({ memberId, organizationId, userId: _userId }: {
|
|
237
233
|
memberId: string;
|
|
238
234
|
organizationId: string;
|
|
239
235
|
userId?: string;
|
|
@@ -251,10 +247,7 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
251
247
|
userAgent?: string | null | undefined;
|
|
252
248
|
}>;
|
|
253
249
|
findOrganizationById: (organizationId: string) => Promise<InferOrganization<O> | null>;
|
|
254
|
-
checkMembership: ({
|
|
255
|
-
userId,
|
|
256
|
-
organizationId
|
|
257
|
-
}: {
|
|
250
|
+
checkMembership: ({ userId, organizationId }: {
|
|
258
251
|
userId: string;
|
|
259
252
|
organizationId: string;
|
|
260
253
|
}) => Promise<((O["teams"] extends {
|
|
@@ -286,18 +279,13 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
286
279
|
};
|
|
287
280
|
}) & (O["schema"] extends {
|
|
288
281
|
member?: {
|
|
289
|
-
additionalFields: infer Field extends Record<string,
|
|
282
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
290
283
|
} | undefined;
|
|
291
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) | null>;
|
|
284
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) | null>;
|
|
292
285
|
/**
|
|
293
286
|
* @requires db
|
|
294
287
|
*/
|
|
295
|
-
findFullOrganization: ({
|
|
296
|
-
organizationId,
|
|
297
|
-
isSlug,
|
|
298
|
-
includeTeams,
|
|
299
|
-
membersLimit
|
|
300
|
-
}: {
|
|
288
|
+
findFullOrganization: ({ organizationId, isSlug, includeTeams, membersLimit }: {
|
|
301
289
|
organizationId: string;
|
|
302
290
|
isSlug?: boolean | undefined;
|
|
303
291
|
includeTeams?: boolean | undefined;
|
|
@@ -311,9 +299,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
311
299
|
metadata?: any;
|
|
312
300
|
} & (O["schema"] extends {
|
|
313
301
|
organization?: {
|
|
314
|
-
additionalFields: infer Field extends Record<string,
|
|
302
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
315
303
|
} | undefined;
|
|
316
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) & {
|
|
304
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) & {
|
|
317
305
|
invitation: InferInvitation<O>[];
|
|
318
306
|
member: InferMember<O>[];
|
|
319
307
|
team: InferTeam<O>[] | undefined;
|
|
@@ -341,9 +329,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
341
329
|
createdAt: Date;
|
|
342
330
|
}) & (O["schema"] extends {
|
|
343
331
|
invitation?: {
|
|
344
|
-
additionalFields: infer Field extends Record<string,
|
|
332
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
345
333
|
} | undefined;
|
|
346
|
-
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends infer T_1 ? { [K_1 in keyof T_1]: T_1[K_1] } : never)[];
|
|
334
|
+
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends (infer T_1) ? { [K_1 in keyof T_1]: T_1[K_1]; } : never)[];
|
|
347
335
|
members: (((O["teams"] extends {
|
|
348
336
|
enabled: true;
|
|
349
337
|
} ? {
|
|
@@ -373,9 +361,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
373
361
|
};
|
|
374
362
|
}) & (O["schema"] extends {
|
|
375
363
|
member?: {
|
|
376
|
-
additionalFields: infer Field extends Record<string,
|
|
364
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
377
365
|
} | undefined;
|
|
378
|
-
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends infer T_2 ? { [K_2 in keyof T_2]: T_2[K_2] } : never) & {
|
|
366
|
+
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends (infer T_2) ? { [K_2 in keyof T_2]: T_2[K_2]; } : never) & {
|
|
379
367
|
user: {
|
|
380
368
|
id: string;
|
|
381
369
|
name: string;
|
|
@@ -391,9 +379,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
391
379
|
updatedAt?: Date | undefined;
|
|
392
380
|
} & (O["schema"] extends {
|
|
393
381
|
team?: {
|
|
394
|
-
additionalFields: infer Field extends Record<string,
|
|
382
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
395
383
|
} | undefined;
|
|
396
|
-
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends infer T_3 ? { [K_3 in keyof T_3]: T_3[K_3] } : never)[] | undefined;
|
|
384
|
+
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends (infer T_3) ? { [K_3 in keyof T_3]: T_3[K_3]; } : never)[] | undefined;
|
|
397
385
|
}) | null>;
|
|
398
386
|
listOrganizations: (userId: string) => Promise<InferOrganization<O>[]>;
|
|
399
387
|
createTeam: (data: TeamInput) => Promise<{
|
|
@@ -404,14 +392,10 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
404
392
|
updatedAt?: Date | undefined;
|
|
405
393
|
} & (O["schema"] extends {
|
|
406
394
|
team?: {
|
|
407
|
-
additionalFields: infer Field extends Record<string,
|
|
395
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
408
396
|
} | undefined;
|
|
409
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never>;
|
|
410
|
-
findTeamById: <IncludeMembers extends boolean>({
|
|
411
|
-
teamId,
|
|
412
|
-
organizationId,
|
|
413
|
-
includeTeamMembers
|
|
414
|
-
}: {
|
|
397
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never>;
|
|
398
|
+
findTeamById: <IncludeMembers extends boolean>({ teamId, organizationId, includeTeamMembers }: {
|
|
415
399
|
teamId: string;
|
|
416
400
|
organizationId?: string | undefined;
|
|
417
401
|
includeTeamMembers?: IncludeMembers | undefined;
|
|
@@ -430,9 +414,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
430
414
|
updatedAt?: Date | undefined;
|
|
431
415
|
} & (O["schema"] extends {
|
|
432
416
|
team?: {
|
|
433
|
-
additionalFields: infer Field extends Record<string,
|
|
417
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
434
418
|
} | undefined;
|
|
435
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) & InferAdditionalFieldsFromPluginOptions<"team", O>) | null>;
|
|
419
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) & InferAdditionalFieldsFromPluginOptions<"team", O>) | null>;
|
|
436
420
|
deleteTeam: (teamId: string) => Promise<void>;
|
|
437
421
|
listTeams: (organizationId: string) => Promise<({
|
|
438
422
|
id: string;
|
|
@@ -442,17 +426,10 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
442
426
|
updatedAt?: Date | undefined;
|
|
443
427
|
} & (O["schema"] extends {
|
|
444
428
|
team?: {
|
|
445
|
-
additionalFields: infer Field extends Record<string,
|
|
429
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
446
430
|
} | undefined;
|
|
447
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never)[]>;
|
|
448
|
-
createTeamInvitation: ({
|
|
449
|
-
email,
|
|
450
|
-
role,
|
|
451
|
-
teamId,
|
|
452
|
-
organizationId,
|
|
453
|
-
inviterId,
|
|
454
|
-
expiresIn
|
|
455
|
-
}: {
|
|
431
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never)[]>;
|
|
432
|
+
createTeamInvitation: ({ email, role, teamId, organizationId, inviterId, expiresIn }: {
|
|
456
433
|
email: string;
|
|
457
434
|
role: string;
|
|
458
435
|
teamId: string;
|
|
@@ -482,9 +459,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
482
459
|
createdAt: Date;
|
|
483
460
|
}) & (O["schema"] extends {
|
|
484
461
|
invitation?: {
|
|
485
|
-
additionalFields: infer Field extends Record<string,
|
|
462
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
486
463
|
} | undefined;
|
|
487
|
-
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends infer T ? { [K in keyof T]: T[K] } : never>;
|
|
464
|
+
} ? FieldAttributeToObject<RemoveFieldsWithReturnedFalse<Field>> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never>;
|
|
488
465
|
setActiveTeam: (sessionToken: string, teamId: string | null, ctx: GenericEndpointContext) => Promise<{
|
|
489
466
|
id: string;
|
|
490
467
|
createdAt: Date;
|
|
@@ -585,9 +562,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
585
562
|
createdAt: Date;
|
|
586
563
|
}) & (O["schema"] extends {
|
|
587
564
|
invitation?: {
|
|
588
|
-
additionalFields: infer Field extends Record<string,
|
|
565
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
589
566
|
} | undefined;
|
|
590
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never)[]>;
|
|
567
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never)[]>;
|
|
591
568
|
listUserInvitations: (email: string) => Promise<(Omit<((O["teams"] extends {
|
|
592
569
|
enabled: true;
|
|
593
570
|
} ? {
|
|
@@ -611,9 +588,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
611
588
|
createdAt: Date;
|
|
612
589
|
}) & (O["schema"] extends {
|
|
613
590
|
invitation?: {
|
|
614
|
-
additionalFields: infer Field extends Record<string,
|
|
591
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
615
592
|
} | undefined;
|
|
616
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) & {
|
|
593
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) & {
|
|
617
594
|
organization: InferOrganization<O, false>;
|
|
618
595
|
}, "organization"> & {
|
|
619
596
|
organizationName: ({
|
|
@@ -625,21 +602,18 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
625
602
|
metadata?: any;
|
|
626
603
|
} & (O["schema"] extends {
|
|
627
604
|
organization?: {
|
|
628
|
-
additionalFields: infer Field extends Record<string,
|
|
605
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
629
606
|
} | undefined;
|
|
630
607
|
} ? FieldAttributeToObject<Field> : {}))["name"];
|
|
631
608
|
})[]>;
|
|
632
|
-
createInvitation: ({
|
|
633
|
-
invitation,
|
|
634
|
-
user
|
|
635
|
-
}: {
|
|
609
|
+
createInvitation: ({ invitation, user }: {
|
|
636
610
|
invitation: {
|
|
637
611
|
email: string;
|
|
638
612
|
role: string;
|
|
639
613
|
organizationId: string;
|
|
640
614
|
teamIds: string[];
|
|
641
615
|
} & Record<string, any>;
|
|
642
|
-
user: User
|
|
616
|
+
user: User;
|
|
643
617
|
}) => Promise<(O["teams"] extends {
|
|
644
618
|
enabled: true;
|
|
645
619
|
} ? {
|
|
@@ -663,9 +637,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
663
637
|
createdAt: Date;
|
|
664
638
|
}) & (O["schema"] extends {
|
|
665
639
|
invitation?: {
|
|
666
|
-
additionalFields: infer Field extends Record<string,
|
|
640
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
667
641
|
} | undefined;
|
|
668
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never>;
|
|
642
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never>;
|
|
669
643
|
findInvitationById: (id: string) => Promise<((O["teams"] extends {
|
|
670
644
|
enabled: true;
|
|
671
645
|
} ? {
|
|
@@ -689,9 +663,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
689
663
|
createdAt: Date;
|
|
690
664
|
}) & (O["schema"] extends {
|
|
691
665
|
invitation?: {
|
|
692
|
-
additionalFields: infer Field extends Record<string,
|
|
666
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
693
667
|
} | undefined;
|
|
694
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) | null>;
|
|
668
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) | null>;
|
|
695
669
|
findPendingInvitation: (data: {
|
|
696
670
|
email: string;
|
|
697
671
|
organizationId: string;
|
|
@@ -718,9 +692,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
718
692
|
createdAt: Date;
|
|
719
693
|
}) & (O["schema"] extends {
|
|
720
694
|
invitation?: {
|
|
721
|
-
additionalFields: infer Field extends Record<string,
|
|
695
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
722
696
|
} | undefined;
|
|
723
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never)[]>;
|
|
697
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never)[]>;
|
|
724
698
|
findPendingInvitations: (data: {
|
|
725
699
|
organizationId: string;
|
|
726
700
|
}) => Promise<((O["teams"] extends {
|
|
@@ -746,9 +720,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
746
720
|
createdAt: Date;
|
|
747
721
|
}) & (O["schema"] extends {
|
|
748
722
|
invitation?: {
|
|
749
|
-
additionalFields: infer Field extends Record<string,
|
|
723
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
750
724
|
} | undefined;
|
|
751
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never)[]>;
|
|
725
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never)[]>;
|
|
752
726
|
listInvitations: (data: {
|
|
753
727
|
organizationId: string;
|
|
754
728
|
}) => Promise<((O["teams"] extends {
|
|
@@ -774,9 +748,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
774
748
|
createdAt: Date;
|
|
775
749
|
}) & (O["schema"] extends {
|
|
776
750
|
invitation?: {
|
|
777
|
-
additionalFields: infer Field extends Record<string,
|
|
751
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
778
752
|
} | undefined;
|
|
779
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never)[]>;
|
|
753
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never)[]>;
|
|
780
754
|
updateInvitation: (data: {
|
|
781
755
|
invitationId: string;
|
|
782
756
|
status: "pending" | "accepted" | "canceled" | "rejected";
|
|
@@ -809,9 +783,9 @@ declare const getOrgAdapter: <O extends OrganizationOptions>(context: AuthContex
|
|
|
809
783
|
createdAt: Date;
|
|
810
784
|
}) & (O["schema"] extends {
|
|
811
785
|
invitation?: {
|
|
812
|
-
additionalFields: infer Field extends Record<string,
|
|
786
|
+
additionalFields: infer Field extends Record<string, import("@better-auth/core/db").DBFieldAttribute>;
|
|
813
787
|
} | undefined;
|
|
814
|
-
} ? FieldAttributeToObject<Field> : {}) extends infer T ? { [K in keyof T]: T[K] } : never) | null>;
|
|
788
|
+
} ? FieldAttributeToObject<Field> : {}) extends (infer T) ? { [K in keyof T]: T[K]; } : never) | null>;
|
|
815
789
|
};
|
|
816
790
|
//#endregion
|
|
817
791
|
export { getOrgAdapter };
|
|
@@ -117,7 +117,8 @@ const getOrgAdapter = (context, options) => {
|
|
|
117
117
|
field: "id",
|
|
118
118
|
value: members[0].map((member) => member.userId),
|
|
119
119
|
operator: "in"
|
|
120
|
-
}]
|
|
120
|
+
}],
|
|
121
|
+
limit: members[0].length
|
|
121
122
|
});
|
|
122
123
|
return {
|
|
123
124
|
members: members[0].map((member) => {
|
|
@@ -314,6 +315,9 @@ const getOrgAdapter = (context, options) => {
|
|
|
314
315
|
}]
|
|
315
316
|
});
|
|
316
317
|
},
|
|
318
|
+
/**
|
|
319
|
+
* @requires db
|
|
320
|
+
*/
|
|
317
321
|
findFullOrganization: async ({ organizationId, isSlug, includeTeams, membersLimit }) => {
|
|
318
322
|
const adapter = await getCurrentAdapter(baseAdapter);
|
|
319
323
|
const result = await adapter.findOne({
|
|
@@ -530,6 +534,18 @@ const getOrgAdapter = (context, options) => {
|
|
|
530
534
|
}
|
|
531
535
|
});
|
|
532
536
|
},
|
|
537
|
+
/**
|
|
538
|
+
* Adds a user to a team only when the team is below its member limit,
|
|
539
|
+
* reading the count and creating the membership in one transaction.
|
|
540
|
+
* Returns the existing membership unchanged (no capacity charge) when the
|
|
541
|
+
* user already belongs to the team.
|
|
542
|
+
*
|
|
543
|
+
* FIXME(team-cap-race): the count-then-create is not atomic under READ
|
|
544
|
+
* COMMITTED, so two concurrent adds can both pass the count check and
|
|
545
|
+
* exceed maximumMembersPerTeam. A durable fix needs a unique constraint on
|
|
546
|
+
* teamMember(teamId, userId) or serializable isolation. Affects every
|
|
547
|
+
* caller (acceptInvitation, addMember, addTeamMember).
|
|
548
|
+
*/
|
|
533
549
|
addTeamMemberWithLimit: async (data) => {
|
|
534
550
|
return runWithTransaction(baseAdapter, async () => {
|
|
535
551
|
const adapter = await getCurrentAdapter(baseAdapter);
|
|
@@ -604,11 +620,9 @@ const getOrgAdapter = (context, options) => {
|
|
|
604
620
|
createInvitation: async ({ invitation, user }) => {
|
|
605
621
|
const adapter = await getCurrentAdapter(baseAdapter);
|
|
606
622
|
const expiresAt = getDate(options?.invitationExpiresIn || 3600 * 48, "sec");
|
|
607
|
-
const invitationId = context.generateId({ model: "invitation" });
|
|
608
623
|
return await adapter.create({
|
|
609
624
|
model: "invitation",
|
|
610
625
|
data: {
|
|
611
|
-
...invitationId !== false ? { id: invitationId } : {},
|
|
612
626
|
status: "pending",
|
|
613
627
|
expiresAt,
|
|
614
628
|
createdAt: /* @__PURE__ */ new Date(),
|