@wizzlethorpe/vaults 0.6.1 → 0.8.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/README.md +135 -17
- package/dist/build.js +433 -181
- package/dist/build.js.map +1 -1
- package/dist/commands/build.js +4 -4
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/init.js +13 -10
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/password.js +3 -1
- package/dist/commands/password.js.map +1 -1
- package/dist/commands/patreon.js +30 -20
- package/dist/commands/patreon.js.map +1 -1
- package/dist/commands/preview.js +10 -8
- package/dist/commands/preview.js.map +1 -1
- package/dist/commands/push.js +11 -9
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/role.js +5 -0
- package/dist/commands/role.js.map +1 -1
- package/dist/config.js +30 -15
- package/dist/config.js.map +1 -1
- package/dist/escape.js +29 -0
- package/dist/escape.js.map +1 -0
- package/dist/favicon.js +3 -36
- package/dist/favicon.js.map +1 -1
- package/dist/foundry-importer.js +61 -0
- package/dist/foundry-importer.js.map +1 -0
- package/dist/images.js +0 -30
- package/dist/images.js.map +1 -1
- package/dist/index.js +37 -4
- package/dist/index.js.map +1 -1
- package/dist/migrate/0.6-legacy-auth-settings.js +96 -0
- package/dist/migrate/0.6-legacy-auth-settings.js.map +1 -0
- package/dist/migrate/0.7-vaults-dir.js +70 -0
- package/dist/migrate/0.7-vaults-dir.js.map +1 -0
- package/dist/migrate/registry.js +6 -0
- package/dist/migrate/registry.js.map +1 -0
- package/dist/migrate/run.js +38 -0
- package/dist/migrate/run.js.map +1 -0
- package/dist/migrate/types.js +8 -0
- package/dist/migrate/types.js.map +1 -0
- package/dist/paths.js +66 -0
- package/dist/paths.js.map +1 -0
- package/dist/render/auth-template.js +23 -141
- package/dist/render/auth-template.js.map +1 -1
- package/dist/render/bases.js +56 -44
- package/dist/render/bases.js.map +1 -1
- package/dist/render/callouts.js +29 -10
- package/dist/render/callouts.js.map +1 -1
- package/dist/render/embed.js +124 -26
- package/dist/render/embed.js.map +1 -1
- package/dist/render/extensions.js +68 -0
- package/dist/render/extensions.js.map +1 -0
- package/dist/render/external-links.js +32 -0
- package/dist/render/external-links.js.map +1 -0
- package/dist/render/footer.js +37 -0
- package/dist/render/footer.js.map +1 -0
- package/dist/render/frontmatter.js +17 -0
- package/dist/render/frontmatter.js.map +1 -0
- package/dist/render/handlers/assets.js +123 -0
- package/dist/render/handlers/assets.js.map +1 -0
- package/dist/render/handlers/builtin/dice.js +78 -0
- package/dist/render/handlers/builtin/dice.js.map +1 -0
- package/dist/render/handlers/builtin/fm-code.js +50 -0
- package/dist/render/handlers/builtin/fm-code.js.map +1 -0
- package/dist/render/handlers/builtin/fm.js +83 -0
- package/dist/render/handlers/builtin/fm.js.map +1 -0
- package/dist/render/handlers/builtin/index.js +10 -0
- package/dist/render/handlers/builtin/index.js.map +1 -0
- package/dist/render/handlers/builtin/inline-format.js +26 -0
- package/dist/render/handlers/builtin/inline-format.js.map +1 -0
- package/dist/render/handlers/builtin/statblock.js +491 -0
- package/dist/render/handlers/builtin/statblock.js.map +1 -0
- package/dist/render/handlers/dispatch.js +182 -0
- package/dist/render/handlers/dispatch.js.map +1 -0
- package/dist/render/handlers/loader.js +90 -0
- package/dist/render/handlers/loader.js.map +1 -0
- package/dist/render/handlers/types.js +60 -0
- package/dist/render/handlers/types.js.map +1 -0
- package/dist/render/image-srcs.js +42 -0
- package/dist/render/image-srcs.js.map +1 -0
- package/dist/render/layout.js +62 -9
- package/dist/render/layout.js.map +1 -1
- package/dist/render/pipeline.js +37 -8
- package/dist/render/pipeline.js.map +1 -1
- package/dist/render/preview.js +10 -5
- package/dist/render/preview.js.map +1 -1
- package/dist/render/slug.js +5 -0
- package/dist/render/slug.js.map +1 -1
- package/dist/render/styles.js +118 -11
- package/dist/render/styles.js.map +1 -1
- package/dist/render/wikilink.js +15 -4
- package/dist/render/wikilink.js.map +1 -1
- package/dist/scan.js +1 -1
- package/dist/scan.js.map +1 -1
- package/dist/settings.js +25 -4
- package/dist/settings.js.map +1 -1
- package/dist/version.js +36 -0
- package/dist/version.js.map +1 -0
- package/package.json +12 -12
- package/dist/api.js +0 -42
- package/dist/api.js.map +0 -1
- package/dist/render/mcp-template.js +0 -239
- package/dist/render/mcp-template.js.map +0 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE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,MAAM,CAAC,iBAAiB,EAAE,iEAAiE,CAAC;KAC5F,MAAM,CAAC,gBAAgB,EAAE,4DAA4D,CAAC;KACtF,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAEtB,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACjC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC;AAEH,SAAS,IAAI,CAAgD,EAAK;IAChE,OAAO,KAAK,EAAE,GAAG,IAAmB,EAAE,EAAE;QACtC,IAAI,CAAC;YACH,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QACpB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACxD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Migration: copy legacy auth fields out of settings.md frontmatter into
|
|
2
|
+
// the CLI-managed config (formerly .vaultrc.json, now .vaults/config.json).
|
|
3
|
+
//
|
|
4
|
+
// Earlier versions stored `roles`, `auth_type`, and `role_passwords` in
|
|
5
|
+
// settings.md. The settings canonicaliser strips unknown keys, so if we
|
|
6
|
+
// don't lift them out before settings.md is rewritten, they're silently
|
|
7
|
+
// dropped. This migration copies anything we still see in settings.md
|
|
8
|
+
// over to the config — but only when the destination is empty / default,
|
|
9
|
+
// so re-running on an already-migrated vault is a no-op.
|
|
10
|
+
//
|
|
11
|
+
// This was previously inline in build.ts as migrateLegacyAuthFromSettings();
|
|
12
|
+
// moved here so all migrations live in one registry.
|
|
13
|
+
import { readFile } from "node:fs/promises";
|
|
14
|
+
import { join } from "node:path";
|
|
15
|
+
import matter from "gray-matter";
|
|
16
|
+
import { loadConfig, saveConfig } from "../config.js";
|
|
17
|
+
import { SETTINGS_FILE } from "../paths.js";
|
|
18
|
+
export const legacyAuthSettingsMigration = {
|
|
19
|
+
id: "0.6-legacy-auth-settings",
|
|
20
|
+
description: "settings.md roles/auth_type/role_passwords → CLI-managed config",
|
|
21
|
+
async needs(vaultPath) {
|
|
22
|
+
const fm = await readSettingsFrontmatter(vaultPath);
|
|
23
|
+
if (!fm)
|
|
24
|
+
return false;
|
|
25
|
+
if (!hasAnyLegacyKey(fm))
|
|
26
|
+
return false;
|
|
27
|
+
const cfg = await loadConfig(vaultPath, {});
|
|
28
|
+
return liftLegacyAuth(fm, cfg, { dryRun: true }).length > 0;
|
|
29
|
+
},
|
|
30
|
+
async apply(vaultPath) {
|
|
31
|
+
const fm = await readSettingsFrontmatter(vaultPath);
|
|
32
|
+
if (!fm)
|
|
33
|
+
return;
|
|
34
|
+
const cfg = await loadConfig(vaultPath, {});
|
|
35
|
+
const moved = liftLegacyAuth(fm, cfg, { dryRun: false });
|
|
36
|
+
if (moved.length === 0)
|
|
37
|
+
return;
|
|
38
|
+
await saveConfig(vaultPath, cfg);
|
|
39
|
+
console.log(` moved ${moved.join(", ")} from settings.md → config`);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
async function readSettingsFrontmatter(vaultPath) {
|
|
43
|
+
try {
|
|
44
|
+
const raw = await readFile(join(vaultPath, SETTINGS_FILE), "utf8");
|
|
45
|
+
return (matter(raw).data ?? {});
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function hasAnyLegacyKey(fm) {
|
|
52
|
+
return "roles" in fm || "auth_type" in fm || "role_passwords" in fm;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Single source of truth for which legacy fields qualify for lift, what
|
|
56
|
+
* they get moved to, and (when `dryRun=false`) the actual mutation.
|
|
57
|
+
*
|
|
58
|
+
* Returns the names of fields that qualified (= would move when not a dry
|
|
59
|
+
* run). `needs()` runs this dry; `apply()` runs it for real.
|
|
60
|
+
*/
|
|
61
|
+
function liftLegacyAuth(fm, cfg, opts) {
|
|
62
|
+
const moved = [];
|
|
63
|
+
if (Array.isArray(fm.roles)) {
|
|
64
|
+
const list = fm.roles.filter((r) => typeof r === "string");
|
|
65
|
+
const isDefault = cfg.roles.length === 0 || (cfg.roles.length === 1 && cfg.roles[0] === "public");
|
|
66
|
+
if (list.length > 0 && isDefault && !arraysEqual(list, ["public"])) {
|
|
67
|
+
if (!opts.dryRun)
|
|
68
|
+
cfg.roles = list;
|
|
69
|
+
moved.push("roles");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
// `auth_type` was a forward-looking knob (password vs cloudflare-access vs
|
|
73
|
+
// oauth-jwt) that nothing has ever read. The field was removed from
|
|
74
|
+
// VaultConfig; lifting it would be a no-op, so we don't bother.
|
|
75
|
+
if (fm.role_passwords && typeof fm.role_passwords === "object" && !Array.isArray(fm.role_passwords)
|
|
76
|
+
&& Object.keys(cfg.rolePasswords).length === 0) {
|
|
77
|
+
const cleaned = filterStringValues(fm.role_passwords);
|
|
78
|
+
if (Object.keys(cleaned).length > 0) {
|
|
79
|
+
if (!opts.dryRun)
|
|
80
|
+
cfg.rolePasswords = cleaned;
|
|
81
|
+
moved.push("role_passwords");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return moved;
|
|
85
|
+
}
|
|
86
|
+
function filterStringValues(map) {
|
|
87
|
+
const out = {};
|
|
88
|
+
for (const [k, v] of Object.entries(map))
|
|
89
|
+
if (typeof v === "string")
|
|
90
|
+
out[k] = v;
|
|
91
|
+
return out;
|
|
92
|
+
}
|
|
93
|
+
function arraysEqual(a, b) {
|
|
94
|
+
return a.length === b.length && a.every((x, i) => x === b[i]);
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=0.6-legacy-auth-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0.6-legacy-auth-settings.js","sourceRoot":"","sources":["../../src/migrate/0.6-legacy-auth-settings.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,4EAA4E;AAC5E,EAAE;AACF,wEAAwE;AACxE,wEAAwE;AACxE,wEAAwE;AACxE,sEAAsE;AACtE,yEAAyE;AACzE,yDAAyD;AACzD,EAAE;AACF,6EAA6E;AAC7E,qDAAqD;AAErD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,MAAM,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAoB,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,2BAA2B,GAAc;IACpD,EAAE,EAAE,0BAA0B;IAC9B,WAAW,EAAE,iEAAiE;IAE9E,KAAK,CAAC,KAAK,CAAC,SAAiB;QAC3B,MAAM,EAAE,GAAG,MAAM,uBAAuB,CAAC,SAAS,CAAC,CAAC;QACpD,IAAI,CAAC,EAAE;YAAE,OAAO,KAAK,CAAC;QACtB,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YAAE,OAAO,KAAK,CAAC;QACvC,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAC5C,OAAO,cAAc,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,SAAiB;QAC3B,MAAM,EAAE,GAAG,MAAM,uBAAuB,CAAC,SAAS,CAAC,CAAC;QACpD,IAAI,CAAC,EAAE;YAAE,OAAO;QAChB,MAAM,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CAAC;IAChF,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,WAAW,CAAC,CAAY,EAAE,CAAY;IAC7C,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAChE,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Migration: consolidate vaults-cli internals into .vaults/.
|
|
2
|
+
//
|
|
3
|
+
// .vaultrc.json → .vaults/config.json
|
|
4
|
+
// .vault-cache/ → .vaults/cache/
|
|
5
|
+
//
|
|
6
|
+
// Also writes .vaults/.gitignore so the cache + config (the latter holds
|
|
7
|
+
// hashed passwords and session secret pointers) stay out of git when the
|
|
8
|
+
// vault later becomes a git repo.
|
|
9
|
+
//
|
|
10
|
+
// settings.md stays at the vault root: it's user-edited from Obsidian, and
|
|
11
|
+
// dotfolders are hidden from Obsidian's file pane by default.
|
|
12
|
+
import { mkdir, rename, stat, writeFile } from "node:fs/promises";
|
|
13
|
+
import { dirname } from "node:path";
|
|
14
|
+
import { configPath, cacheDir, vaultsGitignore, legacyConfigPath, legacyCacheDir, CACHE_DIR, CONFIG_FILE, } from "../paths.js";
|
|
15
|
+
export const vaultsDirMigration = {
|
|
16
|
+
id: "0.7-vaults-dir",
|
|
17
|
+
description: ".vaultrc.json → .vaults/config.json, .vault-cache/ → .vaults/cache/",
|
|
18
|
+
async needs(vaultPath) {
|
|
19
|
+
return (await exists(legacyConfigPath(vaultPath))) || (await exists(legacyCacheDir(vaultPath)));
|
|
20
|
+
},
|
|
21
|
+
async apply(vaultPath) {
|
|
22
|
+
const newConfig = configPath(vaultPath);
|
|
23
|
+
const newCache = cacheDir(vaultPath);
|
|
24
|
+
await mkdir(dirname(newConfig), { recursive: true });
|
|
25
|
+
if (await exists(legacyConfigPath(vaultPath))) {
|
|
26
|
+
// Skip move if dest already exists; the legacy file is then likely
|
|
27
|
+
// a leftover the user can delete by hand.
|
|
28
|
+
if (!(await exists(newConfig))) {
|
|
29
|
+
await rename(legacyConfigPath(vaultPath), newConfig);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (await exists(legacyCacheDir(vaultPath))) {
|
|
33
|
+
if (!(await exists(newCache))) {
|
|
34
|
+
await rename(legacyCacheDir(vaultPath), newCache);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
await ensureVaultsGitignore(vaultPath);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Write a default .vaults/.gitignore if one doesn't already exist. Listed
|
|
42
|
+
* from .vaults/ so the entries are relative — works whether or not the
|
|
43
|
+
* containing vault is a git repo.
|
|
44
|
+
*/
|
|
45
|
+
export async function ensureVaultsGitignore(vaultPath) {
|
|
46
|
+
const path = vaultsGitignore(vaultPath);
|
|
47
|
+
if (await exists(path))
|
|
48
|
+
return;
|
|
49
|
+
const lines = [
|
|
50
|
+
"# vaults-cli internal state — do not edit by hand.",
|
|
51
|
+
"# These entries are forward-compat: if this vault becomes a git repo,",
|
|
52
|
+
"# the cache and config (which holds hashed passwords) stay out.",
|
|
53
|
+
`${CACHE_DIR}/`,
|
|
54
|
+
CONFIG_FILE,
|
|
55
|
+
"",
|
|
56
|
+
].join("\n");
|
|
57
|
+
await writeFile(path, lines);
|
|
58
|
+
}
|
|
59
|
+
async function exists(path) {
|
|
60
|
+
try {
|
|
61
|
+
await stat(path);
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
catch (err) {
|
|
65
|
+
if (err.code === "ENOENT")
|
|
66
|
+
return false;
|
|
67
|
+
throw err;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=0.7-vaults-dir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0.7-vaults-dir.js","sourceRoot":"","sources":["../../src/migrate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AC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Migration orchestrator. Walks the registry, runs each migration whose
|
|
2
|
+
// needs() returns true, and reports what happened.
|
|
3
|
+
//
|
|
4
|
+
// Called automatically at the top of every command that touches a vault.
|
|
5
|
+
// Migrations are designed to be cheap to skip (stat a file, compare two
|
|
6
|
+
// strings) so the overhead on already-migrated vaults is negligible.
|
|
7
|
+
import { MIGRATIONS } from "./registry.js";
|
|
8
|
+
export async function runMigrations(vaultPath, opts = {}) {
|
|
9
|
+
const candidates = opts.only
|
|
10
|
+
? MIGRATIONS.filter((m) => m.id === opts.only)
|
|
11
|
+
: MIGRATIONS;
|
|
12
|
+
if (opts.only && candidates.length === 0) {
|
|
13
|
+
throw new Error(`unknown migration id: ${opts.only}`);
|
|
14
|
+
}
|
|
15
|
+
const applied = [];
|
|
16
|
+
const skipped = [];
|
|
17
|
+
for (const m of candidates) {
|
|
18
|
+
if (!(await m.needs(vaultPath))) {
|
|
19
|
+
skipped.push(m.id);
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (opts.dryRun) {
|
|
23
|
+
if (!opts.silent)
|
|
24
|
+
console.log(` would migrate: ${m.id} — ${m.description}`);
|
|
25
|
+
applied.push(m.id);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
if (!opts.silent)
|
|
29
|
+
console.log(` migrating: ${m.id} — ${m.description}`);
|
|
30
|
+
await m.apply(vaultPath);
|
|
31
|
+
applied.push(m.id);
|
|
32
|
+
}
|
|
33
|
+
return { applied, skipped };
|
|
34
|
+
}
|
|
35
|
+
export function listMigrations() {
|
|
36
|
+
return MIGRATIONS;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=run.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/migrate/run.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,mDAAmD;AACnD,EAAE;AACF,yEAAyE;AACzE,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C,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACrB,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Migration framework: stateless, idempotent, forward-only schema and
|
|
2
|
+
// layout migrations for vaults.
|
|
3
|
+
//
|
|
4
|
+
// Each migration knows how to detect (from on-disk reality) whether it
|
|
5
|
+
// still needs to apply, and how to apply itself. Running a migration twice
|
|
6
|
+
// is a no-op. There is no version file: needs() reads the disk directly.
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/migrate/types.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,gCAAgC;AAChC,EAAE;AACF,uEAAuE;AACvE,2EAA2E;AAC3E,yEAAyE"}
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Centralised vault-internal path constants.
|
|
2
|
+
//
|
|
3
|
+
// The single source of truth for where vaults-cli keeps its own state
|
|
4
|
+
// inside a vault. Migrations rely on these to move files from old to new
|
|
5
|
+
// locations; runtime code should always use the helpers below rather than
|
|
6
|
+
// hardcoding strings.
|
|
7
|
+
import { stat } from "node:fs/promises";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
/** Top-level dotfolder owning all vaults-cli state. */
|
|
10
|
+
export const VAULTS_DIR = ".vaults";
|
|
11
|
+
/** Settings.md stays at the vault root (Obsidian-editable). */
|
|
12
|
+
export const SETTINGS_FILE = "settings.md";
|
|
13
|
+
/** Config (CLI-managed: roles, password hashes, project name, patreon, …). */
|
|
14
|
+
export const CONFIG_FILE = "config.json";
|
|
15
|
+
/** Build artifact directory (rendered HTML, image webp cache). */
|
|
16
|
+
export const CACHE_DIR = "cache";
|
|
17
|
+
/** Internal .gitignore so cache + secrets stay out of git when the vault becomes a git repo. */
|
|
18
|
+
export const VAULTS_GITIGNORE = ".gitignore";
|
|
19
|
+
/** Fully-qualified config file path. */
|
|
20
|
+
export function configPath(vaultPath) {
|
|
21
|
+
return join(vaultPath, VAULTS_DIR, CONFIG_FILE);
|
|
22
|
+
}
|
|
23
|
+
/** Fully-qualified cache directory path. */
|
|
24
|
+
export function cacheDir(vaultPath) {
|
|
25
|
+
return join(vaultPath, VAULTS_DIR, CACHE_DIR);
|
|
26
|
+
}
|
|
27
|
+
/** Fully-qualified rendered output directory (default for build/preview/push). */
|
|
28
|
+
export function defaultOutputDir(vaultPath) {
|
|
29
|
+
return join(cacheDir(vaultPath), "rendered");
|
|
30
|
+
}
|
|
31
|
+
/** Fully-qualified .vaults/.gitignore path. */
|
|
32
|
+
export function vaultsGitignore(vaultPath) {
|
|
33
|
+
return join(vaultPath, VAULTS_DIR, VAULTS_GITIGNORE);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Throw with a friendly error if `vaultPath` doesn't look like an
|
|
37
|
+
* initialised vault. The marker is `settings.md` at the vault root —
|
|
38
|
+
* `vaults init` writes it; the rest of the CLI (build / preview / push /
|
|
39
|
+
* role / patreon / password) reads it.
|
|
40
|
+
*
|
|
41
|
+
* Catches the common confused-cwd case — `vaults preview` from $HOME or
|
|
42
|
+
* a parent directory — with a clear next step instead of an opaque
|
|
43
|
+
* "wrangler exited 1" / blank build a few seconds later.
|
|
44
|
+
*/
|
|
45
|
+
export async function requireInitialisedVault(vaultPath) {
|
|
46
|
+
const marker = join(vaultPath, SETTINGS_FILE);
|
|
47
|
+
try {
|
|
48
|
+
await stat(marker);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new Error(`Not a vaults-initialised directory: ${vaultPath}\n` +
|
|
52
|
+
`Missing ${SETTINGS_FILE}. Run \`vaults init\` here first, or pass the vault path as the first argument.`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// ── Legacy paths (pre-migration) ─────────────────────────────────────────
|
|
56
|
+
// Kept exported so migrations can detect old layouts and move files.
|
|
57
|
+
// Runtime code must NOT read from these.
|
|
58
|
+
export const LEGACY_CONFIG_FILE = ".vaultrc.json";
|
|
59
|
+
export const LEGACY_CACHE_DIR = ".vault-cache";
|
|
60
|
+
export function legacyConfigPath(vaultPath) {
|
|
61
|
+
return join(vaultPath, LEGACY_CONFIG_FILE);
|
|
62
|
+
}
|
|
63
|
+
export function legacyCacheDir(vaultPath) {
|
|
64
|
+
return join(vaultPath, LEGACY_CACHE_DIR);
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,yEAAyE;AACzE,0EAA0E;AAC1E,sBAAsB;AAEtB,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,uDAAuD;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC;AAEpC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CAAC;AAE3C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AAEzC,kEAAkE;AAClE,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AAEjC,gGAAgG;AAChG,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAE7C,wCAAwC;AACxC,MAAM,UAAU,UAAU,CAAC,SAAiB;IAC1C,OAAO,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AAClD,CAAC;AAED,4CAA4C;AAC5C,MAAM,UAAU,QAAQ,CAAC,SAAiB;IACxC,OAAO,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AAChD,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,OAAO,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,CAAC,CAAC;AAC/C,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,OAAO,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC;AACvD,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAAC,SAAiB;IAC7D,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;IAC9C,IAAI,CAAC;QAAC,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC;IAAC,CAAC;IAC3B,MAAM,CAAC;QACL,MAAM,IAAI,KAAK,CACb,uCAAuC,SAAS,IAAI;YACpD,WAAW,aAAa,iFAAiF,CAC1G,CAAC;IACJ,CAAC;AACH,CAAC;AAED,4EAA4E;AAC5E,qEAAqE;AACrE,yCAAyC;AAEzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAClD,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAE/C,MAAM,UAAU,gBAAgB,CAAC,SAAiB;IAChD,OAAO,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C,OAAO,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -321,19 +321,7 @@ function encodeVariantPath(p) {
|
|
|
321
321
|
|
|
322
322
|
async function handleConnectGet(request, env) {
|
|
323
323
|
const url = new URL(request.url);
|
|
324
|
-
const returnTo = url.searchParams.get("return_to") || "";
|
|
325
324
|
const app = url.searchParams.get("app") || "an external app";
|
|
326
|
-
const state = url.searchParams.get("state") || "";
|
|
327
|
-
const delivery = url.searchParams.get("delivery") === "copy" ? "copy" : "redirect";
|
|
328
|
-
|
|
329
|
-
// The "redirect" delivery mode (legacy iframe/popup flow) round-trips a
|
|
330
|
-
// token to a host app via return_to. The "copy" delivery mode is the
|
|
331
|
-
// GitHub-CLI-style device flow: the user copy-pastes the token themselves,
|
|
332
|
-
// so return_to is irrelevant and Patreon login works because we're never
|
|
333
|
-
// inside an iframe.
|
|
334
|
-
if (delivery === "redirect" && (!returnTo || !isValidReturnTo(returnTo))) {
|
|
335
|
-
return new Response("Invalid or missing return_to. Must be an http(s) URL.", { status: 400 });
|
|
336
|
-
}
|
|
337
325
|
|
|
338
326
|
// Require login first; the user's role is what we're authorising.
|
|
339
327
|
const role = await readRole(request, env);
|
|
@@ -347,23 +335,14 @@ async function handleConnectGet(request, env) {
|
|
|
347
335
|
});
|
|
348
336
|
}
|
|
349
337
|
|
|
350
|
-
const
|
|
351
|
-
try { return new URL(returnTo).host; } catch { return returnTo; }
|
|
352
|
-
})();
|
|
353
|
-
const html = renderApprovePage({ app, role, returnTo, returnHost, state, delivery });
|
|
338
|
+
const html = renderApprovePage({ app, role });
|
|
354
339
|
return new Response(html, { headers: { "Content-Type": "text/html; charset=utf-8" } });
|
|
355
340
|
}
|
|
356
341
|
|
|
357
342
|
async function handleConnectApprove(request, env) {
|
|
358
343
|
const form = await request.formData();
|
|
359
|
-
const returnTo = String(form.get("return_to") || "");
|
|
360
|
-
const state = String(form.get("state") || "");
|
|
361
|
-
const delivery = String(form.get("delivery") || "") === "copy" ? "copy" : "redirect";
|
|
362
344
|
const app = String(form.get("app") || "an external app");
|
|
363
345
|
|
|
364
|
-
if (delivery === "redirect" && (!returnTo || !isValidReturnTo(returnTo))) {
|
|
365
|
-
return new Response("Invalid return_to.", { status: 400 });
|
|
366
|
-
}
|
|
367
346
|
const role = await readRole(request, env);
|
|
368
347
|
if (role === ROLES[0]) {
|
|
369
348
|
// User is anonymous; reject (shouldn't reach here via normal UI flow).
|
|
@@ -371,92 +350,14 @@ async function handleConnectApprove(request, env) {
|
|
|
371
350
|
}
|
|
372
351
|
|
|
373
352
|
const token = await signToken(role, env.SESSION_SECRET, BEARER_MAX_AGE);
|
|
374
|
-
const html =
|
|
375
|
-
? renderConnectCopyPage({ token, role, app })
|
|
376
|
-
// Legacy delivery: postMessage to parent/opener; falls back to top-
|
|
377
|
-
// level redirect with the token in the query string. Kept for any
|
|
378
|
-
// existing iframe-based clients; new clients should use delivery=copy.
|
|
379
|
-
: renderConnectDeliveryPage({ token, state, returnTo });
|
|
353
|
+
const html = renderConnectCopyPage({ token, role, app });
|
|
380
354
|
return new Response(html, { headers: { "Content-Type": "text/html; charset=utf-8" } });
|
|
381
355
|
}
|
|
382
356
|
|
|
383
|
-
function
|
|
384
|
-
const returnOrigin = (() => { try { return new URL(returnTo).origin; } catch { return ""; } })();
|
|
385
|
-
const tokenAttr = escAttr(token);
|
|
386
|
-
const stateAttr = escAttr(state);
|
|
387
|
-
const originAttr = escAttr(returnOrigin);
|
|
388
|
-
const returnAttr = escAttr(returnTo);
|
|
389
|
-
return \`<!doctype html>
|
|
390
|
-
<html lang="en">
|
|
391
|
-
<head>
|
|
392
|
-
<meta charset="utf-8">
|
|
393
|
-
<title>Connecting…</title>
|
|
394
|
-
<link rel="stylesheet" href="/styles.css">
|
|
395
|
-
<style>
|
|
396
|
-
body { display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; font-family: inherit; }
|
|
397
|
-
.card { max-width: 24rem; padding: 2rem; text-align: center; color: var(--muted); }
|
|
398
|
-
.card h1 { margin: 0 0 0.5rem; font-size: 1.1rem; color: var(--fg); }
|
|
399
|
-
.card a { color: var(--accent); }
|
|
400
|
-
</style>
|
|
401
|
-
</head>
|
|
402
|
-
<body>
|
|
403
|
-
<div class="card">
|
|
404
|
-
<h1>Authorising…</h1>
|
|
405
|
-
<p id="status">You can close this window.</p>
|
|
406
|
-
<p><a id="manual" href="#">Continue manually</a> if it doesn't close on its own.</p>
|
|
407
|
-
</div>
|
|
408
|
-
<script>
|
|
409
|
-
(function () {
|
|
410
|
-
var token = "\${tokenAttr}";
|
|
411
|
-
var state = "\${stateAttr}";
|
|
412
|
-
var origin = "\${originAttr}";
|
|
413
|
-
var returnTo = "\${returnAttr}";
|
|
414
|
-
|
|
415
|
-
// Iframe flow: parent window is the host (Foundry inside DialogV2).
|
|
416
|
-
// Popup flow: opener is the host. In both cases we postMessage to the
|
|
417
|
-
// host's origin (not '*') so the token can't be intercepted by anything
|
|
418
|
-
// else with a window reference.
|
|
419
|
-
var target = null;
|
|
420
|
-
if (window.parent && window.parent !== window) target = window.parent;
|
|
421
|
-
else if (window.opener && !window.opener.closed) target = window.opener;
|
|
422
|
-
if (target && origin) {
|
|
423
|
-
try {
|
|
424
|
-
target.postMessage({ type: "vaults-connect", token: token, state: state }, origin);
|
|
425
|
-
// Popup self-closes; iframe is dismissed by the host on receipt.
|
|
426
|
-
if (target === window.opener) { try { window.close(); } catch (e) {} }
|
|
427
|
-
return;
|
|
428
|
-
} catch (e) { /* fall through to redirect */ }
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// No parent or opener; fall back to the original redirect flow.
|
|
432
|
-
var sep = returnTo.indexOf("?") === -1 ? "?" : "&";
|
|
433
|
-
var target = returnTo + sep + "token=" + encodeURIComponent(token)
|
|
434
|
-
+ (state ? "&state=" + encodeURIComponent(state) : "");
|
|
435
|
-
document.getElementById("manual").href = target;
|
|
436
|
-
document.getElementById("status").textContent = "Redirecting back…";
|
|
437
|
-
window.location.replace(target);
|
|
438
|
-
})();
|
|
439
|
-
</script>
|
|
440
|
-
</body>
|
|
441
|
-
</html>\`;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
function isValidReturnTo(s) {
|
|
445
|
-
try {
|
|
446
|
-
const u = new URL(s);
|
|
447
|
-
return u.protocol === "http:" || u.protocol === "https:";
|
|
448
|
-
} catch { return false; }
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
function renderApprovePage({ app, role, returnTo, returnHost, state, delivery }) {
|
|
357
|
+
function renderApprovePage({ app, role }) {
|
|
452
358
|
const escapedApp = escHtml(app);
|
|
453
359
|
const escapedRole = escHtml(role);
|
|
454
|
-
const escapedHost = escHtml(returnHost);
|
|
455
|
-
const escapedReturnTo = escAttr(returnTo);
|
|
456
|
-
const escapedState = escAttr(state);
|
|
457
|
-
const escapedDelivery = escAttr(delivery);
|
|
458
360
|
const escapedAppAttr = escAttr(app);
|
|
459
|
-
const isCopy = delivery === "copy";
|
|
460
361
|
return \`<!doctype html>
|
|
461
362
|
<html lang="en">
|
|
462
363
|
<head>
|
|
@@ -473,13 +374,6 @@ function renderApprovePage({ app, role, returnTo, returnHost, state, delivery })
|
|
|
473
374
|
.approve-card h1 { margin: 0 0 1rem; font-size: 1.4rem; }
|
|
474
375
|
.approve-card .info { color: var(--muted); font-size: 0.9rem; margin: 0 0 0.75rem; }
|
|
475
376
|
.approve-card .info strong { color: var(--accent); }
|
|
476
|
-
.approve-card .return-host {
|
|
477
|
-
display: block; margin: 0.75rem 0 1.25rem;
|
|
478
|
-
padding: 0.5rem 0.75rem; background: var(--wikilink-bg);
|
|
479
|
-
border: 1px solid var(--rule); border-radius: 4px;
|
|
480
|
-
font-family: ui-monospace, monospace; font-size: 0.85rem;
|
|
481
|
-
word-break: break-all;
|
|
482
|
-
}
|
|
483
377
|
.approve-card .actions { display: flex; gap: 0.75rem; margin-top: 1.25rem; }
|
|
484
378
|
.approve-card button, .approve-card .deny {
|
|
485
379
|
flex: 1; padding: 0.55rem 1rem; font: inherit; font-size: 0.95rem;
|
|
@@ -488,7 +382,6 @@ function renderApprovePage({ app, role, returnTo, returnHost, state, delivery })
|
|
|
488
382
|
}
|
|
489
383
|
.approve-card button { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
|
|
490
384
|
.approve-card .deny { background: var(--bg); color: var(--muted); }
|
|
491
|
-
.approve-card .warning { color: #b94a3a; font-size: 0.78rem; margin-top: 1rem; }
|
|
492
385
|
</style>
|
|
493
386
|
</head>
|
|
494
387
|
<body>
|
|
@@ -498,14 +391,7 @@ function renderApprovePage({ app, role, returnTo, returnHost, state, delivery })
|
|
|
498
391
|
<strong>\${escapedApp}</strong> wants access to your vault as
|
|
499
392
|
<strong>\${escapedRole}</strong>.
|
|
500
393
|
</p>
|
|
501
|
-
|
|
502
|
-
? \`<p class="info">After approval, this page will display a token to copy and paste back into <strong>\${escapedApp}</strong>.</p>\`
|
|
503
|
-
: \`<p class="info">After approval, you'll be redirected to:</p>
|
|
504
|
-
<code class="return-host">\${escapedHost}</code>
|
|
505
|
-
<p class="warning">⚠ Verify the destination above looks right. If you didn't initiate this request, click Deny.</p>\`}
|
|
506
|
-
<input type="hidden" name="return_to" value="\${escapedReturnTo}">
|
|
507
|
-
<input type="hidden" name="state" value="\${escapedState}">
|
|
508
|
-
<input type="hidden" name="delivery" value="\${escapedDelivery}">
|
|
394
|
+
<p class="info">After approval, this page will display a token to copy and paste back into <strong>\${escapedApp}</strong>.</p>
|
|
509
395
|
<input type="hidden" name="app" value="\${escapedAppAttr}">
|
|
510
396
|
<div class="actions">
|
|
511
397
|
<a class="deny" href="/">Deny</a>
|
|
@@ -598,6 +484,12 @@ function renderConnectCopyPage({ token, role, app }) {
|
|
|
598
484
|
</html>\`;
|
|
599
485
|
}
|
|
600
486
|
|
|
487
|
+
// These two helpers are intentionally inline and not imported: this file
|
|
488
|
+
// generates a Cloudflare Pages Function as a string template, so the
|
|
489
|
+
// emitted worker can't \`import\` from cli/src/escape.ts at runtime. Keep the
|
|
490
|
+
// behaviour in sync with the canonical helpers in cli/src/escape.ts; the
|
|
491
|
+
// \`auth-template escape helpers stay in sync\` test in
|
|
492
|
+
// cli/test/handlers.test.ts asserts the source strings match.
|
|
601
493
|
function escHtml(s) { return String(s).replace(/[&<>]/g, (c) => ({ "&": "&", "<": "<", ">": ">" }[c])); }
|
|
602
494
|
function escAttr(s) { return String(s).replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ }[c])); }
|
|
603
495
|
|
|
@@ -929,12 +821,24 @@ function isSharedAsset(pathname) {
|
|
|
929
821
|
// ROOT (vs. into _variants/<role>/) must be listed here, otherwise it
|
|
930
822
|
// 404s for every visitor. Build code that places root-level files:
|
|
931
823
|
// - styles.css / user.css — build.ts (writeFile join(outputDir, ...))
|
|
824
|
+
// - _handlers.js / _handlers.css — build.ts (handler asset bundles, root)
|
|
825
|
+
// - _foundry/importer.js + version.json — build.ts (foundry-importer bundle)
|
|
932
826
|
// - login.html — build.ts (multi-role only)
|
|
933
827
|
// - favicon.ico — build.ts (buildFavicon)
|
|
934
828
|
// - functions/_middleware.js — build.ts (multi-role only; not served)
|
|
935
829
|
// If you add another, add it both here AND in build.ts.
|
|
830
|
+
//
|
|
831
|
+
// _handlers.foundry.{js,css} is *deliberately not* listed: it lives in
|
|
832
|
+
// each variant directory so the middleware rewrites root requests to
|
|
833
|
+
// /_variants/<role>/_handlers.foundry.* per the requester's role,
|
|
834
|
+
// gating higher-tier handler assets behind authentication the same way
|
|
835
|
+
// page bodies are.
|
|
936
836
|
if (pathname === "/styles.css") return true;
|
|
937
837
|
if (pathname === "/user.css") return true;
|
|
838
|
+
if (pathname === "/_handlers.js") return true;
|
|
839
|
+
if (pathname === "/_handlers.css") return true;
|
|
840
|
+
if (pathname === "/_foundry/importer.js") return true;
|
|
841
|
+
if (pathname === "/_foundry/version.json") return true;
|
|
938
842
|
if (pathname === "/login.html") return true;
|
|
939
843
|
if (pathname === "/favicon.ico" || pathname === "/favicon.svg") return true;
|
|
940
844
|
if (pathname === "/robots.txt") return true;
|
|
@@ -984,11 +888,6 @@ export const LOGIN_HTML = `<!doctype html>
|
|
|
984
888
|
}
|
|
985
889
|
.patreon-btn:hover { filter: brightness(1.05); }
|
|
986
890
|
.patreon-hint { color: var(--muted); font-size: 0.78rem; margin-top: 0.6rem; text-align: center; }
|
|
987
|
-
.patreon-iframe-note {
|
|
988
|
-
color: var(--muted); font-size: 0.78rem; line-height: 1.45;
|
|
989
|
-
margin-top: 0.6rem; padding: 0.6rem 0.7rem;
|
|
990
|
-
border: 1px dashed var(--rule); border-radius: 4px;
|
|
991
|
-
}
|
|
992
891
|
</style>
|
|
993
892
|
</head>
|
|
994
893
|
<body>
|
|
@@ -1016,12 +915,6 @@ export const LOGIN_HTML = `<!doctype html>
|
|
|
1016
915
|
Active patrons of the configured tiers can sign in directly. The role
|
|
1017
916
|
selector above only matters for password sign-in.
|
|
1018
917
|
</p>
|
|
1019
|
-
<p class="patreon-iframe-note" hidden>
|
|
1020
|
-
Patreon refuses to be embedded in iframes, so its sign-in button is
|
|
1021
|
-
hidden when this page is loaded in one (e.g. a Foundry connect
|
|
1022
|
-
dialog). Use a password here, or open the wiki in a normal browser
|
|
1023
|
-
tab to sign in with Patreon.
|
|
1024
|
-
</p>
|
|
1025
918
|
</div>
|
|
1026
919
|
</div>
|
|
1027
920
|
<script>
|
|
@@ -1047,22 +940,11 @@ export const LOGIN_HTML = `<!doctype html>
|
|
|
1047
940
|
}
|
|
1048
941
|
// Show the Patreon button only if the build emitted a roles list for it
|
|
1049
942
|
// (i.e. patreon is configured AND at least one role has a tier mapping).
|
|
1050
|
-
// The Foundry module's connect flow now uses delivery=copy (paste-token),
|
|
1051
|
-
// not an iframe, so Patreon's X-Frame-Options is no longer a problem in
|
|
1052
|
-
// the supported flow. The iframe-detection note still fires defensively
|
|
1053
|
-
// for any third-party that embeds /login.html directly.
|
|
1054
943
|
const card = document.querySelector(".login-card");
|
|
1055
944
|
if (card.dataset.patreonRoles) {
|
|
1056
945
|
const section = document.getElementById("patreon-section");
|
|
1057
946
|
section.hidden = false;
|
|
1058
|
-
|
|
1059
|
-
if (inIframe) {
|
|
1060
|
-
document.getElementById("patreon-btn").hidden = true;
|
|
1061
|
-
document.querySelector(".patreon-hint").hidden = true;
|
|
1062
|
-
document.querySelector(".patreon-iframe-note").hidden = false;
|
|
1063
|
-
} else {
|
|
1064
|
-
document.getElementById("patreon-btn").href = "/auth/patreon/start?next=" + encodeURIComponent(next);
|
|
1065
|
-
}
|
|
947
|
+
document.getElementById("patreon-btn").href = "/auth/patreon/start?next=" + encodeURIComponent(next);
|
|
1066
948
|
}
|
|
1067
949
|
// Autofocus moved here so it picks the right field whether the password
|
|
1068
950
|
// form is visible or the user is going for the Patreon button.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-template.js","sourceRoot":"","sources":["../../src/render/auth-template.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,+EAA+E;AAC/E,2EAA2E;AAC3E,mEAAmE;AAsBnE,MAAM,UAAU,oBAAoB,CAAC,GAAuB;IAC1D,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC3D,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC;IAE3D,OAAO;;;;;;gBAMO,YAAY;oBACR,gBAAgB;kBAClB,cAAc
|
|
1
|
+
{"version":3,"file":"auth-template.js","sourceRoot":"","sources":["../../src/render/auth-template.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,+EAA+E;AAC/E,2EAA2E;AAC3E,mEAAmE;AAsBnE,MAAM,UAAU,oBAAoB,CAAC,GAAuB;IAC1D,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC3D,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,CAA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