feat(sdk): 加密缓存、GracePolicy、时钟校正与剩余规划 API
- 加密租约缓存(AES-256-GCM + HKDF(指纹)):重启恢复 GRACE,401/410 自动重新激活 - WithGracePolicy(KeepBooleans)、WithLicenseBytes、WithHeartbeatInterval、WithHTTPClient、WithAutoActivate、WithOnEntitlementsChange、Deactivate - 心跳/激活 server_time 参与可信时间校正 - 新增缓存/降级/时钟/重激活/回调测试
This commit is contained in:
6 files changed
+760
-17
No files matched your search
+13
-2
@@ -27,9 +27,20 @@ func (c *Client) usable() bool {
|
||||
}
|
||||
|
||||
// Enabled 布尔开关查询;未授权或状态不可用一律 false(docs/design/05-entitlement-model.md §4 规则 1)。
|
||||
// WithGracePolicy(GraceKeepBooleans) 时,EXPIRED 后仍放行 payload 中为 true 的布尔 Feature。
|
||||
func (c *Client) Enabled(fid string) bool {
|
||||
ok, _ := c.Check(fid)
|
||||
return ok
|
||||
if ok, _ := c.Check(fid); ok {
|
||||
return true
|
||||
}
|
||||
if c.opts.gracePolicy != GraceKeepBooleans || c.State() != StateExpired {
|
||||
return false
|
||||
}
|
||||
s := c.snap.Load()
|
||||
if s == nil || s.payload == nil {
|
||||
return false
|
||||
}
|
||||
ent, ok := s.payload.Ent[fid]
|
||||
return ok && ent.AsBool()
|
||||
}
|
||||
|
||||
// Quantity 数量配额查询;未授权返回 0。
|
||||
|
||||
Reference in new issue
Block a user