@nuanu-ai/agentbrowse 0.2.7 → 0.2.8
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 +36 -8
- package/dist/agentpay-stagehand-llm.d.ts.map +1 -1
- package/dist/agentpay-stagehand-llm.js +5 -1
- package/dist/commands/act.d.ts +6 -2
- package/dist/commands/act.d.ts.map +1 -1
- package/dist/commands/act.js +840 -55
- package/dist/commands/act.test-harness.d.ts +19 -0
- package/dist/commands/act.test-harness.d.ts.map +1 -0
- package/dist/commands/act.test-harness.js +245 -0
- package/dist/commands/action-acceptance.d.ts +90 -0
- package/dist/commands/action-acceptance.d.ts.map +1 -0
- package/dist/commands/action-acceptance.js +1411 -0
- package/dist/commands/action-artifacts.d.ts +33 -0
- package/dist/commands/action-artifacts.d.ts.map +1 -0
- package/dist/commands/action-artifacts.js +104 -0
- package/dist/commands/action-execution-guards.d.ts +5 -0
- package/dist/commands/action-execution-guards.d.ts.map +1 -0
- package/dist/commands/action-execution-guards.js +3 -0
- package/dist/commands/action-executor-helpers.d.ts +21 -0
- package/dist/commands/action-executor-helpers.d.ts.map +1 -0
- package/dist/commands/action-executor-helpers.js +242 -0
- package/dist/commands/action-executor.d.ts +12 -0
- package/dist/commands/action-executor.d.ts.map +1 -0
- package/dist/commands/action-executor.js +45 -0
- package/dist/commands/action-fallbacks.d.ts +6 -0
- package/dist/commands/action-fallbacks.d.ts.map +1 -0
- package/dist/commands/action-fallbacks.js +43 -0
- package/dist/commands/action-value-projection.d.ts +32 -0
- package/dist/commands/action-value-projection.d.ts.map +1 -0
- package/dist/commands/action-value-projection.js +151 -0
- package/dist/commands/browse-actions.d.ts +4 -0
- package/dist/commands/browse-actions.d.ts.map +1 -0
- package/dist/commands/browse-actions.js +4 -0
- package/dist/commands/captcha-solve.d.ts.map +1 -1
- package/dist/commands/captcha-solve.js +13 -3
- package/dist/commands/click-action-executor.d.ts +10 -0
- package/dist/commands/click-action-executor.d.ts.map +1 -0
- package/dist/commands/click-action-executor.js +68 -0
- package/dist/commands/create-intent.d.ts +6 -0
- package/dist/commands/create-intent.d.ts.map +1 -0
- package/dist/commands/create-intent.js +75 -0
- package/dist/commands/datepicker-action-executor.d.ts +12 -0
- package/dist/commands/datepicker-action-executor.d.ts.map +1 -0
- package/dist/commands/datepicker-action-executor.js +218 -0
- package/dist/commands/descriptor-validation.d.ts +27 -0
- package/dist/commands/descriptor-validation.d.ts.map +1 -0
- package/dist/commands/descriptor-validation.js +333 -0
- package/dist/commands/extract-scope-resolution.d.ts +20 -0
- package/dist/commands/extract-scope-resolution.d.ts.map +1 -0
- package/dist/commands/extract-scope-resolution.js +100 -0
- package/dist/commands/extract-stagehand-executor.d.ts +17 -0
- package/dist/commands/extract-stagehand-executor.d.ts.map +1 -0
- package/dist/commands/extract-stagehand-executor.js +18 -0
- package/dist/commands/extract.d.ts +3 -2
- package/dist/commands/extract.d.ts.map +1 -1
- package/dist/commands/extract.js +256 -39
- package/dist/commands/fill-secret.d.ts +7 -0
- package/dist/commands/fill-secret.d.ts.map +1 -0
- package/dist/commands/fill-secret.js +371 -0
- package/dist/commands/get-secrets-catalog.d.ts +6 -0
- package/dist/commands/get-secrets-catalog.d.ts.map +1 -0
- package/dist/commands/get-secrets-catalog.js +23 -0
- package/dist/commands/launch.d.ts.map +1 -1
- package/dist/commands/launch.js +41 -7
- package/dist/commands/navigate.d.ts +2 -1
- package/dist/commands/navigate.d.ts.map +1 -1
- package/dist/commands/navigate.js +49 -12
- package/dist/commands/observe-inventory.d.ts +109 -0
- package/dist/commands/observe-inventory.d.ts.map +1 -0
- package/dist/commands/observe-inventory.js +2837 -0
- package/dist/commands/observe-persistence.d.ts +14 -0
- package/dist/commands/observe-persistence.d.ts.map +1 -0
- package/dist/commands/observe-persistence.js +170 -0
- package/dist/commands/observe-projection.d.ts +84 -0
- package/dist/commands/observe-projection.d.ts.map +1 -0
- package/dist/commands/observe-projection.js +140 -0
- package/dist/commands/observe-protected.d.ts +5 -0
- package/dist/commands/observe-protected.d.ts.map +1 -0
- package/dist/commands/observe-protected.js +18 -0
- package/dist/commands/observe-semantics.d.ts +10 -0
- package/dist/commands/observe-semantics.d.ts.map +1 -0
- package/dist/commands/observe-semantics.js +338 -0
- package/dist/commands/observe-stagehand.d.ts +48 -0
- package/dist/commands/observe-stagehand.d.ts.map +1 -0
- package/dist/commands/observe-stagehand.js +105 -0
- package/dist/commands/observe-surfaces.d.ts +9 -0
- package/dist/commands/observe-surfaces.d.ts.map +1 -0
- package/dist/commands/observe-surfaces.js +195 -0
- package/dist/commands/observe.d.ts +47 -1
- package/dist/commands/observe.d.ts.map +1 -1
- package/dist/commands/observe.js +173 -20
- package/dist/commands/observe.test-harness.d.ts +67 -0
- package/dist/commands/observe.test-harness.d.ts.map +1 -0
- package/dist/commands/observe.test-harness.js +107 -0
- package/dist/commands/poll-intent.d.ts +6 -0
- package/dist/commands/poll-intent.d.ts.map +1 -0
- package/dist/commands/poll-intent.js +57 -0
- package/dist/commands/screenshot.d.ts +2 -1
- package/dist/commands/screenshot.d.ts.map +1 -1
- package/dist/commands/screenshot.js +44 -12
- package/dist/commands/select-action-executor.d.ts +10 -0
- package/dist/commands/select-action-executor.d.ts.map +1 -0
- package/dist/commands/select-action-executor.js +91 -0
- package/dist/commands/semantic-observe.d.ts +24 -0
- package/dist/commands/semantic-observe.d.ts.map +1 -0
- package/dist/commands/semantic-observe.js +344 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +75 -2
- package/dist/commands/structured-grid-action-executor.d.ts +3 -0
- package/dist/commands/structured-grid-action-executor.d.ts.map +1 -0
- package/dist/commands/structured-grid-action-executor.js +4 -0
- package/dist/commands/target-resolution.d.ts +4 -0
- package/dist/commands/target-resolution.d.ts.map +1 -0
- package/dist/commands/target-resolution.js +33 -0
- package/dist/commands/text-input-action-executor.d.ts +5 -0
- package/dist/commands/text-input-action-executor.d.ts.map +1 -0
- package/dist/commands/text-input-action-executor.js +116 -0
- package/dist/commands/user-actionable.d.ts +4 -0
- package/dist/commands/user-actionable.d.ts.map +1 -0
- package/dist/commands/user-actionable.js +95 -0
- package/dist/control-semantics.d.ts +29 -0
- package/dist/control-semantics.d.ts.map +1 -0
- package/dist/control-semantics.js +299 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -32
- package/dist/output.d.ts +14 -2
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +17 -29
- package/dist/playwright-runtime.d.ts +35 -0
- package/dist/playwright-runtime.d.ts.map +1 -0
- package/dist/playwright-runtime.js +224 -0
- package/dist/runtime-resolution.d.ts +9 -0
- package/dist/runtime-resolution.d.ts.map +1 -0
- package/dist/runtime-resolution.js +19 -0
- package/dist/runtime-state.d.ts +217 -0
- package/dist/runtime-state.d.ts.map +1 -0
- package/dist/runtime-state.js +629 -0
- package/dist/secrets/backend.d.ts +32 -0
- package/dist/secrets/backend.d.ts.map +1 -0
- package/dist/secrets/backend.js +169 -0
- package/dist/secrets/catalog-applicability.d.ts +5 -0
- package/dist/secrets/catalog-applicability.d.ts.map +1 -0
- package/dist/secrets/catalog-applicability.js +59 -0
- package/dist/secrets/catalog-sync.d.ts +14 -0
- package/dist/secrets/catalog-sync.d.ts.map +1 -0
- package/dist/secrets/catalog-sync.js +35 -0
- package/dist/secrets/field-policy.d.ts +3 -0
- package/dist/secrets/field-policy.d.ts.map +1 -0
- package/dist/secrets/field-policy.js +3 -0
- package/dist/secrets/fill-ordering.d.ts +11 -0
- package/dist/secrets/fill-ordering.d.ts.map +1 -0
- package/dist/secrets/fill-ordering.js +44 -0
- package/dist/secrets/form-matcher.d.ts +60 -0
- package/dist/secrets/form-matcher.d.ts.map +1 -0
- package/dist/secrets/form-matcher.js +596 -0
- package/dist/secrets/intent-output.d.ts +11 -0
- package/dist/secrets/intent-output.d.ts.map +1 -0
- package/dist/secrets/intent-output.js +64 -0
- package/dist/secrets/mock-agentpay-backend.d.ts +13 -0
- package/dist/secrets/mock-agentpay-backend.d.ts.map +1 -0
- package/dist/secrets/mock-agentpay-backend.js +87 -0
- package/dist/secrets/mock-agentpay-cabinet.d.ts +43 -0
- package/dist/secrets/mock-agentpay-cabinet.d.ts.map +1 -0
- package/dist/secrets/mock-agentpay-cabinet.js +195 -0
- package/dist/secrets/protected-artifact-guard.d.ts +25 -0
- package/dist/secrets/protected-artifact-guard.d.ts.map +1 -0
- package/dist/secrets/protected-artifact-guard.js +26 -0
- package/dist/secrets/protected-bindings.d.ts +10 -0
- package/dist/secrets/protected-bindings.d.ts.map +1 -0
- package/dist/secrets/protected-bindings.js +17 -0
- package/dist/secrets/protected-field-values.d.ts +13 -0
- package/dist/secrets/protected-field-values.d.ts.map +1 -0
- package/dist/secrets/protected-field-values.js +100 -0
- package/dist/secrets/protected-fill.d.ts +47 -0
- package/dist/secrets/protected-fill.d.ts.map +1 -0
- package/dist/secrets/protected-fill.js +512 -0
- package/dist/secrets/types.d.ts +84 -0
- package/dist/secrets/types.d.ts.map +1 -0
- package/dist/secrets/types.js +27 -0
- package/dist/session.d.ts +22 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +74 -2
- package/dist/solver/browser-launcher.d.ts.map +1 -1
- package/dist/solver/browser-launcher.js +6 -3
- package/dist/stagehand-runtime.d.ts +4 -0
- package/dist/stagehand-runtime.d.ts.map +1 -0
- package/dist/stagehand-runtime.js +10 -0
- package/dist/stagehand.d.ts +0 -5
- package/dist/stagehand.d.ts.map +1 -1
- package/dist/stagehand.js +0 -6
- package/package.json +5 -2
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { tryResolveAgentpayGatewayConfig } from '../agentpay-gateway.js';
|
|
2
|
+
import { resolveHostFromInput, resolveMockStoredSecretValues, syncMockSecretCatalog, } from './mock-agentpay-backend.js';
|
|
3
|
+
import { createOrReuseMockSecretIntent, getMockSecretIntent, markMockSecretIntentCompleted, } from './mock-agentpay-cabinet.js';
|
|
4
|
+
const ENABLE_MOCK_SECRETS_ENV = 'AGENTBROWSE_ENABLE_MOCK_SECRETS';
|
|
5
|
+
const APPROVAL_CHANNEL = 'agentpay-cabinet';
|
|
6
|
+
function envFlagEnabled(value) {
|
|
7
|
+
if (!value) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const normalized = value.trim().toLowerCase();
|
|
11
|
+
return normalized === '1' || normalized === 'true' || normalized === 'yes' || normalized === 'on';
|
|
12
|
+
}
|
|
13
|
+
export class SecretBackendDisabledError extends Error {
|
|
14
|
+
constructor(message = 'Mock secret backend is disabled for this build/runtime.') {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = 'SecretBackendDisabledError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function toStoredSecretFieldKeys(fields) {
|
|
20
|
+
return fields
|
|
21
|
+
.map((field) => field.key)
|
|
22
|
+
.filter((fieldKey) => [
|
|
23
|
+
'username',
|
|
24
|
+
'password',
|
|
25
|
+
'full_name',
|
|
26
|
+
'document_number',
|
|
27
|
+
'date_of_birth',
|
|
28
|
+
'nationality',
|
|
29
|
+
'issue_date',
|
|
30
|
+
'expiry_date',
|
|
31
|
+
'issuing_country',
|
|
32
|
+
'cardholder',
|
|
33
|
+
'pan',
|
|
34
|
+
'exp_month',
|
|
35
|
+
'exp_year',
|
|
36
|
+
'cvv',
|
|
37
|
+
].includes(fieldKey));
|
|
38
|
+
}
|
|
39
|
+
function mapApiCatalogEntryToStoredSecret(entry, host) {
|
|
40
|
+
return {
|
|
41
|
+
storedSecretRef: entry.id,
|
|
42
|
+
kind: entry.kind,
|
|
43
|
+
scope: entry.applicability.mode === 'global' ? 'global' : 'site',
|
|
44
|
+
displayName: entry.display_name,
|
|
45
|
+
fieldKeys: toStoredSecretFieldKeys(entry.fields),
|
|
46
|
+
intentRequired: true,
|
|
47
|
+
applicability: entry.applicability.mode === 'global'
|
|
48
|
+
? { target: 'global' }
|
|
49
|
+
: { target: 'host', value: host },
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function mapApiIntentResponse(intent) {
|
|
53
|
+
const metadata = intent.metadata && typeof intent.metadata === 'object'
|
|
54
|
+
? intent.metadata
|
|
55
|
+
: {};
|
|
56
|
+
return {
|
|
57
|
+
intentId: intent.id,
|
|
58
|
+
fillRef: typeof metadata.fill_ref === 'string' ? metadata.fill_ref : '',
|
|
59
|
+
storedSecretRef: typeof metadata.secret_id === 'string' ? metadata.secret_id : '',
|
|
60
|
+
status: intent.status,
|
|
61
|
+
approvalChannel: APPROVAL_CHANNEL,
|
|
62
|
+
host: typeof metadata.host === 'string' ? metadata.host : undefined,
|
|
63
|
+
scopeRef: typeof metadata.scope_ref === 'string' ? metadata.scope_ref : undefined,
|
|
64
|
+
createdAt: intent.created_at,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async function requestAgentpay(method, path, body) {
|
|
68
|
+
const gateway = tryResolveAgentpayGatewayConfig();
|
|
69
|
+
if (!gateway) {
|
|
70
|
+
throw new SecretBackendDisabledError('Secret backend is not configured. AgentPay API key is required.');
|
|
71
|
+
}
|
|
72
|
+
const response = await fetch(`${gateway.apiUrl}${path}`, {
|
|
73
|
+
method,
|
|
74
|
+
headers: {
|
|
75
|
+
Authorization: `Bearer ${gateway.apiKey}`,
|
|
76
|
+
'Content-Type': 'application/json',
|
|
77
|
+
},
|
|
78
|
+
...(body ? { body: JSON.stringify(body) } : {}),
|
|
79
|
+
});
|
|
80
|
+
if (!response.ok) {
|
|
81
|
+
const text = await response.text().catch(() => '');
|
|
82
|
+
throw new Error(`agentpay_secret_backend_http_${response.status}${text ? `:${text}` : ''}`);
|
|
83
|
+
}
|
|
84
|
+
return (await response.json());
|
|
85
|
+
}
|
|
86
|
+
const mockSecretBackend = {
|
|
87
|
+
kind: 'mock',
|
|
88
|
+
resolveCatalogHost: resolveHostFromInput,
|
|
89
|
+
async syncSecretCatalog(urlOrHost) {
|
|
90
|
+
return syncMockSecretCatalog(urlOrHost);
|
|
91
|
+
},
|
|
92
|
+
async createOrReuseSecretIntent(input) {
|
|
93
|
+
return createOrReuseMockSecretIntent(input);
|
|
94
|
+
},
|
|
95
|
+
async getSecretIntent(intentId) {
|
|
96
|
+
const snapshot = getMockSecretIntent(intentId);
|
|
97
|
+
if (!snapshot) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
if (snapshot.status !== 'approved') {
|
|
101
|
+
return { snapshot };
|
|
102
|
+
}
|
|
103
|
+
const deliveredValues = resolveMockStoredSecretValues(snapshot.storedSecretRef) ?? undefined;
|
|
104
|
+
const completed = markMockSecretIntentCompleted(intentId);
|
|
105
|
+
return {
|
|
106
|
+
snapshot: completed,
|
|
107
|
+
deliveredValues,
|
|
108
|
+
};
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
const agentpayApiSecretBackend = {
|
|
112
|
+
kind: 'agentpay_api',
|
|
113
|
+
resolveCatalogHost: resolveHostFromInput,
|
|
114
|
+
async syncSecretCatalog(urlOrHost) {
|
|
115
|
+
const host = resolveHostFromInput(urlOrHost);
|
|
116
|
+
const entries = await requestAgentpay('GET', `/secrets/catalog?host=${encodeURIComponent(host)}`);
|
|
117
|
+
return {
|
|
118
|
+
source: 'agentpay_api',
|
|
119
|
+
host,
|
|
120
|
+
syncedAt: new Date().toISOString(),
|
|
121
|
+
storedSecrets: entries.map((entry) => mapApiCatalogEntryToStoredSecret(entry, host)),
|
|
122
|
+
};
|
|
123
|
+
},
|
|
124
|
+
async createOrReuseSecretIntent(input) {
|
|
125
|
+
const response = await requestAgentpay('POST', '/intents', {
|
|
126
|
+
intent_type: 'stored_secret',
|
|
127
|
+
description: `Protected fill for ${input.purpose}`,
|
|
128
|
+
metadata: {
|
|
129
|
+
secret_id: input.storedSecretRef,
|
|
130
|
+
secret_kind: input.secretKind,
|
|
131
|
+
purpose: input.purpose,
|
|
132
|
+
host: input.host,
|
|
133
|
+
fill_ref: input.fillRef,
|
|
134
|
+
requested_field_keys: input.requestedFieldKeys,
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
intent: mapApiIntentResponse(response),
|
|
139
|
+
reused: false,
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
async getSecretIntent(intentId) {
|
|
143
|
+
try {
|
|
144
|
+
const response = await requestAgentpay('GET', `/intents/${intentId}`);
|
|
145
|
+
return {
|
|
146
|
+
snapshot: mapApiIntentResponse(response),
|
|
147
|
+
deliveredValues: response.secret?.values,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
if (error instanceof Error && error.message.startsWith('agentpay_secret_backend_http_404')) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
export function isMockSecretBackendEnabled() {
|
|
159
|
+
return envFlagEnabled(process.env[ENABLE_MOCK_SECRETS_ENV]);
|
|
160
|
+
}
|
|
161
|
+
export function getSecretBackend() {
|
|
162
|
+
if (isMockSecretBackendEnabled()) {
|
|
163
|
+
return mockSecretBackend;
|
|
164
|
+
}
|
|
165
|
+
if (tryResolveAgentpayGatewayConfig()) {
|
|
166
|
+
return agentpayApiSecretBackend;
|
|
167
|
+
}
|
|
168
|
+
throw new SecretBackendDisabledError(`Secret backend is not configured. Set AGENTPAY_API_KEY for real AgentPay API access or ${ENABLE_MOCK_SECRETS_ENV}=1 only for local/dev testing.`);
|
|
169
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SecretCatalogSnapshot, StoredSecretMetadata } from './types.js';
|
|
2
|
+
export declare function normalizeCatalogLookupValue(value: string): string;
|
|
3
|
+
export declare function storedSecretAppliesToHost(metadata: StoredSecretMetadata, host: string): boolean;
|
|
4
|
+
export declare function resolveCachedSecretCatalogForHost(host: string, snapshots: ReadonlyArray<SecretCatalogSnapshot>): SecretCatalogSnapshot | null;
|
|
5
|
+
//# sourceMappingURL=catalog-applicability.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-applicability.d.ts","sourceRoot":"","sources":["../../src/secrets/catalog-applicability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAE9E,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,oBAAoB,EAC9B,IAAI,EAAE,MAAM,GACX,OAAO,CAoBT;AAaD,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,aAAa,CAAC,qBAAqB,CAAC,GAC9C,qBAAqB,GAAG,IAAI,CAoC9B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export function normalizeCatalogLookupValue(value) {
|
|
2
|
+
return value.trim().toLowerCase();
|
|
3
|
+
}
|
|
4
|
+
export function storedSecretAppliesToHost(metadata, host) {
|
|
5
|
+
const normalizedHost = normalizeCatalogLookupValue(host);
|
|
6
|
+
const applicabilityValue = metadata.applicability.value
|
|
7
|
+
? normalizeCatalogLookupValue(metadata.applicability.value)
|
|
8
|
+
: undefined;
|
|
9
|
+
switch (metadata.applicability.target) {
|
|
10
|
+
case 'global':
|
|
11
|
+
return true;
|
|
12
|
+
case 'host':
|
|
13
|
+
return applicabilityValue === normalizedHost;
|
|
14
|
+
case 'site':
|
|
15
|
+
return (applicabilityValue === normalizedHost ||
|
|
16
|
+
(typeof applicabilityValue === 'string' &&
|
|
17
|
+
normalizedHost.endsWith(`.${applicabilityValue}`)));
|
|
18
|
+
default:
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function cloneStoredSecretMetadata(metadata) {
|
|
23
|
+
return {
|
|
24
|
+
...metadata,
|
|
25
|
+
fieldKeys: [...metadata.fieldKeys],
|
|
26
|
+
fieldPolicies: metadata.fieldPolicies ? { ...metadata.fieldPolicies } : undefined,
|
|
27
|
+
preferredForMerchantKeys: metadata.preferredForMerchantKeys
|
|
28
|
+
? [...metadata.preferredForMerchantKeys]
|
|
29
|
+
: undefined,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function resolveCachedSecretCatalogForHost(host, snapshots) {
|
|
33
|
+
const normalizedHost = normalizeCatalogLookupValue(host);
|
|
34
|
+
const exact = snapshots.find((snapshot) => normalizeCatalogLookupValue(snapshot.host) === normalizedHost);
|
|
35
|
+
if (exact) {
|
|
36
|
+
return exact;
|
|
37
|
+
}
|
|
38
|
+
const orderedSnapshots = [...snapshots].sort((left, right) => right.syncedAt.localeCompare(left.syncedAt));
|
|
39
|
+
const storedSecrets = new Map();
|
|
40
|
+
for (const snapshot of orderedSnapshots) {
|
|
41
|
+
for (const secret of snapshot.storedSecrets) {
|
|
42
|
+
if (!storedSecretAppliesToHost(secret, normalizedHost)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (!storedSecrets.has(secret.storedSecretRef)) {
|
|
46
|
+
storedSecrets.set(secret.storedSecretRef, cloneStoredSecretMetadata(secret));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (storedSecrets.size === 0) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
source: orderedSnapshots[0]?.source ?? 'mock',
|
|
55
|
+
host: normalizedHost,
|
|
56
|
+
syncedAt: orderedSnapshots[0]?.syncedAt ?? new Date().toISOString(),
|
|
57
|
+
storedSecrets: [...storedSecrets.values()],
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BrowseSession } from '../session.js';
|
|
2
|
+
import type { SecretCatalogSnapshot } from './types.js';
|
|
3
|
+
export interface SecretCatalogSummary {
|
|
4
|
+
source: SecretCatalogSnapshot['source'];
|
|
5
|
+
host: string;
|
|
6
|
+
syncedAt: string;
|
|
7
|
+
storedSecretCount: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function getCurrentSessionPageUrl(session: BrowseSession): string | null;
|
|
10
|
+
export declare function summarizeSecretCatalog(snapshot: SecretCatalogSnapshot): SecretCatalogSummary;
|
|
11
|
+
export declare function syncSecretCatalogForUrl(session: BrowseSession, urlOrHost: string): Promise<SecretCatalogSnapshot>;
|
|
12
|
+
export declare function resolveCatalogHost(urlOrHost: string): string;
|
|
13
|
+
export declare function tryResolveCatalogHost(urlOrHost: string | null | undefined): string | null;
|
|
14
|
+
//# sourceMappingURL=catalog-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog-sync.d.ts","sourceRoot":"","sources":["../../src/secrets/catalog-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAG9E;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,oBAAoB,CAO5F;AAED,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,qBAAqB,CAAC,CAGhC;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAazF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { saveSecretCatalog } from '../runtime-state.js';
|
|
2
|
+
import { getSecretBackend, SecretBackendDisabledError } from './backend.js';
|
|
3
|
+
export function getCurrentSessionPageUrl(session) {
|
|
4
|
+
const pageRef = session.runtime?.currentPageRef ?? 'p0';
|
|
5
|
+
return session.runtime?.pages?.[pageRef]?.url ?? null;
|
|
6
|
+
}
|
|
7
|
+
export function summarizeSecretCatalog(snapshot) {
|
|
8
|
+
return {
|
|
9
|
+
source: snapshot.source,
|
|
10
|
+
host: snapshot.host,
|
|
11
|
+
syncedAt: snapshot.syncedAt,
|
|
12
|
+
storedSecretCount: snapshot.storedSecrets.length,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export async function syncSecretCatalogForUrl(session, urlOrHost) {
|
|
16
|
+
const snapshot = await getSecretBackend().syncSecretCatalog(urlOrHost);
|
|
17
|
+
return saveSecretCatalog(session, snapshot);
|
|
18
|
+
}
|
|
19
|
+
export function resolveCatalogHost(urlOrHost) {
|
|
20
|
+
return getSecretBackend().resolveCatalogHost(urlOrHost);
|
|
21
|
+
}
|
|
22
|
+
export function tryResolveCatalogHost(urlOrHost) {
|
|
23
|
+
if (!urlOrHost) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
return resolveCatalogHost(urlOrHost);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
if (error instanceof SecretBackendDisabledError) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ProtectedFieldPolicy, StoredSecretFieldKey, StoredSecretFieldPolicies } from './types.js';
|
|
2
|
+
export declare function resolveProtectedFieldPolicy(fieldPolicies: StoredSecretFieldPolicies | undefined, fieldKey: StoredSecretFieldKey): ProtectedFieldPolicy;
|
|
3
|
+
//# sourceMappingURL=field-policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-policy.d.ts","sourceRoot":"","sources":["../../src/secrets/field-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,YAAY,CAAC;AAEpB,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,yBAAyB,GAAG,SAAS,EACpD,QAAQ,EAAE,oBAAoB,GAC7B,oBAAoB,CAEtB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FillableFormRecommendedTiming, StoredSecretFieldKey } from './types.js';
|
|
2
|
+
declare function fieldPriority(purpose: string, fieldKey: StoredSecretFieldKey): number;
|
|
3
|
+
export declare function recommendedTimingForProtectedForm(_purpose: string): FillableFormRecommendedTiming;
|
|
4
|
+
export declare function sortProtectedBindingsForExecution<T extends {
|
|
5
|
+
fieldKeys: StoredSecretFieldKey[];
|
|
6
|
+
}>(purpose: string, bindings: ReadonlyArray<T>): T[];
|
|
7
|
+
export declare const __testFillOrdering: {
|
|
8
|
+
fieldPriority: typeof fieldPriority;
|
|
9
|
+
};
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=fill-ordering.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill-ordering.d.ts","sourceRoot":"","sources":["../../src/secrets/fill-ordering.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,oBAAoB,EACrB,MAAM,YAAY,CAAC;AA2BpB,iBAAS,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,oBAAoB,GAAG,MAAM,CAE9E;AAED,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,MAAM,GACf,6BAA6B,CAE/B;AAED,wBAAgB,iCAAiC,CAAC,CAAC,SAAS;IAAE,SAAS,EAAE,oBAAoB,EAAE,CAAA;CAAE,EAC/F,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GACzB,CAAC,EAAE,CAYL;AAED,eAAO,MAAM,kBAAkB;;CAE9B,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const DEFAULT_PRIORITY = 100;
|
|
2
|
+
const FIELD_PRIORITY_BY_PURPOSE = {
|
|
3
|
+
login: {
|
|
4
|
+
username: 10,
|
|
5
|
+
password: 20,
|
|
6
|
+
},
|
|
7
|
+
identity: {
|
|
8
|
+
full_name: 10,
|
|
9
|
+
document_number: 20,
|
|
10
|
+
date_of_birth: 30,
|
|
11
|
+
nationality: 40,
|
|
12
|
+
issue_date: 50,
|
|
13
|
+
expiry_date: 60,
|
|
14
|
+
issuing_country: 70,
|
|
15
|
+
},
|
|
16
|
+
payment_card: {
|
|
17
|
+
cardholder: 10,
|
|
18
|
+
exp_month: 20,
|
|
19
|
+
exp_year: 20,
|
|
20
|
+
pan: 30,
|
|
21
|
+
cvv: 40,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
function fieldPriority(purpose, fieldKey) {
|
|
25
|
+
return FIELD_PRIORITY_BY_PURPOSE[purpose]?.[fieldKey] ?? DEFAULT_PRIORITY;
|
|
26
|
+
}
|
|
27
|
+
export function recommendedTimingForProtectedForm(_purpose) {
|
|
28
|
+
return 'late';
|
|
29
|
+
}
|
|
30
|
+
export function sortProtectedBindingsForExecution(purpose, bindings) {
|
|
31
|
+
return bindings
|
|
32
|
+
.map((binding, index) => ({
|
|
33
|
+
binding,
|
|
34
|
+
index,
|
|
35
|
+
priority: binding.fieldKeys.length === 0
|
|
36
|
+
? DEFAULT_PRIORITY
|
|
37
|
+
: Math.min(...binding.fieldKeys.map((fieldKey) => fieldPriority(purpose, fieldKey))),
|
|
38
|
+
}))
|
|
39
|
+
.sort((left, right) => left.priority - right.priority || left.index - right.index)
|
|
40
|
+
.map((entry) => entry.binding);
|
|
41
|
+
}
|
|
42
|
+
export const __testFillOrdering = {
|
|
43
|
+
fieldPriority,
|
|
44
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { AgentpayGatewayConfig } from '../agentpay-gateway.js';
|
|
3
|
+
import type { TargetDescriptor } from '../runtime-state.js';
|
|
4
|
+
import type { FillableFormFieldBinding, PersistedFillableForm, SecretCatalogSnapshot, StoredSecretKind } from './types.js';
|
|
5
|
+
type FillableFormDraft = Omit<PersistedFillableForm, 'fillRef'>;
|
|
6
|
+
interface MatcherOptions {
|
|
7
|
+
observedAt?: string;
|
|
8
|
+
gatewayConfig?: AgentpayGatewayConfig | null;
|
|
9
|
+
}
|
|
10
|
+
interface FormTargetGroup {
|
|
11
|
+
groupKey: string;
|
|
12
|
+
targets: TargetDescriptor[];
|
|
13
|
+
}
|
|
14
|
+
declare const protectedFormPlanSchema: z.ZodObject<{
|
|
15
|
+
confidence: z.ZodEnum<["high", "medium", "low"]>;
|
|
16
|
+
bindings: z.ZodArray<z.ZodObject<{
|
|
17
|
+
targetRef: z.ZodString;
|
|
18
|
+
fieldKey: z.ZodString;
|
|
19
|
+
valueHint: z.ZodOptional<z.ZodEnum<["direct", "full_name.given", "full_name.family"]>>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
targetRef: string;
|
|
22
|
+
fieldKey: string;
|
|
23
|
+
valueHint?: "direct" | "full_name.given" | "full_name.family" | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
targetRef: string;
|
|
26
|
+
fieldKey: string;
|
|
27
|
+
valueHint?: "direct" | "full_name.given" | "full_name.family" | undefined;
|
|
28
|
+
}>, "many">;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
confidence: "high" | "medium" | "low";
|
|
31
|
+
bindings: {
|
|
32
|
+
targetRef: string;
|
|
33
|
+
fieldKey: string;
|
|
34
|
+
valueHint?: "direct" | "full_name.given" | "full_name.family" | undefined;
|
|
35
|
+
}[];
|
|
36
|
+
}, {
|
|
37
|
+
confidence: "high" | "medium" | "low";
|
|
38
|
+
bindings: {
|
|
39
|
+
targetRef: string;
|
|
40
|
+
fieldKey: string;
|
|
41
|
+
valueHint?: "direct" | "full_name.given" | "full_name.family" | undefined;
|
|
42
|
+
}[];
|
|
43
|
+
}>;
|
|
44
|
+
declare function selectorSignalFragments(selector: string): string[];
|
|
45
|
+
declare function signalValuesOf(target: TargetDescriptor): string[];
|
|
46
|
+
declare function formGroupKeyOf(target: TargetDescriptor): string;
|
|
47
|
+
declare function groupTargetsByForm(targets: ReadonlyArray<TargetDescriptor>): FormTargetGroup[];
|
|
48
|
+
declare function buildMatcherPrompt(kind: StoredSecretKind, group: FormTargetGroup): string;
|
|
49
|
+
declare function sanitizeBindings(kind: StoredSecretKind, group: FormTargetGroup, bindings: ReadonlyArray<z.infer<typeof protectedFormPlanSchema>['bindings'][number]>): FillableFormFieldBinding[];
|
|
50
|
+
export declare function matchStoredSecretsToObservedTargets(pageRef: string, targets: ReadonlyArray<TargetDescriptor>, catalog: SecretCatalogSnapshot | null, options?: MatcherOptions): Promise<FillableFormDraft[]>;
|
|
51
|
+
export declare const __testFormMatcher: {
|
|
52
|
+
buildMatcherPrompt: typeof buildMatcherPrompt;
|
|
53
|
+
formGroupKeyOf: typeof formGroupKeyOf;
|
|
54
|
+
groupTargetsByForm: typeof groupTargetsByForm;
|
|
55
|
+
sanitizeBindings: typeof sanitizeBindings;
|
|
56
|
+
selectorSignalFragments: typeof selectorSignalFragments;
|
|
57
|
+
signalValuesOf: typeof signalValuesOf;
|
|
58
|
+
};
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=form-matcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"form-matcher.d.ts","sourceRoot":"","sources":["../../src/secrets/form-matcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAA2B,MAAM,qBAAqB,CAAC;AACrF,OAAO,KAAK,EACV,wBAAwB,EAExB,qBAAqB,EACrB,qBAAqB,EAErB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAapB,KAAK,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;AAEhE,UAAU,cAAc;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;CAC9C;AAED,UAAU,eAAe;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B;AAsBD,QAAA,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAW3B,CAAC;AAqCH,iBAAS,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAS3D;AAED,iBAAS,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAsC1D;AAkOD,iBAAS,cAAc,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAgBxD;AAED,iBAAS,kBAAkB,CAAC,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,GAAG,eAAe,EAAE,CAkBvF;AAoFD,iBAAS,kBAAkB,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,eAAe,GAAG,MAAM,CAalF;AAED,iBAAS,gBAAgB,CACvB,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GACnF,wBAAwB,EAAE,CA0C5B;AA6KD,wBAAsB,mCAAmC,CACvD,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,aAAa,CAAC,gBAAgB,CAAC,EACxC,OAAO,EAAE,qBAAqB,GAAG,IAAI,EACrC,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAqD9B;AAED,eAAO,MAAM,iBAAiB;;;;;;;CAO7B,CAAC"}
|