@cosmicdrift/kumiko-bundled-features 0.411.0 → 0.413.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/dist/admin-shell/feature.d.ts +1 -1
- package/dist/agent-tools/agent-doc-lint.d.ts +9 -0
- package/dist/agent-tools/agent-doc-lint.js +42 -5
- package/dist/agent-tools/agent-manifest.d.ts +0 -1
- package/dist/agent-tools/agent-manifest.js +9 -99
- package/dist/agent-tools/api-docs/anchors.d.ts +14 -0
- package/dist/agent-tools/api-docs/anchors.js +49 -0
- package/dist/agent-tools/api-docs/check.d.ts +7 -0
- package/dist/agent-tools/api-docs/check.js +15 -0
- package/dist/agent-tools/api-docs/collect-events.d.ts +10 -0
- package/dist/agent-tools/api-docs/collect-events.js +90 -0
- package/dist/agent-tools/api-docs/collect.d.ts +15 -0
- package/dist/agent-tools/api-docs/collect.js +108 -0
- package/dist/agent-tools/api-docs/curl.d.ts +5 -0
- package/dist/agent-tools/api-docs/curl.js +24 -0
- package/dist/agent-tools/api-docs/error-table.d.ts +9 -0
- package/dist/agent-tools/api-docs/error-table.js +31 -0
- package/dist/agent-tools/api-docs/examples.d.ts +16 -0
- package/dist/agent-tools/api-docs/examples.js +25 -0
- package/dist/agent-tools/api-docs/generate.d.ts +19 -0
- package/dist/agent-tools/api-docs/generate.js +104 -0
- package/dist/agent-tools/api-docs/index-json.d.ts +15 -0
- package/dist/agent-tools/api-docs/index-json.js +6 -0
- package/dist/agent-tools/api-docs/index.d.ts +9 -0
- package/dist/agent-tools/api-docs/index.js +6 -0
- package/dist/agent-tools/api-docs/list-parameters.d.ts +61 -0
- package/dist/agent-tools/api-docs/list-parameters.js +28 -0
- package/dist/agent-tools/api-docs/markdown.d.ts +29 -0
- package/dist/agent-tools/api-docs/markdown.js +48 -0
- package/dist/agent-tools/api-docs/menu-path.d.ts +8 -0
- package/dist/agent-tools/api-docs/menu-path.js +60 -0
- package/dist/agent-tools/api-docs/model.d.ts +76 -0
- package/dist/agent-tools/api-docs/problems.d.ts +32 -0
- package/dist/agent-tools/api-docs/problems.js +28 -0
- package/dist/agent-tools/api-docs/render-events.d.ts +12 -0
- package/dist/agent-tools/api-docs/render-events.js +55 -0
- package/dist/agent-tools/api-docs/render-openapi.d.ts +10 -0
- package/dist/agent-tools/api-docs/render-openapi.js +170 -0
- package/dist/agent-tools/api-docs/render-overview.d.ts +11 -0
- package/dist/agent-tools/api-docs/render-overview.js +60 -0
- package/dist/agent-tools/api-docs/render-reference.d.ts +14 -0
- package/dist/agent-tools/api-docs/render-reference.js +50 -0
- package/dist/agent-tools/api-docs/render-tokens.d.ts +12 -0
- package/dist/agent-tools/api-docs/render-tokens.js +101 -0
- package/dist/agent-tools/api-docs/schema-fields.d.ts +16 -0
- package/dist/agent-tools/api-docs/schema-fields.js +141 -0
- package/dist/agent-tools/api-docs/section-ids.d.ts +25 -0
- package/dist/agent-tools/api-docs/section-ids.js +26 -0
- package/dist/agent-tools/api-docs/system-only.d.ts +5 -0
- package/dist/agent-tools/api-docs/system-only.js +7 -0
- package/dist/agent-tools/api-docs/texts/de.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/de.js +123 -0
- package/dist/agent-tools/api-docs/texts/en.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/en.js +123 -0
- package/dist/agent-tools/api-docs/texts/es.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/es.js +123 -0
- package/dist/agent-tools/api-docs/texts/fr.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/fr.js +123 -0
- package/dist/agent-tools/api-docs/texts/index.d.ts +14 -0
- package/dist/agent-tools/api-docs/texts/index.js +55 -0
- package/dist/agent-tools/api-docs/texts/it.d.ts +123 -0
- package/dist/agent-tools/api-docs/texts/it.js +123 -0
- package/dist/agent-tools/api-docs/texts/types.d.ts +18 -0
- package/dist/agent-tools/api-docs/texts/types.js +104 -0
- package/dist/agent-tools/api-docs/ui-writes.d.ts +12 -0
- package/dist/agent-tools/api-docs/ui-writes.js +73 -0
- package/dist/agent-tools/handler-schema.d.ts +5 -0
- package/dist/agent-tools/handler-schema.js +37 -0
- package/dist/agent-tools/index.d.ts +2 -1
- package/dist/agent-tools/index.js +2 -1
- package/dist/agent-tools/labels.d.ts +26 -0
- package/dist/agent-tools/labels.js +131 -0
- package/dist/auth-email-password/boot-rules.d.ts +7 -0
- package/dist/auth-email-password/boot-rules.js +7 -0
- package/dist/auth-email-password/feature.js +6 -13
- package/dist/auth-email-password/validate-options.d.ts +5 -0
- package/dist/auth-email-password/validate-options.js +15 -0
- package/dist/billing-foundation/boot-rules.d.ts +22 -0
- package/dist/billing-foundation/boot-rules.js +22 -0
- package/dist/billing-foundation/validate-options.js +56 -18
- package/dist/cap-overview/boot-rules.d.ts +12 -0
- package/dist/cap-overview/boot-rules.js +12 -0
- package/dist/cap-overview/feature.js +8 -3
- package/dist/documents/boot-rules.d.ts +12 -0
- package/dist/documents/boot-rules.js +12 -0
- package/dist/documents/feature.js +8 -3
- package/dist/file-derivatives/boot-rules.d.ts +7 -0
- package/dist/file-derivatives/boot-rules.js +7 -0
- package/dist/file-derivatives/feature.js +5 -2
- package/dist/folders/boot-rules.d.ts +7 -0
- package/dist/folders/boot-rules.js +7 -0
- package/dist/folders/feature.js +8 -5
- package/dist/helpdesk/boot-rules.d.ts +7 -0
- package/dist/helpdesk/boot-rules.js +7 -0
- package/dist/{contact → helpdesk}/challenge.js +2 -2
- package/dist/helpdesk/client/helpdesk-client-source.d.ts +1 -0
- package/dist/{contact/client/contact-client-source.js → helpdesk/client/helpdesk-client-source.js} +4 -4
- package/dist/helpdesk/client/helpdesk-website-client.d.ts +26 -0
- package/dist/helpdesk/client/helpdesk-website-client.js +1 -0
- package/dist/helpdesk/client/index.d.ts +2 -0
- package/dist/helpdesk/client/index.js +1 -0
- package/dist/{contact → helpdesk}/entity.d.ts +6 -6
- package/dist/{contact → helpdesk}/entity.js +31 -27
- package/dist/helpdesk/feature.d.ts +3 -0
- package/dist/{contact → helpdesk}/feature.js +43 -39
- package/dist/{contact → helpdesk}/handlers/attempts.d.ts +2 -2
- package/dist/helpdesk/handlers/challenge.query.d.ts +9 -0
- package/dist/{contact → helpdesk}/handlers/challenge.query.js +5 -5
- package/dist/helpdesk/handlers/forward-request.write.d.ts +9 -0
- package/dist/{contact → helpdesk}/handlers/forward-request.write.js +17 -15
- package/dist/{contact → helpdesk}/handlers/mark-done.write.d.ts +2 -2
- package/dist/{contact → helpdesk}/handlers/mark-done.write.js +8 -8
- package/dist/{contact → helpdesk}/handlers/notify-reporter-in-app.write.d.ts +2 -2
- package/dist/{contact → helpdesk}/handlers/notify-reporter-in-app.write.js +11 -11
- package/dist/{contact → helpdesk}/handlers/open-count.js +2 -2
- package/dist/{contact → helpdesk}/handlers/open-count.query.js +4 -4
- package/dist/{contact → helpdesk}/handlers/replies.query.js +6 -6
- package/dist/{contact → helpdesk}/handlers/reply.write.d.ts +4 -4
- package/dist/{contact → helpdesk}/handlers/reply.write.js +16 -16
- package/dist/helpdesk/handlers/report.write.d.ts +16 -0
- package/dist/{contact → helpdesk}/handlers/report.write.js +17 -17
- package/dist/helpdesk/handlers/request-delivery.query.d.ts +16 -0
- package/dist/{contact → helpdesk}/handlers/request-delivery.query.js +24 -24
- package/dist/{contact → helpdesk}/handlers/request-detail.query.d.ts +3 -3
- package/dist/{contact → helpdesk}/handlers/request-detail.query.js +10 -10
- package/dist/{contact → helpdesk}/handlers/request-list.query.js +2 -2
- package/dist/helpdesk/handlers/send-reply-mail.write.d.ts +8 -0
- package/dist/{contact → helpdesk}/handlers/send-reply-mail.write.js +15 -15
- package/dist/helpdesk/handlers/send-test.write.d.ts +5 -0
- package/dist/{contact → helpdesk}/handlers/send-test.write.js +10 -10
- package/dist/{contact → helpdesk}/handlers/submit.write.d.ts +4 -4
- package/dist/{contact → helpdesk}/handlers/submit.write.js +17 -17
- package/dist/{contact → helpdesk}/handlers/take-over-uploads.js +5 -5
- package/dist/{contact → helpdesk}/i18n.d.ts +1 -1
- package/dist/{contact → helpdesk}/i18n.js +78 -75
- package/dist/helpdesk/index.d.ts +5 -0
- package/dist/helpdesk/index.js +4 -0
- package/dist/{contact → helpdesk}/lib.d.ts +5 -5
- package/dist/{contact → helpdesk}/lib.js +16 -16
- package/dist/{contact → helpdesk}/mail.d.ts +20 -20
- package/dist/{contact → helpdesk}/mail.js +47 -47
- package/dist/{contact → helpdesk}/options.d.ts +6 -6
- package/dist/helpdesk/options.js +36 -0
- package/dist/helpdesk/panels.d.ts +2 -0
- package/dist/helpdesk/panels.js +21 -0
- package/dist/{contact → helpdesk}/payloads.d.ts +11 -11
- package/dist/{contact → helpdesk}/payloads.js +28 -28
- package/dist/helpdesk/screens.d.ts +5 -0
- package/dist/{contact → helpdesk}/screens.js +87 -87
- package/dist/{contact → helpdesk}/subject.js +3 -3
- package/dist/helpdesk/user-data-hooks.d.ts +3 -0
- package/dist/{contact → helpdesk}/user-data-hooks.js +15 -15
- package/dist/helpdesk/web/constants.d.ts +127 -0
- package/dist/helpdesk/web/constants.js +126 -0
- package/dist/helpdesk/web/index.d.ts +1 -0
- package/dist/helpdesk/web/index.js +1 -0
- package/dist/host-routing/boot-rules.d.ts +22 -0
- package/dist/host-routing/boot-rules.js +22 -0
- package/dist/host-routing/validate-options.js +35 -11
- package/dist/inbound-mail-foundation/entities.d.ts +84 -0
- package/dist/inbound-mail-foundation/entities.js +96 -71
- package/dist/inbound-mail-foundation/feature.js +2 -2
- package/dist/jobs/boot-rules.d.ts +7 -0
- package/dist/jobs/boot-rules.js +7 -0
- package/dist/jobs/feature.js +5 -2
- package/dist/legal-pages/boot-rules.d.ts +17 -0
- package/dist/legal-pages/boot-rules.js +17 -0
- package/dist/legal-pages/feature.js +5 -2
- package/dist/legal-pages/lib/validate-routes.js +11 -3
- package/dist/metrics/boot-rules.d.ts +12 -0
- package/dist/metrics/boot-rules.js +12 -0
- package/dist/metrics/validate.js +8 -2
- package/dist/notes-history/boot-rules.d.ts +7 -0
- package/dist/notes-history/boot-rules.js +7 -0
- package/dist/notes-history/feature.js +7 -4
- package/dist/personal-access-tokens/boot-rules.d.ts +7 -0
- package/dist/personal-access-tokens/boot-rules.js +7 -0
- package/dist/personal-access-tokens/feature.d.ts +1 -0
- package/dist/personal-access-tokens/feature.js +4 -2
- package/dist/personal-access-tokens/handlers/create.write.js +2 -2
- package/dist/personal-access-tokens/i18n.js +5 -1
- package/dist/personal-access-tokens/index.d.ts +4 -2
- package/dist/personal-access-tokens/index.js +29 -2
- package/dist/personal-access-tokens/scope-events-check.d.ts +3 -0
- package/dist/personal-access-tokens/scope-events-check.js +21 -0
- package/dist/personal-access-tokens/screens.js +8 -2
- package/dist/personal-access-tokens/web/constants.d.ts +1 -0
- package/dist/personal-access-tokens/web/constants.js +1 -0
- package/dist/personal-access-tokens/web/scopes.d.ts +2 -0
- package/dist/personal-access-tokens/web/scopes.js +12 -0
- package/dist/presence/boot-rules.d.ts +7 -0
- package/dist/presence/boot-rules.js +7 -0
- package/dist/presence/options.js +5 -1
- package/dist/readiness/boot-rules.d.ts +12 -0
- package/dist/readiness/boot-rules.js +12 -0
- package/dist/readiness/probe-boot-check.js +8 -3
- package/dist/shared/assert-no-where-rule-in-ownership-write.d.ts +1 -1
- package/dist/shared/assert-no-where-rule-in-ownership-write.js +11 -7
- package/dist/shared/boot-rules.d.ts +7 -0
- package/dist/shared/boot-rules.js +7 -0
- package/dist/subscription-mollie/boot-rules.d.ts +17 -0
- package/dist/subscription-mollie/boot-rules.js +17 -0
- package/dist/subscription-mollie/feature.js +13 -6
- package/dist/tags/boot-rules.d.ts +7 -0
- package/dist/tags/boot-rules.js +7 -0
- package/dist/tags/feature.js +8 -5
- package/dist/template-resolver/boot-rules.d.ts +17 -0
- package/dist/template-resolver/boot-rules.js +17 -0
- package/dist/template-resolver/feature.js +14 -5
- package/dist/tenant/boot-rules.d.ts +7 -0
- package/dist/tenant/boot-rules.js +7 -0
- package/dist/tenant/feature.js +5 -2
- package/kumiko-es-tables.json +4 -4
- package/package.json +29 -29
- package/src/agent-tools/changes.json +24 -0
- package/src/{contact → helpdesk}/changes.json +6 -0
- package/src/inbound-mail-foundation/changes.json +6 -0
- package/src/personal-access-tokens/changes.json +6 -0
- package/dist/contact/client/contact-client-source.d.ts +0 -1
- package/dist/contact/client/contact-website-client.d.ts +0 -26
- package/dist/contact/client/index.d.ts +0 -2
- package/dist/contact/client/index.js +0 -1
- package/dist/contact/feature.d.ts +0 -3
- package/dist/contact/handlers/challenge.query.d.ts +0 -9
- package/dist/contact/handlers/forward-request.write.d.ts +0 -9
- package/dist/contact/handlers/report.write.d.ts +0 -16
- package/dist/contact/handlers/request-delivery.query.d.ts +0 -16
- package/dist/contact/handlers/send-reply-mail.write.d.ts +0 -8
- package/dist/contact/handlers/send-test.write.d.ts +0 -5
- package/dist/contact/index.d.ts +0 -5
- package/dist/contact/index.js +0 -4
- package/dist/contact/options.js +0 -32
- package/dist/contact/panels.d.ts +0 -2
- package/dist/contact/panels.js +0 -21
- package/dist/contact/screens.d.ts +0 -5
- package/dist/contact/user-data-hooks.d.ts +0 -3
- package/dist/contact/web/constants.d.ts +0 -127
- package/dist/contact/web/constants.js +0 -126
- package/dist/contact/web/index.d.ts +0 -1
- package/dist/contact/web/index.js +0 -1
- /package/dist/{contact/client/contact-website-client.js → agent-tools/api-docs/model.js} +0 -0
- /package/dist/{contact → helpdesk}/challenge.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/access.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/access.js +0 -0
- /package/dist/{contact → helpdesk}/handlers/attempts.js +0 -0
- /package/dist/{contact → helpdesk}/handlers/open-count.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/open-count.query.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/replies.query.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/request-list.query.d.ts +0 -0
- /package/dist/{contact → helpdesk}/handlers/take-over-uploads.d.ts +0 -0
- /package/dist/{contact → helpdesk}/pow.d.ts +0 -0
- /package/dist/{contact → helpdesk}/pow.js +0 -0
- /package/dist/{contact → helpdesk}/subject.d.ts +0 -0
- /package/dist/{contact → helpdesk}/user-agent.d.ts +0 -0
- /package/dist/{contact → helpdesk}/user-agent.js +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const HELPDESK_BOOT_RULES: {
|
|
2
|
+
readonly invalidProofOfWorkBits: {
|
|
3
|
+
readonly id: "helpdesk/invalid-proof-of-work-bits";
|
|
4
|
+
readonly summary: "spamProtection.proofOfWorkBits is an integer within the allowed range.";
|
|
5
|
+
readonly fix: "Use an integer inside the documented bounds.";
|
|
6
|
+
};
|
|
7
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
-
import {
|
|
3
|
+
import { HELPDESK_CHALLENGE_REDIS_PREFIX } from "./web/constants.js";
|
|
4
4
|
const CHALLENGE_BYTES = 16;
|
|
5
5
|
const StoredChallengeSchema = z.object({
|
|
6
6
|
issuedAtMs: z.number().int().nonnegative(),
|
|
7
7
|
bits: z.number().int().positive(),
|
|
8
8
|
});
|
|
9
|
-
const challengeKey = (challenge) => `${
|
|
9
|
+
const challengeKey = (challenge) => `${HELPDESK_CHALLENGE_REDIS_PREFIX}${challenge}`;
|
|
10
10
|
export async function issueChallenge(redis, args) {
|
|
11
11
|
const challenge = randomBytes(CHALLENGE_BYTES).toString("base64url");
|
|
12
12
|
const stored = { issuedAtMs: args.nowMs, bits: args.bits };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HELPDESK_CLIENT_SOURCE = "(function () {\n \"use strict\";\n\n var QUERY_PATH = \"/api/query\";\n var WRITE_PATH = \"/api/write\";\n var CHALLENGE_QUERY = \"helpdesk:query:challenge\";\n var SUBMIT_WRITE = \"helpdesk:write:submit\";\n var CSRF_COOKIE_NAME = \"kumiko_csrf\";\n var CSRF_HEADER_NAME = \"X-CSRF-Token\";\n var LOCALE_HEADER_NAME = \"X-Locale\";\n var SLICE_MS = 12;\n\n var K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2\n ]);\n var H0 = [0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19];\n\n var block = new Uint8Array(64);\n var words = new Uint32Array(64);\n var digest = new Uint32Array(8);\n\n function rotr(x, n) {\n return (x >>> n) | (x << (32 - n));\n }\n\n // One 64-byte block only: challenge, colon and decimal nonce stay far below 56 bytes.\n function sha256Block() {\n var i;\n for (i = 0; i < 16; i++) {\n words[i] = (block[i * 4] << 24) | (block[i * 4 + 1] << 16) | (block[i * 4 + 2] << 8) | block[i * 4 + 3];\n }\n for (i = 16; i < 64; i++) {\n var w15 = words[i - 15];\n var w2 = words[i - 2];\n var s0 = rotr(w15, 7) ^ rotr(w15, 18) ^ (w15 >>> 3);\n var s1 = rotr(w2, 17) ^ rotr(w2, 19) ^ (w2 >>> 10);\n words[i] = (words[i - 16] + s0 + words[i - 7] + s1) | 0;\n }\n var a = H0[0], b = H0[1], c = H0[2], d = H0[3], e = H0[4], f = H0[5], g = H0[6], h = H0[7];\n for (i = 0; i < 64; i++) {\n var t1 = (h + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + ((e & f) ^ (~e & g)) + K[i] + words[i]) | 0;\n var t2 = ((rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + ((a & b) ^ (a & c) ^ (b & c))) | 0;\n h = g; g = f; f = e; e = (d + t1) | 0; d = c; c = b; b = a; a = (t1 + t2) | 0;\n }\n digest[0] = (H0[0] + a) | 0; digest[1] = (H0[1] + b) | 0; digest[2] = (H0[2] + c) | 0; digest[3] = (H0[3] + d) | 0;\n digest[4] = (H0[4] + e) | 0; digest[5] = (H0[5] + f) | 0; digest[6] = (H0[6] + g) | 0; digest[7] = (H0[7] + h) | 0;\n }\n\n function hasLeadingZeroBits(bits) {\n var i = 0;\n var remaining = bits;\n while (remaining >= 32) {\n if (digest[i] !== 0) return false;\n i++;\n remaining -= 32;\n }\n if (remaining === 0) return true;\n return (digest[i] >>> (32 - remaining)) === 0;\n }\n\n function solveProofOfWork(challenge, bits) {\n return new Promise(function (resolve, reject) {\n var prefix = challenge + \":\";\n if (prefix.length > 40) {\n reject(new Error(\"challenge too long\"));\n return;\n }\n var i;\n block.fill(0);\n for (i = 0; i < prefix.length; i++) block[i] = prefix.charCodeAt(i);\n var counter = 0;\n\n function step() {\n var deadline = Date.now() + SLICE_MS;\n do {\n var nonce = String(counter);\n var length = prefix.length + nonce.length;\n for (i = 0; i < nonce.length; i++) block[prefix.length + i] = nonce.charCodeAt(i);\n block[length] = 0x80;\n var bitLength = length * 8;\n block[62] = (bitLength >>> 8) & 0xff;\n block[63] = bitLength & 0xff;\n sha256Block();\n if (hasLeadingZeroBits(bits)) {\n resolve(nonce);\n return;\n }\n counter++;\n } while (counter % 256 !== 0 || Date.now() < deadline);\n setTimeout(step, 0);\n }\n step();\n });\n }\n\n function readCsrfToken() {\n var parts = document.cookie.split(\";\");\n for (var i = 0; i < parts.length; i++) {\n var part = parts[i].trim();\n var separator = part.indexOf(\"=\");\n if (separator > 0 && part.slice(0, separator) === CSRF_COOKIE_NAME) {\n return decodeURIComponent(part.slice(separator + 1));\n }\n }\n return undefined;\n }\n\n function pageLocale() {\n var language = (document.documentElement.lang || \"\").toLowerCase().split(\"-\")[0];\n return language === \"de\" ? \"de-DE\" : \"en-US\";\n }\n\n function postJson(path, body) {\n var headers = { \"Content-Type\": \"application/json\" };\n headers[LOCALE_HEADER_NAME] = pageLocale();\n var csrf = readCsrfToken();\n if (csrf !== undefined) headers[CSRF_HEADER_NAME] = csrf;\n return fetch(path, {\n method: \"POST\",\n credentials: \"omit\",\n headers: headers,\n body: JSON.stringify(body)\n }).then(function (response) {\n return response.json().then(\n function (json) { return { status: response.status, response: response, body: json }; },\n function () { return { status: response.status, response: response, body: undefined }; }\n );\n });\n }\n\n function retryAfterOf(result) {\n var header = result.response.headers.get(\"Retry-After\");\n if (header !== null && /^[0-9]+$/.test(header)) return Number(header);\n var error = result.body && result.body.error;\n var seconds = error && error.details && error.details.retryAfterSeconds;\n return typeof seconds === \"number\" ? seconds : undefined;\n }\n\n var pending = null;\n\n function startChallenge() {\n return postJson(QUERY_PATH, { type: CHALLENGE_QUERY, payload: {} }).then(function (result) {\n var data = result.body && result.body.data;\n if (result.status !== 200 || !data || typeof data.challenge !== \"string\") {\n throw new Error(\"challenge failed\");\n }\n var solved = solveProofOfWork(data.challenge, data.bits);\n solved.catch(function () {});\n return { challenge: data.challenge, solved: solved, options: { phone: data.phone, kinds: data.kinds } };\n });\n }\n\n function ensureChallenge() {\n if (pending === null) {\n pending = startChallenge();\n pending.catch(function () { pending = null; });\n }\n return pending;\n }\n\n function load() {\n return ensureChallenge().then(function (state) { return state.options; });\n }\n\n function submit(fields) {\n return ensureChallenge().then(function (state) {\n pending = null;\n return state.solved.then(function (nonce) {\n var payload = {};\n for (var key in fields) {\n if (Object.prototype.hasOwnProperty.call(fields, key)) payload[key] = fields[key];\n }\n payload.challenge = state.challenge;\n payload.nonce = nonce;\n if (payload.locale === undefined) payload.locale = document.documentElement.lang || \"en\";\n return postJson(WRITE_PATH, { type: SUBMIT_WRITE, payload: payload });\n });\n }).then(function (result) {\n if (result.status === 429) {\n var retryAfterSeconds = retryAfterOf(result);\n return retryAfterSeconds === undefined\n ? { kind: \"rate-limited\" }\n : { kind: \"rate-limited\", retryAfterSeconds: retryAfterSeconds };\n }\n if (result.status === 200 && result.body && result.body.isSuccess === true) return { kind: \"sent\" };\n return { kind: \"failed\" };\n }, function () {\n return { kind: \"failed\" };\n });\n }\n\n window.KumikoHelpdesk = { load: load, submit: submit };\n})();\n";
|
package/dist/{contact/client/contact-client-source.js → helpdesk/client/helpdesk-client-source.js}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// The browser client ships as a string so it survives the tsc-only dist build, which copies no
|
|
2
2
|
// loose .js assets. Keep it free of backslashes, backticks and template placeholders.
|
|
3
|
-
export const
|
|
3
|
+
export const HELPDESK_CLIENT_SOURCE = `(function () {
|
|
4
4
|
"use strict";
|
|
5
5
|
|
|
6
6
|
var QUERY_PATH = "/api/query";
|
|
7
7
|
var WRITE_PATH = "/api/write";
|
|
8
|
-
var CHALLENGE_QUERY = "
|
|
9
|
-
var SUBMIT_WRITE = "
|
|
8
|
+
var CHALLENGE_QUERY = "helpdesk:query:challenge";
|
|
9
|
+
var SUBMIT_WRITE = "helpdesk:write:submit";
|
|
10
10
|
var CSRF_COOKIE_NAME = "kumiko_csrf";
|
|
11
11
|
var CSRF_HEADER_NAME = "X-CSRF-Token";
|
|
12
12
|
var LOCALE_HEADER_NAME = "X-Locale";
|
|
@@ -198,6 +198,6 @@ export const CONTACT_CLIENT_SOURCE = `(function () {
|
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
-
window.
|
|
201
|
+
window.KumikoHelpdesk = { load: load, submit: submit };
|
|
202
202
|
})();
|
|
203
203
|
`;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as z from "zod";
|
|
2
|
+
import type { HelpdeskSubmitSchema } from "../payloads.ts";
|
|
3
|
+
import type { HELPDESK_WEBSITE_KINDS, HelpdeskPhoneMode } from "../web/constants.ts";
|
|
4
|
+
export type HelpdeskWebsiteKind = (typeof HELPDESK_WEBSITE_KINDS)[number];
|
|
5
|
+
export type HelpdeskWebsiteFormOptions = {
|
|
6
|
+
readonly phone: HelpdeskPhoneMode;
|
|
7
|
+
readonly kinds: readonly HelpdeskWebsiteKind[];
|
|
8
|
+
};
|
|
9
|
+
export type HelpdeskWebsiteSubmitFields = Omit<z.input<typeof HelpdeskSubmitSchema>, "challenge" | "nonce" | "locale"> & {
|
|
10
|
+
readonly locale?: z.input<typeof HelpdeskSubmitSchema>["locale"];
|
|
11
|
+
};
|
|
12
|
+
export type HelpdeskWebsiteSubmitResult = {
|
|
13
|
+
readonly kind: "sent";
|
|
14
|
+
} | {
|
|
15
|
+
readonly kind: "rate-limited";
|
|
16
|
+
readonly retryAfterSeconds?: number;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "failed";
|
|
19
|
+
};
|
|
20
|
+
export type HelpdeskWebsiteClient = {
|
|
21
|
+
load(): Promise<HelpdeskWebsiteFormOptions>;
|
|
22
|
+
submit(fields: HelpdeskWebsiteSubmitFields): Promise<HelpdeskWebsiteSubmitResult>;
|
|
23
|
+
};
|
|
24
|
+
export type HelpdeskWebsiteWindow = {
|
|
25
|
+
readonly KumikoHelpdesk?: HelpdeskWebsiteClient;
|
|
26
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HELPDESK_CLIENT_SOURCE } from "./helpdesk-client-source.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function createHelpdeskRequestEntity(retentionKeepFor?: string): import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
|
|
2
2
|
readonly kind: {
|
|
3
3
|
readonly type: "select";
|
|
4
4
|
readonly description?: string;
|
|
@@ -200,7 +200,7 @@ export declare function createContactRequestEntity(retentionKeepFor?: string): i
|
|
|
200
200
|
required: false;
|
|
201
201
|
};
|
|
202
202
|
}, "global">;
|
|
203
|
-
export declare function
|
|
203
|
+
export declare function createHelpdeskReplyEntity(retentionKeepFor?: string): import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
|
|
204
204
|
readonly requestId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
|
|
205
205
|
required: true;
|
|
206
206
|
};
|
|
@@ -257,7 +257,7 @@ export declare function createContactReplyEntity(retentionKeepFor?: string): imp
|
|
|
257
257
|
required: true;
|
|
258
258
|
};
|
|
259
259
|
}, "global">;
|
|
260
|
-
export declare const
|
|
260
|
+
export declare const helpdeskRequestEntity: import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
|
|
261
261
|
readonly kind: {
|
|
262
262
|
readonly type: "select";
|
|
263
263
|
readonly description?: string;
|
|
@@ -459,7 +459,7 @@ export declare const contactRequestEntity: import("@cosmicdrift/kumiko-types/fie
|
|
|
459
459
|
required: false;
|
|
460
460
|
};
|
|
461
461
|
}, "global">;
|
|
462
|
-
export declare const
|
|
462
|
+
export declare const helpdeskReplyEntity: import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
|
|
463
463
|
readonly requestId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
|
|
464
464
|
required: true;
|
|
465
465
|
};
|
|
@@ -516,7 +516,7 @@ export declare const contactReplyEntity: import("@cosmicdrift/kumiko-types/field
|
|
|
516
516
|
required: true;
|
|
517
517
|
};
|
|
518
518
|
}, "global">;
|
|
519
|
-
export declare const
|
|
519
|
+
export declare const helpdeskRequestTable: import("@cosmicdrift/kumiko-framework/db").EntityTable<import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
|
|
520
520
|
readonly kind: {
|
|
521
521
|
readonly type: "select";
|
|
522
522
|
readonly description?: string;
|
|
@@ -718,7 +718,7 @@ export declare const contactRequestTable: import("@cosmicdrift/kumiko-framework/
|
|
|
718
718
|
required: false;
|
|
719
719
|
};
|
|
720
720
|
}, "global">>;
|
|
721
|
-
export declare const
|
|
721
|
+
export declare const helpdeskReplyTable: import("@cosmicdrift/kumiko-framework/db").EntityTable<import("@cosmicdrift/kumiko-types/fields").EntityDefinition<{
|
|
722
722
|
readonly requestId: import("@cosmicdrift/kumiko-types/fields").EntityTextFieldDef & {
|
|
723
723
|
required: true;
|
|
724
724
|
};
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { buildEntityTable } from "@cosmicdrift/kumiko-framework/db";
|
|
2
2
|
import { createEntity, createFilesField, createLongTextField, createNumberField, createSelectField, createTextField, createTimestampField, } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
3
|
import { DEFAULT_RETENTION_KEEP_FOR } from "./options.js";
|
|
4
|
-
import {
|
|
4
|
+
import { HELPDESK_KIND, HELPDESK_MAX_FILES, HELPDESK_REPLY_CHANNELS, HELPDESK_SOURCE, HELPDESK_STATUS, } from "./web/constants.js";
|
|
5
5
|
const KIND_OPTIONS = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
HELPDESK_KIND.Question,
|
|
7
|
+
HELPDESK_KIND.Contact,
|
|
8
|
+
HELPDESK_KIND.Bug,
|
|
9
|
+
HELPDESK_KIND.Wish,
|
|
10
10
|
];
|
|
11
|
-
const STATUS_OPTIONS = [
|
|
12
|
-
|
|
11
|
+
const STATUS_OPTIONS = [
|
|
12
|
+
HELPDESK_STATUS.Open,
|
|
13
|
+
HELPDESK_STATUS.Answered,
|
|
14
|
+
HELPDESK_STATUS.Done,
|
|
15
|
+
];
|
|
16
|
+
const SOURCE_OPTIONS = [HELPDESK_SOURCE.Website, HELPDESK_SOURCE.Admin];
|
|
13
17
|
const REPLY_CHANNEL_OPTIONS = [
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
HELPDESK_REPLY_CHANNELS.Email,
|
|
19
|
+
HELPDESK_REPLY_CHANNELS.EmailAndInApp,
|
|
16
20
|
];
|
|
17
21
|
// A signed-in reporter is the data subject; an anonymous reporter has no user id, so the row
|
|
18
22
|
// itself is the crypto-shredding subject.
|
|
19
23
|
const REPORTER_SUBJECT = { of: "reporterUserId", whenAbsent: "self" };
|
|
20
24
|
const MAX_FILE_SIZE = "10MB";
|
|
21
|
-
export function
|
|
25
|
+
export function createHelpdeskRequestEntity(retentionKeepFor = DEFAULT_RETENTION_KEEP_FOR) {
|
|
22
26
|
return createEntity({
|
|
23
|
-
table: "
|
|
27
|
+
table: "read_helpdesk_requests",
|
|
24
28
|
description: "A message from a website visitor or a signed-in user to the platform operators (question, contact request, bug report or wish), tracked through open, answered and done as SystemAdmins process it; name, email, phone, subject and message are the reporter's personal data.",
|
|
25
29
|
systemStream: true,
|
|
26
30
|
tenancy: "global",
|
|
@@ -32,22 +36,22 @@ export function createContactRequestEntity(retentionKeepFor = DEFAULT_RETENTION_
|
|
|
32
36
|
filterable: true,
|
|
33
37
|
sortable: true,
|
|
34
38
|
optionTones: {
|
|
35
|
-
[
|
|
36
|
-
[
|
|
37
|
-
[
|
|
38
|
-
[
|
|
39
|
+
[HELPDESK_KIND.Bug]: "bad",
|
|
40
|
+
[HELPDESK_KIND.Question]: "accent",
|
|
41
|
+
[HELPDESK_KIND.Contact]: "accent",
|
|
42
|
+
[HELPDESK_KIND.Wish]: "neutral",
|
|
39
43
|
},
|
|
40
44
|
}),
|
|
41
45
|
status: createSelectField({
|
|
42
46
|
options: STATUS_OPTIONS,
|
|
43
47
|
required: true,
|
|
44
|
-
default:
|
|
48
|
+
default: HELPDESK_STATUS.Open,
|
|
45
49
|
filterable: true,
|
|
46
50
|
sortable: true,
|
|
47
51
|
optionTones: {
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
52
|
+
[HELPDESK_STATUS.Open]: "warn",
|
|
53
|
+
[HELPDESK_STATUS.Answered]: "accent",
|
|
54
|
+
[HELPDESK_STATUS.Done]: "ok",
|
|
51
55
|
},
|
|
52
56
|
}),
|
|
53
57
|
source: createSelectField({
|
|
@@ -85,7 +89,7 @@ export function createContactRequestEntity(retentionKeepFor = DEFAULT_RETENTION_
|
|
|
85
89
|
browser: createTextField({ personal: false, reason: "is_browser_summary" }),
|
|
86
90
|
locale: createTextField({ personal: false, reason: "is_ui_language_preference" }),
|
|
87
91
|
fileIds: createFilesField({
|
|
88
|
-
maxCount:
|
|
92
|
+
maxCount: HELPDESK_MAX_FILES,
|
|
89
93
|
maxSize: MAX_FILE_SIZE,
|
|
90
94
|
personal: REPORTER_SUBJECT,
|
|
91
95
|
}),
|
|
@@ -102,9 +106,9 @@ export function createContactRequestEntity(retentionKeepFor = DEFAULT_RETENTION_
|
|
|
102
106
|
},
|
|
103
107
|
});
|
|
104
108
|
}
|
|
105
|
-
export function
|
|
109
|
+
export function createHelpdeskReplyEntity(retentionKeepFor = DEFAULT_RETENTION_KEEP_FOR) {
|
|
106
110
|
return createEntity({
|
|
107
|
-
table: "
|
|
111
|
+
table: "read_helpdesk_replies",
|
|
108
112
|
description: "A SystemAdmin's answer to a contact request, with the channels it went out on; the message is the reporter's personal data because it quotes and addresses them.",
|
|
109
113
|
systemStream: true,
|
|
110
114
|
tenancy: "global",
|
|
@@ -124,7 +128,7 @@ export function createContactReplyEntity(retentionKeepFor = DEFAULT_RETENTION_KE
|
|
|
124
128
|
}),
|
|
125
129
|
authorName: createTextField({ required: true, personal: false, reason: "is_admin_label" }),
|
|
126
130
|
fileIds: createFilesField({
|
|
127
|
-
maxCount:
|
|
131
|
+
maxCount: HELPDESK_MAX_FILES,
|
|
128
132
|
maxSize: MAX_FILE_SIZE,
|
|
129
133
|
personal: false,
|
|
130
134
|
reason: "is_business_data",
|
|
@@ -139,7 +143,7 @@ export function createContactReplyEntity(retentionKeepFor = DEFAULT_RETENTION_KE
|
|
|
139
143
|
},
|
|
140
144
|
});
|
|
141
145
|
}
|
|
142
|
-
export const
|
|
143
|
-
export const
|
|
144
|
-
export const
|
|
145
|
-
export const
|
|
146
|
+
export const helpdeskRequestEntity = createHelpdeskRequestEntity();
|
|
147
|
+
export const helpdeskReplyEntity = createHelpdeskReplyEntity();
|
|
148
|
+
export const helpdeskRequestTable = buildEntityTable("helpdesk-request", helpdeskRequestEntity);
|
|
149
|
+
export const helpdeskReplyTable = buildEntityTable("helpdesk-reply", helpdeskReplyEntity);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { access, createSystemConfig, defineFeature, EXT_USER_DATA, } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { HELPDESK_CLIENT_SOURCE } from "./client/helpdesk-client-source.js";
|
|
3
|
+
import { createHelpdeskReplyEntity, createHelpdeskRequestEntity, helpdeskReplyEntity, helpdeskRequestEntity, } from "./entity.js";
|
|
4
4
|
import { createChallengeQuery } from "./handlers/challenge.query.js";
|
|
5
5
|
import { createForwardRequestHandler } from "./handlers/forward-request.write.js";
|
|
6
6
|
import { markDoneHandler } from "./handlers/mark-done.write.js";
|
|
@@ -15,25 +15,27 @@ import { createRequestListQuery } from "./handlers/request-list.query.js";
|
|
|
15
15
|
import { createSendReplyMailHandler } from "./handlers/send-reply-mail.write.js";
|
|
16
16
|
import { createSendTestHandler } from "./handlers/send-test.write.js";
|
|
17
17
|
import { createSubmitHandler } from "./handlers/submit.write.js";
|
|
18
|
-
import {
|
|
18
|
+
import { createHelpdeskI18n } from "./i18n.js";
|
|
19
19
|
import { TELEGRAM_FEATURE } from "./lib.js";
|
|
20
|
-
import {
|
|
21
|
-
import { DEFAULT_RETENTION_KEEP_FOR,
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
20
|
+
import { HELPDESK_ACKNOWLEDGEMENT_VARIABLES, HELPDESK_CONFIRMATION_VARIABLES, HELPDESK_NEW_REQUEST_VARIABLES, HELPDESK_REPLY_VARIABLES, HELPDESK_TEST_VARIABLES, helpdeskAcknowledgementTemplate, helpdeskConfirmationTemplate, helpdeskNewRequestTemplate, helpdeskReplyTemplate, helpdeskTestTemplate, inAppTemplate, telegramTemplate, } from "./mail.js";
|
|
21
|
+
import { DEFAULT_RETENTION_KEEP_FOR, resolveHelpdeskSettings, } from "./options.js";
|
|
22
|
+
import { createHelpdeskScreens } from "./screens.js";
|
|
23
|
+
import { helpdeskDeleteHook, helpdeskExportHook } from "./user-data-hooks.js";
|
|
24
|
+
import { HELPDESK_FEATURE } from "./web/constants.js";
|
|
25
25
|
const REPLY_CONTEXT_FIELDS = ["name", "email", "replyTo"];
|
|
26
|
-
export function
|
|
27
|
-
const settings =
|
|
26
|
+
export function createHelpdeskFeature(opts) {
|
|
27
|
+
const settings = resolveHelpdeskSettings(opts);
|
|
28
28
|
const telegram = opts.telegram === true;
|
|
29
29
|
const keepFor = opts.retentionKeepFor ?? DEFAULT_RETENTION_KEEP_FOR;
|
|
30
30
|
const requestEntity = keepFor === DEFAULT_RETENTION_KEEP_FOR
|
|
31
|
-
?
|
|
32
|
-
:
|
|
33
|
-
const replyEntity = keepFor === DEFAULT_RETENTION_KEEP_FOR
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
? helpdeskRequestEntity
|
|
32
|
+
: createHelpdeskRequestEntity(keepFor);
|
|
33
|
+
const replyEntity = keepFor === DEFAULT_RETENTION_KEEP_FOR
|
|
34
|
+
? helpdeskReplyEntity
|
|
35
|
+
: createHelpdeskReplyEntity(keepFor);
|
|
36
|
+
return defineFeature(HELPDESK_FEATURE, (r) => {
|
|
37
|
+
r.describe("Helpdesk inbox: an anonymous browser client (GET /helpdesk/client.js) submits questions, contact requests, bug reports and wishes behind a honeypot, a minimum submit time and a single-use proof-of-work challenge; signed-in users file reports from the admin. Every request is stored platform-wide and every SystemAdmin is notified by mail, optionally also in a Telegram chat (option `telegram`, off by default); the notification names only the kind, the app and a link, never name, address, phone, subject or message, because mail and Telegram cannot be shredded. SystemAdmins reply by mail (Reply-To set, attachments, quoting the original) and mark requests done; a website sender gets a fixed acknowledgement, a signed-in reporter a copy and an in-app note. Personal data is crypto-shredding-ready and the EXT_USER_DATA hooks export and erase a user's requests.");
|
|
38
|
+
r.uiHints({ displayLabel: "Helpdesk", category: "communication", recommended: false });
|
|
37
39
|
r.systemScope();
|
|
38
40
|
r.requires({ features: ["config", "delivery", "user-data-rights", "files", "notes-history"] });
|
|
39
41
|
// The feature manifest and reference are built from one mounted instance, so the off
|
|
@@ -43,7 +45,7 @@ export function createContactFeature(opts) {
|
|
|
43
45
|
else
|
|
44
46
|
r.optionalRequires(TELEGRAM_FEATURE);
|
|
45
47
|
r.adoptsBundledLists();
|
|
46
|
-
r.translations({ keys:
|
|
48
|
+
r.translations({ keys: createHelpdeskI18n() });
|
|
47
49
|
r.config({
|
|
48
50
|
keys: {
|
|
49
51
|
replyTo: createSystemConfig("text", {
|
|
@@ -67,32 +69,34 @@ export function createContactFeature(opts) {
|
|
|
67
69
|
});
|
|
68
70
|
}
|
|
69
71
|
r.notification("new-request", {
|
|
70
|
-
variables:
|
|
71
|
-
localizedTemplate:
|
|
72
|
+
variables: HELPDESK_NEW_REQUEST_VARIABLES,
|
|
73
|
+
localizedTemplate: helpdeskNewRequestTemplate,
|
|
72
74
|
...(telegram && { templates: { telegram: telegramTemplate } }),
|
|
73
75
|
});
|
|
74
76
|
r.notification("confirmation", {
|
|
75
|
-
variables:
|
|
76
|
-
localizedTemplate:
|
|
77
|
+
variables: HELPDESK_CONFIRMATION_VARIABLES,
|
|
78
|
+
localizedTemplate: helpdeskConfirmationTemplate,
|
|
77
79
|
});
|
|
78
80
|
r.notification("acknowledgement", {
|
|
79
|
-
variables:
|
|
80
|
-
localizedTemplate:
|
|
81
|
+
variables: HELPDESK_ACKNOWLEDGEMENT_VARIABLES,
|
|
82
|
+
localizedTemplate: helpdeskAcknowledgementTemplate,
|
|
81
83
|
});
|
|
82
84
|
r.notification("reply", {
|
|
83
|
-
variables:
|
|
84
|
-
localizedTemplate:
|
|
85
|
+
variables: HELPDESK_REPLY_VARIABLES,
|
|
86
|
+
localizedTemplate: helpdeskReplyTemplate,
|
|
87
|
+
});
|
|
88
|
+
r.notification("reply-in-app", {
|
|
89
|
+
templates: { inApp: inAppTemplate },
|
|
85
90
|
});
|
|
86
|
-
r.notification("reply-in-app", { templates: { inApp: inAppTemplate } });
|
|
87
91
|
if (telegram) {
|
|
88
92
|
r.notification("test", {
|
|
89
|
-
variables:
|
|
90
|
-
localizedTemplate:
|
|
93
|
+
variables: HELPDESK_TEST_VARIABLES,
|
|
94
|
+
localizedTemplate: helpdeskTestTemplate,
|
|
91
95
|
templates: { telegram: telegramTemplate },
|
|
92
96
|
});
|
|
93
97
|
}
|
|
94
|
-
r.entity({ name: "
|
|
95
|
-
r.entity({ name: "
|
|
98
|
+
r.entity({ name: "helpdesk-request", ...requestEntity });
|
|
99
|
+
r.entity({ name: "helpdesk-reply", ...replyEntity });
|
|
96
100
|
r.writeHandler(createSubmitHandler(opts, settings));
|
|
97
101
|
r.writeHandler(createReportHandler(opts, settings));
|
|
98
102
|
r.writeHandler(createForwardRequestHandler(opts));
|
|
@@ -109,24 +113,24 @@ export function createContactFeature(opts) {
|
|
|
109
113
|
r.queryHandler(createRequestDetailQuery(opts));
|
|
110
114
|
r.queryHandler(repliesQuery);
|
|
111
115
|
r.queryHandler(createRequestDeliveryQuery(opts));
|
|
112
|
-
for (const screen of
|
|
116
|
+
for (const screen of createHelpdeskScreens(opts, settings))
|
|
113
117
|
r.screen(screen);
|
|
114
118
|
r.httpRoute({
|
|
115
119
|
method: "GET",
|
|
116
|
-
// A literal, not
|
|
117
|
-
path: "/
|
|
120
|
+
// A literal, not HELPDESK_CLIENT_PATH: the feature-AST extractor only reads string literals.
|
|
121
|
+
path: "/helpdesk/client.js",
|
|
118
122
|
anonymous: true,
|
|
119
|
-
handler: async (c) => c.body(
|
|
123
|
+
handler: async (c) => c.body(HELPDESK_CLIENT_SOURCE, 200, {
|
|
120
124
|
"content-type": "application/javascript; charset=utf-8",
|
|
121
125
|
"cache-control": "public, max-age=300",
|
|
122
126
|
}),
|
|
123
127
|
});
|
|
124
|
-
r.useExtension(EXT_USER_DATA, "
|
|
125
|
-
export:
|
|
126
|
-
delete:
|
|
128
|
+
r.useExtension(EXT_USER_DATA, "helpdesk-request", {
|
|
129
|
+
export: helpdeskExportHook,
|
|
130
|
+
delete: helpdeskDeleteHook,
|
|
127
131
|
});
|
|
128
|
-
// Replies are exported nested under their request and erased with it (
|
|
129
|
-
r.useExtension(EXT_USER_DATA, "
|
|
132
|
+
// Replies are exported nested under their request and erased with it (helpdeskDeleteHook).
|
|
133
|
+
r.useExtension(EXT_USER_DATA, "helpdesk-reply", {
|
|
130
134
|
export: async () => null,
|
|
131
135
|
delete: async () => { },
|
|
132
136
|
});
|
|
@@ -8,7 +8,7 @@ declare const attemptSchema: z.ZodObject<{
|
|
|
8
8
|
status: z.ZodString;
|
|
9
9
|
createdAt: z.ZodCustom<globalThis.Temporal.Instant, globalThis.Temporal.Instant>;
|
|
10
10
|
}, z.core.$strip>;
|
|
11
|
-
export type
|
|
12
|
-
export declare function loadAttemptsByKey(ctx: Pick<HandlerContext, "dispatch">, user: SessionUser, keys: readonly string[]): Promise<readonly
|
|
11
|
+
export type HelpdeskAttempt = z.infer<typeof attemptSchema>;
|
|
12
|
+
export declare function loadAttemptsByKey(ctx: Pick<HandlerContext, "dispatch">, user: SessionUser, keys: readonly string[]): Promise<readonly HelpdeskAttempt[]>;
|
|
13
13
|
export declare function loadReadAtByKey(ctx: Pick<HandlerContext, "dispatch" | "registry">, reporterTenantId: TenantId, keys: readonly string[]): Promise<ReadonlyMap<string, Temporal.Instant | null>>;
|
|
14
14
|
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type HelpdeskSettings } from "../options.ts";
|
|
2
|
+
import { type HelpdeskPhoneMode } from "../web/constants.ts";
|
|
3
|
+
export type HelpdeskChallengeData = {
|
|
4
|
+
readonly challenge: string;
|
|
5
|
+
readonly bits: number;
|
|
6
|
+
readonly phone: HelpdeskPhoneMode;
|
|
7
|
+
readonly kinds: readonly string[];
|
|
8
|
+
};
|
|
9
|
+
export declare function createChallengeQuery(settings: HelpdeskSettings): import("@cosmicdrift/kumiko-types/define-handler").QueryHandlerDefinition<"challenge", import("zod").ZodObject<{}, import("zod/v4/core").$strict>, HelpdeskChallengeData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap>;
|
|
@@ -2,13 +2,13 @@ import { defineQueryHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
|
2
2
|
import { InternalError } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
3
|
import { issueChallenge } from "../challenge.js";
|
|
4
4
|
import { CHALLENGE_RATE_LIMIT } from "../options.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { HelpdeskEmptySchema } from "../payloads.js";
|
|
6
|
+
import { HELPDESK_WEBSITE_KINDS } from "../web/constants.js";
|
|
7
7
|
import { SUBMIT_ROLES } from "./access.js";
|
|
8
8
|
export function createChallengeQuery(settings) {
|
|
9
9
|
return defineQueryHandler({
|
|
10
10
|
name: "challenge",
|
|
11
|
-
schema:
|
|
11
|
+
schema: HelpdeskEmptySchema,
|
|
12
12
|
access: { roles: SUBMIT_ROLES, personalData: "public-intake", anySignedIn: true },
|
|
13
13
|
rateLimit: CHALLENGE_RATE_LIMIT,
|
|
14
14
|
agent: { expose: false },
|
|
@@ -16,7 +16,7 @@ export function createChallengeQuery(settings) {
|
|
|
16
16
|
handler: async (_event, ctx) => {
|
|
17
17
|
if (!ctx.services.redis) {
|
|
18
18
|
throw new InternalError({
|
|
19
|
-
message: "
|
|
19
|
+
message: "helpdesk:challenge requires ctx.services.redis for the challenge store",
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
const challenge = await issueChallenge(ctx.services.redis, {
|
|
@@ -28,7 +28,7 @@ export function createChallengeQuery(settings) {
|
|
|
28
28
|
challenge,
|
|
29
29
|
bits: settings.proofOfWorkBits,
|
|
30
30
|
phone: settings.phone,
|
|
31
|
-
kinds:
|
|
31
|
+
kinds: HELPDESK_WEBSITE_KINDS,
|
|
32
32
|
};
|
|
33
33
|
},
|
|
34
34
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HelpdeskOptions } from "../options.ts";
|
|
2
|
+
export type HelpdeskForwardData = {
|
|
3
|
+
readonly kind: "forwarded";
|
|
4
|
+
readonly adminCount: number;
|
|
5
|
+
readonly telegram: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function createForwardRequestHandler(opts: HelpdeskOptions): import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"forward-request", import("zod").ZodObject<{
|
|
8
|
+
requestId: import("zod").ZodUUID;
|
|
9
|
+
}, import("zod/v4/core").$strict>, HelpdeskForwardData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import { NotFoundError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import { helpdeskDb, internalAccess, listSystemAdminIds, platformActor, requestExecutor, sendBestEffort, } from "../lib.js";
|
|
4
|
+
import { helpdeskNewRequestVariables, resolveHelpdeskMailLocale } from "../mail.js";
|
|
5
|
+
import { HelpdeskForwardRequestSchema } from "../payloads.js";
|
|
6
|
+
import { HELPDESK_NOTIFICATION_TYPES, HELPDESK_REQUEST_ENTITY, HelpdeskConfigKeys, helpdeskIdempotencyKeys, } from "../web/constants.js";
|
|
7
7
|
const EMAIL_CHANNEL = "email";
|
|
8
8
|
// Runs as the platform identity so the notification, the config and the bot token secret are
|
|
9
9
|
// read in the system tenant, whoever filed the request.
|
|
10
10
|
export function createForwardRequestHandler(opts) {
|
|
11
11
|
return defineWriteHandler({
|
|
12
12
|
name: "forward-request",
|
|
13
|
-
schema:
|
|
13
|
+
schema: HelpdeskForwardRequestSchema,
|
|
14
14
|
access: internalAccess,
|
|
15
15
|
agent: { expose: false },
|
|
16
16
|
description: "Internal: forwards a stored contact request to every SystemAdmin by mail and, when a Telegram chat is configured, to that chat. Only the platform identity can call it.",
|
|
17
17
|
handler: async (event, ctx) => {
|
|
18
|
-
const db =
|
|
18
|
+
const db = helpdeskDb(ctx);
|
|
19
19
|
const request = await requestExecutor.detail({ id: event.payload.requestId }, platformActor(), db);
|
|
20
20
|
if (!request) {
|
|
21
|
-
return writeFailure(new NotFoundError(
|
|
21
|
+
return writeFailure(new NotFoundError(HELPDESK_REQUEST_ENTITY, event.payload.requestId));
|
|
22
22
|
}
|
|
23
23
|
const requestId = event.payload.requestId;
|
|
24
24
|
const adminLocale = opts.adminLocale;
|
|
25
25
|
const link = opts.requestLink?.(requestId);
|
|
26
|
-
const data =
|
|
26
|
+
const data = helpdeskNewRequestVariables({
|
|
27
27
|
kind: request.kind,
|
|
28
28
|
appName: opts.appName,
|
|
29
29
|
link,
|
|
@@ -31,25 +31,27 @@ export function createForwardRequestHandler(opts) {
|
|
|
31
31
|
});
|
|
32
32
|
const adminIds = await listSystemAdminIds(db);
|
|
33
33
|
if (adminIds.length > 0) {
|
|
34
|
-
await sendBestEffort(ctx, "admin mail", (notify) => notify(
|
|
34
|
+
await sendBestEffort(ctx, "admin mail", (notify) => notify(HELPDESK_NOTIFICATION_TYPES.newRequest, {
|
|
35
35
|
to: adminIds,
|
|
36
36
|
channels: [EMAIL_CHANNEL],
|
|
37
37
|
data,
|
|
38
|
-
idempotencyKey:
|
|
38
|
+
idempotencyKey: helpdeskIdempotencyKeys.admins(requestId),
|
|
39
39
|
priority: "normal",
|
|
40
|
-
locale:
|
|
40
|
+
locale: resolveHelpdeskMailLocale(adminLocale),
|
|
41
41
|
}));
|
|
42
42
|
}
|
|
43
|
-
const chatId = opts.telegram
|
|
43
|
+
const chatId = opts.telegram
|
|
44
|
+
? await ctx.config?.(HelpdeskConfigKeys.telegramChat)
|
|
45
|
+
: undefined;
|
|
44
46
|
const telegram = opts.telegram === true && typeof chatId === "string" && chatId.trim() !== "";
|
|
45
47
|
if (telegram) {
|
|
46
|
-
await sendBestEffort(ctx, "telegram", (notify) => notify(
|
|
48
|
+
await sendBestEffort(ctx, "telegram", (notify) => notify(HELPDESK_NOTIFICATION_TYPES.newRequest, {
|
|
47
49
|
route: { telegram: chatId.trim() },
|
|
48
50
|
recipientId: requestId,
|
|
49
51
|
data,
|
|
50
|
-
idempotencyKey:
|
|
52
|
+
idempotencyKey: helpdeskIdempotencyKeys.telegram(requestId),
|
|
51
53
|
priority: "normal",
|
|
52
|
-
locale:
|
|
54
|
+
locale: resolveHelpdeskMailLocale(adminLocale),
|
|
53
55
|
}));
|
|
54
56
|
}
|
|
55
57
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type HelpdeskMarkDoneData = {
|
|
2
2
|
readonly kind: "marked";
|
|
3
3
|
readonly changed: number;
|
|
4
4
|
};
|
|
5
5
|
export declare const markDoneHandler: import("@cosmicdrift/kumiko-types/define-handler").WriteHandlerDefinition<"mark-done", import("zod").ZodObject<{
|
|
6
6
|
id: import("zod").ZodUUID;
|
|
7
|
-
}, import("zod/v4/core").$strict>,
|
|
7
|
+
}, import("zod/v4/core").$strict>, HelpdeskMarkDoneData, import("@cosmicdrift/kumiko-types/event-type-map").KumikoEventTypeMap, undefined, undefined>;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { defineWriteHandler } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import { NotFoundError, writeFailure } from "@cosmicdrift/kumiko-framework/errors";
|
|
3
|
-
import { adminAccess,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { adminAccess, helpdeskDb, platformActor, requestExecutor } from "../lib.js";
|
|
4
|
+
import { HelpdeskMarkDoneSchema } from "../payloads.js";
|
|
5
|
+
import { HELPDESK_REQUEST_ENTITY, HELPDESK_STATUS } from "../web/constants.js";
|
|
6
6
|
export const markDoneHandler = defineWriteHandler({
|
|
7
7
|
name: "mark-done",
|
|
8
|
-
schema:
|
|
8
|
+
schema: HelpdeskMarkDoneSchema,
|
|
9
9
|
access: adminAccess,
|
|
10
10
|
agent: { expose: false },
|
|
11
11
|
description: "Marks one contact request as done without sending a reply; a finished request is left as it is.",
|
|
12
12
|
handler: async (event, ctx) => {
|
|
13
|
-
const db =
|
|
13
|
+
const db = helpdeskDb(ctx);
|
|
14
14
|
const { id } = event.payload;
|
|
15
15
|
const request = await requestExecutor.detail({ id }, platformActor(), db);
|
|
16
16
|
if (!request)
|
|
17
|
-
return writeFailure(new NotFoundError(
|
|
18
|
-
if (request.status ===
|
|
17
|
+
return writeFailure(new NotFoundError(HELPDESK_REQUEST_ENTITY, id));
|
|
18
|
+
if (request.status === HELPDESK_STATUS.Done) {
|
|
19
19
|
return { isSuccess: true, data: { kind: "marked", changed: 0 } };
|
|
20
20
|
}
|
|
21
21
|
const updated = await requestExecutor.update({
|
|
22
22
|
id,
|
|
23
23
|
version: request.version,
|
|
24
|
-
changes: { status:
|
|
24
|
+
changes: { status: HELPDESK_STATUS.Done, closedAt: ctx.tz.now() },
|
|
25
25
|
}, platformActor(), db);
|
|
26
26
|
if (!updated.isSuccess)
|
|
27
27
|
return updated;
|