@apifuse/provider-sdk 2.2.0-beta.43 → 2.2.0-beta.44
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
CHANGED
|
@@ -9,7 +9,7 @@ import { validateFailClosedDeclaration } from "../declaration-validation.js";
|
|
|
9
9
|
import { safeProviderErrorObservability } from "../error-observability.js";
|
|
10
10
|
import { SDK_OWNED_PROVIDER_ERROR_CODES, SDK_RUNTIME_OWNED_ERROR_CODES, SDK_STATUS_MAPPED_PROVIDER_ERROR_CODES, } from "../error-resolution.js";
|
|
11
11
|
import { AuthError, isProviderError, isSessionExpiredError, isTransportError, isValidationError, ProviderError, } from "../errors.js";
|
|
12
|
-
import {
|
|
12
|
+
import { sanitizeDiagnosticText } from "../fixture-sanitization.js";
|
|
13
13
|
import { loadProviderLocaleCatalogs, localizeAuthTurn, } from "../i18n/catalog.js";
|
|
14
14
|
import { categoryForStatus, sourceForCategory, isRetryableCategory, PROVIDER_OBSERVABILITY_TAXONOMY_VERSION, } from "../observability.js";
|
|
15
15
|
import { createScratchpad } from "../runtime/auth-flow.js";
|
|
@@ -979,47 +979,8 @@ function extractRequestId(raw) {
|
|
|
979
979
|
}
|
|
980
980
|
const MAX_PROVIDER_ERROR_CAUSE_FRAMES = 5;
|
|
981
981
|
const MAX_PROVIDER_ERROR_CAUSE_MESSAGE_LENGTH = 300;
|
|
982
|
-
const UNSTRUCTURED_PROVIDER_ERROR_CAUSE_MESSAGE = "[UNSTRUCTURED_UPSTREAM_TEXT]";
|
|
983
|
-
const PROVIDER_ERROR_CAUSE_RETAINED_URL_RUN = /https?:\/\/[^\s"'<>]+/giu;
|
|
984
|
-
const PROVIDER_ERROR_CAUSE_TOKEN_RUN = /\S+/gu;
|
|
985
|
-
const PROVIDER_ERROR_CAUSE_TOKEN_EDGE_PUNCTUATION = /^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu;
|
|
986
|
-
const STRUCTURALLY_SAFE_PROVIDER_ERROR_CAUSE_WORDS = new Set([
|
|
987
|
-
"completion",
|
|
988
|
-
"diagnostic",
|
|
989
|
-
"provider",
|
|
990
|
-
"rejected",
|
|
991
|
-
"returned",
|
|
992
|
-
"upstream",
|
|
993
|
-
]);
|
|
994
|
-
/**
|
|
995
|
-
* Cause frames fail closed when sanitization leaves a plausible credential-shaped free-text run.
|
|
996
|
-
* Redaction sentinels and retained URLs are ignored. Every other whitespace token (or each side
|
|
997
|
-
* of a structured key=value token) with at least eight Unicode characters must reduce to this
|
|
998
|
-
* small vocabulary drawn from SDK diagnostics; counting punctuation keeps bare passwords opaque.
|
|
999
|
-
*/
|
|
1000
|
-
function isStructurallySafeProviderErrorCauseMessage(message) {
|
|
1001
|
-
const classifiableMessage = message
|
|
1002
|
-
.replaceAll(REDACTED_FIXTURE_VALUE, " ")
|
|
1003
|
-
.replace(PROVIDER_ERROR_CAUSE_RETAINED_URL_RUN, " ");
|
|
1004
|
-
for (const match of classifiableMessage.matchAll(PROVIDER_ERROR_CAUSE_TOKEN_RUN)) {
|
|
1005
|
-
const token = match[0];
|
|
1006
|
-
for (const run of token.split("=")) {
|
|
1007
|
-
const diagnosticWord = run
|
|
1008
|
-
.replace(PROVIDER_ERROR_CAUSE_TOKEN_EDGE_PUNCTUATION, "")
|
|
1009
|
-
.toLowerCase();
|
|
1010
|
-
if (STRUCTURALLY_SAFE_PROVIDER_ERROR_CAUSE_WORDS.has(diagnosticWord))
|
|
1011
|
-
continue;
|
|
1012
|
-
if ([...run].length >= 8)
|
|
1013
|
-
return false;
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
return true;
|
|
1017
|
-
}
|
|
1018
982
|
function providerErrorCauseMessage(message) {
|
|
1019
983
|
const sanitized = sanitizeDiagnosticText(message);
|
|
1020
|
-
if (!isStructurallySafeProviderErrorCauseMessage(sanitized)) {
|
|
1021
|
-
return UNSTRUCTURED_PROVIDER_ERROR_CAUSE_MESSAGE;
|
|
1022
|
-
}
|
|
1023
984
|
return sanitized.length > MAX_PROVIDER_ERROR_CAUSE_MESSAGE_LENGTH
|
|
1024
985
|
? `${sanitized.slice(0, MAX_PROVIDER_ERROR_CAUSE_MESSAGE_LENGTH)}… [truncated]`
|
|
1025
986
|
: sanitized;
|
package/package.json
CHANGED
|
@@ -23,10 +23,7 @@ import {
|
|
|
23
23
|
type ProviderErrorObservability,
|
|
24
24
|
type ProviderErrorOptions,
|
|
25
25
|
} from "../errors.js";
|
|
26
|
-
import {
|
|
27
|
-
REDACTED_FIXTURE_VALUE,
|
|
28
|
-
sanitizeDiagnosticText,
|
|
29
|
-
} from "../fixture-sanitization.js";
|
|
26
|
+
import { sanitizeDiagnosticText } from "../fixture-sanitization.js";
|
|
30
27
|
import {
|
|
31
28
|
loadProviderLocaleCatalogs,
|
|
32
29
|
localizeAuthTurn,
|
|
@@ -1526,48 +1523,9 @@ export type ProviderErrorCauseFrame = {
|
|
|
1526
1523
|
|
|
1527
1524
|
const MAX_PROVIDER_ERROR_CAUSE_FRAMES = 5;
|
|
1528
1525
|
const MAX_PROVIDER_ERROR_CAUSE_MESSAGE_LENGTH = 300;
|
|
1529
|
-
const UNSTRUCTURED_PROVIDER_ERROR_CAUSE_MESSAGE = "[UNSTRUCTURED_UPSTREAM_TEXT]";
|
|
1530
|
-
const PROVIDER_ERROR_CAUSE_RETAINED_URL_RUN = /https?:\/\/[^\s"'<>]+/giu;
|
|
1531
|
-
const PROVIDER_ERROR_CAUSE_TOKEN_RUN = /\S+/gu;
|
|
1532
|
-
const PROVIDER_ERROR_CAUSE_TOKEN_EDGE_PUNCTUATION =
|
|
1533
|
-
/^[^\p{L}\p{N}]+|[^\p{L}\p{N}]+$/gu;
|
|
1534
|
-
const STRUCTURALLY_SAFE_PROVIDER_ERROR_CAUSE_WORDS = new Set([
|
|
1535
|
-
"completion",
|
|
1536
|
-
"diagnostic",
|
|
1537
|
-
"provider",
|
|
1538
|
-
"rejected",
|
|
1539
|
-
"returned",
|
|
1540
|
-
"upstream",
|
|
1541
|
-
]);
|
|
1542
|
-
|
|
1543
|
-
/**
|
|
1544
|
-
* Cause frames fail closed when sanitization leaves a plausible credential-shaped free-text run.
|
|
1545
|
-
* Redaction sentinels and retained URLs are ignored. Every other whitespace token (or each side
|
|
1546
|
-
* of a structured key=value token) with at least eight Unicode characters must reduce to this
|
|
1547
|
-
* small vocabulary drawn from SDK diagnostics; counting punctuation keeps bare passwords opaque.
|
|
1548
|
-
*/
|
|
1549
|
-
function isStructurallySafeProviderErrorCauseMessage(message: string): boolean {
|
|
1550
|
-
const classifiableMessage = message
|
|
1551
|
-
.replaceAll(REDACTED_FIXTURE_VALUE, " ")
|
|
1552
|
-
.replace(PROVIDER_ERROR_CAUSE_RETAINED_URL_RUN, " ");
|
|
1553
|
-
for (const match of classifiableMessage.matchAll(PROVIDER_ERROR_CAUSE_TOKEN_RUN)) {
|
|
1554
|
-
const token = match[0];
|
|
1555
|
-
for (const run of token.split("=")) {
|
|
1556
|
-
const diagnosticWord = run
|
|
1557
|
-
.replace(PROVIDER_ERROR_CAUSE_TOKEN_EDGE_PUNCTUATION, "")
|
|
1558
|
-
.toLowerCase();
|
|
1559
|
-
if (STRUCTURALLY_SAFE_PROVIDER_ERROR_CAUSE_WORDS.has(diagnosticWord)) continue;
|
|
1560
|
-
if ([...run].length >= 8) return false;
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
return true;
|
|
1564
|
-
}
|
|
1565
1526
|
|
|
1566
1527
|
function providerErrorCauseMessage(message: string): string {
|
|
1567
1528
|
const sanitized = sanitizeDiagnosticText(message);
|
|
1568
|
-
if (!isStructurallySafeProviderErrorCauseMessage(sanitized)) {
|
|
1569
|
-
return UNSTRUCTURED_PROVIDER_ERROR_CAUSE_MESSAGE;
|
|
1570
|
-
}
|
|
1571
1529
|
return sanitized.length > MAX_PROVIDER_ERROR_CAUSE_MESSAGE_LENGTH
|
|
1572
1530
|
? `${sanitized.slice(0, MAX_PROVIDER_ERROR_CAUSE_MESSAGE_LENGTH)}… [truncated]`
|
|
1573
1531
|
: sanitized;
|