@cosmicdrift/kumiko-bundled-features 0.342.0 → 0.344.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/audit/constants.d.ts +5 -1
- package/dist/audit/constants.js +5 -1
- package/dist/audit/escape-hatch-audit-sink.d.ts +1 -0
- package/dist/audit/escape-hatch-audit-sink.js +1 -0
- package/dist/audit/run-escape-hatch-retention.d.ts +3 -2
- package/dist/audit/run-escape-hatch-retention.js +71 -7
- package/dist/auth-email-password/email-templates.d.ts +4 -0
- package/dist/auth-email-password/email-templates.js +69 -16
- package/dist/auth-email-password/handlers/invite-create.write.js +4 -1
- package/dist/auth-email-password/handlers/signup-request.write.js +4 -1
- package/dist/auth-email-password/handlers/token-request-handler.js +3 -0
- package/dist/auth-email-password/magic-link-mail.d.ts +2 -0
- package/dist/auth-email-password/magic-link-mail.js +2 -0
- package/dist/billing-foundation/checkout-core.d.ts +15 -4
- package/dist/billing-foundation/checkout-core.js +18 -6
- package/dist/billing-foundation/consumer-protection/confirmation-mail.d.ts +13 -3
- package/dist/billing-foundation/consumer-protection/confirmation-mail.js +23 -20
- package/dist/billing-foundation/consumer-protection/consent-gate.d.ts +6 -1
- package/dist/billing-foundation/consumer-protection/consent-gate.js +6 -1
- package/dist/billing-foundation/consumer-protection/consent-locale.js +1 -1
- package/dist/billing-foundation/consumer-protection/issue-confirmation.js +24 -2
- package/dist/billing-foundation/events.d.ts +2 -0
- package/dist/billing-foundation/events.js +2 -0
- package/dist/billing-foundation/handlers/billing-plans.query.d.ts +1 -1
- package/dist/billing-foundation/handlers/billing-plans.query.js +5 -1
- package/dist/billing-foundation/handlers/create-checkout-session.write.js +46 -24
- package/dist/billing-foundation/index.d.ts +3 -1
- package/dist/billing-foundation/index.js +2 -0
- package/dist/billing-foundation/types.d.ts +16 -7
- package/dist/billing-foundation/types.js +3 -0
- package/dist/billing-foundation/validate-options.d.ts +1 -1
- package/dist/billing-foundation/validate-options.js +24 -2
- package/dist/billing-foundation/web/billing-plans-panel.js +1 -1
- package/dist/billing-foundation/web/cancel-contract-dialog.js +2 -2
- package/dist/billing-foundation/web/checkout-consent-dialog.d.ts +1 -1
- package/dist/billing-foundation/web/checkout-consent-dialog.js +4 -4
- package/dist/billing-foundation/web/index.d.ts +3 -1
- package/dist/billing-foundation/web/index.js +2 -0
- package/dist/channel-discord/feature.js +1 -0
- package/dist/channel-email/feature.js +1 -0
- package/dist/channel-in-app/feature.js +1 -0
- package/dist/channel-push/feature.js +1 -0
- package/dist/channel-slack/feature.js +1 -0
- package/dist/channel-teams/feature.js +1 -0
- package/dist/channel-teams/teams-channel.d.ts +2 -1
- package/dist/channel-teams/teams-channel.js +12 -0
- package/dist/channel-telegram/feature.js +1 -0
- package/dist/delivery/chat-webhook-channel.d.ts +2 -1
- package/dist/delivery/chat-webhook-channel.js +5 -2
- package/dist/delivery/chat-webhook-sender.d.ts +8 -1
- package/dist/delivery/chat-webhook-sender.js +45 -4
- package/dist/delivery/constants.d.ts +1 -1
- package/dist/delivery/constants.js +1 -1
- package/dist/delivery/delivery-service.d.ts +2 -1
- package/dist/delivery/delivery-service.js +55 -4
- package/dist/delivery/events.d.ts +19 -1
- package/dist/delivery/events.js +11 -1
- package/dist/delivery/feature.js +29 -5
- package/dist/delivery/handlers/log.query.d.ts +4 -2
- package/dist/delivery/handlers/log.query.js +46 -18
- package/dist/delivery/i18n.js +36 -0
- package/dist/delivery/index.d.ts +2 -1
- package/dist/delivery/index.js +1 -0
- package/dist/delivery/jobs.js +24 -10
- package/dist/delivery/notify-factory.d.ts +5 -0
- package/dist/delivery/notify-factory.js +6 -0
- package/dist/delivery/public-names.d.ts +4 -0
- package/dist/delivery/public-names.js +4 -0
- package/dist/delivery/tables.js +3 -0
- package/dist/delivery/testing.d.ts +2 -0
- package/dist/delivery/testing.js +2 -1
- package/dist/delivery/types.d.ts +5 -3
- package/dist/delivery/web/client-plugin.js +9 -1
- package/dist/delivery/web/delivery-channel-cell.d.ts +3 -0
- package/dist/delivery/web/delivery-channel-cell.js +10 -0
- package/dist/delivery/web/delivery-error-cell.d.ts +3 -0
- package/dist/delivery/web/delivery-error-cell.js +16 -0
- package/dist/delivery/web/delivery-status-cell.d.ts +1 -1
- package/dist/delivery/web/delivery-status-cell.js +11 -1
- package/dist/delivery/web/delivery-time-cell.d.ts +3 -0
- package/dist/delivery/web/delivery-time-cell.js +6 -0
- package/dist/delivery/web/delivery-type-cell.d.ts +3 -0
- package/dist/delivery/web/delivery-type-cell.js +17 -0
- package/dist/legal-pages/constants.d.ts +2 -0
- package/dist/legal-pages/feature.js +7 -2
- package/dist/renderer-simple/simple-renderer.js +8 -0
- package/dist/secrets/constants.d.ts +6 -0
- package/dist/secrets/constants.js +8 -0
- package/dist/secrets/feature.d.ts +3 -0
- package/dist/secrets/feature.js +3 -0
- package/dist/secrets/i18n.js +4 -3
- package/dist/secrets/index.d.ts +3 -2
- package/dist/secrets/index.js +3 -2
- package/dist/secrets/write-gate.d.ts +1 -0
- package/dist/secrets/write-gate.js +14 -6
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +1 -0
- package/dist/shared/redact.d.ts +4 -0
- package/dist/shared/redact.js +21 -0
- package/dist/step-dispatcher/feature.js +2 -1
- package/dist/step-dispatcher/mail-runner.d.ts +0 -1
- package/dist/step-dispatcher/mail-runner.js +0 -5
- package/dist/tenant/web/member-roles-cell.js +1 -1
- package/dist/tenant/web/member-status-cell.js +1 -1
- package/dist/tenant-lifecycle/feature.js +8 -2
- package/dist/tenant-lifecycle/run-tenant-destroy.d.ts +2 -1
- package/dist/tenant-lifecycle/run-tenant-destroy.js +16 -7
- package/dist/user/index.d.ts +1 -0
- package/dist/user/index.js +1 -0
- package/dist/user/resolve-display-names.d.ts +2 -0
- package/dist/user/resolve-display-names.js +24 -0
- package/package.json +9 -9
- package/src/audit/changes.json +6 -0
- package/src/auth-email-password/changes.json +7 -0
- package/src/billing-foundation/changes.json +7 -0
- package/src/channel-teams/changes.json +8 -0
- package/src/delivery/changes.json +32 -0
- package/src/jobs/changes.json +6 -0
- package/src/legal-pages/changes.json +6 -0
- package/src/renderer-simple/changes.json +6 -0
- package/src/secrets/changes.json +6 -0
- /package/dist/{tenant → shared}/web/translate-or-raw.d.ts +0 -0
- /package/dist/{tenant → shared}/web/translate-or-raw.js +0 -0
|
@@ -13,6 +13,10 @@ export declare const AuditQueries: {
|
|
|
13
13
|
export declare const AUDIT_LOG_SCREEN_ID: "audit-log";
|
|
14
14
|
/** Single-event detail screen, breadcrumb-linked to the audit-log list. */
|
|
15
15
|
export declare const AUDIT_LOG_DETAIL_SCREEN_ID: "audit-log-detail";
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Config key (system scope) for how long `escapeHatchUse` audit events are kept. Only a fallback
|
|
18
|
+
* for apps without compliance-profiles; with it mounted, the tenant profile's `auditLog.retention`
|
|
19
|
+
* applies (a tenant override can only lengthen it).
|
|
20
|
+
*/
|
|
17
21
|
export declare const ESCAPE_HATCH_RETENTION_DAYS_KEY: "audit:config:escape-hatch-retention-days";
|
|
18
22
|
export declare const DEFAULT_ESCAPE_HATCH_RETENTION_DAYS = 90;
|
package/dist/audit/constants.js
CHANGED
|
@@ -18,6 +18,10 @@ export const AuditQueries = {
|
|
|
18
18
|
export const AUDIT_LOG_SCREEN_ID = "audit-log";
|
|
19
19
|
/** Single-event detail screen, breadcrumb-linked to the audit-log list. */
|
|
20
20
|
export const AUDIT_LOG_DETAIL_SCREEN_ID = "audit-log-detail";
|
|
21
|
-
/**
|
|
21
|
+
/**
|
|
22
|
+
* Config key (system scope) for how long `escapeHatchUse` audit events are kept. Only a fallback
|
|
23
|
+
* for apps without compliance-profiles; with it mounted, the tenant profile's `auditLog.retention`
|
|
24
|
+
* applies (a tenant override can only lengthen it).
|
|
25
|
+
*/
|
|
22
26
|
export const ESCAPE_HATCH_RETENTION_DAYS_KEY = "audit:config:escape-hatch-retention-days";
|
|
23
27
|
export const DEFAULT_ESCAPE_HATCH_RETENTION_DAYS = 90;
|
|
@@ -7,6 +7,7 @@ export declare const escapeHatchUsedSchema: z.ZodObject<{
|
|
|
7
7
|
handler: z.ZodString;
|
|
8
8
|
kind: z.ZodEnum<{
|
|
9
9
|
"acknowledge-cross-tenant": "acknowledge-cross-tenant";
|
|
10
|
+
"cross-tenant-read": "cross-tenant-read";
|
|
10
11
|
"global-write": "global-write";
|
|
11
12
|
"identity-switch": "identity-switch";
|
|
12
13
|
"unsafe-all-tenants": "unsafe-all-tenants";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { DbConnection, DbRunner } from "@cosmicdrift/kumiko-framework/db";
|
|
2
2
|
import { type ConfigResolver, type Registry } from "@cosmicdrift/kumiko-framework/engine";
|
|
3
|
-
import { type PruneEventsResult } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
4
3
|
export declare function isDbConnection(runner: DbRunner): runner is DbConnection;
|
|
5
4
|
export declare function runEscapeHatchRetention(args: {
|
|
6
5
|
readonly db: DbRunner;
|
|
7
6
|
readonly registry: Registry;
|
|
8
7
|
readonly configResolver: ConfigResolver | undefined;
|
|
9
8
|
readonly userId: string;
|
|
10
|
-
}): Promise<
|
|
9
|
+
}): Promise<{
|
|
10
|
+
readonly deletedCount: number;
|
|
11
|
+
}>;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { selectMany } from "@cosmicdrift/kumiko-framework/bun-db";
|
|
2
|
+
import { COMPLIANCE_PROFILES, subtractRetentionSpec, } from "@cosmicdrift/kumiko-framework/compliance";
|
|
3
|
+
import { parseTenantId, SYSTEM_TENANT_ID, } from "@cosmicdrift/kumiko-framework/engine";
|
|
4
|
+
import { eventsTable } from "@cosmicdrift/kumiko-framework/event-store";
|
|
2
5
|
import { pruneEvents } from "@cosmicdrift/kumiko-framework/pipeline";
|
|
6
|
+
import { getTemporal } from "@cosmicdrift/kumiko-framework/time";
|
|
7
|
+
import { resolveProfileForTenant } from "../compliance-profiles/index.js";
|
|
3
8
|
import { createConfigAccessor } from "../config/index.js";
|
|
4
9
|
import { DEFAULT_ESCAPE_HATCH_RETENTION_DAYS, ESCAPE_HATCH_RETENTION_DAYS_KEY, } from "./constants.js";
|
|
5
|
-
import { ESCAPE_HATCH_USE_AGGREGATE_TYPE } from "./escape-hatch-audit-sink.js";
|
|
10
|
+
import { ESCAPE_HATCH_USE_AGGREGATE_TYPE, escapeHatchUsedSchema, } from "./escape-hatch-audit-sink.js";
|
|
6
11
|
// pruneEvents opens its own transaction, so a runner that cannot begin one (a tx handle) is rejected instead of nested.
|
|
7
12
|
export function isDbConnection(runner) {
|
|
8
13
|
return "begin" in runner && typeof runner.begin === "function";
|
|
@@ -14,14 +19,73 @@ async function resolveRetentionDays(args) {
|
|
|
14
19
|
const raw = await config(ESCAPE_HATCH_RETENTION_DAYS_KEY);
|
|
15
20
|
return typeof raw === "number" && raw >= 1 ? raw : DEFAULT_ESCAPE_HATCH_RETENTION_DAYS;
|
|
16
21
|
}
|
|
22
|
+
// Soft dependency: audit must stay mountable without compliance-profiles, so we probe its entity.
|
|
23
|
+
const COMPLIANCE_PROFILE_ENTITY = "tenant-compliance-profile";
|
|
24
|
+
const PRUNE_CHUNK_SIZE = 1000;
|
|
25
|
+
// Overrides may only lengthen retention: the earlier cutoff (same `now`) is the longer period.
|
|
26
|
+
function earlierInstant(a, b) {
|
|
27
|
+
return Temporal.Instant.compare(a, b) <= 0 ? a : b;
|
|
28
|
+
}
|
|
29
|
+
async function resolveTenantCutoff(db, tenantId, now) {
|
|
30
|
+
const { profile } = await resolveProfileForTenant({ db, tenantId });
|
|
31
|
+
const effective = subtractRetentionSpec(now, profile.auditLog.retention);
|
|
32
|
+
const base = subtractRetentionSpec(now, COMPLIANCE_PROFILES[profile.key].auditLog.retention);
|
|
33
|
+
return earlierInstant(effective, base);
|
|
34
|
+
}
|
|
35
|
+
// A cross-tenant audit (e.g. identity-switch) lives under the actor's tenant but must also
|
|
36
|
+
// satisfy the target tenant's retention. A malformed payload falls back to the storing tenant.
|
|
37
|
+
function targetTenantOf(payload) {
|
|
38
|
+
const parsed = escapeHatchUsedSchema.safeParse(payload);
|
|
39
|
+
return parsed.success ? parseTenantId(parsed.data.targetTenantId) : null;
|
|
40
|
+
}
|
|
41
|
+
async function pruneByTenantProfiles(db) {
|
|
42
|
+
const rows = await selectMany(db, eventsTable, {
|
|
43
|
+
aggregateType: ESCAPE_HATCH_USE_AGGREGATE_TYPE,
|
|
44
|
+
});
|
|
45
|
+
const now = getTemporal().Now.instant();
|
|
46
|
+
const cutoffByTenant = new Map();
|
|
47
|
+
const cutoffOf = async (tenantId) => {
|
|
48
|
+
const cached = cutoffByTenant.get(tenantId);
|
|
49
|
+
if (cached)
|
|
50
|
+
return cached;
|
|
51
|
+
const cutoff = await resolveTenantCutoff(db, tenantId, now);
|
|
52
|
+
cutoffByTenant.set(tenantId, cutoff);
|
|
53
|
+
return cutoff;
|
|
54
|
+
};
|
|
55
|
+
const expiredAggregateIds = [];
|
|
56
|
+
for (const row of rows) {
|
|
57
|
+
const targetTenantId = targetTenantOf(row.payload);
|
|
58
|
+
const storeCutoff = await cutoffOf(row.tenantId);
|
|
59
|
+
const cutoff = targetTenantId
|
|
60
|
+
? earlierInstant(storeCutoff, await cutoffOf(targetTenantId))
|
|
61
|
+
: storeCutoff;
|
|
62
|
+
if (Temporal.Instant.compare(row.createdAt, cutoff) < 0) {
|
|
63
|
+
expiredAggregateIds.push(row.aggregateId);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let deletedCount = 0;
|
|
67
|
+
for (let i = 0; i < expiredAggregateIds.length; i += PRUNE_CHUNK_SIZE) {
|
|
68
|
+
const result = await pruneEvents(db, {
|
|
69
|
+
aggregateTypes: [ESCAPE_HATCH_USE_AGGREGATE_TYPE],
|
|
70
|
+
aggregateIds: expiredAggregateIds.slice(i, i + PRUNE_CHUNK_SIZE),
|
|
71
|
+
olderThan: now,
|
|
72
|
+
});
|
|
73
|
+
deletedCount += result.deletedCount;
|
|
74
|
+
}
|
|
75
|
+
return deletedCount;
|
|
76
|
+
}
|
|
17
77
|
export async function runEscapeHatchRetention(args) {
|
|
18
78
|
const { db } = args;
|
|
19
79
|
if (!isDbConnection(db)) {
|
|
20
80
|
throw new Error("audit escape-hatch retention: a transaction-free DbConnection is required");
|
|
21
81
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
82
|
+
if (!args.registry.getEntity(COMPLIANCE_PROFILE_ENTITY)) {
|
|
83
|
+
const olderThanDays = await resolveRetentionDays({ ...args, db });
|
|
84
|
+
const { deletedCount } = await pruneEvents(db, {
|
|
85
|
+
aggregateTypes: [ESCAPE_HATCH_USE_AGGREGATE_TYPE],
|
|
86
|
+
olderThanDays,
|
|
87
|
+
});
|
|
88
|
+
return { deletedCount };
|
|
89
|
+
}
|
|
90
|
+
return { deletedCount: await pruneByTenantProfiles(db) };
|
|
27
91
|
}
|
|
@@ -6,6 +6,10 @@ export type RenderTokenContentArgs = {
|
|
|
6
6
|
readonly locale?: AuthMailLocale;
|
|
7
7
|
/** Optional app name for subject + intro. Default from auth.mail.appNameDefault. */
|
|
8
8
|
readonly appName?: string;
|
|
9
|
+
/** ISO instant the token was issued; the validity duration is measured from it. Default: now. */
|
|
10
|
+
readonly issuedAt?: string;
|
|
11
|
+
/** IANA zone the expiry time is shown in. Default "UTC"; an invalid zone falls back to "UTC". */
|
|
12
|
+
readonly timeZone?: string;
|
|
9
13
|
};
|
|
10
14
|
export type RenderInviteEmailArgs = RenderTokenContentArgs & {
|
|
11
15
|
readonly role: string;
|
|
@@ -15,31 +15,31 @@ export const AUTH_MAIL_EN = {
|
|
|
15
15
|
"auth.mail.reset.greeting": "Hi,",
|
|
16
16
|
"auth.mail.reset.intro": "you requested a password reset for {app}. Click the link below to set a new password:",
|
|
17
17
|
"auth.mail.reset.button": "Reset password",
|
|
18
|
-
"auth.mail.reset.expiry": "The link
|
|
18
|
+
"auth.mail.reset.expiry": "The link is valid for {duration} (until {when}).",
|
|
19
19
|
"auth.mail.reset.ignore": "If you didn't request a reset, you can safely ignore this email — your password won't change.",
|
|
20
20
|
"auth.mail.verify.subject": "{app} — Verify your email",
|
|
21
21
|
"auth.mail.verify.greeting": "Welcome,",
|
|
22
22
|
"auth.mail.verify.intro": "please verify your email address for {app} to activate your account:",
|
|
23
23
|
"auth.mail.verify.button": "Verify email",
|
|
24
|
-
"auth.mail.verify.expiry": "The link
|
|
24
|
+
"auth.mail.verify.expiry": "The link is valid for {duration} (until {when}).",
|
|
25
25
|
"auth.mail.verify.ignore": "If you didn't create this account, you can ignore this email.",
|
|
26
26
|
"auth.mail.activation.subject": "{app} — Activate your account",
|
|
27
27
|
"auth.mail.activation.greeting": "Welcome,",
|
|
28
28
|
"auth.mail.activation.intro": "click the link below to activate your {app} account. The next step is choosing your password:",
|
|
29
29
|
"auth.mail.activation.button": "Activate account",
|
|
30
|
-
"auth.mail.activation.expiry": "The link
|
|
30
|
+
"auth.mail.activation.expiry": "The link is valid for {duration} (until {when}).",
|
|
31
31
|
"auth.mail.activation.ignore": "If you didn't sign up, you can ignore this email — no account is created until you open the link.",
|
|
32
32
|
"auth.mail.invite.subject": "{app} — Workspace invitation",
|
|
33
33
|
"auth.mail.invite.greeting": "Hi,",
|
|
34
34
|
"auth.mail.invite.intro": "you've been invited to a {app} workspace as {role}. Click the link below to accept:",
|
|
35
35
|
"auth.mail.invite.button": "Accept invitation",
|
|
36
|
-
"auth.mail.invite.expiry": "The link
|
|
36
|
+
"auth.mail.invite.expiry": "The link is valid for {duration} (until {when}).",
|
|
37
37
|
"auth.mail.invite.ignore": "If you weren't expecting this invitation, you can ignore this email.",
|
|
38
38
|
"auth.mail.unlock.subject": "{app} — Unlock your account",
|
|
39
39
|
"auth.mail.unlock.greeting": "Hi,",
|
|
40
40
|
"auth.mail.unlock.intro": "your {app} account was temporarily locked after several failed sign-in attempts. Click the link below to unlock it immediately:",
|
|
41
41
|
"auth.mail.unlock.button": "Unlock account",
|
|
42
|
-
"auth.mail.unlock.expiry": "The link
|
|
42
|
+
"auth.mail.unlock.expiry": "The link is valid for {duration} (until {when}).",
|
|
43
43
|
"auth.mail.unlock.ignore": "If you didn't trigger this lock, you can ignore this email — the lock expires on its own.",
|
|
44
44
|
};
|
|
45
45
|
registerMailTranslations("en", AUTH_MAIL_EN);
|
|
@@ -73,7 +73,7 @@ export function renderResetPasswordEmail(args) {
|
|
|
73
73
|
intro: t(locale, "auth.mail.reset.intro", { app }),
|
|
74
74
|
buttonLabel: t(locale, "auth.mail.reset.button"),
|
|
75
75
|
buttonUrl: args.url,
|
|
76
|
-
expiry: t(locale, "auth.mail.reset.expiry",
|
|
76
|
+
expiry: t(locale, "auth.mail.reset.expiry", expiryParams(args, locale)),
|
|
77
77
|
ignore: t(locale, "auth.mail.reset.ignore"),
|
|
78
78
|
});
|
|
79
79
|
}
|
|
@@ -87,7 +87,7 @@ export function renderUnlockAccountEmail(args) {
|
|
|
87
87
|
intro: t(locale, "auth.mail.unlock.intro", { app }),
|
|
88
88
|
buttonLabel: t(locale, "auth.mail.unlock.button"),
|
|
89
89
|
buttonUrl: args.url,
|
|
90
|
-
expiry: t(locale, "auth.mail.unlock.expiry",
|
|
90
|
+
expiry: t(locale, "auth.mail.unlock.expiry", expiryParams(args, locale)),
|
|
91
91
|
ignore: t(locale, "auth.mail.unlock.ignore"),
|
|
92
92
|
});
|
|
93
93
|
}
|
|
@@ -101,7 +101,7 @@ export function renderVerifyEmail(args) {
|
|
|
101
101
|
intro: t(locale, "auth.mail.verify.intro", { app }),
|
|
102
102
|
buttonLabel: t(locale, "auth.mail.verify.button"),
|
|
103
103
|
buttonUrl: args.url,
|
|
104
|
-
expiry: t(locale, "auth.mail.verify.expiry",
|
|
104
|
+
expiry: t(locale, "auth.mail.verify.expiry", expiryParams(args, locale)),
|
|
105
105
|
ignore: t(locale, "auth.mail.verify.ignore"),
|
|
106
106
|
});
|
|
107
107
|
}
|
|
@@ -115,7 +115,7 @@ export function renderActivationEmail(args) {
|
|
|
115
115
|
intro: t(locale, "auth.mail.activation.intro", { app }),
|
|
116
116
|
buttonLabel: t(locale, "auth.mail.activation.button"),
|
|
117
117
|
buttonUrl: args.url,
|
|
118
|
-
expiry: t(locale, "auth.mail.activation.expiry",
|
|
118
|
+
expiry: t(locale, "auth.mail.activation.expiry", expiryParams(args, locale)),
|
|
119
119
|
ignore: t(locale, "auth.mail.activation.ignore"),
|
|
120
120
|
});
|
|
121
121
|
}
|
|
@@ -129,19 +129,72 @@ export function renderInviteEmail(args) {
|
|
|
129
129
|
intro: t(locale, "auth.mail.invite.intro", { app, role: args.role }),
|
|
130
130
|
buttonLabel: t(locale, "auth.mail.invite.button"),
|
|
131
131
|
buttonUrl: args.url,
|
|
132
|
-
expiry: t(locale, "auth.mail.invite.expiry",
|
|
132
|
+
expiry: t(locale, "auth.mail.invite.expiry", expiryParams(args, locale)),
|
|
133
133
|
ignore: t(locale, "auth.mail.invite.ignore"),
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
const MS_PER_MINUTE = 60_000;
|
|
137
|
+
const MS_PER_HOUR = 60 * MS_PER_MINUTE;
|
|
138
|
+
const MS_PER_DAY = 24 * MS_PER_HOUR;
|
|
139
|
+
// Rounds to whole minutes first so a few ms between issuing and signing still
|
|
140
|
+
// read as "1 day"; a larger unit is only used when it divides the span exactly.
|
|
141
|
+
function durationParts(ms) {
|
|
142
|
+
const minutes = Math.max(1, Math.round(ms / MS_PER_MINUTE));
|
|
143
|
+
const minutesPerHour = MS_PER_HOUR / MS_PER_MINUTE;
|
|
144
|
+
const minutesPerDay = MS_PER_DAY / MS_PER_MINUTE;
|
|
145
|
+
if (minutes % minutesPerDay === 0)
|
|
146
|
+
return { amount: minutes / minutesPerDay, unit: "day" };
|
|
147
|
+
if (minutes % minutesPerHour === 0)
|
|
148
|
+
return { amount: minutes / minutesPerHour, unit: "hour" };
|
|
149
|
+
return { amount: minutes, unit: "minute" };
|
|
150
|
+
}
|
|
151
|
+
function formatDuration(ms, locale) {
|
|
152
|
+
const { amount, unit } = durationParts(ms);
|
|
153
|
+
const options = { style: "unit", unit, unitDisplay: "long" };
|
|
137
154
|
try {
|
|
138
|
-
|
|
139
|
-
return `${z.year}-${pad2(z.month)}-${pad2(z.day)} ${pad2(z.hour)}:${pad2(z.minute)} UTC`;
|
|
155
|
+
return new Intl.NumberFormat(locale, options).format(amount);
|
|
140
156
|
}
|
|
141
157
|
catch {
|
|
142
|
-
return
|
|
158
|
+
return new Intl.NumberFormat("en", options).format(amount);
|
|
143
159
|
}
|
|
144
160
|
}
|
|
145
|
-
|
|
146
|
-
|
|
161
|
+
// Intl rejects timeZoneName together with dateStyle/timeStyle, so the zone
|
|
162
|
+
// abbreviation is read from a second formatter and appended.
|
|
163
|
+
function formatWhen(expiresAt, locale, timeZone) {
|
|
164
|
+
const build = (tag, zone) => {
|
|
165
|
+
const at = expiresAt.epochMilliseconds;
|
|
166
|
+
const dateTime = new Intl.DateTimeFormat(tag, {
|
|
167
|
+
dateStyle: "medium",
|
|
168
|
+
timeStyle: "short",
|
|
169
|
+
timeZone: zone,
|
|
170
|
+
}).format(at);
|
|
171
|
+
const zoneName = new Intl.DateTimeFormat(tag, { timeZone: zone, timeZoneName: "short" })
|
|
172
|
+
.formatToParts(at)
|
|
173
|
+
.find((part) => part.type === "timeZoneName")?.value;
|
|
174
|
+
return zoneName ? `${dateTime} ${zoneName}` : dateTime;
|
|
175
|
+
};
|
|
176
|
+
try {
|
|
177
|
+
return build(locale, timeZone);
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
try {
|
|
181
|
+
return build(locale, "UTC");
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
return build("en", "UTC");
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function expiryParams(args, locale) {
|
|
189
|
+
try {
|
|
190
|
+
const expiresAt = Temporal.Instant.from(args.expiresAt);
|
|
191
|
+
const issuedAt = args.issuedAt ? Temporal.Instant.from(args.issuedAt) : Temporal.Now.instant();
|
|
192
|
+
return {
|
|
193
|
+
duration: formatDuration(expiresAt.epochMilliseconds - issuedAt.epochMilliseconds, locale),
|
|
194
|
+
when: formatWhen(expiresAt, locale, args.timeZone ?? "UTC"),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return { duration: args.expiresAt, when: args.expiresAt };
|
|
199
|
+
}
|
|
147
200
|
}
|
|
@@ -67,7 +67,8 @@ async function issueInvitation(opts, ttlSeconds, request, inviter, ctx, refuseAc
|
|
|
67
67
|
}
|
|
68
68
|
const email = request.email.toLowerCase();
|
|
69
69
|
const tenantId = inviter.tenantId;
|
|
70
|
-
const
|
|
70
|
+
const issuedAt = Temporal.Now.instant();
|
|
71
|
+
const expiresAt = issuedAt.add({ seconds: ttlSeconds });
|
|
71
72
|
// The unique index allows one row per (tenantId, email). Whatever its
|
|
72
73
|
// status, a re-invite resets it to pending with a fresh token.
|
|
73
74
|
const existing = await ctx.db.fetchOne(tenantInvitationsTable, { tenantId, email });
|
|
@@ -126,6 +127,8 @@ async function issueInvitation(opts, ttlSeconds, request, inviter, ctx, refuseAc
|
|
|
126
127
|
appUrl: opts.appUrl,
|
|
127
128
|
token,
|
|
128
129
|
expiresAt: expiresAt.toString(),
|
|
130
|
+
issuedAt: issuedAt.toString(),
|
|
131
|
+
timeZone: ctx.tz.user,
|
|
129
132
|
...(opts.appName !== undefined && { appName: opts.appName }),
|
|
130
133
|
locale,
|
|
131
134
|
});
|
|
@@ -104,7 +104,8 @@ export function createSignupRequestHandler(opts) {
|
|
|
104
104
|
// uses randomBytes from node:crypto, the same source as CSRF/
|
|
105
105
|
// session tokens.
|
|
106
106
|
const token = generateToken();
|
|
107
|
-
const
|
|
107
|
+
const issuedAt = Temporal.Now.instant();
|
|
108
|
+
const expiresAt = issuedAt.add({ seconds: ttlSeconds });
|
|
108
109
|
const expiresAtIso = expiresAt.toString();
|
|
109
110
|
await storeSignupToken(ctx.redis, { email, token, ttlSeconds });
|
|
110
111
|
// A handover grant in this request re-verifies and replaces the prior
|
|
@@ -158,6 +159,8 @@ export function createSignupRequestHandler(opts) {
|
|
|
158
159
|
appUrl: opts.appUrl,
|
|
159
160
|
token,
|
|
160
161
|
expiresAt: expiresAtIso,
|
|
162
|
+
issuedAt: issuedAt.toString(),
|
|
163
|
+
timeZone: ctx.tz.user,
|
|
161
164
|
...(opts.appName !== undefined && { appName: opts.appName }),
|
|
162
165
|
locale,
|
|
163
166
|
});
|
|
@@ -55,6 +55,7 @@ export function createTokenRequestHandler(spec, opts) {
|
|
|
55
55
|
return { isSuccess: true, data };
|
|
56
56
|
}
|
|
57
57
|
const { token, expiresAt } = spec.sign(user.id, ttl, opts.hmacSecret);
|
|
58
|
+
const issuedAt = expiresAt.subtract({ minutes: ttl }).toString();
|
|
58
59
|
const locale = resolveHandlerMailLocale(ctx, opts.locale);
|
|
59
60
|
await dispatchMagicLinkMail(ctx.notify, {
|
|
60
61
|
handlerName: spec.handlerName,
|
|
@@ -67,6 +68,8 @@ export function createTokenRequestHandler(spec, opts) {
|
|
|
67
68
|
appUrl: opts.appUrl,
|
|
68
69
|
token,
|
|
69
70
|
expiresAt: expiresAt.toString(),
|
|
71
|
+
issuedAt,
|
|
72
|
+
timeZone: ctx.tz.user,
|
|
70
73
|
...(opts.appName !== undefined && { appName: opts.appName }),
|
|
71
74
|
locale,
|
|
72
75
|
});
|
|
@@ -12,6 +12,8 @@ export type MagicLinkMailParams = {
|
|
|
12
12
|
readonly expiresAt: string;
|
|
13
13
|
readonly appName?: string;
|
|
14
14
|
readonly locale?: AuthMailLocale;
|
|
15
|
+
readonly issuedAt?: string;
|
|
16
|
+
readonly timeZone?: string;
|
|
15
17
|
};
|
|
16
18
|
export declare function resolveHandlerMailLocale(ctx: {
|
|
17
19
|
readonly locale?: string;
|
|
@@ -40,6 +40,8 @@ export async function dispatchMagicLinkMail(notify, spec, params) {
|
|
|
40
40
|
expiresAt: params.expiresAt,
|
|
41
41
|
...(params.locale !== undefined && { locale: params.locale }),
|
|
42
42
|
...(params.appName !== undefined && { appName: params.appName }),
|
|
43
|
+
...(params.issuedAt !== undefined && { issuedAt: params.issuedAt }),
|
|
44
|
+
...(params.timeZone !== undefined && { timeZone: params.timeZone }),
|
|
43
45
|
});
|
|
44
46
|
await notify(spec.notificationType, {
|
|
45
47
|
route: { email: params.email },
|
|
@@ -92,11 +92,22 @@ export type OpenCheckoutInput = {
|
|
|
92
92
|
readonly locale?: string;
|
|
93
93
|
readonly submitMessage?: string;
|
|
94
94
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
type CheckoutCapableProvider = SubscriptionProviderPlugin & {
|
|
96
|
+
readonly createCheckoutSession: NonNullable<SubscriptionProviderPlugin["createCheckoutSession"]>;
|
|
97
|
+
};
|
|
98
|
+
/** All gates that run before a provider checkout call: provider, billing
|
|
99
|
+
* enabled, redirect origins, mode gates, foreign provider customer.
|
|
100
|
+
* `mode: "payment"` (one-off top-ups etc.) skips the price/subscription
|
|
101
|
+
* gates — those apply to recurring subscriptions only. */
|
|
102
|
+
export declare function assertCheckoutAllowed(ctx: HandlerContext, options: OpenCheckoutOptions, input: OpenCheckoutInput): Promise<CheckoutCapableProvider>;
|
|
103
|
+
export declare function startProviderCheckout(ctx: HandlerContext, plugin: CheckoutCapableProvider, input: OpenCheckoutInput): Promise<{
|
|
104
|
+
readonly url: string;
|
|
105
|
+
readonly providerName: string;
|
|
106
|
+
}>;
|
|
107
|
+
/** The one checkout entry-point start-plan-checkout, switch-plan and the
|
|
108
|
+
* non-consumer-protection create-checkout-session funnel through. */
|
|
99
109
|
export declare function openCheckout(ctx: HandlerContext, options: OpenCheckoutOptions, input: OpenCheckoutInput): Promise<{
|
|
100
110
|
readonly url: string;
|
|
101
111
|
readonly providerName: string;
|
|
102
112
|
}>;
|
|
113
|
+
export {};
|
|
@@ -234,13 +234,16 @@ function assertOneOffPriceAllowed(plugin, input) {
|
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
237
|
+
function canCreateCheckoutSession(plugin) {
|
|
238
|
+
return plugin.createCheckoutSession !== undefined;
|
|
239
|
+
}
|
|
240
|
+
/** All gates that run before a provider checkout call: provider, billing
|
|
241
|
+
* enabled, redirect origins, mode gates, foreign provider customer.
|
|
242
|
+
* `mode: "payment"` (one-off top-ups etc.) skips the price/subscription
|
|
243
|
+
* gates — those apply to recurring subscriptions only. */
|
|
244
|
+
export async function assertCheckoutAllowed(ctx, options, input) {
|
|
242
245
|
const { plugin } = resolveProviderPlugin(ctx, input.providerName);
|
|
243
|
-
if (!plugin
|
|
246
|
+
if (!canCreateCheckoutSession(plugin)) {
|
|
244
247
|
throw new Error(`subscription-foundation: provider "${input.providerName}" has no createCheckoutSession-method (e.g. Apple-IAP-only providers). Use the provider's native checkout flow.`);
|
|
245
248
|
}
|
|
246
249
|
// Checked before the redirect-origin hardening for every mode — a
|
|
@@ -272,6 +275,9 @@ export async function openCheckout(ctx, options, input) {
|
|
|
272
275
|
});
|
|
273
276
|
}
|
|
274
277
|
}
|
|
278
|
+
return plugin;
|
|
279
|
+
}
|
|
280
|
+
export async function startProviderCheckout(ctx, plugin, input) {
|
|
275
281
|
const result = await plugin.createCheckoutSession(ctx, {
|
|
276
282
|
priceId: input.priceId,
|
|
277
283
|
tenantId: ctx.user.tenantId,
|
|
@@ -288,3 +294,9 @@ export async function openCheckout(ctx, options, input) {
|
|
|
288
294
|
});
|
|
289
295
|
return { url: result.url, providerName: input.providerName };
|
|
290
296
|
}
|
|
297
|
+
/** The one checkout entry-point start-plan-checkout, switch-plan and the
|
|
298
|
+
* non-consumer-protection create-checkout-session funnel through. */
|
|
299
|
+
export async function openCheckout(ctx, options, input) {
|
|
300
|
+
const plugin = await assertCheckoutAllowed(ctx, options, input);
|
|
301
|
+
return startProviderCheckout(ctx, plugin, input);
|
|
302
|
+
}
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
import type { CheckoutConsentRecordedPayload } from "../events.js";
|
|
2
|
+
export type ContractConfirmationSection = {
|
|
3
|
+
readonly text: string;
|
|
4
|
+
} | {
|
|
5
|
+
readonly heading: string;
|
|
6
|
+
} | {
|
|
7
|
+
readonly markdown: string;
|
|
8
|
+
};
|
|
2
9
|
export type ContractConfirmationContent = {
|
|
3
10
|
readonly subject: string;
|
|
4
11
|
readonly header: string;
|
|
5
|
-
readonly sections: readonly
|
|
6
|
-
readonly text: string;
|
|
7
|
-
}[];
|
|
12
|
+
readonly sections: readonly ContractConfirmationSection[];
|
|
8
13
|
readonly footer: string;
|
|
9
14
|
};
|
|
10
15
|
export type RenderContractConfirmationArgs = {
|
|
11
16
|
readonly consent: CheckoutConsentRecordedPayload;
|
|
17
|
+
readonly timeZone: string;
|
|
18
|
+
/** Translated plan name; falls back to the raw tier. */
|
|
19
|
+
readonly tierLabel?: string;
|
|
20
|
+
/** Translated purchased item for one-off payments; falls back to the generic label. */
|
|
21
|
+
readonly itemLabel?: string;
|
|
12
22
|
readonly consentGivenAtIso: string;
|
|
13
23
|
readonly contractStartIso: string;
|
|
14
24
|
readonly currentPeriodEndIso?: string;
|
|
@@ -3,8 +3,9 @@ import { CONSENT_TEXTS, resolveConsentLocale } from "./consent-text.js";
|
|
|
3
3
|
const LABELS = {
|
|
4
4
|
de: {
|
|
5
5
|
subject: "Vertragsbestätigung",
|
|
6
|
-
intro: "
|
|
6
|
+
intro: "Vielen Dank für deine Bestellung. Hiermit bestätigen wir den Vertragsschluss mit folgendem Inhalt.",
|
|
7
7
|
plan: "Tarif",
|
|
8
|
+
item: "Leistung",
|
|
8
9
|
oneOffPayment: "Einmalzahlung",
|
|
9
10
|
price: "Preis",
|
|
10
11
|
oneOff: "einmalig",
|
|
@@ -24,8 +25,9 @@ const LABELS = {
|
|
|
24
25
|
},
|
|
25
26
|
en: {
|
|
26
27
|
subject: "Contract confirmation",
|
|
27
|
-
intro: "
|
|
28
|
+
intro: "Thank you for your order. We hereby confirm the conclusion of the contract with the following content.",
|
|
28
29
|
plan: "Plan",
|
|
30
|
+
item: "Item",
|
|
29
31
|
oneOffPayment: "One-off payment",
|
|
30
32
|
price: "Price",
|
|
31
33
|
oneOff: "one-off",
|
|
@@ -69,7 +71,7 @@ function formatPrice(consent, locale) {
|
|
|
69
71
|
: `${labels.every} ${count} ${unit.many}`;
|
|
70
72
|
return count === 1 ? `${amount} / ${intervalText}` : `${amount}, ${intervalText}`;
|
|
71
73
|
}
|
|
72
|
-
function formatDate(iso, locale) {
|
|
74
|
+
function formatDate(iso, locale, timeZone) {
|
|
73
75
|
let epochMilliseconds;
|
|
74
76
|
try {
|
|
75
77
|
epochMilliseconds = Temporal.Instant.from(iso).epochMilliseconds;
|
|
@@ -78,18 +80,15 @@ function formatDate(iso, locale) {
|
|
|
78
80
|
return iso;
|
|
79
81
|
}
|
|
80
82
|
return new Intl.DateTimeFormat(locale, {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
year: "numeric",
|
|
84
|
+
month: "long",
|
|
85
|
+
day: "numeric",
|
|
86
|
+
hour: "2-digit",
|
|
87
|
+
minute: "2-digit",
|
|
88
|
+
timeZone,
|
|
89
|
+
timeZoneName: "short",
|
|
84
90
|
}).format(epochMilliseconds);
|
|
85
91
|
}
|
|
86
|
-
function paragraphs(text) {
|
|
87
|
-
return text
|
|
88
|
-
.split(/\n{2,}/)
|
|
89
|
-
.map((part) => part.trim())
|
|
90
|
-
.filter((part) => part.length > 0)
|
|
91
|
-
.map((part) => ({ text: part }));
|
|
92
|
-
}
|
|
93
92
|
/** Structured mail content (header/sections/footer) for the email channel's
|
|
94
93
|
* renderer; the renderer owns HTML escaping, this only builds plain text. */
|
|
95
94
|
export function renderContractConfirmation(args) {
|
|
@@ -97,12 +96,16 @@ export function renderContractConfirmation(args) {
|
|
|
97
96
|
const labels = LABELS[locale];
|
|
98
97
|
const texts = CONSENT_TEXTS[locale];
|
|
99
98
|
const { consent } = args;
|
|
99
|
+
const { timeZone } = args;
|
|
100
|
+
const subjectLine = consent.mode === "payment"
|
|
101
|
+
? `${labels.item}: ${args.itemLabel ?? labels.oneOffPayment}`
|
|
102
|
+
: `${labels.plan}: ${args.tierLabel ?? consent.tier ?? labels.oneOffPayment}`;
|
|
100
103
|
const contractLines = [
|
|
101
|
-
|
|
104
|
+
subjectLine,
|
|
102
105
|
`${labels.price}: ${formatPrice(consent, locale)}`,
|
|
103
|
-
`${labels.contractStart}: ${formatDate(args.contractStartIso, locale)}`,
|
|
106
|
+
`${labels.contractStart}: ${formatDate(args.contractStartIso, locale, timeZone)}`,
|
|
104
107
|
...(args.currentPeriodEndIso !== undefined
|
|
105
|
-
? [`${labels.currentPeriodEnd}: ${formatDate(args.currentPeriodEndIso, locale)}`]
|
|
108
|
+
? [`${labels.currentPeriodEnd}: ${formatDate(args.currentPeriodEndIso, locale, timeZone)}`]
|
|
106
109
|
: []),
|
|
107
110
|
];
|
|
108
111
|
const vatNote = args.vatNote[locale] ?? args.vatNote[resolveConsentLocale()];
|
|
@@ -113,12 +116,12 @@ export function renderContractConfirmation(args) {
|
|
|
113
116
|
{ text: labels.intro },
|
|
114
117
|
...contractLines.map((text) => ({ text })),
|
|
115
118
|
...(vatNote !== undefined ? [{ text: vatNote }] : []),
|
|
116
|
-
{
|
|
119
|
+
{ heading: labels.consentHeading },
|
|
117
120
|
{ text: texts.earlyPerformance },
|
|
118
121
|
{ text: texts.withdrawalLoss },
|
|
119
|
-
{ text: `${labels.consentGivenAt}: ${formatDate(args.consentGivenAtIso, locale)}` },
|
|
120
|
-
{
|
|
121
|
-
|
|
122
|
+
{ text: `${labels.consentGivenAt}: ${formatDate(args.consentGivenAtIso, locale, timeZone)}` },
|
|
123
|
+
{ heading: labels.termsHeading },
|
|
124
|
+
{ markdown: args.termsContent },
|
|
122
125
|
],
|
|
123
126
|
footer: `${labels.contact} ${args.operatorEmail}`,
|
|
124
127
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type HandlerContext } from "@cosmicdrift/kumiko-framework/engine";
|
|
2
2
|
import * as z from "zod";
|
|
3
3
|
import type { ConsumerProtectionOptions, ProviderPrice } from "../types.js";
|
|
4
4
|
export type CheckoutMode = "subscription" | "payment";
|
|
@@ -18,10 +18,15 @@ export type PreparedConsent = {
|
|
|
18
18
|
readonly termsHash: string;
|
|
19
19
|
readonly termsTemplateVersion: number;
|
|
20
20
|
};
|
|
21
|
+
export type OrderItem = {
|
|
22
|
+
readonly labelKey: string;
|
|
23
|
+
readonly params?: Readonly<Record<string, string | number>>;
|
|
24
|
+
};
|
|
21
25
|
export type ConsentPriceDetails = {
|
|
22
26
|
readonly tier: string | null;
|
|
23
27
|
readonly priceId: string;
|
|
24
28
|
readonly price: Pick<ProviderPrice, "unitAmount" | "currency" | "interval" | "intervalCount"> | null;
|
|
29
|
+
readonly orderItem?: OrderItem;
|
|
25
30
|
};
|
|
26
31
|
export declare function prepareConsent(ctx: HandlerContext, options: ConsumerProtectionOptions, consent: ConsentPayload | undefined, mode: CheckoutMode): Promise<PreparedConsent>;
|
|
27
32
|
export declare function consentCheckoutFields(prepared: PreparedConsent): {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Consent gate shared by start-plan-checkout and create-checkout-session:
|
|
2
2
|
// validate + prepare before the provider call, record only after it succeeded.
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
|
+
import { SYSTEM_TENANT_ID } from "@cosmicdrift/kumiko-framework/engine";
|
|
4
5
|
import { UnprocessableError } from "@cosmicdrift/kumiko-framework/errors";
|
|
5
6
|
import { generateId } from "@cosmicdrift/kumiko-framework/utils";
|
|
6
7
|
import * as z from "zod";
|
|
@@ -36,7 +37,7 @@ export async function prepareConsent(ctx, options, consent, mode) {
|
|
|
36
37
|
let terms;
|
|
37
38
|
try {
|
|
38
39
|
terms = await resolver.resolveTemplate({
|
|
39
|
-
tenantId:
|
|
40
|
+
tenantId: SYSTEM_TENANT_ID,
|
|
40
41
|
slug: options.termsTextBlock,
|
|
41
42
|
kind: TEXT_BLOCK_KIND,
|
|
42
43
|
locale,
|
|
@@ -84,6 +85,10 @@ export async function recordConsent(ctx, prepared, details) {
|
|
|
84
85
|
termsTemplateVersion: prepared.termsTemplateVersion,
|
|
85
86
|
locale: prepared.locale,
|
|
86
87
|
actorUserId: String(ctx.user.id),
|
|
88
|
+
...(details.orderItem && {
|
|
89
|
+
itemLabelKey: details.orderItem.labelKey,
|
|
90
|
+
...(details.orderItem.params && { itemLabelParams: details.orderItem.params }),
|
|
91
|
+
}),
|
|
87
92
|
};
|
|
88
93
|
const tenantId = ctx.user.tenantId;
|
|
89
94
|
const isSubscription = prepared.mode === "subscription";
|