deduplicate task parsing and masking helpers

This commit is contained in:
yml
2026-05-21 18:50:07 +08:00
parent efa41ba976
commit 17a615b8de
9 changed files with 151 additions and 491 deletions
@@ -1,4 +1,8 @@
import { resolveCloudtentaclesConfig } from "../../platforms/cloudtentacles/shared.js";
import {
maskCode as maskCodeValue,
maskPhone as maskPhoneValue,
} from "../../../utils/masking.js";
export const KUAISHOU_CLOUD_FIXED_VN_KEY = "1";
@@ -154,29 +158,11 @@ export function normalizeKuaishouCloudRoleInfo(value) {
}
export function maskPhone(value) {
const text = String(value || "").trim();
if (!text) {
return "";
}
if (text.length <= 7) {
return `${text.slice(0, 2)}***${text.slice(-2)}`;
}
return `${text.slice(0, 3)}****${text.slice(-4)}`;
return maskPhoneValue(value);
}
export function maskCode(value) {
const text = String(value || "").trim();
if (!text) {
return "";
}
if (text.length <= 8) {
return `${text.slice(0, 2)}***${text.slice(-2)}`;
}
return `${text.slice(0, 4)}****${text.slice(-4)}`;
return maskCodeValue(value);
}
export function resolveKuaishouCloudBindUrlExpiresAt(preparedAt) {
@@ -1,3 +1,5 @@
import { parseTaskContext as parseTaskContextValue } from "../../../utils/task-json.js";
export function normalizeActor(actor) {
if (!actor || typeof actor !== "object") {
return null;
@@ -21,21 +23,7 @@ export function normalizeActor(actor) {
}
export function parseTaskContext(task) {
const value = task?.context_json;
if (!value) {
return {};
}
if (typeof value === "object") {
return value;
}
try {
return JSON.parse(String(value || "{}"));
} catch {
return {};
}
return parseTaskContextValue(task);
}
export function getTaskClaimExpiresAt(task) {