@plitzi/sdk-auth 0.38.15 → 0.38.17

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,115 @@
1
1
  # @plitzi/sdk-auth
2
2
 
3
+ ## 0.38.17
4
+
5
+ ### Patch Changes
6
+
7
+ - 4f8dc37: ## Packages
8
+
9
+ - **A library package is imported by its root and its folders, never by a file** (`@plitzi/sdk-shared`, `sdk-schema`,
10
+ `sdk-style`, `sdk-elements`, `sdk-interactions`, `sdk-auth`, `sdk-dev-tools`, `sdk-event-bridge`, `sdk-navigation`,
11
+ `sdk-plugins`, `sdk-variables`): each `exports` is now `"."` and `"./*"`, the latter a folder's `index`.
12
+ `@plitzi/sdk-shared/helpers/isRecord` becomes `import { isRecord } from '@plitzi/sdk-shared/helpers'`, and a default
13
+ export by the name its folder gives it — almost always its file's (`import usePlitzi from '…/hooks/usePlitzi'` →
14
+ `import { usePlitzi } from '@plitzi/sdk-shared/hooks'`). A file-level specifier now fails with `ERR_MODULE_NOT_FOUND`.
15
+ New entries where a folder barrel would have brought more than was asked for: `@plitzi/sdk-shared/project` and
16
+ `@plitzi/sdk-shared/plugins/bundle` (Node only), `@plitzi/sdk-interactions/declarations` (the global callbacks and
17
+ utility specs, without React), and `@plitzi/sdk-elements/elements/declarations`, which now also carries the
18
+ declarations' attribute types and the constants they are checked with. `RuleGroup` is exported by `@plitzi/sdk-shared`
19
+ with the document types that use it. `plitzi upgrade migrations` names every such import in a project, with the folder to
20
+ import it from instead.
21
+ - **`@plitzi/sdk-shared`'s root exports the document types, and only them** (`@plitzi/sdk-shared`): what the package
22
+ does is imported from its folder — `formatDate` from `@plitzi/sdk-shared/helpers`, `ThemeProvider` from
23
+ `@plitzi/sdk-shared/theme`, a GraphQL operation's types from `@plitzi/sdk-shared/network/graphql` — so a module that
24
+ imports a type from the root no longer loads every area of the package.
25
+ - **What one package alone used lives in that package** (`@plitzi/sdk-shared`, `@plitzi/sdk-elements`): the data
26
+ source hooks moved from `@plitzi/sdk-shared/dataSource/hooks` to `@plitzi/sdk-elements/dataSource`
27
+ (`useRegisterSource`, `useResolvedVariables`), and the Apollo links the builder's client is built with into the
28
+ builder.
29
+ - **The builder's panels are an entry of their own** (`@plitzi/sdk-style`, `@plitzi/sdk-variables`,
30
+ `@plitzi/sdk-elements`): the style inspector, the advanced style editor and `BuilderStyleContextProvider` are imported
31
+ from `@plitzi/sdk-style/builder`; the variables' lists and forms from `@plitzi/sdk-variables/builder`; the elements'
32
+ settings panels (`defaultElementsSettings`) from `@plitzi/sdk-elements/builder`. Each package's root keeps what a page
33
+ and a server use — `generateCache` no longer loads the inspector, on a server 227 modules down to 21.
34
+
35
+ ## CLI
36
+ - **`plitzi upgrade`'s `renames` part is now `migrations`** (`@plitzi/cli`): what a version changed that a project's
37
+ own source must follow, one file per change in the CLI's `src/migrations/changes/` with the version it shipped in —
38
+ rewritten with `--write` when it has one right answer, said otherwise. The `--json` report carries `migrations` (each
39
+ with its `migration`, `since`, `file`, `line`, `what` and whether it was `written`) in place of `renames` and
40
+ `changes`. The changes of 0.38.0 (`canTemplate` → `canSnippet`, the `*Template` authoring names), 0.38.9 (a
41
+ `formControl` without `required` is optional) and 0.38.12 (`usePlitziServiceContext` → `usePlitzi`) are no longer
42
+ looked for: a project still on one of those versions makes them by hand.
43
+
44
+ - Updated dependencies [4f8dc37]
45
+ - @plitzi/sdk-navigation@0.38.17
46
+ - @plitzi/sdk-shared@0.38.17
47
+
48
+ ## 0.38.16
49
+
50
+ ### Patch Changes
51
+
52
+ - 9cfdccb: ## Security
53
+
54
+ - **A site's credential reads nothing of the space over MCP** (`@plitzi/sdk-mcp`): the `render` token every published
55
+ page embeds — and a self-hosting `host` key — resolved to a grant naming the space, and the MCP served every read
56
+ under it: the unpublished draft, the change history with who made each change and every value before and after, the
57
+ functions' source, the space's private data, its action documents and connectors. Only an `agent` grant attaches a
58
+ space now; any other is a connection with no space (`plitzi_render` and the public guides), told so in the words
59
+ `NO_SPACE_ATTACHED` already uses. A deployment whose `getGrant` answered other scopes for reading must issue agent
60
+ grants for them.
61
+
62
+ ## Agents
63
+ - **`plitzi space watch`** (`@plitzi/cli`): the space read again on every save of `src/space/`, `src/plugins/`,
64
+ `src/data/` or `public/data/`, and only what changed said — what the save did to the space element by element, the
65
+ findings and warnings it brought and fixed (one that only moved down its file is the same one), a save that changed
66
+ nothing, or that the space stopped authoring and why. `--json` is one event a line (`ready`, `pass`, `refused`,
67
+ `error`), for an agent to run in the background instead of `author` and `space lint` after every edit. Each pass reads
68
+ the space in a process of its own (`space watch-pass`, hidden). `space lint`'s reading is `spaceFindings`, shared.
69
+ - **A space's activity, followed** (`@plitzi/sdk-shared`, `@plitzi/sdk-mcp`, `@plitzi/cli`): what happened on a space
70
+ after a cursor — its draft changed (a person in the builder, an agent, the autofix), a version went out, a server
71
+ action failed or was refused — and, with nothing yet, waited for, up to 50 s. One vocabulary,
72
+ `@plitzi/sdk-shared/activity` (`SpaceActivity`, `SpaceActivityPage`, `activityLine`, `isSpaceActivityPage`, the
73
+ limits); the reader's own writes left out and counted (`skippedMine`), `mine` keeps them.
74
+ - **`plitzi_activity { after, wait, limit, mine }`** (`@plitzi/sdk-mcp`), on the new `getActivity` adapter
75
+ (`SSRAdapters`). The listing budget is 78k (was 77k) for it.
76
+ - **`plitzi space activity [--follow] [--after <cursor>] [--mine] [--limit <n>] [--json]`** (`@plitzi/cli`), over
77
+ the platform's `GET /spaces/:spaceId/activity`; `--follow` stays, one page a line with `--json`, and asks again
78
+ when the platform does not answer.
79
+ - **The people in the builder see the agent work** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`, `@plitzi/sdk-mcp`,
80
+ `@plitzi/plitzi-builder`): an agent grant carries the application the member connected (`Grant.client`,
81
+ `StoredSpaceToken.client`, `SSRGrant.client`), and every MCP write `SSRWriteContext.client` — the history's
82
+ `client` for an agent, which was never set. A collaborator may be an agent (`SubscriptionCollaborator.agent`): the
83
+ builder draws it as a robot, names it `Claude · for ana` (`collaboratorTitle`) in the header, on the canvas and in
84
+ its notices. The deployment announces it — Plitzi's joins it on a write, selects what it changed, and lets it go
85
+ after a minute of nothing. `activityLine` names it the same way (`Claude for ana over the MCP, …`), so
86
+ `plitzi space activity` says which application wrote.
87
+ - A tool may declare `documents: false` (`ToolSpec`): the host loads none of the space for it, and passes the call's
88
+ abort signal through `ToolContext.activity`.
89
+
90
+ ## Authoring
91
+ - **A file that does not parse is said at its line under any loader** (`@plitzi/sdk-authoring`): `moduleProblem` read
92
+ the first line of the error, and an esbuild transform (tsx, vitest) puts only `Transform failed with 1 error:` there
93
+ — the file, line and what is wrong are on the next. A line of the message that points at a file of the project is
94
+ now the problem (`src/space/hero.ts:139: Expected "}" but found ";"`), the project's root matched as given and as it
95
+ is on disk (`/var/…` and `/private/var/…` on macOS).
96
+
97
+ ## Testing
98
+ - **`unusedPort` is chosen where the system never hands one out** (`@plitzi/sdk-server`): it answered a port the system
99
+ had just handed out (`listen(0)`), from the ephemeral range every outgoing connection takes its local port from — so
100
+ another worker's request could take it before the test listened, and CI failed `runtime.test.ts` with `EADDRINUSE`
101
+ (the page server then ends the process). It is a free port below that range now, at random, checked first.
102
+
103
+ ## Docs
104
+ - **A self-hosted runtime's endpoints go in `data`**, as 0.38.15 moved them: `docs/en/runtimes.md`, the
105
+ `10-runtime` example and the website still put `served.stage` in `preAuth`, before the cross-site guard.
106
+ - New: `docs/en/activity.md`; `space watch` in `docs/en/agent-tooling.md`'s loop; the CLI README, the CLI skill, the
107
+ generated project's `AGENTS.md`, the MCP guide and README.
108
+
109
+ - Updated dependencies [9cfdccb]
110
+ - @plitzi/sdk-navigation@0.38.16
111
+ - @plitzi/sdk-shared@0.38.16
112
+
3
113
  ## 0.38.15
4
114
 
5
115
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import { sharedContext as e } from "@plitzi/sdk-shared/helpers/sharedContext";
1
+ import { sharedContext as e } from "@plitzi/sdk-shared/helpers";
2
2
  var t = e("AuthContext", {});
3
3
  //#endregion
4
4
  export { t as AuthContext, t as default };
@@ -5,9 +5,9 @@ import r from "./hooks/useAuth/index.mjs";
5
5
  import i from "./hooks/useSessionQueryReset/index.mjs";
6
6
  import { QueryBuilderEvaluator as a } from "@plitzi/plitzi-ui/QueryBuilder";
7
7
  import { use as o, useMemo as s, useRef as c } from "react";
8
- import l from "@plitzi/sdk-navigation/hooks/useNavigation";
8
+ import { useNavigation as l } from "@plitzi/sdk-navigation";
9
9
  import { processTwig as u } from "@plitzi/sdk-shared/helpers/twigWrapper";
10
- import d from "@plitzi/sdk-shared/network/NetworkContext";
10
+ import { NetworkContext as d } from "@plitzi/sdk-shared/network";
11
11
  import { useCommonStore as f, useRenderSettings as p } from "@plitzi/sdk-shared/store";
12
12
  import { jsx as m } from "react/jsx-runtime";
13
13
  //#region src/AuthContextProvider.tsx
@@ -95,33 +95,12 @@ var s = 60, c = 300, l = 2147483647, u = class {
95
95
  user: r?.user,
96
96
  token: r?.token,
97
97
  validatedAt: r?.validatedAt ?? 0
98
- }, this.hintCookie && !i) {
99
- this.endSession(void 0, "hint-missing");
100
- return;
101
- }
102
- if (this.hasLiveToken() && this.session.user) {
98
+ }, this.hintCookie && !i) this.endSession(void 0, "hint-missing");
99
+ else if (this.hasLiveToken() && this.session.user) {
103
100
  this.setState("authenticated", "restored"), this.scheduleRenewal();
104
101
  let e = this.isFresh() && this.gate !== "strict" ? void 0 : this.revalidate(!0);
105
102
  this.gate === "strict" && await e;
106
- return;
107
- }
108
- if (!this.hasEvidence()) {
109
- this.endSession(void 0, "no-evidence");
110
- return;
111
- }
112
- if (this.setState("initLoading", "no-evidence"), this.hasLiveToken() && this.capabilities.identity) {
113
- await this.loadIdentity();
114
- return;
115
- }
116
- if (this.capabilities.renew) {
117
- await this.renew();
118
- return;
119
- }
120
- if (this.capabilities.identity) {
121
- await this.loadIdentity();
122
- return;
123
- }
124
- this.endSession();
103
+ } else this.hasEvidence() ? (this.setState("initLoading", "no-evidence"), this.hasLiveToken() && this.capabilities.identity ? await this.loadIdentity() : this.capabilities.renew ? await this.renew() : this.capabilities.identity ? await this.loadIdentity() : this.endSession()) : this.endSession(void 0, "no-evidence");
125
104
  }
126
105
  dispose() {
127
106
  clearTimeout(this.renewalTimer), this.renewalTimer = void 0, this.detachListeners?.(), this.detachListeners = void 0;
@@ -157,15 +136,9 @@ var s = 60, c = 300, l = 2147483647, u = class {
157
136
  async handOffToServer() {
158
137
  let e = await this.requestExchange();
159
138
  if (e) {
160
- if (e.ok) {
161
- this.adopt(e);
162
- return;
163
- }
164
- if (e.reason === "network") {
165
- this.offline = !0;
166
- return;
167
- }
168
- return this.endSession(e.reason), e.reason;
139
+ if (e.ok) this.adopt(e);
140
+ else if (e.reason === "network") this.offline = !0;
141
+ else return this.endSession(e.reason), e.reason;
169
142
  }
170
143
  }
171
144
  async refresh() {
@@ -211,11 +184,7 @@ var s = 60, c = 300, l = 2147483647, u = class {
211
184
  return e === this.epoch ? t.ok ? (this.adopt(t), this.state === "authenticated") : this.renewable(t.reason) && !this.renewal ? this.renew() : (this.handleFailure(t.reason), !1) : this.state === "authenticated";
212
185
  }
213
186
  handleFailure(e) {
214
- if (e === "network") {
215
- this.offline = !0;
216
- return;
217
- }
218
- this.endSession(e);
187
+ e === "network" ? this.offline = !0 : this.endSession(e);
219
188
  }
220
189
  adopt(e, t = !0, r = "granted") {
221
190
  this.session = {
@@ -259,18 +228,10 @@ var s = 60, c = 300, l = 2147483647, u = class {
259
228
  let e = this.expiresAt();
260
229
  if (e === void 0 || typeof window > "u" || this.state === "guest") return;
261
230
  let t = Math.min((e - s - n()) * 1e3, l);
262
- if (t <= 0) {
263
- this.onRenewalDue();
264
- return;
265
- }
266
- this.renewalTimer = setTimeout(() => this.onRenewalDue(), t);
231
+ t <= 0 ? this.onRenewalDue() : this.renewalTimer = setTimeout(() => this.onRenewalDue(), t);
267
232
  }
268
233
  onRenewalDue() {
269
- if (this.capabilities.renew) {
270
- this.renew();
271
- return;
272
- }
273
- this.endSession("expired");
234
+ this.capabilities.renew ? this.renew() : this.endSession("expired");
274
235
  }
275
236
  attach() {
276
237
  if (typeof window > "u" || this.detachListeners) return;
@@ -287,11 +248,7 @@ var s = 60, c = 300, l = 2147483647, u = class {
287
248
  };
288
249
  }
289
250
  adoptFromStorage(e) {
290
- if (this.epoch += 1, !e?.token && !e?.user) {
291
- clearTimeout(this.renewalTimer), this.renewalTimer = void 0, this.session = { validatedAt: n() }, this.setState("guest", "another-tab"), this.emit({ type: "logout" });
292
- return;
293
- }
294
- this.adopt({
251
+ this.epoch += 1, !e?.token && !e?.user ? (clearTimeout(this.renewalTimer), this.renewalTimer = void 0, this.session = { validatedAt: n() }, this.setState("guest", "another-tab"), this.emit({ type: "logout" })) : this.adopt({
295
252
  ok: !0,
296
253
  user: e.user,
297
254
  token: e.token
package/package.json CHANGED
@@ -1,89 +1,20 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-auth",
3
- "version": "0.38.15",
3
+ "version": "0.38.17",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
8
8
  "exports": {
9
9
  ".": {
10
+ "@plitzi/source": "./src/index.ts",
10
11
  "types": "./dist/index.d.ts",
11
12
  "import": "./dist/index.mjs"
12
13
  },
13
- "./AuthContext": {
14
- "types": "./dist/AuthContext.d.ts",
15
- "import": "./dist/AuthContext.mjs"
16
- },
17
- "./AuthContextProvider": {
18
- "types": "./dist/AuthContextProvider.d.ts",
19
- "import": "./dist/AuthContextProvider.mjs"
20
- },
21
- "./AuthManager": {
22
- "types": "./dist/AuthManager.d.ts",
23
- "import": "./dist/AuthManager.mjs"
24
- },
25
- "./AuthProvider": {
26
- "types": "./dist/AuthProvider.d.ts",
27
- "import": "./dist/AuthProvider.mjs"
28
- },
29
- "./helpers/SessionStore": {
30
- "types": "./dist/helpers/SessionStore.d.ts",
31
- "import": "./dist/helpers/SessionStore.mjs"
32
- },
33
- "./helpers/publishedSession": {
34
- "types": "./dist/helpers/publishedSession.d.ts",
35
- "import": "./dist/helpers/publishedSession.mjs"
36
- },
37
- "./helpers/resolveAuthSettings": {
38
- "types": "./dist/helpers/resolveAuthSettings.d.ts",
39
- "import": "./dist/helpers/resolveAuthSettings.mjs"
40
- },
41
- "./helpers/sessionHint": {
42
- "types": "./dist/helpers/sessionHint.d.ts",
43
- "import": "./dist/helpers/sessionHint.mjs"
44
- },
45
- "./helpers/tokenClaims": {
46
- "types": "./dist/helpers/tokenClaims.d.ts",
47
- "import": "./dist/helpers/tokenClaims.mjs"
48
- },
49
- "./hooks/useAuth": {
50
- "types": "./dist/hooks/useAuth/index.d.ts",
51
- "import": "./dist/hooks/useAuth/index.mjs"
52
- },
53
- "./hooks/useAuth/index": {
54
- "types": "./dist/hooks/useAuth/index.d.ts",
55
- "import": "./dist/hooks/useAuth/index.mjs"
56
- },
57
- "./hooks/useAuth/useAuth": {
58
- "types": "./dist/hooks/useAuth/useAuth.d.ts",
59
- "import": "./dist/hooks/useAuth/useAuth.mjs"
60
- },
61
- "./hooks/useSessionQueryReset": {
62
- "types": "./dist/hooks/useSessionQueryReset/index.d.ts",
63
- "import": "./dist/hooks/useSessionQueryReset/index.mjs"
64
- },
65
- "./hooks/useSessionQueryReset/index": {
66
- "types": "./dist/hooks/useSessionQueryReset/index.d.ts",
67
- "import": "./dist/hooks/useSessionQueryReset/index.mjs"
68
- },
69
- "./hooks/useSessionQueryReset/useSessionQueryReset": {
70
- "types": "./dist/hooks/useSessionQueryReset/useSessionQueryReset.d.ts",
71
- "import": "./dist/hooks/useSessionQueryReset/useSessionQueryReset.mjs"
72
- },
73
- "./index": {
74
- "types": "./dist/index.d.ts",
75
- "import": "./dist/index.mjs"
76
- },
77
- "./providers/BasicAuthProvider": {
78
- "types": "./dist/providers/BasicAuthProvider.d.ts",
79
- "import": "./dist/providers/BasicAuthProvider.mjs"
80
- },
81
- "./providers/ServerAuthProvider": {
82
- "types": "./dist/providers/ServerAuthProvider.d.ts",
83
- "import": "./dist/providers/ServerAuthProvider.mjs"
84
- },
85
- "./types": {
86
- "types": "./dist/types.d.ts"
14
+ "./*": {
15
+ "@plitzi/source": "./src/*/index.ts",
16
+ "types": "./dist/*/index.d.ts",
17
+ "import": "./dist/*/index.mjs"
87
18
  }
88
19
  },
89
20
  "type": "module",
@@ -94,22 +25,22 @@
94
25
  "test": "vitest run",
95
26
  "test:watch": "vitest",
96
27
  "test:ui": "vitest --ui",
97
- "build:dev": "vite build --mode development --minify false && node ../sdk-shared/scripts/generate-exports.mjs",
28
+ "build:dev": "vite build --mode development --minify false",
98
29
  "build:dev-watch": "vite build --mode development --watch --minify false",
99
- "build:prod": "vite build && node ../sdk-shared/scripts/generate-exports.mjs"
30
+ "build:prod": "vite build"
100
31
  },
101
32
  "dependencies": {
102
33
  "@plitzi/nexus": "^1.4.0",
103
34
  "@plitzi/plitzi-ui": "^1.6.33",
104
- "@plitzi/sdk-navigation": "0.38.15",
105
- "@plitzi/sdk-shared": "0.38.15"
35
+ "@plitzi/sdk-navigation": "0.38.17",
36
+ "@plitzi/sdk-shared": "0.38.17"
106
37
  },
107
38
  "devDependencies": {
108
39
  "eslint": "^9.39.5",
109
- "react": "^19.3.0",
40
+ "react": "^19.3.1",
110
41
  "typescript": "^6.0.3",
111
- "vite": "^8.3.2",
112
- "vitest": "^5.0.3"
42
+ "vite": "^8.3.4",
43
+ "vitest": "^5.0.5"
113
44
  },
114
45
  "peerDependencies": {
115
46
  "react": "^19"