alinea 1.7.0-preview.0 → 1.7.0-preview.10

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.
Files changed (97) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +66 -66
  3. package/dist/adapter/next/cms.js +7 -8
  4. package/dist/adapter/next/handler.js +1 -1
  5. package/dist/adapter/next/with-alinea.js +5 -10
  6. package/dist/backend/Handler.js +3 -2
  7. package/dist/backend/api/OAuth2.d.ts +6 -0
  8. package/dist/backend/api/OAuth2.js +35 -13
  9. package/dist/backend/resolver/ParsePreview.d.ts +1 -1
  10. package/dist/backend/resolver/ParsePreview.js +10 -2
  11. package/dist/backend/router/Router.d.ts +15 -0
  12. package/dist/backend/router/Router.js +3 -0
  13. package/dist/backend/util/ExecGit.d.ts +2 -2
  14. package/dist/bundled.d.ts +307 -240
  15. package/dist/chunks/{chunk-XUSXCKEG.js → chunk-WKC37UOZ.js} +13 -9
  16. package/dist/chunks/{chunk-VNF4OZAJ.js → chunk-XQOSC7K3.js} +10 -7
  17. package/dist/cli/Serve.js +4 -4
  18. package/dist/cli/bin.js +6 -4
  19. package/dist/cli/serve/CreateLocalServer.js +34 -4
  20. package/dist/cli/util/ForwardCommand.d.ts +1 -1
  21. package/dist/cli/util/ForwardCommand.js +17 -19
  22. package/dist/cloud/CloudRemote.d.ts +2 -2
  23. package/dist/cloud/CloudRemote.js +8 -2
  24. package/dist/core/Graph.d.ts +1 -1
  25. package/dist/core/Type.d.ts +2 -0
  26. package/dist/core/db/EntryIndex.d.ts +3 -1
  27. package/dist/core/db/EntryIndex.js +15 -3
  28. package/dist/core/db/LocalDB.d.ts +1 -1
  29. package/dist/core/db/Operation.js +3 -1
  30. package/dist/core/db/WriteableGraph.d.ts +1 -1
  31. package/dist/core/field/RichTextField.d.ts +1 -1
  32. package/dist/core/field/RichTextField.js +70 -7
  33. package/dist/core/media/IsImage.d.ts +1 -1
  34. package/dist/core/media/MediaTypes.d.ts +1 -1
  35. package/dist/core/media/Summary.d.ts +2 -2
  36. package/dist/core/shape/ListShape.d.ts +1 -1
  37. package/dist/core/shape/RichTextShape.js +1 -0
  38. package/dist/core/source/FSSource.d.ts +2 -2
  39. package/dist/core/source/Source.d.ts +2 -2
  40. package/dist/core/source/Tree.d.ts +3 -3
  41. package/dist/core/source/Utils.js +4 -1
  42. package/dist/core/util/ArrayBuffers.d.ts +1 -1
  43. package/dist/core/util/BufferToBase64.d.ts +2 -2
  44. package/dist/core/util/EntryFilenames.d.ts +1 -2
  45. package/dist/core/util/EntryFilenames.js +11 -6
  46. package/dist/core/util/EntryFilenames.test.d.ts +1 -0
  47. package/dist/core/util/JWT.d.ts +11 -2
  48. package/dist/core/util/JWT.js +16 -12
  49. package/dist/dashboard/DashboardNav.d.ts +8 -8
  50. package/dist/dashboard/Routes.d.ts +25 -25
  51. package/dist/dashboard/atoms/DbAtoms.d.ts +1 -1
  52. package/dist/dashboard/atoms/Edits.d.ts +3 -3
  53. package/dist/dashboard/atoms/EntryEditorAtoms.d.ts +27 -27
  54. package/dist/dashboard/atoms/EntryEditorAtoms.js +3 -1
  55. package/dist/dashboard/atoms/EntrySummaryAtoms.d.ts +1 -1
  56. package/dist/dashboard/atoms/NavigationAtoms.d.ts +9 -9
  57. package/dist/dashboard/atoms/PreferencesAtoms.d.ts +1 -1
  58. package/dist/dashboard/atoms/RouterAtoms.d.ts +1 -1
  59. package/dist/dashboard/boot/LoadWorker.js +3 -2
  60. package/dist/dashboard/editor/DefaultViews.d.ts +1 -1
  61. package/dist/dashboard/editor/UseField.js +8 -1
  62. package/dist/dashboard/hook/UseNav.d.ts +4 -4
  63. package/dist/dashboard/hook/UseRoot.d.ts +2 -2
  64. package/dist/dashboard/hook/UseWorkspace.d.ts +3 -3
  65. package/dist/dashboard/util/Loader.d.ts +1 -1
  66. package/dist/dashboard/view/InputLabel.d.ts +1 -1
  67. package/dist/dashboard/view/explorer/ExplorerRow.d.ts +1 -1
  68. package/dist/field/link/EntryLink.d.ts +1 -1
  69. package/dist/field/link/FileLink.d.ts +2 -2
  70. package/dist/field/link/LinkField.view.js +18 -0
  71. package/dist/field/link/UrlLink.d.ts +1 -1
  72. package/dist/field/richtext/Extensions.d.ts +1 -0
  73. package/dist/field/richtext/Extensions.js +118 -9
  74. package/dist/field/richtext/Toolbar.d.ts +6 -0
  75. package/dist/field/richtext/Toolbar.js +7 -0
  76. package/dist/index.css +4 -0
  77. package/dist/next.cjs +4 -11
  78. package/dist/picker/url/UrlPicker.js +1 -1
  79. package/dist/query.d.ts +85 -85
  80. package/dist/test/example.d.ts +58 -58
  81. package/dist/test/schema/DemoHome.d.ts +17 -17
  82. package/dist/test/schema/DemoRecipe.d.ts +10 -10
  83. package/dist/test/schema/DemoRecipes.d.ts +2 -2
  84. package/dist/ui/Button.stories.d.ts +1 -1
  85. package/dist/ui/Ellipsis.d.ts +1 -1
  86. package/dist/ui/Stack.d.ts +4 -4
  87. package/dist/ui/Typo.d.ts +2 -2
  88. package/dist/ui/icons/IcRoundAttachFile.d.ts +2 -0
  89. package/dist/ui/icons/IcRoundAttachFile.js +10 -0
  90. package/dist/ui/icons/IcRoundFormatPaint.d.ts +2 -0
  91. package/dist/ui/icons/IcRoundFormatPaint.js +10 -0
  92. package/dist/ui/icons/IcRoundPanorama.d.ts +2 -0
  93. package/dist/ui/icons/IcRoundPanorama.js +10 -0
  94. package/dist/ui/util/CreateTypo.d.ts +2 -2
  95. package/llms-full.txt +4278 -0
  96. package/package.json +10 -5
  97. package/readme.md +4 -0
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "39tRiBmjfWV5beXQN98l81Ul4b1",
2
+ "_id": "3FfTjlrBhYodjHfM2I29mkaD2b0",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
package/dist/LICENSES.md CHANGED
@@ -55,11 +55,11 @@ SOFTWARE.
55
55
 
56
56
  ===
57
57
 
58
- # @headlessui/react@2.2.0 (MIT)
58
+ # react-query@3.39.3 (MIT)
59
59
 
60
60
  MIT License
61
61
 
62
- Copyright (c) 2020 Tailwind Labs
62
+ Copyright (c) 2019 Tanner Linsley
63
63
 
64
64
  Permission is hereby granted, free of charge, to any person obtaining a copy
65
65
  of this software and associated documentation files (the "Software"), to deal
@@ -79,13 +79,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
79
79
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
80
80
  SOFTWARE.
81
81
 
82
+
82
83
  ===
83
84
 
84
- # react-query@3.39.3 (MIT)
85
+ # @headlessui/react@2.2.0 (MIT)
85
86
 
86
87
  MIT License
87
88
 
88
- Copyright (c) 2019 Tanner Linsley
89
+ Copyright (c) 2020 Tailwind Labs
89
90
 
90
91
  Permission is hereby granted, free of charge, to any person obtaining a copy
91
92
  of this software and associated documentation files (the "Software"), to deal
@@ -105,7 +106,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
105
106
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
106
107
  SOFTWARE.
107
108
 
108
-
109
109
  ===
110
110
 
111
111
  # htmlparser2@9.1.0 (MIT)
@@ -157,7 +157,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
157
157
 
158
158
  ===
159
159
 
160
- # domutils@3.1.0 (BSD-2-Clause)
160
+ # domhandler@5.0.3 (BSD-2-Clause)
161
161
 
162
162
  Copyright (c) Felix Böhm
163
163
  All rights reserved.
@@ -174,7 +174,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
174
174
 
175
175
  ===
176
176
 
177
- # domhandler@5.0.3 (BSD-2-Clause)
177
+ # domutils@3.1.0 (BSD-2-Clause)
178
178
 
179
179
  Copyright (c) Felix Böhm
180
180
  All rights reserved.
@@ -233,6 +233,33 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
233
233
  SOFTWARE.
234
234
 
235
235
 
236
+ ===
237
+
238
+ # prop-types@15.8.1 (MIT)
239
+
240
+ MIT License
241
+
242
+ Copyright (c) 2013-present, Facebook, Inc.
243
+
244
+ Permission is hereby granted, free of charge, to any person obtaining a copy
245
+ of this software and associated documentation files (the "Software"), to deal
246
+ in the Software without restriction, including without limitation the rights
247
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
248
+ copies of the Software, and to permit persons to whom the Software is
249
+ furnished to do so, subject to the following conditions:
250
+
251
+ The above copyright notice and this permission notice shall be included in all
252
+ copies or substantial portions of the Software.
253
+
254
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
255
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
256
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
257
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
258
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
259
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
260
+ SOFTWARE.
261
+
262
+
236
263
  ===
237
264
 
238
265
  # @juggle/resize-observer@3.4.0 (Apache-2.0)
@@ -440,33 +467,6 @@ SOFTWARE.
440
467
  limitations under the License.
441
468
 
442
469
 
443
- ===
444
-
445
- # prop-types@15.8.1 (MIT)
446
-
447
- MIT License
448
-
449
- Copyright (c) 2013-present, Facebook, Inc.
450
-
451
- Permission is hereby granted, free of charge, to any person obtaining a copy
452
- of this software and associated documentation files (the "Software"), to deal
453
- in the Software without restriction, including without limitation the rights
454
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
455
- copies of the Software, and to permit persons to whom the Software is
456
- furnished to do so, subject to the following conditions:
457
-
458
- The above copyright notice and this permission notice shall be included in all
459
- copies or substantial portions of the Software.
460
-
461
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
462
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
463
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
464
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
465
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
466
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
467
- SOFTWARE.
468
-
469
-
470
470
  ===
471
471
 
472
472
  # react-is@16.13.1 (MIT)
@@ -513,9 +513,31 @@ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
513
513
 
514
514
  ===
515
515
 
516
- # @headless-tree/react@0.0.15 (MIT)
516
+ # @babel/runtime@7.25.4 (MIT)
517
+
518
+ MIT License
519
+
520
+ Copyright (c) 2014-present Sebastian McKenzie and other contributors
521
+
522
+ Permission is hereby granted, free of charge, to any person obtaining
523
+ a copy of this software and associated documentation files (the
524
+ "Software"), to deal in the Software without restriction, including
525
+ without limitation the rights to use, copy, modify, merge, publish,
526
+ distribute, sublicense, and/or sell copies of the Software, and to
527
+ permit persons to whom the Software is furnished to do so, subject to
528
+ the following conditions:
529
+
530
+ The above copyright notice and this permission notice shall be
531
+ included in all copies or substantial portions of the Software.
532
+
533
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
534
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
535
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
536
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
537
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
538
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
539
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
517
540
 
518
- MIT
519
541
 
520
542
  ===
521
543
 
@@ -525,6 +547,12 @@ MIT
525
547
 
526
548
  ===
527
549
 
550
+ # @headless-tree/react@0.0.15 (MIT)
551
+
552
+ MIT
553
+
554
+ ===
555
+
528
556
  # y-prosemirror@1.2.15 (MIT)
529
557
 
530
558
  The MIT License (MIT)
@@ -552,35 +580,7 @@ SOFTWARE.
552
580
 
553
581
  ===
554
582
 
555
- # @babel/runtime@7.25.4 (MIT)
556
-
557
- MIT License
558
-
559
- Copyright (c) 2014-present Sebastian McKenzie and other contributors
560
-
561
- Permission is hereby granted, free of charge, to any person obtaining
562
- a copy of this software and associated documentation files (the
563
- "Software"), to deal in the Software without restriction, including
564
- without limitation the rights to use, copy, modify, merge, publish,
565
- distribute, sublicense, and/or sell copies of the Software, and to
566
- permit persons to whom the Software is furnished to do so, subject to
567
- the following conditions:
568
-
569
- The above copyright notice and this permission notice shall be
570
- included in all copies or substantial portions of the Software.
571
-
572
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
573
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
574
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
575
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
576
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
577
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
578
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
579
-
580
-
581
- ===
582
-
583
- # @react-aria/interactions@3.23.0 (Apache-2.0)
583
+ # @react-aria/focus@3.19.1 (Apache-2.0)
584
584
 
585
585
  Apache License
586
586
  Version 2.0, January 2004
@@ -787,7 +787,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
787
787
 
788
788
  ===
789
789
 
790
- # @react-aria/focus@3.19.1 (Apache-2.0)
790
+ # @react-aria/interactions@3.23.0 (Apache-2.0)
791
791
 
792
792
  Apache License
793
793
  Version 2.0, January 2004
@@ -49,17 +49,16 @@ var NextCMS = class extends CMS {
49
49
  const payload = getPreviewPayloadFromCookies(cookie.getAll());
50
50
  if (payload) preview = { payload };
51
51
  }
52
- const { PHASE_PRODUCTION_BUILD } = await import("next/constants");
52
+ const { PHASE_PRODUCTION_SERVER, PHASE_PRODUCTION_BUILD } = await import("next/constants");
53
53
  const isEdge = process.env.NEXT_RUNTIME === "edge";
54
+ const isServer = process.env.NEXT_PHASE === PHASE_PRODUCTION_SERVER;
54
55
  const isBuild = process.env.NEXT_PHASE === PHASE_PRODUCTION_BUILD;
55
56
  const request = { preview, ...query, status };
56
- const useLocalDb = isBuild || !preview && !isEdge;
57
- if (useLocalDb) {
58
- const db = await this.bundledDb;
59
- await this.throttle(() => db.syncWith(client), request.syncInterval);
60
- return db.resolve(request);
61
- }
62
- return client.resolve(request);
57
+ const useLocalDb = !isEdge && (isServer || isBuild);
58
+ if (!useLocalDb) return client.resolve(request);
59
+ const db = await this.bundledDb;
60
+ await this.throttle(() => db.syncWith(client), request.syncInterval);
61
+ return db.resolve(request);
63
62
  }
64
63
  async #authenticatedClient() {
65
64
  const { handlerUrl, apiKey } = await requestContext(this.config);
@@ -19,7 +19,7 @@ import { requestContext } from "./context.js";
19
19
  var handlers = /* @__PURE__ */ new WeakMap();
20
20
  function createHandler(input) {
21
21
  const options = input instanceof NextCMS ? { cms: input } : input;
22
- const remote = options.remote ?? (options.backend ? createBackend(options.cms.config, options.backend) : (context) => new CloudRemote(context, options.cms));
22
+ const remote = options.remote ?? (options.backend ? createBackend(options.cms.config, options.backend) : (context) => new CloudRemote(context, options.cms.config));
23
23
  if (handlers.has(options.cms)) return handlers.get(options.cms);
24
24
  const config = options.cms.config;
25
25
  const db = PLazy.from(async () => {
@@ -1,13 +1,10 @@
1
- import {
2
- version
3
- } from "../../chunks/chunk-VNF4OZAJ.js";
4
1
  import "../../chunks/chunk-NZLE2WMY.js";
5
2
 
6
3
  // src/adapter/next/with-alinea.ts
7
4
  import { readFileSync } from "node:fs";
8
5
  import { createRequire } from "node:module";
9
6
  import { resolve } from "node:path";
10
- import { bold, cyan, gray } from "alinea/cli/util/Report";
7
+ import { bold, cyan } from "alinea/cli/util/Report";
11
8
  function createCMS() {
12
9
  throw new Error(
13
10
  'Alinea was loaded in a CJS environment. Please ensure your project is marked as "type": "module" in package.json.'
@@ -98,12 +95,10 @@ function createRewrites(config, adminPath) {
98
95
  const nextHost = process.env.__NEXT_PRIVATE_HOST;
99
96
  const origin = nextOrigin ?? (nextHost ? `http://${nextHost}` : null);
100
97
  const location = origin ? new URL(adminPath, origin).href : adminPath;
101
- if (isDev) {
102
- const alineaVersion = gray(version);
103
- const header = `
104
- ${cyan(bold("\u0251 Alinea"))} ${alineaVersion}
105
- `;
106
- console.log(`${header} - Local CMS: ${location}
98
+ if (isDev && !process.env.__NEXT_PRIVATE_ALINEA_REPORTED) {
99
+ process.env.__NEXT_PRIVATE_ALINEA_REPORTED = "true";
100
+ console.log(`
101
+ ${cyan(bold("\u0251 Alinea CMS"))}: ${location}
107
102
  `);
108
103
  }
109
104
  const existing = config.rewrites ? await config.rewrites() : [];
@@ -215,13 +215,14 @@ function createHandler({
215
215
  return new Response("Bad Request", { status: 400 });
216
216
  } catch (error) {
217
217
  if (error instanceof Response) return error;
218
- console.error(error);
218
+ const status = error instanceof HttpError ? error.code : 500;
219
+ if (!(error instanceof HttpError)) console.error(error);
219
220
  return Response.json(
220
221
  {
221
222
  success: false,
222
223
  error: error instanceof Error ? error.message : String(error)
223
224
  },
224
- { status: error instanceof HttpError ? error.code : 500 }
225
+ { status }
225
226
  );
226
227
  }
227
228
  };
@@ -1,6 +1,7 @@
1
1
  import { Request, Response } from '@alinea/iso';
2
2
  import { Config } from 'alinea/core/Config';
3
3
  import type { AuthApi, AuthedContext, RequestContext } from 'alinea/core/Connection';
4
+ import { JWTPayload } from 'alinea/core/util/JWT';
4
5
  export interface OAuth2Options {
5
6
  /**
6
7
  * OAuth2 clientId
@@ -36,6 +37,11 @@ export interface OAuth2Options {
36
37
  * Required for revoking tokens. Not supported by all servers.
37
38
  */
38
39
  revocationEndpoint?: string;
40
+ /**
41
+ * Extra claims to validate, such as `iss` or `aud`,
42
+ * If the claims are invalid, an error should be thrown.
43
+ */
44
+ validateClaims?(claims: JWTPayload): void;
39
45
  }
40
46
  export declare class OAuth2 implements AuthApi {
41
47
  #private;
@@ -457,13 +457,15 @@ var OAuth2 = class {
457
457
  #config;
458
458
  #client;
459
459
  #jwks;
460
+ #validateClaims;
460
461
  constructor(context, config, options) {
461
462
  this.#context = context;
462
463
  this.#config = config;
464
+ this.#validateClaims = options.validateClaims;
463
465
  this.#client = new OAuth2Client({
464
466
  ...options,
465
467
  authenticationMethod: "client_secret_basic_interop",
466
- async fetch(input, init) {
468
+ fetch: async (input, init) => {
467
469
  const request = new Request2(input, init);
468
470
  const response = await fetch(request);
469
471
  if (!response.ok) {
@@ -526,7 +528,8 @@ var OAuth2 = class {
526
528
  value: codeVerifier,
527
529
  path: redirectUri.pathname,
528
530
  secure: redirectUri.protocol === "https:",
529
- httpOnly: true
531
+ httpOnly: true,
532
+ sameSite: "lax"
530
533
  })
531
534
  }
532
535
  }
@@ -601,31 +604,29 @@ var OAuth2 = class {
601
604
  throw new MissingCredentialsError("Missing access token cookie");
602
605
  const key = selectKey(jwks, accessToken);
603
606
  const user = await verify(accessToken, key);
607
+ this.#validateClaims?.(user);
608
+ assert(user.exp, "Missing exp claim in access token");
604
609
  const expiresSoon = user.exp - Math.floor(Date.now() / 1e3) < 30;
605
610
  if (expiresSoon && refreshToken)
606
611
  throw new InvalidCredentialsError("Access token will expire soon");
607
612
  return { ...ctx, user, token: accessToken };
608
613
  } catch (error) {
609
614
  if (!refreshToken) throw error;
610
- const key = selectKey(jwks, refreshToken);
611
- const [, failed] = await outcome(verify(refreshToken, key));
612
- if (failed)
613
- throw new InvalidCredentialsError("Invalid refresh token", {
614
- cause: [failed, error]
615
- });
616
615
  const token = { accessToken, refreshToken, expiresAt: null };
617
616
  const newToken = await this.#client.refreshToken(token).catch((cause) => {
618
617
  throw new InvalidCredentialsError("Failed to refresh token", {
619
618
  cause: [cause, error]
620
619
  });
621
620
  });
622
- await verify(newToken.accessToken, key, {
621
+ const key = selectKey(jwks, newToken.accessToken);
622
+ const user = await verify(newToken.accessToken, key, {
623
623
  clockTolerance: 30
624
624
  }).catch((cause) => {
625
625
  throw new InvalidCredentialsError("Failed to verify user", {
626
626
  cause: [cause, error]
627
627
  });
628
628
  });
629
+ this.#validateClaims?.(user);
629
630
  throw Response.json(
630
631
  { type: AuthResultType.NeedsRefresh },
631
632
  {
@@ -639,10 +640,29 @@ var OAuth2 = class {
639
640
  }
640
641
  };
641
642
  function selectKey(jwks, token) {
642
- const kid = decode(token).header.kid;
643
- if (!kid) return jwks[0];
643
+ const { header } = decode(token);
644
+ const kid = header.kid;
645
+ const alg = header.alg;
646
+ if (!kid) {
647
+ if (jwks.length === 1) {
648
+ const key2 = jwks[0];
649
+ if (key2.alg && alg && key2.alg !== alg) {
650
+ throw new Error(
651
+ `Algorithm mismatch: token uses ${alg}, but key specifies ${key2.alg}`
652
+ );
653
+ }
654
+ return key2;
655
+ }
656
+ throw new Error(
657
+ 'Token is missing "kid" header, and JWKS contains multiple keys'
658
+ );
659
+ }
644
660
  const key = jwks.find((k) => k.kid === kid);
645
661
  if (!key) throw new Error(`No key found for kid: ${kid}`);
662
+ if (key.alg && alg && key.alg !== alg)
663
+ throw new Error(
664
+ `Algorithm mismatch: token uses ${alg}, but key specifies ${key.alg}`
665
+ );
646
666
  return key;
647
667
  }
648
668
  function clearCookies(redirectUri) {
@@ -653,7 +673,8 @@ function clearCookies(redirectUri) {
653
673
  expires: /* @__PURE__ */ new Date(0),
654
674
  path: "/",
655
675
  secure: redirectUri.protocol === "https:",
656
- httpOnly: true
676
+ httpOnly: true,
677
+ sameSite: "lax"
657
678
  },
658
679
  {
659
680
  name: COOKIE_REFRESH_TOKEN,
@@ -675,7 +696,8 @@ function tokenToCookie(token, redirectUri) {
675
696
  expires: token.expiresAt ? new Date(token.expiresAt) : void 0,
676
697
  path: "/",
677
698
  secure: redirectUri.protocol === "https:",
678
- httpOnly: true
699
+ httpOnly: true,
700
+ sameSite: "lax"
679
701
  },
680
702
  {
681
703
  name: COOKIE_REFRESH_TOKEN,
@@ -1,5 +1,5 @@
1
- import type { PreviewRequest } from 'alinea/core/Preview';
2
1
  import type { LocalDB } from 'alinea/core/db/LocalDB';
2
+ import type { PreviewRequest } from 'alinea/core/Preview';
3
3
  export declare function createPreviewParser(local: LocalDB): {
4
4
  parse(preview: PreviewRequest, sync: () => Promise<unknown>): Promise<PreviewRequest | undefined>;
5
5
  };
@@ -25,9 +25,17 @@ function createPreviewParser(local) {
25
25
  });
26
26
  if (!entry) return;
27
27
  const baseText = decoder.decode(
28
- JsonLoader.format(local.config.schema, createRecord(entry, entry.status))
28
+ JsonLoader.format(
29
+ local.config.schema,
30
+ createRecord(entry, entry.status)
31
+ )
29
32
  );
30
- const updatedText = await applyFilePatch(baseText, payload.patch);
33
+ let updatedText;
34
+ try {
35
+ updatedText = await applyFilePatch(baseText, payload.patch);
36
+ } catch {
37
+ return;
38
+ }
31
39
  const { data } = parseRecord(JSON.parse(updatedText));
32
40
  const { rowHash: _rowHash, fileHash: _fileHash, ...withoutHashes } = entry;
33
41
  const patched = await createEntryRow(
@@ -38,6 +38,11 @@ export declare namespace router {
38
38
  url: URL;
39
39
  params: Record<string, unknown>;
40
40
  }>;
41
+ options(path: string): Route<globalThis.Request, {
42
+ request: globalThis.Request;
43
+ url: URL;
44
+ params: Record<string, unknown>;
45
+ }>;
41
46
  all(path: string): Route<globalThis.Request, {
42
47
  request: globalThis.Request;
43
48
  url: URL;
@@ -65,6 +70,11 @@ export declare namespace router {
65
70
  url: URL;
66
71
  params: Record<string, unknown>;
67
72
  }>;
73
+ options(path: string): Route<globalThis.Request, {
74
+ request: globalThis.Request;
75
+ url: URL;
76
+ params: Record<string, unknown>;
77
+ }>;
68
78
  all(path: string): Route<globalThis.Request, {
69
79
  request: globalThis.Request;
70
80
  url: URL;
@@ -92,6 +102,11 @@ export declare namespace router {
92
102
  url: URL;
93
103
  params: Record<string, unknown>;
94
104
  }>;
105
+ options(path: string): Route<globalThis.Request, {
106
+ request: globalThis.Request;
107
+ url: URL;
108
+ params: Record<string, unknown>;
109
+ }>;
95
110
  all(path: string): Route<globalThis.Request, {
96
111
  request: globalThis.Request;
97
112
  url: URL;
@@ -91,6 +91,9 @@ function callHandler(handler, input) {
91
91
  delete(path) {
92
92
  return withMethod("DELETE").map(withPath(path, getPathname));
93
93
  },
94
+ options(path) {
95
+ return withMethod("OPTIONS").map(withPath(path, getPathname));
96
+ },
94
97
  all(path) {
95
98
  return withPath(path, getPathname);
96
99
  }
@@ -1,8 +1,8 @@
1
1
  import PLazy from 'p-lazy';
2
2
  export declare function execGit(cwd: string, args: string[]): Promise<string>;
3
3
  export declare function gitUser(cwd: string): PLazy<{
4
- name: string;
5
- email: string;
6
4
  sub: string;
7
5
  roles: string[];
6
+ name: string;
7
+ email: string;
8
8
  }>;