alinea 1.7.0-preview.9 → 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 +78 -78
  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-JZK53UUC.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 -2
  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": "3AG2thbJkXYHucSTk90uzYxsKUo",
2
+ "_id": "3FfV0NSwBQrEU7mbIBV6bd2LEJM",
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)
@@ -189,23 +189,6 @@ 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
- # entities@4.5.0 (BSD-2-Clause)
195
-
196
- Copyright (c) Felix Böhm
197
- All rights reserved.
198
-
199
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
200
-
201
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
202
-
203
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
204
-
205
- THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
206
- EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
207
-
208
-
209
192
  ===
210
193
 
211
194
  # @badgateway/oauth2-client@3.2.0 (MIT)
@@ -233,6 +216,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
233
216
  SOFTWARE.
234
217
 
235
218
 
219
+ ===
220
+
221
+ # entities@4.5.0 (BSD-2-Clause)
222
+
223
+ Copyright (c) Felix Böhm
224
+ All rights reserved.
225
+
226
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
227
+
228
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
229
+
230
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
231
+
232
+ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS,
233
+ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
234
+
235
+
236
236
  ===
237
237
 
238
238
  # prop-types@15.8.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)
@@ -580,7 +553,34 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
580
553
 
581
554
  ===
582
555
 
583
- # @react-aria/interactions@3.23.0 (Apache-2.0)
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
+ ===
582
+
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
@@ -1612,33 +1612,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1612
1612
  See the License for the specific language governing permissions and
1613
1613
  limitations under the License.
1614
1614
 
1615
- ===
1616
-
1617
- # @tanstack/virtual-core@3.10.6 (MIT)
1618
-
1619
- MIT License
1620
-
1621
- Copyright (c) 2021-present Tanner Linsley
1622
-
1623
- Permission is hereby granted, free of charge, to any person obtaining a copy
1624
- of this software and associated documentation files (the "Software"), to deal
1625
- in the Software without restriction, including without limitation the rights
1626
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1627
- copies of the Software, and to permit persons to whom the Software is
1628
- furnished to do so, subject to the following conditions:
1629
-
1630
- The above copyright notice and this permission notice shall be included in all
1631
- copies or substantial portions of the Software.
1632
-
1633
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1634
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1635
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1636
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1637
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1638
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1639
- SOFTWARE.
1640
-
1641
-
1642
1615
  ===
1643
1616
 
1644
1617
  # @react-stately/utils@3.10.5 (Apache-2.0)
@@ -1844,3 +1817,30 @@ SOFTWARE.
1844
1817
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1845
1818
  See the License for the specific language governing permissions and
1846
1819
  limitations under the License.
1820
+
1821
+
1822
+ ===
1823
+
1824
+ # @tanstack/virtual-core@3.10.6 (MIT)
1825
+
1826
+ MIT License
1827
+
1828
+ Copyright (c) 2021-present Tanner Linsley
1829
+
1830
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1831
+ of this software and associated documentation files (the "Software"), to deal
1832
+ in the Software without restriction, including without limitation the rights
1833
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1834
+ copies of the Software, and to permit persons to whom the Software is
1835
+ furnished to do so, subject to the following conditions:
1836
+
1837
+ The above copyright notice and this permission notice shall be included in all
1838
+ copies or substantial portions of the Software.
1839
+
1840
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1841
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1842
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1843
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1844
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1845
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1846
+ SOFTWARE.
@@ -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
  }>;