@plitzi/sdk-server 0.38.22 → 0.38.23
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @plitzi/sdk-server
|
|
2
2
|
|
|
3
|
+
## 0.38.23
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1e93ac7: ## Server
|
|
8
|
+
|
|
9
|
+
- **The project's server sends OAuth providers back to its loopback** (`@plitzi/sdk-server`) — PZ-160. 0.38.22 chose
|
|
10
|
+
`publicUrl`, which without `PUBLIC_URL` is the machine's address on the network: a private IP the router may change and
|
|
11
|
+
providers refuse, so a project opened to the network could no longer connect a new account. The callback origin is now
|
|
12
|
+
`127.0.0.1` unless `PUBLIC_URL` is HTTPS, and `serverOptions.functions.oauth.callbackOrigin` names another without
|
|
13
|
+
touching `PUBLIC_URL`. Open to the network with a loopback callback, the server says that a sign-in another device
|
|
14
|
+
starts needs a name of its own.
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [1e93ac7]
|
|
17
|
+
- @plitzi/plitzi-sdk@0.38.23
|
|
18
|
+
- @plitzi/sdk-shared@0.38.23
|
|
19
|
+
|
|
3
20
|
## 0.38.22
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AuthoredDocuments } from './watchSpace';
|
|
2
2
|
import { ServerConfig } from '../../core/createServer';
|
|
3
3
|
import { ConnectorManifest } from '../../modules/connectors';
|
|
4
|
+
import { FunctionsConfig } from '../../modules/functions/config';
|
|
4
5
|
import { ActionEntry, SSRServer } from '@plitzi/sdk-shared';
|
|
5
6
|
/** What `serveProject` sets itself, from the project's layout — so never the project's options'. */
|
|
6
7
|
type SetByProject = 'port' | 'health' | 'adapters' | 'plugins' | 'publicDir' | 'dataDir' | 'functions' | 'action';
|
|
@@ -14,6 +15,12 @@ type SetByProject = 'port' | 'health' | 'adapters' | 'plugins' | 'publicDir' | '
|
|
|
14
15
|
*/
|
|
15
16
|
export type ProjectServerOptions = Partial<Omit<ServerConfig, SetByProject>> & {
|
|
16
17
|
action?: Omit<NonNullable<ServerConfig['action']>, 'lookups'>;
|
|
18
|
+
/**
|
|
19
|
+
* Of the functions, what is the project's to say: `oauth.callbackOrigin`, the one address OAuth providers send a
|
|
20
|
+
* visitor back to — this machine's loopback unless `PUBLIC_URL` says where people reach it. A name of its own for a
|
|
21
|
+
* sign-in another device starts (`https://aiko.example.com:8080`, `process.env.OAUTH_CALLBACK_ORIGIN`).
|
|
22
|
+
*/
|
|
23
|
+
functions?: Pick<FunctionsConfig, 'oauth'>;
|
|
17
24
|
};
|
|
18
25
|
/** A space authored in the project — `authorProjectSpace` of `@plitzi/sdk-authoring/node` — and what it warned of. */
|
|
19
26
|
export type ProjectSpace = AuthoredDocuments & {
|
|
@@ -73,14 +73,14 @@ var LOOPBACK = /* @__PURE__ */ new Set([
|
|
|
73
73
|
]);
|
|
74
74
|
var ANY_ADDRESS = /* @__PURE__ */ new Set(["0.0.0.0", "::"]);
|
|
75
75
|
/**
|
|
76
|
-
* Where OAuth providers send a visitor back (`ctx.oauth`)
|
|
77
|
-
* opened on
|
|
78
|
-
*
|
|
76
|
+
* Where OAuth providers send a visitor back (`ctx.oauth`) when the project does not say: the one address to register,
|
|
77
|
+
* whichever this server was opened on. `PUBLIC_URL`, the address people reach it at, when it is HTTPS; this machine's
|
|
78
|
+
* loopback otherwise — the one address every provider takes. Never its address on the network, which the router may
|
|
79
|
+
* change and providers refuse (a private IP, a `.local` name), nor `localhost`, refused too (RFC 8252).
|
|
79
80
|
*/
|
|
80
81
|
var oauthCallbackOrigin = (publicUrl, localUrl) => {
|
|
81
|
-
const reached = new URL(publicUrl);
|
|
82
|
-
|
|
83
|
-
return reached.protocol === "https:" || loopback ? reached.origin : new URL(localUrl).origin;
|
|
82
|
+
const reached = publicUrl === void 0 ? void 0 : new URL(publicUrl);
|
|
83
|
+
return reached?.protocol === "https:" ? reached.origin : new URL(localUrl).origin;
|
|
84
84
|
};
|
|
85
85
|
/** An address as a URL writes it: an IPv6 one in brackets. */
|
|
86
86
|
var urlHost = (address) => address.includes(":") ? `[${address}]` : address;
|
|
@@ -217,7 +217,7 @@ var startProject = async (options) => {
|
|
|
217
217
|
}) : cloudAdapters(plugins.names);
|
|
218
218
|
const functionsDir = path.join(root, FUNCTIONS_DIR);
|
|
219
219
|
const functions = existsSync(functionsDir) ? await loadFunctions(functionsDir) : [];
|
|
220
|
-
const callbackOrigin = oauthCallbackOrigin(
|
|
220
|
+
const callbackOrigin = serverOptions.functions?.oauth?.callbackOrigin ?? oauthCallbackOrigin(process.env.PUBLIC_URL, localUrl);
|
|
221
221
|
const runtimeBundle = path.join(root, RUNTIME_BUNDLE);
|
|
222
222
|
const spaceRuntime = await loadRuntimeModule(projectModule(root, RUNTIME_ENTRY, process.argv[1])) ?? (existsSync(runtimeBundle) ? await loadRuntime(readFileSync(runtimeBundle), path.join(root, PROJECT_TMP, "runtime")) : void 0);
|
|
223
223
|
const runtime = spaceRuntime && await serveRuntime(spaceRuntime, {
|
|
@@ -273,7 +273,10 @@ var startProject = async (options) => {
|
|
|
273
273
|
console.log(`pages on ${localUrl}/`);
|
|
274
274
|
if (network.length > 0) console.log(`also on ${network.map((address) => `${address}/`).join(", ")} — anyone on this network can open it (HOST=${host})`);
|
|
275
275
|
else if (developing && LOOPBACK.has(host)) console.log("only this machine opens it: HOST=0.0.0.0 in .env opens it to your network (a phone on the Wi-Fi)");
|
|
276
|
-
if ([...functions, ...runtime?.native ?? []].some((definition) => Object.keys(definition.oauth ?? {}).length > 0))
|
|
276
|
+
if ([...functions, ...runtime?.native ?? []].some((definition) => Object.keys(definition.oauth ?? {}).length > 0)) {
|
|
277
|
+
console.log(`OAuth providers send visitors back to ${callbackOrigin}${FUNCTION_ROUTES_PREFIX}${OAUTH_CALLBACK_PATH} — the address to register with each`);
|
|
278
|
+
if (network.length > 0 && new URL(callbackOrigin).origin === new URL(localUrl).origin) console.log(" a sign-in started on another device (a tablet) comes back to its own loopback: for one, give this server a name providers accept — functions.oauth.callbackOrigin in src/config/serverOptions.ts, or PUBLIC_URL");
|
|
279
|
+
}
|
|
277
280
|
if (reached.unnamed.length > 0) console.warn(`[tls] the certificate does not name ${reached.unnamed.join(", ")}: a device that opens it there is refused — \`plitzi cert\` makes one for this machine as it is now`);
|
|
278
281
|
}
|
|
279
282
|
const watching = developing ? [...held ? [watchSpace(root, (authored) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-server",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.23",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
"./dist/env.js"
|
|
115
115
|
],
|
|
116
116
|
"dependencies": {
|
|
117
|
-
"@plitzi/plitzi-sdk": "0.38.
|
|
118
|
-
"@plitzi/sdk-shared": "0.38.
|
|
117
|
+
"@plitzi/plitzi-sdk": "0.38.23",
|
|
118
|
+
"@plitzi/sdk-shared": "0.38.23",
|
|
119
119
|
"ejs": "^7.0.2",
|
|
120
120
|
"esbuild": "^0.28.2",
|
|
121
121
|
"jsonwebtoken": "^9.0.3",
|