@ldo/test-solid-server 1.0.0-alpha.27 → 1.0.0-alpha.34
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/_virtual/rolldown_runtime.cjs +30 -0
- package/dist/authFetch.cjs +80 -0
- package/dist/authFetch.js +80 -0
- package/dist/authFetch.js.map +1 -0
- package/dist/createServer.cjs +32 -0
- package/dist/createServer.d.cts +9 -0
- package/dist/createServer.d.cts.map +1 -0
- package/dist/createServer.d.ts +9 -0
- package/dist/createServer.d.ts.map +1 -0
- package/dist/createServer.js +32 -0
- package/dist/createServer.js.map +1 -0
- package/dist/index.cjs +8 -0
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/resourceUtils.cjs +29 -0
- package/dist/resourceUtils.d.cts +20 -0
- package/dist/resourceUtils.d.cts.map +1 -0
- package/dist/resourceUtils.d.ts +20 -0
- package/dist/resourceUtils.d.ts.map +1 -0
- package/dist/resourceUtils.js +28 -0
- package/dist/resourceUtils.js.map +1 -0
- package/dist/setupTestServer.cjs +56 -0
- package/dist/setupTestServer.d.cts +16 -0
- package/dist/setupTestServer.d.cts.map +1 -0
- package/dist/setupTestServer.d.ts +16 -0
- package/dist/setupTestServer.d.ts.map +1 -0
- package/dist/setupTestServer.js +56 -0
- package/dist/setupTestServer.js.map +1 -0
- package/package.json +14 -11
- package/src/index.ts +3 -3
- package/src/setupTestServer.ts +4 -4
- package/dist/cjs/authFetch.js +0 -106
- package/dist/cjs/authFetch.js.map +0 -1
- package/dist/cjs/configs/server-config-without-websocket.json +0 -44
- package/dist/cjs/configs/server-config.json +0 -43
- package/dist/cjs/configs/solid-css-seed.json +0 -9
- package/dist/cjs/createServer.js +0 -68
- package/dist/cjs/createServer.js.map +0 -1
- package/dist/cjs/index.js +0 -20
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/resourceUtils.js +0 -41
- package/dist/cjs/resourceUtils.js.map +0 -1
- package/dist/cjs/setupTestServer.js +0 -66
- package/dist/cjs/setupTestServer.js.map +0 -1
- package/dist/esm/authFetch.js +0 -100
- package/dist/esm/authFetch.js.map +0 -1
- package/dist/esm/configs/server-config-without-websocket.json +0 -44
- package/dist/esm/configs/server-config.json +0 -43
- package/dist/esm/configs/solid-css-seed.json +0 -9
- package/dist/esm/createServer.js +0 -32
- package/dist/esm/createServer.js.map +0 -1
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/resourceUtils.js +0 -37
- package/dist/esm/resourceUtils.js.map +0 -1
- package/dist/esm/setupTestServer.js +0 -60
- package/dist/esm/setupTestServer.js.map +0 -1
- package/dist/types/authFetch.d.ts +0 -2
- package/dist/types/authFetch.d.ts.map +0 -1
- package/dist/types/createServer.d.ts +0 -3
- package/dist/types/createServer.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/resourceUtils.d.ts +0 -18
- package/dist/types/resourceUtils.d.ts.map +0 -1
- package/dist/types/setupTestServer.d.ts +0 -10
- package/dist/types/setupTestServer.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldo/test-solid-server",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.34",
|
|
4
4
|
"description": "A solid server to be used in jest tests",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/
|
|
7
|
-
"module": "./dist/
|
|
8
|
-
"types": "./dist/
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
"import": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"require": {
|
|
16
|
+
"types": "./dist/index.d.cts",
|
|
17
|
+
"default": "./dist/index.cjs"
|
|
18
|
+
}
|
|
14
19
|
},
|
|
15
20
|
"./package.json": "./package.json"
|
|
16
21
|
},
|
|
17
22
|
"scripts": {
|
|
18
|
-
"build": "rimraf dist &&
|
|
19
|
-
"build:cjs": "tsc --project tsconfig.cjs.json",
|
|
20
|
-
"build:esm": "tsc --project tsconfig.esm.json",
|
|
23
|
+
"build": "rimraf dist && NODE_OPTIONS=--max-old-space-size=8192 tsdown",
|
|
21
24
|
"prepublishOnly": "npm run build",
|
|
22
25
|
"copy-configs": "cp -r src/configs dist/cjs/configs && cp -r src/configs dist/esm/configs",
|
|
23
26
|
"lint": "eslint src/** --fix --no-error-on-unmatched-pattern",
|
|
@@ -45,5 +48,5 @@
|
|
|
45
48
|
"publishConfig": {
|
|
46
49
|
"access": "public"
|
|
47
50
|
},
|
|
48
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "ac9581d27e78e3e813620d0651390ad01d5a387a"
|
|
49
52
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from "./createServer
|
|
2
|
-
export * from "./setupTestServer
|
|
3
|
-
export * from "./resourceUtils
|
|
1
|
+
export * from "./createServer";
|
|
2
|
+
export * from "./setupTestServer";
|
|
3
|
+
export * from "./resourceUtils";
|
package/src/setupTestServer.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import type { App } from "@solid/community-server";
|
|
3
|
-
import { createApp } from "./createServer
|
|
3
|
+
import { createApp } from "./createServer";
|
|
4
4
|
import path from "path";
|
|
5
|
-
import type { ResourceInfo } from "./resourceUtils
|
|
6
|
-
import { cleanResources, initResources } from "./resourceUtils
|
|
7
|
-
import { generateAuthFetch } from "./authFetch
|
|
5
|
+
import type { ResourceInfo } from "./resourceUtils";
|
|
6
|
+
import { cleanResources, initResources } from "./resourceUtils";
|
|
7
|
+
import { generateAuthFetch } from "./authFetch";
|
|
8
8
|
import fs from "fs/promises";
|
|
9
9
|
import {
|
|
10
10
|
beforeAll,
|
package/dist/cjs/authFetch.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateAuthFetch = generateAuthFetch;
|
|
7
|
-
const solid_client_authn_core_1 = require("@inrupt/solid-client-authn-core");
|
|
8
|
-
const cross_fetch_1 = __importDefault(require("cross-fetch"));
|
|
9
|
-
const config = {
|
|
10
|
-
podName: "example",
|
|
11
|
-
email: "hello@example.com",
|
|
12
|
-
password: "abc123",
|
|
13
|
-
};
|
|
14
|
-
async function reportError(response) {
|
|
15
|
-
if (response.status >= 400) {
|
|
16
|
-
console.error(await response.text());
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
async function getAuthorization(port) {
|
|
20
|
-
// First we request the account API controls to find out where we can log in
|
|
21
|
-
const indexResponse = await (0, cross_fetch_1.default)(`http://localhost:${port}/.account/`);
|
|
22
|
-
const { controls } = await indexResponse.json();
|
|
23
|
-
// And then we log in to the account API
|
|
24
|
-
const response = await (0, cross_fetch_1.default)(controls.password.login, {
|
|
25
|
-
method: "POST",
|
|
26
|
-
headers: { "content-type": "application/json" },
|
|
27
|
-
body: JSON.stringify({
|
|
28
|
-
email: config.email,
|
|
29
|
-
password: config.password,
|
|
30
|
-
}),
|
|
31
|
-
});
|
|
32
|
-
// This authorization value will be used to authenticate in the next step
|
|
33
|
-
await reportError(response);
|
|
34
|
-
const result = await response.json();
|
|
35
|
-
return result.authorization;
|
|
36
|
-
}
|
|
37
|
-
async function getSecret(port, authorization) {
|
|
38
|
-
// Now that we are logged in, we need to request the updated controls from the server.
|
|
39
|
-
// These will now have more values than in the previous example.
|
|
40
|
-
const indexResponse = await (0, cross_fetch_1.default)(`http://localhost:${port}/.account/`, {
|
|
41
|
-
headers: { authorization: `CSS-Account-Token ${authorization}` },
|
|
42
|
-
});
|
|
43
|
-
const { controls } = await indexResponse.json();
|
|
44
|
-
// Here we request the server to generate a token on our account
|
|
45
|
-
const response = await (0, cross_fetch_1.default)(controls.account.clientCredentials, {
|
|
46
|
-
method: "POST",
|
|
47
|
-
headers: {
|
|
48
|
-
authorization: `CSS-Account-Token ${authorization}`,
|
|
49
|
-
"content-type": "application/json",
|
|
50
|
-
},
|
|
51
|
-
// The name field will be used when generating the ID of your token.
|
|
52
|
-
// The WebID field determines which WebID you will identify as when using the token.
|
|
53
|
-
// Only WebIDs linked to your account can be used.
|
|
54
|
-
body: JSON.stringify({
|
|
55
|
-
name: "my-token",
|
|
56
|
-
webId: `http://localhost:${port}/${config.podName}/profile/card#me`,
|
|
57
|
-
}),
|
|
58
|
-
});
|
|
59
|
-
await reportError(response);
|
|
60
|
-
// These are the identifier and secret of your token.
|
|
61
|
-
// Store the secret somewhere safe as there is no way to request it again from the server!
|
|
62
|
-
// The `resource` value can be used to delete the token at a later point in time.
|
|
63
|
-
const response2 = await response.json();
|
|
64
|
-
return response2;
|
|
65
|
-
}
|
|
66
|
-
async function getAccessToken(port, id, secret) {
|
|
67
|
-
try {
|
|
68
|
-
// A key pair is needed for encryption.
|
|
69
|
-
// This function from `solid-client-authn` generates such a pair for you.
|
|
70
|
-
const dpopKey = await (0, solid_client_authn_core_1.generateDpopKeyPair)();
|
|
71
|
-
// These are the ID and secret generated in the previous step.
|
|
72
|
-
// Both the ID and the secret need to be form-encoded.
|
|
73
|
-
const authString = `${encodeURIComponent(id)}:${encodeURIComponent(secret)}`;
|
|
74
|
-
// This URL can be found by looking at the "token_endpoint" field at
|
|
75
|
-
// http://localhost:PORT/.well-known/openid-configuration
|
|
76
|
-
// if your server is hosted at http://localhost:3000/.
|
|
77
|
-
const tokenUrl = `http://localhost:${port}/.oidc/token`;
|
|
78
|
-
const response = await (0, cross_fetch_1.default)(tokenUrl, {
|
|
79
|
-
method: "POST",
|
|
80
|
-
headers: {
|
|
81
|
-
// The header needs to be in base64 encoding.
|
|
82
|
-
authorization: `Basic ${Buffer.from(authString).toString("base64")}`,
|
|
83
|
-
"content-type": "application/x-www-form-urlencoded",
|
|
84
|
-
dpop: await (0, solid_client_authn_core_1.createDpopHeader)(tokenUrl, "POST", dpopKey),
|
|
85
|
-
},
|
|
86
|
-
body: "grant_type=client_credentials&scope=webid",
|
|
87
|
-
});
|
|
88
|
-
await reportError(response);
|
|
89
|
-
// This is the Access token that will be used to do an authenticated request to the server.
|
|
90
|
-
// The JSON also contains an "expires_in" field in seconds,
|
|
91
|
-
// which you can use to know when you need request a new Access token.
|
|
92
|
-
const response2 = await response.json();
|
|
93
|
-
return { accessToken: response2.access_token, dpopKey };
|
|
94
|
-
}
|
|
95
|
-
catch (err) {
|
|
96
|
-
console.error(err);
|
|
97
|
-
throw err;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
async function generateAuthFetch(port) {
|
|
101
|
-
const authorization = await getAuthorization(port);
|
|
102
|
-
const { id, secret } = await getSecret(port, authorization);
|
|
103
|
-
const { accessToken, dpopKey } = await getAccessToken(port, id, secret);
|
|
104
|
-
return await (0, solid_client_authn_core_1.buildAuthenticatedFetch)(accessToken, { dpopKey });
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=authFetch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authFetch.js","sourceRoot":"","sources":["../../src/authFetch.ts"],"names":[],"mappings":";;;;;AAmHA,8CAKC;AAvHD,6EAIyC;AACzC,8DAAgC;AAEhC,MAAM,MAAM,GAAG;IACb,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,mBAAmB;IAC1B,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF,KAAK,UAAU,WAAW,CAA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,EAAE,MAAM,EAAE,OAAO,CAAC;aACxD;YACD,IAAI,EAAE,2CAA2C;SAClD,CAAC,CAAC;QACH,MAAM,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC5B,2FAA2F;QAC3F,2DAA2D;QAC3D,sEAAsE;QACtE,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,OAAO,EAAE,WAAW,EAAE,SAAS,CAAC,YAAY,EAAE,OAAO,EAAE,CAAC;IAC1D,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,iBAAiB,CAAC,IAAY;IAClD,MAAM,aAAa,GAAG,MAAM,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IAC5D,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,GAAG,MAAM,cAAc,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IACxE,OAAO,MAAM,IAAA,iDAAuB,EAAC,WAAW,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^8.0.0/components/context.jsonld",
|
|
3
|
-
"import": [
|
|
4
|
-
"css:config/app/init/initialize-root.json",
|
|
5
|
-
"css:config/app/main/default.json",
|
|
6
|
-
"css:config/app/variables/default.json",
|
|
7
|
-
"css:config/http/handler/default.json",
|
|
8
|
-
"css:config/http/middleware/default.json",
|
|
9
|
-
"css:config/http/notifications/webhooks.json",
|
|
10
|
-
"css:config/http/server-factory/http.json",
|
|
11
|
-
"css:config/http/static/default.json",
|
|
12
|
-
"css:config/identity/access/public.json",
|
|
13
|
-
"css:config/identity/email/default.json",
|
|
14
|
-
"css:config/identity/handler/no-accounts.json",
|
|
15
|
-
"css:config/identity/oidc/default.json",
|
|
16
|
-
"css:config/identity/ownership/token.json",
|
|
17
|
-
"css:config/identity/pod/static.json",
|
|
18
|
-
"css:config/ldp/authentication/dpop-bearer.json",
|
|
19
|
-
"css:config/ldp/authorization/webacl.json",
|
|
20
|
-
"css:config/ldp/handler/default.json",
|
|
21
|
-
"css:config/ldp/metadata-parser/default.json",
|
|
22
|
-
"css:config/ldp/metadata-writer/default.json",
|
|
23
|
-
"css:config/ldp/modes/default.json",
|
|
24
|
-
"css:config/storage/backend/file.json",
|
|
25
|
-
"css:config/storage/key-value/resource-store.json",
|
|
26
|
-
"css:config/storage/location/root.json",
|
|
27
|
-
"css:config/storage/middleware/default.json",
|
|
28
|
-
"css:config/util/auxiliary/acl.json",
|
|
29
|
-
"css:config/util/identifiers/suffix.json",
|
|
30
|
-
"css:config/util/index/default.json",
|
|
31
|
-
"css:config/util/logging/winston.json",
|
|
32
|
-
"css:config/util/representation-conversion/default.json",
|
|
33
|
-
"css:config/util/resource-locker/file.json",
|
|
34
|
-
"css:config/util/variables/default.json"
|
|
35
|
-
],
|
|
36
|
-
"@graph": [
|
|
37
|
-
{
|
|
38
|
-
"comment": [
|
|
39
|
-
"A Solid server that stores its resources on disk and uses WAC for authorization.",
|
|
40
|
-
"No registration and the root container is initialized to allow full access for everyone so make sure to change this."
|
|
41
|
-
]
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"@context": [
|
|
3
|
-
"https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^8.0.0/components/context.jsonld"
|
|
4
|
-
],
|
|
5
|
-
"import": [
|
|
6
|
-
"css:config/app/init/static-root.json",
|
|
7
|
-
"css:config/app/main/default.json",
|
|
8
|
-
"css:config/app/variables/default.json",
|
|
9
|
-
"css:config/http/handler/default.json",
|
|
10
|
-
"css:config/http/middleware/default.json",
|
|
11
|
-
"css:config/http/notifications/all.json",
|
|
12
|
-
"css:config/http/server-factory/http.json",
|
|
13
|
-
"css:config/http/static/default.json",
|
|
14
|
-
"css:config/identity/access/public.json",
|
|
15
|
-
"css:config/identity/email/default.json",
|
|
16
|
-
"css:config/identity/handler/default.json",
|
|
17
|
-
"css:config/identity/oidc/default.json",
|
|
18
|
-
"css:config/identity/ownership/token.json",
|
|
19
|
-
"css:config/identity/pod/static.json",
|
|
20
|
-
"css:config/ldp/authentication/dpop-bearer.json",
|
|
21
|
-
"css:config/ldp/authorization/webacl.json",
|
|
22
|
-
"css:config/ldp/handler/default.json",
|
|
23
|
-
"css:config/ldp/metadata-parser/default.json",
|
|
24
|
-
"css:config/ldp/metadata-writer/default.json",
|
|
25
|
-
"css:config/ldp/modes/default.json",
|
|
26
|
-
"css:config/storage/backend/memory.json",
|
|
27
|
-
"css:config/storage/key-value/resource-store.json",
|
|
28
|
-
"css:config/storage/location/pod.json",
|
|
29
|
-
"css:config/storage/middleware/default.json",
|
|
30
|
-
"css:config/util/auxiliary/acl.json",
|
|
31
|
-
"css:config/util/identifiers/suffix.json",
|
|
32
|
-
"css:config/util/index/default.json",
|
|
33
|
-
"css:config/util/logging/winston.json",
|
|
34
|
-
"css:config/util/representation-conversion/default.json",
|
|
35
|
-
"css:config/util/resource-locker/memory.json",
|
|
36
|
-
"css:config/util/variables/default.json"
|
|
37
|
-
],
|
|
38
|
-
"@graph": [
|
|
39
|
-
{
|
|
40
|
-
"comment": "A Solid server that stores its resources on disk and uses WAC for authorization."
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
}
|
package/dist/cjs/createServer.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Taken from https://github.com/comunica/comunica/blob/b237be4265c353a62a876187d9e21e3bc05123a3/engines/query-sparql/test/QuerySparql-solid-test.ts#L9
|
|
3
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
-
if (k2 === undefined) k2 = k;
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
-
}) : function(o, v) {
|
|
17
|
-
o["default"] = v;
|
|
18
|
-
});
|
|
19
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
-
var ownKeys = function(o) {
|
|
21
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
-
var ar = [];
|
|
23
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
-
return ar;
|
|
25
|
-
};
|
|
26
|
-
return ownKeys(o);
|
|
27
|
-
};
|
|
28
|
-
return function (mod) {
|
|
29
|
-
if (mod && mod.__esModule) return mod;
|
|
30
|
-
var result = {};
|
|
31
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
-
__setModuleDefault(result, mod);
|
|
33
|
-
return result;
|
|
34
|
-
};
|
|
35
|
-
})();
|
|
36
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.createApp = createApp;
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
const community_server_1 = require("@solid/community-server");
|
|
40
|
-
const node_path_1 = require("node:path");
|
|
41
|
-
const node_url_1 = require("node:url");
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
const __dirname = (0, node_path_1.dirname)((0, node_url_1.fileURLToPath)(import.meta.url));
|
|
45
|
-
async function createApp(port, customConfigPath) {
|
|
46
|
-
if (process.env.SERVER) {
|
|
47
|
-
return {
|
|
48
|
-
start: () => { },
|
|
49
|
-
stop: () => { },
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
const appRunner = new community_server_1.AppRunner();
|
|
53
|
-
return appRunner.create({
|
|
54
|
-
loaderProperties: {
|
|
55
|
-
mainModulePath: (0, community_server_1.resolveModulePath)(""),
|
|
56
|
-
typeChecking: false,
|
|
57
|
-
},
|
|
58
|
-
config: customConfigPath ?? (0, community_server_1.resolveModulePath)("config/file-root.json"),
|
|
59
|
-
variableBindings: {},
|
|
60
|
-
shorthand: {
|
|
61
|
-
port: port,
|
|
62
|
-
loggingLevel: "off",
|
|
63
|
-
seedConfig: path.join(__dirname, "configs", "solid-css-seed.json"),
|
|
64
|
-
rootFilePath: path.join(__dirname, `./data${port}`),
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=createServer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createServer.js","sourceRoot":"","sources":["../../src/createServer.ts"],"names":[],"mappings":";AAAA,uJAAuJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYvJ,8BA0BC;AApCD,2CAA6B;AAE7B,8DAAuE;AACvE,yCAAoC;AACpC,uCAAyC;AAEzC,6DAA6D;AAC7D,aAAa;AACb,MAAM,SAAS,GAAG,IAAA,mBAAO,EAAC,IAAA,wBAAa,EAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAEnD,KAAK,UAAU,SAAS,CAC7B,IAAY,EACZ,gBAAyB;IAEzB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QACvB,OAAO;YACL,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;YACf,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;SACR,CAAC;IACX,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,4BAAS,EAAE,CAAC;IAElC,OAAO,SAAS,CAAC,MAAM,CAAC;QACtB,gBAAgB,EAAE;YAChB,cAAc,EAAE,IAAA,oCAAiB,EAAC,EAAE,CAAC;YACrC,YAAY,EAAE,KAAK;SACpB;QACD,MAAM,EAAE,gBAAgB,IAAI,IAAA,oCAAiB,EAAC,uBAAuB,CAAC;QACtE,gBAAgB,EAAE,EAAE;QACpB,SAAS,EAAE;YACT,IAAI,EAAE,IAAI;YACV,YAAY,EAAE,KAAK;YACnB,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,qBAAqB,CAAC;YAClE,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,IAAI,EAAE,CAAC;SACpD;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./createServer.js"), exports);
|
|
18
|
-
__exportStar(require("./setupTestServer.js"), exports);
|
|
19
|
-
__exportStar(require("./resourceUtils.js"), exports);
|
|
20
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAkC;AAClC,uDAAqC;AACrC,qDAAmC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initResources = initResources;
|
|
4
|
-
exports.cleanResources = cleanResources;
|
|
5
|
-
async function initResources(rootUri, resourceInfo, authFetch) {
|
|
6
|
-
if (resourceInfo?.shouldNotInit)
|
|
7
|
-
return;
|
|
8
|
-
if (resourceInfo.isContainer) {
|
|
9
|
-
await authFetch(rootUri, {
|
|
10
|
-
method: "POST",
|
|
11
|
-
headers: {
|
|
12
|
-
link: '<http://www.w3.org/ns/ldp#Container>; rel="type"',
|
|
13
|
-
slug: resourceInfo.slug,
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
await Promise.all(resourceInfo.contains.map((subResourceInfo) => initResources(`${rootUri}${resourceInfo.slug}`, subResourceInfo, authFetch)));
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
await authFetch(`${rootUri}${resourceInfo.slug}`, {
|
|
20
|
-
method: "PUT",
|
|
21
|
-
headers: {
|
|
22
|
-
"content-type": resourceInfo.mimeType,
|
|
23
|
-
},
|
|
24
|
-
body: resourceInfo.data,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async function cleanResources(rootUri, resourceInfo, authFetch) {
|
|
29
|
-
if (resourceInfo.isContainer) {
|
|
30
|
-
await Promise.all(resourceInfo.contains.map((subResourceInfo) => cleanResources(`${rootUri}${resourceInfo.slug}`, subResourceInfo, authFetch)));
|
|
31
|
-
await authFetch(`${rootUri}${resourceInfo.slug}`, {
|
|
32
|
-
method: "DELETE",
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
await authFetch(`${rootUri}${resourceInfo.slug}`, {
|
|
37
|
-
method: "DELETE",
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=resourceUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resourceUtils.js","sourceRoot":"","sources":["../../src/resourceUtils.ts"],"names":[],"mappings":";;AAiBA,sCAgCC;AAED,wCAuBC;AAzDM,KAAK,UAAU,aAAa,CACjC,OAAe,EACf,YAA0B,EAC1B,SAAuB;IAEvB,IAAI,YAAY,EAAE,aAAa;QAAE,OAAO;IACxC,IAAI,YAAY,CAAC,WAAW,EAAE,CAAC;QAC7B,MAAM,SAAS,CAAC,OAAO,EAAE;YACvB,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,IAAI,EAAE,kDAAkD;gBACxD,IAAI,EAAE,YAAY,CAAC,IAAI;aACxB;SACF,CAAC,CAAC;QACH,MAAM,OAAO,CAAC,GAAG,CACf,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE,CAC5C,aAAa,CACX,GAAG,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,EAChC,eAAe,EACf,SAAS,CACV,CACF,CACF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,MAAM,SAAS,CAAC,GAAG,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE;YAChD,MAAM,EAAE,KAAK;YACb,OAAO,EAAE;gBACP,cAAc,EAAE,YAAY,CAAC,QAAQ;aACtC;YACD,IAAI,EAAE,YAAY,CAAC,IAAI;SACxB,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,cAAc,CAClC,OAAe,EACf,YAA0B,EAC1B,SAAuB;IAEvB,IAAI,YAAY,CAAC,WAAW,EAAE,CAAC;QAC7B,MAAM,OAAO,CAAC,GAAG,CACf,YAAY,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE,CAC5C,cAAc,CACZ,GAAG,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,EAChC,eAAe,EACf,SAAS,CACV,CACF,CACF,CAAC;QACF,MAAM,SAAS,CAAC,GAAG,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE;YAChD,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,MAAM,SAAS,CAAC,GAAG,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE;YAChD,MAAM,EAAE,QAAQ;SACjB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.setupServer = setupServer;
|
|
7
|
-
const createServer_js_1 = require("./createServer.js");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const resourceUtils_js_1 = require("./resourceUtils.js");
|
|
10
|
-
const authFetch_js_1 = require("./authFetch.js");
|
|
11
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
12
|
-
const vitest_1 = require("vitest");
|
|
13
|
-
const node_path_1 = require("node:path");
|
|
14
|
-
const node_url_1 = require("node:url");
|
|
15
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
const __dirname = (0, node_path_1.dirname)((0, node_url_1.fileURLToPath)(import.meta.url));
|
|
18
|
-
// Use an increased timeout, since the CSS server takes too much setup time.
|
|
19
|
-
vitest_1.vi.setConfig({ testTimeout: 40_000, hookTimeout: 40_000 });
|
|
20
|
-
function setupServer(port, resourceInfo, customConfigPath, skipAuthentication) {
|
|
21
|
-
const data = {
|
|
22
|
-
rootUri: `http://localhost:${port}/`,
|
|
23
|
-
};
|
|
24
|
-
let previousJestId;
|
|
25
|
-
let previousNodeEnv;
|
|
26
|
-
(0, vitest_1.beforeAll)(async () => {
|
|
27
|
-
// Remove Jest ID so that community solid server doesn't use the Jest Import
|
|
28
|
-
process.env.NODE_ENV = "other_test";
|
|
29
|
-
// Start up the server
|
|
30
|
-
data.app = await (0, createServer_js_1.createApp)(port, customConfigPath);
|
|
31
|
-
await data.app.start();
|
|
32
|
-
data.authFetch = skipAuthentication ? fetch : await (0, authFetch_js_1.generateAuthFetch)(port);
|
|
33
|
-
});
|
|
34
|
-
(0, vitest_1.afterAll)(async () => {
|
|
35
|
-
// We're potentially ignoring data clean up and server shutdown because
|
|
36
|
-
// sometimes this doesn't work in CI.
|
|
37
|
-
try {
|
|
38
|
-
await Promise.race([
|
|
39
|
-
data.app.stop?.(),
|
|
40
|
-
new Promise((_, reject) => setTimeout(() => reject(new Error("Shutdown timeout")), 10000)),
|
|
41
|
-
]);
|
|
42
|
-
}
|
|
43
|
-
catch (err) {
|
|
44
|
-
console.warn("⚠️ Ignoring shutdown error in CI:", err.message);
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
const testDataPath = path_1.default.join(__dirname, `./data${port}`);
|
|
48
|
-
await promises_1.default.rm(testDataPath, { recursive: true, force: true });
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
console.warn("⚠️ Ignoring data cleanup error in CI:", err.message);
|
|
52
|
-
}
|
|
53
|
-
process.env.JEST_WORKER_ID = previousJestId;
|
|
54
|
-
process.env.NODE_ENV = previousNodeEnv;
|
|
55
|
-
});
|
|
56
|
-
(0, vitest_1.beforeEach)(async () => {
|
|
57
|
-
data.fetchMock = vitest_1.vi.fn(data.authFetch);
|
|
58
|
-
// Create a new document called sample.ttl
|
|
59
|
-
await (0, resourceUtils_js_1.initResources)(data.rootUri, resourceInfo, data.authFetch);
|
|
60
|
-
});
|
|
61
|
-
(0, vitest_1.afterEach)(async () => {
|
|
62
|
-
await (0, resourceUtils_js_1.cleanResources)(data.rootUri, resourceInfo, data.authFetch);
|
|
63
|
-
});
|
|
64
|
-
return data;
|
|
65
|
-
}
|
|
66
|
-
//# sourceMappingURL=setupTestServer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setupTestServer.js","sourceRoot":"","sources":["../../src/setupTestServer.ts"],"names":[],"mappings":";;;;;AA0BA,kCAsEC;AA9FD,uDAA8C;AAC9C,gDAAwB;AAExB,yDAAmE;AACnE,iDAAmD;AACnD,2DAA6B;AAC7B,mCAOgB;AAChB,yCAAoC;AACpC,uCAAyC;AAEzC,6DAA6D;AAC7D,aAAa;AACb,MAAM,SAAS,GAAG,IAAA,mBAAO,EAAC,IAAA,wBAAa,EAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE1D,4EAA4E;AAC5E,WAAE,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,CAAC;AAE3D,SAAgB,WAAW,CACzB,IAAY,EACZ,YAA0B,EAC1B,gBAAyB,EACzB,kBAA4B;IAE5B,MAAM,IAAI,GAUN;QACF,OAAO,EAAE,oBAAoB,IAAI,GAAG;KAC9B,CAAC;IAET,IAAI,cAAkC,CAAC;IACvC,IAAI,eAAmC,CAAC;IACxC,IAAA,kBAAS,EAAC,KAAK,IAAI,EAAE;QACnB,4EAA4E;QAC5E,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,YAAY,CAAC;QACpC,sBAAsB;QACt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Ae,CAAC;IACzC,CAAC,CAAC,CAAC;IAEH,IAAA,mBAAU,EAAC,KAAK,IAAI,EAAE;QACpB,IAAI,CAAC,SAAS,GAAG,WAAE,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACvC,0CAA0C;QAC1C,MAAM,IAAA,gCAAa,EAAC,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,IAAA,kBAAS,EAAC,KAAK,IAAI,EAAE;QACnB,MAAM,IAAA,iCAAc,EAAC,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/esm/authFetch.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { buildAuthenticatedFetch, createDpopHeader, generateDpopKeyPair, } from "@inrupt/solid-client-authn-core";
|
|
2
|
-
import fetch from "cross-fetch";
|
|
3
|
-
const config = {
|
|
4
|
-
podName: "example",
|
|
5
|
-
email: "hello@example.com",
|
|
6
|
-
password: "abc123",
|
|
7
|
-
};
|
|
8
|
-
async function reportError(response) {
|
|
9
|
-
if (response.status >= 400) {
|
|
10
|
-
console.error(await response.text());
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
async function getAuthorization(port) {
|
|
14
|
-
// First we request the account API controls to find out where we can log in
|
|
15
|
-
const indexResponse = await fetch(`http://localhost:${port}/.account/`);
|
|
16
|
-
const { controls } = await indexResponse.json();
|
|
17
|
-
// And then we log in to the account API
|
|
18
|
-
const response = await fetch(controls.password.login, {
|
|
19
|
-
method: "POST",
|
|
20
|
-
headers: { "content-type": "application/json" },
|
|
21
|
-
body: JSON.stringify({
|
|
22
|
-
email: config.email,
|
|
23
|
-
password: config.password,
|
|
24
|
-
}),
|
|
25
|
-
});
|
|
26
|
-
// This authorization value will be used to authenticate in the next step
|
|
27
|
-
await reportError(response);
|
|
28
|
-
const result = await response.json();
|
|
29
|
-
return result.authorization;
|
|
30
|
-
}
|
|
31
|
-
async function getSecret(port, authorization) {
|
|
32
|
-
// Now that we are logged in, we need to request the updated controls from the server.
|
|
33
|
-
// These will now have more values than in the previous example.
|
|
34
|
-
const indexResponse = await fetch(`http://localhost:${port}/.account/`, {
|
|
35
|
-
headers: { authorization: `CSS-Account-Token ${authorization}` },
|
|
36
|
-
});
|
|
37
|
-
const { controls } = await indexResponse.json();
|
|
38
|
-
// Here we request the server to generate a token on our account
|
|
39
|
-
const response = await fetch(controls.account.clientCredentials, {
|
|
40
|
-
method: "POST",
|
|
41
|
-
headers: {
|
|
42
|
-
authorization: `CSS-Account-Token ${authorization}`,
|
|
43
|
-
"content-type": "application/json",
|
|
44
|
-
},
|
|
45
|
-
// The name field will be used when generating the ID of your token.
|
|
46
|
-
// The WebID field determines which WebID you will identify as when using the token.
|
|
47
|
-
// Only WebIDs linked to your account can be used.
|
|
48
|
-
body: JSON.stringify({
|
|
49
|
-
name: "my-token",
|
|
50
|
-
webId: `http://localhost:${port}/${config.podName}/profile/card#me`,
|
|
51
|
-
}),
|
|
52
|
-
});
|
|
53
|
-
await reportError(response);
|
|
54
|
-
// These are the identifier and secret of your token.
|
|
55
|
-
// Store the secret somewhere safe as there is no way to request it again from the server!
|
|
56
|
-
// The `resource` value can be used to delete the token at a later point in time.
|
|
57
|
-
const response2 = await response.json();
|
|
58
|
-
return response2;
|
|
59
|
-
}
|
|
60
|
-
async function getAccessToken(port, id, secret) {
|
|
61
|
-
try {
|
|
62
|
-
// A key pair is needed for encryption.
|
|
63
|
-
// This function from `solid-client-authn` generates such a pair for you.
|
|
64
|
-
const dpopKey = await generateDpopKeyPair();
|
|
65
|
-
// These are the ID and secret generated in the previous step.
|
|
66
|
-
// Both the ID and the secret need to be form-encoded.
|
|
67
|
-
const authString = `${encodeURIComponent(id)}:${encodeURIComponent(secret)}`;
|
|
68
|
-
// This URL can be found by looking at the "token_endpoint" field at
|
|
69
|
-
// http://localhost:PORT/.well-known/openid-configuration
|
|
70
|
-
// if your server is hosted at http://localhost:3000/.
|
|
71
|
-
const tokenUrl = `http://localhost:${port}/.oidc/token`;
|
|
72
|
-
const response = await fetch(tokenUrl, {
|
|
73
|
-
method: "POST",
|
|
74
|
-
headers: {
|
|
75
|
-
// The header needs to be in base64 encoding.
|
|
76
|
-
authorization: `Basic ${Buffer.from(authString).toString("base64")}`,
|
|
77
|
-
"content-type": "application/x-www-form-urlencoded",
|
|
78
|
-
dpop: await createDpopHeader(tokenUrl, "POST", dpopKey),
|
|
79
|
-
},
|
|
80
|
-
body: "grant_type=client_credentials&scope=webid",
|
|
81
|
-
});
|
|
82
|
-
await reportError(response);
|
|
83
|
-
// This is the Access token that will be used to do an authenticated request to the server.
|
|
84
|
-
// The JSON also contains an "expires_in" field in seconds,
|
|
85
|
-
// which you can use to know when you need request a new Access token.
|
|
86
|
-
const response2 = await response.json();
|
|
87
|
-
return { accessToken: response2.access_token, dpopKey };
|
|
88
|
-
}
|
|
89
|
-
catch (err) {
|
|
90
|
-
console.error(err);
|
|
91
|
-
throw err;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
export async function generateAuthFetch(port) {
|
|
95
|
-
const authorization = await getAuthorization(port);
|
|
96
|
-
const { id, secret } = await getSecret(port, authorization);
|
|
97
|
-
const { accessToken, dpopKey } = await getAccessToken(port, id, secret);
|
|
98
|
-
return await buildAuthenticatedFetch(accessToken, { dpopKey });
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=authFetch.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"authFetch.js","sourceRoot":"","sources":["../../src/authFetch.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,MAAM,aAAa,CAAC;AAEhC,MAAM,MAAM,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