/**
* `qianapp://` 协议解析结果。
*
* **协议形态**: `qianapp://<custom-path>?flowId=...&action=...&result=...&from=tencent_ess&<extras>`
*
* **字段说明**:
* - rawUrl: 原始 URL
* - customPath: host + path 拼接(去除前后斜杠)
* - flowId: 流程 ID(协议未给则为空字符串)
* - action: 动作字符串原值;建议与 `SignAction` 常量比对,未知值原样透出
* - result: 结果字符串原值;建议与 `SignResultStatus` 常量比对,未知值原样透出
* - from: 固定 `tencent_ess`
* - extras: 除上述字段之外的自定义 query 透传
*/
export class SignResult {
/** 原始 qianapp:// URL */
public rawUrl: string;
/** host + path,例 `callback/sign` */
public customPath: string;
/** 流程 ID;协议未给则为空字符串 */
public flowId: string;
/**
* 动作类型(String 直透,未识别值原样透出)。
*
* 已知值见 SignAction:`fill` / `sign` / `reject_fill` / `reject_sign` / `view` / `""`。
*/
public action: string;
/**
* 结果状态(String 直透,未识别值原样透出)。
*
* 已知值见 SignResultStatus:`success` / `fail` / `""`。
*/
public result: string;
/** 来源标识,通常为 `tencent_ess`;协议未给则为空字符串 */
public from: string;
/**
* 客户自定义 query 透传(已剔除 4 个 recognized field)。
*
* 重复 key 保留首个,UTF-8 percent-decoded。
*/
public extras: Map<string, string>;
constructor(
rawUrl: string,
customPath: string,
flowId: string,
action: string,
result: string,
from: string,
extras: Map<string, string>
) {
this.rawUrl = rawUrl;
this.customPath = customPath;
this.flowId = flowId;
this.action = action;
this.result = result;
this.from = from;
this.extras = extras;
}
/**
* 全空 SignResult,用于解析失败兜底。
*
* 通过 `rawUrl.length === 0` 判定空结果,勿用 `===` 引用比较。
*/
public static get EMPTY(): SignResult {
return new SignResult('', '', '', '', '', '', new Map<string, string>());
}
}
|