@xtrable-ltd/nanoesis 0.1.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/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/adapter-azure-blob.d.ts +97 -0
- package/dist/adapter-azure-blob.js +127 -0
- package/dist/adapter-cloudflare.d.ts +28 -0
- package/dist/adapter-cloudflare.js +32 -0
- package/dist/adapter-fs.d.ts +38 -0
- package/dist/adapter-fs.js +54 -0
- package/dist/adapter-local-jwt.d.ts +205 -0
- package/dist/adapter-local-jwt.js +550 -0
- package/dist/adapter-sharp.d.ts +11 -0
- package/dist/adapter-sharp.js +39 -0
- package/dist/adapter-shell.d.ts +48 -0
- package/dist/adapter-shell.js +56 -0
- package/dist/adapter-trusted-header.d.ts +43 -0
- package/dist/adapter-trusted-header.js +21 -0
- package/dist/chunk-G2UEZTYC.js +2541 -0
- package/dist/editor-api.d.ts +198 -0
- package/dist/editor-api.js +592 -0
- package/dist/editor.d.ts +13 -0
- package/dist/editor.js +6 -0
- package/dist/index.d.ts +1238 -0
- package/dist/index.js +124 -0
- package/editor/assets/TemplatesPane-5qsDAK_B.js +792 -0
- package/editor/assets/TemplatesPane-B4_sg2u5.css +1 -0
- package/editor/assets/abap-BrgZPUOV.js +6 -0
- package/editor/assets/apex-DyP6w7ZV.js +6 -0
- package/editor/assets/azcli-BaLxmfj-.js +6 -0
- package/editor/assets/bat-CFOPXBzS.js +6 -0
- package/editor/assets/bicep-BfEKNvv3.js +7 -0
- package/editor/assets/cameligo-BFG1Mk7z.js +6 -0
- package/editor/assets/clojure-DTECt2xU.js +6 -0
- package/editor/assets/codicon-DCmgc-ay.ttf +0 -0
- package/editor/assets/coffee-CDGzqUPQ.js +6 -0
- package/editor/assets/cpp-CLLBncYj.js +6 -0
- package/editor/assets/csharp-dUCx_-0o.js +6 -0
- package/editor/assets/csp-5Rap-vPy.js +6 -0
- package/editor/assets/css-D3h14YRZ.js +8 -0
- package/editor/assets/css.worker-DaIe3gwK.js +84 -0
- package/editor/assets/cssMode-CGp4MIjR.js +9 -0
- package/editor/assets/cypher-DrQuvNYM.js +6 -0
- package/editor/assets/dart-CFKIUWau.js +6 -0
- package/editor/assets/dockerfile-Zznr-cwX.js +6 -0
- package/editor/assets/ecl-Ce3n6wWz.js +6 -0
- package/editor/assets/editor.worker-BCzxt1at.js +12 -0
- package/editor/assets/elixir-deUWdS0T.js +6 -0
- package/editor/assets/flow9-i9-g7ZhI.js +6 -0
- package/editor/assets/freemarker2-CJkwxmPv.js +8 -0
- package/editor/assets/fsharp-CzKuDChf.js +6 -0
- package/editor/assets/go-Cphgjts3.js +6 -0
- package/editor/assets/graphql-Cg7bfA9N.js +6 -0
- package/editor/assets/handlebars-CKb5i2nM.js +6 -0
- package/editor/assets/hcl-0cvrggvQ.js +6 -0
- package/editor/assets/html-DyMbQx0w.js +6 -0
- package/editor/assets/html.worker-CKrFyw_2.js +461 -0
- package/editor/assets/htmlMode-DVPeqtn-.js +9 -0
- package/editor/assets/index-CbuWEnUB.css +7 -0
- package/editor/assets/index-DJmSgobK.js +129 -0
- package/editor/assets/ini-Drc7WvVn.js +6 -0
- package/editor/assets/java-B_fMsGYe.js +6 -0
- package/editor/assets/javascript-Bp1Qh9wR.js +6 -0
- package/editor/assets/json.worker-B7c_PmGb.js +49 -0
- package/editor/assets/jsonMode-FLEeVtx7.js +15 -0
- package/editor/assets/julia-Bqgm2twL.js +6 -0
- package/editor/assets/kotlin-BSkB5QuD.js +6 -0
- package/editor/assets/less-BsTHnhdd.js +7 -0
- package/editor/assets/lexon-YWi4-JPR.js +6 -0
- package/editor/assets/liquid-Bh8c534t.js +6 -0
- package/editor/assets/lua-nf6ki56Z.js +6 -0
- package/editor/assets/m3-Cpb6xl2v.js +6 -0
- package/editor/assets/markdown-DSZPf7rp.js +6 -0
- package/editor/assets/mdx-BUbo8M9l.js +6 -0
- package/editor/assets/mips-B_c3zf-v.js +6 -0
- package/editor/assets/msdax-rUNN04Wq.js +6 -0
- package/editor/assets/mysql-DDwshQtU.js +6 -0
- package/editor/assets/nanoesis-logo-CgieIWPg.png +0 -0
- package/editor/assets/objective-c-B5zXfXm9.js +6 -0
- package/editor/assets/pascal-CXOwvkN_.js +6 -0
- package/editor/assets/pascaligo-Bc-ZgV77.js +6 -0
- package/editor/assets/perl-CwNk8-XU.js +6 -0
- package/editor/assets/pgsql-tGk8EFnU.js +6 -0
- package/editor/assets/php-CpIb_Oan.js +6 -0
- package/editor/assets/pla-B03wrqEc.js +6 -0
- package/editor/assets/postiats-BKlk5iyT.js +6 -0
- package/editor/assets/powerquery-Bhzvs7bI.js +6 -0
- package/editor/assets/powershell-Dd3NCNK9.js +6 -0
- package/editor/assets/protobuf-COyEY5Pt.js +7 -0
- package/editor/assets/pug-BaJupSGV.js +6 -0
- package/editor/assets/python-CuJlk8g3.js +6 -0
- package/editor/assets/qsharp-DXyYeYxl.js +6 -0
- package/editor/assets/r-CdQndTaG.js +6 -0
- package/editor/assets/razor-CuQT_1Ku.js +6 -0
- package/editor/assets/redis-CVwtpugi.js +6 -0
- package/editor/assets/redshift-25W9uPmb.js +6 -0
- package/editor/assets/restructuredtext-DfzH4Xui.js +6 -0
- package/editor/assets/ruby-Cp1zYvxS.js +6 -0
- package/editor/assets/rust-D5C2fndG.js +6 -0
- package/editor/assets/sb-CDntyWJ8.js +6 -0
- package/editor/assets/scala-BoFRg7Ot.js +6 -0
- package/editor/assets/scheme-Bio4gycK.js +6 -0
- package/editor/assets/scss-4Ik7cdeQ.js +8 -0
- package/editor/assets/shell-CX-rkNHf.js +6 -0
- package/editor/assets/solidity-Tw7wswEv.js +6 -0
- package/editor/assets/sophia-C5WLch3f.js +6 -0
- package/editor/assets/sparql-DHaeiCBh.js +6 -0
- package/editor/assets/sql-CCSDG5nI.js +6 -0
- package/editor/assets/st-pnP8ivHi.js +6 -0
- package/editor/assets/swift-DwJ7jVG9.js +8 -0
- package/editor/assets/systemverilog-B9Xyijhd.js +6 -0
- package/editor/assets/tcl-DnHyzjbg.js +6 -0
- package/editor/assets/ts.worker-BhkL8olL.js +51334 -0
- package/editor/assets/tsMode-CT2HUNtN.js +16 -0
- package/editor/assets/twig-CPajHgWi.js +6 -0
- package/editor/assets/typescript-CtMx97cn.js +6 -0
- package/editor/assets/typespec-D-MeaMDU.js +6 -0
- package/editor/assets/vb-DgyLZaXg.js +6 -0
- package/editor/assets/wgsl-BIv9DU6q.js +303 -0
- package/editor/assets/xml-CyfpINj_.js +6 -0
- package/editor/assets/yaml-BBWmgfMA.js +6 -0
- package/editor/config.json +3 -0
- package/editor/index.html +28 -0
- package/package.json +85 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// ../../adapters/shell/src/shell-prebuild.ts
|
|
2
|
+
import { spawn } from "child_process";
|
|
3
|
+
var defaultSpawner = (command, { cwd, env }) => new Promise((resolve, reject) => {
|
|
4
|
+
const child = spawn(command, { cwd, env, shell: true, stdio: "inherit" });
|
|
5
|
+
child.once("error", reject);
|
|
6
|
+
child.once("close", (code) => {
|
|
7
|
+
resolve(code);
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
var ShellPreBuildHook = class {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.spawnFn = config.spawn ?? defaultSpawner;
|
|
14
|
+
}
|
|
15
|
+
config;
|
|
16
|
+
spawnFn;
|
|
17
|
+
async run() {
|
|
18
|
+
const code = await this.spawnFn(this.config.command, {
|
|
19
|
+
cwd: this.config.cwd,
|
|
20
|
+
env: this.config.env ?? process.env
|
|
21
|
+
});
|
|
22
|
+
if (code !== 0) {
|
|
23
|
+
throw new Error(
|
|
24
|
+
`prebuild "${this.config.command}" exited with code ${code ?? "null (signal)"}`
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// ../../adapters/shell/src/site-config.ts
|
|
31
|
+
import { readFile } from "fs/promises";
|
|
32
|
+
import { join } from "path";
|
|
33
|
+
async function readPrebuildCommand(siteDir) {
|
|
34
|
+
let raw;
|
|
35
|
+
try {
|
|
36
|
+
raw = await readFile(join(siteDir, "package.json"), "utf8");
|
|
37
|
+
} catch {
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
const text = raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw;
|
|
41
|
+
let pkg;
|
|
42
|
+
try {
|
|
43
|
+
pkg = JSON.parse(text);
|
|
44
|
+
} catch {
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
if (typeof pkg !== "object" || pkg === null) return void 0;
|
|
48
|
+
const nano = pkg["nanoesis"];
|
|
49
|
+
if (typeof nano !== "object" || nano === null) return void 0;
|
|
50
|
+
const cmd = nano["prebuild"];
|
|
51
|
+
return typeof cmd === "string" && cmd.trim() !== "" ? cmd : void 0;
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
ShellPreBuildHook,
|
|
55
|
+
readPrebuildCommand
|
|
56
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { IdentityProvider } from '@nanoesis/engine';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for {@link trustedHeaderIdentity}. Every header name is overridable so
|
|
5
|
+
* the same adapter handles standard reverse-proxy headers (oauth2-proxy, Authentik,
|
|
6
|
+
* Keycloak, Traefik forwardAuth) and named-header gateways alike. Defaults to the
|
|
7
|
+
* widely-used `X-Forwarded-User` / `X-Forwarded-Email` / `X-Forwarded-Roles`.
|
|
8
|
+
*
|
|
9
|
+
* For Easy Auth, point `userIdHeader` at `X-MS-Client-Principal-Name` (or `-Id`) and
|
|
10
|
+
* either set `rolesHeader` to a header the gateway exposes, or front the app with
|
|
11
|
+
* something that translates Easy Auth's base64 JSON principal into standard headers.
|
|
12
|
+
* For Cloudflare Access, `Cf-Access-Authenticated-User-Email` works as either userId
|
|
13
|
+
* or email, set the same header for both if you want.
|
|
14
|
+
*/
|
|
15
|
+
interface TrustedHeaderConfig {
|
|
16
|
+
/** Header carrying the user identifier (also used as the display handle). Default: `X-Forwarded-User`. */
|
|
17
|
+
readonly userIdHeader?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Header carrying the roles as a comma-separated list (case-insensitive). Roles
|
|
20
|
+
* outside the known set (`author`, `developer`, `admin`) are dropped, defence in
|
|
21
|
+
* depth, the gateway is the authority on what counts as a real role. Default:
|
|
22
|
+
* `X-Forwarded-Roles`.
|
|
23
|
+
*/
|
|
24
|
+
readonly rolesHeader?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A trusted-header {@link IdentityProvider} (DESIGN §11, the recommended production
|
|
28
|
+
* path). An upstream gateway (Easy Auth, Cloudflare Access, oauth2-proxy, Authentik,
|
|
29
|
+
* Keycloak) does the actual authentication and forwards the result as request
|
|
30
|
+
* headers; nanoesis trusts those headers **because the host is only reachable
|
|
31
|
+
* through that gateway**.
|
|
32
|
+
*
|
|
33
|
+
* No login code, no session storage, no password handling, every one of those is the
|
|
34
|
+
* gateway's job. A missing or empty userId header resolves to anonymous (null), at
|
|
35
|
+
* which point the host's role policy denies the editing routes.
|
|
36
|
+
*
|
|
37
|
+
* **Operational guarantee:** if requests can reach the host without going through the
|
|
38
|
+
* gateway, this provider is unsafe (a client can forge the headers). This is true of
|
|
39
|
+
* every trusted-header scheme, not specific to this implementation.
|
|
40
|
+
*/
|
|
41
|
+
declare function trustedHeaderIdentity(config?: TrustedHeaderConfig): IdentityProvider;
|
|
42
|
+
|
|
43
|
+
export { type TrustedHeaderConfig, trustedHeaderIdentity };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// ../../adapters/trusted-header/src/trusted-header.ts
|
|
2
|
+
var KNOWN_ROLES = /* @__PURE__ */ new Set(["author", "developer", "admin"]);
|
|
3
|
+
function isRole(value) {
|
|
4
|
+
return KNOWN_ROLES.has(value);
|
|
5
|
+
}
|
|
6
|
+
function trustedHeaderIdentity(config = {}) {
|
|
7
|
+
const userIdHeader = config.userIdHeader ?? "X-Forwarded-User";
|
|
8
|
+
const rolesHeader = config.rolesHeader ?? "X-Forwarded-Roles";
|
|
9
|
+
return {
|
|
10
|
+
async authenticate(getHeader) {
|
|
11
|
+
const userId = getHeader(userIdHeader);
|
|
12
|
+
if (userId === void 0 || userId === "") return null;
|
|
13
|
+
const rolesRaw = getHeader(rolesHeader) ?? "";
|
|
14
|
+
const roles = rolesRaw.split(",").map((r) => r.trim().toLowerCase()).filter(isRole);
|
|
15
|
+
return { userId, username: userId, roles };
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
trustedHeaderIdentity
|
|
21
|
+
};
|