adula 2.1.0 → 2.3.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/README.md +149 -18
- package/build/agent/AGENTS.template.md +4 -4
- package/build/agent/capabilities.md +22 -12
- package/build/agent/skills/adula-frontend-design/SKILL.md +6 -4
- package/build/agent/skills/idea-review/SKILL.md +2 -2
- package/build/commands/adula_assistant_prune.d.ts +10 -0
- package/build/commands/adula_assistant_prune.js +12 -0
- package/build/commands/adula_outbox.d.ts +10 -0
- package/build/commands/adula_outbox.js +11 -0
- package/build/commands/adula_restore_reconcile.d.ts +10 -0
- package/build/commands/adula_restore_reconcile.js +34 -0
- package/build/commands/adula_runtime_health.d.ts +10 -0
- package/build/commands/adula_runtime_health.js +27 -0
- package/build/commands/adula_uploads_prune.d.ts +10 -0
- package/build/commands/adula_uploads_prune.js +16 -0
- package/build/commands/app.d.ts +10 -0
- package/build/commands/app.js +64 -0
- package/build/commands/backup_create.d.ts +11 -0
- package/build/commands/backup_create.js +99 -0
- package/build/commands/backup_open.d.ts +16 -0
- package/build/commands/backup_open.js +48 -0
- package/build/commands/backup_restore_files.d.ts +11 -0
- package/build/commands/backup_restore_files.js +44 -0
- package/build/commands/backup_restore_test.d.ts +12 -0
- package/build/commands/backup_restore_test.js +188 -0
- package/build/commands/backup_seal.d.ts +12 -0
- package/build/commands/backup_seal.js +36 -0
- package/build/commands/backup_services.d.ts +33 -0
- package/build/commands/backup_services.js +6 -0
- package/build/commands/backup_verify.d.ts +9 -0
- package/build/commands/backup_verify.js +59 -0
- package/build/commands/backup_verify_snapshot.d.ts +10 -0
- package/build/commands/backup_verify_snapshot.js +37 -0
- package/build/commands/client.d.ts +16 -0
- package/build/commands/client.js +71 -0
- package/build/commands/doctor.js +21 -1
- package/build/commands/install.d.ts +8 -0
- package/build/commands/install.js +69 -45
- package/build/commands/main.d.ts +3 -2
- package/build/commands/main.js +32 -0
- package/build/commands/module_add.js +4 -20
- package/build/commands/resource.d.ts +2 -0
- package/build/commands/resource.js +12 -3
- package/build/commands/resource_migration.d.ts +15 -0
- package/build/commands/resource_migration.js +81 -0
- package/build/commands/resource_snapshot.d.ts +2 -0
- package/build/commands/resource_snapshot.js +21 -4
- package/build/commands/sla_evaluate.d.ts +14 -0
- package/build/commands/sla_evaluate.js +16 -0
- package/build/commands/ui.js +4 -2
- package/build/commands/ui_css.d.ts +9 -0
- package/build/commands/ui_css.js +19 -0
- package/build/commands/upgrade.d.ts +1 -1
- package/build/commands/upgrade.js +1 -1
- package/build/configure.js +1 -1
- package/build/database/migrations/1770000000020_two_factor.d.ts +5 -0
- package/build/database/migrations/1770000000020_two_factor.js +10 -0
- package/build/database/migrations/1770000000041_import_modes.d.ts +5 -0
- package/build/database/migrations/1770000000041_import_modes.js +10 -0
- package/build/database/migrations/1770000000042_sync_jobs.d.ts +5 -0
- package/build/database/migrations/1770000000042_sync_jobs.js +10 -0
- package/build/database/migrations/1770000000043_notification_channels.d.ts +5 -0
- package/build/database/migrations/1770000000043_notification_channels.js +10 -0
- package/build/database/migrations/1770000000044_channel_confirmations.d.ts +5 -0
- package/build/database/migrations/1770000000044_channel_confirmations.js +10 -0
- package/build/database/migrations/1770000000045_import_leases.d.ts +5 -0
- package/build/database/migrations/1770000000045_import_leases.js +10 -0
- package/build/database/migrations/1770000000046_workflow_delegation_sla.d.ts +5 -0
- package/build/database/migrations/1770000000046_workflow_delegation_sla.js +10 -0
- package/build/database/migrations/1770000000049_print_templates.d.ts +5 -0
- package/build/database/migrations/1770000000049_print_templates.js +10 -0
- package/build/database/migrations/1770000000051_comment_notifications.d.ts +5 -0
- package/build/database/migrations/1770000000051_comment_notifications.js +10 -0
- package/build/database/migrations/1770000000054_cloud_backups.d.ts +5 -0
- package/build/database/migrations/1770000000054_cloud_backups.js +10 -0
- package/build/database/migrations/1770000000055_ai_assistant.d.ts +5 -0
- package/build/database/migrations/1770000000055_ai_assistant.js +10 -0
- package/build/database/migrations/1770000000056_appearance.d.ts +5 -0
- package/build/database/migrations/1770000000056_appearance.js +10 -0
- package/build/index.d.ts +87 -11
- package/build/index.js +50 -7
- package/build/providers/adula_provider.d.ts +2 -0
- package/build/providers/adula_provider.js +7 -0
- package/build/src/admin/contracts.js +1 -1
- package/build/src/admin/controller.d.ts +14 -1
- package/build/src/admin/controller.js +91 -13
- package/build/src/admin/errors.d.ts +32 -0
- package/build/src/admin/errors.js +63 -1
- package/build/src/admin/presentation.d.ts +21 -2
- package/build/src/admin/resource/editor.d.ts +60 -0
- package/build/src/admin/resource/editor.js +345 -0
- package/build/src/admin/resource/export.d.ts +54 -0
- package/build/src/admin/resource/export.js +262 -0
- package/build/src/admin/resource/lifecycle.d.ts +23 -0
- package/build/src/admin/resource/lifecycle.js +91 -0
- package/build/src/admin/resource/query.d.ts +111 -0
- package/build/src/admin/resource/query.js +595 -0
- package/build/src/admin/resource/read.d.ts +109 -0
- package/build/src/admin/resource/read.js +388 -0
- package/build/src/admin/resource/shared.d.ts +93 -0
- package/build/src/admin/resource/shared.js +265 -0
- package/build/src/admin/resource/trash.d.ts +10 -0
- package/build/src/admin/resource/trash.js +56 -0
- package/build/src/admin/resource/write.d.ts +57 -0
- package/build/src/admin/resource/write.js +603 -0
- package/build/src/admin/resource_service.d.ts +80 -193
- package/build/src/admin/resource_service.js +81 -1343
- package/build/src/admin/resource_tools.d.ts +111 -0
- package/build/src/admin/resource_tools.js +139 -0
- package/build/src/ai/assistant.d.ts +100 -0
- package/build/src/ai/assistant.js +487 -0
- package/build/src/ai/client.d.ts +49 -0
- package/build/src/ai/client.js +85 -0
- package/build/src/ai/prompt.d.ts +23 -0
- package/build/src/ai/prompt.js +83 -0
- package/build/src/ai/settings.d.ts +56 -0
- package/build/src/ai/settings.js +214 -0
- package/build/src/ai/usage.d.ts +16 -0
- package/build/src/ai/usage.js +33 -0
- package/build/src/appearance/appearance.d.ts +134 -0
- package/build/src/appearance/appearance.js +461 -0
- package/build/src/appearance/colors.d.ts +43 -0
- package/build/src/appearance/colors.js +99 -0
- package/build/src/appearance/logo.d.ts +32 -0
- package/build/src/appearance/logo.js +112 -0
- package/build/src/attachments/attachment_service.d.ts +46 -2
- package/build/src/attachments/attachment_service.js +96 -4
- package/build/src/auth/actor_store.d.ts +5 -1
- package/build/src/auth/actor_store.js +8 -4
- package/build/src/auth/conditions.d.ts +5 -0
- package/build/src/auth/conditions.js +26 -3
- package/build/src/auth/sql.js +17 -5
- package/build/src/auth/two_factor.d.ts +96 -0
- package/build/src/auth/two_factor.js +259 -0
- package/build/src/backups/archive.d.ts +52 -0
- package/build/src/backups/archive.js +362 -0
- package/build/src/backups/cloud_backups.d.ts +133 -0
- package/build/src/backups/cloud_backups.js +650 -0
- package/build/src/backups/doctor.d.ts +7 -0
- package/build/src/backups/doctor.js +55 -0
- package/build/src/backups/providers.d.ts +81 -0
- package/build/src/backups/providers.js +470 -0
- package/build/src/collaboration/assignments.d.ts +59 -2
- package/build/src/collaboration/assignments.js +196 -74
- package/build/src/collaboration/record_collaboration.d.ts +21 -4
- package/build/src/collaboration/record_collaboration.js +126 -51
- package/build/src/collaboration/shared.d.ts +24 -0
- package/build/src/collaboration/shared.js +34 -0
- package/build/src/commands/app_scaffold.d.ts +72 -0
- package/build/src/commands/app_scaffold.js +285 -0
- package/build/src/commands/capabilities.js +35 -9
- package/build/src/commands/doctor.d.ts +24 -2
- package/build/src/commands/doctor.js +81 -6
- package/build/src/commands/gap_report.d.ts +1 -1
- package/build/src/commands/gap_report.js +2 -2
- package/build/src/commands/generator.d.ts +37 -1
- package/build/src/commands/generator.js +61 -18
- package/build/src/commands/snapshot.d.ts +24 -13
- package/build/src/commands/snapshot.js +54 -14
- package/build/src/commands/source_markers.d.ts +10 -0
- package/build/src/commands/source_markers.js +29 -0
- package/build/src/core/activity.d.ts +2 -0
- package/build/src/core/activity.js +7 -1
- package/build/src/core/administrators.d.ts +38 -0
- package/build/src/core/administrators.js +145 -0
- package/build/src/core/avatar_image.d.ts +33 -0
- package/build/src/core/avatar_image.js +278 -0
- package/build/src/core/html_sanitizer.d.ts +20 -0
- package/build/src/core/html_sanitizer.js +261 -0
- package/build/src/core/like.d.ts +5 -0
- package/build/src/core/like.js +5 -0
- package/build/src/core/lookups.d.ts +80 -0
- package/build/src/core/lookups.js +319 -0
- package/build/src/core/mail_settings.d.ts +83 -0
- package/build/src/core/mail_settings.js +274 -0
- package/build/src/core/mail_test.d.ts +16 -0
- package/build/src/core/mail_test.js +81 -6
- package/build/src/core/message_templates.d.ts +15 -2
- package/build/src/core/message_templates.js +81 -11
- package/build/src/core/module_seed.js +2 -1
- package/build/src/core/notification_channels.d.ts +235 -0
- package/build/src/core/notification_channels.js +660 -0
- package/build/src/core/roles.js +26 -9
- package/build/src/core/saved_views.d.ts +8 -1
- package/build/src/core/saved_views.js +91 -26
- package/build/src/core/sequences.d.ts +32 -0
- package/build/src/core/sequences.js +97 -0
- package/build/src/core/settings.d.ts +5 -0
- package/build/src/core/settings.js +31 -3
- package/build/src/core/template_language.d.ts +61 -0
- package/build/src/core/template_language.js +141 -0
- package/build/src/core/ui_preferences.d.ts +10 -0
- package/build/src/core/ui_preferences.js +15 -1
- package/build/src/core/user_avatars.d.ts +79 -0
- package/build/src/core/user_avatars.js +186 -0
- package/build/src/core/user_invitations.d.ts +5 -1
- package/build/src/core/user_invitations.js +7 -1
- package/build/src/core/user_preferences.d.ts +36 -0
- package/build/src/core/user_preferences.js +125 -0
- package/build/src/core/users.d.ts +2 -0
- package/build/src/core/users.js +5 -3
- package/build/src/database/calendar_days.d.ts +19 -0
- package/build/src/database/calendar_days.js +36 -0
- package/build/src/database/schema.d.ts +201 -2
- package/build/src/database/schema.js +713 -59
- package/build/src/database/schema_diff.d.ts +70 -0
- package/build/src/database/schema_diff.js +190 -0
- package/build/src/events/record_mutation.d.ts +2 -1
- package/build/src/events/record_mutation.js +1 -0
- package/build/src/integrations/api_client.d.ts +37 -0
- package/build/src/integrations/api_client.js +567 -0
- package/build/src/integrations/import_adapters.d.ts +37 -0
- package/build/src/integrations/import_adapters.js +35 -0
- package/build/src/integrations/imports.d.ts +130 -16
- package/build/src/integrations/imports.js +434 -73
- package/build/src/integrations/openapi.d.ts +3 -1
- package/build/src/integrations/openapi.js +465 -31
- package/build/src/integrations/outbound.d.ts +94 -0
- package/build/src/integrations/outbound.js +276 -0
- package/build/src/integrations/print.d.ts +22 -1
- package/build/src/integrations/print.js +68 -22
- package/build/src/integrations/print_templates.d.ts +216 -0
- package/build/src/integrations/print_templates.js +1017 -0
- package/build/src/integrations/sync_jobs.d.ts +139 -0
- package/build/src/integrations/sync_jobs.js +416 -0
- package/build/src/integrations/webhooks.d.ts +12 -12
- package/build/src/integrations/webhooks.js +34 -43
- package/build/src/integrations/xlsx.d.ts +41 -0
- package/build/src/integrations/xlsx.js +519 -0
- package/build/src/languages/ar.d.ts +11 -0
- package/build/src/languages/ar.js +358 -0
- package/build/src/languages/ar_ui.d.ts +461 -0
- package/build/src/languages/ar_ui.js +464 -0
- package/build/src/languages/catalog.d.ts +66 -0
- package/build/src/languages/catalog.js +152 -0
- package/build/src/languages/en.d.ts +7 -0
- package/build/src/languages/en.js +352 -0
- package/build/src/languages/en_ui.d.ts +3 -0
- package/build/src/languages/en_ui.js +458 -0
- package/build/src/languages/validation.d.ts +26 -0
- package/build/src/languages/validation.js +60 -0
- package/build/src/lists/bulk_actions.d.ts +89 -0
- package/build/src/lists/bulk_actions.js +268 -0
- package/build/src/lists/dashboards.d.ts +138 -0
- package/build/src/lists/dashboards.js +290 -0
- package/build/src/mcp/tools.js +9 -104
- package/build/src/resource/define_resource.d.ts +18 -1
- package/build/src/resource/define_resource.js +212 -18
- package/build/src/resource/definition.d.ts +44 -0
- package/build/src/resource/definition.js +171 -0
- package/build/src/resource/registry.js +15 -4
- package/build/src/resource/types.d.ts +313 -16
- package/build/src/resource/values.d.ts +56 -1
- package/build/src/resource/values.js +237 -5
- package/build/src/services/settings.d.ts +2 -0
- package/build/src/services/settings.js +5 -1
- package/build/src/upgrade/legacy.js +2 -2
- package/build/src/workflows/calendar.d.ts +9 -0
- package/build/src/workflows/calendar.js +44 -0
- package/build/src/workflows/define_workflow.d.ts +48 -3
- package/build/src/workflows/define_workflow.js +57 -13
- package/build/src/workflows/delegations.d.ts +107 -0
- package/build/src/workflows/delegations.js +326 -0
- package/build/src/workflows/engine.d.ts +80 -4
- package/build/src/workflows/engine.js +466 -86
- package/build/src/workflows/sla.d.ts +15 -0
- package/build/src/workflows/sla.js +8 -0
- package/build/stubs/resource_contract.txt +12 -1
- package/package.json +9 -2
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** A validated address the outbound connection is pinned to. */
|
|
2
|
+
export type OutboundTarget = {
|
|
3
|
+
address: string;
|
|
4
|
+
family: 4 | 6;
|
|
5
|
+
};
|
|
6
|
+
export type OutboundOptions = {
|
|
7
|
+
/** Allow http:// and private or loopback addresses (explicit opt-in only). */
|
|
8
|
+
allowPrivateTargets?: boolean;
|
|
9
|
+
/** Hostname resolution; replaceable in tests. */
|
|
10
|
+
resolve?: (host: string) => Promise<string[]>;
|
|
11
|
+
};
|
|
12
|
+
export type OutboundRequest = {
|
|
13
|
+
headers: Record<string, string>;
|
|
14
|
+
body: string;
|
|
15
|
+
signal: AbortSignal;
|
|
16
|
+
/** The address validated before the request; the connection must use it. */
|
|
17
|
+
target?: OutboundTarget;
|
|
18
|
+
};
|
|
19
|
+
/** Stored failure categories; raw error messages and response bodies are never kept. */
|
|
20
|
+
export type OutboundErrorCategory = 'dns' | 'connect' | 'tls' | 'timeout' | 'blocked-target' | 'secret' | `http-status:${number}`;
|
|
21
|
+
/** Raised when a target is not allowed or cannot be resolved. */
|
|
22
|
+
export declare class OutboundTargetError extends Error {
|
|
23
|
+
category: 'blocked-target' | 'dns';
|
|
24
|
+
constructor(category: 'blocked-target' | 'dns');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* True when an IP literal is not a public unicast address. IPv4-mapped and
|
|
28
|
+
* NAT64 (64:ff9b::/96) addresses are checked by the IPv4 address they embed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function isBlockedAddress(address: string): boolean;
|
|
31
|
+
/** True for a link-local address, including IPv4-mapped, IPv4-translated and NAT64 forms. */
|
|
32
|
+
export declare function isLinkLocalAddress(address: string): boolean;
|
|
33
|
+
export declare const defaultResolve: (host: string) => Promise<string[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Resolves a URL's host once and returns the address to pin the connection to.
|
|
36
|
+
* Every resolved address must be public unless private targets are allowed.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveOutboundTarget(url: URL, options?: OutboundOptions): Promise<OutboundTarget>;
|
|
39
|
+
/** A request through the pinned connection; the response body is read up to a bound. */
|
|
40
|
+
export type PinnedRequest = {
|
|
41
|
+
method: string;
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
body?: string | Uint8Array;
|
|
44
|
+
signal: AbortSignal;
|
|
45
|
+
target: OutboundTarget;
|
|
46
|
+
/** Bytes of the response body kept; 0 discards it. A longer body fails the request. */
|
|
47
|
+
maxResponseBytes?: number;
|
|
48
|
+
};
|
|
49
|
+
export type PinnedResponse = {
|
|
50
|
+
status: number;
|
|
51
|
+
headers: Record<string, string | string[] | undefined>;
|
|
52
|
+
body: Buffer;
|
|
53
|
+
};
|
|
54
|
+
/** Raised when a response body exceeds the caller's bound. */
|
|
55
|
+
export declare class OutboundResponseTooLargeError extends Error {
|
|
56
|
+
constructor();
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Sends a request whose TCP connection goes to the pinned address; redirects are not
|
|
60
|
+
* followed and the response body is bounded.
|
|
61
|
+
*/
|
|
62
|
+
export declare function pinnedRequest(url: URL, init: PinnedRequest): Promise<PinnedResponse>;
|
|
63
|
+
/** Sends a POST whose TCP connection goes to the pinned address; redirects are not followed. */
|
|
64
|
+
export declare function pinnedPost(url: URL, init: OutboundRequest & {
|
|
65
|
+
target: OutboundTarget;
|
|
66
|
+
}): Promise<{
|
|
67
|
+
status: number;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Validates an absolute URL for an outbound request: https only (http when private targets
|
|
71
|
+
* are allowed), no credentials, and a resolved address that is public unless allowed.
|
|
72
|
+
*/
|
|
73
|
+
export declare function guardOutboundUrl(value: string | URL, options?: OutboundOptions): Promise<{
|
|
74
|
+
url: import("node:url").URL;
|
|
75
|
+
target: OutboundTarget;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* The guarded outbound HTTP client: validates the URL, resolves its host once,
|
|
79
|
+
* refuses private targets unless allowed and connects to the validated address.
|
|
80
|
+
* A `target` supplied by the caller (already validated) is used as-is.
|
|
81
|
+
*/
|
|
82
|
+
export declare function createOutboundPoster(options?: OutboundOptions): (value: string, init: OutboundRequest) => Promise<{
|
|
83
|
+
status: number;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* The guarded client for calls that need the response body (an API answer, ADR 052): the
|
|
87
|
+
* same URL, address and redirect rules as createOutboundPoster, through pinnedRequest with
|
|
88
|
+
* the body bounded by `maxResponseBytes` (OutboundResponseTooLargeError above it).
|
|
89
|
+
*/
|
|
90
|
+
export declare function createOutboundRequester(options?: OutboundOptions): (value: string, init: OutboundRequest & {
|
|
91
|
+
maxResponseBytes: number;
|
|
92
|
+
}) => Promise<PinnedResponse>;
|
|
93
|
+
/** Maps a delivery failure to a stored category without keeping its message. */
|
|
94
|
+
export declare function outboundErrorCategory(error: unknown): OutboundErrorCategory;
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
import { lookup } from 'node:dns/promises';
|
|
2
|
+
import { request as httpRequest } from 'node:http';
|
|
3
|
+
import { request as httpsRequest } from 'node:https';
|
|
4
|
+
import { BlockList, isIP } from 'node:net';
|
|
5
|
+
/** Raised when a target is not allowed or cannot be resolved. */
|
|
6
|
+
export class OutboundTargetError extends Error {
|
|
7
|
+
category;
|
|
8
|
+
constructor(category) {
|
|
9
|
+
super(category === 'dns' ? 'Target host cannot be resolved' : 'Target address is not allowed');
|
|
10
|
+
this.category = category;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
// IANA special-purpose and non-public ranges.
|
|
14
|
+
const IPV4_BLOCKED = [
|
|
15
|
+
['0.0.0.0', 8],
|
|
16
|
+
['10.0.0.0', 8],
|
|
17
|
+
['100.64.0.0', 10],
|
|
18
|
+
['127.0.0.0', 8],
|
|
19
|
+
['169.254.0.0', 16],
|
|
20
|
+
['172.16.0.0', 12],
|
|
21
|
+
['192.0.0.0', 24],
|
|
22
|
+
['192.0.2.0', 24],
|
|
23
|
+
['192.88.99.0', 24],
|
|
24
|
+
['192.31.196.0', 24], // AS112
|
|
25
|
+
['192.52.193.0', 24], // AMT
|
|
26
|
+
['192.168.0.0', 16],
|
|
27
|
+
['192.175.48.0', 24], // AS112 direct delegation
|
|
28
|
+
['198.18.0.0', 15],
|
|
29
|
+
['198.51.100.0', 24],
|
|
30
|
+
['203.0.113.0', 24],
|
|
31
|
+
['224.0.0.0', 4],
|
|
32
|
+
['240.0.0.0', 4],
|
|
33
|
+
];
|
|
34
|
+
const IPV6_BLOCKED = [
|
|
35
|
+
['::', 96], // unspecified, loopback and deprecated IPv4-compatible addresses
|
|
36
|
+
['64:ff9b:1::', 48], // local-use NAT64
|
|
37
|
+
['100::', 64], // discard-only
|
|
38
|
+
['2001::', 23], // IETF protocol assignments, including Teredo
|
|
39
|
+
['2001:db8::', 32], // documentation
|
|
40
|
+
['2002::', 16], // 6to4 can tunnel to any IPv4 address
|
|
41
|
+
['3fff::', 20], // documentation
|
|
42
|
+
['5f00::', 16], // SRv6 SIDs
|
|
43
|
+
['fc00::', 7], // unique local
|
|
44
|
+
['fe80::', 10], // link-local
|
|
45
|
+
['fec0::', 10], // deprecated site-local
|
|
46
|
+
['ff00::', 8], // multicast
|
|
47
|
+
];
|
|
48
|
+
const ipv4Blocked = new BlockList();
|
|
49
|
+
for (const [network, prefix] of IPV4_BLOCKED)
|
|
50
|
+
ipv4Blocked.addSubnet(network, prefix, 'ipv4');
|
|
51
|
+
ipv4Blocked.addAddress('255.255.255.255', 'ipv4');
|
|
52
|
+
const ipv6Blocked = new BlockList();
|
|
53
|
+
for (const [network, prefix] of IPV6_BLOCKED)
|
|
54
|
+
ipv6Blocked.addSubnet(network, prefix, 'ipv6');
|
|
55
|
+
/** Expands an IPv6 address (optionally with a dotted IPv4 tail) to eight 16-bit groups. */
|
|
56
|
+
function ipv6Groups(address) {
|
|
57
|
+
let value = address.toLowerCase().split('%')[0];
|
|
58
|
+
const dotted = value.match(/(\d+\.\d+\.\d+\.\d+)$/);
|
|
59
|
+
if (dotted) {
|
|
60
|
+
const octets = dotted[1].split('.').map(Number);
|
|
61
|
+
value =
|
|
62
|
+
value.slice(0, -dotted[1].length) +
|
|
63
|
+
`${((octets[0] << 8) | octets[1]).toString(16)}:${((octets[2] << 8) | octets[3]).toString(16)}`;
|
|
64
|
+
}
|
|
65
|
+
const [head, tail] = value.split('::');
|
|
66
|
+
const left = head ? head.split(':') : [];
|
|
67
|
+
const right = tail ? tail.split(':') : [];
|
|
68
|
+
const missing = 8 - left.length - right.length;
|
|
69
|
+
if (value.includes('::') ? missing < 1 : missing !== 0)
|
|
70
|
+
return null;
|
|
71
|
+
const groups = [...left, ...Array(value.includes('::') ? missing : 0).fill('0'), ...right].map((group) => Number.parseInt(group, 16));
|
|
72
|
+
return groups.length === 8 && groups.every((group) => group >= 0 && group <= 0xffff)
|
|
73
|
+
? groups
|
|
74
|
+
: null;
|
|
75
|
+
}
|
|
76
|
+
function embeddedIPv4(groups) {
|
|
77
|
+
return [groups[6] >> 8, groups[6] & 0xff, groups[7] >> 8, groups[7] & 0xff].join('.');
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* True when an IP literal is not a public unicast address. IPv4-mapped and
|
|
81
|
+
* NAT64 (64:ff9b::/96) addresses are checked by the IPv4 address they embed.
|
|
82
|
+
*/
|
|
83
|
+
export function isBlockedAddress(address) {
|
|
84
|
+
const value = address.replace(/^\[|\]$/g, '');
|
|
85
|
+
const version = isIP(value);
|
|
86
|
+
if (version === 4)
|
|
87
|
+
return ipv4Blocked.check(value, 'ipv4');
|
|
88
|
+
if (version !== 6)
|
|
89
|
+
return true;
|
|
90
|
+
const groups = ipv6Groups(value);
|
|
91
|
+
if (!groups)
|
|
92
|
+
return true;
|
|
93
|
+
const prefix96 = groups.slice(0, 6);
|
|
94
|
+
// IPv4-mapped ::ffff:0:0/96 and IPv4-translated ::ffff:0:0:0/96.
|
|
95
|
+
if (prefix96.every((group, index) => group === (index === 5 ? 0xffff : 0)))
|
|
96
|
+
return isBlockedAddress(embeddedIPv4(groups));
|
|
97
|
+
if (prefix96.every((group, index) => group === (index === 4 ? 0xffff : 0)))
|
|
98
|
+
return isBlockedAddress(embeddedIPv4(groups));
|
|
99
|
+
if (groups[0] === 0x64 && groups[1] === 0xff9b && prefix96.slice(2).every((group) => group === 0))
|
|
100
|
+
return isBlockedAddress(embeddedIPv4(groups));
|
|
101
|
+
return ipv6Blocked.check(groups.map((group) => group.toString(16)).join(':'), 'ipv6');
|
|
102
|
+
}
|
|
103
|
+
/** True for a link-local address, including IPv4-mapped, IPv4-translated and NAT64 forms. */
|
|
104
|
+
export function isLinkLocalAddress(address) {
|
|
105
|
+
const value = address.replace(/^\[|\]$/g, '');
|
|
106
|
+
const version = isIP(value);
|
|
107
|
+
if (version === 4) {
|
|
108
|
+
const [first, second] = value.split('.').map(Number);
|
|
109
|
+
return first === 169 && second === 254;
|
|
110
|
+
}
|
|
111
|
+
if (version !== 6)
|
|
112
|
+
return false;
|
|
113
|
+
const groups = ipv6Groups(value);
|
|
114
|
+
if (!groups)
|
|
115
|
+
return false;
|
|
116
|
+
const prefix96 = groups.slice(0, 6);
|
|
117
|
+
if (prefix96.every((group, index) => group === (index === 5 ? 0xffff : 0)) ||
|
|
118
|
+
prefix96.every((group, index) => group === (index === 4 ? 0xffff : 0)) ||
|
|
119
|
+
(groups[0] === 0x64 && groups[1] === 0xff9b && prefix96.slice(2).every((group) => group === 0)))
|
|
120
|
+
return isLinkLocalAddress(embeddedIPv4(groups));
|
|
121
|
+
return (groups[0] & 0xffc0) === 0xfe80;
|
|
122
|
+
}
|
|
123
|
+
export const defaultResolve = async (host) => {
|
|
124
|
+
const entries = await lookup(host, { all: true });
|
|
125
|
+
return entries.map((entry) => entry.address);
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Resolves a URL's host once and returns the address to pin the connection to.
|
|
129
|
+
* Every resolved address must be public unless private targets are allowed.
|
|
130
|
+
*/
|
|
131
|
+
export async function resolveOutboundTarget(url, options = {}) {
|
|
132
|
+
const host = url.hostname.replace(/^\[|\]$/g, '');
|
|
133
|
+
let addresses;
|
|
134
|
+
if (isIP(host))
|
|
135
|
+
addresses = [host];
|
|
136
|
+
else {
|
|
137
|
+
try {
|
|
138
|
+
addresses = await (options.resolve ?? defaultResolve)(host);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
throw new OutboundTargetError('dns');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (!addresses.length || addresses.some((address) => !isIP(address)))
|
|
145
|
+
throw new OutboundTargetError('dns');
|
|
146
|
+
if (options.allowPrivateTargets !== true && addresses.some(isBlockedAddress))
|
|
147
|
+
throw new OutboundTargetError('blocked-target');
|
|
148
|
+
const [address] = addresses;
|
|
149
|
+
return { address, family: isIP(address) === 6 ? 6 : 4 };
|
|
150
|
+
}
|
|
151
|
+
/** Raised when a response body exceeds the caller's bound. */
|
|
152
|
+
export class OutboundResponseTooLargeError extends Error {
|
|
153
|
+
constructor() {
|
|
154
|
+
super('Response body is too large');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Sends a request whose TCP connection goes to the pinned address; redirects are not
|
|
159
|
+
* followed and the response body is bounded.
|
|
160
|
+
*/
|
|
161
|
+
export function pinnedRequest(url, init) {
|
|
162
|
+
const { address, family } = init.target;
|
|
163
|
+
const pinnedLookup = (_host, options, callback) => {
|
|
164
|
+
if (options.all)
|
|
165
|
+
callback(null, [{ address, family }]);
|
|
166
|
+
else
|
|
167
|
+
callback(null, address, family);
|
|
168
|
+
};
|
|
169
|
+
const host = url.hostname.replace(/^\[|\]$/g, '');
|
|
170
|
+
const send = url.protocol === 'https:' ? httpsRequest : httpRequest;
|
|
171
|
+
const limit = init.maxResponseBytes ?? 0;
|
|
172
|
+
const body = init.body ?? '';
|
|
173
|
+
return new Promise((resolve, reject) => {
|
|
174
|
+
const request = send(url, {
|
|
175
|
+
method: init.method,
|
|
176
|
+
headers: { ...init.headers, 'Content-Length': String(Buffer.byteLength(body)) },
|
|
177
|
+
lookup: pinnedLookup,
|
|
178
|
+
servername: isIP(host) ? undefined : host,
|
|
179
|
+
signal: init.signal,
|
|
180
|
+
}, (response) => {
|
|
181
|
+
const result = { status: response.statusCode ?? 0, headers: response.headers };
|
|
182
|
+
if (limit <= 0) {
|
|
183
|
+
response.resume();
|
|
184
|
+
return resolve({ ...result, body: Buffer.alloc(0) });
|
|
185
|
+
}
|
|
186
|
+
const chunks = [];
|
|
187
|
+
let size = 0;
|
|
188
|
+
response.on('data', (chunk) => {
|
|
189
|
+
size += chunk.length;
|
|
190
|
+
if (size > limit) {
|
|
191
|
+
response.destroy();
|
|
192
|
+
request.destroy();
|
|
193
|
+
return reject(new OutboundResponseTooLargeError());
|
|
194
|
+
}
|
|
195
|
+
chunks.push(chunk);
|
|
196
|
+
});
|
|
197
|
+
response.on('end', () => resolve({ ...result, body: Buffer.concat(chunks) }));
|
|
198
|
+
response.on('error', reject);
|
|
199
|
+
});
|
|
200
|
+
request.on('error', reject);
|
|
201
|
+
request.end(body);
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/** Sends a POST whose TCP connection goes to the pinned address; redirects are not followed. */
|
|
205
|
+
export async function pinnedPost(url, init) {
|
|
206
|
+
// The body is never read or stored.
|
|
207
|
+
const { status } = await pinnedRequest(url, { ...init, method: 'POST', maxResponseBytes: 0 });
|
|
208
|
+
return { status };
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Validates an absolute URL for an outbound request: https only (http when private targets
|
|
212
|
+
* are allowed), no credentials, and a resolved address that is public unless allowed.
|
|
213
|
+
*/
|
|
214
|
+
export async function guardOutboundUrl(value, options = {}) {
|
|
215
|
+
const url = new URL(value);
|
|
216
|
+
if (url.protocol !== 'https:' && !(options.allowPrivateTargets && url.protocol === 'http:'))
|
|
217
|
+
throw new OutboundTargetError('blocked-target');
|
|
218
|
+
if (url.username || url.password)
|
|
219
|
+
throw new OutboundTargetError('blocked-target');
|
|
220
|
+
const target = await resolveOutboundTarget(url, options);
|
|
221
|
+
return { url, target };
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The guarded outbound HTTP client: validates the URL, resolves its host once,
|
|
225
|
+
* refuses private targets unless allowed and connects to the validated address.
|
|
226
|
+
* A `target` supplied by the caller (already validated) is used as-is.
|
|
227
|
+
*/
|
|
228
|
+
export function createOutboundPoster(options = {}) {
|
|
229
|
+
return async (value, init) => {
|
|
230
|
+
const { url, target } = await guardedTarget(value, options, init.target);
|
|
231
|
+
return pinnedPost(url, { ...init, target });
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* The guarded client for calls that need the response body (an API answer, ADR 052): the
|
|
236
|
+
* same URL, address and redirect rules as createOutboundPoster, through pinnedRequest with
|
|
237
|
+
* the body bounded by `maxResponseBytes` (OutboundResponseTooLargeError above it).
|
|
238
|
+
*/
|
|
239
|
+
export function createOutboundRequester(options = {}) {
|
|
240
|
+
return async (value, init) => {
|
|
241
|
+
const { url, target } = await guardedTarget(value, options, init.target);
|
|
242
|
+
return pinnedRequest(url, { ...init, method: 'POST', target });
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
/** URL checks of guardOutboundUrl; a caller-supplied target is re-checked, not re-resolved. */
|
|
246
|
+
async function guardedTarget(value, options, target) {
|
|
247
|
+
const url = new URL(value);
|
|
248
|
+
if (url.protocol !== 'https:' && !(options.allowPrivateTargets && url.protocol === 'http:'))
|
|
249
|
+
throw new OutboundTargetError('blocked-target');
|
|
250
|
+
if (url.username || url.password)
|
|
251
|
+
throw new OutboundTargetError('blocked-target');
|
|
252
|
+
const resolved = target ?? (await resolveOutboundTarget(url, options));
|
|
253
|
+
if (options.allowPrivateTargets !== true && isBlockedAddress(resolved.address))
|
|
254
|
+
throw new OutboundTargetError('blocked-target');
|
|
255
|
+
return { url, target: resolved };
|
|
256
|
+
}
|
|
257
|
+
const TLS_CODES = /^(ERR_TLS|ERR_SSL|CERT_|UNABLE_TO_|DEPTH_ZERO|SELF_SIGNED|HOSTNAME_MISMATCH)/;
|
|
258
|
+
const DNS_CODES = new Set(['ENOTFOUND', 'EAI_AGAIN', 'EAI_FAIL', 'ENODATA', 'ESERVFAIL']);
|
|
259
|
+
/** Maps a delivery failure to a stored category without keeping its message. */
|
|
260
|
+
export function outboundErrorCategory(error) {
|
|
261
|
+
for (let current = error, depth = 0; current && depth < 5; depth++) {
|
|
262
|
+
if (current instanceof OutboundTargetError)
|
|
263
|
+
return current.category;
|
|
264
|
+
const { name, code } = current;
|
|
265
|
+
if (name === 'TimeoutError' || name === 'AbortError' || code === 'ABORT_ERR')
|
|
266
|
+
return 'timeout';
|
|
267
|
+
if (code === 'ETIMEDOUT' || code === 'UND_ERR_CONNECT_TIMEOUT')
|
|
268
|
+
return 'timeout';
|
|
269
|
+
if (code && DNS_CODES.has(code))
|
|
270
|
+
return 'dns';
|
|
271
|
+
if (code && TLS_CODES.test(code))
|
|
272
|
+
return 'tls';
|
|
273
|
+
current = current.cause;
|
|
274
|
+
}
|
|
275
|
+
return 'connect';
|
|
276
|
+
}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import type { ResourceDescription } from '../admin/presentation.js';
|
|
2
|
-
import type { SerializedRecord } from '../resource/types.js';
|
|
2
|
+
import type { JsonValue, SerializedRecord } from '../resource/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* `logoUrl` must be a base64 image data URI (see imageDataUri). Any other URL is
|
|
5
|
+
* dropped: the PDF renderer would fetch it from inside the deployment network.
|
|
6
|
+
*/
|
|
3
7
|
export type PrintIdentity = {
|
|
4
8
|
name: string;
|
|
5
9
|
logoUrl?: string | null;
|
|
6
10
|
};
|
|
11
|
+
/** Largest logo inlined into printed documents. */
|
|
12
|
+
export declare const PRINT_LOGO_LIMIT: number;
|
|
13
|
+
/** Inlines a logo file as a data URI for printing; null for unknown types or oversize files. */
|
|
14
|
+
export declare function imageDataUri(bytes: Uint8Array, fileName: string): string | null;
|
|
7
15
|
export type PrintInput = {
|
|
8
16
|
identity: PrintIdentity;
|
|
9
17
|
resource: ResourceDescription;
|
|
@@ -20,6 +28,19 @@ export type PrintInput = {
|
|
|
20
28
|
printedBy: string;
|
|
21
29
|
printedAt?: Date;
|
|
22
30
|
};
|
|
31
|
+
/** HTML-escapes text for printed documents (&, <, >, " and '). */
|
|
32
|
+
export declare const escapeHtml: (value: string) => string;
|
|
33
|
+
/**
|
|
34
|
+
* The label of a related record, as the UI's relationLabel: the server's `_title`, else
|
|
35
|
+
* (user rows) the first non-meta text value, else `#id`. A record the reader may not view
|
|
36
|
+
* has no related row and is printed with a neutral label, never its id.
|
|
37
|
+
*/
|
|
38
|
+
export declare function relationTitle(rows: SerializedRecord[] | undefined, value: JsonValue | undefined): string;
|
|
39
|
+
/**
|
|
40
|
+
* The `<img>` of an inlined logo, or '' for anything that is not a bounded base64 image
|
|
41
|
+
* data URI: the PDF renderer must never fetch a URL (SSRF from its network).
|
|
42
|
+
*/
|
|
43
|
+
export declare function printLogoHtml(identity: PrintIdentity): string;
|
|
23
44
|
/**
|
|
24
45
|
* The generic printable view of one record: RTL A4 HTML, every value escaped.
|
|
25
46
|
* Only fields already serialized for the caller are printed, so printing can
|
|
@@ -1,9 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
import { translate } from '../languages/catalog.js';
|
|
2
|
+
const IMAGE_TYPES = {
|
|
3
|
+
png: 'image/png',
|
|
4
|
+
jpg: 'image/jpeg',
|
|
5
|
+
jpeg: 'image/jpeg',
|
|
6
|
+
gif: 'image/gif',
|
|
7
|
+
webp: 'image/webp',
|
|
8
|
+
svg: 'image/svg+xml',
|
|
9
|
+
};
|
|
10
|
+
const DATA_IMAGE = /^data:image\/(png|jpeg|gif|webp|svg\+xml);base64,[A-Za-z0-9+/]+={0,2}$/;
|
|
11
|
+
/** Largest logo inlined into printed documents. */
|
|
12
|
+
export const PRINT_LOGO_LIMIT = 512 * 1024;
|
|
13
|
+
/** Inlines a logo file as a data URI for printing; null for unknown types or oversize files. */
|
|
14
|
+
export function imageDataUri(bytes, fileName) {
|
|
15
|
+
const type = IMAGE_TYPES[fileName.split('.').pop()?.toLowerCase() ?? ''];
|
|
16
|
+
if (!type || !bytes.byteLength || bytes.byteLength > PRINT_LOGO_LIMIT)
|
|
17
|
+
return null;
|
|
18
|
+
return `data:${type};base64,${Buffer.from(bytes).toString('base64')}`;
|
|
19
|
+
}
|
|
20
|
+
/** HTML-escapes text for printed documents (&, <, >, " and '). */
|
|
21
|
+
export const escapeHtml = (value) => value
|
|
2
22
|
.replaceAll('&', '&')
|
|
3
23
|
.replaceAll('<', '<')
|
|
4
24
|
.replaceAll('>', '>')
|
|
5
25
|
.replaceAll('"', '"')
|
|
6
26
|
.replaceAll("'", ''');
|
|
27
|
+
const RELATION_META = new Set(['id', 'version', 'docStatus', 'orgUnitId']);
|
|
28
|
+
/**
|
|
29
|
+
* The label of a related record, as the UI's relationLabel: the server's `_title`, else
|
|
30
|
+
* (user rows) the first non-meta text value, else `#id`. A record the reader may not view
|
|
31
|
+
* has no related row and is printed with a neutral label, never its id.
|
|
32
|
+
*/
|
|
33
|
+
export function relationTitle(rows, value) {
|
|
34
|
+
const fallback = value === null || value === undefined ? '—' : `#${String(value)}`;
|
|
35
|
+
const row = rows?.find((entry) => String(entry.id) === String(value));
|
|
36
|
+
if (!row)
|
|
37
|
+
return fallback === '—' ? fallback : translate('list.value.unavailable');
|
|
38
|
+
if ('_title' in row)
|
|
39
|
+
return typeof row._title === 'string' && row._title ? row._title : fallback;
|
|
40
|
+
const label = Object.entries(row).find(([key, entry]) => !RELATION_META.has(key) && typeof entry === 'string' && entry);
|
|
41
|
+
return label ? String(label[1]) : fallback;
|
|
42
|
+
}
|
|
7
43
|
function text(field, value, input) {
|
|
8
44
|
if (value === null || value === undefined || value === '')
|
|
9
45
|
return '—';
|
|
@@ -21,15 +57,14 @@ function text(field, value, input) {
|
|
|
21
57
|
case 'lookup':
|
|
22
58
|
return (input.lookups?.[field.key]?.find((option) => option.value === value)?.label ?? String(value));
|
|
23
59
|
case 'user':
|
|
24
|
-
case 'belongsTo':
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
case 'attachment':
|
|
30
|
-
return typeof value === 'object' && !Array.isArray(value) && value.name
|
|
31
|
-
? String(value.name)
|
|
60
|
+
case 'belongsTo':
|
|
61
|
+
return relationTitle(input.related?.[field.key], value);
|
|
62
|
+
case 'attachment': {
|
|
63
|
+
const name = (entry) => entry && typeof entry === 'object' && !Array.isArray(entry) && 'name' in entry
|
|
64
|
+
? String(entry.name)
|
|
32
65
|
: 'مرفق';
|
|
66
|
+
return Array.isArray(value) ? value.map(name).join('، ') : name(value);
|
|
67
|
+
}
|
|
33
68
|
case 'datetime':
|
|
34
69
|
return new Date(String(value)).toLocaleString('ar-u-nu-latn-ca-gregory', { timeZone: 'UTC' });
|
|
35
70
|
case 'json':
|
|
@@ -38,6 +73,16 @@ function text(field, value, input) {
|
|
|
38
73
|
return String(value);
|
|
39
74
|
}
|
|
40
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The `<img>` of an inlined logo, or '' for anything that is not a bounded base64 image
|
|
78
|
+
* data URI: the PDF renderer must never fetch a URL (SSRF from its network).
|
|
79
|
+
*/
|
|
80
|
+
export function printLogoHtml(identity) {
|
|
81
|
+
const logoUrl = identity.logoUrl;
|
|
82
|
+
return logoUrl && logoUrl.length <= PRINT_LOGO_LIMIT * 2 && DATA_IMAGE.test(logoUrl)
|
|
83
|
+
? `<img class="logo" src="${escapeHtml(logoUrl)}" alt="">`
|
|
84
|
+
: '';
|
|
85
|
+
}
|
|
41
86
|
/**
|
|
42
87
|
* The generic printable view of one record: RTL A4 HTML, every value escaped.
|
|
43
88
|
* Only fields already serialized for the caller are printed, so printing can
|
|
@@ -52,31 +97,32 @@ export function renderPrintHtml(input) {
|
|
|
52
97
|
? ['مسودة', 'معتمد', 'ملغي'][input.record.docStatus]
|
|
53
98
|
: null;
|
|
54
99
|
const rows = fields
|
|
55
|
-
.map((field) => `<tr><th scope="row">${
|
|
100
|
+
.map((field) => `<tr><th scope="row">${escapeHtml(field.label.ar)}</th><td>${escapeHtml(text(field, input.record[field.key], input))}</td></tr>`)
|
|
56
101
|
.join('');
|
|
57
102
|
const children = Object.entries(input.children ?? {})
|
|
58
103
|
.map(([key, group]) => {
|
|
59
104
|
const label = input.resource.fields.find((field) => field.key === key)?.label.ar ?? key;
|
|
60
105
|
const columns = group.fields.filter((field) => field.type !== 'hasMany');
|
|
61
|
-
return `<section><h2>${
|
|
62
|
-
.map((column) => `<th scope="col">${
|
|
106
|
+
return `<section><h2>${escapeHtml(label)}</h2><table class="lines"><thead><tr>${columns
|
|
107
|
+
.map((column) => `<th scope="col">${escapeHtml(column.label.ar)}</th>`)
|
|
63
108
|
.join('')}</tr></thead><tbody>${group.rows
|
|
64
|
-
.map((row) => `<tr>${columns.map((column) => `<td>${
|
|
109
|
+
.map((row) => `<tr>${columns.map((column) => `<td>${escapeHtml(text(column, row[column.key], input))}</td>`).join('')}</tr>`)
|
|
65
110
|
.join('')}</tbody></table></section>`;
|
|
66
111
|
})
|
|
67
112
|
.join('');
|
|
68
|
-
const logo = input.identity
|
|
69
|
-
? `<img class="logo" src="${escape(input.identity.logoUrl)}" alt="">`
|
|
70
|
-
: '';
|
|
113
|
+
const logo = printLogoHtml(input.identity);
|
|
71
114
|
return `<!doctype html>
|
|
72
115
|
<html lang="ar" dir="rtl">
|
|
73
116
|
<head>
|
|
74
117
|
<meta charset="utf-8">
|
|
75
|
-
<
|
|
118
|
+
<meta name="color-scheme" content="light">
|
|
119
|
+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">
|
|
120
|
+
<title>${escapeHtml(input.resource.label)} #${escapeHtml(String(input.record.id))}</title>
|
|
76
121
|
<style>
|
|
77
122
|
@page { size: A4; margin: 18mm 16mm; }
|
|
78
123
|
* { box-sizing: border-box; }
|
|
79
|
-
|
|
124
|
+
:root { color-scheme: light; }
|
|
125
|
+
body { font-family: "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif; color: #1c1917; background: #fff; font-size: 12pt; margin: 0; }
|
|
80
126
|
header { display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid #1c1917; padding-bottom: 8mm; margin-bottom: 8mm; }
|
|
81
127
|
header h1 { font-size: 18pt; margin: 0; }
|
|
82
128
|
header p { margin: 2mm 0 0; color: #57534e; font-size: 10pt; }
|
|
@@ -94,14 +140,14 @@ footer { margin-top: 10mm; color: #78716c; font-size: 9pt; }
|
|
|
94
140
|
<body>
|
|
95
141
|
<header>
|
|
96
142
|
<div>
|
|
97
|
-
<h1>${
|
|
98
|
-
<p>${
|
|
143
|
+
<h1>${escapeHtml(input.resource.label)} #${escapeHtml(String(input.record.id))}</h1>
|
|
144
|
+
<p>${escapeHtml(input.identity.name)}</p>
|
|
99
145
|
</div>
|
|
100
|
-
<div>${status ? `<span class="status">${
|
|
146
|
+
<div>${status ? `<span class="status">${escapeHtml(status)}</span>` : ''}${logo}</div>
|
|
101
147
|
</header>
|
|
102
148
|
<table class="fields"><tbody>${rows}</tbody></table>
|
|
103
149
|
${children}
|
|
104
|
-
<footer>طُبع بواسطة ${
|
|
150
|
+
<footer>طُبع بواسطة ${escapeHtml(input.printedBy)} في ${escapeHtml(printedAt.toISOString().slice(0, 16).replace('T', ' '))} UTC</footer>
|
|
105
151
|
</body>
|
|
106
152
|
</html>`;
|
|
107
153
|
}
|