Files
simapi-cj/src/interfaces/SimApiSignProviderBase.cj
T

47 lines
1.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* Copyright (c) 2025 SimcuTeam. All rights reserved.
* 移植自 C# 项目 SimApiE:\simcu\simapi-net),遵循 MIT 许可证。
* 签名提供器基类(对齐 C# ModelBinders/SimApiSignProviderBase)。
*
* 说明:本类含配置字段(appIdName/queryExpires 等),故用 open class 而非 interface
* (Cangjie 接口不能声明字段),与 .NET 抽象类对应。应用继承本类并实现 getKey。
*/
package simcu::simapi.interfaces
/**
* 签名提供器基类:应用继承并实现 getKey(appId),返回 appId 对应的密钥。
*/
public open class SimApiSignProviderBase {
/// appId 字段名(None 表示签名中不包含 appId)
public var appIdName: ?String = Some("appId")
/// 时间戳字段名
public var timestampName: String = "timestamp"
/// 随机串字段名
public var nonceName: String = "nonce"
/// 签名字段名
public var signName: String = "sign"
/// 请求过期秒数(0 表示不校验 timestamp
public var queryExpires: Int64 = 5
/// 是否开启 nonce 去重(需配置缓存)
public var duplicateRequestProtection: Bool = true
/// 参与签名的额外字段(与 appId/timestamp/nonce 一起拼入签名字符串)
public var signFields: Array<String> = []
/**
* 根据 appId 获取密钥。
* @param appId 应用 ID(未配置 appIdName 时为 None)。
* @return 密钥;返回 None 表示获取失败。
*/
public open func getKey(appId: ?String): ?String {
None
}
}