@cosmicdrift/kumiko-bundled-features 0.412.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/api-docs/anchors.js +1 -1
- 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/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/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/scope-events-check.js +7 -4
- 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/{contact → helpdesk}/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 → helpdesk}/challenge.d.ts +0 -0
- /package/dist/{contact/client/contact-website-client.js → helpdesk/client/helpdesk-website-client.js} +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
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createWebhookContractResolver, } from "@cosmicdrift/kumiko-framework/engine";
|
|
1
|
+
import { bootRuleError, createWebhookContractResolver, } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { PERSONAL_ACCESS_TOKENS_BOOT_RULES } from "./boot-rules.js";
|
|
2
3
|
import { PAT_FEATURE } from "./web/constants.js";
|
|
3
4
|
function entityNameOf(qualifiedName) {
|
|
4
5
|
const dot = qualifiedName.lastIndexOf(".");
|
|
@@ -10,9 +11,11 @@ export function validateScopeEventContracts(scopes, features) {
|
|
|
10
11
|
for (const qn of def.events ?? []) {
|
|
11
12
|
if (resolver.get(qn))
|
|
12
13
|
continue;
|
|
13
|
-
throw
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
throw bootRuleError(PERSONAL_ACCESS_TOKENS_BOOT_RULES.scopeEventWithoutContract, {
|
|
15
|
+
message: `[${PAT_FEATURE}] scope "${domain}" lists event "${qn}" without a public contract. ` +
|
|
16
|
+
"Declare it with r.defineWebhookEvent(...), or set webhookEvents: true on the entity to release its <entity>.created/.updated/.deleted events " +
|
|
17
|
+
`(entity "${entityNameOf(qn)}" has no such opt-in); internal r.defineEvent events are never released.`,
|
|
18
|
+
});
|
|
16
19
|
}
|
|
17
20
|
}
|
|
18
21
|
}
|
package/dist/presence/options.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { PRESENCE_BOOT_RULES } from "./boot-rules.js";
|
|
1
3
|
export const PRESENCE_DEFAULT_ROLES = ["TenantAdmin", "TenantMember"];
|
|
2
4
|
export const PRESENCE_DEFAULT_TTL_SECONDS = 45;
|
|
3
5
|
export function resolvePresenceSettings(options) {
|
|
4
6
|
const ttlSeconds = options.ttlSeconds ?? PRESENCE_DEFAULT_TTL_SECONDS;
|
|
5
7
|
if (!Number.isFinite(ttlSeconds) || ttlSeconds <= 0) {
|
|
6
|
-
throw
|
|
8
|
+
throw bootRuleError(PRESENCE_BOOT_RULES.invalidTtlSeconds, {
|
|
9
|
+
message: `presence: ttlSeconds must be a positive number, got ${ttlSeconds}`,
|
|
10
|
+
});
|
|
7
11
|
}
|
|
8
12
|
return {
|
|
9
13
|
entities: new Set(options.entities ?? []),
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const READINESS_BOOT_RULES: {
|
|
2
|
+
readonly probeTranslationMissing: {
|
|
3
|
+
readonly id: "readiness/probe-translation-missing";
|
|
4
|
+
readonly summary: "Probe area and label keys are defined by a mounted feature.";
|
|
5
|
+
readonly fix: "Add the key via r.translations(...).";
|
|
6
|
+
};
|
|
7
|
+
readonly probeFixScreenUnknown: {
|
|
8
|
+
readonly id: "readiness/probe-fix-screen-unknown";
|
|
9
|
+
readonly summary: "A probe fixScreen names a screen of a mounted feature.";
|
|
10
|
+
readonly fix: "Use a <feature>:screen:<id> qualified name of a mounted screen.";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const READINESS_BOOT_RULES = {
|
|
2
|
+
probeTranslationMissing: {
|
|
3
|
+
id: "readiness/probe-translation-missing",
|
|
4
|
+
summary: "Probe area and label keys are defined by a mounted feature.",
|
|
5
|
+
fix: "Add the key via r.translations(...).",
|
|
6
|
+
},
|
|
7
|
+
probeFixScreenUnknown: {
|
|
8
|
+
id: "readiness/probe-fix-screen-unknown",
|
|
9
|
+
summary: "A probe fixScreen names a screen of a mounted feature.",
|
|
10
|
+
fix: "Use a <feature>:screen:<id> qualified name of a mounted screen.",
|
|
11
|
+
},
|
|
12
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { buildConfigFeatureSchema, createRegistry, SETTINGS_HUB_FEATURE, } from "@cosmicdrift/kumiko-framework/engine";
|
|
1
|
+
import { bootRuleError, buildConfigFeatureSchema, createRegistry, SETTINGS_HUB_FEATURE, } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { READINESS_BOOT_RULES } from "./boot-rules.js";
|
|
2
3
|
// Settings screens come from config keys at schema build, not from r.screen, yet a probe may
|
|
3
4
|
// link a failed row to one (mail sending lives on config:screen:mail-foundation-tenant).
|
|
4
5
|
function mountedScreenQns(features) {
|
|
@@ -28,11 +29,15 @@ export function validateProbeTranslations(features) {
|
|
|
28
29
|
["label", probe.label],
|
|
29
30
|
]) {
|
|
30
31
|
if (!defined.has(key)) {
|
|
31
|
-
throw
|
|
32
|
+
throw bootRuleError(READINESS_BOOT_RULES.probeTranslationMissing, {
|
|
33
|
+
message: `Probe "${probe.qualifiedName}": ${field} translation key "${key}" is not defined by any mounted feature. Add it via r.translations(...).`,
|
|
34
|
+
});
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
if (probe.fixScreen !== undefined && !screenQns.has(probe.fixScreen)) {
|
|
35
|
-
throw
|
|
38
|
+
throw bootRuleError(READINESS_BOOT_RULES.probeFixScreenUnknown, {
|
|
39
|
+
message: `Probe "${probe.qualifiedName}": fixScreen "${probe.fixScreen}" is not a screen of any mounted feature. Use a "<feature>:screen:<id>" QN.`,
|
|
40
|
+
});
|
|
36
41
|
}
|
|
37
42
|
}
|
|
38
43
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type OwnershipMap } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
export declare function assertNoWhereRuleInOwnershipWrite(factoryName: string, writeOwnership: OwnershipMap | undefined): void;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { bootRuleError } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { SHARED_BOOT_RULES } from "./boot-rules.js";
|
|
1
3
|
// Boot validation rejects `{ kind: "where" }` in access.write too;
|
|
2
4
|
// failing at factory time names the option instead of an entity scope.
|
|
3
5
|
export function assertNoWhereRuleInOwnershipWrite(factoryName, writeOwnership) {
|
|
@@ -8,11 +10,13 @@ export function assertNoWhereRuleInOwnershipWrite(factoryName, writeOwnership) {
|
|
|
8
10
|
// skip: no where-rule present, the option is valid
|
|
9
11
|
if (!hasWhereRule)
|
|
10
12
|
return;
|
|
11
|
-
throw
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
throw bootRuleError(SHARED_BOOT_RULES.whereRuleInOwnershipWrite, {
|
|
14
|
+
message: `${factoryName}({ ownership }): ownership.write must not contain a ` +
|
|
15
|
+
'`{ kind: "where" }` rule — where-rules are evaluated only at the SQL ' +
|
|
16
|
+
"layer (the read path, via buildOwnershipClause). Write paths that " +
|
|
17
|
+
"consult access.write (userCanCreateFieldRow/userCanWriteFieldRow) can't " +
|
|
18
|
+
"evaluate them, so such a rule can only ever deny — boot validation " +
|
|
19
|
+
"rejects it too (fw#2626). Use a `from()` rule for ownership.write, or " +
|
|
20
|
+
"leave it unset.",
|
|
21
|
+
});
|
|
18
22
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const SHARED_BOOT_RULES: {
|
|
2
|
+
readonly whereRuleInOwnershipWrite: {
|
|
3
|
+
readonly id: "shared/where-rule-in-ownership-write";
|
|
4
|
+
readonly summary: "ownership.write of a bundled-feature factory contains no where rule.";
|
|
5
|
+
readonly fix: "Drop the where rule from ownership.write; it only applies on the read path.";
|
|
6
|
+
};
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const SHARED_BOOT_RULES = {
|
|
2
|
+
whereRuleInOwnershipWrite: {
|
|
3
|
+
id: "shared/where-rule-in-ownership-write",
|
|
4
|
+
summary: "ownership.write of a bundled-feature factory contains no where rule.",
|
|
5
|
+
fix: "Drop the where rule from ownership.write; it only applies on the read path.",
|
|
6
|
+
},
|
|
7
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const SUBSCRIPTION_MOLLIE_BOOT_RULES: {
|
|
2
|
+
readonly emptyApiKey: {
|
|
3
|
+
readonly id: "subscription-mollie/empty-api-key";
|
|
4
|
+
readonly summary: "The Mollie provider receives a non-empty apiKey.";
|
|
5
|
+
readonly fix: "Set MOLLIE_API_KEY before mounting.";
|
|
6
|
+
};
|
|
7
|
+
readonly emptyWebhookUrl: {
|
|
8
|
+
readonly id: "subscription-mollie/empty-webhook-url";
|
|
9
|
+
readonly summary: "The Mollie provider receives a non-empty webhookUrl.";
|
|
10
|
+
readonly fix: "Pass the foundation webhook URL Mollie sends events to.";
|
|
11
|
+
};
|
|
12
|
+
readonly priceMapDrift: {
|
|
13
|
+
readonly id: "subscription-mollie/price-map-drift";
|
|
14
|
+
readonly summary: "priceToTier and priceToConfig declare the same price ids.";
|
|
15
|
+
readonly fix: "Make both maps list the same price ids.";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const SUBSCRIPTION_MOLLIE_BOOT_RULES = {
|
|
2
|
+
emptyApiKey: {
|
|
3
|
+
id: "subscription-mollie/empty-api-key",
|
|
4
|
+
summary: "The Mollie provider receives a non-empty apiKey.",
|
|
5
|
+
fix: "Set MOLLIE_API_KEY before mounting.",
|
|
6
|
+
},
|
|
7
|
+
emptyWebhookUrl: {
|
|
8
|
+
id: "subscription-mollie/empty-webhook-url",
|
|
9
|
+
summary: "The Mollie provider receives a non-empty webhookUrl.",
|
|
10
|
+
fix: "Pass the foundation webhook URL Mollie sends events to.",
|
|
11
|
+
},
|
|
12
|
+
priceMapDrift: {
|
|
13
|
+
id: "subscription-mollie/price-map-drift",
|
|
14
|
+
summary: "priceToTier and priceToConfig declare the same price ids.",
|
|
15
|
+
fix: "Make both maps list the same price ids.",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -38,9 +38,10 @@
|
|
|
38
38
|
// },
|
|
39
39
|
// }),
|
|
40
40
|
// ];
|
|
41
|
-
import { defineFeature } from "@cosmicdrift/kumiko-framework/engine";
|
|
41
|
+
import { bootRuleError, defineFeature, } from "@cosmicdrift/kumiko-framework/engine";
|
|
42
42
|
import { createMollieClient } from "@mollie/api-client";
|
|
43
43
|
import * as z from "zod";
|
|
44
|
+
import { SUBSCRIPTION_MOLLIE_BOOT_RULES } from "./boot-rules.js";
|
|
44
45
|
import { MOLLIE_PROVIDER_NAME, SUBSCRIPTION_MOLLIE_FEATURE } from "./constants.js";
|
|
45
46
|
import { createMollieCheckoutSession } from "./plugin-methods.js";
|
|
46
47
|
import { verifyAndParseMollieWebhook } from "./verify-webhook.js";
|
|
@@ -59,10 +60,14 @@ export const subscriptionMollieEnvSchema = z.object({
|
|
|
59
60
|
});
|
|
60
61
|
export function createSubscriptionMollieFeature(options) {
|
|
61
62
|
if (options.apiKey.length === 0) {
|
|
62
|
-
throw
|
|
63
|
+
throw bootRuleError(SUBSCRIPTION_MOLLIE_BOOT_RULES.emptyApiKey, {
|
|
64
|
+
message: "subscription-mollie: apiKey is empty. Set MOLLIE_API_KEY (or system-config) before mounting.",
|
|
65
|
+
});
|
|
63
66
|
}
|
|
64
67
|
if (options.webhookUrl.length === 0) {
|
|
65
|
-
throw
|
|
68
|
+
throw bootRuleError(SUBSCRIPTION_MOLLIE_BOOT_RULES.emptyWebhookUrl, {
|
|
69
|
+
message: "subscription-mollie: webhookUrl is empty. Set the foundation-webhook-URL where Mollie sends events.",
|
|
70
|
+
});
|
|
66
71
|
}
|
|
67
72
|
// Drift guard: priceToTier and priceToConfig must have identical keys;
|
|
68
73
|
// otherwise verifyAndParseWebhook silently returns null.
|
|
@@ -71,9 +76,11 @@ export function createSubscriptionMollieFeature(options) {
|
|
|
71
76
|
const missingInConfig = [...tierKeys].filter((k) => !configKeys.has(k));
|
|
72
77
|
const missingInTier = [...configKeys].filter((k) => !tierKeys.has(k));
|
|
73
78
|
if (missingInConfig.length > 0 || missingInTier.length > 0) {
|
|
74
|
-
throw
|
|
75
|
-
`
|
|
76
|
-
|
|
79
|
+
throw bootRuleError(SUBSCRIPTION_MOLLIE_BOOT_RULES.priceMapDrift, {
|
|
80
|
+
message: `subscription-mollie: priceToTier ↔ priceToConfig drift — ` +
|
|
81
|
+
`priceIds in tier but missing config: [${missingInConfig.join(", ")}]; ` +
|
|
82
|
+
`priceIds in config but missing tier: [${missingInTier.join(", ")}]`,
|
|
83
|
+
});
|
|
77
84
|
}
|
|
78
85
|
const client = createMollieClient({ apiKey: options.apiKey });
|
|
79
86
|
// Adapter that binds the plugin's minimal fetch client to the full Mollie
|
package/dist/tags/feature.js
CHANGED
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
// Convention aliases tag:{create,update,delete} + tag:detail back the
|
|
18
18
|
// entityList/entityEdit catalog screens (legacy QNs stay for TagManager).
|
|
19
19
|
// Deferred: optional host-projection decoration (`wireTagsFor`), search indexing.
|
|
20
|
-
import { defineEntityDetailHandler, defineEntityListHandler, defineEntityUpdateHandler, defineFeature, } from "@cosmicdrift/kumiko-framework/engine";
|
|
20
|
+
import { bootRuleError, defineEntityDetailHandler, defineEntityListHandler, defineEntityUpdateHandler, defineFeature, } from "@cosmicdrift/kumiko-framework/engine";
|
|
21
21
|
import { assertNoWhereRuleInOwnershipWrite, resolveFeatureAccess } from "../shared/index.js";
|
|
22
|
+
import { TAGS_BOOT_RULES } from "./boot-rules.js";
|
|
22
23
|
import { createTagAssignmentEntity, tagEntity } from "./entity.js";
|
|
23
24
|
import { createTagAssignmentExecutor } from "./executor.js";
|
|
24
25
|
import { createAssignTagHandler } from "./handlers/assign-tag.write.js";
|
|
@@ -98,10 +99,12 @@ export function createTagsFeature(opts = {}) {
|
|
|
98
99
|
return defaultTagsFeature;
|
|
99
100
|
}
|
|
100
101
|
if (opts.parents !== undefined && opts.parents.length === 0) {
|
|
101
|
-
throw
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
throw bootRuleError(TAGS_BOOT_RULES.emptyParentsAllowlist, {
|
|
103
|
+
message: "createTagsFeature({ parents }): parents must not be an empty array — " +
|
|
104
|
+
"an empty allowlist rejects every assign-tag call and hides every " +
|
|
105
|
+
"assignment row. Omit `parents` to keep every registered entity " +
|
|
106
|
+
"admissible as a host instead.",
|
|
107
|
+
});
|
|
105
108
|
}
|
|
106
109
|
assertNoWhereRuleInOwnershipWrite("createTagsFeature", opts.ownership?.write);
|
|
107
110
|
const access = resolveFeatureAccess(opts, DEFAULT_TAG_ACCESS);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const TEMPLATE_RESOLVER_BOOT_RULES: {
|
|
2
|
+
readonly collectionRefusedKind: {
|
|
3
|
+
readonly id: "template-resolver/collection-refused-kind";
|
|
4
|
+
readonly summary: "Collections only use kinds that collections may write.";
|
|
5
|
+
readonly fix: "Pick an allowed collection kind.";
|
|
6
|
+
};
|
|
7
|
+
readonly tenantEditableDuplicate: {
|
|
8
|
+
readonly id: "template-resolver/tenant-editable-duplicate";
|
|
9
|
+
readonly summary: "tenantEditable lists each kind and slug once.";
|
|
10
|
+
readonly fix: "Remove the duplicate entry.";
|
|
11
|
+
};
|
|
12
|
+
readonly tenantEditableInvalidEntry: {
|
|
13
|
+
readonly id: "template-resolver/tenant-editable-invalid-entry";
|
|
14
|
+
readonly summary: "Each tenantEditable entry has a non-empty slug and at least one access role.";
|
|
15
|
+
readonly fix: "Give the entry a slug and roles.";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const TEMPLATE_RESOLVER_BOOT_RULES = {
|
|
2
|
+
collectionRefusedKind: {
|
|
3
|
+
id: "template-resolver/collection-refused-kind",
|
|
4
|
+
summary: "Collections only use kinds that collections may write.",
|
|
5
|
+
fix: "Pick an allowed collection kind.",
|
|
6
|
+
},
|
|
7
|
+
tenantEditableDuplicate: {
|
|
8
|
+
id: "template-resolver/tenant-editable-duplicate",
|
|
9
|
+
summary: "tenantEditable lists each kind and slug once.",
|
|
10
|
+
fix: "Remove the duplicate entry.",
|
|
11
|
+
},
|
|
12
|
+
tenantEditableInvalidEntry: {
|
|
13
|
+
id: "template-resolver/tenant-editable-invalid-entry",
|
|
14
|
+
summary: "Each tenantEditable entry has a non-empty slug and at least one access role.",
|
|
15
|
+
fix: "Give the entry a slug and roles.",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createSystemConfig, defineFeature, } from "@cosmicdrift/kumiko-framework/engine";
|
|
1
|
+
import { bootRuleError, createSystemConfig, defineFeature, } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { TEMPLATE_RESOLVER_BOOT_RULES } from "./boot-rules.js";
|
|
2
3
|
import { bySlugQuery } from "./handlers/by-slug.query.js";
|
|
3
4
|
import { byTenantQuery } from "./handlers/by-tenant.query.js";
|
|
4
5
|
import { makeCollectionItemQuery } from "./handlers/collection-item.query.js";
|
|
@@ -38,7 +39,9 @@ import { DEFAULT_COLLECTION_ACCESS, isCollectionRefusedKind } from "./web/consta
|
|
|
38
39
|
function assertCollectionKindsAllowed(collections) {
|
|
39
40
|
for (const collection of collections) {
|
|
40
41
|
if (isCollectionRefusedKind(collection.kind)) {
|
|
41
|
-
throw
|
|
42
|
+
throw bootRuleError(TEMPLATE_RESOLVER_BOOT_RULES.collectionRefusedKind, {
|
|
43
|
+
message: `template-resolver: collection "${collection.id}" uses kind "${collection.kind}", which collections may not write`,
|
|
44
|
+
});
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
}
|
|
@@ -47,14 +50,20 @@ function assertTenantEditableValid(entries) {
|
|
|
47
50
|
for (const entry of entries) {
|
|
48
51
|
const key = `${entry.kind}/${entry.slug}`;
|
|
49
52
|
if (seen.has(key)) {
|
|
50
|
-
throw
|
|
53
|
+
throw bootRuleError(TEMPLATE_RESOLVER_BOOT_RULES.tenantEditableDuplicate, {
|
|
54
|
+
message: `template-resolver: tenantEditable lists "${key}" twice`,
|
|
55
|
+
});
|
|
51
56
|
}
|
|
52
57
|
seen.add(key);
|
|
53
58
|
if (entry.slug.trim() === "") {
|
|
54
|
-
throw
|
|
59
|
+
throw bootRuleError(TEMPLATE_RESOLVER_BOOT_RULES.tenantEditableInvalidEntry, {
|
|
60
|
+
message: `template-resolver: tenantEditable entry of kind "${entry.kind}" has an empty slug`,
|
|
61
|
+
});
|
|
55
62
|
}
|
|
56
63
|
if (entry.access.roles.length === 0) {
|
|
57
|
-
throw
|
|
64
|
+
throw bootRuleError(TEMPLATE_RESOLVER_BOOT_RULES.tenantEditableInvalidEntry, {
|
|
65
|
+
message: `template-resolver: tenantEditable entry "${entry.kind}/${entry.slug}" has no roles in access`,
|
|
66
|
+
});
|
|
58
67
|
}
|
|
59
68
|
}
|
|
60
69
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const TENANT_BOOT_RULES: {
|
|
2
|
+
readonly assignableRoleMissingFromScreens: {
|
|
3
|
+
readonly id: "tenant/assignable-role-missing-from-screens";
|
|
4
|
+
readonly summary: "Every assignable app role is present in the tenant screens' options.";
|
|
5
|
+
readonly fix: "Pass assignableAppRoles: collectAssignableAppRoles(appFeatures) to createTenantFeature.";
|
|
6
|
+
};
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const TENANT_BOOT_RULES = {
|
|
2
|
+
assignableRoleMissingFromScreens: {
|
|
3
|
+
id: "tenant/assignable-role-missing-from-screens",
|
|
4
|
+
summary: "Every assignable app role is present in the tenant screens' options.",
|
|
5
|
+
fix: "Pass assignableAppRoles: collectAssignableAppRoles(appFeatures) to createTenantFeature.",
|
|
6
|
+
},
|
|
7
|
+
};
|
package/dist/tenant/feature.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { access, assignableAppRolesFromUsages, createSystemConfig, createTenantConfig, defineEntityDetailHandler, defineEntityListHandler, defineEntityUpdateHandler, defineFeature, EXT_ASSIGNABLE_ROLE, i18nKey, } from "@cosmicdrift/kumiko-framework/engine";
|
|
1
|
+
import { access, assignableAppRolesFromUsages, bootRuleError, createSystemConfig, createTenantConfig, defineEntityDetailHandler, defineEntityListHandler, defineEntityUpdateHandler, defineFeature, EXT_ASSIGNABLE_ROLE, i18nKey, } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
|
+
import { TENANT_BOOT_RULES } from "./boot-rules.js";
|
|
2
3
|
import { activeTenantIdsQuery } from "./handlers/active-tenant-ids.query.js";
|
|
3
4
|
import { addMemberWrite } from "./handlers/add-member.write.js";
|
|
4
5
|
import { cancelInvitationWrite } from "./handlers/cancel-invitation.write.js";
|
|
@@ -47,7 +48,9 @@ export function createTenantFeature(options) {
|
|
|
47
48
|
for (const [role, assignableFrom] of collectAssignableAppRoles(features)) {
|
|
48
49
|
if (options?.assignableAppRoles?.get(role) === assignableFrom)
|
|
49
50
|
continue;
|
|
50
|
-
throw
|
|
51
|
+
throw bootRuleError(TENANT_BOOT_RULES.assignableRoleMissingFromScreens, {
|
|
52
|
+
message: `[tenant] assignable app role "${role}" (assignableFrom "${assignableFrom}") is declared but missing from the tenant screens' options; pass assignableAppRoles: collectAssignableAppRoles(appFeatures) to createTenantFeature.`,
|
|
53
|
+
});
|
|
51
54
|
}
|
|
52
55
|
});
|
|
53
56
|
r.entity({ name: "tenant", ...tenantEntity });
|
package/kumiko-es-tables.json
CHANGED
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"export": "configValuesTable"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
|
-
"module": "
|
|
24
|
-
"export": "
|
|
23
|
+
"module": "helpdesk/entity",
|
|
24
|
+
"export": "helpdeskRequestTable"
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
"module": "
|
|
28
|
-
"export": "
|
|
27
|
+
"module": "helpdesk/entity",
|
|
28
|
+
"export": "helpdeskReplyTable"
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
"module": "data-retention/schema/tenant-retention-override",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-bundled-features",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.413.0",
|
|
4
4
|
"description": "Built-in features — tenant, user, auth, delivery. The stuff you'd rewrite anyway, already typed.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -556,21 +556,21 @@
|
|
|
556
556
|
"types": "./dist/legal-pages/web/index.d.ts",
|
|
557
557
|
"default": "./dist/legal-pages/web/index.js"
|
|
558
558
|
},
|
|
559
|
-
"./
|
|
560
|
-
"types": "./dist/
|
|
561
|
-
"default": "./dist/
|
|
559
|
+
"./helpdesk": {
|
|
560
|
+
"types": "./dist/helpdesk/index.d.ts",
|
|
561
|
+
"default": "./dist/helpdesk/index.js"
|
|
562
562
|
},
|
|
563
563
|
"./presence": {
|
|
564
564
|
"types": "./dist/presence/index.d.ts",
|
|
565
565
|
"default": "./dist/presence/index.js"
|
|
566
566
|
},
|
|
567
|
-
"./
|
|
568
|
-
"types": "./dist/
|
|
569
|
-
"default": "./dist/
|
|
567
|
+
"./helpdesk/web": {
|
|
568
|
+
"types": "./dist/helpdesk/web/index.d.ts",
|
|
569
|
+
"default": "./dist/helpdesk/web/index.js"
|
|
570
570
|
},
|
|
571
|
-
"./
|
|
572
|
-
"types": "./dist/
|
|
573
|
-
"default": "./dist/
|
|
571
|
+
"./helpdesk/client": {
|
|
572
|
+
"types": "./dist/helpdesk/client/index.d.ts",
|
|
573
|
+
"default": "./dist/helpdesk/client/index.js"
|
|
574
574
|
},
|
|
575
575
|
"./waitlist": {
|
|
576
576
|
"types": "./dist/waitlist/index.d.ts",
|
|
@@ -614,9 +614,9 @@
|
|
|
614
614
|
}
|
|
615
615
|
},
|
|
616
616
|
"dependencies": {
|
|
617
|
-
"@cosmicdrift/kumiko-framework": "0.
|
|
618
|
-
"@cosmicdrift/kumiko-renderer": "0.
|
|
619
|
-
"@cosmicdrift/kumiko-types": "0.
|
|
617
|
+
"@cosmicdrift/kumiko-framework": "0.413.0",
|
|
618
|
+
"@cosmicdrift/kumiko-renderer": "0.413.0",
|
|
619
|
+
"@cosmicdrift/kumiko-types": "0.413.0",
|
|
620
620
|
"@mollie/api-client": "^4.6.0",
|
|
621
621
|
"@node-rs/argon2": "^2.2.2",
|
|
622
622
|
"@tiptap/core": "^3.32.2",
|
|
@@ -1188,21 +1188,21 @@
|
|
|
1188
1188
|
"types": "./dist/legal-pages/web/index.d.ts",
|
|
1189
1189
|
"default": "./dist/legal-pages/web/index.js"
|
|
1190
1190
|
},
|
|
1191
|
-
"./
|
|
1192
|
-
"types": "./dist/
|
|
1193
|
-
"default": "./dist/
|
|
1191
|
+
"./helpdesk": {
|
|
1192
|
+
"types": "./dist/helpdesk/index.d.ts",
|
|
1193
|
+
"default": "./dist/helpdesk/index.js"
|
|
1194
1194
|
},
|
|
1195
1195
|
"./presence": {
|
|
1196
1196
|
"types": "./dist/presence/index.d.ts",
|
|
1197
1197
|
"default": "./dist/presence/index.js"
|
|
1198
1198
|
},
|
|
1199
|
-
"./
|
|
1200
|
-
"types": "./dist/
|
|
1201
|
-
"default": "./dist/
|
|
1199
|
+
"./helpdesk/web": {
|
|
1200
|
+
"types": "./dist/helpdesk/web/index.d.ts",
|
|
1201
|
+
"default": "./dist/helpdesk/web/index.js"
|
|
1202
1202
|
},
|
|
1203
|
-
"./
|
|
1204
|
-
"types": "./dist/
|
|
1205
|
-
"default": "./dist/
|
|
1203
|
+
"./helpdesk/client": {
|
|
1204
|
+
"types": "./dist/helpdesk/client/index.d.ts",
|
|
1205
|
+
"default": "./dist/helpdesk/client/index.js"
|
|
1206
1206
|
},
|
|
1207
1207
|
"./waitlist": {
|
|
1208
1208
|
"types": "./dist/waitlist/index.d.ts",
|
|
@@ -1254,19 +1254,19 @@
|
|
|
1254
1254
|
"LICENSE"
|
|
1255
1255
|
],
|
|
1256
1256
|
"devDependencies": {
|
|
1257
|
-
"@cosmicdrift/kumiko-locale-de": "0.
|
|
1258
|
-
"@cosmicdrift/kumiko-locale-es": "0.
|
|
1259
|
-
"@cosmicdrift/kumiko-locale-fr": "0.
|
|
1260
|
-
"@cosmicdrift/kumiko-locale-it": "0.
|
|
1261
|
-
"@cosmicdrift/kumiko-renderer-mail-html": "0.
|
|
1262
|
-
"@cosmicdrift/kumiko-testing": "0.
|
|
1257
|
+
"@cosmicdrift/kumiko-locale-de": "0.413.0",
|
|
1258
|
+
"@cosmicdrift/kumiko-locale-es": "0.413.0",
|
|
1259
|
+
"@cosmicdrift/kumiko-locale-fr": "0.413.0",
|
|
1260
|
+
"@cosmicdrift/kumiko-locale-it": "0.413.0",
|
|
1261
|
+
"@cosmicdrift/kumiko-renderer-mail-html": "0.413.0",
|
|
1262
|
+
"@cosmicdrift/kumiko-testing": "0.413.0",
|
|
1263
1263
|
"@testing-library/user-event": "^14.6.8",
|
|
1264
1264
|
"@types/sanitize-html": "^2.16.2",
|
|
1265
1265
|
"jsqr": "^1.4.0",
|
|
1266
1266
|
"unpdf": "^1.9.1"
|
|
1267
1267
|
},
|
|
1268
1268
|
"peerDependencies": {
|
|
1269
|
-
"@cosmicdrift/kumiko-testing": "0.
|
|
1269
|
+
"@cosmicdrift/kumiko-testing": "0.413.0"
|
|
1270
1270
|
},
|
|
1271
1271
|
"peerDependenciesMeta": {
|
|
1272
1272
|
"@cosmicdrift/kumiko-testing": {
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"version": "0.413.0",
|
|
4
|
+
"type": "breaking",
|
|
5
|
+
"title": "contact feature renamed to helpdesk",
|
|
6
|
+
"migration": "The bundled feature contact is renamed to helpdesk; nothing keeps the old names. Imports: @cosmicdrift/kumiko-bundled-features/contact, /contact/web and /contact/client become /helpdesk, /helpdesk/web and /helpdesk/client; createContactFeature, contactOpenRequestsPanels, ContactOptions and the other Contact*/CONTACT_* exports become Helpdesk*/HELPDESK_* (createHelpdeskFeature, helpdeskOpenRequestsPanels, HelpdeskOptions). The feature name, handler, screen, config and i18n keys move from contact: to helpdesk:, the entities from contact-request/contact-reply to helpdesk-request/helpdesk-reply with the tables read_helpdesk_requests/read_helpdesk_replies, and error codes from contact_* to helpdesk_*. The browser client is served at GET /helpdesk/client.js and registers window.KumikoHelpdesk; update script tags, same-origin ingress paths and nav/legal references to the feature name. Notification preferences and opt-outs stored under contact:notify: are not carried over; the six notifications start with their defaults. Run kumiko schema generate and commit the migration. Data stored under the old names is not carried over: requests, replies and their events stay inert under contact-request/contact-reply, and the config values contact:config:reply-to and contact:config:telegram-chat are not read any more. Close open requests before upgrading and set reply-to and the Telegram chat again on the forwarding screen."
|
|
7
|
+
},
|
|
2
8
|
{
|
|
3
9
|
"version": "0.410.0",
|
|
4
10
|
"type": "improvement",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const CONTACT_CLIENT_SOURCE = "(function () {\n \"use strict\";\n\n var QUERY_PATH = \"/api/query\";\n var WRITE_PATH = \"/api/write\";\n var CHALLENGE_QUERY = \"contact:query:challenge\";\n var SUBMIT_WRITE = \"contact: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.KumikoContact = { load: load, submit: submit };\n})();\n";
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type * as z from "zod";
|
|
2
|
-
import type { ContactSubmitSchema } from "../payloads.ts";
|
|
3
|
-
import type { CONTACT_WEBSITE_KINDS, ContactPhoneMode } from "../web/constants.ts";
|
|
4
|
-
export type ContactWebsiteKind = (typeof CONTACT_WEBSITE_KINDS)[number];
|
|
5
|
-
export type ContactWebsiteFormOptions = {
|
|
6
|
-
readonly phone: ContactPhoneMode;
|
|
7
|
-
readonly kinds: readonly ContactWebsiteKind[];
|
|
8
|
-
};
|
|
9
|
-
export type ContactWebsiteSubmitFields = Omit<z.input<typeof ContactSubmitSchema>, "challenge" | "nonce" | "locale"> & {
|
|
10
|
-
readonly locale?: z.input<typeof ContactSubmitSchema>["locale"];
|
|
11
|
-
};
|
|
12
|
-
export type ContactWebsiteSubmitResult = {
|
|
13
|
-
readonly kind: "sent";
|
|
14
|
-
} | {
|
|
15
|
-
readonly kind: "rate-limited";
|
|
16
|
-
readonly retryAfterSeconds?: number;
|
|
17
|
-
} | {
|
|
18
|
-
readonly kind: "failed";
|
|
19
|
-
};
|
|
20
|
-
export type ContactWebsiteClient = {
|
|
21
|
-
load(): Promise<ContactWebsiteFormOptions>;
|
|
22
|
-
submit(fields: ContactWebsiteSubmitFields): Promise<ContactWebsiteSubmitResult>;
|
|
23
|
-
};
|
|
24
|
-
export type ContactWebsiteWindow = {
|
|
25
|
-
readonly KumikoContact?: ContactWebsiteClient;
|
|
26
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CONTACT_CLIENT_SOURCE } from "./contact-client-source.js";
|