@protobase/server 0.63.0 → 0.63.1
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.
|
@@ -113,10 +113,10 @@ export type CreateAuthOptions = {
|
|
|
113
113
|
/**
|
|
114
114
|
* The mail providers people may link their own mailbox with, from the account page, for the app's functions to send
|
|
115
115
|
* mail from it (`context.personalMail`), such as `['gmail']`. Each links through its sign-in provider, which
|
|
116
|
-
* `socialProviders` must have: Gmail through `google`. Default none.
|
|
116
|
+
* `socialProviders` must have: Gmail through `google`. Needs `encryptOAuthTokens`. Default none.
|
|
117
117
|
*/
|
|
118
118
|
personalMail?: PersonalMailProviderId[];
|
|
119
|
-
/** Encrypt the OAuth access
|
|
119
|
+
/** Encrypt the OAuth access and refresh tokens Better Auth stores for social sign-ins, with `secret`; `personalMail` needs it. Default off. */
|
|
120
120
|
encryptOAuthTokens?: boolean;
|
|
121
121
|
/** Runs after a user is created, by any route: `createUser`, an admin, or a social sign-up. Default none. */
|
|
122
122
|
onUserCreated?: UserCreatedHook;
|
|
@@ -78,6 +78,7 @@ const tokenLifetime = "15m";
|
|
|
78
78
|
/** The configured roles with `admin` first; `admin` is added when missing. */
|
|
79
79
|
const normalizeRoles = (roles) => roleDefinitions(roles).names;
|
|
80
80
|
const adminImpersonationPaths = ["/admin/impersonate-user", "/admin/stop-impersonating"];
|
|
81
|
+
const providerTokenPaths = ["/get-access-token", "/refresh-token"];
|
|
81
82
|
/** The optional plugins `options` turns on, imported: an app without SAML or MCP loads neither. */
|
|
82
83
|
const loadAuthPlugins = async (options) => ({
|
|
83
84
|
...(options.sso?.saml.length ?? 0) > 0 && { samlPlugin: (await import("./saml-plugin.js")).samlPlugin },
|
|
@@ -268,6 +269,7 @@ const betterAuthOptions = (options, { origins = [], passkeyDomain, roles, defini
|
|
|
268
269
|
...accountDeletion ? [] : [selfDeletionPath],
|
|
269
270
|
...unusedEmailCodePaths,
|
|
270
271
|
...adminImpersonationPaths,
|
|
272
|
+
...providerTokenPaths,
|
|
271
273
|
...organizations ? organizationPaths : [],
|
|
272
274
|
...saml.length > 0 ? samlDisabledPaths : [],
|
|
273
275
|
...mcp ? mcpUnusedPaths : []
|
|
@@ -371,7 +373,7 @@ const createAuth = (options, plugins = {}) => {
|
|
|
371
373
|
const socialProviders = Object.keys(options.socialProviders ?? {});
|
|
372
374
|
const platformSignIn = platformSignInFor(signInSettings && resolvePlatformSignIn(signInSettings), socialProviders);
|
|
373
375
|
const saml = resolveSamlProviders(options.sso?.saml ?? [], [...socialProviders, ...platformSignIn ? [platformSignIn.provider] : []]);
|
|
374
|
-
const personalMail = resolvePersonalMail(options.personalMail ?? [], socialProviders);
|
|
376
|
+
const personalMail = resolvePersonalMail(options.personalMail ?? [], socialProviders, options.encryptOAuthTokens === true);
|
|
375
377
|
const origins = resolveOrigins(options.baseURL, options.origins ?? platformOrigins());
|
|
376
378
|
const passkeyDomain = resolvePasskeyDomain(options.passkeyDomain ?? platformPasskeyDomain(), [options.baseURL, ...origins]);
|
|
377
379
|
const organizations = options.organizations && resolveOrganizations(options.organizations, definitions, options.baseURL);
|
|
@@ -477,4 +479,4 @@ const createAuth = (options, plugins = {}) => {
|
|
|
477
479
|
/** `createAuth` with the optional plugins its options turn on loaded first (see `loadAuthPlugins`). */
|
|
478
480
|
const buildAuth = async (options) => createAuth(options, await loadAuthPlugins(options));
|
|
479
481
|
//#endregion
|
|
480
|
-
export { authBasePath, betterAuthOptions, buildAuth, createAuth, loadAuthPlugins, normalizeRoles };
|
|
482
|
+
export { authBasePath, betterAuthOptions, buildAuth, createAuth, loadAuthPlugins, normalizeRoles, providerTokenPaths };
|
package/dist/package.js
CHANGED
|
@@ -4,13 +4,17 @@ import { gmail } from "./gmail.js";
|
|
|
4
4
|
const personalMailProviders = { gmail };
|
|
5
5
|
/**
|
|
6
6
|
* The providers of `ids`, each checked against the app's sign-in providers: linking one goes through its sign-in
|
|
7
|
-
* provider, so an app without it is a configuration error at startup.
|
|
7
|
+
* provider, so an app without it is a configuration error at startup. So is one whose OAuth tokens are not encrypted
|
|
8
|
+
* (`encryptOAuthTokens`): a linked account's tokens send mail as the person, so they are never stored in plain text.
|
|
8
9
|
*/
|
|
9
|
-
const resolvePersonalMail = (ids, signInProviders
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
});
|
|
10
|
+
const resolvePersonalMail = (ids, signInProviders, encryptOAuthTokens) => {
|
|
11
|
+
if (ids.length > 0 && !encryptOAuthTokens) throw new Error("auth.personalMail: the linked mailboxes' tokens would be stored in plain text; turn on auth.encryptOAuthTokens");
|
|
12
|
+
return ids.map((id) => {
|
|
13
|
+
if (!Object.hasOwn(personalMailProviders, id)) throw new Error(`auth.personalMail: "${id}" is not a mail provider; use one of ${Object.keys(personalMailProviders).join(", ")}`);
|
|
14
|
+
const provider = personalMailProviders[id]();
|
|
15
|
+
if (!signInProviders.includes(provider.signInProvider)) throw new Error(`auth.personalMail: ${provider.name} links through the sign-in provider "${provider.signInProvider}"; add it to auth.socialProviders`);
|
|
16
|
+
return provider;
|
|
17
|
+
});
|
|
18
|
+
};
|
|
15
19
|
//#endregion
|
|
16
20
|
export { personalMailProviders, resolvePersonalMail };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@protobase/server",
|
|
3
|
-
"version": "0.63.
|
|
3
|
+
"version": "0.63.1",
|
|
4
4
|
"description": "The Protobase REST API as a Hono app, with Better Auth sign-in.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"@better-auth/sso": "^1.7.12",
|
|
43
43
|
"@livekit/protocol": "1.53.1",
|
|
44
44
|
"@modelcontextprotocol/server": "^2.3.1",
|
|
45
|
-
"@protobase/layout": "0.63.
|
|
46
|
-
"@protobase/query": "0.63.
|
|
47
|
-
"@protobase/schema": "0.63.
|
|
45
|
+
"@protobase/layout": "0.63.1",
|
|
46
|
+
"@protobase/query": "0.63.1",
|
|
47
|
+
"@protobase/schema": "0.63.1",
|
|
48
48
|
"@react-email/render": "^2.1.0",
|
|
49
49
|
"@scalar/hono-api-reference": "^0.12.10",
|
|
50
50
|
"@sentry/core": "^11.7.0",
|