@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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { ddl, ddlText } from "../../ddl.js";
|
|
2
|
+
import { sql } from "kysely";
|
|
3
|
+
//#region src/better-auth/store/steps/mail-senders/003-sender-address-evidence.ts
|
|
4
|
+
const gmailSendScope = "https://www.googleapis.com/auth/gmail.send";
|
|
5
|
+
/**
|
|
6
|
+
* Each From address on the mailbox connection it goes out through, with what vouches for it: `typed_at` when its owner
|
|
7
|
+
* typed it; `listed_at`, `provider_state` and `provider_state_read_at` from the provider's last complete listing of
|
|
8
|
+
* the connection; `removed_at` when its owner removed it. `address_key` is the one spelling every writer matches on.
|
|
9
|
+
* An address entered before goes on its owner's Gmail connection when they have exactly one; with none or several it
|
|
10
|
+
* stays on none, and its owner adds it again.
|
|
11
|
+
*
|
|
12
|
+
* One address per connection takes the place of one per person, so the old key on the person and address goes: the
|
|
13
|
+
* version before this one checks for an address entered twice in its own code, so nothing it does relies on the key.
|
|
14
|
+
*/
|
|
15
|
+
const senderAddressEvidence = {
|
|
16
|
+
step: 3,
|
|
17
|
+
version: 15,
|
|
18
|
+
name: "sender_address_evidence",
|
|
19
|
+
title: "The mailbox connection of each From address and what vouches for it",
|
|
20
|
+
tables: [],
|
|
21
|
+
check: ({ table }) => {
|
|
22
|
+
const sender = table("mail_sender");
|
|
23
|
+
const s = sender.columns;
|
|
24
|
+
return ddl`do $check$
|
|
25
|
+
declare
|
|
26
|
+
found text;
|
|
27
|
+
begin
|
|
28
|
+
select string_agg(ids, '; ') into found
|
|
29
|
+
from (
|
|
30
|
+
select string_agg(id::text, ', ' order by id) as ids from ${sender}
|
|
31
|
+
group by ${s.user_id}, lower(btrim(${s.address})) having count(*) > 1 limit 20
|
|
32
|
+
) as twice;
|
|
33
|
+
if found is not null then
|
|
34
|
+
raise exception 'The auth store has From addresses entered twice by one person, without regard to case: %. Keep one of each in a migration of the project''s own written before this one, then apply again.', found;
|
|
35
|
+
end if;
|
|
36
|
+
end
|
|
37
|
+
$check$`;
|
|
38
|
+
},
|
|
39
|
+
statements: ({ table, idRef }) => {
|
|
40
|
+
const sender = table("mail_sender");
|
|
41
|
+
const s = sender.columns;
|
|
42
|
+
const account = table("account");
|
|
43
|
+
const a = account.columns;
|
|
44
|
+
const quoted = (part) => sql.lit(ddlText(ddl`${part}`));
|
|
45
|
+
const dropPersonKey = ddl`do $drop$
|
|
46
|
+
declare
|
|
47
|
+
found text;
|
|
48
|
+
begin
|
|
49
|
+
select con.conname into found from pg_constraint con
|
|
50
|
+
where con.conrelid = ${quoted(sender)}::regclass and con.contype = 'u'
|
|
51
|
+
and (select array_agg('"' || att.attname || '"' order by att.attname) from pg_attribute att where att.attrelid = con.conrelid and att.attnum = any(con.conkey))
|
|
52
|
+
= (select array_agg(name order by name) from unnest(array[${quoted(s.user_id)}, ${quoted(s.address)}]) as name);
|
|
53
|
+
if found is not null then
|
|
54
|
+
execute format('alter table %s drop constraint %I', ${quoted(sender)}::regclass, found);
|
|
55
|
+
end if;
|
|
56
|
+
end
|
|
57
|
+
$drop$`;
|
|
58
|
+
return [
|
|
59
|
+
ddl`alter table ${sender} add column ${s.connection_id} ${idRef} references ${account} (id) on delete set null`,
|
|
60
|
+
ddl`alter table ${sender} add column ${s.address_key} text generated always as (lower(btrim(${s.address}))) stored`,
|
|
61
|
+
ddl`alter table ${sender} add column ${s.typed_at} timestamptz`,
|
|
62
|
+
ddl`alter table ${sender} add column ${s.listed_at} timestamptz`,
|
|
63
|
+
ddl`alter table ${sender} add column ${s.provider_state} text`,
|
|
64
|
+
ddl`alter table ${sender} add column ${s.provider_state_read_at} timestamptz`,
|
|
65
|
+
ddl`alter table ${sender} add column ${s.removed_at} timestamptz`,
|
|
66
|
+
ddl`update ${sender} set ${s.typed_at} = ${s.created_at}`,
|
|
67
|
+
ddl`update ${sender} set ${s.connection_id} = only_one.id
|
|
68
|
+
from (
|
|
69
|
+
select ${a.user_id} as user_id, (array_agg(id))[1] as id from ${account}
|
|
70
|
+
where ${a.provider_id} = 'google' and ${sql.lit(gmailSendScope)} = any(regexp_split_to_array(coalesce(${a.scope}, ''), ${sql.lit("[\\s,]+")}))
|
|
71
|
+
group by ${a.user_id} having count(*) = 1
|
|
72
|
+
) as only_one
|
|
73
|
+
where ${sender}.${s.user_id} = only_one.user_id`,
|
|
74
|
+
ddl`create unique index ${sender.index("mail_sender_connection_address_uidx")} on ${sender} (${s.connection_id}, ${s.address_key})`,
|
|
75
|
+
ddl`create index ${sender.index("mail_sender_user_address_idx")} on ${sender} (${s.user_id}, ${s.address_key})`,
|
|
76
|
+
dropPersonKey
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
export { senderAddressEvidence };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseRoles } from "./parse-roles.js";
|
|
2
|
+
import { storeSqlOf } from "./store/store-sql.js";
|
|
2
3
|
import { exists } from "./store/store-reads.js";
|
|
3
4
|
import { activeAdminExists } from "./store/active-admin.js";
|
|
4
|
-
import { storeSqlOf } from "./store/store-sql.js";
|
|
5
5
|
import { isActiveAdmin } from "./last-admin.js";
|
|
6
6
|
import { revokeMcpGrants } from "./mcp/revoke-grants.js";
|
|
7
7
|
import { pageOf } from "./store/page-of.js";
|
|
@@ -47,11 +47,13 @@ export type FunctionContext = PublicFunctionContext & FunctionCaller & {
|
|
|
47
47
|
/**
|
|
48
48
|
* Mail from the caller's own mailbox, through the mail provider they linked (`auth.personalMail`), attachments and
|
|
49
49
|
* all: `personalMail.send({ to, subject, text, html, attachments })`, or an email template's `send(to, data,
|
|
50
|
-
* context.personalMail, { attachments })`. It goes out from
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* (`
|
|
54
|
-
*
|
|
50
|
+
* context.personalMail, { attachments })`. It goes out from the From address record `sender_address_id` names, through
|
|
51
|
+
* that record's mailbox connection (`send({ sender_address_id, ... })`), else from the caller's default address, else
|
|
52
|
+
* their mailbox's own: an id that is not one of the caller's is refused with a 404 problem, and an address the mailbox
|
|
53
|
+
* cannot send as (`sender_address_failed`), one still `pending` or one on no connection (`sender_address_detached`)
|
|
54
|
+
* with a 409, sending nothing. `sender(address?)` answers the record an address stands for, with its id, state and own
|
|
55
|
+
* signature, `senders()` every address the caller may choose, and `refresh()` lists the send-as addresses of each
|
|
56
|
+
* mailbox whose provider can. Rejects with a `PersonalMailError`, sending nothing, when they linked no
|
|
55
57
|
* mailbox (`not_linked`) or the link no longer works (`link_expired`); thrown on, it answers as a 409 problem with
|
|
56
58
|
* that `code`. Only someone signed in as themselves sends from their mailbox: staff signed in as them, or an outside
|
|
57
59
|
* app acting for them, is refused with a 403 problem. Not on a public function's context.
|
|
@@ -8,7 +8,8 @@ const purpose = "send mail from their own mailbox";
|
|
|
8
8
|
const ownMailbox = (session, personalMailer) => ({
|
|
9
9
|
send: async (message) => personalMailer(ownSignInUser(session, purpose)).send(message),
|
|
10
10
|
sender: async (from) => personalMailer(ownSignInUser(session, purpose)).sender(from),
|
|
11
|
-
senders: async () => personalMailer(ownSignInUser(session, purpose)).senders()
|
|
11
|
+
senders: async () => personalMailer(ownSignInUser(session, purpose)).senders(),
|
|
12
|
+
refresh: async () => personalMailer(ownSignInUser(session, purpose)).refresh()
|
|
12
13
|
});
|
|
13
14
|
//#endregion
|
|
14
15
|
export { ownMailbox };
|
package/dist/functions/routes.js
CHANGED
|
@@ -20,7 +20,8 @@ const personalMailOff = () => Promise.reject(/* @__PURE__ */ new Error("Personal
|
|
|
20
20
|
const noPersonalMail = () => ({
|
|
21
21
|
send: personalMailOff,
|
|
22
22
|
sender: personalMailOff,
|
|
23
|
-
senders: personalMailOff
|
|
23
|
+
senders: personalMailOff,
|
|
24
|
+
refresh: personalMailOff
|
|
24
25
|
});
|
|
25
26
|
const isUpgrade = (request) => request.headers.get("upgrade")?.toLowerCase() === "websocket";
|
|
26
27
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -4,13 +4,15 @@ import { AppIcons, PngIcon, pngIcons } from "./web-app/app-icons.js";
|
|
|
4
4
|
import { RealtimeRelayOptions, RelayChannelOptions, RelayClientEvent, RelayMembers, RelayPresence, checkRelayOptions } from "./relay/relay-options.js";
|
|
5
5
|
import { RealtimeOptions, relayed, sqlSends } from "./realtime/relay/realtime-options.js";
|
|
6
6
|
import { StaffSignIn } from "./better-auth/staff-log.js";
|
|
7
|
+
import { OrganizationRole, StoredMember, StoredOrganization } from "./better-auth/organizations/store.js";
|
|
7
8
|
import { MailAttachment, MailMessage, Mailer, SentMail } from "./mail/mail-message.js";
|
|
9
|
+
import { SenderAddressState } from "./personal-mail/sender-address-state.js";
|
|
8
10
|
import { MailSender } from "./personal-mail/mail-sender.js";
|
|
11
|
+
import { ConnectionListing } from "./personal-mail/sender-listing.js";
|
|
9
12
|
import { PersonalMail, PersonalMailMessage } from "./personal-mail/personal-mailer.js";
|
|
10
13
|
import { RoleDefinition, RolesInput } from "./better-auth/organizations/role-definitions.js";
|
|
11
|
-
import { PersonalMailProviderId } from "./personal-mail/personal-mail-providers.js";
|
|
14
|
+
import { PersonalMailEntry, PersonalMailProviderId } from "./personal-mail/personal-mail-providers.js";
|
|
12
15
|
import { OperatorProvider, readOperatorSettings } from "./better-auth/operator-provider.js";
|
|
13
|
-
import { OrganizationRole, StoredMember, StoredOrganization } from "./better-auth/organizations/store.js";
|
|
14
16
|
import { SignInPolicy, SignInRule, StaffAccessRule, defaultSignInPolicy, signInPolicyMethods } from "./better-auth/sign-in-policy.js";
|
|
15
17
|
import { OrganizationsOptions } from "./better-auth/organizations/options.js";
|
|
16
18
|
import { UnsubscribeLinks } from "./mail/unsubscribe/unsubscribe-links.js";
|
|
@@ -226,10 +228,12 @@ import { ArgumentsPayload, EnqueueJob, JobDeclaration, JobName, JobPayload, JobR
|
|
|
226
228
|
import { isSchedule } from "./jobs/schedule.js";
|
|
227
229
|
import { MailServerTimeoutError } from "./mail/mail-server-timeout.js";
|
|
228
230
|
import { PersonalMailError, PersonalMailErrorCode } from "./personal-mail/personal-mail-error.js";
|
|
231
|
+
import { gmailSettingsScope } from "./personal-mail/gmail-sender-addresses.js";
|
|
229
232
|
import { MailSenderRefusedError } from "./personal-mail/mail-sender-refused.js";
|
|
233
|
+
import { SenderAddressError, SenderAddressErrorCode, SenderAddressNotFoundError } from "./personal-mail/sender-address-error.js";
|
|
230
234
|
import { PdfComponent, PdfOptions, PdfTemplate, definePdf } from "./pdf/define-pdf.js";
|
|
231
235
|
import { DrainResult, JobsRuntime, StartJobsOptions, startJobs } from "./jobs/runtime.js";
|
|
232
236
|
import { jobsDrainApp } from "./jobs/drain-route.js";
|
|
233
237
|
import { checkJobsSchema, jobsSchema, jobsSchemaMigration } from "./jobs/schema.js";
|
|
234
238
|
import { ResourceSource, configExports } from "./resource-source.js";
|
|
235
|
-
export { type Admin, type AdminAuth, type AdminOptions, type AggregateParams, type ApiFunction, type ApiKeys, type ApiKeysOptions, type ApnsEnvironment, type ApnsOptions, type ApnsSettings, type AppIcons, type AppIdentity, type AppPoolConfig, type ApplyOptions, type ApplyResult, type ApprovalAnswer, type ApprovalRequest, type ArgumentsPayload, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type AuthHooks, type AuthSettings, type AuthenticateSettings, type Authenticator, type BaseToolContext, type BatchOperation, type BatchResult, type BetterAuthAuthenticator, type BetterAuthAuthenticatorOptions, type BridgeClosing, type BridgeRule, type BridgeTarget, BulkMailError, type CallBackend, type CallMember, type Caller, type CallerOptions, type CallsAccess, type CallsOptions, type CapturedRow, type CascadingKey, type ChannelBroadcast, type ChannelSender, type ChatMessage, type ChatTextPart, type CheckAiInput, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type CommentItem, type CommentToolsInput, type CommentUsers, type Completion, type CompletionOptions, ConnectionsBusy, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CorsOrigins, type CreateAdminInput, type CreateAuthOptions, type DecryptField, type DerivedClock, type DerivedCompute, type DerivedContext, type Device, type DeviceColumn, type DeviceKind, type DeviceStore, DeviceStoreError, type DrainResult, type EmailComponent, type EmailOptions, type EmailTemplate, type EncryptionStatus, type EncryptionTools, type EncryptionToolsInput, type EnqueueJob, type EnqueueOptions, type ErrorReporter, type ErrorReportingOptions, type ErrorReportingSettings, type EventData, type EventsOptions, FatalJobError, type FcmOptions, type FcmSettings, type FieldApplied, type FieldDecrypter, type FieldReader, type FieldStatus, type FileCleanupInput, type FileLimits, type FileObject, type FileProvider, type FileProviderSettings, type FileRef, type FileStore, type FileVariantObject, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSocket, type FunctionSource, type HistoryColumn, type HistoryOptions, type HistoryPosition, type HistoryStore, HistoryStoreError, type HookContext, HttpProblem, type IssueTokenOptions, type JobContext, type JobDeclaration, type JobDefinition, type JobName, type JobOptions, type JobPayload, type JobRun, type JobsRuntime, type JoinedUser, type JsonObject, type JsonValue, type JwtOptions, type JwtVerifyOptions, type KeyFunctionContext, type LinkedAccount, type ListParams, type ListedOrganization, type LiveKitBackend, type LocalFilesOptions, type MailAttachment, type MailFeedback, type MailMessage, type MailSender, MailSenderRefusedError, MailServerTimeoutError, type MailTemplate, type Mailer, type MapLayer, type MapOptions, type MapSettings, type McpApprovals, type McpGateInput, type McpHandlerInput, type McpRoutesInput, type McpServerInput, type McpToolsInput, type McpWrites, type MemberInput, type Membership, MissingCredentials, type MobileConfig, type MobileSplash, type MobileSplashLook, ModelError, type ModelSettings, type NewDevice, type NewNotification, type NewOrganization, type NewUser, type NotificationRecipients, NotificationSendError, type NotificationsOptions, type OperatorProvider, type OrganizationRole, type OrganizationsCursor, type OrganizationsOptions, type OrganizationsPage, type OverSignIn, type PdfComponent, type PdfOptions, type PdfTemplate, type PersonalMail, PersonalMailError, type PersonalMailErrorCode, type PersonalMailMessage, type PersonalMailProviderId, type PgModule, type PipelineHook, type PlatformSignIn, type PluginOption, type PluginRef, type PngIcon, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type PushAnswer, type PushMessage, PushMessageError, type PushSender, type QueryOptions, type QueryResult, type ReadableResources, type RealtimeOptions, type RealtimePrune, type RealtimeRelayOptions, type ReasoningDetail, type ReasoningEffort, type RebindOption, type RecordGroups, type RecordKey, type RecordKeyInput, type RecordPage, type RelayChannelOptions, type RelayClientEvent, type RelayDevice, type RelayMembers, type RelayPresence, type RelayResult, type RelaySendAnswer, type RelaySendRequest, type RelaySettings, type RenderedEmail, type RenderedTemplate, type ResourceChange, type ResourceSource, type RoleDefinition, type RolesInput, type RunContext, type RuntimeOptions, type S3Bucket, type S3FilesOptions, type S3ListPage, type S3Object, type ScanGuardMode, type ScheduledDelete, type SendNotification, type SentMail, type Session, type SessionOrganization, type Sharp, type SignInPolicy, type SignInRule, type SignatureOptions, type SocketEvents, type SourceOption, type SourceRef, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StartWorkflowOptions, type StatusOptions, type StoreFileInput, type StoredMember, type StoredNotification, type StoredObject, type StoredOrganization, type StoredUser, type StrayValues, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TcpBridge, type TcpBridgeOptions, TemplateDataError, type TemplateOptions, type TemplateSchema, type TemplateScope, type TemplateSendOptions, type TemplateText, type TenantValue, type ToolAnnotations, type ToolCall, type ToolComment, type ToolCommentPage, type ToolComments, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TrustedApp, type TurnOptions, type UnreadableEntry, type UnsubscribeLinks, type Urgency, type User, type UserCreatedHook, type UserTables, type UsersCursor, type UsersPage, type VapidSettings, type ViewSource, type WebPushFields, type WebPushOptions, type WebhooksOptions, type WidgetOptions, type WorkflowCatalog, type WorkflowTypes, type WorkflowsOptions, type WriteEvent, type WriteOperation, type WriteRecordToolsInput, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkMailFeedbackSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkRelayOptions, checkRelaySchema, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUnsubscribesSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, checkWorkflowsSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTemplate, defineTool, deleteRecordTool, deleteUser, derivedMigration, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fcmSender, fcmServiceAccountVariable, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, goTruePath, handleDroppedConnections, hasBuckets, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, hookPath, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isMailTemplate, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mailCheckHeaders, mailCheckSecret, mailFeedbackHeaders, mailFeedbackMigration, mailFeedbackResource, mailFeedbackSecret, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxRelayDevices, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, organizationsPageSize, overSignIn, ownedDefinitionsMigration, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readApnsSettings, readDbConnections, readDefinitionsVersion, readFcmSettings, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIns, readRecordTools, readRelaySettings, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relayUrlVariable, relayed, releaseConnectionsWithUsers, reloadingAdmin, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, sqlSends, startErrorReporting, startJobs, startWorkflow, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, tcpBridge, thumbHash, typingResources, unauthorized, unsubscribesMigration, updateRecordTool, urgencies, userTableResources, userTablesMigration, usersPageSize, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhookIssuePath, webhookParams, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, workflowInstructions, workflowReadTools, workflowTypes, workflowWriteTools, workflowsMigration, writeRecordTools };
|
|
239
|
+
export { type Admin, type AdminAuth, type AdminOptions, type AggregateParams, type ApiFunction, type ApiKeys, type ApiKeysOptions, type ApnsEnvironment, type ApnsOptions, type ApnsSettings, type AppIcons, type AppIdentity, type AppPoolConfig, type ApplyOptions, type ApplyResult, type ApprovalAnswer, type ApprovalRequest, type ArgumentsPayload, type AssistantBackend, type AssistantOptions, type AssistantSettings, type AssistantTool, type AuditEvent, type AuditQueue, type AuthHooks, type AuthSettings, type AuthenticateSettings, type Authenticator, type BaseToolContext, type BatchOperation, type BatchResult, type BetterAuthAuthenticator, type BetterAuthAuthenticatorOptions, type BridgeClosing, type BridgeRule, type BridgeTarget, BulkMailError, type CallBackend, type CallMember, type Caller, type CallerOptions, type CallsAccess, type CallsOptions, type CapturedRow, type CascadingKey, type ChannelBroadcast, type ChannelSender, type ChatMessage, type ChatTextPart, type CheckAiInput, type CleanupEntry, type CleanupReport, type CleanupSchedule, type CoalescedChange, type CommentItem, type CommentToolsInput, type CommentUsers, type Completion, type CompletionOptions, type ConnectionListing, ConnectionsBusy, type Conversation, type ConversationRecord, type ConversationStore, type ConversationsOptions, type CorsOptions, type CorsOrigins, type CreateAdminInput, type CreateAuthOptions, type DecryptField, type DerivedClock, type DerivedCompute, type DerivedContext, type Device, type DeviceColumn, type DeviceKind, type DeviceStore, DeviceStoreError, type DrainResult, type EmailComponent, type EmailOptions, type EmailTemplate, type EncryptionStatus, type EncryptionTools, type EncryptionToolsInput, type EnqueueJob, type EnqueueOptions, type ErrorReporter, type ErrorReportingOptions, type ErrorReportingSettings, type EventData, type EventsOptions, FatalJobError, type FcmOptions, type FcmSettings, type FieldApplied, type FieldDecrypter, type FieldReader, type FieldStatus, type FileCleanupInput, type FileLimits, type FileObject, type FileProvider, type FileProviderSettings, type FileRef, type FileStore, type FileVariantObject, type FilesOptions, type FunctionApp, type FunctionCaller, type FunctionContext, type FunctionEnv, type FunctionHandler, type FunctionOptions, type FunctionRecords, type FunctionSocket, type FunctionSource, type HistoryColumn, type HistoryOptions, type HistoryPosition, type HistoryStore, HistoryStoreError, type HookContext, HttpProblem, type IssueTokenOptions, type JobContext, type JobDeclaration, type JobDefinition, type JobName, type JobOptions, type JobPayload, type JobRun, type JobsRuntime, type JoinedUser, type JsonObject, type JsonValue, type JwtOptions, type JwtVerifyOptions, type KeyFunctionContext, type LinkedAccount, type ListParams, type ListedOrganization, type LiveKitBackend, type LocalFilesOptions, type MailAttachment, type MailFeedback, type MailMessage, type MailSender, MailSenderRefusedError, MailServerTimeoutError, type MailTemplate, type Mailer, type MapLayer, type MapOptions, type MapSettings, type McpApprovals, type McpGateInput, type McpHandlerInput, type McpRoutesInput, type McpServerInput, type McpToolsInput, type McpWrites, type MemberInput, type Membership, MissingCredentials, type MobileConfig, type MobileSplash, type MobileSplashLook, ModelError, type ModelSettings, type NewDevice, type NewNotification, type NewOrganization, type NewUser, type NotificationRecipients, NotificationSendError, type NotificationsOptions, type OperatorProvider, type OrganizationRole, type OrganizationsCursor, type OrganizationsOptions, type OrganizationsPage, type OverSignIn, type PdfComponent, type PdfOptions, type PdfTemplate, type PersonalMail, type PersonalMailEntry, PersonalMailError, type PersonalMailErrorCode, type PersonalMailMessage, type PersonalMailProviderId, type PgModule, type PipelineHook, type PlatformSignIn, type PluginOption, type PluginRef, type PngIcon, type ProtectedFunctionOptions, type PublicFunctionContext, type PublicFunctionEnv, type PublicFunctionHandler, type PublicFunctionOptions, type PushAnswer, type PushMessage, PushMessageError, type PushSender, type QueryOptions, type QueryResult, type ReadableResources, type RealtimeOptions, type RealtimePrune, type RealtimeRelayOptions, type ReasoningDetail, type ReasoningEffort, type RebindOption, type RecordGroups, type RecordKey, type RecordKeyInput, type RecordPage, type RelayChannelOptions, type RelayClientEvent, type RelayDevice, type RelayMembers, type RelayPresence, type RelayResult, type RelaySendAnswer, type RelaySendRequest, type RelaySettings, type RenderedEmail, type RenderedTemplate, type ResourceChange, type ResourceSource, type RoleDefinition, type RolesInput, type RunContext, type RuntimeOptions, type S3Bucket, type S3FilesOptions, type S3ListPage, type S3Object, type ScanGuardMode, type ScheduledDelete, type SendNotification, SenderAddressError, type SenderAddressErrorCode, SenderAddressNotFoundError, type SenderAddressState, type SentMail, type Session, type SessionOrganization, type Sharp, type SignInPolicy, type SignInRule, type SignatureOptions, type SocketEvents, type SourceOption, type SourceRef, type StaffAccessRule, type StaffSignIn, type StandardSchema, type StandardWebhookOptions, type StartJobsOptions, type StartWorkflowOptions, type StatusOptions, type StoreFileInput, type StoredMember, type StoredNotification, type StoredObject, type StoredOrganization, type StoredUser, type StrayValues, type SubscriptionDefinition, type SubscriptionEvent, type SubscriptionOptions, type TcpBridge, type TcpBridgeOptions, TemplateDataError, type TemplateOptions, type TemplateSchema, type TemplateScope, type TemplateSendOptions, type TemplateText, type TenantValue, type ToolAnnotations, type ToolCall, type ToolComment, type ToolCommentPage, type ToolComments, type ToolContext, type ToolRecord, type ToolRecords, type ToolSpec, type TrustedApp, type TurnOptions, type UnreadableEntry, type UnsubscribeLinks, type Urgency, type User, type UserCreatedHook, type UserTables, type UsersCursor, type UsersPage, type VapidSettings, type ViewSource, type WebPushFields, type WebPushOptions, type WebhooksOptions, type WidgetOptions, type WorkflowCatalog, type WorkflowTypes, type WorkflowsOptions, type WriteEvent, type WriteOperation, type WriteRecordToolsInput, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkMailFeedbackSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkRelayOptions, checkRelaySchema, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUnsubscribesSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, checkWorkflowsSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTemplate, defineTool, deleteRecordTool, deleteUser, derivedMigration, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fcmSender, fcmServiceAccountVariable, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, gmailSettingsScope, goTruePath, handleDroppedConnections, hasBuckets, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, hookPath, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isMailTemplate, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mailCheckHeaders, mailCheckSecret, mailFeedbackHeaders, mailFeedbackMigration, mailFeedbackResource, mailFeedbackSecret, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxRelayDevices, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, organizationsPageSize, overSignIn, ownedDefinitionsMigration, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readApnsSettings, readDbConnections, readDefinitionsVersion, readFcmSettings, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIns, readRecordTools, readRelaySettings, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relayUrlVariable, relayed, releaseConnectionsWithUsers, reloadingAdmin, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, sqlSends, startErrorReporting, startJobs, startWorkflow, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, tcpBridge, thumbHash, typingResources, unauthorized, unsubscribesMigration, updateRecordTool, urgencies, userTableResources, userTablesMigration, usersPageSize, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhookIssuePath, webhookParams, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, workflowInstructions, workflowReadTools, workflowTypes, workflowWriteTools, workflowsMigration, writeRecordTools };
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,9 @@ import { goTruePath } from "./gotrue/keys.js";
|
|
|
34
34
|
import { defaultSignInPolicy, signInPolicyMethods } from "./better-auth/sign-in-policy.js";
|
|
35
35
|
import { parseRoles } from "./better-auth/parse-roles.js";
|
|
36
36
|
import { PersonalMailError } from "./personal-mail/personal-mail-error.js";
|
|
37
|
+
import { gmailSettingsScope } from "./personal-mail/gmail-sender-addresses.js";
|
|
37
38
|
import { MailSenderRefusedError } from "./personal-mail/mail-sender-refused.js";
|
|
39
|
+
import { SenderAddressError, SenderAddressNotFoundError } from "./personal-mail/sender-address-error.js";
|
|
38
40
|
import { newWebhookSecret } from "./webhooks/standard-webhooks.js";
|
|
39
41
|
import { mailCheckHeaders, mailCheckSecret } from "./personal-mail/mail-check-signing.js";
|
|
40
42
|
import { passwordLength } from "./better-auth/new-account-password.js";
|
|
@@ -174,4 +176,4 @@ import { defineEmail } from "./mail/define-email.js";
|
|
|
174
176
|
import { definePdf } from "./pdf/define-pdf.js";
|
|
175
177
|
import { startJobs } from "./jobs/runtime.js";
|
|
176
178
|
import { jobsDrainApp } from "./jobs/drain-route.js";
|
|
177
|
-
export { BulkMailError, ConnectionsBusy, DeviceStoreError, FatalJobError, HistoryStoreError, HttpProblem, MailSenderRefusedError, MailServerTimeoutError, MissingCredentials, ModelError, NotificationSendError, PersonalMailError, PushMessageError, TemplateDataError, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkMailFeedbackSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkRelayOptions, checkRelaySchema, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUnsubscribesSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, checkWorkflowsSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTemplate, defineTool, deleteRecordTool, deleteUser, derivedMigration, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fcmSender, fcmServiceAccountVariable, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, goTruePath, handleDroppedConnections, hasBuckets, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, hookPath, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isMailTemplate, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mailCheckHeaders, mailCheckSecret, mailFeedbackHeaders, mailFeedbackMigration, mailFeedbackResource, mailFeedbackSecret, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxRelayDevices, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, organizationsPageSize, overSignIn, ownedDefinitionsMigration, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readApnsSettings, readDbConnections, readDefinitionsVersion, readFcmSettings, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIns, readRecordTools, readRelaySettings, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relayUrlVariable, relayed, releaseConnectionsWithUsers, reloadingAdmin, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, sqlSends, startErrorReporting, startJobs, startWorkflow, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, tcpBridge, thumbHash, typingResources, unauthorized, unsubscribesMigration, updateRecordTool, urgencies, userTableResources, userTablesMigration, usersPageSize, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhookIssuePath, webhookParams, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, workflowInstructions, workflowReadTools, workflowTypes, workflowWriteTools, workflowsMigration, writeRecordTools };
|
|
179
|
+
export { BulkMailError, ConnectionsBusy, DeviceStoreError, FatalJobError, HistoryStoreError, HttpProblem, MailSenderRefusedError, MailServerTimeoutError, MissingCredentials, ModelError, NotificationSendError, PersonalMailError, PushMessageError, SenderAddressError, SenderAddressNotFoundError, TemplateDataError, addAppRoleToOwners, addCommentTool, addEveryUser, addMember, apiKeyCaller, apiKeySettings, apiKeyVariables, apnsKeyIdVariable, apnsKeyVariable, apnsSender, apnsTeamIdVariable, appNameOver, aspectRatio, assistantProtocolRoutes, assistantRoles, assistantSettings, assistantVariables, authSchemaDrift, authSchemaMigration, authStoreTables, backgroundSettled, badRequest, batchWriteTool, beforeSignInPluginsVariable, betterAuthTokens, bridgeClosings, callsMigration, capSocketMessages, capturedBy, changesMigration, channelSendsMigration, checkAi, checkAuthSchema, checkCalls, checkChanges, checkChannelSends, checkComments, checkComputed, checkDerived, checkJobsSchema, checkMailFeedbackSchema, checkNotificationsSchema, checkQueryRunner, checkRealtimeRelay, checkRelayOptions, checkRelaySchema, checkResourcesOutsideAuthStore, checkSourceNames, checkStatusSchema, checkUnsubscribesSchema, checkUserTablesSchema, checkViewQueries, checkWebhooksSchema, checkWorkflowsSchema, coalesce, commentTools, commentsMigration, computedMigration, configExports, consoleAuditQueue, conversationKey, countRecordsTool, createAdmin, createConversations, createEncryptionTools, createFileCleanup, createOrganization, createRecordTool, createUser, defaultAppName, defaultHistoryPage, defaultSignInPolicy, defineEmail, defineFunction, defineJob, definePdf, defineTemplate, defineTool, deleteRecordTool, deleteUser, derivedMigration, describeResourceTool, deviceIdParam, deviceStore, devicesPath, enqueueJob, errorReportingSettings, errorReportingVariable, eventMatcher, fcmSender, fcmServiceAccountVariable, fileConversationStore, fileSize, fileType, forbidden, formatUri, functionApp, generateVapidKeys, getRecordTool, gmailSettingsScope, goTruePath, handleDroppedConnections, hasBuckets, hasUsers, historyIdParam, historyIdPattern, historyLimits, historyPath, historyStore, honorSocketMessageCaps, hookPath, imageSize, isBackgroundWork, isCaptured, isJobDefinition, isMailTemplate, isOAuthWellKnownPath, isSchedule, issueToken, jobDefinitions, jobsDrainApp, jobsSchema, jobsSchemaMigration, jwtAuthenticator, jwtVerifier, limitedFileStore, listCommentsTool, listOrganizations, listRecordsTool, listResourcesTool, listUsers, localFileStore, longQueryTimeoutMs, mailCheckHeaders, mailCheckSecret, mailFeedbackHeaders, mailFeedbackMigration, mailFeedbackResource, mailFeedbackSecret, mapSettings, mapStyleUrl, mapStyleVariable, maxDevicesPerUser, maxHistoryPage, maxMessageBytes, maxRecipients, maxRelayDevices, maxTokenTtlSeconds, maxTtlSeconds, maxUnreadCount, maxWidgetPropsBytes, mcpApprovals, mcpGate, mcpHandler, mcpIcons, mcpInstructions, mcpRoutes, mcpServer, mcpToolContext, mcpTools, migrationCommand, newWebhookSecret, normalizeRoles, notFound, notificationSenders, notificationsMigration, oauthWellKnownPaths, objectKey, onDoNotDisturb, organizationsPageSize, overSignIn, ownedDefinitionsMigration, parseColumns, parseRoles, passwordLength, pluginOptions, pluginsBeforeSignIn, pluginsFor, pluginsVariable, pngIcons, poolWaitMs, postgresDeviceStore, postgresHistoryStore, processor, pushMessage, queryRunnerMigration, readApnsSettings, readDbConnections, readDefinitionsVersion, readFcmSettings, readJson, readOnlyQueryTool, readOperatorSettings, readOutbox, readPlatformSignIns, readRecordTools, readRelaySettings, readVapidSettings, readWriteQueryTool, readableResources, realtimeLimits, realtimeRelayMigration, recordBlocksOf, recordOf, redactHookKeys, refusalOf, refused, relayClientEvents, relayCredentialVariable, relayHandle, relayMigration, relayPresencePath, relayResults, relaySendAnswer, relaySendPath, relaySendRequest, relaySender, relayUrlVariable, relayed, releaseConnectionsWithUsers, reloadingAdmin, removeDevicesWithUsers, removeHistoryWithUsers, removeMember, renderVariant, requestApproval, requireEnv, resourceChange, roleChoices, runInBackground, runReadOnlyQuery, runReadWriteQuery, runTurn, runtimeUrl, runtimeVariable, s3FileStore, seesAssistant, seesRuntime, sendNotification, sessionOf, setMemberRoles, setUserBanned, setUserRole, shownAppName, signInPolicyMethods, socketMessageCapOf, sourceOptions, sourcesFor, sourcesVariable, sqlSends, startErrorReporting, startJobs, startWorkflow, statusMigration, statusNames, storageCleanupSchedule, storageProvider, storeFile, storeUsage, streamChatCompletion, subscription, supabasePath, tcpBridge, thumbHash, typingResources, unauthorized, unsubscribesMigration, updateRecordTool, urgencies, userTableResources, userTablesMigration, usersPageSize, vapidPrivateKeyVariable, vapidPublicKeyVariable, vapidSubjectVariable, variantPath, verifySignature, verifyStandardWebhook, waitUntil, wantsLongQueries, webManifestPath, webPushSender, webauthnPath, webhookIssuePath, webhookParams, webhooksMigration, widget, withCacheBreakpoints, withTrustedApps, workflowInstructions, workflowReadTools, workflowTypes, workflowWriteTools, workflowsMigration, writeRecordTools };
|
package/dist/package.js
CHANGED
|
@@ -2,11 +2,11 @@ import { messages } from "../locale/messages.js";
|
|
|
2
2
|
//#region src/personal-mail/alias-checks.ts
|
|
3
3
|
const text = messages("personal-mail");
|
|
4
4
|
const aliasChecks = (service, mailOf) => ({
|
|
5
|
-
start: async (userId, address, locale) => {
|
|
5
|
+
start: async (userId, { id, address }, locale) => {
|
|
6
6
|
const { token, address: to } = await service.issue();
|
|
7
7
|
const say = text(locale);
|
|
8
8
|
await mailOf(userId).send({
|
|
9
|
-
|
|
9
|
+
sender_address_id: id,
|
|
10
10
|
to,
|
|
11
11
|
subject: say("ALIAS_CHECK_SUBJECT", { address }),
|
|
12
12
|
text: say("ALIAS_CHECK_TEXT", { address })
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/personal-mail/gmail-errors.ts
|
|
2
|
+
const gmailError = async (response) => {
|
|
3
|
+
if (!response.headers.get("content-type")?.includes("json")) return;
|
|
4
|
+
const text = await response.text();
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(text).error;
|
|
7
|
+
} catch (error) {
|
|
8
|
+
if (error instanceof SyntaxError) return;
|
|
9
|
+
throw error;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const gmailReason = (error) => {
|
|
13
|
+
const reasons = [...error?.errors ?? [], ...error?.details ?? []].map((entry) => entry.reason);
|
|
14
|
+
return reasons.includes("insufficientPermissions") || reasons.includes("ACCESS_TOKEN_SCOPE_INSUFFICIENT") ? "insufficientPermissions" : reasons[0];
|
|
15
|
+
};
|
|
16
|
+
const gmailCause = (error) => {
|
|
17
|
+
if (!error) return "";
|
|
18
|
+
const detail = [error.errors?.[0]?.reason, error.message].filter(Boolean).join(": ");
|
|
19
|
+
return `${error.status ? ` ${error.status}` : ""}${detail ? ` (${detail})` : ""}`;
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { gmailCause, gmailError, gmailReason };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
//#region src/personal-mail/gmail-sender-addresses.d.ts
|
|
2
|
+
/** The narrowest scope that reads the send-as addresses, which an app adds to the Gmail link to list them. */
|
|
3
|
+
export declare const gmailSettingsScope = "https://www.googleapis.com/auth/gmail.settings.basic";
|
|
4
|
+
//#endregion
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { PersonalMailError } from "./personal-mail-error.js";
|
|
2
|
+
import { gmailError, gmailReason } from "./gmail-errors.js";
|
|
3
|
+
import { SenderListingError } from "./personal-mail-provider.js";
|
|
4
|
+
import { senderAddressOf } from "./sender-address-input.js";
|
|
5
|
+
//#region src/personal-mail/gmail-sender-addresses.ts
|
|
6
|
+
/** The narrowest scope that reads the send-as addresses, which an app adds to the Gmail link to list them. */
|
|
7
|
+
const gmailSettingsScope = "https://www.googleapis.com/auth/gmail.settings.basic";
|
|
8
|
+
const listingScopes = [
|
|
9
|
+
gmailSettingsScope,
|
|
10
|
+
"https://www.googleapis.com/auth/gmail.readonly",
|
|
11
|
+
"https://www.googleapis.com/auth/gmail.modify",
|
|
12
|
+
"https://mail.google.com/"
|
|
13
|
+
];
|
|
14
|
+
const gmailSendAsUrl = "https://gmail.googleapis.com/gmail/v1/users/me/settings/sendAs";
|
|
15
|
+
const stateOf = (entry) => {
|
|
16
|
+
if (entry.isPrimary === true || entry.verificationStatus === "accepted") return "verified";
|
|
17
|
+
if (entry.verificationStatus === "pending") return "pending";
|
|
18
|
+
};
|
|
19
|
+
const incomplete = (why) => new SenderListingError(`Gmail's send-as list came back incomplete: ${why}`);
|
|
20
|
+
/**
|
|
21
|
+
* The send-as addresses of the Gmail account, through `users.settings.sendAs.list`, which answers them all at once:
|
|
22
|
+
* the reference names no paging. The listing is only taken as complete when every entry is a usable address and no
|
|
23
|
+
* page token says there are more; otherwise it is an error, so absence from it never counts against an address.
|
|
24
|
+
*/
|
|
25
|
+
const listGmailSenderAddresses = async (fetcher, { accessToken, scopes }) => {
|
|
26
|
+
if (!scopes.some((scope) => listingScopes.includes(scope))) return {
|
|
27
|
+
kind: "not_permitted",
|
|
28
|
+
missing_scopes: [gmailSettingsScope]
|
|
29
|
+
};
|
|
30
|
+
const response = await reach(() => fetcher(gmailSendAsUrl, { headers: { authorization: `Bearer ${accessToken}` } }));
|
|
31
|
+
if (response.status === 401) throw new PersonalMailError("link_expired", "gmail");
|
|
32
|
+
if (response.status === 403) {
|
|
33
|
+
if (gmailReason(await gmailError(response)) === "insufficientPermissions") return {
|
|
34
|
+
kind: "not_permitted",
|
|
35
|
+
missing_scopes: [gmailSettingsScope]
|
|
36
|
+
};
|
|
37
|
+
throw new SenderListingError("Gmail refused the send-as list: 403");
|
|
38
|
+
}
|
|
39
|
+
if (!response.ok) throw new SenderListingError(`Gmail refused the send-as list: ${response.status} ${response.statusText}`);
|
|
40
|
+
const body = await jsonBody(response);
|
|
41
|
+
if (!body || typeof body !== "object" || !Array.isArray(body.sendAs)) throw incomplete("no sendAs list");
|
|
42
|
+
if ("nextPageToken" in body) throw incomplete("a page token");
|
|
43
|
+
return {
|
|
44
|
+
kind: "listed",
|
|
45
|
+
addresses: body.sendAs.map((entry) => {
|
|
46
|
+
const address = entry && typeof entry === "object" ? senderAddressOf(entry.sendAsEmail) : void 0;
|
|
47
|
+
if (!address) throw incomplete("an entry that is not an address");
|
|
48
|
+
const provider_state = stateOf(entry);
|
|
49
|
+
return {
|
|
50
|
+
address,
|
|
51
|
+
...provider_state && { provider_state }
|
|
52
|
+
};
|
|
53
|
+
})
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const reach = async (call) => {
|
|
57
|
+
try {
|
|
58
|
+
return await call();
|
|
59
|
+
} catch (error) {
|
|
60
|
+
if (error instanceof TypeError) throw new SenderListingError(`Gmail could not be reached: ${error.message}`);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const jsonBody = async (response) => {
|
|
65
|
+
const text = await response.text();
|
|
66
|
+
try {
|
|
67
|
+
return JSON.parse(text);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
if (error instanceof SyntaxError) throw incomplete("a body that is not JSON");
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
//#endregion
|
|
74
|
+
export { gmailSendAsUrl, gmailSettingsScope, listGmailSenderAddresses };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { PersonalMailError } from "./personal-mail-error.js";
|
|
2
2
|
import { rfc822Message } from "./rfc822-message.js";
|
|
3
|
+
import { gmailCause, gmailError, gmailReason } from "./gmail-errors.js";
|
|
4
|
+
import { gmailSettingsScope, listGmailSenderAddresses } from "./gmail-sender-addresses.js";
|
|
3
5
|
//#region src/personal-mail/gmail.ts
|
|
4
6
|
/** The Gmail API's scope that sends mail and nothing else: no reading of the mailbox. */
|
|
5
7
|
const gmailSendScope = "https://www.googleapis.com/auth/gmail.send";
|
|
@@ -9,7 +11,8 @@ const gmailSendUrl = "https://gmail.googleapis.com/upload/gmail/v1/users/me/mess
|
|
|
9
11
|
* Gmail, linked through Google sign-in: offline access, so Google gives a refresh token, asked with `prompt=consent`
|
|
10
12
|
* so it gives one again on a second link. Without `from`, Gmail sets the From header to the linked address; with it,
|
|
11
13
|
* Gmail keeps it when it is one of the account's verified send-as addresses, and puts the account's own address in its
|
|
12
|
-
* place when it is not, still sending the message
|
|
14
|
+
* place when it is not, still sending the message: so a link with `gmailSettingsScope` lists the send-as addresses,
|
|
15
|
+
* which tells the ones Gmail sends as from the others.
|
|
13
16
|
*
|
|
14
17
|
* A send resolves to no `messageId`: Gmail puts its own `Message-ID` on the mail it sends, and its answer, the sent
|
|
15
18
|
* message's Gmail id, does not name it; reading it back takes a scope that reads the mailbox, which the link does not ask for.
|
|
@@ -19,6 +22,8 @@ const gmail = (fetcher = (...args) => fetch(...args)) => ({
|
|
|
19
22
|
name: "Gmail",
|
|
20
23
|
signInProvider: "google",
|
|
21
24
|
scopes: [gmailSendScope],
|
|
25
|
+
optionalScopes: [gmailSettingsScope],
|
|
26
|
+
addedScopes: [],
|
|
22
27
|
linkParams: {
|
|
23
28
|
access_type: "offline",
|
|
24
29
|
prompt: "consent"
|
|
@@ -38,26 +43,8 @@ const gmail = (fetcher = (...args) => fetch(...args)) => ({
|
|
|
38
43
|
const error = await gmailError(response);
|
|
39
44
|
if (response.status === 403 && gmailReason(error) === "insufficientPermissions") throw new PersonalMailError("link_expired", "gmail");
|
|
40
45
|
throw new Error(`Gmail refused the message: ${response.status} ${response.statusText}${gmailCause(error)}`);
|
|
41
|
-
}
|
|
46
|
+
},
|
|
47
|
+
list_sender_addresses: (connection) => listGmailSenderAddresses(fetcher, connection)
|
|
42
48
|
});
|
|
43
|
-
const gmailError = async (response) => {
|
|
44
|
-
if (!response.headers.get("content-type")?.includes("json")) return;
|
|
45
|
-
const text = await response.text();
|
|
46
|
-
try {
|
|
47
|
-
return JSON.parse(text).error;
|
|
48
|
-
} catch (error) {
|
|
49
|
-
if (error instanceof SyntaxError) return;
|
|
50
|
-
throw error;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
const gmailReason = (error) => {
|
|
54
|
-
const reasons = [...error?.errors ?? [], ...error?.details ?? []].map((entry) => entry.reason);
|
|
55
|
-
return reasons.includes("insufficientPermissions") || reasons.includes("ACCESS_TOKEN_SCOPE_INSUFFICIENT") ? "insufficientPermissions" : reasons[0];
|
|
56
|
-
};
|
|
57
|
-
const gmailCause = (error) => {
|
|
58
|
-
if (!error) return "";
|
|
59
|
-
const detail = [error.errors?.[0]?.reason, error.message].filter(Boolean).join(": ");
|
|
60
|
-
return `${error.status ? ` ${error.status}` : ""}${detail ? ` (${detail})` : ""}`;
|
|
61
|
-
};
|
|
62
49
|
//#endregion
|
|
63
|
-
export { gmail, gmailSendScope, gmailSendUrl };
|
|
50
|
+
export { gmail, gmailSendScope, gmailSendUrl, gmailSettingsScope };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import "./sender-store.js";
|
|
2
|
+
import { SenderRowState } from "./sender-address-state.js";
|
|
3
|
+
import "./mail-sender.js";
|
|
4
|
+
//#region src/personal-mail/listed-mail-senders.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* An address as the account page lists it: its `state`, `detached` for one on no connection they can send through,
|
|
7
|
+
* and its `connection`, none when detached; `listedAt` when the provider's last listing held it.
|
|
8
|
+
*/
|
|
9
|
+
export type ListedMailSender = {
|
|
10
|
+
id: string;
|
|
11
|
+
address: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
signature?: string;
|
|
14
|
+
isDefault: boolean;
|
|
15
|
+
state: Exclude<SenderRowState, 'removed'>;
|
|
16
|
+
connection?: string;
|
|
17
|
+
listedAt?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A mailbox connection as the account page lists it: its provider, its own address when the link names it, whether
|
|
21
|
+
* its provider can list its send-as addresses, and the scopes the app adds to the link that it does not hold yet, so
|
|
22
|
+
* connecting it again lets it list.
|
|
23
|
+
*/
|
|
24
|
+
export type ListedConnection = {
|
|
25
|
+
id: string;
|
|
26
|
+
provider: string;
|
|
27
|
+
address?: string;
|
|
28
|
+
canList: boolean;
|
|
29
|
+
missingScopes: string[];
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { stateIn } from "./mail-sender.js";
|
|
2
|
+
//#region src/personal-mail/listed-mail-senders.ts
|
|
3
|
+
const listedSender = (book, row) => {
|
|
4
|
+
const state = stateIn(book, row);
|
|
5
|
+
if (state === "removed") return;
|
|
6
|
+
return {
|
|
7
|
+
id: row.id,
|
|
8
|
+
address: row.address,
|
|
9
|
+
...row.name && { name: row.name },
|
|
10
|
+
...row.signature && { signature: row.signature },
|
|
11
|
+
isDefault: row.isDefault,
|
|
12
|
+
state,
|
|
13
|
+
...state !== "detached" && row.connectionId && { connection: row.connectionId },
|
|
14
|
+
...row.listedAt && { listedAt: new Date(row.listedAt).toISOString() }
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
/** The person's addresses and connections, as `GET /account/mail-senders` answers them. */
|
|
18
|
+
const listedMailSenders = (book) => ({
|
|
19
|
+
...book.ownAddress && { address: book.ownAddress },
|
|
20
|
+
senders: book.rows.flatMap((row) => listedSender(book, row) ?? []),
|
|
21
|
+
connections: book.connections.map(({ account, provider }) => ({
|
|
22
|
+
id: account.id,
|
|
23
|
+
provider: provider.id,
|
|
24
|
+
...account.address && { address: account.address },
|
|
25
|
+
canList: Boolean(provider.list_sender_addresses),
|
|
26
|
+
missingScopes: provider.addedScopes.filter((scope) => !account.scopes.includes(scope))
|
|
27
|
+
}))
|
|
28
|
+
});
|
|
29
|
+
//#endregion
|
|
30
|
+
export { listedMailSenders, listedSender };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { idTokenAddress, storedScopes } from "./linked-accounts.js";
|
|
2
|
+
import { mailboxConnections } from "./mailbox-connections.js";
|
|
3
|
+
import { linkedMailbox } from "./personal-mailer.js";
|
|
4
|
+
//#region src/personal-mail/mail-sender-book.ts
|
|
5
|
+
/** The accounts as sending reads them, each with the address its ID token names. */
|
|
6
|
+
const linkedAccountsOf = (accounts) => accounts.map((account) => {
|
|
7
|
+
const address = idTokenAddress(account.idToken);
|
|
8
|
+
return {
|
|
9
|
+
id: account.id,
|
|
10
|
+
providerId: account.providerId,
|
|
11
|
+
scopes: storedScopes(account.scope),
|
|
12
|
+
createdAt: account.createdAt,
|
|
13
|
+
...address && { address }
|
|
14
|
+
};
|
|
15
|
+
});
|
|
16
|
+
/** `userId`'s From address rows and mailbox connections, with the address of the connection mail goes through last. */
|
|
17
|
+
const senderBook = (userId, rows, accounts, providers) => {
|
|
18
|
+
const linked = linkedAccountsOf(accounts);
|
|
19
|
+
const ownAddress = linkedMailbox(linked, providers)?.account.address;
|
|
20
|
+
return {
|
|
21
|
+
userId,
|
|
22
|
+
rows,
|
|
23
|
+
connections: mailboxConnections(linked, providers),
|
|
24
|
+
...ownAddress && { ownAddress }
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//#endregion
|
|
28
|
+
export { linkedAccountsOf, senderBook };
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import "./sender-store.js";
|
|
2
|
+
import { SenderAddressState } from "./sender-address-state.js";
|
|
3
|
+
import "./mailbox-connections.js";
|
|
2
4
|
//#region src/personal-mail/mail-sender.d.ts
|
|
3
5
|
/**
|
|
4
|
-
* A From address someone may send mail from: `
|
|
5
|
-
*
|
|
6
|
-
* `
|
|
6
|
+
* A From address someone may send mail from: `id`, the record a send names (`sender_address_id`), null for the
|
|
7
|
+
* mailbox's own address, which goes out with no From header, so the provider fills in its own; `address`, unknown
|
|
8
|
+
* when it is the mailbox's own and the link does not name it; the display `name` its owner entered, if any; `ownerId`,
|
|
9
|
+
* whose mailbox it goes out through; its own `signature`, if it has one; and its `state` (`SenderAddressState`). The
|
|
10
|
+
* mailbox's own address is `verified`: the provider's sign-in vouches for it.
|
|
7
11
|
*/
|
|
8
12
|
export type MailSender = {
|
|
13
|
+
id: string | null;
|
|
9
14
|
address?: string;
|
|
10
15
|
name?: string;
|
|
11
16
|
ownerId: string;
|
|
12
17
|
signature?: string;
|
|
18
|
+
state: SenderAddressState;
|
|
13
19
|
};
|
|
14
20
|
//#endregion
|