alinea 1.7.0-preview.8 → 1.7.0

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 (83) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +62 -62
  3. package/dist/adapter/next/handler.js +1 -1
  4. package/dist/backend/api/OAuth2.d.ts +6 -0
  5. package/dist/backend/api/OAuth2.js +35 -13
  6. package/dist/backend/router/Router.d.ts +15 -0
  7. package/dist/backend/router/Router.js +3 -0
  8. package/dist/backend/util/ExecGit.d.ts +2 -2
  9. package/dist/bundled.d.ts +297 -235
  10. package/dist/chunks/{chunk-VE4QBNQR.js → chunk-2X5P2RZV.js} +10 -5
  11. package/dist/chunks/{chunk-POPX5CXB.js → chunk-WKC37UOZ.js} +12 -6
  12. package/dist/cli/Serve.js +1 -1
  13. package/dist/cli/bin.js +1 -1
  14. package/dist/cli/serve/CreateLocalServer.js +34 -4
  15. package/dist/cloud/CloudRemote.d.ts +2 -2
  16. package/dist/cloud/CloudRemote.js +8 -2
  17. package/dist/core/Graph.d.ts +1 -1
  18. package/dist/core/Type.d.ts +2 -0
  19. package/dist/core/db/EntryIndex.d.ts +3 -1
  20. package/dist/core/db/EntryIndex.js +15 -3
  21. package/dist/core/db/LocalDB.d.ts +1 -1
  22. package/dist/core/db/Operation.js +3 -1
  23. package/dist/core/db/WriteableGraph.d.ts +1 -1
  24. package/dist/core/media/IsImage.d.ts +1 -1
  25. package/dist/core/media/MediaTypes.d.ts +1 -1
  26. package/dist/core/media/Summary.d.ts +2 -2
  27. package/dist/core/shape/ListShape.d.ts +1 -1
  28. package/dist/core/source/FSSource.d.ts +2 -2
  29. package/dist/core/source/Source.d.ts +2 -2
  30. package/dist/core/source/Tree.d.ts +3 -3
  31. package/dist/core/source/Utils.js +4 -1
  32. package/dist/core/util/ArrayBuffers.d.ts +1 -1
  33. package/dist/core/util/BufferToBase64.d.ts +2 -2
  34. package/dist/core/util/JWT.d.ts +11 -2
  35. package/dist/core/util/JWT.js +16 -12
  36. package/dist/dashboard/DashboardNav.d.ts +8 -8
  37. package/dist/dashboard/Routes.d.ts +25 -25
  38. package/dist/dashboard/atoms/DbAtoms.d.ts +1 -1
  39. package/dist/dashboard/atoms/Edits.d.ts +3 -3
  40. package/dist/dashboard/atoms/EntryEditorAtoms.d.ts +27 -27
  41. package/dist/dashboard/atoms/EntryEditorAtoms.js +3 -1
  42. package/dist/dashboard/atoms/EntrySummaryAtoms.d.ts +1 -1
  43. package/dist/dashboard/atoms/NavigationAtoms.d.ts +9 -9
  44. package/dist/dashboard/atoms/PreferencesAtoms.d.ts +1 -1
  45. package/dist/dashboard/atoms/RouterAtoms.d.ts +1 -1
  46. package/dist/dashboard/boot/LoadWorker.js +3 -2
  47. package/dist/dashboard/editor/DefaultViews.d.ts +1 -1
  48. package/dist/dashboard/editor/UseField.js +8 -1
  49. package/dist/dashboard/hook/UseNav.d.ts +4 -4
  50. package/dist/dashboard/hook/UseRoot.d.ts +2 -2
  51. package/dist/dashboard/hook/UseWorkspace.d.ts +3 -3
  52. package/dist/dashboard/util/Loader.d.ts +1 -1
  53. package/dist/dashboard/view/InputLabel.d.ts +1 -1
  54. package/dist/dashboard/view/explorer/ExplorerRow.d.ts +1 -1
  55. package/dist/field/link/EntryLink.d.ts +1 -1
  56. package/dist/field/link/FileLink.d.ts +2 -2
  57. package/dist/field/link/LinkField.view.js +18 -0
  58. package/dist/field/link/UrlLink.d.ts +1 -1
  59. package/dist/field/richtext/Extensions.d.ts +1 -0
  60. package/dist/field/richtext/Extensions.js +118 -9
  61. package/dist/field/richtext/Toolbar.d.ts +6 -0
  62. package/dist/field/richtext/Toolbar.js +7 -0
  63. package/dist/index.css +4 -0
  64. package/dist/picker/url/UrlPicker.js +1 -1
  65. package/dist/query.d.ts +85 -85
  66. package/dist/test/example.d.ts +58 -58
  67. package/dist/test/schema/DemoHome.d.ts +17 -17
  68. package/dist/test/schema/DemoRecipe.d.ts +10 -10
  69. package/dist/test/schema/DemoRecipes.d.ts +2 -2
  70. package/dist/ui/Button.stories.d.ts +1 -1
  71. package/dist/ui/Ellipsis.d.ts +1 -1
  72. package/dist/ui/Stack.d.ts +4 -4
  73. package/dist/ui/Typo.d.ts +2 -2
  74. package/dist/ui/icons/IcRoundAttachFile.d.ts +2 -0
  75. package/dist/ui/icons/IcRoundAttachFile.js +10 -0
  76. package/dist/ui/icons/IcRoundFormatPaint.d.ts +2 -0
  77. package/dist/ui/icons/IcRoundFormatPaint.js +10 -0
  78. package/dist/ui/icons/IcRoundPanorama.d.ts +2 -0
  79. package/dist/ui/icons/IcRoundPanorama.js +10 -0
  80. package/dist/ui/util/CreateTypo.d.ts +2 -2
  81. package/llms-full.txt +4278 -0
  82. package/package.json +10 -5
  83. package/readme.md +4 -0
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "3AAFNBSBqm6OwSCqZ2z4QoOx6xE",
2
+ "_id": "3FfV0NSwBQrEU7mbIBV6bd2LEJM",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
package/dist/LICENSES.md CHANGED
@@ -28,11 +28,11 @@ SOFTWARE.
28
28
 
29
29
  ===
30
30
 
31
- # react-query@3.39.3 (MIT)
31
+ # lib0@0.2.88 (MIT)
32
32
 
33
- MIT License
33
+ The MIT License (MIT)
34
34
 
35
- Copyright (c) 2019 Tanner Linsley
35
+ Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
36
36
 
37
37
  Permission is hereby granted, free of charge, to any person obtaining a copy
38
38
  of this software and associated documentation files (the "Software"), to deal
@@ -55,11 +55,11 @@ SOFTWARE.
55
55
 
56
56
  ===
57
57
 
58
- # lib0@0.2.88 (MIT)
58
+ # react-query@3.39.3 (MIT)
59
59
 
60
- The MIT License (MIT)
60
+ MIT License
61
61
 
62
- Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
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
@@ -189,6 +189,33 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
189
189
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
190
190
 
191
191
 
192
+ ===
193
+
194
+ # @badgateway/oauth2-client@3.2.0 (MIT)
195
+
196
+ MIT License
197
+
198
+ Copyright (c) 2019-2023 Evert Pot
199
+
200
+ Permission is hereby granted, free of charge, to any person obtaining a copy
201
+ of this software and associated documentation files (the "Software"), to deal
202
+ in the Software without restriction, including without limitation the rights
203
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
204
+ copies of the Software, and to permit persons to whom the Software is
205
+ furnished to do so, subject to the following conditions:
206
+
207
+ The above copyright notice and this permission notice shall be included in all
208
+ copies or substantial portions of the Software.
209
+
210
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
211
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
212
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
213
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
214
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
215
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
216
+ SOFTWARE.
217
+
218
+
192
219
  ===
193
220
 
194
221
  # entities@4.5.0 (BSD-2-Clause)
@@ -208,11 +235,11 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
208
235
 
209
236
  ===
210
237
 
211
- # @badgateway/oauth2-client@3.2.0 (MIT)
238
+ # prop-types@15.8.1 (MIT)
212
239
 
213
240
  MIT License
214
241
 
215
- Copyright (c) 2019-2023 Evert Pot
242
+ Copyright (c) 2013-present, Facebook, Inc.
216
243
 
217
244
  Permission is hereby granted, free of charge, to any person obtaining a copy
218
245
  of this software and associated documentation files (the "Software"), to deal
@@ -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)
@@ -523,33 +523,6 @@ MIT
523
523
 
524
524
  MIT
525
525
 
526
- ===
527
-
528
- # y-prosemirror@1.2.15 (MIT)
529
-
530
- The MIT License (MIT)
531
-
532
- Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
533
-
534
- Permission is hereby granted, free of charge, to any person obtaining a copy
535
- of this software and associated documentation files (the "Software"), to deal
536
- in the Software without restriction, including without limitation the rights
537
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
538
- copies of the Software, and to permit persons to whom the Software is
539
- furnished to do so, subject to the following conditions:
540
-
541
- The above copyright notice and this permission notice shall be included in all
542
- copies or substantial portions of the Software.
543
-
544
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
545
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
546
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
547
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
548
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
549
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
550
- SOFTWARE.
551
-
552
-
553
526
  ===
554
527
 
555
528
  # @babel/runtime@7.25.4 (MIT)
@@ -578,6 +551,33 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
578
551
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
579
552
 
580
553
 
554
+ ===
555
+
556
+ # y-prosemirror@1.2.15 (MIT)
557
+
558
+ The MIT License (MIT)
559
+
560
+ Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
561
+
562
+ Permission is hereby granted, free of charge, to any person obtaining a copy
563
+ of this software and associated documentation files (the "Software"), to deal
564
+ in the Software without restriction, including without limitation the rights
565
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
566
+ copies of the Software, and to permit persons to whom the Software is
567
+ furnished to do so, subject to the following conditions:
568
+
569
+ The above copyright notice and this permission notice shall be included in all
570
+ copies or substantial portions of the Software.
571
+
572
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
573
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
574
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
575
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
576
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
577
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
578
+ SOFTWARE.
579
+
580
+
581
581
  ===
582
582
 
583
583
  # @react-aria/focus@3.19.1 (Apache-2.0)
@@ -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,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,
@@ -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
  }>;