outbound-sdk 0.10.0 → 0.11.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/chunks/{chunk-KQCIF5IT.js → chunk-CVLGFVDC.js} +12 -2
- package/dist/chunks/{chunk-NAYVG7SI.js → chunk-V7JKTNRO.js} +1 -1
- package/dist/cli/bin.js +2 -2
- package/dist/cli/config.d.ts +2 -0
- package/dist/cli/index.js +1 -1
- package/dist/redact/index.d.ts +1 -1
- package/dist/redact/index.js +45 -23
- package/dist/redact/plugin.d.ts +12 -4
- package/dist/redact/tokens.d.ts +21 -0
- package/package.json +1 -1
|
@@ -26,6 +26,9 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
fromEnv
|
|
28
28
|
} from "./chunk-5XLR6XVV.js";
|
|
29
|
+
import {
|
|
30
|
+
readEnv
|
|
31
|
+
} from "./chunk-NFWWA7MI.js";
|
|
29
32
|
import {
|
|
30
33
|
OutboundError
|
|
31
34
|
} from "./chunk-XYHM4KHC.js";
|
|
@@ -144,6 +147,7 @@ var wantsRedact = (flags, fromConfig, mcp) => {
|
|
|
144
147
|
}
|
|
145
148
|
return !fromConfig && (flags.redact === true || mcp);
|
|
146
149
|
};
|
|
150
|
+
var REDACT_KEY_ENV = "OUTBOUND_REDACT_KEY";
|
|
147
151
|
var capSetting = (mcp) => mcp ? "--max-requests on outbound mcp" : "--max-requests";
|
|
148
152
|
var insightCaps = (flags, mcp) => ({
|
|
149
153
|
capSetting: capSetting(mcp),
|
|
@@ -161,9 +165,14 @@ var setupFor = async (flags, mcp, note) => {
|
|
|
161
165
|
const configured = loaded.plugins;
|
|
162
166
|
const fromConfig = configured.some((plugin) => plugin.name === "redact");
|
|
163
167
|
const plugins = [];
|
|
168
|
+
const key = readEnv(REDACT_KEY_ENV);
|
|
164
169
|
if (wantsRedact(flags, fromConfig, mcp)) {
|
|
165
170
|
const { redact } = await import("../redact/index.js");
|
|
166
|
-
plugins.push(redact());
|
|
171
|
+
plugins.push(redact({ key }));
|
|
172
|
+
} else if (fromConfig && key !== void 0) {
|
|
173
|
+
note(
|
|
174
|
+
`${REDACT_KEY_ENV} is set, but the config file's redact() takes its own options, so it is not used. Pass it there as redact({ key: process.env.${REDACT_KEY_ENV} }).`
|
|
175
|
+
);
|
|
167
176
|
}
|
|
168
177
|
plugins.push(...configured);
|
|
169
178
|
if (flags.cache !== void 0) {
|
|
@@ -1021,7 +1030,8 @@ var GLOBAL_HELP = [
|
|
|
1021
1030
|
" --cache <seconds> reuse an answer for this long, within this process (for mcp; use a config-file store to persist)",
|
|
1022
1031
|
" --max-requests <n> the most vendor requests one command, or one MCP tool call, may make",
|
|
1023
1032
|
"",
|
|
1024
|
-
"Each adapter reads its own key from the environment, for example INSTANTLY_API_KEY."
|
|
1033
|
+
"Each adapter reads its own key from the environment, for example INSTANTLY_API_KEY.",
|
|
1034
|
+
"OUTBOUND_REDACT_KEY, a secret of at least 32 characters, gives redact the same tokens in every run."
|
|
1025
1035
|
];
|
|
1026
1036
|
var helpText = () => [
|
|
1027
1037
|
"outbound: read-only access to outbound sending tools",
|
package/dist/cli/bin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import "../chunks/chunk-
|
|
3
|
-
import "../chunks/chunk-
|
|
2
|
+
import "../chunks/chunk-V7JKTNRO.js";
|
|
3
|
+
import "../chunks/chunk-CVLGFVDC.js";
|
|
4
4
|
import "../chunks/chunk-OMCDMELK.js";
|
|
5
5
|
import "../chunks/chunk-OVTYA3IB.js";
|
|
6
6
|
import "../chunks/chunk-FTK4JS65.js";
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface PluginFlags {
|
|
|
21
21
|
readonly "max-requests"?: string | undefined;
|
|
22
22
|
readonly cache?: string | undefined;
|
|
23
23
|
}
|
|
24
|
+
/** The secret that keys redact's tokens across runs, when set. Never printed. */
|
|
25
|
+
export declare const REDACT_KEY_ENV = "OUTBOUND_REDACT_KEY";
|
|
24
26
|
/** What a cap message tells a CLI user to raise. */
|
|
25
27
|
export declare const capSetting: (mcp: boolean) => string;
|
|
26
28
|
/**
|
package/dist/cli/index.js
CHANGED
package/dist/redact/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { ALL_FIELDS, KNOWN_TOKENS, MASK, redact } from "./plugin.ts";
|
|
1
|
+
export { ALL_FIELDS, KNOWN_TOKENS, MASK, MIN_KEY_LENGTH, redact, } from "./plugin.ts";
|
|
2
2
|
export type { RedactExtension, RedactField, RedactOptions } from "./plugin.ts";
|
package/dist/redact/index.js
CHANGED
|
@@ -18,28 +18,30 @@ import {
|
|
|
18
18
|
isString
|
|
19
19
|
} from "../chunks/chunk-45TXPJW7.js";
|
|
20
20
|
|
|
21
|
-
// src/redact/
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
"custom",
|
|
26
|
-
"email",
|
|
27
|
-
"linkedin",
|
|
28
|
-
"name",
|
|
29
|
-
"phone",
|
|
30
|
-
"subject"
|
|
31
|
-
];
|
|
32
|
-
var MASK = "[redacted]";
|
|
33
|
-
var replacer = (strategy) => (value) => {
|
|
34
|
-
if (value === null) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
return strategy === "mask" ? MASK : `redacted:${stableId(value).slice(0, 16)}`;
|
|
38
|
-
};
|
|
39
|
-
var keyedToken = () => {
|
|
40
|
-
const key = crypto.getRandomValues(new Uint8Array(32));
|
|
21
|
+
// src/redact/tokens.ts
|
|
22
|
+
var MIN_KEY_LENGTH = 32;
|
|
23
|
+
var keyedToken = (secret) => {
|
|
24
|
+
const key = secret === void 0 ? crypto.getRandomValues(new Uint8Array(32)) : new TextEncoder().encode(secret);
|
|
41
25
|
return (value) => `redacted:${hmacSha256Hex(key, value).slice(0, 16)}`;
|
|
42
26
|
};
|
|
27
|
+
var checkedKey = (key, strategy) => {
|
|
28
|
+
if (key === void 0) {
|
|
29
|
+
return void 0;
|
|
30
|
+
}
|
|
31
|
+
if (strategy !== "mask") {
|
|
32
|
+
throw new OutboundError(
|
|
33
|
+
"Invalid",
|
|
34
|
+
'redact takes a key only with strategy "mask": "hash" writes the same token without one'
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
if (key.length < MIN_KEY_LENGTH) {
|
|
38
|
+
throw new OutboundError(
|
|
39
|
+
"Invalid",
|
|
40
|
+
`The redact key must be at least ${MIN_KEY_LENGTH} characters. It is a secret: make one with \`openssl rand -hex 32\``
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return key;
|
|
44
|
+
};
|
|
43
45
|
var KNOWN_TOKENS = 1e4;
|
|
44
46
|
var TOKEN = /redacted:[0-9a-f]{16}/gu;
|
|
45
47
|
var knownTokens = () => {
|
|
@@ -67,8 +69,27 @@ var knownTokens = () => {
|
|
|
67
69
|
unmask: (text) => text.replaceAll(TOKEN, (token) => values.get(token)?.value ?? token)
|
|
68
70
|
};
|
|
69
71
|
};
|
|
72
|
+
|
|
73
|
+
// src/redact/plugin.ts
|
|
74
|
+
var ALL_FIELDS = [
|
|
75
|
+
"body",
|
|
76
|
+
"company",
|
|
77
|
+
"custom",
|
|
78
|
+
"email",
|
|
79
|
+
"linkedin",
|
|
80
|
+
"name",
|
|
81
|
+
"phone",
|
|
82
|
+
"subject"
|
|
83
|
+
];
|
|
84
|
+
var MASK = "[redacted]";
|
|
85
|
+
var replacer = (strategy) => (value) => {
|
|
86
|
+
if (value === null) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return strategy === "mask" ? MASK : `redacted:${stableId(value).slice(0, 16)}`;
|
|
90
|
+
};
|
|
70
91
|
var maskIdentifier = (masks, field, value) => masks.has(field) ? masks.identifier(field, value) : value;
|
|
71
|
-
var masksFor = (fields, strategy) => {
|
|
92
|
+
var masksFor = (fields, strategy, secret) => {
|
|
72
93
|
const replace = replacer(strategy);
|
|
73
94
|
const has = (field) => fields.has(field);
|
|
74
95
|
const known = knownTokens();
|
|
@@ -81,7 +102,7 @@ var masksFor = (fields, strategy) => {
|
|
|
81
102
|
token: (kind, value, original = value) => known.remember(replace(value) ?? MASK, kind, original)
|
|
82
103
|
};
|
|
83
104
|
}
|
|
84
|
-
const keyed = keyedToken();
|
|
105
|
+
const keyed = keyedToken(secret);
|
|
85
106
|
const token = (kind, value, original = value) => known.remember(keyed(value), kind, original);
|
|
86
107
|
return {
|
|
87
108
|
has,
|
|
@@ -255,7 +276,7 @@ var unmasked = (known, operation) => {
|
|
|
255
276
|
var redact = (options = {}) => {
|
|
256
277
|
const fields = new Set(options.fields ?? ALL_FIELDS);
|
|
257
278
|
const strategy = options.strategy ?? "mask";
|
|
258
|
-
const masks = masksFor(fields, strategy);
|
|
279
|
+
const masks = masksFor(fields, strategy, checkedKey(options.key, strategy));
|
|
259
280
|
return {
|
|
260
281
|
// Asking for bodies while they are being removed is a contradiction, so
|
|
261
282
|
// the capability is turned off and the request is refused up front.
|
|
@@ -300,5 +321,6 @@ export {
|
|
|
300
321
|
ALL_FIELDS,
|
|
301
322
|
KNOWN_TOKENS,
|
|
302
323
|
MASK,
|
|
324
|
+
MIN_KEY_LENGTH,
|
|
303
325
|
redact
|
|
304
326
|
};
|
package/dist/redact/plugin.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Lead } from "../internal/entities.ts";
|
|
2
2
|
import type { ListAll } from "../internal/outbound/api.ts";
|
|
3
3
|
import type { OutboundPlugin } from "../internal/outbound/plugins.ts";
|
|
4
|
+
import type { Identifier } from "./tokens.ts";
|
|
5
|
+
export { KNOWN_TOKENS, MIN_KEY_LENGTH } from "./tokens.ts";
|
|
4
6
|
export type RedactField = "body" | "company" | "custom" | "email" | "linkedin" | "name" | "phone" | "subject";
|
|
5
7
|
export interface RedactOptions {
|
|
6
8
|
/** What to mask. Defaults to everything. */
|
|
@@ -12,6 +14,16 @@ export interface RedactOptions {
|
|
|
12
14
|
* so the same person gets the same token from one run to the next.
|
|
13
15
|
*/
|
|
14
16
|
readonly strategy?: "hash" | "mask" | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* A secret, at least `MIN_KEY_LENGTH` (32) characters, that keys the
|
|
19
|
+
* tokens `mask` writes for addresses and profiles. With it the same person
|
|
20
|
+
* gets the same token in every instance and process given the same key, so
|
|
21
|
+
* redacted data can be joined across runs. Without it each plugin makes a
|
|
22
|
+
* random key of its own. Anyone holding the key can test a guessed address
|
|
23
|
+
* against a token, and a new key gives every person a new token. Only for
|
|
24
|
+
* `mask`; `hash` needs no key.
|
|
25
|
+
*/
|
|
26
|
+
readonly key?: string | undefined;
|
|
15
27
|
}
|
|
16
28
|
export declare const ALL_FIELDS: readonly RedactField[];
|
|
17
29
|
export declare const MASK = "[redacted]";
|
|
@@ -44,9 +56,5 @@ export interface RedactExtension {
|
|
|
44
56
|
readonly leadsByToken: (tokens: readonly string[], campaign: string | null) => ListAll<Lead>;
|
|
45
57
|
};
|
|
46
58
|
}
|
|
47
|
-
type Identifier = "email" | "linkedin";
|
|
48
|
-
/** The most tokens one redact remembers the value of; the oldest go first. */
|
|
49
|
-
export declare const KNOWN_TOKENS = 10000;
|
|
50
59
|
/** Masks emails, names, companies, LinkedIn URLs, custom fields and message text. */
|
|
51
60
|
export declare const redact: (options?: RedactOptions) => OutboundPlugin<RedactExtension>;
|
|
52
|
-
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** The shortest `key` `redact` accepts. */
|
|
2
|
+
export declare const MIN_KEY_LENGTH = 32;
|
|
3
|
+
export declare const keyedToken: (secret: string | undefined) => ((value: string) => string);
|
|
4
|
+
export declare const checkedKey: (key: string | undefined, strategy: "hash" | "mask") => string | undefined;
|
|
5
|
+
export type Identifier = "email" | "linkedin";
|
|
6
|
+
/** The most tokens one redact remembers the value of; the oldest go first. */
|
|
7
|
+
export declare const KNOWN_TOKENS = 10000;
|
|
8
|
+
export declare const TOKEN: RegExp;
|
|
9
|
+
/**
|
|
10
|
+
* The values behind the tokens this redact wrote for addresses and profiles,
|
|
11
|
+
* held in memory for its lifetime and never written out.
|
|
12
|
+
*/
|
|
13
|
+
export interface Known {
|
|
14
|
+
readonly remember: (token: string, kind: Identifier, value: string) => string;
|
|
15
|
+
readonly kindOf: (token: string) => Identifier | null;
|
|
16
|
+
/** Puts each known token's value back, for a call on its way to the vendor. */
|
|
17
|
+
readonly unmask: (text: string) => string;
|
|
18
|
+
/** Puts the tokens back where a value from `unmask` appears. */
|
|
19
|
+
readonly remask: (text: string) => string;
|
|
20
|
+
}
|
|
21
|
+
export declare const knownTokens: () => Known;
|