@plitzi/sdk-auth 0.38.16 → 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 +45 -0
- package/dist/AuthContext.mjs +1 -1
- package/dist/AuthContextProvider.mjs +2 -2
- package/dist/AuthProvider.mjs +10 -53
- package/package.json +13 -82
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
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
|
+
|
|
3
48
|
## 0.38.16
|
|
4
49
|
|
|
5
50
|
### Patch Changes
|
package/dist/AuthContext.mjs
CHANGED
|
@@ -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
|
|
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
|
|
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
|
package/dist/AuthProvider.mjs
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
162
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
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
|
|
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
|
|
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.
|
|
105
|
-
"@plitzi/sdk-shared": "0.38.
|
|
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.
|
|
40
|
+
"react": "^19.3.1",
|
|
110
41
|
"typescript": "^6.0.3",
|
|
111
|
-
"vite": "^8.3.
|
|
112
|
-
"vitest": "^5.0.
|
|
42
|
+
"vite": "^8.3.4",
|
|
43
|
+
"vitest": "^5.0.5"
|
|
113
44
|
},
|
|
114
45
|
"peerDependencies": {
|
|
115
46
|
"react": "^19"
|