Files
simapi-cj/src/annotations/simapi_sign.cj
T

35 lines
1.3 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.
* 遵循 MIT 许可证。
* 声明式签名校验注解。
*
* 标注在控制器方法或类上,请求派发时(SimApiRequestDelegateFactory)自动执行验签:
* - 提取 appId / timestamp / nonce / signQuery 优先,其次 Header
* - 通过 keyProviderDI 解析)获取密钥
* - 过期校验 + nonce 去重(需缓存)
* - 拼接 SignFields + appId + timestamp + nonce + keyMD5 比对
*
* 用法:
* @SimApiSign // 默认 SimApiSignProviderBase(应用需注册实现)
* @SimApiSign["MySignProvider"] // 指定 provider 类型名(DI 注册的实现类)
*
* 说明:仓颉注解参数须为编译期常量,无法直接持有 Type;
* 故 keyProvider 用类型名 String,运行时经 TypeInfo.get 解析后从 DI 取实例。
*/
package simcu::simapi.annotations
@Annotation[target: [MemberFunction, Type]]
public class SimApiSign {
/// 签名提供器类型名(DI 注册的 SimApiSignProviderBase 实现类名)
public let keyProvider: String
public const init() {
this.keyProvider = ""
}
public const init(keyProvider: String) {
this.keyProvider = keyProvider
}
}