设置云触手默认登录设备
This commit is contained in:
@@ -43,6 +43,10 @@ export function resolveKuaishouEticketAdminContext(payload: JsonObject = {}, opt
|
||||
|
||||
import { getCloudtentaclesSourceByKey } from "../../../platforms/cloudtentacles/source-config-service.js";
|
||||
import { getCloudtentaclesSessionStateByKey } from "../../../platforms/cloudtentacles/session-state-service.js";
|
||||
import {
|
||||
normalizeCloudtentaclesDeviceId,
|
||||
normalizeCloudtentaclesDeviceType,
|
||||
} from "../../../platforms/cloudtentacles/defaults.js";
|
||||
|
||||
export function resolveCloudtentaclesAdminContext(payload: JsonObject = {}, options: JsonObject = {}) {
|
||||
const sourceKey = String(
|
||||
@@ -63,16 +67,16 @@ export function resolveCloudtentaclesAdminContext(payload: JsonObject = {}, opti
|
||||
defaultBaseUrl,
|
||||
]),
|
||||
token: pickFirstNonEmpty([payload.token, persistedSession.token]),
|
||||
deviceId: pickFirstNonEmpty([
|
||||
payload.deviceId,
|
||||
savedSource.deviceId,
|
||||
persistedSession.deviceId,
|
||||
"-",
|
||||
]),
|
||||
deviceType:
|
||||
payload.deviceType ??
|
||||
savedSource.deviceType ??
|
||||
persistedSession.deviceType,
|
||||
deviceId: normalizeCloudtentaclesDeviceId(
|
||||
pickFirstNonEmpty([
|
||||
payload.deviceId,
|
||||
savedSource.deviceId,
|
||||
persistedSession.deviceId,
|
||||
])
|
||||
),
|
||||
deviceType: normalizeCloudtentaclesDeviceType(
|
||||
payload.deviceType ?? savedSource.deviceType ?? persistedSession.deviceType
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@ import {
|
||||
maskPhone as maskPhoneValue,
|
||||
maskSecret as maskSecretValue,
|
||||
} from "../../../../utils/masking.js";
|
||||
import {
|
||||
normalizeCloudtentaclesDeviceId,
|
||||
normalizeCloudtentaclesDeviceType,
|
||||
} from "../../../platforms/cloudtentacles/defaults.js";
|
||||
|
||||
type JsonObject = Record<string, any>
|
||||
|
||||
@@ -42,8 +46,8 @@ export function mapAdminCloudtentaclesSourceConfig(config: JsonObject = {}) {
|
||||
username: String(config.username || "").trim(),
|
||||
password: String(config.password || "").trim(),
|
||||
phone: String(config.phone || "").trim(),
|
||||
deviceId: String(config.deviceId || "-").trim() || "-",
|
||||
deviceType: Number(config.deviceType || 0),
|
||||
deviceId: normalizeCloudtentaclesDeviceId(config.deviceId),
|
||||
deviceType: normalizeCloudtentaclesDeviceType(config.deviceType),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -55,8 +59,8 @@ export function mapAdminCloudtentaclesSession(session: JsonObject = {}) {
|
||||
username: String(session.username || "").trim(),
|
||||
phoneMasked: maskPhone(session.phone),
|
||||
loggedInAt: String(session.loggedInAt || "").trim(),
|
||||
deviceId: String(session.deviceId || "-").trim() || "-",
|
||||
deviceType: Number(session.deviceType || 0),
|
||||
deviceId: normalizeCloudtentaclesDeviceId(session.deviceId),
|
||||
deviceType: normalizeCloudtentaclesDeviceType(session.deviceType),
|
||||
hasToken: Boolean(String(session.token || "").trim()),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { getCloudtentaclesSourceByKey } from "../../../platforms/cloudtentacles/source-config-service.js";
|
||||
import { getCloudtentaclesSessionStateByKey } from "../../../platforms/cloudtentacles/session-state-service.js";
|
||||
import {
|
||||
normalizeCloudtentaclesDeviceId,
|
||||
normalizeCloudtentaclesDeviceType,
|
||||
} from "../../../platforms/cloudtentacles/defaults.js";
|
||||
import {
|
||||
pickFirstNonEmpty,
|
||||
resolveCloudtentaclesAdminContext,
|
||||
@@ -34,8 +38,12 @@ export function resolveAdminCloudtentaclesCredentialPayload(
|
||||
username: pickFirstNonEmpty([payload.username, savedSource.username]),
|
||||
password: pickFirstNonEmpty([payload.password, savedSource.password]),
|
||||
phone: pickFirstNonEmpty([payload.phone, savedSource.phone]),
|
||||
deviceId: pickFirstNonEmpty([payload.deviceId, savedSource.deviceId, "-"]),
|
||||
deviceType: payload.deviceType ?? savedSource.deviceType,
|
||||
deviceId: normalizeCloudtentaclesDeviceId(
|
||||
pickFirstNonEmpty([payload.deviceId, savedSource.deviceId])
|
||||
),
|
||||
deviceType: normalizeCloudtentaclesDeviceType(
|
||||
payload.deviceType ?? savedSource.deviceType
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -67,8 +75,12 @@ export function buildAdminCloudtentaclesPersistedSessionPayload(
|
||||
username: pickFirstNonEmpty([options.username, session.username]),
|
||||
phone: pickFirstNonEmpty([options.phone, session.phone]),
|
||||
loggedInAt: String(session.loggedInAt || "").trim(),
|
||||
deviceId: pickFirstNonEmpty([options.deviceId, session.deviceId, "-"]),
|
||||
deviceType: options.deviceType ?? session.deviceType,
|
||||
deviceId: normalizeCloudtentaclesDeviceId(
|
||||
pickFirstNonEmpty([options.deviceId, session.deviceId])
|
||||
),
|
||||
deviceType: normalizeCloudtentaclesDeviceType(
|
||||
options.deviceType ?? session.deviceType
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
import {
|
||||
normalizeCloudtentaclesDeviceId,
|
||||
normalizeCloudtentaclesDeviceType,
|
||||
} from "../../../platforms/cloudtentacles/defaults.js";
|
||||
|
||||
type JsonObject = Record<string, any>;
|
||||
|
||||
export function normalizeAdminCloudtentaclesSourceConfigPayload(
|
||||
@@ -13,7 +18,7 @@ export function normalizeAdminCloudtentaclesSourceConfigPayload(
|
||||
username: String(payload.username || "").trim(),
|
||||
password: String(payload.password || "").trim(),
|
||||
phone: String(payload.phone || "").trim(),
|
||||
deviceId: String(payload.deviceId || "-").trim() || "-",
|
||||
deviceType: Number(payload.deviceType || 0),
|
||||
deviceId: normalizeCloudtentaclesDeviceId(payload.deviceId),
|
||||
deviceType: normalizeCloudtentaclesDeviceType(payload.deviceType),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user