alinea 1.4.5 → 1.5.0-preview.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 (82) hide show
  1. package/dist/.init/content/pages/welcome.json +1 -1
  2. package/dist/LICENSES.md +94 -67
  3. package/dist/adapter/core/preview.js +3 -50
  4. package/dist/adapter/next/cms.d.ts +1 -1
  5. package/dist/adapter/next/cms.js +13 -7
  6. package/dist/adapter/next/handler.d.ts +1 -1
  7. package/dist/adapter/next/handler.js +5 -5
  8. package/dist/backend/Auth.d.ts +11 -0
  9. package/dist/backend/Auth.js +17 -1
  10. package/dist/backend/Handler.js +154 -132
  11. package/dist/backend/api/BasicAuth.d.ts +1 -2
  12. package/dist/backend/api/BasicAuth.js +10 -5
  13. package/dist/backend/api/CreateBackend.d.ts +5 -2
  14. package/dist/backend/api/CreateBackend.js +7 -2
  15. package/dist/backend/api/OAuth2.d.ts +45 -0
  16. package/dist/backend/api/OAuth2.js +665 -0
  17. package/dist/backend/router/Router.d.ts +1 -2
  18. package/dist/backend/router/Router.js +2 -11
  19. package/dist/bundled.d.ts +171 -93
  20. package/dist/chunks/chunk-5LTN67OE.js +51 -0
  21. package/dist/chunks/{chunk-WR25RMMO.js → chunk-T5PTMPOY.js} +5 -3
  22. package/dist/chunks/{chunk-BWPXC7VK.js → chunk-X6AXYEGR.js} +4 -2
  23. package/dist/cli/Init.js +2 -1
  24. package/dist/cli/Serve.js +1 -1
  25. package/dist/cli/bin.js +1 -1
  26. package/dist/cli/generate/DevDB.js +3 -3
  27. package/dist/cli/util/EnsureLibs.js +6 -7
  28. package/dist/cloud/CloudConfig.d.ts +3 -1
  29. package/dist/cloud/CloudConfig.js +5 -2
  30. package/dist/cloud/CloudRemote.d.ts +3 -11
  31. package/dist/cloud/CloudRemote.js +31 -112
  32. package/dist/core/Client.d.ts +4 -5
  33. package/dist/core/Connection.d.ts +5 -3
  34. package/dist/core/HttpError.d.ts +1 -0
  35. package/dist/core/HttpError.js +1 -0
  36. package/dist/core/Outcome.d.ts +4 -59
  37. package/dist/core/Outcome.js +6 -114
  38. package/dist/core/db/EntryIndex.js +2 -1
  39. package/dist/core/db/EntryResolver.d.ts +1 -1
  40. package/dist/core/db/EntryResolver.js +4 -6
  41. package/dist/core/db/EntryTransaction.js +1 -1
  42. package/dist/core/source/CombinedSource.js +2 -1
  43. package/dist/core/source/FSSource.js +1 -1
  44. package/dist/core/source/GitUtils.js +1 -1
  45. package/dist/core/source/GithubSource.js +1 -1
  46. package/dist/core/source/IndexedDBSource.js +47 -18
  47. package/dist/core/source/MemorySource.js +1 -1
  48. package/dist/core/source/Tree.js +2 -1
  49. package/dist/core/source/Utils.d.ts +0 -1
  50. package/dist/core/source/Utils.js +0 -7
  51. package/dist/core/util/Assert.d.ts +1 -0
  52. package/dist/core/util/Assert.js +12 -0
  53. package/dist/core/util/JWT.d.ts +43 -0
  54. package/dist/core/util/JWT.js +1 -0
  55. package/dist/dashboard/atoms/Edits.js +2 -1
  56. package/dist/dashboard/atoms/EntryEditorAtoms.js +8 -5
  57. package/dist/dashboard/atoms/EntrySummaryAtoms.js +3 -3
  58. package/dist/dashboard/view/EntryTree.js +1 -1
  59. package/dist/dashboard/view/InputLabel.d.ts +4 -0
  60. package/dist/dashboard/view/InputLabel.js +45 -16
  61. package/dist/dashboard/view/MediaExplorer.js +1 -5
  62. package/dist/dashboard/view/RootOverview.js +1 -5
  63. package/dist/dashboard/view/WorkspaceLabel.js +2 -2
  64. package/dist/dashboard/view/entry/EntryTitle.js +1 -5
  65. package/dist/dashboard/view/media/FileEntry.js +4 -5
  66. package/dist/field/check/CheckField.view.js +19 -8
  67. package/dist/field/list/ListField.view.d.ts +1 -1
  68. package/dist/field/list/ListField.view.js +160 -94
  69. package/dist/field/metadata/MetadataField.d.ts +1 -3
  70. package/dist/field/metadata/MetadataField.js +3 -5
  71. package/dist/field/select/SelectField.view.js +8 -4
  72. package/dist/field/text/TextField.d.ts +4 -0
  73. package/dist/field/text/TextField.view.js +2 -2
  74. package/dist/index.css +47 -20
  75. package/dist/ui/icons/IcRoundArrowDownward.d.ts +2 -0
  76. package/dist/ui/icons/IcRoundArrowDownward.js +26 -0
  77. package/dist/ui/icons/IcRoundArrowUpward.d.ts +2 -0
  78. package/dist/ui/icons/IcRoundArrowUpward.js +26 -0
  79. package/dist/ui/icons/IcRoundUnfoldLess.d.ts +2 -0
  80. package/dist/ui/icons/IcRoundUnfoldLess.js +26 -0
  81. package/package.json +4 -2
  82. package/readme.md +8 -2
@@ -1,5 +1,5 @@
1
1
  {
2
- "_id": "303LNPVhQGZ57ejsBVupQkfQyNC",
2
+ "_id": "30goFjOPTAuQcjsL8WnVg9QmGeR",
3
3
  "_type": "Page",
4
4
  "_index": "a0",
5
5
  "_seeded": "welcome.json",
package/dist/LICENSES.md CHANGED
@@ -2,11 +2,11 @@ This file contains the licenses of the bundled modules in this distribution.
2
2
 
3
3
  ===
4
4
 
5
- # rado@1.0.15 (MIT)
5
+ # react-query@3.39.3 (MIT)
6
6
 
7
7
  MIT License
8
8
 
9
- Copyright (c) 2024 Ben Merckx
9
+ Copyright (c) 2019 Tanner Linsley
10
10
 
11
11
  Permission is hereby granted, free of charge, to any person obtaining a copy
12
12
  of this software and associated documentation files (the "Software"), to deal
@@ -26,13 +26,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26
26
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27
27
  SOFTWARE.
28
28
 
29
+
29
30
  ===
30
31
 
31
- # lib0@0.2.88 (MIT)
32
+ # @headlessui/react@2.2.0 (MIT)
32
33
 
33
- The MIT License (MIT)
34
+ MIT License
34
35
 
35
- Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
36
+ Copyright (c) 2020 Tailwind Labs
36
37
 
37
38
  Permission is hereby granted, free of charge, to any person obtaining a copy
38
39
  of this software and associated documentation files (the "Software"), to deal
@@ -52,14 +53,13 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
52
53
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
53
54
  SOFTWARE.
54
55
 
55
-
56
56
  ===
57
57
 
58
- # react-query@3.39.3 (MIT)
58
+ # rado@1.0.15 (MIT)
59
59
 
60
60
  MIT License
61
61
 
62
- Copyright (c) 2019 Tanner Linsley
62
+ Copyright (c) 2024 Ben Merckx
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,14 +79,13 @@ 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
-
83
82
  ===
84
83
 
85
- # @headlessui/react@2.2.0 (MIT)
84
+ # lib0@0.2.88 (MIT)
86
85
 
87
- MIT License
86
+ The MIT License (MIT)
88
87
 
89
- Copyright (c) 2020 Tailwind Labs
88
+ Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
90
89
 
91
90
  Permission is hereby granted, free of charge, to any person obtaining a copy
92
91
  of this software and associated documentation files (the "Software"), to deal
@@ -106,6 +105,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
106
105
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
107
106
  SOFTWARE.
108
107
 
108
+
109
109
  ===
110
110
 
111
111
  # htmlparser2@9.1.0 (MIT)
@@ -131,33 +131,34 @@ IN THE SOFTWARE.
131
131
 
132
132
  ===
133
133
 
134
- # @popperjs/core@2.11.8 (MIT)
134
+ # @badgateway/oauth2-client@3.2.0 (MIT)
135
135
 
136
- The MIT License (MIT)
136
+ MIT License
137
137
 
138
- Copyright (c) 2019 Federico Zivolo
138
+ Copyright (c) 2019-2023 Evert Pot
139
139
 
140
- Permission is hereby granted, free of charge, to any person obtaining a copy of
141
- this software and associated documentation files (the "Software"), to deal in
142
- the Software without restriction, including without limitation the rights to
143
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
144
- the Software, and to permit persons to whom the Software is furnished to do so,
145
- subject to the following conditions:
140
+ Permission is hereby granted, free of charge, to any person obtaining a copy
141
+ of this software and associated documentation files (the "Software"), to deal
142
+ in the Software without restriction, including without limitation the rights
143
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
144
+ copies of the Software, and to permit persons to whom the Software is
145
+ furnished to do so, subject to the following conditions:
146
146
 
147
147
  The above copyright notice and this permission notice shall be included in all
148
148
  copies or substantial portions of the Software.
149
149
 
150
150
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
151
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
152
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
153
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
154
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
155
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
151
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
152
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
153
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
154
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
155
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
156
+ SOFTWARE.
156
157
 
157
158
 
158
159
  ===
159
160
 
160
- # domhandler@5.0.3 (BSD-2-Clause)
161
+ # domutils@3.1.0 (BSD-2-Clause)
161
162
 
162
163
  Copyright (c) Felix Böhm
163
164
  All rights reserved.
@@ -174,7 +175,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
174
175
 
175
176
  ===
176
177
 
177
- # domutils@3.1.0 (BSD-2-Clause)
178
+ # domhandler@5.0.3 (BSD-2-Clause)
178
179
 
179
180
  Copyright (c) Felix Böhm
180
181
  All rights reserved.
@@ -189,6 +190,32 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
189
190
  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
190
191
 
191
192
 
193
+ ===
194
+
195
+ # @popperjs/core@2.11.8 (MIT)
196
+
197
+ The MIT License (MIT)
198
+
199
+ Copyright (c) 2019 Federico Zivolo
200
+
201
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
202
+ this software and associated documentation files (the "Software"), to deal in
203
+ the Software without restriction, including without limitation the rights to
204
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
205
+ the Software, and to permit persons to whom the Software is furnished to do so,
206
+ subject to the following conditions:
207
+
208
+ The above copyright notice and this permission notice shall be included in all
209
+ copies or substantial portions of the Software.
210
+
211
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
212
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
213
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
214
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
215
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
216
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
217
+
218
+
192
219
  ===
193
220
 
194
221
  # entities@4.5.0 (BSD-2-Clause)
@@ -467,18 +494,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
467
494
  SOFTWARE.
468
495
 
469
496
 
470
- ===
471
-
472
- # @headless-tree/react@0.0.15 (MIT)
473
-
474
- MIT
475
-
476
- ===
477
-
478
- # @headless-tree/core@0.0.15 (MIT)
479
-
480
- MIT
481
-
482
497
  ===
483
498
 
484
499
  # dom-serializer@2.0.0 (MIT)
@@ -496,33 +511,6 @@ The above copyright notice and this permission notice shall be included in all c
496
511
  THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
497
512
 
498
513
 
499
- ===
500
-
501
- # y-prosemirror@1.2.15 (MIT)
502
-
503
- The MIT License (MIT)
504
-
505
- Copyright (c) 2019 Kevin Jahns <kevin.jahns@protonmail.com>.
506
-
507
- Permission is hereby granted, free of charge, to any person obtaining a copy
508
- of this software and associated documentation files (the "Software"), to deal
509
- in the Software without restriction, including without limitation the rights
510
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
511
- copies of the Software, and to permit persons to whom the Software is
512
- furnished to do so, subject to the following conditions:
513
-
514
- The above copyright notice and this permission notice shall be included in all
515
- copies or substantial portions of the Software.
516
-
517
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
518
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
519
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
520
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
521
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
522
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
523
- SOFTWARE.
524
-
525
-
526
514
  ===
527
515
 
528
516
  # @babel/runtime@7.25.4 (MIT)
@@ -551,6 +539,45 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
551
539
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
552
540
 
553
541
 
542
+ ===
543
+
544
+ # @headless-tree/core@0.0.15 (MIT)
545
+
546
+ MIT
547
+
548
+ ===
549
+
550
+ # @headless-tree/react@0.0.15 (MIT)
551
+
552
+ MIT
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
+
554
581
  ===
555
582
 
556
583
  # @react-aria/focus@3.19.1 (Apache-2.0)
@@ -1,57 +1,10 @@
1
+ import {
2
+ parse
3
+ } from "../../chunks/chunk-5LTN67OE.js";
1
4
  import "../../chunks/chunk-NZLE2WMY.js";
2
5
 
3
6
  // src/adapter/core/preview.tsx
4
7
  import { getPreviewPayloadFromCookies } from "alinea/preview/PreviewCookies";
5
-
6
- // node_modules/cookie-es/dist/index.mjs
7
- function parse(str, options) {
8
- if (typeof str !== "string") {
9
- throw new TypeError("argument str must be a string");
10
- }
11
- const obj = {};
12
- const opt = options || {};
13
- const dec = opt.decode || decode;
14
- let index = 0;
15
- while (index < str.length) {
16
- const eqIdx = str.indexOf("=", index);
17
- if (eqIdx === -1) {
18
- break;
19
- }
20
- let endIdx = str.indexOf(";", index);
21
- if (endIdx === -1) {
22
- endIdx = str.length;
23
- } else if (endIdx < eqIdx) {
24
- index = str.lastIndexOf(";", eqIdx - 1) + 1;
25
- continue;
26
- }
27
- const key = str.slice(index, eqIdx).trim();
28
- if (opt?.filter && !opt?.filter(key)) {
29
- index = endIdx + 1;
30
- continue;
31
- }
32
- if (void 0 === obj[key]) {
33
- let val = str.slice(eqIdx + 1, endIdx).trim();
34
- if (val.codePointAt(0) === 34) {
35
- val = val.slice(1, -1);
36
- }
37
- obj[key] = tryDecode(val, dec);
38
- }
39
- index = endIdx + 1;
40
- }
41
- return obj;
42
- }
43
- function decode(str) {
44
- return str.includes("%") ? decodeURIComponent(str) : str;
45
- }
46
- function tryDecode(str, decode2) {
47
- try {
48
- return decode2(str);
49
- } catch {
50
- return str;
51
- }
52
- }
53
-
54
- // src/adapter/core/preview.tsx
55
8
  import { previewStore } from "./previewContext.js";
56
9
  async function preview(cms, request, run) {
57
10
  const { AsyncLocalStorage } = await import("node:async_hooks");
@@ -1,9 +1,9 @@
1
1
  import { CMS } from 'alinea/core/CMS';
2
2
  import type { Config } from 'alinea/core/Config';
3
3
  import type { UploadResponse } from 'alinea/core/Connection';
4
+ import type { Mutation } from 'alinea/core/db/Mutation';
4
5
  import type { GraphQuery } from 'alinea/core/Graph';
5
6
  import type { User } from 'alinea/core/User';
6
- import type { Mutation } from 'alinea/core/db/Mutation';
7
7
  export interface PreviewProps {
8
8
  widget?: boolean;
9
9
  workspace?: string;
@@ -2,9 +2,8 @@ import "../../chunks/chunk-NZLE2WMY.js";
2
2
 
3
3
  // src/adapter/next/cms.tsx
4
4
  import { Headers } from "@alinea/iso";
5
- import { COOKIE_NAME } from "alinea/cloud/CloudRemote";
6
- import { CMS } from "alinea/core/CMS";
7
5
  import { Client } from "alinea/core/Client";
6
+ import { CMS } from "alinea/core/CMS";
8
7
  import { outcome } from "alinea/core/Outcome";
9
8
  import { getPreviewPayloadFromCookies } from "alinea/preview/PreviewCookies";
10
9
  import { requestContext } from "./context.js";
@@ -38,12 +37,15 @@ var NextCMS = class extends CMS {
38
37
  }
39
38
  async #authenticatedClient() {
40
39
  const { handlerUrl, apiKey } = await requestContext(this.config);
41
- let authCookie;
40
+ const authCookies = [];
42
41
  try {
43
42
  const { cookies } = await import("next/headers");
44
43
  const cookie = await cookies();
45
- const tokenCookie = cookie.get(COOKIE_NAME);
46
- if (tokenCookie) authCookie = tokenCookie.value;
44
+ for (const { name, value } of cookie.getAll()) {
45
+ if (name.startsWith("alinea.")) {
46
+ authCookies.push([name, value]);
47
+ }
48
+ }
47
49
  } catch {
48
50
  }
49
51
  return new Client({
@@ -51,8 +53,12 @@ var NextCMS = class extends CMS {
51
53
  url: handlerUrl.href,
52
54
  applyAuth: (init) => {
53
55
  const headers = new Headers(init?.headers);
54
- if (authCookie) headers.set("Cookie", `${COOKIE_NAME}=${authCookie}`);
55
- else headers.set("Authorization", `Bearer ${apiKey}`);
56
+ headers.set("Authorization", `Bearer ${apiKey}`);
57
+ if (authCookies.length) {
58
+ for (const [name, value] of authCookies) {
59
+ headers.append("Cookie", `${name}=${value}`);
60
+ }
61
+ }
56
62
  return { ...init, headers };
57
63
  }
58
64
  });
@@ -1,5 +1,5 @@
1
- import { type HandlerHooks } from 'alinea/backend/Handler';
2
1
  import { type BackendOptions } from 'alinea/backend/api/CreateBackend';
2
+ import { type HandlerHooks } from 'alinea/backend/Handler';
3
3
  import type { RemoteConnection, RequestContext } from 'alinea/core/Connection';
4
4
  import { NextCMS } from './cms.js';
5
5
  type Handler = (request: Request) => Promise<Response>;
@@ -4,12 +4,12 @@ import {
4
4
  import "../../chunks/chunk-NZLE2WMY.js";
5
5
 
6
6
  // src/adapter/next/handler.ts
7
- import {
8
- createHandler as createCoreHandler
9
- } from "alinea/backend/Handler";
10
7
  import {
11
8
  createBackend
12
9
  } from "alinea/backend/api/CreateBackend";
10
+ import {
11
+ createHandler as createCoreHandler
12
+ } from "alinea/backend/Handler";
13
13
  import { generatedSource } from "alinea/backend/store/GeneratedSource";
14
14
  import { JWTPreviews } from "alinea/backend/util/JWTPreviews";
15
15
  import { CloudRemote } from "alinea/cloud/CloudRemote";
@@ -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.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));
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 () => {
@@ -52,7 +52,7 @@ function createHandler(input) {
52
52
  headers: { location: String(location) }
53
53
  });
54
54
  }
55
- return handleBackend(request, context);
55
+ return await handleBackend(request, context);
56
56
  } catch (error) {
57
57
  console.error(error);
58
58
  return new Response("Internal server error", { status: 500 });
@@ -1,6 +1,17 @@
1
+ import { HttpError } from 'alinea/core/HttpError';
1
2
  export declare enum AuthAction {
2
3
  Status = "status",
3
4
  Handshake = "handshake",
4
5
  Login = "login",
5
6
  Logout = "logout"
6
7
  }
8
+ export declare class AuthError extends HttpError {
9
+ name: string;
10
+ constructor(message: string, options?: ErrorOptions);
11
+ }
12
+ export declare class MissingCredentialsError extends AuthError {
13
+ name: string;
14
+ }
15
+ export declare class InvalidCredentialsError extends AuthError {
16
+ name: string;
17
+ }
@@ -1,6 +1,7 @@
1
1
  import "../chunks/chunk-NZLE2WMY.js";
2
2
 
3
3
  // src/backend/Auth.ts
4
+ import { HttpError } from "alinea/core/HttpError";
4
5
  var AuthAction = /* @__PURE__ */ ((AuthAction2) => {
5
6
  AuthAction2["Status"] = "status";
6
7
  AuthAction2["Handshake"] = "handshake";
@@ -8,6 +9,21 @@ var AuthAction = /* @__PURE__ */ ((AuthAction2) => {
8
9
  AuthAction2["Logout"] = "logout";
9
10
  return AuthAction2;
10
11
  })(AuthAction || {});
12
+ var AuthError = class extends HttpError {
13
+ name = "AuthError";
14
+ constructor(message, options) {
15
+ super(401, message, options);
16
+ }
17
+ };
18
+ var MissingCredentialsError = class extends AuthError {
19
+ name = "MissingCredentialsError";
20
+ };
21
+ var InvalidCredentialsError = class extends AuthError {
22
+ name = "InvalidCredentialsError";
23
+ };
11
24
  export {
12
- AuthAction
25
+ AuthAction,
26
+ AuthError,
27
+ InvalidCredentialsError,
28
+ MissingCredentialsError
13
29
  };