@protobase/server 0.123.6 → 0.124.0
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/better-auth/auth-settings.d.ts +37 -6
- package/dist/better-auth/create-auth.d.ts +49 -31
- package/dist/better-auth/create-auth.js +14 -5
- package/dist/better-auth/last-admin.js +1 -1
- package/dist/better-auth/mcp/mcp-auth-plugins.d.ts +2 -2
- package/dist/better-auth/names/modules/index.d.ts +51 -1
- package/dist/better-auth/names/modules/mail-senders.js +36 -2
- package/dist/better-auth/names/resolve-names.d.ts +1 -1
- package/dist/better-auth/openid-provider/openid-provider-plugins.d.ts +1 -1
- package/dist/better-auth/organizations/accept-invitation.js +1 -1
- package/dist/better-auth/organizations/add-every-user.js +1 -1
- package/dist/better-auth/organizations/host.js +1 -1
- package/dist/better-auth/organizations/options.d.ts +1 -1
- package/dist/better-auth/staff-checks.js +2 -1
- package/dist/better-auth/status-route.js +3 -2
- package/dist/better-auth/store/steps/index.js +6 -1
- package/dist/better-auth/store/steps/legacy-versions.js +4 -0
- package/dist/better-auth/store/steps/mail-senders/003-sender-address-evidence.js +81 -0
- package/dist/better-auth/store/store-sql.d.ts +3 -0
- package/dist/better-auth/users.js +1 -1
- package/dist/functions/define-function.d.ts +7 -5
- package/dist/functions/own-mailbox.js +2 -1
- package/dist/functions/routes.js +2 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.js +3 -1
- package/dist/package.js +1 -1
- package/dist/personal-mail/alias-checks.js +2 -2
- package/dist/personal-mail/gmail-errors.js +22 -0
- package/dist/personal-mail/gmail-sender-addresses.d.ts +4 -0
- package/dist/personal-mail/gmail-sender-addresses.js +74 -0
- package/dist/personal-mail/gmail.js +9 -22
- package/dist/personal-mail/listed-mail-senders.d.ts +31 -0
- package/dist/personal-mail/listed-mail-senders.js +30 -0
- package/dist/personal-mail/mail-sender-book.js +28 -0
- package/dist/personal-mail/mail-sender.d.ts +9 -3
- package/dist/personal-mail/mail-sender.js +43 -32
- package/dist/personal-mail/mail-senders-plugin.js +92 -78
- package/dist/personal-mail/mailbox-connections.d.ts +1 -0
- package/dist/personal-mail/mailbox-connections.js +11 -0
- package/dist/personal-mail/personal-mail-provider.d.ts +32 -0
- package/dist/personal-mail/personal-mail-provider.js +7 -0
- package/dist/personal-mail/personal-mail-providers.d.ts +9 -0
- package/dist/personal-mail/personal-mail-providers.js +12 -5
- package/dist/personal-mail/personal-mailer.d.ts +18 -9
- package/dist/personal-mail/personal-mailer.js +62 -20
- package/dist/personal-mail/sender-address-error.d.ts +21 -0
- package/dist/personal-mail/sender-address-error.js +27 -0
- package/dist/personal-mail/sender-address-input.js +15 -0
- package/dist/personal-mail/sender-address-state.d.ts +12 -0
- package/dist/personal-mail/sender-address-state.js +20 -0
- package/dist/personal-mail/sender-listing.d.ts +22 -0
- package/dist/personal-mail/sender-listing.js +66 -0
- package/dist/personal-mail/sender-store.d.ts +1 -1
- package/dist/personal-mail/sender-store.js +86 -55
- package/dist/webhooks/table/owner-roles.js +1 -1
- package/package.json +6 -6
- package/dist/personal-mail/mail-senders-plugin.d.ts +0 -14
|
@@ -5,19 +5,20 @@ import { Revocation } from "./connections/disconnect-account.js";
|
|
|
5
5
|
import { StaffSignIn } from "./staff-log.js";
|
|
6
6
|
import { Person } from "./organizations/people-endpoint.js";
|
|
7
7
|
import { PersonalAccessToken } from "./personal-access-tokens/token-store.js";
|
|
8
|
+
import { ResolvedNames } from "./names/resolve-names.js";
|
|
9
|
+
import { OrganizationRole, StoredMember, StoredOrganization } from "./organizations/store.js";
|
|
8
10
|
import { Mailer } from "../mail/mail-message.js";
|
|
9
11
|
import { PersonalMailProvider } from "../personal-mail/personal-mail-provider.js";
|
|
12
|
+
import { ListedConnection, ListedMailSender } from "../personal-mail/listed-mail-senders.js";
|
|
13
|
+
import { ConnectionListing } from "../personal-mail/sender-listing.js";
|
|
10
14
|
import { PersonalMail } from "../personal-mail/personal-mailer.js";
|
|
11
15
|
import { AliasCheckResult } from "../personal-mail/alias-checks.js";
|
|
12
|
-
import { ResolvedNames } from "./names/resolve-names.js";
|
|
13
|
-
import { FindMailSenderUse } from "../personal-mail/mail-sender-use.js";
|
|
14
|
-
import { ListedMailSender } from "../personal-mail/mail-senders-plugin.js";
|
|
15
16
|
import { RoleDefinitions } from "./organizations/role-definitions.js";
|
|
16
17
|
import { ConnectedApp } from "./mcp/connected-apps.js";
|
|
17
18
|
import { OperatorClient } from "./openid-provider/operator-clients.js";
|
|
18
19
|
import { VersionedSecret } from "./secret-versions.js";
|
|
19
20
|
import { UserDeletionListener } from "./user-deletion.js";
|
|
20
|
-
import {
|
|
21
|
+
import { FindMailSenderUse } from "../personal-mail/mail-sender-use.js";
|
|
21
22
|
import { SignInPolicy } from "./sign-in-policy.js";
|
|
22
23
|
import { McpAuthOptions } from "./mcp/mcp-plugins.js";
|
|
23
24
|
import { OAuthApiResource } from "./oauth-api.js";
|
|
@@ -6362,8 +6363,9 @@ export declare const buildAppAuth: (settings: AuthSettings, input: AppAuthInput)
|
|
|
6362
6363
|
};
|
|
6363
6364
|
}>>[];
|
|
6364
6365
|
}, {
|
|
6365
|
-
senders: ListedMailSender[];
|
|
6366
6366
|
checks: boolean;
|
|
6367
|
+
senders: ListedMailSender[];
|
|
6368
|
+
connections: ListedConnection[];
|
|
6367
6369
|
address?: string | undefined;
|
|
6368
6370
|
}>;
|
|
6369
6371
|
addMailSender: import("better-call").StrictEndpoint<string, {
|
|
@@ -6392,9 +6394,10 @@ export declare const buildAppAuth: (settings: AuthSettings, input: AppAuthInput)
|
|
|
6392
6394
|
};
|
|
6393
6395
|
}>>[];
|
|
6394
6396
|
body: import("zod").ZodObject<{
|
|
6395
|
-
address: import("zod").ZodEmail
|
|
6397
|
+
address: import("zod").ZodPipe<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodEmail>, import("zod").ZodTransform<string, string>>;
|
|
6396
6398
|
name: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<string | null, string>>>;
|
|
6397
6399
|
signature: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<string | null, string>>>;
|
|
6400
|
+
connection: import("zod").ZodOptional<import("zod").ZodString>;
|
|
6398
6401
|
}, import("zod/v4/core").$strip>;
|
|
6399
6402
|
}, {
|
|
6400
6403
|
sender: ListedMailSender;
|
|
@@ -6464,6 +6467,34 @@ export declare const buildAppAuth: (settings: AuthSettings, input: AppAuthInput)
|
|
|
6464
6467
|
}, {
|
|
6465
6468
|
removed: boolean;
|
|
6466
6469
|
}>;
|
|
6470
|
+
refreshMailSenders: import("better-call").StrictEndpoint<string, {
|
|
6471
|
+
method: "POST";
|
|
6472
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
6473
|
+
session: {
|
|
6474
|
+
session: Record<string, any> & {
|
|
6475
|
+
id: string;
|
|
6476
|
+
createdAt: Date;
|
|
6477
|
+
updatedAt: Date;
|
|
6478
|
+
userId: string;
|
|
6479
|
+
expiresAt: Date;
|
|
6480
|
+
token: string;
|
|
6481
|
+
ipAddress?: string | null | undefined;
|
|
6482
|
+
userAgent?: string | null | undefined;
|
|
6483
|
+
};
|
|
6484
|
+
user: Record<string, any> & {
|
|
6485
|
+
id: string;
|
|
6486
|
+
createdAt: Date;
|
|
6487
|
+
updatedAt: Date;
|
|
6488
|
+
email: string;
|
|
6489
|
+
emailVerified: boolean;
|
|
6490
|
+
name: string;
|
|
6491
|
+
image?: string | null | undefined;
|
|
6492
|
+
};
|
|
6493
|
+
};
|
|
6494
|
+
}>>[];
|
|
6495
|
+
}, {
|
|
6496
|
+
connections: ConnectionListing[];
|
|
6497
|
+
}>;
|
|
6467
6498
|
checkMailSender: import("better-call").StrictEndpoint<string, {
|
|
6468
6499
|
method: "POST";
|
|
6469
6500
|
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
@@ -5,23 +5,24 @@ import { Revocation } from "./connections/disconnect-account.js";
|
|
|
5
5
|
import { StaffSignIn } from "./staff-log.js";
|
|
6
6
|
import { Person } from "./organizations/people-endpoint.js";
|
|
7
7
|
import { PersonalAccessToken } from "./personal-access-tokens/token-store.js";
|
|
8
|
+
import { ResolvedNames, TableNames } from "./names/resolve-names.js";
|
|
9
|
+
import { OrganizationRole, StoredMember } from "./organizations/store.js";
|
|
8
10
|
import { Mailer } from "../mail/mail-message.js";
|
|
9
11
|
import { PersonalMailProvider } from "../personal-mail/personal-mail-provider.js";
|
|
12
|
+
import { ListedConnection, ListedMailSender } from "../personal-mail/listed-mail-senders.js";
|
|
13
|
+
import { ConnectionListing } from "../personal-mail/sender-listing.js";
|
|
10
14
|
import { PersonalMail } from "../personal-mail/personal-mailer.js";
|
|
11
15
|
import { AliasCheckResult } from "../personal-mail/alias-checks.js";
|
|
12
|
-
import { ResolvedNames, TableNames } from "./names/resolve-names.js";
|
|
13
|
-
import { FindMailSenderUse } from "../personal-mail/mail-sender-use.js";
|
|
14
|
-
import "../personal-mail/mail-sender-use-check.js";
|
|
15
|
-
import { ListedMailSender } from "../personal-mail/mail-senders-plugin.js";
|
|
16
16
|
import { RoleDefinitions, RolesInput } from "./organizations/role-definitions.js";
|
|
17
17
|
import { ConnectedApp } from "./mcp/connected-apps.js";
|
|
18
18
|
import { OperatorClient } from "./openid-provider/operator-clients.js";
|
|
19
19
|
import { VersionedSecret } from "./secret-versions.js";
|
|
20
20
|
import { UserDeletionListener } from "./user-deletion.js";
|
|
21
|
-
import {
|
|
21
|
+
import { FindMailSenderUse } from "../personal-mail/mail-sender-use.js";
|
|
22
|
+
import { PersonalMailEntry } from "../personal-mail/personal-mail-providers.js";
|
|
23
|
+
import "../personal-mail/mail-sender-use-check.js";
|
|
22
24
|
import "./auth-base-path.js";
|
|
23
25
|
import { OperatorProvider } from "./operator-provider.js";
|
|
24
|
-
import { OrganizationRole, StoredMember } from "./organizations/store.js";
|
|
25
26
|
import { SignInPolicy } from "./sign-in-policy.js";
|
|
26
27
|
import { McpAuthOptions } from "./mcp/mcp-plugins.js";
|
|
27
28
|
import { OAuthApiOptions, OAuthApiResource } from "./oauth-api.js";
|
|
@@ -138,9 +139,11 @@ export type CreateAuthOptions = {
|
|
|
138
139
|
/**
|
|
139
140
|
* The mail providers people may link their own mailbox with, from the account page, for the app's functions to send
|
|
140
141
|
* mail from it (`context.personalMail`), such as `['gmail']`. Each links through its sign-in provider, which
|
|
141
|
-
* `socialProviders` must have: Gmail through `google`.
|
|
142
|
+
* `socialProviders` must have: Gmail through `google`. An entry may add optional scopes the provider offers for more
|
|
143
|
+
* abilities, such as `{ provider: 'gmail', scopes: [gmailSettingsScope] }`, with which the link reads the mailbox's
|
|
144
|
+
* send-as addresses and whether Gmail sends as each. Needs `encryptOAuthTokens`. Default none.
|
|
142
145
|
*/
|
|
143
|
-
personalMail?:
|
|
146
|
+
personalMail?: PersonalMailEntry[];
|
|
144
147
|
/** Encrypt the OAuth access and refresh tokens Better Auth stores for social sign-ins, with `secret`; `personalMail` and workflow connections need it. Default off. */
|
|
145
148
|
encryptOAuthTokens?: boolean;
|
|
146
149
|
/**
|
|
@@ -1018,11 +1021,7 @@ export declare const createAuth: (options: CreateAuthOptions, plugins?: AuthPlug
|
|
|
1018
1021
|
expiresAt: Date;
|
|
1019
1022
|
token: string;
|
|
1020
1023
|
ipAddress?: string | null | undefined;
|
|
1021
|
-
userAgent
|
|
1022
|
-
* Turns on personal access tokens: a signed-in person makes long-lived tokens on their account page, for a script to
|
|
1023
|
-
* call the app's API as them with `Authorization: Bearer <token>`. `prefix` starts every token, lowercase letters,
|
|
1024
|
-
* digits and underscores ending in `_`, such as `invoices_`; it has no default. Off by default.
|
|
1025
|
-
*/ : string | null | undefined;
|
|
1024
|
+
userAgent?: string | null | undefined;
|
|
1026
1025
|
};
|
|
1027
1026
|
};
|
|
1028
1027
|
}>>[];
|
|
@@ -1881,10 +1880,7 @@ export declare const createAuth: (options: CreateAuthOptions, plugins?: AuthPlug
|
|
|
1881
1880
|
expiresAt: Date;
|
|
1882
1881
|
token: string;
|
|
1883
1882
|
ipAddress?: string | null | undefined;
|
|
1884
|
-
userAgent
|
|
1885
|
-
* The role of a user created without one. Optional: when unset, and more than one role besides `admin` exists,
|
|
1886
|
-
* creating a user without a role is an error that asks for one. With exactly one other role, that role is the default.
|
|
1887
|
-
*/ : string | null | undefined;
|
|
1883
|
+
userAgent?: string | null | undefined;
|
|
1888
1884
|
};
|
|
1889
1885
|
user: Record<string, any> & {
|
|
1890
1886
|
id: string;
|
|
@@ -1893,15 +1889,7 @@ export declare const createAuth: (options: CreateAuthOptions, plugins?: AuthPlug
|
|
|
1893
1889
|
email: string;
|
|
1894
1890
|
emailVerified: boolean;
|
|
1895
1891
|
name: string;
|
|
1896
|
-
image
|
|
1897
|
-
* Open sign-up: anyone makes their own account from the sign-in page, with `role`, after proving their address with
|
|
1898
|
-
* an emailed code. Off by default, so accounts come only from the host, an admin, an invitation or a sign-in provider.
|
|
1899
|
-
* Needs a mailer: without one it is not offered. `role` is one of `roles` and never `admin`; give it the least
|
|
1900
|
-
* a stranger may hold. Not with `organizations`, whose people come from invitations. `domains`, for example
|
|
1901
|
-
* `['example.com']`, limits it to addresses there (subdomains count); `PROTOBASE_SIGN_UP_DOMAINS`, when set, replaces
|
|
1902
|
-
* it. An empty list leaves open sign-up off. `fields` is what it asks for: `['email', 'name']` by default, or
|
|
1903
|
-
* `['email']`, when the emailed sign-in code makes the account of an address without one on the spot.
|
|
1904
|
-
*/ : string | null | undefined;
|
|
1892
|
+
image?: string | null | undefined;
|
|
1905
1893
|
};
|
|
1906
1894
|
};
|
|
1907
1895
|
}>>[];
|
|
@@ -5414,7 +5402,7 @@ export declare const createAuth: (options: CreateAuthOptions, plugins?: AuthPlug
|
|
|
5414
5402
|
organization: {
|
|
5415
5403
|
name?: string;
|
|
5416
5404
|
slug?: string;
|
|
5417
|
-
logo
|
|
5405
|
+
logo? /** Signs cookies and encrypts the JWT private keys. Generate with `openssl rand -base64 32`. */ : string | null;
|
|
5418
5406
|
metadata?: Record<string, any>;
|
|
5419
5407
|
[key: string]: any;
|
|
5420
5408
|
};
|
|
@@ -6559,8 +6547,9 @@ export declare const createAuth: (options: CreateAuthOptions, plugins?: AuthPlug
|
|
|
6559
6547
|
};
|
|
6560
6548
|
}>>[];
|
|
6561
6549
|
}, {
|
|
6562
|
-
senders: ListedMailSender[];
|
|
6563
6550
|
checks: boolean;
|
|
6551
|
+
senders: ListedMailSender[];
|
|
6552
|
+
connections: ListedConnection[];
|
|
6564
6553
|
address?: string | undefined;
|
|
6565
6554
|
}>;
|
|
6566
6555
|
addMailSender: import("better-call").StrictEndpoint<string, {
|
|
@@ -6589,9 +6578,10 @@ export declare const createAuth: (options: CreateAuthOptions, plugins?: AuthPlug
|
|
|
6589
6578
|
};
|
|
6590
6579
|
}>>[];
|
|
6591
6580
|
body: import("zod").ZodObject<{
|
|
6592
|
-
address: import("zod").ZodEmail
|
|
6581
|
+
address: import("zod").ZodPipe<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodEmail>, import("zod").ZodTransform<string, string>>;
|
|
6593
6582
|
name: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<string | null, string>>>;
|
|
6594
6583
|
signature: import("zod").ZodOptional<import("zod").ZodPipe<import("zod").ZodString, import("zod").ZodTransform<string | null, string>>>;
|
|
6584
|
+
connection: import("zod").ZodOptional<import("zod").ZodString>;
|
|
6595
6585
|
}, import("zod/v4/core").$strip>;
|
|
6596
6586
|
}, {
|
|
6597
6587
|
sender: ListedMailSender;
|
|
@@ -6661,6 +6651,34 @@ export declare const createAuth: (options: CreateAuthOptions, plugins?: AuthPlug
|
|
|
6661
6651
|
}, {
|
|
6662
6652
|
removed: boolean;
|
|
6663
6653
|
}>;
|
|
6654
|
+
refreshMailSenders: import("better-call").StrictEndpoint<string, {
|
|
6655
|
+
method: "POST";
|
|
6656
|
+
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
6657
|
+
session: {
|
|
6658
|
+
session: Record<string, any> & {
|
|
6659
|
+
id: string;
|
|
6660
|
+
createdAt: Date;
|
|
6661
|
+
updatedAt: Date;
|
|
6662
|
+
userId: string;
|
|
6663
|
+
expiresAt: Date;
|
|
6664
|
+
token: string;
|
|
6665
|
+
ipAddress?: string | null | undefined;
|
|
6666
|
+
userAgent?: string | null | undefined;
|
|
6667
|
+
};
|
|
6668
|
+
user: Record<string, any> & {
|
|
6669
|
+
id: string;
|
|
6670
|
+
createdAt: Date;
|
|
6671
|
+
updatedAt: Date;
|
|
6672
|
+
email: string;
|
|
6673
|
+
emailVerified: boolean;
|
|
6674
|
+
name: string;
|
|
6675
|
+
image?: string | null | undefined;
|
|
6676
|
+
};
|
|
6677
|
+
};
|
|
6678
|
+
}>>[];
|
|
6679
|
+
}, {
|
|
6680
|
+
connections: ConnectionListing[];
|
|
6681
|
+
}>;
|
|
6664
6682
|
checkMailSender: import("better-call").StrictEndpoint<string, {
|
|
6665
6683
|
method: "POST";
|
|
6666
6684
|
use: import("better-call").Middleware<import("better-call").MiddlewareOptions, (inputContext: import("better-call").MiddlewareInputContext<import("better-call").MiddlewareOptions>) => Promise<{
|
|
@@ -6842,7 +6860,7 @@ export declare const createAuth: (options: CreateAuthOptions, plugins?: AuthPlug
|
|
|
6842
6860
|
claims_parameter_supported?: boolean | undefined;
|
|
6843
6861
|
end_session_endpoint: string;
|
|
6844
6862
|
request_parameter_supported?: boolean | undefined;
|
|
6845
|
-
request_uri_parameter_supported
|
|
6863
|
+
request_uri_parameter_supported? /** The MCP provider's options, resolved (`resolveMcp`), when it is on. */ : boolean | undefined;
|
|
6846
6864
|
prompt_values_supported: import("@better-auth/oauth-provider").Prompt[];
|
|
6847
6865
|
issuer: string;
|
|
6848
6866
|
authorization_endpoint: string;
|
|
@@ -9535,7 +9553,7 @@ export declare const createAuth: (options: CreateAuthOptions, plugins?: AuthPlug
|
|
|
9535
9553
|
claims_parameter_supported?: boolean | undefined;
|
|
9536
9554
|
end_session_endpoint: string;
|
|
9537
9555
|
request_parameter_supported?: boolean | undefined;
|
|
9538
|
-
request_uri_parameter_supported
|
|
9556
|
+
request_uri_parameter_supported? /** The MCP provider's options, resolved (`resolveMcp`), when it is on. */ : boolean | undefined;
|
|
9539
9557
|
prompt_values_supported: import("@better-auth/oauth-provider").Prompt[];
|
|
9540
9558
|
issuer: string;
|
|
9541
9559
|
authorization_endpoint: string;
|
|
@@ -10,7 +10,9 @@ import { betterAuthLinkedAccounts } from "../personal-mail/linked-accounts.js";
|
|
|
10
10
|
import { resolvePersonalMail } from "../personal-mail/personal-mail-providers.js";
|
|
11
11
|
import { personalMailer } from "../personal-mail/personal-mailer.js";
|
|
12
12
|
import { mailLinkHooks } from "../personal-mail/mail-link-hooks.js";
|
|
13
|
-
import {
|
|
13
|
+
import { storeNamesPlugin } from "./names/names-plugin.js";
|
|
14
|
+
import { storeSqlOf } from "./store/store-sql.js";
|
|
15
|
+
import { sqlSenderStore } from "../personal-mail/sender-store.js";
|
|
14
16
|
import { mailSendersPlugin } from "../personal-mail/mail-senders-plugin.js";
|
|
15
17
|
import { aliasChecks } from "../personal-mail/alias-checks.js";
|
|
16
18
|
import { mailCheckService } from "../personal-mail/mail-check-service.js";
|
|
@@ -33,7 +35,6 @@ import { passwordLength } from "./new-account-password.js";
|
|
|
33
35
|
import { platformMailer } from "../mail/platform-mailer.js";
|
|
34
36
|
import { readOperatorSettings, resolveOperator } from "./operator-provider.js";
|
|
35
37
|
import "./invitations/invitation-link-hook.js";
|
|
36
|
-
import { storeNamesPlugin } from "./names/names-plugin.js";
|
|
37
38
|
import { lastAdminGuardPlugin } from "./last-admin-guard.js";
|
|
38
39
|
import { setPasswordPath, setPasswordPlugin } from "./set-password.js";
|
|
39
40
|
import { emailCodeOptions, twoFactorCodeOptions, unusedEmailCodePaths } from "./sign-in-mail.js";
|
|
@@ -143,6 +144,13 @@ const loaded = (plugin, option) => {
|
|
|
143
144
|
};
|
|
144
145
|
const newUserId = (generate) => generate === "uuid" ? crypto.randomUUID() : generate();
|
|
145
146
|
const noContext = () => Promise.reject(/* @__PURE__ */ new Error("The auth context is read only once createAuth has made the instance"));
|
|
147
|
+
const mailboxOff = () => Promise.reject(/* @__PURE__ */ new Error("Not implemented: refreshing send-as addresses needs the mailer createAuth wires"));
|
|
148
|
+
const noMailer = () => ({
|
|
149
|
+
send: mailboxOff,
|
|
150
|
+
sender: mailboxOff,
|
|
151
|
+
senders: mailboxOff,
|
|
152
|
+
refresh: mailboxOff
|
|
153
|
+
});
|
|
146
154
|
const organizationPaths = ["/organization/set-active", "/organization/accept-invitation"];
|
|
147
155
|
/** The reads every page load makes, which the rate limit leaves out: they check a session, never a credential. */
|
|
148
156
|
const pageLoadReads = [
|
|
@@ -154,7 +162,7 @@ const pageLoadReads = [
|
|
|
154
162
|
* The options `createAuth` gives Better Auth, with the roles, default role, mailer, operator provider and platform
|
|
155
163
|
* sign-in provider already resolved.
|
|
156
164
|
*/
|
|
157
|
-
const betterAuthOptions = (options, { origins = [], passkeyDomain, roles, definitions, defaultRole, appName = defaultAppName, mailer, signUpRole, signUpDomains, signUpFields = resolveSignUpFields(void 0), operator, platformSignIn = [], saml = [], organizations, mcp, api, openId, personalAccessTokens, context = noContext, signInPolicy = defaultSignInPolicy, mobile, deletion, mailSenderUse, aliasChecks, lockedAccounts = [], connections, names = resolveNames({
|
|
165
|
+
const betterAuthOptions = (options, { origins = [], passkeyDomain, roles, definitions, defaultRole, appName = defaultAppName, mailer, signUpRole, signUpDomains, signUpFields = resolveSignUpFields(void 0), operator, platformSignIn = [], saml = [], organizations, mcp, api, openId, personalAccessTokens, context = noContext, signInPolicy = defaultSignInPolicy, mobile, deletion, mailSenderUse, aliasChecks, personalMailer: mailOf = noMailer, lockedAccounts = [], connections, names = resolveNames({
|
|
158
166
|
schema: storeSchema({ options }),
|
|
159
167
|
tables: options.tables
|
|
160
168
|
}), ...plugins }) => {
|
|
@@ -390,7 +398,7 @@ const betterAuthOptions = (options, { origins = [], passkeyDomain, roles, defini
|
|
|
390
398
|
definitions,
|
|
391
399
|
names: named
|
|
392
400
|
})] : [],
|
|
393
|
-
...mailProviders.length > 0 ? [mailSendersPlugin(mailProviders, named, mailSenderUse, aliasChecks)] : [],
|
|
401
|
+
...mailProviders.length > 0 ? [mailSendersPlugin(mailProviders, named, mailOf, mailSenderUse, aliasChecks)] : [],
|
|
394
402
|
...mcp ? loaded(plugins.mcpAuthPlugins, "mcp")({
|
|
395
403
|
mcp,
|
|
396
404
|
...api && { api },
|
|
@@ -582,6 +590,7 @@ const createAuth = (options, plugins = {}) => {
|
|
|
582
590
|
deletion,
|
|
583
591
|
mailSenderUse: senderUse,
|
|
584
592
|
...checks && { aliasChecks: checks },
|
|
593
|
+
personalMailer: mailboxOf,
|
|
585
594
|
lockedAccounts,
|
|
586
595
|
origins,
|
|
587
596
|
passkeyDomain,
|
|
@@ -612,7 +621,7 @@ const createAuth = (options, plugins = {}) => {
|
|
|
612
621
|
assertNoEndpointKeyClashes(authOptions.plugins);
|
|
613
622
|
const auth = betterAuth(authOptions);
|
|
614
623
|
instance = auth;
|
|
615
|
-
const senderStore =
|
|
624
|
+
const senderStore = sqlSenderStore(async () => storeSqlOf(await context()));
|
|
616
625
|
return Object.assign(auth, {
|
|
617
626
|
/**
|
|
618
627
|
* Answers a request from the app's iOS or Android build: Better Auth also trusts the Capacitor origin the request
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseRoles } from "./parse-roles.js";
|
|
2
|
-
import { activeAdminExists } from "./store/active-admin.js";
|
|
3
2
|
import { storeSqlOf } from "./store/store-sql.js";
|
|
3
|
+
import { activeAdminExists } from "./store/active-admin.js";
|
|
4
4
|
//#region src/better-auth/last-admin.ts
|
|
5
5
|
/** Holds the admin role and is not blocked: the last of these can never be demoted, blocked or removed. */
|
|
6
6
|
const isActiveAdmin = (user) => parseRoles(user.role).includes("admin") && !user.banned;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AuthContext } from "../organizations/store.js";
|
|
2
2
|
import { RoleDefinitions } from "../organizations/role-definitions.js";
|
|
3
3
|
import { ConnectedApp } from "./connected-apps.js";
|
|
4
|
-
import { AuthContext } from "../organizations/store.js";
|
|
5
4
|
import { SignInPolicy } from "../sign-in-policy.js";
|
|
5
|
+
import { BetterAuthNames } from "../names/better-auth-names.js";
|
|
6
6
|
import { ResolvedMcp } from "./mcp-plugins.js";
|
|
7
7
|
import { OAuthApiResource } from "../oauth-api.js";
|
|
8
8
|
//#region src/better-auth/mcp/mcp-auth-plugins.d.ts
|
|
@@ -773,8 +773,58 @@ export declare const builtInModules: readonly [{
|
|
|
773
773
|
readonly required: true;
|
|
774
774
|
};
|
|
775
775
|
};
|
|
776
|
+
readonly connection_id: {
|
|
777
|
+
field: "connectionId";
|
|
778
|
+
attribute: {
|
|
779
|
+
readonly type: "string";
|
|
780
|
+
readonly required: false;
|
|
781
|
+
};
|
|
782
|
+
};
|
|
783
|
+
readonly address_key: {
|
|
784
|
+
field: "addressKey";
|
|
785
|
+
attribute: {
|
|
786
|
+
readonly type: "string";
|
|
787
|
+
readonly required: false;
|
|
788
|
+
readonly input: false;
|
|
789
|
+
};
|
|
790
|
+
};
|
|
791
|
+
readonly typed_at: {
|
|
792
|
+
field: "typedAt";
|
|
793
|
+
attribute: {
|
|
794
|
+
readonly type: "date";
|
|
795
|
+
readonly required: false;
|
|
796
|
+
};
|
|
797
|
+
};
|
|
798
|
+
readonly listed_at: {
|
|
799
|
+
field: "listedAt";
|
|
800
|
+
attribute: {
|
|
801
|
+
readonly type: "date";
|
|
802
|
+
readonly required: false;
|
|
803
|
+
};
|
|
804
|
+
};
|
|
805
|
+
readonly provider_state: {
|
|
806
|
+
field: "providerState";
|
|
807
|
+
attribute: {
|
|
808
|
+
readonly type: "string";
|
|
809
|
+
readonly required: false;
|
|
810
|
+
};
|
|
811
|
+
};
|
|
812
|
+
readonly provider_state_read_at: {
|
|
813
|
+
field: "providerStateReadAt";
|
|
814
|
+
attribute: {
|
|
815
|
+
readonly type: "date";
|
|
816
|
+
readonly required: false;
|
|
817
|
+
};
|
|
818
|
+
};
|
|
819
|
+
readonly removed_at: {
|
|
820
|
+
field: "removedAt";
|
|
821
|
+
attribute: {
|
|
822
|
+
readonly type: "date";
|
|
823
|
+
readonly required: false;
|
|
824
|
+
};
|
|
825
|
+
};
|
|
776
826
|
};
|
|
777
|
-
readonly indexes: ["mail_sender_default_idx", "mail_sender_shared_idx"];
|
|
827
|
+
readonly indexes: ["mail_sender_default_idx", "mail_sender_shared_idx", "mail_sender_connection_address_uidx", "mail_sender_user_address_idx"];
|
|
778
828
|
};
|
|
779
829
|
};
|
|
780
830
|
}, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { own } from "../declaration.js";
|
|
2
2
|
//#region src/better-auth/names/modules/mail-senders.ts
|
|
3
|
-
/** The From addresses people
|
|
3
|
+
/** The From addresses people send as through a mailbox connection: one row per connection and address, with what vouches for it. */
|
|
4
4
|
const mailSenders = {
|
|
5
5
|
id: "mail_senders",
|
|
6
6
|
requires: ["auth"],
|
|
@@ -35,9 +35,43 @@ const mailSenders = {
|
|
|
35
35
|
created_at: own("createdAt", {
|
|
36
36
|
type: "date",
|
|
37
37
|
required: true
|
|
38
|
+
}),
|
|
39
|
+
connection_id: own("connectionId", {
|
|
40
|
+
type: "string",
|
|
41
|
+
required: false
|
|
42
|
+
}),
|
|
43
|
+
address_key: own("addressKey", {
|
|
44
|
+
type: "string",
|
|
45
|
+
required: false,
|
|
46
|
+
input: false
|
|
47
|
+
}),
|
|
48
|
+
typed_at: own("typedAt", {
|
|
49
|
+
type: "date",
|
|
50
|
+
required: false
|
|
51
|
+
}),
|
|
52
|
+
listed_at: own("listedAt", {
|
|
53
|
+
type: "date",
|
|
54
|
+
required: false
|
|
55
|
+
}),
|
|
56
|
+
provider_state: own("providerState", {
|
|
57
|
+
type: "string",
|
|
58
|
+
required: false
|
|
59
|
+
}),
|
|
60
|
+
provider_state_read_at: own("providerStateReadAt", {
|
|
61
|
+
type: "date",
|
|
62
|
+
required: false
|
|
63
|
+
}),
|
|
64
|
+
removed_at: own("removedAt", {
|
|
65
|
+
type: "date",
|
|
66
|
+
required: false
|
|
38
67
|
})
|
|
39
68
|
},
|
|
40
|
-
indexes: [
|
|
69
|
+
indexes: [
|
|
70
|
+
"mail_sender_default_idx",
|
|
71
|
+
"mail_sender_shared_idx",
|
|
72
|
+
"mail_sender_connection_address_uidx",
|
|
73
|
+
"mail_sender_user_address_idx"
|
|
74
|
+
]
|
|
41
75
|
} }
|
|
42
76
|
};
|
|
43
77
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TableDeclaration } from "./declaration.js";
|
|
2
|
-
import { BuiltInTables, ModuleId } from "./modules/index.js";
|
|
3
2
|
import { ColumnId, IndexId, TableId } from "./identifiers.js";
|
|
3
|
+
import { BuiltInTables, ModuleId } from "./modules/index.js";
|
|
4
4
|
import { DBFieldAttribute } from "@better-auth/core/db";
|
|
5
5
|
//#region src/better-auth/names/resolve-names.d.ts
|
|
6
6
|
/** A column as the model resolves it, with the Better Auth field it holds and that field's attribute where Protobase defines it. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BetterAuthNames } from "../names/better-auth-names.js";
|
|
2
1
|
import { OperatorClient } from "./operator-clients.js";
|
|
3
2
|
import { SignInPolicy } from "../sign-in-policy.js";
|
|
3
|
+
import { BetterAuthNames } from "../names/better-auth-names.js";
|
|
4
4
|
import { ResolvedOpenIdProvider } from "./openid-provider-options.js";
|
|
5
5
|
//#region src/better-auth/openid-provider/openid-provider-plugins.d.ts
|
|
6
6
|
export type OpenIdProviderPluginsOptions = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { parseAppRoles } from "./app-roles.js";
|
|
2
|
-
import { invalidInvitation, invitationIdOf, verifyInvitationToken } from "../invitations/invitation-token.js";
|
|
3
2
|
import { storeSqlOf } from "../store/store-sql.js";
|
|
3
|
+
import { invalidInvitation, invitationIdOf, verifyInvitationToken } from "../invitations/invitation-token.js";
|
|
4
4
|
import { sql } from "kysely";
|
|
5
5
|
import { APIError } from "better-auth/api";
|
|
6
6
|
//#region src/better-auth/organizations/accept-invitation.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { membershipRoles } from "./role-definitions.js";
|
|
2
|
-
import { roleNames } from "../store/active-admin.js";
|
|
3
2
|
import { storeSqlOf } from "../store/store-sql.js";
|
|
3
|
+
import { roleNames } from "../store/active-admin.js";
|
|
4
4
|
import { findOrganizationByKey } from "./host.js";
|
|
5
5
|
import { sql } from "kysely";
|
|
6
6
|
//#region src/better-auth/organizations/add-every-user.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { membershipRoles } from "./role-definitions.js";
|
|
2
2
|
import { parseAppRoles } from "./app-roles.js";
|
|
3
3
|
import { findMember, isOwner, organizationRoleOf, setAppRoles } from "./store.js";
|
|
4
|
-
import { mayBeId } from "../store/store-reads.js";
|
|
5
4
|
import { storeSqlOf } from "../store/store-sql.js";
|
|
5
|
+
import { mayBeId } from "../store/store-reads.js";
|
|
6
6
|
import { pageOf } from "../store/page-of.js";
|
|
7
7
|
import { sql } from "kysely";
|
|
8
8
|
//#region src/better-auth/organizations/host.ts
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RoleDefinitions } from "./role-definitions.js";
|
|
2
1
|
import { StoredMember, StoredOrganization } from "./store.js";
|
|
2
|
+
import { RoleDefinitions } from "./role-definitions.js";
|
|
3
3
|
import { OrganizationOptions } from "better-auth/plugins/organization";
|
|
4
4
|
//#region src/better-auth/organizations/options.d.ts
|
|
5
5
|
type OrganizationHooks = NonNullable<OrganizationOptions['organizationHooks']>;
|
|
@@ -69,7 +69,8 @@ const accountChanges = [
|
|
|
69
69
|
"/account/mail-senders/add",
|
|
70
70
|
"/account/mail-senders/update",
|
|
71
71
|
"/account/mail-senders/remove",
|
|
72
|
-
"/account/mail-senders/check"
|
|
72
|
+
"/account/mail-senders/check",
|
|
73
|
+
"/account/mail-senders/refresh"
|
|
73
74
|
];
|
|
74
75
|
const staffCannotChange = {
|
|
75
76
|
code: "STAFF_CANNOT_CHANGE_SIGN_IN",
|
|
@@ -15,7 +15,7 @@ import { Hono } from "hono";
|
|
|
15
15
|
* operator provider's name, when staff can sign in as people; `passkeyDomains`, when people have passkeys for more than
|
|
16
16
|
* one of the app's hosts, the RP IDs a passkey sign-in can ask for, the passkey domain first; with organizations, who may create them and the roles
|
|
17
17
|
* with their labels, `membership` for those a member can hold, and the roles each one's holders may also give; and
|
|
18
|
-
* `anonymous` when the project's anonymous role reads a resource, so the admin app opens for visitors before anyone signs in; `mcp` when MCP clients can connect, with the `url` of its endpoint, so the account page shows that address and lists the connected clients; `personalAccessTokens` when people may make them, so the account page lists theirs; `personalMail`, the mail providers people may link their mailbox with, each with the sign-in provider it links through, the scopes and the authorization parameters of the link, so the account page offers "Link Gmail"; and
|
|
18
|
+
* `anonymous` when the project's anonymous role reads a resource, so the admin app opens for visitors before anyone signs in; `mcp` when MCP clients can connect, with the `url` of its endpoint, so the account page shows that address and lists the connected clients; `personalAccessTokens` when people may make them, so the account page lists theirs; `personalMail`, the mail providers people may link their mailbox with, each with the sign-in provider it links through, the scopes it needs to send, the optional scopes the app adds to the link (`optionalScopes`) and the authorization parameters of the link, so the account page offers "Link Gmail"; and
|
|
19
19
|
* `plugins`, those the app loads before sign-in (see `PluginOption`); and `locale`, the language `options.locale` puts
|
|
20
20
|
* the screens in, so the sign-in screens and public forms, which come before `/meta`, are in it too; `appName` and
|
|
21
21
|
* `appIcon`, the app's name and the path of its own icon when it has one, which those screens show as `/meta` names them;
|
|
@@ -65,11 +65,12 @@ const statusRoute = (auth, { anonymous = false, plugins = [], locale, firstAdmin
|
|
|
65
65
|
...anonymous && { anonymous },
|
|
66
66
|
...auth.mcp && { mcp: { url: auth.mcp.resource } },
|
|
67
67
|
...auth.personalAccessTokens && { personalAccessTokens: true },
|
|
68
|
-
...auth.personalMail.length > 0 && { personalMail: auth.personalMail.map(({ id, name, signInProvider, scopes, linkParams }) => ({
|
|
68
|
+
...auth.personalMail.length > 0 && { personalMail: auth.personalMail.map(({ id, name, signInProvider, scopes, addedScopes, linkParams }) => ({
|
|
69
69
|
id,
|
|
70
70
|
name,
|
|
71
71
|
provider: signInProvider,
|
|
72
72
|
scopes,
|
|
73
|
+
...addedScopes.length > 0 && { optionalScopes: addedScopes },
|
|
73
74
|
params: linkParams
|
|
74
75
|
})) },
|
|
75
76
|
...plugins.length > 0 && { plugins },
|
|
@@ -5,6 +5,7 @@ import { verificationPatternIndex } from "./auth/004-verification-pattern-index.
|
|
|
5
5
|
import { userNameSearch } from "./auth/005-user-name-search.js";
|
|
6
6
|
import { mailSenders } from "./mail-senders/001-mail-senders.js";
|
|
7
7
|
import { mailSenderNames } from "./mail-senders/002-mail-sender-names.js";
|
|
8
|
+
import { senderAddressEvidence } from "./mail-senders/003-sender-address-evidence.js";
|
|
8
9
|
import { mcp } from "./mcp/001-mcp.js";
|
|
9
10
|
import { organizations } from "./organizations/001-organizations.js";
|
|
10
11
|
import { organizationIndex } from "./organizations/002-organization-index.js";
|
|
@@ -33,7 +34,11 @@ const moduleSteps = {
|
|
|
33
34
|
organizations: [organizations, organizationIndex],
|
|
34
35
|
mcp: [mcp],
|
|
35
36
|
personal_access_tokens: [personalAccessTokens],
|
|
36
|
-
mail_senders: [
|
|
37
|
+
mail_senders: [
|
|
38
|
+
mailSenders,
|
|
39
|
+
mailSenderNames,
|
|
40
|
+
senderAddressEvidence
|
|
41
|
+
],
|
|
37
42
|
platform_devices: [platformDevices]
|
|
38
43
|
};
|
|
39
44
|
//#endregion
|