refactor: SimApiSignProviderBase / AesBodyProviderBase 移至 interfaces 子包
- 新增 src/interfaces/SimApiSignProviderBase.cj / AesBodyProviderBase.cj(package simapi.interfaces) - SimApiSignChecker / SimApiAesBodyChecker 移除基类定义,import simapi.interfaces.* - SimApiRequestDelegateFactory 已 import interfaces,无需改 - 说明:基类含配置字段故用 open class(Cangjie 接口不能声明字段)
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2025 SimcuTeam. All rights reserved.
|
||||
* 移植自 C# 项目 SimApi(E:\simcu\simapi-net),遵循 MIT 许可证。
|
||||
* 签名提供器基类(对齐 C# ModelBinders/SimApiSignProviderBase)。
|
||||
*
|
||||
* 说明:本类含配置字段(appIdName/queryExpires 等),故用 open class 而非 interface
|
||||
* (Cangjie 接口不能声明字段),与 .NET 抽象类对应。应用继承本类并实现 getKey。
|
||||
*/
|
||||
|
||||
package 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> = []
|
||||
|
||||
public init() {}
|
||||
|
||||
/**
|
||||
* 根据 appId 获取密钥。
|
||||
* @param appId 应用 ID(未配置 appIdName 时为 None)。
|
||||
* @return 密钥;返回 None 表示获取失败。
|
||||
*/
|
||||
public open func getKey(appId: ?String): ?String {
|
||||
None
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user