@cookiecrumbs-eu/mcp 0.7.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.
Files changed (62) hide show
  1. package/LICENSE +134 -0
  2. package/README.md +186 -0
  3. package/dist/cli/src/api.js +192 -0
  4. package/dist/cli/src/auth.js +106 -0
  5. package/dist/cli/src/commands/_shared.js +78 -0
  6. package/dist/cli/src/commands/alerts.js +85 -0
  7. package/dist/cli/src/commands/auth.js +92 -0
  8. package/dist/cli/src/commands/declaration.js +45 -0
  9. package/dist/cli/src/commands/diff.js +26 -0
  10. package/dist/cli/src/commands/domains.js +44 -0
  11. package/dist/cli/src/commands/export.js +136 -0
  12. package/dist/cli/src/commands/init.js +134 -0
  13. package/dist/cli/src/commands/install.js +77 -0
  14. package/dist/cli/src/commands/issues.js +61 -0
  15. package/dist/cli/src/commands/link.js +41 -0
  16. package/dist/cli/src/commands/logs.js +98 -0
  17. package/dist/cli/src/commands/open.js +45 -0
  18. package/dist/cli/src/commands/pull.js +89 -0
  19. package/dist/cli/src/commands/push.js +110 -0
  20. package/dist/cli/src/commands/scan.js +94 -0
  21. package/dist/cli/src/commands/schedule.js +97 -0
  22. package/dist/cli/src/commands/services.js +143 -0
  23. package/dist/cli/src/commands/sites.js +111 -0
  24. package/dist/cli/src/commands/status.js +90 -0
  25. package/dist/cli/src/commands/templates.js +133 -0
  26. package/dist/cli/src/commands/tokens.js +50 -0
  27. package/dist/cli/src/commands/usage.js +41 -0
  28. package/dist/cli/src/commands/versions.js +95 -0
  29. package/dist/cli/src/commands/webhooks.js +164 -0
  30. package/dist/cli/src/configpkg.js +10 -0
  31. package/dist/cli/src/diff.js +63 -0
  32. package/dist/cli/src/errors.js +20 -0
  33. package/dist/cli/src/frameworks.js +141 -0
  34. package/dist/cli/src/index.js +100 -0
  35. package/dist/cli/src/jobs.js +59 -0
  36. package/dist/cli/src/merge.js +38 -0
  37. package/dist/cli/src/output.js +112 -0
  38. package/dist/cli/src/project.js +269 -0
  39. package/dist/cli/src/util.js +122 -0
  40. package/dist/config/rules_reference.json +569 -0
  41. package/dist/config/src/canon.js +36 -0
  42. package/dist/config/src/declaration.js +38 -0
  43. package/dist/config/src/defaults.js +804 -0
  44. package/dist/config/src/export.js +130 -0
  45. package/dist/config/src/index.js +16 -0
  46. package/dist/config/src/lint.js +139 -0
  47. package/dist/config/src/regimes.js +62 -0
  48. package/dist/config/src/rules.js +90 -0
  49. package/dist/config/src/schema.js +323 -0
  50. package/dist/config/src/theme.js +147 -0
  51. package/dist/config/src/verify.js +51 -0
  52. package/dist/config/src/webhooks.js +309 -0
  53. package/dist/mcp/src/auth.js +40 -0
  54. package/dist/mcp/src/client.js +44 -0
  55. package/dist/mcp/src/diff.js +134 -0
  56. package/dist/mcp/src/index.js +25 -0
  57. package/dist/mcp/src/matrix.js +106 -0
  58. package/dist/mcp/src/server.js +171 -0
  59. package/dist/mcp/src/shared.js +147 -0
  60. package/dist/mcp/src/tools-config.js +943 -0
  61. package/dist/mcp/src/tools.js +650 -0
  62. package/package.json +66 -0
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Canonical JSON used for every hash in CookieCrumbs. Must stay byte-for-byte
3
+ * identical to private.canon_json() in Postgres:
4
+ * - object keys sorted bytewise (code-unit order), no whitespace
5
+ * - values limited to objects, arrays, strings, booleans and null
6
+ * - numbers are rejected (the DB CHECK constraints forbid them in hashed jsonb)
7
+ * - strings escaped the JSON way (JSON.stringify on the string)
8
+ */
9
+ export function canonJson(value) {
10
+ if (value === null)
11
+ return 'null';
12
+ if (typeof value === 'boolean')
13
+ return value ? 'true' : 'false';
14
+ if (typeof value === 'string')
15
+ return JSON.stringify(value);
16
+ if (typeof value === 'number')
17
+ throw new Error('canonJson: numbers are not allowed in hashed documents');
18
+ if (Array.isArray(value))
19
+ return '[' + value.map(canonJson).join(',') + ']';
20
+ if (typeof value === 'object') {
21
+ const obj = value;
22
+ const keys = Object.keys(obj).sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
23
+ return '{' + keys.map((k) => JSON.stringify(k) + ':' + canonJson(obj[k])).join(',') + '}';
24
+ }
25
+ throw new Error('canonJson: unsupported value ' + typeof value);
26
+ }
27
+ const enc = new TextEncoder();
28
+ export async function sha256Hex(input) {
29
+ const data = typeof input === 'string' ? enc.encode(input) : input;
30
+ const buf = await crypto.subtle.digest('SHA-256', data);
31
+ return [...new Uint8Array(buf)].map((b) => b.toString(16).padStart(2, '0')).join('');
32
+ }
33
+ /** sha256 over canonJson(texts[lang]) — the value the runtime reports as `th`. */
34
+ export const textsHash = (texts) => sha256Hex(canonJson(texts));
35
+ /** sha256 over the purposes list: [{key, gcm}] sorted by key — drives re-ask on material change. */
36
+ export const purposesHash = (categories) => sha256Hex(canonJson([...categories].sort((a, b) => (a.key < b.key ? -1 : 1)).map((c) => ({ key: c.key, gcm: [...c.gcm].sort() }))));
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Cookie declaration (phase 3, schema_registry `declaration` v1). The JSON is rendered in Postgres
3
+ * (`private.render_declaration`) and served by the `declaration` edge function; this file holds the
4
+ * TypeScript shape plus `lifetimeText`, which must word lifetimes exactly like the SQL renderer.
5
+ */
6
+ const UNIT_SECONDS = { minute: 60, hour: 3600, day: 86400, month: 30 * 86400, year: 365 * 86400 };
7
+ const ORDER = ['year', 'month', 'day', 'hour', 'minute'];
8
+ /** Unit words [singular, plural] per language; English fallback. Same wording as the SQL renderer. */
9
+ const WORDS = {
10
+ en: { session: 'Session', minute: ['minute', 'minutes'], hour: ['hour', 'hours'], day: ['day', 'days'], month: ['month', 'months'], year: ['year', 'years'] },
11
+ de: { session: 'Sitzung', minute: ['Minute', 'Minuten'], hour: ['Stunde', 'Stunden'], day: ['Tag', 'Tage'], month: ['Monat', 'Monate'], year: ['Jahr', 'Jahre'] },
12
+ fr: { session: 'Session', minute: ['minute', 'minutes'], hour: ['heure', 'heures'], day: ['jour', 'jours'], month: ['mois', 'mois'], year: ['an', 'ans'] },
13
+ nl: { session: 'Sessie', minute: ['minuut', 'minuten'], hour: ['uur', 'uur'], day: ['dag', 'dagen'], month: ['maand', 'maanden'], year: ['jaar', 'jaar'] },
14
+ es: { session: 'Sesión', minute: ['minuto', 'minutos'], hour: ['hora', 'horas'], day: ['día', 'días'], month: ['mes', 'meses'], year: ['año', 'años'] },
15
+ it: { session: 'Sessione', minute: ['minuto', 'minuti'], hour: ['ora', 'ore'], day: ['giorno', 'giorni'], month: ['mese', 'mesi'], year: ['anno', 'anni'] },
16
+ };
17
+ /**
18
+ * Same algorithm as private.lifetime_text() in SQL: "Session" for null/≤0; otherwise walk the units
19
+ * years (365 d) → months (30 d) → days → hours → minutes and take the first one where the value is
20
+ * ≥ 1 and rounding changes it by at most 5 % (minutes always round): 390 d → "13 months",
21
+ * 400 d → "13 months", 45 d → "45 days", 5400 s → "90 minutes", 30 s → "1 minute".
22
+ * en/de/fr/nl/es/it built in, English for anything else.
23
+ */
24
+ export function lifetimeText(seconds, lang = 'en') {
25
+ const w = WORDS[(lang || 'en').toLowerCase()] ?? WORDS.en;
26
+ if (seconds === null || seconds === undefined || !Number.isFinite(seconds) || seconds <= 0)
27
+ return w.session;
28
+ for (let i = 0; i < ORDER.length; i++) {
29
+ const u = ORDER[i];
30
+ const v = seconds / UNIT_SECONDS[u];
31
+ if (v >= 1) {
32
+ const n = Math.round(v);
33
+ if (u === 'minute' || Math.abs(v - n) / v <= 0.05)
34
+ return `${n} ${w[u][n === 1 ? 0 : 1]}`;
35
+ }
36
+ }
37
+ return `1 ${w.minute[0]}`;
38
+ }