alinea 1.4.9 → 1.5.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.
- package/dist/.init/content/pages/welcome.json +1 -1
- package/dist/LICENSES.md +99 -72
- package/dist/adapter/core/preview.js +3 -50
- package/dist/adapter/next/cms.js +12 -6
- package/dist/adapter/next/handler.d.ts +1 -1
- package/dist/adapter/next/handler.js +5 -5
- package/dist/backend/Auth.d.ts +13 -1
- package/dist/backend/Auth.js +18 -1
- package/dist/backend/HandleAction.d.ts +1 -0
- package/dist/backend/HandleAction.js +1 -0
- package/dist/backend/Handler.js +25 -19
- package/dist/backend/api/BasicAuth.d.ts +1 -2
- package/dist/backend/api/BasicAuth.js +10 -5
- package/dist/backend/api/CreateBackend.d.ts +5 -2
- package/dist/backend/api/CreateBackend.js +7 -2
- package/dist/backend/api/OAuth2.d.ts +45 -0
- package/dist/backend/api/OAuth2.js +659 -0
- package/dist/backend/router/Router.d.ts +1 -1
- package/dist/backend/router/Router.js +1 -1
- package/dist/bundled.d.ts +146 -31
- package/dist/chunks/chunk-5LTN67OE.js +51 -0
- package/dist/chunks/{chunk-NEFR4CFI.js → chunk-ABIK64FW.js} +1 -1
- package/dist/cli/Serve.js +1 -1
- package/dist/cli/bin.js +1 -1
- package/dist/cli/generate/DevDB.js +3 -3
- package/dist/cloud/AuthResult.d.ts +4 -1
- package/dist/cloud/AuthResult.js +1 -0
- package/dist/cloud/CloudConfig.d.ts +3 -1
- package/dist/cloud/CloudConfig.js +5 -2
- package/dist/cloud/CloudRemote.d.ts +2 -10
- package/dist/cloud/CloudRemote.js +20 -109
- package/dist/cloud/view/CloudAuth.browser.js +14 -11
- package/dist/core/Client.d.ts +6 -5
- package/dist/core/Client.js +26 -18
- package/dist/core/Connection.d.ts +4 -3
- package/dist/core/HttpError.d.ts +1 -0
- package/dist/core/HttpError.js +1 -0
- package/dist/core/Outcome.js +1 -0
- package/dist/core/db/EntryIndex.d.ts +2 -0
- package/dist/core/db/EntryIndex.js +16 -7
- package/dist/core/db/EntryResolver.js +2 -1
- package/dist/core/db/EntryTransaction.js +29 -6
- package/dist/core/db/Mutation.d.ts +2 -2
- package/dist/core/db/Operation.d.ts +1 -1
- package/dist/core/db/Operation.js +5 -14
- package/dist/core/source/CombinedSource.js +2 -1
- package/dist/core/source/FSSource.js +1 -1
- package/dist/core/source/GitUtils.js +1 -1
- package/dist/core/source/GithubSource.js +1 -1
- package/dist/core/source/MemorySource.js +1 -1
- package/dist/core/source/Tree.js +2 -1
- package/dist/core/source/Utils.d.ts +0 -1
- package/dist/core/source/Utils.js +0 -7
- package/dist/core/util/Assert.d.ts +1 -0
- package/dist/core/util/Assert.js +12 -0
- package/dist/core/util/JWT.d.ts +43 -0
- package/dist/core/util/JWT.js +1 -0
- package/dist/dashboard/atoms/EntrySummaryAtoms.js +3 -3
- package/dist/dashboard/boot/BootDev.js +133 -1
- package/dist/dashboard/view/EntryTree.js +9 -3
- package/package.json +1 -1
package/dist/LICENSES.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
This file contains the licenses of the bundled modules in this distribution.
|
|
2
2
|
|
|
3
|
+
===
|
|
4
|
+
|
|
5
|
+
# react-query@3.39.3 (MIT)
|
|
6
|
+
|
|
7
|
+
MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2019 Tanner Linsley
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
|
|
3
30
|
===
|
|
4
31
|
|
|
5
32
|
# rado@1.0.15 (MIT)
|
|
@@ -28,6 +55,32 @@ SOFTWARE.
|
|
|
28
55
|
|
|
29
56
|
===
|
|
30
57
|
|
|
58
|
+
# @headlessui/react@2.2.0 (MIT)
|
|
59
|
+
|
|
60
|
+
MIT License
|
|
61
|
+
|
|
62
|
+
Copyright (c) 2020 Tailwind Labs
|
|
63
|
+
|
|
64
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
65
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
66
|
+
in the Software without restriction, including without limitation the rights
|
|
67
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
68
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
69
|
+
furnished to do so, subject to the following conditions:
|
|
70
|
+
|
|
71
|
+
The above copyright notice and this permission notice shall be included in all
|
|
72
|
+
copies or substantial portions of the Software.
|
|
73
|
+
|
|
74
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
75
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
76
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
77
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
78
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
79
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
80
|
+
SOFTWARE.
|
|
81
|
+
|
|
82
|
+
===
|
|
83
|
+
|
|
31
84
|
# lib0@0.2.88 (MIT)
|
|
32
85
|
|
|
33
86
|
The MIT License (MIT)
|
|
@@ -78,11 +131,11 @@ IN THE SOFTWARE.
|
|
|
78
131
|
|
|
79
132
|
===
|
|
80
133
|
|
|
81
|
-
#
|
|
134
|
+
# @badgateway/oauth2-client@3.2.0 (MIT)
|
|
82
135
|
|
|
83
136
|
MIT License
|
|
84
137
|
|
|
85
|
-
Copyright (c) 2019
|
|
138
|
+
Copyright (c) 2019-2023 Evert Pot
|
|
86
139
|
|
|
87
140
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
88
141
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -105,50 +158,33 @@ SOFTWARE.
|
|
|
105
158
|
|
|
106
159
|
===
|
|
107
160
|
|
|
108
|
-
#
|
|
109
|
-
|
|
110
|
-
Copyright (c) Felix Böhm
|
|
111
|
-
All rights reserved.
|
|
112
|
-
|
|
113
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
114
|
-
|
|
115
|
-
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
116
|
-
|
|
117
|
-
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.
|
|
118
|
-
|
|
119
|
-
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,
|
|
120
|
-
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
===
|
|
124
|
-
|
|
125
|
-
# @headlessui/react@2.2.0 (MIT)
|
|
161
|
+
# @popperjs/core@2.11.8 (MIT)
|
|
126
162
|
|
|
127
|
-
MIT License
|
|
163
|
+
The MIT License (MIT)
|
|
128
164
|
|
|
129
|
-
Copyright (c)
|
|
165
|
+
Copyright (c) 2019 Federico Zivolo
|
|
130
166
|
|
|
131
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
167
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
168
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
169
|
+
the Software without restriction, including without limitation the rights to
|
|
170
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
171
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
172
|
+
subject to the following conditions:
|
|
137
173
|
|
|
138
174
|
The above copyright notice and this permission notice shall be included in all
|
|
139
175
|
copies or substantial portions of the Software.
|
|
140
176
|
|
|
141
177
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
142
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
178
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
179
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
180
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
181
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
182
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
183
|
+
|
|
148
184
|
|
|
149
185
|
===
|
|
150
186
|
|
|
151
|
-
#
|
|
187
|
+
# domutils@3.1.0 (BSD-2-Clause)
|
|
152
188
|
|
|
153
189
|
Copyright (c) Felix Böhm
|
|
154
190
|
All rights reserved.
|
|
@@ -165,7 +201,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
165
201
|
|
|
166
202
|
===
|
|
167
203
|
|
|
168
|
-
#
|
|
204
|
+
# domhandler@5.0.3 (BSD-2-Clause)
|
|
169
205
|
|
|
170
206
|
Copyright (c) Felix Böhm
|
|
171
207
|
All rights reserved.
|
|
@@ -182,28 +218,19 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
182
218
|
|
|
183
219
|
===
|
|
184
220
|
|
|
185
|
-
# @
|
|
221
|
+
# entities@4.5.0 (BSD-2-Clause)
|
|
186
222
|
|
|
187
|
-
|
|
223
|
+
Copyright (c) Felix Böhm
|
|
224
|
+
All rights reserved.
|
|
188
225
|
|
|
189
|
-
|
|
226
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
190
227
|
|
|
191
|
-
|
|
192
|
-
this software and associated documentation files (the "Software"), to deal in
|
|
193
|
-
the Software without restriction, including without limitation the rights to
|
|
194
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
195
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
196
|
-
subject to the following conditions:
|
|
228
|
+
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
197
229
|
|
|
198
|
-
|
|
199
|
-
copies or substantial portions of the Software.
|
|
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.
|
|
200
231
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
204
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
205
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
206
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
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.
|
|
207
234
|
|
|
208
235
|
|
|
209
236
|
===
|
|
@@ -440,23 +467,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
440
467
|
SOFTWARE.
|
|
441
468
|
|
|
442
469
|
|
|
443
|
-
===
|
|
444
|
-
|
|
445
|
-
# dom-serializer@2.0.0 (MIT)
|
|
446
|
-
|
|
447
|
-
License
|
|
448
|
-
|
|
449
|
-
(The MIT License)
|
|
450
|
-
|
|
451
|
-
Copyright (c) 2014 The cheeriojs contributors
|
|
452
|
-
|
|
453
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
454
|
-
|
|
455
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
456
|
-
|
|
457
|
-
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.
|
|
458
|
-
|
|
459
|
-
|
|
460
470
|
===
|
|
461
471
|
|
|
462
472
|
# react-is@16.13.1 (MIT)
|
|
@@ -486,9 +496,20 @@ SOFTWARE.
|
|
|
486
496
|
|
|
487
497
|
===
|
|
488
498
|
|
|
489
|
-
#
|
|
499
|
+
# dom-serializer@2.0.0 (MIT)
|
|
500
|
+
|
|
501
|
+
License
|
|
502
|
+
|
|
503
|
+
(The MIT License)
|
|
504
|
+
|
|
505
|
+
Copyright (c) 2014 The cheeriojs contributors
|
|
506
|
+
|
|
507
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
508
|
+
|
|
509
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
510
|
+
|
|
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.
|
|
490
512
|
|
|
491
|
-
MIT
|
|
492
513
|
|
|
493
514
|
===
|
|
494
515
|
|
|
@@ -498,6 +519,12 @@ MIT
|
|
|
498
519
|
|
|
499
520
|
===
|
|
500
521
|
|
|
522
|
+
# @headless-tree/react@0.0.15 (MIT)
|
|
523
|
+
|
|
524
|
+
MIT
|
|
525
|
+
|
|
526
|
+
===
|
|
527
|
+
|
|
501
528
|
# y-prosemirror@1.2.15 (MIT)
|
|
502
529
|
|
|
503
530
|
The MIT License (MIT)
|
|
@@ -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");
|
package/dist/adapter/next/cms.js
CHANGED
|
@@ -2,7 +2,6 @@ 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
5
|
import { Client } from "alinea/core/Client";
|
|
7
6
|
import { CMS } from "alinea/core/CMS";
|
|
8
7
|
import { outcome } from "alinea/core/Outcome";
|
|
@@ -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
|
-
|
|
40
|
+
const authCookies = [];
|
|
42
41
|
try {
|
|
43
42
|
const { cookies } = await import("next/headers");
|
|
44
43
|
const cookie = await cookies();
|
|
45
|
-
const
|
|
46
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
+
headers.set("Authorization", `Bearer ${apiKey}`);
|
|
57
|
+
if (authCookies.length) {
|
|
58
|
+
for (const [name, value] of authCookies) {
|
|
59
|
+
headers.set("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 });
|
package/dist/backend/Auth.d.ts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
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
|
-
Logout = "logout"
|
|
6
|
+
Logout = "logout",
|
|
7
|
+
Refresh = "refresh"
|
|
8
|
+
}
|
|
9
|
+
export declare class AuthError extends HttpError {
|
|
10
|
+
name: string;
|
|
11
|
+
constructor(message: string, options?: ErrorOptions);
|
|
12
|
+
}
|
|
13
|
+
export declare class MissingCredentialsError extends AuthError {
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
export declare class InvalidCredentialsError extends AuthError {
|
|
17
|
+
name: string;
|
|
6
18
|
}
|
package/dist/backend/Auth.js
CHANGED
|
@@ -1,13 +1,30 @@
|
|
|
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";
|
|
7
8
|
AuthAction2["Login"] = "login";
|
|
8
9
|
AuthAction2["Logout"] = "logout";
|
|
10
|
+
AuthAction2["Refresh"] = "refresh";
|
|
9
11
|
return AuthAction2;
|
|
10
12
|
})(AuthAction || {});
|
|
13
|
+
var AuthError = class extends HttpError {
|
|
14
|
+
name = "AuthError";
|
|
15
|
+
constructor(message, options) {
|
|
16
|
+
super(401, message, options);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var MissingCredentialsError = class extends AuthError {
|
|
20
|
+
name = "MissingCredentialsError";
|
|
21
|
+
};
|
|
22
|
+
var InvalidCredentialsError = class extends AuthError {
|
|
23
|
+
name = "InvalidCredentialsError";
|
|
24
|
+
};
|
|
11
25
|
export {
|
|
12
|
-
AuthAction
|
|
26
|
+
AuthAction,
|
|
27
|
+
AuthError,
|
|
28
|
+
InvalidCredentialsError,
|
|
29
|
+
MissingCredentialsError
|
|
13
30
|
};
|
|
@@ -2,6 +2,7 @@ import "../chunks/chunk-NZLE2WMY.js";
|
|
|
2
2
|
|
|
3
3
|
// src/backend/HandleAction.ts
|
|
4
4
|
var HandleAction = /* @__PURE__ */ ((HandleAction2) => {
|
|
5
|
+
HandleAction2["Auth"] = "auth";
|
|
5
6
|
HandleAction2["User"] = "user";
|
|
6
7
|
HandleAction2["Resolve"] = "resolve";
|
|
7
8
|
HandleAction2["Pending"] = "pending";
|
package/dist/backend/Handler.js
CHANGED
|
@@ -18,6 +18,7 @@ import { HttpError } from "alinea/core/HttpError";
|
|
|
18
18
|
import { getScope } from "alinea/core/Scope";
|
|
19
19
|
import { ShaMismatchError } from "alinea/core/source/ShaMismatchError";
|
|
20
20
|
import { base64 } from "alinea/core/util/Encoding";
|
|
21
|
+
import { InvalidCredentialsError, MissingCredentialsError } from "./Auth.js";
|
|
21
22
|
import { HandleAction } from "./HandleAction.js";
|
|
22
23
|
import { createPreviewParser } from "./resolver/ParsePreview.js";
|
|
23
24
|
var limit = pLimit(1);
|
|
@@ -62,30 +63,32 @@ function createHandler({
|
|
|
62
63
|
const auth = params.get("auth");
|
|
63
64
|
let cnx = remote(context);
|
|
64
65
|
let userCtx;
|
|
65
|
-
const action = params.get("action");
|
|
66
66
|
if (auth) return cnx.authenticate(request);
|
|
67
|
+
const action = params.get("action");
|
|
67
68
|
const expectJson = () => {
|
|
68
69
|
const acceptsJson = request.headers.get("accept")?.includes("application/json");
|
|
69
70
|
if (!acceptsJson) throw new Response("Expected JSON", { status: 400 });
|
|
70
71
|
};
|
|
71
|
-
if (action === HandleAction.User && request.method === "GET") {
|
|
72
|
-
expectJson();
|
|
73
|
-
try {
|
|
74
|
-
const { user } = await cnx.verify(request);
|
|
75
|
-
return Response.json(user);
|
|
76
|
-
} catch {
|
|
77
|
-
return Response.json(null);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
72
|
try {
|
|
81
73
|
userCtx = await cnx.verify(request);
|
|
82
74
|
cnx = remote(userCtx);
|
|
83
|
-
} catch {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
} catch (cause) {
|
|
76
|
+
if (cause instanceof MissingCredentialsError) {
|
|
77
|
+
const authorization = request.headers.get("authorization");
|
|
78
|
+
const bearer = authorization?.slice("Bearer ".length);
|
|
79
|
+
if (!context.apiKey)
|
|
80
|
+
throw new MissingCredentialsError("Missing API key", { cause });
|
|
81
|
+
if (bearer !== context.apiKey)
|
|
82
|
+
throw new InvalidCredentialsError("Expected matching api key", {
|
|
83
|
+
cause
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
throw cause;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (action === HandleAction.User && request.method === "GET") {
|
|
90
|
+
expectJson();
|
|
91
|
+
return Response.json(userCtx ? userCtx.user : null);
|
|
89
92
|
}
|
|
90
93
|
const expectUser = () => {
|
|
91
94
|
if (!userCtx) throw new Response("Unauthorized", { status: 401 });
|
|
@@ -198,7 +201,7 @@ function createHandler({
|
|
|
198
201
|
return new Response("OK", { status: 200 });
|
|
199
202
|
}
|
|
200
203
|
if (!cnx.previewUpload) throw new Response("Bad Request", { status: 400 });
|
|
201
|
-
return cnx.previewUpload(entryId);
|
|
204
|
+
return await cnx.previewUpload(entryId);
|
|
202
205
|
}
|
|
203
206
|
if (action === HandleAction.Draft && request.method === "GET") {
|
|
204
207
|
expectJson();
|
|
@@ -215,15 +218,18 @@ function createHandler({
|
|
|
215
218
|
const draft = { ...data, draft: base64.parse(data.draft) };
|
|
216
219
|
return Response.json(await cnx.storeDraft(draft));
|
|
217
220
|
}
|
|
221
|
+
return new Response("Bad Request", { status: 400 });
|
|
218
222
|
} catch (error) {
|
|
219
223
|
if (error instanceof Response) return error;
|
|
220
224
|
console.error(error);
|
|
221
225
|
return Response.json(
|
|
222
|
-
{
|
|
226
|
+
{
|
|
227
|
+
success: false,
|
|
228
|
+
error: error instanceof Error ? error.message : String(error)
|
|
229
|
+
},
|
|
223
230
|
{ status: error instanceof HttpError ? error.code : 500 }
|
|
224
231
|
);
|
|
225
232
|
}
|
|
226
|
-
return new Response("Bad Request", { status: 400 });
|
|
227
233
|
};
|
|
228
234
|
}
|
|
229
235
|
export {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { AuthApi, AuthedContext } from 'alinea/core/Connection';
|
|
2
|
-
import type { RequestContext } from 'alinea/core/Connection';
|
|
1
|
+
import type { AuthApi, AuthedContext, RequestContext } from 'alinea/core/Connection';
|
|
3
2
|
export interface Verifier {
|
|
4
3
|
(username: string, password: string): boolean | Promise<boolean>;
|
|
5
4
|
}
|
|
@@ -3,13 +3,17 @@ import "../../chunks/chunk-NZLE2WMY.js";
|
|
|
3
3
|
// src/backend/api/BasicAuth.ts
|
|
4
4
|
import { AuthResultType } from "alinea/cloud/AuthResult";
|
|
5
5
|
import { atob } from "alinea/core/util/Encoding";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
AuthAction,
|
|
8
|
+
InvalidCredentialsError,
|
|
9
|
+
MissingCredentialsError
|
|
10
|
+
} from "../Auth.js";
|
|
7
11
|
var BasicAuth = class {
|
|
8
12
|
#context;
|
|
9
13
|
#verify;
|
|
10
14
|
constructor(context, verify) {
|
|
11
|
-
this.#verify = verify;
|
|
12
15
|
this.#context = context;
|
|
16
|
+
this.#verify = verify;
|
|
13
17
|
}
|
|
14
18
|
async authenticate(request) {
|
|
15
19
|
try {
|
|
@@ -33,12 +37,13 @@ var BasicAuth = class {
|
|
|
33
37
|
async verify(request) {
|
|
34
38
|
const ctx = this.#context;
|
|
35
39
|
const auth = request.headers.get("Authorization");
|
|
36
|
-
if (!auth) throw
|
|
40
|
+
if (!auth) throw new MissingCredentialsError("Missing authorization header");
|
|
37
41
|
const [scheme, token] = auth.split(" ", 2);
|
|
38
|
-
if (scheme !== "Basic")
|
|
42
|
+
if (scheme !== "Basic")
|
|
43
|
+
throw new MissingCredentialsError("Invalid authorization scheme");
|
|
39
44
|
const [username, password] = atob(token).split(":");
|
|
40
45
|
const authorized = await this.#verify(username, password);
|
|
41
|
-
if (!authorized) throw
|
|
46
|
+
if (!authorized) throw new InvalidCredentialsError("Invalid credentials");
|
|
42
47
|
return {
|
|
43
48
|
...ctx,
|
|
44
49
|
user: { sub: username },
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { Config } from 'alinea/core/Config';
|
|
1
2
|
import type { RemoteConnection, RequestContext } from 'alinea/core/Connection';
|
|
2
3
|
import * as driver from 'rado/driver';
|
|
3
4
|
import { type GithubOptions } from './GithubApi.js';
|
|
5
|
+
import { type OAuth2Options } from './OAuth2.js';
|
|
4
6
|
export type AvailableDrivers = 'd1' | 'mysql2' | '@neondatabase/serverless' | '@vercel/postgres' | 'pg' | '@electric-sql/pglite' | 'sql.js' | '@libsql/client';
|
|
5
7
|
type DatabaseClient<Driver extends AvailableDrivers> = Parameters<(typeof driver)[Driver]>[0];
|
|
6
8
|
type DatabaseOption<Driver extends AvailableDrivers> = {
|
|
@@ -9,10 +11,11 @@ type DatabaseOption<Driver extends AvailableDrivers> = {
|
|
|
9
11
|
};
|
|
10
12
|
export type DatabaseDeclaration = DatabaseOption<'d1'> | DatabaseOption<'mysql2'> | DatabaseOption<'@neondatabase/serverless'> | DatabaseOption<'@vercel/postgres'> | DatabaseOption<'pg'> | DatabaseOption<'@electric-sql/pglite'> | DatabaseOption<'sql.js'> | DatabaseOption<'@libsql/client'>;
|
|
11
13
|
export interface BackendOptions {
|
|
12
|
-
auth(username: string, password: string): boolean | Promise<boolean>;
|
|
14
|
+
auth?(username: string, password: string): boolean | Promise<boolean>;
|
|
15
|
+
oauth2?: OAuth2Options;
|
|
13
16
|
database: DatabaseDeclaration;
|
|
14
17
|
github: GithubOptions;
|
|
15
18
|
}
|
|
16
|
-
export declare function createBackend(options: BackendOptions): (context: RequestContext) => RemoteConnection;
|
|
19
|
+
export declare function createBackend(config: Config, options: BackendOptions): (context: RequestContext) => RemoteConnection;
|
|
17
20
|
export declare function createRemote(...impl: Array<Partial<RemoteConnection>>): RemoteConnection;
|
|
18
21
|
export {};
|
|
@@ -48,6 +48,9 @@ import {
|
|
|
48
48
|
__export
|
|
49
49
|
} from "../../chunks/chunk-NZLE2WMY.js";
|
|
50
50
|
|
|
51
|
+
// src/backend/api/CreateBackend.ts
|
|
52
|
+
import { assert } from "alinea/core/util/Assert";
|
|
53
|
+
|
|
51
54
|
// node_modules/rado/dist/driver.js
|
|
52
55
|
var driver_exports = {};
|
|
53
56
|
__export(driver_exports, {
|
|
@@ -2492,7 +2495,8 @@ function connect8(db) {
|
|
|
2492
2495
|
import { BasicAuth } from "./BasicAuth.js";
|
|
2493
2496
|
import { DatabaseApi } from "./DatabaseApi.js";
|
|
2494
2497
|
import { GithubApi } from "./GithubApi.js";
|
|
2495
|
-
|
|
2498
|
+
import { OAuth2 } from "./OAuth2.js";
|
|
2499
|
+
function createBackend(config, options) {
|
|
2496
2500
|
const db = driver_exports[options.database.driver](options.database.client);
|
|
2497
2501
|
return (context) => {
|
|
2498
2502
|
const { user } = context;
|
|
@@ -2502,7 +2506,8 @@ function createBackend(options) {
|
|
|
2502
2506
|
...options.github
|
|
2503
2507
|
});
|
|
2504
2508
|
const dbApi = new DatabaseApi(context, { db });
|
|
2505
|
-
|
|
2509
|
+
assert(options.oauth2 ?? options.auth, "No auth method provided");
|
|
2510
|
+
const auth = options.oauth2 ? new OAuth2(context, config, options.oauth2) : new BasicAuth(context, options.auth);
|
|
2506
2511
|
return createRemote(ghApi, dbApi, auth);
|
|
2507
2512
|
};
|
|
2508
2513
|
}
|