@reticlehq/core 3.7.0 → 3.8.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/activation-entry.d.ts +9 -0
- package/dist/activation-entry.js +9 -0
- package/dist/artifacts/drive-script.d.ts +64 -64
- package/dist/artifacts/flow-constants.d.ts +15 -0
- package/dist/artifacts/flow-constants.js +15 -0
- package/dist/artifacts/flow-expect-flat.d.ts +8 -8
- package/dist/artifacts/flow-results.d.ts +11 -0
- package/dist/artifacts/flow-types.d.ts +164 -118
- package/dist/artifacts/flow-types.js +12 -0
- package/dist/artifacts/harness-credits.d.ts +6 -3
- package/dist/artifacts/harness-credits.js +9 -6
- package/dist/artifacts/harness-map.d.ts +6 -6
- package/dist/artifacts/impact.d.ts +77 -80
- package/dist/artifacts/impact.js +34 -17
- package/dist/artifacts/journal.d.ts +25 -6
- package/dist/artifacts/journal.js +13 -0
- package/dist/artifacts/prompt-context.d.ts +12 -0
- package/dist/artifacts/prompt-context.js +14 -3
- package/dist/graph/app-graph.d.ts +137 -0
- package/dist/graph/app-graph.js +498 -0
- package/dist/hooks/hook-events.d.ts +22 -22
- package/dist/hud-entry.js +1 -1
- package/dist/identity/checkout.d.ts +41 -0
- package/dist/identity/checkout.js +118 -0
- package/dist/identity/state-dir.d.ts +23 -0
- package/dist/identity/state-dir.js +43 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/onboarding.d.ts +22 -1
- package/dist/onboarding.js +19 -0
- package/dist/registry/dev-server-registry.d.ts +2 -2
- package/dist/schema/event-message.json +3 -1
- package/dist/schema/event-payloads.json +116 -1
- package/dist/schema/event-type.json +3 -1
- package/dist/schema/hello-message.json +21 -0
- package/dist/schema/reticle-event.json +3 -1
- package/dist/schema/reticle-message.json +24 -1
- package/dist/telemetry-bug.d.ts +6 -6
- package/dist/telemetry-entry.d.ts +1 -1
- package/dist/telemetry-entry.js +1 -1
- package/dist/telemetry-feedback.d.ts +14 -0
- package/dist/telemetry-feedback.js +19 -0
- package/dist/telemetry-refusal.d.ts +2 -2
- package/dist/telemetry-session.d.ts +23 -8
- package/dist/telemetry-session.js +15 -4
- package/dist/telemetry-signals.d.ts +227 -9
- package/dist/telemetry-signals.js +88 -1
- package/dist/telemetry.d.ts +379 -72
- package/dist/telemetry.js +71 -5
- package/dist/verdict/check-sentence.d.ts +34 -0
- package/dist/verdict/check-sentence.js +228 -0
- package/dist/verdict/consequence.d.ts +15 -0
- package/dist/verdict/consequence.js +11 -0
- package/dist/verdict/findings.d.ts +10 -0
- package/dist/verdict/findings.js +13 -0
- package/dist/verdict/instrumentation-coverage.d.ts +3 -34
- package/dist/verdict/instrumentation-coverage.js +14 -58
- package/dist/verdict/instrumentation-gap.d.ts +79 -0
- package/dist/verdict/instrumentation-gap.js +64 -0
- package/dist/verdict/predicate-tree.d.ts +2 -0
- package/dist/verdict/predicate-tree.js +16 -0
- package/dist/verdict/predicate.d.ts +2 -1
- package/dist/verdict/predicate.js +103 -12
- package/dist/verdict/property-assertion.d.ts +2 -2
- package/dist/verdict/run-report.d.ts +166 -0
- package/dist/verdict/run-report.js +53 -0
- package/dist/verdict/security.d.ts +36 -2
- package/dist/verdict/security.js +94 -14
- package/dist/verdict/verification-run.d.ts +95 -38
- package/dist/verdict/verification-run.js +33 -2
- package/dist/verdict/verify-progress.d.ts +6 -6
- package/dist/wire/constants/constants.d.ts +56 -141
- package/dist/wire/constants/constants.js +64 -144
- package/dist/wire/constants/discovery.d.ts +4 -4
- package/dist/wire/constants/discovery.js +4 -4
- package/dist/wire/constants/event-types.d.ts +35 -1
- package/dist/wire/constants/event-types.js +33 -1
- package/dist/wire/constants/hud-controls.js +0 -2
- package/dist/wire/constants/hud-use.d.ts +4 -0
- package/dist/wire/constants/hud-use.js +4 -0
- package/dist/wire/constants/mcp-wire.d.ts +16 -0
- package/dist/wire/constants/mcp-wire.js +16 -0
- package/dist/wire/constants/response-body-reason.d.ts +19 -0
- package/dist/wire/constants/response-body-reason.js +18 -0
- package/dist/wire/constants/reticle-env.d.ts +138 -0
- package/dist/wire/constants/reticle-env.js +138 -0
- package/dist/wire/constants/session-constants.d.ts +11 -0
- package/dist/wire/constants/session-constants.js +11 -0
- package/dist/wire/event-payloads.d.ts +150 -36
- package/dist/wire/event-payloads.js +83 -16
- package/dist/wire/messages.d.ts +102 -36
- package/dist/wire/messages.js +16 -0
- package/dist/wire/narrow.d.ts +6 -0
- package/dist/wire/narrow.js +26 -0
- package/dist/wire/next-step.d.ts +90 -0
- package/dist/wire/next-step.js +37 -0
- package/dist/wire/platform-link.d.ts +7 -0
- package/dist/wire/platform-link.js +12 -6
- package/dist/wire/production/activation-ticket.d.ts +64 -0
- package/dist/wire/production/activation-ticket.js +148 -0
- package/dist/wire/production/hello-mode.d.ts +35 -0
- package/dist/wire/production/hello-mode.js +32 -0
- package/dist/wire/production/production-policy.d.ts +138 -0
- package/dist/wire/production/production-policy.js +133 -0
- package/dist/wire/tool-names.d.ts +2 -0
- package/dist/wire/tool-names.js +2 -0
- package/dist/wire/types.d.ts +73 -48
- package/package.json +5 -1
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The end-of-run report: what an agent's run checked, what held, and what it left on disk.
|
|
3
|
+
*
|
|
4
|
+
* The server builds it from what it measured, and the agent shows it as the last part of its
|
|
5
|
+
* answer. The agent does not write the verdicts: an agent asked to summarise an `unknown` tends to
|
|
6
|
+
* summarise it into a pass. Every number here was counted during the run. A number that was not
|
|
7
|
+
* measured is left out, never shown as a zero.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
/** The output field that carries the report. */
|
|
11
|
+
export declare const RUN_REPORT_FIELD = "runReport";
|
|
12
|
+
/** What the agent does with the report. One sentence, said with the report every time. */
|
|
13
|
+
export declare const RUN_REPORT_INSTRUCTION = "End your answer to the user with `runReport.markdown`, unchanged. Do not reword its verdicts.";
|
|
14
|
+
/** Where the hosted dashboard is. */
|
|
15
|
+
export declare const CLOUD_DASHBOARD_URL = "https://app.reticle.sh";
|
|
16
|
+
/**
|
|
17
|
+
* The one line about Reticle Cloud. It is shown only when the project is not linked, it is
|
|
18
|
+
* labelled, and `RETICLE_NO_UPSELL` turns it off. It names no price: the price lives in
|
|
19
|
+
* reticle-cloud's billing, changes with the plan and the currency, and a number here would drift.
|
|
20
|
+
*/
|
|
21
|
+
export declare const CLOUD_VALUE_LINE: string;
|
|
22
|
+
export declare const RunReportClaimSchema: z.ZodObject<{
|
|
23
|
+
/** The claim, in the words the agent wrote. */
|
|
24
|
+
claim: z.ZodString;
|
|
25
|
+
verified: z.ZodNativeEnum<{
|
|
26
|
+
readonly YES: "yes";
|
|
27
|
+
readonly NO: "no";
|
|
28
|
+
readonly UNKNOWN: "unknown";
|
|
29
|
+
readonly NO_FAULT: "no-fault";
|
|
30
|
+
}>;
|
|
31
|
+
/** One piece of evidence: what the check saw, or the source line it drove. */
|
|
32
|
+
evidence: z.ZodOptional<z.ZodString>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
35
|
+
claim: string;
|
|
36
|
+
evidence?: string | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
39
|
+
claim: string;
|
|
40
|
+
evidence?: string | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
export type RunReportClaim = z.infer<typeof RunReportClaimSchema>;
|
|
43
|
+
export declare const RunReportSchema: z.ZodObject<{
|
|
44
|
+
/** The run's verdict: `no` when any claim failed, `yes` only when every claim held. */
|
|
45
|
+
verified: z.ZodNativeEnum<{
|
|
46
|
+
readonly YES: "yes";
|
|
47
|
+
readonly NO: "no";
|
|
48
|
+
readonly UNKNOWN: "unknown";
|
|
49
|
+
readonly NO_FAULT: "no-fault";
|
|
50
|
+
}>;
|
|
51
|
+
claims: z.ZodArray<z.ZodObject<{
|
|
52
|
+
/** The claim, in the words the agent wrote. */
|
|
53
|
+
claim: z.ZodString;
|
|
54
|
+
verified: z.ZodNativeEnum<{
|
|
55
|
+
readonly YES: "yes";
|
|
56
|
+
readonly NO: "no";
|
|
57
|
+
readonly UNKNOWN: "unknown";
|
|
58
|
+
readonly NO_FAULT: "no-fault";
|
|
59
|
+
}>;
|
|
60
|
+
/** One piece of evidence: what the check saw, or the source line it drove. */
|
|
61
|
+
evidence: z.ZodOptional<z.ZodString>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
64
|
+
claim: string;
|
|
65
|
+
evidence?: string | undefined;
|
|
66
|
+
}, {
|
|
67
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
68
|
+
claim: string;
|
|
69
|
+
evidence?: string | undefined;
|
|
70
|
+
}>, "many">;
|
|
71
|
+
/** Claims the agent expected to hold that Reticle found false. */
|
|
72
|
+
caught: z.ZodArray<z.ZodString, "many">;
|
|
73
|
+
flows: z.ZodObject<{
|
|
74
|
+
saved: z.ZodArray<z.ZodString, "many">;
|
|
75
|
+
replayed: z.ZodArray<z.ZodObject<{
|
|
76
|
+
name: z.ZodString;
|
|
77
|
+
verified: z.ZodNativeEnum<{
|
|
78
|
+
readonly YES: "yes";
|
|
79
|
+
readonly NO: "no";
|
|
80
|
+
readonly UNKNOWN: "unknown";
|
|
81
|
+
readonly NO_FAULT: "no-fault";
|
|
82
|
+
}>;
|
|
83
|
+
}, "strip", z.ZodTypeAny, {
|
|
84
|
+
name: string;
|
|
85
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
86
|
+
}, {
|
|
87
|
+
name: string;
|
|
88
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
89
|
+
}>, "many">;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
saved: string[];
|
|
92
|
+
replayed: {
|
|
93
|
+
name: string;
|
|
94
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
95
|
+
}[];
|
|
96
|
+
}, {
|
|
97
|
+
saved: string[];
|
|
98
|
+
replayed: {
|
|
99
|
+
name: string;
|
|
100
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
101
|
+
}[];
|
|
102
|
+
}>;
|
|
103
|
+
memory: z.ZodObject<{
|
|
104
|
+
/** Notes and statements written for the next run. */
|
|
105
|
+
written: z.ZodNumber;
|
|
106
|
+
/** Notes and statements from earlier runs that this run was given. */
|
|
107
|
+
read: z.ZodNumber;
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
read: number;
|
|
110
|
+
written: number;
|
|
111
|
+
}, {
|
|
112
|
+
read: number;
|
|
113
|
+
written: number;
|
|
114
|
+
}>;
|
|
115
|
+
/** From the run's first Reticle call to this report. */
|
|
116
|
+
wallMs: z.ZodNumber;
|
|
117
|
+
/** From the run's first Reticle call to its first decided claim or replay. Absent when none. */
|
|
118
|
+
firstVerdictMs: z.ZodOptional<z.ZodNumber>;
|
|
119
|
+
/** `CLOUD_VALUE_LINE`, only when the project is not linked. */
|
|
120
|
+
cloud: z.ZodOptional<z.ZodString>;
|
|
121
|
+
}, "strip", z.ZodTypeAny, {
|
|
122
|
+
flows: {
|
|
123
|
+
saved: string[];
|
|
124
|
+
replayed: {
|
|
125
|
+
name: string;
|
|
126
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
127
|
+
}[];
|
|
128
|
+
};
|
|
129
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
130
|
+
claims: {
|
|
131
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
132
|
+
claim: string;
|
|
133
|
+
evidence?: string | undefined;
|
|
134
|
+
}[];
|
|
135
|
+
caught: string[];
|
|
136
|
+
memory: {
|
|
137
|
+
read: number;
|
|
138
|
+
written: number;
|
|
139
|
+
};
|
|
140
|
+
wallMs: number;
|
|
141
|
+
firstVerdictMs?: number | undefined;
|
|
142
|
+
cloud?: string | undefined;
|
|
143
|
+
}, {
|
|
144
|
+
flows: {
|
|
145
|
+
saved: string[];
|
|
146
|
+
replayed: {
|
|
147
|
+
name: string;
|
|
148
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
149
|
+
}[];
|
|
150
|
+
};
|
|
151
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
152
|
+
claims: {
|
|
153
|
+
verified: "yes" | "no" | "unknown" | "no-fault";
|
|
154
|
+
claim: string;
|
|
155
|
+
evidence?: string | undefined;
|
|
156
|
+
}[];
|
|
157
|
+
caught: string[];
|
|
158
|
+
memory: {
|
|
159
|
+
read: number;
|
|
160
|
+
written: number;
|
|
161
|
+
};
|
|
162
|
+
wallMs: number;
|
|
163
|
+
firstVerdictMs?: number | undefined;
|
|
164
|
+
cloud?: string | undefined;
|
|
165
|
+
}>;
|
|
166
|
+
export type RunReport = z.infer<typeof RunReportSchema>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The end-of-run report: what an agent's run checked, what held, and what it left on disk.
|
|
3
|
+
*
|
|
4
|
+
* The server builds it from what it measured, and the agent shows it as the last part of its
|
|
5
|
+
* answer. The agent does not write the verdicts: an agent asked to summarise an `unknown` tends to
|
|
6
|
+
* summarise it into a pass. Every number here was counted during the run. A number that was not
|
|
7
|
+
* measured is left out, never shown as a zero.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { Verified } from './verified-constants.js';
|
|
11
|
+
/** The output field that carries the report. */
|
|
12
|
+
export const RUN_REPORT_FIELD = 'runReport';
|
|
13
|
+
/** What the agent does with the report. One sentence, said with the report every time. */
|
|
14
|
+
export const RUN_REPORT_INSTRUCTION = 'End your answer to the user with `runReport.markdown`, unchanged. Do not reword its verdicts.';
|
|
15
|
+
/** Where the hosted dashboard is. */
|
|
16
|
+
export const CLOUD_DASHBOARD_URL = 'https://app.reticle.sh';
|
|
17
|
+
/**
|
|
18
|
+
* The one line about Reticle Cloud. It is shown only when the project is not linked, it is
|
|
19
|
+
* labelled, and `RETICLE_NO_UPSELL` turns it off. It names no price: the price lives in
|
|
20
|
+
* reticle-cloud's billing, changes with the plan and the currency, and a number here would drift.
|
|
21
|
+
*/
|
|
22
|
+
export const CLOUD_VALUE_LINE = 'Reticle Cloud (not linked): keeps this history across runs and agents, adds a team view and ' +
|
|
23
|
+
`the hosted Harness. Plans and prices: ${CLOUD_DASHBOARD_URL}`;
|
|
24
|
+
export const RunReportClaimSchema = z.object({
|
|
25
|
+
/** The claim, in the words the agent wrote. */
|
|
26
|
+
claim: z.string(),
|
|
27
|
+
verified: z.nativeEnum(Verified),
|
|
28
|
+
/** One piece of evidence: what the check saw, or the source line it drove. */
|
|
29
|
+
evidence: z.string().optional(),
|
|
30
|
+
});
|
|
31
|
+
export const RunReportSchema = z.object({
|
|
32
|
+
/** The run's verdict: `no` when any claim failed, `yes` only when every claim held. */
|
|
33
|
+
verified: z.nativeEnum(Verified),
|
|
34
|
+
claims: z.array(RunReportClaimSchema),
|
|
35
|
+
/** Claims the agent expected to hold that Reticle found false. */
|
|
36
|
+
caught: z.array(z.string()),
|
|
37
|
+
flows: z.object({
|
|
38
|
+
saved: z.array(z.string()),
|
|
39
|
+
replayed: z.array(z.object({ name: z.string(), verified: z.nativeEnum(Verified) })),
|
|
40
|
+
}),
|
|
41
|
+
memory: z.object({
|
|
42
|
+
/** Notes and statements written for the next run. */
|
|
43
|
+
written: z.number().int().min(0),
|
|
44
|
+
/** Notes and statements from earlier runs that this run was given. */
|
|
45
|
+
read: z.number().int().min(0),
|
|
46
|
+
}),
|
|
47
|
+
/** From the run's first Reticle call to this report. */
|
|
48
|
+
wallMs: z.number().int().min(0),
|
|
49
|
+
/** From the run's first Reticle call to its first decided claim or replay. Absent when none. */
|
|
50
|
+
firstVerdictMs: z.number().int().min(0).optional(),
|
|
51
|
+
/** `CLOUD_VALUE_LINE`, only when the project is not linked. */
|
|
52
|
+
cloud: z.string().optional(),
|
|
53
|
+
});
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* True only for literal loopback hosts and `localhost`, never a lookalike DNS name such as
|
|
3
|
+
* 127.example.com. Names under `.localhost` are not included: this is the guard against DNS
|
|
4
|
+
* rebinding, and a browser that sends those names to DNS lets a hostile network answer them.
|
|
5
|
+
*/
|
|
2
6
|
export declare function isLoopbackHostname(hostname: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* True for a name under `.localhost`, such as the `<branch>.<app>.localhost` a dev proxy serves for
|
|
9
|
+
* each git worktree. RFC 6761 reserves these names for loopback, and browsers resolve them locally.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isLocalhostSubdomain(hostname: string): boolean;
|
|
3
12
|
/**
|
|
4
13
|
* True when the page is local: an ordinary loopback document, or a desktop webview.
|
|
5
14
|
*
|
|
@@ -28,6 +37,8 @@ export declare function isOpaqueOrigin(origin: string): boolean;
|
|
|
28
37
|
* role (a tool name, a click with no role on the descriptor) omit it and the text decides.
|
|
29
38
|
*/
|
|
30
39
|
export declare function isDangerousActionText(text: string, role?: string): boolean;
|
|
40
|
+
export declare function isInertHref(href: string): boolean;
|
|
41
|
+
export declare function isDangerousNavigation(href: string): boolean;
|
|
31
42
|
export declare const OutwardAction: {
|
|
32
43
|
readonly INVITE: "invite";
|
|
33
44
|
readonly SEND: "send";
|
|
@@ -44,7 +55,30 @@ export declare const OutwardAction: {
|
|
|
44
55
|
readonly CHANGE_STATE: "change state";
|
|
45
56
|
};
|
|
46
57
|
export type OutwardAction = (typeof OutwardAction)[keyof typeof OutwardAction];
|
|
47
|
-
/** The
|
|
58
|
+
/** The origins of the payment providers an app sends a buyer to. A host or any subdomain of it. */
|
|
59
|
+
export declare const PAYMENT_PROVIDER_HOSTS: readonly ["stripe.com", "checkout.dodopayments.com", "paddle.com", "lemonsqueezy.com", "paypal.com", "razorpay.com", "braintreegateway.com"];
|
|
60
|
+
/** Is this an absolute URL on a payment provider's origin? A relative URL stays on the app. */
|
|
61
|
+
export declare function isPaymentProviderUrl(url: string): boolean;
|
|
62
|
+
/** What a text field says about itself. Any part may be absent. */
|
|
63
|
+
export interface PaymentFieldFacts {
|
|
64
|
+
autocomplete?: string | undefined;
|
|
65
|
+
name?: string | undefined;
|
|
66
|
+
id?: string | undefined;
|
|
67
|
+
inputMode?: string | undefined;
|
|
68
|
+
/** Its accessible name or placeholder. */
|
|
69
|
+
label?: string | undefined;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Is this a field for card or bank details? `inputMode` alone decides nothing (a quantity is numeric
|
|
73
|
+
* too); it travels in the facts so a numeric field named "cvv" still reads as one.
|
|
74
|
+
*/
|
|
75
|
+
export declare function isPaymentField(facts: PaymentFieldFacts): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* The outward action a control would take, from its text and role; value pickers take none.
|
|
78
|
+
*
|
|
79
|
+
* Paying is never read from a control's words, only from where it goes: a link or form in `text`
|
|
80
|
+
* that points at a payment provider. `PAY` stays in the journey vocabulary, so "she pays" allows it.
|
|
81
|
+
*/
|
|
48
82
|
export declare function outwardActionOf(text: string, role?: string): OutwardAction | undefined;
|
|
49
83
|
/**
|
|
50
84
|
* The outward actions a journey asks for in so many words. "Invite a teammate" asks for invite;
|
package/dist/verdict/security.js
CHANGED
|
@@ -27,7 +27,13 @@
|
|
|
27
27
|
* permission flag — and a guard that fires on a control it was never written to catch trains agents
|
|
28
28
|
* to route around it, which generalises to the buttons that DO matter.
|
|
29
29
|
*/
|
|
30
|
-
const
|
|
30
|
+
const DESTROY_WORDS = 'delete|remove|destroy|erase|drop|terminate|revoke|reset|close account|cancel subscription';
|
|
31
|
+
const MONEY_WORDS = 'purchase|buy|pay|payment|place order|confirm order|send money|send funds|transfer|withdraw|refund';
|
|
32
|
+
const DANGEROUS_ACTION = new RegExp(`\\b(${DESTROY_WORDS}|${MONEY_WORDS})\\b`, 'i');
|
|
33
|
+
/** Only the words that destroy something. A link target is judged by these, not by money words. */
|
|
34
|
+
const DESTROY_ACTION = new RegExp(`\\b(${DESTROY_WORDS})\\b`, 'i');
|
|
35
|
+
/** Underscores and hyphens join words in names and paths: `delete_account`, `close-account`. */
|
|
36
|
+
const WORD_JOINERS = /[_-]+/g;
|
|
31
37
|
/**
|
|
32
38
|
* Roles that pick a VALUE, not perform an action. Selecting "Payment" as a document type is not a
|
|
33
39
|
* payment, and choosing "Refund" from a reason group is not a refund -- the act those choices feed
|
|
@@ -47,11 +53,17 @@ const DANGEROUS_ACTION = /\b(delete|remove|destroy|erase|drop|terminate|revoke|r
|
|
|
47
53
|
const VALUE_PICKER_ROLES = new Set(['option', 'radio']);
|
|
48
54
|
/** The hostnames that ARE loopback outright, with no parsing: the name, and IPv6 ::1 both ways. */
|
|
49
55
|
const LOOPBACK_HOSTNAMES = ['localhost', '::1', '0:0:0:0:0:0:0:1'];
|
|
56
|
+
/** The suffix of a name RFC 6761 reserves for loopback (`app.localhost`, `feat.app.localhost`). */
|
|
57
|
+
const LOCALHOST_SUFFIX = '.localhost';
|
|
50
58
|
/** IPv4 loopback is the whole 127.0.0.0/8 block, so the first octet is the entire test. */
|
|
51
59
|
const IPV4_LOOPBACK_FIRST_OCTET = '127';
|
|
52
60
|
const IPV4_OCTET_COUNT = 4;
|
|
53
61
|
const IPV4_OCTET_MAX = 255;
|
|
54
|
-
/**
|
|
62
|
+
/**
|
|
63
|
+
* True only for literal loopback hosts and `localhost`, never a lookalike DNS name such as
|
|
64
|
+
* 127.example.com. Names under `.localhost` are not included: this is the guard against DNS
|
|
65
|
+
* rebinding, and a browser that sends those names to DNS lets a hostile network answer them.
|
|
66
|
+
*/
|
|
55
67
|
export function isLoopbackHostname(hostname) {
|
|
56
68
|
const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, '');
|
|
57
69
|
if (LOOPBACK_HOSTNAMES.includes(normalized))
|
|
@@ -66,6 +78,16 @@ export function isLoopbackHostname(hostname) {
|
|
|
66
78
|
return value >= 0 && value <= IPV4_OCTET_MAX;
|
|
67
79
|
}));
|
|
68
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* True for a name under `.localhost`, such as the `<branch>.<app>.localhost` a dev proxy serves for
|
|
83
|
+
* each git worktree. RFC 6761 reserves these names for loopback, and browsers resolve them locally.
|
|
84
|
+
*/
|
|
85
|
+
export function isLocalhostSubdomain(hostname) {
|
|
86
|
+
const normalized = hostname.toLowerCase();
|
|
87
|
+
return (normalized.endsWith(LOCALHOST_SUFFIX) &&
|
|
88
|
+
normalized.length > LOCALHOST_SUFFIX.length &&
|
|
89
|
+
!normalized.startsWith('.'));
|
|
90
|
+
}
|
|
69
91
|
/**
|
|
70
92
|
* Page protocols that mean "this document IS a local desktop app", not a website. A packaged
|
|
71
93
|
* Electron renderer loads over `file:` (or a registered `app:` protocol); a Tauri webview loads over
|
|
@@ -73,11 +95,6 @@ export function isLoopbackHostname(hostname) {
|
|
|
73
95
|
* origin to serve them from — so a page on one is as local as `http://localhost`.
|
|
74
96
|
*/
|
|
75
97
|
const LOCAL_APP_PROTOCOLS = ['file:', 'app:', 'tauri:'];
|
|
76
|
-
/**
|
|
77
|
-
* The hostname Tauri v2 uses on Windows (and Android), where the webview needs a real http origin.
|
|
78
|
-
* `.localhost` is reserved for loopback by RFC 6761, so this can never resolve to a remote host.
|
|
79
|
-
*/
|
|
80
|
-
const TAURI_HTTP_HOSTNAME = 'tauri.localhost';
|
|
81
98
|
/**
|
|
82
99
|
* True when the page is local: an ordinary loopback document, or a desktop webview.
|
|
83
100
|
*
|
|
@@ -86,11 +103,10 @@ const TAURI_HTTP_HOSTNAME = 'tauri.localhost';
|
|
|
86
103
|
* remote is what made Reticle refuse to start inside a packaged Electron or Tauri app.
|
|
87
104
|
*/
|
|
88
105
|
export function isLocalPage(protocol, hostname) {
|
|
89
|
-
|
|
106
|
+
// `isLocalhostSubdomain` also covers `tauri.localhost`, the http origin Tauri v2 uses on Windows.
|
|
107
|
+
if (isLoopbackHostname(hostname) || isLocalhostSubdomain(hostname))
|
|
90
108
|
return true;
|
|
91
|
-
|
|
92
|
-
return true;
|
|
93
|
-
return hostname.toLowerCase() === TAURI_HTTP_HOSTNAME;
|
|
109
|
+
return LOCAL_APP_PROTOCOLS.includes(protocol.toLowerCase());
|
|
94
110
|
}
|
|
95
111
|
/**
|
|
96
112
|
* What `URL.origin` yields for a scheme that has no tuple origin — and what a browser puts in the
|
|
@@ -121,7 +137,21 @@ export function isOpaqueOrigin(origin) {
|
|
|
121
137
|
export function isDangerousActionText(text, role) {
|
|
122
138
|
if (role !== undefined && VALUE_PICKER_ROLES.has(role.trim().toLowerCase()))
|
|
123
139
|
return false;
|
|
124
|
-
return DANGEROUS_ACTION.test(text.replace(
|
|
140
|
+
return DANGEROUS_ACTION.test(text.replace(WORD_JOINERS, ' '));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Is following a link to this href destructive? A link that navigates is a GET: opening a page moves
|
|
144
|
+
* no money, so a money word in a same-app path (`/billing/payment`) is not a reason to refuse it.
|
|
145
|
+
* Typing card details has its own guard. The href is dangerous when its path destroys something
|
|
146
|
+
* (`/account/delete`), or when it goes to a payment provider.
|
|
147
|
+
*/
|
|
148
|
+
/** An href that goes nowhere (`#…`, `javascript:`): the link is a button, judged by its words. */
|
|
149
|
+
const INERT_HREF = /^\s*(#.*|javascript:.*)?$/i;
|
|
150
|
+
export function isInertHref(href) {
|
|
151
|
+
return INERT_HREF.test(href);
|
|
152
|
+
}
|
|
153
|
+
export function isDangerousNavigation(href) {
|
|
154
|
+
return isPaymentProviderUrl(href) || DESTROY_ACTION.test(href.replace(WORD_JOINERS, ' '));
|
|
125
155
|
}
|
|
126
156
|
// ── What the Harness may press ────────────────────────────────────────────────────────────────
|
|
127
157
|
/*
|
|
@@ -174,12 +204,62 @@ const OUTWARD_WORDS = [
|
|
|
174
204
|
/\b(?:reassign|reassigns|reopen|reopens|re-open|archive|archives|unarchive|approve|approves|reject|rejects|mark as (?:fixed|resolved|done|closed))\b/i,
|
|
175
205
|
],
|
|
176
206
|
];
|
|
177
|
-
|
|
207
|
+
/*
|
|
208
|
+
* The payment boundary. "Start free trial" was refused as "would need to pay" on 3 of 4 explores:
|
|
209
|
+
* the words on a button (trial, upgrade, subscribe, checkout) say nothing about whether money moves
|
|
210
|
+
* on an app under test. Money moves when somebody types card or bank details, or leaves for a payment
|
|
211
|
+
* provider, so those are the two things a Harness drive that was not asked to pay refuses.
|
|
212
|
+
*/
|
|
213
|
+
/** The origins of the payment providers an app sends a buyer to. A host or any subdomain of it. */
|
|
214
|
+
export const PAYMENT_PROVIDER_HOSTS = [
|
|
215
|
+
'stripe.com',
|
|
216
|
+
'checkout.dodopayments.com',
|
|
217
|
+
'paddle.com',
|
|
218
|
+
'lemonsqueezy.com',
|
|
219
|
+
'paypal.com',
|
|
220
|
+
'razorpay.com',
|
|
221
|
+
'braintreegateway.com',
|
|
222
|
+
];
|
|
223
|
+
/** Is this an absolute URL on a payment provider's origin? A relative URL stays on the app. */
|
|
224
|
+
export function isPaymentProviderUrl(url) {
|
|
225
|
+
let host;
|
|
226
|
+
try {
|
|
227
|
+
host = new URL(url).hostname.toLowerCase();
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
return false;
|
|
231
|
+
}
|
|
232
|
+
return PAYMENT_PROVIDER_HOSTS.some((h) => host === h || host.endsWith(`.${h}`));
|
|
233
|
+
}
|
|
234
|
+
/** The autocomplete tokens of a card: number, security code, expiry. */
|
|
235
|
+
const CARD_AUTOCOMPLETE = /\bcc-(?:number|csc|exp(?:-month|-year)?)\b/i;
|
|
236
|
+
/** A card or bank field by its name, id or label. */
|
|
237
|
+
const PAYMENT_FIELD_WORDS = /card ?(?:number|no\b)|\bcc ?num|\b(?:cvc|cvv|csc|cvc2|cvv2)\b|security code|card ?code|\bexpir(?:y|ation|es)\b|\bexp ?date\b|\bmm ?\/ ?yy\b|\biban\b|account ?number|routing ?number|sort ?code/i;
|
|
238
|
+
/**
|
|
239
|
+
* Is this a field for card or bank details? `inputMode` alone decides nothing (a quantity is numeric
|
|
240
|
+
* too); it travels in the facts so a numeric field named "cvv" still reads as one.
|
|
241
|
+
*/
|
|
242
|
+
export function isPaymentField(facts) {
|
|
243
|
+
if (CARD_AUTOCOMPLETE.test(facts.autocomplete ?? ''))
|
|
244
|
+
return true;
|
|
245
|
+
const words = [facts.name, facts.id, facts.label]
|
|
246
|
+
.map((w) => (w ?? '').replace(/([a-z])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' '))
|
|
247
|
+
.join(' ');
|
|
248
|
+
return PAYMENT_FIELD_WORDS.test(words);
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* The outward action a control would take, from its text and role; value pickers take none.
|
|
252
|
+
*
|
|
253
|
+
* Paying is never read from a control's words, only from where it goes: a link or form in `text`
|
|
254
|
+
* that points at a payment provider. `PAY` stays in the journey vocabulary, so "she pays" allows it.
|
|
255
|
+
*/
|
|
178
256
|
export function outwardActionOf(text, role) {
|
|
179
257
|
if (role !== undefined && VALUE_PICKER_ROLES.has(role.trim().toLowerCase()))
|
|
180
258
|
return undefined;
|
|
259
|
+
if (text.split(/\s+/).some(isPaymentProviderUrl))
|
|
260
|
+
return OutwardAction.PAY;
|
|
181
261
|
const words = text.replace(/[_-]+/g, ' ');
|
|
182
|
-
return OUTWARD_WORDS.find(([, pattern]) => pattern.test(words))?.[0];
|
|
262
|
+
return OUTWARD_WORDS.find(([action, pattern]) => action !== OutwardAction.PAY && pattern.test(words))?.[0];
|
|
183
263
|
}
|
|
184
264
|
/** A word that turns the action after it into one the journey forbids: "does not send". */
|
|
185
265
|
const NEGATION = /\b(?:not|no|never|without|nor|avoid|avoids|don't|doesn't|won't|didn't)\b/i;
|