@plitzi/sdk-shared 0.38.18 → 0.38.20

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,86 @@
1
1
  # @plitzi/sdk-shared
2
2
 
3
+ ## 0.38.20
4
+
5
+ ### Patch Changes
6
+
7
+ - c7c241a: ## Security
8
+
9
+ - **The `Origin` fallback reads the request's own authority before a forwarded one** (`@plitzi/sdk-server`): 0.38.19
10
+ took `X-Forwarded-Host` first, and with no proxy in front a client could send one naming this host on another port,
11
+ making that port's `Origin` this server's own. Now `:authority` or `Host` decide whenever they name the host the
12
+ request is answered as; `X-Forwarded-Host` only when they do not — a host that took its hostname from the header
13
+ (Express's `trust proxy`) trusts the proxy that wrote it. No option to set: what the host resolved says which one it
14
+ believes. The write guard (`crossSiteWrites`), the sign-in's login-CSRF check and `createOriginGuardMiddleware`
15
+ share it.
16
+
17
+ ## Server
18
+ - **`ctx.oauth`: OAuth 2.0 for a space's code, any provider** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): a
19
+ connection is data in `defineFunctions({ oauth: { calendar: { issuer | authorizeUrl + tokenUrl, credential, scopes,
20
+ authorizeParams, clientAuth } } })` — an OpenID provider by its `issuer` (endpoints discovered), any other by its
21
+ endpoints; none is known to the platform by name. `ctx.oauth.connect(name, { returnTo, owner? })` answers the
22
+ consent URL (authorization code with PKCE); the platform answers `/fn/oauth/callback` — the one address to register
23
+ with every provider — exchanges the code with the app's id and secret from the named credential, and sends the
24
+ visitor back to `returnTo` with `?oauth=<name>&oauth_result=connected` (or `&oauth_error=`). `ctx.oauth.fetch(name,
25
+ url)` writes the token in, renewed before it lapses and once more on a 401, only to `allow.hosts`; `status` and
26
+ `disconnect` (revoked where the provider says). A token is a signed-in visitor's own by default, `{ owner: 'space' }`
27
+ the space's, or a key of the code's own; it is kept in the space's `kv` sealed with a key of the space's that no
28
+ `ctx.sign` reaches, so the code never holds one. In the sandbox, natively and in a space's runtime alike; a plugin's
29
+ functions declare and reach none. Needs `signingSecret`. Runs also carry the `origin` of the request that started
30
+ them (`ctx.origin` of a task context), what the callback address is made of.
31
+
32
+ ## Packages
33
+ - **No path a package does not export is written anywhere in the packages** (`@plitzi/plitzi-sdk`,
34
+ `@plitzi/sdk-shared`): two JSDoc comments sent readers to `@plitzi/sdk-authoring/testing`, which is not an entry —
35
+ `inspectRenders` is exported by `@plitzi/sdk-authoring`. `yarn check:specifiers` (in CI after the build) reads every
36
+ `@plitzi/<package>/<path>` the workspace writes — the code, its built declarations, JSDoc, skills and docs — against
37
+ what that package exports, so an import somebody would copy into a project and get `ERR_MODULE_NOT_FOUND` from cannot
38
+ be published again.
39
+
40
+ - **The packages that run in Node say which Node** (`@plitzi/sdk-server`, `@plitzi/cli`, `@plitzi/sdk-mcp`,
41
+ `@plitzi/sdk-authoring`): `"engines": { "node": ">=22.18" }`, the floor every project the CLI makes already declares —
42
+ installed on an older Node they now say so, instead of failing on the first API it lacks (`--env-file-if-exists`,
43
+ `--permission`, `Set#union`). The browser's packages declare none: a bundler reads them.
44
+
45
+ - **A short render guide, and each part of it alone** (`@plitzi/sdk-mcp`): `renderGuideText` stays the whole guide
46
+ (~30k characters); `renderGuideCore` is a third of it for an agent that counts its tokens — a voice assistant, a small
47
+ model — with the model of a render, the element types, the host's theme and what to do on a refusal, and the address
48
+ of every other section; `renderGuideTopics[topic]` and `renderGuideTopicUri(topic)` (`plitzi://render/guide/repeat`,
49
+ `…/data`…) serve each one, cut from the one text. The MCP server answers them as resources and through `plitzi_read`.
50
+
51
+ ## CLI
52
+ - **What Plitzi decided reaches the agent writing a report** (`@plitzi/cli`): `plitzi feedback`'s brief lists what was
53
+ reported and kept as it is — with why, and what to do instead — so a report files it under `changed` as `decided`
54
+ rather than carrying it as open, and the page has that status.
55
+
56
+ - **The CLI skill says what `ERR_MODULE_NOT_FOUND` into a `@plitzi` package's `dist` is** (`@plitzi/cli`): an import of
57
+ a path the package does not export — a file rather than its folder — with `plitzi doctor` to name each one and
58
+ `plitzi upgrade migrations --write` to rewrite it.
59
+
60
+ ## 0.38.19
61
+
62
+ ### Patch Changes
63
+
64
+ - 92a9f1b: ## Security
65
+
66
+ - **The `Origin` fallback tells the ports apart over HTTP/2 too** (`@plitzi/sdk-server`): a browser that sends no
67
+ `Sec-Fetch-Site` (Safari before 16.4, older webviews) is judged by its `Origin`, compared with the authority the
68
+ request was addressed to. HTTP/2 carries no `Host` header — the authority is `:authority` — and the comparison then
69
+ fell back to the host's NAME, so every port and scheme of it counted as this server's own: what 0.38.18 closed for
70
+ `same-site` stayed open there, over TLS, where a Plitzi server speaks HTTP/2. The authority is now `:authority`,
71
+ `Host`, or the `X-Forwarded-Host` a proxy in front wrote — whichever names the host the request is answered as — port
72
+ included; when none does, the origin is not taken as its own. The write guard (`crossSiteWrites`), the sign-in's
73
+ login-CSRF check and `createOriginGuardMiddleware` share it.
74
+
75
+ ## Packages
76
+ - **The server evaluates rules without the query editor** (`@plitzi/sdk-shared`, `@plitzi/sdk-auth`,
77
+ `@plitzi/sdk-elements`, `@plitzi/sdk-interactions`, `@plitzi/plitzi-builder`): every evaluation of a `when` rule
78
+ group imports `QueryBuilderEvaluator` from `@plitzi/plitzi-ui/QueryBuilder/evaluator` — the evaluator alone — instead
79
+ of the `QueryBuilder` barrel, which brings the editor's React components, or `QueryBuilder/helpers`, which brings the
80
+ SQL and MongoDB formatters. `@plitzi/sdk-shared/helpers` reads `get` and `omit` from `@plitzi/plitzi-ui/helpers/lodash`.
81
+ Importing `@plitzi/sdk-server` loads 19 modules of `@plitzi/plitzi-ui` (26 before) and neither
82
+ `class-variance-authority` nor `clsx`, and starts in ~125 ms (~150 before). Needs `@plitzi/plitzi-ui` 1.6.34.
83
+
3
84
  ## 0.38.18
4
85
 
5
86
  ### Patch Changes
@@ -2,7 +2,7 @@ import { isTrue as e } from "./utility/truthiness.mjs";
2
2
  import t from "./utility/index.mjs";
3
3
  import { checkboxParams as n } from "./utility/checkboxParams.mjs";
4
4
  import { camelCase as r, get as i, set as a } from "@plitzi/plitzi-ui/helpers/lodash";
5
- import { QueryBuilderEvaluator as o } from "@plitzi/plitzi-ui/QueryBuilder";
5
+ import { QueryBuilderEvaluator as o } from "@plitzi/plitzi-ui/QueryBuilder/evaluator";
6
6
  import { produce as s } from "immer";
7
7
  //#region src/dataSource/getBindingsDetails.ts
8
8
  var c = (e, t, n, r, a) => {
@@ -1,4 +1,4 @@
1
- import { QueryBuilderEvaluator as e } from "@plitzi/plitzi-ui/QueryBuilder";
1
+ import { QueryBuilderEvaluator as e } from "@plitzi/plitzi-ui/QueryBuilder/evaluator";
2
2
  //#region src/dataSource/resolveVariables.ts
3
3
  var t = (t, n = {}) => Array.isArray(t) ? t.reduce((t, r) => {
4
4
  let { name: i, value: a, subValues: o } = r;
@@ -1,5 +1,5 @@
1
1
  import { isRecord as e } from "./isRecord.mjs";
2
- import { omit as t } from "@plitzi/plitzi-ui/helpers";
2
+ import { omit as t } from "@plitzi/plitzi-ui/helpers/lodash";
3
3
  //#region src/helpers/generateFacade.tsx
4
4
  var n = (e) => e.replace(/^@/, "").replace(/[-/]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase()).replace(/\s+/g, ""), r = (t, n) => {
5
5
  let r = Reflect.get(window, t), i = e(r) ? r[n] : void 0;
@@ -1,14 +1,14 @@
1
- import { RuleGroup, RuleValue } from '@plitzi/plitzi-ui/QueryBuilder';
1
+ import { RuleGroup, RuleValue } from '@plitzi/plitzi-ui/QueryBuilder/evaluator';
2
2
  /**
3
3
  * Evaluates a `when` rule group against a value bag.
4
4
  *
5
5
  * A rule group has to be evaluated on both sides — the browser for an interaction, the server for an action — and
6
6
  * the only implementation lives in `plitzi-ui`. This wrapper exists for two reasons beyond naming:
7
7
  *
8
- * - the `@plitzi/plitzi-ui/QueryBuilder` BARREL pulls the React components with it, which is the boot weight the
9
- * MCP already paid for once. `/QueryBuilder/helpers` carries the evaluator and nothing that renders;
8
+ * - the `@plitzi/plitzi-ui/QueryBuilder` BARREL pulls the React components with it, and `/QueryBuilder/helpers` the
9
+ * SQL and MongoDB formatters; `/QueryBuilder/evaluator` is the evaluator alone, which is all a server loads;
10
10
  * - it keeps `plitzi-ui` out of the server's dependency list. `sdk-shared` already depends on it, so the chain is
11
11
  * declared in exactly one place.
12
12
  */
13
13
  export declare const evaluateRuleGroup: (group: RuleGroup, values: Record<string, RuleValue>) => boolean;
14
- export type { Rule, RuleGroup, RuleValue } from '@plitzi/plitzi-ui/QueryBuilder';
14
+ export type { Rule, RuleGroup, RuleValue } from '@plitzi/plitzi-ui/QueryBuilder/evaluator';
@@ -1,4 +1,4 @@
1
- import { QueryBuilderEvaluator as e } from "@plitzi/plitzi-ui/QueryBuilder/helpers";
1
+ import { QueryBuilderEvaluator as e } from "@plitzi/plitzi-ui/QueryBuilder/evaluator";
2
2
  //#region src/helpers/ruleEvaluator.ts
3
3
  var t = (t, n) => !!e(t, n);
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { get as e } from "@plitzi/plitzi-ui/helpers";
1
+ import { get as e } from "@plitzi/plitzi-ui/helpers/lodash";
2
2
  //#region src/helpers/utils.ts
3
3
  function t(e) {
4
4
  return e && (e.displayName || e.name) || "Component";
@@ -2,7 +2,7 @@ import { CommitEntry, PropChange } from '../../types';
2
2
  import { ProfilerOnRenderCallback } from 'react';
3
3
  /**
4
4
  * What the SDK publishes as `window.plitziTracing` while its render tracing is on (`debugMode`): the commits since a
5
- * mark, for a test to ask which elements an interaction rendered — `inspectRenders` in `@plitzi/sdk-authoring/testing`.
5
+ * mark, for a test to ask which elements an interaction rendered — `inspectRenders` of `@plitzi/sdk-authoring`.
6
6
  */
7
7
  export type TracingReader = {
8
8
  lastCommitId: () => number;
@@ -23,6 +23,29 @@ export type FunctionTaskManifest = {
23
23
  limits?: FunctionTimeLimits;
24
24
  };
25
25
  /** What a space's functions declare, read from the bundle when it is saved: its tasks, routes and reachable hosts. */
26
+ /**
27
+ * One OAuth 2.0 connection a space's code makes on its visitors' (or its own) behalf, declared as data: any provider,
28
+ * none of them known to the platform by name. `issuer` for one that publishes OpenID metadata — its endpoints are read
29
+ * from `<issuer>/.well-known/openid-configuration` — or the endpoints themselves for one that does not.
30
+ */
31
+ export type FunctionOAuthConnection = {
32
+ /** An OpenID provider's issuer (`https://accounts.google.com`): the endpoints are discovered from it. */
33
+ issuer?: string;
34
+ /** Where the visitor is sent to consent, when there is no `issuer` (or to override what it publishes). */
35
+ authorizeUrl?: string;
36
+ /** Where the code is exchanged and the token refreshed, when there is no `issuer` (or to override it). */
37
+ tokenUrl?: string;
38
+ /** Where a token is revoked on `disconnect`, when the provider has one. */
39
+ revokeUrl?: string;
40
+ /** The space's credential holding the app's `clientId` and `clientSecret`: the code names it, never holds it. */
41
+ credential: string;
42
+ /** What is asked for, as the provider spells it. */
43
+ scopes?: string[];
44
+ /** More of the consent URL, as the provider needs it: `{ access_type: 'offline', prompt: 'consent' }`. */
45
+ authorizeParams?: Record<string, string>;
46
+ /** How the app proves who it is to `tokenUrl`: in the body (the default) or as HTTP Basic. */
47
+ clientAuth?: 'body' | 'basic';
48
+ };
26
49
  export type FunctionsManifest = {
27
50
  hosts: string[];
28
51
  tasks: FunctionTaskManifest[];
@@ -30,6 +53,8 @@ export type FunctionsManifest = {
30
53
  routes: string[];
31
54
  /** What every task and route asks for beyond the default, unless a task asks for its own. */
32
55
  limits?: FunctionTimeLimits;
56
+ /** The OAuth connections its code makes (`ctx.oauth`), by the name the code calls them. */
57
+ oauth?: Record<string, FunctionOAuthConnection>;
33
58
  };
34
59
  /** One reason functions were not saved, where it is — what an editor underlines. */
35
60
  export type FunctionsProblem = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-shared",
3
- "version": "0.38.18",
3
+ "version": "0.38.20",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist",
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@plitzi/nexus": "^1.4.0",
37
- "@plitzi/plitzi-ui": "^1.6.33",
37
+ "@plitzi/plitzi-ui": "^1.6.34",
38
38
  "date-fns": "^4.4.0",
39
39
  "immer": "^11.1.21",
40
40
  "zod": "^4.6.7"