@livespace/plugin-cli 0.1.0 → 0.2.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.
@@ -147,6 +147,6 @@ export async function keysJwks(ctx) {
147
147
  await mkdir(dirname(path), { recursive: true });
148
148
  await writeFile(path, `${JSON.stringify({ keys }, null, 2)}\n`);
149
149
  ctx.out.success(`Wrote ${out}.`);
150
- ctx.out.end("For a plugin also installed by URL: serve it at /.well-known/livespace/jwks.json on the plugin's origin, as application/json with Access-Control-Allow-Origin: *, no redirect, under 16 KiB.");
150
+ ctx.out.end('For a plugin also installed by URL: serve it at /.well-known/livespace/jwks.json on the plugin\'s origin, as application/json, no redirect, under 16 KiB, with Access-Control-Allow-Origin: * on any request header (browsers send priority and cache-control). On S3, that\'s a CORS rule with "AllowedHeaders": ["*"].');
151
151
  ctx.out.result({ jwks: out, keys: keys.map((k) => k.kid) });
152
152
  }
@@ -3,7 +3,7 @@ import { checkManifest } from "../manifest/check.js";
3
3
  import { readManifestText, readPackageJson, serializeManifest, writeManifest, } from "../manifest/file.js";
4
4
  import { prefillFrom } from "../manifest/package-json.js";
5
5
  import { CATEGORIES, EXPECTED_LOCALES, LOCALES, MANIFEST_FILE, OBJECT_TYPES, REQUIRED_LOCALE, clientIdOf, } from "../manifest/schema.js";
6
- import { isHexColor, isHttpsOrigin, isHttpsUrl, isId, isKeyList, isSemver, isSvgUrl, splitList, } from "../ui/validators.js";
6
+ import { isHexColor, isHttpsOrigin, isHttpsUrl, isId, isImageUrl, isKeyList, isSemver, splitList, } from "../ui/validators.js";
7
7
  import { UsageError } from "./context.js";
8
8
  import { createKeys, saveKeys } from "./keys.js";
9
9
  import { loadManifest } from "./load.js";
@@ -161,15 +161,15 @@ export async function manifestInit(ctx) {
161
161
  const categories = await askCategories(p);
162
162
  const iconUrl = await p.text({
163
163
  name: "icon-url",
164
- message: "Icon URL (.svg, optional)?",
164
+ message: "Icon URL (.svg or .png, optional)?",
165
165
  optional: true,
166
- validate: isSvgUrl,
166
+ validate: isImageUrl,
167
167
  });
168
168
  const illustrationUrl = await p.text({
169
169
  name: "illustration-url",
170
- message: "Illustration URL (.svg, optional)?",
170
+ message: "Illustration URL (.svg or .png, optional)?",
171
171
  optional: true,
172
- validate: isSvgUrl,
172
+ validate: isImageUrl,
173
173
  });
174
174
  const accentColor = await p.text({
175
175
  name: "accent-color",
@@ -268,7 +268,7 @@ const SETTERS = {
268
268
  message: "Icon URL?",
269
269
  initial: m.iconUrl,
270
270
  optional: true,
271
- validate: isSvgUrl,
271
+ validate: isImageUrl,
272
272
  });
273
273
  },
274
274
  "illustration-url": async (p, m) => {
@@ -277,7 +277,7 @@ const SETTERS = {
277
277
  message: "Illustration URL?",
278
278
  initial: m.illustrationUrl,
279
279
  optional: true,
280
- validate: isSvgUrl,
280
+ validate: isImageUrl,
281
281
  });
282
282
  },
283
283
  "accent-color": async (p, m) => {
@@ -9,7 +9,7 @@
9
9
  import { CATEGORIES, EXPECTED_LOCALES, FIELDS, ID_PATTERN, KEY_ALG, KEY_USES, MAX_KEYS_PER_USE, MIN_RSA_BITS, OBJECT_TYPES, REQUIRED_LOCALE, } from "./schema.js";
10
10
  const SEMVER = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
11
11
  const HEX_COLOR = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
12
- const SVG = /\.svg(?:[?#].*)?$/i;
12
+ const IMAGE = /\.(?:svg|png)(?:[?#].*)?$/i;
13
13
  const RAW_HTML = /<\/?[a-zA-Z][^>]*>/;
14
14
  const LINK = /\[[^\]]*\]\([^)]*\)|<https?:\/\/[^>]*>|https?:\/\/\S+/;
15
15
  /** JWK members that only a private key has. One in a manifest is a leaked key. */
@@ -185,8 +185,8 @@ function checkAssets(m, failures, warnings) {
185
185
  continue;
186
186
  }
187
187
  if ((key === "iconUrl" || key === "illustrationUrl") &&
188
- !SVG.test(url.pathname)) {
189
- failures.push(`"${key}" must be an .svg`);
188
+ !IMAGE.test(url.pathname)) {
189
+ failures.push(`"${key}" must be an .svg or .png`);
190
190
  }
191
191
  if (origin !== undefined && url.origin !== origin) {
192
192
  warnings.push(`"${key}" is served from another origin than the plugin (${url.origin}) — fine if intended`);
@@ -27,8 +27,10 @@ export const isHttpsOrigin = (v) => {
27
27
  : `the origin alone, no path or trailing slash: ${url.origin}`;
28
28
  };
29
29
  export const isHttpsUrl = (v) => parse(v)?.protocol === "https:" ? undefined : "an https URL";
30
- export const isSvgUrl = (v) => isHttpsUrl(v) ??
31
- (/\.svg(?:[?#].*)?$/i.test(parse(v)?.pathname ?? "") ? undefined : "an .svg");
30
+ export const isImageUrl = (v) => isHttpsUrl(v) ??
31
+ (/\.(?:svg|png)(?:[?#].*)?$/i.test(parse(v)?.pathname ?? "")
32
+ ? undefined
33
+ : "an .svg or .png");
32
34
  export const isHexColor = (v) => /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.test(v)
33
35
  ? undefined
34
36
  : "a hex colour, e.g. #5546b8";
package/package.json CHANGED
@@ -1,18 +1,25 @@
1
1
  {
2
2
  "name": "@livespace/plugin-cli",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Sets up a Livespace plugin's catalog manifest, its key pairs included.",
5
5
  "author": "LS FE team",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "bin": {
9
- "livespace-plugin": "./dist/cli.js"
9
+ "livespace-plugin": "dist/cli.js"
10
10
  },
11
- "files": ["dist"],
11
+ "files": [
12
+ "dist"
13
+ ],
12
14
  "engines": {
13
15
  "node": ">=20.12"
14
16
  },
15
- "keywords": ["livespace", "plugin", "manifest", "cli"],
17
+ "keywords": [
18
+ "livespace",
19
+ "plugin",
20
+ "manifest",
21
+ "cli"
22
+ ],
16
23
  "homepage": "https://www.npmjs.com/package/@livespace/plugin-cli",
17
24
  "repository": {
18
25
  "type": "git",