@jini-ai/integrations 0.4.2 → 0.6.10
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/CHANGELOG.md +99 -1
- package/README.md +1 -0
- package/dist/api-connections/access-token.d.ts +9 -0
- package/dist/api-connections/access-token.js +92 -0
- package/dist/api-connections/account-actions.d.ts +40 -0
- package/dist/api-connections/account-actions.js +110 -0
- package/dist/api-connections/attempt-state.d.ts +28 -0
- package/dist/api-connections/attempt-state.js +73 -0
- package/dist/api-connections/authorization.d.ts +45 -0
- package/dist/api-connections/authorization.js +120 -0
- package/dist/api-connections/deps.d.ts +41 -0
- package/dist/api-connections/deps.js +13 -0
- package/dist/api-connections/descriptor.d.ts +6 -0
- package/dist/api-connections/descriptor.js +111 -0
- package/dist/api-connections/errors.d.ts +23 -0
- package/dist/api-connections/errors.js +24 -0
- package/dist/api-connections/finish-authorization.d.ts +24 -0
- package/dist/api-connections/finish-authorization.js +117 -0
- package/dist/api-connections/index.d.ts +18 -0
- package/dist/api-connections/index.js +10 -0
- package/dist/api-connections/install-credential.d.ts +19 -0
- package/dist/api-connections/install-credential.js +12 -0
- package/dist/api-connections/keys.d.ts +27 -0
- package/dist/api-connections/keys.js +22 -0
- package/dist/api-connections/ports.d.ts +73 -0
- package/dist/api-connections/ports.js +2 -0
- package/dist/api-connections/records.d.ts +27 -0
- package/dist/api-connections/records.js +52 -0
- package/dist/api-connections/request-checks.d.ts +18 -0
- package/dist/api-connections/request-checks.js +67 -0
- package/dist/api-connections/service.d.ts +25 -0
- package/dist/api-connections/service.js +26 -0
- package/dist/api-connections/status.d.ts +28 -0
- package/dist/api-connections/status.js +36 -0
- package/dist/api-connections/token-store/errors.d.ts +20 -0
- package/dist/api-connections/token-store/errors.js +38 -0
- package/dist/api-connections/token-store/index.d.ts +6 -0
- package/dist/api-connections/token-store/index.js +6 -0
- package/dist/api-connections/token-store/record.d.ts +69 -0
- package/dist/api-connections/token-store/record.js +97 -0
- package/dist/api-connections/token-store/vault-token-store.d.ts +26 -0
- package/dist/api-connections/token-store/vault-token-store.js +215 -0
- package/dist/api-connections/types.d.ts +101 -0
- package/dist/api-connections/types.js +9 -0
- package/dist/credentialed-http/auth-schemes.js +8 -4
- package/dist/credentialed-http/credentialed-request.d.ts +4 -0
- package/dist/credentialed-http/credentialed-request.js +61 -77
- package/dist/credentialed-http/response-redaction.d.ts +15 -0
- package/dist/credentialed-http/response-redaction.js +82 -0
- package/dist/media-providers/catalog.d.ts +3 -1
- package/dist/media-providers/catalog.js +3 -1
- package/dist/media-providers/dispatch/async-operation-store.d.ts +31 -0
- package/dist/media-providers/dispatch/async-operation-store.js +75 -37
- package/dist/media-providers/dispatch/builtin-vendors.d.ts +1 -1
- package/dist/media-providers/dispatch/context.js +10 -2
- package/dist/media-providers/dispatch/engine.d.ts +6 -3
- package/dist/media-providers/dispatch/engine.js +99 -109
- package/dist/media-providers/dispatch/index.d.ts +4 -2
- package/dist/media-providers/dispatch/index.js +3 -1
- package/dist/media-providers/dispatch/media-provider-registry.d.ts +62 -0
- package/dist/media-providers/dispatch/media-provider-registry.js +141 -0
- package/dist/media-providers/dispatch/node.d.ts +13 -0
- package/dist/media-providers/dispatch/node.js +24 -0
- package/dist/media-providers/dispatch/openai-compatible.d.ts +1 -1
- package/dist/media-providers/dispatch/openai-compatible.js +90 -87
- package/dist/media-providers/dispatch/operation-runtime.js +116 -89
- package/dist/media-providers/dispatch/outbound.d.ts +8 -4
- package/dist/media-providers/dispatch/outbound.js +27 -26
- package/dist/media-providers/dispatch/providers/aihubmix.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/aihubmix.js +61 -56
- package/dist/media-providers/dispatch/providers/custom-image.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/elevenlabs.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/fishaudio.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/grok.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/imagerouter-video-async.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/imagerouter-video-async.js +53 -49
- package/dist/media-providers/dispatch/providers/imagerouter.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/imagerouter.js +11 -24
- package/dist/media-providers/dispatch/providers/minimax.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/nanobanana.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/nanobanana.js +22 -30
- package/dist/media-providers/dispatch/providers/openai.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/openai.js +51 -47
- package/dist/media-providers/dispatch/providers/openrouter.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/openrouter.js +52 -37
- package/dist/media-providers/dispatch/providers/senseaudio.d.ts +1 -1
- package/dist/media-providers/dispatch/providers/senseaudio.js +47 -28
- package/dist/media-providers/dispatch/providers/volcengine.d.ts +1 -1
- package/dist/media-providers/dispatch/response-parsers.js +37 -21
- package/dist/media-providers/dispatch/sqlite-async-operation-store.js +9 -29
- package/dist/media-providers/dispatch/ssrf-guard.d.ts +3 -2
- package/dist/media-providers/dispatch/ssrf-guard.js +6 -5
- package/dist/media-providers/dispatch/types.d.ts +76 -2
- package/dist/media-providers/dispatch/vendor-adapter.d.ts +2 -43
- package/dist/media-providers/dispatch/vendor-adapter.js +2 -2
- package/dist/media-providers/dispatch/vendor-registry-core.d.ts +24 -0
- package/dist/media-providers/dispatch/vendor-registry-core.js +34 -0
- package/dist/media-providers/dispatch/vendor-registry.d.ts +10 -36
- package/dist/media-providers/dispatch/vendor-registry.js +14 -42
- package/dist/media-providers/policy.js +25 -17
- package/dist/media-providers/providers.d.ts +5 -0
- package/dist/media-providers/providers.js +2 -0
- package/dist/media-providers/sqlite-task-store.js +12 -80
- package/dist/media-providers/staging.js +77 -58
- package/dist/media-providers/task-lifecycle.d.ts +33 -0
- package/dist/media-providers/task-lifecycle.js +124 -0
- package/dist/media-providers/task-store.js +8 -86
- package/dist/media-providers/ui-defaults.d.ts +10 -0
- package/dist/media-providers/ui-defaults.js +167 -0
- package/dist/media-providers/video-request.js +112 -90
- package/dist/saved-requests/definition.d.ts +17 -0
- package/dist/saved-requests/definition.js +84 -0
- package/dist/saved-requests/execute.d.ts +17 -0
- package/dist/saved-requests/execute.js +95 -0
- package/dist/saved-requests/index.d.ts +6 -0
- package/dist/saved-requests/index.js +4 -0
- package/dist/saved-requests/projection.d.ts +9 -0
- package/dist/saved-requests/projection.js +48 -0
- package/dist/saved-requests/schema.d.ts +7 -0
- package/dist/saved-requests/schema.js +73 -0
- package/dist/saved-requests/types.d.ts +58 -0
- package/dist/saved-requests/types.js +2 -0
- package/dist/saved-requests/validation.d.ts +46 -0
- package/dist/saved-requests/validation.js +66 -0
- package/dist/webhooks/delivery.d.ts +14 -0
- package/dist/webhooks/delivery.js +41 -10
- package/dist/webhooks/index.d.ts +1 -0
- package/dist/webhooks/index.js +1 -0
- package/dist/webhooks/ports.d.ts +23 -0
- package/dist/webhooks/worker.d.ts +83 -0
- package/dist/webhooks/worker.js +105 -0
- package/package.json +46 -9
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
/** @file `OAuthTokenStore` backed by the platform secrets vault.
|
|
2
|
+
* Exists so OAuth connections reuse the vault's sealing, AAD binding and revision CAS instead
|
|
3
|
+
* of a second secret store. It adds three guarantees the OAuth refresher relies on:
|
|
4
|
+
* - a durable refresh lease (vault metadata + CAS), so only one process refreshes at a time;
|
|
5
|
+
* - fencing: a write is refused once the connection's generation moved on (disconnect,
|
|
6
|
+
* account switch, reconnect) or a newer attempt took the lease, so a late refresh cannot
|
|
7
|
+
* resurrect tokens;
|
|
8
|
+
* - owner binding: every read must match the expected workspace/plugin/connection/client.
|
|
9
|
+
* A sign-in install is not a refresh, so it takes no lease: it is fenced by the generation the
|
|
10
|
+
* caller moved the connection to, and never overwrites a newer generation's tokens. */
|
|
11
|
+
import { randomUUID } from "node:crypto";
|
|
12
|
+
import { VaultError } from "@jini-ai/platform/secrets/credential-sets";
|
|
13
|
+
import { OAuthTokenStoreError } from "./errors.js";
|
|
14
|
+
import { buildRecordMeta, buildTokenPayload, parseTokenPayload, parseTokenSet, readRecordMeta, readReplaceableGeneration } from "./record.js";
|
|
15
|
+
/** A crashed holder's lease frees itself after this long; longer than any single token request. */
|
|
16
|
+
const LEASE_TTL_MS = 30_000;
|
|
17
|
+
/** Loads older than this cannot belong to a refresh that is about to take the lease. */
|
|
18
|
+
const LOAD_OBSERVATION_WINDOW_MS = 60_000;
|
|
19
|
+
/** Disconnect and install must win over concurrent lease writes; each retry re-reads the newest revision. */
|
|
20
|
+
const WRITE_ATTEMPTS = 3;
|
|
21
|
+
function isConflict(error) {
|
|
22
|
+
return error instanceof VaultError && error.code === "conflict";
|
|
23
|
+
}
|
|
24
|
+
/** Creates the store for one connection owner.
|
|
25
|
+
* @throws OAuthTokenStoreError `configuration` when the vault scope names another workspace. */
|
|
26
|
+
export function createVaultOAuthTokenStore(deps, _optionalArgs = {}) {
|
|
27
|
+
const { vault, vaultScope, owner, readGeneration, clock } = deps;
|
|
28
|
+
if (vaultScope.workspaceId !== owner.workspaceId)
|
|
29
|
+
throw new OAuthTokenStoreError({ code: "configuration" });
|
|
30
|
+
// Leases this instance holds, with the generation recorded at acquisition (the write fence).
|
|
31
|
+
const held = new Map();
|
|
32
|
+
// Generations recent loads returned; a lease is refused if any differs from the live one,
|
|
33
|
+
// because the refresher would then be refreshing tokens of a connection that has moved on.
|
|
34
|
+
const loads = new Map();
|
|
35
|
+
const identity = (key) => ({ ...vaultScope, id: key });
|
|
36
|
+
const open = async (key) => {
|
|
37
|
+
const found = await vault.get(identity(key));
|
|
38
|
+
if (found === null)
|
|
39
|
+
return null;
|
|
40
|
+
const meta = readRecordMeta({ meta: found.summary.meta });
|
|
41
|
+
return { revision: found.summary.revision, meta, payload: parseTokenPayload({ payload: found.payload, key, owner }) };
|
|
42
|
+
};
|
|
43
|
+
const observeLoad = (key, generation) => {
|
|
44
|
+
const nowMs = clock.nowMs();
|
|
45
|
+
const recent = (loads.get(key) ?? []).filter(entry => nowMs - entry.atMs < LOAD_OBSERVATION_WINDOW_MS);
|
|
46
|
+
loads.set(key, [...recent, { generation, atMs: nowMs }]);
|
|
47
|
+
};
|
|
48
|
+
const takeRecentLoads = (key) => {
|
|
49
|
+
const nowMs = clock.nowMs();
|
|
50
|
+
const recent = (loads.get(key) ?? []).filter(entry => nowMs - entry.atMs < LOAD_OBSERVATION_WINDOW_MS);
|
|
51
|
+
loads.delete(key);
|
|
52
|
+
return recent;
|
|
53
|
+
};
|
|
54
|
+
const writeRecord = async (key, required) => {
|
|
55
|
+
// The vault keeps labels unique per scope, and one scope holds several rows per connection
|
|
56
|
+
// (main and staged keys, other plugins' connections), so the label is the unique, non-secret key.
|
|
57
|
+
await vault.put({ ...identity(key), expectedRevision: required.revision, provider: null,
|
|
58
|
+
label: key, meta: buildRecordMeta({ meta: required.meta }), payload: required.payload });
|
|
59
|
+
};
|
|
60
|
+
// Every token write re-proves the lease and the generation immediately before the CAS write.
|
|
61
|
+
const fencedWrite = async (key, required) => {
|
|
62
|
+
const lease = held.get(key);
|
|
63
|
+
if (lease === undefined)
|
|
64
|
+
throw new OAuthTokenStoreError({ code: "lease-not-held" });
|
|
65
|
+
if (await readGeneration({ key }) !== lease.generation)
|
|
66
|
+
throw new OAuthTokenStoreError({ code: "stale-generation" });
|
|
67
|
+
const record = await open(key);
|
|
68
|
+
if (record === null || record.meta.leaseHolder !== lease.holder)
|
|
69
|
+
throw new OAuthTokenStoreError({ code: "lease-lost" });
|
|
70
|
+
const payload = buildTokenPayload({ key, owner, generation: lease.generation, tokens: required.tokens });
|
|
71
|
+
try {
|
|
72
|
+
await writeRecord(key, { revision: record.revision, meta: { ...record.meta, status: required.status }, payload });
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
throw isConflict(error) ? new OAuthTokenStoreError({ code: "lease-lost" }, { cause: error }) : error;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const claimLease = async (key, required) => {
|
|
79
|
+
const leaseFields = { leaseHolder: required.holder, leaseExpiresAtMs: clock.nowMs() + LEASE_TTL_MS };
|
|
80
|
+
try {
|
|
81
|
+
if (required.record === null) {
|
|
82
|
+
await writeRecord(key, { revision: null, meta: { status: "active", ...leaseFields },
|
|
83
|
+
payload: buildTokenPayload({ key, owner, generation: required.generation, tokens: null }) });
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
await vault.patchMeta({ ...identity(key), expectedRevision: required.record.revision, patch: leaseFields });
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
if (isConflict(error))
|
|
92
|
+
return false;
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
// Lease fields are kept: a refresher holding the lease for an older generation is refused by
|
|
97
|
+
// its own generation check or by this write's revision change, and then releases as usual.
|
|
98
|
+
// The row an install replaces; see `readReplaceableGeneration` for which rows qualify.
|
|
99
|
+
const openInstallTarget = async (key) => {
|
|
100
|
+
const found = await vault.get(identity(key));
|
|
101
|
+
if (found === null)
|
|
102
|
+
return { revision: null, generation: null, meta: { status: "active", leaseHolder: null, leaseExpiresAtMs: null } };
|
|
103
|
+
return { revision: found.summary.revision, generation: readReplaceableGeneration({ payload: found.payload, key, owner }),
|
|
104
|
+
meta: readRecordMeta({ meta: found.summary.meta }) };
|
|
105
|
+
};
|
|
106
|
+
const installOnce = async (key, required) => {
|
|
107
|
+
if (await readGeneration({ key }) !== required.generation)
|
|
108
|
+
throw new OAuthTokenStoreError({ code: "stale-generation" });
|
|
109
|
+
const target = await openInstallTarget(key);
|
|
110
|
+
// The live generation moved on after the check above and a newer install already landed.
|
|
111
|
+
if (target.generation !== null && target.generation > required.generation)
|
|
112
|
+
throw new OAuthTokenStoreError({ code: "stale-generation" });
|
|
113
|
+
try {
|
|
114
|
+
await writeRecord(key, { revision: target.revision, meta: { ...target.meta, status: "active" },
|
|
115
|
+
payload: buildTokenPayload({ key, owner, generation: required.generation, tokens: required.tokens }) });
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (isConflict(error))
|
|
120
|
+
return false;
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
// Needs only the revision: a row this owner can no longer open (another client id, malformed)
|
|
125
|
+
// must still be removable, or a disconnect could never clear it.
|
|
126
|
+
const deleteOnce = async (key) => {
|
|
127
|
+
const found = await vault.get(identity(key));
|
|
128
|
+
if (found === null)
|
|
129
|
+
return true;
|
|
130
|
+
try {
|
|
131
|
+
await vault.delete({ ...identity(key), expectedRevision: found.summary.revision });
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
if (isConflict(error))
|
|
136
|
+
return false;
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
async load({ key }) {
|
|
142
|
+
const generation = await readGeneration({ key });
|
|
143
|
+
const record = await open(key);
|
|
144
|
+
// Tokens sealed under an older generation belong to a disconnected or switched account.
|
|
145
|
+
if (record === null || record.payload.generation !== generation)
|
|
146
|
+
return null;
|
|
147
|
+
observeLoad(key, generation);
|
|
148
|
+
return record.payload.tokens;
|
|
149
|
+
},
|
|
150
|
+
// Generation-agnostic on purpose: a disconnect disables the credential by moving the
|
|
151
|
+
// generation, and only that disabled credential can still revoke the grant. Not recorded as a
|
|
152
|
+
// load, so it never feeds the refresh-lease decision.
|
|
153
|
+
async loadForRevocation({ key }) {
|
|
154
|
+
const record = await open(key);
|
|
155
|
+
return record?.payload.tokens ?? null;
|
|
156
|
+
},
|
|
157
|
+
async persist({ key, tokens }) {
|
|
158
|
+
await fencedWrite(key, { status: "active", tokens: parseTokenSet({ value: tokens }) });
|
|
159
|
+
},
|
|
160
|
+
async install({ key, tokens, generation }) {
|
|
161
|
+
const parsed = parseTokenSet({ value: tokens });
|
|
162
|
+
for (let attempt = 0; attempt < WRITE_ATTEMPTS; attempt += 1) {
|
|
163
|
+
if (await installOnce(key, { tokens: parsed, generation }))
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
throw new OAuthTokenStoreError({ code: "write-conflict" });
|
|
167
|
+
},
|
|
168
|
+
// The reason is not stored: callers may pass provider text, and status must stay secret-free.
|
|
169
|
+
// The refresh token is dead after invalid_grant, so the tokens are cleared with the status change.
|
|
170
|
+
async markNeedsReauth({ key }) {
|
|
171
|
+
await fencedWrite(key, { status: "reconnect-required", tokens: null });
|
|
172
|
+
},
|
|
173
|
+
async tryAcquireRefreshLease({ key }) {
|
|
174
|
+
const recentLoads = takeRecentLoads(key);
|
|
175
|
+
const generation = await readGeneration({ key });
|
|
176
|
+
if (recentLoads.some(entry => entry.generation !== generation))
|
|
177
|
+
return false;
|
|
178
|
+
const record = await open(key);
|
|
179
|
+
const leaseExpiresAtMs = record?.meta.leaseExpiresAtMs ?? null;
|
|
180
|
+
if (record?.meta.leaseHolder && leaseExpiresAtMs !== null && leaseExpiresAtMs > clock.nowMs())
|
|
181
|
+
return false;
|
|
182
|
+
const holder = randomUUID();
|
|
183
|
+
if (!await claimLease(key, { record, generation, holder }))
|
|
184
|
+
return false;
|
|
185
|
+
held.set(key, { holder, generation });
|
|
186
|
+
return true;
|
|
187
|
+
},
|
|
188
|
+
async releaseRefreshLease({ key }) {
|
|
189
|
+
const lease = held.get(key);
|
|
190
|
+
if (lease === undefined)
|
|
191
|
+
return;
|
|
192
|
+
held.delete(key);
|
|
193
|
+
const record = await open(key);
|
|
194
|
+
if (record === null || record.meta.leaseHolder !== lease.holder)
|
|
195
|
+
return;
|
|
196
|
+
try {
|
|
197
|
+
await vault.patchMeta({ ...identity(key), expectedRevision: record.revision, patch: { leaseHolder: null, leaseExpiresAtMs: null } });
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
// A concurrent writer changed the row; the lease then lapses on its own expiry.
|
|
201
|
+
if (!isConflict(error))
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
async delete({ key }) {
|
|
206
|
+
loads.delete(key);
|
|
207
|
+
for (let attempt = 0; attempt < WRITE_ATTEMPTS; attempt += 1) {
|
|
208
|
+
if (await deleteOnce(key))
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
throw new OAuthTokenStoreError({ code: "write-conflict" });
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=vault-token-store.js.map
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Value types for plugin-declared API connections: the trusted descriptor, the durable
|
|
3
|
+
* non-secret connection record and the single-use authorization attempt.
|
|
4
|
+
*
|
|
5
|
+
* Exists so the record store, token store and service agree on one vocabulary. Nothing here
|
|
6
|
+
* names a provider: a plugin supplies endpoints, parameters and hooks; the engine supplies flow.
|
|
7
|
+
*/
|
|
8
|
+
/** Lifecycle visible to hosts. Only `connected` lets tokens leave the store. */
|
|
9
|
+
export type ApiConnectionStatus = 'connected' | 'reconnect-required' | 'revocation-pending' | 'disconnected';
|
|
10
|
+
/** `connect` covers first connect, reconnect and adding scopes for the same account. */
|
|
11
|
+
export type ApiConnectionIntent = 'connect' | 'switch-account';
|
|
12
|
+
/** Identity reported by the plugin's account hook; shown to people, never used as a secret. */
|
|
13
|
+
export interface ApiConnectionAccount {
|
|
14
|
+
readonly accountId: string;
|
|
15
|
+
readonly displayName: string;
|
|
16
|
+
}
|
|
17
|
+
/** A plugin-declared request or callback field: the name is the allowlist, maxLength the bound. */
|
|
18
|
+
export interface ApiConnectionBoundedField {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly maxLength: number;
|
|
21
|
+
}
|
|
22
|
+
/** Validated, frozen plugin declaration. Contains no client secret. */
|
|
23
|
+
export interface ApiConnectionDescriptor {
|
|
24
|
+
readonly pluginId: string;
|
|
25
|
+
readonly connectionId: string;
|
|
26
|
+
readonly label: string;
|
|
27
|
+
readonly authorizationEndpoint: string;
|
|
28
|
+
readonly tokenEndpoint: string;
|
|
29
|
+
/** Fixed extra authorization parameters per client kind (hosted confidential vs installed public). */
|
|
30
|
+
readonly authorizationParams: {
|
|
31
|
+
readonly public: Readonly<Record<string, string>>;
|
|
32
|
+
readonly confidential: Readonly<Record<string, string>>;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Extra authorization parameters a hosted (`confidential`) start adds only when nothing renewable
|
|
36
|
+
* is stored for the account it signs in (first connect, switch, reconnect after a lost or rejected
|
|
37
|
+
* refresh token), so the provider issues a refresh token again, e.g. a forced consent prompt.
|
|
38
|
+
*/
|
|
39
|
+
readonly forceConsentParams: Readonly<Record<string, string>>;
|
|
40
|
+
/** Parameters a caller may set per start, e.g. a one-off selection flow. */
|
|
41
|
+
readonly startParams: readonly ApiConnectionBoundedField[];
|
|
42
|
+
/** Extra provider callback fields passed back to the plugin after the exchange succeeds. */
|
|
43
|
+
readonly callbackFields: readonly ApiConnectionBoundedField[];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Why the last remote revocation was not confirmed: a fixed code, never hook or provider text.
|
|
47
|
+
* `provider-unreachable` / `provider-refused` are the revoke hook's own classification (an error
|
|
48
|
+
* whose `code` is one of them); `unclassified` is any other hook failure; `credential-unreadable`
|
|
49
|
+
* means the stored credential could not be read, so it was removed locally without revoking.
|
|
50
|
+
*/
|
|
51
|
+
export type ApiConnectionRevocationFailure = 'provider-unreachable' | 'provider-refused' | 'unclassified' | 'credential-unreadable';
|
|
52
|
+
/** A switch-account result held aside until the person confirms it. */
|
|
53
|
+
export interface ApiConnectionStagedSwitch {
|
|
54
|
+
readonly account: ApiConnectionAccount;
|
|
55
|
+
readonly grantedScopes: readonly string[];
|
|
56
|
+
readonly actorId: string;
|
|
57
|
+
/** Credential generation the staged switch was made against; a change voids it. */
|
|
58
|
+
readonly generation: number;
|
|
59
|
+
readonly expiresAt: string;
|
|
60
|
+
}
|
|
61
|
+
/** Durable non-secret metadata. `revision` fences every write; `generation` fences credentials. */
|
|
62
|
+
export interface ApiConnectionRecord {
|
|
63
|
+
readonly key: string;
|
|
64
|
+
readonly workspaceId: string;
|
|
65
|
+
readonly pluginId: string;
|
|
66
|
+
readonly connectionId: string;
|
|
67
|
+
readonly status: ApiConnectionStatus;
|
|
68
|
+
readonly revision: number;
|
|
69
|
+
readonly generation: number;
|
|
70
|
+
readonly account: ApiConnectionAccount | null;
|
|
71
|
+
readonly grantedScopes: readonly string[];
|
|
72
|
+
readonly staged: ApiConnectionStagedSwitch | null;
|
|
73
|
+
/** Set by a disconnect or cancel whose revocation was not confirmed; cleared by the next confirmed one or sign-in. */
|
|
74
|
+
readonly revocationFailure: ApiConnectionRevocationFailure | null;
|
|
75
|
+
readonly updatedAt: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* One authorization round trip. `codeVerifier` is a short-lived PKCE secret: useless without the
|
|
79
|
+
* one-time code, but record stores must still keep attempts out of logs and exports.
|
|
80
|
+
*/
|
|
81
|
+
export interface ApiConnectionAttempt {
|
|
82
|
+
readonly state: string;
|
|
83
|
+
/** Random id plugin code and frames may hold; unlike `state` it is no CSRF binding. */
|
|
84
|
+
readonly attemptId: string;
|
|
85
|
+
readonly key: string;
|
|
86
|
+
readonly ownerKey: string;
|
|
87
|
+
/** SHA-256 (base64url) of the host-only binding the starting browser carries; never the binding itself. */
|
|
88
|
+
readonly browserBindingHash: string;
|
|
89
|
+
readonly workspaceId: string;
|
|
90
|
+
readonly actorId: string;
|
|
91
|
+
readonly pluginId: string;
|
|
92
|
+
readonly connectionId: string;
|
|
93
|
+
readonly intent: ApiConnectionIntent;
|
|
94
|
+
readonly requestedScopes: readonly string[];
|
|
95
|
+
readonly redirectUri: string;
|
|
96
|
+
readonly generation: number;
|
|
97
|
+
readonly codeVerifier: string;
|
|
98
|
+
readonly createdAt: string;
|
|
99
|
+
readonly expiresAt: string;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Value types for plugin-declared API connections: the trusted descriptor, the durable
|
|
3
|
+
* non-secret connection record and the single-use authorization attempt.
|
|
4
|
+
*
|
|
5
|
+
* Exists so the record store, token store and service agree on one vocabulary. Nothing here
|
|
6
|
+
* names a provider: a plugin supplies endpoints, parameters and hooks; the engine supplies flow.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -45,15 +45,19 @@ function parseRule(entry, at) {
|
|
|
45
45
|
if (!isPlainObject(entry))
|
|
46
46
|
return `${at} must be an object`;
|
|
47
47
|
const { id, prefix, scheme } = entry;
|
|
48
|
-
if (
|
|
48
|
+
if (!isBoundedMatch(id, RULE_ID_PATTERN))
|
|
49
49
|
return `${at}.id must be a lowercase hyphenated id`;
|
|
50
|
-
|
|
50
|
+
// HTTP_TOKEN_PATTERN's `+` quantifier already refuses an empty prefix, so "non-empty" needs no separate test.
|
|
51
|
+
if (!isBoundedMatch(prefix, HTTP_TOKEN_PATTERN))
|
|
51
52
|
return `${at}.prefix must be a non-empty run of HTTP token characters`;
|
|
52
|
-
|
|
53
|
-
if (typeof scheme !== "string" || scheme.length > MAX_FIELD_LENGTH || !HTTP_TOKEN_PATTERN.test(scheme))
|
|
53
|
+
if (!isBoundedMatch(scheme, HTTP_TOKEN_PATTERN))
|
|
54
54
|
return `${at}.scheme must be an HTTP auth-scheme name`;
|
|
55
55
|
return { id, prefix, scheme };
|
|
56
56
|
}
|
|
57
|
+
// Every rule field shares one shape check: a string no longer than MAX_FIELD_LENGTH matching its pattern.
|
|
58
|
+
function isBoundedMatch(value, pattern) {
|
|
59
|
+
return typeof value === "string" && value.length <= MAX_FIELD_LENGTH && pattern.test(value);
|
|
60
|
+
}
|
|
57
61
|
function isPlainObject(value) {
|
|
58
62
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
59
63
|
}
|
|
@@ -72,6 +72,10 @@ export interface CredentialedRequestDeps {
|
|
|
72
72
|
export interface CredentialedRequestOptions {
|
|
73
73
|
readonly headers?: unknown;
|
|
74
74
|
readonly body?: unknown;
|
|
75
|
+
/** Opt-in structured redaction after transport completeness checks. Existing text callers keep
|
|
76
|
+
* their original body formatting. JSON escapes cannot disguise a reflected credential value;
|
|
77
|
+
* credential-bearing keys and numbers refuse the body rather than changing its schema/types. */
|
|
78
|
+
readonly responseFormat?: "json";
|
|
75
79
|
readonly errorPolicy?: CredentialedRequestErrorPolicyPort;
|
|
76
80
|
readonly diagnosticMapper?: (required: {
|
|
77
81
|
diagnostic: AuthFailureDiagnostic;
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
import { IntegrationError } from "../argument-error.js";
|
|
10
10
|
import { nowIso } from "@jini-ai/core/primitives";
|
|
11
11
|
import { detectSelfDescribingAuthScheme } from "./auth-schemes.js";
|
|
12
|
+
import { redactJsonResponseBody, redactResponseHeaders, resolveRedactedResponseBody } from "./response-redaction.js";
|
|
12
13
|
export class CredentialNotFoundError extends IntegrationError {
|
|
13
14
|
}
|
|
14
15
|
// Multiple saved origins support providers with separate API hosts. A single absolute URL keeps
|
|
@@ -30,62 +31,6 @@ const MAX_REQUEST_BODY_BYTES = 1_000_000;
|
|
|
30
31
|
// Caller headers cannot replace credentials or override the bound host. User-Agent is allowed:
|
|
31
32
|
// it carries no secret and does not widen origin binding; the transport's default need not override it.
|
|
32
33
|
const FORBIDDEN_REQUEST_HEADER_NAMES = new Set(["authorization", "cookie", "host", "proxy-authorization"]);
|
|
33
|
-
// Echo endpoints and provider cookies must not return credential-bearing headers to the model,
|
|
34
|
-
// even when a value is too short to identify safely by substring matching.
|
|
35
|
-
const FORBIDDEN_RESPONSE_HEADER_NAMES = new Set(["authorization", "proxy-authorization", "set-cookie", "cookie"]);
|
|
36
|
-
// A visible marker explains removal; silently splicing bytes out could alter the response's meaning.
|
|
37
|
-
const REDACTED_MARKER = "[REDACTED]";
|
|
38
|
-
// Very short tokens can match ordinary words ("ab" inside "abacus"); scrubbing would silently
|
|
39
|
-
// mangle unrelated content. The eight-character floor retains normal long API-token responses
|
|
40
|
-
// while withholding pathological ones. Dropping a whole response header needs no such floor.
|
|
41
|
-
const MIN_SAFE_BODY_REDACTION_TOKEN_LENGTH = 8;
|
|
42
|
-
// Withhold the body rather than leak the secret or make unrelated content look like provider output;
|
|
43
|
-
// the request still ran, and the marker lets a caller distinguish display limits from auth failure.
|
|
44
|
-
const BODY_WITHHELD_SHORT_TOKEN_MARKER = "[body withheld: credential too short to redact safely]";
|
|
45
|
-
// Match secrets embedded in diagnostic header values too, not just values equal to a full secret.
|
|
46
|
-
// Whole-header removal has no partial-mangling failure mode and therefore applies at any length.
|
|
47
|
-
function redactResponseHeaders(headers, secrets) {
|
|
48
|
-
const result = {};
|
|
49
|
-
for (const [key, value] of Object.entries(headers)) {
|
|
50
|
-
if (FORBIDDEN_RESPONSE_HEADER_NAMES.has(key.trim().toLowerCase()))
|
|
51
|
-
continue;
|
|
52
|
-
if (secrets.some((secret) => secret !== "" && value.includes(secret)))
|
|
53
|
-
continue;
|
|
54
|
-
result[key] = value;
|
|
55
|
-
}
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
|
-
// Reflecting responses must not send injected credentials back through the model; retain all other
|
|
59
|
-
// provider text instead of replacing the provider's answer with an authentication diagnosis.
|
|
60
|
-
function redactSecretSubstrings(text, secrets) {
|
|
61
|
-
return secrets.reduce((acc, secret) => (secret === "" ? acc : acc.split(secret).join(REDACTED_MARKER)), text);
|
|
62
|
-
}
|
|
63
|
-
// One-to-three-character suffix matches are too ambiguous to identify a cut-off secret. This
|
|
64
|
-
// four-character partial-tail floor gates a different risk from the full-token length floor above.
|
|
65
|
-
const MIN_SAFE_TRUNCATED_TAIL_PREFIX_LENGTH = 4;
|
|
66
|
-
// A size cap can cut a reflected secret mid-token, so whole-secret replacement alone leaks its
|
|
67
|
-
// prefix. Use the longest matching suffix across all secrets to remove the whole fragment; only
|
|
68
|
-
// truncated bodies qualify, since matching complete bodies could remove innocent trailing text.
|
|
69
|
-
function redactTruncatedTail(body, secrets) {
|
|
70
|
-
let longestMatch = 0;
|
|
71
|
-
for (const secret of secrets) {
|
|
72
|
-
for (let len = Math.min(secret.length, body.length); len >= MIN_SAFE_TRUNCATED_TAIL_PREFIX_LENGTH; len--) {
|
|
73
|
-
if (body.endsWith(secret.slice(0, len))) {
|
|
74
|
-
longestMatch = Math.max(longestMatch, len);
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return longestMatch === 0 ? body : body.slice(0, body.length - longestMatch) + REDACTED_MARKER;
|
|
80
|
-
}
|
|
81
|
-
// Gate on the raw token: a scheme-prefixed header is longer and cannot make a short token safe.
|
|
82
|
-
// The second pass is conditional because a complete response has no cap-cut fragment to repair.
|
|
83
|
-
function resolveRedactedResponseBody(bodyText, token, secrets, bodyTruncated) {
|
|
84
|
-
if (token.length < MIN_SAFE_BODY_REDACTION_TOKEN_LENGTH)
|
|
85
|
-
return BODY_WITHHELD_SHORT_TOKEN_MARKER;
|
|
86
|
-
const redacted = redactSecretSubstrings(bodyText, secrets);
|
|
87
|
-
return bodyTruncated ? redactTruncatedTail(redacted, secrets) : redacted;
|
|
88
|
-
}
|
|
89
34
|
// Match the HTTP port's verb vocabulary so every validated method is one the transport can send.
|
|
90
35
|
const SUPPORTED_METHODS = new Set(["GET", "POST", "PUT", "PATCH", "DELETE"]);
|
|
91
36
|
function requireLabel(raw) {
|
|
@@ -212,6 +157,10 @@ function buildAuthFailureDiagnostic(connection, status, schemes) {
|
|
|
212
157
|
"for that reason — this credential has no username saved. If that's the cause, saving one may fix it.",
|
|
213
158
|
};
|
|
214
159
|
}
|
|
160
|
+
// Keep the entry's field order identical for every outcome so serialized audit lines stay stable.
|
|
161
|
+
function auditEntry(base, status) {
|
|
162
|
+
return { label: base.label, host: base.host, method: base.method, status, bodyBytes: base.bodyBytes, at: base.at };
|
|
163
|
+
}
|
|
215
164
|
// A structured line gives deployments an inspectable trail without requiring a database audit sink.
|
|
216
165
|
export class ConsoleCredentialedRequestAuditLog {
|
|
217
166
|
required;
|
|
@@ -256,10 +205,15 @@ async function resolveCredentialOrThrow(deps, input) {
|
|
|
256
205
|
function classifyCustomCredentialStatus(status) {
|
|
257
206
|
if (status >= 200 && status < 300)
|
|
258
207
|
return "valid";
|
|
259
|
-
if (status
|
|
208
|
+
if (isAuthRejectionStatus(status))
|
|
260
209
|
return "invalid";
|
|
261
210
|
return "unreachable";
|
|
262
211
|
}
|
|
212
|
+
// 401 and 403 are the only affirmative authentication rejections; both classification and
|
|
213
|
+
// diagnostics key off this one predicate so they cannot disagree.
|
|
214
|
+
function isAuthRejectionStatus(status) {
|
|
215
|
+
return status === 401 || status === 403;
|
|
216
|
+
}
|
|
263
217
|
// Wording may change without changing the three-way classification contract.
|
|
264
218
|
function buildVerificationMessage(label, status, outcome) {
|
|
265
219
|
if (outcome === "valid")
|
|
@@ -279,7 +233,7 @@ export async function verifyCustomCredential(required, optional = {}) {
|
|
|
279
233
|
const checkedAt = nowIso({ clock: deps.clock });
|
|
280
234
|
const { baseUrl, connection } = await resolveCredentialOrThrow(deps, { workspaceId: input.workspaceId, label });
|
|
281
235
|
const url = new URL(`${new URL(baseUrl).origin}/`);
|
|
282
|
-
const
|
|
236
|
+
const auditBase = { label, host: url.hostname, method: "GET", bodyBytes: 0, at: checkedAt };
|
|
283
237
|
const schemes = await deps.schemeRegistry.load({ workspaceId: input.workspaceId });
|
|
284
238
|
let status;
|
|
285
239
|
try {
|
|
@@ -292,12 +246,12 @@ export async function verifyCustomCredential(required, optional = {}) {
|
|
|
292
246
|
status = response.status;
|
|
293
247
|
}
|
|
294
248
|
catch {
|
|
295
|
-
audit.record({ entry:
|
|
249
|
+
deps.audit.record({ entry: auditEntry(auditBase, 0) });
|
|
296
250
|
return { status: "unreachable", message: `Could not reach '${label}' to verify this credential — this does not necessarily mean the credential is bad.`, checkedAt };
|
|
297
251
|
}
|
|
298
|
-
audit.record({ entry:
|
|
252
|
+
deps.audit.record({ entry: auditEntry(auditBase, status) });
|
|
299
253
|
const outcome = classifyCustomCredentialStatus(status);
|
|
300
|
-
const authDiagnostic =
|
|
254
|
+
const authDiagnostic = isAuthRejectionStatus(status) ? mapAuthDiagnostic(connection, status, schemes, optional) : undefined;
|
|
301
255
|
return { status: outcome, message: buildVerificationMessage(label, status, outcome), checkedAt, ...(authDiagnostic ? { authDiagnostic } : {}) };
|
|
302
256
|
}
|
|
303
257
|
// Echo endpoints may return bare Basic payloads or bare self-describing values without their scheme
|
|
@@ -327,13 +281,12 @@ export async function makeCredentialedRequest(required, optional = {}) {
|
|
|
327
281
|
const extraHeaders = validateExtraHeaders(optional.headers);
|
|
328
282
|
const body = validateOptionalBody(optional.body);
|
|
329
283
|
const at = nowIso({ clock: deps.clock });
|
|
330
|
-
const
|
|
331
|
-
const url = resolveAllowedRequestUrl(input.url, allowedOriginsFor(
|
|
332
|
-
const
|
|
333
|
-
const bodyBytes = body !== undefined ? Buffer.byteLength(body, "utf8") : 0;
|
|
284
|
+
const credential = await resolveCredentialOrThrow(deps, { workspaceId: input.workspaceId, label });
|
|
285
|
+
const url = resolveAllowedRequestUrl(input.url, allowedOriginsFor(credential));
|
|
286
|
+
const auditBase = { label, host: url.hostname, method, bodyBytes: body !== undefined ? Buffer.byteLength(body, "utf8") : 0, at };
|
|
334
287
|
const schemes = await deps.schemeRegistry.load({ workspaceId: input.workspaceId });
|
|
335
|
-
const authorizationHeader = buildAuthorizationHeader({ connection, schemes });
|
|
336
|
-
const
|
|
288
|
+
const authorizationHeader = buildAuthorizationHeader({ connection: credential.connection, schemes });
|
|
289
|
+
const redaction = { connection: credential.connection, schemes, secrets: buildResponseSecrets(credential.connection, authorizationHeader, schemes) };
|
|
337
290
|
let response;
|
|
338
291
|
try {
|
|
339
292
|
response = await deps.httpClient.send({ request: {
|
|
@@ -345,21 +298,52 @@ export async function makeCredentialedRequest(required, optional = {}) {
|
|
|
345
298
|
} });
|
|
346
299
|
}
|
|
347
300
|
catch (err) {
|
|
348
|
-
|
|
349
|
-
// Preserve the host refusal class: wrapping it would make a recoverable target-policy problem
|
|
350
|
-
// indistinguishable from a redacted internal failure at the tool boundary. Audit status stays zero.
|
|
351
|
-
if (optional.errorPolicy?.isEgressRefusal({ error: err }))
|
|
352
|
-
throw err;
|
|
353
|
-
throw new CredentialedRequestTransportError({ message: `request to '${label}' failed: ${resolveRedactedResponseBody(err instanceof Error ? err.message : String(err), connection.token, responseSecrets, false)}` });
|
|
301
|
+
return failTransport({ err, audit: deps.audit, auditBase, redaction }, optional);
|
|
354
302
|
}
|
|
355
|
-
audit.record({ entry:
|
|
356
|
-
|
|
303
|
+
deps.audit.record({ entry: auditEntry(auditBase, response.status) });
|
|
304
|
+
return buildExecutedResult({ response, redaction }, optional);
|
|
305
|
+
}
|
|
306
|
+
// Audit every transport failure with status zero, then rethrow. Preserve the host refusal class:
|
|
307
|
+
// wrapping it would make a recoverable target-policy problem indistinguishable from a redacted
|
|
308
|
+
// internal failure at the tool boundary. Audit status stays zero.
|
|
309
|
+
function failTransport(required, optional) {
|
|
310
|
+
const { err, audit, auditBase, redaction } = required;
|
|
311
|
+
const egressRefusal = describeEgressRefusal(err, optional.errorPolicy);
|
|
312
|
+
audit.record({ entry: { ...auditEntry(auditBase, 0), ...(egressRefusal !== undefined ? { egressRefusal } : {}) } });
|
|
313
|
+
if (egressRefusal !== undefined)
|
|
314
|
+
throw err;
|
|
315
|
+
const detail = err instanceof Error ? err.message : String(err);
|
|
316
|
+
throw new CredentialedRequestTransportError({ message: `request to '${auditBase.label}' failed: ${resolveRedactedResponseBody(detail, redaction.connection.token, redaction.secrets, false)}` });
|
|
317
|
+
}
|
|
318
|
+
// Only a host-recognized refusal yields audit detail; any other failure, or no policy, yields none.
|
|
319
|
+
function describeEgressRefusal(err, policy) {
|
|
320
|
+
return policy?.isEgressRefusal({ error: err }) ? policy.describeEgressRefusal({ error: err }) : undefined;
|
|
321
|
+
}
|
|
322
|
+
// Redact before returning: headers and body may reflect the injected secrets. A 401/403 adds the
|
|
323
|
+
// auth diagnostic alongside the provider's own answer, never in place of it.
|
|
324
|
+
function buildExecutedResult(required, optional) {
|
|
325
|
+
const { response, redaction } = required;
|
|
326
|
+
const authDiagnostic = isAuthRejectionStatus(response.status) ? mapAuthDiagnostic(redaction.connection, response.status, redaction.schemes, optional) : undefined;
|
|
357
327
|
return {
|
|
358
328
|
executed: true,
|
|
359
329
|
status: response.status,
|
|
360
|
-
headers: redactResponseHeaders(response.headers,
|
|
361
|
-
bodyText:
|
|
330
|
+
headers: redactResponseHeaders(response.headers, redaction.secrets),
|
|
331
|
+
bodyText: redactExecutedBody({ response, redaction }, optional),
|
|
362
332
|
...(authDiagnostic ? { authDiagnostic } : {}),
|
|
363
333
|
};
|
|
364
334
|
}
|
|
335
|
+
/** Keep decoded-string redaction in the credential owner, before any caller's projection. */
|
|
336
|
+
function redactExecutedBody({ response, redaction }, options = {}) {
|
|
337
|
+
if (options.responseFormat === "json") {
|
|
338
|
+
if (response.bodyTruncated || response.bodyBytesTruncated)
|
|
339
|
+
throw new CredentialedRequestValidationError({ message: "JSON response must be complete" });
|
|
340
|
+
try {
|
|
341
|
+
return redactJsonResponseBody({ bodyText: response.bodyText, token: redaction.connection.token, secrets: redaction.secrets });
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
throw new CredentialedRequestValidationError({ message: "JSON response must be valid" });
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return resolveRedactedResponseBody(response.bodyText, redaction.connection.token, redaction.secrets, response.bodyTruncated === true);
|
|
348
|
+
}
|
|
365
349
|
//# sourceMappingURL=credentialed-request.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare function redactResponseHeaders(headers: Readonly<Record<string, string>>, secrets: readonly string[]): Record<string, string>;
|
|
2
|
+
export declare function redactSecretSubstrings(text: string, secrets: readonly string[]): string;
|
|
3
|
+
export declare function redactTruncatedTail(body: string, secrets: readonly string[]): string;
|
|
4
|
+
export declare function resolveRedactedResponseBody(bodyText: string, token: string, secrets: readonly string[], bodyTruncated: boolean): string;
|
|
5
|
+
/** Opt-in JSON release boundary: decode escaped strings before using the same credential-secret
|
|
6
|
+
* owner. Scrubbing only serialized bytes misses a provider echo such as `\u0073ecret-token`.
|
|
7
|
+
* Callers must reject truncated responses first. Malformed JSON or secrets in keys/numbers throw;
|
|
8
|
+
* short tokens withhold the whole body under the existing rule. The reviver visits decoded keys
|
|
9
|
+
* and values at every depth. @complexity O(n * s), bounded body and secrets. */
|
|
10
|
+
export declare function redactJsonResponseBody({ bodyText, token, secrets }: {
|
|
11
|
+
bodyText: string;
|
|
12
|
+
token: string;
|
|
13
|
+
secrets: readonly string[];
|
|
14
|
+
}, _options?: Record<string, never>): string;
|
|
15
|
+
//# sourceMappingURL=response-redaction.d.ts.map
|