@ldo/test-solid-server 1.0.0-alpha.45 → 1.0.0-alpha.48
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/authFetch.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let _inrupt_solid_client_authn_core = require("@inrupt/solid-client-authn-core");
|
|
3
3
|
let cross_fetch = require("cross-fetch");
|
|
4
|
-
cross_fetch = require_runtime.__toESM(cross_fetch);
|
|
4
|
+
cross_fetch = require_runtime.__toESM(cross_fetch, 1);
|
|
5
5
|
//#region src/authFetch.ts
|
|
6
6
|
const config = {
|
|
7
7
|
podName: "example",
|
package/dist/authFetch.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authFetch.mjs","names":[],"sources":["../src/authFetch.ts"],"sourcesContent":["import type { KeyPair } from \"@inrupt/solid-client-authn-core\";\nimport {\n buildAuthenticatedFetch,\n createDpopHeader,\n generateDpopKeyPair,\n} from \"@inrupt/solid-client-authn-core\";\nimport fetch from \"cross-fetch\";\n\nconst config = {\n podName: \"example\",\n email: \"hello@example.com\",\n password: \"abc123\",\n};\n\nasync function reportError(response: Response) {\n if (response.status >= 400) {\n console.error(await response.text());\n }\n}\n\nasync function getAuthorization(port: number): Promise<string> {\n // First we request the account API controls to find out where we can log in\n const indexResponse = await fetch(`http://localhost:${port}/.account/`);\n const { controls } = await indexResponse.json();\n\n // And then we log in to the account API\n const response = await fetch(controls.password.login, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n email: config.email,\n password: config.password,\n }),\n });\n // This authorization value will be used to authenticate in the next step\n await reportError(response);\n const result = await response.json();\n return result.authorization;\n}\n\nasync function getSecret(\n port: number,\n authorization: string,\n): Promise<{ id: string; secret: string; resource: string }> {\n // Now that we are logged in, we need to request the updated controls from the server.\n // These will now have more values than in the previous example.\n const indexResponse = await fetch(`http://localhost:${port}/.account/`, {\n headers: { authorization: `CSS-Account-Token ${authorization}` },\n });\n const { controls } = await indexResponse.json();\n\n // Here we request the server to generate a token on our account\n const response = await fetch(controls.account.clientCredentials, {\n method: \"POST\",\n headers: {\n authorization: `CSS-Account-Token ${authorization}`,\n \"content-type\": \"application/json\",\n },\n // The name field will be used when generating the ID of your token.\n // The WebID field determines which WebID you will identify as when using the token.\n // Only WebIDs linked to your account can be used.\n body: JSON.stringify({\n name: \"my-token\",\n webId: `http://localhost:${port}/${config.podName}/profile/card#me`,\n }),\n });\n await reportError(response);\n // These are the identifier and secret of your token.\n // Store the secret somewhere safe as there is no way to request it again from the server!\n // The `resource` value can be used to delete the token at a later point in time.\n const response2 = await response.json();\n return response2;\n}\n\nasync function getAccessToken(\n port: number,\n id: string,\n secret: string,\n): Promise<{ accessToken: string; dpopKey: KeyPair }> {\n try {\n // A key pair is needed for encryption.\n // This function from `solid-client-authn` generates such a pair for you.\n const dpopKey = await generateDpopKeyPair();\n\n // These are the ID and secret generated in the previous step.\n // Both the ID and the secret need to be form-encoded.\n const authString = `${encodeURIComponent(id)}:${encodeURIComponent(\n secret,\n )}`;\n // This URL can be found by looking at the \"token_endpoint\" field at\n // http://localhost:PORT/.well-known/openid-configuration\n // if your server is hosted at http://localhost:3000/.\n const tokenUrl = `http://localhost:${port}/.oidc/token`;\n const response = await fetch(tokenUrl, {\n method: \"POST\",\n headers: {\n // The header needs to be in base64 encoding.\n authorization: `Basic ${Buffer.from(authString).toString(\"base64\")}`,\n \"content-type\": \"application/x-www-form-urlencoded\",\n dpop: await createDpopHeader(tokenUrl, \"POST\", dpopKey),\n },\n body: \"grant_type=client_credentials&scope=webid\",\n });\n await reportError(response);\n // This is the Access token that will be used to do an authenticated request to the server.\n // The JSON also contains an \"expires_in\" field in seconds,\n // which you can use to know when you need request a new Access token.\n const response2 = await response.json();\n return { accessToken: response2.access_token, dpopKey };\n } catch (err) {\n console.error(err);\n throw err;\n }\n}\n\nexport async function generateAuthFetch(port: number) {\n const authorization = await getAuthorization(port);\n const { id, secret } = await getSecret(port, authorization);\n const { accessToken, dpopKey } = await getAccessToken(port, id, secret);\n return await buildAuthenticatedFetch(accessToken, { dpopKey });\n}\n"],"mappings":";;;AAQA,MAAM,SAAS;CACb,SAAS;CACT,OAAO;CACP,UAAU;CACX;AAED,eAAe,YAAY,UAAoB;AAC7C,KAAI,SAAS,UAAU,IACrB,SAAQ,MAAM,MAAM,SAAS,MAAM,CAAC;;AAIxC,eAAe,iBAAiB,MAA+B;CAG7D,MAAM,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"authFetch.mjs","names":[],"sources":["../src/authFetch.ts"],"sourcesContent":["import type { KeyPair } from \"@inrupt/solid-client-authn-core\";\nimport {\n buildAuthenticatedFetch,\n createDpopHeader,\n generateDpopKeyPair,\n} from \"@inrupt/solid-client-authn-core\";\nimport fetch from \"cross-fetch\";\n\nconst config = {\n podName: \"example\",\n email: \"hello@example.com\",\n password: \"abc123\",\n};\n\nasync function reportError(response: Response) {\n if (response.status >= 400) {\n console.error(await response.text());\n }\n}\n\nasync function getAuthorization(port: number): Promise<string> {\n // First we request the account API controls to find out where we can log in\n const indexResponse = await fetch(`http://localhost:${port}/.account/`);\n const { controls } = await indexResponse.json();\n\n // And then we log in to the account API\n const response = await fetch(controls.password.login, {\n method: \"POST\",\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({\n email: config.email,\n password: config.password,\n }),\n });\n // This authorization value will be used to authenticate in the next step\n await reportError(response);\n const result = await response.json();\n return result.authorization;\n}\n\nasync function getSecret(\n port: number,\n authorization: string,\n): Promise<{ id: string; secret: string; resource: string }> {\n // Now that we are logged in, we need to request the updated controls from the server.\n // These will now have more values than in the previous example.\n const indexResponse = await fetch(`http://localhost:${port}/.account/`, {\n headers: { authorization: `CSS-Account-Token ${authorization}` },\n });\n const { controls } = await indexResponse.json();\n\n // Here we request the server to generate a token on our account\n const response = await fetch(controls.account.clientCredentials, {\n method: \"POST\",\n headers: {\n authorization: `CSS-Account-Token ${authorization}`,\n \"content-type\": \"application/json\",\n },\n // The name field will be used when generating the ID of your token.\n // The WebID field determines which WebID you will identify as when using the token.\n // Only WebIDs linked to your account can be used.\n body: JSON.stringify({\n name: \"my-token\",\n webId: `http://localhost:${port}/${config.podName}/profile/card#me`,\n }),\n });\n await reportError(response);\n // These are the identifier and secret of your token.\n // Store the secret somewhere safe as there is no way to request it again from the server!\n // The `resource` value can be used to delete the token at a later point in time.\n const response2 = await response.json();\n return response2;\n}\n\nasync function getAccessToken(\n port: number,\n id: string,\n secret: string,\n): Promise<{ accessToken: string; dpopKey: KeyPair }> {\n try {\n // A key pair is needed for encryption.\n // This function from `solid-client-authn` generates such a pair for you.\n const dpopKey = await generateDpopKeyPair();\n\n // These are the ID and secret generated in the previous step.\n // Both the ID and the secret need to be form-encoded.\n const authString = `${encodeURIComponent(id)}:${encodeURIComponent(\n secret,\n )}`;\n // This URL can be found by looking at the \"token_endpoint\" field at\n // http://localhost:PORT/.well-known/openid-configuration\n // if your server is hosted at http://localhost:3000/.\n const tokenUrl = `http://localhost:${port}/.oidc/token`;\n const response = await fetch(tokenUrl, {\n method: \"POST\",\n headers: {\n // The header needs to be in base64 encoding.\n authorization: `Basic ${Buffer.from(authString).toString(\"base64\")}`,\n \"content-type\": \"application/x-www-form-urlencoded\",\n dpop: await createDpopHeader(tokenUrl, \"POST\", dpopKey),\n },\n body: \"grant_type=client_credentials&scope=webid\",\n });\n await reportError(response);\n // This is the Access token that will be used to do an authenticated request to the server.\n // The JSON also contains an \"expires_in\" field in seconds,\n // which you can use to know when you need request a new Access token.\n const response2 = await response.json();\n return { accessToken: response2.access_token, dpopKey };\n } catch (err) {\n console.error(err);\n throw err;\n }\n}\n\nexport async function generateAuthFetch(port: number) {\n const authorization = await getAuthorization(port);\n const { id, secret } = await getSecret(port, authorization);\n const { accessToken, dpopKey } = await getAccessToken(port, id, secret);\n return await buildAuthenticatedFetch(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,CAAC,SAAS,SAAS;IAClE,gBAAgB;IAChB,MAAM,MAAM,iBAAiB,UAAU,QAAQ,QAAQ;IACxD;GACD,MAAM;GACP,CAAC;AACF,QAAM,YAAY,SAAS;AAK3B,SAAO;GAAE,cAAa,MADE,SAAS,MAAM,EACP;GAAc;GAAS;UAChD,KAAK;AACZ,UAAQ,MAAM,IAAI;AAClB,QAAM;;;AAIV,eAAsB,kBAAkB,MAAc;CAEpD,MAAM,EAAE,IAAI,WAAW,MAAM,UAAU,MAAM,MADjB,iBAAiB,KAAK,CACS;CAC3D,MAAM,EAAE,aAAa,YAAY,MAAM,eAAe,MAAM,IAAI,OAAO;AACvE,QAAO,MAAM,wBAAwB,aAAa,EAAE,SAAS,CAAC"}
|
package/dist/createServer.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let path = require("path");
|
|
3
|
-
path = require_runtime.__toESM(path);
|
|
3
|
+
path = require_runtime.__toESM(path, 1);
|
|
4
4
|
let _solid_community_server = require("@solid/community-server");
|
|
5
5
|
let node_path = require("node:path");
|
|
6
6
|
let node_url = require("node:url");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createServer.mjs","names":["path"],"sources":["../src/createServer.ts"],"sourcesContent":["// Taken from https://github.com/comunica/comunica/blob/b237be4265c353a62a876187d9e21e3bc05123a3/engines/query-sparql/test/QuerySparql-solid-test.ts#L9\n\nimport * as path from \"path\";\nimport type { App } from \"@solid/community-server\";\nimport { AppRunner, resolveModulePath } from \"@solid/community-server\";\nimport { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport async function createApp(\n port: number,\n customConfigPath?: string,\n): Promise<App> {\n if (process.env.SERVER) {\n return {\n start: () => {},\n stop: () => {},\n } as App;\n }\n const appRunner = new AppRunner();\n\n return appRunner.create({\n loaderProperties: {\n mainModulePath: resolveModulePath(\"\"),\n typeChecking: false,\n },\n config: customConfigPath ?? resolveModulePath(\"config/file-root.json\"),\n variableBindings: {},\n shorthand: {\n port: port,\n loggingLevel: \"off\",\n seedConfig: path.join(__dirname, \"configs\", \"solid-css-seed.json\"),\n rootFilePath: path.join(__dirname, `./data${port}`),\n },\n });\n}\n"],"mappings":";;;;;AAUA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,eAAsB,UACpB,MACA,kBACc;AACd,KAAI,QAAQ,IAAI,OACd,QAAO;EACL,aAAa;EACb,YAAY;EACb;AAIH,
|
|
1
|
+
{"version":3,"file":"createServer.mjs","names":["path"],"sources":["../src/createServer.ts"],"sourcesContent":["// Taken from https://github.com/comunica/comunica/blob/b237be4265c353a62a876187d9e21e3bc05123a3/engines/query-sparql/test/QuerySparql-solid-test.ts#L9\n\nimport * as path from \"path\";\nimport type { App } from \"@solid/community-server\";\nimport { AppRunner, resolveModulePath } from \"@solid/community-server\";\nimport { dirname } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-ignore\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport async function createApp(\n port: number,\n customConfigPath?: string,\n): Promise<App> {\n if (process.env.SERVER) {\n return {\n start: () => {},\n stop: () => {},\n } as App;\n }\n const appRunner = new AppRunner();\n\n return appRunner.create({\n loaderProperties: {\n mainModulePath: resolveModulePath(\"\"),\n typeChecking: false,\n },\n config: customConfigPath ?? resolveModulePath(\"config/file-root.json\"),\n variableBindings: {},\n shorthand: {\n port: port,\n loggingLevel: \"off\",\n seedConfig: path.join(__dirname, \"configs\", \"solid-css-seed.json\"),\n rootFilePath: path.join(__dirname, `./data${port}`),\n },\n });\n}\n"],"mappings":";;;;;AAUA,MAAM,YAAY,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAEzD,eAAsB,UACpB,MACA,kBACc;AACd,KAAI,QAAQ,IAAI,OACd,QAAO;EACL,aAAa;EACb,YAAY;EACb;AAIH,QAAO,IAFe,WAEN,CAAC,OAAO;EACtB,kBAAkB;GAChB,gBAAgB,kBAAkB,GAAG;GACrC,cAAc;GACf;EACD,QAAQ,oBAAoB,kBAAkB,wBAAwB;EACtE,kBAAkB,EAAE;EACpB,WAAW;GACH;GACN,cAAc;GACd,YAAYA,OAAK,KAAK,WAAW,WAAW,sBAAsB;GAClE,cAAcA,OAAK,KAAK,WAAW,SAAS,OAAO;GACpD;EACF,CAAC"}
|
package/dist/setupTestServer.cjs
CHANGED
|
@@ -3,11 +3,11 @@ const require_createServer = require("./createServer.cjs");
|
|
|
3
3
|
const require_resourceUtils = require("./resourceUtils.cjs");
|
|
4
4
|
const require_authFetch = require("./authFetch.cjs");
|
|
5
5
|
let path = require("path");
|
|
6
|
-
path = require_runtime.__toESM(path);
|
|
6
|
+
path = require_runtime.__toESM(path, 1);
|
|
7
7
|
let node_path = require("node:path");
|
|
8
8
|
let node_url = require("node:url");
|
|
9
9
|
let fs_promises = require("fs/promises");
|
|
10
|
-
fs_promises = require_runtime.__toESM(fs_promises);
|
|
10
|
+
fs_promises = require_runtime.__toESM(fs_promises, 1);
|
|
11
11
|
let vitest = require("vitest");
|
|
12
12
|
//#region src/setupTestServer.ts
|
|
13
13
|
const __dirname$1 = (0, node_path.dirname)((0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldo/test-solid-server",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.48",
|
|
4
4
|
"description": "A solid server to be used in jest tests",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "088bddcc93bb029bc538c5a08dbf74eba3d25129"
|
|
53
53
|
}
|